0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: languages.php.tar
home/academiac/www/administrator/components/com_installer/models/languages.php 0000644 00000016423 15137210326 0024057 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_installer * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; // Import library dependencies jimport('joomla.application.component.modellist'); jimport('joomla.updater.update'); /** * Languages Installer Model * * @package Joomla.Administrator * @subpackage com_installer * @since 2.5.7 */ class InstallerModelLanguages extends JModelList { /** * Constructor override, defines a white list of column filters. * * @param array $config An optional associative array of configuration settings. * * @see JModelList */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'update_id', 'update_id', 'name', 'name', ); } parent::__construct($config); } /** * Method to get the available languages database query. * * @return JDatabaseQuery The database query */ protected function _getListQuery() { $db = JFactory::getDBO(); $query = $db->getQuery(true); // Select the required fields from the updates table $query->select('update_id, name, version, detailsurl, type'); $query->from('#__updates'); // This Where clause will avoid to list languages already installed. $query->where('extension_id = 0'); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('(name LIKE ' . $search . ')'); } // Add the list ordering clause. $listOrder = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); $query->order($db->escape($listOrder) . ' ' . $db->escape($orderDirn)); return $query; } /** * Method to get a store id based on model configuration state. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); return parent::getStoreId($id); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param null $ordering list order * @param null $direction direction in the list * * @return void */ protected function populateState($ordering = 'name', $direction = 'asc') { // Initialise variables. $app = JFactory::getApplication(); $value = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $value); $this->setState('extension_message', $app->getUserState('com_installer.extension_message')); parent::populateState($ordering, $direction); } /** * Method to find available languages in the Accredited Languages Update Site. * * @param int $cache_timeout time before refreshing the cached updates * * @return bool */ public function findLanguages($cache_timeout = 0) { $updater = JUpdater::getInstance(); /* * The following function uses extension_id 600, that is the english language extension id. * In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo */ $updater->findUpdates(array(600), $cache_timeout); return true; } /** * Install languages in the system. * * @param array $lids array of language ids selected in the list * * @return bool */ public function install($lids) { $app = JFactory::getApplication(); $installer = JInstaller::getInstance(); // Loop through every selected language foreach ($lids as $id) { // Loads the update database object that represents the language $language = JTable::getInstance('update'); $language->load($id); // Get the url to the XML manifest file of the selected language $remote_manifest = $this->_getLanguageManifest($id); if (!$remote_manifest) { // Could not find the url, the information in the update server may be corrupt $message = JText::sprintf('COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_MANIFEST', $language->name); $message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER'); $app->enqueueMessage($message); continue; } // Based on the language XML manifest get the url of the package to download $package_url = $this->_getPackageUrl($remote_manifest); if (!$package_url) { // Could not find the url , maybe the url is wrong in the update server, or there is not internet access $message = JText::sprintf('COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_PACKAGE', $language->name); $message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER'); $app->enqueueMessage($message); continue; } // Download the package to the tmp folder $package = $this->_downloadPackage($package_url); // Install the package if (!$installer->install($package['dir'])) { // There was an error installing the package $message = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', $language->name); $message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER'); $app->enqueueMessage($message); continue; } // Package installed successfully $app->enqueueMessage(JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', $language->name)); // Cleanup the install files in tmp folder if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); // Delete the installed language from the list $language->delete($id); } } /** * Gets the manifest file of a selected language from a the language list in a update server. * * @param int $uid the id of the language in the #__updates table * * @return string */ protected function _getLanguageManifest($uid) { $instance = JTable::getInstance('update'); $instance->load($uid); $detailurl = trim($instance->detailsurl); return $detailurl; } /** * Finds the url of the package to download. * * @param string $remote_manifest url to the manifest XML file of the remote package * * @return string|bool */ protected function _getPackageUrl( $remote_manifest ) { $update = new JUpdate; $update->loadFromXML($remote_manifest); $package_url = trim($update->get('downloadurl', false)->_data); return $package_url; } /** * Download a language package from an URL and unpack it in the tmp folder. * * @param string $url url of the package * * @return array|bool Package details or false on failure */ protected function _downloadPackage($url) { // Download the package from the given URL $p_file = JInstallerHelper::downloadPackage($url); // Was the package downloaded? if (!$p_file) { JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL')); return false; } $config = JFactory::getConfig(); $tmp_dest = $config->get('tmp_path'); // Unpack the downloaded package file $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file); return $package; } } home/academiac/www/administrator/components/com_installer/controllers/languages.php 0000644 00000004141 15137211600 0025130 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_installer * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License, see LICENSE.php */ // No direct access defined('_JEXEC') or die; /** * Languages Installer Controller * * @package Joomla.Administrator * @subpackage com_installer * @since 2.5.7 */ class InstallerControllerLanguages extends JControllerLegacy { /** * Finds new Languages. * * @return void */ public function find() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get the caching duration jimport('joomla.application.component.helper'); $component = JComponentHelper::getComponent('com_installer'); $params = $component->params; $cache_timeout = $params->get('cachetimeout', 6, 'int'); $cache_timeout = 3600 * $cache_timeout; // Find updates $model = $this->getModel('languages'); $model->findLanguages($cache_timeout); $this->setRedirect(JRoute::_('index.php?option=com_installer&view=languages', false)); } /** * Purgue the updates list. * * @return void */ public function purge() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Purge updates $model = $this->getModel('update'); $model->purge(); $model->enableSites(); $this->setRedirect(JRoute::_('index.php?option=com_installer&view=languages', false), $model->_message); } /** * Install languages. * * @return void */ public function install() { $model = $this->getModel('languages'); // Get array of selected languages $lids = JRequest::getVar('cid', array(), '', 'array'); JArrayHelper::toInteger($lids, array()); if (!$lids) { // No languages have been selected $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_NOEXTENSIONSELECTED')); } else { // Install selected languages $model->install($lids); } $this->setRedirect(JRoute::_('index.php?option=com_installer&view=languages', false)); } } home/academiac/www/administrator/components/com_virtuemart/tables/languages.php 0000604 00000002777 15137216277 0024271 0 ustar 00 <?php /** * * Manufacturer table * * @package VirtueMart * @subpackage Manufacturer * @author Patrick Kohl * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart 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. * @version $Id: manufacturers.php 4708 2011-11-15 04:19:09Z electrocity $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if(!class_exists('VmTable'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmtable.php'); /** * Manufacturer table class * The class is used to manage the manufacturer table in the shop. * * @package VirtueMart * @author Max Milbers */ class TableLanguages extends VmTable { /** @var int Primary key */ var $virtuemart_language_id = 0; /** @var string language name */ var $language_name = ''; var $language_code = ''; /** @var int published or unpublished */ var $published = 0; /** @var int published or unpublished */ var $installed = 0; /** * @author Max Milbers * @param JDataBase $db */ function __construct(&$db) { parent::__construct('#__virtuemart_languages', 'virtuemart_language_id', $db); $this->setTableShortCut('l'); } } // pure php no closing tag home/academiac/www/libraries/joomla/html/parameter/element/languages.php 0000644 00000003364 15137262336 0022516 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage HTML * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Renders a languages element * * @package Joomla.Platform * @subpackage Parameter * @since 11.1 * @deprecated 12.1 Use JFormFieldLanguage instead * @note In updating please noe that JFormFieldLanguage does not end in s. */ class JElementLanguages extends JElement { /** * Element name * * @var string */ protected $_name = 'Languages'; /** * Fetch the language list element * * @param string $name Element name * @param string $value Element value * @param JXMLElement &$node JXMLElement node object containing the settings for the element * @param string $control_name Control name * * @return string * * @deprecated 12.1 Use JFormFieldLanguage * @note When updating note that JFormFieldLanguage has no s. * @since 11.1 */ public function fetchElement($name, $value, &$node, $control_name) { // Deprecation warning. JLog::add('JElementLanguages::fetchElement() is deprecated.', JLog::WARNING, 'deprecated'); $client = $node->attributes('client'); $languages = JLanguageHelper::createLanguageList($value, constant('JPATH_' . strtoupper($client)), true); array_unshift($languages, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_LANGUAGE'))); return JHtml::_( 'select.genericlist', $languages, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value) ); } } home/academiac/www/administrator/components/com_languages/languages.php 0000644 00000001060 15137316211 0022534 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Access check. if (!JFactory::getUser()->authorise('core.manage', 'com_languages')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } $controller = JControllerLegacy::getInstance('Languages'); $controller->execute(JRequest::getCmd('task')); $controller->redirect(); home/academiac/www/administrator/components/com_languages/models/languages.php 0000644 00000012441 15137317415 0024033 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * Languages Model Class * * @package Joomla.Administrator * @subpackage com_languages * @since 1.6 */ class LanguagesModelLanguages extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'lang_id', 'a.lang_id', 'lang_code', 'a.lang_code', 'title', 'a.title', 'title_native', 'a.title_native', 'sef', 'a.sef', 'image', 'a.image', 'published', 'a.published', 'ordering', 'a.ordering', 'access', 'a.access', 'access_level', 'home', 'l.home', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('administrator'); // Load the filter state. $search = $this->getUserStateFromRequest($this->context.'.search', 'filter_search'); $this->setState('filter.search', $search); $accessId = $this->getUserStateFromRequest($this->context.'.access', 'filter_access', null, 'int'); $this->setState('filter.access', $accessId); $published = $this->getUserStateFromRequest($this->context.'.published', 'filter_published', ''); $this->setState('filter.published', $published); // Load the parameters. $params = JComponentHelper::getParams('com_languages'); $this->setState('params', $params); // List state information. parent::populateState('a.title', 'asc'); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.search'); $id .= ':'.$this->getState('filter.access'); $id .= ':'.$this->getState('filter.published'); return parent::getStoreId($id); } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select all fields from the languages table. $query->select($this->getState('list.select', 'a.*', 'l.home')); $query->from($db->quoteName('#__languages').' AS a'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Select the language home pages $query->select('l.home AS home'); $query->join('LEFT', $db->quoteName('#__menu') . ' AS l ON l.language = a.lang_code AND l.home=1 AND l.language <> ' . $db->quote('*')); // Filter on the published state. $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.published = '.(int) $published); } elseif ($published === '') { $query->where('(a.published IN (0, 1))'); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $search = $db->Quote('%'.$db->escape($search, true).'%', false); $query->where('(a.title LIKE '.$search.')'); } // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = '.(int) $access); } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Set the published language(s) * * @param array $cid An array of language IDs. * @param int $value The value of the published state. * * @return boolean True on success, false otherwise. * @since 1.6 */ public function setPublished($cid, $value = 0) { return JTable::getInstance('Language')->publish($cid, $value); } /** * Method to delete records. * * @param array An array of item primary keys. * * @return boolean Returns true on success, false on failure. * @since 1.6 */ public function delete($pks) { // Sanitize the array. $pks = (array) $pks; // Get a row instance. $table = JTable::getInstance('Language'); // Iterate the items to delete each one. foreach ($pks as $itemId) { if (!$table->delete((int) $itemId)) { $this->setError($table->getError()); return false; } } // Clean the cache. $this->cleanCache(); return true; } /** * Custom clean cache method, 2 places for 2 clients * * @since 1.6 */ protected function cleanCache($group = null, $client_id = 0) { parent::cleanCache('_system'); parent::cleanCache('com_languages'); } } home/academiac/www/administrator/components/com_languages/helpers/html/languages.php 0000644 00000003477 15137320206 0025157 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; /** * Utility class working with languages * * @package Joomla.Administrator * @subpackage com_languages * @since 1.6 */ abstract class JHtmlLanguages { /** * method to generate an information about the default language * * @param boolean $published is the language the default? * * @return string html code */ public static function published($published) { if ($published) { return JHtml::_('image', 'menu/icon-16-default.png', JText::_('COM_LANGUAGES_HEADING_DEFAULT'), NULL, true); } else { return ' '; } } /** * method to generate an input radio button * * @param int $rowNum the row number * @param string language tag * * @return string html code */ public static function id($rowNum, $language) { return '<input type="radio" id="cb'.$rowNum.'" name="cid" value="'.htmlspecialchars($language).'" onclick="Joomla.isChecked(this.checked);" title="'.($rowNum+1).'"/>'; } public static function clients() { return array( JHtml::_('select.option', 0, JText::_('JSITE')), JHtml::_('select.option', 1, JText::_('JADMINISTRATOR')) ); } /** * Returns an array of published state filter options. * * @return string The HTML code for the select tag * @since 1.6 */ public static function publishedOptions() { // Build the active state filter options. $options = array(); $options[] = JHtml::_('select.option', '1', 'JPUBLISHED'); $options[] = JHtml::_('select.option', '0', 'JUNPUBLISHED'); $options[] = JHtml::_('select.option', '-2', 'JTRASHED'); $options[] = JHtml::_('select.option', '*', 'JALL'); return $options; } } home/academiac/www/administrator/components/com_languages/controllers/languages.php 0000644 00000001654 15137321575 0025124 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; jimport('joomla.application.component.controlleradmin'); /** * @package Joomla.Administrator * @subpackage com_languages * @since 1.6 */ class LanguagesControllerLanguages extends JControllerAdmin { /** * Method to get a model object, loading it if required. * * @param string $name The model name. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * * @return object The model. * * @since 1.6 */ public function getModel($name = 'Language', $prefix = 'LanguagesModel', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } } home/academiac/www/administrator/components/com_languages/helpers/languages.php 0000644 00000006703 15137441616 0024217 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; /** * Languages component helper. * * @package Joomla.Administrator * @subpackage com_languages * @since 1.6 */ class LanguagesHelper { /** * Configure the Linkbar. * * @param string The name of the active view. */ public static function addSubmenu($vName) { JSubMenuHelper::addEntry( JText::_('COM_LANGUAGES_SUBMENU_INSTALLED_SITE'), 'index.php?option=com_languages&view=installed&client=0', $vName == 'installed' ); JSubMenuHelper::addEntry( JText::_('COM_LANGUAGES_SUBMENU_INSTALLED_ADMINISTRATOR'), 'index.php?option=com_languages&view=installed&client=1', $vName == 'installed' ); JSubMenuHelper::addEntry( JText::_('COM_LANGUAGES_SUBMENU_CONTENT'), 'index.php?option=com_languages&view=languages', $vName == 'languages' ); JSubMenuHelper::addEntry( JText::_('COM_LANGUAGES_SUBMENU_OVERRIDES'), 'index.php?option=com_languages&view=overrides', $vName == 'overrides' ); } /** * Gets a list of the actions that can be performed. * * @return JObject */ public static function getActions() { $user = JFactory::getUser(); $result = new JObject; $assetName = 'com_languages'; $actions = JAccess::getActions($assetName); foreach ($actions as $action) { $result->set($action->name, $user->authorise($action->name, $assetName)); } return $result; } /** * Method for parsing ini files * * @param string $filename Path and name of the ini file to parse * * @return array Array of strings found in the file, the array indices will be the keys. On failure an empty array will be returned * * @since 2.5 */ public static function parseFile($filename) { jimport('joomla.filesystem.file'); if (!JFile::exists($filename)) { return array(); } // Capture hidden PHP errors from the parsing $version = phpversion(); $php_errormsg = null; $track_errors = ini_get('track_errors'); ini_set('track_errors', true); if ($version >= '5.3.1') { $contents = file_get_contents($filename); $contents = str_replace('_QQ_', '"\""', $contents); $strings = @parse_ini_string($contents); if ($strings === false) { return array(); } } else { $strings = @parse_ini_file($filename); if ($strings === false) { return array(); } if ($version == '5.3.0' && is_array($strings)) { foreach ($strings as $key => $string) { $strings[$key] = str_replace('_QQ_', '"', $string); } } } return $strings; } /** * Filter method for language keys. * This method will be called by JForm while filtering the form data. * * @param string $value The language key to filter * * @return string The filtered language key * * @since 2.5 */ public static function filterKey($value) { $filter = JFilterInput::getInstance(null, null, 1, 1); return strtoupper($filter->clean($value, 'cmd')); } /** * Filter method for language strings. * This method will be called by JForm while filtering the form data. * * @param string $value The language string to filter * * @return string The filtered language string * * @since 2.5 */ public static function filterText($value) { $filter = JFilterInput::getInstance(null, null, 1, 1); return $filter->clean($value); } }
©
2018.