You've already forked joomla_test
first commit
This commit is contained in:
356
administrator/includes/application.php
Normal file
356
administrator/includes/application.php
Normal file
@ -0,0 +1,356 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Joomla! Application class
|
||||
*
|
||||
* Provide many supporting API functions
|
||||
*
|
||||
* @final
|
||||
* @package Joomla.Administrator
|
||||
* @since 1.5
|
||||
*/
|
||||
class JAdministrator extends JApplication
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* Recognized key values include 'clientId' (this list is not meant to be comprehensive).
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$config['clientId'] = 1;
|
||||
parent::__construct($config);
|
||||
|
||||
//Set the root in the URI based on the application name
|
||||
JUri::root(null, str_ireplace('/' . $this->getName(), '', JUri::base(true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the application.
|
||||
*
|
||||
* @param array $options An optional associative array of configuration settings.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.5
|
||||
*/
|
||||
public function initialise($options = array())
|
||||
{
|
||||
$config = JFactory::getConfig();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// If the user is a guest we populate it with the guest user group.
|
||||
if ($user->guest)
|
||||
{
|
||||
$guestUsergroup = JComponentHelper::getParams('com_users')->get('guest_usergroup', 1);
|
||||
$user->groups = array($guestUsergroup);
|
||||
}
|
||||
|
||||
// if a language was specified it has priority
|
||||
// otherwise use user or default language settings
|
||||
if (empty($options['language']))
|
||||
{
|
||||
$lang = $user->getParam('admin_language');
|
||||
|
||||
// Make sure that the user's language exists
|
||||
if ($lang && JLanguage::exists($lang))
|
||||
{
|
||||
$options['language'] = $lang;
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = JComponentHelper::getParams('com_languages');
|
||||
$client = JApplicationHelper::getClientInfo($this->getClientId());
|
||||
$options['language'] = $params->get($client->name, $config->get('language', 'en-GB'));
|
||||
}
|
||||
}
|
||||
|
||||
// One last check to make sure we have something
|
||||
if (!JLanguage::exists($options['language']))
|
||||
{
|
||||
$lang = $config->get('language', 'en-GB');
|
||||
if (JLanguage::exists($lang))
|
||||
{
|
||||
$options['language'] = $lang;
|
||||
}
|
||||
else
|
||||
{
|
||||
$options['language'] = 'en-GB'; // as a last ditch fail to english
|
||||
}
|
||||
}
|
||||
|
||||
// Execute the parent initialise method.
|
||||
parent::initialise($options);
|
||||
|
||||
// Load Library language
|
||||
$lang = JFactory::getLanguage();
|
||||
$lang->load('lib_joomla', JPATH_ADMINISTRATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Route the application
|
||||
*
|
||||
* @return void
|
||||
* @since 1.5
|
||||
*/
|
||||
public function route()
|
||||
{
|
||||
$uri = JUri::getInstance();
|
||||
|
||||
if ($this->getCfg('force_ssl') >= 1 && strtolower($uri->getScheme()) != 'https')
|
||||
{
|
||||
//forward to https
|
||||
$uri->setScheme('https');
|
||||
$this->redirect((string) $uri);
|
||||
}
|
||||
|
||||
// Trigger the onAfterRoute event.
|
||||
JPluginHelper::importPlugin('system');
|
||||
$this->triggerEvent('onAfterRoute');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to the JRouter object.
|
||||
*
|
||||
* @return JRouter
|
||||
* @since 1.5
|
||||
*/
|
||||
static public function getRouter($name = null, array $options = array())
|
||||
{
|
||||
$router = parent::getRouter('administrator');
|
||||
return $router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the application
|
||||
*
|
||||
* @param string $component The component to dispatch.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.5
|
||||
*/
|
||||
public function dispatch($component = null)
|
||||
{
|
||||
if ($component === null)
|
||||
{
|
||||
$component = JAdministratorHelper::findOption();
|
||||
}
|
||||
|
||||
$document = JFactory::getDocument();
|
||||
|
||||
switch ($document->getType())
|
||||
{
|
||||
case 'html':
|
||||
$document->setMetaData('keywords', $this->getCfg('MetaKeys'));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$document->setTitle($this->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION'));
|
||||
$document->setDescription($this->getCfg('MetaDesc'));
|
||||
$document->setGenerator('Joomla! - Open Source Content Management');
|
||||
|
||||
$contents = JComponentHelper::renderComponent($component);
|
||||
$document->setBuffer($contents, 'component');
|
||||
|
||||
// Trigger the onAfterDispatch event.
|
||||
JPluginHelper::importPlugin('system');
|
||||
$this->triggerEvent('onAfterDispatch');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the application.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.5
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$component = $this->input->get('option', 'com_login');
|
||||
$template = $this->getTemplate(true);
|
||||
$file = $this->input->get('tmpl', 'index');
|
||||
|
||||
if ($component == 'com_login')
|
||||
{
|
||||
$file = 'login';
|
||||
}
|
||||
|
||||
// Safety check for when configuration.php root_user is in use.
|
||||
$config = JFactory::getConfig();
|
||||
$rootUser = $config->get('root_user');
|
||||
if (property_exists('JConfig', 'root_user')
|
||||
&& (JFactory::getUser()->get('username') == $rootUser || JFactory::getUser()->id === (string) $rootUser)
|
||||
)
|
||||
{
|
||||
JError::raiseNotice(200, JText::sprintf('JWARNING_REMOVE_ROOT_USER', 'index.php?option=com_config&task=application.removeroot&' . JSession::getFormToken() . '=1'));
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'template' => $template->template,
|
||||
'file' => $file . '.php',
|
||||
'directory' => JPATH_THEMES,
|
||||
'params' => $template->params
|
||||
);
|
||||
|
||||
$document = JFactory::getDocument();
|
||||
$document->parse($params);
|
||||
$this->triggerEvent('onBeforeRender');
|
||||
$data = $document->render(false, $params);
|
||||
JResponse::setBody($data);
|
||||
$this->triggerEvent('onAfterRender');
|
||||
}
|
||||
|
||||
/**
|
||||
* Login authentication function
|
||||
*
|
||||
* @param array Array('username' => string, 'password' => string)
|
||||
* @param array Array('remember' => boolean)
|
||||
*
|
||||
* @return boolean True on success.
|
||||
* @see JApplication::login
|
||||
* @since 1.5
|
||||
*/
|
||||
public function login($credentials, $options = array())
|
||||
{
|
||||
//The minimum group
|
||||
$options['group'] = 'Public Backend';
|
||||
|
||||
//Make sure users are not autoregistered
|
||||
$options['autoregister'] = false;
|
||||
|
||||
//Set the application login entry point
|
||||
if (!array_key_exists('entry_url', $options))
|
||||
{
|
||||
$options['entry_url'] = JUri::base() . 'index.php?option=com_users&task=login';
|
||||
}
|
||||
|
||||
// Set the access control action to check.
|
||||
$options['action'] = 'core.login.admin';
|
||||
|
||||
$result = parent::login($credentials, $options);
|
||||
|
||||
if (!($result instanceof Exception))
|
||||
{
|
||||
$lang = $this->input->get('lang');
|
||||
$lang = preg_replace('/[^A-Z-]/i', '', $lang);
|
||||
$this->setUserState('application.lang', $lang);
|
||||
|
||||
self::purgeMessages();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template
|
||||
*
|
||||
* @return string The template name
|
||||
* @since 1.0
|
||||
*/
|
||||
public function getTemplate($params = false)
|
||||
{
|
||||
static $template;
|
||||
|
||||
if (!isset($template))
|
||||
{
|
||||
$admin_style = JFactory::getUser()->getParam('admin_style');
|
||||
// Load the template name from the database
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('template, s.params')
|
||||
->from('#__template_styles as s')
|
||||
->join('LEFT', '#__extensions as e ON e.type=' . $db->quote('template') . ' AND e.element=s.template AND e.client_id=s.client_id');
|
||||
if ($admin_style)
|
||||
{
|
||||
$query->where('s.client_id = 1 AND id = ' . (int) $admin_style . ' AND e.enabled = 1', 'OR');
|
||||
}
|
||||
$query->where('s.client_id = 1 AND home = ' . $db->quote('1'), 'OR')
|
||||
->order('home');
|
||||
$db->setQuery($query);
|
||||
$template = $db->loadObject();
|
||||
|
||||
$template->template = JFilterInput::getInstance()->clean($template->template, 'cmd');
|
||||
$template->params = new JRegistry($template->params);
|
||||
|
||||
if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php'))
|
||||
{
|
||||
$this->enqueueMessage(JText::_('JERROR_ALERTNOTEMPLATE'), 'error');
|
||||
$template->params = new JRegistry;
|
||||
$template->template = 'isis';
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php'))
|
||||
{
|
||||
throw new InvalidArgumentException(JText::sprintf('JERROR_COULD_NOT_FIND_TEMPLATE', $template->template));
|
||||
}
|
||||
|
||||
if ($params)
|
||||
{
|
||||
return $template;
|
||||
}
|
||||
|
||||
return $template->template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge the jos_messages table of old messages
|
||||
*
|
||||
* @return void
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function purgeMessages()
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$userid = $user->get('id');
|
||||
|
||||
$query = 'SELECT *'
|
||||
. ' FROM #__messages_cfg'
|
||||
. ' WHERE user_id = ' . (int) $userid
|
||||
. ' AND cfg_name = ' . $db->quote('auto_purge');
|
||||
|
||||
$db->setQuery($query);
|
||||
$config = $db->loadObject();
|
||||
|
||||
// check if auto_purge value set
|
||||
if (is_object($config) and $config->cfg_name == 'auto_purge')
|
||||
{
|
||||
$purge = $config->cfg_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if no value set, default is 7 days
|
||||
$purge = 7;
|
||||
}
|
||||
// calculation of past date
|
||||
|
||||
// if purge value is not 0, then allow purging of old messages
|
||||
if ($purge > 0)
|
||||
{
|
||||
// purge old messages at day set in message configuration
|
||||
$past = JFactory::getDate(time() - $purge * 86400);
|
||||
$pastStamp = $past->toSql();
|
||||
|
||||
$query = 'DELETE FROM #__messages'
|
||||
. ' WHERE date_time < ' . $db->quote($pastStamp)
|
||||
. ' AND user_id_to = ' . (int) $userid;
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
}
|
26
administrator/includes/defines.php
Normal file
26
administrator/includes/defines.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
*
|
||||
* @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;
|
||||
|
||||
//Global definitions.
|
||||
//Joomla framework path definitions.
|
||||
$parts = explode(DIRECTORY_SEPARATOR, JPATH_BASE);
|
||||
array_pop($parts);
|
||||
|
||||
//Defines.
|
||||
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('JPATH_SITE', JPATH_ROOT);
|
||||
define('JPATH_CONFIGURATION', JPATH_ROOT);
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . '/administrator');
|
||||
define('JPATH_LIBRARIES', JPATH_ROOT . '/libraries');
|
||||
define('JPATH_PLUGINS', JPATH_ROOT . '/plugins');
|
||||
define('JPATH_INSTALLATION', JPATH_ROOT . '/installation');
|
||||
define('JPATH_THEMES', JPATH_BASE . '/templates');
|
||||
define('JPATH_CACHE', JPATH_ROOT . '/cache');
|
||||
define('JPATH_MANIFESTS', JPATH_ADMINISTRATOR . '/manifests');
|
93
administrator/includes/framework.php
Normal file
93
administrator/includes/framework.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
*
|
||||
* @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;
|
||||
|
||||
/*
|
||||
* Joomla! system checks.
|
||||
*/
|
||||
|
||||
@ini_set('magic_quotes_runtime', 0);
|
||||
|
||||
/*
|
||||
* Installation check, and check on removal of the install directory.
|
||||
*/
|
||||
if (!file_exists(JPATH_CONFIGURATION.'/configuration.php') || (filesize(JPATH_CONFIGURATION.'/configuration.php') < 10) || file_exists(JPATH_INSTALLATION.'/index.php'))
|
||||
{
|
||||
header('Location: ../installation/index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
// Joomla system startup.
|
||||
//
|
||||
|
||||
// System includes.
|
||||
require_once JPATH_LIBRARIES.'/import.legacy.php';
|
||||
|
||||
JError::setErrorHandling(E_NOTICE, 'message');
|
||||
JError::setErrorHandling(E_WARNING, 'message');
|
||||
JError::setErrorHandling(E_ERROR, 'message', array('JError', 'customErrorPage'));
|
||||
|
||||
// Botstrap the CMS libraries.
|
||||
require_once JPATH_LIBRARIES.'/cms.php';
|
||||
|
||||
// Pre-Load configuration.
|
||||
ob_start();
|
||||
require_once JPATH_CONFIGURATION.'/configuration.php';
|
||||
ob_end_clean();
|
||||
|
||||
// System configuration.
|
||||
$config = new JConfig;
|
||||
|
||||
// Set the error_reporting
|
||||
switch ($config->error_reporting)
|
||||
{
|
||||
case 'default':
|
||||
case '-1':
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
case '0':
|
||||
error_reporting(0);
|
||||
break;
|
||||
|
||||
case 'simple':
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
ini_set('display_errors', 1);
|
||||
break;
|
||||
|
||||
case 'maximum':
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
break;
|
||||
|
||||
case 'development':
|
||||
error_reporting(-1);
|
||||
ini_set('display_errors', 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
error_reporting($config->error_reporting);
|
||||
ini_set('display_errors', 1);
|
||||
break;
|
||||
}
|
||||
|
||||
define('JDEBUG', $config->debug);
|
||||
|
||||
unset($config);
|
||||
|
||||
/*
|
||||
* Joomla! framework loading.
|
||||
*/
|
||||
|
||||
// System profiler.
|
||||
if (JDEBUG)
|
||||
{
|
||||
$_PROFILER = JProfiler::getInstance('Application');
|
||||
}
|
48
administrator/includes/helper.php
Normal file
48
administrator/includes/helper.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Joomla! Administrator Application helper class.
|
||||
* Provide many supporting API functions.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Application
|
||||
* @since 1.5
|
||||
*/
|
||||
class JAdministratorHelper
|
||||
{
|
||||
/**
|
||||
* Return the application option string [main component].
|
||||
*
|
||||
* @return string The component to access.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function findOption()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$option = strtolower($app->input->get('option'));
|
||||
|
||||
$app->loadIdentity();
|
||||
$user = $app->getIdentity();
|
||||
if ($user->get('guest') || !$user->authorise('core.login.admin'))
|
||||
{
|
||||
$option = 'com_login';
|
||||
}
|
||||
|
||||
if (empty($option))
|
||||
{
|
||||
$option = 'com_cpanel';
|
||||
}
|
||||
|
||||
$app->input->set('option', $option);
|
||||
return $option;
|
||||
}
|
||||
}
|
1
administrator/includes/index.html
Normal file
1
administrator/includes/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
714
administrator/includes/toolbar.php
Normal file
714
administrator/includes/toolbar.php
Normal file
@ -0,0 +1,714 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Utility class for the button bar.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class JToolbarHelper
|
||||
{
|
||||
/**
|
||||
* Title cell.
|
||||
* For the title and toolbar to be rendered correctly,
|
||||
* this title fucntion must be called before the starttable function and the toolbars icons
|
||||
* this is due to the nature of how the css has been used to postion the title in respect to the toolbar.
|
||||
*
|
||||
* @param string $title The title.
|
||||
* @param string $icon The space-separated names of the image.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function title($title, $icon = 'generic.png')
|
||||
{
|
||||
// Strip the extension.
|
||||
$icons = explode(' ', $icon);
|
||||
foreach ($icons as $i => $icon)
|
||||
{
|
||||
$icons[$i] = 'icon-48-' . preg_replace('#\.[^.]*$#', '', $icon);
|
||||
}
|
||||
|
||||
$html = '<div class="pagetitle ' . htmlspecialchars(implode(' ', $icons)) . '"><h2>' . $title . '</h2></div>';
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$app->JComponentTitle = $html;
|
||||
JFactory::getDocument()->setTitle($app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - ' . $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a spacer cell.
|
||||
*
|
||||
* @param string $width The width for the cell
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function spacer($width = '')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a spacer.
|
||||
$bar->appendButton('Separator', 'spacer', $width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a divider between menu buttons
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function divider()
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a divider.
|
||||
$bar->appendButton('Separator', 'divider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a custom option and task button for the button bar.
|
||||
*
|
||||
* @param string $task The task to perform (picked up by the switch($task) blocks.
|
||||
* @param string $icon The image to display.
|
||||
* @param string $iconOver The image to display when moused over.
|
||||
* @param string $alt The alt text for the icon image.
|
||||
* @param bool $listSelect True if required to check that a standard list item is checked.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Strip extension.
|
||||
$icon = preg_replace('#\.[^.]*$#', '', $icon);
|
||||
|
||||
// Add a standard button.
|
||||
$bar->appendButton('Standard', $icon, $alt, $task, $listSelect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a preview button for a given option (opens a popup window).
|
||||
*
|
||||
* @param string $url The name of the popup file (excluding the file extension)
|
||||
* @param bool $updateEditors
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function preview($url = '', $updateEditors = false)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a preview button.
|
||||
$bar->appendButton('Popup', 'preview', 'Preview', $url.'&task=preview');
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a preview button for a given option (opens a popup window).
|
||||
*
|
||||
* @param string $ref The name of the popup file (excluding the file extension for an xml file).
|
||||
* @param bool $com Use the help file in the component directory.
|
||||
* @param string $override Use this URL instead of any other
|
||||
* @param string $component Name of component to get Help (null for current component)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function help($ref, $com = false, $override = null, $component = null)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a help button.
|
||||
$bar->appendButton('Help', $ref, $com, $override, $component);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a cancel button that will go back to the previous page without doing
|
||||
* any other operation.
|
||||
*
|
||||
* @param string $alt Alternative text.
|
||||
* @param string $href URL of the href attribute.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function back($alt = 'JTOOLBAR_BACK', $href = 'javascript:history.back();')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a back button.
|
||||
$bar->appendButton('Link', 'back', $alt, $href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a media_manager button.
|
||||
*
|
||||
* @param string $directory The sub-directory to upload the media to.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function media_manager($directory = '', $alt = 'JTOOLBAR_UPLOAD')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an upload button.
|
||||
$bar->appendButton('Popup', 'upload', $alt, 'index.php?option=com_media&tmpl=component&task=popupUpload&folder=' . $directory, 800, 520);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'default' button for a record.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function makeDefault($task = 'default', $alt = 'JTOOLBAR_DEFAULT')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a default button.
|
||||
$bar->appendButton('Standard', 'default', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'assign' button for a record.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function assign($task = 'assign', $alt = 'JTOOLBAR_ASSIGN')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an assign button.
|
||||
$bar->appendButton('Standard', 'assign', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the common 'new' icon for the button bar.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
* @param boolean $check True if required to check that a standard list item is checked.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function addNew($task = 'add', $alt = 'JTOOLBAR_NEW', $check = false)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a new button.
|
||||
$bar->appendButton('Standard', 'new', $alt, $task, $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'publish' button.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
* @param boolean $check True if required to check that a standard list item is checked.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function publish($task = 'publish', $alt = 'JTOOLBAR_PUBLISH', $check = false)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a publish button.
|
||||
$bar->appendButton('Standard', 'publish', $alt, $task, $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'publish' button for a list of records.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function publishList($task = 'publish', $alt = 'JTOOLBAR_PUBLISH')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a publish button (list).
|
||||
$bar->appendButton('Standard', 'publish', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'unpublish' button.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
* @param boolean $check True if required to check that a standard list item is checked.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function unpublish($task = 'unpublish', $alt = 'JTOOLBAR_UNPUBLISH', $check = false)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an unpublish button
|
||||
$bar->appendButton('Standard', 'unpublish', $alt, $task, $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'unpublish' button for a list of records.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function unpublishList($task = 'unpublish', $alt = 'JTOOLBAR_UNPUBLISH')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an unpublish button (list).
|
||||
$bar->appendButton('Standard', 'unpublish', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'archive' button for a list of records.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function archiveList($task = 'archive', $alt = 'JTOOLBAR_ARCHIVE')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an archive button.
|
||||
$bar->appendButton('Standard', 'archive', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an unarchive button for a list of records.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function unarchiveList($task = 'unarchive', $alt = 'JTOOLBAR_UNARCHIVE')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an unarchive button (list).
|
||||
$bar->appendButton('Standard', 'unarchive', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'edit' button for a list of records.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function editList($task = 'edit', $alt = 'JTOOLBAR_EDIT')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an edit button.
|
||||
$bar->appendButton('Standard', 'edit', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'edit' button for a template html.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function editHtml($task = 'edit_source', $alt = 'JTOOLBAR_EDIT_HTML')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an edit html button.
|
||||
$bar->appendButton('Standard', 'edithtml', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'edit' button for a template css.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function editCss($task = 'edit_css', $alt = 'JTOOLBAR_EDIT_CSS')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an edit css button (hide).
|
||||
$bar->appendButton('Standard', 'editcss', $alt, $task, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a common 'delete' button for a list of records.
|
||||
*
|
||||
* @param string $msg Postscript for the 'are you sure' message.
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function deleteList($msg = '', $task = 'remove', $alt = 'JTOOLBAR_DELETE')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a delete button.
|
||||
if ($msg)
|
||||
{
|
||||
$bar->appendButton('Confirm', $msg, 'delete', $alt, $task, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bar->appendButton('Standard', 'delete', $alt, $task, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a trash button that will move items to Trash Manager.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
* @param bool $check
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function trash($task = 'remove', $alt = 'JTOOLBAR_TRASH', $check = true)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a trash button.
|
||||
$bar->appendButton('Standard', 'trash', $alt, $task, $check, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a save button for a given option.
|
||||
* Apply operation leads to a save action only (does not leave edit mode).
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function apply($task = 'apply', $alt = 'JTOOLBAR_APPLY')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add an apply button
|
||||
$bar->appendButton('Standard', 'apply', $alt, $task, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a save button for a given option.
|
||||
* Save operation leads to a save and then close action.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function save($task = 'save', $alt = 'JTOOLBAR_SAVE')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a save button.
|
||||
$bar->appendButton('Standard', 'save', $alt, $task, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a save and create new button for a given option.
|
||||
* Save and create operation leads to a save and then add action.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function save2new($task = 'save2new', $alt = 'JTOOLBAR_SAVE_AND_NEW')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a save and create new button.
|
||||
$bar->appendButton('Standard', 'save-new', $alt, $task, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a save as copy button for a given option.
|
||||
* Save as copy operation leads to a save after clearing the key,
|
||||
* then returns user to edit mode with new key.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function save2copy($task = 'save2copy', $alt = 'JTOOLBAR_SAVE_AS_COPY')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a save and create new button.
|
||||
$bar->appendButton('Standard', 'save-copy', $alt, $task, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a checkin button for a given option.
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
* @param boolean $check True if required to check that a standard list item is checked.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function checkin($task = 'checkin', $alt = 'JTOOLBAR_CHECKIN', $check = true)
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a save and create new button.
|
||||
$bar->appendButton('Standard', 'checkin', $alt, $task, $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a cancel button and invokes a cancel operation (eg a checkin).
|
||||
*
|
||||
* @param string $task An override for the task.
|
||||
* @param string $alt An override for the alt text.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function cancel($task = 'cancel', $alt = 'JTOOLBAR_CANCEL')
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
// Add a cancel button.
|
||||
$bar->appendButton('Standard', 'cancel', $alt, $task, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a configuration button and invokes a cancel operation (eg a checkin).
|
||||
*
|
||||
* @param string $component The name of the component, eg, com_content.
|
||||
* @param int $height The height of the popup. [UNUSED]
|
||||
* @param int $width The width of the popup. [UNUSED]
|
||||
* @param string $alt The name of the button.
|
||||
* @param string $path An alternative path for the configuation xml relative to JPATH_SITE.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function preferences($component, $height = '550', $width = '875', $alt = 'JToolbar_Options', $path = '')
|
||||
{
|
||||
$component = urlencode($component);
|
||||
$path = urlencode($path);
|
||||
$bar = JToolBar::getInstance('toolbar');
|
||||
|
||||
$uri = (string) JUri::getInstance();
|
||||
$return = urlencode(base64_encode($uri));
|
||||
|
||||
// Add a button linking to config for component.
|
||||
$bar->appendButton('Link', 'options', $alt, 'index.php?option=com_config&view=component&component=' . $component . '&path=' . $path . '&return=' . $return);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class for the submenu.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @since 1.5
|
||||
* @deprecated 4.0 Use JHtmlSidebar instead.
|
||||
*/
|
||||
abstract class JSubMenuHelper
|
||||
{
|
||||
/**
|
||||
* Menu entries
|
||||
*
|
||||
* @var array
|
||||
* @since 3.0
|
||||
* @deprecated 4.0
|
||||
*/
|
||||
protected static $entries = array();
|
||||
|
||||
/**
|
||||
* Filters
|
||||
*
|
||||
* @var array
|
||||
* @since 3.0
|
||||
* @deprecated 4.0
|
||||
*/
|
||||
protected static $filters = array();
|
||||
|
||||
/**
|
||||
* Value for the action attribute of the form.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.0
|
||||
* @deprecated 4.0
|
||||
*/
|
||||
protected static $action = '';
|
||||
|
||||
/**
|
||||
* Method to add a menu item to submenu.
|
||||
*
|
||||
* @param string $name Name of the menu item.
|
||||
* @param string $link URL of the menu item.
|
||||
* @param bool $active True if the item is active, false otherwise.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
* @deprecated 4.0 Use JHtmlSidebar::addEntry() instead.
|
||||
*/
|
||||
public static function addEntry($name, $link = '', $active = false)
|
||||
{
|
||||
JLog::add('JSubMenuHelper::addEntry() is deprecated. Use JHtmlSidebar::addEntry() instead.', JLog::WARNING, 'deprecated');
|
||||
array_push(self::$entries, array($name, $link, $active));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all submenu entries
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.0
|
||||
* @deprecated 4.0 Use JHtmlSidebar::getEntries() instead.
|
||||
*/
|
||||
public static function getEntries()
|
||||
{
|
||||
JLog::add('JSubMenuHelper::getEntries() is deprecated. Use JHtmlSidebar::getEntries() instead.', JLog::WARNING, 'deprecated');
|
||||
return self::$entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add a filter to the submenu
|
||||
*
|
||||
* @param string $label Label for the menu item.
|
||||
* @param string $name name for the filter. Also used as id.
|
||||
* @param string $options options for the select field.
|
||||
* @param bool $noDefault Don't the label as the empty option
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0
|
||||
* @deprecated 4.0 Use JHtmlSidebar::addFilter() instead.
|
||||
*/
|
||||
public static function addFilter($label, $name, $options, $noDefault = false)
|
||||
{
|
||||
JLog::add('JSubMenuHelper::addFilter() is deprecated. Use JHtmlSidebar::addFilter() instead.', JLog::WARNING, 'deprecated');
|
||||
array_push(self::$filters, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all filters
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.0
|
||||
* @deprecated 4.0 Use JHtmlSidebar::getFilters() instead.
|
||||
*/
|
||||
public static function getFilters()
|
||||
{
|
||||
JLog::add('JSubMenuHelper::getFilters() is deprecated. Use JHtmlSidebar::getFilters() instead.', JLog::WARNING, 'deprecated');
|
||||
return self::$filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value for the action attribute of the filter form
|
||||
*
|
||||
* @param string $action Value for the action attribute of the form
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0
|
||||
* @deprecated 4.0 Use JHtmlSidebar::setAction() instead.
|
||||
*/
|
||||
public static function setAction($action)
|
||||
{
|
||||
JLog::add('JSubMenuHelper::setAction() is deprecated. Use JHtmlSidebar::setAction() instead.', JLog::WARNING, 'deprecated');
|
||||
self::$action = $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value for the action attribute of the filter form
|
||||
*
|
||||
* @return string Value for the action attribute of the form
|
||||
*
|
||||
* @since 3.0
|
||||
* @deprecated 4.0 Use JHtmlSidebar::getAction() instead.
|
||||
*/
|
||||
public static function getAction()
|
||||
{
|
||||
JLog::add('JSubMenuHelper::getAction() is deprecated. Use JHtmlSidebar::getAction() instead.', JLog::WARNING, 'deprecated');
|
||||
return self::$action;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user