[TASK] Use external Core Project DBAL as Git submodule
[Packages/TYPO3.CMS.git] / typo3 / show_item.php
old mode 100755 (executable)
new mode 100644 (file)
index 81c389d..4268987
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 /**
  * Shows information about a database or file item
  *
- * $Id$
- * Revised for TYPO3 3.7 May/2004 by Kasper Skaarhoj
+ * Revised for TYPO3 3.7 May/2004 by Kasper Skårhøj
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
@@ -59,9 +58,6 @@
 $BACK_PATH = '';
 require($BACK_PATH.'init.php');
 require($BACK_PATH.'template.php');
-require_once(PATH_t3lib.'class.t3lib_page.php');
-require_once(PATH_t3lib.'class.t3lib_loaddbgroup.php');
-require_once(PATH_t3lib.'class.t3lib_transferdata.php');
 
 
 
@@ -77,7 +73,7 @@ require_once(PATH_t3lib.'class.t3lib_transferdata.php');
 /**
  * Extension of transfer data class
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -103,8 +99,13 @@ class transferData extends t3lib_transferData       {
                $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
                switch($config['type']) {
                        case 'input':
-                               if (isset($config['checkbox']) && $content==$config['checkbox'])        {$content=''; break;}
-                               if (t3lib_div::inList($config['eval'],'date'))  {$content = Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$content); }
+                               if (isset($config['checkbox']) && $content == $config['checkbox']) {
+                                       $content = '';
+                                       break;
+                               }
+                               if (t3lib_div::inList($config['eval'],'date')) {
+                                       $content = Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $content);
+                               }
                        break;
                        case 'group':
                        break;
@@ -128,7 +129,7 @@ class transferData extends t3lib_transferData       {
 /**
  * Script Class for showing information about an item.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -140,7 +141,7 @@ class SC_show_item {
 
                // Internal, static:
        var $perms_clause;      // Page select clause
-       var $access;            // If true, access to element is granted
+       var $access;            // If TRUE, access to element is granted
        var $type;                      // Which type of element: "file" or "db"
        var $doc;                       // Document Template Object
 
@@ -158,31 +159,31 @@ class SC_show_item {
         * @return      void
         */
        function init() {
-               global $BE_USER,$LANG,$BACK_PATH,$TCA;
+               global $BACK_PATH;
 
                        // Setting input variables.
                $this->table = t3lib_div::_GET('table');
                $this->uid = t3lib_div::_GET('uid');
 
                        // Initialize:
-               $this->perms_clause = $BE_USER->getPagePermsClause(1);
-               $this->access = 0;      // Set to true if there is access to the record / file.
+               $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
+               $this->access = 0;      // Set to TRUE if there is access to the record / file.
                $this->type = '';       // Sets the type, "db" or "file". If blank, nothing can be shown.
 
                        // Checking if the $table value is really a table and if the user has access to it.
-               if (isset($TCA[$this->table]))  {
+               if (isset($GLOBALS['TCA'][$this->table])) {
                        t3lib_div::loadTCA($this->table);
                        $this->type = 'db';
                        $this->uid = intval($this->uid);
 
                                // Check permissions and uid value:
-                       if ($this->uid && $BE_USER->check('tables_select',$this->table))        {
+                       if ($this->uid && $GLOBALS['BE_USER']->check('tables_select',$this->table)) {
                                if ((string)$this->table=='pages')      {
                                        $this->pageinfo = t3lib_BEfunc::readPageAccess($this->uid,$this->perms_clause);
                                        $this->access = is_array($this->pageinfo) ? 1 : 0;
                                        $this->row = $this->pageinfo;
                                } else {
-                                       $this->row = t3lib_BEfunc::getRecord($this->table,$this->uid);
+                                       $this->row = t3lib_BEfunc::getRecordWSOL($this->table, $this->uid);
                                        if ($this->row) {
                                                $this->pageinfo = t3lib_BEfunc::readPageAccess($this->row['pid'],$this->perms_clause);
                                                $this->access = is_array($this->pageinfo) ? 1 : 0;
@@ -196,7 +197,7 @@ class SC_show_item {
                } else  {
                        // if the filereference $this->file is relative, we correct the path
                        if (substr($this->table,0,3)=='../')    {
-                               $this->file = PATH_site.ereg_replace('^\.\./','',$this->table);
+                               $this->file = PATH_site.preg_replace('/^\.\.\//','',$this->table);
                        } else {
                                $this->file = $this->table;
                        }
@@ -207,13 +208,12 @@ class SC_show_item {
                }
 
                        // Initialize document template object:
-               $this->doc = t3lib_div::makeInstance('smallDoc');
+               $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $BACK_PATH;
-               $this->doc->docType = 'xhtml_trans';
 
                        // Starting the page by creating page header stuff:
-               $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.viewItem'));
-               $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.viewItem'));
+               $this->content.=$this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem'));
+               $this->content.='<h3 class="t3-row-header">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem') . '</h3>';
                $this->content.=$this->doc->spacer(5);
        }
 
@@ -223,20 +223,20 @@ class SC_show_item {
         * @return      void
         */
        function main() {
-               global $LANG;
 
                if ($this->access)      {
-                       $returnLinkTag = t3lib_div::_GP('returnUrl') ? '<a href="'.t3lib_div::_GP('returnUrl').'" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
+                       $returnLink =  t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
+                       $returnLinkTag = $returnLink ? '<a href="' . $returnLink . '" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
 
                                // render type by user func
-                       $typeRendered = false;
+                       $typeRendered = FALSE;
                        if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
                                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
                                        $typeRenderObj = t3lib_div::getUserObj($classRef);
                                        if(is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render'))    {
                                                if ($typeRenderObj->isValid($this->type, $this)) {
                                                        $this->content .=  $typeRenderObj->render($this->type, $this);
-                                                       $typeRendered = true;
+                                                       $typeRendered = TRUE;
                                                        break;
                                                }
                                        }
@@ -257,10 +257,10 @@ class SC_show_item {
                        }
 
                                // If return Url is set, output link to go back:
-                       if (t3lib_div::_GP('returnUrl'))        {
-                               $this->content = $this->doc->section('',$returnLinkTag.'<strong>'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a><br /><br />').$this->content;
+                       if (t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl')))   {
+                               $this->content = $this->doc->section('',$returnLinkTag.'<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a><br /><br />').$this->content;
 
-                               $this->content .= $this->doc->section('','<br />'.$returnLinkTag.'<strong>'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a>');
+                               $this->content .= $this->doc->section('','<br />'.$returnLinkTag.'<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack',1).'</strong></a>');
                        }
                }
        }
@@ -271,7 +271,6 @@ class SC_show_item {
         * @return      void
         */
        function renderDBInfo() {
-               global $LANG,$TCA;
 
                        // Print header, path etc:
                $code = $this->doc->getHeader($this->table,$this->row,$this->pageinfo['_thePath'],1).'<br />';
@@ -282,16 +281,16 @@ class SC_show_item {
                $i = 0;
 
                        // Traverse the list of fields to display for the record:
-               $fieldList = t3lib_div::trimExplode(',',$TCA[$this->table]['interface']['showRecordFieldList'],1);
-               foreach($fieldList as $name)    {
+               $fieldList = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], 1);
+               foreach ($fieldList as $name) {
                        $name = trim($name);
-                       if ($TCA[$this->table]['columns'][$name])       {
-                               if (!$TCA[$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$this->table.':'.$name))        {
+                       if ($GLOBALS['TCA'][$this->table]['columns'][$name]) {
+                               if (!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name)) {
                                        $i++;
                                        $tableRows[] = '
                                                <tr>
-                                                       <td class="bgColor5">'.$LANG->sL(t3lib_BEfunc::getItemLabel($this->table,$name),1).'</td>
-                                                       <td class="bgColor4">'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($this->table,$name,$this->row[$name])).'</td>
+                                                       <td class="t3-col-header">' . $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($this->table, $name), 1) . '</td>
+                                                       <td>' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $this->row['uid'])) . '</td>
                                                </tr>';
                                }
                        }
@@ -299,23 +298,22 @@ class SC_show_item {
 
                        // Create table from the information:
                $tableCode = '
-                                       <table border="0" cellpadding="1" cellspacing="1" id="typo3-showitem">
+                                       <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
                                                '.implode('',$tableRows).'
                                        </table>';
                $this->content.=$this->doc->section('',$tableCode);
-               $this->content.=$this->doc->divider(2);
 
                        // Add path and table information in the bottom:
                $code = '';
-               $code.= $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path').': '.t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-48).'<br />';
-               $code.= $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.table').': '.$LANG->sL($TCA[$this->table]['ctrl']['title']).' ('.$this->table.') - UID: '.$this->uid.'<br />';
+               $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path') . ': ' . t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'], -48) . '<br />';
+               $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table') . ': ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']) . ' (' . $this->table . ') - UID: ' . $this->uid . '<br />';
                $this->content.= $this->doc->section('', $code);
 
                        // References:
-               $this->content.= $this->doc->section('References to this item:',$this->makeRef($this->table,$this->row['uid']));
+               $this->content.= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'),$this->makeRef($this->table,$this->row['uid']));
 
                        // References:
-               $this->content.= $this->doc->section('References from this item:',$this->makeRefFrom($this->table,$this->row['uid']));
+               $this->content.= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesFromThisItem'),$this->makeRefFrom($this->table,$this->row['uid']));
        }
 
        /**
@@ -325,16 +323,14 @@ class SC_show_item {
         * @return      void
         */
        function renderFileInfo($returnLinkTag) {
-               global $LANG;
 
                        // Initialize object to work on the image:
-               require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
                $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
                $imgObj->init();
                $imgObj->mayScaleUp = 0;
                $imgObj->absPrefix = PATH_site;
 
-                       // Read Image Dimensions (returns false if file was not an image type, otherwise dimensions in an array)
+                       // Read Image Dimensions (returns FALSE if file was not an image type, otherwise dimensions in an array)
                $imgInfo = '';
                $imgInfo = $imgObj->getImageDimensions($this->file);
 
@@ -345,18 +341,16 @@ class SC_show_item {
                $code = '';
 
                        // Setting header:
-               $icon = t3lib_BEfunc::getFileIcon($ext);
-               $url = 'gfx/fileicons/'.$icon;
-               $fileName = '<img src="'.$url.'" width="18" height="16" align="top" alt="" /><b>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.file',1).':</b> '.$fI['file'];
+               $fileName = t3lib_iconWorks::getSpriteIconForFile($ext) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) . ':</strong> ' . $fI['file'];
                if (t3lib_div::isFirstPartOfStr($this->file,PATH_site)) {
                        $code.= '<a href="../'.substr($this->file,strlen(PATH_site)).'" target="_blank">'.$fileName.'</a>';
                } else {
                        $code.= $fileName;
                }
-               $code.=' &nbsp;&nbsp;<b>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.filesize').':</b> '.t3lib_div::formatSize(@filesize($this->file)).'<br />
+               $code.=' &nbsp;&nbsp;<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize').':</strong> '.t3lib_div::formatSize(@filesize($this->file)).'<br />
                        ';
                if (is_array($imgInfo)) {
-                       $code.= '<b>'.$LANG->sL('LLL:EXT:lang/locallang_core.php:show_item.php.dimensions').':</b> '.$imgInfo[0].'x'.$imgInfo[1].' pixels';
+                       $code.= '<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions').':</strong> '.$imgInfo[0].'x'.$imgInfo[1].' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels');
                }
                $this->content.=$this->doc->section('',$code);
                $this->content.=$this->doc->divider(2);
@@ -378,7 +372,7 @@ class SC_show_item {
                                if ($ext=='zip')        {
                                        $code = '';
                                        $t = array();
-                                       exec('unzip -l '.$this->file, $t);
+                                       t3lib_utility_Command::exec('unzip -l ' . $this->file, $t);
                                        if (is_array($t))       {
                                                reset($t);
                                                next($t);
@@ -403,7 +397,7 @@ class SC_show_item {
                                                $compr = 'z';
                                        }
                                        $t = array();
-                                       exec('tar t'.$compr.'f '.$this->file, $t);
+                                       t3lib_utility_Command::exec('tar t' . $compr . 'f ' . $this->file, $t);
                                        if (is_array($t))       {
                                                foreach($t as $val)     {
                                                        $code.='
@@ -412,7 +406,7 @@ class SC_show_item {
 
                                                $code.='
                                                                 -------<br/>
-                                                                '.count($t).' files';
+                                                                '.count($t).' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.files');
 
                                                $code = '
                                                        <span class="nobr">'.$code.'
@@ -422,7 +416,7 @@ class SC_show_item {
                                        $this->content.= $this->doc->section('',$code);
                                }
                        } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
-                               $this->content.= $this->doc->section('','Sorry, TYPO3_CONF_VARS[BE][disable_exec_function] was set, so cannot display content of archive file.');
+                               $this->content.= $this->doc->section('',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.cannotDisplayArchive'));
                        }
 
                                // Font files:
@@ -440,7 +434,7 @@ class SC_show_item {
 
 
                        // References:
-               $this->content.= $this->doc->section('References to this item:',$this->makeRef('_FILE',$this->file));
+               $this->content.= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'),$this->makeRef('_FILE',$this->file));
        }
 
        /**
@@ -493,13 +487,13 @@ class SC_show_item {
                        // Compile information for title tag:
                $infoData = array();
                if (count($rows))       {
-                       $infoData[] = '<tr class="bgColor5 tableheader">' .
-                                       '<td>Table:</td>' .
-                                       '<td>Uid:</td>' .
-                                       '<td>Field:</td>'.
-                                       '<td>Flexpointer:</td>'.
-                                       '<td>Softref Key:</td>'.
-                                       '<td>Sorting:</td>'.
+                       $infoData[] = '<tr class="t3-row-header">' .
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.table').'</td>' .
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.uid').'</td>' .
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting').'</td>'.
                                        '</tr>';
                }
                foreach($rows as $row)  {
@@ -513,7 +507,7 @@ class SC_show_item {
                                        '</tr>';
                }
 
-               return count($infoData) ? '<table border="0" cellpadding="1" cellspacing="1">'.implode('',$infoData).'</table>' : '';
+               return count($infoData) ? '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>' : '';
        }
 
        /**
@@ -536,14 +530,14 @@ class SC_show_item {
                        // Compile information for title tag:
                $infoData = array();
                if (count($rows))       {
-                       $infoData[] = '<tr class="bgColor5 tableheader">' .
-                                       '<td>Field:</td>'.
-                                       '<td>Flexpointer:</td>'.
-                                       '<td>Softref Key:</td>'.
-                                       '<td>Sorting:</td>'.
-                                       '<td>Ref Table:</td>' .
-                                       '<td>Ref Uid:</td>' .
-                                       '<td>Ref String:</td>' .
+                       $infoData[] = '<tr class="t3-row-header">' .
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting').'</td>'.
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refTable').'</td>' .
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refUid').'</td>' .
+                                       '<td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refString').'</td>' .
                                        '</tr>';
                }
                foreach($rows as $row)  {
@@ -558,23 +552,14 @@ class SC_show_item {
                                        '</tr>';
                }
 
-               return count($infoData) ? '<table border="0" cellpadding="1" cellspacing="1">'.implode('',$infoData).'</table>' : '';
+               return count($infoData) ? '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>' : '';
        }
 }
 
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/show_item.php'])    {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/show_item.php']);
-}
-
-
-
-
-
-
-
-
 
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/show_item.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/show_item.php']);
+}
 
 
 
@@ -583,4 +568,5 @@ $SOBE = t3lib_div::makeInstance('SC_show_item');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file