Fixed bug #10234: when "create new record" in list module, page (after) is last entry
[Packages/TYPO3.CMS.git] / typo3 / db_new.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * New database item menu
29 *
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
32 *
33 * $Id$
34 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
35 * XHTML compliant
36 *
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 */
39 /**
40 * [CLASS/FUNCTION INDEX of SCRIPT]
41 *
42 *
43 *
44 * 90: class localPageTree extends t3lib_pageTree
45 * 99: function wrapIcon($icon,$row)
46 * 110: function expandNext($id)
47 *
48 *
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='')
58 *
59 * TOTAL FUNCTIONS: 10
60 * (This index is automatically created/updated by the extension "extdeveval")
61 *
62 */
63
64
65
66
67 $BACK_PATH='';
68 require('init.php');
69 require('template.php');
70 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
71
72 // ***************************
73 // Including classes
74 // ***************************
75 require_once(PATH_t3lib.'class.t3lib_page.php');
76 require_once(PATH_t3lib.'class.t3lib_positionmap.php');
77 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
78
79
80
81
82
83 /**
84 * Extension for the tree class that generates the tree of pages in the page-wizard mode
85 *
86 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
87 * @package TYPO3
88 * @subpackage core
89 */
90 class localPageTree extends t3lib_pageTree {
91
92 /**
93 * Inserting uid-information in title-text for an icon
94 *
95 * @param string Icon image
96 * @param array Item row
97 * @return string Wrapping icon image.
98 */
99 function wrapIcon($icon,$row) {
100 return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
101 }
102
103 /**
104 * Determines whether to expand a branch or not.
105 * Here the branch is expanded if the current id matches the global id for the listing/new
106 *
107 * @param integer The ID (page id) of the element
108 * @return boolean Returns true if the IDs matches
109 */
110 function expandNext($id) {
111 return $id==$GLOBALS['SOBE']->id ? 1 : 0;
112 }
113 }
114
115
116
117
118
119
120
121 /**
122 * Script class for 'db_new'
123 *
124 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
125 * @package TYPO3
126 * @subpackage core
127 */
128 class SC_db_new {
129 var $pageinfo;
130 var $pidInfo;
131 var $newPagesInto;
132 var $newContentInto;
133 var $newPagesAfter;
134 var $web_list_modTSconfig;
135 var $allowedNewTables;
136 var $deniedNewTables;
137 var $web_list_modTSconfig_pid;
138 var $allowedNewTables_pid;
139 var $deniedNewTables_pid;
140 var $code;
141 var $R_URI;
142
143 // Internal, static: GPvar
144 var $id; // see init()
145 var $returnUrl; // Return url.
146 var $pagesOnly; // pagesOnly flag.
147
148 // Internal
149 var $perms_clause; // see init()
150
151 /**
152 * Document template object
153 *
154 * @var mediumDoc
155 */
156 var $doc;
157 var $content; // Accumulated HTML output
158
159
160 /**
161 * Constructor function for the class
162 *
163 * @return void
164 */
165 function init() {
166 global $BE_USER,$LANG,$BACK_PATH;
167
168 // page-selection permission clause (reading)
169 $this->perms_clause = $BE_USER->getPagePermsClause(1);
170
171 // this will hide records from display - it has nothing todo with user rights!!
172 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
173 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
174 $this->perms_clause .= ' AND pages.uid NOT IN ('.$pidList.')';
175 }
176 }
177 // Setting GPvars:
178 $this->id = intval(t3lib_div::_GP('id')); // The page id to operate from
179 $this->returnUrl = t3lib_div::_GP('returnUrl');
180 $this->pagesOnly = t3lib_div::_GP('pagesOnly');
181
182 // Create instance of template class for output
183 $this->doc = t3lib_div::makeInstance('template');
184 $this->doc->backPath = $BACK_PATH;
185 $this->doc->setModuleTemplate('templates/db_new.html');
186 $this->doc->JScode='';
187
188 // Setting up the context sensitive menu:
189 $this->doc->getContextMenuCode();
190
191 // Creating content
192 $this->content='';
193 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
194
195 // Id a positive id is supplied, ask for the page record with permission information contained:
196 if ($this->id > 0) {
197 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
198 }
199
200 // If a page-record was returned, the user had read-access to the page.
201 if ($this->pageinfo['uid']) {
202 // Get record of parent page
203
204 $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
205 // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
206 if ($BE_USER->doesUserHaveAccess($this->pageinfo,8)) {
207 $this->newPagesInto=1;
208 }
209 if ($BE_USER->doesUserHaveAccess($this->pageinfo,16)) {
210 $this->newContentInto=1;
211 }
212
213 if (($BE_USER->isAdmin()||is_array($this->pidInfo)) && $BE_USER->doesUserHaveAccess($this->pidInfo,8)) {
214 $this->newPagesAfter=1;
215 }
216 } elseif ($BE_USER->isAdmin()) {
217 // Admins can do it all
218 $this->newPagesInto=1;
219 $this->newContentInto=1;
220 $this->newPagesAfter=0;
221 } else {
222 // People with no permission can do nothing
223 $this->newPagesInto=0;
224 $this->newContentInto=0;
225 $this->newPagesAfter=0;
226 }
227 }
228
229 /**
230 * Main processing, creating the list of new record tables to select from
231 *
232 * @return void
233 */
234 function main() {
235 global $BE_USER,$LANG;
236
237 // If there was a page - or if the user is admin (admins has access to the root) we proceed:
238 if ($this->pageinfo['uid'] || $BE_USER->isAdmin()) {
239 // Acquiring TSconfig for this module/current page:
240 $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
241 $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
242 $this->deniedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['deniedNewTables'],1);
243
244 // Acquiring TSconfig for this module/parent page:
245 $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
246 $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
247 $this->deniedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['deniedNewTables'],1);
248
249 // More init:
250 if (!$this->showNewRecLink('pages')) {
251 $this->newPagesInto=0;
252 }
253 if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid)) {
254 $this->newPagesAfter=0;
255 }
256
257
258 // Set header-HTML and return_url
259 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
260 $iconImgTag = t3lib_iconWorks::getIconImage('pages', $this->pageinfo, $this->backPath, 'title="' . htmlspecialchars($this->pageinfo['_thePath']) . '"');
261 $title = strip_tags($this->pageinfo[$GLOBALS['TCA']['pages']['ctrl']['label']]);
262 } else {
263 $iconImgTag = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif') . ' title="' . htmlspecialchars($this->pageinfo['_thePath']) . '" alt="" />';
264 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
265 }
266
267 $this->code = '<span class="typo3-moduleHeader">' . $this->doc->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo['uid']) . htmlspecialchars(t3lib_div::fixed_lgd_cs($title, 45)) . '</span><br />';
268
269 $this->R_URI = $this->returnUrl;
270
271 // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
272 if (!$this->pagesOnly) { // Regular new element:
273 $this->regularNew();
274 } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
275 $this->pagesOnly();
276 }
277
278 // Add all the content to an output section
279 $this->content.=$this->doc->section('',$this->code);
280
281 // Setting up the buttons and markers for docheader
282 $docHeaderButtons = $this->getButtons();
283 $markers['CSH'] = $docHeaderButtons['csh'];
284
285 $markers['CONTENT'] = $this->content;
286
287 // Build the <body> for the module
288 $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
289 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
290 $this->content.= $this->doc->endPage();
291 $this->content = $this->doc->insertStylesAndJS($this->content);
292 }
293 }
294
295 /**
296 * Create the panel of buttons for submitting the form or otherwise perform operations.
297 *
298 * @return array all available buttons as an assoc. array
299 */
300 protected function getButtons() {
301 global $LANG, $BACK_PATH;
302
303 $buttons = array(
304 'csh' => '',
305 'back' => '',
306 'view' => '',
307 'new_page' => '',
308 'record_list' => ''
309 );
310
311
312 if (!$this->pagesOnly) { // Regular new element:
313 // New page
314 if ($this->showNewRecLink('pages')) {
315 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly' => '1'))) . '">' .
316 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/new_page.gif') . ' alt="" />' .
317 '</a>';
318 }
319 // CSH
320 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE);
321 } elseif($this->showNewRecLink('pages')) { // Pages only wizard
322 // CSH
323 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE);
324 }
325
326 // Back
327 if ($this->R_URI) {
328 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack">' .
329 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/goback.gif') . ' alt="" />' .
330 '</a>';
331 }
332
333 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
334 // View
335 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $this->backPath, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
336 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" alt="" />' .
337 '</a>';
338
339 // Record list
340 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
341 $href = $this->backPath . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
342 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
343 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
344 '</a>';
345 }
346 }
347
348
349
350 return $buttons;
351 }
352
353 /**
354 * Creates the position map for pages wizard
355 *
356 * @return void
357 */
358 function pagesOnly() {
359 global $LANG;
360
361 $posMap = t3lib_div::makeInstance('t3lib_positionMap');
362 $this->code.='
363 <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
364 ';
365 $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
366 }
367
368 /**
369 * Create a regular new element (pages and records)
370 *
371 * @return void
372 */
373 function regularNew() {
374 global $BE_USER,$LANG,$BACK_PATH,$TCA;
375
376 $doNotShowFullDescr = FALSE;
377
378 // Slight spacer from header:
379 $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
380
381 // Initialize array for accumulating table rows:
382 $tRows = array();
383
384 // New pages INSIDE this pages
385 if ($this->newPagesInto
386 && $this->isTableAllowedForThisPage($this->pageinfo, 'pages')
387 && $BE_USER->check('tables_modify','pages')
388 && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, 'pages')
389 ) {
390
391 // Create link to new page inside:
392 $t = 'pages';
393 $v = $TCA[$t];
394 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
395 $this->linkWrap(
396 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
397 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
398 $t,
399 $this->id).'<br/>';
400
401 // Link to page-wizard:
402 $rowContent.= '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
403 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
404 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
405 htmlspecialchars($LANG->getLL('clickForWizard')).
406 '</a>';
407 // Half-line:
408 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
409
410 // Compile table row:
411 $tRows[]='
412 <tr>
413 <td nowrap="nowrap">'.$rowContent.'</td>
414 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
415 </tr>
416 ';
417 }
418
419 // New pages AFTER this pages
420 if ($this->newPagesAfter
421 && $this->isTableAllowedForThisPage($this->pidInfo,'pages')
422 && $BE_USER->check('tables_modify','pages')
423 && $BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')
424 ) {
425
426 // Create link to new page after
427 $t = 'pages';
428 $v = $TCA[$t];
429 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
430 $this->linkWrap(
431 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
432 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
433 'pages',
434 -$this->id
435 );
436 // Half-line added:
437 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
438
439 // Compile table row:
440 $tRows[] = '
441 <tr>
442 <td nowrap="nowrap">'.$rowContent.'</td>
443 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
444 </tr>
445 ';
446 }
447
448 // New tables (but not pages) INSIDE this pages
449 if ($this->newContentInto) {
450 if (is_array($TCA)) {
451 foreach($TCA as $t => $v) {
452 if ($t!='pages'
453 && $this->showNewRecLink($t)
454 && $this->isTableAllowedForThisPage($this->pageinfo, $t)
455 && $BE_USER->check('tables_modify',$t)
456 && (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel']==-1)
457 && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, $t)
458 ) {
459
460 // Create new link for record:
461 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
462 $this->linkWrap(
463 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
464 $LANG->sL($v['ctrl']['title'],1)
465 ,$t
466 ,$this->id);
467
468 // If the table is 'tt_content' (from "cms" extension), create link to wizard
469 if ($t=='tt_content') {
470
471 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
472 $overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
473 $pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
474
475 $href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
476 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
477 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
478 '<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
479 htmlspecialchars($LANG->getLL('clickForWizard')).
480 '</a>';
481
482 // Half-line added:
483 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
484 }
485
486
487 // Compile table row:
488 $tRows[] = '
489 <tr>
490 <td nowrap="nowrap">'.$rowContent.'</td>
491 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
492 </tr>
493 ';
494
495 }
496 }
497 }
498 }
499
500
501 // Compile table row:
502 $tRows[]='
503 <tr>
504 <td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /></td>
505 <td></td>
506 </tr>
507 ';
508
509
510 // Make table:
511 $this->code.='
512 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
513 '.implode('',$tRows).'
514 </table>
515 ';
516 }
517
518 /**
519 * Ending page output and echo'ing content to browser.
520 *
521 * @return void
522 */
523 function printContent() {
524 echo $this->content;
525 }
526
527 /**
528 * Links the string $code to a create-new form for a record in $table created on page $pid
529 *
530 * @param string Link string
531 * @param string Table name (in which to create new record)
532 * @param integer PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
533 * @param boolean If $addContentTable is set, then a new contentTable record is created together with pages
534 * @return string The link.
535 */
536 function linkWrap($code,$table,$pid,$addContentTable=0) {
537 $params = '&edit['.$table.']['.$pid.']=new'.
538 ($table=='pages'
539 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
540 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
541 && $addContentTable ?
542 '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1' :
543 ''
544 );
545 $onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
546 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
547 }
548
549 /**
550 * Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
551 *
552 * @param array Record for parent page.
553 * @param string Table name to check
554 * @return boolean Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
555 */
556 function isTableAllowedForThisPage($pid_row, $checkTable) {
557 global $TCA, $PAGES_TYPES;
558 if (!is_array($pid_row)) {
559 if ($GLOBALS['BE_USER']->user['admin']) {
560 return true;
561 } else {
562 return false;
563 }
564 }
565 // be_users and be_groups may not be created anywhere but in the root.
566 if ($checkTable=='be_users' || $checkTable=='be_groups') {
567 return false;
568 }
569 // Checking doktype:
570 $doktype = intval($pid_row['doktype']);
571 if (!$allowedTableList = $PAGES_TYPES[$doktype]['allowedTables']) {
572 $allowedTableList = $PAGES_TYPES['default']['allowedTables'];
573 }
574 if (strstr($allowedTableList,'*') || t3lib_div::inList($allowedTableList,$checkTable)) { // If all tables or the table is listed as a allowed type, return true
575 return true;
576 }
577 }
578
579 /**
580 * Returns true if:
581 * - $allowedNewTables and $deniedNewTables are empty
582 * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
583 *
584 * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
585 * has priority over $allowedNewTables.
586 *
587 * @param string Table name to test if in allowedTables
588 * @param array Array of new tables that are allowed.
589 * @param array Array of new tables that are not allowed.
590 * @return boolean Returns true if a link for creating new records should be displayed for $table
591 */
592 function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
593 $allowedNewTables = ($allowedNewTables ? $allowedNewTables : $this->allowedNewTables);
594 $deniedNewTables = ($deniedNewTables ? $deniedNewTables : $this->deniedNewTables);
595 // No deny/allow tables are set:
596 if (!count($allowedNewTables) && !count($deniedNewTables)) {
597 return true;
598 // If table is not denied (which takes precedence over allowed tables):
599 } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) || in_array($table, $allowedNewTables))) {
600 return true;
601 // If table is denied or allowed tables are set, but table is not part of:
602 } else {
603 return false;
604 }
605 }
606 }
607
608
609 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']) {
610 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
611 }
612
613
614
615 // Make instance:
616 $SOBE = t3lib_div::makeInstance('SC_db_new');
617 $SOBE->init();
618 $SOBE->main();
619 $SOBE->printContent();
620
621 ?>