Guten Tag,
Ich kriege es in der Klasse class.tx_msfootermenu_pi1.php
nicht hin, dass ein Link aus der 2. Ebene angezeigt wird welcher nur Children (Subpages) hat die nicht im Menü angezeigt werden.
Außerdem würde ich gerne den aktivem Link eine die Parent cssklasse zuweisen, so dass dieser Fett wird. Dies habe ich mit einem Vergleich mit php_self bis jetzt nicht hinbekommen
Hat das vllt. schon jmd getan?Oder kann mir Tipps geben?
MfG,
Pawhi
Finde leider keine Spoilerfunktion:
?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Manfred Mueller-Spaeth <fms1961@gmail.com>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
require_once(PATH_tslib.'class.tslib_pibase.php');
/**
* Plugin 'Footer menu (overview)' for the 'ms_footermenu' extension.
*
* @author Manfred Mueller-Spaeth <fms1961@gmail.com>
* @package TYPO3
* @subpackage tx_msfootermenu
*/
class tx_msfootermenu_pi1 extends tslib_pibase {
var $prefixId = 'tx_msfootermenu_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_msfootermenu_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'ms_footermenu'; // The extension key.
var $sysPage;
var $menuTree;
var $menuCols;
var $menuFilter;
var $menuLevels;
var $debug;
/**
* The main method of the PlugIn
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
* @return The content that is displayed on the website
*/
function main($content,$conf) {
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$this->pi_USER_INT_obj = 1;
$this->debug = 0;
$content = '';
$content .= $this->initSettings($content);
$content .= $this->renderFooterMenu($content);
return $this->pi_wrapInBaseClass($content);
}
/**
* function initSettings($content)
*
* @param string $content: The PlugIn content
* @return The content that is perhaps changed (for debugging purposes)
*/
function initSettings($content) {
// for debugging purposes
$content .= $this->debug ? 'Debug: content of $this->conf: <br />'.t3lib_div::view_array($this->conf) : '';
// get standard configuration values
$this->conf['pidList'] = $this->cObj->data['pages'];
$this->conf['recursive'] = $this->cObj->data['recursive'];
// set filter and blacklists
$this->menuFilterPre = explode(',', $this->conf['filterPre']);
$this->menuFilterPost = explode(',', $this->conf['filterPost']);
$this->menuBlackList = explode(',', $this->conf['dontrender']);
$this->menuWhiteList = explode(',', $this->conf['alwaysrender']);
// we need this for page access ...
$this->sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
// let's check the startpoint (only the first pid in pidList is used)
$root = intval($this->conf['start_pid']);
if (($root <= 0) && (strlen($this->conf['pidList']) > 0)) {
$pidList = explode(',', $this->conf['pidList']);
if (is_array($pidList)) {
list($root) = $pidList;
}
}
$root = (is_numeric($root) && $root) ? $root : $GLOBALS['TSFE']->tmpl->rootId;
// get the page tree
$this->menuTree = $this->getPages(intval($root), array(), 0);
// flatten the page tree
$this->getColumns();
// finish the page tree (eliminate unwanted items etc.)
$this->menuCols = $this->finishColumns();
return $content;
}
/**
* The renderFooterMenu method of the PlugIn
*
* @param string $content: The PlugIn content
* @return The content with the footer menu appended
*/
function renderFooterMenu ($content) {
// we need a template file
$tmplFile = $this->cObj->fileResource($this->conf['templateFile']);
// now we step through the flattened tree and collect the data
// which will be inserted in the template
$linkGroups = '';
foreach ($this->menuCols as $key => $value) {
$linkList = '';
foreach ($value as $sort => $page) {
$linkClass = $this->conf['classLink'];
// parent links have an additional class
if ($this->isParent($page)) {
$linkClass .= ' '.$this->conf['classParent'];
}
// collect the data in the marker array
// note: as there are sometimes quotes in titles or subtitles,
// these strings are escaped
// link, title and subtitle are from the database, the other parameters
// are configuration values (setup in TS)
$mrkLink = array (
'###MS_FOOTER_LNKCLS###' => $linkClass,
'###MS_FOOTER_AHREF###' => $this->pi_getPageLink($page['uid']),
'###MS_FOOTER_TARGET###' => $this->conf['footertarget'],
'###MS_FOOTER_TITLE###' => htmlentities($page['subtitle'] ? $page['subtitle']:$page['title'], ENT_QUOTES, $GLOBALS['TSFE']->renderCharset),
'###MS_FOOTER_TEXT###' => htmlentities($page['title'], ENT_QUOTES,$GLOBALS['TSFE']->renderCharset)
);
// generate the output text
$tmplLink = $this->cObj->getSubpart($tmplFile, '###MS_FOOTER_LINK###');
$linkList .= $this->cObj->substituteMarkerArray($tmplLink, $mrkLink);
}
// insert the collected links in the group template
$mrkGroup = array (
'###MS_FOOTER_GRPCLS###' => $this->conf['classGroup'],
'###MS_FOOTER_ALL-LINKS###' => $linkList
);
$tmplGroup = $this->cObj->getSubpart($tmplFile, '###MS_FOOTER_GROUP###');
$linkGroups .= $this->cObj->substituteMarkerArray($tmplGroup, $mrkGroup);
};
// insert the collected groups in the footer template
$mrkContent = array (
'###MS_FOOTER_CONTCLS###' => $this->conf['classContent'],
'###MS_FOOTER_CONTENT###' => $linkGroups
);
$tmplMain = $this->cObj->getSubpart($tmplFile, '###MS_FOOTER_MAIN###');
$content .= $this->cObj->substituteMarkerArrayCached($tmplMain, $mrkContent);
return $content;
}
/**
* The isParent method of the PlugIn
*
* @param array $page: The current page
* @return true if the page is a parent page, false if not
*/
function isParent($page) {
if ($page['isParent'] && $page['isParent'] != '0') {
return true;
}
return false;
}
/**
* function hasChildren($page)
*
* @param array $page: The current page
* @return true if the page has children, false if not
*/
function hasChildren($page) {
return (count($page['children']) > 0);
}
/**
* function isAccepted($page, $filter)
*
* This function checks the given doktype-filter and some
* other attributes against the current page: hidden, nav_hide
* and the blackList (if existing). Might be overwrtten by an
* entry in the whiteList ("isForced")
*
* @param array $page: The current page
* @param array $filter: The used doktype-filter
* @return true if the page is accepted, false if not
*/
function isAccepted($page, $filter) {
$accepted = in_array($page['doktype'], $filter) &&
!in_array($page['uid'], $this->menuBlackList) &&
!intval($page['hidden']) &&
!intval($page['nav_hide']);
$accepted = $accepted || $this->isForced($page);
return $accepted;
}
/**
* function isForced($page)
*
* This function checks whether the given page is in the
* whiteList defined in the $conf-array
*
* @param array $page: The current page
* @param array $filter: The used doktype-filter
* @return true if the page is forced to use, false if not
*/
function isForced($page) {
$forced = in_array($page['uid'], $this->menuWhiteList);
return $forced;
}
/**
* function getColumns ($pageTree = null, $packet = '0000')
*
* This function traverses recursive the pageTree and flattens the
* items: all found levels are put in one row. Doktype filters,
* blackList and whiteList are used.
*
* @param array $pageTree: The current pageTree
* @param string $packet: the packet Nr. (for sorting purposes, starts with zero)
* @return always true, false if error occurs (not yet implemented))
*/
function getColumns ($pageTree = null, $packet = '0000') {
// if the pageTree ist not set, we start with the collected
// menuTree (for recusrion purposes implemented in this way)
if (!isset($pageTree)) {
$this->menuCols = array();
$pageTree = $this->menuTree;
}
// stepping thropugh the pages on one level (same pid) ...
foreach ($pageTree as $idx => $page) {
// no action if the filter denies the use of this page
if (!$this->isAccepted($page, $this->menuFilterPre)) {
continue;
}
// if the page has children, the method is called recursive
if ($this->hasChildren($page)) {
// the sorting value of the page will be added to the current on
// in normalized leght, so the sorting will be the same
// in the flattened array
$sortID = sprintf("%04d", intval($page['sorting']));
$this->getColumns($page['children'], $packet.$sortID);
}
// now check the second filter (post fitler), if the page will
// be accepted or abandoned. This filter has to be *after* the recursion,
// because some pages with children will be denie, but their
// children will be accepted
if ($this->isAccepted($page, $this->menuFilterPost)) {
// insert page in the column array
$this->menuCols[$packet][$idx] = $page;
// cut the children array off, replace it with an attribute "hasChildren"
$this->menuCols[$packet][$idx]['children'] = intval($this->hasChildren($page));
}
}
return true;
}
/**
* function finishColumns
*
* This function finishes the flattened list (will be the columns of the footer menu)
*
* @return $colOut the new, finished and usebale array with the pages
* sorted in several packets (columns)
*/
function finishColumns () {
// first find the maximum length of the sorting index
$maxIDX = 0;
foreach ($this->menuCols as $idx => $page) {
$maxIDX = max($maxIDX, strlen($idx));
}
// now colelct the resutling packets
$colOut = array();
foreach ($this->menuCols as $index => $pageArr) {
foreach ($pageArr as $sorting => $page) {
// pages with children are cut out in this place,
// but not, if they are found in the whiteList ("isForced")
if ((intval($page['children']) == 1) && !$this->isForced($page)) {
unset($pageArr[$sorting]);
}
}
// now generate the new sorting index with normalized length
$newIDX = str_pad($index, $maxIDX, "0");
// add the page to the resulting array, if not empty
if (!empty($pageArr)) $colOut[$newIDX] = $pageArr;
}
// sort the result by the keys (sorting index))
ksort($colOut);
// for each packet of pages the parent page is retrieved and added on top
// this page is marked with "isParent" and might be rendered differently later
foreach ($colOut as $idx => $pages) {
$probe = reset($pages);
$pid = $probe['pid'];
$parent = $this->findMenuPage($pid, $this->menuTree);
$parent['isParent'] = 1;
$parent['uid'] = $pid;
$parent['children'] = 1;
array_unshift($colOut[$idx], $parent);
}
// returns the resulting array
return $colOut;
}
/**
* function getPages ($uid, $pageTree, $level = 0)
*
* This function collects the page tree of TYPO3 with all the pages, the current
* user may see. It starts with a root element (given by a $conf entry) and walks
* recursively through the pages, creating a multidimensional array with the
* page tree structure in it, which will be the base for the other operations.
* Nothing will be filtered at this place.
*
* @param string $uid: the id of the examined page
* @param array $pageTree: The current pageTree (where to add ne items)
* @param integer $level: The level of the recursion. Starts per default with 0
* @return $pageTree: the array with new created items in the current level
*
*/
function getPages ($uid, $pageTree, $level = 0) {
// Philip Almeida: Multilanguage suport did not work until this line was added
// Maybe server configuration error... -> Tested not likely.
// Either way this is a quick and not deep documented approach
$this->sysPage->sys_language_uid = (int)$GLOBALS['TSFE']->sys_language_content;
// get the page data from the TYPO3 pages
$row = $this->sysPage->getPage($uid);
// if not found: return the unchanged tree - the traversing
// of the structure will *not* be interrupted
if (!$row) {
return $pageTree;
}
// collect the data needed in the array. As key we use the "sorting" value of the page
$idx = $row['sorting'];
$pageTree[$idx]['uid'] = $uid;
$pageTree[$idx]['pid'] = $row['pid'];
$pageTree[$idx]['sorting'] = $row['sorting'];
$pageTree[$idx]['title'] = $row['title'];
$pageTree[$idx]['subtitle'] = $row['subtitle'];
$pageTree[$idx]['alias'] = $row['alias'];
$pageTree[$idx]['doktype'] = $row['doktype'];
$pageTree[$idx]['hidden'] = $row['hidden'];
$pageTree[$idx]['level'] = $level;
$pageTree[$idx]['is_siteroot'] = $row['is_siteroot'];
$pageTree[$idx]['nav_title'] = $row['nav_title'];
$pageTree[$idx]['nav_hide'] = $row['nav_hide'];
$pageTree[$idx]['accepted'] = intval($this->isAccepted($pageTree[$idx], $this->menuFilterPost));
// now get the children of the page (if any))
$pidList = $this->cObj->getTreeList($uid, 1);
if ($pidList != '') {
// create an array with the cildrens uids
$pageTree[$idx]['children'] = array();
$pages = explode(',', rtrim($pidList, ','));
// for each page go to the recursion of the method, increment the level and
// add the result with the key "children" to the current created page
foreach ($pages as $num => $uid) {
$pageTree[$idx]['children'] = $this->getPages(intval($uid), $pageTree[$idx]['children'], $level + 1);
}
}
// sort the page (sorting value)
ksort($pageTree);
return $pageTree;
}
/**
* function findMenuPage ($uid, $pageTree)
*
* This function searches a page with the id $uid recursively in the given pageTree array
* and returns the found page.
*
* @param string $uid: the id of the examined page
* @param array $pageTree: The current pageTree (where to add ne items)
* @return $page: the array with the found page (or unset if not found)
*
*/
function findMenuPage ($uid, $pageTree) {
// the result has to be defined as unsetz first
unset($found);
// no array? we quit ...
if (is_array($pageTree)) {
foreach ($pageTree as $idx => $page) {
// compare the uid of the page with the searched one, if they are the same,
// the page will be stored in found, if not, we try to recurse to the next level
$found = ($page['uid'] == $uid) ? $page : $this->findMenuPage($uid, $page['children']);
// if something has been found, we return here, else we continue
if (isset($found)) {
return $found;
}
}
}
return $found;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ms_footermenu/pi1/class.tx_msfootermenu_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ms_footermenu/pi1/class.tx_msfootermenu_pi1.php']);
}
?>