/**
	 * Search for a title in a certain PID
	 *
	 * @param	integer		Page id in which to search subpages matching title
	 * @param	string		Title to search for
	 * @return	array		First entry is uid, second entry is the row selected, including information about the page as a mount point.
	 * @access private
	 * @see searchTitle()
	 */
	function searchTitle_searchPid($searchPid, $title) {

		// List of "pages" fields to traverse for a "directory title" in the speaking URL (only from RootLine!!):
		$segTitleFieldList = $this->conf['segTitleFieldList'] ? $this->conf['segTitleFieldList'] : TX_REALURL_SEGTITLEFIELDLIST_DEFAULT;
		$selList = t3lib_div::uniqueList('uid,pid,doktype,mount_pid,mount_pid_ol,tx_realurl_exclude,' . $segTitleFieldList);
		$segTitleFieldArray = t3lib_div::trimExplode(',', $segTitleFieldList, 1);

		// page select object - used to analyse mount points.
		$sys_page = t3lib_div::makeInstance('t3lib_pageSelect');

		// Build an array with encoded values from the segTitleFieldArray of the subpages
		// First we find field values from the default language
		// Pages are selected in menu order and if duplicate titles are found the first takes precedence!
		$titles = array(); // array(title => uid);
		$exclude = array();
		$uidTrack = array();
		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selList, 'pages',
						'pid=' . intval($searchPid) .
						' AND deleted=0 AND doktype!=255', '', 'sorting');
		while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))) {

			// Mount points:
			$mount_info = $sys_page->getMountPointInfo($row['uid'], $row);
			if (is_array($mount_info)) {
				// There is a valid mount point.
				if ($mount_info['overlay']) {
					// Overlay mode: Substitute WHOLE record:
					$result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selList, 'pages',
									'uid=' . intval($mount_info['mount_pid']) .
									' AND deleted=0 AND doktype!=255');
					$mp_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2);
					if (is_array($mp_row)) {
						$row = $mp_row;
					}
					else {
						unset($row); // If the mount point could not be fetched, unset the row
					}
				}
				$row['_IS_MOUNTPOINT'] = $mount_info;
			}

			// Collect titles from selected row:
			if (is_array($row)) {
				if ($row['tx_realurl_exclude']) {
					// segment is excluded
					$exclude[] = $row;
				}
				// Process titles. Note that excluded segments are also searched
				// otherwise they will never be found
				$uidTrack[$row['uid']] = $row;
				foreach ($segTitleFieldArray as $fieldName) {
					if ($row[$fieldName]) {
						$encodedTitle = $this->encodeTitle($row[$fieldName]);
						if (!isset($titles[$fieldName][$encodedTitle])) {
							$titles[$fieldName][$encodedTitle] = $row['uid'];
						}
					}
				}
			}
		}
		$GLOBALS['TYPO3_DB']->sql_free_result($result);

		// We have to search the language overlay too, if: a) the language isn't the default (0), b) if it's not set (-1)
		$uidTrackKeys = array_keys($uidTrack);
		foreach ($uidTrackKeys as $l_id) {
			$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(TX_REALURL_SEGTITLEFIELDLIST_PLO,
					'pages_language_overlay', 'pid=' . intval($l_id) . ' AND deleted=0');
			while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))) {
				foreach ($segTitleFieldArray as $fieldName) {
					if ($row[$fieldName]) {
						$encodedTitle = $this->encodeTitle($row[$fieldName]);
						if (!isset($titles[$fieldName][$encodedTitle])) {
							$titles[$fieldName][$encodedTitle] = $l_id;
						}
					}
				}
			}
			$GLOBALS['TYPO3_DB']->sql_free_result($result);
		}

		// Merge titles:
		$segTitleFieldArray = array_reverse($segTitleFieldArray); // To observe the priority order...
		$allTitles = array();
		foreach ($segTitleFieldArray as $fieldName) {
			if (is_array($titles[$fieldName])) {
				$allTitles = t3lib_div::array_merge($allTitles, $titles[$fieldName]);
			}
		}

		// Return:
		$encodedTitle = $this->encodeTitle($title);
		if (isset($allTitles[$encodedTitle])) {
			return array($allTitles[$encodedTitle], $uidTrack[$allTitles[$encodedTitle]], false);
		}
		return array(false, false, $exclude);
	}
 /**
  * get all content elements containing a t3s_content-Plugin
  *
  * @return array Array containing tt_content records
  */
 public function getTtContentRecordsWithT3sPlugin()
 {
     $targetPid = intval($this->indexerConfig['targetpid']);
     if ($targetPid) {
         $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tt_content', '1=1' . ' AND pid=' . $targetPid . ' AND CType="list"' . ' AND list_type="t3s_content_pi1"' . ' AND hidden=0 AND deleted=0', '', '', '', 'uid');
         if ($rows) {
             foreach ($rows as $key => $row) {
                 if (TYPO3_VERSION_INTEGER >= 7000000) {
                     $xml = TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($row['pi_flexform']);
                 } else {
                     $xml = t3lib_div::xml2array($row['pi_flexform']);
                 }
                 $config = $xml['data']['general']['lDEF'];
                 $ttContentUids[] = $config['contentElements']['vDEF'];
             }
             $ttContentUids = implode(',', $ttContentUids);
             if (TYPO3_VERSION_INTEGER >= 7000000) {
                 $ttContentUids = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($ttContentUids);
             } else {
                 $ttContentUids = t3lib_div::uniqueList($ttContentUids);
             }
             $ttContentRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tt_content', ' uid IN (' . $ttContentUids . ')', '', '', '', 'uid');
             if ($ttContentRecords) {
                 return $ttContentRecords;
             }
         }
     }
     return array();
 }
 /**
  * store collected data of defined indexers to db
  *
  * @param integer $storagepid
  * @param string $title
  * @param string $type
  * @param string $targetpid
  * @param string $content
  * @param string $tags
  * @param string $params
  * @param string $abstract
  * @param string $language
  * @param integer $starttime
  * @param integer $endtime
  * @param string $fe_group
  * @param boolean $debugOnly
  * @param array $additionalFields
  */
 function storeInIndex($storagePid, $title, $type, $targetPid, $content, $tags = '', $params = '', $abstract = '', $language = 0, $starttime = 0, $endtime = 0, $fe_group = '', $debugOnly = false, $additionalFields = array())
 {
     // if there are errors found in current record return false and break processing
     if (!$this->checkIfRecordHasErrorsBeforeIndexing($storagePid, $title, $type, $targetPid)) {
         return false;
     }
     // optionally add tag set in the indexer configuration
     if (!empty($this->indexerConfig['filteroption']) && (substr($type, 0, 4) != 'file' || substr($type, 0, 4) == 'file' && $this->indexerConfig['index_use_page_tags_for_files'] || $this->indexerConfig['type'] == 'file')) {
         $indexerTag = $this->getTag($this->indexerConfig['filteroption']);
         $tagChar = $this->extConf['prePostTagChar'];
         if ($tags) {
             $tags .= ',' . $tagChar . $indexerTag . $tagChar;
         } else {
             $tags = $tagChar . $indexerTag . $tagChar;
         }
         if (TYPO3_VERSION_INTEGER >= 7000000) {
             $tags = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($tags);
         } else {
             $tags = t3lib_div::uniqueList($tags);
         }
     }
     $table = 'tx_kesearch_index';
     $fieldValues = $this->createFieldValuesForIndexing($storagePid, $title, $type, $targetPid, $content, $tags, $params, $abstract, $language, $starttime, $endtime, $fe_group, $additionalFields);
     // check if record already exists
     if (substr($type, 0, 4) == 'file') {
         $recordExists = $this->checkIfFileWasIndexed($fieldValues['type'], $fieldValues['hash']);
     } else {
         $recordExists = $this->checkIfRecordWasIndexed($fieldValues['orig_uid'], $fieldValues['pid'], $fieldValues['type'], $fieldValues['language']);
     }
     if ($recordExists) {
         // update existing record
         $where = 'uid=' . intval($this->currentRow['uid']);
         unset($fieldValues['crdate']);
         if ($debugOnly) {
             // do not process - just debug query
             t3lib_utility_Debug::debug($GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fieldValues), 1);
         } else {
             // process storing of index record and return uid
             $this->prepareRecordForUpdate($fieldValues);
             return true;
         }
     } else {
         // insert new record
         if ($debugOnly) {
             // do not process - just debug query
             t3lib_utility_Debug::debug($GLOBALS['TYPO3_DB']->INSERTquery($table, $fieldValues, FALSE));
         } else {
             // process storing of index record and return uid
             $this->prepareRecordForInsert($fieldValues);
             return $GLOBALS['TYPO3_DB']->sql_insert_id();
         }
     }
 }
 /**
  * Initializing workspace.
  * Called from within this function, see fetchGroupData()
  *
  * @return	void
  * @see fetchGroupData()
  */
 function workspaceInit()
 {
     // Initializing workspace by evaluating and setting the workspace, possibly updating it in the user record!
     $this->setWorkspace($this->user['workspace_id']);
     // Setting up the db mount points of the (custom) workspace, if any:
     if ($this->workspace > 0 && trim($this->workspaceRec['db_mountpoints']) !== '') {
         // Initialize:
         $newMounts = array();
         $readPerms = '1=1';
         // Notice: We cannot call $this->getPagePermsClause(1); as usual because the group-list is not available at this point. But bypassing is fine because all we want here is check if the workspace mounts are inside the current webmounts rootline. The actual permission checking on page level is done elsewhere as usual anyway before the page tree is rendered.
         // Traverse mount points of the
         $mountPoints = t3lib_div::intExplode(',', $this->workspaceRec['db_mountpoints']);
         foreach ($mountPoints as $mpId) {
             if ($this->isInWebMount($mpId, $readPerms)) {
                 $newMounts[] = $mpId;
             }
         }
         // Re-insert webmounts:
         $this->groupData['webmounts'] = implode(',', array_unique($newMounts));
     }
     // Setting up the file mount points of the (custom) workspace, if any:
     if ($this->workspace !== 0) {
         $this->groupData['filemounts'] = array();
     }
     if ($this->workspace > 0 && trim($this->workspaceRec['file_mountpoints']) !== '') {
         // Processing filemounts
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->workspaceRec['file_mountpoints']) . ')');
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $this->addFileMount($row['title'], $row['path'], $row['path'], $row['base'] ? 1 : 0, '');
         }
     }
     if ($allowed_languages = $this->getTSConfigVal('options.workspaces.allowed_languages.' . $this->workspace)) {
         $this->groupData['allowed_languages'] = $allowed_languages;
         $this->groupData['allowed_languages'] = t3lib_div::uniqueList($this->groupData['allowed_languages']);
     }
 }
 /**
  * Listview of the trouble tickets
  *
  * @return	HTML list of table entries
  */
 public function listView()
 {
     /*{{{*/
     // which template should be used?
     $templateSubpart = $this->listViewConf['templateSubpart'];
     $templateSubpartRow = $this->listViewConf['templateSubpartRow'];
     $content = $this->cObj->getSubpart($this->templateCode, $templateSubpart);
     // Initialize pointer
     if (!isset($this->piVars['pointer'])) {
         $this->piVars['pointer'] = 0;
     }
     /* --------------------------------
     			// Initialize the query parameters.
     			/* -------------------------------*/
     // Tablename
     $this->internal['currentTable'] = $this->tablename;
     // set orderBy and descFlag
     list($this->internal['orderBy'], $this->internal['descFlag']) = explode('-', $this->piVars['sort']);
     // Number of results to show in a listing.
     if ($this->getNumericTYPO3versionNumber() >= 6000000) {
         $this->internal['results_at_a_time'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->listViewConf['results_at_a_time'], 0, 1000, 10);
     } else {
         $this->internal['results_at_a_time'] = t3lib_div::intInRange($this->listViewConf['results_at_a_time'], 0, 1000, 10);
     }
     if ($this->piVars['entries_per_page']) {
         $this->internal['results_at_a_time'] = $this->piVars['entries_per_page'];
     }
     // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
     if ($this->getNumericTYPO3versionNumber() >= 6000000) {
         $this->internal['maxPages'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->listViewConf['maxPages'], 0, 1000, 5);
     } else {
         $this->internal['maxPages'] = t3lib_div::intInRange($this->listViewConf['maxPages'], 0, 1000, 5);
     }
     // fields to search in
     $this->internal['searchFieldList'] = 'title,description';
     // fields allowed for the ORDER BY command
     //$this->internal['orderByList']='uid,title,crdate,until_date';
     $this->internal['orderByList'] = $this->conf['listView.']['headerList'];
     // center the page browser
     $this->internal['pagefloat'] = 'CENTER';
     // PERMISSION CHECKS
     $addWhere = $this->getUserAccessibleTicketsWhereClause($GLOBALS['TSFE']->fe_user->user['uid']);
     // add filter
     if (is_array($this->filter)) {
         foreach ($this->filter as $filterName => $filterValue) {
             // HACK for the "open and working" filter
             // TODO: Should be configurable in Typoscript in future versions
             if ($filterName == 'status') {
                 switch ($filterValue) {
                     case 'open_and_working':
                         $addWhere .= ' AND (status="open" OR status="working")';
                         break;
                     case 'all_not_closed':
                         /* Fetch only tickets which are not closed.
                          * closed tickets are all ticket types that have the
                          * CONST_STATUS_CLOSED (normally "closed") in their key.
                          * That rule also applies to locked ticket which have the
                          * key "closed_locked".
                          * You can invent new "closed"-types like
                          * "closed_without_solution" or "closed_another_reason" ...
                          */
                         $addWhere .= ' AND status NOT LIKE "' . CONST_STATUS_CLOSED . '%"';
                         break;
                     case 'all':
                         break;
                     default:
                         $addWhere .= ' AND ' . $filterName . '="' . mysql_real_escape_string($filterValue) . '"';
                         break;
                 }
                 // HACK for the "not fully charged" filter
                 // TODO: Should be configurable in Typoscript in future versions
             } else {
                 if ($filterName == 'charged') {
                     switch ($filterValue) {
                         case NOT_FULLY_CHARGED_FILTER:
                             $addWhere .= ' AND (charged!="fully_charged")';
                             break;
                         default:
                             $addWhere .= ' AND ' . $filterName . '="' . mysql_real_escape_string($filterValue) . '"';
                             break;
                     }
                 } else {
                     if ($filterName == 'closed_in_month') {
                         $from = intval($filterValue);
                         $month_to = date('m', $from) + 1;
                         $year_to = date('Y', $from);
                         if ($month_to > 12) {
                             $month_to = 1;
                             $year_to++;
                         }
                         $to = mktime(0, 0, 0, $month_to, 1, $year_to);
                         $addWhere .= ' AND close_time >=' . $from . ' AND close_time <= ' . $to;
                     } else {
                         $addWhere .= ' AND ' . $filterName . '="' . mysql_real_escape_string($filterValue) . '"';
                     }
                 }
             }
         }
     }
     // filter for categories
     if ($this->ffdata['listcategories'] != '') {
         $addWhere .= ' AND category IN (' . $this->ffdata['listcategories'] . ') ';
     }
     // Get number of records:
     $res = $this->pi_exec_query($this->tablename, 1, $addWhere);
     list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
     // we exit here, if the listview has no results (if configured so)
     if ($this->listViewConf['hideIfNoResults'] && !$this->internal['res_count']) {
         return '';
     }
     // Check if submitted sort is allowed, if not, set it to default
     if ($this->piVars['sort'] && $this->piVars['sort'] != DEFAULT_SORT && !t3lib_div::inList(t3lib_div::uniqueList($this->internal['orderByList']), $this->internal['orderBy'])) {
         list($this->internal['orderBy'], $this->internal['descFlag']) = explode(',', DEFAULT_SORT);
     }
     // compile orderBy-parameter
     $orderBy = $this->internal['orderBy'] . ($this->internal['descFlag'] ? ' DESC' : '');
     // add a second sorting
     if ($this->listViewConf['sort2']) {
         $orderBy .= $this->listViewConf['sort2'];
     }
     // Increase limit for the csv export
     if (isset($this->piVars['export']) && $this->piVars['export'] == 'csv') {
         $this->internal['results_at_a_time'] = 1000000;
     }
     // exec the query
     $res = $this->pi_exec_query($this->tablename, '', $addWhere, '', '', $orderBy);
     // Now that we have the query, we can do the csv-export
     if (isset($this->piVars['export']) && $this->piVars['export'] == 'csv') {
         $this->outputCSV($res);
     }
     // render the sorting links
     $this->renderListSortingLinks();
     // render the filters
     foreach ($this->conf['formFieldList.'] as $fieldConf) {
         if (t3lib_div::inList(t3lib_div::uniqueList($this->listViewConf['filterList']), $fieldConf['name'])) {
             // dont't pre-select user values in the filter if the filter ist empty
             if ($fieldConf['prefillWithCurrentUserIfEmpty']) {
                 $fieldConf['prefillWithCurrentUserIfEmpty'] = 0;
             }
             $this->markerArray['FILTER_' . strtoupper(trim($fieldConf['name']))] = $this->renderFormField($fieldConf, RENDER_EMPTY_DRODOWN_ELEMENT, 'onchange="this.form.submit();"');
         }
     }
     // render the viewtype selector
     $this->markerArray['VIEWTYPE_SELECTOR'] = $this->renderFormField($this->conf['viewtype_selector.'], DONT_RENDER_EMPTY_DRODOWN_ELEMENT, 'onchange="this.form.submit();"');
     // add the filter form markers
     $this->markerArray['FILTERFORM_NAME'] = $this->ticketFormName . '_filter';
     $this->markerArray['FILTERFORM_ACTION'] = $this->cObj->typoLink_URL(array('parameter' => $GLOBALS['TSFE']->id, 'additionalParams' => $this->getAdditionalParamsFromKeepPiVars()));
     $this->markerArray['FILTER_SUBMIT'] = '<input type="submit" name="' . $this->prefixId . '[filter_submit]' . '" value="' . $this->pi_getLL('LABEL_FILTER_SUBMIT') . '">';
     // show filter reset button / status icon
     $this->markerArray['FILTER_STATUSICON'] = $this->getFieldContent('filter_statusicon');
     // make the whole list
     $this->markerArray['LISTCONTENT'] = $this->makelist($res, $templateSubpartRow);
     // create the search box
     $this->markerArray['SEARCHBOX'] = $this->pi_list_searchBox();
     // create the result browser
     $wrapper['disabledLinkWrap'] = '<span class="disable">|</span>';
     $wrapper['inactiveLinkWrap'] = '<span class="inactive">|</span>';
     $wrapper['activeLinkWrap'] = '<span' . $this->pi_classParam('browsebox-SCell') . '>|</span>';
     $wrapper['browseLinksWrap'] = '<div class="browseLinks">|</div>';
     $wrapper['browseLinksWrap'] .= '<div class="kett_entries_per_page">';
     $wrapper['browseLinksWrap'] .= '<label>' . $this->pi_getLL('LABEL_ENTRIES_PER_PAGE') . '</label>';
     $wrapper['browseLinksWrap'] .= $this->getEntriesPerPageSelection($this->listViewConf);
     $wrapper['browseLinksWrap'] .= '</div><div class="kett_float_clean">&nbsp;</div>';
     $wrapper['showResultsWrap'] = '<p class="resultText">|</p>';
     $wrapper['browseBoxWrap'] = '<div ' . $this->pi_classParam('browsebox') . '> | </div>';
     $this->markerArray['PAGEBROWSER'] = $this->pi_list_browseresults(1, '', $wrapper);
     // get additional markers (locallang, ...)
     $this->markerArray = $this->getAdditionalMarkers($this->markerArray);
     // substitute the markers
     $content = $this->cObj->substituteMarkerArray($content, $this->markerArray, '###|###', true);
     // check every filter if there is content for every filter, otherwise substitute
     // whole filter block subpart with empty content
     foreach ($this->conf['formFieldList.'] as $fieldConf) {
         if (t3lib_div::inList(t3lib_div::uniqueList($this->listViewConf['filterList']), $fieldConf['name'])) {
             if ($this->markerArray['FILTER_' . strtoupper(trim($fieldConf['name']))] == '') {
                 $content = $this->cObj->substituteSubpart($content, '###FILTER_BLOCK_' . strtoupper(trim($fieldConf['name'])), '');
             }
         }
         // remove Filters for Internal Fields if User is no internal User
         if ($fieldConf['internal'] && !$this->isCurrentUserInternalUser()) {
             $content = $this->cObj->substituteSubpart($content, '###FILTER_BLOCK_' . strtoupper(trim($fieldConf['name'])), '');
         }
     }
     // overwrite status message subpart if no status message is set
     if (empty($this->markerArray['STATUS_MESSAGE_TEXT'])) {
         $content = $this->cObj->substituteSubpart($content, '###STATUS_MESSAGE###', '');
     }
     // Returns the content from the plugin.
     return $content;
 }
 /**
  * @param string $in_list Accept multiple parameters which can be comma-separated lists of values and arrays.
  * @param mixed $secondParameter Dummy field, which if set will show a warning!
  * @return string Returns the list without any duplicates of values, space around values are trimmed
  */
 public function uniqueList($in_list, $secondParameter = NULL)
 {
     /** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */
     return t3lib_div::uniqueList($in_list, $secondParameter);
 }
 /**
  * Returns array with fields of the pages from here ($uid) and back to the root
  * NOTICE: This function only takes deleted pages into account! So hidden, starttime and endtime restricted pages are included no matter what.
  * Further: If any "recycler" page is found (doktype=255) then it will also block for the rootline)
  * If you want more fields in the rootline records than default such can be added by listing them in $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']
  *
  * @param	integer		The page uid for which to seek back to the page tree root.
  * @param	string		Commalist of MountPoint parameters, eg. "1-2,3-4" etc. Normally this value comes from the GET var, MP
  * @param	boolean		If set, some errors related to Mount Points in root line are ignored.
  * @return	array		Array with page records from the root line as values. The array is ordered with the outer records first and root record in the bottom. The keys are numeric but in reverse order. So if you traverse/sort the array by the numeric keys order you will get the order from root and out. If an error is found (like eternal looping or invalid mountpoint) it will return an empty array.
  * @see tslib_fe::getPageAndRootline()
  */
 function getRootLine($uid, $MP = '', $ignoreMPerrors = false)
 {
     $cacheUid = $uid = intval($uid);
     $cacheIgnoreMPerrors = $ignoreMPerrors ? 1 : 0;
     if (is_array($this->cache_getRootLine[$cacheUid][$this->sys_language_uid][$MP][$cacheIgnoreMPerrors])) {
         return $this->cache_getRootLine[$cacheUid][$this->sys_language_uid][$MP][$cacheIgnoreMPerrors];
     }
     // Initialize:
     $selFields = t3lib_div::uniqueList('pid,uid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,title,alias,nav_title,media,layout,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,TSconfig,storage_pid,is_siteroot,mount_pid,mount_pid_ol,fe_login_mode,' . $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']);
     $this->error_getRootLine = '';
     $this->error_getRootLine_failPid = 0;
     // Splitting the $MP parameters if present
     $MPA = array();
     if ($MP) {
         $MPA = explode(',', $MP);
         foreach ($MPA as $MPAk => $v) {
             $MPA[$MPAk] = explode('-', $MPA[$MPAk]);
         }
     }
     $loopCheck = 0;
     $theRowArray = array();
     while ($uid != 0 && $loopCheck < 20) {
         // Max 20 levels in the page tree.
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, 'pages', 'uid=' . intval($uid) . ' AND pages.deleted=0 AND pages.doktype!=255');
         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         if ($row) {
             $this->versionOL('pages', $row, FALSE, TRUE);
             $this->fixVersioningPid('pages', $row);
             if (is_array($row)) {
                 // Mount Point page types are allowed ONLY a) if they are the outermost record in rootline and b) if the overlay flag is not set:
                 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] && $row['doktype'] == 7 && !$ignoreMPerrors) {
                     $mount_info = $this->getMountPointInfo($row['uid'], $row);
                     if ($loopCheck > 0 || $mount_info['overlay']) {
                         $this->error_getRootLine = 'Illegal Mount Point found in rootline';
                         return array();
                     }
                 }
                 $uid = $row['pid'];
                 // Next uid
                 if (count($MPA) && $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids']) {
                     $curMP = end($MPA);
                     if (!strcmp($row['uid'], $curMP[0])) {
                         array_pop($MPA);
                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, 'pages', 'uid=' . intval($curMP[1]) . ' AND pages.deleted=0 AND pages.doktype!=255');
                         $mp_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
                         $this->versionOL('pages', $mp_row, FALSE, TRUE);
                         $this->fixVersioningPid('pages', $mp_row);
                         if (is_array($mp_row)) {
                             $mount_info = $this->getMountPointInfo($mp_row['uid'], $mp_row);
                             if (is_array($mount_info) && $mount_info['mount_pid'] == $curMP[0]) {
                                 $uid = $mp_row['pid'];
                                 // Setting next uid
                                 if ($mount_info['overlay']) {
                                     // Symlink style: Keep mount point (current row).
                                     $row['_MOUNT_OL'] = TRUE;
                                     // Set overlay mode:
                                     $row['_MOUNT_PAGE'] = array('uid' => $mp_row['uid'], 'pid' => $mp_row['pid'], 'title' => $mp_row['title']);
                                 } else {
                                     // Normal operation: Insert the mount page row in rootline instead mount point.
                                     if ($loopCheck > 0) {
                                         $row = $mp_row;
                                     } else {
                                         $this->error_getRootLine = 'Current Page Id is a mounted page of the overlay type and cannot be accessed directly!';
                                         return array();
                                         // Matching the page id (first run, $loopCheck = 0) with the MPvar is ONLY allowed if the mount point is the "overlay" type (otherwise it could be forged!)
                                     }
                                 }
                                 $row['_MOUNTED_FROM'] = $curMP[0];
                                 $row['_MP_PARAM'] = $mount_info['MPvar'];
                             } else {
                                 $this->error_getRootLine = 'MP var was corrupted';
                                 return array();
                                 // The MP variables did NOT connect proper mount points:
                             }
                         } else {
                             $this->error_getRootLine = 'No moint point record found according to PID in MP var';
                             return array();
                             // The second PID in MP var was NOT a valid page.
                         }
                     }
                 }
             }
             // Add row to rootline with language overlaid:
             $theRowArray[] = $this->getPageOverlay($row);
         } else {
             $this->error_getRootLine = 'Broken rootline';
             $this->error_getRootLine_failPid = $uid;
             return array();
             // broken rootline.
         }
         $loopCheck++;
     }
     // If the MPA array is NOT empty, we have to return an error; All MP elements were not resolved!
     if (count($MPA)) {
         $this->error_getRootLine = 'MP value remain!';
         return array();
     }
     // Create output array (with reversed order of numeric keys):
     $output = array();
     $c = count($theRowArray);
     foreach ($theRowArray as $key => $val) {
         $c--;
         $output[$c] = $val;
     }
     // Note: rootline errors are not cached
     $this->cache_getRootLine[$cacheUid][$this->sys_language_uid][$MP][$cacheIgnoreMPerrors] = $output;
     return $output;
 }
 public function addOtherLabelsList($otherLabelsList)
 {
     if ($otherLabelsList != '') {
         $formerOtherLabelsList = $this->getOtherLabelsList();
         if ($formerOtherLabelsList != '') {
             $newOtherLabelsList = $formerOtherLabelsList . ',' . $otherLabelsList;
             $newOtherLabelsList = t3lib_div::uniqueList($newOtherLabelsList);
             $this->setOtherLabelsList($newOtherLabelsList);
         }
     }
 }
 function getRootLine($uid, $selFields = '', $where = ' ', $MP = '')
 {
     if ($selFields == '') {
         #TODO
         $selFields = t3lib_div::uniqueList('pid,uid,title,nav_title,hidden,fe_group,' . $this->parentField);
     }
     $MPA = array();
     if ($MP) {
         $MPA = explode(',', $MP);
         reset($MPA);
         while (list($MPAk) = each($MPA)) {
             $MPA[$MPAk] = explode('-', $MPA[$MPAk]);
         }
     }
     $loopCheck = 20;
     $theRowArray = array();
     $output = array();
     $uid = intval($uid);
     while ($uid != 0 && $loopCheck > 0) {
         $loopCheck--;
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, $this->table, 'uid=' . intval($uid) . $where . $this->where_default);
         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             if (count($MPA)) {
                 $curMP = end($MPA);
                 if (!strcmp($row['uid'], $curMP[0])) {
                     array_pop($MPA);
                     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, $this->table, 'uid=' . intval($curMP[1]) . $where . $this->where_default);
                     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                     $row['_MOUNTED_FROM'] = $curMP[0];
                     if (!is_array($row)) {
                         return array();
                     }
                     // error - no record...
                 }
             }
             $uid = $row[$this->parentField];
             $theRowArray[] = $row;
         } else {
             $theRowArray = '';
             break;
         }
     }
     if (is_array($theRowArray) && !count($MPA)) {
         reset($theRowArray);
         $c = count($theRowArray);
         while (list($key, $val) = each($theRowArray)) {
             $c--;
             $output[$c] = $val;
         }
     }
     ksort($output);
     return $output;
 }
 /**
  * Like getRecord(), but overlays workspace version if any.
  *
  * @param	string		Table name present in $TCA
  * @param	integer		UID of record
  * @param	string		List of fields to select
  * @param	string		Additional WHERE clause, eg. " AND blablabla = 0"
  * @param	boolean		Use the deleteClause to check if a record is deleted (default true)
  * @param	boolean		If true the function does not return a "pointer" row for moved records in a workspace
  * @return	array		Returns the row if found, otherwise nothing
  */
 public static function getRecordWSOL($table, $uid, $fields = '*', $where = '', $useDeleteClause = TRUE, $unsetMovePointers = FALSE)
 {
     if ($fields !== '*') {
         $internalFields = t3lib_div::uniqueList($fields . ',uid,pid' . ($table == 'pages' ? ',t3ver_swapmode' : ''));
         $row = self::getRecord($table, $uid, $internalFields, $where, $useDeleteClause);
         self::workspaceOL($table, $row, -99, $unsetMovePointers);
         if (is_array($row)) {
             foreach (array_keys($row) as $key) {
                 if (!t3lib_div::inList($fields, $key) && $key[0] !== '_') {
                     unset($row[$key]);
                 }
             }
         }
     } else {
         $row = self::getRecord($table, $uid, $fields, $where, $useDeleteClause);
         self::workspaceOL($table, $row, -99, $unsetMovePointers);
     }
     return $row;
 }
 /**
  * Initializing workspace.
  * Called from within this function, see fetchGroupData()
  *
  * @return	void
  * @see fetchGroupData()
  */
 function workspaceInit()
 {
     // Initializing workspace by evaluating and setting the workspace, possibly updating it in the user record!
     $this->setWorkspace($this->user['workspace_id']);
     // Limiting the DB mountpoints if there any selected in the workspace record
     $dbMountpoints = trim($this->workspaceRec['db_mountpoints']);
     if ($this->workspace > 0 && $dbMountpoints != '') {
         $filteredDbMountpoints = array();
         $readPerms = '1=1';
         // Notice: We cannot call $this->getPagePermsClause(1); as usual because the group-list is not available at this point. But bypassing is fine because all we want here is check if the workspace mounts are inside the current webmounts rootline. The actual permission checking on page level is done elsewhere as usual anyway before the page tree is rendered.
         // Traverse mount points of the
         $dbMountpoints = t3lib_div::intExplode(',', $dbMountpoints);
         foreach ($dbMountpoints as $mpId) {
             if ($this->isInWebMount($mpId, $readPerms)) {
                 $filteredDbMountpoints[] = $mpId;
             }
         }
         // Re-insert webmounts:
         $filteredDbMountpoints = array_unique($filteredDbMountpoints);
         $this->groupData['webmounts'] = implode(',', $filteredDbMountpoints);
     }
     // Filtering the file mountpoints
     // if there some selected in the workspace record
     if ($this->workspace !== 0) {
         $usersFileMounts = $this->groupData['filemounts'];
         $this->groupData['filemounts'] = array();
     }
     $fileMountpoints = trim($this->workspaceRec['file_mountpoints']);
     if ($this->workspace > 0) {
         // no custom filemounts that should serve as filter or user is admin
         // so all user mountpoints are re-applied
         if ($this->isAdmin() || $fileMountpoints === '') {
             $this->groupData['filemounts'] = $usersFileMounts;
         } else {
             // Fetching all filemounts from the workspace
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted = 0 AND hidden = 0 AND pid = 0 AND uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($fileMountpoints) . ')');
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 // add every filemount of this workspace record
                 $this->addFileMount($row['title'], $row['path'], $row['path'], $row['base'] ? 1 : 0, '');
                 // get the added entry, and check if it was in the users' original filemounts
                 // if not, remove it from the new filemount list again
                 // see self::addFileMount
                 end($this->groupData['filemounts']);
                 $md5hash = key($this->groupData['filemounts']);
                 if (!array_key_exists($md5hash, $usersFileMounts)) {
                     unset($this->groupData['filemounts'][$md5hash]);
                 }
             }
         }
     }
     if ($allowed_languages = $this->getTSConfigVal('options.workspaces.allowed_languages.' . $this->workspace)) {
         $this->groupData['allowed_languages'] = $allowed_languages;
         $this->groupData['allowed_languages'] = t3lib_div::uniqueList($this->groupData['allowed_languages']);
     }
 }
 /**
  * Reads a directory for files and returns the filepaths in a string list separated by comma.
  * Implements the stdWrap property "filelist"
  *
  * @param	string		The command which contains information about what files/directory listing to return. See the "filelist" property of stdWrap for details.
  * @return	string		Comma list of files.
  * @access private
  * @see stdWrap()
  */
 function filelist($data)
 {
     $data = trim($data);
     if ($data) {
         $data_arr = explode('|', $data);
         // read directory:
         if ($GLOBALS['TSFE']->lockFilePath) {
             // MUST exist!
             $path = $this->clean_directory($data_arr[0]);
             // Cleaning name..., only relative paths accepted.
             // see if path starts with lockFilePath, the additional '/' is needed because clean_directory gets rid of it
             $path = t3lib_div::isFirstPartOfStr($path . '/', $GLOBALS['TSFE']->lockFilePath) ? $path : '';
         }
         if ($path) {
             $items = array('files' => array(), 'sorting' => array());
             $ext_list = strtolower(t3lib_div::uniqueList($data_arr[1]));
             $sorting = trim($data_arr[2]);
             // read dir:
             $d = @dir($path);
             $tempArray = array();
             if (is_object($d)) {
                 $count = 0;
                 while ($entry = $d->read()) {
                     if ($entry != '.' && $entry != '..') {
                         $wholePath = $path . '/' . $entry;
                         // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
                         if (file_exists($wholePath) && filetype($wholePath) == 'file') {
                             $info = t3lib_div::split_fileref($wholePath);
                             if (!$ext_list || t3lib_div::inList($ext_list, $info['fileext'])) {
                                 $items['files'][] = $info['file'];
                                 switch ($sorting) {
                                     case 'name':
                                         $items['sorting'][] = strtolower($info['file']);
                                         break;
                                     case 'size':
                                         $items['sorting'][] = filesize($wholePath);
                                         break;
                                     case 'ext':
                                         $items['sorting'][] = $info['fileext'];
                                         break;
                                     case 'date':
                                         $items['sorting'][] = filectime($wholePath);
                                         break;
                                     case 'mdate':
                                         $items['sorting'][] = filemtime($wholePath);
                                         break;
                                     default:
                                         $items['sorting'][] = $count;
                                         break;
                                 }
                                 $count++;
                             }
                         }
                     }
                 }
                 $d->close();
             }
             // Sort if required
             if (count($items['sorting'])) {
                 if (strtolower(trim($data_arr[3])) != 'r') {
                     asort($items['sorting']);
                 } else {
                     arsort($items['sorting']);
                 }
             }
             if (count($items['files'])) {
                 // make list
                 reset($items['sorting']);
                 $fullPath = trim($data_arr[4]);
                 $list_arr = array();
                 foreach ($items['sorting'] as $key => $v) {
                     $list_arr[] = $fullPath ? $path . '/' . $items['files'][$key] : $items['files'][$key];
                 }
                 return implode(',', $list_arr);
             }
         }
     }
 }
 /**
  * Gets the list of extensions to be ignored (not to be loaded).
  *
  * @return string
  */
 public static function getIgnoredExtensionList()
 {
     $ignoredExtensionList = t3lib_div::uniqueList($GLOBALS['TYPO3_CONF_VARS']['EXT']['ignoredExt']);
     return $ignoredExtensionList;
 }
 /**
  * get content of current page and save data to db
  * @param $uid page-UID that has to be indexed
  */
 public function getPageContent($uid)
 {
     $flex = $this->pageRecords[$uid]['tx_templavoila_flex'];
     if (empty($flex)) {
         return '';
     }
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $flex = TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($flex);
     } else {
         $flex = t3lib_div::xml2array($flex);
     }
     // TODO: Maybe I need a more detailed collection of retrieving CE UIDS
     $contentElementUids = array();
     if (!$this->indexerConfig['tvpath']) {
         $tvPaths = 'field_content';
     } else {
         $tvPaths = $this->indexerConfig['tvpath'];
     }
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $tvPaths = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tvPaths);
     } else {
         $tvPaths = t3lib_div::trimExplode(',', $tvPaths);
     }
     foreach ($tvPaths as $tvPath) {
         $contentElementUids[] = $flex['data']['sDEF']['lDEF'][$tvPath]['vDEF'];
     }
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $contentElementUids = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList(implode(',', $contentElementUids));
     } else {
         $contentElementUids = t3lib_div::uniqueList(implode(',', $contentElementUids));
     }
     if (empty($contentElementUids)) {
         return '';
     }
     // TODO: Maybe it's good to check comma seperated list for int values
     // get content elements for this page
     $fields = '*';
     $table = 'tt_content';
     $where = 'uid IN (' . $contentElementUids . ')';
     $where .= ' AND (' . $this->whereClauseForCType . ')';
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
         $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
     } else {
         $where .= t3lib_BEfunc::BEenableFields($table);
         $where .= t3lib_BEfunc::deleteClause($table);
     }
     // if indexing of content elements with restrictions is not allowed
     // get only content elements that have empty group restrictions
     if ($this->indexerConfig['index_content_with_restrictions'] != 'yes') {
         $where .= ' AND (fe_group = "" OR fe_group = "0") ';
     }
     $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where);
     if (count($rows)) {
         $this->counter++;
         foreach ($rows as $row) {
             // header
             // add header only if not set to "hidden"
             if ($row['header_layout'] != 100) {
                 $pageContent[$row['sys_language_uid']] .= strip_tags($row['header']) . "\n";
             }
             // bodytext
             $bodytext = $row['bodytext'];
             if ($row['CType'] == 'table') {
                 // replace table dividers with whitespace
                 $bodytext = str_replace('|', ' ', $bodytext);
             }
             if ($row['CType'] == 'templavoila_pi1') {
                 //$bodytext = $this->getContentForTV($row);
                 $bodytext = $this->tv->renderElement($row, 'tt_content');
             }
             // following lines prevents having words one after the other like: HelloAllTogether
             $bodytext = str_replace('<td', ' <td', $bodytext);
             $bodytext = str_replace('<br', ' <br', $bodytext);
             $bodytext = str_replace('<p', ' <p', $bodytext);
             $bodytext = str_replace('<li', ' <li', $bodytext);
             $bodytext = strip_tags($bodytext);
             $pageContent[$row['sys_language_uid']] .= $bodytext . "\n";
         }
     }
     // get Tags for current page
     $tags = $this->pageRecords[intval($uid)]['tags'];
     // make it possible to modify the indexerConfig via hook
     $indexerConfig = $this->indexerConfig;
     // hook for custom modifications of the indexed data, e. g. the tags
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyTemplaVoilaIndexEntry'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyTemplaVoilaIndexEntry'] as $_classRef) {
             if (TYPO3_VERSION_INTEGER >= 7000000) {
                 $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
             } else {
                 $_procObj =& t3lib_div::getUserObj($_classRef);
             }
             $_procObj->modifyPagesIndexEntry($uid, $pageContent, $tags, $this->cachedPageRecords, $additionalFields, $indexerConfig);
         }
     }
     // store record in index table
     foreach ($pageContent as $langKey => $content) {
         $this->pObj->storeInIndex($indexerConfig['storagepid'], $this->cachedPageRecords[$langKey][$uid]['title'], 'templavoila', $uid, $content, $tags, '', '', $langKey, $this->cachedPageRecords[$langKey][$uid]['starttime'], $this->cachedPageRecords[$langKey][$uid]['endtime'], $this->cachedPageRecords[$langKey][$uid]['fe_group'], false, $additionalFields);
     }
 }
 /**
  * Constructor
  * This function should be called to initialise the internal arrays $this->mounts and $this->f_ext
  *
  *  A typical example of the array $mounts is this:
  * 		$mounts[xx][path] = (..a mounted path..)
  * 	the 'xx'-keys is just numerical from zero. There are also a [name] and [type] value that just denotes the mountname and type. Not used for athentication here.
  * 	$this->mounts is traversed in the function checkPathAgainstMounts($thePath), and it is checked that $thePath is actually below one of the mount-paths
  * 	The mountpaths are with a trailing '/'. $thePath must be with a trailing '/' also!
  * 	As you can see, $this->mounts is very critical! This is the array that decides where the user will be allowed to copy files!!
  *  Typically the global var $WEBMOUNTS would be passed along as $mounts
  *
  * 	A typical example of the array $f_ext is this:
  * 		$f_ext['webspace']['allow']='';
  * 		$f_ext['webspace']['deny']= PHP_EXTENSIONS_DEFAULT;
  * 		$f_ext['ftpspace']['allow']='*';
  * 		$f_ext['ftpspace']['deny']='';
  * 	The control of fileextensions goes in two catagories. Webspace and Ftpspace. Webspace is folders accessible from a webbrowser (below TYPO3_DOCUMENT_ROOT) and ftpspace is everything else.
  * 	The control is done like this: If an extension matches 'allow' then the check returns true. If not and an extension matches 'deny' then the check return false. If no match at all, returns true.
  * 	You list extensions comma-separated. If the value is a '*' every extension is allowed
  * 	The list is case-insensitive when used in this class (see init())
  *  Typically TYPO3_CONF_VARS['BE']['fileExtensions'] would be passed along as $f_ext.
  *
  *  Example:
  * 	$basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
  *
  * @param	array		Contains the paths of the file mounts for the current BE user. Normally $GLOBALS['FILEMOUNTS'] is passed. This variable is set during backend user initialization; $FILEMOUNTS = $BE_USER->returnFilemounts(); (see typo3/init.php)
  * @param	array		Array with information about allowed and denied file extensions. Typically passed: $TYPO3_CONF_VARS['BE']['fileExtensions']
  * @return	void
  * @see typo3/init.php, t3lib_userAuthGroup::returnFilemounts()
  */
 function init($mounts, $f_ext)
 {
     $this->f_ext['webspace']['allow'] = t3lib_div::uniqueList(strtolower($f_ext['webspace']['allow']));
     $this->f_ext['webspace']['deny'] = t3lib_div::uniqueList(strtolower($f_ext['webspace']['deny']));
     $this->f_ext['ftpspace']['allow'] = t3lib_div::uniqueList(strtolower($f_ext['ftpspace']['allow']));
     $this->f_ext['ftpspace']['deny'] = t3lib_div::uniqueList(strtolower($f_ext['ftpspace']['deny']));
     $this->mounts = $mounts;
     $this->webPath = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT');
     $this->isInit = 1;
     $this->maxInputNameLen = $GLOBALS['TYPO3_CONF_VARS']['SYS']['maxFileNameLength'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['maxFileNameLength'] : $this->maxInputNameLen;
 }
 /**
  * 
  * combines two string comma lists
  * 
  * @param string $list1
  * @param string $list2
  * @author Christian Bülter <*****@*****.**>
  * @since 23.07.13 
  * @return string
  */
 public function combineLists($list1 = '', $list2 = '')
 {
     if (!empty($list2) && !empty($list2)) {
         $list1 .= ',';
     }
     $list1 .= $list2;
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $returnValue = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($list1);
     } else {
         $returnValue = t3lib_div::uniqueList($list1);
     }
     return $returnValue;
 }
 /**
  * Initializing workspace.
  * Called from within this function, see fetchGroupData()
  *
  * @return void
  * @see fetchGroupData()
  * @todo Define visibility
  */
 public function workspaceInit()
 {
     // Initializing workspace by evaluating and setting the workspace, possibly updating it in the user record!
     $this->setWorkspace($this->user['workspace_id']);
     // Limiting the DB mountpoints if there any selected in the workspace record
     $this->initializeDbMountpointsInWorkspace();
     if ($allowed_languages = $this->getTSConfigVal('options.workspaces.allowed_languages.' . $this->workspace)) {
         $this->groupData['allowed_languages'] = $allowed_languages;
         $this->groupData['allowed_languages'] = t3lib_div::uniqueList($this->groupData['allowed_languages']);
     }
 }
Beispiel #18
0
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function initSubCategories()
 {
     if ($this->useSubCategories && $this->category) {
         $subcats = tx_ttnews_div::getSubCategories($this->category);
         $this->selectedCategories = t3lib_div::uniqueList($this->category . ($subcats ? ',' . $subcats : ''));
     } else {
         $this->selectedCategories = $this->category;
     }
 }
 /**
  * This method is needed because the getRootline method from t3lib_pageSelect causes an error when
  * getRootline is called be cause getRootline internally uses languagevisibility to determine the
  * visibility during the rootline calculation. This results in an unlimited recursion.
  *
  * @todo The rooline can be build in a smarter way, once the rootline for a page has been created
  * same parts of the rootline not have to be calculated twice.
  *
  * @param	integer		The page uid for which to seek back to the page tree root.
  * @see tslib_fe::getPageAndRootline()
  */
 protected function getOverlayedRootLine($uid, $languageid)
 {
     $cacheManager = tx_languagevisibility_cacheManager::getInstance();
     $cacheData = $cacheManager->get('overlayedRootline');
     $isCacheEnabled = $cacheManager->isCacheEnabled();
     if (!$isCacheEnabled || !isset($cacheData[$uid][$languageid])) {
         $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
         $sys_page->sys_language_uid = $languageid;
         $uid = intval($uid);
         // Initialize:
         $selFields = t3lib_div::uniqueList('pid,uid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,title,alias,nav_title,media,layout,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,TSconfig,storage_pid,is_siteroot,mount_pid,mount_pid_ol,fe_login_mode,' . $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']);
         $loopCheck = 0;
         $theRowArray = array();
         while ($uid != 0 && $loopCheck < 20) {
             // Max 20 levels in the page tree.
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, 'pages', 'uid=' . intval($uid) . ' AND pages.deleted=0 AND pages.doktype!=255');
             $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
             $GLOBALS['TYPO3_DB']->sql_free_result($res);
             if ($row) {
                 $sys_page->versionOL('pages', $row, FALSE, TRUE);
                 $sys_page->fixVersioningPid('pages', $row);
                 if (is_array($row)) {
                     // Mount Point page types are allowed ONLY a) if they are the outermost record in rootline and b) if the overlay flag is not set:
                     $uid = $row['pid'];
                     // Next uid
                 }
                 // Add row to rootline with language overlaid:
                 if (version_compare(TYPO3_version, '4.3', '>')) {
                     $langvisHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPageOverlay']['languagevisility'];
                     unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPageOverlay']['languagevisility']);
                     $theRowArray[] = $sys_page->getPageOverlay($row, $languageid);
                     $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPageOverlay']['languagevisility'] = $langvisHook;
                 } else {
                     $theRowArray[] = $sys_page->_original_getPageOverlay($row, $languageid);
                 }
             } else {
                 return array();
                 // broken rootline.
             }
             $loopCheck++;
         }
         // Create output array (with reversed order of numeric keys):
         $output = array();
         $c = count($theRowArray);
         foreach ($theRowArray as $key => $val) {
             $c--;
             $output[$c] = $val;
         }
         $cacheData[$uid][$languageid] = $output;
         $cacheManager->set('overlayedRootline', $cacheData);
     }
     return $cacheData[$uid][$languageid];
 }