Documentation TYPO3 par Ameos

class.tx_cms_webinfo_lang.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00052 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
00053 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
00054 
00055 
00056 
00057 
00065 class tx_cms_webinfo_lang extends t3lib_extobjbase {
00066 
00072         function modMenu()      {
00073                 global $LANG;
00074 
00075                 return array (
00076                         'depth' => array(
00077                                 1 => $LANG->getLL('depth_1'),
00078                                 2 => $LANG->getLL('depth_2'),
00079                                 3 => $LANG->getLL('depth_3')
00080                         )
00081                 );
00082         }
00083 
00089         function main() {
00090                 global $BACK_PATH,$LANG,$SOBE;
00091 
00092                 if ($this->pObj->id)    {
00093                         $theOutput = '';
00094 
00095                                 // Depth selector:
00096                         $h_func = t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[depth]',$this->pObj->MOD_SETTINGS['depth'],$this->pObj->MOD_MENU['depth'],'index.php');
00097                         $theOutput.= $h_func;
00098 
00099                                 // Add CSH:
00100                         $theOutput.= t3lib_BEfunc::cshItem('_MOD_web_info','lang',$GLOBALS['BACK_PATH'],'|<br/>');
00101 
00102                                 // Showing the tree:
00103                                 // Initialize starting point of page tree:
00104                         $treeStartingPoint = intval($this->pObj->id);
00105                         $treeStartingRecord = t3lib_BEfunc::getRecord('pages', $treeStartingPoint);
00106                         $depth = $this->pObj->MOD_SETTINGS['depth'];
00107 
00108                                 // Initialize tree object:
00109                         $tree = t3lib_div::makeInstance('t3lib_pageTree');
00110                         $tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));
00111                         $tree->addField('l18n_cfg');
00112 
00113                                 // Creating top icon; the current page
00114                         $HTML = t3lib_iconWorks::getIconImage('pages', $treeStartingRecord, $GLOBALS['BACK_PATH'],'align="top"');
00115                         $tree->tree[] = array(
00116                                 'row' => $treeStartingRecord,
00117                                 'HTML'=>$HTML
00118                         );
00119 
00120                                 // Create the tree from starting point:
00121                         $tree->getTree($treeStartingPoint, $depth, '');
00122                         #debug($tree->tree);
00123 
00124                                 // Add CSS needed:
00125                         $css_content = '
00126                                 TABLE#langTable {
00127                                         margin-top: 10px;
00128                                 }
00129                                 TABLE#langTable TR TD {
00130                                         padding-left : 2px;
00131                                         padding-right : 2px;
00132                                         white-space: nowrap;
00133                                 }
00134                                 TD.c-blocked { background-color: red; }
00135                                 TD.c-ok { background-color: #669966; }
00136                                 TD.c-fallback {  }
00137                                 TD.c-leftLine {border-left: 2px solid black; }
00138                                 .bgColor5 { font-weight: bold; }
00139                         ';
00140                         $marker = '/*###POSTCSSMARKER###*/';
00141                         $this->pObj->content = str_replace($marker,$css_content.chr(10).$marker,$this->pObj->content);
00142 
00143                                 // Render information table:
00144                         $theOutput.= $this->renderL10nTable($tree);
00145                 }
00146 
00147                 return $theOutput;
00148         }
00149 
00156         function renderL10nTable(&$tree)        {
00157                 global $LANG;
00158 
00159                         // System languages retrieved:
00160                 $languages = $this->getSystemLanguages();
00161 
00162                         // Title length:
00163                 $titleLen = $GLOBALS['BE_USER']->uc['titleLen'];
00164 
00165                         // Put together the TREE:
00166                 $output = '';
00167                 $newOL_js = array();
00168                 $langRecUids = array();
00169                 foreach($tree->tree as $data)   {
00170                         $tCells = array();
00171                         $langRecUids[0][] = $data['row']['uid'];
00172 
00173                                 // Page icons / titles etc.
00174                         $tCells[] = '<td>'.
00175                                                         $data['HTML'].
00176                                                         htmlspecialchars(t3lib_div::fixed_lgd_cs($data['row']['title'],$titleLen)).
00177                                                         (strcmp($data['row']['nav_title'],'') ? ' [Nav: <em>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($data['row']['nav_title'],$titleLen)).'</em>]' : '').
00178                                                         '</td>';
00179 
00180                                 // DEFAULT language:
00181                                 // "View page" link is created:
00182                         $viewPageLink= '<a href="#" onclick="'.
00183                                         htmlspecialchars(t3lib_BEfunc::viewOnClick($data['row']['uid'],$GLOBALS['BACK_PATH'],'','','','&L=###LANG_UID###')).'">'.
00184                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->getLL('lang_renderl10n_viewPage','1').'" border="0" alt="" />'.
00185                                         '</a>';
00186                         $status = $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-ok';
00187 
00188                                 // Create links:
00189                         $info = '';
00190                         $editUid = $data['row']['uid'];
00191                         $params = '&edit[pages]['.$editUid.']=edit';
00192                         $info.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">'.
00193                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editDefaultLanguagePage','1').'" border="0" alt="" />'.
00194                                         '</a>';
00195                         $info.= '<a href="#" onclick="'.htmlspecialchars('top.loadEditId('.intval($data['row']['uid']).',"&SET[language]=0"); return false;').'">'.
00196                                         '<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="" />'.
00197                                         '</a>';
00198                         $info.= str_replace('###LANG_UID###','0',$viewPageLink);
00199 
00200                         $info.= '&nbsp;';
00201                         $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;';
00202                         $info.= $data['row']['l18n_cfg']&2 ? '<span title="'.$LANG->sL('LLL:EXT:cms/locallang_tca.php:pages.l18n_cfg.I.2','1').'">N</span>' : '&nbsp;';
00203 
00204                                 // Put into cell:
00205                         $tCells[] = '<td class="'.$status.' c-leftLine">'.$info.'</td>';
00206                         $tCells[] = '<td class="'.$status.'" title="'.$LANG->getLL('lang_renderl10n_CEcount','1').'" align="center">'.$this->getContentElementCount($data['row']['uid'],0).'</td>';
00207 
00208                                 // Traverse system languages:
00209                         foreach($languages as $langRow) {
00210                                 $row = $this->getLangStatus($data['row']['uid'], $langRow['uid']);
00211                                 $info = '';
00212 
00213                                 if (is_array($row))     {
00214                                         $langRecUids[$langRow['uid']][] = $row['uid'];
00215                                         $status = $row['_HIDDEN'] ? ($data['row']['l18n_cfg']&2 || $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-fallback') : 'c-ok';
00216                                         $icon = t3lib_iconWorks::getIconImage(
00217                                                 'pages_language_overlay',
00218                                                 $row,
00219                                                 $GLOBALS['BACK_PATH'],
00220                                                 'align="top" class="c-recIcon"'
00221                                         );
00222 
00223                                         $info = $icon.
00224                                                                 htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$titleLen)).
00225                                                                 (strcmp($row['nav_title'],'') ? ' [Nav: <em>'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['nav_title'],$titleLen)).'</em>]' : '').
00226                                                                 ($row['_COUNT']>1 ? '<div>'.$LANG->getLL('lang_renderl10n_badThingThereAre','1').'</div>':'');
00227                                         $tCells[] = '<td class="'.$status.' c-leftLine">'.$info.'</td>';
00228 
00229                                                 // Edit whole record:
00230                                         $info = '';
00231                                         $editUid = $row['uid'];
00232                                         $params = '&edit[pages_language_overlay]['.$editUid.']=edit';
00233                                         $info.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">'.
00234                                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editLanguageOverlayRecord','1').'" border="0" alt="" />'.
00235                                                         '</a>';
00236 
00237                                         $info.= '<a href="#" onclick="'.htmlspecialchars('top.loadEditId('.intval($data['row']['uid']).',"&SET[language]='.$langRow['uid'].'"); return false;').'">'.
00238                                                         '<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="" />'.
00239                                                         '</a>';
00240                                         $info.= str_replace('###LANG_UID###',$langRow['uid'],$viewPageLink);
00241 
00242                                         $tCells[] = '<td class="'.$status.'">'.$info.'</td>';
00243                                         $tCells[] = '<td class="'.$status.'" title="'.$LANG->getLL('lang_renderl10n_CEcount','1').'" align="center">'.$this->getContentElementCount($data['row']['uid'],$langRow['uid']).'</td>';
00244                                 } else {
00245                                         $status = $data['row']['l18n_cfg']&2 || $data['row']['l18n_cfg']&1 ? 'c-blocked' : 'c-fallback';
00246                                         $tCells[] = '<td class="'.$status.' c-leftLine">&nbsp;</td>';
00247                                         $tCells[] = '<td class="'.$status.'">&nbsp;</td>';
00248 
00249                                         $info = '';
00250                                         $info.= '<input type="checkbox" name="newOL['.$langRow['uid'].']['.$data['row']['uid'].']" value="1" />';
00251                                         $newOL_js[$langRow['uid']].= '
00252                                                 +(document.webinfoForm[\'newOL['.$langRow['uid'].']['.$data['row']['uid'].']\'].checked ? \'&edit[pages_language_overlay]['.$data['row']['uid'].']=new\' : \'\')
00253                                         ';
00254                                         $tCells[] = '<td class="'.$status.'">'.$info.'</td>';
00255                                 }
00256                         }
00257 
00258                         $output.= '
00259                                 <tr class="bgColor4">
00260                                         '.implode('
00261                                         ',$tCells).'
00262                                 </tr>';
00263                 }
00264 
00265                         // Put together HEADER:
00266                 $tCells = array();
00267                 $tCells[] = '<td>'.$LANG->getLL('lang_renderl10n_page','1').':</td>';
00268 
00269                 if (is_array($langRecUids[0]))  {
00270                         $params = '&edit[pages]['.implode(',',$langRecUids[0]).']=edit&columnsOnly=title,nav_title,l18n_cfg,hidden';
00271                         $editIco = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">
00272                                 <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editPageHeaders','1').'" border="0" alt="" />
00273                                 </a>';
00274                 } else $editIco = '';
00275                 $tCells[] = '<td class="c-leftLine" colspan="2">'.
00276                                         $LANG->getLL('lang_renderl10n_default','1').':'.
00277                                         $editIco.
00278                                         '</td>';
00279 
00280                 foreach($languages as $langRow) {
00281                                 // Title:
00282                         $tCells[] = '<td class="c-leftLine">'.htmlspecialchars($langRow['title']).'</td>';
00283 
00284                                 // Edit language overlay records:
00285                         if (is_array($langRecUids[$langRow['uid']]))    {
00286                                 $params = '&edit[pages_language_overlay]['.implode(',',$langRecUids[$langRow['uid']]).']=edit&columnsOnly=title,nav_title,hidden';
00287                                 $tCells[] = '<td><a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">
00288                                         <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('lang_renderl10n_editLangOverlays','1').'" border="0" alt="" />
00289                                         </a></td>';
00290                         } else {
00291                                 $tCells[] = '<td>&nbsp;</td>';
00292                         }
00293 
00294                                 // Create new overlay records:
00295                         $params = "'".$newOL_js[$langRow['uid']]."+'&columnsOnly=title,hidden,sys_language_uid&defVals[pages_language_overlay][sys_language_uid]=".$langRow['uid'];
00296                         $tCells[] = '<td><a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'])).'">
00297                                 <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="" />
00298                                 </a></td>';
00299                 }
00300 
00301                 $output = '
00302                         <tr class="bgColor5">
00303                                 '.implode('
00304                                 ',$tCells).'
00305                         </tr>'.$output;
00306 
00307                 $output = '
00308 
00309                 <table border="0" cellspacing="0" cellpadding="0" id="langTable">'.$output.'
00310                 </table>';
00311 
00312                 return $output;
00313         }
00314 
00320         function getSystemLanguages()   {
00321                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00322                         '*',
00323                         'sys_language',
00324                         '1'.t3lib_BEfunc::deleteClause('sys_language')
00325                 );
00326 
00327                 $outputArray = array();
00328                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00329                         $outputArray[] = $row;
00330                 }
00331 
00332                 return $outputArray;
00333         }
00334 
00342         function getLangStatus($pageId, $langId)        {
00343                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00344                         '*',
00345                         'pages_language_overlay',
00346                         'pid='.intval($pageId).
00347                                 ' AND sys_language_uid='.intval($langId).
00348                                 t3lib_BEfunc::deleteClause('pages_language_overlay')
00349                 );
00350 
00351                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00352                 if (is_array($row))     {
00353                         $row['_COUNT'] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00354                         $row['_HIDDEN'] = $row['hidden'] ||
00355                                                         (intval($row['endtime']) > 0 && intval($row['endtime']) < time()) ||
00356                                                         (time() < intval($row['starttime']));
00357                 }
00358 
00359                 return $row;
00360         }
00361 
00369         function getContentElementCount($pageId,$sysLang)       {
00370                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00371                         'count(*)',
00372                         'tt_content',
00373                         'pid='.intval($pageId).
00374                                 ' AND sys_language_uid='.intval($sysLang).
00375                                 t3lib_BEfunc::deleteClause('tt_content')
00376                 );
00377 
00378                 list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00379                 return $count ? $count : '-';
00380         }
00381 }
00382 
00383 
00384 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo_lang.php'])  {
00385         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo_lang.php']);
00386 }
00387 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6