Fixed #11430: Performance improvement: use $GLOBALS['EXEC_TIME'] instead of time...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / web_info / class.tx_cms_webinfo_lang.php
index d12d49d..c41cd9a 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
-
-require_once(PATH_t3lib.'class.t3lib_pagetree.php');
-require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
-
-
-
-
 /**
  * Class for displaying translation status of pages in the tree.
  *
@@ -111,7 +104,7 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
                        $theOutput.= $h_func;
 
                                // Add CSH:
-                       $theOutput.= t3lib_BEfunc::cshItem('_MOD_web_info','lang',$GLOBALS['BACK_PATH'],'|<br/>');
+                       $theOutput .= t3lib_BEfunc::cshItem('_MOD_web_info', 'lang', $GLOBALS['BACK_PATH'], '|<br />');
 
                                // Showing the tree:
                                // Initialize starting point of page tree:
@@ -136,23 +129,21 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
                        #debug($tree->tree);
 
                                // Add CSS needed:
-                       $css_content = '
-                               TABLE#langTable {
+                       $this->pObj->doc->inDocStylesArray[] = '
+                               table#langTable {
                                        margin-top: 10px;
                                }
-                               TABLE#langTable TR TD {
+                               table#langTable tr td {
                                        padding-left : 2px;
                                        padding-right : 2px;
                                        white-space: nowrap;
                                }
-                               TD.c-blocked { background-color: red; }
-                               TD.c-ok { background-color: #669966; }
-                               TD.c-fallback {  }
-                               TD.c-leftLine {border-left: 2px solid black; }
+                               td.c-blocked { background-color: #f72116; }
+                               td.c-ok { background-color: #86b571; }
+                               td.c-fallback {  }
+                               td.c-leftLine {border-left: 2px solid black; }
                                .bgColor5 { font-weight: bold; }
                        ';
-                       $marker = '/*###POSTCSSMARKER###*/';
-                       $this->pObj->content = str_replace($marker,$css_content.chr(10).$marker,$this->pObj->content);
 
                                // Render information table:
                        $theOutput.= $this->renderL10nTable($tree);
@@ -219,6 +210,9 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
                        $tCells[] = '<td class="'.$status.' c-leftLine">'.$info.'</td>';
                        $tCells[] = '<td class="'.$status.'" title="'.$LANG->getLL('lang_renderl10n_CEcount','1').'" align="center">'.$this->getContentElementCount($data['row']['uid'],0).'</td>';
 
+                       $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($data['row']['uid'], 'mod.SHARED');
+                       $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? t3lib_div::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], 1) : array();
+
                                // Traverse system languages:
                        foreach($languages as $langRow) {
                                if ($this->pObj->MOD_SETTINGS['lang']==0 || (int)$this->pObj->MOD_SETTINGS['lang']===(int)$langRow['uid'])      {
@@ -259,14 +253,20 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
                                                $tCells[] = '<td class="'.$status.'">'.$info.'</td>';
                                                $tCells[] = '<td class="'.$status.'" title="'.$LANG->getLL('lang_renderl10n_CEcount','1').'" align="center">'.$this->getContentElementCount($data['row']['uid'],$langRow['uid']).'</td>';
                                        } else {
-                                               $status = t3lib_div::hideIfNotTranslated($data['row']['l18n_cfg']) || $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-fallback';
+                                               if (in_array($langRow['uid'], $disableLanguages)) {
+                                                               // Language has been disabled for this page
+                                                       $status = 'c-blocked';
+                                                       $info = '';
+                                               } else {
+                                                       $status = t3lib_div::hideIfNotTranslated($data['row']['l18n_cfg']) || $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-fallback';
+                                                       $info = '<input type="checkbox" name="newOL['.$langRow['uid'].']['.$data['row']['uid'].']" value="1" />';
+                                                       $newOL_js[$langRow['uid']].= '
+                                                               +(document.webinfoForm[\'newOL['.$langRow['uid'].']['.$data['row']['uid'].']\'].checked ? \'&edit[pages_language_overlay]['.$data['row']['uid'].']=new\' : \'\')
+                                                       ';
+                                               }
+
                                                $tCells[] = '<td class="'.$status.' c-leftLine">&nbsp;</td>';
                                                $tCells[] = '<td class="'.$status.'">&nbsp;</td>';
-
-                                               $info = '<input type="checkbox" name="newOL['.$langRow['uid'].']['.$data['row']['uid'].']" value="1" />';
-                                               $newOL_js[$langRow['uid']].= '
-                                                       +(document.webinfoForm[\'newOL['.$langRow['uid'].']['.$data['row']['uid'].']\'].checked ? \'&edit[pages_language_overlay]['.$data['row']['uid'].']=new\' : \'\')
-                                               ';
                                                $tCells[] = '<td class="'.$status.'">'.$info.'</td>';
                                        }
                                }
@@ -337,6 +337,12 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
         * @return      array           System language records in an array.
         */
        function getSystemLanguages()   {
+               if (!$GLOBALS['BE_USER']->user['admin'] &&
+                       strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) {
+
+                       $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages']));
+               }
+
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                        '*',
                        'sys_language',
@@ -345,7 +351,14 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
 
                $outputArray = array();
                while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
-                       $outputArray[] = $row;
+                       if (is_array($allowed_languages) && count($allowed_languages)) {
+                               if (isset($allowed_languages[$row['uid']])) {
+                                       $outputArray[] = $row;
+                               }
+                       }
+                       else {
+                               $outputArray[] = $row;
+                       }
                }
 
                return $outputArray;
@@ -373,8 +386,8 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
                if (is_array($row))     {
                        $row['_COUNT'] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
                        $row['_HIDDEN'] = $row['hidden'] ||
-                                                       (intval($row['endtime']) > 0 && intval($row['endtime']) < time()) ||
-                                                       (time() < intval($row['starttime']));
+                                                       (intval($row['endtime']) > 0 && intval($row['endtime']) < $GLOBALS['EXEC_TIME']) ||
+                                                       ($GLOBALS['EXEC_TIME'] < intval($row['starttime']));
                }
 
                return $row;
@@ -388,16 +401,14 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
         * @return      integer         Number of content elements from the PID where the language is set to a certain value.
         */
        function getContentElementCount($pageId,$sysLang)       {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       'count(*)',
+               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       'uid',
                        'tt_content',
-                       'pid='.intval($pageId).
-                               ' AND sys_language_uid='.intval($sysLang).
-                               t3lib_BEfunc::deleteClause('tt_content').
+                       'pid=' . intval($pageId) .
+                               ' AND sys_language_uid=' . intval($sysLang) .
+                               t3lib_BEfunc::deleteClause('tt_content') .
                                t3lib_BEfunc::versioningPlaceholderClause('tt_content')
                );
-
-               list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
                return $count ? $count : '-';
        }
 }
@@ -406,4 +417,5 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo_lang.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo_lang.php']);
 }
+
 ?>
\ No newline at end of file