You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Languages Controller
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
* @since 1.5
|
||||
*/
|
||||
class LanguagesControllerInstalled extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* task to set the default language
|
||||
*/
|
||||
public function setDefault()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JInvalid_Token'));
|
||||
|
||||
$cid = $this->input->get('cid', '');
|
||||
$model = $this->getModel('installed');
|
||||
if ($model->publish($cid))
|
||||
{
|
||||
$msg = JText::_('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED');
|
||||
$type = 'message';
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = $this->getError();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
$clientId = $model->getState('filter.client_id');
|
||||
$this->setredirect('index.php?option=com_languages&view=installed&client='.$clientId, $msg, $type);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Languages list actions controller.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
* @since 1.6
|
||||
*/
|
||||
class LanguagesControllerLanguage extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param int $recordId The primary key id for the item.
|
||||
* @param string $key The name of the primary key variable.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $key = 'lang_id')
|
||||
{
|
||||
return parent::getRedirectToItemAppend($recordId, $key);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
196
administrator/components/com_languages/controllers/override.php
Normal file
196
administrator/components/com_languages/controllers/override.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Languages Override Controller
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
* @since 2.5
|
||||
*/
|
||||
class LanguagesControllerOverride extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* Method to edit an existing override
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable (not used here).
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (not used here).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function edit($key = null, $urlVar = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$cid = $this->input->post->get('cid', array(), 'array');
|
||||
$context = "$this->option.edit.$this->context";
|
||||
|
||||
// Get the constant name
|
||||
$recordId = (count($cid) ? $cid[0] : $this->input->get('id'));
|
||||
|
||||
// Access check
|
||||
if (!$this->allowEdit())
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$app->setUserState($context.'.data', null);
|
||||
$this->setRedirect('index.php?option='.$this->option.'&view='.$this->view_item.$this->getRedirectToItemAppend($recordId, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save an override
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable (not used here).
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (not used here).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function save($key = null, $urlVar = null)
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$model = $this->getModel();
|
||||
$data = $this->input->post->get('jform', array(), 'array');
|
||||
$context = "$this->option.edit.$this->context";
|
||||
$task = $this->getTask();
|
||||
|
||||
$recordId = $this->input->get('id');
|
||||
$data['id'] = $recordId;
|
||||
|
||||
// Access check
|
||||
if (!$this->allowSave($data, 'id'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate the posted data
|
||||
$form = $model->getForm($data, false);
|
||||
if (!$form)
|
||||
{
|
||||
$app->enqueueMessage($model->getError(), 'error');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Require helper for filter functions called by JForm
|
||||
require_once JPATH_COMPONENT.'/helpers/languages.php';
|
||||
|
||||
// Test whether the data is valid.
|
||||
$validData = $model->validate($form, $data);
|
||||
|
||||
// Check for validation errors.
|
||||
if ($validData === false)
|
||||
{
|
||||
// Get the validation messages
|
||||
$errors = $model->getErrors();
|
||||
|
||||
// Push up to three validation messages out to the user.
|
||||
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
|
||||
{
|
||||
if ($errors[$i] instanceof Exception)
|
||||
{
|
||||
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
$app->enqueueMessage($errors[$i], 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
// Save the data in the session
|
||||
$app->setUserState($context.'.data', $data);
|
||||
|
||||
// Redirect back to the edit screen
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_item.$this->getRedirectToItemAppend($recordId, 'id'), false));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to save the data
|
||||
if (!$model->save($validData))
|
||||
{
|
||||
// Save the data in the session
|
||||
$app->setUserState($context.'.data', $validData);
|
||||
|
||||
// Redirect back to the edit screen
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_item.$this->getRedirectToItemAppend($recordId, 'id'), false));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Add message of success
|
||||
$this->setMessage(JText::_('COM_LANGUAGES_VIEW_OVERRIDE_SAVE_SUCCESS'));
|
||||
|
||||
// Redirect the user and adjust session state based on the chosen task
|
||||
switch ($task)
|
||||
{
|
||||
case 'apply':
|
||||
// Set the record data in the session
|
||||
$app->setUserState($context.'.data', null);
|
||||
|
||||
// Redirect back to the edit screen
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_item.$this->getRedirectToItemAppend($validData['key'], 'id'), false));
|
||||
break;
|
||||
|
||||
case 'save2new':
|
||||
// Clear the record id and data from the session
|
||||
$app->setUserState($context.'.data', null);
|
||||
|
||||
// Redirect back to the edit screen
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_item.$this->getRedirectToItemAppend(null, 'id'), false));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Clear the record id and data from the session
|
||||
$app->setUserState($context.'.data', null);
|
||||
|
||||
// Redirect to the list screen
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable (not used here).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function cancel($key = null, $test = null)
|
||||
{
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$context = "$this->option.edit.$this->context";
|
||||
|
||||
$app->setUserState($context.'.data', null);
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Languages Overrides Controller
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
* @since 2.5
|
||||
*/
|
||||
class LanguagesControllerOverrides extends JControllerAdmin
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $text_prefix = 'COM_LANGUAGES_VIEW_OVERRIDES';
|
||||
|
||||
/**
|
||||
* Method for deleting one or more overrides
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Get items to dlete from the request
|
||||
$cid = $this->input->get('cid', array(), 'array');
|
||||
|
||||
if (!is_array($cid) || count($cid) < 1)
|
||||
{
|
||||
$this->setMessage(JText::_($this->text_prefix.'_NO_ITEM_SELECTED'), 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the model
|
||||
$model = $this->getModel('overrides');
|
||||
|
||||
// Remove the items
|
||||
if ($model->delete($cid))
|
||||
{
|
||||
$this->setMessage(JText::plural($this->text_prefix.'_N_ITEMS_DELETED', count($cid)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setMessage($model->getError());
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list, false));
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Languages Strings JSON Controller
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_languages
|
||||
* @since 2.5
|
||||
*/
|
||||
class LanguagesControllerStrings extends JControllerAdmin
|
||||
{
|
||||
/**
|
||||
* Method for refreshing the cache in the database with the known language strings
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
echo new JResponseJson($this->getModel('strings')->refresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for searching language strings
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
echo new JResponseJson($this->getModel('strings')->search());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user