Fixed bug #13137: redirect/returnUrl isn't validated in core (thanks to Georg Ringer...
[Packages/TYPO3.CMS.git] / typo3 / template.php
index a143f03..f191579 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -195,11 +195,18 @@ class template {
        var $backGroundImage = '';              // Background image of page (relative to PATH_typo3)
        var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
 
+       /**
+        * Whether to use the X-UA-Compatible meta tag
+        * @var boolean
+        */
+       protected $useCompatibilityTag = TRUE;
+
                // Skinning
                // stylesheets from core
        protected $stylesheetsCore = array(
                'structure' => 'stylesheets/structure/',
                'visual' => 'stylesheets/visual/',
+               'generatedSprites' => '../typo3temp/sprites/',
        );
 
                // include these CSS directories from skins by default
@@ -305,6 +312,8 @@ class template {
                        );
                        $this->pageRenderer->setLanguage($GLOBALS['LANG']->lang);
                        $this->pageRenderer->enableConcatenateFiles();
+                       $this->pageRenderer->enableCompressCss();
+                       $this->pageRenderer->enableCompressJavascript();
                }
                return $this->pageRenderer;
        }
@@ -363,12 +372,12 @@ class template {
                global $BE_USER;
                $str = '';
                        // If access to Web>List for user, then link to that module.
-               if ($BE_USER->check('modules','web_list'))      {
-                       $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
-                       $str.= '<a href="'.htmlspecialchars($href).'">'.
-                                       '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/list.gif','width="11" height="11"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList',1).'"'.($addParams?' '.trim($addParams):'').' alt="" />'.
-                                       '</a>';
-               }
+               $str .= t3lib_extMgm::createListViewLink(
+                       $id,
+                       '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')),
+                       $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', TRUE)
+               );
+
                        // Make link to view page
                $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
                                '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'"'.($addParams?' '.trim($addParams):"").' hspace="3" alt="" />'.
@@ -440,12 +449,12 @@ class template {
        function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))     {
                global $TCA;
                if (is_array($row) && $row['uid'])      {
-                       $iconImgTag=t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($path).'"');
+                       $iconImgTag=t3lib_iconWorks::getSpriteIconForRecord($table, $row , array('title' => htmlspecialchars($path)));
                        $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
                        $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
                        if ($table=='pages')    $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
                } else {
-                       $iconImgTag='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif',$wHattribs='width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />';
+                       $iconImgTag = t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-domain', array('title' => htmlspecialchars($path)));
                        $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
                }
 
@@ -465,7 +474,7 @@ class template {
         */
        function getFileheader($title,$path,$iconfile)  {
                $fileInfo = t3lib_div::split_fileref($title);
-               $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'],-35)).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
+               $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'],-35)).'<strong>'.htmlspecialchars($fileInfo['file']).'</strong>';
                return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks::skinImg($this->backPath,$iconfile,'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
        }
 
@@ -501,7 +510,8 @@ class template {
                        .'\''.rawurlencode($pathInfo['path']."?".$storeUrl).$mMN.'\''
                .');return false;';
 
-               $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/shortcut.gif','width="14" height="14"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut',1).'" alt="" /></a>';
+               $sIcon = '<a href="#" onclick="' . htmlspecialchars($onClick).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut', TRUE) . '">'
+                       . t3lib_iconworks::getSpriteIcon('actions-system-shortcut-new') . '</a>';
                return $sIcon;
        }
 
@@ -588,7 +598,7 @@ class template {
                ));
 
                $out ="
-       var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::_GP('returnUrl')))."';
+       var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'))))."';
        var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
                ";
                return $out;
@@ -626,6 +636,16 @@ class template {
                }
        }
 
+       /**
+        * Defines whether to use the X-UA-Compatible meta tag.
+        *
+        * @param boolean $useCompatibilityTag Whether to use the tag
+        * @return void
+        */
+       public function useCompatibilityTag($useCompatibilityTag = TRUE) {
+               $this->useCompatibilityTag = (bool) $useCompatibilityTag;
+       }
+
 
 
 
@@ -683,12 +703,14 @@ class template {
                header ('Content-Type:text/html;charset='.$this->charset);
 
                        // Standard HTML tag
-               $this->pageRenderer->setHtmlTag('<html xmlns="http://www.w3.org/1999/xhtml">');
+               $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
 
                switch($this->docType)  {
                        case 'html_3':
                                $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
                                $htmlTag = '<html>';
+                               // disable rendering of XHTML tags
+                               $this->getPageRenderer()->setRenderXhtml(FALSE);
                                break;
                        case 'xhtml_strict':
                                $headerStart = '<!DOCTYPE html
@@ -697,10 +719,16 @@ class template {
                                break;
                        case 'xhtml_frames':
                                $headerStart = '<!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
+       PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
                                break;
-                       // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
+                       case 'html_5':
+                               $headerStart = '<!DOCTYPE html>' . LF;
+                               $htmlTag = '<html>';
+                               // disable rendering of XHTML tags
+                               $this->getPageRenderer()->setRenderXhtml(FALSE);
+                               break;
+                               // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
                        case 'xhtml_trans':
                        default:
                                $headerStart = '<!DOCTYPE html
@@ -708,6 +736,8 @@ class template {
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
                }
 
+               $this->pageRenderer->setHtmlTag($htmlTag);
+
                // This loads the tabulator-in-textarea feature. It automatically modifies
                // every textarea which is found.
                if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) {
@@ -724,7 +754,7 @@ class template {
                $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
 
                        // Add the XML prologue for XHTML doctypes
-               if ($this->docType !== 'html_3') {
+               if ($this->docType !== 'html_3' && $this->docType !== 'html_5') {
                                // Put the XML prologue before or after the doctype declaration according to browser
                        if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
                                $headerStart = $headerStart . LF . $xmlPrologue;
@@ -742,7 +772,9 @@ class template {
                $this->pageRenderer->setHeadTag('<head>' . LF. '<!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->');
                $this->pageRenderer->setCharSet($this->charset);
                $this->pageRenderer->addMetaTag($this->generator());
-               $this->pageRenderer->addMetaTag($this->xUaCompatible());
+               if ($this->useCompatibilityTag) {
+                       $this->pageRenderer->addMetaTag($this->xUaCompatible());
+               }
                $this->pageRenderer->setTitle($title);
 
                // add docstyles
@@ -766,6 +798,19 @@ class template {
                        $this->pageRenderer->addExtOnReadyCode($this->extJScode);
                }
 
+                       // hook for additional headerData
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) {
+                       $preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'];
+                       if (is_array($preHeaderRenderHook)) {
+                               $hookParameters = array(
+                                       'pageRenderer' => &$this->pageRenderer,
+                               );
+                               foreach ($preHeaderRenderHook as $hookFunction) {
+                                       t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
+                               }
+                       }
+               }
+
                        // Construct page header.
                $str = $this->pageRenderer->render(t3lib_PageRenderer::PART_HEADER);
 
@@ -782,8 +827,8 @@ $str.=$this->docBodyTagBegin().
 ($this->divClass?'
 
 <!-- Wrapping DIV-section for whole page BEGIN -->
-<div class="'.$this->divClass.'">
-':'').trim($this->form);
+<div class="' . $this->divClass . '">
+' : '' ) . trim($this->form);
                return $str;
        }
 
@@ -801,10 +846,13 @@ $str.=$this->docBodyTagBegin().
                                $this->parseTime().
                                ($this->form?'
 </form>':'');
-                       // if something is in buffer, put it to end of page
-               $str .= ob_get_clean();
+                       // if something is in buffer like debug, put it to end of page
+               if (ob_get_contents()) {
+                       $str .= ob_get_clean();
+                       header('Content-Encoding: None');
+               }
 
-               if ($this->docType!='xhtml_frames') {
+               if ($this->docType !== 'xhtml_frames') {
 
                        $str .= ($this->divClass?'
 
@@ -1160,12 +1208,11 @@ $str.=$this->docBodyTagBegin().
        /**
         * Returns X-UA-Compatible meta tag
         *
+        * @param       string          $content Content of the compatible tag (default: IE-8)
         * @return      string          <meta http-equiv="X-UA-Compatible" content="???" />
         */
-       function xUaCompatible() {
-                       // the most recent version if Internet Explorer, in which the Backend works
-               $str = "IE=8";
-               return '<meta http-equiv="X-UA-Compatible" content="' . $str . '" />';
+       public function xUaCompatible($content = 'IE=8') {
+               return '<meta http-equiv="X-UA-Compatible" content="' . $content . '" />';
        }
 
 
@@ -1198,22 +1245,22 @@ $str.=$this->docBodyTagBegin().
        function icons($type, $styleAttribValue='')     {
                switch($type)   {
                        case '3':
-                               $icon = 'gfx/icon_fatalerror.gif';
+                               $icon = 'status-dialog-error';
                        break;
                        case '2':
-                               $icon = 'gfx/icon_warning.gif';
+                               $icon = 'status-dialog-warning';
                        break;
                        case '1':
-                               $icon = 'gfx/icon_note.gif';
+                               $icon = 'status-dialog-notification';
                        break;
                        case '-1':
-                               $icon = 'gfx/icon_ok.gif';
+                               $icon = 'status-dialog-ok';
                        break;
                        default:
                        break;
                }
                if ($icon)      {
-                       return '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
+                       return t3lib_iconWorks::getSpriteIcon($icon);
                }
        }
 
@@ -1301,7 +1348,7 @@ $str.=$this->docBodyTagBegin().
                )
        );
        var $table_TR = '<tr>';
-       var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-tmpltable">';
+       var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" id="typo3-tmpltable">';
 
        /**
         * Returns a table based on the input $data
@@ -1556,7 +1603,6 @@ $str.=$this->docBodyTagBegin().
                        $widthAct = $widthNo + $addToAct;
                        $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
 
-                       $first=true;
                        foreach($menuItems as $id => $def) {
                                $isActive = $def['isActive'];
                                $class = $isActive ? 'tabact' : 'tab';
@@ -1567,14 +1613,7 @@ $str.=$this->docBodyTagBegin().
                                $url = htmlspecialchars($def['url']);
                                $params = $def['addParams'];
 
-                               if($first) {
-                                       $options.= '
-                                                       <td width="'.$width.'%" class="'.$class.'" style="border-left: solid #000 1px;"><a href="'.$url.'" style="padding-left:5px;padding-right:2px;" '.$params.'>'.$label.'</a></td>';
-                               } else {
-                                       $options.='
-                                                       <td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
-                               }
-                               $first=false;
+                               $options .= '<td width="' . $width . '%" class="' . $class . '"><a href="' . $url . '" ' . $params . '>' . $label . '</a></td>';
                        }
 
                        if ($options)   {
@@ -1786,29 +1825,42 @@ $str.=$this->docBodyTagBegin().
 
                                        // If more than one was found...:
                                if (count($versions)>1) {
+                                       $selectorLabel = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.label', TRUE) . '</strong>';
 
                                                // Create selector box entries:
                                        $opt = array();
                                        foreach($versions as $vRow)     {
-                                               $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$vRow['uid']))).'"'.($id==$vRow['uid']?' selected="selected"':'').'>'.
-                                                               htmlspecialchars($vRow['t3ver_label'].' [v#'.$vRow['t3ver_id'].', WS:'.$vRow['t3ver_wsid'].']'.($vRow['uid']==$onlineId ? ' =>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online').'<=':'')).
-                                                               '</option>';
+                                               if ($vRow['uid'] == $onlineId) {
+                                                               //Live version
+                                                       $label = '[' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.live', TRUE) . ']';
+                                               } else {
+                                                       $label = $vRow['t3ver_label'] . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionId', TRUE) . ' ' . $vRow['t3ver_id'] .
+                                                               ($vRow['t3ver_wsid'] != 0 ? ' ' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspaceId', TRUE) . ' ' . $vRow['t3ver_wsid'] : '') . ')';
+                                               }
+
+                                               $opt[] = '<option value="' . htmlspecialchars(t3lib_div::linkThisScript(array('id' => $vRow['uid']))) . '"' .
+                                                       ($id == $vRow['uid'] ? ' selected="selected"' : '') . '>' .
+                                                       htmlspecialchars($label) . '</option>';
                                        }
 
                                                // Add management link:
-                                       $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$id))).'">---</option>';
-                                       $opt[] = '<option value="'.htmlspecialchars($this->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?table=pages&uid='.$onlineId).'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.mgm',1).'</option>';
-
+                                       $management = '<input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.mgm', TRUE) . '" onclick="window.location.href=\'' .
+                                                       htmlspecialchars($this->backPath . t3lib_extMgm::extRelPath('version') . 'cm1/index.php?table=pages&uid=' . $onlineId) . '\';" />';
                                                // Create onchange handler:
                                        $onChange = "window.location.href=this.options[this.selectedIndex].value;";
 
                                                // Controls:
-                                       if ($id==$onlineId)     {
-                                               $controls = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="absmiddle" alt="" /> <b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online',1).'</b>';
+                                       if ($id == $onlineId) {
+                                               $controls .= '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/blinkarrow_left.gif','width="5" height="9"') .
+                                                       ' class="absmiddle" alt="" /> <strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online', TRUE) .
+                                                       '</strong>';
                                        } elseif (!$noAction) {
-                                               $controls = '<a href="'.$this->issueCommand('&cmd[pages]['.$onlineId.'][version][swapWith]='.$id.'&cmd[pages]['.$onlineId.'][version][action]=swap',t3lib_div::linkThisScript(array('id'=>$onlineId))).'" class="nobr">'.
-                                                               '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert1.gif','width="14" height="14"').' style="margin-right: 2px;" class="absmiddle" alt="" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swapPage',1).'" />'.
-                                                               '<b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap',1).'</b></a>';
+                                               $controls .= '<a href="' . $this->issueCommand('&cmd[pages][' . $onlineId . '][version][swapWith]=' . $id .
+                                                       '&cmd[pages][' . $onlineId . '][version][action]=swap', t3lib_div::linkThisScript(array('id' => $onlineId))) .
+                                                       '" class="nobr">' . t3lib_iconWorks::getSpriteIcon('actions-version-swap-version', array(
+                                                               'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swapPage', TRUE),
+                                                               'style' => 'margin-left:5px;vertical-align:bottom;'
+                                                       )) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap', TRUE) . '</strong></a>';
                                        }
 
                                                // Write out HTML code:
@@ -1819,32 +1871,33 @@ $str.=$this->docBodyTagBegin().
                                                -->
                                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
                                                        <tr>
-                                                               <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.selVer',1).'</td>
+                                                               <td>' . $selectorLabel . '</td>
                                                                <td>
-                                                                       <select onchange="'.htmlspecialchars($onChange).'">
-                                                                               '.implode('',$opt).'
+                                                                       <select onchange="' . htmlspecialchars($onChange) . '">
+                                                                               ' . implode('', $opt) . '
                                                                        </select></td>
-                                                               <td>'.$controls.'</td>
+                                                               <td>' . $controls . '</td>
+                                                               <td>' . $management . '</td>
                                                        </tr>
                                                </table>
                                        ';
                                }
-                       } elseif ($GLOBALS['BE_USER']->workspace!==0) {
+                       } elseif ($GLOBALS['BE_USER']->workspace !== 0) {
 
                                        // Write out HTML code:
-                               switch($GLOBALS['BE_USER']->workspace)  {
+                               switch($GLOBALS['BE_USER']->workspace) {
                                        case 0:
-                                               $wsTitle = 'LIVE';
+                                               $wsTitle = $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:live', TRUE);
                                        break;
                                        case -1:
-                                               $wsTitle = 'Draft';
+                                               $wsTitle = $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:draft', TRUE);
                                        break;
                                        default:
                                                $wsTitle = $GLOBALS['BE_USER']->workspaceRec['title'];
                                        break;
                                }
 
-                               if (t3lib_BEfunc::isPidInVersionizedBranch($id)=='branchpoint') {
+                               if (t3lib_BEfunc::isPidInVersionizedBranch($id) == 'branchpoint') {
                                        return '
 
                                                <!--
@@ -1852,26 +1905,30 @@ $str.=$this->docBodyTagBegin().
                                                -->
                                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
                                                        <tr>
-                                                               <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
-                                                               <td><em>Inside branch, no further versioning possible</em></td>
+                                                               <td>' . $selectorLabel . '</td>
+                                                               <td>Workspace: "' . htmlspecialchars($wsTitle) . '"</td>
+                                                               <td><em>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.inBranch', TRUE) . '</em></td>
                                                        </tr>
                                                </table>
                                        ';
                                } else {
                                                // Get Current page record:
-                                       $curPage = t3lib_BEfunc::getRecord('pages',$id);
+                                       $curPage = t3lib_BEfunc::getRecord('pages', $id);
                                                // If the selected page is not online, find the right ID
                                        $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
                                                // The version of page:
                                        $verPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, 'pages', $onlineId);
 
-                                       if (!$verPage)  {
+                                       if (!$verPage) {
 
-                                               if (!count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $onlineId)))      {
-                                                       if ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0))      {
+                                               if (!count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $onlineId))) {
+                                                       if ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0)) {
 
-                                                               $onClick = $this->issueCommand('&cmd[pages]['.$onlineId.'][version][action]=new&cmd[pages]['.$onlineId.'][version][treeLevels]=0',t3lib_div::linkThisScript(array('id'=>$onlineId)));
-                                                               $onClick = 'window.location.href=\''.$onClick.'\'; return false;';
+                                                               $onClick = $this->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=new&cmd[pages][' . $onlineId . '][version][treeLevels]=0',
+                                                                       t3lib_div::linkThisScript(array(
+                                                                               'id' => $onlineId
+                                                                       )));
+                                                               $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
                                                                        // Write out HTML code:
                                                                return '
 
@@ -1880,14 +1937,16 @@ $str.=$this->docBodyTagBegin().
                                                                        -->
                                                                        <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
                                                                                <tr>
-                                                                                       <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
+                                                                                       <td>' . $selectorLabel . '</td>
+                                                                                       <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
                                                                                        <td>
-                                                                                               <input type="submit" value="New version of page" name="_" onclick="'.htmlspecialchars($onClick).'" /></td>
+                                                                                               <input type="button" value="New version of page" name="_" onclick="' . htmlspecialchars($onClick) . '" /></td>
                                                                                </tr>
                                                                        </table>
                                                                ';
                                                        }
-                                               } else {
+                                               } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['elementVersioningOnly'] == FALSE && $GLOBALS['TYPO3_CONF_VARS']['BE']['newPagesVersioningType'] == 0) {
+                                                               // only add this info if old/deprecated newPagesVersioning is allowed
                                                        return '
 
                                                                <!--
@@ -1895,15 +1954,20 @@ $str.=$this->docBodyTagBegin().
                                                                -->
                                                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
                                                                        <tr>
-                                                                               <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
-                                                                               <td><em>Versions found on page, no "Page" versioning possible</em></td>
+                                                                               <td>' . $selectorLabel . '</td>
+                                                                               <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
+                                                                               <td><em>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.versionsFound', TRUE) . '</em></td>
                                                                        </tr>
                                                                </table>
                                                        ';
                                                }
                                        } elseif ($verPage['t3ver_swapmode']==0) {
-                                               $onClick = $this->issueCommand('&cmd[pages]['.$onlineId.'][version][action]=swap&cmd[pages]['.$onlineId.'][version][swapWith]='.$verPage['uid'],t3lib_div::linkThisScript(array('id'=>$onlineId)));
-                                               $onClick = 'window.location.href=\''.$onClick.'\'; return false;';
+                                               $onClick = $this->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=swap&cmd[pages][' .
+                                                       $onlineId . '][version][swapWith]=' . $verPage['uid'],
+                                                       t3lib_div::linkThisScript(array(
+                                                               'id' => $onlineId
+                                                       )));
+                                               $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
 
                                                        // Write out HTML code:
                                                return '
@@ -1913,9 +1977,11 @@ $str.=$this->docBodyTagBegin().
                                                        -->
                                                        <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
                                                                <tr>
-                                                                       <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
+                                                                       <td>' . $selectorLabel . '</td>
+                                                                       <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
                                                                        <td>
-                                                                               <input type="submit" value="Publish page" name="_" onclick="'.htmlspecialchars($onClick).'" /></td>
+                                                                               <input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.publish', TRUE) .
+                                                                                       '" onclick="' . htmlspecialchars($onClick) . '" /></td>
                                                                </tr>
                                                        </table>
                                                ';
@@ -2082,10 +2148,16 @@ $str.=$this->docBodyTagBegin().
        protected function getPagePath($pageRecord) {
                        // Is this a real page
                if ($pageRecord['uid']) {
-                       $title = $pageRecord['_thePathFull'];
+                       $title = substr($pageRecord['_thePathFull'], 0, -1);
+                               // remove current page title
+                       $pos = strrpos($title, '/');
+                       if ($pos !== FALSE) {
+                               $title = substr($title, 0, $pos) . '/';
+                       }
                } else {
-                       $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
+                       $title = '';
                }
+
                        // Setting the path of the page
                $pagePath = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <span class="typo3-docheader-pagePath">';
 
@@ -2112,23 +2184,25 @@ $str.=$this->docBodyTagBegin().
                                // Add icon with clickmenu, etc:
                if ($pageRecord['uid']) {       // If there IS a real page
                        $alttext = t3lib_BEfunc::getRecordIconAltText($pageRecord, 'pages');
-                       $iconImg = t3lib_iconWorks::getIconImage('pages', $pageRecord, $this->backPath, 'class="absmiddle" title="'. htmlspecialchars($alttext) . '"');
+                       $iconImg = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord, array('title'=>$alttext));
                                // Make Icon:
                        $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
-                       $pid = $pageRecord['uid'];
+                       $uid = $pageRecord['uid'];
+                       $title = t3lib_BEfunc::getRecordTitle('pages', $pageRecord);
                } else {        // On root-level of page tree
                                // Make Icon
-                       $iconImg = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif') . ' alt="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '" />';
+                       $iconImg = t3lib_iconWorks::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])));
                        if($BE_USER->user['admin']) {
                                $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', 0);
                        } else {
                                $theIcon = $iconImg;
                        }
-                       $pid = '0 (root)';
+                       $uid = '0';
+                       $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
                }
 
                        // Setting icon with clickmenu + uid
-               $pageInfo = $theIcon . '<em>[pid: ' . $pid . ']</em>';
+               $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . '&nbsp;[' . $uid . ']</strong>';
                return $pageInfo;
        }
 
@@ -2236,4 +2310,5 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/templ
 // ******************************
 $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('template');
 
-?>
+
+?>
\ No newline at end of file