2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * New database item menu
31 * This script lets users choose a new database element to create.
32 * Includes a wizard mode for visually pointing out the position of new pages
34 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
42 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
45 * Extension for the tree class that generates the tree of pages in the page-wizard mode
47 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
51 class localPageTree
extends t3lib_pageTree
{
54 * Inserting uid-information in title-text for an icon
56 * @param string $icon Icon image
57 * @param array $row Item row
58 * @return string Wrapping icon image.
60 function wrapIcon($icon, $row) {
61 return $this->addTagAttributes($icon, ' title="id='.htmlspecialchars($row['uid']).'"');
65 * Determines whether to expand a branch or not.
66 * Here the branch is expanded if the current id matches the global id for the listing/new
68 * @param integer $id The ID (page id) of the element
69 * @return boolean Returns TRUE if the IDs matches
71 function expandNext($id) {
72 return $id == $GLOBALS['SOBE']->id ?
1 : 0;
77 * Script class for 'db_new'
79 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
91 * Determines, whether "Select Position" for new page should be shown
92 * @var bool $newPagesSelectPosition
94 protected $newPagesSelectPosition = TRUE;
96 var $web_list_modTSconfig;
97 var $allowedNewTables;
99 var $web_list_modTSconfig_pid;
100 var $allowedNewTables_pid;
101 var $deniedNewTables_pid;
105 // Internal, static: GPvar
118 * Document template object
123 // Accumulated HTML output
128 * Constructor function for the class
134 // Page-selection permission clause (reading)
135 $this->perms_clause
= $GLOBALS['BE_USER']->getPagePermsClause(1);
137 // This will hide records from display - it has nothing to do with user rights!!
138 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
139 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
140 $this->perms_clause
.= ' AND pages.uid NOT IN ('.$pidList.')';
144 // The page id to operate from
145 $this->id
= intval(t3lib_div
::_GP('id'));
146 $this->returnUrl
= t3lib_div
::sanitizeLocalUrl(t3lib_div
::_GP('returnUrl'));
147 $this->pagesOnly
= t3lib_div
::_GP('pagesOnly');
149 // Create instance of template class for output
150 $this->doc
= t3lib_div
::makeInstance('template');
151 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
152 $this->doc
->setModuleTemplate('templates/db_new.html');
153 $this->doc
->JScode
= '';
155 // Setting up the context sensitive menu:
156 $this->doc
->getContextMenuCode();
160 $this->content
.= $this->doc
->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
162 // Id a positive id is supplied, ask for the page record with permission information contained:
164 $this->pageinfo
= t3lib_BEfunc
::readPageAccess($this->id
, $this->perms_clause
);
167 // If a page-record was returned, the user had read-access to the page.
168 if ($this->pageinfo
['uid']) {
169 // Get record of parent page
171 $this->pidInfo
=t3lib_BEfunc
::getRecord('pages', $this->pageinfo
['pid']);
172 // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
173 if ($GLOBALS['BE_USER']->doesUserHaveAccess($this->pageinfo
, 8)) {
174 $this->newPagesInto
=1;
176 if ($GLOBALS['BE_USER']->doesUserHaveAccess($this->pageinfo
, 16)) {
177 $this->newContentInto
=1;
180 if (($GLOBALS['BE_USER']->isAdmin() ||
is_array($this->pidInfo
)) && $GLOBALS['BE_USER']->doesUserHaveAccess($this->pidInfo
, 8)) {
181 $this->newPagesAfter
=1;
183 } elseif ($GLOBALS['BE_USER']->isAdmin()) {
184 // Admins can do it all
185 $this->newPagesInto
=1;
186 $this->newContentInto
=1;
187 $this->newPagesAfter
=0;
189 // People with no permission can do nothing
190 $this->newPagesInto
=0;
191 $this->newContentInto
=0;
192 $this->newPagesAfter
=0;
197 * Main processing, creating the list of new record tables to select from
203 // If there was a page - or if the user is admin (admins has access to the root) we proceed:
204 if ($this->pageinfo
['uid'] ||
$GLOBALS['BE_USER']->isAdmin()) {
205 // Acquiring TSconfig for this module/current page:
206 $this->web_list_modTSconfig
= t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'], 'mod.web_list');
207 $this->allowedNewTables
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig
['properties']['allowedNewTables'], 1);
208 $this->deniedNewTables
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig
['properties']['deniedNewTables'], 1);
210 // Acquiring TSconfig for this module/parent page:
211 $this->web_list_modTSconfig_pid
= t3lib_BEfunc
::getModTSconfig($this->pageinfo
['pid'], 'mod.web_list');
212 $this->allowedNewTables_pid
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig_pid
['properties']['allowedNewTables'], 1);
213 $this->deniedNewTables_pid
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig_pid
['properties']['deniedNewTables'], 1);
216 if (!$this->showNewRecLink('pages')) {
217 $this->newPagesInto
=0;
219 if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid
, $this->deniedNewTables_pid
)) {
220 $this->newPagesAfter
=0;
223 // Set header-HTML and return_url
224 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
225 $iconImgTag = t3lib_iconWorks
::getSpriteIconForRecord('pages', $this->pageinfo
, array('title' => htmlspecialchars($this->pageinfo
['_thePath'])));
226 $title = strip_tags($this->pageinfo
[$GLOBALS['TCA']['pages']['ctrl']['label']]);
228 $iconImgTag = t3lib_iconWorks
::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($this->pageinfo
['_thePath'])));
229 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
232 $this->code
= '<span class="typo3-moduleHeader">' . $this->doc
->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo
['uid']) . htmlspecialchars(t3lib_div
::fixed_lgd_cs($title, 45)) . '</span><br />';
234 $this->R_URI
= $this->returnUrl
;
236 // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
237 // Regular new element:
238 if (!$this->pagesOnly
) {
240 } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
244 // Add all the content to an output section
245 $this->content
.= $this->doc
->section('', $this->code
);
247 // Setting up the buttons and markers for docheader
248 $docHeaderButtons = $this->getButtons();
249 $markers['CSH'] = $docHeaderButtons['csh'];
251 $markers['CONTENT'] = $this->content
;
253 // Build the <body> for the module
254 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
255 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
256 $this->content
.= $this->doc
->endPage();
257 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
262 * Create the panel of buttons for submitting the form or otherwise perform operations.
264 * @return array All available buttons as an assoc. array
266 protected function getButtons() {
274 // Regular new element:
275 if (!$this->pagesOnly
) {
277 if ($this->showNewRecLink('pages')) {
278 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('pagesOnly' => '1'))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:newPage', 1) . '">' .
279 t3lib_iconWorks
::getSpriteIcon('actions-page-new') .
283 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE);
284 } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
286 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE);
291 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI
) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', 1) . '">' .
292 t3lib_iconWorks
::getSpriteIcon('actions-view-go-back') .
296 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
298 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc
::viewOnClick($this->pageinfo
['uid'], $this->backPath
, t3lib_BEfunc
::BEgetRootLine($this->pageinfo
['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '">' .
299 t3lib_iconWorks
::getSpriteIcon('actions-document-view') .
307 * Creates the position map for pages wizard
311 function pagesOnly() {
312 $numberOfPages = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'pages', '1=1' . t3lib_BEfunc
::deleteClause('pages'));
313 if ($numberOfPages > 0) {
315 <h3>' . htmlspecialchars($GLOBALS['LANG']->getLL('selectPosition')) . ':</h3>
317 $positionMap = t3lib_div
::makeInstance('t3lib_positionMap');
318 /** @var t3lib_positionMap $positionMap */
319 $this->code
.= $positionMap->positionTree($this->id
, $this->pageinfo
, $this->perms_clause
, $this->R_URI
);
321 // No pages yet, no need to prompt for position, redirect to page creation.
322 $javascript = t3lib_BEfunc
::editOnClick('returnUrl=%2Ftypo3%2Fdb_new.php%3Fid%3D0%26pagesOnly%3D1&edit[pages][0]=new&returnNewPageId=1');
323 $startPos = strpos($javascript, 'href=\'') +
6;
324 $endPos = strpos($javascript, '\';');
325 $url = substr($javascript, $startPos, $endPos - $startPos);
327 t3lib_utility_Http
::redirect($url);
332 * Create a regular new element (pages and records)
336 function regularNew() {
338 $doNotShowFullDescr = FALSE;
339 // Initialize array for accumulating table rows:
340 $this->tRows
= array();
343 $halfLine = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/halfline.gif', 'width="18" height="8"') . ' alt="" />';
344 $firstLevel = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/join.gif', 'width="18" height="16"') . ' alt="" />';
345 $secondLevel = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />
346 <img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/join.gif', 'width="18" height="16"') . ' alt="" />';
347 $secondLevelLast = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />
348 <img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/joinbottom.gif', 'width="18" height="16"') . ' alt="" />';
350 // Get TSconfig for current page
351 $pageTS = t3lib_BEfunc
::getPagesTSconfig($this->id
);
352 // Finish initializing new pages options with TSconfig
353 // Each new page option may be hidden by TSconfig
355 // Enabled option for the position of a new page
356 $this->newPagesSelectPosition
= !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageSelectPosition']);
357 // Pseudo-boolean (0/1) for backward compatibility
358 $this->newPagesInto
= (!empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageInside']) ?
1 : 0);
359 $this->newPagesAfter
= (!empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageAfter']) ?
1 : 0);
361 // Slight spacer from header:
362 $this->code
.= $halfLine;
366 $v = $GLOBALS['TCA'][$table];
367 $pageIcon = t3lib_iconWorks
::getSpriteIconForRecord($table, array());
369 $newPageIcon = t3lib_iconWorks
::getSpriteIcon('actions-page-new');
372 // New pages INSIDE this pages
373 $newPageLinks = array();
374 if ($this->newPagesInto
375 && $this->isTableAllowedForThisPage($this->pageinfo
, 'pages')
376 && $GLOBALS['BE_USER']->check('tables_modify', 'pages')
377 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pageinfo
['_ORIG_uid']?
$this->pageinfo
['_ORIG_uid']:$this->id
, 'pages')
380 // Create link to new page inside:
381 $newPageLinks[] = $this->linkWrap(
382 t3lib_iconWorks
::getSpriteIconForRecord($table, array()) .
383 $GLOBALS['LANG']->sL($v['ctrl']['title'], 1) . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside', 1) . ')',
389 // New pages AFTER this pages
390 if ($this->newPagesAfter
391 && $this->isTableAllowedForThisPage($this->pidInfo
, 'pages')
392 && $GLOBALS['BE_USER']->check('tables_modify', 'pages')
393 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pidInfo
['uid'], 'pages')
396 $newPageLinks[] = $this->linkWrap(
398 $GLOBALS['LANG']->sL($v['ctrl']['title'], 1) . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after', 1) . ')',
404 // New pages at selection position
405 if ($this->newPagesSelectPosition
) {
406 // Link to page-wizard:
407 $newPageLinks[] = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('pagesOnly' => 1))) . '">' .
409 htmlspecialchars($GLOBALS['LANG']->getLL('pageSelectPosition')) .
413 // Assemble all new page links
414 $numPageLinks = count($newPageLinks);
415 for ($i = 0; $i < $numPageLinks; $i++
) {
416 // For the last link, use the "branch bottom" icon
417 if ($i == $numPageLinks - 1) {
418 $treeComponent = $secondLevelLast;
420 $treeComponent = $secondLevel;
422 $rowContent .= '<br />' . $treeComponent . $newPageLinks[$i];
424 // Add row header and half-line if not empty
425 if (!empty($rowContent)) {
426 $rowContent.= '<br />' . $halfLine;
427 $rowContent = $firstLevel . $newPageIcon . ' <strong>' . $GLOBALS['LANG']->getLL('createNewPage') . '</strong>' . $rowContent;
430 // Compile table row to show the icon for "new page (select position)"
431 $startRows = array();
432 if ($this->showNewRecLink('pages') && !empty($rowContent)) {
435 <td nowrap="nowrap">' . $rowContent . '</td>
436 <td>' . t3lib_BEfunc
::wrapInHelp($table, '') . '</td>
441 // New tables (but not pages) INSIDE this pages
442 $isAdmin = $GLOBALS['BE_USER']->isAdmin();
443 $newContentIcon = t3lib_iconWorks
::getSpriteIcon('actions-document-new');
444 if ($this->newContentInto
) {
445 if (is_array($GLOBALS['TCA'])) {
447 foreach ($GLOBALS['TCA'] as $table => $v) {
448 $count = count($GLOBALS['TCA'][$table]);
450 if ($table != 'pages'
451 && $this->showNewRecLink($table)
452 && $this->isTableAllowedForThisPage($this->pageinfo
, $table)
453 && $GLOBALS['BE_USER']->check('tables_modify', $table)
454 && (($v['ctrl']['rootLevel'] xor $this->id
) ||
$v['ctrl']['rootLevel'] == -1)
455 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pageinfo
['_ORIG_uid'] ?
$this->pageinfo
['_ORIG_uid'] : $this->id
, $table)
458 $newRecordIcon = t3lib_iconWorks
::getSpriteIconForRecord($table, array());
461 // Create new link for record:
462 $newLink = $this->linkWrap($newRecordIcon . $GLOBALS['LANG']->sL($v['ctrl']['title'], 1), $table, $this->id
);
464 // If the table is 'tt_content' (from "cms" extension), create link to wizard
465 if ($table == 'tt_content') {
466 $groupName = $GLOBALS['LANG']->getLL('createNewContent');
467 $rowContent = $firstLevel . $newContentIcon . ' <strong>' . $GLOBALS['LANG']->getLL('createNewContent') . '</strong>';
468 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
469 $overrideExt = $this->web_list_modTSconfig
['properties']['newContentWiz.']['overrideWithExtension'];
470 $pathToWizard = (t3lib_extMgm
::isLoaded($overrideExt)) ?
(t3lib_extMgm
::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
472 $href = $pathToWizard . '?id=' . $this->id
. '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
473 $rowContent.= '<br />' . $secondLevel . $newLink . '<br />' .
475 '<a href="' . htmlspecialchars($href) . '">' .
476 $newContentIcon . htmlspecialchars($GLOBALS['LANG']->getLL('clickForWizard')) .
480 $rowContent.= '<br />' . $halfLine;
483 if ($v['ctrl']['readOnly'] ||
$v['ctrl']['hideTable'] ||
$v['ctrl']['is_static']) {
486 if ($v['ctrl']['adminOnly'] && !$isAdmin) {
489 $nameParts = explode('_', $table);
491 if ($nameParts[0] == 'tx' ||
$nameParts[0] == 'tt') {
492 // Try to extract extension name
493 if (substr($v['ctrl']['title'], 0, 8) == 'LLL:EXT:') {
494 $_EXTKEY = substr($v['ctrl']['title'], 8);
495 $_EXTKEY = substr($_EXTKEY, 0, strpos($_EXTKEY, '/'));
496 if ($_EXTKEY != '') {
497 // First try to get localisation of extension title
498 $temp = explode(':', substr($v['ctrl']['title'], 9 +
strlen($_EXTKEY)));
499 $langFile = $temp[0];
500 $thisTitle = $GLOBALS['LANG']->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
501 // If no localisation available, read title from ext_emconf.php
502 if (!$thisTitle && is_file(t3lib_extMgm
::extPath($_EXTKEY) . 'ext_emconf.php')) {
503 include(t3lib_extMgm
::extPath($_EXTKEY) . 'ext_emconf.php');
504 $thisTitle = $EM_CONF[$_EXTKEY]['title'];
506 $iconFile[$_EXTKEY] = '<img alt="" src="' . t3lib_extMgm
::extRelPath($_EXTKEY) .
507 $GLOBALS['TYPO3_LOADED_EXT'][$_EXTKEY]['ext_icon'] . '" height="16" />';
509 $thisTitle = $nameParts[1];
510 $iconFile[$_EXTKEY] = '';
513 $thisTitle = $nameParts[1];
514 $iconFile[$_EXTKEY] = '';
518 $thisTitle = $GLOBALS['LANG']->getLL('system_records');
519 $iconFile['system'] = t3lib_iconWorks
::getSpriteIcon('apps-pagetree-root');
522 if ($groupName == '' ||
$groupName != $_EXTKEY) {
523 $groupName = empty($v['ctrl']['groupName']) ?
$_EXTKEY : $v['ctrl']['groupName'];
526 $rowContent .= $newLink;
531 // Compile table row:
532 if ($table == 'tt_content') {
535 <td nowrap="nowrap">' . $rowContent . '</td>
536 <td>' . t3lib_BEfunc
::wrapInHelp($table, '') . '</td>
539 $this->tRows
[$groupName]['title'] = $thisTitle;
540 $this->tRows
[$groupName]['html'][] = $rowContent;
541 $this->tRows
[$groupName]['table'][] = $table;
549 if (isset($pageTS['mod.']['wizards.']['newRecord.']['order'])) {
550 $this->newRecordSortList
= t3lib_div
::trimExplode(',', $pageTS['mod.']['wizards.']['newRecord.']['order'], TRUE);
552 uksort($this->tRows
, array($this, 'sortNewRecordsByConfig'));
554 // Compile table row:
555 $finalRows = array();
556 $finalRows[] = implode('', $startRows);
557 foreach ($this->tRows
as $key => $value) {
559 <td nowrap="nowrap">' . $halfLine . '<br />' .
560 $firstLevel . '' . $iconFile[$key] . ' <strong>' . $value['title'] . '</strong>' .
561 '</td><td> <br />' . t3lib_BEfunc
::wrapInHelp($key, '') . '</td>
563 $count = count($value['html']) - 1;
564 foreach ($value['html'] as $recordKey => $record) {
567 <td nowrap="nowrap">' . ($recordKey < $count ?
$secondLevel : $secondLevelLast) . $record . '</td>
568 <td>' . t3lib_BEfunc
::wrapInHelp($value['table'][$recordKey], '') . '</td>
577 <td><img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/stopper.gif', 'width="18" height="16"') . ' alt="" /></td>
584 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
585 ' . implode('', $finalRows) . '
591 * User array sort function used by regularNew
593 * @param string $a First array element for compare
594 * @param string $b First array element for compare
595 * @return integer -1 for lower, 0 for equal, 1 for greater
597 function sortNewRecordsByConfig($a, $b) {
598 if (count($this->newRecordSortList
)) {
599 if (in_array($a, $this->newRecordSortList
) && in_array($b, $this->newRecordSortList
)) {
600 // Both are in the list, return relative to position in array
601 $sub = array_search($a, $this->newRecordSortList
) - array_search($b, $this->newRecordSortList
);
602 $ret = $sub < 0 ?
-1 : $sub == 0 ?
0 : 1;
603 } elseif (in_array($a, $this->newRecordSortList
)) {
604 // First element is in array, put to top
606 } elseif (in_array($b, $this->newRecordSortList
)) {
607 // Second element is in array, put first to bottom
610 // No element is in array, return alphabetic order
611 $ret = strnatcasecmp($this->tRows
[$a]['title'], $this->tRows
[$b]['title']);
615 // Return alphabetic order
616 return strnatcasecmp($this->tRows
[$a]['title'], $this->tRows
[$b]['title']);
621 * Ending page output and echo'ing content to browser.
625 function printContent() {
630 * Links the string $code to a create-new form for a record in $table created on page $pid
632 * @param string $linkText Link text
633 * @param string $table Table name (in which to create new record)
634 * @param integer $pid PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
635 * @param boolean $addContentTable If $addContentTable is set, then a new contentTable record is created together with pages
636 * @return string The link.
638 function linkWrap($linkText, $table, $pid, $addContentTable = FALSE) {
639 $parameters = '&edit[' . $table . '][' . $pid . ']=new';
641 if ($table == 'pages'
642 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
643 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
644 && $addContentTable) {
645 $parameters .= '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1';
646 } elseif ($table == 'pages_language_overlay') {
647 $parameters .= '&overrideVals[pages_language_overlay][doktype]='
648 . (int) $this->pageinfo
['doktype'];
651 $onClick = t3lib_BEfunc
::editOnClick($parameters, '', $this->returnUrl
);
653 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">' . $linkText . '</a>';
657 * Returns TRUE if the tablename $checkTable is allowed to be created on the page with record $pid_row
659 * @param array $pid_row Record for parent page.
660 * @param string $checkTable Table name to check
661 * @return boolean Returns TRUE if the tablename $checkTable is allowed to be created on the page with record $pid_row
663 function isTableAllowedForThisPage($pid_row, $checkTable) {
664 if (!is_array($pid_row)) {
665 if ($GLOBALS['BE_USER']->user
['admin']) {
671 // be_users and be_groups may not be created anywhere but in the root.
672 if ($checkTable == 'be_users' ||
$checkTable == 'be_groups') {
676 $doktype = intval($pid_row['doktype']);
677 if (!$allowedTableList = $GLOBALS['PAGES_TYPES'][$doktype]['allowedTables']) {
678 $allowedTableList = $GLOBALS['PAGES_TYPES']['default']['allowedTables'];
680 // If all tables or the table is listed as a allowed type, return TRUE
681 if (strstr($allowedTableList, '*') || t3lib_div
::inList($allowedTableList, $checkTable)) {
688 * - $allowedNewTables and $deniedNewTables are empty
689 * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
691 * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
692 * has priority over $allowedNewTables.
694 * @param string $table Table name to test if in allowedTables
695 * @param array $allowedNewTables Array of new tables that are allowed.
696 * @param array $deniedNewTables Array of new tables that are not allowed.
697 * @return boolean Returns TRUE if a link for creating new records should be displayed for $table
699 function showNewRecLink($table, array $allowedNewTables = array(), array $deniedNewTables = array()) {
700 $allowedNewTables = ($allowedNewTables ?
$allowedNewTables : $this->allowedNewTables
);
701 $deniedNewTables = ($deniedNewTables ?
$deniedNewTables : $this->deniedNewTables
);
702 // No deny/allow tables are set:
703 if (!count($allowedNewTables) && !count($deniedNewTables)) {
705 // If table is not denied (which takes precedence over allowed tables):
706 } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) ||
in_array($table, $allowedNewTables))) {
708 // If table is denied or allowed tables are set, but table is not part of:
716 $SOBE = t3lib_div
::makeInstance('SC_db_new');
719 $SOBE->printContent();