/** * Fetch available page overlay records of page * * @param array $result * @return array */ public function addData(array $result) { if ($result['effectivePid'] === 0) { // No overlays for records on pid 0 and not for new pages below root return $result; } $database = $this->getDatabase(); $dbRows = $database->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=' . (int) $result['effectivePid'] . BackendUtility::deleteClause('pages_language_overlay') . BackendUtility::versioningPlaceholderClause('pages_language_overlay')); if ($dbRows === null) { throw new \UnexpectedValueException('Database query error ' . $database->sql_error(), 1440777705); } $result['pageLanguageOverlayRows'] = $dbRows; return $result; }
/** * Try to retrieve all reference objects * * @param integer $uid * @param string $table * @param string $field * @return array<\TYPO3\CMS\Core\Resource\FileReference> */ public static function getReferenceObjects($uid, $table, $field) { $fileReferenceObjects = array(); /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $database */ $database =& $GLOBALS['TYPO3_DB']; $references = $database->exec_SELECTgetRows('uid', 'sys_file_reference', 'tablenames = ' . $database->fullQuoteStr($table, 'sys_file_reference') . ' AND fieldname=' . $database->fullQuoteStr($field, 'sys_file_reference') . ' AND uid_foreign=' . intval($uid) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_file_reference') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('sys_file_reference')); if (!empty($references)) { foreach ($references as $reference) { $referenceUid = (int) $reference['uid']; if ($referenceUid > 0) { try { $referenceObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject($referenceUid); if ($referenceObject instanceof \TYPO3\CMS\Core\Resource\FileReference) { $fileReferenceObjects[] = $referenceObject; } } catch (\Exception $e) { } } } } return $fileReferenceObjects; }
/** * Build the MySql where clause by table. * * @param string $tableName Record table name * @param array $fieldsToSearchWithin User right based visible fields where we can search within. * @return string */ protected function makeQuerySearchByTable($tableName, array $fieldsToSearchWithin) { $queryPart = ''; $whereParts = array(); // Load the full TCA for the table, as we need to access column configuration \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName); // If the search string is a simple integer, assemble an equality comparison if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->queryString)) { foreach ($fieldsToSearchWithin as $fieldName) { if ($fieldName == 'uid' || $fieldName == 'pid' || isset($GLOBALS['TCA'][$tableName]['columns'][$fieldName])) { $fieldConfig =& $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']; // Assemble the search condition only if the field is an integer, or is uid or pid if ($fieldName == 'uid' || $fieldName == 'pid' || $fieldConfig['type'] == 'input' && $fieldConfig['eval'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($fieldConfig['eval'], 'int')) { $whereParts[] = $fieldName . '=' . $this->queryString; } } } } else { $like = '\'%' . $GLOBALS['TYPO3_DB']->escapeStrForLike($GLOBALS['TYPO3_DB']->quoteStr($this->queryString, $tableName), $tableName) . '%\''; foreach ($fieldsToSearchWithin as $fieldName) { if (isset($GLOBALS['TCA'][$tableName]['columns'][$fieldName])) { $fieldConfig =& $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']; // Check whether search should be case-sensitive or not $format = 'LCASE(%s) LIKE LCASE(%s)'; if (is_array($fieldConfig['search'])) { if (in_array('case', $fieldConfig['search'])) { $format = '%s LIKE %s'; } // Apply additional condition, if any if ($fieldConfig['search']['andWhere']) { $format = '((' . $fieldConfig['search']['andWhere'] . ') AND (' . $format . '))'; } } // Assemble the search condition only if the field makes sense to be searched if ($fieldConfig['type'] == 'text' || $fieldConfig['type'] == 'flex' || $fieldConfig['type'] == 'input' && (!$fieldConfig['eval'] || !preg_match('/date|time|int/', $fieldConfig['eval']))) { $whereParts[] = sprintf($format, $fieldName, $like); } } } } // If at least one condition was defined, create the search query if (count($whereParts) > 0) { $queryPart = ' AND (' . implode(' OR ', $whereParts) . ')'; // And the relevant conditions for deleted and versioned records $queryPart .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableName); $queryPart .= \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause($tableName); } else { $queryPart = ' AND 0 = 1'; } return $queryPart; }
/** * Returns the SQL-query array to select the records * from a table $table with pid = $id * * @param string $table Table name * @param int $id Page id (NOT USED! $this->pidSelect is used instead) * @param string $addWhere Additional part for where clause * @param string $fieldList Field list to select, * for all (for "SELECT [fieldlist] FROM ...") * * @return array Returns query array */ public function makeQueryArray($table, $id, $addWhere = '', $fieldList = '*') { $database = $this->getDatabaseConnection(); $hookObjectsArr = array(); if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) { $hookObjectsArr[] = GeneralUtility::getUserObj($classRef); } } // Set ORDER BY: $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? 'ORDER BY ' . $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['sortby'] : $GLOBALS['TCA'][$table]['ctrl']['default_sortby']; if ($this->sortField) { if (in_array($this->sortField, $this->makeFieldList($table, 1))) { $orderBy = 'ORDER BY ' . $table . '.' . $this->sortField; if ($this->sortRev) { $orderBy .= ' DESC'; } } } // Set LIMIT: $limit = ''; if ($this->iLimit) { $limit = ($this->firstElementNumber ? $this->firstElementNumber . ',' : '') . ($this->iLimit + 1); } // Filtering on displayable tx_commerce_categories (permissions): $pC = $table == 'tx_commerce_categories' && $this->perms_clause ? ' AND ' . $this->perms_clause : ''; $categoryWhere = sprintf($this->addWhere[$table], $this->parentUid); // Adding search constraints: $search = $this->makeSearchString($table); // Compiling query array: $queryParts = array('SELECT' => $fieldList, 'FROM' => $table . $this->joinTables[$table], 'WHERE' => $this->pidSelect . ' ' . $pC . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table) . ' ' . $addWhere . $categoryWhere . ' ' . $search, 'GROUPBY' => '', 'ORDERBY' => $database->stripOrderBy($orderBy), 'LIMIT' => $limit); // Apply hook as requested in http://bugs.typo3.org/view.php?id=4361 foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'makeQueryArray_post')) { $parameter = array('orderBy' => $orderBy, 'limit' => $limit, 'pC' => $pC, 'search' => $search); $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $parameter); } } // Return query: return $queryParts; }
/** * Renders table rows of all pages containing TSConfig together with its rootline * * @return array */ protected function getOverviewOfPagesUsingTSConfig() { $db = $this->getDatabaseConnection(); $res = $db->exec_SELECTquery('uid, TSconfig', 'pages', 'TSconfig != \'\'' . BackendUtility::deleteClause('pages') . BackendUtility::versioningPlaceholderClause('pages'), 'pages.uid'); $pageArray = array(); while ($row = $db->sql_fetch_assoc($res)) { $this->setInPageArray($pageArray, BackendUtility::BEgetRootLine($row['uid'], 'AND 1=1'), $row); } return $this->getList($pageArray); }
/** * Main * * @return void * @todo Define visibility */ public function main() { // Template markers $markers = array('CSH' => '', 'FUNC_MENU' => '', 'CONTENT' => ''); // Access check... // The page will show only if there is a valid page and if this page may be viewed by the user $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); $this->access = is_array($this->pageinfo) ? 1 : 0; $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('EXT:tstemplate/Resources/Private/Templates/tstemplate.html'); if ($this->id && $this->access) { $urlParameters = array('id' => $this->id, 'template' => 'all'); $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters); $this->doc->form = '<form action="' . htmlspecialchars($aHref) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editForm">'; // JavaScript $this->doc->JScode = ' <script language="javascript" type="text/javascript"> function uFormUrl(aname) { document.forms[0].action = ' . GeneralUtility::quoteJSvalue($aHref . '#', TRUE) . '+aname; } function brPoint(lnumber,t) { window.location.href = ' . GeneralUtility::quoteJSvalue($aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateObjectBrowserModuleFunctionController&SET[ts_browser_type]=', TRUE) . '+(t?"setup":"const")+"&breakPointLN="+lnumber; return false; } </script> '; $this->doc->postCode = ' <script language="javascript" type="text/javascript"> if (top.fsMod) top.fsMod.recentIds["web"] = ' . $this->id . '; </script> '; $this->doc->inDocStylesArray[] = ' TABLE#typo3-objectBrowser { width: 100%; margin-bottom: 24px; } TABLE#typo3-objectBrowser A { text-decoration: none; } TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; } .ts-typoscript { width: 100%; } .tsob-menu label, .tsob-menu-row2 label, .tsob-conditions label { padding: 0 5px 0 0; vertical-align: text-top;} .tsob-menu-row2 {margin-top: 10px;} .tsob-conditions {padding: 1px 2px;} .tsob-search-submit {margin-left: 3px; margin-right: 3px;} .tst-analyzer-options { margin:5px 0; } .tst-analyzer-options label {padding-left:5px; vertical-align:text-top; } '; // Setting up the context sensitive menu: $this->doc->getContextMenuCode(); // Build the modulle content $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle')); $this->extObjContent(); // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers['FUNC_MENU'] = BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']); $markers['CONTENT'] = $this->content; } else { // Template pages: $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val', 'pages,sys_template', 'pages.uid=sys_template.pid' . BackendUtility::deleteClause('pages') . BackendUtility::versioningPlaceholderClause('pages') . BackendUtility::deleteClause('sys_template') . BackendUtility::versioningPlaceholderClause('sys_template'), 'pages.uid'); $templateArray = array(); $pArray = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->setInPageArray($pArray, BackendUtility::BEgetRootLine($row['uid'], 'AND 1=1'), $row); } $GLOBALS['TYPO3_DB']->sql_free_result($res); $table = '<table class="t3-table" id="ts-overview">' . '<thead>' . '<tr>' . '<th>' . $GLOBALS['LANG']->getLL('pageName') . '</th>' . '<th>' . $GLOBALS['LANG']->getLL('templates') . '</th>' . '<th>' . $GLOBALS['LANG']->getLL('isRoot') . '</th>' . '<th>' . $GLOBALS['LANG']->getLL('isExt') . '</th>' . '</tr>' . '</thead>' . '<tbody>' . implode('', $this->renderList($pArray)) . '</tbody>' . '</table>'; $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle')); $this->content .= $this->doc->section('', '<p class="lead">' . $GLOBALS['LANG']->getLL('overview') . '</p>' . $table); // RENDER LIST of pages with templates, END // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers['CONTENT'] = $this->content; } // Build the <body> for the module $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); // Renders the module page $this->content = $this->doc->render('Template Tools', $this->content); }
/** * Creates HTML for inserting/moving content elements. * * @param int $pid page id onto which to insert content element. * @param int $moveUid Move-uid (tt_content element uid?) * @param string $colPosList List of columns to show * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out. * @param string $R_URI Request URI * @return string HTML */ public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI) { $this->R_URI = $R_URI; $this->moveUid = $moveUid; $colPosArray = GeneralUtility::trimExplode(',', $colPosList, TRUE); $lines = array(); foreach ($colPosArray as $kk => $vv) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $pid . ($showHidden ? '' : BackendUtility::BEenableFields('tt_content')) . ' AND colPos=' . (int) $vv . ((string) $this->cur_sys_language !== '' ? ' AND sys_language_uid=' . (int) $this->cur_sys_language : '') . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting'); $lines[$vv] = array(); $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { BackendUtility::workspaceOL('tt_content', $row); if (is_array($row)) { $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row); $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid); } } $GLOBALS['TYPO3_DB']->sql_free_result($res); } return $this->printRecordMap($lines, $colPosArray, $pid); }
/** * Returns the SQL-query array to select the records from a table $table with pid = $id * * @param string $table Table name * @param int $id Page id (NOT USED! $this->pidSelect is used instead) * @param string $addWhere Additional part for where clause * @param string $fieldList Field list to select, * for all (for "SELECT [fieldlist] FROM ...") * @return string[] Returns query array * * @deprecated since TYPO3 v8, will be removed in TYPO3 v9. Please use getQueryBuilder() */ public function makeQueryArray($table, $id, $addWhere = '', $fieldList = '*') { GeneralUtility::logDeprecatedFunction(); $hookObjectsArr = []; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) { $hookObjectsArr[] = GeneralUtility::getUserObj($classRef); } } // Set ORDER BY: $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? 'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby'] : $GLOBALS['TCA'][$table]['ctrl']['default_sortby']; if ($this->sortField) { if (in_array($this->sortField, $this->makeFieldList($table, 1))) { $orderBy = 'ORDER BY ' . $this->sortField; if ($this->sortRev) { $orderBy .= ' DESC'; } } } // Set LIMIT: $limit = $this->iLimit ? ($this->firstElementNumber ? $this->firstElementNumber . ',' : '') . $this->iLimit : ''; // Filtering on displayable pages (permissions): $pC = $table == 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : ''; // Adding search constraints: $search = $this->makeSearchString($table, $id); // Compiling query array: $queryParts = ['SELECT' => $fieldList, 'FROM' => $table, 'WHERE' => $this->getPageIdConstraint($table) . ' ' . $pC . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table) . ' ' . $addWhere . ' ' . $search, 'GROUPBY' => '', 'LIMIT' => $limit]; $tempOrderBy = []; foreach (QueryHelper::parseOrderBy($orderBy) as $orderPair) { list($fieldName, $order) = $orderPair; if ($order !== null) { $tempOrderBy[] = implode(' ', $orderPair); } else { $tempOrderBy[] = $fieldName; } } $queryParts['ORDERBY'] = implode(',', $tempOrderBy); // Filter out records that are translated, if TSconfig mod.web_list.hideTranslations is set if ((in_array($table, GeneralUtility::trimExplode(',', $this->hideTranslations)) || $this->hideTranslations === '*') && !empty($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) && $table !== 'pages_language_overlay') { $queryParts['WHERE'] .= ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=0 '; } // Apply hook as requested in http://forge.typo3.org/issues/16634 foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'makeQueryArray_post')) { $_params = ['orderBy' => $orderBy, 'limit' => $limit, 'pC' => $pC, 'search' => $search]; $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $_params); } } // Return query: return $queryParts; }
/** * Counting content elements for a single language on a page. * * @param integer $pageId Page id to select for. * @param integer $sysLang Sys language uid * @return integer Number of content elements from the PID where the language is set to a certain value. * @todo Define visibility */ public function getContentElementCount($pageId, $sysLang) { $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tt_content', 'pid=' . (int) $pageId . ' AND sys_language_uid=' . (int) $sysLang . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content')); return $count ?: '-'; }
/** * Returns a SQL query for selecting sys_language records. * * @param integer $id Page id: If zero, the query will select all sys_language records from root level which are NOT hidden. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user) * @return string Return query string. * @todo Define visibility */ public function exec_languageQuery($id) { if ($id) { $exQ = \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('pages_language_overlay') . ($GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0'); return $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_language.*', 'pages_language_overlay,sys_language', 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . intval($id) . $exQ . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('pages_language_overlay'), 'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.static_lang_isocode,sys_language.flag', 'sys_language.title'); } else { return $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_language.*', 'sys_language', 'sys_language.hidden=0', '', 'sys_language.title'); } }
/** * Returns the where clause for fetching pages * * @param integer $id * @param string $searchFilter * @return string */ protected function getWhereClause($id, $searchFilter = '') { $where = $GLOBALS['BE_USER']->getPagePermsClause(1) . BackendUtility::deleteClause('pages') . BackendUtility::versioningPlaceholderClause('pages'); if (is_numeric($id) && $id >= 0) { $where .= ' AND pid= ' . $GLOBALS['TYPO3_DB']->fullQuoteStr((int) $id, 'pages'); } $excludedDoktypes = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.excludeDoktypes'); if (!empty($excludedDoktypes)) { $excludedDoktypes = $GLOBALS['TYPO3_DB']->fullQuoteArray(GeneralUtility::intExplode(',', $excludedDoktypes), 'pages'); $where .= ' AND doktype NOT IN (' . implode(',', $excludedDoktypes) . ')'; } if ($searchFilter !== '') { if (is_numeric($searchFilter) && $searchFilter > 0) { $searchWhere .= 'uid = ' . (int) $searchFilter . ' OR '; } $searchFilter = $GLOBALS['TYPO3_DB']->fullQuoteStr('%' . $searchFilter . '%', 'pages'); $useNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle'); $useAlias = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.searchInAlias'); $searchWhereAlias = ''; if ($useAlias) { $searchWhereAlias = ' OR alias LIKE ' . $searchFilter; } if ($useNavTitle) { $searchWhere .= '(nav_title LIKE ' . $searchFilter . ' OR (nav_title = "" AND title LIKE ' . $searchFilter . ')' . $searchWhereAlias . ')'; } else { $searchWhere .= 'title LIKE ' . $searchFilter . $searchWhereAlias; } $where .= ' AND (' . $searchWhere . ')'; } return $where; }
/** * Redirects to TCEforms (alt_doc) if a record is just localized. * * @param string $justLocalized String with table, orig uid and language separated by ": * @return void * @todo Define visibility */ public function localizationRedirect($justLocalized) { list($table, $orig_uid, $language) = explode(':', $justLocalized); if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) { $localizedRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', $table, $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . intval($language) . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . intval($orig_uid) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table) . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause($table)); if (is_array($localizedRecord)) { // Create parameters and finally run the classic page module for creating a new page translation $url = substr($this->listURL(), strlen($this->backPath)); $params = '&edit[' . $table . '][' . $localizedRecord['uid'] . ']=edit'; $returnUrl = '&returnUrl=' . rawurlencode($url); $location = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $params . $returnUrl; \TYPO3\CMS\Core\Utility\HttpUtility::redirect($location); } } }
/** * Gets the icon for the shortcut * * @param array $row * @param array $shortcut * @return string Shortcut icon as img tag */ protected function getShortcutIcon($row, $shortcut) { $databaseConnection = $this->getDatabaseConnection(); $languageService = $this->getLanguageService(); $titleAttribute = htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut')); switch ($row['module_name']) { case 'xMOD_alt_doc.php': $table = $shortcut['table']; $recordid = $shortcut['recordid']; $icon = ''; if ($shortcut['type'] == 'edit') { // Creating the list of fields to include in the SQL query: $selectFields = $this->fieldArray; $selectFields[] = 'uid'; $selectFields[] = 'pid'; if ($table == 'pages') { $selectFields[] = 'module'; $selectFields[] = 'extendToSubpages'; $selectFields[] = 'doktype'; } if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) { $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']); } if ($GLOBALS['TCA'][$table]['ctrl']['type']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type']; } if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column']; } if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { $selectFields[] = 't3ver_state'; } // Unique list! $selectFields = array_unique($selectFields); $permissionClause = $table === 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : ''; $sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table)); $result = $databaseConnection->exec_SELECT_queryArray($sqlQueryParts); $row = $databaseConnection->sql_fetch_assoc($result); $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIconForRecord($table, (array) $row, Icon::SIZE_SMALL)->render() . '</span>'; } elseif ($shortcut['type'] == 'new') { $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIconForRecord($table, array(), Icon::SIZE_SMALL)->render() . '</span>'; } break; case 'file_edit': $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIcon('mimetypes-text-html', Icon::SIZE_SMALL)->render() . '</span>'; break; case 'wizard_rte': $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIcon('mimetypes-word', Icon::SIZE_SMALL)->render() . '</span>'; break; default: $iconIdentifier = ''; $moduleName = $row['module_name']; if (strpos($moduleName, '_') !== false) { list($mainModule, $subModule) = explode('_', $moduleName, 2); $iconIdentifier = $this->moduleLoader->modules[$mainModule]['sub'][$subModule]['iconIdentifier']; } elseif (!empty($moduleName)) { $iconIdentifier = $this->moduleLoader->modules[$moduleName]['iconIdentifier']; } if (!$iconIdentifier) { $iconIdentifier = 'empty-empty'; } $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL)->render() . '</span>'; } return $icon; }
function getConfigurationsForBranch($rootid, $depth) { $configurationsForBranch = array(); $pageTSconfig = $this->getPageTSconfigForId($rootid); if (is_array($pageTSconfig) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.'])) { $sets = $pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.']; if (is_array($sets)) { foreach ($sets as $key => $value) { if (!is_array($value)) { continue; } $configurationsForBranch[] = substr($key, -1) == '.' ? substr($key, 0, -1) : $key; } } } $pids = array(); $rootLine = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($rootid); foreach ($rootLine as $node) { $pids[] = $node['uid']; } /* @var \TYPO3\CMS\Backend\Tree\View\PageTreeView */ $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView'); $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); $tree->init('AND ' . $perms_clause); $tree->getTree($rootid, $depth, ''); foreach ($tree->tree as $node) { $pids[] = $node['row']['uid']; } $res = $this->db->exec_SELECTquery('*', 'tx_crawler_configuration', 'pid IN (' . implode(',', $pids) . ') ' . \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_crawler_configuration') . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_crawler_configuration') . ' ' . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tx_crawler_configuration') . ' '); while ($row = $this->db->sql_fetch_assoc($res)) { $configurationsForBranch[] = $row['name']; } $this->db->sql_free_result($res); return $configurationsForBranch; }
/** * Information about translation for an element * Will overlay workspace version of record too! * * @param string $table Table name * @param int $uid Record uid * @param int $languageUid Language uid. If 0, then all languages are selected. * @param array $row The record to be translated * @param string $selFieldList Select fields for the query which fetches the translations of the current record * @return mixed Array with information or error message as a string. */ public function translationInfo($table, $uid, $languageUid = 0, array $row = null, $selFieldList = '') { if (!$GLOBALS['TCA'][$table] || !$uid) { return 'No table "' . $table . '" or no UID value'; } if ($row === null) { $row = BackendUtility::getRecordWSOL($table, $uid); } if (!is_array($row)) { return 'Record "' . $table . '_' . $uid . '" was not found'; } $translationTable = $this->getTranslationTable($table); if ($translationTable === '') { return 'Translation is not supported for this table!'; } if ($translationTable === $table && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) { return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a language value "' . $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] . '", relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")'; } if ($translationTable === $table && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) { return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")'; } // Look for translations of this record, index by language field value: if (!$selFieldList) { $selFieldList = 'uid,' . $GLOBALS['TCA'][$translationTable]['ctrl']['languageField']; } $where = $GLOBALS['TCA'][$translationTable]['ctrl']['transOrigPointerField'] . '=' . (int) $uid . ' AND pid=' . (int) ($table === 'pages' ? $row['uid'] : $row['pid']) . ' AND ' . $GLOBALS['TCA'][$translationTable]['ctrl']['languageField'] . (!$languageUid ? '>0' : '=' . (int) $languageUid) . BackendUtility::deleteClause($translationTable) . BackendUtility::versioningPlaceholderClause($translationTable); $translationRecords = $this->getDatabaseConnection()->exec_SELECTgetRows($selFieldList, $translationTable, $where); $translations = array(); $translationsErrors = array(); foreach ($translationRecords as $translationRecord) { if (!isset($translations[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]])) { $translations[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]] = $translationRecord; } else { $translationsErrors[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]][] = $translationRecord; } } return array('table' => $table, 'uid' => $uid, 'CType' => $row['CType'], 'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']], 'translation_table' => $translationTable, 'translations' => $translations, 'excessive_translations' => $translationsErrors); }
/** * Based on t3lib_Befunc::getRecordsByField * * @param string $theTable * @param string $theField * @param string $theValue * @param string $whereClause * @param string $groupBy * @param string $orderBy * @param string $limit * @param bool $useDeleteClause * * @return array */ public function getRecordsByField($theTable, $theField, $theValue, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '', $useDeleteClause = TRUE) { if (is_array($GLOBALS['TCA'][$theTable])) { $database = $this->getDatabaseConnection(); $res = $database->exec_SELECTquery('*', $theTable, $theField . ' IN (' . $theValue . ')' . ($useDeleteClause ? \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($theTable) . ' ' : '') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause($theTable) . ' ' . $whereClause, $groupBy, $orderBy, $limit); $rows = array(); while ($row = $database->sql_fetch_assoc($res)) { $rows[] = $row; } $database->sql_free_result($res); if (count($rows)) { return $rows; } } return array(); }
/** * @param $edit_record array * * @return array */ protected function makeQuickEditMenu($edit_record) { $lang = $this->getLanguageService(); $databaseConnection = $this->getDatabaseConnection(); $beUser = $this->getBackendUser(); $quickEditMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); $quickEditMenu->setIdentifier('quickEditMenu'); $quickEditMenu->setLabel(''); // Setting close url/return url for exiting this script: // Goes to 'Columns' view if close is pressed (default) $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1))); if ($this->returnUrl) { $this->closeUrl = $this->returnUrl; } $retUrlStr = $this->returnUrl ? '&returnUrl=' . rawurlencode($this->returnUrl) : ''; // Creating the selector box, allowing the user to select which element to edit: $isSelected = 0; $languageOverlayRecord = ''; if ($this->current_sys_language) { list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int) $this->current_sys_language); } if (is_array($languageOverlayRecord)) { $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid']; $isSelected += (int) $edit_record == $inValue; $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('editLanguageHeader', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue); $quickEditMenu->addMenuItem($menuItem); } else { $inValue = 'pages:' . $this->id; $isSelected += (int) $edit_record == $inValue; $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('editPageProperties', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue); $quickEditMenu->addMenuItem($menuItem); } // Selecting all content elements from this language and allowed colPos: $whereClause = 'pid=' . (int) $this->id . ' AND sys_language_uid=' . (int) $this->current_sys_language . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'); if (!$this->getBackendUser()->user['admin']) { $whereClause .= ' AND editlock = 0'; } $res = $databaseConnection->exec_SELECTquery('*', 'tt_content', $whereClause, '', 'colPos,sorting'); $colPos = null; $first = 1; // Page is the pid if no record to put this after. $prev = $this->id; while ($cRow = $databaseConnection->sql_fetch_assoc($res)) { BackendUtility::workspaceOL('tt_content', $cRow); if (is_array($cRow)) { if ($first) { if (!$edit_record) { $edit_record = 'tt_content:' . $cRow['uid']; } $first = 0; } if (!isset($colPos) || $cRow['colPos'] !== $colPos) { $colPos = $cRow['colPos']; $menuItem = $quickEditMenu->makeMenuItem()->setTitle(' ')->setHref('#'); $quickEditMenu->addMenuItem($menuItem); $menuItem = $quickEditMenu->makeMenuItem()->setTitle('__' . $lang->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), true) . ':__')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=_EDIT_COL:' . $colPos . $retUrlStr); $quickEditMenu->addMenuItem($menuItem); } $inValue = 'tt_content:' . $cRow['uid']; $isSelected += (int) $edit_record == $inValue; $menuItem = $quickEditMenu->makeMenuItem()->setTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $beUser->uc['titleLen'])))->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue); $quickEditMenu->addMenuItem($menuItem); $prev = -$cRow['uid']; } } // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element: if (!$edit_record) { $edit_record = 'tt_content:new/' . $prev . '/' . $colPos; $inValue = 'tt_content:new/' . $prev . '/' . $colPos; $isSelected += (int) $edit_record == $inValue; $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('newLabel', 1) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue); $quickEditMenu->addMenuItem($menuItem); } // If none is yet selected... if (!$isSelected) { $menuItem = $quickEditMenu->makeMenuItem()->setTitle('__________')->setHref('#'); $quickEditMenu->addMenuItem($menuItem); $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('newLabel', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $edit_record . $retUrlStr)->setActive($edit_record == $inValue); $quickEditMenu->addMenuItem($menuItem); } $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($quickEditMenu); return $edit_record; }
/** * Getting the tree data: Selecting/Initializing data pointer to items for a certain parent id. * For tables: This will make a database query to select all children to "parent" * For arrays: This will return key to the ->dataLookup array * * @param int $parentId parent item id * * @return mixed Data handle (Tables: An sql-resource, arrays: A parentId integer. -1 is returned if there were NO subLevel.) * @access private */ public function getDataInit($parentId) { if (is_array($this->data)) { if (!is_array($this->dataLookup[$parentId][$this->subLevelID])) { $parentId = -1; } else { reset($this->dataLookup[$parentId][$this->subLevelID]); } return $parentId; } else { $db = $this->getDatabaseConnection(); $where = $this->parentField . '=' . $db->fullQuoteStr($parentId, $this->table) . BackendUtility::deleteClause($this->table) . BackendUtility::versioningPlaceholderClause($this->table) . $this->clause; return $db->exec_SELECTquery(implode(',', $this->fieldArray), $this->table, $where, '', $this->orderByFields); } }
/** * Gets the icon for the shortcut * * @param array $row * @param array $shortcut * @return string Shortcut icon as img tag */ protected function getShortcutIcon($row, $shortcut) { $databaseConnection = $this->getDatabaseConnection(); $languageService = $this->getLanguageService(); $titleAttribute = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut', TRUE); switch ($row['module_name']) { case 'xMOD_alt_doc.php': $table = $shortcut['table']; $recordid = $shortcut['recordid']; $icon = ''; if ($shortcut['type'] == 'edit') { // Creating the list of fields to include in the SQL query: $selectFields = $this->fieldArray; $selectFields[] = 'uid'; $selectFields[] = 'pid'; if ($table == 'pages') { $selectFields[] = 'module'; $selectFields[] = 'extendToSubpages'; $selectFields[] = 'doktype'; } if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) { $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']); } if ($GLOBALS['TCA'][$table]['ctrl']['type']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type']; } if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column']; } if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { $selectFields[] = 't3ver_state'; } // Unique list! $selectFields = array_unique($selectFields); $permissionClause = $table === 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : ''; $sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table)); $result = $databaseConnection->exec_SELECT_queryArray($sqlQueryParts); $row = $databaseConnection->sql_fetch_assoc($result); $icon = IconUtility::getSpriteIconForRecord($table, (array) $row, array('title' => $titleAttribute)); } elseif ($shortcut['type'] == 'new') { $icon = IconUtility::getSpriteIconForRecord($table, array(), array('title' => $titleAttribute)); } break; case 'file_edit': $icon = IconUtility::getSpriteIcon('mimetypes-text-html', array('title' => $titleAttribute)); break; case 'wizard_rte': $icon = IconUtility::getSpriteIcon('mimetypes-word', array('title' => $titleAttribute)); break; default: if ($languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']) { $icon = $languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']; // Change icon of fileadmin references - otherwise it doesn't differ with Web->List $icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon); if (GeneralUtility::isAbsPath($icon)) { $icon = '../' . PathUtility::stripPathSitePrefix($icon); } // @todo: hardcoded width as we don't have a way to address module icons with an API yet. $icon = '<img src="' . htmlspecialchars($icon) . '" alt="' . $titleAttribute . '" width="16">'; } else { $icon = IconUtility::getSpriteIcon('empty-empty', array('title' => $titleAttribute)); } } return $icon; }
/** * Handler for Flex Forms * * @param string $table The table name of the record * @param string $field The field name which this element is supposed to edit * @param array $row The record data array where the value(s) for the field can be found * @param array $PA An array with additional configuration options. * @return string The HTML code for the TCEform field * @todo Define visibility */ public function getSingleField_typeFlex($table, $field, $row, &$PA) { // Data Structure: $dataStructArray = BackendUtility::getFlexFormDS($PA['fieldConf']['config'], $row, $table, $field); $item = ''; // Manipulate Flexform DS via TSConfig and group access lists if (is_array($dataStructArray)) { $flexFormHelper = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FlexFormsHelper'); $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $PA['fieldConf']); unset($flexFormHelper); } // Get data structure: if (is_array($dataStructArray)) { // Get data: $xmlData = $PA['itemFormElValue']; $xmlHeaderAttributes = GeneralUtility::xmlGetHeaderAttribs($xmlData); $storeInCharset = strtolower($xmlHeaderAttributes['encoding']); if ($storeInCharset) { $currentCharset = $this->getLanguageService()->charSet; $xmlData = $this->getLanguageService()->csConvObj->conv($xmlData, $storeInCharset, $currentCharset, 1); } $editData = GeneralUtility::xml2array($xmlData); // Must be XML parsing error... if (!is_array($editData)) { $editData = array(); } elseif (!isset($editData['meta']) || !is_array($editData['meta'])) { $editData['meta'] = array(); } // Find the data structure if sheets are found: $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF'; // Sheet to display // Create language menu: $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0; $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0; $editData['meta']['currentLangId'] = array(); // Look up page overlays: $checkPageLanguageOverlay = $this->getBackendUserAuthentication()->getTSConfigVal('options.checkPageLanguageOverlay') ? TRUE : FALSE; if ($checkPageLanguageOverlay) { $where_clause = 'pid=' . (int) $row['pid'] . BackendUtility::deleteClause('pages_language_overlay') . BackendUtility::versioningPlaceholderClause('pages_language_overlay'); $pageOverlays = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'pages_language_overlay', $where_clause, '', '', '', 'sys_language_uid'); } $languages = $this->getAvailableLanguages(); foreach ($languages as $lInfo) { if ($this->getBackendUserAuthentication()->checkLanguageAccess($lInfo['uid']) && (!$checkPageLanguageOverlay || $lInfo['uid'] <= 0 || is_array($pageOverlays[$lInfo['uid']]))) { $editData['meta']['currentLangId'][] = $lInfo['ISOcode']; } } if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId'])) { $editData['meta']['currentLangId'] = array('DEF'); } $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']); $PA['_noEditDEF'] = FALSE; if ($langChildren || $langDisabled) { $rotateLang = array('DEF'); } else { if (!in_array('DEF', $editData['meta']['currentLangId'])) { array_unshift($editData['meta']['currentLangId'], 'DEF'); $PA['_noEditDEF'] = TRUE; } $rotateLang = $editData['meta']['currentLangId']; } // Tabs sheets if (is_array($dataStructArray['sheets'])) { $tabsToTraverse = array_keys($dataStructArray['sheets']); } else { $tabsToTraverse = array($sheet); } /** @var $elementConditionMatcher \TYPO3\CMS\Backend\Form\ElementConditionMatcher */ $elementConditionMatcher = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\ElementConditionMatcher'); foreach ($rotateLang as $lKey) { if (!$langChildren && !$langDisabled) { $item .= '<strong>' . $this->getLanguageIcon($table, $row, 'v' . $lKey) . $lKey . ':</strong>'; } // Default language, other options are "lUK" or whatever country code (independent of system!!!) $lang = 'l' . $lKey; $tabParts = array(); $sheetContent = ''; foreach ($tabsToTraverse as $sheet) { list($dataStruct, $sheet) = GeneralUtility::resolveSheetDefInDS($dataStructArray, $sheet); // If sheet has displayCond if ($dataStruct['ROOT']['TCEforms']['displayCond']) { $splitCondition = GeneralUtility::trimExplode(':', $dataStruct['ROOT']['TCEforms']['displayCond']); $skipCondition = FALSE; $fakeRow = array(); switch ($splitCondition[0]) { case 'FIELD': list($sheetName, $fieldName) = GeneralUtility::trimExplode('.', $splitCondition[1]); $fieldValue = $editData['data'][$sheetName][$lang][$fieldName]; $splitCondition[1] = $fieldName; $dataStruct['ROOT']['TCEforms']['displayCond'] = join(':', $splitCondition); $fakeRow = array($fieldName => $fieldValue); break; case 'HIDE_FOR_NON_ADMINS': case 'VERSION': case 'HIDE_L10N_SIBLINGS': case 'EXT': break; case 'REC': $fakeRow = array('uid' => $row['uid']); break; default: $skipCondition = TRUE; } $displayConditionResult = TRUE; if ($dataStruct['ROOT']['TCEforms']['displayCond']) { $displayConditionResult = $elementConditionMatcher->match($dataStruct['ROOT']['TCEforms']['displayCond'], $fakeRow, 'vDEF'); } // If sheets displayCond leads to false if (!$skipCondition && !$displayConditionResult) { // Don't create this sheet continue; } } // Render sheet: if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) { // Default language, other options are "lUK" or whatever country code (independent of system!!!) $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; $PA['_lang'] = $lang; // Assemble key for loading the correct CSH file $dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], TRUE); $PA['_cshKey'] = $table . '.' . $field; foreach ($dsPointerFields as $key) { $PA['_cshKey'] .= '.' . $row[$key]; } // Push the sheet level tab to DynNestedStack $tabIdentString = ''; if (is_array($dataStructArray['sheets'])) { $tabIdentString = $this->getDocumentTemplate()->getDynTabMenuId('TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang']); $this->pushToDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1)); } // Render flexform: $tRows = $this->getSingleField_typeFlex_draw($dataStruct['ROOT']['el'], $editData['data'][$sheet][$lang], $table, $field, $row, $PA, '[data][' . $sheet . '][' . $lang . ']'); $sheetContent = '<div class="typo3-TCEforms-flexForm">' . $tRows . '</div>'; // Pop the sheet level tab from DynNestedStack if (is_array($dataStructArray['sheets'])) { $this->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1)); } } else { $sheetContent = 'Data Structure ERROR: No ROOT element found for sheet "' . $sheet . '".'; } // Add to tab: $tabParts[] = array('label' => $dataStruct['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetTitle']) : $sheet, 'description' => $dataStruct['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetDescription']) : '', 'linkTitle' => $dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : '', 'content' => $sheetContent); } if (is_array($dataStructArray['sheets'])) { $dividersToTabsBehaviour = isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1; $item .= $this->getDynTabMenu($tabParts, 'TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang'], $dividersToTabsBehaviour); } else { $item .= $sheetContent; } } } else { $item = 'Data Structure ERROR: ' . $dataStructArray; } return $item; }
/** * Redirects to FormEngine if a record is just localized. * * @param string $justLocalized String with table, orig uid and language separated by ": * @return void */ public function localizationRedirect($justLocalized) { list($table, $orig_uid, $language) = explode(':', $justLocalized); if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) { $localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', $table, $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int) $language . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int) $orig_uid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table)); if (is_array($localizedRecord)) { // Create parameters and finally run the classic page module for creating a new page translation $url = $this->listURL(); $editUserAccountUrl = BackendUtility::getModuleUrl('record_edit', array('edit[' . $table . '][' . $localizedRecord['uid'] . ']' => 'edit', 'returnUrl' => $url)); HttpUtility::redirect($editUserAccountUrl); } } }
/** * Checks whether the current page has sub pages * * @return bool */ protected function currentPageHasSubPages() { $count = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'pages', 'pid = ' . (int) $this->id . BackendUtility::deleteClause('pages') . BackendUtility::versioningPlaceholderClause('pages') . BackendUtility::getWorkspaceWhereClause('pages')); return $count > 0; }
/** * Getting the tree data: Selecting/Initializing data pointer to items for a certain parent id. * For tables: This will make a database query to select all children to "parent" * For arrays: This will return key to the ->dataLookup array * * @param int $parentId parent item id * @param string $subCSSclass Class for sub-elements. * @return mixed Data handle (Tables: An sql-resource, arrays: A parentId integer. -1 is returned if there were NO subLevel.) * @access private */ public function getDataInit($parentId, $subCSSclass = '') { if (is_array($this->data)) { if (!is_array($this->dataLookup[$parentId][$this->subLevelID])) { $parentId = -1; } else { reset($this->dataLookup[$parentId][$this->subLevelID]); } return $parentId; } else { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', $this->fieldArray), $this->table, $this->parentField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($parentId, $this->table) . BackendUtility::deleteClause($this->table) . BackendUtility::versioningPlaceholderClause($this->table) . $this->clause, '', $this->orderByFields); return $res; } }
/** * This displays all content elements on a page and lets you create a link to the element. * * @param int $expPageId Page uid to expand * * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...) */ public function expandPage($expPageId) { // If there is an anchor value (content element reference) in the element reference, then force an ID to expand: if (!$expPageId && isset($this->linkParts['anchor'])) { // Set to the current link page id. $expPageId = $this->linkParts['pageid']; } // Draw the record list IF there is a page id to expand: if (!$expPageId || !MathUtility::canBeInterpretedAsInteger($expPageId) || !$this->getBackendUser()->isInWebMount($expPageId)) { return ''; } // Set header: $out = '<h3>' . $this->getLanguageService()->getLL('contentElements') . ':</h3>'; // Create header for listing, showing the page title/icon: $mainPageRec = BackendUtility::getRecordWSOL('pages', $expPageId); $db = $this->getDatabaseConnection(); $out .= ' <ul class="list-tree list-tree-root list-tree-root-clean"> <li class="list-tree-control-open"> <span class="list-tree-group"> <span class="list-tree-icon">' . $this->iconFactory->getIconForRecord('pages', $mainPageRec, Icon::SIZE_SMALL)->render() . '</span> <span class="list-tree-title">' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $mainPageRec, true)) . '</span> </span> <ul> '; // Look up tt_content elements from the expanded page: $res = $db->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext', 'tt_content', 'pid=' . (int) $expPageId . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting'); // Traverse list of records: $c = 0; while ($row = $db->sql_fetch_assoc($res)) { $c++; $icon = $this->iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL)->render(); $selected = ''; if (!empty($this->linkParts) && (int) $this->linkParts['anchor'] === (int) $row['uid']) { $selected = ' class="active"'; } // Putting list element HTML together: $out .= ' <li' . $selected . '> <span class="list-tree-group"> <span class="list-tree-icon"> ' . $icon . ' </span> <span class="list-tree-title"> <a href="#" class="t3js-pageLink" data-id="' . (int) $expPageId . '" data-anchor="#' . (int) $row['uid'] . '"> ' . htmlspecialchars(BackendUtility::getRecordTitle('tt_content', $row, true)) . ' </a> </span> </span> </li> '; } $out .= ' </ul> </li> </ul> '; return $out; }
/** * For RTE: This displays all content elements on a page and lets you create a link to the element. * * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...) */ function expandPage() { $out = ''; $expPageId = $this->browseLinks->expandPage; // Set page id (if any) to expand // If there is an anchor value (content element reference) in the element reference, then force an ID to expand: if (!$this->browseLinks->expandPage && $this->browseLinks->curUrlInfo['cElement']) { $expPageId = $this->browseLinks->curUrlInfo['pageid']; // Set to the current link page id. } // Draw the record list IF there is a page id to expand: if ($expPageId && t3lib_utility_Math::canBeInterpretedAsInteger($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) { // Set header: $out .= $this->browseLinks->barheader($GLOBALS['LANG']->getLL('contentElements') . ':'); // Create header for listing, showing the page title/icon: $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']); $mainPageRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $expPageId); $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec); $picon .= \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE); $out .= $picon . '<br />'; // Look up tt_content elements from the expanded page: $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext,tx_jfmulticontent_view,tx_jfmulticontent_pages,tx_jfmulticontent_contents', 'tt_content', 'pid=' . intval($expPageId) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting'); $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); // Traverse list of records: $c = 0; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $c++; $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row); if ($this->browseLinks->curUrlInfo['act'] == 'page' && $this->browseLinks->curUrlInfo['cElement'] == $row['uid']) { $arrCol = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />'; } else { $arrCol = ''; } // Putting list element HTML together: $out .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join' . ($c == $cc ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">' . $icon . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('tt_content', $row, TRUE) . '</a><br />'; $contents = array(); // get all contents switch ($row['tx_jfmulticontent_view']) { case "page": $contents = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(",", $row['tx_jfmulticontent_pages']); break; case "content": $contents = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(",", $row['tx_jfmulticontent_contents']); break; case "irre": $resIrre = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'tx_jfmulticontent_irre_parentid=' . intval($row['uid']) . ' AND deleted = 0 AND hidden = 0', '', ''); while ($rowIrre = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resIrre)) { $contents[] = $rowIrre['uid']; } break; } if (count($contents) > 0) { $out .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/blank.gif', 'width="18" height="16"') . ' alt="" />'; foreach ($contents as $key => $content) { $out .= '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#jfmulticontent_c' . $row['uid'] . '-' . ($key + 1) . '\');">' . ' ' . ($key + 1) . ' ' . '</a>'; } $out .= '<br/>'; } } } return $out; }
/** * Selects records from table / pid * * @param string $table Table to select from * @param integer $pid Page ID to select from * @param integer $limit Max number of records to select * @return pointer SQL resource pointer * @todo Define visibility */ public function exec_listQueryPid($table, $pid, $limit) { $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? 'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby'] : $GLOBALS['TCA'][$table]['ctrl']['default_sortby']; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . intval($pid) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table) . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause($table), '', $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), $limit); // Warning about hitting limit: if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) { $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('execlistqu_maxNumberLimit'), sprintf($GLOBALS['LANG']->getLL('makeconfig_anSqlQueryReturned', 1), $limit), 0, 1, 2); } return $res; }
/** * For RTE: This displays all content elements on a page and lets you create a link to the element. * * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...) * @todo Define visibility */ public function expandPage() { $out = ''; // Set page id (if any) to expand $expPageId = $this->expandPage; // If there is an anchor value (content element reference) in the element reference, then force an ID to expand: if (!$this->expandPage && $this->curUrlInfo['cElement']) { // Set to the current link page id. $expPageId = $this->curUrlInfo['pageid']; } // Draw the record list IF there is a page id to expand: if ($expPageId && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) { // Set header: $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements') . ':'); // Create header for listing, showing the page title/icon: $mainPageRec = BackendUtility::getRecordWSOL('pages', $expPageId); $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec); $picon .= BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE); $out .= $picon . '<br />'; // Look up tt_content elements from the expanded page: $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext', 'tt_content', 'pid=' . (int) $expPageId . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting'); $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); // Traverse list of records: $c = 0; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $c++; $icon = IconUtility::getSpriteIconForRecord('tt_content', $row); if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) { $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />'; } else { $arrCol = ''; } // Putting list element HTML together: $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join' . ($c == $cc ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">' . $icon . BackendUtility::getRecordTitle('tt_content', $row, TRUE) . '</a><br />'; // Finding internal anchor points: if (GeneralUtility::inList('text,textpic', $row['CType'])) { $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($split as $skey => $sval) { if ($skey % 3 == 2) { // Putting list element HTML together: $sval = substr($sval, 0, 100); $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join' . ($skey + 3 > count($split) ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . '<a href="#" onclick="return link_typo3Page(' . GeneralUtility::quoteJSvalue($expPageId) . ',' . GeneralUtility::quoteJSvalue('#' . $sval) . ';">' . htmlspecialchars(' <A> ' . $sval) . '</a><br />'; } } } } } return $out; }
/** * Function, which populates the internal editconf array with editing commands for all tt_content elements from * the normal column in normal language from the page pointed to by $this->editRegularContentFromId * * @return void * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8 */ public function editRegularContentFromId() { GeneralUtility::logDeprecatedFunction(); $dbConnection = $this->getDatabaseConnection(); $res = $dbConnection->exec_SELECTquery('uid', 'tt_content', 'pid=' . (int) $this->editRegularContentFromId . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content') . ' AND colPos=0 AND sys_language_uid=0', '', 'sorting'); if ($dbConnection->sql_num_rows($res)) { $ecUids = array(); while ($ecRec = $dbConnection->sql_fetch_assoc($res)) { $ecUids[] = $ecRec['uid']; } $this->editconf['tt_content'][implode(',', $ecUids)] = 'edit'; } $dbConnection->sql_free_result($res); }
/** * Creates a menu of the tables that can be listed by this function * Only tables which has records on the page will be included. * Notice: The function also fills in the internal variable $this->activeTables with icon/titles. * * @param int $id Page id from which we are listing records (the function will look up if there are records on the page) * @return string HTML output. */ public function getTableMenu($id) { // Initialize: $this->activeTables = array(); $theTables = array('tt_content'); // External tables: if (is_array($this->externalTables)) { $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables))); } $out = ''; // Traverse tables to check: foreach ($theTables as $tName) { // Check access and whether the proper extensions are loaded: if ($this->getBackendUser()->check('tables_select', $tName) && (isset($this->externalTables[$tName]) || GeneralUtility::inList('fe_users,tt_content', $tName) || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName))) { // Make query to count records from page: $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int) $id . BackendUtility::deleteClause($tName) . BackendUtility::versioningPlaceholderClause($tName)); // If records were found (or if "tt_content" is the table...): if ($c || GeneralUtility::inList('tt_content', $tName)) { // Add row to menu: $out .= ' <td><a href="#' . $tName . '" title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . '"></a>' . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render() . '</td>'; // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere) $title = $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', true); $this->activeTables[$tName] = '<span title="' . $title . '">' . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render() . '</span>' . ' ' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true); } } } // Wrap cells in table tags: $out = ' <!-- Menu of tables on the page (table menu) --> <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu"> <tr>' . $out . ' </tr> </table>'; // Return the content: return $out; }
/** * Returns a SQL query for selecting sys_language records. * * @param int $id Page id: If zero, the query will select all sys_language records from root level which are NOT hidden. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user) * @return string Return query string. */ public function exec_languageQuery($id) { if ($id) { $exQ = BackendUtility::deleteClause('pages_language_overlay') . ($this->getBackendUser()->isAdmin() ? '' : ' AND sys_language.hidden=0'); return $this->getDatabaseConnection()->exec_SELECTquery('sys_language.*', 'pages_language_overlay,sys_language', 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . (int) $id . $exQ . BackendUtility::versioningPlaceholderClause('pages_language_overlay'), 'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.language_isocode,sys_language.static_lang_isocode,sys_language.flag', 'sys_language.title'); } else { return $this->getDatabaseConnection()->exec_SELECTquery('sys_language.*', 'sys_language', 'sys_language.hidden=0', '', 'sys_language.title'); } }