From cc4c11a0fe647b84c390db03668a5ea4dd42c23a Mon Sep 17 00:00:00 2001 From: Pavel Kulbakin
The modules of the left side. The array elements are in the form - * $leftorder[order] = label - * where order is the module order from the db table and label is a - * text label associciated with the order.
- * @param array See notes for leftorder - * @param array An array of select lists - * @param object Parameters - */ - function edit( &$model, &$row, &$orders2, &$lists, &$params, $client ) - { - JRequest::setVar( 'hidemainmenu', 1 ); - - // clean item data - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' ); - - // Check for component metadata.xml file - //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module ); - //$params = new JParameter( $row->params, $path ); - $document =& JFactory::getDocument(); - - JHTML::_('behavior.combobox'); - - jimport('joomla.html.pane'); + /** + * Writes a list of the defined modules + * @param array An array of category objects + */ + public static function view( &$rows, &$client, &$page, &$lists ) + { + $user =& JFactory::getUser(); + + //Ordering allowed ? + $ordering = ($lists['order'] == 'm.ordering' || $lists['order'] == 'm.position'); + + JHTML::_('behavior.tooltip'); + ?> + + $row is passed with the id + * property set to 0. + * + * @param JTableCategory The category object + * @param arrayThe modules of the left side. The array elements are in the form + * $leftorder[order] = label + * where order is the module order from the db table and label is a + * text label associciated with the order.
+ * @param array See notes for leftorder + * @param array An array of select lists + * @param object Parameters + */ + public static function edit( &$model, &$row, &$orders2, &$lists, &$params, $client ) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + // clean item data + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' ); + + // Check for component metadata.xml file + //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module ); + //$params = new JParameter( $row->params, $path ); + $document =& JFactory::getDocument(); + + JHTML::_('behavior.combobox'); + + jimport('joomla.html.pane'); // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. - $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); - $editor =& JFactory::getEditor(); - - JHTML::_('behavior.tooltip'); - ?> - - - - - -- | |
+ | |
$menu = &JSite::getMenu();- * - * @access public - * @param string $client The name of the client - * @param array $options An associative array of options - * @return JMenu A menu object. - * @since 1.5 - */ - function &getInstance($client, $options = array()) - { - static $instances; - - if (!isset( $instances )) { - $instances = array(); - } - - if (empty($instances[$client])) - { - //Load the router object - $info =& JApplicationHelper::getClientInfo($client, true); - - $path = $info->path.DS.'includes'.DS.'menu.php'; - if(file_exists($path)) - { - require_once $path; - - // Create a JPathway object - $classname = 'JMenu'.ucfirst($client); - $instance = new $classname($options); - } - else - { - //$error = JError::raiseError( 500, 'Unable to load menu: '.$client); - $error = null; //Jinx : need to fix this - return $error; - } - - $instances[$client] = & $instance; - } - - return $instances[$client]; - } - - /** - * Get menu item by id - * - * @access public - * @param int The item id - * @return mixed The item object, or null if not found - */ - function &getItem($id) - { - $result = null; - if (isset($this->_items[$id])) { - $result = &$this->_items[$id]; - } - - return $result; - } - - /** - * Set the default item by id - * - * @param int The item id - * @access public - * @return True, if succesfull - */ - function setDefault($id) - { - if(isset($this->_items[$id])) { - $this->_default = $id; - return true; - } - - return false; - } - - /** - * Get menu item by id - * - * @access public - * - * @return object The item object - */ - function &getDefault() - { - $item =& $this->_items[$this->_default]; - return $item; - } - - /** - * Set the default item by id - * - * @param int The item id - * @access public - * @return If successfull the active item, otherwise null - */ - function &setActive($id) - { - if(isset($this->_items[$id])) - { - $this->_active = $id; - $result = &$this->_items[$id]; - return $result; - } - - $result = null; - return $result; - } - - /** - * Get menu item by id - * - * @access public - * - * @return object The item object - */ - function &getActive() - { - if ($this->_active) { - $item =& $this->_items[$this->_active]; - return $item; - } - - $result = null; - return $result; - } - - /** - * Gets menu items by attribute - * - * @access public - * @param string The field name - * @param string The value of the field - * @param boolean If true, only returns the first item found - * @return array - */ - function getItems($attribute, $value, $firstonly = false) - { - $items = null; - - foreach ($this->_items as $item) - { - if ( ! is_object($item) ) - continue; - - if ($item->$attribute == $value) - { - if($firstonly) { - return $item; - } - - $items[] = $item; - } - } - - return $items; - } - - /** - * Gets the parameter object for a certain menu item - * - * @access public - * @param int The item id - * @return object A JParameter object - */ - function &getParams($id) - { - $ini = ''; - if ($menu =& $this->getItem($id)) { - $ini = $menu->params; - } - $result = new JParameter( $ini ); - - return $result; - } - - /** - * Getter for the menu array - * - * @access public - * @return array - */ - function getMenu() { - return $this->_items; - } - - /** - * Method to check JMenu object authorization against an access control - * object and optionally an access extension object - * - * @access public - * @param integer $id The menu id - * @param integer $accessid The users access identifier - * @return boolean True if authorized - */ - function authorize($id, $accessid = 0) - { - $menu =& $this->getItem($id); - return ((isset($menu->access) ? $menu->access : 0) <= $accessid); - } - - /** - * Loads the menu items - * - * @abstract - * @access public - * @return array - */ - function load() - { - return array(); - } -} \ No newline at end of file + /** + * Array to hold the menu items + * + * @access private + * @param array + */ + var $_items = array (); + + /** + * Identifier of the default menu item + * + * @access private + * @param integer + */ + var $_default = 0; + + /** + * Identifier of the active menu item + * + * @access private + * @param integer + */ + var $_active = 0; + + + /** + * Class constructor + * + * @access public + * @return boolean True on success + */ + function __construct($options = array()) + { + $this->load(); //load the menu items + + foreach ($this->_items as $k => $item) { + if ($item->home) { + $this->_default = $item->id; + } + } + } + + /** + * Returns a reference to a JMenu object + * + * This method must be invoked as: + *
$menu = &JSite::getMenu();+ * + * @param string $client The name of the client + * @param array $options An associative array of options + * @return JMenu A menu object. + * @since 1.5 + */ + public static function &getInstance($client, $options = array()) + { + static $instances; + + if ( ! isset( $instances )) { + $instances = array(); + } + + if (empty($instances[$client])) { + //Load the router object + $info =& JApplicationHelper::getClientInfo($client, true); + $path = $info->path.DS.'includes'.DS.'menu.php'; + if( file_exists($path)) { + require_once $path; + + // Create a JPathway object + $classname = 'JMenu'.ucfirst($client); + $instance = new $classname($options); + } else { + //$error = JError::raiseError( 500, 'Unable to load menu: '.$client); + $error = null; //Jinx : need to fix this + return $error; + } + + $instances[$client] = & $instance; + } + + return $instances[$client]; + } + + /** + * Get menu item by id + * + * @access public + * @param int The item id + * @return mixed The item object, or null if not found + */ + function &getItem($id) + { + $result = null; + if (isset($this->_items[$id])) { + $result = &$this->_items[$id]; + } + + return $result; + } + + /** + * Set the default item by id + * + * @param int The item id + * @access public + * @return True, if succesfull + */ + function setDefault($id) + { + if (isset($this->_items[$id])) { + $this->_default = $id; + return true; + } + + return false; + } + + /** + * Get menu item by id + * + * @access public + * @return object The item object + */ + function &getDefault() + { + $item =& $this->_items[$this->_default]; + return $item; + } + + /** + * Set the default item by id + * + * @param int The item id + * @access public + * @return If successfull the active item, otherwise null + */ + function &setActive($id) + { + if (isset($this->_items[$id])) { + $this->_active = $id; + $result = &$this->_items[$id]; + return $result; + } + + $result = null; + return $result; + } + + /** + * Get menu item by id + * + * @access public + * @return object The item object + */ + function &getActive() { + if ($this->_active) { + $item =& $this->_items[$this->_active]; + return $item; + } + + $result = null; + return $result; + } + + /** + * Gets menu items by attribute + * + * @access public + * @param string The field name + * @param string The value of the field + * @param boolean If true, only returns the first item found + * @return array + */ + function getItems($attribute, $value, $firstonly = false) + { + $items = null; + + foreach ($this->_items as $item) { + if ( ! is_object($item)) + continue; + + if ($item->$attribute == $value) { + if($firstonly) { + return $item; + } + $items[] = $item; + } + } + + return $items; + } + + /** + * Gets the parameter object for a certain menu item + * + * @access public + * @param int The item id + * @return object A JParameter object + */ + function &getParams($id) + { + $ini = ''; + if ($menu =& $this->getItem($id)) { + $ini = $menu->params; + } + $result = new JParameter( $ini ); + + return $result; + } + + /** + * Getter for the menu array + * + * @access public + * @return array + */ + function getMenu() { + return $this->_items; + } + + /** + * Method to check JMenu object authorization against an access control + * object and optionally an access extension object + * + * @access public + * @param integer $id The menu id + * @param integer $accessid The users access identifier + * @return boolean True if authorized + */ + function authorize($id, $accessid = 0) + { + $menu =& $this->getItem($id); + return ((isset($menu->access) ? $menu->access : 0) <= $accessid); + } + + /** + * Loads the menu items + * + * @abstract + * @access public + * @return array + */ + function load() + { + return array(); + } +} diff --git a/vendor/joomla/libraries/joomla/cache/cache.php b/vendor/joomla/libraries/joomla/cache/cache.php index f0f153eb1..25949607f 100644 --- a/vendor/joomla/libraries/joomla/cache/cache.php +++ b/vendor/joomla/libraries/joomla/cache/cache.php @@ -1,17 +1,4 @@ _options =& $options; - - // Get the default group and caching - if(isset($options['language'])) { - $this->_options['language'] = $options['language']; - } else { - $options['language'] = 'en-GB'; - } - - if(isset($options['cachebase'])) { - $this->_options['cachebase'] = $options['cachebase']; - } else { - $this->_options['cachebase'] = JPATH_ROOT.DS.'cache'; - } - - if(isset($options['defaultgroup'])) { - $this->_options['defaultgroup'] = $options['defaultgroup']; - } else { - $this->_options['defaultgroup'] = 'default'; - } - - if(isset($options['caching'])) { - $this->_options['caching'] = $options['caching']; - } else { - $this->_options['caching'] = true; - } - - if( isset($options['storage'])) { - $this->_options['storage'] = $options['storage']; - } else { - $this->_options['storage'] = 'file'; - } - - //Fix to detect if template positions are enabled... - if(JRequest::getCMD('tpl',0)) { - $this->_options['caching'] = false; - } - } - - /** - * Returns a reference to a cache adapter object, always creating it - * - * @static - * @param string $type The cache object type to instantiate - * @return object A JCache object - * @since 1.5 - */ - function &getInstance($type = 'output', $options = array()) - { - $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type)); - - $class = 'JCache'.ucfirst($type); - - if(!class_exists($class)) - { - $path = dirname(__FILE__).DS.'handler'.DS.$type.'.php'; - - if (file_exists($path)) { - require_once($path); - } else { - JError::raiseError(500, 'Unable to load Cache Handler: '.$type); - } - } - - $instance = new $class($options); - - return $instance; - } - - /** - * Get the storage handlers - * - * @access public - * @return array An array of available storage handlers - */ - function getStores() - { - jimport('joomla.filesystem.folder'); - $handlers = JFolder::files(dirname(__FILE__).DS.'storage', '.php$'); - - $names = array(); - foreach($handlers as $handler) - { - $name = substr($handler, 0, strrpos($handler, '.')); - $class = 'JCacheStorage'.$name; - - if(!class_exists($class)) { - require_once(dirname(__FILE__).DS.'storage'.DS.$name.'.php'); - } - - if(call_user_func_array( array( trim($class), 'test' ), array())) { - $names[] = $name; - } - } - - return $names; - } - - /** - * Set caching enabled state - * - * @access public - * @param boolean $enabled True to enable caching - * @return void - * @since 1.5 - */ - function setCaching($enabled) - { - $this->_options['caching'] = $enabled; - } - - /** - * Set cache lifetime - * - * @access public - * @param int $lt Cache lifetime - * @return void - * @since 1.5 - */ - function setLifeTime($lt) - { - $this->_options['lifetime'] = $lt; - } - - /** - * Set cache validation - * - * @access public - * @return void - * @since 1.5 - */ - function setCacheValidation() - { - // Deprecated - } - - /** - * Get cached data by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group=null) - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler) && $this->_options['caching']) { - return $handler->get($id, $group, (isset($this->_options['checkTime']))? $this->_options['checkTime'] : true); - } - return false; - } - - /** - * Store the cached data by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param mixed $data The data to store - * @return boolean True if cache stored - * @since 1.5 - */ - function store($data, $id, $group=null) - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler and store the cached data - $handler =& $this->_getStorage(); - if (!JError::isError($handler) && $this->_options['caching']) { - return $handler->store($id, $group, $data); - } - return false; - } - - /** - * Remove a cached data entry by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group=null) - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler)) { - return $handler->remove($id, $group); - } - return false; - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group=null, $mode='group') - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler)) { - return $handler->clean($group, $mode); - } - return false; - } - - /** - * Garbage collect expired cache data - * - * @access public - * @return boolean True on success, false otherwise. - * @since 1.5 - */ - function gc() - { - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler)) { - return $handler->gc(); - } - return false; - } - - /** - * Get the cache storage handler - * - * @access protected - * @return object A JCacheStorage object - * @since 1.5 - */ - function &_getStorage() - { - if (is_a($this->_handler, 'JCacheStorage')) { - return $this->_handler; - } - - $this->_handler =& JCacheStorage::getInstance($this->_options['storage'], $this->_options); - return $this->_handler; - } + /** + * Storage Handler + * + * @access private + * @var object + */ + var $_handler; + + /** + * Cache Options + * + * @access private + * @var array + */ + var $_options; + + /** + * Constructor + * + * @access protected + * @param array $options options + */ + function __construct($options) + { + $this->_options =& $options; + + // Get the default group and caching + if(isset($options['language'])) { + $this->_options['language'] = $options['language']; + } else { + $options['language'] = 'en-GB'; + } + + if(isset($options['cachebase'])) { + $this->_options['cachebase'] = $options['cachebase']; + } else { + $this->_options['cachebase'] = JPATH_ROOT.DS.'cache'; + } + + if(isset($options['defaultgroup'])) { + $this->_options['defaultgroup'] = $options['defaultgroup']; + } else { + $this->_options['defaultgroup'] = 'default'; + } + + if(isset($options['caching'])) { + $this->_options['caching'] = $options['caching']; + } else { + $this->_options['caching'] = true; + } + + if( isset($options['storage'])) { + $this->_options['storage'] = $options['storage']; + } else { + $this->_options['storage'] = 'file'; + } + + //Fix to detect if template positions are enabled... + if(JRequest::getCMD('tpl',0)) { + $this->_options['caching'] = false; + } + } + + /** + * Returns a reference to a cache adapter object, always creating it + * + * @param string $type The cache object type to instantiate + * @return object A JCache object + * @since 1.5 + */ + public static function &getInstance($type = 'output', $options = array()) + { + $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type)); + $class = 'JCache'.ucfirst($type); + + if( ! class_exists($class)) { + $path = dirname(__FILE__).DS.'handler'.DS.$type.'.php'; + + if (file_exists($path)) { + require_once($path); + } else { + JError::raiseError(500, 'Unable to load Cache Handler: '.$type); + } + } + + $instance = new $class($options); + + return $instance; + } + + /** + * Get the storage handlers + * + * @access public + * @return array An array of available storage handlers + */ + public static function getStores() + { + jimport('joomla.filesystem.folder'); + $handlers = JFolder::files(dirname(__FILE__).DS.'storage', '.php$'); + + $names = array(); + foreach($handlers as $handler) { + $name = substr($handler, 0, strrpos($handler, '.')); + $class = 'JCacheStorage'.$name; + + if( ! class_exists($class)) { + require_once(dirname(__FILE__).DS.'storage'.DS.$name.'.php'); + } + + if(call_user_func_array( array( trim($class), 'test' ), array())) { + $names[] = $name; + } + } + + return $names; + } + + /** + * Set caching enabled state + * + * @access public + * @param boolean $enabled True to enable caching + * @return void + * @since 1.5 + */ + function setCaching($enabled) + { + $this->_options['caching'] = $enabled; + } + + /** + * Set cache lifetime + * + * @access public + * @param int $lt Cache lifetime + * @return void + * @since 1.5 + */ + function setLifeTime($lt) + { + $this->_options['lifetime'] = $lt; + } + + /** + * Set cache validation + * + * @access public + * @return void + * @since 1.5 + */ + function setCacheValidation() + { + // Deprecated + } + + /** + * Get cached data by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null) + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler) && $this->_options['caching']) { + return $handler->get($id, $group, (isset($this->_options['checkTime']))? $this->_options['checkTime'] : true); + } + return false; + } + + /** + * Store the cached data by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param mixed $data The data to store + * @return boolean True if cache stored + * @since 1.5 + */ + function store($data, $id, $group = null) + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler and store the cached data + $handler =& $this->_getStorage(); + if (!JError::isError($handler) && $this->_options['caching']) { + return $handler->store($id, $group, $data); + } + return false; + } + + /** + * Remove a cached data entry by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group=null) + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler)) { + return $handler->remove($id, $group); + } + return false; + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group = null, $mode = 'group') + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler)) { + return $handler->clean($group, $mode); + } + return false; + } + + /** + * Garbage collect expired cache data + * + * @access public + * @return boolean True on success, false otherwise. + * @since 1.5 + */ + function gc() + { + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler)) { + return $handler->gc(); + } + return false; + } + + /** + * Get the cache storage handler + * + * @access protected + * @return object A JCacheStorage object + * @since 1.5 + */ + function &_getStorage() + { + if (is_a($this->_handler, 'JCacheStorage')) { + return $this->_handler; + } + + $this->_handler =& JCacheStorage::getInstance($this->_options['storage'], $this->_options); + return $this->_handler; + } } diff --git a/vendor/joomla/libraries/joomla/cache/handler/callback.php b/vendor/joomla/libraries/joomla/cache/handler/callback.php index 88f7dbe76..59a9bc318 100644 --- a/vendor/joomla/libraries/joomla/cache/handler/callback.php +++ b/vendor/joomla/libraries/joomla/cache/handler/callback.php @@ -1,133 +1,121 @@ [recommended] - * - Function name as a string eg. 'foo' for function foo() - * - Static method name as a string eg. 'MyClass::myMethod' for method myMethod() of class MyClass - * - * @access public - * @return mixed Result of the callback - * @since 1.5 - */ - function call() - { - // Get callback and arguments - $args = func_get_args(); - $callback = array_shift($args); - - return $this->get( $callback, $args ); - } - - /** - * Executes a cacheable callback if not found in cache else returns cached output and result - * - * @access public - * @param mixed Callback or string shorthand for a callback - * @param array Callback arguments - * @return mixed Result of the callback - * @since 1.5 - */ - function get( $callback, $args, $id=false ) - { - // Normalize callback - if (is_array( $callback ) || $callback instanceof Closure) { - // We have a standard php callback array -- do nothing - } elseif (strstr( $callback, '::' )) { - // This is shorthand for a static method callback classname::methodname - list( $class, $method ) = explode( '::', $callback ); - $callback = array( trim($class), trim($method) ); - } elseif (strstr( $callback, '->' )) { - /* - * This is a really not so smart way of doing this... we provide this for backward compatability but this - * WILL!!! disappear in a future version. If you are using this syntax change your code to use the standard - * PHP callback array syntax:
$document = &JDocument::getInstance();* - * @access public * @param type $type The document type to instantiate * @return object The document object. */ - function &getInstance($type = 'html', $attributes = array()) + public static function &getInstance($type = 'html', $attributes = array()) { static $instances; diff --git a/vendor/joomla/libraries/joomla/document/error/error.php b/vendor/joomla/libraries/joomla/document/error/error.php index a8dd8ad67..f04610a5b 100644 --- a/vendor/joomla/libraries/joomla/document/error/error.php +++ b/vendor/joomla/libraries/joomla/document/error/error.php @@ -86,7 +86,7 @@ function render( $cache = false, $params = array()) // check template $directory = isset($params['directory']) ? $params['directory'] : 'templates'; - $template = isset($params['template']) ? JFilterInput::clean($params['template'], 'cmd') : 'system'; + $template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; if ( !file_exists( $directory.DS.$template.DS.$file) ) { $template = 'system'; diff --git a/vendor/joomla/libraries/joomla/document/html/html.php b/vendor/joomla/libraries/joomla/document/html/html.php index 4ecf31f9f..98bf26e36 100644 --- a/vendor/joomla/libraries/joomla/document/html/html.php +++ b/vendor/joomla/libraries/joomla/document/html/html.php @@ -201,7 +201,7 @@ function getBuffer($type = null, $name = null, $attribs = array()) * @param string $name oke The name of the element to render * @param string $content The content to be set in the buffer */ - function setBuffer($contents, $type, $name = null) + function setBuffer($contents, $type = null, $name = null) { $this->_buffer[$type][$name] = $contents; } @@ -218,8 +218,8 @@ function render( $caching = false, $params = array()) { // check $directory = isset($params['directory']) ? $params['directory'] : 'templates'; - $template = JFilterInput::clean($params['template'], 'cmd'); - $file = JFilterInput::clean($params['file'], 'cmd'); + $template = JFilterInput::getInstance()->clean($params['template'], 'cmd'); + $file = JFilterInput::getInstance()->clean($params['file'], 'cmd'); if ( !file_exists( $directory.DS.$template.DS.$file) ) { $template = 'system'; diff --git a/vendor/joomla/libraries/joomla/environment/response.php b/vendor/joomla/libraries/joomla/environment/response.php index 6210c3ef9..7b7227824 100644 --- a/vendor/joomla/libraries/joomla/environment/response.php +++ b/vendor/joomla/libraries/joomla/environment/response.php @@ -1,17 +1,4 @@ cachable = false; $GLOBALS['_JRESPONSE']->headers = array(); -$GLOBALS['_JRESPONSE']->body = array(); +$GLOBALS['_JRESPONSE']->body = array(); /** * JResponse Class - * + * * This class serves to provide the Joomla Framework with a common interface to access * response variables. This includes header and body. - * - * @static - * @package Joomla.Framework - * @subpackage Environment - * @since 1.5 + * + * @package Joomla.Framework + * @subpackage Environment + * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * @since 1.5 */ class JResponse { - /** - * Set/get cachable state for the response - * - * If $allow is set, sets the cachable state of the response. Always returns current state - * - * @static - * @param boolean $allow - * @return boolean True of browser caching should be allowed - * @since 1.5 - */ - function allowCache($allow = null) - { - if (!is_null($allow)) { - $GLOBALS['_JRESPONSE']->cachable = (bool) $allow; - } - return $GLOBALS['_JRESPONSE']->cachable; - } - - /** - * Set a header - * - * If $replace is true, replaces any headers already defined with that - * $name. - * - * @access public - * @param string $name - * @param string $value - * @param boolean $replace - */ - function setHeader($name, $value, $replace = false) - { - $name = (string) $name; - $value = (string) $value; - - if ($replace) - { - foreach ($GLOBALS['_JRESPONSE']->headers as $key => $header) { - if ($name == $header['name']) { - unset($GLOBALS['_JRESPONSE']->headers[$key]); - } - } - } - - $GLOBALS['_JRESPONSE']->headers[] = array( - 'name' => $name, - 'value' => $value - ); - } - - /** - * Return array of headers; - * - * @access public - * @return array - */ - function getHeaders() { - return $GLOBALS['_JRESPONSE']->headers; - } - - /** - * Clear headers - * - * @access public - */ - function clearHeaders() { - $GLOBALS['_JRESPONSE']->headers = array(); - } - - /** - * Send all headers - * - * @access public - * @return void - */ - function sendHeaders() - { - if (!headers_sent()) - { - foreach ($GLOBALS['_JRESPONSE']->headers as $header) - { - if ('status' == strtolower($header['name'])) - { - // 'status' headers indicate an HTTP status, and need to be handled slightly differently - header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']); - } else { - header($header['name'] . ': ' . $header['value']); - } - } - } - } - - /** - * Set body content - * - * If body content already defined, this will replace it. - * - * @access public - * @param string $content - */ - function setBody($content) { - $GLOBALS['_JRESPONSE']->body = array((string) $content); - } - - /** - * Prepend content to the body content - * - * @access public - * @param string $content - */ - function prependBody($content) { - array_unshift($GLOBALS['_JRESPONSE']->body, (string) $content); - } - - /** - * Append content to the body content - * - * @access public - * @param string $content - */ - function appendBody($content) { - array_push($GLOBALS['_JRESPONSE']->body, (string) $content); - } - - /** - * Return the body content - * - * @access public - * @param boolean $toArray Whether or not to return the body content as an - * array of strings or as a single string; defaults to false - * @return string|array - */ - function getBody($toArray = false) - { - if ($toArray) { - return $GLOBALS['_JRESPONSE']->body; - } - - ob_start(); - foreach ($GLOBALS['_JRESPONSE']->body as $content) { - echo $content; - } - return ob_get_clean(); - } - - /** - * Sends all headers prior to returning the string - * - * @access public - * @param boolean $compress If true, compress the data - * @return string - */ - function toString($compress = false) - { - $data = JResponse::getBody(); - - // Don't compress something if the server is going todo it anyway. Waste of time. - if($compress && !ini_get('zlib.output_compression') && ini_get('output_handler')!='ob_gzhandler') { - $data = JResponse::_compress($data); - } - - if (JResponse::allowCache() === false) - { - JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true ); // Expires in the past - JResponse::setHeader( 'Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true ); // Always modified - JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate', true ); // Extra CYA - JResponse::setHeader( 'Cache-Control', 'post-check=0, pre-check=0', false ); // HTTP/1.1 - JResponse::setHeader( 'Pragma', 'no-cache' ); // HTTP 1.0 - } - - JResponse::sendHeaders(); - return $data; - } - - /** - * Compress the data - * - * Checks the accept encoding of the browser and compresses the data before - * sending it to the client. - * - * @access public - * @param string data - * @return string compressed data - */ - function _compress( $data ) - { - $encoding = JResponse::_clientEncoding(); - - if (!$encoding) - return $data; - - if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) { - return $data; - } - - if (headers_sent()) - return $data; - - if (connection_status() !== 0) - return $data; - - - $level = 4; //ideal level - - /* - $size = strlen($data); - $crc = crc32($data); - - $gzdata = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; - $gzdata .= gzcompress($data, $level); - - $gzdata = substr($gzdata, 0, strlen($gzdata) - 4); - $gzdata .= pack("V",$crc) . pack("V", $size); - */ - - $gzdata = gzencode($data, $level); - - JResponse::setHeader('Content-Encoding', $encoding); - JResponse::setHeader('X-Content-Encoded-By', 'Joomla! 1.5'); - - return $gzdata; - } - - /** - * check, whether client supports compressed data - * - * @access private - * @return boolean - */ - function _clientEncoding() - { - if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { - return false; - } - - $encoding = false; - - if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { - $encoding = 'gzip'; - } - - if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { - $encoding = 'x-gzip'; - } - - return $encoding; - } + /** + * Set/get cachable state for the response + * + * If $allow is set, sets the cachable state of the response. Always returns current state + * + * @param boolean $allow + * @return boolean True of browser caching should be allowed + * @since 1.5 + */ + public static function allowCache($allow = null) + { + if ( ! is_null($allow)) { + $GLOBALS['_JRESPONSE']->cachable = (bool) $allow; + } + return $GLOBALS['_JRESPONSE']->cachable; + } + + /** + * Set a header + * + * If $replace is true, replaces any headers already defined with that + * $name. + * + * @param string $name + * @param string $value + * @param boolean $replace + */ + public static function setHeader($name, $value, $replace = false) + { + $name = (string)$name; + $value = (string)$value; + + if ($replace) { + foreach ($GLOBALS['_JRESPONSE']->headers as $key => $header) { + if ($name == $header['name']) { + unset($GLOBALS['_JRESPONSE']->headers[$key]); + } + } + } + + $GLOBALS['_JRESPONSE']->headers[] = array( + 'name' => $name, + 'value' => $value + ); + } + + /** + * Return array of headers; + * + * @return array + */ + public static function getHeaders() + { + return $GLOBALS['_JRESPONSE']->headers; + } + + /** + * Clear headers + */ + public static function clearHeaders() + { + $GLOBALS['_JRESPONSE']->headers = array(); + } + + /** + * Send all headers + * + * @return void + */ + public static function sendHeaders() + { + if ( ! headers_sent()) { + foreach ($GLOBALS['_JRESPONSE']->headers as $header) { + if ('status' == strtolower($header['name'])) { + // 'status' headers indicate an HTTP status, and need to be handled slightly differently + header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']); + } else { + header($header['name'] . ': ' . $header['value']); + } + } + } + } + + /** + * Set body content + * + * If body content already defined, this will replace it. + * + * @param string $content + */ + public static function setBody($content) + { + $GLOBALS['_JRESPONSE']->body = array((string)$content); + } + + /** + * Prepend content to the body content + * + * @param string $content + */ + public static function prependBody($content) + { + array_unshift($GLOBALS['_JRESPONSE']->body, (string) $content); + } + + /** + * Append content to the body content + * + * @param string $content + */ + public static function appendBody($content) + { + array_push($GLOBALS['_JRESPONSE']->body, (string)$content); + } + + /** + * Return the body content + * + * @param boolean $toArray Whether or not to return the body content as an + * array of strings or as a single string; defaults to false + * @return string|array + */ + public static function getBody($toArray = false) + { + if ($toArray) { + return $GLOBALS['_JRESPONSE']->body; + } + + ob_start(); + foreach ($GLOBALS['_JRESPONSE']->body as $content) { + echo $content; + } + return ob_get_clean(); + } + + /** + * Sends all headers prior to returning the string + * + * @param boolean $compress If true, compress the data + * @return string + */ + public static function toString($compress = false) + { + $data = JResponse::getBody(); + + // Don't compress something if the server is going todo it anyway. Waste of time. + if ($compress && ! ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') { + $data = JResponse::_compress($data); + } + + if (JResponse::allowCache() === false) { + JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true ); // Expires in the past + JResponse::setHeader( 'Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true ); // Always modified + JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate', true ); // Extra CYA + JResponse::setHeader( 'Cache-Control', 'post-check=0, pre-check=0', false ); // HTTP/1.1 + JResponse::setHeader( 'Pragma', 'no-cache' ); // HTTP 1.0 + } + + JResponse::sendHeaders(); + return $data; + } + + /** + * Compress the data + * + * Checks the accept encoding of the browser and compresses the data before + * sending it to the client. + * + * @param string data + * @return string compressed data + */ + protected static function _compress($data) + { + $encoding = JResponse::_clientEncoding(); + + if ( ! $encoding) + return $data; + + if ( ! extension_loaded('zlib') || ini_get('zlib.output_compression')) { + return $data; + } + + if (headers_sent()) + return $data; + + if (connection_status() !== 0) + return $data; + + $level = 4; //ideal level + + /* + $size = strlen($data); + $crc = crc32($data); + + $gzdata = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; + $gzdata .= gzcompress($data, $level); + + $gzdata = substr($gzdata, 0, strlen($gzdata) - 4); + $gzdata .= pack("V",$crc) . pack("V", $size); + */ + + $gzdata = gzencode($data, $level); + + JResponse::setHeader('Content-Encoding', $encoding); + JResponse::setHeader('X-Content-Encoded-By', 'Joomla! 1.5'); + + return $gzdata; + } + + /** + * check, whether client supports compressed data + * + * @return boolean + */ + protected static function _clientEncoding() + { + if ( ! isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { + return false; + } + + $encoding = false; + + if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { + $encoding = 'gzip'; + } + + if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { + $encoding = 'x-gzip'; + } + + return $encoding; + } } diff --git a/vendor/joomla/libraries/joomla/environment/uri.php b/vendor/joomla/libraries/joomla/environment/uri.php index 86965de9f..535148dda 100644 --- a/vendor/joomla/libraries/joomla/environment/uri.php +++ b/vendor/joomla/libraries/joomla/environment/uri.php @@ -1,804 +1,775 @@ parse($uri); - } - } - - /** - * Returns a reference to a global JURI object, only creating it - * if it doesn't already exist. - * - * This method must be invoked as: - *
$uri =& JURI::getInstance([$uri]);- * - * @static - * @param string $uri The URI to parse. [optional: if null uses script URI] - * @return JURI The URI object. - * @since 1.5 - */ - function &getInstance($uri = 'SERVER') - { - static $instances = array(); - - if (!isset ($instances[$uri])) - { - // Are we obtaining the URI from the server? - if ($uri == 'SERVER') - { - // Determine if the request was over SSL (HTTPS) - if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) { - $https = 's://'; - } else { - $https = '://'; - } - - /* - * Since we are assigning the URI from the server variables, we first need - * to determine if we are running on apache or IIS. If PHP_SELF and REQUEST_URI - * are present, we will assume we are running on apache. - */ - if (!empty ($_SERVER['PHP_SELF']) && !empty ($_SERVER['REQUEST_URI'])) { - - /* - * To build the entire URI we need to prepend the protocol, and the http host - * to the URI string. - */ - $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - - /* - * Since we do not have REQUEST_URI to work with, we will assume we are - * running on IIS and will therefore need to work some magic with the SCRIPT_NAME and - * QUERY_STRING environment variables. - */ - - if (strlen($_SERVER['QUERY_STRING']) && strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']) === false) { - $theURI .= '?'.$_SERVER['QUERY_STRING']; - } - - } - else - { - // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS - $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; - - // If the query string exists append it to the URI string - if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { - $theURI .= '?' . $_SERVER['QUERY_STRING']; - } - } - - // Now we need to clean what we got since we can't trust the server var - // Need to check that the URI is fully decoded in case of multiple-encoded attack vectors. - $halt = 0; - while (true) - { - $last = $theURI; - $theURI = urldecode($theURI); - - // Check whether the last decode is equal to the first. - if ($theURI == $last) { - // Break out of the while if the URI is stable. - break; - } - else if (++$halt > 10) { - // Runaway check. URI has been seriously compromised. - jexit(); - } - } - - $theURI = str_replace('"', '"',$theURI); - $theURI = str_replace('<', '<',$theURI); - $theURI = str_replace('>', '>',$theURI); - $theURI = preg_replace('/eval\((.*)\)/', '', $theURI); - $theURI = preg_replace('/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', $theURI); - } - else - { - // We were given a URI - $theURI = $uri; - } - - // Create the new JURI instance - $instances[$uri] = new JURI($theURI); - } - return $instances[$uri]; - } - - /** - * Returns the base URI for the request. - * - * @access public - * @static - * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. - * @return string The base URI string - * @since 1.5 - */ - function base($pathonly = false) - { - static $base; - - // Get the base request path - if (!isset($base)) - { - $config =& JFactory::getConfig(); - $live_site = $config->getValue('config.live_site'); - if(trim($live_site) != '') { - $uri =& JURI::getInstance($live_site); - $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); - $base['path'] = rtrim($uri->toString( array('path')), '/\\'); - if(str_replace('\\', '/', JPATH_BASE) == str_replace('\\', '/', JPATH_ADMINISTRATOR)) { - $base['path'] .= '/administrator'; - } - } else { - $uri =& JURI::getInstance(); - $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); - - if (strpos(php_sapi_name(), 'cgi') !== false && !empty($_SERVER['REQUEST_URI']) && - (!ini_get('cgi.fix_pathinfo') || version_compare(PHP_VERSION, '5.2.4', '<'))) { - // CGI on PHP pre-5.2.4 with cgi.fix_pathinfo = 0. - - // In pre-rev. 240885 of main_cgi.c, SCRIPT_NAME doesn't conform the PHP spec., - // therefore we use PHP_SELF instead. - $base['path'] = rtrim(dirname(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])), '/\\'); - } else { - // Since PHP 5.2.4 we can trust SCRIPT_NAME; it conforms the spec. - $base['path'] = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); - } - } - } - - return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path']; - } - - /** - * Returns the root URI for the request. - * - * @access public - * @static - * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. - * @return string The root URI string - * @since 1.5 - */ - function root($pathonly = false, $path = null) - { - static $root; - - // Get the scheme - if(!isset($root)) - { - $uri =& JURI::getInstance(JURI::base()); - $root['prefix'] = $uri->toString( array('scheme', 'host', 'port') ); - $root['path'] = rtrim($uri->toString( array('path') ), '/\\'); - } - - // Get the scheme - if(isset($path)) { - $root['path'] = $path; - } - - return $pathonly === false ? $root['prefix'].$root['path'].'/' : $root['path']; - } - - /** - * Returns the URL for the request, minus the query - * - * @access public - * @return string - * @since 1.5 - */ - function current() - { - static $current; - - // Get the current URL - if (!isset($current)) - { - $uri = & JURI::getInstance(); - $current = $uri->toString( array('scheme', 'host', 'port', 'path')); - } - - return $current; - } - - /** - * Parse a given URI and populate the class fields - * - * @access public - * @param string $uri The URI string to parse - * @return boolean True on success - * @since 1.5 - */ - function parse($uri) - { - //Initialize variables - $retval = false; - - // Set the original URI to fall back on - $this->_uri = $uri; - - /* - * Parse the URI and populate the object fields. If URI is parsed properly, - * set method return value to true. - */ - if ($_parts = $this->_parseURL($uri)) { - $retval = true; - } - - //We need to replace & with & for parse_str to work right... - if(isset ($_parts['query']) && strpos($_parts['query'], '&')) { - $_parts['query'] = str_replace('&', '&', $_parts['query']); - } - - $this->_scheme = isset ($_parts['scheme']) ? $_parts['scheme'] : null; - $this->_user = isset ($_parts['user']) ? $_parts['user'] : null; - $this->_pass = isset ($_parts['pass']) ? $_parts['pass'] : null; - $this->_host = isset ($_parts['host']) ? $_parts['host'] : null; - $this->_port = isset ($_parts['port']) ? $_parts['port'] : null; - $this->_path = isset ($_parts['path']) ? $_parts['path'] : null; - $this->_query = isset ($_parts['query'])? $_parts['query'] : null; - $this->_fragment = isset ($_parts['fragment']) ? $_parts['fragment'] : null; - - //parse the query - - if(isset ($_parts['query'])) parse_str($_parts['query'], $this->_vars); - return $retval; - } - - /** - * Returns full uri string - * - * @access public - * @param array $parts An array specifying the parts to render - * @return string The rendered URI string - * @since 1.5 - */ - function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) - { - $query = $this->getQuery(); //make sure the query is created - - $uri = ''; - $uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme.'://' : '') : ''; - $uri .= in_array('user', $parts) ? $this->_user : ''; - $uri .= in_array('pass', $parts) ? (!empty ($this->_pass) ? ':' : '') .$this->_pass. (!empty ($this->_user) ? '@' : '') : ''; - $uri .= in_array('host', $parts) ? $this->_host : ''; - $uri .= in_array('port', $parts) ? (!empty ($this->_port) ? ':' : '').$this->_port : ''; - $uri .= in_array('path', $parts) ? $this->_path : ''; - $uri .= in_array('query', $parts) ? (!empty ($query) ? '?'.$query : '') : ''; - $uri .= in_array('fragment', $parts)? (!empty ($this->_fragment) ? '#'.$this->_fragment : '') : ''; - - return $uri; - } - - /** - * Adds a query variable and value, replacing the value if it - * already exists and returning the old value. - * - * @access public - * @param string $name Name of the query variable to set - * @param string $value Value of the query variable - * @return string Previous value for the query variable - * @since 1.5 - */ - function setVar($name, $value) - { - $tmp = @$this->_vars[$name]; - $this->_vars[$name] = $value; - - //empty the query - $this->_query = null; - - return $tmp; - } - - /** - * Returns a query variable by name - * - * @access public - * @param string $name Name of the query variable to get - * @return array Query variables - * @since 1.5 - */ - function getVar($name = null, $default=null) - { - if(isset($this->_vars[$name])) { - return $this->_vars[$name]; - } - return $default; - } - - /** - * Removes an item from the query string variables if it exists - * - * @access public - * @param string $name Name of variable to remove - * @since 1.5 - */ - function delVar($name) - { - if (in_array($name, array_keys($this->_vars))) - { - unset ($this->_vars[$name]); - - //empty the query - $this->_query = null; - } - } - - /** - * Sets the query to a supplied string in format: - * foo=bar&x=y - * - * @access public - * @param mixed (array|string) $query The query string - * @since 1.5 - */ - function setQuery($query) - { - if(!is_array($query)) { - if(strpos($query, '&') !== false) - { - $query = str_replace('&','&',$query); - } - parse_str($query, $this->_vars); - } - - if(is_array($query)) { - $this->_vars = $query; - } - - //empty the query - $this->_query = null; - } - - /** - * Returns flat query string - * - * @access public - * @return string Query string - * @since 1.5 - */ - function getQuery($toArray = false) - { - if($toArray) { - return $this->_vars; - } - - //If the query is empty build it first - if(is_null($this->_query)) { - $this->_query = $this->buildQuery($this->_vars); - } - - return $this->_query; - } - - /** - * Build a query from a array (reverse of the PHP parse_str()) - * - * @access public - * @return string The resulting query string - * @since 1.5 - * @see parse_str() - */ - function buildQuery ($params, $akey = null) - { - if ( !is_array($params) || count($params) == 0 ) { - return false; - } - - $out = array(); - - //reset in case we are looping - if( !isset($akey) && !count($out) ) { - unset($out); - $out = array(); - } - - foreach ( $params as $key => $val ) - { - if ( is_array($val) ) { - $out[] = JURI::buildQuery($val,$key); - continue; - } - - $thekey = ( !$akey ) ? $key : $akey.'['.$key.']'; - $out[] = $thekey."=".urlencode($val); - } - - return implode("&",$out); - } - - /** - * Get URI scheme (protocol) - * ie. http, https, ftp, etc... - * - * @access public - * @return string The URI scheme - * @since 1.5 - */ - function getScheme() { - return $this->_scheme; - } - - /** - * Set URI scheme (protocol) - * ie. http, https, ftp, etc... - * - * @access public - * @param string $scheme The URI scheme - * @since 1.5 - */ - function setScheme($scheme) { - $this->_scheme = $scheme; - } - - /** - * Get URI username - * returns the username, or null if no username was specified - * - * @access public - * @return string The URI username - * @since 1.5 - */ - function getUser() { - return $this->_user; - } - - /** - * Set URI username - * - * @access public - * @param string $user The URI username - * @since 1.5 - */ - function setUser($user) { - $this->_user = $user; - } - - /** - * Get URI password - * returns the password, or null if no password was specified - * - * @access public - * @return string The URI password - * @since 1.5 - */ - function getPass() { - return $this->_pass; - } - - /** - * Set URI password - * - * @access public - * @param string $pass The URI password - * @since 1.5 - */ - function setPass($pass) { - $this->_pass = $pass; - } - - /** - * Get URI host - * returns the hostname/ip, or null if no hostname/ip was specified - * - * @access public - * @return string The URI host - * @since 1.5 - */ - function getHost() { - return $this->_host; - } - - /** - * Set URI host - * - * @access public - * @param string $host The URI host - * @since 1.5 - */ - function setHost($host) { - $this->_host = $host; - } - - /** - * Get URI port - * returns the port number, or null if no port was specified - * - * @access public - * @return int The URI port number - */ - function getPort() { - return (isset ($this->_port)) ? $this->_port : null; - } - - /** - * Set URI port - * - * @access public - * @param int $port The URI port number - * @since 1.5 - */ - function setPort($port) { - $this->_port = $port; - } - - /** - * Gets the URI path string - * - * @access public - * @return string The URI path string - * @since 1.5 - */ - function getPath() { - return $this->_path; - } - - /** - * Set the URI path string - * - * @access public - * @param string $path The URI path string - * @since 1.5 - */ - function setPath($path) { - $this->_path = $this->_cleanPath($path); - } - - /** - * Get the URI archor string - * everything after the "#" - * - * @access public - * @return string The URI anchor string - * @since 1.5 - */ - function getFragment() { - return $this->_fragment; - } - - /** - * Set the URI anchor string - * everything after the "#" - * - * @access public - * @param string $anchor The URI anchor string - * @since 1.5 - */ - function setFragment($anchor) { - $this->_fragment = $anchor; - } - - /** - * Checks whether the current URI is using HTTPS - * - * @access public - * @return boolean True if using SSL via HTTPS - * @since 1.5 - */ - function isSSL() { - return $this->getScheme() == 'https' ? true : false; - } - - /** - * Checks if the supplied URL is internal - * - * @access public - * @param string $url The URL to check - * @return boolean True if Internal - * @since 1.5 - */ - function isInternal($url) { - $uri =& JURI::getInstance($url); - $base = $uri->toString(array('scheme', 'host', 'port', 'path')); - $host = $uri->toString(array('scheme', 'host', 'port')); - if(stripos($base, JURI::base()) !== 0 && !empty($host)) { - return false; - } - return true; - } - - /** - * Resolves //, ../ and ./ from a path and returns - * the result. Eg: - * - * /foo/bar/../boo.php => /foo/boo.php - * /foo/bar/../../boo.php => /boo.php - * /foo/bar/.././/boo.php => /foo/boo.php - * - * @access private - * @param string $uri The URI path to clean - * @return string Cleaned and resolved URI path - * @since 1.5 - */ - function _cleanPath($path) - { - $path = explode('/', preg_replace('#(/+)#', '/', $path)); - - for ($i = 0; $i < count($path); $i ++) { - if ($path[$i] == '.') { - unset ($path[$i]); - $path = array_values($path); - $i --; - - } - elseif ($path[$i] == '..' AND ($i > 1 OR ($i == 1 AND $path[0] != ''))) { - unset ($path[$i]); - unset ($path[$i -1]); - $path = array_values($path); - $i -= 2; - - } - elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { - unset ($path[$i]); - $path = array_values($path); - $i --; - - } else { - continue; - } - } - - return implode('/', $path); - } - - /** - * Backwards compatibility function for parse_url function - * - * This function solves different bugs in PHP versions lower then - * 4.4, will be deprecated in future versions. - * - * @access private - * @return array Associative array containing the URL parts - * @since 1.5 - * @see parse_url() - */ - function _parseURL($uri) - { - $parts = array(); - if (version_compare( phpversion(), '4.4' ) < 0) - { - $regex = "<^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?>"; - $matches = array(); - preg_match($regex, $uri, $matches, PREG_OFFSET_CAPTURE); - - $authority = @$matches[4][0]; - if (strpos($authority, '@') !== false) { - $authority = explode('@', $authority); - @list($parts['user'], $parts['pass']) = explode(':', $authority[0]); - $authority = $authority[1]; - } - - if (strpos($authority, ':') !== false) { - $authority = explode(':', $authority); - $parts['host'] = $authority[0]; - $parts['port'] = $authority[1]; - } else { - $parts['host'] = $authority; - } - - $parts['scheme'] = @$matches[2][0]; - $parts['path'] = @$matches[5][0]; - $parts['query'] = @$matches[7][0]; - $parts['fragment'] = @$matches[9][0]; - } - else - { - $parts = @parse_url($uri); - } - return $parts; - } - - public function __toString() - { - return $this->toString(); - } - - + /** + * Original URI + * + * @var string + */ + var $_uri = null; + + /** + * Protocol + * + * @var string + */ + var $_scheme = null; + + /** + * Host + * + * @var string + */ + var $_host = null; + + /** + * Port + * + * @var integer + */ + var $_port = null; + + /** + * Username + * + * @var string + */ + var $_user = null; + + /** + * Password + * + * @var string + */ + var $_pass = null; + + /** + * Path + * + * @var string + */ + var $_path = null; + + /** + * Query + * + * @var string + */ + var $_query = null; + + /** + * Anchor + * + * @var string + */ + var $_fragment = null; + + /** + * Query variable hash + * + * @var array + */ + var $_vars = array (); + + /** + * Constructor. + * You can pass a URI string to the constructor to initialize a specific URI. + * + * @param string $uri The optional URI string + */ + function __construct($uri = null) + { + if ($uri !== null) { + $this->parse($uri); + } + } + + /** + * Returns a reference to a global JURI object, only creating it + * if it doesn't already exist. + * + * This method must be invoked as: + *
$uri =& JURI::getInstance([$uri]);+ * + * @param string $uri The URI to parse. [optional: if null uses script URI] + * @return JURI The URI object. + * @since 1.5 + */ + public static function &getInstance($uri = 'SERVER') + { + static $instances = array(); + + if ( ! isset($instances[$uri])) { + // Are we obtaining the URI from the server? + if ($uri == 'SERVER') { + // Determine if the request was over SSL (HTTPS) + if (isset($_SERVER['HTTPS']) && ! empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) { + $https = 's://'; + } else { + $https = '://'; + } + + /* + * Since we are assigning the URI from the server variables, we first need + * to determine if we are running on apache or IIS. If PHP_SELF and REQUEST_URI + * are present, we will assume we are running on apache. + */ + if ( ! empty ($_SERVER['PHP_SELF']) && !empty ($_SERVER['REQUEST_URI'])) { + + /* + * To build the entire URI we need to prepend the protocol, and the http host + * to the URI string. + */ + $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + + /* + * Since we do not have REQUEST_URI to work with, we will assume we are + * running on IIS and will therefore need to work some magic with the SCRIPT_NAME and + * QUERY_STRING environment variables. + */ + if (strlen($_SERVER['QUERY_STRING']) && strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']) === false) { + $theURI .= '?'.$_SERVER['QUERY_STRING']; + } + } else { + // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS + $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; + + // If the query string exists append it to the URI string + if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { + $theURI .= '?' . $_SERVER['QUERY_STRING']; + } + } + + // Now we need to clean what we got since we can't trust the server var + // Need to check that the URI is fully decoded in case of multiple-encoded attack vectors. + $halt = 0; + while (true) { + $last = $theURI; + $theURI = urldecode($theURI); + + // Check whether the last decode is equal to the first. + if ($theURI == $last) { + // Break out of the while if the URI is stable. + break; + } elseif (++$halt > 10) { + // Runaway check. URI has been seriously compromised. + jexit(); + } + } + + $theURI = str_replace('"', '"',$theURI); + $theURI = str_replace('<', '<',$theURI); + $theURI = str_replace('>', '>',$theURI); + $theURI = preg_replace('/eval\((.*)\)/', '', $theURI); + $theURI = preg_replace('/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', $theURI); + } else { + // We were given a URI + $theURI = $uri; + } + + // Create the new JURI instance + $instances[$uri] = new JURI($theURI); + } + return $instances[$uri]; + } + + /** + * Returns the base URI for the request. + * + * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. + * @return string The base URI string + * @since 1.5 + */ + public static function base($pathonly = false) + { + static $base; + + // Get the base request path + if ( ! isset($base)) { + $config =& JFactory::getConfig(); + $live_site = $config->getValue('config.live_site'); + if(trim($live_site) != '') { + $uri =& JURI::getInstance($live_site); + $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); + $base['path'] = rtrim($uri->toString( array('path')), '/\\'); + if(str_replace('\\', '/', JPATH_BASE) == str_replace('\\', '/', JPATH_ADMINISTRATOR)) { + $base['path'] .= '/administrator'; + } + } else { + $uri =& JURI::getInstance(); + $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); + + if (strpos(php_sapi_name(), 'cgi') !== false && !empty($_SERVER['REQUEST_URI']) && + (!ini_get('cgi.fix_pathinfo') || version_compare(PHP_VERSION, '5.2.4', '<'))) { + // CGI on PHP pre-5.2.4 with cgi.fix_pathinfo = 0. + + // In pre-rev. 240885 of main_cgi.c, SCRIPT_NAME doesn't conform the PHP spec., + // therefore we use PHP_SELF instead. + $base['path'] = rtrim(dirname(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])), '/\\'); + } else { + // Since PHP 5.2.4 we can trust SCRIPT_NAME; it conforms the spec. + $base['path'] = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); + } + } + } + + return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path']; + } + + /** + * Returns the root URI for the request. + * + * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. + * @return string The root URI string + * @since 1.5 + */ + public static function root($pathonly = false, $path = null) + { + static $root; + + // Get the scheme + if( ! isset($root)) { + $uri =& JURI::getInstance(JURI::base()); + $root['prefix'] = $uri->toString( array('scheme', 'host', 'port') ); + $root['path'] = rtrim($uri->toString( array('path') ), '/\\'); + } + + // Get the scheme + if(isset($path)) { + $root['path'] = $path; + } + + return $pathonly === false ? $root['prefix'].$root['path'].'/' : $root['path']; + } + + /** + * Returns the URL for the request, minus the query + * + * @return string + * @since 1.5 + */ + public static function current() + { + static $current; + + // Get the current URL + if ( ! isset($current)) { + $uri =& JURI::getInstance(); + $current = $uri->toString(array('scheme', 'host', 'port', 'path')); + } + + return $current; + } + + /** + * Parse a given URI and populate the class fields + * + * @access public + * @param string $uri The URI string to parse + * @return boolean True on success + * @since 1.5 + */ + function parse($uri) + { + //Initialize variables + $retval = false; + + // Set the original URI to fall back on + $this->_uri = $uri; + + /* + * Parse the URI and populate the object fields. If URI is parsed properly, + * set method return value to true. + */ + if ($_parts = $this->_parseURL($uri)) { + $retval = true; + } + + //We need to replace & with & for parse_str to work right... + if(isset ($_parts['query']) && strpos($_parts['query'], '&')) { + $_parts['query'] = str_replace('&', '&', $_parts['query']); + } + + $this->_scheme = isset ($_parts['scheme']) ? $_parts['scheme'] : null; + $this->_user = isset ($_parts['user']) ? $_parts['user'] : null; + $this->_pass = isset ($_parts['pass']) ? $_parts['pass'] : null; + $this->_host = isset ($_parts['host']) ? $_parts['host'] : null; + $this->_port = isset ($_parts['port']) ? $_parts['port'] : null; + $this->_path = isset ($_parts['path']) ? $_parts['path'] : null; + $this->_query = isset ($_parts['query'])? $_parts['query'] : null; + $this->_fragment = isset ($_parts['fragment']) ? $_parts['fragment'] : null; + + //parse the query + if(isset ($_parts['query'])) parse_str($_parts['query'], $this->_vars); + return $retval; + } + + /** + * Returns full uri string + * + * @access public + * @param array $parts An array specifying the parts to render + * @return string The rendered URI string + * @since 1.5 + */ + function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) + { + $query = $this->getQuery(); //make sure the query is created + + $uri = ''; + $uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme.'://' : '') : ''; + $uri .= in_array('user', $parts) ? $this->_user : ''; + $uri .= in_array('pass', $parts) ? (!empty ($this->_pass) ? ':' : '') .$this->_pass. (!empty ($this->_user) ? '@' : '') : ''; + $uri .= in_array('host', $parts) ? $this->_host : ''; + $uri .= in_array('port', $parts) ? (!empty ($this->_port) ? ':' : '').$this->_port : ''; + $uri .= in_array('path', $parts) ? $this->_path : ''; + $uri .= in_array('query', $parts) ? (!empty ($query) ? '?'.$query : '') : ''; + $uri .= in_array('fragment', $parts)? (!empty ($this->_fragment) ? '#'.$this->_fragment : '') : ''; + + return $uri; + } + + /** + * Adds a query variable and value, replacing the value if it + * already exists and returning the old value. + * + * @access public + * @param string $name Name of the query variable to set + * @param string $value Value of the query variable + * @return string Previous value for the query variable + * @since 1.5 + */ + function setVar($name, $value) + { + $tmp = @$this->_vars[$name]; + $this->_vars[$name] = $value; + + //empty the query + $this->_query = null; + + return $tmp; + } + + /** + * Returns a query variable by name + * + * @access public + * @param string $name Name of the query variable to get + * @return array Query variables + * @since 1.5 + */ + function getVar($name = null, $default=null) + { + if(isset($this->_vars[$name])) { + return $this->_vars[$name]; + } + return $default; + } + + /** + * Removes an item from the query string variables if it exists + * + * @access public + * @param string $name Name of variable to remove + * @since 1.5 + */ + function delVar($name) + { + if (in_array($name, array_keys($this->_vars))) { + unset ($this->_vars[$name]); + + //empty the query + $this->_query = null; + } + } + + /** + * Sets the query to a supplied string in format: + * foo=bar&x=y + * + * @access public + * @param mixed (array|string) $query The query string + * @since 1.5 + */ + function setQuery($query) + { + if ( ! is_array($query)) { + if (strpos($query, '&') !== false) { + $query = str_replace('&','&',$query); + } + parse_str($query, $this->_vars); + } + + if (is_array($query)) { + $this->_vars = $query; + } + + //empty the query + $this->_query = null; + } + + /** + * Returns flat query string + * + * @access public + * @return string Query string + * @since 1.5 + */ + function getQuery($toArray = false) + { + if ($toArray) { + return $this->_vars; + } + + //If the query is empty build it first + if (is_null($this->_query)) { + $this->_query = $this->buildQuery($this->_vars); + } + + return $this->_query; + } + + /** + * Build a query from a array (reverse of the PHP parse_str()) + * + * @access public + * @return string The resulting query string + * @since 1.5 + * @see parse_str() + */ + function buildQuery ($params, $akey = null) + { + if ( ! is_array($params) || count($params) == 0) { + return false; + } + + $out = array(); + + //reset in case we are looping + if ( ! isset($akey) && !count($out)) { + unset($out); + $out = array(); + } + + foreach ($params as $key => $val) { + if (is_array($val)) { + $out[] = JURI::buildQuery($val,$key); + continue; + } + + $thekey = ( !$akey ) ? $key : $akey.'['.$key.']'; + $out[] = $thekey."=".urlencode($val); + } + + return implode("&",$out); + } + + /** + * Get URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @access public + * @return string The URI scheme + * @since 1.5 + */ + function getScheme() { + return $this->_scheme; + } + + /** + * Set URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @access public + * @param string $scheme The URI scheme + * @since 1.5 + */ + function setScheme($scheme) + { + $this->_scheme = $scheme; + } + + /** + * Get URI username + * returns the username, or null if no username was specified + * + * @access public + * @return string The URI username + * @since 1.5 + */ + function getUser() + { + return $this->_user; + } + + /** + * Set URI username + * + * @access public + * @param string $user The URI username + * @since 1.5 + */ + function setUser($user) + { + $this->_user = $user; + } + + /** + * Get URI password + * returns the password, or null if no password was specified + * + * @access public + * @return string The URI password + * @since 1.5 + */ + function getPass() + { + return $this->_pass; + } + + /** + * Set URI password + * + * @access public + * @param string $pass The URI password + * @since 1.5 + */ + function setPass($pass) + { + $this->_pass = $pass; + } + + /** + * Get URI host + * returns the hostname/ip, or null if no hostname/ip was specified + * + * @access public + * @return string The URI host + * @since 1.5 + */ + function getHost() + { + return $this->_host; + } + + /** + * Set URI host + * + * @access public + * @param string $host The URI host + * @since 1.5 + */ + function setHost($host) + { + $this->_host = $host; + } + + /** + * Get URI port + * returns the port number, or null if no port was specified + * + * @access public + * @return int The URI port number + */ + function getPort() + { + return $this->_port; + } + + /** + * Set URI port + * + * @access public + * @param int $port The URI port number + * @since 1.5 + */ + function setPort($port) + { + $this->_port = $port; + } + + /** + * Gets the URI path string + * + * @access public + * @return string The URI path string + * @since 1.5 + */ + function getPath() + { + return $this->_path; + } + + /** + * Set the URI path string + * + * @access public + * @param string $path The URI path string + * @since 1.5 + */ + function setPath($path) + { + $this->_path = $this->_cleanPath($path); + } + + /** + * Get the URI archor string + * everything after the "#" + * + * @access public + * @return string The URI anchor string + * @since 1.5 + */ + function getFragment() + { + return $this->_fragment; + } + + /** + * Set the URI anchor string + * everything after the "#" + * + * @access public + * @param string $anchor The URI anchor string + * @since 1.5 + */ + function setFragment($anchor) + { + $this->_fragment = $anchor; + } + + /** + * Checks whether the current URI is using HTTPS + * + * @access public + * @return boolean True if using SSL via HTTPS + * @since 1.5 + */ + function isSSL() + { + return $this->getScheme() == 'https' ? true : false; + } + + /** + * Checks if the supplied URL is internal + * + * @param string $url The URL to check + * @return boolean True if Internal + * @since 1.5 + */ + public static function isInternal($url) { + $uri =& JURI::getInstance($url); + $base = $uri->toString(array('scheme', 'host', 'port', 'path')); + $host = $uri->toString(array('scheme', 'host', 'port')); + if (stripos($base, JURI::base()) !== 0 && ! empty($host)) { + return false; + } + return true; + } + + /** + * Resolves //, ../ and ./ from a path and returns + * the result. Eg: + * + * /foo/bar/../boo.php => /foo/boo.php + * /foo/bar/../../boo.php => /boo.php + * /foo/bar/.././/boo.php => /foo/boo.php + * + * @access private + * @param string $uri The URI path to clean + * @return string Cleaned and resolved URI path + * @since 1.5 + */ + function _cleanPath($path) + { + $path = explode('/', preg_replace('#(/+)#', '/', $path)); + + for ($i = 0; $i < count($path); $i ++) { + if ($path[$i] == '.') { + unset ($path[$i]); + $path = array_values($path); + $i --; + } elseif ($path[$i] == '..' AND ($i > 1 OR ($i == 1 AND $path[0] != ''))) { + unset ($path[$i]); + unset ($path[$i -1]); + $path = array_values($path); + $i -= 2; + } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { + unset ($path[$i]); + $path = array_values($path); + $i --; + } else { + continue; + } + } + + return implode('/', $path); + } + + /** + * Backwards compatibility function for parse_url function + * + * This function solves different bugs in PHP versions lower then + * 4.4, will be deprecated in future versions. + * + * @access private + * @return array Associative array containing the URL parts + * @since 1.5 + * @see parse_url() + */ + function _parseURL($uri) + { + $parts = array(); + if (version_compare( phpversion(), '4.4' ) < 0) { + $regex = "<^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?>"; + $matches = array(); + preg_match($regex, $uri, $matches, PREG_OFFSET_CAPTURE); + + $authority = @$matches[4][0]; + if (strpos($authority, '@') !== false) { + $authority = explode('@', $authority); + @list($parts['user'], $parts['pass']) = explode(':', $authority[0]); + $authority = $authority[1]; + } + + if (strpos($authority, ':') !== false) { + $authority = explode(':', $authority); + $parts['host'] = $authority[0]; + $parts['port'] = $authority[1]; + } else { + $parts['host'] = $authority; + } + + $parts['scheme'] = @$matches[2][0]; + $parts['path'] = @$matches[5][0]; + $parts['query'] = @$matches[7][0]; + $parts['fragment'] = @$matches[9][0]; + } else { + $parts = @parse_url($uri); + } + return $parts; + } + + public function __toString() + { + return $this->toString(); + } } diff --git a/vendor/joomla/libraries/joomla/error/error.php b/vendor/joomla/libraries/joomla/error/error.php index 5691d8efe..9d5167c8a 100644 --- a/vendor/joomla/libraries/joomla/error/error.php +++ b/vendor/joomla/libraries/joomla/error/error.php @@ -71,7 +71,7 @@ class JError * @return boolean True if argument is an exception, false otherwise. * @since 1.5 */ - static public function isError(& $object) + public static function isError(& $object) { if (!is_object($object)) { return false; @@ -88,7 +88,7 @@ static public function isError(& $object) * @return mixed Last exception object in the error stack or boolean false if none exist * @since 1.5 */ - static public function & getError($unset = false) + public static function & getError($unset = false) { if (!isset($GLOBALS['_JERROR_STACK'][0])) { $false = false; @@ -110,7 +110,7 @@ static public function & getError($unset = false) * @return array Chronological array of errors that have been stored during script execution * @since 1.5 */ - static public function & getErrors() + public static function & getErrors() { return $GLOBALS['_JERROR_STACK']; } @@ -128,7 +128,7 @@ static public function & getErrors() * * @see JException */ - static public function & raise($level, $code, $msg, $info = null, $backtrace = false) + public static function & raise($level, $code, $msg, $info = null, $backtrace = false) { jimport('joomla.error.exception'); @@ -166,7 +166,7 @@ static public function & raise($level, $code, $msg, $info = null, $backtrace = f * @return object $error The configured JError object * @since 1.5 */ - static public function & raiseError($code, $msg, $info = null) + public static function & raiseError($code, $msg, $info = null) { $reference = & JError::raise(E_ERROR, $code, $msg, $info, true); return $reference; @@ -182,7 +182,7 @@ static public function & raiseError($code, $msg, $info = null) * @return object $error The configured JError object * @since 1.5 */ - static public function & raiseWarning($code, $msg, $info = null) + public static function & raiseWarning($code, $msg, $info = null) { $reference = & JError::raise(E_WARNING, $code, $msg, $info); return $reference; @@ -198,7 +198,7 @@ static public function & raiseWarning($code, $msg, $info = null) * @return object $error The configured JError object * @since 1.5 */ - static public function & raiseNotice($code, $msg, $info = null) + public static function & raiseNotice($code, $msg, $info = null) { $reference = & JError::raise(E_NOTICE, $code, $msg, $info); return $reference; @@ -212,7 +212,7 @@ static public function & raiseNotice($code, $msg, $info = null) * @return array All error handling details * @since 1.5 */ - static public function getErrorHandling( $level ) + public static function getErrorHandling( $level ) { return $GLOBALS['_JERROR_HANDLERS'][$level]; } @@ -242,7 +242,7 @@ static public function getErrorHandling( $level ) * @return mixed True on success, or a JException object if failed. * @since 1.5 */ - static public function setErrorHandling($level, $mode, $options = null) + public static function setErrorHandling($level, $mode, $options = null) { $levels = $GLOBALS['_JERROR_LEVELS']; @@ -291,7 +291,7 @@ static public function setErrorHandling($level, $mode, $options = null) * @access public * @see set_error_handler */ - static public function attachHandler() + public static function attachHandler() { set_error_handler(array('JError', 'customErrorHandler')); } @@ -302,7 +302,7 @@ static public function attachHandler() * @access public * @see restore_error_handler */ - static public function detachHandler() + public static function detachHandler() { restore_error_handler(); } @@ -322,7 +322,7 @@ static public function detachHandler() * @return boolean True on success; false if the level already has been registered * @since 1.5 */ - static public function registerErrorLevel( $level, $name, $handler = 'ignore' ) + public static function registerErrorLevel( $level, $name, $handler = 'ignore' ) { if( isset($GLOBALS['_JERROR_LEVELS'][$level]) ) { return false; @@ -341,7 +341,7 @@ static public function registerErrorLevel( $level, $name, $handler = 'ignore' ) * @return mixed Human readable error level name or boolean false if it doesn't exist * @since 1.5 */ - static public function translateErrorLevel( $level ) + public static function translateErrorLevel( $level ) { if( isset($GLOBALS['_JERROR_LEVELS'][$level]) ) { return $GLOBALS['_JERROR_LEVELS'][$level]; @@ -361,7 +361,7 @@ static public function translateErrorLevel( $level ) * * @see raise() */ - static public function & handleIgnore(&$error, $options) + public static function & handleIgnore(&$error, $options) { return $error; } @@ -378,7 +378,7 @@ static public function & handleIgnore(&$error, $options) * * @see raise() */ - static public function & handleEcho(&$error, $options) + public static function & handleEcho(&$error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); @@ -408,7 +408,7 @@ static public function & handleEcho(&$error, $options) * * @see raise() */ - static public function & handleVerbose(& $error, $options) + public static function & handleVerbose(& $error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); $info = $error->get('info'); @@ -443,7 +443,7 @@ static public function & handleVerbose(& $error, $options) * * @see raise() */ - static public function & handleDie(& $error, $options) + public static function & handleDie(& $error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); @@ -473,7 +473,7 @@ static public function & handleDie(& $error, $options) * * @see raise() */ - static public function & handleMessage(& $error, $options) + public static function & handleMessage(& $error, $options) { global $mainframe; $type = ($error->get('level') == E_NOTICE) ? 'notice' : 'error'; @@ -493,7 +493,7 @@ static public function & handleMessage(& $error, $options) * * @see raise() */ - static public function & handleLog(& $error, $options) + public static function & handleLog(& $error, $options) { static $log; @@ -525,7 +525,7 @@ static public function & handleLog(& $error, $options) * * @see raise() */ - static public function &handleCallback( &$error, $options ) + public static function &handleCallback( &$error, $options ) { $result = call_user_func( $options, $error ); return $result; @@ -539,7 +539,7 @@ static public function &handleCallback( &$error, $options ) * @return void * @since 1.5 */ - static public function customErrorPage(& $error) + public static function customErrorPage(& $error) { // Initialize variables jimport('joomla.document.document'); @@ -577,7 +577,7 @@ static public function customErrorPage(& $error) $app->close(0); } - static public function customErrorHandler($level, $msg) + public static function customErrorHandler($level, $msg) { JError::raise($level, '', $msg); } diff --git a/vendor/joomla/libraries/joomla/filesystem/file.php b/vendor/joomla/libraries/joomla/filesystem/file.php index 7de4531d9..925990d47 100644 --- a/vendor/joomla/libraries/joomla/filesystem/file.php +++ b/vendor/joomla/libraries/joomla/filesystem/file.php @@ -1,17 +1,4 @@ 0) { - return $chunks[$chunksCount]; - } - - return false; - } - - /** - * Strips the last extension off a file name - * - * @param string $file The file name - * @return string The file name without the extension - * @since 1.5 - */ - function stripExt($file) { - return preg_replace('#\.[^.]*$#', '', $file); - } - - /** - * Makes file name safe to use - * - * @param string $file The name of the file [not full path] - * @return string The sanitised string - * @since 1.5 - */ - function makeSafe($file) { - $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#'); - return preg_replace($regex, '', $file); - } - - /** - * Copies a file - * - * @param string $src The path to the source file - * @param string $dest The path to the destination file - * @param string $path An optional base path to prefix to the file names - * @return boolean True on success - * @since 1.5 - */ - function copy($src, $dest, $path = null) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - // Prepend a base path if it exists - if ($path) { - $src = JPath::clean($path.DS.$src); - $dest = JPath::clean($path.DS.$dest); - } - - //Check src path - if (!is_readable($src)) { - JError::raiseWarning(21, 'JFile::copy: ' . JText::_('Cannot find or read file') . ": '$src'"); - return false; - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - // If the parent folder doesn't exist we must create it - if (!file_exists(dirname($dest))) { - jimport('joomla.filesystem.folder'); - JFolder::create(dirname($dest)); - } - - //Translate the destination path for the FTP account - $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); - if (!$ftp->store($src, $dest)) { - // FTP connector throws an error - return false; - } - $ret = true; - } else { - if (!@ copy($src, $dest)) { - JError::raiseWarning(21, JText::_('Copy failed')); - return false; - } - $ret = true; - } - return $ret; - } - - /** - * Delete a file or array of files - * - * @param mixed $file The file name or an array of file names - * @return boolean True on success - * @since 1.5 - */ - function delete($file) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - if (is_array($file)) { - $files = $file; - } else { - $files[] = $file; - } - - // Do NOT use ftp if it is not enabled - if ($FTPOptions['enabled'] == 1) - { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - } - - foreach ($files as $file) - { - $file = JPath::clean($file); - - // Try making the file writeable first. If it's read-only, it can't be deleted - // on Windows, even if the parent folder is writeable - @chmod($file, 0777); - - // In case of restricted permissions we zap it one way or the other - // as long as the owner is either the webserver or the ftp - if (@unlink($file)) { - // Do nothing - } elseif ($FTPOptions['enabled'] == 1) { - $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); - if (!$ftp->delete($file)) { - // FTP connector throws an error - return false; - } - } else { - $filename = basename($file); - JError::raiseWarning('SOME_ERROR_CODE', JText::_('Delete failed') . ": '$filename'"); - return false; - } - } - - return true; - } - - /** - * Moves a file - * - * @param string $src The path to the source file - * @param string $dest The path to the destination file - * @param string $path An optional base path to prefix to the file names - * @return boolean True on success - * @since 1.5 - */ - function move($src, $dest, $path = '') - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - if ($path) { - $src = JPath::clean($path.DS.$src); - $dest = JPath::clean($path.DS.$dest); - } - - //Check src path - if (!is_readable($src) && !is_writable($src)) { - JError::raiseWarning(21, 'JFile::move: ' . JText::_('Cannot find, read or write file') . ": '$src'"); - return false; - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - //Translate path for the FTP account - $src = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $src), '/'); - $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); - - // Use FTP rename to simulate move - if (!$ftp->rename($src, $dest)) { - JError::raiseWarning(21, JText::_('Rename failed')); - return false; - } - } else { - if (!@ rename($src, $dest)) { - JError::raiseWarning(21, JText::_('Rename failed')); - return false; - } - } - return true; - } - - /** - * Read the contents of a file - * - * @param string $filename The full file path - * @param boolean $incpath Use include path - * @param int $amount Amount of file to read - * @param int $chunksize Size of chunks to read - * @param int $offset Offset of the file - * @return mixed Returns file contents or boolean False if failed - * @since 1.5 - */ - function read($filename, $incpath = false, $amount = 0, $chunksize = 8192, $offset = 0) - { - // Initialize variables - $data = null; - if($amount && $chunksize > $amount) { $chunksize = $amount; } - if (false === $fh = fopen($filename, 'rb', $incpath)) { - JError::raiseWarning(21, 'JFile::read: '.JText::_('Unable to open file') . ": '$filename'"); - return false; - } - clearstatcache(); - if($offset) fseek($fh, $offset); - if ($fsize = @ filesize($filename)) { - if($amount && $fsize > $amount) { - $data = fread($fh, $amount); - } else { - $data = fread($fh, $fsize); - } - } else { - $data = ''; - $x = 0; - // While its: - // 1: Not the end of the file AND - // 2a: No Max Amount set OR - // 2b: The length of the data is less than the max amount we want - while (!feof($fh) && (!$amount || strlen($data) < $amount)) { - $data .= fread($fh, $chunksize); - } - } - fclose($fh); - - return $data; - } - - /** - * Write contents to a file - * - * @param string $file The full file path - * @param string $buffer The buffer to write - * @return boolean True on success - * @since 1.5 - */ - function write($file, $buffer) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - // If the destination directory doesn't exist we need to create it - if (!file_exists(dirname($file))) { - jimport('joomla.filesystem.folder'); - JFolder::create(dirname($file)); - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - // Translate path for the FTP account and use FTP write buffer to file - $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); - $ret = $ftp->write($file, $buffer); - } else { - $file = JPath::clean($file); - $ret = file_put_contents($file, $buffer); - } - return $ret; - } - - /** - * Moves an uploaded file to a destination folder - * - * @param string $src The name of the php (temporary) uploaded file - * @param string $dest The path (including filename) to move the uploaded file to - * @return boolean True on success - * @since 1.5 - */ - function upload($src, $dest) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - $ret = false; - - // Ensure that the path is valid and clean - $dest = JPath::clean($dest); - - // Create the destination directory if it does not exist - $baseDir = dirname($dest); - if (!file_exists($baseDir)) { - jimport('joomla.filesystem.folder'); - JFolder::create($baseDir); - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - //Translate path for the FTP account - $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); - - // Copy the file to the destination directory - if (is_uploaded_file($src) && $ftp->store($src, $dest)) - { - $ret = true; - unlink($src); - } else { - JError::raiseWarning(21, JText::_('WARNFS_ERR02')); - } - } else { - if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors - if (JPath::setPermissions($dest)) { - $ret = true; - } else { - JError::raiseWarning(21, JText::_('WARNFS_ERR01')); - } - } else { - JError::raiseWarning(21, JText::_('WARNFS_ERR02')); - } - } - return $ret; - } - - /** - * Wrapper for the standard file_exists function - * - * @param string $file File path - * @return boolean True if path is a file - * @since 1.5 - */ - function exists($file) - { - return is_file(JPath::clean($file)); - } - - /** - * Returns the name, sans any path - * - * param string $file File path - * @return string filename - * @since 1.5 - */ - function getName($file) { - $slash = strrpos($file, DS); - if ($slash !== false) { - return substr($file, $slash + 1); - } else { - return $file; - } - } + /** + * Gets the extension of a file name + * + * @param string $file The file name + * @return string The file extension + * @since 1.5 + */ + public static function getExt($file) + { + $chunks = explode('.', $file); + $chunksCount = count($chunks) - 1; + + if ($chunksCount > 0) { + return $chunks[$chunksCount]; + } + + return false; + } + + /** + * Strips the last extension off a file name + * + * @param string $file The file name + * @return string The file name without the extension + * @since 1.5 + */ + public static function stripExt($file) + { + return preg_replace('#\.[^.]*$#', '', $file); + } + + /** + * Makes file name safe to use + * + * @param string $file The name of the file [not full path] + * @return string The sanitised string + * @since 1.5 + */ + public static function makeSafe($file) + { + $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#'); + return preg_replace($regex, '', $file); + } + + /** + * Copies a file + * + * @param string $src The path to the source file + * @param string $dest The path to the destination file + * @param string $path An optional base path to prefix to the file names + * @return boolean True on success + * @since 1.5 + */ + public static function copy($src, $dest, $path = null) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + // Prepend a base path if it exists + if ($path) { + $src = JPath::clean($path.DS.$src); + $dest = JPath::clean($path.DS.$dest); + } + + //Check src path + if ( ! is_readable($src)) { + JError::raiseWarning(21, 'JFile::copy: '.JText::_('Cannot find or read file').": '$src'"); + return false; + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + // If the parent folder doesn't exist we must create it + if ( ! file_exists(dirname($dest))) { + jimport('joomla.filesystem.folder'); + JFolder::create(dirname($dest)); + } + + //Translate the destination path for the FTP account + $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); + if (!$ftp->store($src, $dest)) { + // FTP connector throws an error + return false; + } + $ret = true; + } else { + if (! @copy($src, $dest)) { + JError::raiseWarning(21, JText::_('Copy failed')); + return false; + } + $ret = true; + } + return $ret; + } + + /** + * Delete a file or array of files + * + * @param mixed $file The file name or an array of file names + * @return boolean True on success + * @since 1.5 + */ + public static function delete($file) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + if (is_array($file)) { + $files = $file; + } else { + $files[] = $file; + } + + // Do NOT use ftp if it is not enabled + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + } + + foreach ($files as $file) { + $file = JPath::clean($file); + + // Try making the file writeable first. If it's read-only, it can't be deleted + // on Windows, even if the parent folder is writeable + @chmod($file, 0777); + + // In case of restricted permissions we zap it one way or the other + // as long as the owner is either the webserver or the ftp + if (@unlink($file)) { + // Do nothing + } elseif ($FTPOptions['enabled'] == 1) { + $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); + if (!$ftp->delete($file)) { + // FTP connector throws an error + return false; + } + } else { + $filename = basename($file); + JError::raiseWarning('SOME_ERROR_CODE', JText::_('Delete failed') . ": '$filename'"); + return false; + } + } + + return true; + } + + /** + * Moves a file + * + * @param string $src The path to the source file + * @param string $dest The path to the destination file + * @param string $path An optional base path to prefix to the file names + * @return boolean True on success + * @since 1.5 + */ + public static function move($src, $dest, $path = '') + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + if ($path) { + $src = JPath::clean($path.DS.$src); + $dest = JPath::clean($path.DS.$dest); + } + + //Check src path + if ( ! is_readable($src) && !is_writable($src)) { + JError::raiseWarning(21, 'JFile::move: '.JText::_('Cannot find, read or write file').": '$src'"); + return false; + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + //Translate path for the FTP account + $src = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $src), '/'); + $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); + + // Use FTP rename to simulate move + if (!$ftp->rename($src, $dest)) { + JError::raiseWarning(21, JText::_('Rename failed')); + return false; + } + } else { + if (!@ rename($src, $dest)) { + JError::raiseWarning(21, JText::_('Rename failed')); + return false; + } + } + return true; + } + + /** + * Read the contents of a file + * + * @param string $filename The full file path + * @param boolean $incpath Use include path + * @param int $amount Amount of file to read + * @param int $chunksize Size of chunks to read + * @param int $offset Offset of the file + * @return mixed Returns file contents or boolean False if failed + * @since 1.5 + */ + public static function read($filename, $incpath = false, $amount = 0, $chunksize = 8192, $offset = 0) + { + // Initialize variables + $data = null; + if($amount && $chunksize > $amount) { + $chunksize = $amount; + } + if (false === $fh = fopen($filename, 'rb', $incpath)) { + JError::raiseWarning(21, 'JFile::read: '.JText::_('Unable to open file') . ": '$filename'"); + return false; + } + clearstatcache(); + if ($offset) fseek($fh, $offset); + if ($fsize = @filesize($filename)) { + if($amount && $fsize > $amount) { + $data = fread($fh, $amount); + } else { + $data = fread($fh, $fsize); + } + } else { + $data = ''; + $x = 0; + // While its: + // 1: Not the end of the file AND + // 2a: No Max Amount set OR + // 2b: The length of the data is less than the max amount we want + while (!feof($fh) && (!$amount || strlen($data) < $amount)) { + $data .= fread($fh, $chunksize); + } + } + fclose($fh); + + return $data; + } + + /** + * Write contents to a file + * + * @param string $file The full file path + * @param string $buffer The buffer to write + * @return boolean True on success + * @since 1.5 + */ + public static function write($file, $buffer) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + // If the destination directory doesn't exist we need to create it + if (!file_exists(dirname($file))) { + jimport('joomla.filesystem.folder'); + JFolder::create(dirname($file)); + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + // Translate path for the FTP account and use FTP write buffer to file + $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); + $ret = $ftp->write($file, $buffer); + } else { + $file = JPath::clean($file); + $ret = file_put_contents($file, $buffer); + } + return $ret; + } + + /** + * Moves an uploaded file to a destination folder + * + * @param string $src The name of the php (temporary) uploaded file + * @param string $dest The path (including filename) to move the uploaded file to + * @return boolean True on success + * @since 1.5 + */ + public static function upload($src, $dest) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + $ret = false; + + // Ensure that the path is valid and clean + $dest = JPath::clean($dest); + + // Create the destination directory if it does not exist + $baseDir = dirname($dest); + if ( ! file_exists($baseDir)) { + jimport('joomla.filesystem.folder'); + JFolder::create($baseDir); + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + //Translate path for the FTP account + $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); + + // Copy the file to the destination directory + if (is_uploaded_file($src) && $ftp->store($src, $dest)) { + $ret = true; + unlink($src); + } else { + JError::raiseWarning(21, JText::_('WARNFS_ERR02')); + } + } else { + if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors + if (JPath::setPermissions($dest)) { + $ret = true; + } else { + JError::raiseWarning(21, JText::_('WARNFS_ERR01')); + } + } else { + JError::raiseWarning(21, JText::_('WARNFS_ERR02')); + } + } + return $ret; + } + + /** + * Wrapper for the standard file_exists function + * + * @param string $file File path + * @return boolean True if path is a file + * @since 1.5 + */ + public static function exists($file) + { + return is_file(JPath::clean($file)); + } + + /** + * Returns the name, sans any path + * + * param string $file File path + * @return string filename + * @since 1.5 + */ + public static function getName($file) { + $slash = strrpos($file, DS); + if ($slash !== false) { + return substr($file, $slash + 1); + } else { + return $file; + } + } } diff --git a/vendor/joomla/libraries/joomla/filesystem/folder.php b/vendor/joomla/libraries/joomla/filesystem/folder.php index 9d7ebd39c..6e9d3dde2 100644 --- a/vendor/joomla/libraries/joomla/filesystem/folder.php +++ b/vendor/joomla/libraries/joomla/filesystem/folder.php @@ -1,17 +1,4 @@ store($sfid, $dfid)) { - return JError::raiseError(-1, JText::_('Copy failed')); - } - break; - } - } - } else { - if (!($dh = @opendir($src))) { - return JError::raiseError(-1, JText::_('Unable to open source folder')); - } - // Walk through the directory copying files and recursing into folders. - while (($file = readdir($dh)) !== false) { - $sfid = $src . DS . $file; - $dfid = $dest . DS . $file; - switch (filetype($sfid)) { - case 'dir': - if ($file != '.' && $file != '..') { - $ret = JFolder::copy($sfid, $dfid, null, $force); - if ($ret !== true) { - return $ret; - } - } - break; - - case 'file': - if (!@copy($sfid, $dfid)) { - return JError::raiseError(-1, JText::_('Copy failed')); - } - break; - } - } - } - return true; - } - - /** - * Create a folder -- and all necessary parent folders. - * - * @param string A path to create from the base path. - * @param int Directory permissions to set for folders created. - * @return boolean True if successful. - * @since 1.5 - */ - function create($path = '', $mode = 0755) - { - // Initialize variables - jimport('joomla.client.helper'); - $ftpOptions = JClientHelper::getCredentials('ftp'); - static $nested = 0; - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Check if parent dir exists - $parent = dirname($path); - if (!JFolder::exists($parent)) { - // Prevent infinite loops! - $nested++; - if (($nested > 20) || ($parent == $path)) { - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::create: ' . JText::_('Infinite loop detected') - ); - $nested--; - return false; - } - - // Create the parent directory - if (JFolder::create($parent, $mode) !== true) { - // JFolder::create throws an error - $nested--; - return false; - } - - // OK, parent directory has been created - $nested--; - } - - // Check if dir already exists - if (JFolder::exists($path)) { - return true; - } - - // Check for safe mode - if ($ftpOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = &JFTP::getInstance( - $ftpOptions['host'], $ftpOptions['port'], null, - $ftpOptions['user'], $ftpOptions['pass'] - ); - - // Translate path to FTP path - $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); - $ret = $ftp->mkdir($path); - $ftp->chmod($path, $mode); - } else { - // We need to get and explode the open_basedir paths - $obd = ini_get('open_basedir'); - - // If open_basedir is set we need to get the open_basedir that the path is in - if ($obd != null) - { - if (JPATH_ISWIN) { - $obdSeparator = ";"; - } else { - $obdSeparator = ":"; - } - // Create the array of open_basedir paths - $obdArray = explode($obdSeparator, $obd); - $inBaseDir = false; - // Iterate through open_basedir paths looking for a match - foreach ($obdArray as $test) { - $test = JPath::clean($test); - if (strpos($path, $test) === 0) { - $obdpath = $test; - $inBaseDir = true; - break; - } - } - if ($inBaseDir == false) { - // Return false for JFolder::create because the path to be created is not in open_basedir - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::create: ' . JText::_('Path not in open_basedir paths') - ); - return false; - } - } - - // First set umask - $origmask = @umask(0); - - // Create the path - if (!$ret = @mkdir($path, $mode)) { - @umask($origmask); - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::create: ' . JText::_('Could not create directory'), - 'Path: ' . $path - ); - return false; - } - - // Reset umask - @umask($origmask); - } - return $ret; - } - - /** - * Delete a folder. - * - * @param string The path to the folder to delete. - * @return boolean True on success. - * @since 1.5 - */ - function delete($path) - { - // Sanity check - if (!$path) { - // Bad programmer! Bad Bad programmer! - JError::raiseWarning(500, 'JFolder::delete: ' . JText::_('Attempt to delete base directory') ); - return false; - } - - // Initialize variables - jimport('joomla.client.helper'); - $ftpOptions = JClientHelper::getCredentials('ftp'); - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Is this really a folder? - if (!is_dir($path)) { - JError::raiseWarning(21, 'JFolder::delete: ' . JText::_('Path is not a folder'), 'Path: ' . $path); - return false; - } - - // Remove all the files in folder if they exist - $files = JFolder::files($path, '.', false, true, array()); - if (!empty($files)) { - jimport('joomla.filesystem.file'); - if (JFile::delete($files) !== true) { - // JFile::delete throws an error - return false; - } - } - - // Remove sub-folders of folder - $folders = JFolder::folders($path, '.', false, true, array()); - foreach ($folders as $folder) { - if (is_link($folder)) { - // Don't descend into linked directories, just delete the link. - jimport('joomla.filesystem.file'); - if (JFile::delete($folder) !== true) { - // JFile::delete throws an error - return false; - } - } elseif (JFolder::delete($folder) !== true) { - // JFolder::delete throws an error - return false; - } - } - - if ($ftpOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = &JFTP::getInstance( - $ftpOptions['host'], $ftpOptions['port'], null, - $ftpOptions['user'], $ftpOptions['pass'] - ); - } - - // In case of restricted permissions we zap it one way or the other - // as long as the owner is either the webserver or the ftp - if (@rmdir($path)) { - $ret = true; - } elseif ($ftpOptions['enabled'] == 1) { - // Translate path and delete - $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); - // FTP connector throws an error - $ret = $ftp->delete($path); - } else { - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::delete: ' . JText::_('Could not delete folder'), - 'Path: ' . $path - ); - $ret = false; - } - return $ret; - } - - /** - * Moves a folder. - * - * @param string The path to the source folder. - * @param string The path to the destination folder. - * @param string An optional base path to prefix to the file names. - * @return mixed Error message on false or boolean true on success. - * @since 1.5 - */ - function move($src, $dest, $path = '') - { - // Initialize variables - jimport('joomla.client.helper'); - $ftpOptions = JClientHelper::getCredentials('ftp'); - - if ($path) { - $src = JPath::clean($path . DS . $src); - $dest = JPath::clean($path . DS . $dest); - } - - if (!JFolder::exists($src) && !is_writable($src)) { - return JText::_('Cannot find source folder'); - } - if (JFolder::exists($dest)) { - return JText::_('Folder already exists'); - } - - if ($ftpOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = &JFTP::getInstance( - $ftpOptions['host'], $ftpOptions['port'], null, - $ftpOptions['user'], $ftpOptions['pass'] - ); - - //Translate path for the FTP account - $src = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $src), '/'); - $dest = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dest), '/'); - - // Use FTP rename to simulate move - if (!$ftp->rename($src, $dest)) { - return JText::_('Rename failed'); - } - $ret = true; - } else { - if (!@rename($src, $dest)) { - return JText::_('Rename failed'); - } - $ret = true; - } - return $ret; - } - - /** - * Wrapper for the standard file_exists function - * - * @param string Folder name relative to installation dir - * @return boolean True if path is a folder - * @since 1.5 - */ - function exists($path) - { - return is_dir(JPath::clean($path)); - } - - /** - * Utility function to read the files in a folder. - * - * @param string The path of the folder to read. - * @param string A filter for file names. - * @param mixed True to recursively search into sub-folders, or an - * integer to specify the maximum depth. - * @param boolean True to return the full path to the file. - * @param array Array with names of files which should not be shown in - * the result. - * @return array Files in the given folder. - * @since 1.5 - */ - function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) - { - // Initialize variables - $arr = array(); - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Is the path a folder? - if (!is_dir($path)) { - JError::raiseWarning(21, 'JFolder::files: ' . JText::_('Path is not a folder'), 'Path: ' . $path); - return false; - } - - // read the source directory - $handle = opendir($path); - while (($file = readdir($handle)) !== false) - { - if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) { - $dir = $path . DS . $file; - $isDir = is_dir($dir); - if ($isDir) { - if ($recurse) { - if (is_integer($recurse)) { - $arr2 = JFolder::files($dir, $filter, $recurse - 1, $fullpath); - } else { - $arr2 = JFolder::files($dir, $filter, $recurse, $fullpath); - } - - $arr = array_merge($arr, $arr2); - } - } else { - if (preg_match("/$filter/", $file)) { - if ($fullpath) { - $arr[] = $path . DS . $file; - } else { - $arr[] = $file; - } - } - } - } - } - closedir($handle); - - asort($arr); - return $arr; - } - - /** - * Utility function to read the folders in a folder. - * - * @param string The path of the folder to read. - * @param string A filter for folder names. - * @param mixed True to recursively search into sub-folders, or an - * integer to specify the maximum depth. - * @param boolean True to return the full path to the folders. - * @param array Array with names of folders which should not be shown in - * the result. - * @return array Folders in the given folder. - * @since 1.5 - */ - function folders($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) - { - // Initialize variables - $arr = array(); - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Is the path a folder? - if (!is_dir($path)) { - JError::raiseWarning(21, 'JFolder::folder: ' . JText::_('Path is not a folder'), 'Path: ' . $path); - return false; - } - - // read the source directory - $handle = opendir($path); - while (($file = readdir($handle)) !== false) - { - if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) { - $dir = $path . DS . $file; - $isDir = is_dir($dir); - if ($isDir) { - // Removes filtered directories - if (preg_match("/$filter/", $file)) { - if ($fullpath) { - $arr[] = $dir; - } else { - $arr[] = $file; - } - } - if ($recurse) { - if (is_integer($recurse)) { - $arr2 = JFolder::folders($dir, $filter, $recurse - 1, $fullpath); - } else { - $arr2 = JFolder::folders($dir, $filter, $recurse, $fullpath); - } - - $arr = array_merge($arr, $arr2); - } - } - } - } - closedir($handle); - - asort($arr); - return $arr; - } - - /** - * Lists folder in format suitable for tree display. - * - * @access public - * @param string The path of the folder to read. - * @param string A filter for folder names. - * @param integer The maximum number of levels to recursively read, - * defaults to three. - * @param integer The current level, optional. - * @param integer Unique identifier of the parent folder, if any. - * @return array Folders in the given folder. - * @since 1.5 - */ - function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0) - { - $dirs = array (); - if ($level == 0) { - $GLOBALS['_JFolder_folder_tree_index'] = 0; - } - if ($level < $maxLevel) { - $folders = JFolder::folders($path, $filter); - // first path, index foldernames - foreach ($folders as $name) { - $id = ++$GLOBALS['_JFolder_folder_tree_index']; - $fullName = JPath::clean($path . DS . $name); - $dirs[] = array( - 'id' => $id, - 'parent' => $parent, - 'name' => $name, - 'fullname' => $fullName, - 'relname' => str_replace(JPATH_ROOT, '', $fullName) - ); - $dirs2 = JFolder::listFolderTree($fullName, $filter, $maxLevel, $level + 1, $id); - $dirs = array_merge($dirs, $dirs2); - } - } - return $dirs; - } - - /** - * Makes path name safe to use. - * - * @access public - * @param string The full path to sanitise. - * @return string The sanitised string. - * @since 1.5 - */ - function makeSafe($path) - { - $ds = (DS == '\\') ? '\\' . DS : DS; - $regex = array('#[^A-Za-z0-9:\_\-' . $ds . ' ]#'); - return preg_replace($regex, '', $path); - } - -} \ No newline at end of file + /** + * Copy a folder. + * + * @param string The path to the source folder. + * @param string The path to the destination folder. + * @param string An optional base path to prefix to the file names. + * @param boolean Optionally force folder/file overwrites. + * @return mixed JError object on failure or boolean True on success. + * @since 1.5 + */ + public static function copy($src, $dest, $path = '', $force = false) + { + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + + if ($path) { + $src = JPath::clean($path.DS.$src); + $dest = JPath::clean($path.DS.$dest); + } + + // Eliminate trailing directory separators, if any + $src = rtrim($src, DS); + $dest = rtrim($dest, DS); + + if ( ! JFolder::exists($src)) { + return JError::raiseError(-1, JText::_('Cannot find source folder')); + } + if (JFolder::exists($dest) && !$force) { + return JError::raiseError(-1, JText::_('Folder already exists')); + } + + // Make sure the destination exists + if ( ! JFolder::create($dest)) { + return JError::raiseError(-1, JText::_('Unable to create target folder')); + } + + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + + if ( ! ($dh = @opendir($src))) { + return JError::raiseError(-1, JText::_('Unable to open source folder')); + } + // Walk through the directory copying files and recursing into folders. + while (($file = readdir($dh)) !== false) { + $sfid = $src.DS.$file; + $dfid = $dest.DS.$file; + switch (filetype($sfid)) { + case 'dir': + if ($file != '.' && $file != '..') { + $ret = JFolder::copy($sfid, $dfid, null, $force); + if ($ret !== true) { + return $ret; + } + } + break; + case 'file': + // Translate path for the FTP account + $dfid = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dfid), '/'); + if (! $ftp->store($sfid, $dfid)) { + return JError::raiseError(-1, JText::_('Copy failed')); + } + break; + } + } + } else { + if ( ! ($dh = @opendir($src))) { + return JError::raiseError(-1, JText::_('Unable to open source folder')); + } + // Walk through the directory copying files and recursing into folders. + while (($file = readdir($dh)) !== false) { + $sfid = $src.DS.$file; + $dfid = $dest.DS.$file; + switch (filetype($sfid)) { + case 'dir': + if ($file != '.' && $file != '..') { + $ret = JFolder::copy($sfid, $dfid, null, $force); + if ($ret !== true) { + return $ret; + } + } + break; + case 'file': + if (!@copy($sfid, $dfid)) { + return JError::raiseError(-1, JText::_('Copy failed')); + } + break; + } + } + } + return true; + } + + /** + * Create a folder -- and all necessary parent folders. + * + * @param string A path to create from the base path. + * @param int Directory permissions to set for folders created. + * @return boolean True if successful. + * @since 1.5 + */ + public static function create($path = '', $mode = 0755) + { + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + static $nested = 0; + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Check if parent dir exists + $parent = dirname($path); + if ( ! JFolder::exists($parent)) { + // Prevent infinite loops! + $nested++; + if ($nested > 20 || $parent == $path) { + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::create: ' . JText::_('Infinite loop detected') + ); + $nested--; + return false; + } + + // Create the parent directory + if (JFolder::create($parent, $mode) !== true) { + // JFolder::create throws an error + $nested--; + return false; + } + + // OK, parent directory has been created + $nested--; + } + + // Check if dir already exists + if (JFolder::exists($path)) { + return true; + } + + // Check for safe mode + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + + // Translate path to FTP path + $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); + $ret = $ftp->mkdir($path); + $ftp->chmod($path, $mode); + } else { + // We need to get and explode the open_basedir paths + $obd = ini_get('open_basedir'); + + // If open_basedir is set we need to get the open_basedir that the path is in + if ($obd != null) { + if (JPATH_ISWIN) { + $obdSeparator = ";"; + } else { + $obdSeparator = ":"; + } + // Create the array of open_basedir paths + $obdArray = explode($obdSeparator, $obd); + $inBaseDir = false; + // Iterate through open_basedir paths looking for a match + foreach ($obdArray as $test) { + $test = JPath::clean($test); + if (strpos($path, $test) === 0) { + $obdpath = $test; + $inBaseDir = true; + break; + } + } + if ($inBaseDir == false) { + // Return false for JFolder::create because the path to be created is not in open_basedir + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::create: ' . JText::_('Path not in open_basedir paths') + ); + return false; + } + } + + // First set umask + $origmask = @umask(0); + + // Create the path + if ( ! ($ret = @mkdir($path, $mode))) { + @umask($origmask); + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::create: ' . JText::_('Could not create directory'), + 'Path: ' . $path + ); + return false; + } + + // Reset umask + @umask($origmask); + } + return $ret; + } + + /** + * Delete a folder. + * + * @param string The path to the folder to delete. + * @return boolean True on success. + * @since 1.5 + */ + public static function delete($path) + { + // Sanity check + if ( ! $path) { + // Bad programmer! Bad Bad programmer! + JError::raiseWarning(500, 'JFolder::delete: ' . JText::_('Attempt to delete base directory') ); + return false; + } + + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Is this really a folder? + if ( ! is_dir($path)) { + JError::raiseWarning(21, 'JFolder::delete: '.JText::_('Path is not a folder'), 'Path: '.$path); + return false; + } + + // Remove all the files in folder if they exist + $files = JFolder::files($path, '.', false, true, array()); + if ( ! empty($files)) { + jimport('joomla.filesystem.file'); + if (JFile::delete($files) !== true) { + // JFile::delete throws an error + return false; + } + } + + // Remove sub-folders of folder + $folders = JFolder::folders($path, '.', false, true, array()); + foreach ($folders as $folder) { + if (is_link($folder)) { + // Don't descend into linked directories, just delete the link. + jimport('joomla.filesystem.file'); + if (JFile::delete($folder) !== true) { + // JFile::delete throws an error + return false; + } + } elseif (JFolder::delete($folder) !== true) { + // JFolder::delete throws an error + return false; + } + } + + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + } + + // In case of restricted permissions we zap it one way or the other + // as long as the owner is either the webserver or the ftp + if (@rmdir($path)) { + $ret = true; + } elseif ($ftpOptions['enabled'] == 1) { + // Translate path and delete + $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); + // FTP connector throws an error + $ret = $ftp->delete($path); + } else { + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::delete: ' . JText::_('Could not delete folder'), + 'Path: ' . $path + ); + $ret = false; + } + return $ret; + } + + /** + * Moves a folder. + * + * @param string The path to the source folder. + * @param string The path to the destination folder. + * @param string An optional base path to prefix to the file names. + * @return mixed Error message on false or boolean true on success. + * @since 1.5 + */ + public static function move($src, $dest, $path = '') + { + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + + if ($path) { + $src = JPath::clean($path . DS . $src); + $dest = JPath::clean($path . DS . $dest); + } + + if (!JFolder::exists($src) && !is_writable($src)) { + return JText::_('Cannot find source folder'); + } + if (JFolder::exists($dest)) { + return JText::_('Folder already exists'); + } + + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + + //Translate path for the FTP account + $src = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $src), '/'); + $dest = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dest), '/'); + + // Use FTP rename to simulate move + if (!$ftp->rename($src, $dest)) { + return JText::_('Rename failed'); + } + $ret = true; + } else { + if ( ! @rename($src, $dest)) { + return JText::_('Rename failed'); + } + $ret = true; + } + return $ret; + } + + /** + * Wrapper for the standard file_exists function + * + * @param string Folder name relative to installation dir + * @return boolean True if path is a folder + * @since 1.5 + */ + public static function exists($path) + { + return is_dir(JPath::clean($path)); + } + + /** + * Utility function to read the files in a folder. + * + * @param string The path of the folder to read. + * @param string A filter for file names. + * @param mixed True to recursively search into sub-folders, or an + * integer to specify the maximum depth. + * @param boolean True to return the full path to the file. + * @param array Array with names of files which should not be shown in + * the result. + * @return array Files in the given folder. + * @since 1.5 + */ + public static function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) + { + // Initialize variables + $arr = array(); + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Is the path a folder? + if ( ! is_dir($path)) { + JError::raiseWarning(21, 'JFolder::files: ' . JText::_('Path is not a folder'), 'Path: ' . $path); + return false; + } + + // read the source directory + $handle = opendir($path); + while (($file = readdir($handle)) !== false) { + if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) { + $dir = $path . DS . $file; + $isDir = is_dir($dir); + if ($isDir) { + if ($recurse) { + if (is_integer($recurse)) { + $arr2 = JFolder::files($dir, $filter, $recurse - 1, $fullpath); + } else { + $arr2 = JFolder::files($dir, $filter, $recurse, $fullpath); + } + + $arr = array_merge($arr, $arr2); + } + } else { + if (preg_match("/$filter/", $file)) { + if ($fullpath) { + $arr[] = $path . DS . $file; + } else { + $arr[] = $file; + } + } + } + } + } + closedir($handle); + + asort($arr); + return $arr; + } + + /** + * Utility function to read the folders in a folder. + * + * @param string The path of the folder to read. + * @param string A filter for folder names. + * @param mixed True to recursively search into sub-folders, or an + * integer to specify the maximum depth. + * @param boolean True to return the full path to the folders. + * @param array Array with names of folders which should not be shown in + * the result. + * @return array Folders in the given folder. + * @since 1.5 + */ + public static function folders($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) + { + // Initialize variables + $arr = array(); + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Is the path a folder? + if (!is_dir($path)) { + JError::raiseWarning(21, 'JFolder::folder: '.JText::_('Path is not a folder'), 'Path: '.$path); + return false; + } + + // read the source directory + $handle = opendir($path); + while (($file = readdir($handle)) !== false) { + if ($file != '.' && $file != '..' && ! in_array($file, $exclude)) { + $dir = $path.DS.$file; + $isDir = is_dir($dir); + if ($isDir) { + // Removes filtered directories + if (preg_match("/$filter/", $file)) { + if ($fullpath) { + $arr[] = $dir; + } else { + $arr[] = $file; + } + } + if ($recurse) { + if (is_integer($recurse)) { + $arr2 = JFolder::folders($dir, $filter, $recurse - 1, $fullpath); + } else { + $arr2 = JFolder::folders($dir, $filter, $recurse, $fullpath); + } + + $arr = array_merge($arr, $arr2); + } + } + } + } + closedir($handle); + + asort($arr); + return $arr; + } + + /** + * Lists folder in format suitable for tree display. + * + * @param string The path of the folder to read. + * @param string A filter for folder names. + * @param integer The maximum number of levels to recursively read, + * defaults to three. + * @param integer The current level, optional. + * @param integer Unique identifier of the parent folder, if any. + * @return array Folders in the given folder. + * @since 1.5 + */ + public static function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0) + { + $dirs = array (); + if ($level == 0) { + $GLOBALS['_JFolder_folder_tree_index'] = 0; + } + if ($level < $maxLevel) { + $folders = JFolder::folders($path, $filter); + // first path, index foldernames + foreach ($folders as $name) { + $id = ++$GLOBALS['_JFolder_folder_tree_index']; + $fullName = JPath::clean($path . DS . $name); + $dirs[] = array( + 'id' => $id, + 'parent' => $parent, + 'name' => $name, + 'fullname' => $fullName, + 'relname' => str_replace(JPATH_ROOT, '', $fullName) + ); + $dirs2 = JFolder::listFolderTree($fullName, $filter, $maxLevel, $level + 1, $id); + $dirs = array_merge($dirs, $dirs2); + } + } + return $dirs; + } + + /** + * Makes path name safe to use. + * + * @param string The full path to sanitise. + * @return string The sanitised string. + * @since 1.5 + */ + public static function makeSafe($path) + { + $ds = (DS == '\\') ? '\\' . DS : DS; + $regex = array('#[^A-Za-z0-9:\_\-'.$ds.' ]#'); + return preg_replace($regex, '', $path); + } +} diff --git a/vendor/joomla/libraries/joomla/filesystem/path.php b/vendor/joomla/libraries/joomla/filesystem/path.php index 9dd70d168..839f243ff 100644 --- a/vendor/joomla/libraries/joomla/filesystem/path.php +++ b/vendor/joomla/libraries/joomla/filesystem/path.php @@ -1,16 +1,4 @@ * Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie. - * - * @package Joomla.Framework - * @subpackage Filter - * @since 1.5 + * + * @package Joomla.Framework + * @subpackage Filter + * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * @since 1.5 */ class JFilterInput extends JObject { - var $tagsArray; // default = empty array - var $attrArray; // default = empty array - - var $tagsMethod; // default = 0 - var $attrMethod; // default = 0 - - var $xssAuto; // default = 1 - var $tagBlacklist = array ('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml'); - var $attrBlacklist = array ('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers - - /** - * Constructor for inputFilter class. Only first parameter is required. - * - * @access protected - * @param array $tagsArray list of user-defined tags - * @param array $attrArray list of user-defined attributes - * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 - * @param int $attrMethod WhiteList method = 0, BlackList method = 1 - * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 - * @since 1.5 - */ - function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) - { - // Make sure user defined arrays are in lowercase - $tagsArray = array_map('strtolower', (array) $tagsArray); - $attrArray = array_map('strtolower', (array) $attrArray); - - // Assign member variables - $this->tagsArray = $tagsArray; - $this->attrArray = $attrArray; - $this->tagsMethod = $tagsMethod; - $this->attrMethod = $attrMethod; - $this->xssAuto = $xssAuto; - } - - /** - * Returns a reference to an input filter object, only creating it if it doesn't already exist. - * - * This method must be invoked as: - *
$filter = & JFilterInput::getInstance();- * - * @static - * @param array $tagsArray list of user-defined tags - * @param array $attrArray list of user-defined attributes - * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 - * @param int $attrMethod WhiteList method = 0, BlackList method = 1 - * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 - * @return object The JFilterInput object. - * @since 1.5 - */ - static public function & getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) - { - static $instances; - - $sig = md5(serialize(array($tagsArray,$attrArray,$tagsMethod,$attrMethod,$xssAuto))); - - if (!isset ($instances)) { - $instances = array(); - } - - if (empty ($instances[$sig])) { - $instances[$sig] = new JFilterInput($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto); - } - - return $instances[$sig]; - } - - /** - * Method to be called by another php script. Processes for XSS and - * specified bad code. - * - * @access public - * @param mixed $source Input string/array-of-string to be 'cleaned' - * @param string $type Return type for the variable (INT, FLOAT, BOOLEAN, WORD, ALNUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) - * @return mixed 'Cleaned' version of input parameter - * @since 1.5 - * @static - */ - public function clean($source, $type='string') - { - // Handle the type constraint - switch (strtoupper($type)) - { - case 'INT' : - case 'INTEGER' : - // Only use the first integer value - preg_match('/-?[0-9]+/', (string) $source, $matches); - $result = @ (int) $matches[0]; - break; - - case 'FLOAT' : - case 'DOUBLE' : - // Only use the first floating point value - preg_match('/-?[0-9]+(\.[0-9]+)?/', (string) $source, $matches); - $result = @ (float) $matches[0]; - break; - - case 'BOOL' : - case 'BOOLEAN' : - $result = (bool) $source; - break; - - case 'WORD' : - $result = (string) preg_replace( '/[^A-Z_]/i', '', $source ); - break; - - case 'ALNUM' : - $result = (string) preg_replace( '/[^A-Z0-9]/i', '', $source ); - break; - - case 'CMD' : - $result = (string) preg_replace( '/[^A-Z0-9_\.-]/i', '', $source ); - $result = ltrim($result, '.'); - break; - - case 'BASE64' : - $result = (string) preg_replace( '/[^A-Z0-9\/+=]/i', '', $source ); - break; - - case 'STRING' : - // Check for static usage and assign $filter the proper variable - if(isset($this) && is_a( $this, 'JFilterInput' )) { - $filter =& $this; - } else { - $filter =& JFilterInput::getInstance(); - } - $result = (string) $filter->_remove($filter->_decode((string) $source)); - break; - - case 'ARRAY' : - $result = (array) $source; - break; - - case 'PATH' : - $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/'; - preg_match($pattern, (string) $source, $matches); - $result = @ (string) $matches[0]; - break; - - case 'USERNAME' : - $result = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $source ); - break; - - case 'MENUTYPE': - $result = str_replace('-', ' ', $source); - $lang = &JFactory::getLanguage(); - $result = $lang->transliterate($result); - $result = (string) preg_replace( - array('/\s+/','/[^A-Za-z0-9\-\_ ]/'), array('-',''), $result - ); - $result = trim($result); - break; - - - default : - // Check for static usage and assign $filter the proper variable - if(is_object($this) && get_class($this) == 'JFilterInput') { - $filter =& $this; - } else { - $filter =& JFilterInput::getInstance(); - } - // Are we dealing with an array? - if (is_array($source)) { - foreach ($source as $key => $value) - { - // filter element for XSS and other 'bad' code etc. - if (is_string($value)) { - $source[$key] = $filter->_remove($filter->_decode($value)); - } - } - $result = $source; - } else { - // Or a string? - if (is_string($source) && !empty ($source)) { - // filter source for XSS and other 'bad' code etc. - $result = $filter->_remove($filter->_decode($source)); - } else { - // Not an array or string.. return the passed parameter - $result = $source; - } - } - break; - } - return $result; - } - - /** - * Function to determine if contents of an attribute is safe - * - * @static - * @param array $attrSubSet A 2 element array for attributes name,value - * @return boolean True if bad code is detected - * @since 1.5 - */ - function checkAttribute($attrSubSet) - { - $attrSubSet[0] = strtolower($attrSubSet[0]); - $attrSubSet[1] = strtolower($attrSubSet[1]); - return (((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style') || (strpos($attrSubSet[1], 'javascript:') !== false) || (strpos($attrSubSet[1], 'behaviour:') !== false) || (strpos($attrSubSet[1], 'vbscript:') !== false) || (strpos($attrSubSet[1], 'mocha:') !== false) || (strpos($attrSubSet[1], 'livescript:') !== false)); - } - - /** - * Internal method to iteratively remove all unwanted tags and attributes - * - * @access protected - * @param string $source Input string to be 'cleaned' - * @return string 'Cleaned' version of input parameter - * @since 1.5 - */ - function _remove($source) - { - $loopCounter = 0; - - // Iteration provides nested tag protection - while ($source != $this->_cleanTags($source)) - { - $source = $this->_cleanTags($source); - $loopCounter ++; - } - return $source; - } - - /** - * Internal method to strip a string of certain tags - * - * @access protected - * @param string $source Input string to be 'cleaned' - * @return string 'Cleaned' version of input parameter - * @since 1.5 - */ - function _cleanTags($source) - { - /* - * In the beginning we don't really have a tag, so everything is - * postTag - */ - $preTag = null; - $postTag = $source; - $currentSpace = false; - $attr = ''; // moffats: setting to null due to issues in migration system - undefined variable errors - - // Is there a tag? If so it will certainly start with a '<' - $tagOpen_start = strpos($source, '<'); - - while ($tagOpen_start !== false) - { - // Get some information about the tag we are processing - $preTag .= substr($postTag, 0, $tagOpen_start); - $postTag = substr($postTag, $tagOpen_start); - $fromTagOpen = substr($postTag, 1); - $tagOpen_end = strpos($fromTagOpen, '>'); - - // Let's catch any non-terminated tags and skip over them - if ($tagOpen_end === false) { - $postTag = substr($postTag, $tagOpen_start +1); - $tagOpen_start = strpos($postTag, '<'); - continue; - } - - // Do we have a nested tag? - $tagOpen_nested = strpos($fromTagOpen, '<'); - $tagOpen_nested_end = strpos(substr($postTag, $tagOpen_end), '>'); - if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) { - $preTag .= substr($postTag, 0, ($tagOpen_nested +1)); - $postTag = substr($postTag, ($tagOpen_nested +1)); - $tagOpen_start = strpos($postTag, '<'); - continue; - } - - // Lets get some information about our tag and setup attribute pairs - $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start +1); - $currentTag = substr($fromTagOpen, 0, $tagOpen_end); - $tagLength = strlen($currentTag); - $tagLeft = $currentTag; - $attrSet = array (); - $currentSpace = strpos($tagLeft, ' '); - - // Are we an open tag or a close tag? - if (substr($currentTag, 0, 1) == '/') { - // Close Tag - $isCloseTag = true; - list ($tagName) = explode(' ', $currentTag); - $tagName = substr($tagName, 1); - } else { - // Open Tag - $isCloseTag = false; - list ($tagName) = explode(' ', $currentTag); - } - - /* - * Exclude all "non-regular" tagnames - * OR no tagname - * OR remove if xssauto is on and tag is blacklisted - */ - if ((!preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) { - $postTag = substr($postTag, ($tagLength +2)); - $tagOpen_start = strpos($postTag, '<'); - // Strip tag - continue; - } - - /* - * Time to grab any attributes from the tag... need this section in - * case attributes have spaces in the values. - */ - while ($currentSpace !== false) - { - $attr = ''; - $fromSpace = substr($tagLeft, ($currentSpace +1)); - $nextSpace = strpos($fromSpace, ' '); - $openQuotes = strpos($fromSpace, '"'); - $closeQuotes = strpos(substr($fromSpace, ($openQuotes +1)), '"') + $openQuotes +1; - - // Do we have an attribute to process? [check for equal sign] - if (strpos($fromSpace, '=') !== false) { - /* - * If the attribute value is wrapped in quotes we need to - * grab the substring from the closing quote, otherwise grab - * till the next space - */ - if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes +1)), '"') !== false)) { - $attr = substr($fromSpace, 0, ($closeQuotes +1)); - } else { - $attr = substr($fromSpace, 0, $nextSpace); - } - } else { - /* - * No more equal signs so add any extra text in the tag into - * the attribute array [eg. checked] - */ - if ($fromSpace != '/') { - $attr = substr($fromSpace, 0, $nextSpace); - } - } - - // Last Attribute Pair - if (!$attr && $fromSpace != '/') { - $attr = $fromSpace; - } - - // Add attribute pair to the attribute array - $attrSet[] = $attr; - - // Move search point and continue iteration - $tagLeft = substr($fromSpace, strlen($attr)); - $currentSpace = strpos($tagLeft, ' '); - } - - // Is our tag in the user input array? - $tagFound = in_array(strtolower($tagName), $this->tagsArray); - - // If the tag is allowed lets append it to the output string - if ((!$tagFound && $this->tagsMethod) || ($tagFound && !$this->tagsMethod)) { - - // Reconstruct tag with allowed attributes - if (!$isCloseTag) { - // Open or Single tag - $attrSet = $this->_cleanAttributes($attrSet); - $preTag .= '<'.$tagName; - for ($i = 0; $i < count($attrSet); $i ++) - { - $preTag .= ' '.$attrSet[$i]; - } - - // Reformat single tags to XHTML - if (strpos($fromTagOpen, ''.$tagName)) { - $preTag .= '>'; - } else { - $preTag .= ' />'; - } - } else { - // Closing Tag - $preTag .= ''.$tagName.'>'; - } - } - - // Find next tag's start and continue iteration - $postTag = substr($postTag, ($tagLength +2)); - $tagOpen_start = strpos($postTag, '<'); - } - - // Append any code after the end of tags and return - if ($postTag != '<') { - $preTag .= $postTag; - } - return $preTag; - } - - /** - * Internal method to strip a tag of certain attributes - * - * @access protected - * @param array $attrSet Array of attribute pairs to filter - * @return array Filtered array of attribute pairs - * @since 1.5 - */ - function _cleanAttributes($attrSet) - { - // Initialize variables - $newSet = array(); - - // Iterate through attribute pairs - for ($i = 0; $i < count($attrSet); $i ++) - { - // Skip blank spaces - if (!$attrSet[$i]) { - continue; - } - - // Split into name/value pairs - $attrSubSet = explode('=', trim($attrSet[$i]), 2); - list ($attrSubSet[0]) = explode(' ', $attrSubSet[0]); - - /* - * Remove all "non-regular" attribute names - * AND blacklisted attributes - */ - if ((!preg_match('/[a-z]*$/i', $attrSubSet[0])) || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on')))) { - continue; - } - - // XSS attribute value filtering - if ($attrSubSet[1]) { - // strips unicode, hex, etc - $attrSubSet[1] = str_replace('', '', $attrSubSet[1]); - // strip normal newline within attr value - $attrSubSet[1] = preg_replace('/[\n\r]/', '', $attrSubSet[1]); - // strip double quotes - $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); - // convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value) - if ((substr($attrSubSet[1], 0, 1) == "'") && (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'")) { - $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2)); - } - // strip slashes - $attrSubSet[1] = stripslashes($attrSubSet[1]); - } - - // Autostrip script tags - if (JFilterInput::checkAttribute($attrSubSet)) { - continue; - } - - // Is our attribute in the user input array? - $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray); - - // If the tag is allowed lets keep it - if ((!$attrFound && $this->attrMethod) || ($attrFound && !$this->attrMethod)) { - - // Does the attribute have a value? - if ($attrSubSet[1]) { - $newSet[] = $attrSubSet[0].'="'.$attrSubSet[1].'"'; - } elseif ($attrSubSet[1] == "0") { - /* - * Special Case - * Is the value 0? - */ - $newSet[] = $attrSubSet[0].'="0"'; - } else { - $newSet[] = $attrSubSet[0].'="'.$attrSubSet[0].'"'; - } - } - } - return $newSet; - } - - /** - * Try to convert to plaintext - * - * @access protected - * @param string $source - * @return string Plaintext string - * @since 1.5 - */ - function _decode($source) - { - // entity decode - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - foreach($trans_tbl as $k => $v) { - $ttr[$v] = utf8_encode($k); - } - $source = strtr($source, $ttr); - - // convert decimal - $source = preg_replace_callback('/(\d+);/m', function($m){return utf8_encode(chr($m[1]));}, $source); - - // convert hex - $source = preg_replace_callback('/([a-f0-9]+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source); - - return $source; - } + var $tagsArray; // default = empty array + var $attrArray; // default = empty array + + var $tagsMethod; // default = 0 + var $attrMethod; // default = 0 + + var $xssAuto; // default = 1 + var $tagBlacklist = array ('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml'); + var $attrBlacklist = array ('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers + + /** + * Constructor for inputFilter class. Only first parameter is required. + * + * @access protected + * @param array $tagsArray list of user-defined tags + * @param array $attrArray list of user-defined attributes + * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 + * @param int $attrMethod WhiteList method = 0, BlackList method = 1 + * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 + * @since 1.5 + */ + function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) + { + // Make sure user defined arrays are in lowercase + $tagsArray = array_map('strtolower', (array) $tagsArray); + $attrArray = array_map('strtolower', (array) $attrArray); + + // Assign member variables + $this->tagsArray = $tagsArray; + $this->attrArray = $attrArray; + $this->tagsMethod = $tagsMethod; + $this->attrMethod = $attrMethod; + $this->xssAuto = $xssAuto; + } + + /** + * Returns a reference to an input filter object, only creating it if it doesn't already exist. + * + * This method must be invoked as: + *
$filter = & JFilterInput::getInstance();+ * + * @static + * @param array $tagsArray list of user-defined tags + * @param array $attrArray list of user-defined attributes + * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 + * @param int $attrMethod WhiteList method = 0, BlackList method = 1 + * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 + * @return object The JFilterInput object. + * @since 1.5 + */ + public static function &getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) + { + static $instances; + + $sig = md5(serialize(array($tagsArray,$attrArray,$tagsMethod,$attrMethod,$xssAuto))); + + if ( ! isset($instances)) { + $instances = array(); + } + + if (empty($instances[$sig])) { + $instances[$sig] = new JFilterInput($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto); + } + + return $instances[$sig]; + } + + /** + * Method to be called by another php script. Processes for XSS and + * specified bad code. + * + * @access public + * @param mixed $source Input string/array-of-string to be 'cleaned' + * @param string $type Return type for the variable (INT, FLOAT, BOOLEAN, WORD, ALNUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) + * @return mixed 'Cleaned' version of input parameter + * @since 1.5 + * @static + */ + public function clean($source, $type = 'string') + { + // Handle the type constraint + switch (strtoupper($type)) + { + case 'INT': + case 'INTEGER': + // Only use the first integer value + preg_match('/-?[0-9]+/', (string) $source, $matches); + $result = @ (int)$matches[0]; + break; + case 'FLOAT': + case 'DOUBLE': + // Only use the first floating point value + preg_match('/-?[0-9]+(\.[0-9]+)?/', (string) $source, $matches); + $result = @ (float)$matches[0]; + break; + case 'BOOL': + case 'BOOLEAN': + $result = (bool)$source; + break; + case 'WORD': + $result = (string)preg_replace( '/[^A-Z_]/i', '', $source ); + break; + case 'ALNUM': + $result = (string)preg_replace( '/[^A-Z0-9]/i', '', $source ); + break; + case 'CMD' : + $result = (string)preg_replace( '/[^A-Z0-9_\.-]/i', '', $source ); + $result = ltrim($result, '.'); + break; + case 'BASE64': + $result = (string)preg_replace( '/[^A-Z0-9\/+=]/i', '', $source ); + break; + case 'STRING': + // Check for static usage and assign $filter the proper variable + if(isset($this) && is_a( $this, 'JFilterInput' )) { + $filter =& $this; + } else { + $filter =& JFilterInput::getInstance(); + } + $result = (string)$filter->_remove($filter->_decode((string) $source)); + break; + case 'ARRAY': + $result = (array)$source; + break; + case 'PATH': + $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/'; + preg_match($pattern, (string) $source, $matches); + $result = @ (string) $matches[0]; + break; + case 'USERNAME': + $result = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $source ); + break; + case 'MENUTYPE': + $result = str_replace('-', ' ', $source); + $lang = &JFactory::getLanguage(); + $result = $lang->transliterate($result); + $result = (string) preg_replace( + array('/\s+/','/[^A-Za-z0-9\-\_ ]/'), array('-',''), $result + ); + $result = trim($result); + break; + default: + // Check for static usage and assign $filter the proper variable + if(is_object($this) && get_class($this) == 'JFilterInput') { + $filter =& $this; + } else { + $filter =& JFilterInput::getInstance(); + } + // Are we dealing with an array? + if (is_array($source)) { + foreach ($source as $key => $value) + { + // filter element for XSS and other 'bad' code etc. + if (is_string($value)) { + $source[$key] = $filter->_remove($filter->_decode($value)); + } + } + $result = $source; + } else { + // Or a string? + if (is_string($source) && !empty ($source)) { + // filter source for XSS and other 'bad' code etc. + $result = $filter->_remove($filter->_decode($source)); + } else { + // Not an array or string.. return the passed parameter + $result = $source; + } + } + break; + } + return $result; + } + + /** + * Function to determine if contents of an attribute is safe + * + * @param array $attrSubSet A 2 element array for attributes name,value + * @return boolean True if bad code is detected + * @since 1.5 + */ + public static function checkAttribute($attrSubSet) + { + $attrSubSet[0] = strtolower($attrSubSet[0]); + $attrSubSet[1] = strtolower($attrSubSet[1]); + return (((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style') || (strpos($attrSubSet[1], 'javascript:') !== false) || (strpos($attrSubSet[1], 'behaviour:') !== false) || (strpos($attrSubSet[1], 'vbscript:') !== false) || (strpos($attrSubSet[1], 'mocha:') !== false) || (strpos($attrSubSet[1], 'livescript:') !== false)); + } + + /** + * Internal method to iteratively remove all unwanted tags and attributes + * + * @param string $source Input string to be 'cleaned' + * @return string 'Cleaned' version of input parameter + * @since 1.5 + */ + protected function _remove($source) + { + $loopCounter = 0; + + // Iteration provides nested tag protection + while ($source != $this->_cleanTags($source)) + { + $source = $this->_cleanTags($source); + $loopCounter ++; + } + return $source; + } + + /** + * Internal method to strip a string of certain tags + * + * @param string $source Input string to be 'cleaned' + * @return string 'Cleaned' version of input parameter + * @since 1.5 + */ + protected function _cleanTags($source) + { + /* + * In the beginning we don't really have a tag, so everything is + * postTag + */ + $preTag = null; + $postTag = $source; + $currentSpace = false; + $attr = ''; // moffats: setting to null due to issues in migration system - undefined variable errors + + // Is there a tag? If so it will certainly start with a '<' + $tagOpen_start = strpos($source, '<'); + + while ($tagOpen_start !== false) { + // Get some information about the tag we are processing + $preTag .= substr($postTag, 0, $tagOpen_start); + $postTag = substr($postTag, $tagOpen_start); + $fromTagOpen = substr($postTag, 1); + $tagOpen_end = strpos($fromTagOpen, '>'); + + // Let's catch any non-terminated tags and skip over them + if ($tagOpen_end === false) { + $postTag = substr($postTag, $tagOpen_start +1); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Do we have a nested tag? + $tagOpen_nested = strpos($fromTagOpen, '<'); + $tagOpen_nested_end = strpos(substr($postTag, $tagOpen_end), '>'); + if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) { + $preTag .= substr($postTag, 0, ($tagOpen_nested +1)); + $postTag = substr($postTag, ($tagOpen_nested +1)); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Lets get some information about our tag and setup attribute pairs + $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start +1); + $currentTag = substr($fromTagOpen, 0, $tagOpen_end); + $tagLength = strlen($currentTag); + $tagLeft = $currentTag; + $attrSet = array (); + $currentSpace = strpos($tagLeft, ' '); + + // Are we an open tag or a close tag? + if (substr($currentTag, 0, 1) == '/') { + // Close Tag + $isCloseTag = true; + list($tagName) = explode(' ', $currentTag); + $tagName = substr($tagName, 1); + } else { + // Open Tag + $isCloseTag = false; + list($tagName) = explode(' ', $currentTag); + } + + /* + * Exclude all "non-regular" tagnames + * OR no tagname + * OR remove if xssauto is on and tag is blacklisted + */ + if (( ! preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || ! $tagName || (in_array(strtolower($tagName), $this->tagBlacklist) && $this->xssAuto)) { + $postTag = substr($postTag, ($tagLength +2)); + $tagOpen_start = strpos($postTag, '<'); + // Strip tag + continue; + } + + /* + * Time to grab any attributes from the tag... need this section in + * case attributes have spaces in the values. + */ + while ($currentSpace !== false) { + $attr = ''; + $fromSpace = substr($tagLeft, ($currentSpace +1)); + $nextSpace = strpos($fromSpace, ' '); + $openQuotes = strpos($fromSpace, '"'); + $closeQuotes = strpos(substr($fromSpace, ($openQuotes +1)), '"') + $openQuotes +1; + + // Do we have an attribute to process? [check for equal sign] + if (strpos($fromSpace, '=') !== false) { + /* + * If the attribute value is wrapped in quotes we need to + * grab the substring from the closing quote, otherwise grab + * till the next space + */ + if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes +1)), '"') !== false)) { + $attr = substr($fromSpace, 0, ($closeQuotes +1)); + } else { + $attr = substr($fromSpace, 0, $nextSpace); + } + } else { + /* + * No more equal signs so add any extra text in the tag into + * the attribute array [eg. checked] + */ + if ($fromSpace != '/') { + $attr = substr($fromSpace, 0, $nextSpace); + } + } + + // Last Attribute Pair + if ( ! $attr && $fromSpace != '/') { + $attr = $fromSpace; + } + + // Add attribute pair to the attribute array + $attrSet[] = $attr; + + // Move search point and continue iteration + $tagLeft = substr($fromSpace, strlen($attr)); + $currentSpace = strpos($tagLeft, ' '); + } + + // Is our tag in the user input array? + $tagFound = in_array(strtolower($tagName), $this->tagsArray); + + // If the tag is allowed lets append it to the output string + if (( ! $tagFound && $this->tagsMethod) || ($tagFound && ! $this->tagsMethod)) { + + // Reconstruct tag with allowed attributes + if (!$isCloseTag) { + // Open or Single tag + $attrSet = $this->_cleanAttributes($attrSet); + $preTag .= '<'.$tagName; + for ($i = 0; $i < count($attrSet); $i ++) { + $preTag .= ' '.$attrSet[$i]; + } + + // Reformat single tags to XHTML + if (strpos($fromTagOpen, ''.$tagName)) { + $preTag .= '>'; + } else { + $preTag .= ' />'; + } + } else { + // Closing Tag + $preTag .= ''.$tagName.'>'; + } + } + + // Find next tag's start and continue iteration + $postTag = substr($postTag, ($tagLength +2)); + $tagOpen_start = strpos($postTag, '<'); + } + + // Append any code after the end of tags and return + if ($postTag != '<') { + $preTag .= $postTag; + } + return $preTag; + } + + /** + * Internal method to strip a tag of certain attributes + * + * @param array $attrSet Array of attribute pairs to filter + * @return array Filtered array of attribute pairs + * @since 1.5 + */ + protected function _cleanAttributes($attrSet) + { + // Initialize variables + $newSet = array(); + + // Iterate through attribute pairs + for ($i = 0; $i < count($attrSet); $i ++) { + // Skip blank spaces + if (!$attrSet[$i]) { + continue; + } + + // Split into name/value pairs + $attrSubSet = explode('=', trim($attrSet[$i]), 2); + list ($attrSubSet[0]) = explode(' ', $attrSubSet[0]); + + /* + * Remove all "non-regular" attribute names + * AND blacklisted attributes + */ + if ( ! preg_match('/[a-z]*$/i', $attrSubSet[0]) || ($this->xssAuto && (in_array(strtolower($attrSubSet[0]), $this->attrBlacklist) || substr($attrSubSet[0], 0, 2) == 'on'))) { + continue; + } + + // XSS attribute value filtering + if ($attrSubSet[1]) { + // strips unicode, hex, etc + $attrSubSet[1] = str_replace('', '', $attrSubSet[1]); + // strip normal newline within attr value + $attrSubSet[1] = preg_replace('/[\n\r]/', '', $attrSubSet[1]); + // strip double quotes + $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); + // convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value) + if ((substr($attrSubSet[1], 0, 1) == "'") && (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'")) { + $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2)); + } + // strip slashes + $attrSubSet[1] = stripslashes($attrSubSet[1]); + } + + // Autostrip script tags + if (JFilterInput::checkAttribute($attrSubSet)) { + continue; + } + + // Is our attribute in the user input array? + $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray); + + // If the tag is allowed lets keep it + if (( ! $attrFound && $this->attrMethod) || ($attrFound && ! $this->attrMethod)) { + + // Does the attribute have a value? + if ($attrSubSet[1]) { + $newSet[] = $attrSubSet[0].'="'.$attrSubSet[1].'"'; + } elseif ($attrSubSet[1] == "0") { + /* + * Special Case + * Is the value 0? + */ + $newSet[] = $attrSubSet[0].'="0"'; + } else { + $newSet[] = $attrSubSet[0].'="'.$attrSubSet[0].'"'; + } + } + } + return $newSet; + } + + /** + * Try to convert to plaintext + * + * @param string $source + * @return string Plaintext string + * @since 1.5 + */ + protected function _decode($source) + { + // entity decode + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + foreach($trans_tbl as $k => $v) { + $ttr[$v] = utf8_encode($k); + } + $source = strtr($source, $ttr); + + // convert decimal + $source = preg_replace_callback('/(\d+);/m', function($m){return utf8_encode(chr($m[1]));}, $source); + + // convert hex + $source = preg_replace_callback('/([a-f0-9]+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source); + + return $source; + } } - diff --git a/vendor/joomla/libraries/joomla/filter/filteroutput.php b/vendor/joomla/libraries/joomla/filter/filteroutput.php index c43684e68..b6d7fd17f 100644 --- a/vendor/joomla/libraries/joomla/filter/filteroutput.php +++ b/vendor/joomla/libraries/joomla/filter/filteroutput.php @@ -1,148 +1,131 @@ $v) - { - if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) { - continue; - } - - if (is_string( $exclude_keys ) && $k == $exclude_keys) { - continue; - } else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) { - continue; - } - - $mixed->$k = htmlspecialchars( $v, $quote_style, 'UTF-8' ); - } - } - } - - /** - * This method processes a string and replaces all instances of & with & in links only - * - * @static - * @param string $input String to process - * @return string Processed string - * @since 1.5 - */ - function linkXHTMLSafe($input) - { - $regex = 'href="([^"]*(&(amp;){0})[^"]*)*?"'; - return preg_replace_callback( "#$regex#i", array('JFilterOutput', '_ampReplaceCallback'), $input ); - } - - /** - * This method processes a string and replaces all accented UTF-8 characters by unaccented - * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased. - * - * @static - * @param string $input String to process - * @return string Processed string - * @since 1.5 - */ - function stringURLSafe($string) - { - //remove any '-' from the string they will be used as concatonater - $str = str_replace('-', ' ', $string); - - $lang =& JFactory::getLanguage(); - $str = $lang->transliterate($str); - - // remove any duplicate whitespace, and ensure all characters are alphanumeric - $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); - - // lowercase and trim - $str = trim(strtolower($str)); - return $str; - } - - /** - * Replaces & with & for xhtml compliance - * - * @todo There must be a better way??? - * - * @static - * @since 1.5 - */ - function ampReplace( $text ) - { - $text = str_replace( '&&', '*--*', $text ); - $text = str_replace( '', '*-*', $text ); - $text = str_replace( '&', '&', $text ); - $text = preg_replace( '|&(?![\w]+;)|', '&', $text ); - $text = str_replace( '*-*', '', $text ); - $text = str_replace( '*--*', '&&', $text ); - - return $text; - } - - /** - * Callback method for replacing & with & in a string - * - * @static - * @param string $m String to process - * @return string Replaced string - * @since 1.5 - */ - function _ampReplaceCallback( $m ) - { - $rx = '&(?!amp;)'; - return preg_replace( '#'.$rx.'#', '&', $m[0] ); - } - - /** - * Cleans text of all formating and scripting code - */ - function cleanText ( &$text ) - { - $text = preg_replace( "''si", '', $text ); - $text = preg_replace( '/]*>([^<]+)<\/a>/is', '\2 (\1)', $text ); - $text = preg_replace( '//', '', $text ); - $text = preg_replace( '/{.+?}/', '', $text ); - $text = preg_replace( '/ /', ' ', $text ); - $text = preg_replace( '/&/', ' ', $text ); - $text = preg_replace( '/"/', ' ', $text ); - $text = strip_tags( $text ); - $text = htmlspecialchars( $text ); - return $text; - } + /** + * Makes an object safe to display in forms + * + * Object parameters that are non-string, array, object or start with underscore + * will be converted + * + * @param object An object to be parsed + * @param int The optional quote style for the htmlspecialchars function + * @param string|array An optional single field name or array of field names not + * to be parsed (eg, for a textarea) + * @since 1.5 + */ + public static function objectHTMLSafe(&$mixed, $quote_style=ENT_QUOTES, $exclude_keys = '') + { + if (is_object($mixed)) { + foreach (get_object_vars($mixed) as $k => $v) { + if (is_array($v) || is_object($v) || $v == NULL || substr($k, 1, 1) == '_' ) { + continue; + } + + if (is_string($exclude_keys) && $k == $exclude_keys) { + continue; + } else if (is_array($exclude_keys) && in_array($k, $exclude_keys)) { + continue; + } + + $mixed->$k = htmlspecialchars($v, $quote_style, 'UTF-8'); + } + } + } + + /** + * This method processes a string and replaces all instances of & with & in links only + * + * @param string $input String to process + * @return string Processed string + * @since 1.5 + */ + public static function linkXHTMLSafe($input) + { + $regex = 'href="([^"]*(&(amp;){0})[^"]*)*?"'; + return preg_replace_callback( "#$regex#i", array('JFilterOutput', '_ampReplaceCallback'), $input ); + } + + /** + * This method processes a string and replaces all accented UTF-8 characters by unaccented + * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased. + * + * @param string $input String to process + * @return string Processed string + * @since 1.5 + */ + public static function stringURLSafe($string) + { + //remove any '-' from the string they will be used as concatonater + $str = str_replace('-', ' ', $string); + + $lang =& JFactory::getLanguage(); + $str = $lang->transliterate($str); + + // remove any duplicate whitespace, and ensure all characters are alphanumeric + $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); + + // lowercase and trim + $str = trim(strtolower($str)); + return $str; + } + + /** + * Replaces & with & for xhtml compliance + * + * @todo There must be a better way??? + * + * @since 1.5 + */ + public static function ampReplace($text) + { + $text = str_replace('&&', '*--*', $text); + $text = str_replace('', '*-*', $text); + $text = str_replace('&', '&', $text); + $text = preg_replace('|&(?![\w]+;)|', '&', $text); + $text = str_replace('*-*', '', $text); + $text = str_replace('*--*', '&&', $text); + + return $text; + } + + /** + * Callback method for replacing & with & in a string + * + * @param string $m String to process + * @return string Replaced string + * @since 1.5 + */ + public static function _ampReplaceCallback($m) + { + $rx = '&(?!amp;)'; + return preg_replace( '#'.$rx.'#', '&', $m[0] ); + } + + /** + * Cleans text of all formating and scripting code + */ + public static function cleanText(&$text) + { + $text = preg_replace("''si", '', $text); + $text = preg_replace('/]*>([^<]+)<\/a>/is', '\2 (\1)', $text); + $text = preg_replace('//', '', $text); + $text = preg_replace('/{.+?}/', '', $text); + $text = preg_replace('/ /', ' ', $text); + $text = preg_replace('/&/', ' ', $text); + $text = preg_replace('/"/', ' ', $text); + $text = strip_tags($text); + $text = htmlspecialchars($text); + return $text; + } } diff --git a/vendor/joomla/libraries/joomla/html/editor.php b/vendor/joomla/libraries/joomla/html/editor.php index 9495eef35..5a42b08c7 100644 --- a/vendor/joomla/libraries/joomla/html/editor.php +++ b/vendor/joomla/libraries/joomla/html/editor.php @@ -1,17 +1,4 @@ '', 'end' => ''); - - /** - * constructor - * - * @access protected - * @param string The editor name - */ - function __construct($editor = 'none') - { - $this->_name = $editor; - } - - /** - * Returns a reference to a global Editor object, only creating it - * if it doesn't already exist. - * - * This method must be invoked as: - *
$editor = &JEditor::getInstance([$editor);- * - * @access public - * @param string $editor The editor to use. - * @return JEditor The Editor object. - */ - function &getInstance($editor = 'none') - { - static $instances; - $editor = 'none'; - if (!isset ($instances)) { - $instances = array (); - } - - $signature = serialize($editor); - - if (empty ($instances[$signature])) { - $instances[$signature] = new JEditor($editor); - } - - return $instances[$signature]; - } - - /** - * Initialize the editor - */ - function initialise() - { - //check if editor is already loaded - if(is_null(($this->_editor))) { - return; - } - - $args['event'] = 'onInit'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - //$return .= $result; - $return = $result; - } - } - - $document =& JFactory::getDocument(); - $document->addCustomTag($return); - } - - /** - * Present a text area - * - * @param string The control name - * @param string The contents of the text area - * @param string The width of the text area (px or %) - * @param string The height of the text area (px or %) - * @param int The number of columns for the textarea - * @param int The number of rows for the textarea - * @param boolean True and the editor buttons will be displayed - * @param array Associative array of editor parameters - */ - function display($name, $html, $width, $height, $col, $row, $buttons = true, $params = array()) - { - $this->_loadEditor($params); - - //check if editor is already loaded - if(is_null(($this->_editor))) { - return; - } - - // Backwards compatibility. Width and height should be passed without a semicolon from now on. - // If editor plugins need a unit like "px" for CSS styling, they need to take care of that - $width = str_replace( ';', '', $width ); - $height = str_replace( ';', '', $height ); - - // Initialize variables - $return = null; - - $args['name'] = $name; - $args['content'] = $html; - $args['width'] = $width; - $args['height'] = $height; - $args['col'] = $col; - $args['row'] = $row; - $args['buttons'] = $buttons; - $args['event'] = 'onDisplay'; - - $results[] = $this->_editor->update($args); - - foreach ($results as $result) - { - if (trim($result)) { - $return .= $result; - } - } - return $this->_tagForSEF['start'] . $return . $this->_tagForSEF['end']; - } - - /** - * Save the editor content - * - * @param string The name of the editor control - */ - function save( $editor ) - { - $this->_loadEditor(); - - //check if editor is already loaded - if(is_null(($this->_editor))) { - return; - } - - $args[] = $editor; - $args['event'] = 'onSave'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - $return .= $result; - } - } - return $return; - } - - /** - * Get the editor contents - * - * @param string The name of the editor control - */ - function getContent( $editor ) - { - $this->_loadEditor(); - - $args['name'] = $editor; - $args['event'] = 'onGetContent'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - $return .= $result; - } - } - return $return; - } - - /** - * Set the editor contents - * - * @param string The name of the editor control - * @param string The contents of the text area - */ - function setContent( $editor, $html ) - { - $this->_loadEditor(); - - $args['name'] = $editor; - $args['html'] = $html; - $args['event'] = 'onSetContent'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - $return .= $result; - } - } - return $return; - } - - /** - * Get the editor buttons - * - * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are displayed, if array defines a list of buttons not to show. - * @access public - * @since 1.5 - */ - function getButtons($editor, $buttons = true) - { - $result = array(); - - if(is_bool($buttons) && !$buttons) { - return $result; - } - - // Get plugins - $plugins = JPluginHelper::getPlugin('editors-xtd'); - - foreach($plugins as $plugin) - { - if(is_array($buttons) && in_array($plugin->name, $buttons)) { - continue; - } - - $isLoaded = JPluginHelper::importPlugin('editors-xtd', $plugin->name, false); - - $className = 'plgButton'.$plugin->name; - if(class_exists($className)) { - $plugin = new $className($this, (array)$plugin); - } - - // Try to authenticate -- only add to array if authentication is successful - $resultTest = $plugin->onDisplay($editor); - if ($resultTest) $result[] = $resultTest; - } - - return $result; - } - - /** - * Load the editor - * - * @access private - * @param array Associative array of editor config paramaters - * @since 1.5 - */ - function _loadEditor($config = array()) - { - //check if editor is already loaded - if(!is_null(($this->_editor))) { - return; - } - - jimport('joomla.filesystem.file'); - - // Build the path to the needed editor plugin - $name = JFilterInput::clean($this->_name, 'cmd'); - $path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php'; - - if ( ! JFile::exists($path) ) - { - $message = JText::_('Cannot load the editor'); - JError::raiseWarning( 500, $message ); - return false; - } - - // Require plugin file - require_once $path; - - // Get the plugin - $plugin =& JPluginHelper::getPlugin('editors', $this->_name); - if ( $plugin ) { - $params = new JParameter($plugin->params); - $params->loadArray($config); - $plugin->params = $params; - } - // Build editor plugin classname - $name = 'plgEditor'.$this->_name; - if($this->_editor = new $name ($this, (array)$plugin)) - { - // load plugin parameters - $this->initialise(); - JPluginHelper::importPlugin('editors-xtd'); - } - } -} \ No newline at end of file + /** + * Editor Plugin object + * + * @var object + */ + var $_editor = null; + + /** + * Editor Plugin name + * + * @var string + */ + var $_name = null; + + /** + * Editor start and end tag + * Used to tell SEF plugin not to process editor contents + * + * @var array + */ + var $_tagForSEF = array('start' => '', 'end' => ''); + + /** + * constructor + * + * @access protected + * @param string The editor name + */ + function __construct($editor = 'none') + { + $this->_name = $editor; + } + + /** + * Returns a reference to a global Editor object, only creating it + * if it doesn't already exist. + * + * This method must be invoked as: + *
$editor = &JEditor::getInstance([$editor);+ * + * @param string $editor The editor to use. + * @return JEditor The Editor object. + */ + public static function &getInstance($editor = 'none') + { + static $instances; + + $editor = 'none'; + if ( ! isset($instances)) { + $instances = array (); + } + + $signature = serialize($editor); + if (empty ($instances[$signature])) { + $instances[$signature] = new JEditor($editor); + } + + return $instances[$signature]; + } + + /** + * Initialize the editor + */ + function initialise() + { + //check if editor is already loaded + if(is_null(($this->_editor))) { + return; + } + + $args['event'] = 'onInit'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + //$return .= $result; + $return = $result; + } + } + + $document =& JFactory::getDocument(); + $document->addCustomTag($return); + } + + /** + * Present a text area + * + * @param string The control name + * @param string The contents of the text area + * @param string The width of the text area (px or %) + * @param string The height of the text area (px or %) + * @param int The number of columns for the textarea + * @param int The number of rows for the textarea + * @param boolean True and the editor buttons will be displayed + * @param array Associative array of editor parameters + */ + function display($name, $html, $width, $height, $col, $row, $buttons = true, $params = array()) + { + $this->_loadEditor($params); + + //check if editor is already loaded + if (is_null(($this->_editor))) { + return; + } + + // Backwards compatibility. Width and height should be passed without a semicolon from now on. + // If editor plugins need a unit like "px" for CSS styling, they need to take care of that + $width = str_replace( ';', '', $width ); + $height = str_replace( ';', '', $height ); + + // Initialize variables + $return = null; + + $args['name'] = $name; + $args['content'] = $html; + $args['width'] = $width; + $args['height'] = $height; + $args['col'] = $col; + $args['row'] = $row; + $args['buttons'] = $buttons; + $args['event'] = 'onDisplay'; + + $results[] = $this->_editor->update($args); + + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $this->_tagForSEF['start'] . $return . $this->_tagForSEF['end']; + } + + /** + * Save the editor content + * + * @param string The name of the editor control + */ + function save( $editor ) + { + $this->_loadEditor(); + + //check if editor is already loaded + if (is_null(($this->_editor))) { + return; + } + + $args[] = $editor; + $args['event'] = 'onSave'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $return; + } + + /** + * Get the editor contents + * + * @param string The name of the editor control + */ + function getContent( $editor ) + { + $this->_loadEditor(); + + $args['name'] = $editor; + $args['event'] = 'onGetContent'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $return; + } + + /** + * Set the editor contents + * + * @param string The name of the editor control + * @param string The contents of the text area + */ + function setContent( $editor, $html ) + { + $this->_loadEditor(); + + $args['name'] = $editor; + $args['html'] = $html; + $args['event'] = 'onSetContent'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $return; + } + + /** + * Get the editor buttons + * + * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are displayed, if array defines a list of buttons not to show. + * @access public + * @since 1.5 + */ + function getButtons($editor, $buttons = true) + { + $result = array(); + + if (is_bool($buttons) && !$buttons) { + return $result; + } + + // Get plugins + $plugins = JPluginHelper::getPlugin('editors-xtd'); + + foreach($plugins as $plugin) { + if (is_array($buttons) && in_array($plugin->name, $buttons)) { + continue; + } + + $isLoaded = JPluginHelper::importPlugin('editors-xtd', $plugin->name, false); + $className = 'plgButton'.$plugin->name; + if (class_exists($className)) { + $plugin = new $className($this, (array)$plugin); + } + + // Try to authenticate -- only add to array if authentication is successful + $resultTest = $plugin->onDisplay($editor); + if ($resultTest) $result[] = $resultTest; + } + + return $result; + } + + /** + * Load the editor + * + * @param array Associative array of editor config paramaters + * @since 1.5 + */ + protected function _loadEditor($config = array()) + { + //check if editor is already loaded + if(!is_null(($this->_editor))) { + return; + } + + jimport('joomla.filesystem.file'); + + // Build the path to the needed editor plugin + $name = JFilterInput::getInstance()->clean($this->_name, 'cmd'); + $path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php'; + + if ( ! JFile::exists($path)) { + $message = JText::_('Cannot load the editor'); + JError::raiseWarning( 500, $message ); + return false; + } + + // Require plugin file + require_once $path; + + // Get the plugin + $plugin =& JPluginHelper::getPlugin('editors', $this->_name); + if ($plugin) { + $params = new JParameter($plugin->params); + $params->loadArray($config); + $plugin->params = $params; + } + // Build editor plugin classname + $name = 'plgEditor'.$this->_name; + if ($this->_editor = new $name ($this, (array)$plugin)) { + // load plugin parameters + $this->initialise(); + JPluginHelper::importPlugin('editors-xtd'); + } + } +} diff --git a/vendor/joomla/libraries/joomla/html/html.php b/vendor/joomla/libraries/joomla/html/html.php index 82f8f7cf8..8fc037917 100644 --- a/vendor/joomla/libraries/joomla/html/html.php +++ b/vendor/joomla/libraries/joomla/html/html.php @@ -1,332 +1,304 @@ $v) { - $args[] = &$temp[$k]; - } - return call_user_func_array( array( $className, $func ), $args ); - } - else - { - JError::raiseWarning( 0, $className.'::'.$func.' not supported.' ); - return false; - } - } - - /** - * Write a element - * - * @access public - * @param string The relative URL to use for the href attribute - * @param string The target attribute to use - * @param array An associative array of attributes to add - * @since 1.5 - */ - function link($url, $text, $attribs = null) - { - if (is_array( $attribs )) { - $attribs = JArrayHelper::toString( $attribs ); - } - - return ''.$text.''; - } - - /** - * Write a element - * - * @access public - * @param string The relative or absoluete URL to use for the src attribute - * @param string The target attribute to use - * @param array An associative array of attributes to add - * @since 1.5 - */ - function image($url, $alt, $attribs = null) - { - if (is_array($attribs)) { - $attribs = JArrayHelper::toString( $attribs ); - } - - if(strpos($url, 'http') !== 0) { - $url = JURI::root(true).'/'.$url; - }; - - return ''; - } - - /** - * Write a element - * - * @access public - * @param string The relative URL to use for the src attribute - * @param string The target attribute to use - * @param array An associative array of attributes to add - * @param string The message to display if the iframe tag is not supported - * @since 1.5 - */ - function iframe( $url, $name, $attribs = null, $noFrames = '' ) - { - if (is_array( $attribs )) { - $attribs = JArrayHelper::toString( $attribs ); - } - - return ''; - } - - /** - * Write a element - * - * @access public - * @param string The name of the script file - * * @param string The relative or absolute path of the script file - * @param boolean If true, the mootools library will be loaded - * @since 1.5 - */ - function script($filename, $path = 'media/system/js/', $mootools = true) - { - // Include mootools framework - if($mootools) { - JHTML::_('behavior.mootools'); - } - - if(strpos($path, 'http') !== 0) { - $path = JURI::root(true).'/'.$path; - }; - - $document = &JFactory::getDocument(); - $document->addScript( $path.$filename ); - return; - } - - /** - * Write a element - * - * @access public - * @param string The relative URL to use for the href attribute - * @since 1.5 - */ - function stylesheet($filename, $path = 'media/system/css/', $attribs = array()) - { - if(strpos($path, 'http') !== 0) { - $path = JURI::root(true).'/'.$path; - }; - - $document = &JFactory::getDocument(); - $document->addStylesheet( $path.$filename, 'text/css', null, $attribs ); - return; - } - - /** - * Returns formated date according to current local and adds time offset - * - * @access public - * @param string date in an US English date format - * @param string format optional format for strftime - * @returns string formated date - * @see strftime - * @since 1.5 - */ - function date($date, $format = null, $offset = NULL) - { - if ( ! $format ) { - $format = JText::_('DATE_FORMAT_LC1'); - } - - - - if(is_null($offset)) - { - $config =& JFactory::getConfig(); - $offset = $config->getValue('config.offset'); - } - $instance =& JFactory::getDate($date); - $instance->setOffset($offset); - - return $instance->toFormat($format); - } - - /** - * Creates a tooltip with an image as button - * - * @access public - * @param string $tooltip The tip string - * @param string $title The title of the tooltip - * @param string $image The image for the tip, if no text is provided - * @param string $text The text for the tip - * @param string $href An URL that will be used to create the link - * @param boolean depreciated - * @return string - * @since 1.5 - */ - function tooltip($tooltip, $title='', $image='tooltip.png', $text='', $href='', $link=1) - { - $tooltip = addslashes(htmlspecialchars($tooltip, ENT_QUOTES, 'UTF-8')); - $title = addslashes(htmlspecialchars($title, ENT_QUOTES, 'UTF-8')); - - if ( !$text ) { - $image = JURI::root(true).'/includes/js/ThemeOffice/'. $image; - $text = ''; - } else { - $text = JText::_( $text, true ); - } - - if($title) { - $title = $title.'::'; - } - - $style = 'style="text-decoration: none; color: #333;"'; - - if ( $href ) { - $href = JRoute::_( $href ); - $style = ''; - $tip = ''. $text .''; - } else { - $tip = ''. $text .''; - } - - return $tip; - } - - /** - * Displays a calendar control field - * - * @param string The date value - * @param string The name of the text field - * @param string The id of the text field - * @param string The date format - * @param array Additional html attributes - */ - function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null) - { - JHTML::_('behavior.calendar'); //load the calendar behavior - - if (is_array($attribs)) { - $attribs = JArrayHelper::toString( $attribs ); - } - $document =& JFactory::getDocument(); - $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({ - inputField : "'.$id.'", // id of the input field - ifFormat : "'.$format.'", // format of the input field - button : "'.$id.'_img", // trigger for the calendar (button ID) - align : "Tl", // alignment (defaults to "Bl") - singleClick : true - });});'); - - return ''. - ''; - } - - /** - * Add a directory where JHTML should search for helpers. You may - * either pass a string or an array of directories. - * - * @access public - * @param string A path to search. - * @return array An array with directory elements - * @since 1.5 - */ - function addIncludePath( $path='' ) - { - static $paths; - - if (!isset($paths)) { - $paths = array( JPATH_LIBRARIES.DS.'joomla'.DS.'html'.DS.'html' ); - } - - // force path to array - settype($path, 'array'); - - // loop through the path directories - foreach ($path as $dir) - { - if (!empty($dir) && !in_array($dir, $paths)) { - array_unshift($paths, JPath::clean( $dir )); - } - } - - return $paths; - } + /** + * Class loader method + * + * Additional arguments may be supplied and are passed to the sub-class. + * Additional include paths are also able to be specified for third-party use + * + * @param string The name of helper method to load, (prefix).(class).function + * prefix and class are optional and can be used to load custom + * html helpers. + */ + public static function _($type) { + //Initialise variables + $prefix = 'JHTML'; + $file = ''; + $func = $type; + + // Check to see if we need to load a helper file + $parts = explode('.', $type); + + switch (count($parts)) { + case 3: + $prefix = preg_replace( '#[^A-Z0-9_]#i', '', $parts[0] ); + $file = preg_replace( '#[^A-Z0-9_]#i', '', $parts[1] ); + $func = preg_replace( '#[^A-Z0-9_]#i', '', $parts[2] ); + break; + case 2: + $file = preg_replace( '#[^A-Z0-9_]#i', '', $parts[0] ); + $func = preg_replace( '#[^A-Z0-9_]#i', '', $parts[1] ); + break; + } + + $className = $prefix.ucfirst($file); + + if ( ! class_exists($className)) { + jimport('joomla.filesystem.path'); + if (($path = JPath::find(JHTML::addIncludePath(), strtolower($file).'.php'))) { + require_once $path; + + if ( ! class_exists($className)) { + JError::raiseWarning(0, $className.'::' .$func. ' not found in file.'); + return false; + } + } else { + JError::raiseWarning(0, $prefix.$file.' not supported. File not found.'); + return false; + } + } + + if (is_callable(array($className, $func))) { + $temp = func_get_args(); + array_shift( $temp ); + $args = array(); + foreach ($temp as $k => $v) { + $args[] = &$temp[$k]; + } + return call_user_func_array( array( $className, $func ), $args ); + } else { + JError::raiseWarning(0, $className.'::'.$func.' not supported.'); + return false; + } + } + + /** + * Write a element + * + * @access public + * @param string The relative URL to use for the href attribute + * @param string The target attribute to use + * @param array An associative array of attributes to add + * @since 1.5 + */ + public static function link($url, $text, $attribs = null) + { + if (is_array( $attribs )) { + $attribs = JArrayHelper::toString( $attribs ); + } + + return ''.$text.''; + } + + /** + * Write a element + * + * @access public + * @param string The relative or absoluete URL to use for the src attribute + * @param string The target attribute to use + * @param array An associative array of attributes to add + * @since 1.5 + */ + public static function image($url, $alt, $attribs = null) + { + if (is_array($attribs)) { + $attribs = JArrayHelper::toString( $attribs ); + } + + if (strpos($url, 'http') !== 0) { + $url = JURI::root(true).'/'.$url; + }; + + return ''; + } + + /** + * Write a element + * + * @access public + * @param string The relative URL to use for the src attribute + * @param string The target attribute to use + * @param array An associative array of attributes to add + * @param string The message to display if the iframe tag is not supported + * @since 1.5 + */ + public static function iframe( $url, $name, $attribs = null, $noFrames = '' ) + { + if (is_array( $attribs )) { + $attribs = JArrayHelper::toString( $attribs ); + } + + return ''; + } + + /** + * Write a element + * + * @access public + * @param string The name of the script file + * @param string The relative or absolute path of the script file + * @param boolean If true, the mootools library will be loaded + * @since 1.5 + */ + public static function script($filename, $path = 'media/system/js/', $mootools = true) + { + // Include mootools framework + if ($mootools) { + JHTML::_('behavior.mootools'); + } + + if (strpos($path, 'http') !== 0) { + $path = JURI::root(true).'/'.$path; + } + + $document = &JFactory::getDocument(); + $document->addScript( $path.$filename ); + return; + } + + /** + * Write a element + * + * @access public + * @param string The relative URL to use for the href attribute + * @since 1.5 + */ + public static function stylesheet($filename, $path = 'media/system/css/', $attribs = array()) + { + if (strpos($path, 'http') !== 0) { + $path = JURI::root(true).'/'.$path; + } + + $document = &JFactory::getDocument(); + $document->addStylesheet( $path.$filename, 'text/css', null, $attribs ); + return; + } + + /** + * Returns formated date according to current local and adds time offset + * + * @access public + * @param string date in an US English date format + * @param string format optional format for strftime + * @returns string formated date + * @see strftime + * @since 1.5 + */ + public static function date($date, $format = null, $offset = NULL) + { + if ( ! $format ) { + $format = JText::_('DATE_FORMAT_LC1'); + } + + if (is_null($offset)) { + $config =& JFactory::getConfig(); + $offset = $config->getValue('config.offset'); + } + $instance =& JFactory::getDate($date); + $instance->setOffset($offset); + + return $instance->toFormat($format); + } + + /** + * Creates a tooltip with an image as button + * + * @access public + * @param string $tooltip The tip string + * @param string $title The title of the tooltip + * @param string $image The image for the tip, if no text is provided + * @param string $text The text for the tip + * @param string $href An URL that will be used to create the link + * @param boolean depreciated + * @return string + * @since 1.5 + */ + public static function tooltip($tooltip, $title = '', $image = 'tooltip.png', $text = '', $href = '', $link = 1) + { + $tooltip = addslashes(htmlspecialchars($tooltip, ENT_QUOTES, 'UTF-8')); + $title = addslashes(htmlspecialchars($title, ENT_QUOTES, 'UTF-8')); + + if ( ! $text) { + $image = JURI::root(true).'/includes/js/ThemeOffice/'. $image; + $text = ''; + } else { + $text = JText::_( $text, true ); + } + + if ($title) { + $title = $title.'::'; + } + + $style = 'style="text-decoration: none; color: #333;"'; + + if ($href) { + $href = JRoute::_( $href ); + $style = ''; + $tip = ''. $text .''; + } else { + $tip = ''. $text .''; + } + + return $tip; + } + + /** + * Displays a calendar control field + * + * @param string The date value + * @param string The name of the text field + * @param string The id of the text field + * @param string The date format + * @param array Additional html attributes + */ + public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null) + { + JHTML::_('behavior.calendar'); //load the calendar behavior + + if (is_array($attribs)) { + $attribs = JArrayHelper::toString( $attribs ); + } + $document =& JFactory::getDocument(); + $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({ + inputField: "'.$id.'", // id of the input field + ifFormat: "'.$format.'", // format of the input field + button: "'.$id.'_img", // trigger for the calendar (button ID) + align: "Tl", // alignment (defaults to "Bl") + singleClick: true + });});'); + + return ''. + ''; + } + + /** + * Add a directory where JHTML should search for helpers. You may + * either pass a string or an array of directories. + * + * @access public + * @param string A path to search. + * @return array An array with directory elements + * @since 1.5 + */ + public static function addIncludePath($path = '') + { + static $paths; + + if ( ! isset($paths)) { + $paths = array(JPATH_LIBRARIES.DS.'joomla'.DS.'html'.DS.'html'); + } + + // force path to array + settype($path, 'array'); + + // loop through the path directories + foreach ($path as $dir) { + if ( ! empty($dir) && ! in_array($dir, $paths)) { + array_unshift($paths, JPath::clean($dir)); + } + } + + return $paths; + } } diff --git a/vendor/joomla/libraries/joomla/html/html/behavior.php b/vendor/joomla/libraries/joomla/html/html/behavior.php index 637cf3e1d..1b2a9d79f 100644 --- a/vendor/joomla/libraries/joomla/html/html/behavior.php +++ b/vendor/joomla/libraries/joomla/html/html/behavior.php @@ -1,383 +1,368 @@ getValue('config.debug'); - } - - // TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this - $konkcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror") : null; - + /** + * Method to load the mootools framework into the document head + * + * - If debugging mode is on an uncompressed version of mootools is included for easier debugging. + * + * @param boolean $debug Is debugging mode on? [optional] + * @return void + * @since 1.5 + */ + public static function mootools($debug = null) + { + static $loaded; + + // Only load once + if ($loaded) { + return; + } + + // If no debugging value is set, use the configuration setting + if ($debug === null) { + $config = &JFactory::getConfig(); + $debug = $config->getValue('config.debug'); + } + + // TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this + $konkcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror") : null; + if ( JFactory::getApplication()->isAdmin() ) { JHTML::script('lib_anahita/js/production/mootools.js', 'media/', false); } - if ($debug || $konkcheck) { + if ($debug || $konkcheck) { //JHTML::script('lib_anahita/js/vendors/mootools-core.js', 'media/', false); //JHTML::script('lib_anahita/js/vendors/mootools-more.js', 'media/', false); //JHTML::script('lib_anahita/js/vendors/clientcide.js', 'media/', false); //JHTML::script('lib_anahita/js/min/mootools.js', 'media/', false); - } else { - //JHTML::script('lib_anahita/js/min/mootools.js', 'media/', false); - } - - $loaded = true; - return; - } - - function caption() { - JHTML::script('caption.js'); - } - - function formvalidation() { - JHTML::script('validate.js' ); - } - - function switcher() { - JHTML::script('switcher.js' ); - } - - function combobox() { - JHTML::script('combobox.js' ); - } - - function tooltip($selector='.hasTip', $params = array()) - { - static $tips; - - if (!isset($tips)) { - $tips = array(); - } - - // Include mootools framework - JHTMLBehavior::mootools(); - - $sig = md5(serialize(array($selector,$params))); - if (isset($tips[$sig]) && ($tips[$sig])) { - return; - } - - // Setup options object - $opt['maxTitleChars'] = (isset($params['maxTitleChars']) && ($params['maxTitleChars'])) ? (int)$params['maxTitleChars'] : 50 ; - // offsets needs an array in the format: array('x'=>20, 'y'=>30) - $opt['offsets'] = (isset($params['offsets']) && (is_array($params['offsets']))) ? $params['offsets'] : null; - $opt['showDelay'] = (isset($params['showDelay'])) ? (int)$params['showDelay'] : null; - $opt['hideDelay'] = (isset($params['hideDelay'])) ? (int)$params['hideDelay'] : null; - $opt['className'] = (isset($params['className'])) ? $params['className'] : null; - $opt['fixed'] = (isset($params['fixed']) && ($params['fixed'])) ? '\\true' : '\\false'; - $opt['onShow'] = (isset($params['onShow'])) ? '\\'.$params['onShow'] : null; - $opt['onHide'] = (isset($params['onHide'])) ? '\\'.$params['onHide'] : null; - - $options = JHTMLBehavior::_getJSObject($opt); - - // Attach tooltips to document - $document =& JFactory::getDocument(); - $tooltipInit = ' window.addEvent(\'domready\', function(){ var JTooltips = new Tips($$(\''.$selector.'\'), '.$options.'); });'; - $document->addScriptDeclaration($tooltipInit); - - // Set static array - $tips[$sig] = true; - return; - } - - function modal($selector='a.modal', $params = array()) - { - static $modals; - static $included; - - $document =& JFactory::getDocument(); - - // Load the necessary files if they haven't yet been loaded - if (!isset($included)) { - - // Load the javascript and css - JHTML::script('modal.js'); - JHTML::stylesheet('modal.css'); - - $included = true; - } - - if (!isset($modals)) { - $modals = array(); - } - - $sig = md5(serialize(array($selector,$params))); - if (isset($modals[$sig]) && ($modals[$sig])) { - return; - } - - // Setup options object - $opt['ajaxOptions'] = (isset($params['ajaxOptions']) && (is_array($params['ajaxOptions']))) ? $params['ajaxOptions'] : null; - $opt['size'] = (isset($params['size']) && (is_array($params['size']))) ? $params['size'] : null; - $opt['onOpen'] = (isset($params['onOpen'])) ? $params['onOpen'] : null; - $opt['onClose'] = (isset($params['onClose'])) ? $params['onClose'] : null; - $opt['onUpdate'] = (isset($params['onUpdate'])) ? $params['onUpdate'] : null; - $opt['onResize'] = (isset($params['onResize'])) ? $params['onResize'] : null; - $opt['onMove'] = (isset($params['onMove'])) ? $params['onMove'] : null; - $opt['onShow'] = (isset($params['onShow'])) ? $params['onShow'] : null; - $opt['onHide'] = (isset($params['onHide'])) ? $params['onHide'] : null; - - $options = JHTMLBehavior::_getJSObject($opt); - - // Attach modal behavior to document - $document->addScriptDeclaration(" - window.addEvent('domready', function() { - - SqueezeBox.initialize(".$options."); - - $$('".$selector."').each(function(el) { - el.addEvent('click', function(e) { - new Event(e).stop(); - SqueezeBox.fromElement(el); - }); - }); - });"); - - // Set static array - $modals[$sig] = true; - return; - } - - function uploader($id='file-upload', $params = array()) - { - JHTML::script('swf.js' ); - JHTML::script('uploader.js' ); - - static $uploaders; - - if (!isset($uploaders)) { - $uploaders = array(); - } - - if (isset($uploaders[$id]) && ($uploaders[$id])) { - return; - } - - // Setup options object - $opt['url'] = (isset($params['targetURL'])) ? $params['targetURL'] : null ; - $opt['swf'] = (isset($params['swf'])) ? $params['swf'] : JURI::root(true).'/media/system/swf/uploader.swf'; - $opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true'; - $opt['queued'] = (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true'; - $opt['queueList'] = (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue'; - $opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false'; - $opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true'; - $opt['limitSize'] = (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null; - $opt['limitFiles'] = (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null; - $opt['optionFxDuration'] = (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null; - $opt['container'] = (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()'; - $opt['types'] = (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}'; - - - // Optional functions - $opt['createReplacement'] = (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null; - $opt['onComplete'] = (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null; - $opt['onAllComplete'] = (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null; - -/* types: Object with (description: extension) pairs, default: Images (*.jpg; *.jpeg; *.gif; *.png) - */ - - $options = JHTMLBehavior::_getJSObject($opt); - - // Attach tooltips to document - $document =& JFactory::getDocument(); - $uploaderInit = 'sBrowseCaption=\''.JText::_('Browse Files', true).'\'; - sRemoveToolTip=\''.JText::_('Remove from queue', true).'\'; - window.addEvent(\'load\', function(){ - var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.'); - $(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.JText::_('Clear Completed').'\' })); });'; - $document->addScriptDeclaration($uploaderInit); - - // Set static array - $uploaders[$id] = true; - return; - } - - function tree($id, $params = array(), $root = array()) - { - static $trees; - - if (!isset($trees)) { - $trees = array(); - } - - // Include mootools framework - JHTMLBehavior::mootools(); - JHTML::script('mootree.js'); - JHTML::stylesheet('mootree.css'); - - if (isset($trees[$id]) && ($trees[$id])) { - return; - } - - // Setup options object - $opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id.'_tree'; - $opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders'; - $opt['grid'] = (array_key_exists('grid', $params)) ? '\\'.$params['grid'] : '\\true'; - $opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JURI::root(true).'/media/system/images/mootree.gif'; - - // Event handlers - $opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\'.$params['onExpand'] : null; - $opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\'.$params['onSelect'] : null; - $opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\'.$params['onClick'] : '\\function(node){ window.open(node.data.url, $chk(node.data.target) ? node.data.target : \'_self\'); }'; - $options = JHTMLBehavior::_getJSObject($opt); - - // Setup root node - $rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root'; - $rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null; - $rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null; - $rt['open'] = (array_key_exists('open', $root)) ? '\\'.$root['open'] : '\\true'; - $rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null; - $rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null; - $rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null; - $rootNode = JHTMLBehavior::_getJSObject($rt); - - $treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : ''; - - $js = ' window.addEvent(\'domready\', function(){ - tree'.$treeName.' = new MooTreeControl('.$options.','.$rootNode.'); - tree'.$treeName.'.adopt(\''.$id.'\');})'; - - // Attach tooltips to document - $document =& JFactory::getDocument(); - $document->addScriptDeclaration($js); - - // Set static array - $trees[$id] = true; - return; - } - - function calendar() - { - $document =& JFactory::getDocument(); - JHTML::stylesheet('calendar-jos.css', 'media/system/css/', array(' title' => JText::_( 'green' ) ,' media' => 'all' )); - JHTML::script( 'calendar.js', 'media/system/js/' ); - JHTML::script( 'calendar-setup.js', 'media/system/js/' ); - - $translation = JHTMLBehavior::_calendartranslation(); - if($translation) { - $document->addScriptDeclaration($translation); - } - } - - /** - * Keep session alive, for example, while editing or creating an article. - */ - function keepalive() - { - // Include mootools framework - JHTMLBehavior::mootools(); - - $config =& JFactory::getConfig(); - $lifetime = ( $config->getValue('lifetime') * 60000 ); - $refreshTime = ( $lifetime <= 60000 ) ? 30000 : $lifetime - 60000; - //refresh time is 1 minute less than the liftime assined in the configuration.php file - - $document =& JFactory::getDocument(); - $script = ''; - $script .= 'function keepAlive( ) {'; - $script .= ' var myAjax = new Request.HTML( "index.php", { method: "get" } ).send();'; - $script .= '}'; - $script .= ' window.addEvent("domready", function()'; - $script .= '{ keepAlive.periodical('.$refreshTime.' ); }'; - $script .= ');'; - - $document->addScriptDeclaration($script); - - return; - } - - /** - * Internal method to get a JavaScript object notation string from an array - * - * @param array $array The array to convert to JavaScript object notation - * @return string JavaScript object notation representation of the array - * @since 1.5 - */ - function _getJSObject($array=array()) - { - // Initialize variables - $object = '{'; - - // Iterate over array to build objects - foreach ((array)$array as $k => $v) - { - if (is_null($v)) { - continue; - } - if (!is_array($v) && !is_object($v)) { - $object .= ' '.$k.': '; - $object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'"; - $object .= ','; - } else { - $object .= ' '.$k.': '.JHTMLBehavior::_getJSObject($v).','; - } - } - if (substr($object, -1) == ',') { - $object = substr($object, 0, -1); - } - $object .= '}'; - - return $object; - } - - /** - * Internal method to translate the JavaScript Calendar - * - * @return string JavaScript that translates the object - * @since 1.5 - */ - function _calendartranslation() - { - static $jsscript = 0; - - if($jsscript == 0) - { - $return = 'Calendar._DN = new Array ("'.JText::_('Sunday').'", "'.JText::_('Monday').'", "'.JText::_('Tuesday').'", "'.JText::_('Wednesday').'", "'.JText::_('Thursday').'", "'.JText::_('Friday').'", "'.JText::_('Saturday').'", "'.JText::_('Sunday').'");Calendar._SDN = new Array ("'.JText::_('Sun').'", "'.JText::_('Mon').'", "'.JText::_('Tue').'", "'.JText::_('Wed').'", "'.JText::_('Thu').'", "'.JText::_('Fri').'", "'.JText::_('Sat').'", "'.JText::_('Sun').'"); Calendar._FD = 0; Calendar._MN = new Array ("'.JText::_('January').'", "'.JText::_('February').'", "'.JText::_('March').'", "'.JText::_('April').'", "'.JText::_('May').'", "'.JText::_('June').'", "'.JText::_('July').'", "'.JText::_('August').'", "'.JText::_('September').'", "'.JText::_('October').'", "'.JText::_('November').'", "'.JText::_('December').'"); Calendar._SMN = new Array ("'.JText::_('January_short').'", "'.JText::_('February_short').'", "'.JText::_('March_short').'", "'.JText::_('April_short').'", "'.JText::_('May_short').'", "'.JText::_('June_short').'", "'.JText::_('July_short').'", "'.JText::_('August_short').'", "'.JText::_('September_short').'", "'.JText::_('October_short').'", "'.JText::_('November_short').'", "'.JText::_('December_short').'");Calendar._TT = {};Calendar._TT["INFO"] = "'.JText::_('About the calendar').'"; - Calendar._TT["ABOUT"] = - "DHTML Date/Time Selector\n" + - "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + + } else { + //JHTML::script('lib_anahita/js/min/mootools.js', 'media/', false); + } + + $loaded = true; + return; + } + + public static function caption() + { + JHTML::script('caption.js'); + } + + public static function formvalidation() + { + JHTML::script('validate.js'); + } + + public static function switcher() + { + JHTML::script('switcher.js'); + } + + public static function combobox() + { + JHTML::script('combobox.js' ); + } + + public static function tooltip($selector='.hasTip', $params = array()) + { + static $tips; + + if ( ! isset($tips)) { + $tips = array(); + } + + // Include mootools framework + JHTMLBehavior::mootools(); + + $sig = md5(serialize(array($selector,$params))); + if (isset($tips[$sig]) && ($tips[$sig])) { + return; + } + + // Setup options object + $opt['maxTitleChars'] = (isset($params['maxTitleChars']) && ($params['maxTitleChars'])) ? (int)$params['maxTitleChars'] : 50 ; + // offsets needs an array in the format: array('x'=>20, 'y'=>30) + $opt['offsets'] = (isset($params['offsets']) && (is_array($params['offsets']))) ? $params['offsets'] : null; + $opt['showDelay'] = (isset($params['showDelay'])) ? (int)$params['showDelay'] : null; + $opt['hideDelay'] = (isset($params['hideDelay'])) ? (int)$params['hideDelay'] : null; + $opt['className'] = (isset($params['className'])) ? $params['className'] : null; + $opt['fixed'] = (isset($params['fixed']) && ($params['fixed'])) ? '\\true' : '\\false'; + $opt['onShow'] = (isset($params['onShow'])) ? '\\'.$params['onShow'] : null; + $opt['onHide'] = (isset($params['onHide'])) ? '\\'.$params['onHide'] : null; + + $options = JHTMLBehavior::_getJSObject($opt); + + // Attach tooltips to document + $document =& JFactory::getDocument(); + $tooltipInit = ' window.addEvent(\'domready\', function(){ var JTooltips = new Tips($$(\''.$selector.'\'), '.$options.'); });'; + $document->addScriptDeclaration($tooltipInit); + + // Set static array + $tips[$sig] = true; + return; + } + + public static function modal($selector='a.modal', $params = array()) + { + static $modals; + static $included; + + $document =& JFactory::getDocument(); + + // Load the necessary files if they haven't yet been loaded + if ( ! isset($included)) { + // Load the javascript and css + JHTML::script('modal.js'); + JHTML::stylesheet('modal.css'); + + $included = true; + } + + if ( ! isset($modals)) { + $modals = array(); + } + + $sig = md5(serialize(array($selector,$params))); + if (isset($modals[$sig]) && ($modals[$sig])) { + return; + } + + // Setup options object + $opt['ajaxOptions'] = (isset($params['ajaxOptions']) && (is_array($params['ajaxOptions']))) ? $params['ajaxOptions'] : null; + $opt['size'] = (isset($params['size']) && (is_array($params['size']))) ? $params['size'] : null; + $opt['onOpen'] = (isset($params['onOpen'])) ? $params['onOpen'] : null; + $opt['onClose'] = (isset($params['onClose'])) ? $params['onClose'] : null; + $opt['onUpdate'] = (isset($params['onUpdate'])) ? $params['onUpdate'] : null; + $opt['onResize'] = (isset($params['onResize'])) ? $params['onResize'] : null; + $opt['onMove'] = (isset($params['onMove'])) ? $params['onMove'] : null; + $opt['onShow'] = (isset($params['onShow'])) ? $params['onShow'] : null; + $opt['onHide'] = (isset($params['onHide'])) ? $params['onHide'] : null; + + $options = JHTMLBehavior::_getJSObject($opt); + + // Attach modal behavior to document + $document->addScriptDeclaration(" + window.addEvent('domready', function() { + SqueezeBox.initialize(".$options."); + $$('".$selector."').each(function(el) { + el.addEvent('click', function(e) { + new Event(e).stop(); + SqueezeBox.fromElement(el); + }); + }); + });"); + + // Set static array + $modals[$sig] = true; + return; + } + + public static function uploader($id='file-upload', $params = array()) + { + JHTML::script('swf.js' ); + JHTML::script('uploader.js' ); + + static $uploaders; + + if (!isset($uploaders)) { + $uploaders = array(); + } + + if (isset($uploaders[$id]) && ($uploaders[$id])) { + return; + } + + // Setup options object + $opt['url'] = (isset($params['targetURL'])) ? $params['targetURL'] : null ; + $opt['swf'] = (isset($params['swf'])) ? $params['swf'] : JURI::root(true).'/media/system/swf/uploader.swf'; + $opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true'; + $opt['queued'] = (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true'; + $opt['queueList'] = (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue'; + $opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false'; + $opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true'; + $opt['limitSize'] = (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null; + $opt['limitFiles'] = (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null; + $opt['optionFxDuration'] = (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null; + $opt['container'] = (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()'; + $opt['types'] = (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}'; + // Optional functions + $opt['createReplacement'] = (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null; + $opt['onComplete'] = (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null; + $opt['onAllComplete'] = (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null; + + /* + * types: Object with (description: extension) pairs, default: Images (*.jpg; *.jpeg; *.gif; *.png) + */ + $options = JHTMLBehavior::_getJSObject($opt); + + // Attach tooltips to document + $document =& JFactory::getDocument(); + $uploaderInit = 'sBrowseCaption=\''.JText::_('Browse Files', true).'\'; + sRemoveToolTip=\''.JText::_('Remove from queue', true).'\'; + window.addEvent(\'load\', function(){ + var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.'); + $(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.JText::_('Clear Completed').'\' })); });'; + $document->addScriptDeclaration($uploaderInit); + + // Set static array + $uploaders[$id] = true; + return; + } + + public static function tree($id, $params = array(), $root = array()) + { + static $trees; + + if ( ! isset($trees)) { + $trees = array(); + } + + // Include mootools framework + JHTMLBehavior::mootools(); + JHTML::script('mootree.js'); + JHTML::stylesheet('mootree.css'); + + if (isset($trees[$id]) && ($trees[$id])) { + return; + } + + // Setup options object + $opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id.'_tree'; + $opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders'; + $opt['grid'] = (array_key_exists('grid', $params)) ? '\\'.$params['grid'] : '\\true'; + $opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JURI::root(true).'/media/system/images/mootree.gif'; + // Event handlers + $opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\'.$params['onExpand'] : null; + $opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\'.$params['onSelect'] : null; + $opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\'.$params['onClick'] : '\\function(node){ window.open(node.data.url, $chk(node.data.target) ? node.data.target : \'_self\'); }'; + + $options = JHTMLBehavior::_getJSObject($opt); + + // Setup root node + $rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root'; + $rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null; + $rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null; + $rt['open'] = (array_key_exists('open', $root)) ? '\\'.$root['open'] : '\\true'; + $rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null; + $rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null; + $rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null; + + $rootNode = JHTMLBehavior::_getJSObject($rt); + $treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : ''; + + $js = ' window.addEvent(\'domready\', function(){ + tree'.$treeName.' = new MooTreeControl('.$options.','.$rootNode.'); + tree'.$treeName.'.adopt(\''.$id.'\');})'; + + // Attach tooltips to document + $document =& JFactory::getDocument(); + $document->addScriptDeclaration($js); + + // Set static array + $trees[$id] = true; + return; + } + + public static function calendar() + { + $document =& JFactory::getDocument(); + JHTML::stylesheet('calendar-jos.css', 'media/system/css/', array(' title' => JText::_( 'green' ) ,' media' => 'all' )); + JHTML::script( 'calendar.js', 'media/system/js/' ); + JHTML::script( 'calendar-setup.js', 'media/system/js/' ); + + $translation = JHTMLBehavior::_calendartranslation(); + if ($translation) { + $document->addScriptDeclaration($translation); + } + } + + /** + * Keep session alive, for example, while editing or creating an article. + */ + public static function keepalive() + { + // Include mootools framework + JHTMLBehavior::mootools(); + + $config =& JFactory::getConfig(); + $lifetime = ( $config->getValue('lifetime') * 60000 ); + $refreshTime = ( $lifetime <= 60000 ) ? 30000 : $lifetime - 60000; + //refresh time is 1 minute less than the liftime assined in the configuration.php file + + $document =& JFactory::getDocument(); + $script = ''; + $script .= 'function keepAlive( ) {'; + $script .= ' var myAjax = new Request.HTML( "index.php", { method: "get" } ).send();'; + $script .= '}'; + $script .= ' window.addEvent("domready", function()'; + $script .= '{ keepAlive.periodical('.$refreshTime.' ); }'; + $script .= ');'; + + $document->addScriptDeclaration($script); + + return; + } + + /** + * Internal method to get a JavaScript object notation string from an array + * + * @param array $array The array to convert to JavaScript object notation + * @return string JavaScript object notation representation of the array + * @since 1.5 + */ + protected static function _getJSObject($array=array()) + { + // Initialize variables + $object = '{'; + + // Iterate over array to build objects + foreach ((array)$array as $k => $v) { + if (is_null($v)) { + continue; + } + if ( ! is_array($v) && !is_object($v)) { + $object .= ' '.$k.': '; + $object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'"; + $object .= ','; + } else { + $object .= ' '.$k.': '.JHTMLBehavior::_getJSObject($v).','; + } + } + if (substr($object, -1) == ',') { + $object = substr($object, 0, -1); + } + $object .= '}'; + + return $object; + } + + /** + * Internal method to translate the JavaScript Calendar + * + * @return string JavaScript that translates the object + * @since 1.5 + */ + protected static function _calendartranslation() + { + static $jsscript = 0; + + if ($jsscript == 0) { + $return = 'Calendar._DN = new Array ("'.JText::_('Sunday').'", "'.JText::_('Monday').'", "'.JText::_('Tuesday').'", "'.JText::_('Wednesday').'", "'.JText::_('Thursday').'", "'.JText::_('Friday').'", "'.JText::_('Saturday').'", "'.JText::_('Sunday').'");Calendar._SDN = new Array ("'.JText::_('Sun').'", "'.JText::_('Mon').'", "'.JText::_('Tue').'", "'.JText::_('Wed').'", "'.JText::_('Thu').'", "'.JText::_('Fri').'", "'.JText::_('Sat').'", "'.JText::_('Sun').'"); Calendar._FD = 0; Calendar._MN = new Array ("'.JText::_('January').'", "'.JText::_('February').'", "'.JText::_('March').'", "'.JText::_('April').'", "'.JText::_('May').'", "'.JText::_('June').'", "'.JText::_('July').'", "'.JText::_('August').'", "'.JText::_('September').'", "'.JText::_('October').'", "'.JText::_('November').'", "'.JText::_('December').'"); Calendar._SMN = new Array ("'.JText::_('January_short').'", "'.JText::_('February_short').'", "'.JText::_('March_short').'", "'.JText::_('April_short').'", "'.JText::_('May_short').'", "'.JText::_('June_short').'", "'.JText::_('July_short').'", "'.JText::_('August_short').'", "'.JText::_('September_short').'", "'.JText::_('October_short').'", "'.JText::_('November_short').'", "'.JText::_('December_short').'");Calendar._TT = {};Calendar._TT["INFO"] = "'.JText::_('About the calendar').'"; + Calendar._TT["ABOUT"] = +"DHTML Date/Time Selector\n" + +"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + "For latest version visit: http://www.dynarch.com/projects/calendar/\n" + "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + "\n\n" + @@ -391,12 +376,11 @@ function _calendartranslation() "- or Shift-click to decrease it\n" + "- or click and drag for faster selection."; - Calendar._TT["PREV_YEAR"] = "'.JText::_('Prev. year (hold for menu)').'";Calendar._TT["PREV_MONTH"] = "'.JText::_('Prev. month (hold for menu)').'"; Calendar._TT["GO_TODAY"] = "'.JText::_('Go Today').'";Calendar._TT["NEXT_MONTH"] = "'.JText::_('Next month (hold for menu)').'";Calendar._TT["NEXT_YEAR"] = "'.JText::_('Next year (hold for menu)').'";Calendar._TT["SEL_DATE"] = "'.JText::_('Select date').'";Calendar._TT["DRAG_TO_MOVE"] = "'.JText::_('Drag to move').'";Calendar._TT["PART_TODAY"] = "'.JText::_('(Today)').'";Calendar._TT["DAY_FIRST"] = "'.JText::_('Display %s first').'";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "'.JText::_('Close').'";Calendar._TT["TODAY"] = "'.JText::_('Today').'";Calendar._TT["TIME_PART"] = "'.JText::_('(Shift-)Click or drag to change value').'";Calendar._TT["DEF_DATE_FORMAT"] = "'.JText::_('%Y-%m-%d').'"; Calendar._TT["TT_DATE_FORMAT"] = "'.JText::_('%a, %b %e').'";Calendar._TT["WK"] = "'.JText::_('wk').'";Calendar._TT["TIME"] = "'.JText::_('Time:').'";'; - $jsscript = 1; - return $return; - } else { - return false; - } - } + Calendar._TT["PREV_YEAR"] = "'.JText::_('Prev. year (hold for menu)').'";Calendar._TT["PREV_MONTH"] = "'.JText::_('Prev. month (hold for menu)').'"; Calendar._TT["GO_TODAY"] = "'.JText::_('Go Today').'";Calendar._TT["NEXT_MONTH"] = "'.JText::_('Next month (hold for menu)').'";Calendar._TT["NEXT_YEAR"] = "'.JText::_('Next year (hold for menu)').'";Calendar._TT["SEL_DATE"] = "'.JText::_('Select date').'";Calendar._TT["DRAG_TO_MOVE"] = "'.JText::_('Drag to move').'";Calendar._TT["PART_TODAY"] = "'.JText::_('(Today)').'";Calendar._TT["DAY_FIRST"] = "'.JText::_('Display %s first').'";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "'.JText::_('Close').'";Calendar._TT["TODAY"] = "'.JText::_('Today').'";Calendar._TT["TIME_PART"] = "'.JText::_('(Shift-)Click or drag to change value').'";Calendar._TT["DEF_DATE_FORMAT"] = "'.JText::_('%Y-%m-%d').'"; Calendar._TT["TT_DATE_FORMAT"] = "'.JText::_('%a, %b %e').'";Calendar._TT["WK"] = "'.JText::_('wk').'";Calendar._TT["TIME"] = "'.JText::_('Time:').'";'; + $jsscript = 1; + return $return; + } else { + return false; + } + } } - diff --git a/vendor/joomla/libraries/joomla/html/html/form.php b/vendor/joomla/libraries/joomla/html/html/form.php index 2e9b8734c..fe9e7d298 100644 --- a/vendor/joomla/libraries/joomla/html/html/form.php +++ b/vendor/joomla/libraries/joomla/html/html/form.php @@ -1,38 +1,26 @@ '; - } -} \ No newline at end of file + /** + * Displays a hidden token field to reduce the risk of CSRF exploits + * + * Use in conjuction with JRequest::checkToken + * + * @return void + * @since 1.5 + */ + public static function token() + { + return ''; + } +} diff --git a/vendor/joomla/libraries/joomla/html/html/grid.php b/vendor/joomla/libraries/joomla/html/html/grid.php index bc51fbd38..a6dd6d178 100644 --- a/vendor/joomla/libraries/joomla/html/html/grid.php +++ b/vendor/joomla/libraries/joomla/html/html/grid.php @@ -1,173 +1,148 @@ '; - $html .= JText::_( $title ); - if ($order == $selected ) { - $html .= JHTML::_('image.administrator', $images[$index], '/images/', NULL, NULL); - } - $html .= ''; - return $html; - } - - /** - * @param int The row index - * @param int The record id - * @param boolean - * @param string The name of the form element - * - * @return string - */ - function id( $rowNum, $recId, $checkedOut=false, $name='cid' ) - { - if ( $checkedOut ) { - return ''; - } else { - return ''; - } - } - - function access( &$row, $i, $archived = NULL ) - { - if ( !$row->access ) { - $color_access = 'style="color: green;"'; - $task_access = 'accessregistered'; - } else if ( $row->access == 1 ) { - $color_access = 'style="color: red;"'; - $task_access = 'accessspecial'; - } else { - $color_access = 'style="color: black;"'; - $task_access = 'accesspublic'; - } - - if ($archived == -1) - { - $href = JText::_( $row->groupname ); - } - else - { - $href = ' - - '. JText::_( $row->groupname ) .'' - ; - } - - return $href; - } - - function checkedOut( &$row, $i, $identifier = 'id' ) - { - $user =& JFactory::getUser(); - $userid = $user->get('id'); - - $result = false; - if(is_a($row, 'JTable')) { - $result = $row->isCheckedOut($userid); - } else { - $result = JTable::isCheckedOut($userid, $row->checked_out); - } - - $checked = ''; - if ( $result ) { - $checked = JHTMLGrid::_checkedOut( $row ); - } else { - $checked = JHTML::_('grid.id', $i, $row->$identifier ); - } - - return $checked; - } - - function published( &$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' ) - { - $img = $row->published ? $imgY : $imgX; - $task = $row->published ? 'unpublish' : 'publish'; - $alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' ); - $action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' ); - - $href = ' - - ' - ; - - return $href; - } - - function state( $filter_state='*', $published='Published', $unpublished='Unpublished', $archived=NULL, $trashed=NULL ) - { - $state[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' ); - //Jinx : Why is this used ? - //$state[] = JHTML::_('select.option', '*', JText::_( 'Any' ) ); - $state[] = JHTML::_('select.option', 'P', JText::_( $published ) ); - $state[] = JHTML::_('select.option', 'U', JText::_( $unpublished ) ); - - if ($archived) { - $state[] = JHTML::_('select.option', 'A', JText::_( $archived ) ); - } - - if ($trashed) { - $state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) ); - } - - return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state ); - } - - function order( $rows, $image='filesave.png', $task="saveorder" ) - { - $image = JHTML::_('image.administrator', $image, '/images/', NULL, NULL, JText::_( 'Save Order' ) ); - $href = ''.$image.''; - return $href; - } - - - function _checkedOut( &$row, $overlib = 1 ) - { - $hover = ''; - if ( $overlib ) - { - $text = addslashes(htmlspecialchars($row->editor)); - - $date = JHTML::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1') ); - $time = JHTML::_('date', $row->checked_out_time, '%H:%M' ); - - $hover = ''; - } - $checked = $hover .''; - - return $checked; - } + /** + * @param string The link title + * @param string The order field for the column + * @param string The current direction + * @param string The selected ordering + * @param string An optional task override + */ + public static function sort($title, $order, $direction = 'asc', $selected = 0, $task = NULL) + { + $direction = strtolower( $direction ); + $images = array( 'sort_asc.png', 'sort_desc.png' ); + $index = intval( $direction == 'desc' ); + $direction = ($direction == 'desc') ? 'asc' : 'desc'; + + $html = ''; + $html .= JText::_( $title ); + if ($order == $selected ) { + $html .= JHTML::_('image.administrator', $images[$index], '/images/', NULL, NULL); + } + $html .= ''; + return $html; + } + + /** + * @param int The row index + * @param int The record id + * @param boolean + * @param string The name of the form element + * + * @return string + */ + public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid') + { + if ($checkedOut) { + return ''; + } else { + return ''; + } + } + + public static function access(&$row, $i, $archived = NULL) + { + if ( ! $row->access) { + $color_access = 'style="color: green;"'; + $task_access = 'accessregistered'; + } elseif ($row->access == 1) { + $color_access = 'style="color: red;"'; + $task_access = 'accessspecial'; + } else { + $color_access = 'style="color: black;"'; + $task_access = 'accesspublic'; + } + + if ($archived == -1) { + $href = JText::_( $row->groupname ); + } else { + $href = ' + + '. JText::_( $row->groupname ) .'' + ; + } + + return $href; + } + + public static function checkedOut( &$row, $i, $identifier = 'id' ) + { + $user =& JFactory::getUser(); + $userid = $user->get('id'); + $result = JTable::isCheckedOut($userid, $row->checked_out); + + $checked = ''; + if ($result) { + $checked = JHTMLGrid::_checkedOut( $row ); + } else { + $checked = JHTML::_('grid.id', $i, $row->$identifier ); + } + + return $checked; + } + + public static function published(&$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix = '') { + $img = $row->published ? $imgY : $imgX; + $task = $row->published ? 'unpublish' : 'publish'; + $alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' ); + $action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' ); + + $href = ' + + ' + ; + + return $href; + } + + public static function state($filter_state = '*', $published = 'Published', $unpublished = 'Unpublished', $archived = NULL, $trashed = NULL) + { + $state[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' ); + //Jinx : Why is this used ? + //$state[] = JHTML::_('select.option', '*', JText::_( 'Any' ) ); + $state[] = JHTML::_('select.option', 'P', JText::_( $published ) ); + $state[] = JHTML::_('select.option', 'U', JText::_( $unpublished ) ); + + if ($archived) { + $state[] = JHTML::_('select.option', 'A', JText::_( $archived ) ); + } + + if ($trashed) { + $state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) ); + } + + return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state ); + } + + public static function order($rows, $image = 'filesave.png', $task = "saveorder") + { + $image = JHTML::_('image.administrator', $image, '/images/', NULL, NULL, JText::_( 'Save Order' ) ); + $href = ''.$image.''; + return $href; + } + + protected static function _checkedOut( &$row, $overlib = 1 ) + { + $hover = ''; + if ($overlib) { + $text = addslashes(htmlspecialchars($row->editor)); + $date = JHTML::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1') ); + $time = JHTML::_('date', $row->checked_out_time, '%H:%M' ); + $hover = ''; + } + $checked = $hover .''; + + return $checked; + } } diff --git a/vendor/joomla/libraries/joomla/html/html/image.php b/vendor/joomla/libraries/joomla/html/html/image.php index 39712d1b3..bdda828e2 100644 --- a/vendor/joomla/libraries/joomla/html/html/image.php +++ b/vendor/joomla/libraries/joomla/html/html/image.php @@ -1,153 +1,137 @@ getTemplate(); - - if ( $altFile ) - { - // $param allows for an alternative file to be used - $src = $altFolder . $altFile; - } - else if ( $altFile == -1 ) - { - // Comes from an image list param field with 'Do not use' selected - return ''; - } else { - $path = JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file; - if (!isset( $paths[$path] )) - { - if ( file_exists( JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file ) ) { - $paths[$path] = 'templates/'. $cur_template .'/images/'. $file; - } else { - // outputs only path to image - $paths[$path] = $folder . $file; - } - } - $src = $paths[$path]; - } - - if (substr($src, 0, 1 ) == "/") { - $src = substr_replace($src, '', 0, 1); - } - - // Prepend the base path - $src = JURI::base(true).'/'.$src; - - // outputs actual html tag - if ($asTag) { - return ''; - } - - return $src; - } - - /** - * Checks to see if an image exists in the current templates image directory - * if it does it loads this image. Otherwise the default image is loaded. - * Also can be used in conjunction with the menulist param to create the chosen image - * load the default or use no image - * - * @param string The file name, eg foobar.png - * @param string The path to the image - * @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder - * @param string Another path. Only used for the contact us form based on the value of the imagelist parm - * @param string Alt text - * @param array An associative array of attributes to add - * @param boolean True (default) to display full tag, false to return just the path - */ - function administrator( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt = NULL, $attribs = null, $type = 1 ) - { - global $mainframe; - - if (is_array( $attribs )) { - $attribs = JArrayHelper::toString( $attribs ); - } - - $cur_template = $mainframe->getTemplate(); - - // strip html - $alt = html_entity_decode( $alt ); - - if ( $param ) { - $image = $param_directory . $param; - } else if ( $param == -1 ) { - $image = ''; - } else { - if ( file_exists( JPATH_ADMINISTRATOR .'/templates/'. $cur_template .'/images/'. $file ) ) { - $image = 'templates/'. $cur_template .'/images/'. $file; - } else { - // compability with previous versions - if ( substr($directory, 0, 14 )== "/administrator" ) { - $image = substr($directory,15) . $file; - } else { - $image = $directory . $file; - } - } - } - - if (substr($image, 0, 1 ) == "/") { - $image = substr_replace($image, '', 0, 1); - } - - // Prepend the base path - $image = JURI::base(true).'/'.$image; - - // outputs actual html tag - if ( $type ) { - $image = ''; - } - - return $image; - } -} \ No newline at end of file + /** + * Checks to see if an image exists in the current templates image directory + * if it does it loads this image. Otherwise the default image is loaded. + * Also can be used in conjunction with the menulist param to create the chosen image + * load the default or use no image + * + * @param string The file name, eg foobar.png + * @param string The path to the image + * @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder + * @param string Another path. Only used for the contact us form based on the value of the imagelist parm + * @param string Alt text + * @param array An associative array of attributes to add + * @param boolean True (default) to display full tag, false to return just the path + */ + public static function site($file, $folder='/images/M_images/', $altFile=NULL, $altFolder='/images/M_images/', $alt=NULL, $attribs = null, $asTag = 1) + { + static $paths; + global $mainframe; + + if ( ! $paths) { + $paths = array(); + } + + if (is_array( $attribs )) { + $attribs = JArrayHelper::toString( $attribs ); + } + + $cur_template = $mainframe->getTemplate(); + + if ($altFile) { + // $param allows for an alternative file to be used + $src = $altFolder . $altFile; + } elseif ($altFile == -1) { + // Comes from an image list param field with 'Do not use' selected + return ''; + } else { + $path = JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file; + if ( ! isset( $paths[$path])) { + if (file_exists( JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file)) { + $paths[$path] = 'templates/'. $cur_template .'/images/'. $file; + } else { + // outputs only path to image + $paths[$path] = $folder . $file; + } + } + $src = $paths[$path]; + } + + if (substr($src, 0, 1 ) == "/") { + $src = substr_replace($src, '', 0, 1); + } + + // Prepend the base path + $src = JURI::base(true).'/'.$src; + + // outputs actual html tag + if ($asTag) { + return ''; + } + + return $src; + } + + /** + * Checks to see if an image exists in the current templates image directory + * if it does it loads this image. Otherwise the default image is loaded. + * Also can be used in conjunction with the menulist param to create the chosen image + * load the default or use no image + * + * @param string The file name, eg foobar.png + * @param string The path to the image + * @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder + * @param string Another path. Only used for the contact us form based on the value of the imagelist parm + * @param string Alt text + * @param array An associative array of attributes to add + * @param boolean True (default) to display full tag, false to return just the path + */ + public static function administrator( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt = NULL, $attribs = null, $type = 1 ) + { + global $mainframe; + + if (is_array($attribs)) { + $attribs = JArrayHelper::toString( $attribs ); + } + + $cur_template = $mainframe->getTemplate(); + + // strip html + $alt = html_entity_decode( $alt ); + + if ($param) { + $image = $param_directory . $param; + } elseif ($param == -1) { + $image = ''; + } else { + if (file_exists( JPATH_ADMINISTRATOR.'/templates/'.$cur_template.'/images/'.$file)) { + $image = 'templates/'.$cur_template.'/images/'.$file; + } else { + // compability with previous versions + if (substr($directory, 0, 14) == "/administrator") { + $image = substr($directory,15) . $file; + } else { + $image = $directory . $file; + } + } + } + + if (substr($image, 0, 1 ) == "/") { + $image = substr_replace($image, '', 0, 1); + } + + // Prepend the base path + $image = JURI::base(true).'/'.$image; + + // outputs actual html tag + if ($type) { + $image = ''; + } + + return $image; + } +} diff --git a/vendor/joomla/libraries/joomla/html/html/list.php b/vendor/joomla/libraries/joomla/html/html/list.php index 76954e9dc..9ffc8b5c8 100644 --- a/vendor/joomla/libraries/joomla/html/html/list.php +++ b/vendor/joomla/libraries/joomla/html/html/list.php @@ -1,236 +1,222 @@ setQuery( $query ); - $groups = $db->loadObjectList(); - $access = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), '', 1 ); - - return $access; - } - - /** - * Build the select list to choose an image - */ - function images( $name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png" ) - { - if ( !$directory ) { - $directory = '/images/stories/'; - } - - if ( !$javascript ) { - $javascript = "onchange=\"javascript:if (document.forms.adminForm." . $name . ".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm." . $name . ".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; - } - - jimport( 'joomla.filesystem.folder' ); - $imageFiles = JFolder::files( JPATH_SITE.DS.$directory ); - $images = array( JHTML::_('select.option', '', '- '. JText::_( 'Select Image' ) .' -' ) ); - foreach ( $imageFiles as $file ) { - if ( preg_match( "#$extensions#i", $file ) ) { - $images[] = JHTML::_('select.option', $file ); - } - } - $images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); - - return $images; - } - - /** - * Description - * - * @param string SQL with ordering As value and 'name field' AS text - * @param integer The length of the truncated headline - * @since 1.5 - */ - function genericordering( $sql, $chop = '30' ) - { - $db =& JFactory::getDBO(); - $order = array(); - $db->setQuery( $sql ); - if (!($orders = $db->loadObjectList())) { - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } else { - $order[] = JHTML::_('select.option', 1, JText::_( 'first' ) ); - return $order; - } - } - $order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) ); - for ($i=0, $n=count( $orders ); $i < $n; $i++) { - - if (JString::strlen($orders[$i]->text) > $chop) { - $text = JString::substr($orders[$i]->text,0,$chop)."..."; - } else { - $text = $orders[$i]->text; - } - - $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); - } - $order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) ); - - return $order; - } - - /** - * Build the select list for Ordering of a specified Table - */ - function specificordering( &$row, $id, $query, $neworder = 0 ) - { - $db =& JFactory::getDBO(); - - if ( $id ) { - $order = JHTML::_('list.genericordering', $query ); - $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); - } else { - if ( $neworder ) { - $text = JText::_( 'descNewItemsFirst' ); - } else { - $text = JText::_( 'descNewItemsLast' ); - } - $ordering = ''. $text; - } - return $ordering; - } - - /** - * Select list of active users - */ - function users( $name, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1 ) - { - $db =& JFactory::getDBO(); - - $and = ''; - if ( $reg ) { - // does not include registered users in the list - $and = ' AND gid > 18'; - } - - $query = 'SELECT id AS value, name AS text' - . ' FROM #__users' - . ' WHERE block = 0' - . $and - . ' ORDER BY '. $order - ; - $db->setQuery( $query ); - if ( $nouser ) { - $users[] = JHTML::_('select.option', '0', '- '. JText::_( 'No User' ) .' -' ); - $users = array_merge( $users, $db->loadObjectList() ); - } else { - $users = $db->loadObjectList(); - } - - $users = JHTML::_('select.genericlist', $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); - - return $users; - } - - /** - * Select list of positions - generally used for location of images - */ - function positions( $name, $active = NULL, $javascript = NULL, $none = 1, $center = 1, $left = 1, $right = 1, $id = false ) - { - if ( $none ) { - $pos[] = JHTML::_('select.option', '', JText::_( 'None' ) ); - } - if ( $center ) { - $pos[] = JHTML::_('select.option', 'center', JText::_( 'Center' ) ); - } - if ( $left ) { - $pos[] = JHTML::_('select.option', 'left', JText::_( 'Left' ) ); - } - if ( $right ) { - $pos[] = JHTML::_('select.option', 'right', JText::_( 'Right' ) ); - } - - $positions = JHTML::_('select.genericlist', $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active, $id ); - - return $positions; - } - - /** - * Select list of active categories for components - */ - function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 ) - { - $db =& JFactory::getDBO(); - - $query = 'SELECT id AS value, title AS text' - . ' FROM #__categories' - . ' WHERE section = '.$db->Quote($section) - . ' AND published = 1' - . ' ORDER BY '. $order - ; - $db->setQuery( $query ); - if ( $sel_cat ) { - $categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' ); - $categories = array_merge( $categories, $db->loadObjectList() ); - } else { - $categories = $db->loadObjectList(); - } - - $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); - return $category; - } - - /** - * Select list of active sections - */ - function section( $name, $active = NULL, $javascript = NULL, $order = 'ordering', $uncategorized = true, $scope = 'content' ) - { - $db =& JFactory::getDBO(); - - $categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Section' ) .' -' ); - - if ($uncategorized) { - $categories[] = JHTML::_('select.option', '0', JText::_( 'Uncategorized' ) ); - } - - $query = 'SELECT id AS value, title AS text' - . ' FROM #__sections' - . ' WHERE published = 1' - . ' AND scope = ' . $db->Quote($scope) - . ' ORDER BY ' . $order - ; - $db->setQuery( $query ); - $sections = array_merge( $categories, $db->loadObjectList() ); - - $category = JHTML::_('select.genericlist', $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); - - return $category; - } + /** + * Build the select list for access level + */ + public static function accesslevel( &$row ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT id AS value, name AS text' + . ' FROM #__groups' + . ' ORDER BY id' + ; + $db->setQuery( $query ); + $groups = $db->loadObjectList(); + $access = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), '', 1 ); + + return $access; + } + + /** + * Build the select list to choose an image + */ + public static function images($name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png") + { + if ( ! $directory) { + $directory = '/images/stories/'; + } + + if ( ! $javascript) { + $javascript = "onchange=\"javascript:if (document.forms.adminForm.".$name.".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm.".$name.".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; + } + + jimport('joomla.filesystem.folder'); + $imageFiles = JFolder::files(JPATH_SITE.DS.$directory); + $images = array(JHTML::_('select.option', '', '- '. JText::_( 'Select Image' ) .' -')); + foreach ($imageFiles as $file) { + if (preg_match("#$extensions#i", $file)) { + $images[] = JHTML::_('select.option', $file ); + } + } + $images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); + + return $images; + } + + /** + * Description + * + * @param string SQL with ordering As value and 'name field' AS text + * @param integer The length of the truncated headline + * @since 1.5 + */ + public static function genericordering( $sql, $chop = '30' ) + { + $db =& JFactory::getDBO(); + $order = array(); + $db->setQuery( $sql ); + if ( ! ($orders = $db->loadObjectList())) { + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } else { + $order[] = JHTML::_('select.option', 1, JText::_( 'first' ) ); + return $order; + } + } + $order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) ); + for ($i = 0, $n = count( $orders ); $i < $n; $i++) { + if (JString::strlen($orders[$i]->text) > $chop) { + $text = JString::substr($orders[$i]->text,0,$chop)."..."; + } else { + $text = $orders[$i]->text; + } + + $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); + } + $order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) ); + + return $order; + } + + /** + * Build the select list for Ordering of a specified Table + */ + public static function specificordering( &$row, $id, $query, $neworder = 0 ) + { + $db =& JFactory::getDBO(); + + if ($id) { + $order = JHTML::_('list.genericordering', $query ); + $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); + } else { + if ($neworder) { + $text = JText::_( 'descNewItemsFirst' ); + } else { + $text = JText::_( 'descNewItemsLast' ); + } + $ordering = ''. $text; + } + return $ordering; + } + + /** + * Select list of active users + */ + public static function users($name, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1) + { + $db =& JFactory::getDBO(); + + $and = ''; + if ($reg) { + // does not include registered users in the list + $and = ' AND gid > 18'; + } + + $query = 'SELECT id AS value, name AS text' + . ' FROM #__users' + . ' WHERE block = 0' + . $and + . ' ORDER BY '. $order + ; + $db->setQuery( $query ); + if ($nouser) { + $users[] = JHTML::_('select.option', '0', '- '. JText::_( 'No User' ) .' -' ); + $users = array_merge( $users, $db->loadObjectList() ); + } else { + $users = $db->loadObjectList(); + } + + $users = JHTML::_('select.genericlist', $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); + + return $users; + } + + /** + * Select list of positions - generally used for location of images + */ + public static function positions( $name, $active = NULL, $javascript = NULL, $none = 1, $center = 1, $left = 1, $right = 1, $id = false ) + { + if ( $none ) { + $pos[] = JHTML::_('select.option', '', JText::_( 'None' ) ); + } + if ( $center ) { + $pos[] = JHTML::_('select.option', 'center', JText::_( 'Center' ) ); + } + if ( $left ) { + $pos[] = JHTML::_('select.option', 'left', JText::_( 'Left' ) ); + } + if ( $right ) { + $pos[] = JHTML::_('select.option', 'right', JText::_( 'Right' ) ); + } + + $positions = JHTML::_('select.genericlist', $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active, $id ); + + return $positions; + } + + /** + * Select list of active categories for components + */ + public static function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT id AS value, title AS text' + . ' FROM #__categories' + . ' WHERE section = '.$db->Quote($section) + . ' AND published = 1' + . ' ORDER BY '. $order + ; + $db->setQuery( $query ); + if ( $sel_cat ) { + $categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' ); + $categories = array_merge( $categories, $db->loadObjectList() ); + } else { + $categories = $db->loadObjectList(); + } + + $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); + return $category; + } + + /** + * Select list of active sections + */ + public static function section( $name, $active = NULL, $javascript = NULL, $order = 'ordering', $uncategorized = true, $scope = 'content' ) + { + $db =& JFactory::getDBO(); + + $categories[] = JHTML::_('select.option', '-1', '- '. JText::_('Select Section') .' -' ); + + if ($uncategorized) { + $categories[] = JHTML::_('select.option', '0', JText::_('Uncategorized')); + } + + $query = 'SELECT id AS value, title AS text' + . ' FROM #__sections' + . ' WHERE published = 1' + . ' AND scope = ' . $db->Quote($scope) + . ' ORDER BY ' . $order + ; + $db->setQuery( $query ); + $sections = array_merge( $categories, $db->loadObjectList() ); + $category = JHTML::_('select.genericlist', $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active); + + return $category; + } } diff --git a/vendor/joomla/libraries/joomla/html/html/menu.php b/vendor/joomla/libraries/joomla/html/html/menu.php index bad42e865..20c87755e 100644 --- a/vendor/joomla/libraries/joomla/html/html/menu.php +++ b/vendor/joomla/libraries/joomla/html/html/menu.php @@ -1,17 +1,4 @@ Quote($row->menutype) - . ' AND parent = '.(int) $row->parent - . ' AND published != -2' - . ' ORDER BY ordering'; - $order = JHTML::_('list.genericordering', $query ); - $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); - } - else - { - $ordering = ''. JText::_( 'DESCNEWITEMSLAST' ); - } - return $ordering; - } - - /** - * Build the multiple select list for Menu Links/Pages - */ - function linkoptions( $all=false, $unassigned=false ) - { - $db =& JFactory::getDBO(); - - // get a list of the menu items - $query = 'SELECT m.id, m.parent, m.name, m.menutype' - . ' FROM #__menu AS m' - . ' WHERE m.published = 1' - . ' ORDER BY m.menutype, m.parent, m.ordering' - ; - $db->setQuery( $query ); - $mitems = $db->loadObjectList(); - $mitems_temp = $mitems; - - // establish the hierarchy of the menu - $children = array(); - // first pass - collect children - foreach ( $mitems as $v ) - { - $id = $v->id; - $pt = $v->parent; - $list = @$children[$pt] ? $children[$pt] : array(); - array_push( $list, $v ); - $children[$pt] = $list; - } - // second pass - get an indent list of the items - $list = JHTMLMenu::TreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); - - // Code that adds menu name to Display of Page(s) - $mitems_spacer = $mitems_temp[0]->menutype; - - $mitems = array(); - if ($all | $unassigned) { - $mitems[] = JHTML::_('select.option', '' ); - } - - $lastMenuType = null; - $tmpMenuType = null; - foreach ($list as $list_a) - { - if ($list_a->menutype != $lastMenuType) - { - if ($tmpMenuType) { - $mitems[] = JHTML::_('select.option', '' ); - } - $mitems[] = JHTML::_('select.option', '' ); - } - - return $mitems; - } - - function treerecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 ) - { - if (@$children[$id] && $level <= $maxlevel) - { - foreach ($children[$id] as $v) - { - $id = $v->id; - - if ( $type ) { - $pre = '|_ '; - $spacer = '. '; - } else { - $pre = '- '; - $spacer = ' '; - } - - if ( $v->parent == 0 ) { - $txt = $v->name; - } else { - $txt = $pre . $v->name; - } - $pt = $v->parent; - $list[$id] = $v; - $list[$id]->treename = "$indent$txt"; - $list[$id]->children = count( @$children[$id] ); - $list = JHTMLMenu::TreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type ); - } - } - return $list; - } -} \ No newline at end of file + /** + * Build the select list for Menu Ordering + */ + public static function ordering( &$row, $id ) + { + $db =& JFactory::getDBO(); + + if ($id) { + $query = 'SELECT ordering AS value, name AS text' + . ' FROM #__menu' + . ' WHERE menutype = '.$db->Quote($row->menutype) + . ' AND parent = '.(int) $row->parent + . ' AND published != -2' + . ' ORDER BY ordering'; + $order = JHTML::_('list.genericordering', $query ); + $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); + } else { + $ordering = ''. JText::_( 'DESCNEWITEMSLAST' ); + } + return $ordering; + } + + /** + * Build the multiple select list for Menu Links/Pages + */ + public static function linkoptions($all = false, $unassigned = false) + { + $db =& JFactory::getDBO(); + + // get a list of the menu items + $query = 'SELECT m.id, m.parent, m.name, m.menutype' + . ' FROM #__menu AS m' + . ' WHERE m.published = 1' + . ' ORDER BY m.menutype, m.parent, m.ordering' + ; + $db->setQuery( $query ); + $mitems = $db->loadObjectList(); + $mitems_temp = $mitems; + + // establish the hierarchy of the menu + $children = array(); + // first pass - collect children + foreach ($mitems as $v) { + $id = $v->id; + $pt = $v->parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + // second pass - get an indent list of the items + $list = JHTMLMenu::TreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); + + // Code that adds menu name to Display of Page(s) + $mitems_spacer = $mitems_temp[0]->menutype; + + $mitems = array(); + if ($all | $unassigned) { + $mitems[] = JHTML::_('select.option', '' ); + } + + $lastMenuType = null; + $tmpMenuType = null; + foreach ($list as $list_a) { + if ($list_a->menutype != $lastMenuType) { + if ($tmpMenuType) { + $mitems[] = JHTML::_('select.option', '' ); + } + $mitems[] = JHTML::_('select.option', '' ); + } + + return $mitems; + } + + public static function treerecurse( $id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1) + { + if (@$children[$id] && $level <= $maxlevel) { + foreach ($children[$id] as $v) { + $id = $v->id; + + if ($type) { + $pre = '|_ '; + $spacer = '. '; + } else { + $pre = '- '; + $spacer = ' '; + } + + if ( $v->parent == 0 ) { + $txt = $v->name; + } else { + $txt = $pre.$v->name; + } + $pt = $v->parent; + $list[$id] = $v; + $list[$id]->treename = "$indent$txt"; + $list[$id]->children = count(@$children[$id]); + $list = JHTMLMenu::TreeRecurse($id, $indent.$spacer, $list, $children, $maxlevel, $level + 1, $type); + } + } + return $list; + } +} diff --git a/vendor/joomla/libraries/joomla/html/html/select.php b/vendor/joomla/libraries/joomla/html/html/select.php index 8ca1767e5..e29e419c8 100644 --- a/vendor/joomla/libraries/joomla/html/html/select.php +++ b/vendor/joomla/libraries/joomla/html/html/select.php @@ -1,275 +1,251 @@ $value_name = $value; - $obj->$text_name = trim( $text ) ? $text : $value; - $obj->disable = $disable; - return $obj; - } - - /** - * @param string The text for the option - * @param string The returned object property name for the value - * @param string The returned object property name for the text - * @return object - */ - function optgroup( $text, $value_name = 'value', $text_name = 'text' ) - { - $obj = new stdClass; - $obj->$value_name = '