Bug #8422: Context Sensitive Help mode with "display full text messages"
[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->docType= 'xhtml_trans';
187 $this->doc->JScode='';
188
189 // Setting up the context sensitive menu:
190 $this->doc->getContextMenuCode();
191
192 // Creating content
193 $this->content='';
194 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
195
196 // Id a positive id is supplied, ask for the page record with permission information contained:
197 if ($this->id > 0) {
198 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
199 }
200
201 // If a page-record was returned, the user had read-access to the page.
202 if ($this->pageinfo['uid']) {
203 // Get record of parent page
204
205 $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
206 // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
207 if ($BE_USER->doesUserHaveAccess($this->pageinfo,8)) {
208 $this->newPagesInto=1;
209 }
210 if ($BE_USER->doesUserHaveAccess($this->pageinfo,16)) {
211 $this->newContentInto=1;
212 }
213
214 if (($BE_USER->isAdmin()||is_array($this->pidInfo)) && $BE_USER->doesUserHaveAccess($this->pidInfo,8)) {
215 $this->newPagesAfter=1;
216 }
217 } elseif ($BE_USER->isAdmin()) {
218 // Admins can do it all
219 $this->newPagesInto=1;
220 $this->newContentInto=1;
221 $this->newPagesAfter=0;
222 } else {
223 // People with no permission can do nothing
224 $this->newPagesInto=0;
225 $this->newContentInto=0;
226 $this->newPagesAfter=0;
227 }
228 }
229
230 /**
231 * Main processing, creating the list of new record tables to select from
232 *
233 * @return void
234 */
235 function main() {
236 global $BE_USER,$LANG;
237
238 // If there was a page - or if the user is admin (admins has access to the root) we proceed:
239 if ($this->pageinfo['uid'] || $BE_USER->isAdmin()) {
240 // Acquiring TSconfig for this module/current page:
241 $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
242 $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
243 $this->deniedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['deniedNewTables'],1);
244
245 // Acquiring TSconfig for this module/parent page:
246 $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
247 $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
248 $this->deniedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['deniedNewTables'],1);
249
250 // More init:
251 if (!$this->showNewRecLink('pages')) {
252 $this->newPagesInto=0;
253 }
254 if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid)) {
255 $this->newPagesAfter=0;
256 }
257
258
259 // Set header-HTML and return_url
260 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
261 $iconImgTag = t3lib_iconWorks::getIconImage('pages', $this->pageinfo, $this->backPath, 'title="' . htmlspecialchars($this->pageinfo['_thePath']) . '"');
262 $title = strip_tags($this->pageinfo[$GLOBALS['TCA']['pages']['ctrl']['label']]);
263 } else {
264 $iconImgTag = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif') . ' title="' . htmlspecialchars($this->pageinfo['_thePath']) . '" alt="" />';
265 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
266 }
267
268 $this->code = '<span class="typo3-moduleHeader">' . $this->doc->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo['uid']) . htmlspecialchars(t3lib_div::fixed_lgd_cs($title, 45)) . '</span><br />';
269
270 $this->R_URI = $this->returnUrl;
271
272 // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
273 if (!$this->pagesOnly) { // Regular new element:
274 $this->regularNew();
275 } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
276 $this->pagesOnly();
277 }
278
279 // Add all the content to an output section
280 $this->content.=$this->doc->section('',$this->code);
281
282 // Setting up the buttons and markers for docheader
283 $docHeaderButtons = $this->getButtons();
284 $markers['CSH'] = $docHeaderButtons['csh'];
285
286 $markers['CONTENT'] = $this->content;
287
288 // Build the <body> for the module
289 $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
290 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
291 $this->content.= $this->doc->endPage();
292 $this->content = $this->doc->insertStylesAndJS($this->content);
293 }
294 }
295
296 /**
297 * Create the panel of buttons for submitting the form or otherwise perform operations.
298 *
299 * @return array all available buttons as an assoc. array
300 */
301 protected function getButtons() {
302 global $LANG, $BACK_PATH;
303
304 $buttons = array(
305 'csh' => '',
306 'back' => '',
307 'view' => '',
308 'new_page' => '',
309 'record_list' => ''
310 );
311
312
313 if (!$this->pagesOnly) { // Regular new element:
314 // New page
315 if ($this->showNewRecLink('pages')) {
316 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly' => '1'))) . '">' .
317 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/new_page.gif') . ' alt="" />' .
318 '</a>';
319 }
320 // CSH
321 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE);
322 } elseif($this->showNewRecLink('pages')) { // Pages only wizard
323 // CSH
324 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE);
325 }
326
327 // Back
328 if ($this->R_URI) {
329 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack">' .
330 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/goback.gif') . ' alt="" />' .
331 '</a>';
332 }
333
334 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
335 // View
336 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $this->backPath, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
337 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" alt="" />' .
338 '</a>';
339
340 // Record list
341 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
342 $href = $this->backPath . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
343 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
344 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
345 '</a>';
346 }
347 }
348
349
350
351 return $buttons;
352 }
353
354 /**
355 * Creates the position map for pages wizard
356 *
357 * @return void
358 */
359 function pagesOnly() {
360 global $LANG;
361
362 $posMap = t3lib_div::makeInstance('t3lib_positionMap');
363 $this->code.='
364 <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
365 ';
366 $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
367 }
368
369 /**
370 * Create a regular new element (pages and records)
371 *
372 * @return void
373 */
374 function regularNew() {
375 global $BE_USER,$LANG,$BACK_PATH,$TCA;
376
377 $doNotShowFullDescr = FALSE;
378
379 // Slight spacer from header:
380 $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
381
382 // Initialize array for accumulating table rows:
383 $tRows = array();
384
385 // New pages INSIDE this pages
386 if ($this->newPagesInto
387 && $this->isTableAllowedForThisPage($this->pageinfo, 'pages')
388 && $BE_USER->check('tables_modify','pages')
389 && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, 'pages')
390 ) {
391
392 // Create link to new page inside:
393 $t = 'pages';
394 $v = $TCA[$t];
395 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
396 $this->linkWrap(
397 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
398 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
399 $t,
400 $this->id).'<br/>';
401
402 // Link to page-wizard:
403 $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="" />'.
404 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
405 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
406 htmlspecialchars($LANG->getLL('clickForWizard')).
407 '</a>';
408 // Half-line:
409 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
410
411 // Compile table row:
412 $tRows[]='
413 <tr>
414 <td nowrap="nowrap">'.$rowContent.'</td>
415 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
416 </tr>
417 ';
418 }
419
420 // New tables (but not pages) INSIDE this pages
421 if ($this->newContentInto) {
422 if (is_array($TCA)) {
423 foreach($TCA as $t => $v) {
424 if ($t!='pages'
425 && $this->showNewRecLink($t)
426 && $this->isTableAllowedForThisPage($this->pageinfo, $t)
427 && $BE_USER->check('tables_modify',$t)
428 && (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel']==-1)
429 && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, $t)
430 ) {
431
432 // Create new link for record:
433 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
434 $this->linkWrap(
435 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
436 $LANG->sL($v['ctrl']['title'],1)
437 ,$t
438 ,$this->id);
439
440 // If the table is 'tt_content' (from "cms" extension), create link to wizard
441 if ($t=='tt_content') {
442
443 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
444 $overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
445 $pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
446
447 $href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
448 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
449 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
450 '<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
451 htmlspecialchars($LANG->getLL('clickForWizard')).
452 '</a>';
453
454 // Half-line added:
455 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
456 }
457
458
459 // Compile table row:
460 $tRows[] = '
461 <tr>
462 <td nowrap="nowrap">'.$rowContent.'</td>
463 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
464 </tr>
465 ';
466
467 }
468 }
469 }
470 }
471
472 // New pages AFTER this pages
473 if ($this->newPagesAfter
474 && $this->isTableAllowedForThisPage($this->pidInfo,'pages')
475 && $BE_USER->check('tables_modify','pages')
476 && $BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')
477 ) {
478
479 // Create link to new page after
480 $t = 'pages';
481 $v = $TCA[$t];
482 $rowContent = $this->linkWrap(
483 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
484 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
485 'pages',
486 -$this->id
487 );
488
489 // Compile table row:
490 $tRows[] = '
491 <tr>
492 <td nowrap="nowrap">'.$rowContent.'</td>
493 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
494 </tr>
495 ';
496 } else {
497 // Compile table row:
498 $tRows[]='
499 <tr>
500 <td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /></td>
501 <td></td>
502 </tr>
503 ';
504 }
505
506 // Make table:
507 $this->code.='
508 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
509 '.implode('',$tRows).'
510 </table>
511 ';
512 }
513
514 /**
515 * Ending page output and echo'ing content to browser.
516 *
517 * @return void
518 */
519 function printContent() {
520 echo $this->content;
521 }
522
523 /**
524 * Links the string $code to a create-new form for a record in $table created on page $pid
525 *
526 * @param string Link string
527 * @param string Table name (in which to create new record)
528 * @param integer PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
529 * @param boolean If $addContentTable is set, then a new contentTable record is created together with pages
530 * @return string The link.
531 */
532 function linkWrap($code,$table,$pid,$addContentTable=0) {
533 $params = '&edit['.$table.']['.$pid.']=new'.
534 ($table=='pages'
535 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
536 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
537 && $addContentTable ?
538 '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1' :
539 ''
540 );
541 $onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
542 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
543 }
544
545 /**
546 * Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
547 *
548 * @param array Record for parent page.
549 * @param string Table name to check
550 * @return boolean Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
551 */
552 function isTableAllowedForThisPage($pid_row, $checkTable) {
553 global $TCA, $PAGES_TYPES;
554 if (!is_array($pid_row)) {
555 if ($GLOBALS['BE_USER']->user['admin']) {
556 return true;
557 } else {
558 return false;
559 }
560 }
561 // be_users and be_groups may not be created anywhere but in the root.
562 if ($checkTable=='be_users' || $checkTable=='be_groups') {
563 return false;
564 }
565 // Checking doktype:
566 $doktype = intval($pid_row['doktype']);
567 if (!$allowedTableList = $PAGES_TYPES[$doktype]['allowedTables']) {
568 $allowedTableList = $PAGES_TYPES['default']['allowedTables'];
569 }
570 if (strstr($allowedTableList,'*') || t3lib_div::inList($allowedTableList,$checkTable)) { // If all tables or the table is listed as a allowed type, return true
571 return true;
572 }
573 }
574
575 /**
576 * Returns true if:
577 * - $allowedNewTables and $deniedNewTables are empty
578 * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
579 *
580 * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
581 * has priority over $allowedNewTables.
582 *
583 * @param string Table name to test if in allowedTables
584 * @param array Array of new tables that are allowed.
585 * @param array Array of new tables that are not allowed.
586 * @return boolean Returns true if a link for creating new records should be displayed for $table
587 */
588 function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
589 $allowedNewTables = ($allowedNewTables ? $allowedNewTables : $this->allowedNewTables);
590 $deniedNewTables = ($deniedNewTables ? $deniedNewTables : $this->deniedNewTables);
591 // No deny/allow tables are set:
592 if (!count($allowedNewTables) && !count($deniedNewTables)) {
593 return true;
594 // If table is not denied (which takes precedence over allowed tables):
595 } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) || in_array($table, $allowedNewTables))) {
596 return true;
597 // If table is denied or allowed tables are set, but table is not part of:
598 } else {
599 return false;
600 }
601 }
602 }
603
604 // Include extension?
605 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']) {
606 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
607 }
608
609
610
611
612
613 // Make instance:
614 $SOBE = t3lib_div::makeInstance('SC_db_new');
615 $SOBE->init();
616 $SOBE->main();
617 $SOBE->printContent();
618 ?>