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 ***************************************************************/
28 * New database item menu
30 * This script lets users choose a new database element to create.
31 * Includes a wizard mode for visually pointing out the position of new pages
33 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
44 require('template.php');
45 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
49 * Extension for the tree class that generates the tree of pages in the page-wizard mode
51 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
55 class localPageTree
extends t3lib_pageTree
{
58 * Inserting uid-information in title-text for an icon
60 * @param string Icon image
61 * @param array Item row
62 * @return string Wrapping icon image.
64 function wrapIcon($icon, $row) {
65 return $this->addTagAttributes($icon, ' title="id='.htmlspecialchars($row['uid']).'"');
69 * Determines whether to expand a branch or not.
70 * Here the branch is expanded if the current id matches the global id for the listing/new
72 * @param integer The ID (page id) of the element
73 * @return boolean Returns TRUE if the IDs matches
75 function expandNext($id) {
76 return $id==$GLOBALS['SOBE']->id ?
1 : 0;
87 * Script class for 'db_new'
89 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
101 * Determines, whether "Select Position" for new page should be shown
102 * @var bool $newPagesSelectPosition
104 protected $newPagesSelectPosition = TRUE
;
106 var $web_list_modTSconfig;
107 var $allowedNewTables;
108 var $deniedNewTables;
109 var $web_list_modTSconfig_pid;
110 var $allowedNewTables_pid;
111 var $deniedNewTables_pid;
115 // Internal, static: GPvar
116 var $id; // see init()
117 var $returnUrl; // Return url.
118 var $pagesOnly; // pagesOnly flag.
121 var $perms_clause; // see init()
124 * Document template object
129 var $content; // Accumulated HTML output
133 * Constructor function for the class
139 // page-selection permission clause (reading)
140 $this->perms_clause
= $GLOBALS['BE_USER']->getPagePermsClause(1);
142 // this will hide records from display - it has nothing to do with user rights!!
143 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
144 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
145 $this->perms_clause
.= ' AND pages.uid NOT IN ('.$pidList.')';
149 $this->id
= intval(t3lib_div
::_GP('id')); // The page id to operate from
150 $this->returnUrl
= t3lib_div
::sanitizeLocalUrl(t3lib_div
::_GP('returnUrl'));
151 $this->pagesOnly
= t3lib_div
::_GP('pagesOnly');
153 // Create instance of template class for output
154 $this->doc
= t3lib_div
::makeInstance('template');
155 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
156 $this->doc
->setModuleTemplate('templates/db_new.html');
157 $this->doc
->JScode
='';
159 // Setting up the context sensitive menu:
160 $this->doc
->getContextMenuCode();
164 $this->content
.=$this->doc
->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
166 // Id a positive id is supplied, ask for the page record with permission information contained:
168 $this->pageinfo
= t3lib_BEfunc
::readPageAccess($this->id
, $this->perms_clause
);
171 // If a page-record was returned, the user had read-access to the page.
172 if ($this->pageinfo
['uid']) {
173 // Get record of parent page
175 $this->pidInfo
=t3lib_BEfunc
::getRecord('pages', $this->pageinfo
['pid']);
176 // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
177 if ($GLOBALS['BE_USER']->doesUserHaveAccess($this->pageinfo
, 8)) {
178 $this->newPagesInto
=1;
180 if ($GLOBALS['BE_USER']->doesUserHaveAccess($this->pageinfo
, 16)) {
181 $this->newContentInto
=1;
184 if (($GLOBALS['BE_USER']->isAdmin() ||
is_array($this->pidInfo
)) && $GLOBALS['BE_USER']->doesUserHaveAccess($this->pidInfo
, 8)) {
185 $this->newPagesAfter
=1;
187 } elseif ($GLOBALS['BE_USER']->isAdmin()) {
188 // Admins can do it all
189 $this->newPagesInto
=1;
190 $this->newContentInto
=1;
191 $this->newPagesAfter
=0;
193 // People with no permission can do nothing
194 $this->newPagesInto
=0;
195 $this->newContentInto
=0;
196 $this->newPagesAfter
=0;
201 * Main processing, creating the list of new record tables to select from
207 // If there was a page - or if the user is admin (admins has access to the root) we proceed:
208 if ($this->pageinfo
['uid'] ||
$GLOBALS['BE_USER']->isAdmin()) {
209 // Acquiring TSconfig for this module/current page:
210 $this->web_list_modTSconfig
= t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'], 'mod.web_list');
211 $this->allowedNewTables
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig
['properties']['allowedNewTables'], 1);
212 $this->deniedNewTables
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig
['properties']['deniedNewTables'], 1);
214 // Acquiring TSconfig for this module/parent page:
215 $this->web_list_modTSconfig_pid
= t3lib_BEfunc
::getModTSconfig($this->pageinfo
['pid'], 'mod.web_list');
216 $this->allowedNewTables_pid
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig_pid
['properties']['allowedNewTables'], 1);
217 $this->deniedNewTables_pid
= t3lib_div
::trimExplode(',', $this->web_list_modTSconfig_pid
['properties']['deniedNewTables'], 1);
220 if (!$this->showNewRecLink('pages')) {
221 $this->newPagesInto
=0;
223 if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid
, $this->deniedNewTables_pid
)) {
224 $this->newPagesAfter
=0;
228 // Set header-HTML and return_url
229 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
230 $iconImgTag = t3lib_iconWorks
::getSpriteIconForRecord('pages', $this->pageinfo
, array('title' => htmlspecialchars($this->pageinfo
['_thePath'])));
231 $title = strip_tags($this->pageinfo
[$GLOBALS['TCA']['pages']['ctrl']['label']]);
233 $iconImgTag = t3lib_iconWorks
::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($this->pageinfo
['_thePath'])));
234 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
237 $this->code
= '<span class="typo3-moduleHeader">' . $this->doc
->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo
['uid']) . htmlspecialchars(t3lib_div
::fixed_lgd_cs($title, 45)) . '</span><br />';
239 $this->R_URI
= $this->returnUrl
;
241 // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
242 if (!$this->pagesOnly
) { // Regular new element:
244 } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
248 // Add all the content to an output section
249 $this->content
.=$this->doc
->section('', $this->code
);
251 // Setting up the buttons and markers for docheader
252 $docHeaderButtons = $this->getButtons();
253 $markers['CSH'] = $docHeaderButtons['csh'];
255 $markers['CONTENT'] = $this->content
;
257 // Build the <body> for the module
258 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
259 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
260 $this->content
.= $this->doc
->endPage();
261 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
266 * Create the panel of buttons for submitting the form or otherwise perform operations.
268 * @return array all available buttons as an assoc. array
270 protected function getButtons() {
280 if (!$this->pagesOnly
) { // Regular new element:
282 if ($this->showNewRecLink('pages')) {
283 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('pagesOnly' => '1'))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:newPage', 1) . '">' .
284 t3lib_iconWorks
::getSpriteIcon('actions-page-new') .
288 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE
);
289 } elseif($this->showNewRecLink('pages')) { // Pages only wizard
291 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE
);
296 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI
) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', 1) . '">' .
297 t3lib_iconWorks
::getSpriteIcon('actions-view-go-back') .
301 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
303 $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) . '">' .
304 t3lib_iconWorks
::getSpriteIcon('actions-document-view') .
308 // If access to Web>List for user, then link to that module.
309 $buttons['record_list'] = t3lib_BEfunc
::getListViewLink(
311 'id' => $this->pageinfo
['uid'],
312 'returnUrl' => t3lib_div
::getIndpEnv('REQUEST_URI'),
314 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
324 * Creates the position map for pages wizard
328 function pagesOnly() {
329 $numberOfPages = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'pages', '1=1' . t3lib_BEfunc
::deleteClause('pages'));
330 if ($numberOfPages > 0) {
332 <h3>' . htmlspecialchars($GLOBALS['LANG']->getLL('selectPosition')) . ':</h3>
334 $positionMap = t3lib_div
::makeInstance('t3lib_positionMap');
335 /** @var t3lib_positionMap $positionMap */
336 $this->code
.= $positionMap->positionTree($this->id
, $this->pageinfo
, $this->perms_clause
, $this->R_URI
);
338 // No pages yet, no need to prompt for position, redirect to page creation.
339 $javascript = t3lib_BEfunc
::editOnClick('returnUrl=%2Ftypo3%2Fdb_new.php%3Fid%3D0%26pagesOnly%3D1&edit[pages][0]=new&returnNewPageId=1');
340 $startPos = strpos($javascript, 'href=\'') +
6;
341 $endPos = strpos($javascript, '\';');
342 $url = substr($javascript, $startPos, $endPos - $startPos);
344 t3lib_utility_Http
::redirect($url);
349 * Create a regular new element (pages and records)
353 function regularNew() {
355 $doNotShowFullDescr = FALSE
;
356 // Initialize array for accumulating table rows:
357 $this->tRows
= array();
360 $halfLine = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/halfline.gif', 'width="18" height="8"') . ' alt="" />';
361 $firstLevel = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/join.gif', 'width="18" height="16"') . ' alt="" />';
362 $secondLevel = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />
363 <img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/join.gif', 'width="18" height="16"') . ' alt="" />';
364 $secondLevelLast = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />
365 <img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/joinbottom.gif', 'width="18" height="16"') . ' alt="" />';
367 // Get TSconfig for current page
368 $pageTS = t3lib_BEfunc
::getPagesTSconfig($this->id
);
369 // Finish initializing new pages options with TSconfig
370 // Each new page option may be hidden by TSconfig
372 // Enabled option for the position of a new page
373 $this->newPagesSelectPosition
= !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageSelectPosition']);
374 // pseudo-boolean (0/1) for backward compatibility
375 $this->newPagesInto
= (!empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageInside']) ?
1 : 0);
376 $this->newPagesAfter
= (!empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageAfter']) ?
1 : 0);
379 // Slight spacer from header:
380 $this->code
.= $halfLine;
384 $v = $GLOBALS['TCA'][$table];
385 $pageIcon = t3lib_iconWorks
::getSpriteIconForRecord($table, array());
387 $newPageIcon = t3lib_iconWorks
::getSpriteIcon('actions-page-new');
390 // New pages INSIDE this pages
391 $newPageLinks = array();
392 if ($this->newPagesInto
393 && $this->isTableAllowedForThisPage($this->pageinfo
, 'pages')
394 && $GLOBALS['BE_USER']->check('tables_modify', 'pages')
395 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pageinfo
['_ORIG_uid']?
$this->pageinfo
['_ORIG_uid']:$this->id
, 'pages')
398 // Create link to new page inside:
399 $newPageLinks[] = $this->linkWrap(
400 t3lib_iconWorks
::getSpriteIconForRecord($table, array()) .
401 $GLOBALS['LANG']->sL($v['ctrl']['title'], 1) . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside', 1) . ')',
407 // New pages AFTER this pages
408 if ($this->newPagesAfter
409 && $this->isTableAllowedForThisPage($this->pidInfo
, 'pages')
410 && $GLOBALS['BE_USER']->check('tables_modify', 'pages')
411 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pidInfo
['uid'], 'pages')
414 $newPageLinks[] = $this->linkWrap(
416 $GLOBALS['LANG']->sL($v['ctrl']['title'], 1) . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after', 1) . ')',
423 // New pages at selection position
424 if ($this->newPagesSelectPosition
) {
425 // Link to page-wizard:
426 $newPageLinks[] = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('pagesOnly' => 1))) . '">' .
428 htmlspecialchars($GLOBALS['LANG']->getLL('pageSelectPosition')) .
432 // Assemble all new page links
433 $numPageLinks = count($newPageLinks);
434 for ($i = 0; $i < $numPageLinks; $i++
) {
435 // For the last link, use the "branch bottom" icon
436 if ($i == $numPageLinks - 1) {
437 $treeComponent = $secondLevelLast;
439 $treeComponent = $secondLevel;
441 $rowContent .= '<br />' . $treeComponent . $newPageLinks[$i];
443 // Add row header and half-line if not empty
444 if (!empty($rowContent)) {
445 $rowContent.= '<br />' . $halfLine;
446 $rowContent = $firstLevel . $newPageIcon . ' <strong>' . $GLOBALS['LANG']->getLL('createNewPage') . '</strong>' . $rowContent;
449 // Compile table row to show the icon for "new page (select position)"
450 $startRows = array();
451 if ($this->showNewRecLink('pages') && !empty($rowContent)) {
454 <td nowrap="nowrap">' . $rowContent . '</td>
455 <td>' . t3lib_BEfunc
::wrapInHelp($table, '') . '</td>
461 // New tables (but not pages) INSIDE this pages
462 $isAdmin = $GLOBALS['BE_USER']->isAdmin();
463 $newContentIcon = t3lib_iconWorks
::getSpriteIcon('actions-document-new');
464 if ($this->newContentInto
) {
465 if (is_array($GLOBALS['TCA'])) {
467 foreach($GLOBALS['TCA'] as $table => $v) {
468 $count = count($GLOBALS['TCA'][$table]);
470 if ($table != 'pages'
471 && $this->showNewRecLink($table)
472 && $this->isTableAllowedForThisPage($this->pageinfo
, $table)
473 && $GLOBALS['BE_USER']->check('tables_modify', $table)
474 && (($v['ctrl']['rootLevel'] xor $this->id
) ||
$v['ctrl']['rootLevel'] == -1)
475 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pageinfo
['_ORIG_uid'] ?
$this->pageinfo
['_ORIG_uid'] : $this->id
, $table)
478 $newRecordIcon = t3lib_iconWorks
::getSpriteIconForRecord($table, array());
481 // Create new link for record:
482 $newLink = $this->linkWrap($newRecordIcon . $GLOBALS['LANG']->sL($v['ctrl']['title'], 1), $table, $this->id
);
484 // If the table is 'tt_content' (from "cms" extension), create link to wizard
485 if ($table == 'tt_content') {
486 $groupName = $GLOBALS['LANG']->getLL('createNewContent');
487 $rowContent = $firstLevel . $newContentIcon . ' <strong>' . $GLOBALS['LANG']->getLL('createNewContent') . '</strong>';
488 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
489 $overrideExt = $this->web_list_modTSconfig
['properties']['newContentWiz.']['overrideWithExtension'];
490 $pathToWizard = (t3lib_extMgm
::isLoaded($overrideExt)) ?
(t3lib_extMgm
::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
492 $href = $pathToWizard . '?id=' . $this->id
. '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
493 $rowContent.= '<br />' . $secondLevel . $newLink . '<br />' .
495 '<a href="' . htmlspecialchars($href) . '">' .
496 $newContentIcon . htmlspecialchars($GLOBALS['LANG']->getLL('clickForWizard')) .
500 $rowContent.= '<br />' . $halfLine;
503 if ($v['ctrl']['readOnly'] ||
$v['ctrl']['hideTable'] ||
$v['ctrl']['is_static']) {
506 if ($v['ctrl']['adminOnly'] && !$isAdmin) {
509 $nameParts = explode('_', $table);
511 if ($nameParts[0] == 'tx' ||
$nameParts[0] == 'tt') {
512 // try to extract extension name
513 if (substr($v['ctrl']['title'], 0, 8) == 'LLL:EXT:') {
514 $_EXTKEY = substr($v['ctrl']['title'], 8);
515 $_EXTKEY = substr($_EXTKEY, 0, strpos($_EXTKEY, '/'));
516 if ($_EXTKEY != '') {
517 // first try to get localisation of extension title
518 $temp = explode(':', substr($v['ctrl']['title'], 9 +
strlen($_EXTKEY)));
519 $langFile = $temp[0];
520 $thisTitle = $GLOBALS['LANG']->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
521 // if no localisation available, read title from ext_emconf.php
522 if (!$thisTitle && is_file(t3lib_extMgm
::extPath($_EXTKEY) . 'ext_emconf.php')) {
523 include(t3lib_extMgm
::extPath($_EXTKEY) . 'ext_emconf.php');
524 $thisTitle = $EM_CONF[$_EXTKEY]['title'];
526 $iconFile[$_EXTKEY] = '<img src="' . t3lib_extMgm
::extRelPath($_EXTKEY) . 'ext_icon.gif" />';
528 $thisTitle = $nameParts[1];
529 $iconFile[$_EXTKEY] = '';
532 $thisTitle = $nameParts[1];
533 $iconFile[$_EXTKEY] = '';
537 $thisTitle = $GLOBALS['LANG']->getLL('system_records');
538 $iconFile['system'] = t3lib_iconWorks
::getSpriteIcon('apps-pagetree-root');
541 if ($groupName == '' ||
$groupName != $_EXTKEY) {
542 $groupName = empty($v['ctrl']['groupName']) ?
$_EXTKEY : $v['ctrl']['groupName'];
545 $rowContent .= $newLink;
551 // Compile table row:
552 if ($table == 'tt_content') {
555 <td nowrap="nowrap">' . $rowContent . '</td>
556 <td>' . t3lib_BEfunc
::wrapInHelp($table, '') . '</td>
559 $this->tRows
[$groupName]['title'] = $thisTitle;
560 $this->tRows
[$groupName]['html'][] = $rowContent;
561 $this->tRows
[$groupName]['table'][] = $table;
569 if (isset($pageTS['mod.']['wizards.']['newRecord.']['order'])) {
570 $this->newRecordSortList
= t3lib_div
::trimExplode(',', $pageTS['mod.']['wizards.']['newRecord.']['order'], TRUE
);
572 uksort($this->tRows
, array($this, 'sortNewRecordsByConfig'));
574 // Compile table row:
575 $finalRows = array();
576 $finalRows[] = implode('', $startRows);
577 foreach ($this->tRows
as $key => $value) {
579 <td nowrap="nowrap">' . $halfLine . '<br />' .
580 $firstLevel . '' . $iconFile[$key] . ' <strong>' . $value['title'] . '</strong>' .
581 '</td><td> <br />' . t3lib_BEfunc
::wrapInHelp($key, '') . '</td>
583 $count = count($value['html']) - 1;
584 foreach ($value['html'] as $recordKey => $record) {
587 <td nowrap="nowrap">' . ($recordKey < $count ?
$secondLevel : $secondLevelLast) . $record . '</td>
588 <td>' . t3lib_BEfunc
::wrapInHelp($value['table'][$recordKey], '') . '</td>
597 <td><img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/stopper.gif', 'width="18" height="16"') . ' alt="" /></td>
605 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
606 ' . implode('', $finalRows) . '
612 * user array sort function used by regularNew
614 * @param string first array element for compare
615 * @param string first array element for compare
616 * @return int -1 for lower, 0 for equal, 1 for greater
618 function sortNewRecordsByConfig($a, $b) {
619 if (count($this->newRecordSortList
)) {
620 if (in_array($a, $this->newRecordSortList
) && in_array($b, $this->newRecordSortList
)) {
621 // both are in the list, return relative to position in array
622 $sub = array_search($a, $this->newRecordSortList
) - array_search($b, $this->newRecordSortList
);
623 $ret = $sub < 0 ?
-1 : $sub == 0 ?
0 : 1;
624 } elseif (in_array($a, $this->newRecordSortList
)) {
625 // first element is in array, put to top
627 } elseif (in_array($b, $this->newRecordSortList
)) {
628 // second element is in array, put first to bottom
631 // no element is in array, return alphabetic order
632 $ret = strnatcasecmp($this->tRows
[$a]['title'], $this->tRows
[$b]['title']);
636 // return alphabetic order
637 return strnatcasecmp($this->tRows
[$a]['title'], $this->tRows
[$b]['title']);
642 * Ending page output and echo'ing content to browser.
646 function printContent() {
651 * Links the string $code to a create-new form for a record in $table created on page $pid
653 * @param string Link text
654 * @param string Table name (in which to create new record)
655 * @param integer PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
656 * @param boolean If $addContentTable is set, then a new contentTable record is created together with pages
657 * @return string The link.
659 function linkWrap($linkText, $table, $pid, $addContentTable = FALSE
) {
660 $parameters = '&edit[' . $table . '][' . $pid . ']=new';
662 if ($table == 'pages'
663 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
664 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
665 && $addContentTable) {
666 $parameters .= '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1';
667 } elseif ($table == 'pages_language_overlay') {
668 $parameters .= '&overrideVals[pages_language_overlay][doktype]='
669 . (int) $this->pageinfo
['doktype'];
672 $onClick = t3lib_BEfunc
::editOnClick($parameters, '', $this->returnUrl
);
674 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">' . $linkText . '</a>';
678 * Returns TRUE if the tablename $checkTable is allowed to be created on the page with record $pid_row
680 * @param array Record for parent page.
681 * @param string Table name to check
682 * @return boolean Returns TRUE if the tablename $checkTable is allowed to be created on the page with record $pid_row
684 function isTableAllowedForThisPage($pid_row, $checkTable) {
685 if (!is_array($pid_row)) {
686 if ($GLOBALS['BE_USER']->user
['admin']) {
692 // be_users and be_groups may not be created anywhere but in the root.
693 if ($checkTable=='be_users' ||
$checkTable=='be_groups') {
697 $doktype = intval($pid_row['doktype']);
698 if (!$allowedTableList = $GLOBALS['PAGES_TYPES'][$doktype]['allowedTables']) {
699 $allowedTableList = $GLOBALS['PAGES_TYPES']['default']['allowedTables'];
701 if (strstr($allowedTableList, '*') || t3lib_div
::inList($allowedTableList, $checkTable)) { // If all tables or the table is listed as a allowed type, return TRUE
708 * - $allowedNewTables and $deniedNewTables are empty
709 * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
711 * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
712 * has priority over $allowedNewTables.
714 * @param string Table name to test if in allowedTables
715 * @param array Array of new tables that are allowed.
716 * @param array Array of new tables that are not allowed.
717 * @return boolean Returns TRUE if a link for creating new records should be displayed for $table
719 function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
720 $allowedNewTables = ($allowedNewTables ?
$allowedNewTables : $this->allowedNewTables
);
721 $deniedNewTables = ($deniedNewTables ?
$deniedNewTables : $this->deniedNewTables
);
722 // No deny/allow tables are set:
723 if (!count($allowedNewTables) && !count($deniedNewTables)) {
725 // If table is not denied (which takes precedence over allowed tables):
726 } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) ||
in_array($table, $allowedNewTables))) {
728 // If table is denied or allowed tables are set, but table is not part of:
736 $SOBE = t3lib_div
::makeInstance('SC_db_new');
739 $SOBE->printContent();