本文整理汇总了PHP中t3lib_div::uniqueList方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::uniqueList方法的具体用法?PHP t3lib_div::uniqueList怎么用?PHP t3lib_div::uniqueList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::uniqueList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchTitle_searchPid
/**
* 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);
//.........这里部分代码省略.........
示例2: getTtContentRecordsWithT3sPlugin
/**
* 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();
}
示例3: storeInIndex
/**
* 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();
}
}
}
示例4: workspaceInit
/**
* 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']);
}
}
示例5: listView
//.........这里部分代码省略.........
$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();"');
示例6: uniqueList
/**
* @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);
}
示例7: getRootLine
/**
* 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';
//.........这里部分代码省略.........
示例8: addOtherLabelsList
public function addOtherLabelsList($otherLabelsList)
{
if ($otherLabelsList != '') {
$formerOtherLabelsList = $this->getOtherLabelsList();
if ($formerOtherLabelsList != '') {
$newOtherLabelsList = $formerOtherLabelsList . ',' . $otherLabelsList;
$newOtherLabelsList = t3lib_div::uniqueList($newOtherLabelsList);
$this->setOtherLabelsList($newOtherLabelsList);
}
}
}
示例9: getRootLine
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;
}
示例10: getRecordWSOL
/**
* 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;
}
示例11: workspaceInit
/**
* 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']);
}
}
示例12: filelist
/**
* 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);
}
}
}
}
示例13: getIgnoredExtensionList
/**
* 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;
}
示例14: getPageContent
/**
* 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
//.........这里部分代码省略.........
示例15: init
/**
* 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;
}