本文整理汇总了PHP中TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendUtility::getRecordsByField方法的具体用法?PHP BackendUtility::getRecordsByField怎么用?PHP BackendUtility::getRecordsByField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Backend\Utility\BackendUtility
的用法示例。
在下文中一共展示了BackendUtility::getRecordsByField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canHandleLink
/**
* Checks if this is the handler for the given link
*
* The handler may store this information locally for later usage.
*
* @param array $linkParts Link parts as returned from TypoLinkCodecService
*
* @return bool
*/
public function canHandleLink(array $linkParts)
{
if (!$linkParts['url']) {
return false;
}
$id = $linkParts['url'];
$parts = explode('#', $id);
if (count($parts) > 1) {
$id = $parts[0];
$anchor = $parts[1];
} else {
$anchor = '';
}
// Checking if the id-parameter is an alias.
if (!MathUtility::canBeInterpretedAsInteger($id)) {
$records = BackendUtility::getRecordsByField('pages', 'alias', $id);
if (empty($records)) {
return false;
}
$id = (int) $records[0]['uid'];
}
$pageRow = BackendUtility::getRecordWSOL('pages', $id);
if (!$pageRow) {
return false;
}
$this->linkParts = $linkParts;
$this->linkParts['pageid'] = $id;
$this->linkParts['anchor'] = $anchor;
return true;
}
示例2: getDomains
/**
* Get all domains from database just once..
* If already retrieved, just return element
*
* @return array
*/
public function getDomains()
{
static $results;
if (!isset($results)) {
$results = BackendUtility::getRecordsByField('sys_domain', 'redirectTo', '');
}
return $results;
}
示例3: getModelSitesList
/**
* Gets an ordered list of the pages with the "Model site" flag set.
*
* @return array The model sites in an array. Empty array if no model was found.
*/
public static function getModelSitesList()
{
$modelSitesPid = Core::getExtensionConfiguration('modelSitesPid');
$aModelSites = BackendUtility::getRecordsByField('pages', 'pid', $modelSitesPid);
$orderedModelSites = array();
if (is_array($aModelSites)) {
foreach ($aModelSites as $modelSite) {
$orderedModelSites[$modelSite['uid']] = $modelSite['title'] . ' (' . $modelSite['uid'] . ')';
}
}
return $orderedModelSites;
}
示例4: getAdditionalFields
/**
* This method is used to define new fields for adding or editing a task
* In this case, it adds an email field
*
* @param array $taskInfo reference to the array containing the info used in the add/edit form
* @param object $task when editing, reference to the current task object. Null when adding.
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject reference to the calling object (Scheduler's BE module)
*
* @return array Array containg all the information pertaining to the additional fields
* The array is multidimensional, keyed to the task class name and each field's id
* For each field it provides an associative sub-array with the following:
* ['code'] => The HTML code for the field
* ['label'] => The label of the field (possibly localized)
* ['cshKey'] => The CSH key for the field
* ['cshLabel'] => The code of the CSH label
*/
public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $parentObject)
{
// Initialize extra field value
if (empty($taskInfo['selecteddraft'])) {
if ($parentObject->CMD == 'edit') {
// In case of edit, and editing a test task, set to internal value if not data was submitted already
$taskInfo['selecteddraft'] = $task->draftUid;
} else {
// Otherwise set an empty value, as it will not be used anyway
$taskInfo['selecteddraft'] = '';
}
}
// fetch all available drafts
$drafts = array();
$draftsInternal = BackendUtility::getRecordsByField('sys_dmail', 'type', 2);
$draftsExternal = BackendUtility::getRecordsByField('sys_dmail', 'type', 3);
if (is_array($draftsInternal)) {
$drafts = array_merge($drafts, $draftsInternal);
}
if (is_array($draftsExternal)) {
$drafts = array_merge($drafts, $draftsExternal);
}
// Create the input field
$fieldID = 'task_selecteddraft';
$fieldHtml = '';
if (count($drafts) === 0) {
// TODO: localization
$fieldHtml .= '<option>' . 'No drafts found. Please add one first through the direct mail process' . '</option>';
} else {
foreach ($drafts as $draft) {
// see #44577
$selected = $task->draftUid == $draft['uid'] ? ' selected="selected"' : '';
$fieldHtml .= '<option value="' . $draft['uid'] . '"' . $selected . '>' . $draft['subject'] . ' [' . $draft['uid'] . ']</option>';
}
}
$fieldHtml = '<select name="tx_scheduler[selecteddraft]" id="' . $fieldID . '">' . $fieldHtml . '</select>';
$additionalFields = array();
$additionalFields[$fieldID] = array('code' => $fieldHtml, 'label' => 'Choose Draft to create DirectMail from', 'cshKey' => '', 'cshLabel' => $fieldID);
return $additionalFields;
}
示例5: processDatamap_afterDatabaseOperations
/**
* 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 DataHandling\DataHandler $parentObject parent Object
*
* @return void
*/
public function processDatamap_afterDatabaseOperations($status, $table, $recordUid, array $fields, DataHandling\DataHandler $parentObject)
{
if (in_array($status, array('new', 'update')) && !in_array($table, array('tt_content', 'pages', 'sys_file_reference'))) {
$record = BackendUtility::getRecord($table, $recordUid);
if ((int) $record['sys_language_uid'] > 0) {
// Ref Parent depend of context
$uidForeign = $table === 'pages_language_overlay' ? (int) $record['pid'] : (int) $record['l10n_parent'];
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('fieldname', 'sys_file_reference', "tablenames='{$table}' AND uid_foreign=" . $uidForeign . BackendUtility::deleteClause('sys_file_reference'), 'fieldname', 'fieldname');
$fieldnames = array();
foreach ($rows as $row) {
$fieldnames[] = $row['fieldname'];
}
foreach ($fieldnames as $fieldname) {
$references = BackendUtility::getRecordsByField('sys_file_reference', 'tablenames', $table, 'AND uid_foreign=' . $recordUid . " AND fieldname='{$fieldname}'", '', 'sorting ASC');
$l10nParents = BackendUtility::getRecordsByField('sys_file_reference', 'uid_foreign', $uidForeign, " AND fieldname='{$fieldname}'", '', 'sorting ASC');
if ($references) {
for ($i = 0; count($references) > $i; $i++) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_file_reference', 'uid=' . $references[$i]['uid'], array('sys_language_uid' => $record['sys_language_uid'], 'l10n_parent' => isset($l10nParents[$i]) && isset($l10nParents[$i]['uid']) ? $l10nParents[$i]['uid'] : 0));
}
}
}
}
}
}
示例6: deleteL10nOverlayRecords
/**
* Find l10n-overlay records and perform the requested delete action for these records.
*
* @param string $table Record Table
* @param string $uid Record UID
* @return void
*/
public function deleteL10nOverlayRecords($table, $uid)
{
// Check whether table can be localized or has a different table defined to store localizations:
if (!BackendUtility::isTableLocalizable($table) || !empty($GLOBALS['TCA'][$table]['ctrl']['transForeignTable']) || !empty($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
return;
}
$where = '';
if (isset($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
$where = ' AND t3ver_oid=0';
}
$l10nRecords = BackendUtility::getRecordsByField($table, $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], $uid, $where);
if (is_array($l10nRecords)) {
foreach ($l10nRecords as $record) {
// Ignore workspace delete placeholders. Those records have been marked for
// deletion before - deleting them again in a workspace would revert that state.
if ($this->BE_USER->workspace > 0 && BackendUtility::isTableWorkspaceEnabled($table)) {
BackendUtility::workspaceOL($table, $record);
if (VersionState::cast($record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
continue;
}
}
$this->deleteAction($table, (int) $record['t3ver_oid'] > 0 ? (int) $record['t3ver_oid'] : (int) $record['uid']);
}
}
}
示例7: editPageIdFunc
/**
* If "editPage" value is sent to script and it points to an accessible page, the internal var $this->theEditRec is set to the page record which should be loaded.
* Returns void
*
* @return void
* @todo Define visibility
*/
public function editPageIdFunc()
{
if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
return;
}
// EDIT page:
$this->editPage = trim($GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $this->editPage, 'toLower'));
$this->editError = '';
$this->theEditRec = '';
$this->searchFor = '';
if ($this->editPage) {
// First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
$this->alternativeTableUid = explode(':', $this->editPage);
// We restrict it to admins only just because I'm not really sure if alt_doc.php properly
// checks permissions of passed records for editing. If alt_doc.php does that, then we can remove this.
if (!(count($this->alternativeTableUid) == 2 && $GLOBALS['BE_USER']->isAdmin())) {
$where = ' AND (' . $GLOBALS['BE_USER']->getPagePermsClause(2) . ' OR ' . $GLOBALS['BE_USER']->getPagePermsClause(16) . ')';
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->editPage)) {
$this->theEditRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $this->editPage, '*', $where);
} else {
$records = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $this->editPage, $where);
if (is_array($records)) {
$this->theEditRec = reset($records);
\TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $this->theEditRec);
}
}
if (!is_array($this->theEditRec)) {
unset($this->theEditRec);
$this->searchFor = $this->editPage;
} elseif (!$GLOBALS['BE_USER']->isInWebMount($this->theEditRec['uid'])) {
unset($this->theEditRec);
$this->editError = $GLOBALS['LANG']->getLL('bookmark_notEditable');
} else {
// Visual path set:
$perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
$this->editPath = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
if (!$GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
$bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
// Expanding page tree:
\TYPO3\CMS\Backend\Utility\BackendUtility::openPageTree($this->theEditRec['pid'], !$bookmarkKeepExpanded);
}
}
}
}
}
示例8: TS_links_rte
/**
* Transformation handler: 'ts_links' / direction: "rte"
* Converting <link tags> to <A>-tags
*
* @param string $value Content input
* @return string Content output
* @see TS_links_rte()
* @todo Define visibility
*/
public function TS_links_rte($value)
{
$conf = array();
$value = $this->TS_AtagToAbs($value);
// Split content by the TYPO3 pseudo tag "<link>":
$blockSplit = $this->splitIntoBlock('link', $value, 1);
$siteUrl = $this->siteUrl();
foreach ($blockSplit as $k => $v) {
$error = '';
$external = FALSE;
// Block
if ($k % 2) {
$tagCode = \TYPO3\CMS\Core\Utility\GeneralUtility::unQuoteFilenames(trim(substr($this->getFirstTag($v), 0, -1)), TRUE);
$link_param = $tagCode[1];
$href = '';
// Parsing the typolink data. This parsing is roughly done like in tslib_content->typolink()
if (strstr($link_param, '@')) {
// mailadr
$href = 'mailto:' . preg_replace('/^mailto:/i', '', $link_param);
} elseif (substr($link_param, 0, 1) == '#') {
// check if anchor
$href = $siteUrl . $link_param;
} else {
// Check for FAL link-handler keyword:
list($linkHandlerKeyword, $linkHandlerValue) = explode(':', trim($link_param), 2);
if ($linkHandlerKeyword === 'file') {
$href = $siteUrl . '?' . $linkHandlerKeyword . ':' . rawurlencode($linkHandlerValue);
} else {
$fileChar = intval(strpos($link_param, '/'));
$urlChar = intval(strpos($link_param, '.'));
// Parse URL:
$pU = parse_url($link_param);
// Detects if a file is found in site-root.
list($rootFileDat) = explode('?', $link_param);
$rFD_fI = pathinfo($rootFileDat);
if (trim($rootFileDat) && !strstr($link_param, '/') && (@is_file(PATH_site . $rootFileDat) || \TYPO3\CMS\Core\Utility\GeneralUtility::inList('php,html,htm', strtolower($rFD_fI['extension'])))) {
$href = $siteUrl . $link_param;
} elseif ($pU['scheme'] || $urlChar && (!$fileChar || $urlChar < $fileChar)) {
// url (external): if has scheme or if a '.' comes before a '/'.
$href = $link_param;
if (!$pU['scheme']) {
$href = 'http://' . $href;
}
$external = TRUE;
} elseif ($fileChar) {
// file (internal)
$href = $siteUrl . $link_param;
} else {
// integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to tables.php!!)
// Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/parameters triplet
$pairParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $link_param, TRUE);
$idPart = $pairParts[0];
$link_params_parts = explode('#', $idPart);
$idPart = trim($link_params_parts[0]);
$sectionMark = trim($link_params_parts[1]);
if (!strcmp($idPart, '')) {
$idPart = $this->recPid;
}
// If no id or alias is given, set it to class record pid
// Checking if the id-parameter is an alias.
if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($idPart)) {
list($idPartR) = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $idPart);
$idPart = intval($idPartR['uid']);
}
$page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $idPart);
if (is_array($page)) {
// Page must exist...
$href = $siteUrl . '?id=' . $idPart . ($pairParts[2] ? $pairParts[2] : '') . ($sectionMark ? '#' . $sectionMark : '');
} elseif (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][array_shift(explode(':', $link_param))])) {
$href = $link_param;
} else {
$href = $siteUrl . '?id=' . $link_param;
$error = 'No page found: ' . $idPart;
}
}
}
}
// Setting the A-tag:
$bTag = '<a href="' . htmlspecialchars($href) . '"' . ($tagCode[2] && $tagCode[2] != '-' ? ' target="' . htmlspecialchars($tagCode[2]) . '"' : '') . ($tagCode[3] && $tagCode[3] != '-' ? ' class="' . htmlspecialchars($tagCode[3]) . '"' : '') . ($tagCode[4] ? ' title="' . htmlspecialchars($tagCode[4]) . '"' : '') . ($external ? ' data-htmlarea-external="1"' : '') . ($error ? ' rteerror="' . htmlspecialchars($error) . '" style="background-color: yellow; border:2px red solid; color: black;"' : '') . '>';
$eTag = '</a>';
// Modify parameters
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['modifyParams_LinksRte_PostProc']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['modifyParams_LinksRte_PostProc'])) {
$parameters = array('conf' => &$conf, 'currentBlock' => $v, 'url' => $href, 'tagCode' => $tagCode, 'external' => $external, 'error' => $error);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['modifyParams_LinksRte_PostProc'] as $objRef) {
$processor = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef);
$blockSplit[$k] = $processor->modifyParamsLinksRte($parameters, $this);
}
} else {
$blockSplit[$k] = $bTag . $this->TS_links_rte($this->removeFirstAndLastTag($blockSplit[$k])) . $eTag;
}
}
//.........这里部分代码省略.........
示例9: getPageIdFromAlias
/**
* Look up and return page uid for alias
*
* @param integer $link_param Page alias string value
* @return integer Page uid corresponding to alias value.
* @todo Define visibility
*/
public function getPageIdFromAlias($link_param)
{
$pRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $link_param);
return $pRec[0]['uid'];
}
示例10: parseCurUrl
/**
* For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
*
* @param string $href HREF value tp analyse
* @param string $siteUrl The URL of the current website (frontend)
* @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
* @todo Define visibility
*/
public function parseCurUrl($href, $siteUrl)
{
$href = trim($href);
if ($href) {
$info = array();
// Default is "url":
$info['value'] = $href;
$info['act'] = 'url';
$specialParts = explode('#_SPECIAL', $href);
// Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
if (count($specialParts) == 2) {
$info['value'] = '#_SPECIAL' . $specialParts[1];
$info['act'] = 'spec';
} elseif (strpos($href, 'file:') !== FALSE) {
$rel = substr($href, strpos($href, 'file:') + 5);
$rel = rawurldecode($rel);
// resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
$fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
if ($fileOrFolderObject instanceof Folder) {
$info['act'] = 'folder';
$info['value'] = $fileOrFolderObject->getCombinedIdentifier();
} elseif ($fileOrFolderObject instanceof File) {
$info['act'] = 'file';
$info['value'] = $fileOrFolderObject->getUid();
} else {
$info['value'] = $rel;
}
} elseif (GeneralUtility::isFirstPartOfStr($href, $siteUrl)) {
// If URL is on the current frontend website:
// URL is a file, which exists:
if (file_exists(PATH_site . rawurldecode($href))) {
$info['value'] = rawurldecode($href);
if (@is_dir(PATH_site . $info['value'])) {
$info['act'] = 'folder';
} else {
$info['act'] = 'file';
}
} else {
// URL is a page (id parameter)
$uP = parse_url($href);
$pp = preg_split('/^id=/', $uP['query']);
$pp[1] = preg_replace('/&id=[^&]*/', '', $pp[1]);
$parameters = explode('&', $pp[1]);
$id = array_shift($parameters);
if ($id) {
// Checking if the id-parameter is an alias.
if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
list($idPartR) = BackendUtility::getRecordsByField('pages', 'alias', $id);
$id = (int) $idPartR['uid'];
}
$pageRow = BackendUtility::getRecordWSOL('pages', $id);
$titleLen = (int) $GLOBALS['BE_USER']->uc['titleLen'];
$info['value'] = $GLOBALS['LANG']->getLL('page', TRUE) . ' \'' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen)) . '\' (ID:' . $id . ($uP['fragment'] ? ', #' . $uP['fragment'] : '') . ')';
$info['pageid'] = $id;
$info['cElement'] = $uP['fragment'];
$info['act'] = 'page';
$info['query'] = $parameters[0] ? '&' . implode('&', $parameters) : '';
}
}
} else {
// Email link:
if (strtolower(substr($href, 0, 7)) == 'mailto:') {
$info['value'] = trim(substr($href, 7));
$info['act'] = 'mail';
}
}
$info['info'] = $info['value'];
} else {
// NO value inputted:
$info = array();
$info['info'] = $GLOBALS['LANG']->getLL('none');
$info['value'] = '';
$info['act'] = 'page';
}
// let the hook have a look
foreach ($this->hookObjects as $hookObject) {
$info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
}
return $info;
}
示例11: setData
/**
* Set all deleted rows
*
* @param integer $id: UID from record
* @param string $table: Tablename from record
* @param integer $depth: How many levels recursive
* @param array $ctrl: TCA CTRL Array
* @param string $filter: Filter text
* @return void
*/
protected function setData($id = 0, $table, $depth, $tcaCtrl, $filter)
{
$id = intval($id);
if (array_key_exists('delete', $tcaCtrl)) {
// find the 'deleted' field for this table
$deletedField = \TYPO3\CMS\Recycler\Utility\RecyclerUtility::getDeletedField($table);
// create the filter WHERE-clause
if (trim($filter) != '') {
$filterWhere = ' AND (' . (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($filter) ? 'uid = ' . $filter . ' OR pid = ' . $filter . ' OR ' : '') . $tcaCtrl['label'] . ' LIKE "%' . $this->escapeValueForLike($filter, $table) . '%"' . ')';
}
// get the limit
if ($this->limit != '') {
// count the number of deleted records for this pid
$deletedCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $table, $deletedField . '<>0 AND pid = ' . $id . $filterWhere);
// split the limit
$parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->limit);
$offset = $parts[0];
$rowCount = $parts[1];
// subtract the number of deleted records from the limit's offset
$result = $offset - $deletedCount;
// if the result is >= 0
if ($result >= 0) {
// store the new offset in the limit and go into the next depth
$offset = $result;
$this->limit = implode(',', array($offset, $rowCount));
// do NOT query this depth; limit also does not need to be set, we set it anyways
$allowQuery = FALSE;
$allowDepth = TRUE;
$limit = '';
} else {
// the offset for the temporary limit has to remain like the original offset
// in case the original offset was just crossed by the amount of deleted records
if ($offset != 0) {
$tempOffset = $offset;
} else {
$tempOffset = 0;
}
// set the offset in the limit to 0
$newOffset = 0;
// convert to negative result to the positive equivalent
$absResult = abs($result);
// if the result now is > limit's row count
if ($absResult > $rowCount) {
// use the limit's row count as the temporary limit
$limit = implode(',', array($tempOffset, $rowCount));
// set the limit's row count to 0
$this->limit = implode(',', array($newOffset, 0));
// do not go into new depth
$allowDepth = FALSE;
} else {
// if the result now is <= limit's row count
// use the result as the temporary limit
$limit = implode(',', array($tempOffset, $absResult));
// subtract the result from the row count
$newCount = $rowCount - $absResult;
// store the new result in the limit's row count
$this->limit = implode(',', array($newOffset, $newCount));
// if the new row count is > 0
if ($newCount > 0) {
// go into new depth
$allowDepth = TRUE;
} else {
// if the new row count is <= 0 (only =0 makes sense though)
// do not go into new depth
$allowDepth = FALSE;
}
}
// allow query for this depth
$allowQuery = TRUE;
}
} else {
$limit = '';
$allowDepth = TRUE;
$allowQuery = TRUE;
}
// query for actual deleted records
if ($allowQuery) {
$recordsToCheck = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField($table, $deletedField, '1', ' AND pid = ' . $id . $filterWhere, '', '', $limit, FALSE);
if ($recordsToCheck) {
$this->checkRecordAccess($table, $recordsToCheck);
}
}
// go into depth
if ($allowDepth && $depth >= 1) {
// check recursively for elements beneath this page
$resPages = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid=' . $id, '', 'sorting');
if (is_resource($resPages)) {
while ($rowPages = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resPages)) {
$this->setData($rowPages['uid'], $table, $depth - 1, $tcaCtrl, $filter);
// some records might have been added, check if we still have the limit for further queries
//.........这里部分代码省略.........
示例12: makeQuickEditMenu
/**
* @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;
}
示例13: checkFullLanguagesAccess
/**
* Check if user has access to all existing localizations for a certain record
*
* @param string $table The table
* @param array $record The current record
* @return boolean
* @todo Define visibility
*/
public function checkFullLanguagesAccess($table, $record)
{
$recordLocalizationAccess = $this->checkLanguageAccess(0);
if ($recordLocalizationAccess && (BackendUtility::isTableLocalizable($table) || isset($GLOBALS['TCA'][$table]['ctrl']['transForeignTable']))) {
if (isset($GLOBALS['TCA'][$table]['ctrl']['transForeignTable'])) {
$l10nTable = $GLOBALS['TCA'][$table]['ctrl']['transForeignTable'];
$pointerField = $GLOBALS['TCA'][$l10nTable]['ctrl']['transOrigPointerField'];
$pointerValue = $record['uid'];
} else {
$l10nTable = $table;
$pointerField = $GLOBALS['TCA'][$l10nTable]['ctrl']['transOrigPointerField'];
$pointerValue = $record[$pointerField] > 0 ? $record[$pointerField] : $record['uid'];
}
$recordLocalizations = BackendUtility::getRecordsByField($l10nTable, $pointerField, $pointerValue, '', '', '', '1');
if (is_array($recordLocalizations)) {
foreach ($recordLocalizations as $localization) {
$recordLocalizationAccess = $recordLocalizationAccess && $this->checkLanguageAccess($localization[$GLOBALS['TCA'][$l10nTable]['ctrl']['languageField']]);
if (!$recordLocalizationAccess) {
break;
}
}
}
}
return $recordLocalizationAccess;
}
示例14: renderQuickEdit
/**
* Rendering the quick-edit view.
*
* @return void
* @todo Define visibility
*/
public function renderQuickEdit()
{
// Alternative template
$this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
// Alternative form tag; Quick Edit submits its content to tce_db.php.
$this->doc->form = '<form action="' . htmlspecialchars($GLOBALS['BACK_PATH'] . 'tce_db.php?&prErr=1&uPT=1') . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
// Setting up the context sensitive menu:
$this->doc->getContextMenuCode();
// Set the edit_record value for internal use in this function:
$edit_record = $this->edit_record;
// If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
if (substr($edit_record, 0, 9) == '_EDIT_COL') {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND colPos=' . intval(substr($edit_record, 10)) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_content')) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
$idListA = array();
while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$idListA[] = $cRow['uid'];
}
$url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
}
// If the former record edited was the creation of a NEW record, this will look up the created records uid:
if ($this->new_unique_uid) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'userid=' . intval($GLOBALS['BE_USER']->user['uid']) . ' AND NEWid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->new_unique_uid, 'sys_log'));
$sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
if (is_array($sys_log_row)) {
$edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
}
}
// Creating the selector box, allowing the user to select which element to edit:
$opt = array();
$is_selected = 0;
$languageOverlayRecord = '';
if ($this->current_sys_language) {
list($languageOverlayRecord) = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . intval($this->current_sys_language));
}
if (is_array($languageOverlayRecord)) {
$inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
$is_selected += intval($edit_record == $inValue);
$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', 1) . ' ]</option>';
} else {
$inValue = 'pages:' . $this->id;
$is_selected += intval($edit_record == $inValue);
$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', 1) . ' ]</option>';
}
// Selecting all content elements from this language and allowed colPos:
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_content')) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
$colPos = '';
$first = 1;
// Page is the pid if no record to put this after.
$prev = $this->id;
while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
\TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('tt_content', $cRow);
if (is_array($cRow)) {
if ($first) {
if (!$edit_record) {
$edit_record = 'tt_content:' . $cRow['uid'];
}
$first = 0;
}
if (strcmp($cRow['colPos'], $colPos)) {
$colPos = $cRow['colPos'];
$opt[] = '<option value=""></option>';
$opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), 1) . ':__</option>';
}
$inValue = 'tt_content:' . $cRow['uid'];
$is_selected += intval($edit_record == $inValue);
$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $GLOBALS['BE_USER']->uc['titleLen'])) . '</option>';
$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;
$is_selected += intval($edit_record == $inValue);
$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
}
// If none is yet selected...
if (!$is_selected) {
$opt[] = '<option value=""></option>';
$opt[] = '<option value="' . $edit_record . '" selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
}
// Splitting the edit-record cmd value into table/uid:
$this->eRParts = explode(':', $edit_record);
// Delete-button flag?
$this->deleteButton = \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
// If undo-button should be rendered (depends on available items in sys_history)
$this->undoButton = 0;
$undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . intval($this->eRParts[1]), '', 'tstamp DESC', '1');
if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
$this->undoButton = 1;
}
// Setting up the Return URL for coming back to THIS script (if links take the user to another script)
$R_URL_parts = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'));
//.........这里部分代码省略.........
示例15: handlePageEditing
/**
* Checking if the "&edit" variable was sent so we can open it for editing the page.
* Code based on code from "alt_shortcut.php"
*
* @return void
*/
protected function handlePageEditing()
{
if (!\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('cms')) {
return;
}
// EDIT page:
$editId = preg_replace('/[^[:alnum:]_]/', '', \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('edit'));
$editRecord = '';
if ($editId) {
// Looking up the page to edit, checking permissions:
$where = ' AND (' . $GLOBALS['BE_USER']->getPagePermsClause(2) . ' OR ' . $GLOBALS['BE_USER']->getPagePermsClause(16) . ')';
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($editId)) {
$editRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $editId, '*', $where);
} else {
$records = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $editId, $where);
if (is_array($records)) {
$editRecord = reset($records);
\TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $editRecord);
}
}
// If the page was accessible, then let the user edit it.
if (is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
// Setting JS code to open editing:
$this->js .= '
// Load page to edit:
window.setTimeout("top.loadEditId(' . intval($editRecord['uid']) . ');", 500);
';
// Checking page edit parameter:
if (!$GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
$bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
// Expanding page tree:
\TYPO3\CMS\Backend\Utility\BackendUtility::openPageTree(intval($editRecord['pid']), !$bookmarkKeepExpanded);
}
} else {
$this->js .= '
// Warning about page editing:
alert(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)) . ');
';
}
}
}