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