You've already forked joomla_test
first commit
This commit is contained in:
1
libraries/legacy/access/index.html
Normal file
1
libraries/legacy/access/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
39
libraries/legacy/access/rule.php
Normal file
39
libraries/legacy/access/rule.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Access
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Deprecated class placeholder. You should use JAccessRule instead.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Access
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JRule extends JAccessRule
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The input array must be in the form: array(-42 => true, 3 => true, 4 => false)
|
||||
* or an equivalent JSON encoded string.
|
||||
*
|
||||
* @param mixed $identities A JSON format string (probably from the database) or a named array.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function __construct($identities)
|
||||
{
|
||||
JLog::add('JRule is deprecated. Use JAccessRule instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct($identities);
|
||||
}
|
||||
}
|
39
libraries/legacy/access/rules.php
Normal file
39
libraries/legacy/access/rules.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Access
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Deprecated class placeholder. You should use JAccessRules instead.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Access
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JRules extends JAccessRules
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The input array must be in the form: array('action' => array(-42 => true, 3 => true, 4 => false))
|
||||
* or an equivalent JSON encoded string, or an object where properties are arrays.
|
||||
*
|
||||
* @param mixed $input A JSON format string (probably from the database) or a nested array.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function __construct($input = '')
|
||||
{
|
||||
JLog::add('JRules is deprecated. Use JAccessRules instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct($input);
|
||||
}
|
||||
}
|
1168
libraries/legacy/application/application.php
Normal file
1168
libraries/legacy/application/application.php
Normal file
File diff suppressed because it is too large
Load Diff
46
libraries/legacy/application/cli.php
Normal file
46
libraries/legacy/application/cli.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Application
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Deprecated class placeholder. You should use JApplicationCli instead.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Application
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use JApplicationCli instead.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JCli extends JApplicationCli
|
||||
{
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param mixed $input An optional argument to provide dependency injection for the application's
|
||||
* input object. If the argument is a JInputCli object that object will become
|
||||
* the application's input object, otherwise a default input object is created.
|
||||
* @param mixed $config An optional argument to provide dependency injection for the application's
|
||||
* config object. If the argument is a JRegistry object that object will become
|
||||
* the application's config object, otherwise a default config object is created.
|
||||
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
|
||||
* event dispatcher. If the argument is a JEventDispatcher object that object will become
|
||||
* the application's event dispatcher, if it is null then the default event dispatcher
|
||||
* will be created based on the application's loadDispatcher() method.
|
||||
*
|
||||
* @see loadDispatcher()
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 Use JApplicationCli instead.
|
||||
*/
|
||||
public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
|
||||
{
|
||||
JLog::add('JCli is deprecated. Use JApplicationCli instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct($input, $config, $dispatcher);
|
||||
}
|
||||
}
|
48
libraries/legacy/application/daemon.php
Normal file
48
libraries/legacy/application/daemon.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JDaemon has been renamed to JApplicationDaemon.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* Backward Compatability Stub for JApplicationDaemon
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use JApplicationDaemon instead.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JDaemon extends JApplicationDaemon
|
||||
{
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param mixed $input An optional argument to provide dependency injection for the application's
|
||||
* input object. If the argument is a JInputCli object that object will become
|
||||
* the application's input object, otherwise a default input object is created.
|
||||
* @param mixed $config An optional argument to provide dependency injection for the application's
|
||||
* config object. If the argument is a JRegistry object that object will become
|
||||
* the application's config object, otherwise a default config object is created.
|
||||
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
|
||||
* event dispatcher. If the argument is a JEventDispatcher object that object will become
|
||||
* the application's event dispatcher, if it is null then the default event dispatcher
|
||||
* will be created based on the application's loadDispatcher() method.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 Use JApplicationDaemon instead.
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
|
||||
{
|
||||
JLog::add('JDaemon is deprecated. Use JApplicationDaemon instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct($input, $config, $dispatcher);
|
||||
}
|
||||
}
|
229
libraries/legacy/application/helper.php
Normal file
229
libraries/legacy/application/helper.php
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Application helper functions
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
* @since 11.1
|
||||
*/
|
||||
class JApplicationHelper
|
||||
{
|
||||
/**
|
||||
* Client information array
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static $_clients = null;
|
||||
|
||||
/**
|
||||
* Return the name of the request component [main component]
|
||||
*
|
||||
* @param string $default The default option
|
||||
*
|
||||
* @return string Option (e.g. com_something)
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getComponentName($default = null)
|
||||
{
|
||||
static $option;
|
||||
|
||||
if ($option)
|
||||
{
|
||||
return $option;
|
||||
}
|
||||
|
||||
$input = JFactory::getApplication()->input;
|
||||
$option = strtolower($input->get('option'));
|
||||
|
||||
if (empty($option))
|
||||
{
|
||||
$option = $default;
|
||||
}
|
||||
|
||||
$input->set('option', $option);
|
||||
return $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information on a specific client id. This method will be useful in
|
||||
* future versions when we start mapping applications in the database.
|
||||
*
|
||||
* This method will return a client information array if called
|
||||
* with no arguments which can be used to add custom application information.
|
||||
*
|
||||
* @param integer $id A client identifier
|
||||
* @param boolean $byName If True, find the client by its name
|
||||
*
|
||||
* @return mixed Object describing the client or false if not known
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getClientInfo($id = null, $byName = false)
|
||||
{
|
||||
// Only create the array if it does not exist
|
||||
if (self::$_clients === null)
|
||||
{
|
||||
$obj = new stdClass;
|
||||
|
||||
// Site Client
|
||||
$obj->id = 0;
|
||||
$obj->name = 'site';
|
||||
$obj->path = JPATH_SITE;
|
||||
self::$_clients[0] = clone $obj;
|
||||
|
||||
// Administrator Client
|
||||
$obj->id = 1;
|
||||
$obj->name = 'administrator';
|
||||
$obj->path = JPATH_ADMINISTRATOR;
|
||||
self::$_clients[1] = clone $obj;
|
||||
|
||||
// Installation Client
|
||||
$obj->id = 2;
|
||||
$obj->name = 'installation';
|
||||
$obj->path = JPATH_INSTALLATION;
|
||||
self::$_clients[2] = clone $obj;
|
||||
}
|
||||
|
||||
// If no client id has been passed return the whole array
|
||||
if (is_null($id))
|
||||
{
|
||||
return self::$_clients;
|
||||
}
|
||||
|
||||
// Are we looking for client information by id or by name?
|
||||
if (!$byName)
|
||||
{
|
||||
if (isset(self::$_clients[$id]))
|
||||
{
|
||||
return self::$_clients[$id];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (self::$_clients as $client)
|
||||
{
|
||||
if ($client->name == strtolower($id))
|
||||
{
|
||||
return $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds information for a client.
|
||||
*
|
||||
* @param mixed $client A client identifier either an array or object
|
||||
*
|
||||
* @return boolean True if the information is added. False on error
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function addClientInfo($client)
|
||||
{
|
||||
if (is_array($client))
|
||||
{
|
||||
$client = (object) $client;
|
||||
}
|
||||
|
||||
if (!is_object($client))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$info = self::getClientInfo();
|
||||
|
||||
if (!isset($client->id))
|
||||
{
|
||||
$client->id = count($info);
|
||||
}
|
||||
|
||||
self::$_clients[$client->id] = clone $client;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a XML install manifest file.
|
||||
*
|
||||
* XML Root tag should be 'install' except for languages which use meta file.
|
||||
*
|
||||
* @param string $path Full path to XML file.
|
||||
*
|
||||
* @return array XML metadata.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 13.3 Use JInstaller::parseXMLInstallFile instead.
|
||||
*/
|
||||
public static function parseXMLInstallFile($path)
|
||||
{
|
||||
JLog::add('JApplicationHelper::parseXMLInstallFile is deprecated. Use JInstaller::parseXMLInstallFile instead.', JLog::WARNING, 'deprecated');
|
||||
return JInstaller::parseXMLInstallFile($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a XML language meta file.
|
||||
*
|
||||
* XML Root tag for languages which is meta file.
|
||||
*
|
||||
* @param string $path Full path to XML file.
|
||||
*
|
||||
* @return array XML metadata.
|
||||
*
|
||||
* @deprecated 13.3 Use JInstaller::parseXMLInstallFile instead.
|
||||
*/
|
||||
public static function parseXMLLangMetaFile($path)
|
||||
{
|
||||
JLog::add('JApplicationHelper::parseXMLLangMetaFile is deprecated. Use JInstaller::parseXMLInstallFile instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
// Read the file to see if it's a valid component XML file
|
||||
$xml = simplexml_load_file($path);
|
||||
|
||||
if (!$xml)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for a valid XML root tag.
|
||||
*
|
||||
* Should be 'metafile'.
|
||||
*/
|
||||
if ($xml->getName() != 'metafile')
|
||||
{
|
||||
unset($xml);
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['name'] = (string) $xml->name;
|
||||
$data['type'] = $xml->attributes()->type;
|
||||
|
||||
$data['creationDate'] = ((string) $xml->creationDate) ? (string) $xml->creationDate : JText::_('JLIB_UNKNOWN');
|
||||
$data['author'] = ((string) $xml->author) ? (string) $xml->author : JText::_('JLIB_UNKNOWN');
|
||||
|
||||
$data['copyright'] = (string) $xml->copyright;
|
||||
$data['authorEmail'] = (string) $xml->authorEmail;
|
||||
$data['authorUrl'] = (string) $xml->authorUrl;
|
||||
$data['version'] = (string) $xml->version;
|
||||
$data['description'] = (string) $xml->description;
|
||||
$data['group'] = (string) $xml->group;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
1
libraries/legacy/application/index.html
Normal file
1
libraries/legacy/application/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
libraries/legacy/base/index.html
Normal file
1
libraries/legacy/base/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
157
libraries/legacy/base/node.php
Normal file
157
libraries/legacy/base/node.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Tree Node Class.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JNode extends JObject
|
||||
{
|
||||
/**
|
||||
* Parent node
|
||||
* @var object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_parent = null;
|
||||
|
||||
/**
|
||||
* Array of Children
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_children = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
JLog::add('JNode::__construct() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add child to this node
|
||||
*
|
||||
* If the child already has a parent, the link is unset
|
||||
*
|
||||
* @param JNode &$child The child to be added
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function addChild(&$child)
|
||||
{
|
||||
JLog::add('JNode::addChild() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if ($child instanceof Jnode)
|
||||
{
|
||||
$child->setParent($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent of a this node
|
||||
*
|
||||
* If the node already has a parent, the link is unset
|
||||
*
|
||||
* @param mixed &$parent The JNode for parent to be set or null
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setParent(&$parent)
|
||||
{
|
||||
JLog::add('JNode::setParent() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if ($parent instanceof JNode || is_null($parent))
|
||||
{
|
||||
$hash = spl_object_hash($this);
|
||||
if (!is_null($this->_parent))
|
||||
{
|
||||
unset($this->_parent->children[$hash]);
|
||||
}
|
||||
if (!is_null($parent))
|
||||
{
|
||||
$parent->_children[$hash] = & $this;
|
||||
}
|
||||
$this->_parent = & $parent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the children of this node
|
||||
*
|
||||
* @return array The children
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function &getChildren()
|
||||
{
|
||||
JLog::add('JNode::getChildren() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent of this node
|
||||
*
|
||||
* @return mixed JNode object with the parent or null for no parent
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function &getParent()
|
||||
{
|
||||
JLog::add('JNode::getParent() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this node has children
|
||||
*
|
||||
* @return boolean True if there are children
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function hasChildren()
|
||||
{
|
||||
JLog::add('JNode::hasChildren() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return (bool) count($this->_children);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this node has a parent
|
||||
*
|
||||
* @return boolean True if there is a parent
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function hasParent()
|
||||
{
|
||||
JLog::add('JNode::hasParent() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $this->getParent() != null;
|
||||
}
|
||||
}
|
197
libraries/legacy/base/observable.php
Normal file
197
libraries/legacy/base/observable.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Abstract observable class to implement the observer design pattern
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JObservable extends JObject
|
||||
{
|
||||
/**
|
||||
* An array of Observer objects to notify
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
protected $_observers = array();
|
||||
|
||||
/**
|
||||
* The state of the observable object
|
||||
*
|
||||
* @var mixed
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
protected $_state = null;
|
||||
|
||||
/**
|
||||
* A multi dimensional array of [function][] = key for observers
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
protected $_methods = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Note: Make Sure it's not directly instantiated
|
||||
*
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_observers = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of the JObservable object
|
||||
*
|
||||
* @return mixed The state of the object.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update each attached observer object and return an array of their return values
|
||||
*
|
||||
* @return array Array of return values from the observers
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function notify()
|
||||
{
|
||||
// Iterate through the _observers array
|
||||
foreach ($this->_observers as $observer)
|
||||
{
|
||||
$return[] = $observer->update();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach an observer object
|
||||
*
|
||||
* @param object $observer An observer object to attach
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function attach($observer)
|
||||
{
|
||||
if (is_array($observer))
|
||||
{
|
||||
if (!isset($observer['handler']) || !isset($observer['event']) || !is_callable($observer['handler']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we haven't already attached this array as an observer
|
||||
foreach ($this->_observers as $check)
|
||||
{
|
||||
if (is_array($check) && $check['event'] == $observer['event'] && $check['handler'] == $observer['handler'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_observers[] = $observer;
|
||||
end($this->_observers);
|
||||
$methods = array($observer['event']);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!($observer instanceof JObserver))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we haven't already attached this object as an observer
|
||||
$class = get_class($observer);
|
||||
|
||||
foreach ($this->_observers as $check)
|
||||
{
|
||||
if ($check instanceof $class)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_observers[] = $observer;
|
||||
$methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin'));
|
||||
}
|
||||
|
||||
$key = key($this->_observers);
|
||||
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
$method = strtolower($method);
|
||||
|
||||
if (!isset($this->_methods[$method]))
|
||||
{
|
||||
$this->_methods[$method] = array();
|
||||
}
|
||||
|
||||
$this->_methods[$method][] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach an observer object
|
||||
*
|
||||
* @param object $observer An observer object to detach.
|
||||
*
|
||||
* @return boolean True if the observer object was detached.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function detach($observer)
|
||||
{
|
||||
$retval = false;
|
||||
|
||||
$key = array_search($observer, $this->_observers);
|
||||
|
||||
if ($key !== false)
|
||||
{
|
||||
unset($this->_observers[$key]);
|
||||
$retval = true;
|
||||
|
||||
foreach ($this->_methods as &$method)
|
||||
{
|
||||
$k = array_search($key, $method);
|
||||
|
||||
if ($k !== false)
|
||||
{
|
||||
unset($method[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
60
libraries/legacy/base/observer.php
Normal file
60
libraries/legacy/base/observer.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Abstract observer class to implement the observer design pattern
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
abstract class JObserver extends JObject
|
||||
{
|
||||
/**
|
||||
* Event object to observe.
|
||||
*
|
||||
* @var object
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
protected $_subject = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object &$subject The object to observe.
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public function __construct(&$subject)
|
||||
{
|
||||
// Register the observer ($this) so we can be notified
|
||||
$subject->attach($this);
|
||||
|
||||
// Set the subject to observe
|
||||
$this->_subject = &$subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the state of observable objects
|
||||
*
|
||||
* @param array &$args An array of arguments to pass to the listener.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3
|
||||
*/
|
||||
public abstract function update(&$args);
|
||||
}
|
100
libraries/legacy/base/tree.php
Normal file
100
libraries/legacy/base/tree.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Tree Class.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Base
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JTree extends JObject
|
||||
{
|
||||
/**
|
||||
* Root node
|
||||
*
|
||||
* @var object
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_root = null;
|
||||
|
||||
/**
|
||||
* Current working node
|
||||
*
|
||||
* @var object
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_current = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
JLog::add('JTree::__construct() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$this->_root = new JNode('ROOT');
|
||||
$this->_current = & $this->_root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add a child
|
||||
*
|
||||
* @param array &$node The node to process
|
||||
* @param boolean $setCurrent True to set as current working node
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function addChild(&$node, $setCurrent = false)
|
||||
{
|
||||
JLog::add('JTree::addChild() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$this->_current->addChild($node);
|
||||
if ($setCurrent)
|
||||
{
|
||||
$this->_current = &$node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the parent
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
JLog::add('JTree::getParent() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$this->_current = &$this->_current->getParent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the parent
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
JLog::add('JTree::reset() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$this->_current = &$this->_root;
|
||||
}
|
||||
}
|
994
libraries/legacy/categories/categories.php
Normal file
994
libraries/legacy/categories/categories.php
Normal file
@ -0,0 +1,994 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Categories
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* JCategories Class.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Categories
|
||||
* @since 11.1
|
||||
*/
|
||||
class JCategories
|
||||
{
|
||||
/**
|
||||
* Array to hold the object instances
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
public static $instances = array();
|
||||
|
||||
/**
|
||||
* Array of category nodes
|
||||
*
|
||||
* @var mixed
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_nodes;
|
||||
|
||||
/**
|
||||
* Array of checked categories -- used to save values when _nodes are null
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_checkedCategories;
|
||||
|
||||
/**
|
||||
* Name of the extension the categories belong to
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_extension = null;
|
||||
|
||||
/**
|
||||
* Name of the linked content table to get category content count
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_table = null;
|
||||
|
||||
/**
|
||||
* Name of the category field
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_field = null;
|
||||
|
||||
/**
|
||||
* Name of the key field
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_key = null;
|
||||
|
||||
/**
|
||||
* Name of the items state field
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_statefield = null;
|
||||
|
||||
/**
|
||||
* Array of options
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_options = null;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $options Array of options
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($options)
|
||||
{
|
||||
$this->_extension = $options['extension'];
|
||||
$this->_table = $options['table'];
|
||||
$this->_field = (isset($options['field']) && $options['field']) ? $options['field'] : 'catid';
|
||||
$this->_key = (isset($options['key']) && $options['key']) ? $options['key'] : 'id';
|
||||
$this->_statefield = (isset($options['statefield'])) ? $options['statefield'] : 'state';
|
||||
$options['access'] = (isset($options['access'])) ? $options['access'] : 'true';
|
||||
$options['published'] = (isset($options['published'])) ? $options['published'] : 1;
|
||||
$this->_options = $options;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a JCategories object
|
||||
*
|
||||
* @param string $extension Name of the categories extension
|
||||
* @param array $options An array of options
|
||||
*
|
||||
* @return JCategories JCategories object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getInstance($extension, $options = array())
|
||||
{
|
||||
$hash = md5($extension . serialize($options));
|
||||
|
||||
if (isset(self::$instances[$hash]))
|
||||
{
|
||||
return self::$instances[$hash];
|
||||
}
|
||||
|
||||
$parts = explode('.', $extension);
|
||||
$component = 'com_' . strtolower($parts[0]);
|
||||
$section = count($parts) > 1 ? $parts[1] : '';
|
||||
$classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories';
|
||||
|
||||
if (!class_exists($classname))
|
||||
{
|
||||
$path = JPATH_SITE . '/components/' . $component . '/helpers/category.php';
|
||||
if (is_file($path))
|
||||
{
|
||||
include_once $path;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
self::$instances[$hash] = new $classname($options);
|
||||
|
||||
return self::$instances[$hash];
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a specific category and all its children in a JCategoryNode object
|
||||
*
|
||||
* @param mixed $id an optional id integer or equal to 'root'
|
||||
* @param boolean $forceload True to force the _load method to execute
|
||||
*
|
||||
* @return mixed JCategoryNode object or null if $id is not valid
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function get($id = 'root', $forceload = false)
|
||||
{
|
||||
if ($id !== 'root')
|
||||
{
|
||||
$id = (int) $id;
|
||||
|
||||
if ($id == 0)
|
||||
{
|
||||
$id = 'root';
|
||||
}
|
||||
}
|
||||
|
||||
// If this $id has not been processed yet, execute the _load method
|
||||
if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload)
|
||||
{
|
||||
$this->_load($id);
|
||||
}
|
||||
|
||||
// If we already have a value in _nodes for this $id, then use it.
|
||||
if (isset($this->_nodes[$id]))
|
||||
{
|
||||
return $this->_nodes[$id];
|
||||
}
|
||||
// If we processed this $id already and it was not valid, then return null.
|
||||
elseif (isset($this->_checkedCategories[$id]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load method
|
||||
*
|
||||
* @param integer $id Id of category to load
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _load($id)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$user = JFactory::getUser();
|
||||
$extension = $this->_extension;
|
||||
|
||||
// Record that has this $id has been checked
|
||||
$this->_checkedCategories[$id] = true;
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Right join with c for category
|
||||
$query->select('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
|
||||
c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
|
||||
c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
|
||||
c.path, c.published, c.rgt, c.title, c.modified_user_id, c.version');
|
||||
$case_when = ' CASE WHEN ';
|
||||
$case_when .= $query->charLength('c.alias', '!=', '0');
|
||||
$case_when .= ' THEN ';
|
||||
$c_id = $query->castAsChar('c.id');
|
||||
$case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
|
||||
$case_when .= ' ELSE ';
|
||||
$case_when .= $c_id . ' END as slug';
|
||||
$query->select($case_when)
|
||||
->from('#__categories as c')
|
||||
->where('(c.extension=' . $db->quote($extension) . ' OR c.extension=' . $db->quote('system') . ')');
|
||||
|
||||
if ($this->_options['access'])
|
||||
{
|
||||
$query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
if ($this->_options['published'] == 1)
|
||||
{
|
||||
$query->where('c.published = 1');
|
||||
}
|
||||
|
||||
$query->order('c.lft');
|
||||
|
||||
// Note: s for selected id
|
||||
if ($id != 'root')
|
||||
{
|
||||
// Get the selected category
|
||||
$query->join('LEFT', '#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)')
|
||||
->where('s.id=' . (int) $id);
|
||||
}
|
||||
|
||||
$subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' .
|
||||
'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) .
|
||||
' AND parent.published != 1 GROUP BY cat.id) ';
|
||||
$query->join('LEFT', $subQuery . 'AS badcats ON badcats.id = c.id')
|
||||
->where('badcats.id is null');
|
||||
|
||||
// Note: i for item
|
||||
if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1)
|
||||
{
|
||||
if ($this->_options['published'] == 1)
|
||||
{
|
||||
$query->join(
|
||||
'LEFT',
|
||||
$db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->join('LEFT', $db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id');
|
||||
}
|
||||
|
||||
$query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems');
|
||||
}
|
||||
|
||||
// Group by
|
||||
$query->group(
|
||||
'c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
|
||||
c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
|
||||
c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
|
||||
c.path, c.published, c.rgt, c.title, c.modified_user_id, c.version'
|
||||
);
|
||||
|
||||
// Get the results
|
||||
$db->setQuery($query);
|
||||
$results = $db->loadObjectList('id');
|
||||
$childrenLoaded = false;
|
||||
|
||||
if (count($results))
|
||||
{
|
||||
// Foreach categories
|
||||
foreach ($results as $result)
|
||||
{
|
||||
// Deal with root category
|
||||
if ($result->id == 1)
|
||||
{
|
||||
$result->id = 'root';
|
||||
}
|
||||
|
||||
// Deal with parent_id
|
||||
if ($result->parent_id == 1)
|
||||
{
|
||||
$result->parent_id = 'root';
|
||||
}
|
||||
|
||||
// Create the node
|
||||
if (!isset($this->_nodes[$result->id]))
|
||||
{
|
||||
// Create the JCategoryNode and add to _nodes
|
||||
$this->_nodes[$result->id] = new JCategoryNode($result, $this);
|
||||
|
||||
// If this is not root and if the current node's parent is in the list or the current node parent is 0
|
||||
if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1))
|
||||
{
|
||||
// Compute relationship between node and its parent - set the parent in the _nodes field
|
||||
$this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
|
||||
}
|
||||
|
||||
// If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0),
|
||||
// then remove the node from the list
|
||||
if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0))
|
||||
{
|
||||
unset($this->_nodes[$result->id]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($result->id == $id || $childrenLoaded)
|
||||
{
|
||||
$this->_nodes[$result->id]->setAllLoaded();
|
||||
$childrenLoaded = true;
|
||||
}
|
||||
}
|
||||
elseif ($result->id == $id || $childrenLoaded)
|
||||
{
|
||||
// Create the JCategoryNode
|
||||
$this->_nodes[$result->id] = new JCategoryNode($result, $this);
|
||||
|
||||
if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id))
|
||||
{
|
||||
// Compute relationship between node and its parent
|
||||
$this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
|
||||
}
|
||||
|
||||
if (!isset($this->_nodes[$result->parent_id]))
|
||||
{
|
||||
unset($this->_nodes[$result->id]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($result->id == $id || $childrenLoaded)
|
||||
{
|
||||
$this->_nodes[$result->id]->setAllLoaded();
|
||||
$childrenLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_nodes[$id] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to load Categorytree
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Categories
|
||||
* @since 11.1
|
||||
*/
|
||||
class JCategoryNode extends JObject
|
||||
{
|
||||
/**
|
||||
* Primary key
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $id = null;
|
||||
|
||||
/**
|
||||
* The id of the category in the asset table
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $asset_id = null;
|
||||
|
||||
/**
|
||||
* The id of the parent of category in the asset table, 0 for category root
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $parent_id = null;
|
||||
|
||||
/**
|
||||
* The lft value for this category in the category tree
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $lft = null;
|
||||
|
||||
/**
|
||||
* The rgt value for this category in the category tree
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $rgt = null;
|
||||
|
||||
/**
|
||||
* The depth of this category's position in the category tree
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $level = null;
|
||||
|
||||
/**
|
||||
* The extension this category is associated with
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $extension = null;
|
||||
|
||||
/**
|
||||
* The menu title for the category (a short name)
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $title = null;
|
||||
|
||||
/**
|
||||
* The the alias for the category
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $alias = null;
|
||||
|
||||
/**
|
||||
* Description of the category.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $description = null;
|
||||
|
||||
/**
|
||||
* The publication status of the category
|
||||
*
|
||||
* @var boolean
|
||||
* @since 11.1
|
||||
*/
|
||||
public $published = null;
|
||||
|
||||
/**
|
||||
* Whether the category is or is not checked out
|
||||
*
|
||||
* @var boolean
|
||||
* @since 11.1
|
||||
*/
|
||||
public $checked_out = 0;
|
||||
|
||||
/**
|
||||
* The time at which the category was checked out
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $checked_out_time = 0;
|
||||
|
||||
/**
|
||||
* Access level for the category
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $access = null;
|
||||
|
||||
/**
|
||||
* JSON string of parameters
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $params = null;
|
||||
|
||||
/**
|
||||
* Metadata description
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $metadesc = null;
|
||||
|
||||
/**
|
||||
* Key words for meta data
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $metakey = null;
|
||||
|
||||
/**
|
||||
* JSON string of other meta data
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $metadata = null;
|
||||
|
||||
/**
|
||||
* The ID of the user who created the category
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $created_user_id = null;
|
||||
|
||||
/**
|
||||
* The time at which the category was created
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $created_time = null;
|
||||
|
||||
/**
|
||||
* The ID of the user who last modified the category
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $modified_user_id = null;
|
||||
|
||||
/**
|
||||
* The time at which the category was modified
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $modified_time = null;
|
||||
|
||||
/**
|
||||
* Nmber of times the category has been viewed
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $hits = null;
|
||||
|
||||
/**
|
||||
* The language for the category in xx-XX format
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $language = null;
|
||||
|
||||
/**
|
||||
* Number of items in this category or descendants of this category
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $numitems = null;
|
||||
|
||||
/**
|
||||
* Number of children items
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
public $childrennumitems = null;
|
||||
|
||||
/**
|
||||
* Slug fo the category (used in URL)
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $slug = null;
|
||||
|
||||
/**
|
||||
* Array of assets
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
public $assets = null;
|
||||
|
||||
/**
|
||||
* Parent Category object
|
||||
*
|
||||
* @var object
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_parent = null;
|
||||
|
||||
/**
|
||||
* @var Array of Children
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_children = array();
|
||||
|
||||
/**
|
||||
* Path from root to this category
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_path = array();
|
||||
|
||||
/**
|
||||
* Category left of this one
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_leftSibling = null;
|
||||
|
||||
/**
|
||||
* Category right of this one
|
||||
*
|
||||
* @var
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_rightSibling = null;
|
||||
|
||||
/**
|
||||
* true if all children have been loaded
|
||||
*
|
||||
* @var boolean
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_allChildrenloaded = false;
|
||||
|
||||
/**
|
||||
* Constructor of this tree
|
||||
*
|
||||
* @var
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_constructor = null;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $category The category data.
|
||||
* @param JCategoryNode $constructor The tree constructor.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($category = null, $constructor = null)
|
||||
{
|
||||
if ($category)
|
||||
{
|
||||
$this->setProperties($category);
|
||||
if ($constructor)
|
||||
{
|
||||
$this->_constructor = $constructor;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent of this category
|
||||
*
|
||||
* If the category already has a parent, the link is unset
|
||||
*
|
||||
* @param mixed $parent JCategoryNode for the parent to be set or null
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
if ($parent instanceof JCategoryNode || is_null($parent))
|
||||
{
|
||||
if (!is_null($this->_parent))
|
||||
{
|
||||
$key = array_search($this, $this->_parent->_children);
|
||||
unset($this->_parent->_children[$key]);
|
||||
}
|
||||
|
||||
if (!is_null($parent))
|
||||
{
|
||||
$parent->_children[] = & $this;
|
||||
}
|
||||
|
||||
$this->_parent = $parent;
|
||||
|
||||
if ($this->id != 'root')
|
||||
{
|
||||
if ($this->parent_id != 1)
|
||||
{
|
||||
$this->_path = $parent->getPath();
|
||||
}
|
||||
$this->_path[] = $this->id . ':' . $this->alias;
|
||||
}
|
||||
|
||||
if (count($parent->_children) > 1)
|
||||
{
|
||||
end($parent->_children);
|
||||
$this->_leftSibling = prev($parent->_children);
|
||||
$this->_leftSibling->_rightsibling = & $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add child to this node
|
||||
*
|
||||
* If the child already has a parent, the link is unset
|
||||
*
|
||||
* @param JCategoryNode $child The child to be added.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function addChild($child)
|
||||
{
|
||||
if ($child instanceof JCategoryNode)
|
||||
{
|
||||
$child->setParent($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a specific child
|
||||
*
|
||||
* @param integer $id ID of a category
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function removeChild($id)
|
||||
{
|
||||
$key = array_search($this, $this->_parent->_children);
|
||||
unset($this->_parent->_children[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the children of this node
|
||||
*
|
||||
* @param boolean $recursive False by default
|
||||
*
|
||||
* @return array The children
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function &getChildren($recursive = false)
|
||||
{
|
||||
if (!$this->_allChildrenloaded)
|
||||
{
|
||||
$temp = $this->_constructor->get($this->id, true);
|
||||
if ($temp)
|
||||
{
|
||||
$this->_children = $temp->getChildren();
|
||||
$this->_leftSibling = $temp->getSibling(false);
|
||||
$this->_rightSibling = $temp->getSibling(true);
|
||||
$this->setAllLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
if ($recursive)
|
||||
{
|
||||
$items = array();
|
||||
foreach ($this->_children as $child)
|
||||
{
|
||||
$items[] = $child;
|
||||
$items = array_merge($items, $child->getChildren(true));
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent of this node
|
||||
*
|
||||
* @return mixed JCategoryNode or null
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this node has children
|
||||
*
|
||||
* @return boolean True if there is a child
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function hasChildren()
|
||||
{
|
||||
return count($this->_children);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this node has a parent
|
||||
*
|
||||
* @return boolean True if there is a parent
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function hasParent()
|
||||
{
|
||||
return $this->getParent() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to set the left or right sibling of a category
|
||||
*
|
||||
* @param JCategoryNode $sibling JCategoryNode object for the sibling
|
||||
* @param boolean $right If set to false, the sibling is the left one
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setSibling($sibling, $right = true)
|
||||
{
|
||||
if ($right)
|
||||
{
|
||||
$this->_rightSibling = $sibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_leftSibling = $sibling;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the right or left sibling of a category
|
||||
*
|
||||
* @param boolean $right If set to false, returns the left sibling
|
||||
*
|
||||
* @return mixed JCategoryNode object with the sibling information or
|
||||
* NULL if there is no sibling on that side.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getSibling($right = true)
|
||||
{
|
||||
if (!$this->_allChildrenloaded)
|
||||
{
|
||||
$temp = $this->_constructor->get($this->id, true);
|
||||
$this->_children = $temp->getChildren();
|
||||
$this->_leftSibling = $temp->getSibling(false);
|
||||
$this->_rightSibling = $temp->getSibling(true);
|
||||
$this->setAllLoaded();
|
||||
}
|
||||
|
||||
if ($right)
|
||||
{
|
||||
return $this->_rightSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_leftSibling;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category parameters
|
||||
*
|
||||
* @return JRegistry
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
if (!($this->params instanceof JRegistry))
|
||||
{
|
||||
$temp = new JRegistry;
|
||||
$temp->loadString($this->params);
|
||||
$this->params = $temp;
|
||||
}
|
||||
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category metadata
|
||||
*
|
||||
* @return JRegistry A JRegistry object containing the metadata
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getMetadata()
|
||||
{
|
||||
if (!($this->metadata instanceof JRegistry))
|
||||
{
|
||||
$temp = new JRegistry;
|
||||
$temp->loadString($this->metadata);
|
||||
$this->metadata = $temp;
|
||||
}
|
||||
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category path to the root category
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user that created the category
|
||||
*
|
||||
* @param boolean $modified_user Returns the modified_user when set to true
|
||||
*
|
||||
* @return JUser A JUser object containing a userid
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getAuthor($modified_user = false)
|
||||
{
|
||||
if ($modified_user)
|
||||
{
|
||||
return JFactory::getUser($this->modified_user_id);
|
||||
}
|
||||
|
||||
return JFactory::getUser($this->created_user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to load all children
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setAllLoaded()
|
||||
{
|
||||
$this->_allChildrenloaded = true;
|
||||
foreach ($this->_children as $child)
|
||||
{
|
||||
$child->setAllLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of items.
|
||||
*
|
||||
* @param boolean $recursive If false number of children, if true number of descendants
|
||||
*
|
||||
* @return integer Number of children or descendants
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getNumItems($recursive = false)
|
||||
{
|
||||
if ($recursive)
|
||||
{
|
||||
$count = $this->numitems;
|
||||
|
||||
foreach ($this->getChildren() as $child)
|
||||
{
|
||||
$count = $count + $child->getNumItems(true);
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
return $this->numitems;
|
||||
}
|
||||
}
|
1
libraries/legacy/categories/index.html
Normal file
1
libraries/legacy/categories/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
411
libraries/legacy/component/helper.php
Normal file
411
libraries/legacy/component/helper.php
Normal file
@ -0,0 +1,411 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Component
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Component helper class
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Component
|
||||
* @since 11.1
|
||||
*/
|
||||
class JComponentHelper
|
||||
{
|
||||
/**
|
||||
* The component list cache
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static $components = array();
|
||||
|
||||
/**
|
||||
* Get the component information.
|
||||
*
|
||||
* @param string $option The component option.
|
||||
* @param boolean $strict If set and the component does not exist, the enabled attribute will be set to false.
|
||||
*
|
||||
* @return object An object with the information for the component.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getComponent($option, $strict = false)
|
||||
{
|
||||
if (!isset(self::$components[$option]))
|
||||
{
|
||||
if (self::_load($option))
|
||||
{
|
||||
$result = self::$components[$option];
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = new stdClass;
|
||||
$result->enabled = $strict ? false : true;
|
||||
$result->params = new JRegistry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = self::$components[$option];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the component is enabled
|
||||
*
|
||||
* @param string $option The component option.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function isEnabled($option)
|
||||
{
|
||||
$result = self::getComponent($option, true);
|
||||
|
||||
return $result->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter object for the component
|
||||
*
|
||||
* @param string $option The option for the component.
|
||||
* @param boolean $strict If set and the component does not exist, false will be returned
|
||||
*
|
||||
* @return JRegistry A JRegistry object.
|
||||
*
|
||||
* @see JRegistry
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getParams($option, $strict = false)
|
||||
{
|
||||
$component = self::getComponent($option, $strict);
|
||||
|
||||
return $component->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the global text filters to arbitrary text as per settings for current user groups
|
||||
*
|
||||
* @param string $text The string to filter
|
||||
*
|
||||
* @return string The filtered string
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
public static function filterText($text)
|
||||
{
|
||||
// Filter settings
|
||||
$config = self::getParams('com_config');
|
||||
$user = JFactory::getUser();
|
||||
$userGroups = JAccess::getGroupsByUser($user->get('id'));
|
||||
|
||||
$filters = $config->get('filters');
|
||||
|
||||
$blackListTags = array();
|
||||
$blackListAttributes = array();
|
||||
|
||||
$customListTags = array();
|
||||
$customListAttributes = array();
|
||||
|
||||
$whiteListTags = array();
|
||||
$whiteListAttributes = array();
|
||||
|
||||
$whiteList = false;
|
||||
$blackList = false;
|
||||
$customList = false;
|
||||
$unfiltered = false;
|
||||
|
||||
// Cycle through each of the user groups the user is in.
|
||||
// Remember they are included in the Public group as well.
|
||||
foreach ($userGroups as $groupId)
|
||||
{
|
||||
// May have added a group by not saved the filters.
|
||||
if (!isset($filters->$groupId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Each group the user is in could have different filtering properties.
|
||||
$filterData = $filters->$groupId;
|
||||
$filterType = strtoupper($filterData->filter_type);
|
||||
|
||||
if ($filterType == 'NH')
|
||||
{
|
||||
// Maximum HTML filtering.
|
||||
}
|
||||
elseif ($filterType == 'NONE')
|
||||
{
|
||||
// No HTML filtering.
|
||||
$unfiltered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Black or white list.
|
||||
// Preprocess the tags and attributes.
|
||||
$tags = explode(',', $filterData->filter_tags);
|
||||
$attributes = explode(',', $filterData->filter_attributes);
|
||||
$tempTags = array();
|
||||
$tempAttributes = array();
|
||||
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
$tag = trim($tag);
|
||||
|
||||
if ($tag)
|
||||
{
|
||||
$tempTags[] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
$attribute = trim($attribute);
|
||||
|
||||
if ($attribute)
|
||||
{
|
||||
$tempAttributes[] = $attribute;
|
||||
}
|
||||
}
|
||||
|
||||
// Collect the black or white list tags and attributes.
|
||||
// Each list is cummulative.
|
||||
if ($filterType == 'BL')
|
||||
{
|
||||
$blackList = true;
|
||||
$blackListTags = array_merge($blackListTags, $tempTags);
|
||||
$blackListAttributes = array_merge($blackListAttributes, $tempAttributes);
|
||||
}
|
||||
elseif ($filterType == 'CBL')
|
||||
{
|
||||
// Only set to true if Tags or Attributes were added
|
||||
if ($tempTags || $tempAttributes)
|
||||
{
|
||||
$customList = true;
|
||||
$customListTags = array_merge($customListTags, $tempTags);
|
||||
$customListAttributes = array_merge($customListAttributes, $tempAttributes);
|
||||
}
|
||||
}
|
||||
elseif ($filterType == 'WL')
|
||||
{
|
||||
$whiteList = true;
|
||||
$whiteListTags = array_merge($whiteListTags, $tempTags);
|
||||
$whiteListAttributes = array_merge($whiteListAttributes, $tempAttributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicates before processing (because the black list uses both sets of arrays).
|
||||
$blackListTags = array_unique($blackListTags);
|
||||
$blackListAttributes = array_unique($blackListAttributes);
|
||||
$customListTags = array_unique($customListTags);
|
||||
$customListAttributes = array_unique($customListAttributes);
|
||||
$whiteListTags = array_unique($whiteListTags);
|
||||
$whiteListAttributes = array_unique($whiteListAttributes);
|
||||
|
||||
// Unfiltered assumes first priority.
|
||||
if ($unfiltered)
|
||||
{
|
||||
// Dont apply filtering.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Custom blacklist precedes Default blacklist
|
||||
if ($customList)
|
||||
{
|
||||
$filter = JFilterInput::getInstance(array(), array(), 1, 1);
|
||||
|
||||
// Override filter's default blacklist tags and attributes
|
||||
if ($customListTags)
|
||||
{
|
||||
$filter->tagBlacklist = $customListTags;
|
||||
}
|
||||
if ($customListAttributes)
|
||||
{
|
||||
$filter->attrBlacklist = $customListAttributes;
|
||||
}
|
||||
}
|
||||
// Black lists take second precedence.
|
||||
elseif ($blackList)
|
||||
{
|
||||
// Remove the white-listed tags and attributes from the black-list.
|
||||
$blackListTags = array_diff($blackListTags, $whiteListTags);
|
||||
$blackListAttributes = array_diff($blackListAttributes, $whiteListAttributes);
|
||||
|
||||
$filter = JFilterInput::getInstance($blackListTags, $blackListAttributes, 1, 1);
|
||||
|
||||
// Remove white listed tags from filter's default blacklist
|
||||
if ($whiteListTags)
|
||||
{
|
||||
$filter->tagBlacklist = array_diff($filter->tagBlacklist, $whiteListTags);
|
||||
}
|
||||
// Remove white listed attributes from filter's default blacklist
|
||||
if ($whiteListAttributes)
|
||||
{
|
||||
$filter->attrBlacklist = array_diff($filter->attrBlacklist);
|
||||
}
|
||||
}
|
||||
// White lists take third precedence.
|
||||
elseif ($whiteList)
|
||||
{
|
||||
// Turn off XSS auto clean
|
||||
$filter = JFilterInput::getInstance($whiteListTags, $whiteListAttributes, 0, 0, 0);
|
||||
}
|
||||
// No HTML takes last place.
|
||||
else
|
||||
{
|
||||
$filter = JFilterInput::getInstance();
|
||||
}
|
||||
|
||||
$text = $filter->clean($text, 'html');
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the component.
|
||||
*
|
||||
* @param string $option The component option.
|
||||
* @param array $params The component parameters
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @since 11.1
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function renderComponent($option, $params = array())
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Load template language files.
|
||||
$template = $app->getTemplate(true)->template;
|
||||
$lang = JFactory::getLanguage();
|
||||
$lang->load('tpl_' . $template, JPATH_BASE, null, false, false)
|
||||
|| $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, false)
|
||||
|| $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", $lang->getDefault(), false, false);
|
||||
|
||||
if (empty($option))
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Record the scope
|
||||
$scope = $app->scope;
|
||||
|
||||
// Set scope to component name
|
||||
$app->scope = $option;
|
||||
|
||||
// Build the component path.
|
||||
$option = preg_replace('/[^A-Z0-9_\.-]/i', '', $option);
|
||||
$file = substr($option, 4);
|
||||
|
||||
// Define component path.
|
||||
define('JPATH_COMPONENT', JPATH_BASE . '/components/' . $option);
|
||||
define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/' . $option);
|
||||
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option);
|
||||
|
||||
$path = JPATH_COMPONENT . '/' . $file . '.php';
|
||||
|
||||
// If component is disabled throw error
|
||||
if (!self::isEnabled($option) || !file_exists($path))
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Load common and local language files.
|
||||
$lang->load($option, JPATH_BASE, null, false, false) || $lang->load($option, JPATH_COMPONENT, null, false, false)
|
||||
|| $lang->load($option, JPATH_BASE, $lang->getDefault(), false, false)
|
||||
|| $lang->load($option, JPATH_COMPONENT, $lang->getDefault(), false, false);
|
||||
|
||||
// Handle template preview outlining.
|
||||
$contents = null;
|
||||
|
||||
// Execute the component.
|
||||
$contents = self::executeComponent($path);
|
||||
|
||||
// Revert the scope
|
||||
$app->scope = $scope;
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the component.
|
||||
*
|
||||
* @param string $path The component path.
|
||||
*
|
||||
* @return string The component output
|
||||
*
|
||||
* @since 11.3
|
||||
*/
|
||||
protected static function executeComponent($path)
|
||||
{
|
||||
ob_start();
|
||||
require_once $path;
|
||||
$contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the installed components into the components property.
|
||||
*
|
||||
* @param string $option The element value for the extension
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static function _load($option)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('extension_id AS id, element AS "option", params, enabled')
|
||||
->from('#__extensions')
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($option));
|
||||
$db->setQuery($query);
|
||||
|
||||
$cache = JFactory::getCache('_system', 'callback');
|
||||
|
||||
try
|
||||
{
|
||||
self::$components[$option] = $cache->get(array($db, 'loadObject'), null, $option, false);
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
// Fatal error.
|
||||
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $e->getMessage()), JLog::WARNING, 'jerror');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty(self::$components[$option]))
|
||||
{
|
||||
// Fatal error.
|
||||
$error = JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND');
|
||||
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $error), JLog::WARNING, 'jerror');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert the params to an object.
|
||||
if (is_string(self::$components[$option]->params))
|
||||
{
|
||||
$temp = new JRegistry;
|
||||
$temp->loadString(self::$components[$option]->params);
|
||||
self::$components[$option]->params = $temp;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
1
libraries/legacy/component/index.html
Normal file
1
libraries/legacy/component/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
377
libraries/legacy/controller/admin.php
Normal file
377
libraries/legacy/controller/admin.php
Normal file
@ -0,0 +1,377 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Controller
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Base class for a Joomla Administrator Controller
|
||||
*
|
||||
* Controller (controllers are where you put all the actual code) Provides basic
|
||||
* functionality, such as rendering views (aka displaying templates).
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Controller
|
||||
* @since 12.2
|
||||
*/
|
||||
class JControllerAdmin extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* The URL option for the component.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $option;
|
||||
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $text_prefix;
|
||||
|
||||
/**
|
||||
* The URL view list variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $view_list;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @see JControllerLegacy
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
// Define standard task mappings.
|
||||
|
||||
// Value = 0
|
||||
$this->registerTask('unpublish', 'publish');
|
||||
|
||||
// Value = 2
|
||||
$this->registerTask('archive', 'publish');
|
||||
|
||||
// Value = -2
|
||||
$this->registerTask('trash', 'publish');
|
||||
|
||||
// Value = -3
|
||||
$this->registerTask('report', 'publish');
|
||||
$this->registerTask('orderup', 'reorder');
|
||||
$this->registerTask('orderdown', 'reorder');
|
||||
|
||||
// Guess the option as com_NameOfController.
|
||||
if (empty($this->option))
|
||||
{
|
||||
$this->option = 'com_' . strtolower($this->getName());
|
||||
}
|
||||
|
||||
// Guess the JText message prefix. Defaults to the option.
|
||||
if (empty($this->text_prefix))
|
||||
{
|
||||
$this->text_prefix = strtoupper($this->option);
|
||||
}
|
||||
|
||||
// Guess the list view as the suffix, eg: OptionControllerSuffix.
|
||||
if (empty($this->view_list))
|
||||
{
|
||||
$r = null;
|
||||
if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r))
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500);
|
||||
}
|
||||
$this->view_list = strtolower($r[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an item.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Get items to remove from the request.
|
||||
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
|
||||
|
||||
if (!is_array($cid) || count($cid) < 1)
|
||||
{
|
||||
JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the model.
|
||||
$model = $this->getModel();
|
||||
|
||||
// Make sure the item ids are integers
|
||||
jimport('joomla.utilities.arrayhelper');
|
||||
JArrayHelper::toInteger($cid);
|
||||
|
||||
// Remove the items.
|
||||
if ($model->delete($cid))
|
||||
{
|
||||
$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setMessage($model->getError());
|
||||
}
|
||||
}
|
||||
// Invoke the postDelete method to allow for the child class to access the model.
|
||||
$this->postDeleteHook($model, $cid);
|
||||
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data
|
||||
* after the item has been deleted.
|
||||
*
|
||||
* @param JModelLegacy $model The data model object.
|
||||
* @param integer $id The validated data.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function postDeleteHook(JModelLegacy $model, $id = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Display is not supported by this controller.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return JControllerLegacy A JControllerLegacy object to support chaining.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = array())
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to publish a list of items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function publish()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Get items to publish from the request.
|
||||
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
|
||||
$data = array('publish' => 1, 'unpublish' => 0, 'archive' => 2, 'trash' => -2, 'report' => -3);
|
||||
$task = $this->getTask();
|
||||
$value = JArrayHelper::getValue($data, $task, 0, 'int');
|
||||
|
||||
if (empty($cid))
|
||||
{
|
||||
JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the model.
|
||||
$model = $this->getModel();
|
||||
|
||||
// Make sure the item ids are integers
|
||||
JArrayHelper::toInteger($cid);
|
||||
|
||||
// Publish the items.
|
||||
try
|
||||
{
|
||||
$model->publish($cid, $value);
|
||||
|
||||
if ($value == 1)
|
||||
{
|
||||
$ntext = $this->text_prefix . '_N_ITEMS_PUBLISHED';
|
||||
}
|
||||
elseif ($value == 0)
|
||||
{
|
||||
$ntext = $this->text_prefix . '_N_ITEMS_UNPUBLISHED';
|
||||
}
|
||||
elseif ($value == 2)
|
||||
{
|
||||
$ntext = $this->text_prefix . '_N_ITEMS_ARCHIVED';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ntext = $this->text_prefix . '_N_ITEMS_TRASHED';
|
||||
}
|
||||
$this->setMessage(JText::plural($ntext, count($cid)));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->setMessage(JText::_('JLIB_DATABASE_ERROR_ANCESTOR_NODES_LOWER_STATE'), 'error');
|
||||
}
|
||||
|
||||
}
|
||||
$extension = $this->input->get('extension');
|
||||
$extensionURL = ($extension) ? '&extension=' . $extension : '';
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the order of one or more records.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function reorder()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$ids = JFactory::getApplication()->input->post->get('cid', array(), 'array');
|
||||
$inc = ($this->getTask() == 'orderup') ? -1 : +1;
|
||||
|
||||
$model = $this->getModel();
|
||||
$return = $model->reorder($ids, $inc);
|
||||
if ($return === false)
|
||||
{
|
||||
// Reorder failed.
|
||||
$message = JText::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError());
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reorder succeeded.
|
||||
$message = JText::_('JLIB_APPLICATION_SUCCESS_ITEM_REORDERED');
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the submitted ordering values for records.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function saveorder()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Get the input
|
||||
$pks = $this->input->post->get('cid', array(), 'array');
|
||||
$order = $this->input->post->get('order', array(), 'array');
|
||||
|
||||
// Sanitize the input
|
||||
JArrayHelper::toInteger($pks);
|
||||
JArrayHelper::toInteger($order);
|
||||
|
||||
// Get the model
|
||||
$model = $this->getModel();
|
||||
|
||||
// Save the ordering
|
||||
$return = $model->saveorder($pks, $order);
|
||||
|
||||
if ($return === false)
|
||||
{
|
||||
// Reorder failed
|
||||
$message = JText::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError());
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reorder succeeded.
|
||||
$this->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED'));
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check in of one or more records.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function checkin()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$ids = JFactory::getApplication()->input->post->get('cid', array(), 'array');
|
||||
|
||||
$model = $this->getModel();
|
||||
$return = $model->checkin($ids);
|
||||
if ($return === false)
|
||||
{
|
||||
// Checkin failed.
|
||||
$message = JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError());
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Checkin succeeded.
|
||||
$message = JText::plural($this->text_prefix . '_N_ITEMS_CHECKED_IN', count($ids));
|
||||
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the submitted ordering values for records via AJAX.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function saveOrderAjax()
|
||||
{
|
||||
// Get the input
|
||||
$pks = $this->input->post->get('cid', array(), 'array');
|
||||
$order = $this->input->post->get('order', array(), 'array');
|
||||
|
||||
// Sanitize the input
|
||||
JArrayHelper::toInteger($pks);
|
||||
JArrayHelper::toInteger($order);
|
||||
|
||||
// Get the model
|
||||
$model = $this->getModel();
|
||||
|
||||
// Save the ordering
|
||||
$return = $model->saveorder($pks, $order);
|
||||
|
||||
if ($return)
|
||||
{
|
||||
echo "1";
|
||||
}
|
||||
|
||||
// Close the application
|
||||
JFactory::getApplication()->close();
|
||||
}
|
||||
}
|
792
libraries/legacy/controller/form.php
Normal file
792
libraries/legacy/controller/form.php
Normal file
@ -0,0 +1,792 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Controller
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Controller tailored to suit most form-based admin operations.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Controller
|
||||
* @since 12.2
|
||||
* @todo Add ability to set redirect manually to better cope with frontend usage.
|
||||
*/
|
||||
class JControllerForm extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* The context for storing internal data, e.g. record.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* The URL option for the component.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $option;
|
||||
|
||||
/**
|
||||
* The URL view item variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $view_item;
|
||||
|
||||
/**
|
||||
* The URL view list variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $view_list;
|
||||
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $text_prefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @see JControllerLegacy
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
// Guess the option as com_NameOfController
|
||||
if (empty($this->option))
|
||||
{
|
||||
$this->option = 'com_' . strtolower($this->getName());
|
||||
}
|
||||
|
||||
// Guess the JText message prefix. Defaults to the option.
|
||||
if (empty($this->text_prefix))
|
||||
{
|
||||
$this->text_prefix = strtoupper($this->option);
|
||||
}
|
||||
|
||||
// Guess the context as the suffix, eg: OptionControllerContent.
|
||||
if (empty($this->context))
|
||||
{
|
||||
$r = null;
|
||||
if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r))
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500);
|
||||
}
|
||||
$this->context = strtolower($r[2]);
|
||||
}
|
||||
|
||||
// Guess the item view as the context.
|
||||
if (empty($this->view_item))
|
||||
{
|
||||
$this->view_item = $this->context;
|
||||
}
|
||||
|
||||
// Guess the list view as the plural of the item view.
|
||||
if (empty($this->view_list))
|
||||
{
|
||||
// @TODO Probably worth moving to an inflector class based on
|
||||
// http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
|
||||
|
||||
// Simple pluralisation based on public domain snippet by Paul Osman
|
||||
// For more complex types, just manually set the variable in your class.
|
||||
$plural = array(
|
||||
array('/(x|ch|ss|sh)$/i', "$1es"),
|
||||
array('/([^aeiouy]|qu)y$/i', "$1ies"),
|
||||
array('/([^aeiouy]|qu)ies$/i', "$1y"),
|
||||
array('/(bu)s$/i', "$1ses"),
|
||||
array('/s$/i', "s"),
|
||||
array('/$/', "s"));
|
||||
|
||||
// Check for matches using regular expressions
|
||||
foreach ($plural as $pattern)
|
||||
{
|
||||
if (preg_match($pattern[0], $this->view_item))
|
||||
{
|
||||
$this->view_list = preg_replace($pattern[0], $pattern[1], $this->view_item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply, Save & New, and Save As copy should be standard on forms.
|
||||
$this->registerTask('apply', 'save');
|
||||
$this->registerTask('save2new', 'save');
|
||||
$this->registerTask('save2copy', 'save');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add a new record.
|
||||
*
|
||||
* @return mixed True if the record can be added, a error object if not.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$context = "$this->option.edit.$this->context";
|
||||
|
||||
// Access check.
|
||||
if (!$this->allowAdd())
|
||||
{
|
||||
// Set the internal error and also the redirect error.
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED'));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list
|
||||
. $this->getRedirectToListAppend(), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the record edit information from the session.
|
||||
$app->setUserState($context . '.data', null);
|
||||
|
||||
// Redirect to the edit screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend(), false
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if you can add a new record.
|
||||
*
|
||||
* Extended classes can override this if necessary.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
return ($user->authorise('core.create', $this->option) || count($user->getAuthorisedCategories($this->option, 'core.create')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if you can add a new record.
|
||||
*
|
||||
* Extended classes can override this if necessary.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key; default is id.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
return JFactory::getUser()->authorise('core.edit', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if you can save a new or existing record.
|
||||
*
|
||||
* Extended classes can override this if necessary.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function allowSave($data, $key = 'id')
|
||||
{
|
||||
$recordId = isset($data[$key]) ? $data[$key] : '0';
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
return $this->allowEdit($data, $key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->allowAdd($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param JModelLegacy $model The model of the component being processed.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function batch($model)
|
||||
{
|
||||
$vars = $this->input->post->get('batch', array(), 'array');
|
||||
$cid = $this->input->post->get('cid', array(), 'array');
|
||||
|
||||
// Build an array of item contexts to check
|
||||
$contexts = array();
|
||||
foreach ($cid as $id)
|
||||
{
|
||||
// If we're coming from com_categories, we need to use extension vs. option
|
||||
if (isset($this->extension))
|
||||
{
|
||||
$option = $this->extension;
|
||||
}
|
||||
else
|
||||
{
|
||||
$option = $this->option;
|
||||
}
|
||||
$contexts[$id] = $option . '.' . $this->context . '.' . $id;
|
||||
}
|
||||
|
||||
// Attempt to run the batch operation.
|
||||
if ($model->batch($vars, $cid, $contexts))
|
||||
{
|
||||
$this->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_BATCH'));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_FAILED', $model->getError()), 'warning');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return boolean True if access level checks pass, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function cancel($key = null)
|
||||
{
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$model = $this->getModel();
|
||||
$table = $model->getTable();
|
||||
$checkin = property_exists($table, 'checked_out');
|
||||
$context = "$this->option.edit.$this->context";
|
||||
|
||||
if (empty($key))
|
||||
{
|
||||
$key = $table->getKeyName();
|
||||
}
|
||||
|
||||
$recordId = $app->input->getInt($key);
|
||||
|
||||
// Attempt to check-in the current record.
|
||||
if ($recordId)
|
||||
{
|
||||
// Check we are holding the id in the edit list.
|
||||
if (!$this->checkEditId($context, $recordId))
|
||||
{
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list
|
||||
. $this->getRedirectToListAppend(), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($checkin)
|
||||
{
|
||||
if ($model->checkin($recordId) === false)
|
||||
{
|
||||
// Check-in failed, go back to the record and display a notice.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend($recordId, $key), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the session data and redirect.
|
||||
$this->releaseEditId($context, $recordId);
|
||||
$app->setUserState($context . '.data', null);
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list
|
||||
. $this->getRedirectToListAppend(), false
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to edit an existing record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key
|
||||
* (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if access level check and checkout passes, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function edit($key = null, $urlVar = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$model = $this->getModel();
|
||||
$table = $model->getTable();
|
||||
$cid = $this->input->post->get('cid', array(), 'array');
|
||||
$context = "$this->option.edit.$this->context";
|
||||
|
||||
// Determine the name of the primary key for the data.
|
||||
if (empty($key))
|
||||
{
|
||||
$key = $table->getKeyName();
|
||||
}
|
||||
|
||||
// To avoid data collisions the urlVar may be different from the primary key.
|
||||
if (empty($urlVar))
|
||||
{
|
||||
$urlVar = $key;
|
||||
}
|
||||
|
||||
// Get the previous record id (if any) and the current record id.
|
||||
$recordId = (int) (count($cid) ? $cid[0] : $this->input->getInt($urlVar));
|
||||
$checkin = property_exists($table, 'checked_out');
|
||||
|
||||
// Access check.
|
||||
if (!$this->allowEdit(array($key => $recordId), $key))
|
||||
{
|
||||
$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 false;
|
||||
}
|
||||
|
||||
// Attempt to check-out the new record for editing and redirect.
|
||||
if ($checkin && !$model->checkout($recordId))
|
||||
{
|
||||
// Check-out failed, display a notice but allow the user to see the record.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKOUT_FAILED', $model->getError()));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend($recordId, $urlVar), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check-out succeeded, push the new record id into the session.
|
||||
$this->holdEditId($context, $recordId);
|
||||
$app->setUserState($context . '.data', null);
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend($recordId, $urlVar), false
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 12.2
|
||||
*/
|
||||
public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true))
|
||||
{
|
||||
if (empty($name))
|
||||
{
|
||||
$name = $this->context;
|
||||
}
|
||||
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
|
||||
{
|
||||
$tmpl = $this->input->get('tmpl');
|
||||
$layout = $this->input->get('layout', 'edit');
|
||||
$append = '';
|
||||
|
||||
// Setup redirect info.
|
||||
if ($tmpl)
|
||||
{
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
if ($layout)
|
||||
{
|
||||
$append .= '&layout=' . $layout;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
$append .= '&' . $urlVar . '=' . $recordId;
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to a list redirect.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getRedirectToListAppend()
|
||||
{
|
||||
$tmpl = JFactory::getApplication()->input->get('tmpl');
|
||||
$append = '';
|
||||
|
||||
// Setup redirect info.
|
||||
if ($tmpl)
|
||||
{
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data
|
||||
* after the data has been saved.
|
||||
*
|
||||
* @param JModelLegacy $model The data model object.
|
||||
* @param array $validData The validated data.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function postSaveHook(JModelLegacy $model, $validData = array())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if successful, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function save($key = null, $urlVar = null)
|
||||
{
|
||||
// Check for request forgeries.
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$lang = JFactory::getLanguage();
|
||||
$model = $this->getModel();
|
||||
$table = $model->getTable();
|
||||
$data = $this->input->post->get('jform', array(), 'array');
|
||||
$checkin = property_exists($table, 'checked_out');
|
||||
$context = "$this->option.edit.$this->context";
|
||||
$task = $this->getTask();
|
||||
|
||||
// Determine the name of the primary key for the data.
|
||||
if (empty($key))
|
||||
{
|
||||
$key = $table->getKeyName();
|
||||
}
|
||||
|
||||
// To avoid data collisions the urlVar may be different from the primary key.
|
||||
if (empty($urlVar))
|
||||
{
|
||||
$urlVar = $key;
|
||||
}
|
||||
|
||||
$recordId = $this->input->getInt($urlVar);
|
||||
|
||||
if (!$this->checkEditId($context, $recordId))
|
||||
{
|
||||
// Somehow the person just went to the form and tried to save it. We don't allow that.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list
|
||||
. $this->getRedirectToListAppend(), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Populate the row id from the session.
|
||||
$data[$key] = $recordId;
|
||||
|
||||
// The save2copy task needs to be handled slightly differently.
|
||||
if ($task == 'save2copy')
|
||||
{
|
||||
// Check-in the original row.
|
||||
if ($checkin && $model->checkin($data[$key]) === false)
|
||||
{
|
||||
// Check-in failed. Go back to the item and display a notice.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend($recordId, $urlVar), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the ID and then treat the request as for Apply.
|
||||
$data[$key] = 0;
|
||||
$task = 'apply';
|
||||
}
|
||||
|
||||
// Access check.
|
||||
if (!$this->allowSave($data, $key))
|
||||
{
|
||||
$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 false;
|
||||
}
|
||||
|
||||
// Validate the posted data.
|
||||
// Sometimes the form needs some posted data, such as for plugins and modules.
|
||||
$form = $model->getForm($data, false);
|
||||
|
||||
if (!$form)
|
||||
{
|
||||
$app->enqueueMessage($model->getError(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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, $urlVar), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($validData['tags']))
|
||||
{
|
||||
$validData['tags'] = null;
|
||||
}
|
||||
|
||||
// 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, $urlVar), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save succeeded, so check-in the record.
|
||||
if ($checkin && $model->checkin($validData[$key]) === false)
|
||||
{
|
||||
// Save the data in the session.
|
||||
$app->setUserState($context . '.data', $validData);
|
||||
|
||||
// Check-in failed, so go back to the record and display a notice.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend($recordId, $urlVar), false
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setMessage(
|
||||
JText::_(
|
||||
($lang->hasKey($this->text_prefix . ($recordId == 0 && $app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS')
|
||||
? $this->text_prefix
|
||||
: 'JLIB_APPLICATION') . ($recordId == 0 && $app->isSite() ? '_SUBMIT' : '') . '_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.
|
||||
$recordId = $model->getState($this->context . '.id');
|
||||
$this->holdEditId($context, $recordId);
|
||||
$app->setUserState($context . '.data', null);
|
||||
$model->checkout($recordId);
|
||||
|
||||
// Redirect back to the edit screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item
|
||||
. $this->getRedirectToItemAppend($recordId, $urlVar), false
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'save2new':
|
||||
// Clear the record id and data from the session.
|
||||
$this->releaseEditId($context, $recordId);
|
||||
$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, $urlVar), false
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Clear the record id and data from the session.
|
||||
$this->releaseEditId($context, $recordId);
|
||||
$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;
|
||||
}
|
||||
|
||||
// Invoke the postSave method to allow for the child class to access the model.
|
||||
$this->postSaveHook($model, $validData);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
1
libraries/legacy/controller/index.html
Normal file
1
libraries/legacy/controller/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1090
libraries/legacy/controller/legacy.php
Normal file
1090
libraries/legacy/controller/legacy.php
Normal file
File diff suppressed because it is too large
Load Diff
24
libraries/legacy/database/exception.php
Normal file
24
libraries/legacy/database/exception.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JDatabaseException is deprecated, use SPL Exceptions instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* Exception class definition for the Database subpackage.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use semantic exceptions instead
|
||||
*/
|
||||
class JDatabaseException extends RuntimeException
|
||||
{
|
||||
}
|
1
libraries/legacy/database/index.html
Normal file
1
libraries/legacy/database/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
25
libraries/legacy/database/mysql.php
Normal file
25
libraries/legacy/database/mysql.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JDatabaseMysql is deprecated, use JDatabaseDriverMysql instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* MySQL database driver
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
* @see http://dev.mysql.com/doc/
|
||||
* @since 11.1
|
||||
* @deprecated 13.1 (Platform) & 4.0 (CMS) - Use JDatabaseDriverMysql instead.
|
||||
*/
|
||||
class JDatabaseMysql extends JDatabaseDriverMysql
|
||||
{
|
||||
}
|
25
libraries/legacy/database/mysqli.php
Normal file
25
libraries/legacy/database/mysqli.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JDatabaseMysqli is deprecated, use JDatabaseDriverMysqli instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* MySQLi database driver
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
* @see http://php.net/manual/en/book.mysqli.php
|
||||
* @since 11.1
|
||||
* @deprecated 13.1 (Platform) & 4.0 (CMS) - Use JDatabaseDriverMysqli instead.
|
||||
*/
|
||||
class JDatabaseMysqli extends JDatabaseDriverMysqli
|
||||
{
|
||||
}
|
25
libraries/legacy/database/sqlazure.php
Normal file
25
libraries/legacy/database/sqlazure.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JDatabaseSqlazure is deprecated, use JDatabaseDriverSqlazure instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* SQL Server database driver
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee336279.aspx
|
||||
* @since 11.1
|
||||
* @deprecated 13.1 (Platform) & 4.0 (CMS) - Use JDatabaseDriverSqlazure instead.
|
||||
*/
|
||||
class JDatabaseSqlazure extends JDatabaseDriverSqlazure
|
||||
{
|
||||
}
|
25
libraries/legacy/database/sqlsrv.php
Normal file
25
libraries/legacy/database/sqlsrv.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JDatabaseSqlsrv is deprecated, use JDatabaseDriverSqlsrv instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* SQL Server database driver
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Database
|
||||
* @see http://msdn.microsoft.com/en-us/library/cc296152(SQL.90).aspx
|
||||
* @since 11.1
|
||||
* @deprecated 13.1 (Platform) & 4.0 (CMS) - Use JDatabaseDriverSqlsrv instead.
|
||||
*/
|
||||
class JDatabaseSqlsrv extends JDatabaseDriverSqlsrv
|
||||
{
|
||||
}
|
33
libraries/legacy/dispatcher/dispatcher.php
Normal file
33
libraries/legacy/dispatcher/dispatcher.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Dispatcher
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Deprecated class placeholder. You should use JEventDispatcher instead.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Dispatcher
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JDispatcher extends JEventDispatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
JLog::add('JDispatcher is deprecated. Use JEventDispatcher instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
1
libraries/legacy/dispatcher/index.html
Normal file
1
libraries/legacy/dispatcher/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
885
libraries/legacy/error/error.php
Normal file
885
libraries/legacy/error/error.php
Normal file
@ -0,0 +1,885 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Error
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
// Error Definition: Illegal Options
|
||||
const JERROR_ILLEGAL_OPTIONS = 1;
|
||||
|
||||
// Error Definition: Callback does not exist
|
||||
const JERROR_CALLBACK_NOT_CALLABLE = 2;
|
||||
|
||||
// Error Definition: Illegal Handler
|
||||
const JERROR_ILLEGAL_MODE = 3;
|
||||
|
||||
/**
|
||||
* Error Handling Class
|
||||
*
|
||||
* This class is inspired in design and concept by patErrorManager <http://www.php-tools.net>
|
||||
*
|
||||
* patErrorManager contributors include:
|
||||
* - gERD Schaufelberger <gerd@php-tools.net>
|
||||
* - Sebastian Mordziol <argh@php-tools.net>
|
||||
* - Stephan Schmidt <scst@php-tools.net>
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Error
|
||||
* @since 11.1
|
||||
* @deprecated 12.1 (Platform) & 4.0 (CMS) - Use PHP Exception
|
||||
*/
|
||||
abstract class JError
|
||||
{
|
||||
/**
|
||||
* Legacy error handling marker
|
||||
*
|
||||
* @var boolean True to enable legacy error handling using JError, false to use exception handling. This flag
|
||||
* is present to allow an easy transition into exception handling for code written against the
|
||||
* existing JError API in Joomla.
|
||||
* @since 11.1
|
||||
*/
|
||||
public static $legacy = false;
|
||||
|
||||
/**
|
||||
* Array of message levels
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static $levels = array(E_NOTICE => 'Notice', E_WARNING => 'Warning', E_ERROR => 'Error');
|
||||
|
||||
protected static $handlers = array(
|
||||
E_NOTICE => array('mode' => 'ignore'),
|
||||
E_WARNING => array('mode' => 'ignore'),
|
||||
E_ERROR => array('mode' => 'ignore')
|
||||
);
|
||||
|
||||
protected static $stack = array();
|
||||
|
||||
/**
|
||||
* Method to determine if a value is an exception object.
|
||||
*
|
||||
* @param mixed $object Object to check.
|
||||
*
|
||||
* @return boolean True if argument is an exception, false otherwise.
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function isError($object)
|
||||
{
|
||||
JLog::add('JError::isError() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $object instanceof Exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for retrieving the last exception object in the error stack
|
||||
*
|
||||
* @param boolean $unset True to remove the error from the stack.
|
||||
*
|
||||
* @return mixed Last exception object in the error stack or boolean false if none exist
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getError($unset = false)
|
||||
{
|
||||
JLog::add('JError::getError() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if (!isset(self::$stack[0]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($unset)
|
||||
{
|
||||
$error = array_shift(self::$stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = &self::$stack[0];
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for retrieving the exception stack
|
||||
*
|
||||
* @return array Chronological array of errors that have been stored during script execution
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getErrors()
|
||||
{
|
||||
JLog::add('JError::getErrors() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return self::$stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add non-JError thrown JExceptions to the JError stack for debugging purposes
|
||||
*
|
||||
* @param JException &$e Add an exception to the stack.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function addToStack(JException &$e)
|
||||
{
|
||||
JLog::add('JError::addToStack() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
self::$stack[] = &$e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new JException object given the passed arguments
|
||||
*
|
||||
* @param integer $level The error level - use any of PHP's own error levels for
|
||||
* this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
|
||||
* E_USER_WARNING, E_USER_NOTICE.
|
||||
* @param string $code The application-internal error code for this error
|
||||
* @param string $msg The error message, which may also be shown the user if need be.
|
||||
* @param mixed $info Optional: Additional error information (usually only
|
||||
* developer-relevant information that the user should never see,
|
||||
* like a database DSN).
|
||||
* @param boolean $backtrace Add a stack backtrace to the exception.
|
||||
*
|
||||
* @return mixed The JException object
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @see JException
|
||||
*/
|
||||
public static function raise($level, $code, $msg, $info = null, $backtrace = false)
|
||||
{
|
||||
JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
// Build error object
|
||||
$exception = new JException($msg, $code, $level, $info, $backtrace);
|
||||
return self::throwError($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error
|
||||
*
|
||||
* @param object &$exception An exception to throw.
|
||||
*
|
||||
* @return reference
|
||||
*
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @see JException
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function throwError(&$exception)
|
||||
{
|
||||
JLog::add('JError::throwError() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
static $thrown = false;
|
||||
|
||||
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
|
||||
if ($thrown)
|
||||
{
|
||||
self::handleEcho($exception, array());
|
||||
|
||||
// Inifite loop.
|
||||
jexit();
|
||||
}
|
||||
|
||||
$thrown = true;
|
||||
$level = $exception->get('level');
|
||||
|
||||
// See what to do with this kind of error
|
||||
$handler = self::getErrorHandling($level);
|
||||
|
||||
$function = 'handle' . ucfirst($handler['mode']);
|
||||
if (is_callable(array('JError', $function)))
|
||||
{
|
||||
$reference = call_user_func_array(array('JError', $function), array(&$exception, (isset($handler['options'])) ? $handler['options'] : array()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is required to prevent a very unhelpful white-screen-of-death
|
||||
jexit(
|
||||
'JError::raise -> Static method JError::' . $function . ' does not exist. Contact a developer to debug' .
|
||||
'<br /><strong>Error was</strong> <br />' . $exception->getMessage()
|
||||
);
|
||||
}
|
||||
// We don't need to store the error, since JException already does that for us!
|
||||
// Remove loop check
|
||||
$thrown = false;
|
||||
|
||||
return $reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method for the raise() method with predefined error level of E_ERROR and backtrace set to true.
|
||||
*
|
||||
* @param string $code The application-internal error code for this error
|
||||
* @param string $msg The error message, which may also be shown the user if need be.
|
||||
* @param mixed $info Optional: Additional error information (usually only
|
||||
* developer-relevant information that the user should
|
||||
* never see, like a database DSN).
|
||||
*
|
||||
* @return object $error The configured JError object
|
||||
*
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function raiseError($code, $msg, $info = null)
|
||||
{
|
||||
JLog::add('JError::raiseError() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return self::raise(E_ERROR, $code, $msg, $info, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method for the {@link raise()} method with predefined error level of E_WARNING and
|
||||
* backtrace set to false.
|
||||
*
|
||||
* @param string $code The application-internal error code for this error
|
||||
* @param string $msg The error message, which may also be shown the user if need be.
|
||||
* @param mixed $info Optional: Additional error information (usually only
|
||||
* developer-relevant information that
|
||||
* the user should never see, like a database DSN).
|
||||
*
|
||||
* @return object The configured JError object
|
||||
*
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @see JError
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function raiseWarning($code, $msg, $info = null)
|
||||
{
|
||||
JLog::add('JError::raiseWarning() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return self::raise(E_WARNING, $code, $msg, $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method for the {@link raise()} method with predefined error
|
||||
* level of E_NOTICE and backtrace set to false.
|
||||
*
|
||||
* @param string $code The application-internal error code for this error
|
||||
* @param string $msg The error message, which may also be shown the user if need be.
|
||||
* @param mixed $info Optional: Additional error information (usually only
|
||||
* developer-relevant information that the user
|
||||
* should never see, like a database DSN).
|
||||
*
|
||||
* @return object The configured JError object
|
||||
*
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function raiseNotice($code, $msg, $info = null)
|
||||
{
|
||||
JLog::add('JError::raiseNotice() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return self::raise(E_NOTICE, $code, $msg, $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the current error handler settings for a specified error level.
|
||||
*
|
||||
* @param integer $level The error level to retrieve. This can be any of PHP's
|
||||
* own error levels, e.g. E_ALL, E_NOTICE...
|
||||
*
|
||||
* @return array All error handling details
|
||||
*
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getErrorHandling($level)
|
||||
{
|
||||
JLog::add('JError::getErrorHandling() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return self::$handlers[$level];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the way the JError will handle different error levels. Use this if you want to override the default settings.
|
||||
*
|
||||
* Error handling modes:
|
||||
* - ignore
|
||||
* - echo
|
||||
* - verbose
|
||||
* - die
|
||||
* - message
|
||||
* - log
|
||||
* - callback
|
||||
*
|
||||
* You may also set the error handling for several modes at once using PHP's bit operations.
|
||||
* Examples:
|
||||
* - E_ALL = Set the handling for all levels
|
||||
* - E_ERROR | E_WARNING = Set the handling for errors and warnings
|
||||
* - E_ALL ^ E_ERROR = Set the handling for all levels except errors
|
||||
*
|
||||
* @param integer $level The error level for which to set the error handling
|
||||
* @param string $mode The mode to use for the error handling.
|
||||
* @param mixed $options Optional: Any options needed for the given mode.
|
||||
*
|
||||
* @return mixed True on success or a JException object if failed.
|
||||
*
|
||||
* @deprecated 12.1 Use PHP Exception
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function setErrorHandling($level, $mode, $options = null)
|
||||
{
|
||||
JLog::add('JError::setErrorHandling() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$levels = self::$levels;
|
||||
|
||||
$function = 'handle' . ucfirst($mode);
|
||||
|
||||
if (!is_callable(array('JError', $function)))
|
||||
{
|
||||
return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_MODE, 'Error Handling mode is not known', 'Mode: ' . $mode . ' is not implemented.');
|
||||
}
|
||||
|
||||
foreach ($levels as $eLevel => $eTitle)
|
||||
{
|
||||
if (($level & $eLevel) != $eLevel)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set callback options
|
||||
if ($mode == 'callback')
|
||||
{
|
||||
if (!is_array($options))
|
||||
{
|
||||
return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_OPTIONS, 'Options for callback not valid');
|
||||
}
|
||||
|
||||
if (!is_callable($options))
|
||||
{
|
||||
$tmp = array('GLOBAL');
|
||||
if (is_array($options))
|
||||
{
|
||||
$tmp[0] = $options[0];
|
||||
$tmp[1] = $options[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp[1] = $options;
|
||||
}
|
||||
|
||||
return self::raiseError(
|
||||
E_ERROR,
|
||||
'JError:' . JERROR_CALLBACK_NOT_CALLABLE,
|
||||
'Function is not callable',
|
||||
'Function:' . $tmp[1] . ' scope ' . $tmp[0] . '.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Save settings
|
||||
self::$handlers[$eLevel] = array('mode' => $mode);
|
||||
if ($options != null)
|
||||
{
|
||||
self::$handlers[$eLevel]['options'] = $options;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that attaches the error handler to JError
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see set_error_handler
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function attachHandler()
|
||||
{
|
||||
JLog::add('JError::getErrorHandling() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
set_error_handler(array('JError', 'customErrorHandler'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that detaches the error handler from JError
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see restore_error_handler
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function detachHandler()
|
||||
{
|
||||
JLog::add('JError::detachHandler() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to register a new error level for handling errors
|
||||
*
|
||||
* This allows you to add custom error levels to the built-in
|
||||
* - E_NOTICE
|
||||
* - E_WARNING
|
||||
* - E_NOTICE
|
||||
*
|
||||
* @param integer $level Error level to register
|
||||
* @param string $name Human readable name for the error level
|
||||
* @param string $handler Error handler to set for the new error level [optional]
|
||||
*
|
||||
* @return boolean True on success; false if the level already has been registered
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function registerErrorLevel($level, $name, $handler = 'ignore')
|
||||
{
|
||||
JLog::add('JError::registerErrorLevel() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if (isset(self::$levels[$level]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$levels[$level] = $name;
|
||||
self::setErrorHandling($level, $handler);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an error level integer to a human readable string
|
||||
* e.g. E_ERROR will be translated to 'Error'
|
||||
*
|
||||
* @param integer $level Error level to translate
|
||||
*
|
||||
* @return mixed Human readable error level name or boolean false if it doesn't exist
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
|
||||
public static function translateErrorLevel($level)
|
||||
{
|
||||
JLog::add('JError::translateErrorLevel() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if (isset(self::$levels[$level]))
|
||||
{
|
||||
return self::$levels[$level];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore error handler
|
||||
* - Ignores the error
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleIgnore(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::handleIgnore() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Echo error handler
|
||||
* - Echos the error message to output
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleEcho(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::handleEcho() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$level_human = self::translateErrorLevel($error->get('level'));
|
||||
|
||||
// If system debug is set, then output some more information.
|
||||
if (defined('JDEBUG'))
|
||||
{
|
||||
$backtrace = $error->getTrace();
|
||||
$trace = '';
|
||||
for ($i = count($backtrace) - 1; $i >= 0; $i--)
|
||||
{
|
||||
if (isset($backtrace[$i]['class']))
|
||||
{
|
||||
$trace .= sprintf("\n%s %s %s()", $backtrace[$i]['class'], $backtrace[$i]['type'], $backtrace[$i]['function']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$trace .= sprintf("\n%s()", $backtrace[$i]['function']);
|
||||
}
|
||||
|
||||
if (isset($backtrace[$i]['file']))
|
||||
{
|
||||
$trace .= sprintf(' @ %s:%d', $backtrace[$i]['file'], $backtrace[$i]['line']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SERVER['HTTP_HOST']))
|
||||
{
|
||||
// Output as html
|
||||
echo "<br /><b>jos-$level_human</b>: "
|
||||
. $error->get('message') . "<br />\n"
|
||||
. (defined('JDEBUG') ? nl2br($trace) : '');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output as simple text
|
||||
if (defined('STDERR'))
|
||||
{
|
||||
fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n");
|
||||
if (defined('JDEBUG'))
|
||||
{
|
||||
fwrite(STDERR, $trace);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "J$level_human: " . $error->get('message') . "\n";
|
||||
if (defined('JDEBUG'))
|
||||
{
|
||||
echo $trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verbose error handler
|
||||
* - Echos the error message to output as well as related info
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleVerbose(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::handleVerbose() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$level_human = self::translateErrorLevel($error->get('level'));
|
||||
$info = $error->get('info');
|
||||
|
||||
if (isset($_SERVER['HTTP_HOST']))
|
||||
{
|
||||
// Output as html
|
||||
echo "<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n";
|
||||
|
||||
if ($info != null)
|
||||
{
|
||||
echo "   " . $info . "<br />\n";
|
||||
}
|
||||
|
||||
echo $error->getBacktrace(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output as simple text
|
||||
echo "J$level_human: " . $error->get('message') . "\n";
|
||||
if ($info != null)
|
||||
{
|
||||
echo "\t" . $info . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die error handler
|
||||
* - Echos the error message to output and then dies
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleDie(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::handleDie() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$level_human = self::translateErrorLevel($error->get('level'));
|
||||
|
||||
if (isset($_SERVER['HTTP_HOST']))
|
||||
{
|
||||
// Output as html
|
||||
jexit("<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output as simple text
|
||||
if (defined('STDERR'))
|
||||
{
|
||||
fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n");
|
||||
jexit();
|
||||
}
|
||||
else
|
||||
{
|
||||
jexit("J$level_human: " . $error->get('message') . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message error handler
|
||||
* Enqueues the error message into the system queue
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleMessage(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::hanleMessage() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$appl = JFactory::getApplication();
|
||||
$type = ($error->get('level') == E_NOTICE) ? 'notice' : 'error';
|
||||
$appl->enqueueMessage($error->get('message'), $type);
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log error handler
|
||||
* Logs the error message to a system log file
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleLog(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::handleLog() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
static $log;
|
||||
|
||||
if ($log == null)
|
||||
{
|
||||
$options['text_file'] = date('Y-m-d') . '.error.log';
|
||||
$options['format'] = "{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}";
|
||||
JLog::addLogger($options, JLog::ALL, array('error'));
|
||||
}
|
||||
|
||||
$entry = new JLogEntry(
|
||||
str_replace(array("\r", "\n"), array('', '\\n'), $error->get('message')),
|
||||
$error->get('level'),
|
||||
'error'
|
||||
);
|
||||
$entry->code = $error->get('code');
|
||||
JLog::add($entry);
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback error handler
|
||||
* - Send the error object to a callback method for error handling
|
||||
*
|
||||
* @param object &$error Exception object to handle
|
||||
* @param array $options Handler options
|
||||
*
|
||||
* @return object The exception object
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see raise()
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function handleCallback(&$error, $options)
|
||||
{
|
||||
JLog::add('JError::handleCallback() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return call_user_func($options, $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a custom error page and exit gracefully
|
||||
*
|
||||
* @param object &$error Exception object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function customErrorPage(&$error)
|
||||
{
|
||||
JLog::add('JError::customErrorPage() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$document = JDocument::getInstance('error');
|
||||
if ($document)
|
||||
{
|
||||
$config = JFactory::getConfig();
|
||||
|
||||
// Get the current template from the application
|
||||
$template = $app->getTemplate();
|
||||
|
||||
// Push the error object into the document
|
||||
$document->setError($error);
|
||||
|
||||
@ob_end_clean();
|
||||
$document->setTitle(JText::_('Error') . ': ' . $error->getCode());
|
||||
$data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
|
||||
|
||||
// Failsafe to get the error displayed.
|
||||
if (empty($data))
|
||||
{
|
||||
self::handleEcho($error, array());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not allow cache
|
||||
JResponse::allowCache(false);
|
||||
|
||||
JResponse::setBody($data);
|
||||
echo JResponse::toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just echo the error since there is no document
|
||||
// This is a common use case for Command Line Interface applications.
|
||||
self::handleEcho($error, array());
|
||||
}
|
||||
$app->close(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a message to the user
|
||||
*
|
||||
* @param integer $level The error level - use any of PHP's own error levels
|
||||
* for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
|
||||
* E_USER_WARNING, E_USER_NOTICE.
|
||||
* @param string $msg Error message, shown to user if need be.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function customErrorHandler($level, $msg)
|
||||
{
|
||||
JLog::add('JError::customErrorHandler() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
self::raise($level, '', $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the backtrace
|
||||
*
|
||||
* @param integer $error The error
|
||||
*
|
||||
* @return string Contents of the backtrace
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function renderBacktrace($error)
|
||||
{
|
||||
JLog::add('JError::renderBacktrace() is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$contents = null;
|
||||
$backtrace = $error->getTrace();
|
||||
|
||||
if (is_array($backtrace))
|
||||
{
|
||||
ob_start();
|
||||
$j = 1;
|
||||
echo '<table cellpadding="0" cellspacing="0" class="Table">';
|
||||
echo ' <tr>';
|
||||
echo ' <td colspan="3" class="TD"><strong>Call stack</strong></td>';
|
||||
echo ' </tr>';
|
||||
echo ' <tr>';
|
||||
echo ' <td class="TD"><strong>#</strong></td>';
|
||||
echo ' <td class="TD"><strong>Function</strong></td>';
|
||||
echo ' <td class="TD"><strong>Location</strong></td>';
|
||||
echo ' </tr>';
|
||||
|
||||
for ($i = count($backtrace) - 1; $i >= 0; $i--)
|
||||
{
|
||||
echo ' <tr>';
|
||||
echo ' <td class="TD">' . $j . '</td>';
|
||||
|
||||
if (isset($backtrace[$i]['class']))
|
||||
{
|
||||
echo ' <td class="TD">' . $backtrace[$i]['class'] . $backtrace[$i]['type'] . $backtrace[$i]['function'] . '()</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo ' <td class="TD">' . $backtrace[$i]['function'] . '()</td>';
|
||||
}
|
||||
|
||||
if (isset($backtrace[$i]['file']))
|
||||
{
|
||||
echo ' <td class="TD">' . $backtrace[$i]['file'] . ':' . $backtrace[$i]['line'] . '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo ' <td class="TD"> </td>';
|
||||
}
|
||||
|
||||
echo ' </tr>';
|
||||
$j++;
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
$contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
}
|
1
libraries/legacy/error/index.html
Normal file
1
libraries/legacy/error/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
380
libraries/legacy/exception/exception.php
Normal file
380
libraries/legacy/exception/exception.php
Normal file
@ -0,0 +1,380 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Exception
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Joomla! Exception object.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Exception
|
||||
* @since 11.1
|
||||
* @deprecated 12.1 (Platform) & 4.0 (CMS)
|
||||
*/
|
||||
class JException extends Exception
|
||||
{
|
||||
/**
|
||||
* @var string Error level.
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $level = null;
|
||||
|
||||
/**
|
||||
* @var string Error code.
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $code = null;
|
||||
|
||||
/**
|
||||
* @var string Error message.
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $message = null;
|
||||
|
||||
/**
|
||||
* Additional info about the error relevant to the developer,
|
||||
* for example, if a database connect fails, the dsn used
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $info = '';
|
||||
|
||||
/**
|
||||
* Name of the file the error occurred in [Available if backtrace is enabled]
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $file = null;
|
||||
|
||||
/**
|
||||
* Line number the error occurred in [Available if backtrace is enabled]
|
||||
*
|
||||
* @var int
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $line = 0;
|
||||
|
||||
/**
|
||||
* Name of the method the error occurred in [Available if backtrace is enabled]
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $function = null;
|
||||
|
||||
/**
|
||||
* Name of the class the error occurred in [Available if backtrace is enabled]
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $class = null;
|
||||
|
||||
/**
|
||||
* @var string Error type.
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = null;
|
||||
|
||||
/**
|
||||
* Arguments recieved by the method the error occurred in [Available if backtrace is enabled]
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $args = array();
|
||||
|
||||
/**
|
||||
* @var mixed Backtrace information.
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $backtrace = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* - used to set up the error with all needed error details.
|
||||
*
|
||||
* @param string $msg The error message
|
||||
* @param string $code The error code from the application
|
||||
* @param integer $level The error level (use the PHP constants E_ALL, E_NOTICE etc.).
|
||||
* @param string $info Optional: The additional error information.
|
||||
* @param boolean $backtrace True if backtrace information is to be collected
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public function __construct($msg, $code = 0, $level = null, $info = null, $backtrace = false)
|
||||
{
|
||||
JLog::add('JException is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$this->level = $level;
|
||||
$this->code = $code;
|
||||
$this->message = $msg;
|
||||
|
||||
if ($info != null)
|
||||
{
|
||||
$this->info = $info;
|
||||
}
|
||||
|
||||
if ($backtrace && function_exists('debug_backtrace'))
|
||||
{
|
||||
$this->backtrace = debug_backtrace();
|
||||
|
||||
for ($i = count($this->backtrace) - 1; $i >= 0; --$i)
|
||||
{
|
||||
++$i;
|
||||
if (isset($this->backtrace[$i]['file']))
|
||||
{
|
||||
$this->file = $this->backtrace[$i]['file'];
|
||||
}
|
||||
if (isset($this->backtrace[$i]['line']))
|
||||
{
|
||||
$this->line = $this->backtrace[$i]['line'];
|
||||
}
|
||||
if (isset($this->backtrace[$i]['class']))
|
||||
{
|
||||
$this->class = $this->backtrace[$i]['class'];
|
||||
}
|
||||
if (isset($this->backtrace[$i]['function']))
|
||||
{
|
||||
$this->function = $this->backtrace[$i]['function'];
|
||||
}
|
||||
if (isset($this->backtrace[$i]['type']))
|
||||
{
|
||||
$this->type = $this->backtrace[$i]['type'];
|
||||
}
|
||||
|
||||
$this->args = false;
|
||||
if (isset($this->backtrace[$i]['args']))
|
||||
{
|
||||
$this->args = $this->backtrace[$i]['args'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Store exception for debugging purposes!
|
||||
JError::addToStack($this);
|
||||
|
||||
parent::__construct($msg, (int) $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns to error message
|
||||
*
|
||||
* @return string Error message
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
JLog::add('JException::__toString is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns to error message
|
||||
*
|
||||
* @return string Error message
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
JLog::add('JException::toString is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return (string) $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a property of the object or the default value if the property is not set.
|
||||
*
|
||||
* @param string $property The name of the property
|
||||
* @param mixed $default The default value
|
||||
*
|
||||
* @return mixed The value of the property or null
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see getProperties()
|
||||
* @since 11.1
|
||||
*/
|
||||
public function get($property, $default = null)
|
||||
{
|
||||
JLog::add('JException::get is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if (isset($this->$property))
|
||||
{
|
||||
return $this->$property;
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an associative array of object properties
|
||||
*
|
||||
* @param boolean $public If true, returns only the public properties
|
||||
*
|
||||
* @return array Object properties
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see get()
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getProperties($public = true)
|
||||
{
|
||||
JLog::add('JException::getProperties is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$vars = get_object_vars($this);
|
||||
if ($public)
|
||||
{
|
||||
foreach ($vars as $key => $value)
|
||||
{
|
||||
if ('_' == substr($key, 0, 1))
|
||||
{
|
||||
unset($vars[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent error message
|
||||
*
|
||||
* @param integer $i Option error index
|
||||
* @param boolean $toString Indicates if JError objects should return their error message
|
||||
*
|
||||
* @return string Error message
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public function getError($i = null, $toString = true)
|
||||
{
|
||||
JLog::add('JException::getError is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
// Find the error
|
||||
if ($i === null)
|
||||
{
|
||||
// Default, return the last message
|
||||
$error = end($this->_errors);
|
||||
}
|
||||
elseif (!array_key_exists($i, $this->_errors))
|
||||
{
|
||||
// If $i has been specified but does not exist, return false
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = $this->_errors[$i];
|
||||
}
|
||||
|
||||
// Check if only the string is requested
|
||||
if ($error instanceof Exception && $toString)
|
||||
{
|
||||
return (string) $error;
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all errors, if any
|
||||
*
|
||||
* @return array Array of error messages or JErrors
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
JLog::add('JException::getErrors is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
return $this->_errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies a property of the object, creating it if it does not already exist.
|
||||
*
|
||||
* @param string $property The name of the property
|
||||
* @param mixed $value The value of the property to set
|
||||
*
|
||||
* @return mixed Previous value of the property
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see setProperties()
|
||||
* @since 11.1
|
||||
*/
|
||||
public function set($property, $value = null)
|
||||
{
|
||||
JLog::add('JException::set is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$previous = isset($this->$property) ? $this->$property : null;
|
||||
$this->$property = $value;
|
||||
return $previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object properties based on a named array/hash
|
||||
*
|
||||
* @param mixed $properties Either and associative array or another object
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @see set()
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setProperties($properties)
|
||||
{
|
||||
JLog::add('JException::setProperties is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
// Cast to an array
|
||||
$properties = (array) $properties;
|
||||
|
||||
if (is_array($properties))
|
||||
{
|
||||
foreach ($properties as $k => $v)
|
||||
{
|
||||
$this->$k = $v;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error message
|
||||
*
|
||||
* @param string $error Error message
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public function setError($error)
|
||||
{
|
||||
JLog::add('JException::setErrors is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
array_push($this->_errors, $error);
|
||||
}
|
||||
}
|
1
libraries/legacy/exception/index.html
Normal file
1
libraries/legacy/exception/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
98
libraries/legacy/form/field/category.php
Normal file
98
libraries/legacy/form/field/category.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports an HTML select list of categories
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldCategory extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'Category';
|
||||
|
||||
/**
|
||||
* Method to get the field options for category
|
||||
* Use the extension attribute in a form to specify the.specific extension for
|
||||
* which categories should be displayed.
|
||||
* Use the show_root attribute to specify whether to show the global category root in the list.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
$extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope'];
|
||||
$published = (string) $this->element['published'];
|
||||
|
||||
// Load the category options for a given extension.
|
||||
if (!empty($extension))
|
||||
{
|
||||
// Filter over published state or not depending upon if it is present.
|
||||
if ($published)
|
||||
{
|
||||
$options = JHtml::_('category.options', $extension, array('filter.published' => explode(',', $published)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$options = JHtml::_('category.options', $extension);
|
||||
}
|
||||
|
||||
// Verify permissions. If the action attribute is set, then we scan the options.
|
||||
if ((string) $this->element['action'])
|
||||
{
|
||||
|
||||
// Get the current user object.
|
||||
$user = JFactory::getUser();
|
||||
|
||||
foreach ($options as $i => $option)
|
||||
{
|
||||
/*
|
||||
* To take save or create in a category you need to have create rights for that category
|
||||
* unless the item is already in that category.
|
||||
* Unset the option if the user isn't authorised for it. In this field assets are always categories.
|
||||
*/
|
||||
if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true)
|
||||
{
|
||||
unset($options[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($this->element['show_root']))
|
||||
{
|
||||
array_unshift($options, JHtml::_('select.option', '0', JText::_('JGLOBAL_ROOT')));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JLog::add(JText::_('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY'), JLog::WARNING, 'jerror');
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
245
libraries/legacy/form/field/componentlayout.php
Normal file
245
libraries/legacy/form/field/componentlayout.php
Normal file
@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
/**
|
||||
* Form Field to display a list of the layouts for a component view from
|
||||
* the extension or template overrides.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldComponentlayout extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'ComponentLayout';
|
||||
|
||||
/**
|
||||
* Method to get the field input for a component layout field.
|
||||
*
|
||||
* @return string The field input.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Get the client id.
|
||||
$clientId = $this->element['client_id'];
|
||||
|
||||
if (is_null($clientId) && $this->form instanceof JForm)
|
||||
{
|
||||
$clientId = $this->form->getValue('client_id');
|
||||
}
|
||||
$clientId = (int) $clientId;
|
||||
|
||||
$client = JApplicationHelper::getClientInfo($clientId);
|
||||
|
||||
// Get the extension.
|
||||
$extn = (string) $this->element['extension'];
|
||||
|
||||
if (empty($extn) && ($this->form instanceof JForm))
|
||||
{
|
||||
$extn = $this->form->getValue('extension');
|
||||
}
|
||||
|
||||
$extn = preg_replace('#\W#', '', $extn);
|
||||
|
||||
// Get the template.
|
||||
$template = (string) $this->element['template'];
|
||||
$template = preg_replace('#\W#', '', $template);
|
||||
|
||||
// Get the style.
|
||||
if ($this->form instanceof JForm)
|
||||
{
|
||||
$template_style_id = $this->form->getValue('template_style_id');
|
||||
}
|
||||
|
||||
$template_style_id = preg_replace('#\W#', '', $template_style_id);
|
||||
|
||||
// Get the view.
|
||||
$view = (string) $this->element['view'];
|
||||
$view = preg_replace('#\W#', '', $view);
|
||||
|
||||
// If a template, extension and view are present build the options.
|
||||
if ($extn && $view && $client)
|
||||
{
|
||||
|
||||
// Load language file
|
||||
$lang = JFactory::getLanguage();
|
||||
$lang->load($extn . '.sys', JPATH_ADMINISTRATOR, null, false, false)
|
||||
|| $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false)
|
||||
|| $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|
||||
|| $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false);
|
||||
|
||||
// Get the database object and a new query object.
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Build the query.
|
||||
$query->select('e.element, e.name')
|
||||
->from('#__extensions as e')
|
||||
->where('e.client_id = ' . (int) $clientId)
|
||||
->where('e.type = ' . $db->quote('template'))
|
||||
->where('e.enabled = 1');
|
||||
|
||||
if ($template)
|
||||
{
|
||||
$query->where('e.element = ' . $db->quote($template));
|
||||
}
|
||||
|
||||
if ($template_style_id)
|
||||
{
|
||||
$query->join('LEFT', '#__template_styles as s on s.template=e.element')
|
||||
->where('s.id=' . (int) $template_style_id);
|
||||
}
|
||||
|
||||
// Set the query and load the templates.
|
||||
$db->setQuery($query);
|
||||
$templates = $db->loadObjectList('element');
|
||||
|
||||
// Build the search paths for component layouts.
|
||||
$component_path = JPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl');
|
||||
|
||||
// Prepare array of component layouts
|
||||
$component_layouts = array();
|
||||
|
||||
// Prepare the grouped list
|
||||
$groups = array();
|
||||
|
||||
// Add a Use Global option if useglobal="true" in XML file
|
||||
if ($this->element['useglobal'] == 'true')
|
||||
{
|
||||
$groups[JText::_('JOPTION_FROM_STANDARD')]['items'][] = JHtml::_('select.option', '', JText::_('JGLOBAL_USE_GLOBAL'));
|
||||
}
|
||||
|
||||
// Add the layout options from the component path.
|
||||
if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\.xml$', false, true)))
|
||||
{
|
||||
// Create the group for the component
|
||||
$groups['_'] = array();
|
||||
$groups['_']['id'] = $this->id . '__';
|
||||
$groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT');
|
||||
$groups['_']['items'] = array();
|
||||
|
||||
foreach ($component_layouts as $i => $file)
|
||||
{
|
||||
// Attempt to load the XML file.
|
||||
if (!$xml = simplexml_load_file($file))
|
||||
{
|
||||
unset($component_layouts[$i]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the help data from the XML file if present.
|
||||
if (!$menu = $xml->xpath('layout[1]'))
|
||||
{
|
||||
unset($component_layouts[$i]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$menu = $menu[0];
|
||||
|
||||
// Add an option to the component group
|
||||
$value = basename($file, '.xml');
|
||||
$component_layouts[$i] = $value;
|
||||
$text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value);
|
||||
$groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop on all templates
|
||||
if ($templates)
|
||||
{
|
||||
foreach ($templates as $template)
|
||||
{
|
||||
// Load language file
|
||||
$lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false)
|
||||
|| $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false)
|
||||
|| $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load(
|
||||
'tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false
|
||||
);
|
||||
|
||||
$template_path = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $extn . '/' . $view);
|
||||
|
||||
// Add the layout options from the template path.
|
||||
if (is_dir($template_path) && ($files = JFolder::files($template_path, '^[^_]*\.php$', false, true)))
|
||||
{
|
||||
// Files with corresponding XML files are alternate menu items, not alternate layout files
|
||||
// so we need to exclude these files from the list.
|
||||
$xml_files = JFolder::files($template_path, '^[^_]*\.xml$', false, true);
|
||||
for ($j = 0, $count = count($xml_files); $j < $count; $j++)
|
||||
{
|
||||
$xml_files[$j] = basename($xml_files[$j], '.xml');
|
||||
}
|
||||
foreach ($files as $i => $file)
|
||||
{
|
||||
// Remove layout files that exist in the component folder or that have XML files
|
||||
if ((in_array(basename($file, '.php'), $component_layouts))
|
||||
|| (in_array(basename($file, '.php'), $xml_files)))
|
||||
{
|
||||
unset($files[$i]);
|
||||
}
|
||||
}
|
||||
if (count($files))
|
||||
{
|
||||
// Create the group for the template
|
||||
$groups[$template->name] = array();
|
||||
$groups[$template->name]['id'] = $this->id . '_' . $template->element;
|
||||
$groups[$template->name]['text'] = JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name);
|
||||
$groups[$template->name]['items'] = array();
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// Add an option to the template group
|
||||
$value = basename($file, '.php');
|
||||
$text = $lang
|
||||
->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value))
|
||||
? JText::_($key) : $value;
|
||||
$groups[$template->name]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute attributes for the grouped list
|
||||
$attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
|
||||
// Prepare HTML code
|
||||
$html = array();
|
||||
|
||||
// Compute the current selected values
|
||||
$selected = array($this->value);
|
||||
|
||||
// Add a grouped list
|
||||
$html[] = JHtml::_(
|
||||
'select.groupedlist', $groups, $this->name,
|
||||
array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected)
|
||||
);
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
1
libraries/legacy/form/field/index.html
Normal file
1
libraries/legacy/form/field/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
208
libraries/legacy/form/field/modulelayout.php
Normal file
208
libraries/legacy/form/field/modulelayout.php
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
/**
|
||||
* Form Field to display a list of the layouts for module display from the module or template overrides.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldModulelayout extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'ModuleLayout';
|
||||
|
||||
/**
|
||||
* Method to get the field input for module layouts.
|
||||
*
|
||||
* @return string The field input.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Get the client id.
|
||||
$clientId = $this->element['client_id'];
|
||||
|
||||
if (is_null($clientId) && $this->form instanceof JForm)
|
||||
{
|
||||
$clientId = $this->form->getValue('client_id');
|
||||
}
|
||||
$clientId = (int) $clientId;
|
||||
|
||||
$client = JApplicationHelper::getClientInfo($clientId);
|
||||
|
||||
// Get the module.
|
||||
$module = (string) $this->element['module'];
|
||||
|
||||
if (empty($module) && ($this->form instanceof JForm))
|
||||
{
|
||||
$module = $this->form->getValue('module');
|
||||
}
|
||||
|
||||
$module = preg_replace('#\W#', '', $module);
|
||||
|
||||
// Get the template.
|
||||
$template = (string) $this->element['template'];
|
||||
$template = preg_replace('#\W#', '', $template);
|
||||
|
||||
// Get the style.
|
||||
if ($this->form instanceof JForm)
|
||||
{
|
||||
$template_style_id = $this->form->getValue('template_style_id');
|
||||
}
|
||||
|
||||
$template_style_id = preg_replace('#\W#', '', $template_style_id);
|
||||
|
||||
// If an extension and view are present build the options.
|
||||
if ($module && $client)
|
||||
{
|
||||
|
||||
// Load language file
|
||||
$lang = JFactory::getLanguage();
|
||||
$lang->load($module . '.sys', $client->path, null, false, false)
|
||||
|| $lang->load($module . '.sys', $client->path . '/modules/' . $module, null, false, false)
|
||||
|| $lang->load($module . '.sys', $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load($module . '.sys', $client->path . '/modules/' . $module, $lang->getDefault(), false, false);
|
||||
|
||||
// Get the database object and a new query object.
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Build the query.
|
||||
$query->select('element, name')
|
||||
->from('#__extensions as e')
|
||||
->where('e.client_id = ' . (int) $clientId)
|
||||
->where('e.type = ' . $db->quote('template'))
|
||||
->where('e.enabled = 1');
|
||||
|
||||
if ($template)
|
||||
{
|
||||
$query->where('e.element = ' . $db->quote($template));
|
||||
}
|
||||
|
||||
if ($template_style_id)
|
||||
{
|
||||
$query->join('LEFT', '#__template_styles as s on s.template=e.element')
|
||||
->where('s.id=' . (int) $template_style_id);
|
||||
}
|
||||
|
||||
// Set the query and load the templates.
|
||||
$db->setQuery($query);
|
||||
$templates = $db->loadObjectList('element');
|
||||
|
||||
// Build the search paths for module layouts.
|
||||
$module_path = JPath::clean($client->path . '/modules/' . $module . '/tmpl');
|
||||
|
||||
// Prepare array of component layouts
|
||||
$module_layouts = array();
|
||||
|
||||
// Prepare the grouped list
|
||||
$groups = array();
|
||||
|
||||
// Add the layout options from the module path.
|
||||
if (is_dir($module_path) && ($module_layouts = JFolder::files($module_path, '^[^_]*\.php$')))
|
||||
{
|
||||
// Create the group for the module
|
||||
$groups['_'] = array();
|
||||
$groups['_']['id'] = $this->id . '__';
|
||||
$groups['_']['text'] = JText::sprintf('JOPTION_FROM_MODULE');
|
||||
$groups['_']['items'] = array();
|
||||
|
||||
foreach ($module_layouts as $file)
|
||||
{
|
||||
// Add an option to the module group
|
||||
$value = basename($file, '.php');
|
||||
$text = $lang->hasKey($key = strtoupper($module . '_LAYOUT_' . $value)) ? JText::_($key) : $value;
|
||||
$groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop on all templates
|
||||
if ($templates)
|
||||
{
|
||||
foreach ($templates as $template)
|
||||
{
|
||||
// Load language file
|
||||
$lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false)
|
||||
|| $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false)
|
||||
|| $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load(
|
||||
'tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(),
|
||||
false, false
|
||||
);
|
||||
|
||||
$template_path = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $module);
|
||||
|
||||
// Add the layout options from the template path.
|
||||
if (is_dir($template_path) && ($files = JFolder::files($template_path, '^[^_]*\.php$')))
|
||||
{
|
||||
foreach ($files as $i => $file)
|
||||
{
|
||||
// Remove layout that already exist in component ones
|
||||
if (in_array($file, $module_layouts))
|
||||
{
|
||||
unset($files[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($files))
|
||||
{
|
||||
// Create the group for the template
|
||||
$groups[$template->element] = array();
|
||||
$groups[$template->element]['id'] = $this->id . '_' . $template->element;
|
||||
$groups[$template->element]['text'] = JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name);
|
||||
$groups[$template->element]['items'] = array();
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// Add an option to the template group
|
||||
$value = basename($file, '.php');
|
||||
$text = $lang->hasKey($key = strtoupper('TPL_' . $template->element . '_' . $module . '_LAYOUT_' . $value))
|
||||
? JText::_($key) : $value;
|
||||
$groups[$template->element]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Compute attributes for the grouped list
|
||||
$attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
|
||||
// Prepare HTML code
|
||||
$html = array();
|
||||
|
||||
// Compute the current selected values
|
||||
$selected = array($this->value);
|
||||
|
||||
// Add a grouped list
|
||||
$html[] = JHtml::_(
|
||||
'select.groupedlist', $groups, $this->name,
|
||||
array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected)
|
||||
);
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
1
libraries/legacy/form/index.html
Normal file
1
libraries/legacy/form/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
libraries/legacy/index.html
Normal file
1
libraries/legacy/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
libraries/legacy/log/index.html
Normal file
1
libraries/legacy/log/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
24
libraries/legacy/log/logexception.php
Normal file
24
libraries/legacy/log/logexception.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Log
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('LogException is deprecated, use SPL Exceptions instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* Exception class definition for the Log subpackage.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Log
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use semantic exceptions instead
|
||||
*/
|
||||
class LogException extends RuntimeException
|
||||
{
|
||||
}
|
1
libraries/legacy/menu/index.html
Normal file
1
libraries/legacy/menu/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
358
libraries/legacy/menu/menu.php
Normal file
358
libraries/legacy/menu/menu.php
Normal file
@ -0,0 +1,358 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Menu
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* JMenu class
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Menu
|
||||
* @since 11.1
|
||||
*/
|
||||
class JMenu
|
||||
{
|
||||
/**
|
||||
* Array to hold the menu items
|
||||
*
|
||||
* @var array
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_items = array();
|
||||
|
||||
/**
|
||||
* Identifier of the default menu item
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_default = array();
|
||||
|
||||
/**
|
||||
* Identifier of the active menu item
|
||||
*
|
||||
* @var integer
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_active = 0;
|
||||
|
||||
/**
|
||||
* @var array JMenu instances container.
|
||||
* @since 11.3
|
||||
*/
|
||||
protected static $instances = array();
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $options An array of configuration options.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
// Load the menu items
|
||||
$this->load();
|
||||
|
||||
foreach ($this->_items as $item)
|
||||
{
|
||||
if ($item->home)
|
||||
{
|
||||
$this->_default[trim($item->language)] = $item->id;
|
||||
}
|
||||
|
||||
// Decode the item params
|
||||
$result = new JRegistry;
|
||||
$result->loadString($item->params);
|
||||
$item->params = $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JMenu object
|
||||
*
|
||||
* @param string $client The name of the client
|
||||
* @param array $options An associative array of options
|
||||
*
|
||||
* @return JMenu A menu object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getInstance($client, $options = array())
|
||||
{
|
||||
if (empty(self::$instances[$client]))
|
||||
{
|
||||
// Create a JMenu object
|
||||
$classname = 'JMenu' . ucfirst($client);
|
||||
|
||||
if (!class_exists($classname))
|
||||
{
|
||||
// @deprecated 13.3 Everything in this block is deprecated but the warning is only logged after the file_exists
|
||||
// Load the menu object
|
||||
$info = JApplicationHelper::getClientInfo($client, true);
|
||||
|
||||
if (is_object($info))
|
||||
{
|
||||
$path = $info->path . '/includes/menu.php';
|
||||
if (file_exists($path))
|
||||
{
|
||||
JLog::add('Non-autoloadable JMenu subclasses are deprecated.', JLog::WARNING, 'deprecated');
|
||||
include_once $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists($classname))
|
||||
{
|
||||
self::$instances[$client] = new $classname($options);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_MENU_LOAD', $client), 500);
|
||||
}
|
||||
}
|
||||
|
||||
return self::$instances[$client];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get menu item by id
|
||||
*
|
||||
* @param integer $id The item id
|
||||
*
|
||||
* @return mixed The item object, or null if not found
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getItem($id)
|
||||
{
|
||||
$result = null;
|
||||
if (isset($this->_items[$id]))
|
||||
{
|
||||
$result = &$this->_items[$id];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default item by id and language code.
|
||||
*
|
||||
* @param integer $id The menu item id.
|
||||
* @param string $language The language cod (since 1.6).
|
||||
*
|
||||
* @return boolean True, if successful
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setDefault($id, $language = '')
|
||||
{
|
||||
if (isset($this->_items[$id]))
|
||||
{
|
||||
$this->_default[$language] = $id;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default item by language code.
|
||||
*
|
||||
* @param string $language The language code, default value of * means all.
|
||||
*
|
||||
* @return object The item object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getDefault($language = '*')
|
||||
{
|
||||
if (array_key_exists($language, $this->_default))
|
||||
{
|
||||
return $this->_items[$this->_default[$language]];
|
||||
}
|
||||
elseif (array_key_exists('*', $this->_default))
|
||||
{
|
||||
return $this->_items[$this->_default['*']];
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default item by id
|
||||
*
|
||||
* @param integer $id The item id
|
||||
*
|
||||
* @return mixed If successful the active item, otherwise null
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setActive($id)
|
||||
{
|
||||
if (isset($this->_items[$id]))
|
||||
{
|
||||
$this->_active = $id;
|
||||
$result = &$this->_items[$id];
|
||||
return $result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get menu item by id.
|
||||
*
|
||||
* @return object The item object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
if ($this->_active)
|
||||
{
|
||||
$item = &$this->_items[$this->_active];
|
||||
return $item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets menu items by attribute
|
||||
*
|
||||
* @param mixed $attributes The field name(s).
|
||||
* @param mixed $values The value(s) of the field. If an array, need to match field names
|
||||
* each attribute may have multiple values to lookup for.
|
||||
* @param boolean $firstonly If true, only returns the first item found
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getItems($attributes, $values, $firstonly = false)
|
||||
{
|
||||
$items = array();
|
||||
$attributes = (array) $attributes;
|
||||
$values = (array) $values;
|
||||
|
||||
foreach ($this->_items as $item)
|
||||
{
|
||||
if (!is_object($item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$test = true;
|
||||
for ($i = 0, $count = count($attributes); $i < $count; $i++)
|
||||
{
|
||||
if (is_array($values[$i]))
|
||||
{
|
||||
if (!in_array($item->$attributes[$i], $values[$i]))
|
||||
{
|
||||
$test = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($item->$attributes[$i] != $values[$i])
|
||||
{
|
||||
$test = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($test)
|
||||
{
|
||||
if ($firstonly)
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter object for a certain menu item
|
||||
*
|
||||
* @param integer $id The item id
|
||||
*
|
||||
* @return JRegistry A JRegistry object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getParams($id)
|
||||
{
|
||||
if ($menu = $this->getItem($id))
|
||||
{
|
||||
return $menu->params;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the menu array
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getMenu()
|
||||
{
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check JMenu object authorization against an access control
|
||||
* object and optionally an access extension object
|
||||
*
|
||||
* @param integer $id The menu id
|
||||
*
|
||||
* @return boolean True if authorised
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function authorise($id)
|
||||
{
|
||||
$menu = $this->getItem($id);
|
||||
$user = JFactory::getUser();
|
||||
|
||||
if ($menu)
|
||||
{
|
||||
return in_array((int) $menu->access, $user->getAuthorisedViewLevels());
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the menu items
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
1181
libraries/legacy/model/admin.php
Normal file
1181
libraries/legacy/model/admin.php
Normal file
File diff suppressed because it is too large
Load Diff
325
libraries/legacy/model/form.php
Normal file
325
libraries/legacy/model/form.php
Normal file
@ -0,0 +1,325 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Prototype form model.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
* @see JForm
|
||||
* @see JFormField
|
||||
* @see JFormRule
|
||||
* @since 12.2
|
||||
*/
|
||||
abstract class JModelForm extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* Array of form objects.
|
||||
*
|
||||
* @var array
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $_forms = array();
|
||||
|
||||
/**
|
||||
* Method to checkin a row.
|
||||
*
|
||||
* @param integer $pk The numeric id of the primary key.
|
||||
*
|
||||
* @return boolean False on failure or error, true otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function checkin($pk = null)
|
||||
{
|
||||
// Only attempt to check the row in if it exists.
|
||||
if ($pk)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Get an instance of the row to checkin.
|
||||
$table = $this->getTable();
|
||||
|
||||
if (!$table->load($pk))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if this is the user having previously checked out the row.
|
||||
if ($table->checked_out > 0 && $table->checked_out != $user->get('id') && !$user->authorise('core.admin', 'com_checkin'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Attempt to check the row in.
|
||||
if (!$table->checkin($pk))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check-out a row for editing.
|
||||
*
|
||||
* @param integer $pk The numeric id of the primary key.
|
||||
*
|
||||
* @return boolean False on failure or error, true otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function checkout($pk = null)
|
||||
{
|
||||
// Only attempt to check the row in if it exists.
|
||||
if ($pk)
|
||||
{
|
||||
// Get an instance of the row to checkout.
|
||||
$table = $this->getTable();
|
||||
|
||||
if (!$table->load($pk))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is no checked_out or checked_out_time field, just return true.
|
||||
if (!property_exists($table, 'checked_out') || !property_exists($table, 'checked_out_time'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Check if this is the user having previously checked out the row.
|
||||
if ($table->checked_out > 0 && $table->checked_out != $user->get('id'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Attempt to check the row out.
|
||||
if (!$table->checkout($user->get('id'), $pk))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract method for getting the form from the model.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return mixed A JForm object on success, false on failure
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
abstract public function getForm($data = array(), $loadData = true);
|
||||
|
||||
/**
|
||||
* Method to get a form object.
|
||||
*
|
||||
* @param string $name The name of the form.
|
||||
* @param string $source The form source. Can be XML string if file flag is set to false.
|
||||
* @param array $options Optional array of options for the form creation.
|
||||
* @param boolean $clear Optional argument to force load a new form.
|
||||
* @param string $xpath An optional xpath to search for the fields.
|
||||
*
|
||||
* @return mixed JForm object on success, False on error.
|
||||
*
|
||||
* @see JForm
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false)
|
||||
{
|
||||
// Handle the optional arguments.
|
||||
$options['control'] = JArrayHelper::getValue($options, 'control', false);
|
||||
|
||||
// Create a signature hash.
|
||||
$hash = md5($source . serialize($options));
|
||||
|
||||
// Check if we can use a previously loaded form.
|
||||
if (isset($this->_forms[$hash]) && !$clear)
|
||||
{
|
||||
return $this->_forms[$hash];
|
||||
}
|
||||
|
||||
// Get the form.
|
||||
JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
|
||||
JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
|
||||
JForm::addFormPath(JPATH_COMPONENT . '/model/form');
|
||||
JForm::addFieldPath(JPATH_COMPONENT . '/model/field');
|
||||
|
||||
try
|
||||
{
|
||||
$form = JForm::getInstance($name, $source, $options, false, $xpath);
|
||||
|
||||
if (isset($options['load_data']) && $options['load_data'])
|
||||
{
|
||||
// Get the data for the form.
|
||||
$data = $this->loadFormData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array();
|
||||
}
|
||||
|
||||
// Allow for additional modification of the form, and events to be triggered.
|
||||
// We pass the data because plugins may require it.
|
||||
$this->preprocessForm($form, $data);
|
||||
|
||||
// Load the data into the form after the plugins have operated.
|
||||
$form->bind($data);
|
||||
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the form for later.
|
||||
$this->_forms[$hash] = $form;
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return array The default data is an empty array.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to allow derived classes to preprocess the data.
|
||||
*
|
||||
* @param string $context The context identifier.
|
||||
* @param mixed &$data The data to be processed. It gets altered directly.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function preprocessData($context, &$data)
|
||||
{
|
||||
// Get the dispatcher and load the users plugins.
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('content');
|
||||
|
||||
// Trigger the data preparation event.
|
||||
$results = $dispatcher->trigger('onContentPrepareData', array($context, $data));
|
||||
|
||||
// Check for errors encountered while preparing the data.
|
||||
if (count($results) > 0 && in_array(false, $results, true))
|
||||
{
|
||||
$this->setError($dispatcher->getError());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to allow derived classes to preprocess the form.
|
||||
*
|
||||
* @param JForm $form A JForm object.
|
||||
* @param mixed $data The data expected for the form.
|
||||
* @param string $group The name of the plugin group to import (defaults to "content").
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @see JFormField
|
||||
* @since 12.2
|
||||
* @throws Exception if there is an error in the form event.
|
||||
*/
|
||||
protected function preprocessForm(JForm $form, $data, $group = 'content')
|
||||
{
|
||||
// Import the appropriate plugin group.
|
||||
JPluginHelper::importPlugin($group);
|
||||
|
||||
// Get the dispatcher.
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
|
||||
// Trigger the form preparation event.
|
||||
$results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
|
||||
|
||||
// Check for errors encountered while preparing the form.
|
||||
if (count($results) && in_array(false, $results, true))
|
||||
{
|
||||
// Get the last error.
|
||||
$error = $dispatcher->getError();
|
||||
|
||||
if (!($error instanceof Exception))
|
||||
{
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate the form data.
|
||||
*
|
||||
* @param JForm $form The form to validate against.
|
||||
* @param array $data The data to validate.
|
||||
* @param string $group The name of the field group to validate.
|
||||
*
|
||||
* @return mixed Array of filtered data if valid, false otherwise.
|
||||
*
|
||||
* @see JFormRule
|
||||
* @see JFilterInput
|
||||
* @since 12.2
|
||||
*/
|
||||
public function validate($form, $data, $group = null)
|
||||
{
|
||||
// Filter and validate the form data.
|
||||
$data = $form->filter($data);
|
||||
$return = $form->validate($data, $group);
|
||||
|
||||
// Check for an error.
|
||||
if ($return instanceof Exception)
|
||||
{
|
||||
$this->setError($return->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the validation results.
|
||||
if ($return === false)
|
||||
{
|
||||
// Get the validation messages from the form.
|
||||
foreach ($form->getErrors() as $message)
|
||||
{
|
||||
$this->setError($message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tags B/C break at 3.1.2
|
||||
if (isset($data['metadata']['tags']) && !isset($data['tags']))
|
||||
{
|
||||
$data['tags'] = $data['metadata']['tags'];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
1
libraries/legacy/model/index.html
Normal file
1
libraries/legacy/model/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
54
libraries/legacy/model/item.php
Normal file
54
libraries/legacy/model/item.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Prototype item model.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
* @since 12.2
|
||||
*/
|
||||
abstract class JModelItem extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* An item.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_item = null;
|
||||
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $_context = 'group.type';
|
||||
|
||||
/**
|
||||
* 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 12.2
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
return md5($id);
|
||||
}
|
||||
}
|
521
libraries/legacy/model/legacy.php
Normal file
521
libraries/legacy/model/legacy.php
Normal file
@ -0,0 +1,521 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Base class for a Joomla Model
|
||||
*
|
||||
* Acts as a Factory class for application specific objects and
|
||||
* provides many supporting API functions.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
* @since 12.2
|
||||
*/
|
||||
abstract class JModelLegacy extends JObject
|
||||
{
|
||||
/**
|
||||
* Indicates if the internal state has been set
|
||||
*
|
||||
* @var boolean
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $__state_set = null;
|
||||
|
||||
/**
|
||||
* Database Connector
|
||||
*
|
||||
* @var object
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $_db;
|
||||
|
||||
/**
|
||||
* The model (base) name
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The URL option for the component.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $option = null;
|
||||
|
||||
/**
|
||||
* A state object
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The event to trigger when cleaning cache.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $event_clean_cache = null;
|
||||
|
||||
/**
|
||||
* Add a directory where JModelLegacy should search for models. You may
|
||||
* either pass a string or an array of directories.
|
||||
*
|
||||
* @param mixed $path A path or array[sting] of paths to search.
|
||||
* @param string $prefix A prefix for models.
|
||||
*
|
||||
* @return array An array with directory elements. If prefix is equal to '', all directories are returned.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public static function addIncludePath($path = '', $prefix = '')
|
||||
{
|
||||
static $paths;
|
||||
|
||||
if (!isset($paths))
|
||||
{
|
||||
$paths = array();
|
||||
}
|
||||
|
||||
if (!isset($paths[$prefix]))
|
||||
{
|
||||
$paths[$prefix] = array();
|
||||
}
|
||||
|
||||
if (!isset($paths['']))
|
||||
{
|
||||
$paths[''] = array();
|
||||
}
|
||||
|
||||
if (!empty($path))
|
||||
{
|
||||
jimport('joomla.filesystem.path');
|
||||
|
||||
if (!in_array($path, $paths[$prefix]))
|
||||
{
|
||||
array_unshift($paths[$prefix], JPath::clean($path));
|
||||
}
|
||||
|
||||
if (!in_array($path, $paths['']))
|
||||
{
|
||||
array_unshift($paths[''], JPath::clean($path));
|
||||
}
|
||||
}
|
||||
|
||||
return $paths[$prefix];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the stack of model table paths in LIFO order.
|
||||
*
|
||||
* @param mixed $path The directory as a string or directories as an array to add.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public static function addTablePath($path)
|
||||
{
|
||||
JTable::addIncludePath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the filename for a resource
|
||||
*
|
||||
* @param string $type The resource type to create the filename for.
|
||||
* @param array $parts An associative array of filename information.
|
||||
*
|
||||
* @return string The filename
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected static function _createFileName($type, $parts = array())
|
||||
{
|
||||
$filename = '';
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'model':
|
||||
$filename = strtolower($parts['name']) . '.php';
|
||||
break;
|
||||
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Model object, always creating it
|
||||
*
|
||||
* @param string $type The model type to instantiate
|
||||
* @param string $prefix Prefix for the model class name. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return mixed A model object or false on failure
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public static function getInstance($type, $prefix = '', $config = array())
|
||||
{
|
||||
$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
|
||||
$modelClass = $prefix . ucfirst($type);
|
||||
|
||||
if (!class_exists($modelClass))
|
||||
{
|
||||
jimport('joomla.filesystem.path');
|
||||
$path = JPath::find(self::addIncludePath(null, $prefix), self::_createFileName('model', array('name' => $type)));
|
||||
if (!$path)
|
||||
{
|
||||
$path = JPath::find(self::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type)));
|
||||
}
|
||||
if ($path)
|
||||
{
|
||||
require_once $path;
|
||||
|
||||
if (!class_exists($modelClass))
|
||||
{
|
||||
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass), JLog::WARNING, 'jerror');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return new $modelClass($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
// Guess the option from the class name (Option)Model(View).
|
||||
if (empty($this->option))
|
||||
{
|
||||
$r = null;
|
||||
|
||||
if (!preg_match('/(.*)Model/i', get_class($this), $r))
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME'), 500);
|
||||
}
|
||||
|
||||
$this->option = 'com_' . strtolower($r[1]);
|
||||
}
|
||||
|
||||
// Set the view name
|
||||
if (empty($this->name))
|
||||
{
|
||||
if (array_key_exists('name', $config))
|
||||
{
|
||||
$this->name = $config['name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->name = $this->getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Set the model state
|
||||
if (array_key_exists('state', $config))
|
||||
{
|
||||
$this->state = $config['state'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->state = new JObject;
|
||||
}
|
||||
|
||||
// Set the model dbo
|
||||
if (array_key_exists('dbo', $config))
|
||||
{
|
||||
$this->_db = $config['dbo'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_db = JFactory::getDbo();
|
||||
}
|
||||
|
||||
// Set the default view search path
|
||||
if (array_key_exists('table_path', $config))
|
||||
{
|
||||
$this->addTablePath($config['table_path']);
|
||||
}
|
||||
elseif (defined('JPATH_COMPONENT_ADMINISTRATOR'))
|
||||
{
|
||||
$this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
|
||||
$this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR . '/table');
|
||||
}
|
||||
|
||||
// Set the internal state marker - used to ignore setting state from the request
|
||||
if (!empty($config['ignore_request']))
|
||||
{
|
||||
$this->__state_set = true;
|
||||
}
|
||||
|
||||
// Set the clean cache event
|
||||
if (isset($config['event_clean_cache']))
|
||||
{
|
||||
$this->event_clean_cache = $config['event_clean_cache'];
|
||||
}
|
||||
elseif (empty($this->event_clean_cache))
|
||||
{
|
||||
$this->event_clean_cache = 'onContentCleanCache';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of objects from the results of database query.
|
||||
*
|
||||
* @param string $query The query.
|
||||
* @param integer $limitstart Offset.
|
||||
* @param integer $limit The number of records.
|
||||
*
|
||||
* @return array An array of results.
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function _getList($query, $limitstart = 0, $limit = 0)
|
||||
{
|
||||
$this->_db->setQuery($query, $limitstart, $limit);
|
||||
$result = $this->_db->loadObjectList();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a record count for the query.
|
||||
*
|
||||
* @param JDatabaseQuery|string $query The query.
|
||||
*
|
||||
* @return integer Number of rows for query.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function _getListCount($query)
|
||||
{
|
||||
// Use fast COUNT(*) on JDatabaseQuery objects if there no GROUP BY or HAVING clause:
|
||||
if ($query instanceof JDatabaseQuery
|
||||
&& $query->type == 'select'
|
||||
&& $query->group === null
|
||||
&& $query->having === null)
|
||||
{
|
||||
$query = clone $query;
|
||||
$query->clear('select')->clear('order')->select('COUNT(*)');
|
||||
|
||||
$this->_db->setQuery($query);
|
||||
return (int) $this->_db->loadResult();
|
||||
}
|
||||
|
||||
// Otherwise fall back to inefficient way of counting all results.
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
|
||||
return (int) $this->_db->getNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to load and return a model object.
|
||||
*
|
||||
* @param string $name The name of the view
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration settings to pass to JTable::getInstance
|
||||
*
|
||||
* @return mixed Model object or boolean false if failed
|
||||
*
|
||||
* @since 12.2
|
||||
* @see JTable::getInstance
|
||||
*/
|
||||
protected function _createTable($name, $prefix = 'Table', $config = array())
|
||||
{
|
||||
// Clean the model name
|
||||
$name = preg_replace('/[^A-Z0-9_]/i', '', $name);
|
||||
$prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
|
||||
|
||||
// Make sure we are returning a DBO object
|
||||
if (!array_key_exists('dbo', $config))
|
||||
{
|
||||
$config['dbo'] = $this->getDbo();
|
||||
}
|
||||
|
||||
return JTable::getInstance($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the database driver object
|
||||
*
|
||||
* @return JDatabaseDriver
|
||||
*/
|
||||
public function getDbo()
|
||||
{
|
||||
return $this->_db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the model name
|
||||
*
|
||||
* The model name. By default parsed using the classname or it can be set
|
||||
* by passing a $config['name'] in the class constructor
|
||||
*
|
||||
* @return string The name of the model
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
if (empty($this->name))
|
||||
{
|
||||
$r = null;
|
||||
if (!preg_match('/Model(.*)/i', get_class($this), $r))
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME'), 500);
|
||||
}
|
||||
$this->name = strtolower($r[1]);
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get model state variables
|
||||
*
|
||||
* @param string $property Optional parameter name
|
||||
* @param mixed $default Optional default value
|
||||
*
|
||||
* @return object The property where specified, the state object where omitted
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getState($property = null, $default = null)
|
||||
{
|
||||
if (!$this->__state_set)
|
||||
{
|
||||
// Protected method to auto-populate the model state.
|
||||
$this->populateState();
|
||||
|
||||
// Set the model state set flag to true.
|
||||
$this->__state_set = true;
|
||||
}
|
||||
|
||||
return $property === null ? $this->state : $this->state->get($property, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a table object, load it if necessary.
|
||||
*
|
||||
* @param string $name The table name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $options Configuration array for model. Optional.
|
||||
*
|
||||
* @return JTable A JTable object
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getTable($name = '', $prefix = 'Table', $options = array())
|
||||
{
|
||||
if (empty($name))
|
||||
{
|
||||
$name = $this->getName();
|
||||
}
|
||||
|
||||
if ($table = $this->_createTable($name, $prefix, $options))
|
||||
{
|
||||
return $table;
|
||||
}
|
||||
|
||||
throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $name), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* This method should only be called once per instantiation and is designed
|
||||
* to be called on the first call to the getState() method unless the model
|
||||
* configuration flag to ignore the request is set.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @note Calling getState in this method will result in recursion.
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the database driver object
|
||||
*
|
||||
* @param JDatabaseDriver $db A JDatabaseDriver based object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function setDbo($db)
|
||||
{
|
||||
$this->_db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set model state variables
|
||||
*
|
||||
* @param string $property The name of the property.
|
||||
* @param mixed $value The value of the property to set or null.
|
||||
*
|
||||
* @return mixed The previous value of the property or null if not set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function setState($property, $value = null)
|
||||
{
|
||||
return $this->state->set($property, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean the cache
|
||||
*
|
||||
* @param string $group The cache group
|
||||
* @param integer $client_id The ID of the client
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function cleanCache($group = null, $client_id = 0)
|
||||
{
|
||||
$conf = JFactory::getConfig();
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
|
||||
$options = array(
|
||||
'defaultgroup' => ($group) ? $group : (isset($this->option) ? $this->option : JFactory::getApplication()->input->get('option')),
|
||||
'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'));
|
||||
|
||||
$cache = JCache::getInstance('callback', $options);
|
||||
$cache->clean();
|
||||
|
||||
// Trigger the onContentCleanCache event.
|
||||
$dispatcher->trigger($this->event_clean_cache, $options);
|
||||
}
|
||||
}
|
374
libraries/legacy/model/list.php
Normal file
374
libraries/legacy/model/list.php
Normal file
@ -0,0 +1,374 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Model class for handling lists of items.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Model
|
||||
* @since 12.2
|
||||
*/
|
||||
class JModelList extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* Internal memory based cache array of data.
|
||||
*
|
||||
* @var array
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $cache = array();
|
||||
|
||||
/**
|
||||
* Context string for the model type. This is used to handle uniqueness
|
||||
* when dealing with the getStoreId() method and caching data structures.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $context = null;
|
||||
|
||||
/**
|
||||
* Valid filter fields or ordering.
|
||||
*
|
||||
* @var array
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $filter_fields = array();
|
||||
|
||||
/**
|
||||
* An internal cache for the last query used.
|
||||
*
|
||||
* @var JDatabaseQuery
|
||||
* @since 12.2
|
||||
*/
|
||||
protected $query = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @see JModelLegacy
|
||||
* @since 12.2
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
// Add the ordering filtering fields white list.
|
||||
if (isset($config['filter_fields']))
|
||||
{
|
||||
$this->filter_fields = $config['filter_fields'];
|
||||
}
|
||||
|
||||
// Guess the context as Option.ModelName.
|
||||
if (empty($this->context))
|
||||
{
|
||||
$this->context = strtolower($this->option . '.' . $this->getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cache the last query constructed.
|
||||
*
|
||||
* This method ensures that the query is constructed only once for a given state of the model.
|
||||
*
|
||||
* @return JDatabaseQuery A JDatabaseQuery object
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function _getListQuery()
|
||||
{
|
||||
// Capture the last store id used.
|
||||
static $lastStoreId;
|
||||
|
||||
// Compute the current store id.
|
||||
$currentStoreId = $this->getStoreId();
|
||||
|
||||
// If the last store id is different from the current, refresh the query.
|
||||
if ($lastStoreId != $currentStoreId || empty($this->query))
|
||||
{
|
||||
$lastStoreId = $currentStoreId;
|
||||
$this->query = $this->getListQuery();
|
||||
}
|
||||
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
// Get a storage key.
|
||||
$store = $this->getStoreId();
|
||||
|
||||
// Try to load the data from internal storage.
|
||||
if (isset($this->cache[$store]))
|
||||
{
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
// Load the list items.
|
||||
$query = $this->_getListQuery();
|
||||
|
||||
try
|
||||
{
|
||||
$items = $this->_getList($query, $this->getStart(), $this->getState('list.limit'));
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the items to the internal cache.
|
||||
$this->cache[$store] = $items;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a JDatabaseQuery object for retrieving the data set from a database.
|
||||
*
|
||||
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a JPagination object for the data set.
|
||||
*
|
||||
* @return JPagination A JPagination object for the data set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getPagination()
|
||||
{
|
||||
// Get a storage key.
|
||||
$store = $this->getStoreId('getPagination');
|
||||
|
||||
// Try to load the data from internal storage.
|
||||
if (isset($this->cache[$store]))
|
||||
{
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
// Create the pagination object.
|
||||
$limit = (int) $this->getState('list.limit') - (int) $this->getState('list.links');
|
||||
$page = new JPagination($this->getTotal(), $this->getStart(), $limit);
|
||||
|
||||
// Add the object to the internal cache.
|
||||
$this->cache[$store] = $page;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on the 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 An identifier string to generate the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Add the list state to the store id.
|
||||
$id .= ':' . $this->getState('list.start');
|
||||
$id .= ':' . $this->getState('list.limit');
|
||||
$id .= ':' . $this->getState('list.ordering');
|
||||
$id .= ':' . $this->getState('list.direction');
|
||||
|
||||
return md5($this->context . ':' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the total number of items for the data set.
|
||||
*
|
||||
* @return integer The total number of items available in the data set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getTotal()
|
||||
{
|
||||
// Get a storage key.
|
||||
$store = $this->getStoreId('getTotal');
|
||||
|
||||
// Try to load the data from internal storage.
|
||||
if (isset($this->cache[$store]))
|
||||
{
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
// Load the total.
|
||||
$query = $this->_getListQuery();
|
||||
try
|
||||
{
|
||||
$total = (int) $this->_getListCount($query);
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the total to the internal cache.
|
||||
$this->cache[$store] = $total;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the starting number of items for the data set.
|
||||
*
|
||||
* @return integer The starting number of items available in the data set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getStart()
|
||||
{
|
||||
$store = $this->getStoreId('getstart');
|
||||
|
||||
// Try to load the data from internal storage.
|
||||
if (isset($this->cache[$store]))
|
||||
{
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
$start = $this->getState('list.start');
|
||||
$limit = $this->getState('list.limit');
|
||||
$total = $this->getTotal();
|
||||
if ($start > $total - $limit)
|
||||
{
|
||||
$start = max(0, (int) (ceil($total / $limit) - 1) * $limit);
|
||||
}
|
||||
|
||||
// Add the total to the internal cache.
|
||||
$this->cache[$store] = $start;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* This method should only be called once per instantiation and is designed
|
||||
* to be called on the first call to the getState() method unless the model
|
||||
* configuration flag to ignore the request is set.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// If the context is set, assume that stateful lists are used.
|
||||
if ($this->context)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$value = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
|
||||
$limit = $value;
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
$value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0);
|
||||
$limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0);
|
||||
$this->setState('list.start', $limitstart);
|
||||
|
||||
// Check if the ordering field is in the white list, otherwise use the incoming value.
|
||||
$value = $app->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', $ordering);
|
||||
if (!in_array($value, $this->filter_fields))
|
||||
{
|
||||
$value = $ordering;
|
||||
$app->setUserState($this->context . '.ordercol', $value);
|
||||
}
|
||||
$this->setState('list.ordering', $value);
|
||||
|
||||
// Check if the ordering direction is valid, otherwise use the incoming value.
|
||||
$value = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $direction);
|
||||
if (!in_array(strtoupper($value), array('ASC', 'DESC', '')))
|
||||
{
|
||||
$value = $direction;
|
||||
$app->setUserState($this->context . '.orderdirn', $value);
|
||||
}
|
||||
$this->setState('list.direction', $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setState('list.start', 0);
|
||||
$this->state->set('list.limit', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a user state variable and sets it in the session
|
||||
*
|
||||
* This is the same as the method in JApplication except that this also can optionally
|
||||
* force you back to the first page when a filter has changed
|
||||
*
|
||||
* @param string $key The key of the user state variable.
|
||||
* @param string $request The name of the variable passed in a request.
|
||||
* @param string $default The default value for the variable if not found. Optional.
|
||||
* @param string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional.
|
||||
* @param boolean $resetPage If true, the limitstart in request is set to zero
|
||||
*
|
||||
* @return The request user state.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$input = $app->input;
|
||||
$old_state = $app->getUserState($key);
|
||||
$cur_state = (!is_null($old_state)) ? $old_state : $default;
|
||||
$new_state = $input->get($request, null, $type);
|
||||
|
||||
if (($cur_state != $new_state) && ($resetPage))
|
||||
{
|
||||
$input->set('limitstart', 0);
|
||||
}
|
||||
|
||||
// Save the new value only if it is set in this request.
|
||||
if ($new_state !== null)
|
||||
{
|
||||
$app->setUserState($key, $new_state);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_state = $cur_state;
|
||||
}
|
||||
|
||||
return $new_state;
|
||||
}
|
||||
}
|
523
libraries/legacy/module/helper.php
Normal file
523
libraries/legacy/module/helper.php
Normal file
@ -0,0 +1,523 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Module
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Module helper class
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Module
|
||||
* @since 11.1
|
||||
*/
|
||||
abstract class JModuleHelper
|
||||
{
|
||||
/**
|
||||
* Get module by name (real, eg 'Breadcrumbs' or folder, eg 'mod_breadcrumbs')
|
||||
*
|
||||
* @param string $name The name of the module
|
||||
* @param string $title The title of the module, optional
|
||||
*
|
||||
* @return object The Module object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function &getModule($name, $title = null)
|
||||
{
|
||||
$result = null;
|
||||
$modules =& self::_load();
|
||||
$total = count($modules);
|
||||
|
||||
for ($i = 0; $i < $total; $i++)
|
||||
{
|
||||
// Match the name of the module
|
||||
if ($modules[$i]->name == $name || $modules[$i]->module == $name)
|
||||
{
|
||||
// Match the title if we're looking for a specific instance of the module
|
||||
if (!$title || $modules[$i]->title == $title)
|
||||
{
|
||||
// Found it
|
||||
$result = &$modules[$i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't find it, and the name is mod_something, create a dummy object
|
||||
if (is_null($result) && substr($name, 0, 4) == 'mod_')
|
||||
{
|
||||
$result = new stdClass;
|
||||
$result->id = 0;
|
||||
$result->title = '';
|
||||
$result->module = $name;
|
||||
$result->position = '';
|
||||
$result->content = '';
|
||||
$result->showtitle = 0;
|
||||
$result->control = '';
|
||||
$result->params = '';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get modules by position
|
||||
*
|
||||
* @param string $position The position of the module
|
||||
*
|
||||
* @return array An array of module objects
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function &getModules($position)
|
||||
{
|
||||
$position = strtolower($position);
|
||||
$result = array();
|
||||
$input = JFactory::getApplication()->input;
|
||||
|
||||
$modules =& self::_load();
|
||||
|
||||
$total = count($modules);
|
||||
for ($i = 0; $i < $total; $i++)
|
||||
{
|
||||
if ($modules[$i]->position == $position)
|
||||
{
|
||||
$result[] = &$modules[$i];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
if ($input->getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display'))
|
||||
{
|
||||
$result[0] = self::getModule('mod_' . $position);
|
||||
$result[0]->title = $position;
|
||||
$result[0]->content = $position;
|
||||
$result[0]->position = $position;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a module is enabled
|
||||
*
|
||||
* @param string $module The module name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function isEnabled($module)
|
||||
{
|
||||
$result = self::getModule($module);
|
||||
|
||||
return !is_null($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the module.
|
||||
*
|
||||
* @param object $module A module object.
|
||||
* @param array $attribs An array of attributes for the module (probably from the XML).
|
||||
*
|
||||
* @return string The HTML content of the module output.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function renderModule($module, $attribs = array())
|
||||
{
|
||||
static $chrome;
|
||||
|
||||
if (defined('JDEBUG'))
|
||||
{
|
||||
JProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
|
||||
}
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Record the scope.
|
||||
$scope = $app->scope;
|
||||
|
||||
// Set scope to component name
|
||||
$app->scope = $module->module;
|
||||
|
||||
// Get module parameters
|
||||
$params = new JRegistry;
|
||||
$params->loadString($module->params);
|
||||
|
||||
// Get the template
|
||||
$template = $app->getTemplate();
|
||||
|
||||
// Get module path
|
||||
$module->module = preg_replace('/[^A-Z0-9_\.-]/i', '', $module->module);
|
||||
$path = JPATH_BASE . '/modules/' . $module->module . '/' . $module->module . '.php';
|
||||
|
||||
// Load the module
|
||||
if (file_exists($path))
|
||||
{
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
// 1.5 or Core then 1.6 3PD
|
||||
$lang->load($module->module, JPATH_BASE, null, false, false) ||
|
||||
$lang->load($module->module, dirname($path), null, false, false) ||
|
||||
$lang->load($module->module, JPATH_BASE, $lang->getDefault(), false, false) ||
|
||||
$lang->load($module->module, dirname($path), $lang->getDefault(), false, false);
|
||||
|
||||
$content = '';
|
||||
ob_start();
|
||||
include $path;
|
||||
$module->content = ob_get_contents() . $content;
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
// Load the module chrome functions
|
||||
if (!$chrome)
|
||||
{
|
||||
$chrome = array();
|
||||
}
|
||||
|
||||
include_once JPATH_THEMES . '/system/html/modules.php';
|
||||
$chromePath = JPATH_THEMES . '/' . $template . '/html/modules.php';
|
||||
|
||||
if (!isset($chrome[$chromePath]))
|
||||
{
|
||||
if (file_exists($chromePath))
|
||||
{
|
||||
include_once $chromePath;
|
||||
}
|
||||
|
||||
$chrome[$chromePath] = true;
|
||||
}
|
||||
|
||||
// Check if the current module has a style param to override template module style
|
||||
$paramsChromeStyle = $params->get('style');
|
||||
if ($paramsChromeStyle)
|
||||
{
|
||||
$attribs['style'] = preg_replace('/^(system|' . $template . ')\-/i', '', $paramsChromeStyle);
|
||||
}
|
||||
|
||||
// Make sure a style is set
|
||||
if (!isset($attribs['style']))
|
||||
{
|
||||
$attribs['style'] = 'none';
|
||||
}
|
||||
|
||||
// Dynamically add outline style
|
||||
if ($app->input->getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display'))
|
||||
{
|
||||
$attribs['style'] .= ' outline';
|
||||
}
|
||||
|
||||
foreach (explode(' ', $attribs['style']) as $style)
|
||||
{
|
||||
$chromeMethod = 'modChrome_' . $style;
|
||||
|
||||
// Apply chrome and render module
|
||||
if (function_exists($chromeMethod))
|
||||
{
|
||||
$module->style = $attribs['style'];
|
||||
|
||||
ob_start();
|
||||
$chromeMethod($module, $params, $attribs);
|
||||
$module->content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
}
|
||||
|
||||
// Revert the scope
|
||||
$app->scope = $scope;
|
||||
|
||||
if (defined('JDEBUG'))
|
||||
{
|
||||
JProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
|
||||
}
|
||||
|
||||
return $module->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to a layout for a module
|
||||
*
|
||||
* @param string $module The name of the module
|
||||
* @param string $layout The name of the module layout. If alternative layout, in the form template:filename.
|
||||
*
|
||||
* @return string The path to the module layout
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getLayoutPath($module, $layout = 'default')
|
||||
{
|
||||
$template = JFactory::getApplication()->getTemplate();
|
||||
$defaultLayout = $layout;
|
||||
|
||||
if (strpos($layout, ':') !== false)
|
||||
{
|
||||
// Get the template and file name from the string
|
||||
$temp = explode(':', $layout);
|
||||
$template = ($temp[0] == '_') ? $template : $temp[0];
|
||||
$layout = $temp[1];
|
||||
$defaultLayout = ($temp[1]) ? $temp[1] : 'default';
|
||||
}
|
||||
|
||||
// Build the template and base path for the layout
|
||||
$tPath = JPATH_THEMES . '/' . $template . '/html/' . $module . '/' . $layout . '.php';
|
||||
$bPath = JPATH_BASE . '/modules/' . $module . '/tmpl/' . $defaultLayout . '.php';
|
||||
$dPath = JPATH_BASE . '/modules/' . $module . '/tmpl/default.php';
|
||||
|
||||
// If the template has a layout override use it
|
||||
if (file_exists($tPath))
|
||||
{
|
||||
return $tPath;
|
||||
}
|
||||
elseif (file_exists($bPath))
|
||||
{
|
||||
return $bPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $dPath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load published modules.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static function &_load()
|
||||
{
|
||||
static $clean;
|
||||
|
||||
if (isset($clean))
|
||||
{
|
||||
return $clean;
|
||||
}
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$Itemid = $app->input->getInt('Itemid');
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$lang = JFactory::getLanguage()->getTag();
|
||||
$clientId = (int) $app->getClientId();
|
||||
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid')
|
||||
->from('#__modules AS m')
|
||||
->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id')
|
||||
->where('m.published = 1')
|
||||
|
||||
->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id')
|
||||
->where('e.enabled = 1');
|
||||
|
||||
$date = JFactory::getDate();
|
||||
$now = $date->toSql();
|
||||
$nullDate = $db->getNullDate();
|
||||
$query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')')
|
||||
->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')')
|
||||
|
||||
->where('m.access IN (' . $groups . ')')
|
||||
->where('m.client_id = ' . $clientId)
|
||||
->where('(mm.menuid = ' . (int) $Itemid . ' OR mm.menuid <= 0)');
|
||||
|
||||
// Filter by language
|
||||
if ($app->isSite() && $app->getLanguageFilter())
|
||||
{
|
||||
$query->where('m.language IN (' . $db->quote($lang) . ',' . $db->quote('*') . ')');
|
||||
}
|
||||
|
||||
$query->order('m.position, m.ordering');
|
||||
|
||||
// Set the query
|
||||
$db->setQuery($query);
|
||||
$clean = array();
|
||||
|
||||
try
|
||||
{
|
||||
$modules = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $e->getMessage()), JLog::WARNING, 'jerror');
|
||||
return $clean;
|
||||
}
|
||||
|
||||
// Apply negative selections and eliminate duplicates
|
||||
$negId = $Itemid ? -(int) $Itemid : false;
|
||||
$dupes = array();
|
||||
for ($i = 0, $n = count($modules); $i < $n; $i++)
|
||||
{
|
||||
$module = &$modules[$i];
|
||||
|
||||
// The module is excluded if there is an explicit prohibition
|
||||
$negHit = ($negId === (int) $module->menuid);
|
||||
|
||||
if (isset($dupes[$module->id]))
|
||||
{
|
||||
// If this item has been excluded, keep the duplicate flag set,
|
||||
// but remove any item from the cleaned array.
|
||||
if ($negHit)
|
||||
{
|
||||
unset($clean[$module->id]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$dupes[$module->id] = true;
|
||||
|
||||
// Only accept modules without explicit exclusions.
|
||||
if (!$negHit)
|
||||
{
|
||||
$module->name = substr($module->module, 4);
|
||||
$module->style = null;
|
||||
$module->position = strtolower($module->position);
|
||||
$clean[$module->id] = $module;
|
||||
}
|
||||
}
|
||||
|
||||
unset($dupes);
|
||||
|
||||
// Return to simple indexing that matches the query order.
|
||||
$clean = array_values($clean);
|
||||
|
||||
return $clean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module cache helper
|
||||
*
|
||||
* Caching modes:
|
||||
* To be set in XML:
|
||||
* 'static' One cache file for all pages with the same module parameters
|
||||
* 'oldstatic' 1.5 definition of module caching, one cache file for all pages
|
||||
* with the same module id and user aid,
|
||||
* 'itemid' Changes on itemid change, to be called from inside the module:
|
||||
* 'safeuri' Id created from $cacheparams->modeparams array,
|
||||
* 'id' Module sets own cache id's
|
||||
*
|
||||
* @param object $module Module object
|
||||
* @param object $moduleparams Module parameters
|
||||
* @param object $cacheparams Module cache parameters - id or url parameters, depending on the module cache mode
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @link JFilterInput::clean()
|
||||
*/
|
||||
public static function moduleCache($module, $moduleparams, $cacheparams)
|
||||
{
|
||||
if (!isset($cacheparams->modeparams))
|
||||
{
|
||||
$cacheparams->modeparams = null;
|
||||
}
|
||||
|
||||
if (!isset($cacheparams->cachegroup))
|
||||
{
|
||||
$cacheparams->cachegroup = $module->module;
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
$cache = JFactory::getCache($cacheparams->cachegroup, 'callback');
|
||||
$conf = JFactory::getConfig();
|
||||
|
||||
// Turn cache off for internal callers if parameters are set to off and for all logged in users
|
||||
if ($moduleparams->get('owncache', null) === '0' || $conf->get('caching') == 0 || $user->get('id'))
|
||||
{
|
||||
$cache->setCaching(false);
|
||||
}
|
||||
|
||||
// Module cache is set in seconds, global cache in minutes, setLifeTime works in minutes
|
||||
$cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') * 60) / 60);
|
||||
|
||||
$wrkaroundoptions = array('nopathway' => 1, 'nohead' => 0, 'nomodules' => 1, 'modulemode' => 1, 'mergehead' => 1);
|
||||
|
||||
$wrkarounds = true;
|
||||
$view_levels = md5(serialize($user->getAuthorisedViewLevels()));
|
||||
|
||||
switch ($cacheparams->cachemode)
|
||||
{
|
||||
case 'id':
|
||||
$ret = $cache->get(
|
||||
array($cacheparams->class, $cacheparams->method),
|
||||
$cacheparams->methodparams,
|
||||
$cacheparams->modeparams,
|
||||
$wrkarounds,
|
||||
$wrkaroundoptions
|
||||
);
|
||||
break;
|
||||
|
||||
case 'safeuri':
|
||||
$secureid = null;
|
||||
if (is_array($cacheparams->modeparams))
|
||||
{
|
||||
$uri = JRequest::get();
|
||||
$safeuri = new stdClass;
|
||||
foreach ($cacheparams->modeparams as $key => $value)
|
||||
{
|
||||
// Use int filter for id/catid to clean out spamy slugs
|
||||
if (isset($uri[$key]))
|
||||
{
|
||||
$noHtmlFilter = JFilterInput::getInstance();
|
||||
$safeuri->$key = $noHtmlFilter->clean($uri[$key], $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$secureid = md5(serialize(array($safeuri, $cacheparams->method, $moduleparams)));
|
||||
$ret = $cache->get(
|
||||
array($cacheparams->class, $cacheparams->method),
|
||||
$cacheparams->methodparams,
|
||||
$module->id . $view_levels . $secureid,
|
||||
$wrkarounds,
|
||||
$wrkaroundoptions
|
||||
);
|
||||
break;
|
||||
|
||||
case 'static':
|
||||
$ret = $cache->get(
|
||||
array($cacheparams->class,
|
||||
$cacheparams->method),
|
||||
$cacheparams->methodparams,
|
||||
$module->module . md5(serialize($cacheparams->methodparams)),
|
||||
$wrkarounds,
|
||||
$wrkaroundoptions
|
||||
);
|
||||
break;
|
||||
|
||||
// Provided for backward compatibility, not really useful.
|
||||
case 'oldstatic':
|
||||
$ret = $cache->get(
|
||||
array($cacheparams->class, $cacheparams->method),
|
||||
$cacheparams->methodparams,
|
||||
$module->id . $view_levels,
|
||||
$wrkarounds,
|
||||
$wrkaroundoptions
|
||||
);
|
||||
break;
|
||||
|
||||
case 'itemid':
|
||||
default:
|
||||
$ret = $cache->get(
|
||||
array($cacheparams->class, $cacheparams->method),
|
||||
$cacheparams->methodparams,
|
||||
$module->id . $view_levels . JFactory::getApplication()->input->getInt('Itemid', null),
|
||||
$wrkarounds,
|
||||
$wrkaroundoptions
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
1
libraries/legacy/module/index.html
Normal file
1
libraries/legacy/module/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
libraries/legacy/pathway/index.html
Normal file
1
libraries/legacy/pathway/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
219
libraries/legacy/pathway/pathway.php
Normal file
219
libraries/legacy/pathway/pathway.php
Normal file
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Pathway
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Class to maintain a pathway.
|
||||
*
|
||||
* The user's navigated path within the application.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Pathway
|
||||
* @since 11.1
|
||||
*/
|
||||
class JPathway
|
||||
{
|
||||
/**
|
||||
* @var array Array to hold the pathway item objects
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_pathway = array();
|
||||
|
||||
/**
|
||||
* @var integer Integer number of items in the pathway
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $_count = 0;
|
||||
|
||||
/**
|
||||
* @var array JPathway instances container.
|
||||
* @since 11.3
|
||||
*/
|
||||
protected static $instances = array();
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $options The class options.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JPathway object
|
||||
*
|
||||
* @param string $client The name of the client
|
||||
* @param array $options An associative array of options
|
||||
*
|
||||
* @return JPathway A JPathway object.
|
||||
*
|
||||
* @since 11.1
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function getInstance($client, $options = array())
|
||||
{
|
||||
if (empty(self::$instances[$client]))
|
||||
{
|
||||
// Create a JPathway object
|
||||
$classname = 'JPathway' . ucfirst($client);
|
||||
|
||||
if (!class_exists($classname))
|
||||
{
|
||||
JLog::add('Non-autoloadable JPathway subclasses are deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
// Load the pathway object
|
||||
$info = JApplicationHelper::getClientInfo($client, true);
|
||||
|
||||
if (is_object($info))
|
||||
{
|
||||
$path = $info->path . '/includes/pathway.php';
|
||||
if (file_exists($path))
|
||||
{
|
||||
include_once $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists($classname))
|
||||
{
|
||||
self::$instances[$client] = new $classname($options);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException(JText::sprintf('JLIB_APPLICATION_ERROR_PATHWAY_LOAD', $client), 500);
|
||||
}
|
||||
}
|
||||
|
||||
return self::$instances[$client];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the JPathWay items array
|
||||
*
|
||||
* @return array Array of pathway items
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getPathway()
|
||||
{
|
||||
$pw = $this->_pathway;
|
||||
|
||||
// Use array_values to reset the array keys numerically
|
||||
return array_values($pw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the JPathway items array.
|
||||
*
|
||||
* @param array $pathway An array of pathway objects.
|
||||
*
|
||||
* @return array The previous pathway data.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setPathway($pathway)
|
||||
{
|
||||
$oldPathway = $this->_pathway;
|
||||
|
||||
// Set the new pathway.
|
||||
$this->_pathway = array_values((array) $pathway);
|
||||
|
||||
return array_values($oldPathway);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return an array of the pathway names.
|
||||
*
|
||||
* @return array Array of names of pathway items
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function getPathwayNames()
|
||||
{
|
||||
$names = array();
|
||||
|
||||
// Build the names array using just the names of each pathway item
|
||||
foreach ($this->_pathway as $item)
|
||||
{
|
||||
$names[] = $item->name;
|
||||
}
|
||||
|
||||
// Use array_values to reset the array keys numerically
|
||||
return array_values($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and add an item to the pathway.
|
||||
*
|
||||
* @param string $name The name of the item.
|
||||
* @param string $link The link to the item.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function addItem($name, $link = '')
|
||||
{
|
||||
$ret = false;
|
||||
|
||||
if ($this->_pathway[] = $this->_makeItem($name, $link))
|
||||
{
|
||||
$ret = true;
|
||||
$this->_count++;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set item name.
|
||||
*
|
||||
* @param integer $id The id of the item on which to set the name.
|
||||
* @param string $name The name to set.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setItemName($id, $name)
|
||||
{
|
||||
$ret = false;
|
||||
|
||||
if (isset($this->_pathway[$id]))
|
||||
{
|
||||
$this->_pathway[$id]->name = $name;
|
||||
$ret = true;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new pathway object.
|
||||
*
|
||||
* @param string $name Name of the item
|
||||
* @param string $link Link to the item
|
||||
*
|
||||
* @return JPathway Pathway item object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _makeItem($name, $link)
|
||||
{
|
||||
$item = new stdClass;
|
||||
$item->name = html_entity_decode($name, ENT_COMPAT, 'UTF-8');
|
||||
$item->link = $link;
|
||||
|
||||
return $item;
|
||||
}
|
||||
}
|
1
libraries/legacy/request/index.html
Normal file
1
libraries/legacy/request/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
554
libraries/legacy/request/request.php
Normal file
554
libraries/legacy/request/request.php
Normal file
@ -0,0 +1,554 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Request
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Create the request global object
|
||||
*/
|
||||
$GLOBALS['_JREQUEST'] = array();
|
||||
|
||||
/**
|
||||
* Set the available masks for cleaning variables
|
||||
*/
|
||||
const JREQUEST_NOTRIM = 1;
|
||||
const JREQUEST_ALLOWRAW = 2;
|
||||
const JREQUEST_ALLOWHTML = 4;
|
||||
|
||||
JLog::add('JRequest is deprecated.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* JRequest Class
|
||||
*
|
||||
* This class serves to provide the Joomla Platform with a common interface to access
|
||||
* request variables. This includes $_POST, $_GET, and naturally $_REQUEST. Variables
|
||||
* can be passed through an input filter to avoid injection or returned raw.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Request
|
||||
* @since 11.1
|
||||
* @deprecated 12.1 (Platform) & 4.0 (CMS) - Get the JInput object from the application instead
|
||||
*/
|
||||
class JRequest
|
||||
{
|
||||
/**
|
||||
* Gets the full request path.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function getURI()
|
||||
{
|
||||
$uri = JUri::getInstance();
|
||||
return $uri->toString(array('path', 'query'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request method.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1 Use JInput::getMethod() instead
|
||||
*/
|
||||
public static function getMethod()
|
||||
{
|
||||
$method = strtoupper($_SERVER['REQUEST_METHOD']);
|
||||
return $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given variable.
|
||||
*
|
||||
* The default behaviour is fetching variables depending on the
|
||||
* current request method: GET and HEAD will result in returning
|
||||
* an entry from $_GET, POST and PUT will result in returning an
|
||||
* entry from $_POST.
|
||||
*
|
||||
* You can force the source by setting the $hash parameter:
|
||||
*
|
||||
* post $_POST
|
||||
* get $_GET
|
||||
* files $_FILES
|
||||
* cookie $_COOKIE
|
||||
* env $_ENV
|
||||
* server $_SERVER
|
||||
* method via current $_SERVER['REQUEST_METHOD']
|
||||
* default $_REQUEST
|
||||
*
|
||||
* @param string $name Variable name.
|
||||
* @param string $default Default value if the variable does not exist.
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
|
||||
* @param string $type Return type for the variable, for valid values see {@link JFilterInput::clean()}.
|
||||
* @param integer $mask Filter mask for the variable.
|
||||
*
|
||||
* @return mixed Requested variable.
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1 Use JInput::Get
|
||||
*/
|
||||
public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0)
|
||||
{
|
||||
// Ensure hash and type are uppercase
|
||||
$hash = strtoupper($hash);
|
||||
if ($hash === 'METHOD')
|
||||
{
|
||||
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
|
||||
}
|
||||
$type = strtoupper($type);
|
||||
$sig = $hash . $type . $mask;
|
||||
|
||||
// Get the input hash
|
||||
switch ($hash)
|
||||
{
|
||||
case 'GET':
|
||||
$input = &$_GET;
|
||||
break;
|
||||
case 'POST':
|
||||
$input = &$_POST;
|
||||
break;
|
||||
case 'FILES':
|
||||
$input = &$_FILES;
|
||||
break;
|
||||
case 'COOKIE':
|
||||
$input = &$_COOKIE;
|
||||
break;
|
||||
case 'ENV':
|
||||
$input = &$_ENV;
|
||||
break;
|
||||
case 'SERVER':
|
||||
$input = &$_SERVER;
|
||||
break;
|
||||
default:
|
||||
$input = &$_REQUEST;
|
||||
$hash = 'REQUEST';
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['_JREQUEST'][$name]['SET.' . $hash]) && ($GLOBALS['_JREQUEST'][$name]['SET.' . $hash] === true))
|
||||
{
|
||||
// Get the variable from the input hash
|
||||
$var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default;
|
||||
$var = self::_cleanVar($var, $mask, $type);
|
||||
}
|
||||
elseif (!isset($GLOBALS['_JREQUEST'][$name][$sig]))
|
||||
{
|
||||
if (isset($input[$name]) && $input[$name] !== null)
|
||||
{
|
||||
// Get the variable from the input hash and clean it
|
||||
$var = self::_cleanVar($input[$name], $mask, $type);
|
||||
|
||||
$GLOBALS['_JREQUEST'][$name][$sig] = $var;
|
||||
}
|
||||
elseif ($default !== null)
|
||||
{
|
||||
// Clean the default value
|
||||
$var = self::_cleanVar($default, $mask, $type);
|
||||
}
|
||||
else
|
||||
{
|
||||
$var = $default;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$var = $GLOBALS['_JREQUEST'][$name][$sig];
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given filtered variable. The integer
|
||||
* filter will allow only digits and the - sign to be returned. This is currently
|
||||
* only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name.
|
||||
* @param string $default Default value if the variable does not exist.
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
|
||||
*
|
||||
* @return integer Requested variable.
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function getInt($name, $default = 0, $hash = 'default')
|
||||
{
|
||||
return self::getVar($name, $default, $hash, 'int');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given filtered variable. The unsigned integer
|
||||
* filter will allow only digits to be returned. This is currently
|
||||
* only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name.
|
||||
* @param string $default Default value if the variable does not exist.
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
|
||||
*
|
||||
* @return integer Requested variable.
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getUInt($name, $default = 0, $hash = 'default')
|
||||
{
|
||||
return self::getVar($name, $default, $hash, 'uint');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given filtered variable. The float
|
||||
* filter only allows digits and periods. This is currently
|
||||
* only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name.
|
||||
* @param string $default Default value if the variable does not exist.
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
|
||||
*
|
||||
* @return float Requested variable.
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function getFloat($name, $default = 0.0, $hash = 'default')
|
||||
{
|
||||
return self::getVar($name, $default, $hash, 'float');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given filtered variable. The bool
|
||||
* filter will only return true/false bool values. This is
|
||||
* currently only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name.
|
||||
* @param string $default Default value if the variable does not exist.
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
|
||||
*
|
||||
* @return boolean Requested variable.
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getBool($name, $default = false, $hash = 'default')
|
||||
{
|
||||
return self::getVar($name, $default, $hash, 'bool');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given filtered variable. The word
|
||||
* filter only allows the characters [A-Za-z_]. This is currently
|
||||
* only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name.
|
||||
* @param string $default Default value if the variable does not exist.
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
|
||||
*
|
||||
* @return string Requested variable.
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function getWord($name, $default = '', $hash = 'default')
|
||||
{
|
||||
return self::getVar($name, $default, $hash, 'word');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cmd (Word and Integer0 filter
|
||||
*
|
||||
* Fetches and returns a given filtered variable. The cmd
|
||||
* filter only allows the characters [A-Za-z0-9.-_]. This is
|
||||
* currently only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name
|
||||
* @param string $default Default value if the variable does not exist
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
||||
*
|
||||
* @return string Requested variable
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function getCmd($name, $default = '', $hash = 'default')
|
||||
{
|
||||
return self::getVar($name, $default, $hash, 'cmd');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a given filtered variable. The string
|
||||
* filter deletes 'bad' HTML code, if not overridden by the mask.
|
||||
* This is currently only a proxy function for getVar().
|
||||
*
|
||||
* See getVar() for more in-depth documentation on the parameters.
|
||||
*
|
||||
* @param string $name Variable name
|
||||
* @param string $default Default value if the variable does not exist
|
||||
* @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
||||
* @param integer $mask Filter mask for the variable
|
||||
*
|
||||
* @return string Requested variable
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function getString($name, $default = '', $hash = 'default', $mask = 0)
|
||||
{
|
||||
// Cast to string, in case JREQUEST_ALLOWRAW was specified for mask
|
||||
return (string) self::getVar($name, $default, $hash, 'string', $mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a variable in one of the request variables.
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param string $value Value
|
||||
* @param string $hash Hash
|
||||
* @param boolean $overwrite Boolean
|
||||
*
|
||||
* @return string Previous value
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @deprecated 12.1
|
||||
*/
|
||||
public static function setVar($name, $value = null, $hash = 'method', $overwrite = true)
|
||||
{
|
||||
// If overwrite is true, makes sure the variable hasn't been set yet
|
||||
if (!$overwrite && array_key_exists($name, $_REQUEST))
|
||||
{
|
||||
return $_REQUEST[$name];
|
||||
}
|
||||
|
||||
// Clean global request var
|
||||
$GLOBALS['_JREQUEST'][$name] = array();
|
||||
|
||||
// Get the request hash value
|
||||
$hash = strtoupper($hash);
|
||||
if ($hash === 'METHOD')
|
||||
{
|
||||
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
|
||||
}
|
||||
|
||||
$previous = array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : null;
|
||||
|
||||
switch ($hash)
|
||||
{
|
||||
case 'GET':
|
||||
$_GET[$name] = $value;
|
||||
$_REQUEST[$name] = $value;
|
||||
break;
|
||||
case 'POST':
|
||||
$_POST[$name] = $value;
|
||||
$_REQUEST[$name] = $value;
|
||||
break;
|
||||
case 'COOKIE':
|
||||
$_COOKIE[$name] = $value;
|
||||
$_REQUEST[$name] = $value;
|
||||
break;
|
||||
case 'FILES':
|
||||
$_FILES[$name] = $value;
|
||||
break;
|
||||
case 'ENV':
|
||||
$_ENV['name'] = $value;
|
||||
break;
|
||||
case 'SERVER':
|
||||
$_SERVER['name'] = $value;
|
||||
break;
|
||||
}
|
||||
|
||||
// Mark this variable as 'SET'
|
||||
$GLOBALS['_JREQUEST'][$name]['SET.' . $hash] = true;
|
||||
$GLOBALS['_JREQUEST'][$name]['SET.REQUEST'] = true;
|
||||
|
||||
return $previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns a request array.
|
||||
*
|
||||
* The default behaviour is fetching variables depending on the
|
||||
* current request method: GET and HEAD will result in returning
|
||||
* $_GET, POST and PUT will result in returning $_POST.
|
||||
*
|
||||
* You can force the source by setting the $hash parameter:
|
||||
*
|
||||
* post $_POST
|
||||
* get $_GET
|
||||
* files $_FILES
|
||||
* cookie $_COOKIE
|
||||
* env $_ENV
|
||||
* server $_SERVER
|
||||
* method via current $_SERVER['REQUEST_METHOD']
|
||||
* default $_REQUEST
|
||||
*
|
||||
* @param string $hash to get (POST, GET, FILES, METHOD).
|
||||
* @param integer $mask Filter mask for the variable.
|
||||
*
|
||||
* @return mixed Request hash.
|
||||
*
|
||||
* @deprecated 12.1 User JInput::get
|
||||
* @see JInput
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function get($hash = 'default', $mask = 0)
|
||||
{
|
||||
$hash = strtoupper($hash);
|
||||
|
||||
if ($hash === 'METHOD')
|
||||
{
|
||||
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
|
||||
}
|
||||
|
||||
switch ($hash)
|
||||
{
|
||||
case 'GET':
|
||||
$input = $_GET;
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
$input = $_POST;
|
||||
break;
|
||||
|
||||
case 'FILES':
|
||||
$input = $_FILES;
|
||||
break;
|
||||
|
||||
case 'COOKIE':
|
||||
$input = $_COOKIE;
|
||||
break;
|
||||
|
||||
case 'ENV':
|
||||
$input = &$_ENV;
|
||||
break;
|
||||
|
||||
case 'SERVER':
|
||||
$input = &$_SERVER;
|
||||
break;
|
||||
|
||||
default:
|
||||
$input = $_REQUEST;
|
||||
break;
|
||||
}
|
||||
|
||||
$result = self::_cleanVar($input, $mask);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a request variable.
|
||||
*
|
||||
* @param array $array An associative array of key-value pairs.
|
||||
* @param string $hash The request variable to set (POST, GET, FILES, METHOD).
|
||||
* @param boolean $overwrite If true and an existing key is found, the value is overwritten, otherwise it is ignored.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 12.1 Use JInput::Set
|
||||
* @see JInput::Set
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function set($array, $hash = 'default', $overwrite = true)
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
self::setVar($key, $value, $hash, $overwrite);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a form token in the request.
|
||||
*
|
||||
* Use in conjunction with JHtml::_('form.token').
|
||||
*
|
||||
* @param string $method The request method in which to look for the token key.
|
||||
*
|
||||
* @return boolean True if found and valid, false otherwise.
|
||||
*
|
||||
* @deprecated 12.1 Use JSession::checkToken() instead. Note that 'default' has to become 'request'.
|
||||
* @since 11.1
|
||||
*/
|
||||
public static function checkToken($method = 'post')
|
||||
{
|
||||
if ($method == 'default')
|
||||
{
|
||||
$method = 'request';
|
||||
}
|
||||
|
||||
return JSession::checkToken($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up an input variable.
|
||||
*
|
||||
* @param mixed $var The input variable.
|
||||
* @param integer $mask Filter bit mask.
|
||||
* 1 = no trim: If this flag is cleared and the input is a string, the string will have leading and trailing
|
||||
* whitespace trimmed.
|
||||
* 2 = allow_raw: If set, no more filtering is performed, higher bits are ignored.
|
||||
* 4 = allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering
|
||||
* is performed. If no bits other than the 1 bit is set, a strict filter is applied.
|
||||
* @param string $type The variable type {@see JFilterInput::clean()}.
|
||||
*
|
||||
* @return mixed Same as $var
|
||||
*
|
||||
* @deprecated 12.1
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static function _cleanVar($var, $mask = 0, $type = null)
|
||||
{
|
||||
// If the no trim flag is not set, trim the variable
|
||||
if (!($mask & 1) && is_string($var))
|
||||
{
|
||||
$var = trim($var);
|
||||
}
|
||||
|
||||
// Now we handle input filtering
|
||||
if ($mask & 2)
|
||||
{
|
||||
// If the allow raw flag is set, do not modify the variable
|
||||
$var = $var;
|
||||
}
|
||||
elseif ($mask & 4)
|
||||
{
|
||||
// If the allow HTML flag is set, apply a safe HTML filter to the variable
|
||||
$safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1);
|
||||
$var = $safeHtmlFilter->clean($var, $type);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since no allow flags were set, we will apply the most strict filter to the variable
|
||||
// $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults.
|
||||
$noHtmlFilter = JFilterInput::getInstance();
|
||||
$var = $noHtmlFilter->clean($var, $type);
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
}
|
1
libraries/legacy/simplecrypt/index.html
Normal file
1
libraries/legacy/simplecrypt/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
85
libraries/legacy/simplecrypt/simplecrypt.php
Normal file
85
libraries/legacy/simplecrypt/simplecrypt.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Simplecrypt
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* JSimpleCrypt is a very simple encryption algorithm for encrypting/decrypting strings
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Simplecrypt
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use JCrypt instead.
|
||||
*/
|
||||
class JSimplecrypt
|
||||
{
|
||||
/**
|
||||
* Encryption/Decryption Key
|
||||
*
|
||||
* @var JCrypt
|
||||
* @since 12.1
|
||||
* @deprecated 12.3 Use JCrypt instead.
|
||||
*/
|
||||
private $_crypt;
|
||||
|
||||
/**
|
||||
* Object Constructor takes an optional key to be used for encryption/decryption. If no key is given then the
|
||||
* secret word from the configuration object is used.
|
||||
*
|
||||
* @param string $privateKey Optional encryption key
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 Use JCrypt instead.
|
||||
*/
|
||||
public function __construct($privateKey = null)
|
||||
{
|
||||
JLog::add('JSimpleCrypt is deprecated. Use JCrypt instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if (empty($privateKey))
|
||||
{
|
||||
$privateKey = md5(JFactory::getConfig()->get('secret'));
|
||||
}
|
||||
|
||||
// Build the JCryptKey object.
|
||||
$key = new JCryptKey('simple', $privateKey, $privateKey);
|
||||
|
||||
// Setup the JCrypt object.
|
||||
$this->_crypt = new JCrypt(new JCryptCipherSimple, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt a string
|
||||
*
|
||||
* @param string $s String to decrypt
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 Use JCrypt instead.
|
||||
*/
|
||||
public function decrypt($s)
|
||||
{
|
||||
return $this->_crypt->decrypt($s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt a string
|
||||
*
|
||||
* @param string $s String to encrypt
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 12.3 Use JCrypt instead.
|
||||
*/
|
||||
public function encrypt($s)
|
||||
{
|
||||
return $this->_crypt->encrypt($s);
|
||||
}
|
||||
}
|
67
libraries/legacy/simplepie/factory.php
Normal file
67
libraries/legacy/simplepie/factory.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Simplepie
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
jimport('simplepie.simplepie');
|
||||
|
||||
/**
|
||||
* Class to maintain a pathway.
|
||||
*
|
||||
* The user's navigated path within the application.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Simplepie
|
||||
* @since 12.2
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use JFeed or supply your own methods
|
||||
*/
|
||||
class JSimplepieFactory
|
||||
{
|
||||
/**
|
||||
* Get a parsed XML Feed Source
|
||||
*
|
||||
* @param string $url Url for feed source.
|
||||
* @param integer $cache_time Time to cache feed for (using internal cache mechanism).
|
||||
*
|
||||
* @return mixed SimplePie parsed object on success, false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
* @deprecated 4.0 Use JFeedFactory($url) instead.
|
||||
*
|
||||
* @note In 3.2 will be proxied to JFeedFactory()
|
||||
*/
|
||||
public static function getFeedParser($url, $cache_time = 0)
|
||||
{
|
||||
JLog::add(__METHOD__ . ' is deprecated. Use JFeedFactory() or supply Simple Pie instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$cache = JFactory::getCache('feed_parser', 'callback');
|
||||
|
||||
if ($cache_time > 0)
|
||||
{
|
||||
$cache->setLifeTime($cache_time);
|
||||
}
|
||||
|
||||
$simplepie = new SimplePie(null, null, 0);
|
||||
|
||||
$simplepie->enable_cache(false);
|
||||
$simplepie->set_feed_url($url);
|
||||
$simplepie->force_feed(true);
|
||||
|
||||
$contents = $cache->get(array($simplepie, 'init'), null, false, false);
|
||||
|
||||
if ($contents)
|
||||
{
|
||||
return $simplepie;
|
||||
}
|
||||
|
||||
JLog::add(JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'), JLog::WARNING, 'jerror');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
1
libraries/legacy/simplepie/index.html
Normal file
1
libraries/legacy/simplepie/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
229
libraries/legacy/table/category.php
Normal file
229
libraries/legacy/table/category.php
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Category table
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
* @since 11.1
|
||||
*/
|
||||
class JTableCategory extends JTableNested
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabaseDriver $db Database driver object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct('#__categories', 'id', $db);
|
||||
|
||||
$this->access = (int) JFactory::getConfig()->get('access');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to compute the default name of the asset.
|
||||
* The default name is in the form table_name.id
|
||||
* where id is the value of the primary key of the table.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _getAssetName()
|
||||
{
|
||||
$k = $this->_tbl_key;
|
||||
return $this->extension . '.category.' . (int) $this->$k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to return the title to use for the asset table.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _getAssetTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent asset id for the record
|
||||
*
|
||||
* @param JTable $table A JTable object for the asset parent.
|
||||
* @param integer $id The id for the asset
|
||||
*
|
||||
* @return integer The id of the asset's parent
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _getAssetParentId($table = null, $id = null)
|
||||
{
|
||||
$assetId = null;
|
||||
|
||||
// This is a category under a category.
|
||||
if ($this->parent_id > 1)
|
||||
{
|
||||
// Build the query to get the asset id for the parent category.
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select($this->_db->quoteName('asset_id'))
|
||||
->from($this->_db->quoteName('#__categories'))
|
||||
->where($this->_db->quoteName('id') . ' = ' . $this->parent_id);
|
||||
|
||||
// Get the asset id from the database.
|
||||
$this->_db->setQuery($query);
|
||||
if ($result = $this->_db->loadResult())
|
||||
{
|
||||
$assetId = (int) $result;
|
||||
}
|
||||
}
|
||||
// This is a category that needs to parent with the extension.
|
||||
elseif ($assetId === null)
|
||||
{
|
||||
// Build the query to get the asset id for the parent category.
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select($this->_db->quoteName('id'))
|
||||
->from($this->_db->quoteName('#__assets'))
|
||||
->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote($this->extension));
|
||||
|
||||
// Get the asset id from the database.
|
||||
$this->_db->setQuery($query);
|
||||
if ($result = $this->_db->loadResult())
|
||||
{
|
||||
$assetId = (int) $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the asset id.
|
||||
if ($assetId)
|
||||
{
|
||||
return $assetId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::_getAssetParentId($table, $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override check function
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @see JTable::check
|
||||
* @since 11.1
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// Check for a title.
|
||||
if (trim($this->title) == '')
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_CATEGORY'));
|
||||
return false;
|
||||
}
|
||||
$this->alias = trim($this->alias);
|
||||
if (empty($this->alias))
|
||||
{
|
||||
$this->alias = $this->title;
|
||||
}
|
||||
|
||||
$this->alias = JApplication::stringURLSafe($this->alias);
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function.
|
||||
*
|
||||
* @param array $array named array
|
||||
* @param string $ignore An optional array or space separated list of properties
|
||||
* to ignore while binding.
|
||||
*
|
||||
* @return mixed Null if operation was satisfactory, otherwise returns an error
|
||||
*
|
||||
* @see JTable::bind
|
||||
* @since 11.1
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
if (isset($array['params']) && is_array($array['params']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadArray($array['params']);
|
||||
$array['params'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['metadata']) && is_array($array['metadata']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadArray($array['metadata']);
|
||||
$array['metadata'] = (string) $registry;
|
||||
}
|
||||
|
||||
// Bind the rules.
|
||||
if (isset($array['rules']) && is_array($array['rules']))
|
||||
{
|
||||
$rules = new JAccessRules($array['rules']);
|
||||
$this->setRules($rules);
|
||||
}
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden JTable::store to set created/modified and user id.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
$date = JFactory::getDate();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
// Existing category
|
||||
$this->modified_time = $date->toSql();
|
||||
$this->modified_user_id = $user->get('id');
|
||||
}
|
||||
else
|
||||
{
|
||||
// New category
|
||||
$this->created_time = $date->toSql();
|
||||
$this->created_user_id = $user->get('id');
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = JTable::getInstance('Category', 'JTable', array('dbo' => $this->getDbo()));
|
||||
|
||||
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'extension' => $this->extension))
|
||||
&& ($table->id != $this->id || $this->id == 0))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
}
|
378
libraries/legacy/table/content.php
Normal file
378
libraries/legacy/table/content.php
Normal file
@ -0,0 +1,378 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Content table
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
* @since 11.1
|
||||
* @deprecated Class will be removed upon completion of transition to UCM
|
||||
*/
|
||||
class JTableContent extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabaseDriver $db A database connector object
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct('#__content', 'id', $db);
|
||||
|
||||
/*
|
||||
* This is left here for reference:
|
||||
*
|
||||
* This would set up the tags observer in $this from here (so not entirely decoupled):
|
||||
* JTableObserverTags::createObserver($this, array('typeAlias' => 'com_content.article'));
|
||||
*
|
||||
* But this makes the relation between content and tags completely external to Content as JTable is observable:
|
||||
* So we are doing this only once in libraries/cms.php:
|
||||
* JObserverFactory::addObserverClassToClass('JTableObserverTags', 'JTableContent', array('typeAlias' => 'com_content.article'));
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to compute the default name of the asset.
|
||||
* The default name is in the form table_name.id
|
||||
* where id is the value of the primary key of the table.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _getAssetName()
|
||||
{
|
||||
$k = $this->_tbl_key;
|
||||
return 'com_content.article.' . (int) $this->$k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to return the title to use for the asset table.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _getAssetTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the parent asset id for the record
|
||||
*
|
||||
* @param JTable $table A JTable object (optional) for the asset parent
|
||||
* @param integer $id The id (optional) of the content.
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function _getAssetParentId($table = null, $id = null)
|
||||
{
|
||||
$assetId = null;
|
||||
|
||||
// This is a article under a category.
|
||||
if ($this->catid)
|
||||
{
|
||||
// Build the query to get the asset id for the parent category.
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select($this->_db->quoteName('asset_id'))
|
||||
->from($this->_db->quoteName('#__categories'))
|
||||
->where($this->_db->quoteName('id') . ' = ' . (int) $this->catid);
|
||||
|
||||
// Get the asset id from the database.
|
||||
$this->_db->setQuery($query);
|
||||
if ($result = $this->_db->loadResult())
|
||||
{
|
||||
$assetId = (int) $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the asset id.
|
||||
if ($assetId)
|
||||
{
|
||||
return $assetId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::_getAssetParentId($table, $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function
|
||||
*
|
||||
* @param array $array Named array
|
||||
* @param mixed $ignore An optional array or space separated list of properties
|
||||
* to ignore while binding.
|
||||
*
|
||||
* @return mixed Null if operation was satisfactory, otherwise returns an error string
|
||||
*
|
||||
* @see JTable::bind
|
||||
* @since 11.1
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
// Search for the {readmore} tag and split the text up accordingly.
|
||||
if (isset($array['articletext']))
|
||||
{
|
||||
$pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
|
||||
$tagPos = preg_match($pattern, $array['articletext']);
|
||||
|
||||
if ($tagPos == 0)
|
||||
{
|
||||
$this->introtext = $array['articletext'];
|
||||
$this->fulltext = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
list ($this->introtext, $this->fulltext) = preg_split($pattern, $array['articletext'], 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($array['attribs']) && is_array($array['attribs']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadArray($array['attribs']);
|
||||
$array['attribs'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['metadata']) && is_array($array['metadata']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadArray($array['metadata']);
|
||||
$array['metadata'] = (string) $registry;
|
||||
}
|
||||
|
||||
// Bind the rules.
|
||||
if (isset($array['rules']) && is_array($array['rules']))
|
||||
{
|
||||
$rules = new JAccessRules($array['rules']);
|
||||
$this->setRules($rules);
|
||||
}
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean True on success, false on failure
|
||||
*
|
||||
* @see JTable::check
|
||||
* @since 11.1
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
if (trim($this->title) == '')
|
||||
{
|
||||
$this->setError(JText::_('COM_CONTENT_WARNING_PROVIDE_VALID_NAME'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trim($this->alias) == '')
|
||||
{
|
||||
$this->alias = $this->title;
|
||||
}
|
||||
|
||||
$this->alias = JApplication::stringURLSafe($this->alias);
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
if (trim(str_replace(' ', '', $this->fulltext)) == '')
|
||||
{
|
||||
$this->fulltext = '';
|
||||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up)
|
||||
{
|
||||
// Swap the dates.
|
||||
$temp = $this->publish_up;
|
||||
$this->publish_up = $this->publish_down;
|
||||
$this->publish_down = $temp;
|
||||
}
|
||||
|
||||
// Clean up keywords -- eliminate extra spaces between phrases
|
||||
// and cr (\r) and lf (\n) characters from string
|
||||
if (!empty($this->metakey))
|
||||
{
|
||||
// Only process if not empty
|
||||
|
||||
// Array of characters to remove
|
||||
$bad_characters = array("\n", "\r", "\"", "<", ">");
|
||||
|
||||
// Remove bad characters
|
||||
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
|
||||
|
||||
// Create array using commas as delimiter
|
||||
$keys = explode(',', $after_clean);
|
||||
|
||||
$clean_keys = array();
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (trim($key))
|
||||
{
|
||||
// Ignore blank keywords
|
||||
$clean_keys[] = trim($key);
|
||||
}
|
||||
}
|
||||
// Put array back together delimited by ", "
|
||||
$this->metakey = implode(", ", $clean_keys);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides JTable::store to set modified data and user id.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
$date = JFactory::getDate();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
// Existing item
|
||||
$this->modified = $date->toSql();
|
||||
$this->modified_by = $user->get('id');
|
||||
}
|
||||
else
|
||||
{
|
||||
// New article. An article created and created_by field can be set by the user,
|
||||
// so we don't touch either of these if they are set.
|
||||
if (!(int) $this->created)
|
||||
{
|
||||
$this->created = $date->toSql();
|
||||
}
|
||||
|
||||
if (empty($this->created_by))
|
||||
{
|
||||
$this->created_by = $user->get('id');
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = JTable::getInstance('Content', 'JTable');
|
||||
|
||||
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the publishing state for a row or list of rows in the database
|
||||
* table. The method respects checked out rows by other users and will attempt
|
||||
* to checkin rows that it can after adjustments are made.
|
||||
*
|
||||
* @param mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
|
||||
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
|
||||
* @param integer $userId The user id of the user performing the operation.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function publish($pks = null, $state = 1, $userId = 0)
|
||||
{
|
||||
$k = $this->_tbl_key;
|
||||
|
||||
// Sanitize input.
|
||||
JArrayHelper::toInteger($pks);
|
||||
$userId = (int) $userId;
|
||||
$state = (int) $state;
|
||||
|
||||
// If there are no primary keys set check to see if the instance key is set.
|
||||
if (empty($pks))
|
||||
{
|
||||
if ($this->$k)
|
||||
{
|
||||
$pks = array($this->$k);
|
||||
}
|
||||
// Nothing to set publishing state on, return false.
|
||||
else
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the WHERE clause for the primary keys.
|
||||
$where = $k . '=' . implode(' OR ' . $k . '=', $pks);
|
||||
|
||||
// Determine if there is checkin support for the table.
|
||||
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time'))
|
||||
{
|
||||
$checkin = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')';
|
||||
}
|
||||
|
||||
// Update the publishing state for rows with the given primary keys.
|
||||
$query = $this->_db->getQuery(true)
|
||||
->update($this->_db->quoteName($this->_tbl))
|
||||
->set($this->_db->quoteName('state') . ' = ' . (int) $state)
|
||||
->where('(' . $where . ')' . $checkin);
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$this->_db->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// If checkin is supported and all rows were adjusted, check them in.
|
||||
if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
|
||||
{
|
||||
// Checkin the rows.
|
||||
foreach ($pks as $pk)
|
||||
{
|
||||
$this->checkin($pk);
|
||||
}
|
||||
}
|
||||
|
||||
// If the JTable instance value is in the list of primary keys that were set, set the instance.
|
||||
if (in_array($this->$k, $pks))
|
||||
{
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
$this->setError('');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
1
libraries/legacy/table/index.html
Normal file
1
libraries/legacy/table/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
204
libraries/legacy/table/menu.php
Normal file
204
libraries/legacy/table/menu.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Menu table
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
* @since 11.1
|
||||
*/
|
||||
class JTableMenu extends JTableNested
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabaseDriver $db Database driver object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct('#__menu', 'id', $db);
|
||||
|
||||
// Set the default access level.
|
||||
$this->access = (int) JFactory::getConfig()->get('access');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function
|
||||
*
|
||||
* @param array $array Named array
|
||||
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
|
||||
*
|
||||
* @return mixed Null if operation was satisfactory, otherwise returns an error
|
||||
*
|
||||
* @see JTable::bind
|
||||
* @since 11.1
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
// Verify that the default home menu is not unset
|
||||
if ($this->home == '1' && $this->language == '*' && ($array['home'] == '0'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT_DEFAULT'));
|
||||
return false;
|
||||
}
|
||||
// Verify that the default home menu set to "all" languages" is not unset
|
||||
if ($this->home == '1' && $this->language == '*' && ($array['language'] != '*'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that the default home menu is not unpublished
|
||||
if ($this->home == '1' && $this->language == '*' && $array['published'] != '1')
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($array['params']) && is_array($array['params']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadArray($array['params']);
|
||||
$array['params'] = (string) $registry;
|
||||
}
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @see JTable::check
|
||||
* @since 11.1
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// If the alias field is empty, set it to the title.
|
||||
$this->alias = trim($this->alias);
|
||||
if ((empty($this->alias)) && ($this->type != 'alias' && $this->type != 'url'))
|
||||
{
|
||||
$this->alias = $this->title;
|
||||
}
|
||||
|
||||
// Make the alias URL safe.
|
||||
$this->alias = JApplication::stringURLSafe($this->alias);
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
// Cast the home property to an int for checking.
|
||||
$this->home = (int) $this->home;
|
||||
|
||||
// Verify that a first level menu item alias is not 'component'.
|
||||
if ($this->parent_id == 1 && $this->alias == 'component')
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that a first level menu item alias is not the name of a folder.
|
||||
jimport('joomla.filesystem.folder');
|
||||
if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT)))
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that the home item a component.
|
||||
if ($this->home && $this->type != 'component')
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded store function
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return mixed False on failure, positive integer on success.
|
||||
*
|
||||
* @see JTable::store
|
||||
* @since 11.1
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
|
||||
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => (int) $this->client_id, 'language' => $this->language))
|
||||
&& ($table->id != $this->id || $this->id == 0))
|
||||
{
|
||||
if ($this->menutype == $table->menutype)
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS_ROOT'));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Verify that the home page for this language is unique
|
||||
if ($this->home == '1')
|
||||
{
|
||||
$table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
|
||||
if ($table->load(array('home' => '1', 'language' => $this->language)))
|
||||
{
|
||||
if ($table->checked_out && $table->checked_out != $this->checked_out)
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
|
||||
return false;
|
||||
}
|
||||
$table->home = 0;
|
||||
$table->checked_out = 0;
|
||||
$table->checked_out_time = $db->getNullDate();
|
||||
$table->store();
|
||||
}
|
||||
// Verify that the home page for this menu is unique.
|
||||
if ($table->load(array('home' => '1', 'menutype' => $this->menutype)) && ($table->id != $this->id || $this->id == 0))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!parent::store($updateNulls))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Get the new path in case the node was moved
|
||||
$pathNodes = $this->getPath();
|
||||
$segments = array();
|
||||
foreach ($pathNodes as $node)
|
||||
{
|
||||
// Don't include root in path
|
||||
if ($node->alias != 'root')
|
||||
{
|
||||
$segments[] = $node->alias;
|
||||
}
|
||||
}
|
||||
$newPath = trim(implode('/', $segments), ' /\\');
|
||||
|
||||
// Use new path for partial rebuild of table
|
||||
// Rebuild will return positive integer on success, false on failure
|
||||
return ($this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0);
|
||||
}
|
||||
}
|
1
libraries/legacy/table/menu/index.html
Normal file
1
libraries/legacy/table/menu/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
226
libraries/legacy/table/menu/type.php
Normal file
226
libraries/legacy/table/menu/type.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Menu Types table
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
* @since 11.1
|
||||
*/
|
||||
class JTableMenuType extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabaseDriver $db Database driver object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct('#__menu_types', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean True on success, false on failure
|
||||
*
|
||||
* @see JTable::check
|
||||
* @since 11.1
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$this->menutype = JApplication::stringURLSafe($this->menutype);
|
||||
if (empty($this->menutype))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENUTYPE_EMPTY'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sanitise data.
|
||||
if (trim($this->title) == '')
|
||||
{
|
||||
$this->title = $this->menutype;
|
||||
}
|
||||
|
||||
// Check for unique menutype.
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select('COUNT(id)')
|
||||
->from($this->_db->quoteName('#__menu_types'))
|
||||
->where($this->_db->quoteName('menutype') . ' = ' . $this->_db->quote($this->menutype))
|
||||
->where($this->_db->quoteName('id') . ' <> ' . (int) $this->id);
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
if ($this->_db->loadResult())
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENUTYPE_EXISTS', $this->menutype));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to store a row in the database from the JTable instance properties.
|
||||
* If a primary key value is set the row with that primary key value will be
|
||||
* updated with the instance property values. If no primary key value is set
|
||||
* a new row will be inserted into the database with the properties from the
|
||||
* JTable instance.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @link http://docs.joomla.org/JTable/store
|
||||
* @since 11.1
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
if ($this->id)
|
||||
{
|
||||
// Get the user id
|
||||
$userId = JFactory::getUser()->id;
|
||||
|
||||
// Get the old value of the table
|
||||
$table = JTable::getInstance('Menutype', 'JTable');
|
||||
$table->load($this->id);
|
||||
|
||||
// Verify that no items are checked out
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select('id')
|
||||
->from('#__menu')
|
||||
->where('menutype=' . $this->_db->quote($table->menutype))
|
||||
->where('checked_out !=' . (int) $userId)
|
||||
->where('checked_out !=0');
|
||||
$this->_db->setQuery($query);
|
||||
if ($this->_db->loadRowList())
|
||||
{
|
||||
$this->setError(
|
||||
JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), JText::_('JLIB_DATABASE_ERROR_MENUTYPE_CHECKOUT'))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that no module for this menu are checked out
|
||||
$query->clear()
|
||||
->select('id')
|
||||
->from('#__modules')
|
||||
->where('module=' . $this->_db->quote('mod_menu'))
|
||||
->where('params LIKE ' . $this->_db->quote('%"menutype":' . json_encode($table->menutype) . '%'))
|
||||
->where('checked_out !=' . (int) $userId)
|
||||
->where('checked_out !=0');
|
||||
$this->_db->setQuery($query);
|
||||
if ($this->_db->loadRowList())
|
||||
{
|
||||
$this->setError(
|
||||
JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), JText::_('JLIB_DATABASE_ERROR_MENUTYPE_CHECKOUT'))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update the menu items
|
||||
$query->clear()
|
||||
->update('#__menu')
|
||||
->set('menutype=' . $this->_db->quote($this->menutype))
|
||||
->where('menutype=' . $this->_db->quote($table->menutype));
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
|
||||
// Update the module items
|
||||
$query->clear()
|
||||
->update('#__modules')
|
||||
->set(
|
||||
'params=REPLACE(params,' . $this->_db->quote('"menutype":' . json_encode($table->menutype)) . ',' .
|
||||
$this->_db->quote('"menutype":' . json_encode($this->menutype)) . ')'
|
||||
);
|
||||
$query->where('module=' . $this->_db->quote('mod_menu'))
|
||||
->where('params LIKE ' . $this->_db->quote('%"menutype":' . json_encode($table->menutype) . '%'));
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
}
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override parent delete method to delete tags information.
|
||||
*
|
||||
* @param mixed $pk An optional primary key value to delete. If not set the instance property value is used.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @link http://docs.joomla.org/JTable/delete
|
||||
* @since 11.1
|
||||
*/
|
||||
public function delete($pk = null)
|
||||
{
|
||||
$k = $this->_tbl_key;
|
||||
$pk = (is_null($pk)) ? $this->$k : $pk;
|
||||
|
||||
// If no primary key is given, return false.
|
||||
if ($pk !== null)
|
||||
{
|
||||
// Get the user id
|
||||
$userId = JFactory::getUser()->id;
|
||||
|
||||
// Get the old value of the table
|
||||
$table = JTable::getInstance('Menutype', 'JTable');
|
||||
$table->load($pk);
|
||||
|
||||
// Verify that no items are checked out
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select('id')
|
||||
->from('#__menu')
|
||||
->where('menutype=' . $this->_db->quote($table->menutype))
|
||||
->where('client_id=0')
|
||||
->where('(checked_out NOT IN (0,' . (int) $userId . ') OR home=1 AND language=' . $this->_db->quote('*') . ')');
|
||||
$this->_db->setQuery($query);
|
||||
if ($this->_db->loadRowList())
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_DELETE_FAILED', get_class($this), JText::_('JLIB_DATABASE_ERROR_MENUTYPE')));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that no module for this menu are checked out
|
||||
$query->clear()
|
||||
->select('id')
|
||||
->from('#__modules')
|
||||
->where('module=' . $this->_db->quote('mod_menu'))
|
||||
->where('params LIKE ' . $this->_db->quote('%"menutype":' . json_encode($table->menutype) . '%'))
|
||||
->where('checked_out !=' . (int) $userId)
|
||||
->where('checked_out !=0');
|
||||
$this->_db->setQuery($query);
|
||||
if ($this->_db->loadRowList())
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_DELETE_FAILED', get_class($this), JText::_('JLIB_DATABASE_ERROR_MENUTYPE')));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the menu items
|
||||
$query->clear()
|
||||
->delete('#__menu')
|
||||
->where('menutype=' . $this->_db->quote($table->menutype))
|
||||
->where('client_id=0');
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
|
||||
// Update the module items
|
||||
$query->clear()
|
||||
->delete('#__modules')
|
||||
->where('module=' . $this->_db->quote('mod_menu'))
|
||||
->where('params LIKE ' . $this->_db->quote('%"menutype":' . json_encode($table->menutype) . '%'));
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
}
|
||||
return parent::delete($pk);
|
||||
}
|
||||
}
|
86
libraries/legacy/table/module.php
Normal file
86
libraries/legacy/table/module.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Module table
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
* @since 11.1
|
||||
*/
|
||||
class JTableModule extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JDatabaseDriver $db Database driver object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct('#__modules', 'id', $db);
|
||||
|
||||
$this->access = (int) JFactory::getConfig()->get('access');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function.
|
||||
*
|
||||
* @return boolean True if the instance is sane and able to be stored in the database.
|
||||
*
|
||||
* @see JTable::check
|
||||
* @since 11.1
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// Check for valid name
|
||||
if (trim($this->title) == '')
|
||||
{
|
||||
$this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_MODULE'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up)
|
||||
{
|
||||
// Swap the dates.
|
||||
$temp = $this->publish_up;
|
||||
$this->publish_up = $this->publish_down;
|
||||
$this->publish_down = $temp;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function.
|
||||
*
|
||||
* @param array $array Named array.
|
||||
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
|
||||
*
|
||||
* @return mixed Null if operation was satisfactory, otherwise returns an error
|
||||
*
|
||||
* @see JTable::bind
|
||||
* @since 11.1
|
||||
*/
|
||||
public function bind($array, $ignore = '')
|
||||
{
|
||||
if (isset($array['params']) && is_array($array['params']))
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadArray($array['params']);
|
||||
$array['params'] = (string) $registry;
|
||||
}
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
}
|
192
libraries/legacy/table/session.php
Normal file
192
libraries/legacy/table/session.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Session table
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Table
|
||||
* @since 11.1
|
||||
*/
|
||||
class JTableSession extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabaseDriver $db Database driver object.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
parent::__construct('#__session', 'session_id', $db);
|
||||
|
||||
$this->guest = 1;
|
||||
$this->username = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a session
|
||||
*
|
||||
* @param string $sessionId The session id
|
||||
* @param integer $clientId The id of the client application
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function insert($sessionId, $clientId)
|
||||
{
|
||||
$this->session_id = $sessionId;
|
||||
$this->client_id = $clientId;
|
||||
|
||||
$this->time = time();
|
||||
$ret = $this->_db->insertObject($this->_tbl, $this, 'session_id');
|
||||
|
||||
if (!$ret)
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the session
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function update($updateNulls = false)
|
||||
{
|
||||
$this->time = time();
|
||||
$ret = $this->_db->updateObject($this->_tbl, $this, 'session_id', $updateNulls);
|
||||
|
||||
if (!$ret)
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the pre-existing session
|
||||
*
|
||||
* @param integer $userId Identifier of the user for this session.
|
||||
* @param array $clientIds Array of client ids for which session(s) will be destroyed
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function destroy($userId, $clientIds = array())
|
||||
{
|
||||
$clientIds = implode(',', $clientIds);
|
||||
|
||||
$query = $this->_db->getQuery(true)
|
||||
->delete($this->_db->quoteName($this->_tbl))
|
||||
->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userId))
|
||||
->where($this->_db->quoteName('client_id') . ' IN (' . $clientIds . ')');
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
if (!$this->_db->execute())
|
||||
{
|
||||
$this->setError($this->_db->stderr());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge old sessions
|
||||
*
|
||||
* @param integer $maxLifetime Session age in seconds
|
||||
*
|
||||
* @return mixed Resource on success, null on fail
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function purge($maxLifetime = 1440)
|
||||
{
|
||||
$past = time() - $maxLifetime;
|
||||
$query = $this->_db->getQuery(true)
|
||||
->delete($this->_db->quoteName($this->_tbl))
|
||||
->where($this->_db->quoteName('time') . ' < ' . (int) $past);
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
return $this->_db->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if a user has a one or more active sessions
|
||||
*
|
||||
* @param integer $userid The identifier of the user
|
||||
*
|
||||
* @return boolean True if a session for this user exists
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function exists($userid)
|
||||
{
|
||||
$query = $this->_db->getQuery(true)
|
||||
->select('COUNT(userid)')
|
||||
->from($this->_db->quoteName($this->_tbl))
|
||||
->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userid));
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
if (!$result = $this->_db->loadResult())
|
||||
{
|
||||
$this->setError($this->_db->stderr());
|
||||
return false;
|
||||
}
|
||||
|
||||
return (boolean) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded delete method
|
||||
*
|
||||
* We must override it because of the non-integer primary key
|
||||
*
|
||||
* @param integer $oid The object id (optional).
|
||||
*
|
||||
* @return mixed True if successful otherwise an error message
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function delete($oid = null)
|
||||
{
|
||||
$k = $this->_tbl_key;
|
||||
if ($oid)
|
||||
{
|
||||
$this->$k = $oid;
|
||||
}
|
||||
|
||||
$query = $this->_db->getQuery(true)
|
||||
->delete($this->_db->quoteName($this->_tbl))
|
||||
->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->$k));
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
$this->_db->execute();
|
||||
return true;
|
||||
}
|
||||
}
|
1
libraries/legacy/utilities/index.html
Normal file
1
libraries/legacy/utilities/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
106
libraries/legacy/utilities/xmlelement.php
Normal file
106
libraries/legacy/utilities/xmlelement.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Utilities
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JLog::add('JXMLElement is deprecated. Use SimpleXMLElement.', JLog::WARNING, 'deprecated');
|
||||
|
||||
/**
|
||||
* Wrapper class for php SimpleXMLElement.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Utilities
|
||||
* @since 11.1
|
||||
* @deprecated 13.3 (Platform) & 4.0 (CMS) - Use SimpleXMLElement instead.
|
||||
*/
|
||||
class JXMLElement extends SimpleXMLElement
|
||||
{
|
||||
/**
|
||||
* Get the name of the element.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 13.3 Use SimpleXMLElement::getName() instead.
|
||||
*/
|
||||
public function name()
|
||||
{
|
||||
JLog::add('JXMLElement::name() is deprecated, use SimpleXMLElement::getName() instead.', JLog::WARNING, 'deprecated');
|
||||
return (string) $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a well-formed XML string based on SimpleXML element
|
||||
*
|
||||
* @param boolean $compressed Should we use indentation and newlines ?
|
||||
* @param string $indent Indention character.
|
||||
* @param integer $level The level within the document which informs the indentation.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 11.1
|
||||
* @deprecated 13.3 Use SimpleXMLElement::asXML() instead.
|
||||
*/
|
||||
public function asFormattedXML($compressed = false, $indent = "\t", $level = 0)
|
||||
{
|
||||
JLog::add('JXMLElement::asFormattedXML() is deprecated, use SimpleXMLElement::asXML() instead.', JLog::WARNING, 'deprecated');
|
||||
$out = '';
|
||||
|
||||
// Start a new line, indent by the number indicated in $level
|
||||
$out .= ($compressed) ? '' : "\n" . str_repeat($indent, $level);
|
||||
|
||||
// Add a <, and add the name of the tag
|
||||
$out .= '<' . $this->getName();
|
||||
|
||||
// For each attribute, add attr="value"
|
||||
foreach ($this->attributes() as $attr)
|
||||
{
|
||||
$out .= ' ' . $attr->getName() . '="' . htmlspecialchars((string) $attr, ENT_COMPAT, 'UTF-8') . '"';
|
||||
}
|
||||
|
||||
// If there are no children and it contains no data, end it off with a />
|
||||
if (!count($this->children()) && !(string) $this)
|
||||
{
|
||||
$out .= " />";
|
||||
}
|
||||
else
|
||||
{
|
||||
// If there are children
|
||||
if (count($this->children()))
|
||||
{
|
||||
// Close off the start tag
|
||||
$out .= '>';
|
||||
|
||||
$level++;
|
||||
|
||||
// For each child, call the asFormattedXML function (this will ensure that all children are added recursively)
|
||||
foreach ($this->children() as $child)
|
||||
{
|
||||
$out .= $child->asFormattedXML($compressed, $indent, $level);
|
||||
}
|
||||
|
||||
$level--;
|
||||
|
||||
// Add the newline and indentation to go along with the close tag
|
||||
$out .= ($compressed) ? '' : "\n" . str_repeat($indent, $level);
|
||||
|
||||
}
|
||||
elseif ((string) $this)
|
||||
{
|
||||
// If there is data, close off the start tag and add the data
|
||||
$out .= '>' . htmlspecialchars((string) $this, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
|
||||
// Add the end tag
|
||||
$out .= '</' . $this->getName() . '>';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
1
libraries/legacy/view/index.html
Normal file
1
libraries/legacy/view/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
798
libraries/legacy/view/legacy.php
Normal file
798
libraries/legacy/view/legacy.php
Normal file
@ -0,0 +1,798 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage View
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Base class for a Joomla View
|
||||
*
|
||||
* Class holding methods for displaying presentation data.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage View
|
||||
* @since 12.2
|
||||
*/
|
||||
class JViewLegacy extends JObject
|
||||
{
|
||||
/**
|
||||
* The name of the view
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_name = null;
|
||||
|
||||
/**
|
||||
* Registered models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_models = array();
|
||||
|
||||
/**
|
||||
* The base path of the view
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_basePath = null;
|
||||
|
||||
/**
|
||||
* The default model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_defaultModel = null;
|
||||
|
||||
/**
|
||||
* Layout name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_layout = 'default';
|
||||
|
||||
/**
|
||||
* Layout extension
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_layoutExt = 'php';
|
||||
|
||||
/**
|
||||
* Layout template
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_layoutTemplate = '_';
|
||||
|
||||
/**
|
||||
* The set of search directories for resources (templates)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_path = array('template' => array(), 'helper' => array());
|
||||
|
||||
/**
|
||||
* The name of the default template source file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = null;
|
||||
|
||||
/**
|
||||
* The output of the template script.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_output = null;
|
||||
|
||||
/**
|
||||
* Callback for escaping.
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 13.3
|
||||
*/
|
||||
protected $_escape = 'htmlspecialchars';
|
||||
|
||||
/**
|
||||
* Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $config A named configuration array for object construction.<br/>
|
||||
* name: the name (optional) of the view (defaults to the view class name suffix).<br/>
|
||||
* charset: the character set to use for display<br/>
|
||||
* escape: the name (optional) of the function to use for escaping strings<br/>
|
||||
* base_path: the parent path (optional) of the views directory (defaults to the component folder)<br/>
|
||||
* template_plath: the path (optional) of the layout directory (defaults to base_path + /views/ + view name<br/>
|
||||
* helper_path: the path (optional) of the helper files (defaults to base_path + /helpers/)<br/>
|
||||
* layout: the layout (optional) to use to display the view<br/>
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
// Set the view name
|
||||
if (empty($this->_name))
|
||||
{
|
||||
if (array_key_exists('name', $config))
|
||||
{
|
||||
$this->_name = $config['name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_name = $this->getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Set the charset (used by the variable escaping functions)
|
||||
if (array_key_exists('charset', $config))
|
||||
{
|
||||
JLog::add('Setting a custom charset for escaping is deprecated. Override JViewLegacy::escape() instead.', JLog::WARNING, 'deprecated');
|
||||
$this->_charset = $config['charset'];
|
||||
}
|
||||
|
||||
// User-defined escaping callback
|
||||
if (array_key_exists('escape', $config))
|
||||
{
|
||||
$this->setEscape($config['escape']);
|
||||
}
|
||||
|
||||
// Set a base path for use by the view
|
||||
if (array_key_exists('base_path', $config))
|
||||
{
|
||||
$this->_basePath = $config['base_path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_basePath = JPATH_COMPONENT;
|
||||
}
|
||||
|
||||
// Set the default template search path
|
||||
if (array_key_exists('template_path', $config))
|
||||
{
|
||||
// User-defined dirs
|
||||
$this->_setPath('template', $config['template_path']);
|
||||
}
|
||||
elseif (is_dir(JPATH_COMPONENT . '/view'))
|
||||
{
|
||||
$this->_setPath('template', $this->_basePath . '/view/' . $this->getName() . '/tmpl');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_setPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl');
|
||||
}
|
||||
|
||||
// Set the default helper search path
|
||||
if (array_key_exists('helper_path', $config))
|
||||
{
|
||||
// User-defined dirs
|
||||
$this->_setPath('helper', $config['helper_path']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_setPath('helper', $this->_basePath . '/helpers');
|
||||
}
|
||||
|
||||
// Set the layout
|
||||
if (array_key_exists('layout', $config))
|
||||
{
|
||||
$this->setLayout($config['layout']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setLayout('default');
|
||||
}
|
||||
|
||||
$this->baseurl = JUri::base(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return mixed A string if successful, otherwise a Error object.
|
||||
*
|
||||
* @see fetch()
|
||||
* @since 12.2
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$result = $this->loadTemplate($tpl);
|
||||
if ($result instanceof Exception)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
echo $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns variables to the view script via differing strategies.
|
||||
*
|
||||
* This method is overloaded; you can assign all the properties of
|
||||
* an object, an associative array, or a single value by name.
|
||||
*
|
||||
* You are not allowed to set variables that begin with an underscore;
|
||||
* these are either private properties for JView or private variables
|
||||
* within the template script itself.
|
||||
*
|
||||
* <code>
|
||||
* $view = new JView;
|
||||
*
|
||||
* // Assign directly
|
||||
* $view->var1 = 'something';
|
||||
* $view->var2 = 'else';
|
||||
*
|
||||
* // Assign by name and value
|
||||
* $view->assign('var1', 'something');
|
||||
* $view->assign('var2', 'else');
|
||||
*
|
||||
* // Assign by assoc-array
|
||||
* $ary = array('var1' => 'something', 'var2' => 'else');
|
||||
* $view->assign($obj);
|
||||
*
|
||||
* // Assign by object
|
||||
* $obj = new stdClass;
|
||||
* $obj->var1 = 'something';
|
||||
* $obj->var2 = 'else';
|
||||
* $view->assign($obj);
|
||||
*
|
||||
* </code>
|
||||
*
|
||||
* @return boolean True on success, false on failure.
|
||||
*
|
||||
* @deprecated 13.3 Use native PHP syntax.
|
||||
*/
|
||||
public function assign()
|
||||
{
|
||||
JLog::add(__METHOD__ . ' is deprecated. Use native PHP syntax.', JLog::WARNING, 'deprecated');
|
||||
|
||||
// Get the arguments; there may be 1 or 2.
|
||||
$arg0 = @func_get_arg(0);
|
||||
$arg1 = @func_get_arg(1);
|
||||
|
||||
// Assign by object
|
||||
if (is_object($arg0))
|
||||
{
|
||||
// Assign public properties
|
||||
foreach (get_object_vars($arg0) as $key => $val)
|
||||
{
|
||||
if (substr($key, 0, 1) != '_')
|
||||
{
|
||||
$this->$key = $val;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Assign by associative array
|
||||
if (is_array($arg0))
|
||||
{
|
||||
foreach ($arg0 as $key => $val)
|
||||
{
|
||||
if (substr($key, 0, 1) != '_')
|
||||
{
|
||||
$this->$key = $val;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Assign by string name and mixed value.
|
||||
|
||||
// We use array_key_exists() instead of isset() because isset()
|
||||
// fails if the value is set to null.
|
||||
if (is_string($arg0) && substr($arg0, 0, 1) != '_' && func_num_args() > 1)
|
||||
{
|
||||
$this->$arg0 = $arg1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// $arg0 was not object, array, or string.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign variable for the view (by reference).
|
||||
*
|
||||
* You are not allowed to set variables that begin with an underscore;
|
||||
* these are either private properties for JView or private variables
|
||||
* within the template script itself.
|
||||
*
|
||||
* <code>
|
||||
* $view = new JView;
|
||||
*
|
||||
* // Assign by name and value
|
||||
* $view->assignRef('var1', $ref);
|
||||
*
|
||||
* // Assign directly
|
||||
* $view->ref = &$var1;
|
||||
* </code>
|
||||
*
|
||||
* @param string $key The name for the reference in the view.
|
||||
* @param mixed &$val The referenced variable.
|
||||
*
|
||||
* @return boolean True on success, false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
* @deprecated 13.3 Use native PHP syntax.
|
||||
*/
|
||||
public function assignRef($key, &$val)
|
||||
{
|
||||
JLog::add(__METHOD__ . ' is deprecated. Use native PHP syntax.', JLog::WARNING, 'deprecated');
|
||||
|
||||
if (is_string($key) && substr($key, 0, 1) != '_')
|
||||
{
|
||||
$this->$key = &$val;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a value for output in a view script.
|
||||
*
|
||||
* If escaping mechanism is either htmlspecialchars or htmlentities, uses
|
||||
* {@link $_encoding} setting.
|
||||
*
|
||||
* @param mixed $var The output to escape.
|
||||
*
|
||||
* @return mixed The escaped value.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function escape($var)
|
||||
{
|
||||
if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities')))
|
||||
{
|
||||
return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_charset);
|
||||
}
|
||||
|
||||
return call_user_func($this->_escape, $var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get data from a registered model or a property of the view
|
||||
*
|
||||
* @param string $property The name of the method to call on the model or the property to get
|
||||
* @param string $default The name of the model to reference or the default value [optional]
|
||||
*
|
||||
* @return mixed The return value of the method
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function get($property, $default = null)
|
||||
{
|
||||
// If $model is null we use the default model
|
||||
if (is_null($default))
|
||||
{
|
||||
$model = $this->_defaultModel;
|
||||
}
|
||||
else
|
||||
{
|
||||
$model = strtolower($default);
|
||||
}
|
||||
|
||||
// First check to make sure the model requested exists
|
||||
if (isset($this->_models[$model]))
|
||||
{
|
||||
// Model exists, let's build the method name
|
||||
$method = 'get' . ucfirst($property);
|
||||
|
||||
// Does the method exist?
|
||||
if (method_exists($this->_models[$model], $method))
|
||||
{
|
||||
// The method exists, let's call it and return what we get
|
||||
$result = $this->_models[$model]->$method();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Degrade to JObject::get
|
||||
$result = parent::get($property, $default);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the model object
|
||||
*
|
||||
* @param string $name The name of the model (optional)
|
||||
*
|
||||
* @return mixed JModelLegacy object
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function getModel($name = null)
|
||||
{
|
||||
if ($name === null)
|
||||
{
|
||||
$name = $this->_defaultModel;
|
||||
}
|
||||
return $this->_models[strtolower($name)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the layout.
|
||||
*
|
||||
* @return string The layout name
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the layout template.
|
||||
*
|
||||
* @return string The layout template name
|
||||
*/
|
||||
public function getLayoutTemplate()
|
||||
{
|
||||
return $this->_layoutTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the view name
|
||||
*
|
||||
* The model name by default parsed using the classname, or it can be set
|
||||
* by passing a $config['name'] in the class constructor
|
||||
*
|
||||
* @return string The name of the model
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
if (empty($this->_name))
|
||||
{
|
||||
$classname = get_class($this);
|
||||
$viewpos = strpos($classname, 'View');
|
||||
|
||||
if ($viewpos === false)
|
||||
{
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME'), 500);
|
||||
}
|
||||
|
||||
$this->_name = strtolower(substr($classname, $viewpos + 4));
|
||||
}
|
||||
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add a model to the view. We support a multiple model single
|
||||
* view system by which models are referenced by classname. A caveat to the
|
||||
* classname referencing is that any classname prepended by JModel will be
|
||||
* referenced by the name without JModel, eg. JModelCategory is just
|
||||
* Category.
|
||||
*
|
||||
* @param JModelLegacy $model The model to add to the view.
|
||||
* @param boolean $default Is this the default model?
|
||||
*
|
||||
* @return object The added model.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function setModel($model, $default = false)
|
||||
{
|
||||
$name = strtolower($model->getName());
|
||||
$this->_models[$name] = $model;
|
||||
|
||||
if ($default)
|
||||
{
|
||||
$this->_defaultModel = $name;
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the layout name to use
|
||||
*
|
||||
* @param string $layout The layout name or a string in format <template>:<layout file>
|
||||
*
|
||||
* @return string Previous value.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function setLayout($layout)
|
||||
{
|
||||
$previous = $this->_layout;
|
||||
if (strpos($layout, ':') === false)
|
||||
{
|
||||
$this->_layout = $layout;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert parameter to array based on :
|
||||
$temp = explode(':', $layout);
|
||||
$this->_layout = $temp[1];
|
||||
|
||||
// Set layout template
|
||||
$this->_layoutTemplate = $temp[0];
|
||||
}
|
||||
|
||||
return $previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows a different extension for the layout files to be used
|
||||
*
|
||||
* @param string $value The extension.
|
||||
*
|
||||
* @return string Previous value
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function setLayoutExt($value)
|
||||
{
|
||||
$previous = $this->_layoutExt;
|
||||
if ($value = preg_replace('#[^A-Za-z0-9]#', '', trim($value)))
|
||||
{
|
||||
$this->_layoutExt = $value;
|
||||
}
|
||||
|
||||
return $previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the _escape() callback.
|
||||
*
|
||||
* @param mixed $spec The callback for _escape() to use.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
* @deprecated 13.3 Override JViewLegacy::escape() instead.
|
||||
*/
|
||||
public function setEscape($spec)
|
||||
{
|
||||
JLog::add(__METHOD__ . ' is deprecated. Override JViewLegacy::escape() instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
$this->_escape = $spec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the stack of view script paths in LIFO order.
|
||||
*
|
||||
* @param mixed $path A directory path or an array of paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function addTemplatePath($path)
|
||||
{
|
||||
$this->_addPath('template', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the stack of helper script paths in LIFO order.
|
||||
*
|
||||
* @param mixed $path A directory path or an array of paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function addHelperPath($path)
|
||||
{
|
||||
$this->_addPath('helper', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a template file -- first look in the templates folder for an override
|
||||
*
|
||||
* @param string $tpl The name of the template source file; automatically searches the template paths and compiles as needed.
|
||||
*
|
||||
* @return string The output of the the template script.
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loadTemplate($tpl = null)
|
||||
{
|
||||
// Clear prior output
|
||||
$this->_output = null;
|
||||
|
||||
$template = JFactory::getApplication()->getTemplate();
|
||||
$layout = $this->getLayout();
|
||||
$layoutTemplate = $this->getLayoutTemplate();
|
||||
|
||||
// Create the template file name based on the layout
|
||||
$file = isset($tpl) ? $layout . '_' . $tpl : $layout;
|
||||
|
||||
// Clean the file name
|
||||
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $file);
|
||||
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $tpl) : $tpl;
|
||||
|
||||
// Load the language file for the template
|
||||
$lang = JFactory::getLanguage();
|
||||
$lang->load('tpl_' . $template, JPATH_BASE, null, false, false)
|
||||
|| $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, false)
|
||||
|| $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", $lang->getDefault(), false, false);
|
||||
|
||||
// Change the template folder if alternative layout is in different template
|
||||
if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template)
|
||||
{
|
||||
$this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']);
|
||||
}
|
||||
|
||||
// Load the template script
|
||||
jimport('joomla.filesystem.path');
|
||||
$filetofind = $this->_createFileName('template', array('name' => $file));
|
||||
$this->_template = JPath::find($this->_path['template'], $filetofind);
|
||||
|
||||
// If alternate layout can't be found, fall back to default layout
|
||||
if ($this->_template == false)
|
||||
{
|
||||
$filetofind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl)));
|
||||
$this->_template = JPath::find($this->_path['template'], $filetofind);
|
||||
}
|
||||
|
||||
if ($this->_template != false)
|
||||
{
|
||||
// Unset so as not to introduce into template scope
|
||||
unset($tpl);
|
||||
unset($file);
|
||||
|
||||
// Never allow a 'this' property
|
||||
if (isset($this->this))
|
||||
{
|
||||
unset($this->this);
|
||||
}
|
||||
|
||||
// Start capturing output into a buffer
|
||||
ob_start();
|
||||
|
||||
// Include the requested template filename in the local scope
|
||||
// (this will execute the view logic).
|
||||
include $this->_template;
|
||||
|
||||
// Done with the requested template; get the buffer and
|
||||
// clear it.
|
||||
$this->_output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $this->_output;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a helper file
|
||||
*
|
||||
* @param string $hlp The name of the helper source file automatically searches the helper paths and compiles as needed.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function loadHelper($hlp = null)
|
||||
{
|
||||
// Clean the file name
|
||||
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $hlp);
|
||||
|
||||
// Load the template script
|
||||
jimport('joomla.filesystem.path');
|
||||
$helper = JPath::find($this->_path['helper'], $this->_createFileName('helper', array('name' => $file)));
|
||||
|
||||
if ($helper != false)
|
||||
{
|
||||
// Include the requested template filename in the local scope
|
||||
include_once $helper;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an entire array of search paths for templates or resources.
|
||||
*
|
||||
* @param string $type The type of path to set, typically 'template'.
|
||||
* @param mixed $path The new search path, or an array of search paths. If null or false, resets to the current directory only.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function _setPath($type, $path)
|
||||
{
|
||||
$component = JApplicationHelper::getComponentName();
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Clear out the prior search dirs
|
||||
$this->_path[$type] = array();
|
||||
|
||||
// Actually add the user-specified directories
|
||||
$this->_addPath($type, $path);
|
||||
|
||||
// Always add the fallback directories as last resort
|
||||
switch (strtolower($type))
|
||||
{
|
||||
case 'template':
|
||||
// Set the alternative template search dir
|
||||
if (isset($app))
|
||||
{
|
||||
$component = preg_replace('/[^A-Z0-9_\.-]/i', '', $component);
|
||||
$fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName();
|
||||
$this->_addPath('template', $fallback);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the search path for templates and resources.
|
||||
*
|
||||
* @param string $type The type of path to add.
|
||||
* @param mixed $path The directory or stream, or an array of either, to search.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function _addPath($type, $path)
|
||||
{
|
||||
// Just force to array
|
||||
settype($path, 'array');
|
||||
|
||||
// Loop through the path directories
|
||||
foreach ($path as $dir)
|
||||
{
|
||||
// No surrounding spaces allowed!
|
||||
$dir = trim($dir);
|
||||
|
||||
// Add trailing separators as needed
|
||||
if (substr($dir, -1) != DIRECTORY_SEPARATOR)
|
||||
{
|
||||
// Directory
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
// Add to the top of the search dirs
|
||||
array_unshift($this->_path[$type], $dir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the filename for a resource
|
||||
*
|
||||
* @param string $type The resource type to create the filename for
|
||||
* @param array $parts An associative array of filename information
|
||||
*
|
||||
* @return string The filename
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function _createFileName($type, $parts = array())
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 'template':
|
||||
$filename = strtolower($parts['name']) . '.' . $this->_layoutExt;
|
||||
break;
|
||||
|
||||
default:
|
||||
$filename = strtolower($parts['name']) . '.php';
|
||||
break;
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
}
|
37
libraries/legacy/web/client.php
Normal file
37
libraries/legacy/web/client.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Deprecated class placeholder. You should use JApplicationWebClient instead.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
* @since 11.3
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JWebClient extends JApplicationWebClient
|
||||
{
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param mixed $userAgent The optional user-agent string to parse.
|
||||
* @param mixed $acceptEncoding The optional client accept encoding string to parse.
|
||||
* @param mixed $acceptLanguage The optional client accept language string to parse.
|
||||
*
|
||||
* @since 11.3
|
||||
*/
|
||||
public function __construct($userAgent = null, $acceptEncoding = null, $acceptLanguage = null)
|
||||
{
|
||||
JLog::add('JWebClient is deprecated. Use JApplicationWebClient instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct($userAgent, $acceptEncoding, $acceptLanguage);
|
||||
}
|
||||
}
|
1
libraries/legacy/web/index.html
Normal file
1
libraries/legacy/web/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
44
libraries/legacy/web/web.php
Normal file
44
libraries/legacy/web/web.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Deprecated class placeholder. You should use JApplicationWeb instead.
|
||||
*
|
||||
* @package Joomla.Legacy
|
||||
* @subpackage Application
|
||||
* @since 11.3
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) - Use JApplicationWeb instead.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JWeb extends JApplicationWeb
|
||||
{
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param mixed $input An optional argument to provide dependency injection for the application's
|
||||
* input object. If the argument is a JInput object that object will become
|
||||
* the application's input object, otherwise a default input object is created.
|
||||
* @param mixed $config An optional argument to provide dependency injection for the application's
|
||||
* config object. If the argument is a JRegistry object that object will become
|
||||
* the application's config object, otherwise a default config object is created.
|
||||
* @param mixed $client An optional argument to provide dependency injection for the application's
|
||||
* client object. If the argument is a JApplicationWebClient object that object will become
|
||||
* the application's client object, otherwise a default client object is created.
|
||||
*
|
||||
* @since 11.3
|
||||
* @deprecated 12.3 (Platform) & 4.0 (CMS) Use JApplicationWeb instead.
|
||||
*/
|
||||
public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null)
|
||||
{
|
||||
JLog::add('JWeb is deprecated. Use JApplicationWeb instead.', JLog::WARNING, 'deprecated');
|
||||
parent::__construct($input, $config, $client);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user