/** * Main function * Will issue a location-header, redirecting either BACK or to a new alt_doc.php instance... * * @return void * @todo Define visibility */ public function main() { // Get this record $origRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($this->P['table'], $this->P['uid']); // Get TSconfig for it. $TSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCEFORM_TSconfig($this->table, is_array($origRow) ? $origRow : array('pid' => $this->P['pid'])); // Set [params][pid] if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') { $this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]); } else { $this->pid = intval($this->P['params']['pid']); } // Make redirect: // If pid is blank OR if id is set, then return... if (!strcmp($this->pid, '') || strcmp($this->id, '')) { $redirectUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']); } else { // Otherwise, show the list: $urlParameters = array(); $urlParameters['id'] = $this->pid; $urlParameters['table'] = $this->P['params']['table']; $urlParameters['returnUrl'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'); $redirectUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_list', $urlParameters); } \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl); }
/** * @test */ public function exportGroupFileAndFileReferenceItem() { $this->export->setRecordTypesIncludeFields(array('pages' => array('title', 'deleted', 'doktype', 'hidden', 'perms_everybody'), 'sys_file' => array('storage', 'type', 'metadata', 'extension', 'identifier', 'identifier_hash', 'folder_hash', 'mime_type', 'name', 'sha1', 'size', 'creation_date', 'modification_date'), 'sys_file_storage' => array('name', 'description', 'driver', 'configuration', 'is_default', 'is_browsable', 'is_public', 'is_writable', 'is_online'), 'tx_impexpgroupfiles_item' => array('title', 'deleted', 'hidden', 'images', 'image_references', 'flexform'))); $this->export->relOnlyTables = array('sys_file', 'sys_file_storage'); $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 2)); $this->export->export_addRecord('tx_impexpgroupfiles_item', BackendUtility::getRecord('tx_impexpgroupfiles_item', 2)); $this->setPageTree(2, 0); // After adding ALL records we set relations: for ($a = 0; $a < 10; $a++) { $addR = $this->export->export_addDBRelations($a); if (!count($addR)) { break; } } // hacky, but the timestamp will change on every clone, so set the file // modification timestamp to the asserted value $success = @touch(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824); if (!$success) { $this->markTestSkipped('Could not set file modification timestamp for a fixture binary file. This is required for running the test successful.'); } $this->export->export_addFilesFromRelations(); $this->export->export_addFilesFromSysFilesRecords(); $out = $this->export->compileMemoryToFileContent('xml'); $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item-in-ff.xml', $out); }
/** * Sets the TYPO3 Backend context to a certain workspace, * called by the Backend toolbar menu * * @param array $parameters * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler * @return void */ public function setWorkspace($parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler) { $workspaceId = (int) GeneralUtility::_GP('workspaceId'); $pageId = (int) GeneralUtility::_GP('pageId'); $finalPageUid = 0; $originalPageId = $pageId; $this->getBackendUser()->setWorkspace($workspaceId); while ($pageId) { $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')'); if ($page) { if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) { break; } } else { $page = BackendUtility::getRecord('pages', $pageId); } $pageId = $page['pid']; } if (isset($page['uid'])) { $finalPageUid = (int) $page['uid']; } $response = array('title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? NULL : $finalPageUid); $ajaxRequestHandler->setContent($response); $ajaxRequestHandler->setContentFormat('json'); }
/** * Checks the page access rights (Code for access check mostly taken from FormEngine) * as well as the table access rights of the user. * * @param string $table The table to check access for * @param string $row Record array * @return bool Returns TRUE is the user has access, or FALSE if not */ public static function checkAccess($table, $row) { $backendUser = static::getBackendUser(); // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...) // First, resetting flags. $hasAccess = false; $calcPRec = $row; BackendUtility::fixVersioningPid($table, $calcPRec); if (is_array($calcPRec)) { if ($table === 'pages') { // If pages: // @todo: find a decent way for non-admins to get deleted pages respecting the permissions WITHOUT some isInWebMount stuff. $calculatedPermissions = $backendUser->calcPerms($calcPRec); $hasAccess = (bool) ($calculatedPermissions & Permission::PAGE_EDIT); } else { $calculatedPermissions = $backendUser->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid'])); // Fetching pid-record first. $hasAccess = (bool) ($calculatedPermissions & Permission::CONTENT_EDIT); } // Check internals regarding access: if ($hasAccess) { $hasAccess = $backendUser->recordEditAccessInternals($table, $calcPRec); } } if (!$backendUser->check('tables_modify', $table)) { $hasAccess = false; } return $hasAccess; }
/** * Returns array of system languages * * Since TYPO3 4.5 the flagIcon is not returned as a filename in "gfx/flags/*" anymore, * but as a string <flags-xx>. The calling party should call * t3lib_iconWorks::getSpriteIcon(<flags-xx>) to get an HTML which will represent * the flag of this language. * * @param integer $page_id Page id (only used to get TSconfig configuration setting flag and label for default language) * @param string $backPath Backpath for flags * @return array Array with languages (title, uid, flagIcon) * @todo Define visibility */ public function getSystemLanguages($page_id = 0, $backPath = '') { $modSharedTSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($page_id, 'mod.SHARED'); $languageIconTitles = array(); // fallback "old iconstyles" if (preg_match('/\\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) { $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace('.gif', '', $modSharedTSconfig['properties']['defaultLanguageFlag']); } $languageIconTitles[0] = array('uid' => 0, 'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage') . ')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage'), 'ISOcode' => 'DEF', 'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) ? 'flags-' . $modSharedTSconfig['properties']['defaultLanguageFlag'] : 'empty-empty'); // Set "All" language: $languageIconTitles[-1] = array('uid' => -1, 'title' => $GLOBALS['LANG']->getLL('multipleLanguages'), 'ISOcode' => 'DEF', 'flagIcon' => 'flags-multiple'); // Find all system languages: $sys_languages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_language', ''); foreach ($sys_languages as $row) { $languageIconTitles[$row['uid']] = $row; if ($row['static_lang_isocode'] && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) { $staticLangRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('static_languages', $row['static_lang_isocode'], 'lg_iso_2'); if ($staticLangRow['lg_iso_2']) { $languageIconTitles[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2']; } } if (strlen($row['flag'])) { $languageIconTitles[$row['uid']]['flagIcon'] = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconName('sys_language', $row); } } return $languageIconTitles; }
function main(&$backRef, $menuItems, $tableID, $srcId) { $this->backRef = $backRef; $this->beUser = $GLOBALS['BE_USER']; $this->LANG = $GLOBALS['LANG']; $this->includeLocalLang(); if (($tableID == 'dragDrop_tt_news_cat' || $tableID == 'tt_news_cat_CM') && $srcId) { $table = 'tt_news_cat'; $rec = BackendUtility::getRecordWSOL($table, $srcId); // fetch page record to get editing permissions $lCP = $this->beUser->calcPerms(BackendUtility::getRecord('pages', $rec['pid'])); $doEdit = $lCP & 16; // if ($doEdit && $tableID == 'dragDrop_tt_news_cat') { // $dstId = intval(GeneralUtility::_GP('dstId')); // $menuItems['moveinto'] = $this->dragDrop_moveCategory($srcId,$dstId); // $menuItems['copyinto'] = $this->dragDrop_copyCategory($srcId,$dstId); // } if ($tableID == 'tt_news_cat_CM') { $menuItems = array(); if ($doEdit) { $menuItems['edit'] = $this->DB_edit($table, $srcId); $menuItems['new'] = $this->DB_new($table, $rec); $menuItems['newsub'] = $this->DB_new($table, $rec, true); } $menuItems['info'] = $this->backRef->DB_info($table, $srcId); if ($doEdit) { $menuItems['hide'] = $this->DB_hideUnhide($table, $rec, 'hidden'); $elInfo = array(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle('tt_news_cat', $rec), $this->beUser->uc['titleLen'])); $menuItems['spacer2'] = 'spacer'; $menuItems['delete'] = $this->DB_delete($table, $srcId, $elInfo); } } } return $menuItems; }
/** * Get the referenced record from the database * * Using the GET or POST variable 'P' * * @return boolean|\TYPO3\CMS\Form\Domain\Model\Content if found, FALSE if not */ public function getRecord() { $record = FALSE; $getPostVariables = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('P'); $table = (string) $getPostVariables['table']; $recordId = (int) $getPostVariables['uid']; $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $recordId); if (is_array($row)) { // strip off the leading "[Translate to XY]" text after localizing the original record $languageField = $GLOBALS['TCA']['tt_content']['ctrl']['languageField']; $transOrigPointerField = $GLOBALS['TCA']['tt_content']['ctrl']['transOrigPointerField']; if ($row[$languageField] > 0 && $row[$transOrigPointerField] > 0) { $bodytext = preg_replace('/^\\[.*?\\] /', '', $row['bodytext'], 1); } else { $bodytext = $row['bodytext']; } /** @var $typoScriptParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */ $typoScriptParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser'); $typoScriptParser->parse($bodytext); /** @var $record \TYPO3\CMS\Form\Domain\Model\Content */ $record = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Domain\\Model\\Content'); $record->setUid($row['uid']); $record->setPageId($row['pid']); $record->setTyposcript($typoScriptParser->setup); } return $record; }
/** * Checks the page access rights (Code for access check mostly taken from FormEngine) * as well as the table access rights of the user. * * @param string $table The table to check access for * @param string $row Record array * @return bool Returns TRUE is the user has access, or FALSE if not */ public static function checkAccess($table, $row) { $backendUser = static::getBackendUser(); // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...) // First, resetting flags. $hasAccess = FALSE; $calcPRec = $row; BackendUtility::fixVersioningPid($table, $calcPRec); if (is_array($calcPRec)) { if ($table === 'pages') { // If pages: $calculatedPermissions = $backendUser->calcPerms($calcPRec); $hasAccess = $calculatedPermissions & Permission::PAGE_EDIT ? TRUE : FALSE; } else { $calculatedPermissions = $backendUser->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid'])); // Fetching pid-record first. $hasAccess = $calculatedPermissions & Permission::CONTENT_EDIT ? TRUE : FALSE; } // Check internals regarding access: if ($hasAccess) { $hasAccess = $backendUser->recordEditAccessInternals($table, $calcPRec); } } if (!$backendUser->check('tables_modify', $table)) { $hasAccess = FALSE; } return $hasAccess; }
/** * Building tcemain CMD-array for swapping all versions in a workspace. * * @param integer $wsid Real workspace ID, cannot be ONLINE (zero). * @param boolean $doSwap If set, then the currently online versions are swapped into the workspace in exchange for the offline versions. Otherwise the workspace is emptied. * @param int $pageId * @return array Command array for tcemain * @todo Define visibility */ public function getCmdArrayForPublishWS($wsid, $doSwap, $pageId = 0) { $wsid = (int) $wsid; $cmd = array(); if ($wsid >= -1 && $wsid !== 0) { // Define stage to select: $stage = -99; if ($wsid > 0) { $workspaceRec = BackendUtility::getRecord('sys_workspace', $wsid); if ($workspaceRec['publish_access'] & 1) { $stage = 10; } } // Select all versions to swap: $versions = $this->selectVersionsInWorkspace($wsid, 0, $stage, $pageId ? $pageId : -1); // Traverse the selection to build CMD array: foreach ($versions as $table => $records) { foreach ($records as $rec) { // Build the cmd Array: $cmd[$table][$rec['t3ver_oid']]['version'] = array('action' => 'swap', 'swapWith' => $rec['uid'], 'swapIntoWS' => $doSwap ? 1 : 0); } } } return $cmd; }
/** * Checks the page access rights (Code for access check mostly taken from alt_doc.php) * as well as the table access rights of the user. * * @param string $cmd: The command that sould be performed ('new' or 'edit') * @param string $table: The table to check access for * @param string $theUid: The record uid of the table * @return boolean Returns TRUE is the user has access, or FALSE if not */ public static function checkAccess($table, $row) { // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...) // First, resetting flags. $hasAccess = 0; $calcPRec = $row; \TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid($table, $calcPRec); if (is_array($calcPRec)) { if ($table == 'pages') { // If pages: $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec); $hasAccess = $CALC_PERMS & 2 ? 1 : 0; } else { $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $calcPRec['pid'])); // Fetching pid-record first. $hasAccess = $CALC_PERMS & 16 ? 1 : 0; } // Check internals regarding access: if ($hasAccess) { $hasAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($table, $calcPRec); } } if (!$GLOBALS['BE_USER']->check('tables_modify', $table)) { $hasAccess = 0; } return $hasAccess ? TRUE : FALSE; }
/** * Get the Records * * @param integer $startPage * @param array $basePages * @param Tx_GoogleServices_Controller_SitemapController $obj * * @return Tx_GoogleServices_Domain_Model_Node */ public function getRecords($startPage, $basePages, Tx_GoogleServices_Controller_SitemapController $obj) { $nodes = array(); $database = $this->getDatabaseConnection(); $res = $database->exec_SELECTquery('*', 'tt_content', 'CType="list" AND list_type="googleservices_pisitemap" AND hidden=0 AND deleted=0'); while ($row = $database->sql_fetch_assoc($res)) { $uid = $row['pid']; if ($uid == $GLOBALS['TSFE']->id) { continue; } // Build URL $url = $obj->getUriBuilder()->setTargetPageUid($uid)->build(); // can't generate a valid url if (!strlen($url)) { continue; } // Get Record $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $uid); // Build Node $node = new Tx_GoogleServices_Domain_Model_Node(); $node->setLoc($url); $node->setLastmod($this->getModifiedDate($record)); $nodes[] = $node; } return $nodes; }
/** * Analyses user groups * * @param array $reports * @return void */ protected function analyseUserGroups(&$reports) { /** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */ $service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService'); $userGroups = $service->findAllGroupsWithIpAuthentication(); if (empty($userGroups)) { // Message that no user group has IP authentication $reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', 'IP Usergroup Authentication', 'No user groups with IP authentication found', 'No user groups were found anywhere that are active and have an automatic IP authentication enabled.' . 'Your current IP is: <strong>' . $this->myIp . '</strong>', \TYPO3\CMS\Reports\Status::INFO); } else { $thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); $userGroupInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">'; $userGroupInfo .= '<thead><tr><th style="padding-bottom: 10px;">User Group</th><th>IP/Range</th></tr></thead>'; $userGroupInfo .= '<tbody>'; // Add user group strings foreach ($userGroups as $group) { $uid = $group['uid']; $ips = implode(', ', $group['tx_aoeipauth_ip']); $fullRecord = BackendUtility::getRecord('fe_groups', $uid); $title = $fullRecord['title']; $button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . $thisUrl . '&edit[fe_groups][' . $uid . ']=edit\'; return false;" href="#">' . '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open"> </span>' . '</a>'; $userGroupInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>'; } $userGroupInfo .= '</tbody>'; $userGroupInfo .= '</table>'; $userGroupInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>'; // Inform about the groups $reports[] = $this->objectManager->get('tx_reports_reports_status_Status', 'IP Usergroup Authentication', 'Some groups with automatic IP authentication were found.', $userGroupInfo, \TYPO3\CMS\Reports\Status::OK); } }
/** * Sets the TYPO3 Backend context to a certain workspace, * called by the Backend toolbar menu * * @param ServerRequestInterface $request * @param ResponseInterface $response * @return ResponseInterface */ public function switchWorkspaceAction(ServerRequestInterface $request, ResponseInterface $response) { $parsedBody = $request->getParsedBody(); $queryParams = $request->getQueryParams(); $workspaceId = (int) (isset($parsedBody['workspaceId']) ? $parsedBody['workspaceId'] : $queryParams['workspaceId']); $pageId = (int) (isset($parsedBody['pageId']) ? $parsedBody['pageId'] : $queryParams['pageId']); $finalPageUid = 0; $originalPageId = $pageId; $this->getBackendUser()->setWorkspace($workspaceId); while ($pageId) { $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')'); if ($page) { if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) { break; } } else { $page = BackendUtility::getRecord('pages', $pageId); } $pageId = $page['pid']; } if (isset($page['uid'])) { $finalPageUid = (int) $page['uid']; } $ajaxResponse = ['title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? null : $finalPageUid]; $response->getBody()->write(json_encode($ajaxResponse)); return $response; }
static function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$reference) { global $TCA; $tca =& $TCA[$table]['ctrl']['EXT']['wec_map']; $isMappable = $tca['isMappable']; if ($isMappable) { if ($tca['addressFields']) { /* Get the names of the fields from the TCA */ $streetField = tx_wecmap_shared::getAddressField($table, 'street'); $cityField = tx_wecmap_shared::getAddressField($table, 'city'); $stateField = tx_wecmap_shared::getAddressField($table, 'state'); $zipField = tx_wecmap_shared::getAddressField($table, 'zip'); $countryField = tx_wecmap_shared::getAddressField($table, 'country'); /* Get the row that we're saving */ $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id); /* @todo Eliminate double save */ self::drawGeocodeStatus($row[$streetField], $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField]); } else { if ($tca['latlongFields']) { /* Get the names of the fields from the TCA */ $latField = tx_wecmap_shared::getLatLongField($table, 'lat'); $longField = tx_wecmap_shared::getLatLongField($table, 'long'); /* Get the row that we're saving */ $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id); /* @todo Eliminate double save */ self::drawLatlongStatus($row[$latField], $row[$longField]); } } } }
/** * Generate a different preview link * * @param string $status status * @param string $table table name * @param integer $recordUid id of the record * @param array $fields fieldArray * @param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObject parent Object * @return void */ public function processDatamap_afterDatabaseOperations($status, $table, $recordUid, array $fields, \TYPO3\CMS\Core\DataHandling\DataHandler $parentObject) { // Clear category cache if ($table === 'sys_category') { /** @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache */ $cache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_news_category'); $cache->flush(); } // Preview link if ($table === 'tx_news_domain_model_news') { // direct preview if (!is_numeric($recordUid)) { $recordUid = $parentObject->substNEWwithIDs[$recordUid]; } if (isset($GLOBALS['_POST']['_savedokview_x']) && !$fields['type']) { // If "savedokview" has been pressed and current article has "type" 0 (= normal news article) $pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($GLOBALS['_POST']['popViewId']); if ($pagesTsConfig['tx_news.']['singlePid']) { $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('tx_news_domain_model_news', $recordUid); $parameters = array('no_cache' => 1, 'tx_news_pi1[controller]' => 'News', 'tx_news_pi1[action]' => 'detail', 'tx_news_pi1[news_preview]' => $record['uid']); if ($record['sys_language_uid'] > 0) { if ($record['l10n_parent'] > 0) { $parameters['tx_news_pi1[news_preview]'] = $record['l10n_parent']; } $parameters['L'] = $record['sys_language_uid']; } $GLOBALS['_POST']['popViewId_addParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $parameters, '', FALSE, TRUE); $GLOBALS['_POST']['popViewId'] = $pagesTsConfig['tx_news.']['singlePid']; } } } }
/** * Main function * Will issue a location-header, redirecting either BACK or to a new FormEngine instance... * * @return void */ public function main() { // Get this record $origRow = BackendUtility::getRecord($this->P['table'], $this->P['uid']); // Get TSconfig for it. $TSconfig = BackendUtility::getTCEFORM_TSconfig($this->table, is_array($origRow) ? $origRow : array('pid' => $this->P['pid'])); // Set [params][pid] if (substr($this->P['params']['pid'], 0, 3) === '###' && substr($this->P['params']['pid'], -3) === '###') { $keyword = substr($this->P['params']['pid'], 3, -3); if (strpos($keyword, 'PAGE_TSCONFIG_') === 0) { $this->pid = (int) $TSconfig[$this->P['field']][$keyword]; } else { $this->pid = (int) $TSconfig['_' . $keyword]; } } else { $this->pid = (int) $this->P['params']['pid']; } // Make redirect: // If pid is blank OR if id is set, then return... if ((string) $this->id !== '') { $redirectUrl = GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']); } else { // Otherwise, show the list: $urlParameters = array(); $urlParameters['id'] = $this->pid; $urlParameters['table'] = $this->P['params']['table']; $urlParameters['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI'); $redirectUrl = BackendUtility::getModuleUrl('web_list', $urlParameters); } HttpUtility::redirect($redirectUrl); }
/** * Get the Records * * @param integer $startPage * @param array $basePages * @param Tx_GoogleServices_Controller_SitemapController $obj * @return Tx_GoogleServices_Domain_Model_Node */ public function getRecords($startPage, $basePages, Tx_GoogleServices_Controller_SitemapController $obj) { $nodes = array(); foreach ($basePages as $uid) { // Build URL $url = $obj->getUriBuilder()->setTargetPageUid($uid)->build(); // can't generate a valid url if (!strlen($url)) { continue; } // Get Record $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $uid); // exclude Doctypes if (in_array($record['doktype'], array(4))) { continue; } // Build Node $node = new Tx_GoogleServices_Domain_Model_Node(); $node->setLoc($url); $node->setPriority($this->getPriority($startPage, $record)); $node->setChangefreq(Tx_GoogleServices_Service_SitemapDataService::mapTimeout2Period($record['cache_timeout'])); $node->setLastmod($this->getModifiedDate($record)); #$geo = new Tx_GoogleServices_Domain_Model_Node_Geo(); #$geo->setFormat('kml'); #$node->setGeo($geo); $nodes[] = $node; } return $nodes; }
/** * This method is called by a hook in the TYPO3 core when a record is saved. * * We use the tx_linkhandler for backend "save & show" button to display records on the configured detail view page. * * @param string $status Type of database operation i.e. new/update. * @param string $table The table currently being processed. * @param integer $id The records id (if any). * @param array $fieldArray The field names and their values to be processed (passed by reference). * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj Reference to the parent object. */ public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $pObj) { if (isset($GLOBALS['_POST']['_savedokview_x'])) { $settingFound = FALSE; $currentPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($GLOBALS['_POST']['popViewId']); $rootPageData = $this->getRootPage($currentPageId); $defaultPageId = isset($rootPageData) && array_key_exists('uid', $rootPageData) ? $rootPageData['uid'] : $currentPageId; $pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($currentPageId); $handlerConfigurationStruct = $pagesTsConfig['mod.']['tx_linkhandler.']; // search for the current setting for given table foreach ($pagesTsConfig['mod.']['tx_linkhandler.'] as $key => $handler) { if (is_array($handler) && $handler['listTables'] === $table) { $settingFound = TRUE; $selectedConfiguration = $key; break; } } if ($settingFound) { $l18nPointer = array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl']) ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] : ''; if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) { $id = $pObj->substNEWwithIDs[$id]; } if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) { $recordArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id); } else { $recordArray = $fieldArray; } if (array_key_exists('previewPageId', $handlerConfigurationStruct[$selectedConfiguration]) && \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']) > 0) { $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']); } else { $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($defaultPageId); } if ($GLOBALS['BE_USER']->workspace != 0) { $timeToLiveHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) ? intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) : 24 * 2; $wsPreviewValue = ';' . $GLOBALS['BE_USER']->workspace . ':' . $GLOBALS['BE_USER']->user['uid'] . ':' . 60 * 60 * $timeToLiveHours; // get record UID for if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) { $id = $recordArray[$l18nPointer]; } elseif (array_key_exists('t3ver_oid', $recordArray) && intval($recordArray['t3ver_oid']) > 0) { // this makes no sense because we already receive the UID of the WS-Placeholder which will be the real record in the LIVE-WS $id = $recordArray['t3ver_oid']; } } else { $wsPreviewValue = ''; if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) { $id = $recordArray[$l18nPointer]; } } $previewDomainRootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($previewPageId); $previewDomain = \TYPO3\CMS\Backend\Utility\BackendUtility::getViewDomain($previewPageId, $previewDomainRootline); $linkParamValue = 'record:' . $table . ':' . $id; $queryString = '&eID=linkhandlerPreview&linkParams=' . urlencode($linkParamValue . $wsPreviewValue); $languageParam = '&L=' . $recordArray['sys_language_uid']; $queryString .= $languageParam . '&authCode=' . \TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode($linkParamValue . $wsPreviewValue . intval($recordArray['sys_language_uid']), '', 32); $GLOBALS['_POST']['viewUrl'] = $previewDomain . '/index.php?id=' . $previewPageId . $queryString . '&y='; $GLOBALS['_POST']['popViewId_addParams'] = $queryString; } } }
/** * Fetch the record and set the crop value if the record is available * * @param int $uid the ID of the record * @param array $fieldArray the field array to modify * @return array the modified field array */ protected function getCropValueFromRecord($uid, $fieldArray) { $parent = BackendUtility::getRecord($this->table, $uid); if (is_array($parent)) { $fieldArray['crop'] = $parent['crop']; } return $fieldArray; }
/** * @return array */ protected function insertRecordWithRadioFieldValue($value) { // pid 88 comes from LiveDefaultPages $result = $this->actionService->createNewRecord('tt_content', 88, array('tx_testdatahandler_radio' => $value)); $recordUid = $result['tt_content'][0]; $record = BackendUtility::getRecord('tt_content', $recordUid); return $record; }
protected function getTargetPage() { $targetPageId = $this->getFieldFromFlexform('targetPage'); if (!empty($targetPageId)) { $page = BackendUtility::getRecord('pages', $targetPageId, 'title'); $this->settings['Target Page'] = '[' . (int) $targetPageId . '] ' . $page['title']; } }
/** * Get domain from database just once.. * If already retrieved, just return element * * @param integer $domainId * @return array */ public function getDomain($domainId) { static $results; if (!isset($results[$domainId])) { $results[$domainId] = BackendUtility::getRecord('sys_domain', $domainId); } return $results[$domainId]; }
/** * Constructor. * * @param integer $rootPageId Site root page ID (uid). The page must be marked as site root ("Use as Root Page" flag). */ public function __construct($rootPageId) { $page = BackendUtility::getRecord('pages', $rootPageId); if (!$page['is_siteroot']) { throw new \InvalidArgumentException('The page for the given page ID \'' . $rootPageId . '\' is not marked as root page and can therefore not be used as site root page.', 1309272922); } $this->rootPage = $page; }
/** * Render the sprite icon * * @param string $table table name * @param integer $uid uid of record * @param string $title title * @return string sprite icon */ public function render($table, $uid, $title) { $icon = ''; $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $uid); if (is_array($row)) { $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($title))); } return $icon; }
public function countOfPartners(&$parameters, $parentObject) { // DebugUtility::debug($parameters); // DebugUtility::debug(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($parameters['table'], $parameters['row']['uid'])); $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($parameters['table'], $parameters['row']['uid']); $newTitle = $record['name']; // $newTitle .= ' (' . substr(strip_tags($record['name']), 0, 10) . '...)'; $parameters['title'] = $newTitle; }
/** * Creates the version selector for the page id inputted. * Moved out of the core file \TYPO3\CMS\Backend\Template\DocumentTemplate * * @param int $id Page id to create selector for. * @param bool $noAction If set, there will be no button for swapping page. * @return void * @see \TYPO3\CMS\Backend\Template\DocumentTemplate */ public function getVersionSelector($id, $noAction = FALSE) { if ($id <= 0) { return; } if ($GLOBALS['BE_USER']->workspace == 0) { // Get Current page record: $curPage = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $id); // If the selected page is not online, find the right ID $onlineId = $curPage['pid'] == -1 ? $curPage['t3ver_oid'] : $id; // Select all versions of online version: $versions = \TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_wsid,t3ver_id'); // If more than one was found...: if (count($versions) > 1) { $selectorLabel = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:versionSelect.label', TRUE) . '</strong>'; // Create selector box entries: $opt = array(); foreach ($versions as $vRow) { if ($vRow['uid'] == $onlineId) { // Live version $label = '[' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:versionSelect.live', TRUE) . ']'; } else { $label = $vRow['t3ver_label'] . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:versionId', TRUE) . ' ' . $vRow['t3ver_id'] . ($vRow['t3ver_wsid'] != 0 ? ' ' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:workspaceId', TRUE) . ' ' . $vRow['t3ver_wsid'] : '') . ')'; } $opt[] = '<option value="' . htmlspecialchars(GeneralUtility::linkThisScript(array('id' => $vRow['uid']))) . '"' . ($id == $vRow['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>'; } // Add management link: $management = '<input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.mgm', TRUE) . '" onclick="window.location.href=\'' . htmlspecialchars($GLOBALS['BACK_PATH'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', array('table' => 'pages', 'uid' => $onlineId))) . '\';" />'; // Create onchange handler: $onChange = 'window.location.href=this.options[this.selectedIndex].value;'; // Controls: if ($id == $onlineId) { $controls = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="absmiddle" alt="" /> <strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.online', TRUE) . '</strong>'; } elseif (!$noAction) { $href = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][swapWith]=' . $id . '&cmd[pages][' . $onlineId . '][version][action]=swap', GeneralUtility::linkThisScript(array('id' => $onlineId))); $controls = '<a href="' . htmlspecialchars($href) . '" class="text-nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-version-swap-version', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.swapPage', TRUE), 'style' => 'margin-left:5px;vertical-align:bottom;')) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.swap', TRUE) . '</strong></a>'; } // Write out HTML code: return ' <!-- Version selector: --> <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector"> <tr> <td>' . $selectorLabel . '</td> <td> <select onchange="' . htmlspecialchars($onChange) . '"> ' . implode('', $opt) . ' </select></td> <td>' . $controls . '</td> <td>' . $management . '</td> </tr> </table> '; } } }
function propertiesBasedTitle(&$parameters, $parentObject) { $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($parameters['table'], $parameters['row']['uid']); if (false === is_null($record)) { $this->initializeViewVariables($record); $pop = $record['header']; $parameters['title'] = json_encode($this->settings); // $type.'[Uid: '.$record['uid'].'] '.(empty($pop) ? ' ->' : '').$pop; } }
/** * Overrides the icon overlay with a LDAP symbol, if needed. * * @param string $table The current database table * @param array $row The current record * @param array &$status The array of associated statuses * @return void * @see \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordOverlayToSpriteIconName() */ public function overrideIconOverlay($table, array $row, array &$status) { if (GeneralUtility::inList('be_groups,be_users,fe_groups,fe_users', $table)) { if (!array_key_exists('tx_igldapssoauth_dn', $row)) { // This is the case, e.g., in Backend users module $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $row['uid']); } $status['is_ldap_record'] = !empty($row['tx_igldapssoauth_dn']); } }
function getUserLabelRaceResult(&$params, &$pObj) { $uid = $params['row']['uid']; $raceresult = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('tx_mtbraceresult_domain_model_raceresult', $uid); $racer = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('tx_mtbraceresult_domain_model_racer', $raceresult['racer']); $race = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('tx_mtbraceresult_domain_model_race', $raceresult['race']); if (isset($racer) && isset($race)) { $params['title'] = sprintf("%s / %s / %s", $race['date'], $racer['name'], $race['location']); } }
/** * @param array $params * @param object $pObj */ function getActorTitle(&$params, $pObj) { $data = BackendUtility::getRecord($params['table'], $params['row']['uid']); // Person if ($data['type'] == '0') { $params['title'] = $data['lastname'] . ', ' . $data['firstname']; } else { $params['title'] = $data['company']; } }