[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_languages/ -> admin.languages.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: admin.languages.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @subpackage    Languages
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // no direct access
  16  defined( '_JEXEC' ) or die( 'Restricted access' );
  17  
  18  /*
  19   * Make sure the user is authorized to view this page
  20   */
  21  $user = & JFactory::getUser();
  22  if (!$user->authorize( 'com_languages', 'manage' )) {
  23      $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
  24  }
  25  
  26  require_once( JApplicationHelper::getPath( 'admin_html' ) );
  27  
  28  $task     = strtolower( JRequest::getCmd( 'task' ) );
  29  $cid     = JRequest::getVar( 'cid', array(0), '', 'array' );
  30  $cid    = array(JFilterInput::clean(@$cid[0], 'cmd'));
  31  
  32  $client    = JRequest::getVar('client', 0, '', 'int');
  33  if ($client == 1) {
  34      JSubMenuHelper::addEntry(JText::_('Site'),'#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');');
  35      JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');', true );
  36  } else {
  37      JSubMenuHelper::addEntry(JText::_('Site'), '#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');', true );
  38      JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');');
  39  }
  40  
  41  switch ($task)
  42  {
  43      case 'publish':
  44          publishLanguage( $cid[0]);
  45          break;
  46  
  47      default:
  48          viewLanguages();
  49          break;
  50  }
  51  
  52  /**
  53  * Compiles a list of installed languages
  54  */
  55  function viewLanguages()
  56  {
  57      global $mainframe, $option;
  58  
  59      // Initialize some variables
  60      $db        =& JFactory::getDBO();
  61      $client    =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
  62      $rows    = array ();
  63  
  64      $limit        = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
  65      $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
  66  
  67      $rowid = 0;
  68  
  69      // Set FTP credentials, if given
  70      jimport('joomla.client.helper');
  71      $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
  72  
  73      //load folder filesystem class
  74      jimport('joomla.filesystem.folder');
  75      $path = JLanguage::getLanguagePath($client->path);
  76      $dirs = JFolder::folders( $path );
  77  
  78      foreach ($dirs as $dir)
  79      {
  80          $files = JFolder::files( $path.DS.$dir, '^([-_A-Za-z]*)\.xml$' );
  81          foreach ($files as $file)
  82          {
  83              $data = JApplicationHelper::parseXMLLangMetaFile($path.DS.$dir.DS.$file);
  84  
  85              $row             = new StdClass();
  86              $row->id         = $rowid;
  87              $row->language     = substr($file,0,-4);
  88  
  89              if (!is_array($data)) {
  90                  continue;
  91              }
  92              foreach($data as $key => $value) {
  93                  $row->$key = $value;
  94              }
  95  
  96              // if current than set published
  97              $params = JComponentHelper::getParams('com_languages');
  98              if ( $params->get($client->name, 'en-GB') == $row->language) {
  99                  $row->published    = 1;
 100              } else {
 101                  $row->published = 0;
 102              }
 103  
 104              $row->checked_out = 0;
 105              $row->mosname = JString::strtolower( str_replace( " ", "_", $row->name ) );
 106              $rows[] = $row;
 107              $rowid++;
 108          }
 109      }
 110  
 111  
 112      jimport('joomla.html.pagination');
 113      $pageNav = new JPagination( $rowid, $limitstart, $limit );
 114  
 115      $rows = array_slice( $rows, $pageNav->limitstart, $pageNav->limit );
 116  
 117      HTML_languages::showLanguages( $rows, $pageNav, $option, $client, $ftp );
 118  }
 119  
 120  /**
 121  * Publish, or make current, the selected language
 122  */
 123  function publishLanguage( $language )
 124  {
 125      global $mainframe;
 126  
 127      // Check for request forgeries
 128      JRequest::checkToken() or jexit( 'Invalid Token' );
 129  
 130      // Initialize some variables
 131      $client    =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
 132  
 133      $params = JComponentHelper::getParams('com_languages');
 134      $params->set($client->name, $language);
 135  
 136      $table =& JTable::getInstance('component');
 137      $table->loadByOption( 'com_languages' );
 138  
 139      $table->params = $params->toString();
 140  
 141      // pre-save checks
 142      if (!$table->check()) {
 143          JError::raiseWarning( 500, $table->getError() );
 144          return false;
 145      }
 146  
 147      // save the changes
 148      if (!$table->store()) {
 149          JError::raiseWarning( 500, $table->getError() );
 150          return false;
 151      }
 152  
 153      $mainframe->redirect('index.php?option=com_languages&client='.$client->id);
 154  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1