本文整理汇总了PHP中TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentObjectRenderer::getTreeList方法的具体用法?PHP ContentObjectRenderer::getTreeList怎么用?PHP ContentObjectRenderer::getTreeList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
的用法示例。
在下文中一共展示了ContentObjectRenderer::getTreeList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTreeListReturnsChildPageUidsAndOriginalPidForNegativeValue
/**
* @test
*/
public function getTreeListReturnsChildPageUidsAndOriginalPidForNegativeValue()
{
$GLOBALS['TYPO3_DB']->expects($this->any())->method('exec_SELECTgetSingleRow')->with('treelist')->will($this->returnValue(null));
$GLOBALS['TSFE']->sys_page->expects($this->any())->method('getRawRecord')->will($this->onConsecutiveCalls(array('uid' => 17), array('uid' => 321), array('uid' => 719), array('uid' => 42)));
$GLOBALS['TSFE']->sys_page->expects($this->any())->method('getMountPointInfo')->will($this->returnValue(null));
$GLOBALS['TYPO3_DB']->expects($this->any())->method('exec_SELECTgetRows')->will($this->onConsecutiveCalls(array(array('uid' => 321)), array(array('uid' => 719)), array(array('uid' => 42))));
// 17 = pageId, 5 = recursionLevel, 0 = begin (entry to recursion, internal), TRUE = do not check enable fields
// 17 is negative, we expect 17 to be included in result
$result = $this->subject->getTreeList(-17, 5, 0, true);
$expectedResult = '42,719,321,17';
$this->assertEquals($expectedResult, $result);
}
示例2: pi_getPidList
/**
* Returns a commalist of page ids for a query (eg. 'WHERE pid IN (...)')
*
* @param string $pid_list A comma list of page ids (if empty current page is used)
* @param int $recursive An integer >=0 telling how deep to dig for pids under each entry in $pid_list
* @return string List of PID values (comma separated)
*/
public function pi_getPidList($pid_list, $recursive = 0)
{
if (!strcmp($pid_list, '')) {
$pid_list = $this->frontendController->id;
}
$recursive = MathUtility::forceIntegerInRange($recursive, 0);
$pid_list_arr = array_unique(GeneralUtility::trimExplode(',', $pid_list, TRUE));
$pid_list = array();
foreach ($pid_list_arr as $val) {
$val = MathUtility::forceIntegerInRange($val, 0);
if ($val) {
$_list = $this->cObj->getTreeList(-1 * $val, $recursive);
if ($_list) {
$pid_list[] = $_list;
}
}
}
return implode(',', $pid_list);
}
示例3: pi_getPidList
/**
* Returns a commalist of page ids for a query (eg. 'WHERE pid IN (...)')
*
* @param string $pid_list A comma list of page ids (if empty current page is used)
* @param integer$recursive An integer >=0 telling how deep to dig for pids under each entry in $pid_list
* @return string List of PID values (comma separated)
* @todo Define visibility
*/
public function pi_getPidList($pid_list, $recursive = 0)
{
if (!strcmp($pid_list, '')) {
$pid_list = $GLOBALS['TSFE']->id;
}
$recursive = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($recursive, 0);
$pid_list_arr = array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $pid_list, 1));
$pid_list = array();
foreach ($pid_list_arr as $val) {
$val = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($val, 0);
if ($val) {
$_list = $this->cObj->getTreeList(-1 * $val, $recursive);
if ($_list) {
$pid_list[] = $_list;
}
}
}
return implode(',', $pid_list);
}
示例4: makeMenu
//.........这里部分代码省略.........
$this->sys_page->versionOL('pages', $row, TRUE);
}
// Add external MP params, then the row:
if (is_array($row)) {
if ($MP) {
$row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
}
$temp[] = $this->sys_page->getPageOverlay($row);
}
}
break;
case 'updated':
if ($value == '') {
$value = $GLOBALS['TSFE']->page['uid'];
}
$items = GeneralUtility::intExplode(',', $value);
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
$depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 1, 20);
} else {
$depth = 20;
}
// Max number of items
$limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
$maxAge = (int) $this->parent_cObj->calc($this->conf['special.']['maxAge']);
if (!$limit) {
$limit = 10;
}
// *'auto', 'manual', 'tstamp'
$mode = $this->conf['special.']['mode'];
// Get id's
$id_list_arr = array();
foreach ($items as $id) {
$bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
$id_list_arr[] = $this->parent_cObj->getTreeList(-1 * $id, $depth - 1 + $bA, $bA - 1);
}
$id_list = implode(',', $id_list_arr);
// Get sortField (mode)
switch ($mode) {
case 'starttime':
$sortField = 'starttime';
break;
case 'lastUpdated':
case 'manual':
$sortField = 'lastUpdated';
break;
case 'tstamp':
$sortField = 'tstamp';
break;
case 'crdate':
$sortField = 'crdate';
break;
default:
$sortField = 'SYS_LASTCHANGED';
}
// Get
$extraWhere = ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
if ($this->conf['special.']['excludeNoSearchPages']) {
$extraWhere .= ' AND pages.no_search=0';
}
if ($maxAge > 0) {
$extraWhere .= ' AND ' . $sortField . '>' . ($GLOBALS['SIM_ACCESS_TIME'] - $maxAge);
}
$res = $this->parent_cObj->exec_getQuery('pages', array('pidInList' => '0', 'uidInList' => $id_list, 'where' => $sortField . '>=0' . $extraWhere, 'orderBy' => $altSortFieldValue ? $altSortFieldValue : $sortField . ' desc', 'max' => $limit));
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
if (is_array($row)) {
示例5: prepareMenuItemsForKeywordsMenu
/**
* Fetches all menuitems if special = keywords is set
*
* @param string $specialValue The value from special.value
* @param string $sortingField The sorting field
* @return array
*/
protected function prepareMenuItemsForKeywordsMenu($specialValue, $sortingField)
{
$tsfe = $this->getTypoScriptFrontendController();
$menuItems = array();
list($specialValue) = GeneralUtility::intExplode(',', $specialValue);
if (!$specialValue) {
$specialValue = $tsfe->page['uid'];
}
if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
$kw = isset($this->conf['special.']['setKeywords.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']) : $this->conf['special.']['setKeywords'];
} else {
// The page record of the 'value'.
$value_rec = $this->sys_page->getPage($specialValue);
$kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
// keywords.
$kw = trim($this->parent_cObj->keywords($value_rec[$kfieldSrc]));
}
// *'auto', 'manual', 'tstamp'
$mode = $this->conf['special.']['mode'];
switch ($mode) {
case 'starttime':
$sortField = 'starttime';
break;
case 'lastUpdated':
case 'manual':
$sortField = 'lastUpdated';
break;
case 'tstamp':
$sortField = 'tstamp';
break;
case 'crdate':
$sortField = 'crdate';
break;
default:
$sortField = 'SYS_LASTCHANGED';
}
// Depth, limit, extra where
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
$depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 0, 20);
} else {
$depth = 20;
}
// Max number of items
$limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
$extraWhere = ' AND pages.uid<>' . $specialValue . ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
if ($this->conf['special.']['excludeNoSearchPages']) {
$extraWhere .= ' AND pages.no_search=0';
}
// Start point
$eLevel = $this->parent_cObj->getKey(isset($this->conf['special.']['entryLevel.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['entryLevel'], $this->conf['special.']['entryLevel.']) : $this->conf['special.']['entryLevel'], $this->tmpl->rootLine);
$startUid = (int) $this->tmpl->rootLine[$eLevel]['uid'];
// Which field is for keywords
$kfield = 'keywords';
if ($this->conf['special.']['keywordsField']) {
list($kfield) = explode(' ', trim($this->conf['special.']['keywordsField']));
}
// If there are keywords and the startuid is present
if ($kw && $startUid) {
$bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
$id_list = $this->parent_cObj->getTreeList(-1 * $startUid, $depth - 1 + $bA, $bA - 1);
$kwArr = explode(',', $kw);
$keyWordsWhereArr = array();
foreach ($kwArr as $word) {
$word = trim($word);
if ($word) {
$keyWordsWhereArr[] = $kfield . ' LIKE \'%' . $this->getDatabaseConnection()->quoteStr($word, 'pages') . '%\'';
}
}
$where = empty($keyWordsWhereArr) ? '' : '(' . implode(' OR ', $keyWordsWhereArr) . ')';
$res = $this->parent_cObj->exec_getQuery('pages', array('pidInList' => '0', 'uidInList' => $id_list, 'where' => $where . $extraWhere, 'orderBy' => $sortingField ?: $sortField . ' desc', 'max' => $limit));
while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
$tsfe->sys_page->versionOL('pages', $row, true);
if (is_array($row)) {
$menuItems[$row['uid']] = $this->sys_page->getPageOverlay($row);
}
}
$this->getDatabaseConnection()->sql_free_result($res);
}
return $menuItems;
}
示例6: execFinalQuery
/**
* Execute final query, based on phash integer list. The main point is sorting the result in the right order.
*
* @param string List of phash integers which match the search.
* @param integer Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
* @return pointer Query result pointer
*/
protected function execFinalQuery($list, $freeIndexUid = -1)
{
// Setting up methods of filtering results
// based on page types, access, etc.
$page_join = '';
$page_where = '';
// Indexing configuration clause:
$freeIndexUidClause = $this->freeIndexUidWhere($freeIndexUid);
// Calling hook for alternative creation of page ID list
if ($hookObj = $this->hookRequest('execFinalQuery_idList')) {
$page_where = $hookObj->execFinalQuery_idList($list);
}
// Alternative to getting all page ids by ->getTreeList() where
// "excludeSubpages" is NOT respected.
if ($this->joinPagesForQuery) {
$page_join = ',
pages';
$page_where = ' AND pages.uid = ISEC.page_id
' . $this->enableFields('pages') . '
AND pages.no_search=0
AND pages.doktype<200
';
} elseif ($this->searchRootPageIdList >= 0) {
// Collecting all pages IDs in which to search;
// filtering out ALL pages that are not accessible due to enableFields.
// Does NOT look for "no_search" field!
$siteIdNumbers = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->searchRootPageIdList);
$pageIdList = array();
foreach ($siteIdNumbers as $rootId) {
$pageIdList[] = \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList($rootId, 9999, 0, 0, '', '') . $rootId;
}
$page_where = ' AND ISEC.page_id IN (' . implode(',', $pageIdList) . ')';
}
// otherwise select all / disable everything
// If any of the ranking sortings are selected, we must make a
// join with the word/rel-table again, because we need to
// calculate ranking based on all search-words found.
if (substr($this->sortOrder, 0, 5) == 'rank_') {
switch ($this->sortOrder) {
case 'rank_flag':
// This gives priority to word-position (max-value) so that words in title, keywords, description counts more than in content.
// The ordering is refined with the frequency sum as well.
$grsel = 'MAX(IR.flags) AS order_val1, SUM(IR.freq) AS order_val2';
$orderBy = 'order_val1' . $this->getDescendingSortOrderFlag() . ', order_val2' . $this->getDescendingSortOrderFlag();
break;
case 'rank_first':
// Results in average position of search words on page.
// Must be inversely sorted (low numbers are closer to top)
$grsel = 'AVG(IR.first) AS order_val';
$orderBy = 'order_val' . $this->getDescendingSortOrderFlag(TRUE);
break;
case 'rank_count':
// Number of words found
$grsel = 'SUM(IR.count) AS order_val';
$orderBy = 'order_val' . $this->getDescendingSortOrderFlag();
break;
default:
// Frequency sum. I'm not sure if this is the best way to do
// it (make a sum...). Or should it be the average?
$grsel = 'SUM(IR.freq) AS order_val';
$orderBy = 'order_val' . $this->getDescendingSortOrderFlag();
break;
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('ISEC.*, IP.*, ' . $grsel, 'index_words IW,
index_rel IR,
index_section ISEC,
index_phash IP' . $page_join, 'IP.phash IN (' . $list . ') ' . $this->mediaTypeWhere() . $this->languageWhere() . $freeIndexUidClause . '
AND IW.wid=IR.wid
AND ISEC.phash = IR.phash
AND IP.phash = IR.phash' . $page_where, 'IP.phash,ISEC.phash,ISEC.phash_t3,ISEC.rl0,ISEC.rl1,ISEC.rl2 ,ISEC.page_id,ISEC.uniqid,IP.phash_grouping,IP.data_filename ,IP.data_page_id ,IP.data_page_reg1,IP.data_page_type,IP.data_page_mp,IP.gr_list,IP.item_type,IP.item_title,IP.item_description,IP.item_mtime,IP.tstamp,IP.item_size,IP.contentHash,IP.crdate,IP.parsetime,IP.sys_language_uid,IP.item_crdate,IP.cHashParams,IP.externalUrl,IP.recordUid,IP.freeIndexUid,IP.freeIndexSetId', $orderBy);
} else {
// Otherwise, if sorting are done with the pages table or other fields,
// there is no need for joining with the rel/word tables:
$orderBy = '';
switch ((string) $this->sortOrder) {
case 'title':
$orderBy = 'IP.item_title' . $this->getDescendingSortOrderFlag();
break;
case 'crdate':
$orderBy = 'IP.item_crdate' . $this->getDescendingSortOrderFlag();
break;
case 'mtime':
$orderBy = 'IP.item_mtime' . $this->getDescendingSortOrderFlag();
break;
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('ISEC.*, IP.*', 'index_phash IP,index_section ISEC' . $page_join, 'IP.phash IN (' . $list . ') ' . $this->mediaTypeWhere() . $this->languageWhere() . $freeIndexUidClause . '
AND IP.phash = ISEC.phash' . $page_where, 'IP.phash,ISEC.phash,ISEC.phash_t3,ISEC.rl0,ISEC.rl1,ISEC.rl2 ,ISEC.page_id,ISEC.uniqid,IP.phash_grouping,IP.data_filename ,IP.data_page_id ,IP.data_page_reg1,IP.data_page_type,IP.data_page_mp,IP.gr_list,IP.item_type,IP.item_title,IP.item_description,IP.item_mtime,IP.tstamp,IP.item_size,IP.contentHash,IP.crdate,IP.parsetime,IP.sys_language_uid,IP.item_crdate,IP.cHashParams,IP.externalUrl,IP.recordUid,IP.freeIndexUid,IP.freeIndexSetId', $orderBy);
}
return $res;
}
示例7: user_getTreeList
/**
* renders a recursive pidList to reference content from a list of pages
*/
public function user_getTreeList()
{
$GLOBALS['TSFE']->register['pidInList'] = trim($this->cObj->data['uid'] . ',' . ($GLOBALS['TSFE']->register['tt_content_shortcut_recursive'] ? $this->cObj->getTreeList($this->cObj->data['uid'], $GLOBALS['TSFE']->register['tt_content_shortcut_recursive']) : ''), ',');
}