Documentation TYPO3 par Ameos

class.tx_cms_webinfo_lang.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00053 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
00054 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
00055 
00056 
00057 
00058 
00066 class tx_cms_webinfo_lang extends t3lib_extobjbase {
00067 
00073         function modMenu()      {
00074                 global $LANG;
00075 
00076                 $menuArray = array (
00077                         'depth' => array(
00078                                 0 => $LANG->getLL('depth_0'),
00079                                 1 => $LANG->getLL('depth_1'),
00080                                 2 => $LANG->getLL('depth_2'),
00081                                 3 => $LANG->getLL('depth_3')
00082                         ),
00083                 );
00084 
00085                         // Languages:
00086                 $lang = $this->getSystemLanguages();
00087                 $menuArray['lang']=array(
00088                         0 => '[All]'
00089                 );
00090                 foreach($lang as $langRec)      {
00091                         $menuArray['lang'][$langRec['uid']] = $langRec['title'];
00092                 }
00093 
00094                 return $menuArray;
00095         }
00096 
00102         function main() {
00103                 global $BACK_PATH,$LANG,$SOBE;
00104 
00105                 if ($this->pObj->id)    {
00106                         $theOutput = '';
00107 
00108                                 // Depth selector:
00109                         $h_func = t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[depth]',$this->pObj->MOD_SETTINGS['depth'],$this->pObj->MOD_MENU['depth'],'index.php');
00110                         $h_func.= t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[lang]',$this->pObj->MOD_SETTINGS['lang'],$this->pObj->MOD_MENU['lang'],'index.php');
00111                         $theOutput.= $h_func;
00112 
00113                                 // Add CSH:
00114                         $theOutput.= t3lib_BEfunc::cshItem('_MOD_web_info','lang',$GLOBALS['BACK_PATH'],'|<br/>');
00115 
00116                                 // Showing the tree:
00117                                 // Initialize starting point of page tree:
00118                         $treeStartingPoint = intval($this->pObj->id);
00119                         $treeStartingRecord = t3lib_BEfunc::getRecordWSOL('pages', $treeStartingPoint);
00120                         $depth = $this->pObj->MOD_SETTINGS['depth'];
00121 
00122                                 // Initialize tree object:
00123                         $tree = t3lib_div::makeInstance('t3lib_pageTree');
00124                         $tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));
00125                         $tree->addField('l18n_cfg');
00126 
00127                                 // Creating top icon; the current page
00128                         $HTML = t3lib_iconWorks::getIconImage('pages', $treeStartingRecord, $GLOBALS['BACK_PATH'],'align="top"');
00129                         $tree->tree[] = array(
00130                                 'row' => $treeStartingRecord,
00131                                 'HTML'=>$HTML
00132                         );
00133 
00134                                 // Create the tree from starting point:
00135                         if ($depth)     $tree->getTree($treeStartingPoint, $depth, '');
00136                         #debug($tree->tree);
00137 
00138                                 // Add CSS needed:
00139                         $css_content = '
00140                                 TABLE#langTable {
00141                                         margin-top: 10px;
00142                                 }
00143                                 TABLE#langTable TR TD {
00144                                         padding-left : 2px;
00145                                         padding-right : 2px;
00146                                         white-space: nowrap;
00147                                 }
00148                                 TD.c-blocked { background-color: red; }
00149                                 TD.c-ok { background-color: #669966; }
00150                                 TD.c-fallback {  }
00151                                 TD.c-leftLine {border-left: 2px solid black; }
00152                                 .bgColor5 { font-weight: bold; }
00153                         ';
00154                         $marker = '/*###POSTCSSMARKER###*/';
00155                         $this->pObj->content = str_replace($marker,$css_content.chr(10).$marker,$this->pObj->content);
00156 
00157                                 // Render information table:
00158                         $theOutput.= $this->renderL10nTable($tree);
00159                 }
00160 
00161                 return $theOutput;
00162         }
00163 
00170         function renderL10nTable(&$tree)        {
00171                 global $LANG;
00172 
00173                         // System languages retrieved:
00174                 $languages = $this->getSystemLanguages();
00175 
00176                         // Title length:
00177                 $titleLen = $GLOBALS['BE_USER']->uc['titleLen'];
00178 
00179                         // Put together the TREE:
00180                 $output = '';
00181                 $newOL_js = array();
00182                 $langRecUids = array();
00183                 foreach($tree->tree as $data)   {
00184                         $tCells = array();
00185                         $langRecUids[0][] = $data['row']['uid'];
00186 
00187                                 // Page icons / titles etc.
00188                         $tCells[] = '<td'.($data['row']['_CSSCLASS'] ? ' class="'.$data['row']['_CSSCLASS'].'"' : '').'>'.
00189                                                         $data['HTML'].
00190                                                         htmlspecialchars(t3lib_div::fixed_lgd_cs($data['row']['title'],$titleLen)).
00191                                                         (strcmp($data['row']['nav_title'],'') ? ' [Nav: <em>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($data['row']['nav_title'],$titleLen)).'</em>]' : '').
00192                                                         '</td>';
00193 
00194                                 // DEFAULT language:
00195                                 // "View page" link is created:
00196                         $viewPageLink= '<a href="#" onclick="'.
00197                                         htmlspecialchars(t3lib_BEfunc::viewOnClick($data['row']['uid'],$GLOBALS['BACK_PATH'],'','','','&L=###LANG_UID###')).'">'.
00198                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->getLL('lang_renderl10n_viewPage','1').'" border="0" alt="" />'.
00199                                         '</a>';
00200                         $status = $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-ok';
00201 
00202                                 // Create links:
00203                         $info = '';
00204                         $editUid = $data['row']['uid'];
00205                         $params = '&edit[pages]['.$editUid.']=edit';
00206                         $info.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">'.
00207                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editDefaultLanguagePage','1').'" border="0" alt="" />'.
00208                                         '</a>';
00209                         $info.= '<a href="#" onclick="'.htmlspecialchars('top.loadEditId('.intval($data['row']['uid']).',"&SET[language]=0"); return false;').'">'.
00210                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit_page.gif','width="12" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editPage','1').'" border="0" alt="" />'.
00211                                         '</a>';
00212                         $info.= str_replace('###LANG_UID###','0',$viewPageLink);
00213 
00214                         $info.= '&nbsp;';
00215                         $info.= $data['row']['l18n_cfg']&1 ? '<span title="'.$LANG->sL('LLL:EXT:cms/locallang_tca.php:pages.l18n_cfg.I.1','1').'">D</span>' : '&nbsp;';
00216                         $info.= t3lib_div::hideIfNotTranslated($data['row']['l18n_cfg']) ? '<span title="'.$LANG->sL('LLL:EXT:cms/locallang_tca.php:pages.l18n_cfg.I.2','1').'">N</span>' : '&nbsp;';
00217 
00218                                 // Put into cell:
00219                         $tCells[] = '<td class="'.$status.' c-leftLine">'.$info.'</td>';
00220                         $tCells[] = '<td class="'.$status.'" title="'.$LANG->getLL('lang_renderl10n_CEcount','1').'" align="center">'.$this->getContentElementCount($data['row']['uid'],0).'</td>';
00221 
00222                                 // Traverse system languages:
00223                         foreach($languages as $langRow) {
00224                                 if ($this->pObj->MOD_SETTINGS['lang']==0 || (int)$this->pObj->MOD_SETTINGS['lang']===(int)$langRow['uid'])      {
00225                                         $row = $this->getLangStatus($data['row']['uid'], $langRow['uid']);
00226                                         $info = '';
00227 
00228                                         if (is_array($row))     {
00229                                                 $langRecUids[$langRow['uid']][] = $row['uid'];
00230                                                 $status = $row['_HIDDEN'] ? (t3lib_div::hideIfNotTranslated($data['row']['l18n_cfg']) || $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-fallback') : 'c-ok';
00231                                                 $icon = t3lib_iconWorks::getIconImage(
00232                                                         'pages_language_overlay',
00233                                                         $row,
00234                                                         $GLOBALS['BACK_PATH'],
00235                                                         'align="top" class="c-recIcon"'
00236                                                 );
00237 
00238                                                 $info = $icon.
00239                                                                         htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$titleLen)).
00240                                                                         (strcmp($row['nav_title'],'') ? ' [Nav: <em>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['nav_title'],$titleLen)).'</em>]' : '').
00241                                                                         ($row['_COUNT']>1 ? '<div>'.$LANG->getLL('lang_renderl10n_badThingThereAre','1').'</div>':'');
00242                                                 $tCells[] = '<td class="'.$status.' c-leftLine">'.
00243                                                                                 $info.
00244                                                                                 '</td>';
00245 
00246                                                         // Edit whole record:
00247                                                 $info = '';
00248                                                 $editUid = $row['uid'];
00249                                                 $params = '&edit[pages_language_overlay]['.$editUid.']=edit';
00250                                                 $info.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">'.
00251                                                                 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editLanguageOverlayRecord','1').'" border="0" alt="" />'.
00252                                                                 '</a>';
00253 
00254                                                 $info.= '<a href="#" onclick="'.htmlspecialchars('top.loadEditId('.intval($data['row']['uid']).',"&SET[language]='.$langRow['uid'].'"); return false;').'">'.
00255                                                                 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit_page.gif','width="12" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editPageLang','1').'" border="0" alt="" />'.
00256                                                                 '</a>';
00257                                                 $info.= str_replace('###LANG_UID###',$langRow['uid'],$viewPageLink);
00258 
00259                                                 $tCells[] = '<td class="'.$status.'">'.$info.'</td>';
00260                                                 $tCells[] = '<td class="'.$status.'" title="'.$LANG->getLL('lang_renderl10n_CEcount','1').'" align="center">'.$this->getContentElementCount($data['row']['uid'],$langRow['uid']).'</td>';
00261                                         } else {
00262                                                 $status = t3lib_div::hideIfNotTranslated($data['row']['l18n_cfg']) || $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-fallback';
00263                                                 $tCells[] = '<td class="'.$status.' c-leftLine">&nbsp;</td>';
00264                                                 $tCells[] = '<td class="'.$status.'">&nbsp;</td>';
00265 
00266                                                 $info = '<input type="checkbox" name="newOL['.$langRow['uid'].']['.$data['row']['uid'].']" value="1" />';
00267                                                 $newOL_js[$langRow['uid']].= '
00268                                                         +(document.webinfoForm[\'newOL['.$langRow['uid'].']['.$data['row']['uid'].']\'].checked ? \'&edit[pages_language_overlay]['.$data['row']['uid'].']=new\' : \'\')
00269                                                 ';
00270                                                 $tCells[] = '<td class="'.$status.'">'.$info.'</td>';
00271                                         }
00272                                 }
00273                         }
00274 
00275                         $output.= '
00276                                 <tr class="bgColor4">
00277                                         '.implode('
00278                                         ',$tCells).'
00279                                 </tr>';
00280                 }
00281 
00282                         // Put together HEADER:
00283                 $tCells = array();
00284                 $tCells[] = '<td>'.$LANG->getLL('lang_renderl10n_page','1').':</td>';
00285 
00286                 if (is_array($langRecUids[0]))  {
00287                         $params = '&edit[pages]['.implode(',',$langRecUids[0]).']=edit&columnsOnly=title,nav_title,l18n_cfg,hidden';
00288                         $editIco = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">
00289                                 <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editPageProperties','1').'" border="0" alt="" />
00290                                 </a>';
00291                 } else $editIco = '';
00292                 $tCells[] = '<td class="c-leftLine" colspan="2">'.
00293                                         $LANG->getLL('lang_renderl10n_default','1').':'.
00294                                         $editIco.
00295                                         '</td>';
00296 
00297                 foreach($languages as $langRow) {
00298                         if ($this->pObj->MOD_SETTINGS['lang']==0 || (int)$this->pObj->MOD_SETTINGS['lang']===(int)$langRow['uid'])      {
00299                                         // Title:
00300                                 $tCells[] = '<td class="c-leftLine">'.htmlspecialchars($langRow['title']).'</td>';
00301 
00302                                         // Edit language overlay records:
00303                                 if (is_array($langRecUids[$langRow['uid']]))    {
00304                                         $params = '&edit[pages_language_overlay]['.implode(',',$langRecUids[$langRow['uid']]).']=edit&columnsOnly=title,nav_title,hidden';
00305                                         $tCells[] = '<td><a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">
00306                                                 <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editLangOverlays','1').'" border="0" alt="" />
00307                                                 </a></td>';
00308                                 } else {
00309                                         $tCells[] = '<td>&nbsp;</td>';
00310                                 }
00311 
00312                                         // Create new overlay records:
00313                                 $params = "'".$newOL_js[$langRow['uid']]."+'&columnsOnly=title,hidden,sys_language_uid&defVals[pages_language_overlay][sys_language_uid]=".$langRow['uid'];
00314                                 $tCells[] = '<td><a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">
00315                                         <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/new_el.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_getlangsta_createNewTranslationHeaders','1').'" border="0" alt="" />
00316                                         </a></td>';
00317                         }
00318                 }
00319 
00320                 $output = '
00321                         <tr class="bgColor5">
00322                                 '.implode('
00323                                 ',$tCells).'
00324                         </tr>'.$output;
00325 
00326                 $output = '
00327 
00328                 <table border="0" cellspacing="0" cellpadding="0" id="langTable">'.$output.'
00329                 </table>';
00330 
00331                 return $output;
00332         }
00333 
00339         function getSystemLanguages()   {
00340                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00341                         '*',
00342                         'sys_language',
00343                         '1=1'.t3lib_BEfunc::deleteClause('sys_language')
00344                 );
00345 
00346                 $outputArray = array();
00347                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00348                         $outputArray[] = $row;
00349                 }
00350 
00351                 return $outputArray;
00352         }
00353 
00361         function getLangStatus($pageId, $langId)        {
00362                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00363                         '*',
00364                         'pages_language_overlay',
00365                         'pid='.intval($pageId).
00366                                 ' AND sys_language_uid='.intval($langId).
00367                                 t3lib_BEfunc::deleteClause('pages_language_overlay').
00368                                 t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay')
00369                 );
00370 
00371                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00372                 if (is_array($row))     {
00373                         t3lib_BEfunc::workspaceOL('pages_language_overlay',$row);
00374                         $row['_COUNT'] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00375                         $row['_HIDDEN'] = $row['hidden'] ||
00376                                                         (intval($row['endtime']) > 0 && intval($row['endtime']) < time()) ||
00377                                                         (time() < intval($row['starttime']));
00378                 }
00379 
00380                 return $row;
00381         }
00382 
00390         function getContentElementCount($pageId,$sysLang)       {
00391                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00392                         'count(*)',
00393                         'tt_content',
00394                         'pid='.intval($pageId).
00395                                 ' AND sys_language_uid='.intval($sysLang).
00396                                 t3lib_BEfunc::deleteClause('tt_content').
00397                                 t3lib_BEfunc::versioningPlaceholderClause('tt_content')
00398                 );
00399 
00400                 list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00401                 return $count ? $count : '-';
00402         }
00403 }
00404 
00405 
00406 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo_lang.php'])  {
00407         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo_lang.php']);
00408 }
00409 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6