/** * Returns the users which are in the groups with the given UIDs. * * @param string $groupUids * the UIDs of the user groups from which to get the users, must be a * comma-separated list of group UIDs, must not be empty * * @return Tx_Oelib_List<Tx_Oelib_Model_FrontEndUser> the found user models, will be empty if * no users were found for the given groups */ public function getGroupMembers($groupUids) { if ($groupUids === '') { throw new InvalidArgumentException('$groupUids must not be an empty string.', 1331488505); } return $this->getListOfModels(Tx_Oelib_Db::selectMultiple('*', $this->getTableName(), $this->getUniversalWhereClause() . ' AND ' . 'usergroup REGEXP \'(^|,)(' . implode('|', t3lib_div::intExplode(',', $groupUids)) . ')($|,)\'')); }
/** * Creates a query object working on the given class name * * @param string $className The class name * @return Tx_Extbase_Persistence_QueryInterface */ public function create($className) { $query = $this->objectManager->create('Tx_Extbase_Persistence_QueryInterface', $className); $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_Typo3QuerySettings'); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $querySettings->setStoragePageIds(t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid'])); $query->setQuerySettings($querySettings); return $query; }
/** * Explodes a comma-separated list of integer values and sorts them * numerically. * * @param string $valueList * comma-separated list of values, may be empty * * @return int[] the separate values, sorted numerically, may be empty */ private function sortExplode($valueList) { if ($valueList === '') { return array(); } $numbers = t3lib_div::intExplode(',', $valueList); sort($numbers, SORT_NUMERIC); return $numbers; }
protected function determineStoragePidForNewRecord($entity) { $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $className = \Doctrine\Common\Util\ClassUtils::getClass($object); if (isset($frameworkConfiguration['persistence']['classes'][$className]) && !empty($frameworkConfiguration['persistence']['classes'][$className]['newRecordStoragePid'])) { return (int) $frameworkConfiguration['persistence']['classes'][$className]['newRecordStoragePid']; } $storagePidList = t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid']); return (int) $storagePidList[0]; }
/** * @return Tx_Doctrine2_Query */ public function create($className) { $query = new Tx_Doctrine2_Query($className); $query->injectEntityManager($this->manager->getEntityManager()); if (!$this->objectManager || !$this->configurationManager) { return $query; } $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_QuerySettingsInterface'); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $querySettings->setStoragePageIds(t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid'])); $query->setQuerySettings($querySettings); return $query; }
/** * Main function, rendering the element browser in RTE mode. * * @return void */ function main() { // Setting alternative web browsing mounts (ONLY local to browse_links.php this script so they stay "read-only") $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints')); // Clear temporary DB mounts $tmpMount = t3lib_div::_GET('setTempDBmount'); if (isset($tmpMount)) { $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($tmpMount)); } // Set temporary DB mounts $tempDBmount = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint')); if ($tempDBmount) { $altMountPoints = $tempDBmount; } if ($altMountPoints) { $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints))); $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts(); } // Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only") $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints')); if ($altMountPoints) { $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints); foreach ($altMountPoints as $filePathRelativeToFileadmindir) { $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly'); } $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts(); } // Render type by user function $browserRendered = false; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) { $browserRenderObj = t3lib_div::getUserObj($classRef); if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) { if ($browserRenderObj->isValid($this->mode, $this)) { $this->content .= $browserRenderObj->render($this->mode, $this); $browserRendered = true; break; } } } } // If type was not rendered, use default rendering functions if (!$browserRendered) { $GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links'); $GLOBALS['SOBE']->browser->init(); $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses'); list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData); $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData); $this->content = $GLOBALS['SOBE']->browser->main_rte(); } }
/** * Generates extension site map. * * @return void */ protected function generateSitemapContent() { $selector = trim(t3lib_div::_GP('selector')); t3lib_div::loadTCA($selector); $typoscriptSelector = $selector . '.'; $currentSetup = $GLOBALS['TSFE']->tmpl->setup['plugin.']['dd_googlesitemap_dmf.'][$typoscriptSelector]; $pidList = $currentSetup['pidList'] ? t3lib_div::intExplode(',', $currentSetup['pidList']) : $this->pidList; $catList = t3lib_div::_GP('catList') ? t3lib_div::intExplode(',', t3lib_div::_GP('catList')) : t3lib_div::intExplode(',', $currentSetup['catList']); $catMMList = t3lib_div::_GP('catMMList') ? t3lib_div::intExplode(',', t3lib_div::_GP('catMMList')) : t3lib_div::intExplode(',', $currentSetup['catMMList']); $currentSetup['singlePid'] = t3lib_div::_GP('singlePid') ? intval(t3lib_div::_GP('singlePid')) : intval($currentSetup['singlePid']); $currentSetup['languageUid'] = ''; if (!$currentSetup['disableLanguageCheck']) { if (is_int($GLOBALS['TSFE']->sys_language_uid)) { // set language through TSFE checkup $currentSetup['languageUid'] = intval($GLOBALS['TSFE']->sys_language_uid); } if (t3lib_div::_GP('L')) { // overwrites if L param is set $currentSetup['languageUid'] = intval(t3lib_div::_GP('L')); } } if (count($pidList) > 0 && isset($selector) && isset($currentSetup)) { $table = $currentSetup['sqlMainTable']; $mmTable = $currentSetup['sqlMMTable']; $catColumn = $currentSetup['sqlCatColumn']; $sqlCondition = $catColumn && count($catList) > 0 && $catList[0] > 0 ? ' AND ' . $catColumn . ' IN (' . implode(',', $catList) . ')' : ''; $sqlMMCondition = $sqlMMTable = ''; if ($mmTable != '' && count($catMMList) > 0 && $catMMList[0] > 0) { $sqlMMTable = ',' . $mmTable; $sqlMMCondition = ' AND ' . $table . '.uid = ' . $mmTable . '.uid_local AND ' . $mmTable . '.uid_foreign IN (' . implode(',', $catMMList) . ')'; } $newsSelect = t3lib_div::_GP('type') == 'news' ? ',' . $currentSetup['sqlTitle'] . ',' . $currentSetup['sqlKeywords'] : ''; $languageWhere = is_int($currentSetup['languageUid']) ? ' AND ' . $table . '.sys_language_uid=' . $currentSetup['languageUid'] : ''; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,' . $currentSetup['sqlLastUpdated'] . $newsSelect, $table . $sqlMMTable, 'pid IN (' . implode(',', $pidList) . ')' . $sqlCondition . $sqlMMCondition . $this->cObj->enableFields($table) . $languageWhere, 'uid', $currentSetup['sqlOrder'] ? $currentSetup['sqlOrder'] : ''); $rowCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res); while (FALSE !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) { if ($url = $this->getVariousItemUrl($row['uid'], $currentSetup)) { $frequency = $currentSetup['frequency'] ? $currentSetup['frequency'] : $this->getChangeFrequency($row[$currentSetup['sqlLastUpdated']]); echo $this->renderer->renderEntry($url, $row[$currentSetup['sqlTitle']], $row[$currentSetup['sqlLastUpdated']], $frequency, $row[$currentSetup['sqlKeywords']]); } } $GLOBALS['TYPO3_DB']->sql_free_result($res); if ($rowCount === 0) { echo '<!-- It appears that there are no extension entries. If your ' . 'storage sysfolder is outside of the rootline, you may ' . 'want to use the dd_googlesitemap.skipRootlineCheck=1 TS ' . 'setup option. Beware: it is insecure and may cause certain ' . 'undesired effects! Better move your pid sysfolder ' . 'inside the rootline! -->'; } elseif (!$rowCount) { echo '<!-- There is an sql error. please check all corresponding sql fields in your typoscript setup. -->'; } } else { echo 'There is something wrong with the config. Please check your selector and pidList elements. You may ' . 'want to use the dd_googlesitemap.skipRootlineCheck=1 TS ' . 'setup option if your storage sysfolder is outside the rootline. Beware: it is insecure and may cause certain ' . 'undesired effects! Better move your pid sysfolder ' . 'inside the rootline! -->'; } }
/** * Returns an array of constraints created from a given demand object. * * @param Tx_Extbase_Persistence_QueryInterface $query * @param Tx_News_Domain_Model_DemandInterface $demand * @return array<Tx_Extbase_Persistence_QOM_Constrain> */ protected function createConstraintsFromDemand(Tx_Extbase_Persistence_QueryInterface $query, Tx_News_Domain_Model_DemandInterface $demand) { $constraints = array(); // Storage page if ($demand->getStoragePage() != 0) { $pidList = t3lib_div::intExplode(',', $demand->getStoragePage(), TRUE); $constraints[] = $query->in('pid', $pidList); } // Clean not used constraints foreach ($constraints as $key => $value) { if (is_null($value)) { unset($constraints[$key]); } } return $constraints; }
/** * action list * * @param Tx_WoehrlSeminare_Domain_Model_Category $category * @ignorevalidation * @return void */ public function listAction(Tx_WoehrlSeminare_Domain_Model_Category $category = NULL) { //~ t3lib_utility_Debug::debug($this->settings, 'settings... '); // take the root category of the flexform $category = $this->categoryRepository->findAllByUids(t3lib_div::intExplode(',', $this->settings['categorySelection'], TRUE))->getFirst(); //~ t3lib_utility_Debug::debug($category, 'category... '); $categories = $this->categoryRepository->findCurrentBranch($category); //~ $categories = $this->categoryRepository->findCurrentLevel($category); //~ t3lib_utility_Debug::debug($categories, 'listAction... '); if (count($categories) == 0) { // there are no further child categories --> show events $this->forward('gbList'); } else { $this->view->assign('categories', $categories); } }
/** * Find all ids from given ids and level * * @param string $pidList comma separated list of ids * @param integer $recursive recursive levels * @return string comma separated list of ids */ public static function extendPidListByChildren($pidList = '', $recursive = 0) { $recursive = (int) $recursive; if ($recursive <= 0) { return $pidList; } $queryGenerator = t3lib_div::makeInstance('t3lib_queryGenerator'); $recursiveStoragePids = $pidList; $storagePids = t3lib_div::intExplode(',', $pidList); foreach ($storagePids as $startPid) { $pids = $queryGenerator->getTreeList($startPid, $recursive, 0, 1); if (strlen($pids) > 0) { $recursiveStoragePids .= ',' . $pids; } } return $recursiveStoragePids; }
/** * Generates the options for the results per page switch. * * @return array Array of results per page switch options. */ public function getResultsPerPageOptions() { $resultsPerPageOptions = array(); $resultsPerPageSwitchOptions = t3lib_div::intExplode(',', $this->configuration['search.']['results.']['resultsPerPageSwitchOptions'], TRUE); $currentNumberOfResultsShown = $this->parentPlugin->getNumberOfResultsPerPage(); $queryLinkBuilder = t3lib_div::makeInstance('Tx_Solr_Query_LinkBuilder', $this->parentPlugin->getSearch()->getQuery()); $queryLinkBuilder->removeUnwantedUrlParameter('resultsPerPage'); $queryLinkBuilder->setLinkTargetPageId($this->parentPlugin->getLinkTargetPageId()); foreach ($resultsPerPageSwitchOptions as $option) { $selected = ''; $selectedClass = ''; if ($option == $currentNumberOfResultsShown) { $selected = ' selected="selected"'; $selectedClass = ' class="currentNumberOfResults"'; } $resultsPerPageOptions[] = array('value' => $option, 'selected' => $selected, 'selectedClass' => $selectedClass, 'url' => $queryLinkBuilder->getQueryUrl(array('resultsPerPage' => $option))); } return $resultsPerPageOptions; }
/** * Includes static template records from static_template table, loaded through a hook * * @param string A list of already processed template ids including the current; The list is on the form "[prefix]_[uid]" where [prefix] is "sys" for "sys_template" records, "static" for "static_template" records and "ext_" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion. * @param string The id of the current template. Same syntax as $idList ids, eg. "sys_123" * @param array The PID of the input template record * @param array A full TypoScript template record * @return void */ public function includeStaticTypoScriptSources(&$params, &$pObj) { // Static Template Records (static_template): include_static is a // list of static templates to include if (trim($params['row']['include_static'])) { $includeStaticArr = t3lib_div::intExplode(',', $params['row']['include_static']); // traversing list foreach ($includeStaticArr as $id) { // if $id is not already included ... if (!t3lib_div::inList($params['idList'], 'static_' . $id)) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'static_template', 'uid = ' . intval($id)); // there was a template, then we fetch that if ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $subrow = $pObj->prependStaticExtra($subrow); $pObj->processTemplate($subrow, $params['idList'] . ',static_' . $id, $params['pid'], 'static_' . $id, $params['templateId']); } $GLOBALS['TYPO3_DB']->sql_free_result($res); } } } }
/** * Returns an array of flexform pointers to all sub elements of the element specified by $table and $uid. * * @param string $table: Name of the table of the parent element ('pages' or 'tt_content') * @param integer $uid: UID of the parent element * @param array $flexformPointers: Array of flexform pointers - used internally, don't touch * @param integer $recursionDepth: Tracks the current level of recursion - used internall, don't touch. * @return array Array of flexform pointers * @access public */ function flexform_getFlexformPointersToSubElementsRecursively($table, $uid, &$flexformPointers, $recursionDepth = 0) { if (!is_array($flexformPointers)) { $flexformPointers = array(); } $parentRecord = t3lib_BEfunc::getRecordWSOL($table, $uid, 'uid,pid,tx_templavoila_flex,tx_templavoila_ds,tx_templavoila_to' . ($table == 'pages' ? ',t3ver_swapmode' : '')); $flexFieldArr = t3lib_div::xml2array($parentRecord['tx_templavoila_flex']); $expandedDataStructure = $this->ds_getExpandedDataStructure($table, $parentRecord); if (is_array($flexFieldArr['data'])) { foreach ($flexFieldArr['data'] as $sheetKey => $languagesArr) { if (is_array($languagesArr)) { foreach ($languagesArr as $languageKey => $fieldsArr) { if (is_array($fieldsArr)) { foreach ($fieldsArr as $fieldName => $valuesArr) { if (is_array($valuesArr)) { foreach ($valuesArr as $valueName => $value) { if ($expandedDataStructure[$sheetKey]['ROOT']['el'][$fieldName]['tx_templavoila']['eType'] == 'ce') { $valueItems = t3lib_div::intExplode(',', $value); if (is_array($valueItems)) { $position = 1; foreach ($valueItems as $subElementUid) { if ($subElementUid > 0) { $flexformPointers[] = array('table' => $table, 'uid' => $uid, 'sheet' => $sheetKey, 'sLang' => $languageKey, 'field' => $fieldName, 'vLang' => $valueName, 'position' => $position, 'targetCheckUid' => $subElementUid); if ($recursionDepth < 100) { $this->flexform_getFlexformPointersToSubElementsRecursively('tt_content', $subElementUid, $flexformPointers, $recursionDepth + 1); } $position++; } } } } } } } } } } } } return $flexformPointers; }
/** * Creating the module output. * * @return void */ function main() { global $LANG, $BACK_PATH, $BE_USER; if ($this->page_id) { // Get record for element: $elRow = t3lib_BEfunc::getRecordWSOL($this->table, $this->moveUid); // Headerline: Icon, record title: $hline = t3lib_iconWorks::getSpriteIconForRecord($this->table, $elRow, array('id' => "c-recIcon", 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow, $this->table)))); $hline .= t3lib_BEfunc::getRecordTitle($this->table, $elRow, TRUE); // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently): $onClick = 'window.location.href=\'' . t3lib_div::linkThisScript(array('makeCopy' => !$this->makeCopy)) . '\';'; $hline .= '<br /><input type="hidden" name="makeCopy" value="0" /><input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy">' . $LANG->getLL('makeCopy', 1) . '</label>'; // Add the header-content to the module content: $this->content .= $this->doc->section($LANG->getLL('moveElement') . ':', $hline, 0, 1); $this->content .= $this->doc->spacer(20); // Reset variable to pick up the module content in: $code = ''; // IF the table is "pages": if ((string) $this->table == 'pages') { // Get page record (if accessible): $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id, $this->perms_clause); if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'], $this->perms_clause)) { // Initialize the position map: $posMap = t3lib_div::makeInstance('ext_posMap_pages'); $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move'; // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page). if ($pageinfo['pid']) { $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'], $this->perms_clause); if (is_array($pidPageInfo)) { if ($BE_USER->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) { $code .= '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('uid' => intval($pageinfo['pid']), 'moveUid' => $this->moveUid))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-view-go-up') . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />'; } else { $code .= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />'; } } } // Create the position tree: $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI); } } // IF the table is "tt_content": if ((string) $this->table == 'tt_content') { // First, get the record: $tt_content_rec = t3lib_BEfunc::getRecord('tt_content', $this->moveUid); // ? if (!$this->input_moveUid) { $this->page_id = $tt_content_rec['pid']; } // Checking if the parent page is readable: $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id, $this->perms_clause); if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'], $this->perms_clause)) { // Initialize the position map: $posMap = t3lib_div::makeInstance('ext_posMap_tt_content'); $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move'; $posMap->cur_sys_language = $this->sys_language; // Headerline for the parent page: Icon, record title: $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages')))); $hline .= t3lib_BEfunc::getRecordTitle('pages', $pageinfo, TRUE); // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable: $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id, 'mod.SHARED'); // SHARED page-TSconfig settings. $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']), '') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3'; $colPosList = implode(',', array_unique(t3lib_div::intExplode(',', $colPosList))); // Removing duplicates, if any // Adding parent page-header and the content element columns from position-map: $code = $hline . '<br />'; $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI); // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page). $code .= '<br />'; $code .= '<br />'; if ($pageinfo['pid']) { $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'], $this->perms_clause); if (is_array($pidPageInfo)) { if ($BE_USER->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) { $code .= '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('uid' => intval($pageinfo['pid']), 'moveUid' => $this->moveUid))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-view-go-up') . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />'; } else { $code .= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />'; } } } // Create the position tree (for pages): $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI); } } // Add the $code content as a new section to the module: $this->content .= $this->doc->section($LANG->getLL('selectPositionOfElement') . ':', $code, 0, 1); } // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers['CSH'] = $docHeaderButtons['csh']; $markers['CONTENT'] = $this->content; // Build the <body> for the module $this->content = $this->doc->startPage($LANG->getLL('movingElement')); $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); }
/** * Creates an n:1 relation using a comma-separated list of UIDs. * * @param array &$data * the model data to process, will be modified * @param string $key * the key of the data item for which the relation should be created, must not be empty * @param Tx_Oelib_Model $model the model to create the relation for * * @return void */ private function createCommaSeparatedRelation(array &$data, $key, Tx_Oelib_Model $model) { /** @var Tx_Oelib_List $list */ $list = t3lib_div::makeInstance('Tx_Oelib_List'); $list->setParentModel($model); $uidList = isset($data[$key]) ? trim($data[$key]) : ''; if ($uidList !== '') { $mapper = Tx_Oelib_MapperRegistry::get($this->relations[$key]); $uids = t3lib_div::intExplode(',', $uidList); foreach ($uids as $uid) { // Some relations might have a junk 0 in it. We ignore it to avoid crashing. if ($uid === 0) { continue; } $list->add($mapper->find($uid)); } } $data[$key] = $list; }
/** * Gets the related items from a table using a 1:n relation. * * @param string $localFieldName Local table field name * @param integer $localRecordUid Local record uid * @param array $localFieldTca The local table's TCA * @param tslib_cObj $parentContentObject parent content object * @return array Array of related items, values already resolved from related records */ protected function getRelatedItemsFromForeignTable($localFieldName, $localRecordUid, array $localFieldTca, tslib_cObj $parentContentObject) { $relatedItems = array(); $foreignTableName = $localFieldTca['config']['foreign_table']; t3lib_div::loadTCA($foreignTableName); $foreignTableTca = $GLOBALS['TCA'][$foreignTableName]; $foreignTableLabelField = $this->resolveForeignTableLabelField($foreignTableTca); $whereClause = ''; if (!empty($localFieldTca['config']['foreign_field'])) { $foreignTableField = $localFieldTca['config']['foreign_field']; $whereClause = $foreignTableName . '.' . $foreignTableField . ' = ' . (int) $localRecordUid; } else { $foreignTableUids = t3lib_div::intExplode(',', $parentContentObject->data[$localFieldName]); if (count($foreignTableUids) > 1) { $whereClause = $foreignTableName . '.uid IN (' . implode(',', $foreignTableUids) . ')'; } else { $whereClause = $foreignTableName . '.uid = ' . (int) array_shift($foreignTableUids); } } $pageSelector = t3lib_div::makeInstance('t3lib_pageSelect'); $whereClause .= $pageSelector->enableFields($foreignTableName); $relatedRecordsResource = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($foreignTableName . '.*', $foreignTableName, $whereClause); foreach ($relatedRecordsResource as $relatedRecord) { $resolveRelatedValue = $this->resolveRelatedValue($relatedRecord, $foreignTableTca, $foreignTableLabelField, $parentContentObject, $foreignTableName); if (!empty($resolveRelatedValue) || !$this->configuration['removeEmptyValues']) { $relatedItems[] = $resolveRelatedValue; } } if (!empty($this->configuration['removeDuplicateValues'])) { $relatedItems = array_unique($relatedItems); } return $relatedItems; }
/** * Includes static template records (from static_template table, loaded through a hook) and static template files (from extensions) for the input template record row. * * @param string A list of already processed template ids including the current; The list is on the form "[prefix]_[uid]" where [prefix] is "sys" for "sys_template" records, "static" for "static_template" records and "ext_" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion. * @param string The id of the current template. Same syntax as $idList ids, eg. "sys_123" * @param array The PID of the input template record * @param array A full TypoScript template record * @return void * @see processTemplate() */ function includeStaticTypoScriptSources($idList, $templateID, $pid, $row) { // Static Template Records (static_template): include_static is a list of static templates to include // Call function for link rendering: if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSources'])) { $_params = array('idList' => &$idList, 'templateId' => &$templateID, 'pid' => &$pid, 'row' => &$row); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSources'] as $_funcRef) { t3lib_div::callUserFunction($_funcRef, $_params, $this); } } // Static Template Files (Text files from extensions): include_static_file is a list of static files to include (from extensions) if (trim($row['include_static_file'])) { $include_static_fileArr = t3lib_div::trimExplode(',', $row['include_static_file'], true); foreach ($include_static_fileArr as $ISF_file) { // traversing list if (substr($ISF_file, 0, 4) == 'EXT:') { list($ISF_extKey, $ISF_localPath) = explode('/', substr($ISF_file, 4), 2); if (strcmp($ISF_extKey, '') && t3lib_extMgm::isLoaded($ISF_extKey) && strcmp($ISF_localPath, '')) { $ISF_localPath = rtrim($ISF_localPath, '/') . '/'; $ISF_filePath = t3lib_extMgm::extPath($ISF_extKey) . $ISF_localPath; if (@is_dir($ISF_filePath)) { $mExtKey = str_replace('_', '', $ISF_extKey . '/' . $ISF_localPath); $subrow = array('constants' => @is_file($ISF_filePath . 'constants.txt') ? t3lib_div::getUrl($ISF_filePath . 'constants.txt') : '', 'config' => @is_file($ISF_filePath . 'setup.txt') ? t3lib_div::getUrl($ISF_filePath . 'setup.txt') : '', 'editorcfg' => @is_file($ISF_filePath . 'editorcfg.txt') ? t3lib_div::getUrl($ISF_filePath . 'editorcfg.txt') : '', 'include_static' => @is_file($ISF_filePath . 'include_static.txt') ? implode(',', array_unique(t3lib_div::intExplode(',', t3lib_div::getUrl($ISF_filePath . 'include_static.txt')))) : '', 'include_static_file' => @is_file($ISF_filePath . 'include_static_file.txt') ? implode(',', array_unique(explode(',', t3lib_div::getUrl($ISF_filePath . 'include_static_file.txt')))) : '', 'title' => $ISF_file, 'uid' => $mExtKey); $subrow = $this->prependStaticExtra($subrow); $this->processTemplate($subrow, $idList . ',ext_' . $mExtKey, $pid, 'ext_' . $mExtKey, $templateID); } } } } } $this->addExtensionStatics($idList, $templateID, $pid, $row); // Include Static Template Records after all other TypoScript has been included. if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSourcesAtEnd'])) { $_params = array('idList' => &$idList, 'templateId' => &$templateID, 'pid' => &$pid, 'row' => &$row); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSourcesAtEnd'] as $_funcRef) { t3lib_div::callUserFunction($_funcRef, $_params, $this); } } }
/** * Creating unique menu id string plus other initialization of internal variables (all prefixed "WM") * * @return void */ function extProc_init() { $this->WMid = trim($this->mconf['layer_menu_id']) ? trim($this->mconf['layer_menu_id']) . 'x' : substr(md5(microtime()), 0, 6); // NO '_' (underscore) in the ID!!! NN4 breaks! $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'][] = $this->WMid; $this->WMtempStore = $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']; $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array(); // Save: $this->WMonlyOnLoad = $this->mconf['displayActiveOnLoad'] && !$this->mconf['displayActiveOnLoad.']['onlyOnLoad']; $this->WMbordersWithin = t3lib_div::intExplode(',', $this->mconf['bordersWithin'] . ',0,0,0,0,0'); }
/** * Wrapping internal vars ->tm, ->lm, ->rm, ->bm and ->content in a table where each content part is stored in a cell. * The two arguments to this function defines some offsets and margins to use in the arrangement of the content in the table. * * @param string List of offset parameters; x,y * @param string List of margin parameters; left, top, right, bottom * @return string The content strings wrapped in a <table> as the parameters defined * @see tslib_cObj::CTABLE() */ function start($offset, $cMargins) { $offArr = t3lib_div::intExplode(',', $offset); $cMargArr = t3lib_div::intExplode(',', $cMargins); $cols = 0; $rows = 0; if ($this->lm) { $cols++; } if ($this->rm) { $cols++; } if ($cMargArr[0]) { $cols++; } if ($cMargArr[2]) { $cols++; } if ($cMargArr[1] || $cMargArr[3] || $this->tm || $this->bm || $this->content || $this->contentW) { $cols++; } if ($cMargArr[1]) { $rows++; } if ($cMargArr[3]) { $rows++; } if ($this->tm) { $rows++; } if ($this->bm) { $rows++; } if ($this->content) { $rows++; } if ($this->contentW) { $rows++; } if (!$rows && $cols) { $rows = 1; } // If there are no rows in the middle but still som columns... if ($rows && $cols) { $res = LF . '<table ' . $this->tableParams . '>'; // top offset: if ($offArr[1]) { $xoff = $offArr[0] ? 1 : 0; if ($cols + $xoff > 1) { $colspan = ' colspan="' . ($cols + $xoff) . '"'; } $res .= '<tr><td' . $colspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $offArr[1] . '" alt="" title="" /></td></tr>'; } // The rows: if ($rows > 1) { $rowspan = ' rowspan="' . $rows . '"'; } $res .= '<tr>'; if ($offArr[0]) { $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" height="1" width="' . $offArr[0] . '" alt="" title="" /></td>'; } if ($this->lm) { $res .= '<td' . $rowspan . ' ' . $this->lmTDparams . '>' . $this->lm . '</td>'; } if ($cMargArr[0]) { $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" height="1" width="' . $cMargArr[0] . '" alt="" title="" /></td>'; } // content... $middle = array(); if ($this->tm) { $middle[] = '<td ' . $this->tmTDparams . '>' . $this->tm . '</td>'; } if ($cMargArr[1]) { $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $cMargArr[1] . '" alt="" title="" /></td>'; } if ($this->content) { $middle[] = '<td ' . $this->contentTDparams . '>' . $this->content . '</td>'; } if ($cMargArr[3]) { $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $cMargArr[3] . '" alt="" title="" /></td>'; } if ($this->bm) { $middle[] = '<td ' . $this->bmTDparams . '>' . $this->bm . '</td>'; } if ($this->contentW) { $middle[] = '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" height="1" width="' . $this->contentW . '" alt="" title="" /></td>'; } if (isset($middle[0])) { $res .= $middle[0]; } // Left of content if ($cMargArr[2]) { $res .= '<td' . $rowspan . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" height="1" width="' . $cMargArr[2] . '" alt="" title="" /></td>'; } if ($this->rm) { $res .= '<td' . $rowspan . ' ' . $this->rmTDparams . '>' . $this->rm . '</td>'; } $res .= '</tr>'; // More than the two rows $mCount = count($middle); for ($a = 1; $a < $mCount; $a++) { $res .= '<tr>' . $middle[$a] . '</tr>'; } $res .= '</table>'; return $res; } }
/** * Tree rendering * * @param integer PID value * @param string Additional where clause * @return array Array of tree elements */ function ext_tree($pid, $clause = '') { // Initialize: $this->init(' AND ' . $this->permsC() . $clause); // Get stored tree structure: $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']); // PM action: $PM = t3lib_div::intExplode('_', t3lib_div::_GP('PM')); // traverse mounts: $titleLen = intval($this->BE_USER->uc['titleLen']); $treeArr = array(); $idx = 0; // Set first: $this->bank = $idx; $isOpen = $this->stored[$idx][$pid] || $this->expandFirst; $curIds = $this->ids; // save ids $this->reset(); $this->ids = $curIds; // Set PM icon: $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $pid; $icon = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif', 'width="18" height="16"') . ' align="top" alt="" />'; $firstHtml = $this->PM_ATagWrap($icon, $cmd); if ($pid > 0) { $rootRec = t3lib_befunc::getRecordWSOL('pages', $pid); $firstHtml .= $this->wrapIcon(t3lib_iconWorks::getSpriteIconForRecord('pages', $rootRec), $rootRec); } else { $rootRec = array('title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], 'uid' => 0); $firstHtml .= $this->wrapIcon('<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif', 'width="18" height="16"') . ' align="top" alt="" />', $rootRec); } $this->tree[] = array('HTML' => $firstHtml, 'row' => $rootRec); if ($isOpen) { // Set depth: $depthD = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />'; if ($this->addSelfId) { $this->ids[] = $pid; } $this->getTree($pid, 999, $depthD); $idH = array(); $idH[$pid]['uid'] = $pid; if (count($this->buffer_idH)) { $idH[$pid]['subrow'] = $this->buffer_idH; } $this->buffer_idH = $idH; } // Add tree: $treeArr = array_merge($treeArr, $this->tree); return $treeArr; }
/** * Gets the value stored under the key $key, converted to an array of * integers. * * @param string $key the key of the element to retrieve, must not be empty * * @return int[] the array value of the given key, may be empty */ protected function getAsIntegerArray($key) { $stringValue = $this->getAsString($key); if ($stringValue === '') { return array(); } return t3lib_div::intExplode(',', $stringValue); }
/** * Returns the number of results per Page. * * @return int number of results to show per page */ public function getNumberOfResultsPerPage() { $configuration = tx_solr_Util::getSolrConfiguration(); $resultsPerPageSwitchOptions = t3lib_div::intExplode(',', $configuration['search.']['results.']['resultsPerPageSwitchOptions']); $solrParameters = array(); $solrPostParameters = t3lib_div::_POST('tx_solr'); $solrGetParameters = t3lib_div::_GET('tx_solr'); // check for GET parameters, POST takes precedence if (isset($solrGetParameters) && is_array($solrGetParameters)) { $solrParameters = $solrGetParameters; } if (isset($solrPostParameters) && is_array($solrPostParameters)) { $solrParameters = $solrPostParameters; } if (isset($solrParameters['resultsPerPage']) && in_array($solrParameters['resultsPerPage'], $resultsPerPageSwitchOptions)) { $GLOBALS['TSFE']->fe_user->setKey('ses', 'tx_solr_resultsPerPage', intval($solrParameters['resultsPerPage'])); $this->resultsPerPageChanged = TRUE; } $defaultNumberOfResultsShown = $configuration['search.']['results.']['resultsPerPage']; $userSetNumberOfResultsShown = $GLOBALS['TSFE']->fe_user->getKey('ses', 'tx_solr_resultsPerPage'); $currentNumberOfResultsShown = $defaultNumberOfResultsShown; if (!is_null($userSetNumberOfResultsShown) && in_array($userSetNumberOfResultsShown, $resultsPerPageSwitchOptions)) { $currentNumberOfResultsShown = (int) $userSetNumberOfResultsShown; } if ($this->conf['search.']['allowEmptyQuery'] && empty($this->piVars['q'])) { // set number of rows to return to 0 $currentNumberOfResultsShown = 0; } return $currentNumberOfResultsShown; }
/** * * * @return array */ function main() { global $TYPO3_DB; // Initialize result array: $resultArray = array('message' => $this->cli_help['name'] . chr(10) . chr(10) . $this->cli_help['description'], 'headers' => array('all_unused' => array('List of all unused content elements', 'All elements means elements which are not used on that specific page. However, they could be referenced from another record. That is indicated by index "1" which is the number of references leading to the element.', 1), 'deleteMe' => array('List of elements that can be deleted', 'This is all elements which had no references to them and hence should be OK to delete right away.', 2)), 'all_unused' => array(), 'deleteMe' => array()); $startingPoint = $this->cli_isArg('--pid') ? t3lib_div::intInRange($this->cli_argValue('--pid'), 0) : 0; $depth = $this->cli_isArg('--depth') ? t3lib_div::intInRange($this->cli_argValue('--depth'), 0) : 1000; $this->excludePageIdList = $this->cli_isArg('--excludePageIdList') ? t3lib_div::intExplode(',', $this->cli_argValue('--excludePageIdList')) : array(); $this->resultArray =& $resultArray; $this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'), 'main_parseTreeCallBack'); ksort($resultArray['all_unused']); ksort($resultArray['deleteMe']); return $resultArray; }
/** * gets the addresses which meet the group selection * * @return array array of addresses with their uids as array keys */ function getRecordsFromGroups() { $groupRecords = array(); // similar to t3lib_db::cleanIntList(), but we need the count for AND combination $groups = t3lib_div::intExplode(',', $this->conf['groupSelection']); $count = count($groups); $groupList = implode(',', $groups); if (!empty($groupList) && !empty($this->conf['pidList'])) { if ($this->conf['combination'] == 'AND') { // AND $res = $GLOBALS['TYPO3_DB']->sql_query('SELECT tt_address.*, COUNT(tt_address.uid) AS c ' . 'FROM tt_address ' . 'JOIN tt_address_group_mm AS tta_txagg_mm ON tt_address.uid = tta_txagg_mm.uid_local ' . 'JOIN tt_address_group AS txagg ON txagg.uid = tta_txagg_mm.uid_foreign ' . 'WHERE uid_foreign IN (' . $groupList . ') ' . $this->cObj->enableFields('tt_address') . ' AND tt_address.pid IN(' . $this->conf['pidList'] . ') ' . 'GROUP BY tt_address.uid ' . 'HAVING c = ' . $count . ' '); } elseif ($this->conf['combination'] == 'OR') { // OR $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT tt_address.*', 'tt_address, tt_address_group_mm, tt_address_group', 'tt_address_group_mm.uid_foreign IN(' . $groupList . ') AND tt_address.uid = tt_address_group_mm.uid_local ' . $this->cObj->enableFields('tt_address') . ' AND tt_address.pid IN(' . $this->conf['pidList'] . ')'); } while ($address = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $groupRecords[$address['uid']] = $this->getGroupsForAddress($address); } } return $groupRecords; }
/** * Fetches subgroups of groups. Function is called recursively for each subgroup. * Function was previously copied from t3lib_userAuthGroup->fetchGroups and has been slightly modified. * * @param string Commalist of fe_groups uid numbers * @param string List of already processed fe_groups-uids so the function will not fall into a eternal recursion. * @return array * @access private */ function getSubGroups($grList, $idList = '', &$groups) { // Fetching records of the groups in $grList (which are not blocked by lockedToDomain either): $lockToDomain_SQL = ' AND (lockToDomain=\'\' OR lockToDomain IS NULL OR lockToDomain=\'' . $this->authInfo['HTTP_HOST'] . '\')'; if (!$this->authInfo['showHiddenRecords']) { $hiddenP = 'AND hidden=0 '; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,subgroup', 'fe_groups', 'deleted=0 ' . $hiddenP . ' AND uid IN (' . $grList . ')' . $lockToDomain_SQL); $groupRows = array(); // Internal group record storage // The groups array is filled while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { if (!in_array($row['uid'], $groups)) { $groups[] = $row['uid']; } $groupRows[$row['uid']] = $row; } // Traversing records in the correct order $include_staticArr = t3lib_div::intExplode(',', $grList); foreach ($include_staticArr as $uid) { // traversing list // Get row: $row = $groupRows[$uid]; if (is_array($row) && !t3lib_div::inList($idList, $uid)) { // Must be an array and $uid should not be in the idList, because then it is somewhere previously in the grouplist // Include sub groups if (trim($row['subgroup'])) { $theList = implode(',', t3lib_div::intExplode(',', $row['subgroup'])); // Make integer list $this->getSubGroups($theList, $idList . ',' . $uid, $groups); // Call recursively, pass along list of already processed groups so they are not recursed again. } } } }
/** * combine group access restrictons from page(s) and content element * * @param string $feGroupsPages comma list * @param string $feGroupsContentElement comma list * @return type * @author Christian Bülter <*****@*****.**> * @since 26.09.13 */ public function getCombinedFeGroupsForContentElement($feGroupsPages, $feGroupsContentElement) { // combine frontend groups from page(s) and content elemenet as follows // 1. if page has no groups, but ce has groups, use ce groups // 2. if ce has no groups, but page has grooups, use page groups // 3. if page has "show at any login" (-2) and ce has groups, use ce groups // 4. if ce has "show at any login" (-2) and page has groups, use page groups // 5. if page and ce have explicit groups (not "hide at login" (-1), merge them (use only groups both have) // 6. if page or ce has "hide at login" and the other // has an expclicit group the element will never be shown and we must not index it. // So which group do we set here? Let's use a constant for that and check in the calling function for that. if (!$feGroupsPages && $feGroupsContentElement) { $feGroups = $feGroupsContentElement; } if ($feGroupsPages && !$feGroupsContentElement) { $feGroups = $feGroupsPages; } if ($feGroupsPages == '-2' && $feGroupsContentElement) { $feGroups = $feGroupsContentElement; } if ($feGroupsPages && $feGroupsContentElement == '-2') { $feGroups = $feGroupsPages; } if ($feGroupsPages && $feGroupsContentElement && $feGroupsPages != '-1' && $feGroupsContentElement != '-1') { if (TYPO3_VERSION_INTEGER >= 7000000) { $feGroupsContentElementArray = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $feGroupsContentElement); $feGroupsPagesArray = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $feGroupsPages); } else { $feGroupsContentElementArray = t3lib_div::intExplode(',', $feGroupsContentElement); $feGroupsPagesArray = t3lib_div::intExplode(',', $feGroupsPages); } $feGroups = implode(',', array_intersect($feGroupsContentElementArray, $feGroupsContentElementArray)); } if ($feGroupsContentElement && $feGroupsContentElement != '-1' && $feGroupsContentElement != -2 && $feGroupsPages == '-1' || $feGroupsPages && $feGroupsPages != '-1' && $feGroupsPages != -2 && $feGroupsContentElement == '-1') { $feGroups = DONOTINDEX; } return $feGroups; }
/** * @return array */ function main() { global $TYPO3_DB; // Initialize result array: $resultArray = array('message' => $this->cli_help['name'] . chr(10) . chr(10) . $this->cli_help['description'], 'headers' => array('index' => array('Full index of translation', 'NEEDS MUCH MORE WORK....', 1)), 'index' => array()); $startingPoints = t3lib_div::intExplode(',', $this->cli_argValue('--pid')); $workspaceID = $this->cli_isArg('--workspace') ? t3lib_div::intInRange($this->cli_argValue('--workspace'), -1) : 0; $depth = $this->cli_isArg('--depth') ? t3lib_div::intInRange($this->cli_argValue('--depth'), 0) : 1000; if ($workspaceID != 0) { $GLOBALS['BE_USER']->setWorkspace($workspaceID); if ($GLOBALS['BE_USER']->workspace != $workspaceID) { die('Workspace ' . $workspaceID . ' did not exist!' . chr(10)); } } $this->resultArray =& $resultArray; foreach ($startingPoints as $pidPoint) { if ($pidPoint >= 0) { $this->genTree($pidPoint, $depth, (int) $this->cli_argValue('--echotree'), 'main_parseTreeCallBack'); } } return $resultArray; }
/** * The Main Function * * Loads and sets global configuration and calls singleView or showWiki to display * the whole wiki or a single Version * * @param [type] $content: ... * @param [type] $conf: ... * @return [type] ... */ function main($content, $conf) { // Configuring so caching is not expected. This value means that no cHash // params are ever set. We do this, because it's a USER_INT object! $this->pi_USER_INT_obj = 1; // Local cObj. $this->local_cObj = t3lib_div::makeInstance('tslib_cObj'); // Disable Caching $GLOBALS["TSFE"]->set_no_cache(); // uncomment to enable debug-output of failed queries $GLOBALS['TYPO3_DB']->debugOutput = FALSE; // Initialise plug-in array $myPluginArray = new tx_drwiki_pi1_plugin(); // Initialise Index List formatting object $this->indexListFormatter = new tx_drwiki_pi1_indexListFormatter(); // Load language and initialise local language settings $this->pi_loadLL(); // get configuration from TYPO3 TCA/Flexform and initialise extension $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_initPIflexForm(); // Init and get the flexform data of the plugin $this->sanitizer = new html_sanitizer(); //initialte HTML sanitizer //TODO: Add to configuration $this->sanitizer->addAllowedTags($this->allowedHTML); $this->sanitizer->addAdditionalTags($this->allowedWIKI); $this->sanitizer->allowStyle(); // get rid of XSS exploits by sanitising the piVars // tx_drwiki_pi1[keyword]=<script>alert("doh")</script> and // tx_drwiki_pi1[key"><SCRIPT%3Ealert("XSS")</SCRIPT>word]=HomePage $this->piVars = $this->sanitizeValues($this->piVars); // Assign the flexform data to a local variable for easier access $piFlexForm = $this->cObj->data['pi_flexform']; // Traverse the entire array based on the language... // and assign each configuration option to $this->ffConf array... if ($piFlexForm) { foreach ($piFlexForm['data'] as $sheet => $data) { foreach ($data as $lang => $value) { foreach ($value as $key => $val) { $this->ffConf[$key] = $this->pi_getFFvalue($piFlexForm, $key, $sheet); } } } } // Merge TS and FlexForm values // Priority goes to the FlexForms values! $this->minHeaderCount = $this->ffConf["minHeaderCount"] ? $this->ffConf["minHeaderCount"] : $conf['toc.']['minHeaderCount']; $this->maxTocLevel = $this->ffConf["maxTocLevel"] ? $this->ffConf["maxTocLevel"] : $conf['toc.']['maxTocLevel']; $this->enableWikiCaching = $this->ffConf["disableWikiCaching"] ? false : true; $this->doNumberHeadings = $this->ffConf["disableDoNumberHeadings"] ? false : true; $this->doShowToc = $this->ffConf["disable_toc"] ? false : true; $this->read_only = $this->ffConf["read_only"] ? true : false; $this->extLinkTarget = $this->ffConf["extLinkTarget"] ? $this->ffConf["extLinkTarget"] : "_blank"; $this->turnOffImageLink = $this->ffConf["turnOffImageLink"] ? true : false; // Template insertion $this->initialPageText1Name = $this->ffConf["initialPageText1Name"] ? $this->ffConf["initialPageText1Name"] : "Template 1"; $this->initialPageText1 = $this->ffConf["initialPageText1"] ? $this->ffConf["initialPageText1"] : "no template defined"; $this->initialPageText1 = addcslashes($this->initialPageText1, "\n,\\',\""); $this->initialPageText2Name = $this->ffConf["initialPageText2Name"] ? $this->ffConf["initialPageText2Name"] : "Template 2"; $this->initialPageText2 = $this->ffConf["initialPageText2"] ? $this->ffConf["initialPageText2"] : "no template defined"; $this->initialPageText2 = addcslashes($this->initialPageText2, "\n,\\',\""); $this->initialPageText3Name = $this->ffConf["initialPageText3Name"] ? $this->ffConf["initialPageText3Name"] : "Template 3"; $this->initialPageText3 = $this->ffConf["initialPageText3"] ? $this->ffConf["initialPageText3"] : "no template defined"; $this->initialPageText3 = addcslashes($this->initialPageText3, "\n,\\',\""); $this->activateInitialPageText = $this->ffConf["activateInitialPageText"] ? true : false; // Footer an Header $this->wikiHeader = $this->ffConf["wikiHeader"] ? $this->ffConf["wikiHeader"] : ""; $this->wikiFooter = $this->ffConf["wikiFooter"] ? $this->ffConf["wikiFooter"] : ""; //add mail stuff mailHideItem $this->mailNotify = $this->ffConf["mailNotify"] ? true : false; $this->mailHideItem = $this->ffConf["mailHideItem"] ? false : true; $this->mailRecipient = $this->ffConf["mailRecipient"] ? $this->ffConf["mailRecipient"] : ""; $this->mailFromEmail = $this->ffConf["mailFromEmail"] ? $this->ffConf["mailFromEmail"] : ""; $this->mailFromName = $this->ffConf["mailFromName"] ? $this->ffConf["mailFromName"] : ""; $this->mailSubject = $this->ffConf["mailSubject"] ? $this->ffConf["mailSubject"] : ""; // Editor Config $this->numberRows = $this->ffConf["numberRows"] ? $this->ffConf["numberRows"] : $conf['editorConfig.']['numberRows']; $this->numberColumns = $this->ffConf["numberColumns"] ? $this->ffConf["numberColumns"] : $conf['editorConfig.']['numberColumns']; $this->wrapLinesOn = $this->ffConf["wrapLinesOn"] ? "on" : "off"; $this->charSummary = $this->ffConf["charSummary"] ? $this->ffConf["charSummary"] : $conf['editorConfig.']['charSummary']; // Settings for Write Access control. Replaces older "Redirect settings". // The admin can decide who can write to the WIKI. // The user gets redirected to $this->pageRedirect $this->activateAccessControl = $this->ffConf["activateAccessControl"] ? $this->ffConf["activateAccessControl"] : false; $this->allowedGroups = $this->ffConf["allowedGroups"] ? $this->ffConf["allowedGroups"] : false; $this->disallowedGroups = $this->ffConf["disallowedGroups"] ? $this->ffConf["disallowedGroups"] : false; $this->pageRedirect = $this->ffConf["pageRedirect"] ? $this->ffConf["pageRedirect"] : false; $this->adminUserGroup = $this->ffConf["adminUserGroup"] ? $this->ffConf["adminUserGroup"] : false; // Initialise extension template: Use std template if no FlexForm template is set: $this->templateCode = $this->ffConf["templatefile"] ? $this->cObj->fileResource("uploads/tx_drwiki/" . $this->ffConf["templatefile"]) : $this->cObj->fileResource($this->conf["templateFile"]); // Set HomePage / KeyWord $this->wikiHomePage = $this->ffConf["setHomePage"] ? $this->ffConf["setHomePage"] : $this->wikiHomePage; // Set site-path for images $this->sitePath = t3lib_extMgm::siteRelPath('dr_wiki'); // load allowedHTML $this->allowedHTML = $this->allowedHTML ? $this->allowedHTML : $this->cObj->stdWrap($this->conf["allowedHTML"], $this->conf["allowedHTML."]); // Global content-replaces list($globalMarkerArray["###GW1B###"], $globalMarkerArray["###GW1E###"]) = explode("|", $this->conf["wrap1"]); list($globalMarkerArray["###GW2B###"], $globalMarkerArray["###GW2E###"]) = explode("|", $this->conf["wrap2"]); list($globalMarkerArray["###GW3B###"], $globalMarkerArray["###GW3E###"]) = explode("|", $this->conf["wrap3"]); $globalMarkerArray["###GC1###"] = $this->cObj->stdWrap($this->conf["color1"], $this->conf["color1."]); $globalMarkerArray["###GC2###"] = $this->cObj->stdWrap($this->conf["color2"], $this->conf["color2."]); $globalMarkerArray["###GC3###"] = $this->cObj->stdWrap($this->conf["color3"], $this->conf["color3."]); // Load templatecode $this->templateCode = $this->cObj->substituteMarkerArrayCached($this->templateCode, $globalMarkerArray); // Not nice, but functional :-) Loads the plugin-array // from the global variable $pluginArray defined in plugins/plugincfg.php $this->pluginArray = $myPluginArray->getPlugIns(); $this->pluginList = $myPluginArray->getPluginString(); // Load the ratings API if enabled if (t3lib_extMgm::isLoaded('ratings')) { $this->ratingsApiObj = t3lib_div::makeInstance('tx_ratings_api'); } // include srfreecap if (t3lib_extMgm::isLoaded('sr_freecap')) { require_once t3lib_extMgm::extPath('sr_freecap') . 'pi2/class.tx_srfreecap_pi2.php'; $this->freeCap = t3lib_div::makeInstance('tx_srfreecap_pi2'); } switch ((string) $conf["CMD"]) { case "singleView": // displays a single version list($t) = explode(":", $this->cObj->currentRecord); $this->internal["currentTable"] = $t; $this->internal["currentRow"] = $this->cObj->data; return $this->pi_wrapInBaseClass($this->singleView($content, $conf)); break; default: // displays the wiki und stores records under the PID defined in the pages-field if (strstr($this->cObj->currentRecord, "tt_content")) { // Get Page ID - now without explicitly setting it ;-) $this->conf["pidList"] = $this->ffConf["pages"]; $this->conf["pidList"] = $this->conf["pidList"] ? implode(t3lib_div::intExplode(",", $this->conf["pidList"]), ",") : $GLOBALS["TSFE"]->id; $this->conf["recursive"] = $this->ffConf["recursive"]; list($pid) = explode(",", $this->conf["pidList"]); $this->storagePid = $pid; } return $this->pi_wrapInBaseClass($this->showWiki($content, $conf)); break; } }
/** * extends the pid_list given from $conf or FF recursively by the pids of the subpages * generates an array from the pagetitles of those pages * * @return void */ function initPidList() { // pid_list is the pid/list of pids from where to fetch the news items. $pid_list = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'pages', 's_misc'); $pid_list = $pid_list ? $pid_list : trim($this->cObj->stdWrap($this->conf['pid_list'], $this->conf['pid_list.'])); $pid_list = $pid_list ? implode(t3lib_div::intExplode(',', $pid_list), ',') : $this->tsfe->id; $recursive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'recursive', 's_misc'); if (!strcmp($recursive, '') || $recursive === NULL) { $recursive = $this->cObj->stdWrap($this->conf['recursive'], $this->conf['recursive.']); } // extend the pid_list by recursive levels $this->pid_list = $this->pi_getPidList($pid_list, $recursive); $this->pid_list = $this->pid_list ? $this->pid_list : 0; if (!$this->pid_list) { $this->errors[] = 'No pid_list defined'; } }
/** * [Describe function...] * * @param [type] $cmd: ... * @return [type] ... */ function renderCatTree($calledFromAjax = false) { // $tStart = microtime(true); // $this->debug['start'] = time(); if (substr($this->table, 0, 3) != 'be_') { // ignore useStoragePid if table is be_user/groups. if ($this->confArr['useStoragePid']) { if ($this->storagePidFromAjax) { $this->storagePid = $this->storagePidFromAjax; } else { $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, $this->row); $this->storagePid = $TSconfig['_STORAGE_PID'] ? $TSconfig['_STORAGE_PID'] : intval($this->row['pid']); } $SPaddWhere = ' AND tt_news_cat.pid IN (' . $this->storagePid . ')'; if ($this->table == 'tt_news_cat' && intval($this->row['pid']) > 0 && $this->row['pid'] != $this->storagePid) { $msg = $this->printMsg('notInGRSP', 'warning2'); $notInGRSP = true; } } $catlistWhere = tx_ttnews_div::getCatlistWhere(); if ($catlistWhere) { $this->getNotAllowedItems($SPaddWhere); } } $treeOrderBy = $this->confArr['treeOrderBy'] ? $this->confArr['treeOrderBy'] : 'uid'; // instantiate tree object $treeViewObj = t3lib_div::makeInstance('tx_ttnews_tceforms_categorytree'); $treeViewObj->treeName = $this->table . '_tree'; $treeViewObj->table = 'tt_news_cat'; $treeViewObj->tceFormsTable = $this->table; $treeViewObj->tceFormsRecID = $this->recID; $treeViewObj->storagePid = $this->storagePid; $treeViewObj->useStoragePid = $this->confArr['useStoragePid']; $treeViewObj->init($SPaddWhere . $catlistWhere, $treeOrderBy); $treeViewObj->backPath = $GLOBALS['BACK_PATH']; $treeViewObj->thisScript = 'class.tx_ttnews_tceformsSelectTree.php'; $treeViewObj->fieldArray = array('uid', 'title', 'description', 'hidden', 'starttime', 'endtime', 'fe_group'); // those fields will be filled to the array $treeViewObj->tree $treeViewObj->parentField = 'parent_category'; $treeViewObj->expandable = $this->useAjax; $treeViewObj->expandAll = !$this->useAjax; $treeViewObj->useAjax = $this->useAjax; $treeViewObj->titleLen = 60; $treeViewObj->disableAll = $notInGRSP; $treeViewObj->ext_IconMode = '1'; // no context menu on icons $treeViewObj->title = $GLOBALS['LANG']->sL('LLL:EXT:tt_news/locallang_tca.xml:tt_news.treeSelect.treeTitle'); $treeViewObj->TCEforms_itemFormElName = $this->PA['itemFormElName']; if ($this->table == 'tt_news_cat') { $treeViewObj->TCEforms_nonSelectableItemsArray[] = $this->row['uid']; } /** * FIXME * making categories not-selectable with tt_newsPerms.tt_news_cat.allowedItems doesn't work anymore */ // if (tx_ttnews_div::useAllowedCategories() && !tx_ttnews_div::allowedItemsFromTreeSelector) { // // 'options.useListOfAllowedItems' is set but no category is selected --> check the 'allowedItems' list // $notAllowedItems = $this->getNotAllowedItems($SPaddWhere); // } // if (is_array($notAllowedItems) && $notAllowedItems[0]) { // foreach ($notAllowedItems as $k) { // $treeViewObj->TCEforms_nonSelectableItemsArray[] = $k; // } // } $sPageIcon = ''; // mark selected categories $treeViewObj->TCEforms_selectedItemsArray = $this->selectedItems; $treeViewObj->selectedItemsArrayParents = $this->getCatRootline($SPaddWhere); if (substr($this->table, 0, 3) == 'be_') { // if table is 'be_users' or 'be_groups' group the categories by folder. 'useStoragePid' is ignored $cf = $this->getCategoryFolders($SPaddWhere . $catlistWhere); /** * FIXME: * currently 'expandFirst' is required to prevent js errors when expanding/collapsing the tree * the problems are caused by multiple "root" records with uid=0 */ $treeViewObj->expandFirst = 1; $treeViewObj->MOUNTS = $cf; $groupByPages = TRUE; } else { if ($this->storagePid > 0) { $addWhere = ' AND pid=' . $this->storagePid; } else { // useStoragePid=0 and table != beusers/groups $addWhere = ''; } // get selected categories from be user/group without subcategories $tmpsc = tx_ttnews_div::getBeUserCatMounts(FALSE); $beUserSelCatArr = t3lib_div::intExplode(',', $tmpsc); $includeListArr = tx_ttnews_div::getIncludeCatArray(); $subcatArr = array_diff($includeListArr, $beUserSelCatArr); // get all selected category records from the current storagePid which are not 'root' categories // and add them as tree mounts. Subcategories of selected categories will be excluded. $cMounts = array(); $nonRootMounts = FALSE; foreach ($beUserSelCatArr as $catID) { $tmpR = t3lib_BEfunc::getRecord('tt_news_cat', $catID, 'parent_category,hidden', $addWhere); if (is_array($tmpR) && !in_array($catID, $subcatArr)) { if ($tmpR['parent_category'] > 0) { $nonRootMounts = TRUE; if (!$calledFromAjax) { $sPageIcon = $this->getStoragePageIcon($treeViewObj); } } $cMounts[] = $catID; } } if ($nonRootMounts) { $treeViewObj->MOUNTS = $cMounts; } } // render tree html $treeContent = $sPageIcon . $treeViewObj->getBrowsableTree($groupByPages); $this->treeObj_ajaxStatus = $treeViewObj->ajaxStatus; // if (count($treeViewObj->ids) == 0) { // $msg .= str_replace('###PID###',$this->storagePid,$this->printMsg('emptyTree','note')); // $treeContent = ''; // } return $msg . $treeContent; }