db_new.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * New database item menu
00029  *
00030  * This script lets users choose a new database element to create.
00031  * Includes a wizard mode for visually pointing out the position of new pages
00032  *
00033  * $Id: db_new.php 4433 2008-11-07 04:13:12Z flyguide $
00034  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00035  * XHTML compliant
00036  *
00037  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00038  */
00039 /**
00040  * [CLASS/FUNCTION INDEX of SCRIPT]
00041  *
00042  *
00043  *
00044  *   90: class localPageTree extends t3lib_pageTree
00045  *   99:     function wrapIcon($icon,$row)
00046  *  110:     function expandNext($id)
00047  *
00048  *
00049  *  128: class SC_db_new
00050  *  157:     function init()
00051  *  224:     function main()
00052  *  276:     function pagesOnly()
00053  *  294:     function regularNew()
00054  *  458:     function printContent()
00055  *  473:     function linkWrap($code,$table,$pid,$addContentTable=0)
00056  *  493:     function isTableAllowedForThisPage($pid_row, $checkTable)
00057  *  523:     function showNewRecLink($table,$allowedNewTables='')
00058  *
00059  * TOTAL FUNCTIONS: 10
00060  * (This index is automatically created/updated by the extension "extdeveval")
00061  *
00062  */
00063 
00064 
00065 
00066 
00067 $BACK_PATH='';
00068 require('init.php');
00069 require('template.php');
00070 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00071 
00072 // ***************************
00073 // Including classes
00074 // ***************************
00075 require_once(PATH_t3lib.'class.t3lib_page.php');
00076 require_once(PATH_t3lib.'class.t3lib_positionmap.php');
00077 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
00078 
00079 
00080 
00081 
00082 
00083 /**
00084  * Extension for the tree class that generates the tree of pages in the page-wizard mode
00085  *
00086  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00087  * @package TYPO3
00088  * @subpackage core
00089  */
00090 class localPageTree extends t3lib_pageTree {
00091 
00092     /**
00093      * Inserting uid-information in title-text for an icon
00094      *
00095      * @param   string      Icon image
00096      * @param   array       Item row
00097      * @return  string      Wrapping icon image.
00098      */
00099     function wrapIcon($icon,$row)   {
00100         return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
00101     }
00102 
00103     /**
00104      * Determines whether to expand a branch or not.
00105      * Here the branch is expanded if the current id matches the global id for the listing/new
00106      *
00107      * @param   integer     The ID (page id) of the element
00108      * @return  boolean     Returns true if the IDs matches
00109      */
00110     function expandNext($id)    {
00111         return $id==$GLOBALS['SOBE']->id ? 1 : 0;
00112     }
00113 }
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 /**
00122  * Script class for 'db_new'
00123  *
00124  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00125  * @package TYPO3
00126  * @subpackage core
00127  */
00128 class SC_db_new {
00129     var $pageinfo;
00130     var $pidInfo;
00131     var $newPagesInto;
00132     var $newContentInto;
00133     var $newPagesAfter;
00134     var $web_list_modTSconfig;
00135     var $allowedNewTables;
00136     var $deniedNewTables;
00137     var $web_list_modTSconfig_pid;
00138     var $allowedNewTables_pid;
00139     var $deniedNewTables_pid;
00140     var $code;
00141     var $R_URI;
00142 
00143         // Internal, static: GPvar
00144     var $id;            // see init()
00145     var $returnUrl;     // Return url.
00146     var $pagesOnly;     // pagesOnly flag.
00147 
00148         // Internal
00149     var $perms_clause;  // see init()
00150 
00151     /**
00152      * Document template object
00153      *
00154      * @var mediumDoc
00155      */
00156     var $doc;
00157     var $content;       // Accumulated HTML output
00158 
00159 
00160     /**
00161      * Constructor function for the class
00162      *
00163      * @return  void
00164      */
00165     function init() {
00166         global $BE_USER,$LANG,$BACK_PATH;
00167 
00168             // page-selection permission clause (reading)
00169         $this->perms_clause = $BE_USER->getPagePermsClause(1);
00170 
00171             // this will hide records from display - it has nothing todo with user rights!!
00172         if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
00173             if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
00174                 $this->perms_clause .= ' AND pages.uid NOT IN ('.$pidList.')';
00175             }
00176         }
00177             // Setting GPvars:
00178         $this->id = intval(t3lib_div::_GP('id'));   // The page id to operate from
00179         $this->returnUrl = t3lib_div::_GP('returnUrl');
00180         $this->pagesOnly = t3lib_div::_GP('pagesOnly');
00181 
00182             // Create instance of template class for output
00183         $this->doc = t3lib_div::makeInstance('template');
00184         $this->doc->backPath = $BACK_PATH;
00185         $this->doc->setModuleTemplate('templates/db_new.html');
00186         $this->doc->JScode='';
00187 
00188             // Setting up the context sensitive menu:
00189         $this->doc->getContextMenuCode();
00190 
00191             // Creating content
00192         $this->content='';
00193         $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
00194 
00195             // Id a positive id is supplied, ask for the page record with permission information contained:
00196         if ($this->id > 0)  {
00197             $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00198         }
00199 
00200             // If a page-record was returned, the user had read-access to the page.
00201         if ($this->pageinfo['uid']) {
00202                 // Get record of parent page
00203 
00204             $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
00205                 // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
00206             if ($BE_USER->doesUserHaveAccess($this->pageinfo,8))    {
00207                 $this->newPagesInto=1;
00208             }
00209             if ($BE_USER->doesUserHaveAccess($this->pageinfo,16))   {
00210                 $this->newContentInto=1;
00211             }
00212 
00213             if (($BE_USER->isAdmin()||is_array($this->pidInfo)) && $BE_USER->doesUserHaveAccess($this->pidInfo,8))  {
00214                 $this->newPagesAfter=1;
00215             }
00216         } elseif ($BE_USER->isAdmin())  {
00217                 // Admins can do it all
00218             $this->newPagesInto=1;
00219             $this->newContentInto=1;
00220             $this->newPagesAfter=0;
00221         } else {
00222                 // People with no permission can do nothing
00223             $this->newPagesInto=0;
00224             $this->newContentInto=0;
00225             $this->newPagesAfter=0;
00226         }
00227     }
00228 
00229     /**
00230      * Main processing, creating the list of new record tables to select from
00231      *
00232      * @return  void
00233      */
00234     function main() {
00235         global $BE_USER,$LANG;
00236 
00237             // If there was a page - or if the user is admin (admins has access to the root) we proceed:
00238         if ($this->pageinfo['uid'] || $BE_USER->isAdmin())  {
00239                 // Acquiring TSconfig for this module/current page:
00240             $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00241             $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
00242             $this->deniedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['deniedNewTables'],1);
00243 
00244                 // Acquiring TSconfig for this module/parent page:
00245             $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
00246             $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
00247             $this->deniedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['deniedNewTables'],1);
00248 
00249                 // More init:
00250             if (!$this->showNewRecLink('pages'))    {
00251                 $this->newPagesInto=0;
00252             }
00253             if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid))   {
00254                 $this->newPagesAfter=0;
00255             }
00256 
00257 
00258                 // Set header-HTML and return_url
00259             if (is_array($this->pageinfo) && $this->pageinfo['uid'])    {
00260                 $iconImgTag = t3lib_iconWorks::getIconImage('pages', $this->pageinfo, $this->backPath, 'title="' . htmlspecialchars($this->pageinfo['_thePath']) . '"');
00261                 $title = strip_tags($this->pageinfo[$GLOBALS['TCA']['pages']['ctrl']['label']]);
00262             } else {
00263                 $iconImgTag = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif') . ' title="' . htmlspecialchars($this->pageinfo['_thePath']) . '" alt="" />';
00264                 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
00265             }
00266 
00267             $this->code = '<span class="typo3-moduleHeader">' . $this->doc->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo['uid']) . htmlspecialchars(t3lib_div::fixed_lgd_cs($title, 45)) . '</span><br />';
00268 
00269             $this->R_URI = $this->returnUrl;
00270 
00271                 // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
00272             if (!$this->pagesOnly)  {   // Regular new element:
00273                 $this->regularNew();
00274             } elseif ($this->showNewRecLink('pages')) { // Pages only wizard
00275                 $this->pagesOnly();
00276             }
00277 
00278                 // Add all the content to an output section
00279             $this->content.=$this->doc->section('',$this->code);
00280 
00281                             // Setting up the buttons and markers for docheader
00282             $docHeaderButtons = $this->getButtons();
00283             $markers['CSH'] = $docHeaderButtons['csh'];
00284 
00285             $markers['CONTENT'] = $this->content;
00286 
00287                 // Build the <body> for the module
00288             $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
00289             $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00290             $this->content.= $this->doc->endPage();
00291             $this->content = $this->doc->insertStylesAndJS($this->content);
00292         }
00293     }
00294 
00295     /**
00296      * Create the panel of buttons for submitting the form or otherwise perform operations.
00297      *
00298      * @return  array   all available buttons as an assoc. array
00299      */
00300     protected function getButtons() {
00301         global $LANG, $BACK_PATH;
00302 
00303         $buttons = array(
00304             'csh' => '',
00305             'back' => '',
00306             'view' => '',
00307             'new_page' => '',
00308             'record_list' => ''
00309         );
00310 
00311 
00312         if (!$this->pagesOnly)  {   // Regular new element:
00313                 // New page
00314             if ($this->showNewRecLink('pages')) {
00315                 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly' => '1'))) . '">' .
00316                     '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/new_page.gif') . ' alt="" />' .
00317                     '</a>';
00318             }
00319                 // CSH
00320             $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE);
00321         } elseif($this->showNewRecLink('pages')) {  // Pages only wizard
00322                 // CSH
00323             $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE);
00324         }
00325 
00326             // Back
00327         if ($this->R_URI) {
00328             $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack">' .
00329                 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/goback.gif') . ' alt="" />' .
00330                 '</a>';
00331         }
00332 
00333         if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
00334                 // View
00335             $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $this->backPath, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
00336                 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" alt="" />' .
00337                 '</a>';
00338 
00339                 // Record list
00340             if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
00341                 $href = $this->backPath . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00342                 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
00343                     '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
00344                     '</a>';
00345             }
00346         }
00347 
00348 
00349 
00350         return $buttons;
00351     }
00352 
00353     /**
00354      * Creates the position map for pages wizard
00355      *
00356      * @return  void
00357      */
00358     function pagesOnly()    {
00359         global $LANG;
00360 
00361         $posMap = t3lib_div::makeInstance('t3lib_positionMap');
00362         $this->code.='
00363             <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
00364         ';
00365         $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
00366     }
00367 
00368     /**
00369      * Create a regular new element (pages and records)
00370      *
00371      * @return  void
00372      */
00373     function regularNew()   {
00374         global $BE_USER,$LANG,$BACK_PATH,$TCA;
00375 
00376         $doNotShowFullDescr = FALSE;
00377 
00378             // Slight spacer from header:
00379         $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
00380 
00381             // Initialize array for accumulating table rows:
00382         $tRows = array();
00383 
00384             // New pages INSIDE this pages
00385         if ($this->newPagesInto
00386             && $this->isTableAllowedForThisPage($this->pageinfo, 'pages')
00387             && $BE_USER->check('tables_modify','pages')
00388             && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, 'pages')
00389             )   {
00390 
00391                 // Create link to new page inside:
00392             $t = 'pages';
00393             $v = $TCA[$t];
00394             $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
00395                     $this->linkWrap(
00396                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
00397                             $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
00398                         $t,
00399                         $this->id).'<br/>';
00400 
00401                 // Link to page-wizard:
00402             $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="" />'.
00403                 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
00404                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
00405                 htmlspecialchars($LANG->getLL('clickForWizard')).
00406                 '</a>';
00407                 // Half-line:
00408             $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00409 
00410                 // Compile table row:
00411             $tRows[]='
00412                 <tr>
00413                     <td nowrap="nowrap">'.$rowContent.'</td>
00414                     <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00415                 </tr>
00416             ';
00417         }
00418 
00419             // New tables (but not pages) INSIDE this pages
00420         if ($this->newContentInto)  {
00421             if (is_array($TCA)) {
00422                 foreach($TCA as $t => $v)   {
00423                     if ($t!='pages'
00424                             && $this->showNewRecLink($t)
00425                             && $this->isTableAllowedForThisPage($this->pageinfo, $t)
00426                             && $BE_USER->check('tables_modify',$t)
00427                             && (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel']==-1)
00428                             && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, $t)
00429                             )   {
00430 
00431                             // Create new link for record:
00432                         $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
00433                                 $this->linkWrap(
00434                                 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
00435                                 $LANG->sL($v['ctrl']['title'],1)
00436                             ,$t
00437                             ,$this->id);
00438 
00439                             // If the table is 'tt_content' (from "cms" extension), create link to wizard
00440                         if ($t=='tt_content')   {
00441 
00442                                 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
00443                             $overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
00444                             $pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00445 
00446                             $href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00447                             $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
00448                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
00449                                         '<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
00450                                         htmlspecialchars($LANG->getLL('clickForWizard')).
00451                                         '</a>';
00452 
00453                                 // Half-line added:
00454                             $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00455                         }
00456 
00457 
00458                             // Compile table row:
00459                         $tRows[] = '
00460                 <tr>
00461                     <td nowrap="nowrap">'.$rowContent.'</td>
00462                     <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00463                 </tr>
00464             ';
00465 
00466                     }
00467                 }
00468             }
00469         }
00470 
00471             // New pages AFTER this pages
00472         if ($this->newPagesAfter
00473             && $this->isTableAllowedForThisPage($this->pidInfo,'pages')
00474             && $BE_USER->check('tables_modify','pages')
00475             && $BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')
00476             )   {
00477 
00478                 // Create link to new page after
00479             $t = 'pages';
00480             $v = $TCA[$t];
00481             $rowContent = $this->linkWrap(
00482                     t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
00483                         $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
00484                     'pages',
00485                     -$this->id
00486                 );
00487 
00488                 // Compile table row:
00489             $tRows[] = '
00490                 <tr>
00491                     <td nowrap="nowrap">'.$rowContent.'</td>
00492                     <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00493                 </tr>
00494             ';
00495         } else {
00496                 // Compile table row:
00497             $tRows[]='
00498                 <tr>
00499                     <td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /></td>
00500                     <td></td>
00501                 </tr>
00502             ';
00503         }
00504 
00505             // Make table:
00506         $this->code.='
00507             <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
00508             '.implode('',$tRows).'
00509             </table>
00510         ';
00511     }
00512 
00513     /**
00514      * Ending page output and echo'ing content to browser.
00515      *
00516      * @return  void
00517      */
00518     function printContent() {
00519         echo $this->content;
00520     }
00521 
00522     /**
00523      * Links the string $code to a create-new form for a record in $table created on page $pid
00524      *
00525      * @param   string      Link string
00526      * @param   string      Table name (in which to create new record)
00527      * @param   integer     PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
00528      * @param   boolean     If $addContentTable is set, then a new contentTable record is created together with pages
00529      * @return  string      The link.
00530      */
00531     function linkWrap($code,$table,$pid,$addContentTable=0) {
00532         $params = '&edit['.$table.']['.$pid.']=new'.
00533             ($table=='pages'
00534                 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
00535                 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
00536                 && $addContentTable ?
00537                 '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1' :
00538                 ''
00539             );
00540         $onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
00541         return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
00542     }
00543 
00544     /**
00545      * Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
00546      *
00547      * @param   array       Record for parent page.
00548      * @param   string      Table name to check
00549      * @return  boolean     Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
00550      */
00551     function isTableAllowedForThisPage($pid_row, $checkTable)   {
00552         global $TCA, $PAGES_TYPES;
00553         if (!is_array($pid_row))    {
00554             if ($GLOBALS['BE_USER']->user['admin']) {
00555                 return true;
00556             } else {
00557                 return false;
00558             }
00559         }
00560             // be_users and be_groups may not be created anywhere but in the root.
00561         if ($checkTable=='be_users' || $checkTable=='be_groups')    {
00562             return false;
00563         }
00564             // Checking doktype:
00565         $doktype = intval($pid_row['doktype']);
00566         if (!$allowedTableList = $PAGES_TYPES[$doktype]['allowedTables'])   {
00567             $allowedTableList = $PAGES_TYPES['default']['allowedTables'];
00568         }
00569         if (strstr($allowedTableList,'*') || t3lib_div::inList($allowedTableList,$checkTable))  {       // If all tables or the table is listed as a allowed type, return true
00570             return true;
00571         }
00572     }
00573 
00574     /**
00575      * Returns true if:
00576      * - $allowedNewTables and $deniedNewTables are empty
00577      * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
00578      *
00579      * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
00580      * has priority over $allowedNewTables.
00581      *
00582      * @param   string      Table name to test if in allowedTables
00583      * @param   array       Array of new tables that are allowed.
00584      * @param   array       Array of new tables that are not allowed.
00585      * @return  boolean     Returns true if a link for creating new records should be displayed for $table
00586      */
00587     function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
00588         $allowedNewTables = ($allowedNewTables ? $allowedNewTables : $this->allowedNewTables);
00589         $deniedNewTables = ($deniedNewTables ? $deniedNewTables : $this->deniedNewTables);
00590             // No deny/allow tables are set:
00591         if (!count($allowedNewTables) && !count($deniedNewTables)) {
00592             return true;
00593             // If table is not denied (which takes precedence over allowed tables):
00594         } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) || in_array($table, $allowedNewTables))) {
00595             return true;
00596             // If table is denied or allowed tables are set, but table is not part of:
00597         } else {
00598             return false;
00599         }
00600     }
00601 }
00602 
00603 
00604 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php'])    {
00605     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
00606 }
00607 
00608 
00609 
00610 // Make instance:
00611 $SOBE = t3lib_div::makeInstance('SC_db_new');
00612 $SOBE->init();
00613 $SOBE->main();
00614 $SOBE->printContent();
00615 
00616 ?>

Generated on Sat Jan 3 04:23:28 2009 for TYPO3 API by  doxygen 1.4.7