* Added a checkbox for be-users to disable IP locking. This is useful if you have...
[Packages/TYPO3.CMS.git] / typo3 / db_new.php
index 2bfce30..51b0c34 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is 
@@ -31,8 +31,8 @@
  * Includes a wizard mode for visually pointing out the position of new pages
  *
  * $Id$
- * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
- * XHTML compliant (not with pages wizard yet... position map and other classes needs cleaning)
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * XHTML compliant
  *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  */
  *  110:     function expandNext($id)  
  *
  *
- *  123: class SC_db_new 
- *  149:     function init()   
- *  206:     function main()   
- *  263:     function pagesOnly()      
- *  279:     function regularNew()     
- *  412:     function printContent()   
- *  426:     function linkWrap($code,$table,$pid,$addContentTable=0)   
- *  446:     function isTableAllowedForThisPage($pid_row, $checkTable) 
- *  476:     function showNewRecLink($table,$allowedNewTables='')      
+ *  128: class SC_db_new 
+ *  157:     function init()   
+ *  217:     function main()   
+ *  274:     function pagesOnly()      
+ *  289:     function regularNew()     
+ *  432:     function printContent()   
+ *  446:     function linkWrap($code,$table,$pid,$addContentTable=0)   
+ *  466:     function isTableAllowedForThisPage($pid_row, $checkTable) 
+ *  496:     function showNewRecLink($table,$allowedNewTables='')      
  *
  * TOTAL FUNCTIONS: 10
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -82,7 +82,7 @@ require_once (PATH_t3lib.'class.t3lib_pagetree.php');
 
 /**
  * Extension for the tree class that generates the tree of pages in the page-wizard mode
- * 
+ *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage core
@@ -91,20 +91,20 @@ class localPageTree extends t3lib_pageTree {
 
        /**
         * Inserting uid-information in title-text for an icon
-        * 
+        *
         * @param       string          Icon image
         * @param       array           Item row
         * @return      string          Wrapping icon image.
         */
        function wrapIcon($icon,$row)   {
-               return substr($icon,0,-1).' title="id='.htmlspecialchars($row['uid']).'">';
+               return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
        }
 
        /**
         * Determines whether to expand a branch or not.
         * Here the branch is expanded if the current id matches the global id for the listing/new
-        * 
-        * @param       integer         The ID
+        *
+        * @param       integer         The ID (page id) of the element
         * @return      boolean         Returns true if the IDs matches
         */
        function expandNext($id)        {
@@ -113,9 +113,14 @@ class localPageTree extends t3lib_pageTree {
 }
 
 
+
+
+
+
+
 /**
  * Script class for 'db_new'
- * 
+ *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage core
@@ -132,27 +137,33 @@ class SC_db_new {
        var $allowedNewTables_pid;
        var $code;
        var $R_URI;
-       var $code;      
        
+               // Internal, static: GPvar
+       var $id;                        // see init()
+       var $returnUrl;         // Return url.
+       var $pagesOnly;         // pagesOnly flag.
+
                // Internal
        var $perms_clause;      // see init()
-       var $id;                        // see init()
        var $doc;                       // see init()
        var $content;           // Accumulated HTML output 
 
-
+       
        /**
-        * Constructor
-        * 
-        * @return      void            
+        * Constructor function for the class
+        *
+        * @return      void
         */
        function init() {
-               global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA;
+               global $BE_USER,$LANG,$BACK_PATH;
 
                        // page-selection permission clause (reading)
                $this->perms_clause = $BE_USER->getPagePermsClause(1);
-                       // The page id to operate from
-               $this->id = intval(t3lib_div::GPvar('id'));
+
+                       // Setting GPvars:
+               $this->id = intval(t3lib_div::_GP('id'));       // The page id to operate from
+               $this->returnUrl = t3lib_div::_GP('returnUrl');
+               $this->pagesOnly = t3lib_div::_GP('pagesOnly');
                
                        // Create instance of template class for output
                $this->doc = t3lib_div::makeInstance('smallDoc');
@@ -199,12 +210,12 @@ class SC_db_new {
        }
 
        /**
-        * Main processing
-        * 
-        * @return      void            
+        * Main processing, creating the list of new record tables to select from
+        *
+        * @return      void
         */
        function main() {
-               global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA;
+               global $BE_USER,$LANG;
 
                        // If there was a page - or if the user is admin (admins has access to the root) we proceed:
                if ($this->pageinfo['uid'] || $BE_USER->isAdmin())      {
@@ -228,7 +239,7 @@ class SC_db_new {
                                // Set header-HTML and return_url
                        $this->code=$this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br />
                        ';
-                       $this->R_URI=t3lib_div::GPvar('returnUrl');
+                       $this->R_URI=$this->returnUrl;
                
                                // If CSH is enabled (Context Sensitive Help), load descriptions for 'pages' in any case:
                        if ($BE_USER->uc['edit_showFieldHelp']) {
@@ -236,7 +247,7 @@ class SC_db_new {
                        }
                
                                // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
-                       if (!t3lib_div::GPvar('pagesOnly'))     {       // Regular new element:
+                       if (!$this->pagesOnly)  {       // Regular new element:
                                $this->regularNew();
                        } elseif ($this->showNewRecLink('pages')) {     // Pages only wizard
                                $this->pagesOnly();
@@ -246,8 +257,8 @@ class SC_db_new {
                        if ($this->R_URI)       {
                                $this->code.='<br />
                <a href="'.htmlspecialchars($this->R_URI).'" class="typo3-goBack">'.
-               '<img src="gfx/goback.gif" width="14" height="14" hspace="2" border="0" align="top" alt="" />'.
-               '<strong>'.$LANG->getLL('goBack').'</strong>'.
+               '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'.
+               $LANG->getLL('goBack',1).
                '</a>';
                        }
                                // Add all the content to an output section
@@ -257,30 +268,29 @@ class SC_db_new {
 
        /**
         * Creates the position map for pages wizard
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function pagesOnly()    {
                global $LANG;
 
                $posMap = t3lib_div::makeInstance('t3lib_positionMap');
-               $this->code.='<br />
-               <strong>'.htmlspecialchars($LANG->getLL('selectPosition')).':</strong><br />
-               <br />
+               $this->code.='
+                       <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
                ';
                $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
        }
 
        /**
         * Create a regular new element (pages and records)
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function regularNew()   {
-               global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA;
+               global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA;
 
                        // Slight spacer from header:
-               $this->code.='<img src="'.$BACK_PATH.'t3lib/gfx/ol/halfline.gif" width="18" height="8" align="top" alt="" /><br />';
+               $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
        
                        // New pages INSIDE this pages
                if ($this->newPagesInto && $this->isTableAllowedForThisPage($this->pageinfo, 'pages') && $BE_USER->check('tables_modify','pages'))      {
@@ -288,9 +298,9 @@ class SC_db_new {
                                // Create link to new page inside:
                        $t='pages';
                        $v=$TCA[$t];
-                       $this->code.=$this->linkWrap(
-                                               '<img src="'.$BACK_PATH.'t3lib/gfx/ol/join.gif" width="18" height="16" align="top" border="0" alt="" />'.
-                                                       '<img src="'.$BACK_PATH.'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif').'" width="18" height="16" align="top" border="0" alt="" /> '.
+                       $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
+                                                       $this->linkWrap(
+                                                       '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
                                                        $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
                                                $t,
                                                $this->id);
@@ -299,28 +309,27 @@ class SC_db_new {
                        if (isset($TCA_DESCR[$t]['columns']['']))       {
                                $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$t.'.\',\'viewFieldHelp\',\'height=300,width=250,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
                                $this->code.='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
-                                                       '<img src="gfx/helpbubble.gif" width="14" height="14" hspace="4" border="0" align="absmiddle"'.$this->doc->helpStyle().' alt="" />'.
+                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/helpbubble.gif','width="14" height="14"').' class="c-helpImg" align="right"'.$this->doc->helpStyle().' alt="" />'.
                                                        '</a>';
                        }
                        $this->code.='<br />
                        ';
 
                                // Link to page-wizard:
-                       $this->code.='<img src="gfx/ol/line.gif" width="18" height="16" border="0" align="top" alt="" /><img src="gfx/ol/joinbottom.gif" width="18" height="16" border="0" align="top" alt="" />'.
+                       $this->code.='<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="" />'.
                                '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
-                               '<img src="gfx/new_page.gif" width="13" height="12" border="0" align="top" alt="" /> '.
+                               '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
                                htmlspecialchars($LANG->getLL('clickForWizard')).
                                '</a><br />
                                ';
-                       $this->code.='<img src="gfx/ol/halfline.gif" width="18" height="8" border="0" align="top" alt="" /><br />
+                       $this->code.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />
                        ';
                }
 
                        // New tables (but not pages) INSIDE this pages
                if ($this->newContentInto)      {
                        if (is_array($TCA))     {
-                               reset($TCA);
-                               while(list($t,$v)=each($TCA))   {
+                               foreach($TCA as $t => $v)       {
                                        if ($t!='pages' 
                                                        && $this->showNewRecLink($t)
                                                        && $this->isTableAllowedForThisPage($this->pageinfo, $t) 
@@ -329,9 +338,9 @@ class SC_db_new {
                                                        )       {
 
                                                        // Create new link for record:
-                                               $this->code.=$this->linkWrap(
-                                                       '<img src="'.$BACK_PATH.'t3lib/gfx/ol/join.gif" width="18" height="16" align="top" border="0" alt="" />'.
-                                                               '<img src="'.$BACK_PATH.t3lib_iconWorks::getIcon($t).'" width="18" height="16" align="top" border="0" alt="" /> '.
+                                               $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
+                                                               $this->linkWrap(
+                                                               t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
                                                                $LANG->sL($v['ctrl']['title'],1)
                                                        ,$t
                                                        ,$this->id);
@@ -342,7 +351,7 @@ class SC_db_new {
                                                        if (isset($TCA_DESCR[$t]['columns']['']))       {
                                                                $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$t.'.\',\'viewFieldHelp\',\'height=300,width=250,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
                                                                $this->code.='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
-                                                                       '<img src="gfx/helpbubble.gif" width="14" height="14" hspace="4" border="0" align="absmiddle"'.$this->doc->helpStyle().' alt="" />'.
+                                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/helpbubble.gif','width="14" height="14"').' class="c-helpImg" align="right"'.$this->doc->helpStyle().' alt="" />'.
                                                                        '</a>';
                                                        }
                                                }
@@ -351,15 +360,20 @@ class SC_db_new {
 
                                                        // If the table is 'tt_content' (from "cms" extension), create link to wizard
                                                if ($t=='tt_content')   {
-                                                       $href = 'db_new_content_el.php?id='.$this->id.'&returnUrl='.rawurlencode($this->R_URI);
-                                                       $this->code.='<img src="gfx/ol/line.gif" width="18" height="16" border="0" align="top" alt="" />'.
-                                                                               '<img src="gfx/ol/joinbottom.gif" width="18" height="16" border="0" align="top" alt="" />'.
-                                                                               '<a href="'.htmlspecialchars($href).'"><img src="gfx/new_record.gif" width="16" height="12" border="0" align="top" alt="" /> '.
+
+                                                               // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
+                                                       $overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
+                                                       $pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
+                                                       
+                                                       $href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode($this->R_URI);
+                                                       $this->code.='<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="" />'.
+                                                                               '<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
                                                                                htmlspecialchars($LANG->getLL('clickForWizard')).
                                                                                '</a><br />
                                                                                ';
-                                                       $this->code.='<img src="gfx/ol/halfline.gif" width="18" height="8" border="0" align="top" alt="" /><br />
-                                                       ';
+                                                       $this->code.='<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />
+                                                                               ';
                                                }
                                        }
                                }
@@ -373,41 +387,47 @@ class SC_db_new {
                        $t='pages';
                        $v=$TCA[$t];
                        $this->code.=$this->linkWrap(
-                                       '<img src="'.$BACK_PATH.t3lib_iconWorks::getIcon($t).'" width="18" height="16" align="top" border="0" alt="" /> '.
+                                       t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
                                                $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
-                                       "pages",
-                                       -$this->id);
+                                       'pages',
+                                       -$this->id
+                               );
 
                                // Link to CSH for pages table:
                        if (isset($TCA_DESCR[$t]['columns']['']))       {
                                $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$t.'.\',\'viewFieldHelp\',\'height=300,width=250,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
                                $this->code.='<a href="#" onclick="'.htmlspecialchars($onCLick).'">'.
-                                                       '<img src="gfx/helpbubble.gif" width="14" height="14" hspace="4" border="0" align="absmiddle"'.$this->doc->helpStyle().' alt="" />'.
+                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/helpbubble.gif','width="14" height="14"').' class="c-helpImg" align="right"'.$this->doc->helpStyle().' alt="" />'.
                                                        '</a>';
                        }
                        $this->code.='<br />
                        ';
                } else {
-                       $this->code.='<img src="'.$BACK_PATH.'t3lib/gfx/ol/stopper.gif" width="18" height="16" align="top" alt="" /><br />
+                       $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /><br />
                        ';
                }
                
                        // Create a link to the new-pages wizard.
                if ($this->showNewRecLink('pages'))     {
-                       $this->code.='<br />
-                               <a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>'1'))).'">'.
-                               '<img src="gfx/new_page.gif" width="13" height="12" border="0" align="top" alt="" />'.
-                               '<img src="clear.gif" width="3" height="1" align="top" border="0" alt="" /><strong>'.
-                               htmlspecialchars($LANG->getLL('createNewPage')).
-                               '</strong></a><br />
+                       $this->code.='
+                               
+                               <!--
+                                       Link; create new page:
+                               -->
+                               <div id="typo3-newPageLink">
+                                       <a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>'1'))).'">'.
+                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" />'.
+                                       htmlspecialchars($LANG->getLL('createNewPage')).
+                                       '</a>
+                               </div>
                                ';
                }
        }
 
        /**
         * Ending page output and echo'ing content to browser.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function printContent() {
                $this->content.= $this->doc->endPage();
@@ -416,7 +436,7 @@ class SC_db_new {
 
        /**
         * Links the string $code to a create-new form for a record in $table created on page $pid
-        * 
+        *
         * @param       string          Link string
         * @param       string          Table name (in which to create new record)
         * @param       integer         PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
@@ -427,18 +447,18 @@ class SC_db_new {
                $params = '&edit['.$table.']['.$pid.']=new'.
                        ($table=='pages' 
                                && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'] 
-                               && isset($GLOBALS["TCA"][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']]) 
+                               && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']]) 
                                && $addContentTable     ?
                                '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1'     :
                                ''
                        );
-               $onClick = t3lib_BEfunc::editOnClick($params,'',t3lib_div::GPvar('returnUrl'));
+               $onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
                return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
        }
 
        /**
         * Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
-        * 
+        *
         * @param       array           Record for parent page.
         * @param       string          Table name to check
         * @return      boolean         Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row
@@ -468,7 +488,7 @@ class SC_db_new {
 
        /**
         * Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty)
-        * 
+        *
         * @param       string          Table name to test if in allowedTables
         * @param       array           Array of new tables that are allowed.
         * @return      boolean         Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty)
@@ -493,4 +513,4 @@ $SOBE = t3lib_div::makeInstance('SC_db_new');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
-?>
+?>
\ No newline at end of file