2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (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
34 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
40 * [CLASS/FUNCTION INDEX of SCRIPT]
44 * 90: class localPageTree extends t3lib_pageTree
45 * 99: function wrapIcon($icon,$row)
46 * 110: function expandNext($id)
49 * 128: class SC_db_new
50 * 157: function init()
51 * 224: function main()
52 * 276: function pagesOnly()
53 * 294: function regularNew()
54 * 458: function printContent()
55 * 473: function linkWrap($code,$table,$pid,$addContentTable=0)
56 * 493: function isTableAllowedForThisPage($pid_row, $checkTable)
57 * 523: function showNewRecLink($table,$allowedNewTables='')
60 * (This index is automatically created/updated by the extension "extdeveval")
69 require('template.php');
70 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
74 * Extension for the tree class that generates the tree of pages in the page-wizard mode
76 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
80 class localPageTree
extends t3lib_pageTree
{
83 * Inserting uid-information in title-text for an icon
85 * @param string Icon image
86 * @param array Item row
87 * @return string Wrapping icon image.
89 function wrapIcon($icon,$row) {
90 return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
94 * Determines whether to expand a branch or not.
95 * Here the branch is expanded if the current id matches the global id for the listing/new
97 * @param integer The ID (page id) of the element
98 * @return boolean Returns true if the IDs matches
100 function expandNext($id) {
101 return $id==$GLOBALS['SOBE']->id ?
1 : 0;
112 * Script class for 'db_new'
114 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
124 var $web_list_modTSconfig;
125 var $allowedNewTables;
126 var $deniedNewTables;
127 var $web_list_modTSconfig_pid;
128 var $allowedNewTables_pid;
129 var $deniedNewTables_pid;
133 // Internal, static: GPvar
134 var $id; // see init()
135 var $returnUrl; // Return url.
136 var $pagesOnly; // pagesOnly flag.
139 var $perms_clause; // see init()
142 * Document template object
147 var $content; // Accumulated HTML output
151 * Constructor function for the class
156 global $BE_USER,$LANG,$BACK_PATH;
158 // page-selection permission clause (reading)
159 $this->perms_clause
= $BE_USER->getPagePermsClause(1);
161 // this will hide records from display - it has nothing todo with user rights!!
162 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
163 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
164 $this->perms_clause
.= ' AND pages.uid NOT IN ('.$pidList.')';
168 $this->id
= intval(t3lib_div
::_GP('id')); // The page id to operate from
169 $this->returnUrl
= t3lib_div
::_GP('returnUrl');
170 $this->pagesOnly
= t3lib_div
::_GP('pagesOnly');
172 // Create instance of template class for output
173 $this->doc
= t3lib_div
::makeInstance('template');
174 $this->doc
->backPath
= $BACK_PATH;
175 $this->doc
->setModuleTemplate('templates/db_new.html');
176 $this->doc
->JScode
='';
178 // Setting up the context sensitive menu:
179 $this->doc
->getContextMenuCode();
183 $this->content
.=$this->doc
->header($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
185 // Id a positive id is supplied, ask for the page record with permission information contained:
187 $this->pageinfo
= t3lib_BEfunc
::readPageAccess($this->id
,$this->perms_clause
);
190 // If a page-record was returned, the user had read-access to the page.
191 if ($this->pageinfo
['uid']) {
192 // Get record of parent page
194 $this->pidInfo
=t3lib_BEfunc
::getRecord('pages',$this->pageinfo
['pid']);
195 // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
196 if ($BE_USER->doesUserHaveAccess($this->pageinfo
,8)) {
197 $this->newPagesInto
=1;
199 if ($BE_USER->doesUserHaveAccess($this->pageinfo
,16)) {
200 $this->newContentInto
=1;
203 if (($BE_USER->isAdmin()||
is_array($this->pidInfo
)) && $BE_USER->doesUserHaveAccess($this->pidInfo
,8)) {
204 $this->newPagesAfter
=1;
206 } elseif ($BE_USER->isAdmin()) {
207 // Admins can do it all
208 $this->newPagesInto
=1;
209 $this->newContentInto
=1;
210 $this->newPagesAfter
=0;
212 // People with no permission can do nothing
213 $this->newPagesInto
=0;
214 $this->newContentInto
=0;
215 $this->newPagesAfter
=0;
220 * Main processing, creating the list of new record tables to select from
225 global $BE_USER,$LANG;
227 // If there was a page - or if the user is admin (admins has access to the root) we proceed:
228 if ($this->pageinfo
['uid'] ||
$BE_USER->isAdmin()) {
229 // Acquiring TSconfig for this module/current page:
230 $this->web_list_modTSconfig
= t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
231 $this->allowedNewTables
= t3lib_div
::trimExplode(',',$this->web_list_modTSconfig
['properties']['allowedNewTables'],1);
232 $this->deniedNewTables
= t3lib_div
::trimExplode(',',$this->web_list_modTSconfig
['properties']['deniedNewTables'],1);
234 // Acquiring TSconfig for this module/parent page:
235 $this->web_list_modTSconfig_pid
= t3lib_BEfunc
::getModTSconfig($this->pageinfo
['pid'],'mod.web_list');
236 $this->allowedNewTables_pid
= t3lib_div
::trimExplode(',',$this->web_list_modTSconfig_pid
['properties']['allowedNewTables'],1);
237 $this->deniedNewTables_pid
= t3lib_div
::trimExplode(',',$this->web_list_modTSconfig_pid
['properties']['deniedNewTables'],1);
240 if (!$this->showNewRecLink('pages')) {
241 $this->newPagesInto
=0;
243 if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid
, $this->deniedNewTables_pid
)) {
244 $this->newPagesAfter
=0;
248 // Set header-HTML and return_url
249 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
250 $iconImgTag = t3lib_iconWorks
::getIconImage('pages', $this->pageinfo
, $this->backPath
, 'title="' . htmlspecialchars($this->pageinfo
['_thePath']) . '"');
251 $title = strip_tags($this->pageinfo
[$GLOBALS['TCA']['pages']['ctrl']['label']]);
253 $iconImgTag = '<img' . t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/i/_icon_website.gif') . ' title="' . htmlspecialchars($this->pageinfo
['_thePath']) . '" alt="" />';
254 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
257 $this->code
= '<span class="typo3-moduleHeader">' . $this->doc
->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo
['uid']) . htmlspecialchars(t3lib_div
::fixed_lgd_cs($title, 45)) . '</span><br />';
259 $this->R_URI
= $this->returnUrl
;
261 // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
262 if (!$this->pagesOnly
) { // Regular new element:
264 } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
268 // Add all the content to an output section
269 $this->content
.=$this->doc
->section('',$this->code
);
271 // Setting up the buttons and markers for docheader
272 $docHeaderButtons = $this->getButtons();
273 $markers['CSH'] = $docHeaderButtons['csh'];
275 $markers['CONTENT'] = $this->content
;
277 // Build the <body> for the module
278 $this->content
= $this->doc
->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
279 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
280 $this->content
.= $this->doc
->endPage();
281 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
286 * Create the panel of buttons for submitting the form or otherwise perform operations.
288 * @return array all available buttons as an assoc. array
290 protected function getButtons() {
291 global $LANG, $BACK_PATH;
302 if (!$this->pagesOnly
) { // Regular new element:
304 if ($this->showNewRecLink('pages')) {
305 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('pagesOnly' => '1'))) . '">' .
306 '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/new_page.gif') . ' alt="" />' .
310 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE
);
311 } elseif($this->showNewRecLink('pages')) { // Pages only wizard
313 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE
);
318 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI
) . '" class="typo3-goBack">' .
319 '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/goback.gif') . ' alt="" />' .
323 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
325 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc
::viewOnClick($this->pageinfo
['uid'], $this->backPath
, t3lib_BEfunc
::BEgetRootLine($this->pageinfo
['uid']))) . '">' .
326 '<img' . t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" alt="" />' .
330 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
331 $href = $this->backPath
. 'db_list.php?id=' . $this->pageinfo
['uid'] . '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
332 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
333 '<img' . t3lib_iconWorks
::skinImg($this->backPath
, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
344 * Creates the position map for pages wizard
348 function pagesOnly() {
351 $posMap = t3lib_div
::makeInstance('t3lib_positionMap');
353 <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
355 $this->code
.= $posMap->positionTree($this->id
,$this->pageinfo
,$this->perms_clause
,$this->R_URI
);
359 * Create a regular new element (pages and records)
363 function regularNew() {
365 $doNotShowFullDescr = false
;
366 // Initialize array for accumulating table rows:
367 $this->tRows
= array();
370 $halfLine = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/halfline.gif', 'width="18" height="8"') . ' alt="" />';
371 $firstLevel = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/join.gif', 'width="18" height="16"') . ' alt="" />';
372 $secondLevel = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />
373 <img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/join.gif', 'width="18" height="16"') . ' alt="" />';
374 $secondLevelLast = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />
375 <img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/joinbottom.gif', 'width="18" height="16"') . ' alt="" />';
377 // Slight spacer from header:
378 $this->code
.= $halfLine;
382 $v = $GLOBALS['TCA'][$table];
383 $pageIcon = t3lib_iconWorks
::getIconImage($table, array(), $this->doc
->backPath
, '');
384 $newPageIcon = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/new_page.gif', 'width="13" height="12"') . ' alt="" />';
385 $rowContent = $firstLevel . $newPageIcon . ' <strong>' . $GLOBALS['LANG']->getLL('createNewPage') . '</strong>';
387 // New pages INSIDE this pages
388 if ($this->newPagesInto
389 && $this->isTableAllowedForThisPage($this->pageinfo
, 'pages')
390 && $GLOBALS['BE_USER']->check('tables_modify','pages')
391 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pageinfo
['_ORIG_uid']?
$this->pageinfo
['_ORIG_uid']:$this->id
, 'pages')
394 // Create link to new page inside:
396 $rowContent .= '<br />' . $secondLevel . $this->linkWrap(
397 '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/i/' . ($v['ctrl']['iconfile'] ?
$v['ctrl']['iconfile'] : $table . '.gif'), 'width="18" height="16"') . ' alt="" />' .
398 $GLOBALS['LANG']->sL($v['ctrl']['title'], 1) . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside', 1) . ')',
403 // New pages AFTER this pages
404 if ($this->newPagesAfter
405 && $this->isTableAllowedForThisPage($this->pidInfo
, 'pages')
406 && $GLOBALS['BE_USER']->check('tables_modify', 'pages')
407 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pidInfo
['uid'], 'pages')
410 $rowContent .= '<br />' . $secondLevel .
413 $GLOBALS['LANG']->sL($v['ctrl']['title'], 1) . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1) . ')',
420 // Link to page-wizard:
421 $rowContent.= '<br />' . $secondLevelLast .
422 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('pagesOnly' => 1))) . '">' .
424 htmlspecialchars($GLOBALS['LANG']->getLL('pageSelectPosition')) .
428 $rowContent.= '<br />' . $halfLine;
430 // Compile table row to show the icon for "new page (select position)"
431 $startRows = array();
432 if ($this->showNewRecLink('pages')) {
435 <td nowrap="nowrap">' . $rowContent . '</td>
436 <td>' . t3lib_BEfunc
::cshItem($table, '', $this->doc
->backPath
, '', $doNotShowFullDescr) . '</td>
442 // New tables (but not pages) INSIDE this pages
443 $isAdmin = $GLOBALS['BE_USER']->isAdmin();
444 $newContentIcon = '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/new_record.gif', 'width="16" height="12"') . ' alt="" />';
445 if ($this->newContentInto
) {
446 if (is_array($GLOBALS['TCA'])) {
448 foreach($GLOBALS['TCA'] as $table => $v) {
449 $count = count($GLOBALS['TCA'][$table]);
451 if ($table != 'pages'
452 && $this->showNewRecLink($table)
453 && $this->isTableAllowedForThisPage($this->pageinfo
, $table)
454 && $GLOBALS['BE_USER']->check('tables_modify', $table)
455 && (($v['ctrl']['rootLevel'] xor $this->id
) ||
$v['ctrl']['rootLevel'] == -1)
456 && $GLOBALS['BE_USER']->workspaceCreateNewRecord($this->pageinfo
['_ORIG_uid'] ?
$this->pageinfo
['_ORIG_uid'] : $this->id
, $table)
459 $newRecordIcon = t3lib_iconWorks
::getIconImage($table ,array(), $this->doc
->backPath
, '');
462 // Create new link for record:
463 $newLink = $this->linkWrap(
464 $newRecordIcon . $GLOBALS['LANG']->sL($v['ctrl']['title'],1)
468 // If the table is 'tt_content' (from "cms" extension), create link to wizard
469 if ($table == 'tt_content') {
470 $groupName = $GLOBALS['LANG']->getLL('createNewContent');
471 $rowContent = $firstLevel . $newContentIcon . ' <strong>' . $GLOBALS['LANG']->getLL('createNewContent') . '</strong>';
472 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
473 $overrideExt = $this->web_list_modTSconfig
['properties']['newContentWiz.']['overrideWithExtension'];
474 $pathToWizard = (t3lib_extMgm
::isLoaded($overrideExt)) ?
(t3lib_extMgm
::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
476 $href = $pathToWizard . '?id=' . $this->id
. '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
477 $rowContent.= '<br />' . $secondLevel . $newLink . '<br />' .
479 '<a href="' . htmlspecialchars($href) . '">' .
480 $newContentIcon . htmlspecialchars($GLOBALS['LANG']->getLL('clickForWizard')) .
484 $rowContent.= '<br />' . $halfLine;
487 if ($v['ctrl']['readOnly'] ||
$v['ctrl']['hideTable'] ||
$v['ctrl']['is_static']) {
490 if ($v['ctrl']['adminOnly'] && !$isAdmin) {
493 $nameParts = explode('_', $table);
495 if ($nameParts[0] == 'tx' ||
$nameParts[0] == 'tt') {
496 // try to extract extension name
497 if (substr($v['ctrl']['title'], 0, 8) == 'LLL:EXT:') {
498 $_EXTKEY = substr($v['ctrl']['title'], 8);
499 $_EXTKEY = substr($_EXTKEY, 0, strpos($_EXTKEY, '/'));
500 if ($_EXTKEY != '') {
501 // first try to get localisation of extension title
502 $temp = explode(':', substr($v['ctrl']['title'], 9 +
strlen($_EXTKEY)));
503 $langFile = $temp[0];
504 $thisTitle = $GLOBALS['LANG']->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
505 // if no localisation available, read title from ext_emconf.php
506 if (!$thisTitle && is_file(t3lib_extMgm
::extPath($_EXTKEY) . 'ext_emconf.php')) {
507 include(t3lib_extMgm
::extPath($_EXTKEY) . 'ext_emconf.php');
508 $thisTitle = $EM_CONF[$_EXTKEY]['title'];
510 $iconFile[$_EXTKEY] = '<img src="' . t3lib_extMgm
::extRelPath($_EXTKEY) . 'ext_icon.gif" />';
512 $thisTitle = $nameParts[1];
513 $iconFile[$_EXTKEY] = '';
516 $thisTitle = $nameParts[1];
517 $iconFile[$_EXTKEY] = '';
521 $thisTitle = $GLOBALS['LANG']->getLL('system_records');
522 $iconFile['system'] = '<img src="gfx/typo3.png" />';
525 if($groupName == '' ||
$groupName != $_EXTKEY) {
526 $groupName = $_EXTKEY;
529 $rowContent .= $newLink;
535 // Compile table row:
536 if ($table == 'tt_content') {
539 <td nowrap="nowrap">' . $rowContent . '</td>
540 <td>' . t3lib_BEfunc
::cshItem($table, '', $this->doc
->backPath
, '', $doNotShowFullDescr) . '</td>
543 $this->tRows
[$groupName]['title'] = $thisTitle;
544 $this->tRows
[$groupName]['html'][] = $rowContent;
545 $this->tRows
[$groupName]['table'][] = $table;
553 $pageTS = t3lib_BEfunc
::getPagesTSconfig($this->id
);
554 if (isset($pageTS['mod.']['wizards.']['newRecord.']['order'])) {
555 $this->newRecordSortList
= t3lib_div
::trimExplode(',', $pageTS['mod.']['wizards.']['newRecord.']['order'], true
);
557 uksort($this->tRows
, array($this, 'sortNewRecordsByConfig'));
559 // Compile table row:
560 $finalRows = array();
561 $finalRows[] = implode('', $startRows);
562 foreach ($this->tRows
as $key => $value) {
564 <td nowrap="nowrap">' . $halfLine . '<br />' .
565 $firstLevel . '' . $iconFile[$key] . ' <strong>' . $value['title'] . '</strong>' .
566 '</td><td>'.t3lib_BEfunc
::cshItem($t,'',$this->doc
->backPath
,'',$doNotShowFullDescr).'</td>
568 $count = count($value['html']) - 1;
569 foreach ($value['html'] as $recordKey => $record) {
572 <td nowrap="nowrap">' . ($recordKey < $count ?
$secondLevel : $secondLevelLast) . $record . '</td>
573 <td>'.t3lib_BEfunc
::cshItem($value['table'][$recordKey], '', $this->doc
->backPath
, '', $doNotShowFullDescr) . '</td>
582 <td><img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/ol/stopper.gif','width="18" height="16"') . ' alt="" /></td>
590 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
591 ' . implode('', $finalRows) . '
597 * user array sort function used by regularNew
599 * @param string first array element for compare
600 * @param string first array element for compare
601 * @return int -1 for lower, 0 for equal, 1 for greater
603 function sortNewRecordsByConfig($a, $b) {
604 if (count($this->newRecordSortList
)) {
605 if (in_array($a, $this->newRecordSortList
) && in_array($b, $this->newRecordSortList
)) {
606 // both are in the list, return relative to position in array
607 $sub = array_search($a, $this->newRecordSortList
) - array_search($b, $this->newRecordSortList
);
608 $ret = $sub < 0 ?
-1 : $sub == 0 ?
0 : 1;
609 } elseif (in_array($a, $this->newRecordSortList
)) {
610 // first element is in array, put to top
612 } elseif (in_array($b, $this->newRecordSortList
)) {
613 // second element is in array, put first to bottom
616 // no element is in array, return alphabetic order
617 $ret = strnatcasecmp($this->tRows
[$a]['title'], $this->tRows
[$b]['title']);
621 // return alphabetic order
622 return strnatcasecmp($this->tRows
[$a]['title'], $this->tRows
[$b]['title']);
627 * Ending page output and echo'ing content to browser.
631 function printContent() {
636 * Links the string $code to a create-new form for a record in $table created on page $pid
638 * @param string Link text
639 * @param string Table name (in which to create new record)
640 * @param integer PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
641 * @param boolean If $addContentTable is set, then a new contentTable record is created together with pages
642 * @return string The link.
644 function linkWrap($linkText, $table, $pid, $addContentTable = false
) {
645 $parameters = '&edit[' . $table . '][' . $pid . ']=new';
647 if ($table == 'pages'
648 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
649 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
650 && $addContentTable) {
651 $parameters .= '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1';
652 } elseif ($table == 'pages_language_overlay') {
653 $parameters .= '&overrideVals[pages_language_overlay][doktype]='
654 . (int) $this->pageinfo
['doktype'];
657 $onClick = t3lib_BEfunc
::editOnClick($parameters, '', $this->returnUrl
);
659 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">' . $linkText . '</a>';
663 * Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
665 * @param array Record for parent page.
666 * @param string Table name to check
667 * @return boolean Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
669 function isTableAllowedForThisPage($pid_row, $checkTable) {
670 global $TCA, $PAGES_TYPES;
671 if (!is_array($pid_row)) {
672 if ($GLOBALS['BE_USER']->user
['admin']) {
678 // be_users and be_groups may not be created anywhere but in the root.
679 if ($checkTable=='be_users' ||
$checkTable=='be_groups') {
683 $doktype = intval($pid_row['doktype']);
684 if (!$allowedTableList = $PAGES_TYPES[$doktype]['allowedTables']) {
685 $allowedTableList = $PAGES_TYPES['default']['allowedTables'];
687 if (strstr($allowedTableList,'*') || t3lib_div
::inList($allowedTableList,$checkTable)) { // If all tables or the table is listed as a allowed type, return true
694 * - $allowedNewTables and $deniedNewTables are empty
695 * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
697 * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
698 * has priority over $allowedNewTables.
700 * @param string Table name to test if in allowedTables
701 * @param array Array of new tables that are allowed.
702 * @param array Array of new tables that are not allowed.
703 * @return boolean Returns true if a link for creating new records should be displayed for $table
705 function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
706 $allowedNewTables = ($allowedNewTables ?
$allowedNewTables : $this->allowedNewTables
);
707 $deniedNewTables = ($deniedNewTables ?
$deniedNewTables : $this->deniedNewTables
);
708 // No deny/allow tables are set:
709 if (!count($allowedNewTables) && !count($deniedNewTables)) {
711 // If table is not denied (which takes precedence over allowed tables):
712 } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) ||
in_array($table, $allowedNewTables))) {
714 // If table is denied or allowed tables are set, but table is not part of:
722 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/db_new.php']) {
723 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/db_new.php']);
729 $SOBE = t3lib_div
::makeInstance('SC_db_new');
732 $SOBE->printContent();