/e107_handlers/e107_class.php
PHP | 3742 lines | 1991 code | 446 blank | 1305 comment | 316 complexity | a517ec26db31667465c4b0d116aef157 MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- * e107 website system
- *
- * Copyright (C) 2008-2012 e107 Inc (e107.org)
- * Released under the terms and conditions of the
- * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
- *
- * e107 Main
- *
- * $URL$
- * $Id$
- */
- if (!defined('e107_INIT')) { exit; }
- /**
- *
- * @package e107
- * @category e107_handlers
- * @version $Id$
- * @author e107inc
- *
- * e107_class - core class with many system-related methods
- */
- class e107
- {
- /**
- * IPV6 string for localhost - as stored in DB
- */
- const LOCALHOST_IP = '0000:0000:0000:0000:0000:ffff:7f00:0001';
- public $server_path;
- public $e107_dirs = array();
- /**
- * @var array SQL connection data
- */
- protected $e107_config_mysql_info = array();
- public $http_path;
- public $https_path;
- public $base_path;
- public $file_path;
- public $site_path;
- public $relative_base_path;
- public $_ip_cache;
- public $_host_name_cache;
- public $site_theme; // class2 -> check valid theme
- public $http_theme_dir; // class2 -> check valid theme
- /**
- * Contains reference to global $_E107 array
- * Assignment is done inside prepare_request() method
- *
- * @var array
- */
- protected $_E107 = array();
- /**
- * @var string Current request type (http or https)
- */
- protected $HTTP_SCHEME;
- /**
- * Used for runtime caching of user extended struct
- *
- * @var array
- * @see get_user_data()
- */
- public $extended_struct;
- /**
- * User login name
- *
- * @var string
- * @see init_session()
- */
- public $currentUser = '';
- /**
- * Run once load core shortcodes
- * while initialize SC parser
- *
- * @var boolean
- */
- protected static $_sc_core_loaded = false;
- /**
- * Singleton instance
- * Allow class extends - override {@link getInstance()}
- *
- * @var e107
- */
- protected static $_instance = null;
- /**
- * e107 registry
- *
- * @var array
- */
- private static $_registry = array();
- /**
- * e107 core config object storage
- *
- * @var array
- */
- protected static $_core_config_arr = array();
- /**
- * e107 plugin config object storage
- *
- * @var array
- */
- protected static $_plug_config_arr = array();
- /**
- * Core handlers array
- * For new/missing handler add
- * 'class name' => 'path' pair
- *
- * Used to auto-load core/plugin handlers
- * NOTE: aplhabetically sorted! (by class name)
- *
- * @see addHandler()
- * @see setHandlerOverload()
- * @see getSingleton()
- * @see getObject()
- * @var array
- */
- protected static $_known_handlers = array(
- 'UserHandler' => '{e_HANDLER}user_handler.php',
- 'comment' => '{e_HANDLER}comment_class.php',
- 'convert' => '{e_HANDLER}date_handler.php',
- 'db' => '{e_HANDLER}mysql_class.php',
- 'e107Email' => '{e_HANDLER}mail.php',
- 'e107_event' => '{e_HANDLER}event_class.php',
- 'e107_db_debug' => '{e_HANDLER}db_debug_class.php',
- 'e107_traffic' => '{e_HANDLER}traffic_class.php',
- 'e107_user_extended' => '{e_HANDLER}user_extended_class.php',
- 'e107plugin' => '{e_HANDLER}plugin_class.php',
- 'e_chart' => '{e_HANDLER}chart_class.php',
- 'e_core_session' => '{e_HANDLER}session_handler.php',
- 'e_admin_controller' => '{e_HANDLER}admin_ui.php',
- 'e_admin_controller_ui' => '{e_HANDLER}admin_ui.php',
- 'e_admin_dispatcher' => '{e_HANDLER}admin_ui.php',
- 'e_admin_form_ui' => '{e_HANDLER}admin_ui.php',
- 'e_admin_log' => '{e_HANDLER}admin_log_class.php',
- 'e_admin_model' => '{e_HANDLER}model_class.php',
- 'e_admin_request' => '{e_HANDLER}admin_ui.php',
- 'e_admin_response' => '{e_HANDLER}admin_ui.php',
- 'e_admin_ui' => '{e_HANDLER}admin_ui.php',
- 'e_array' => '{e_HANDLER}core_functions.php', // Old ArrayStorage.
- 'e_bbcode' => '{e_HANDLER}bbcode_handler.php',
- 'e_bb_base' => '{e_HANDLER}bbcode_handler.php',
- 'e_file' => '{e_HANDLER}file_class.php',
- 'e_form' => '{e_HANDLER}form_handler.php',
- 'e_jshelper' => '{e_HANDLER}js_helper.php',
- 'e_media' => '{e_HANDLER}media_class.php',
- 'e_menu' => '{e_HANDLER}menu_class.php',
- 'e_model' => '{e_HANDLER}model_class.php',
- 'e_navigation' => '{e_HANDLER}sitelinks_class.php',
- 'e_news_item' => '{e_HANDLER}news_class.php',
- 'e_news_tree' => '{e_HANDLER}news_class.php',
- 'e_object' => '{e_HANDLER}model_class.php',
- 'e_online' => '{e_HANDLER}online_class.php',
- 'e_parse' => '{e_HANDLER}e_parse_class.php',
- 'e_parser' => '{e_HANDLER}e_parse_class.php',
- 'e_parse_shortcode' => '{e_HANDLER}shortcode_handler.php',
- 'e_ranks' => '{e_HANDLER}e_ranks_class.php',
- 'e_shortcode' => '{e_HANDLER}shortcode_handler.php',
- 'e_system_user' => '{e_HANDLER}user_model.php',
- 'e_upgrade' => '{e_HANDLER}e_upgrade_class.php',
- 'e_user_model' => '{e_HANDLER}user_model.php',
- 'e_user' => '{e_HANDLER}user_model.php',
- 'e_user_extended_structure_tree' => '{e_HANDLER}user_model.php',
- 'e_userperms' => '{e_HANDLER}user_handler.php',
- 'e_validator' => '{e_HANDLER}validator_class.php',
- 'e_vars' => '{e_HANDLER}model_class.php',
- 'ecache' => '{e_HANDLER}cache_handler.php',
- 'eController' => '{e_HANDLER}application.php',
- 'eDispatcher' => '{e_HANDLER}application.php',
- 'eException' => '{e_HANDLER}application.php',
- 'eFront' => '{e_HANDLER}application.php',
- 'eHelper' => '{e_HANDLER}application.php',
- 'eIPHandler' => '{e_HANDLER}iphandler_class.php',
- 'email_validation_class' => '{e_HANDLER}mail_validation_class.php',
- 'eMessage' => '{e_HANDLER}message_handler.php',
- 'eRequest' => '{e_HANDLER}application.php',
- 'eResponse' => '{e_HANDLER}application.php',
- 'eRouter' => '{e_HANDLER}application.php',
- 'eUrl' => '{e_HANDLER}e107Url.php',
- 'eUrlConfig' => '{e_HANDLER}application.php',
- 'eUrlRule' => '{e_HANDLER}application.php',
- 'Hybrid_Auth' => '{e_HANDLER}hybridauth/Hybrid/Auth.php',
- 'language' => '{e_HANDLER}language_class.php',
- 'news' => '{e_HANDLER}news_class.php',
- 'notify' => '{e_HANDLER}notify_class.php',
- 'override' => '{e_HANDLER}override_class.php',
- 'rater' => '{e_HANDLER}rate_class.php',
- 'redirection' => '{e_HANDLER}redirection_class.php',
- 'secure_image' => '{e_HANDLER}secure_img_handler.php',
- 'sitelinks' => '{e_HANDLER}sitelinks_class.php',
- 'themeHandler' => '{e_HANDLER}theme_handler.php',
- 'user_class' => '{e_HANDLER}userclass_class.php',
- 'userlogin' => '{e_HANDLER}login.php',
- 'validatorClass' => '{e_HANDLER}validator_class.php',
- 'xmlClass' => '{e_HANDLER}xml_class.php',
- );
- /**
- * Overload core handlers array
- * Format: 'core_class' => array('overload_class', 'overload_path');
- *
- * NOTE: to overload core singleton objects, you have to add record to
- * $_overload_handlers before the first singleton call.
- *
- * Example:
- * <code> array('e_form' => array('plugin_myplugin_form_handler' => '{e_PLUGIN}myplugin/includes/form/handler.php'));</code>
- *
- * Used to auto-load core handlers
- *
- * @var array
- */
- protected static $_overload_handlers = array();
- /**
- * Constructor
- *
- * Use {@link getInstance()}, direct instantiating
- * is not possible for singleton objects
- *
- * @return void
- */
- protected function __construct()
- {
- // FIXME registered shutdown functions not executed after the $page output in footer - investigate
- // Currently manually called in front-end/admin footer
- //register_shutdown_function(array($this, 'destruct'));
- }
- /**
- * Cloning is not allowed
- *
- */
- private function __clone()
- {
- }
- /**
- * Get singleton instance (php4 no more supported)
- *
- * @return e107
- */
- public static function getInstance()
- {
- if(null == self::$_instance)
- {
- self::$_instance = new self();
- }
- return self::$_instance;
- }
- /**
- * Initialize environment path constants
- * Public proxy to the protected method {@link _init()}
- *
- * @return e107
- */
- public function initCore($e107_paths, $e107_root_path, $e107_config_mysql_info, $e107_config_override = array())
- {
- return $this->_init($e107_paths, $e107_root_path, $e107_config_mysql_info, $e107_config_override);
- }
- /**
- * Initialize environment path constants while installing e107
- *
- * @return e107
- */
- public function initInstall($e107_paths, $e107_root_path, $e107_config_override = array())
- {
- $e107_config = 'e107_config.php';
- if (!file_exists($e107_config)) // prevent blank-page with missing file during install.
- {
- if(file_put_contents($e107_config, '')===false)
- {
- return false;
- }
- }
-
- // Do some security checks/cleanup, prepare the environment
- $this->prepare_request();
-
- //generated from mysql data at stage 5 of install.
- $this->site_path = isset($e107_config_override['site_path']) ? $e107_config_override['site_path'] : "[hash]"; // placeholder
-
- // folder info
- //$this->e107_dirs = $e107_paths;
- $this->setDirs($e107_paths, $e107_config_override);
-
- // build all paths
- $this->set_paths();
- $this->file_path = $this->fix_windows_paths($e107_root_path)."/";
- // set base path, SSL is auto-detected
- $this->set_base_path();
- // cleanup QUERY_STRING and friends, set related constants
- $this->set_request();
- // set some core URLs (e_LOGIN/SIGNUP)
- $this->set_urls();
-
- return $this;
- }
- /**
- * Resolve paths, will run only once
- *
- * @return e107
- */
- protected function _init($e107_paths, $e107_root_path, $e107_config_mysql_info, $e107_config_override = array())
- {
- if(empty($this->e107_dirs))
- {
- // Do some security checks/cleanup, prepare the environment
- $this->prepare_request();
-
- // mysql connection info
- $this->e107_config_mysql_info = $e107_config_mysql_info;
-
- // unique folder for e_MEDIA - support for multiple websites from single-install. Must be set before setDirs()
- $this->site_path = $this->makeSiteHash($e107_config_mysql_info['mySQLdefaultdb'], $e107_config_mysql_info['mySQLprefix']);
-
- // Set default folder (and override paths) if missing from e107_config.php
- $this->setDirs($e107_paths, $e107_config_override);
-
- // various constants - MAGIC_QUOTES_GPC, MPREFIX, ...
- $this->set_constants();
- // build all paths
- $this->set_paths();
- $this->file_path = $this->fix_windows_paths($e107_root_path)."/";
- // set base path, SSL is auto-detected
- $this->set_base_path();
- // cleanup QUERY_STRING and friends, set related constants
- $this->set_request();
- // set some core URLs (e_LOGIN/SIGNUP)
- $this->set_urls();
- }
-
- return $this;
- }
- // Create a unique hash for each database configuration (multi-site support)
- function makeSiteHash($db,$prefix) // also used by install.
- {
- return substr(md5($db.".".$prefix),0,10);
-
- }
- /**
- * Set system folders and override paths
- * $e107_paths is the 'compact' version of e107_config folder vars ($ADMIN_DIRECTORY, $IMAGES_DIRECTORY, etc)
- * $e107_config_override is the new override method - it can do it for all server and http paths via
- * the newly introduced $E107_CONFIG array.
- *
- * Overriding just replace _DIRECTORY with _SERVER or _HTTP:
- * - override server path example:
- * <code>$E107_CONFIG['SYSTEM_SERVER'] = '/home/user/system/';</code>
- *
- * - override http path example:
- * <code>$E107_CONFIG['MEDIA_VIDEOS_HTTP'] = 'http://static.mydomain.com/videos/';</code>
- *
- * @param array $e107_dirs Override folder instructions (*_DIRECTORY vars - e107_config.php)
- * @param array $e107_config_override Override path insructions ($E107_CONFIG array - e107_config.php)
- * @return e107
- */
- public function setDirs($e107_dirs, $e107_config_override = array())
- {
- $override = array_merge((array) $e107_dirs, (array) $e107_config_override);
- // override all
- $this->e107_dirs = array_merge($this->defaultDirs($override), $override);
-
- // TODO add e_MEDIA_BASE, e_SYSTEM_BASE (free of site path constants);
-
- if(strpos($this->e107_dirs['MEDIA_DIRECTORY'],$this->site_path) === false)
- {
- $this->e107_dirs['MEDIA_DIRECTORY'] .= $this->site_path."/"; // multisite support.
- }
-
- if(strpos($this->e107_dirs['SYSTEM_DIRECTORY'],$this->site_path) === false)
- {
- $this->e107_dirs['SYSTEM_DIRECTORY'] .= $this->site_path."/"; // multisite support.
- }
- // FIXME Quick fix - override base cache folder for legacy configs (e.g. e107_files/cache), discuss
- if(strpos($this->e107_dirs['CACHE_DIRECTORY'], $this->site_path) === false)
- {
- $this->e107_dirs['CACHE_DIRECTORY'] = $this->e107_dirs['SYSTEM_DIRECTORY']."cache/"; // multisite support.
- }
-
- return $this;
- }
- /**
- * Get default e107 folders, root folders can be overridden by passed override array
- *
- * @param array $override_root
- * @param boolean $return_root
- * @return array
- */
- public function defaultDirs($override_root = array(), $return_root = false)
- {
- $ret = array_merge(array(
- 'ADMIN_DIRECTORY' => 'e107_admin/',
- 'IMAGES_DIRECTORY' => 'e107_images/',
- 'THEMES_DIRECTORY' => 'e107_themes/',
- 'PLUGINS_DIRECTORY' => 'e107_plugins/',
- 'FILES_DIRECTORY' => 'e107_files/', // DEPRECATED!!!
- 'HANDLERS_DIRECTORY' => 'e107_handlers/',
- 'LANGUAGES_DIRECTORY' => 'e107_languages/',
- 'DOCS_DIRECTORY' => 'e107_docs/',
- 'MEDIA_DIRECTORY' => 'e107_media/',
- 'SYSTEM_DIRECTORY' => 'e107_system/',
- 'CORE_DIRECTORY' => 'e107_core/',
- 'WEB_DIRECTORY' => 'e107_web/',
- ), (array) $override_root);
-
- $ret['MEDIA_DIRECTORY'] .= $this->site_path."/"; // multisite support.
- $ret['SYSTEM_DIRECTORY'] .= $this->site_path."/"; // multisite support.
-
- if($return_root) return $ret;
-
- $ret['HELP_DIRECTORY'] = $ret['DOCS_DIRECTORY'].'help/';
- $ret['MEDIA_IMAGES_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'images/';
- $ret['MEDIA_ICONS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'icons/';
-
- $ret['MEDIA_VIDEOS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'videos/';
- $ret['MEDIA_FILES_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'files/';
- $ret['MEDIA_UPLOAD_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'temp/'; // security measure. Media is public, system is private.
- $ret['AVATARS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'avatars/';
- $ret['WEB_JS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'js/';
- // $ret['WEB_JS_DIRECTORY'] = $ret['FILES_DIRECTORY'].'jslib/';
-
-
- $ret['WEB_CSS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'css/';
- $ret['WEB_IMAGES_DIRECTORY'] = $ret['WEB_DIRECTORY'].'images/';
- // $ret['WEB_PACKS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'packages/';
- $ret['DOWNLOADS_DIRECTORY'] = $ret['MEDIA_FILES_DIRECTORY'];
- $ret['UPLOADS_DIRECTORY'] = $ret['MEDIA_UPLOAD_DIRECTORY'];
- $ret['CACHE_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'cache/';
- $ret['CACHE_CONTENT_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'content/';
- $ret['CACHE_IMAGE_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'images/';
- $ret['CACHE_DB_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'db/';
- $ret['CACHE_URL_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'url/';
-
- $ret['AVATARS_UPLOAD_DIRECTORY'] = $ret['AVATARS_DIRECTORY'].'upload/';
- $ret['AVATARS_DEFAULT_DIRECTORY'] = $ret['AVATARS_DIRECTORY'].'default/';
- $ret['LOGS_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'logs/';
- $ret['BACKUP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'backup/';
- $ret['TEMP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'temp/';
- $ret['IMPORT_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'import/';
- //TODO create directories which don't exist.
- return $ret;
- }
- /**
- * Set mysql data
- *
- * @return e107
- */
- public function initInstallSql($e107_config_mysql_info)
- {
- // mysql connection info
- $this->e107_config_mysql_info = $e107_config_mysql_info;
- // various constants - MAGIC_QUOTES_GPC, MPREFIX, ...
- $this->set_constants();
- return $this;
- }
- /**
- * Get data from the registry
- * Returns $default if data not found
- * Replacement of cachevar()
- *
- * @param string $id
- * @return mixed
- */
- public static function getRegistry($id, $default = null)
- {
- if(isset(self::$_registry[$id]))
- {
- return self::$_registry[$id];
- }
- return $default;
- }
- /**
- * Add data to the registry - replacement of getcachedvars().
- * $id is path-like unique id bind to the passed data.
- * If $data argument is null, $id will be removed from the registry.
- * When removing objects from the registry, __destruct() method will be auto-executed
- * if available
- *
- * Naming standards (namespaces):
- * 'area/area_id/storage_type'<br>
- * where <br>
- * - area = 'core'|'plugin'|'external' (everything else)
- * - area_id = core handler id|plugin name (depends on area)
- * - (optional) storage_type = current data storage stack
- *
- * Examples:
- * - 'core/e107/' - reserved for this class
- * - 'core/e107/singleton/' - singleton objects repo {@link getSingleton()}
- *
- * @param string $id
- * @param mixed|null $data
- * @return void
- */
- public static function setRegistry($id, $data = null, $allow_override = true)
- {
- if(null === $data)
- {
- if(is_object(self::$_registry[$id]) && method_exists(self::$_registry[$id], '__destruct'))
- {
- self::$_registry[$id]->__destruct();
- }
- unset(self::$_registry[$id]);
- return;
- }
- if(!$allow_override && null !== self::getRegistry($id))
- {
- return;
- }
- self::$_registry[$id] = $data;
- }
- /**
- * Get folder name (e107_config)
- * Replaces all $(*)_DIRECTORY globals
- * Example: <code>$e107->getFolder('images')</code>;
- *
- * @param string $for
- * @return string
- */
- function getFolder($for)
- {
- $key = strtoupper($for).'_DIRECTORY';
- $self = self::getInstance();
- return (isset($self->e107_dirs[$key]) ? $self->e107_dirs[$key] : '');
- }
- /**
- * Get value from $_E107 config array
- * Note: will always return false if called before prepare_request() method!
- *
- * @param string $key
- * @return boolean
- */
- public static function getE107($key = null)
- {
- $self = self::getInstance();
- if(null === $key) return $self->_E107;
- return (isset($self->_E107[$key]) && $self->_E107[$key] ? true : false);
- }
- /**
- * Convenient proxy to $_E107 getter - check if
- * the system is currently running in cli mode
- * Note: will always return false if called before prepare_request() method!
- *
- * @return boolean
- */
- public static function isCli()
- {
- return self::getE107('cli');
- }
- /**
- * Get mysql config var (e107_config.php)
- * Replaces all $mySQL(*) globals
- * Example: <code>$e107->getMySQLConfig('prefix');</code>
- *
- * @param string $for prefix|server|user|password|defaultdb - leave blank for full array.
- * @return string or array
- */
- function getMySQLConfig($for='')
- {
- $key = 'mySQL'.$for;
- $self = self::getInstance();
-
- if($for == '')
- {
- return $self->e107_config_mysql_info;
- }
-
- return (isset($self->e107_config_mysql_info[$key]) ? $self->e107_config_mysql_info[$key] : '');
- }
-
- /**
- * Return a unique path based on database used. ie. multi-site support from single install.
- *
- * @return string
- * @author
- */
- function getSitePath()
- {
- $self = self::getInstance();
- return $self->site_path;
- }
- /**
- * Get known handler path
- *
- * @param string $class_name
- * @param boolean $parse_path [optional] parse path shortcodes
- * @return string|null
- */
- public static function getHandlerPath($class_name, $parse_path = true)
- {
- $ret = isset(self::$_known_handlers[$class_name]) ? self::$_known_handlers[$class_name] : null;
- if($parse_path && $ret)
- {
- $ret = self::getParser()->replaceConstants($ret);
- }
- return $ret;
- }
- /**
- * Add handler to $_known_handlers array on runtime
- * If class name is array, method will add it (recursion) and ignore $path argument
- *
- * @param array|string $class_name
- * @param string $path [optional]
- * @return void
- */
- public static function addHandler($class_name, $path = '')
- {
- if(is_array($class_name))
- {
- foreach ($class_name as $cname => $path)
- {
- self::addHandler($cname, $path);
- }
- return;
- }
- if(!self::isHandler($class_name))
- {
- self::$_known_handlers[$class_name] = $path;
- }
- }
- /**
- * Check handler presence
- *
- * @param string $class_name
- * @return boolean
- */
- public static function isHandler($class_name)
- {
- return isset(self::$_known_handlers[$class_name]);
- }
- /**
- * Get overlod class and path (if any)
- *
- * @param object $class_name
- * @param object $default_handler [optional] return data from $_known_handlers if no overload data available
- * @param object $parse_path [optional] parse path shortcodes
- * @return array
- */
- public static function getHandlerOverload($class_name, $default_handler = true, $parse_path = true)
- {
- $ret = (isset(self::$_overload_handlers[$class_name]) ? self::$_overload_handlers[$class_name] : ($default_handler ? array($class_name, self::getHandlerPath($class_name, false)) : array()));
- if ($parse_path && isset($ret[1]))
- {
- $ret[1] = self::getParser()->replaceConstants($ret[1]);
- }
- return $ret;
- }
- /**
- * Overload present handler.
- * If class name is array, method will add it (recursion) and
- * ignore $overload_class_name and $overload_path arguments
- *
- * @param string $class_name
- * @param string $overload_name [optional]
- * @param string $overload_path [optional]
- * @return void
- */
- public static function setHandlerOverload($class_name, $overload_class_name = '', $overload_path = '')
- {
- if(is_array($class_name))
- {
- foreach ($class_name as $cname => $overload_array)
- {
- self::setHandlerOverload($cname, $overload_array[0], $overload_array[1]);
- }
- return;
- }
- if(self::isHandler($class_name) && !self::isHandlerOverloadable($class_name))
- {
- self::$_overload_handlers[$class_name] = array($overload_class_name, $overload_path);
- }
- }
- /**
- * Check if handler is already overloaded
- *
- * @param string $class_name
- * @return boolean
- */
- public static function isHandlerOverloadable($class_name)
- {
- return isset(self::$_overload_handlers[$class_name]);
- }
- /**
- * Retrieve singleton object
- *
- * @param string $class_name
- * @param string|boolean $path optional script path
- * @param string $regpath additional registry path
- * @return Object
- */
- public static function getSingleton($class_name, $path = true, $regpath = '')
- {
- $id = 'core/e107/singleton/'.$class_name.$regpath;
- //singleton object found - overload not possible
- if(self::getRegistry($id))
- {
- return self::getRegistry($id);
- }
- //auto detection + overload check
- if(is_bool($path))
- {
- //overload allowed
- if(true === $path && self::isHandlerOverloadable($class_name))
- {
- $tmp = self::getHandlerOverload($class_name);
- $class_name = $tmp[0];
- $path = $tmp[1];
- }
- //overload not allowed
- else
- {
- $path = self::getHandlerPath($class_name);
- }
- }
- if($path && is_string($path) && !class_exists($class_name, false))
- {
- e107_require_once($path); //no existence/security checks here!
- //e107_require_once() is available without class2.php. - see core_functions.php
- }
- if(class_exists($class_name, false))
- {
- e107::setRegistry($id, new $class_name());
- }
- return self::getRegistry($id);
- }
- /**
- * Retrieve object
- * Prepare for __autoload
- *
- * @param string $class_name
- * @param mxed $arguments
- * @param string|boolean $path optional script path
- * @return object|null
- */
- public static function getObject($class_name, $arguments = null, $path = true)
- {
- if(true === $path)
- {
- if(isset(self::$_known_handlers[$class_name]))
- {
- $path = self::getParser()->replaceConstants(self::$_known_handlers[$class_name]);
- }
- }
- //auto detection + overload check
- if(is_bool($path))
- {
- //overload allowed
- if(true === $path && self::isHandlerOverloadable($class_name))
- {
- $tmp = self::getHandlerOverload($class_name);
- $class_name = $tmp[0];
- $path = $tmp[1];
- }
- //overload not allowed
- else
- {
- $path = self::getHandlerPath($class_name);
- }
- }
- if($path && is_string($path) && !class_exists($class_name, false))
- {
- e107_require_once($path); //no existence/security checks here!
- }
- if(class_exists($class_name, false))
- {
- if(null !== $arguments) return new $class_name($arguments);
- return new $class_name();
- }
- trigger_error("Class {$class_name} not found!", E_USER_ERROR);
- return null;
- }
- /**
- * Retrieve core config handlers.
- * List of allowed $name values (aliases) could be found
- * in {@link e_core_pref} class
- *
- * @param string $name core|core_backup|emote|menu|search|notify
- * @return e_core_pref
- */
- public static function getConfig($name = 'core', $load = true, $refresh=false)
- {
-
- if(isset(self::$_plug_config_arr[$name])) //FIXME Load pluginPref Object instead - Not quite working with calendar_menu.
- {
- return self::getPlugConfig($name);
- }
-
- if(!isset(self::$_core_config_arr[$name]) || ($refresh == true)) // required by update_routines to clear out earlier values.
- {
- e107_require_once(e_HANDLER.'pref_class.php');
- self::$_core_config_arr[$name] = new e_core_pref($name, $load);
-
- if($name == 'core') // prevent loop between pref and cache handlers.
- {
- e107::getCache()->UserCacheActive = self::getPref('cachestatus');
- e107::getCache()->SystemCacheActive = self::getPref('syscachestatus');
- }
- }
- return self::$_core_config_arr[$name];
- }
- /**
- * Retrieve core config handler preference value or the core preference array
- * Shorthand of self::getConfig()->get()
- *
- * @see e_core_pref::get()
- * @param string $pref_name
- * @param mixed $default default value if preference is not found
- * @return mixed
- */
- public static function getPref($pref_name = '', $default = null)
- {
- return empty($pref_name) ? self::getConfig()->getPref() : self::getConfig()->get($pref_name, $default);
- }
- /**
- * Advanced version of self::getPref(). $pref_name is parsed,
- * so that $pref_name = 'x/y/z' will search for value pref_data[x][y][z]
- * Shorthand of self::getConfig()->getPref()
- *
- * @see e_core_pref::getPref()
- * @param string $pref_name
- * @param mixed $default default value if preference is not found
- * @return mixed
- */
- public static function findPref($pref_name, $default = null, $index = null)
- {
- return self::getConfig()->getPref($pref_name, $default, $index);
- }
- /**
- * Retrieve plugin config handlers.
- * Multiple plugin preference DB rows are supported
- * Class overload is supported.
- * Examples:
- * - <code>e107::getPluginConfig('myplug');</code>
- * will search for e107_plugins/myplug/e_pref/myplug_pref.php which
- * should contain class 'e_plugin_myplug_pref' class (child of e_plugin_pref)
- * - <code>e107::getPluginConfig('myplug', 'row2');</code>
- * will search for e107_plugins/myplug/e_pref/myplug_row2_pref.php which
- * should contain class 'e_plugin_myplug_row2_pref' class (child of e_plugin_pref)
- *
- * @param string $plug_name
- * @param string $multi_row
- * @param boolean $load load from DB on startup
- * @return e_plugin_pref
- */
- public static function getPlugConfig($plug_name, $multi_row = '', $load = true)
- {
- if(!isset(self::$_plug_config_arr[$plug_name.$multi_row]))
- {
- e107_require_once(e_HANDLER.'pref_class.php');
- $override_id = $plug_name.($multi_row ? "_{$multi_row}" : '');
- //check (once) for custom plugin pref handler
- if(is_readable(e_PLUGIN.$plug_name.'/e_pref/'.$override_id.'_pref.php'))
- {
- require_once(e_PLUGIN.$plug_name.'/e_pref/'.$override_id.'_pref.php');
- $class_name = 'e_plugin_'.$override_id.'_pref';
- //PHPVER: string parameter for is_subclass_of require PHP 5.0.3+
- if(class_exists($class_name, false) && is_subclass_of('e_plugin_pref', $class_name)) //or e_pref ?
- {
- self::$_plug_config_arr[$plug_name.$multi_row] = new $class_name($load);
- return self::$_plug_config_arr[$plug_name.$multi_row];
- }
- }
- self::$_plug_config_arr[$plug_name.$multi_row] = new e_plugin_pref($plug_name, $multi_row, $load);
- }
- return self::$_plug_config_arr[$plug_name.$multi_row];
- }
- /**
- * Retrieve plugin preference value.
- * Shorthand of self::getPluginConfig()->get()
- * NOTE: Multiple plugin preference DB rows are NOT supported
- * This will only look for your default plugin config (empty $milti_row)
- *
- * @see e_plugin_pref::get()
- * @param string $plug_name
- * @param string $pref_name
- * @param mixed $default default value if preference is not found
- * @return mixed
- */
- public static function getPlugPref($plug_name, $pref_name = '', $default = null)
- {
- return empty($pref_name) ? self::getPlugConfig($plug_name)->getPref() : self::getPlugConfig($plug_name)->get($pref_name, $default);
- }
- /**
- * Advanced version of self::getPlugPref(). $pref_name is parsed,
- * so that $pref_name = 'x/y/z' will search for value pref_data[x][y][z]
- * Shorthand of self::getPluginConfig()->getPref()
- *
- * @see e_core_pref::getPref()
- * @param string $pref_name
- * @param mixed $default default value if preference is not found
- * @return mixed
- */
- public static function findPlugPref($plug_name, $pref_name, $default = null, $index = null)
- {
- return self::getPlugConfig($plug_name)->getPref($pref_name, $default, $index);
- }
- /**
- * Get current theme preference. $pref_name is parsed,
- * so that $pref_name = 'x/y/z' will search for value pref_data[x][y][z]
- * Shorthand of self::getConfig()->getPref('current_theme/sitetheme_pref/pref_name')
- *
- * @see e_core_pref::getPref()
- * @param string $pref_name
- * @param mixed $default default value if preference is not found
- * @return mixed
- */
- public static function getThemePref($pref_name = '', $default = null, $index = null)
- {
- if($pref_name) $pref_name = '/'.$pref_name;
- return e107::getConfig()->getPref('sitetheme_pref'.$pref_name, $default, $index);
- }
-
- /**
- * Set current theme preference. $pref_name is parsed,
- * so that $pref_name = 'x/y/z' will set value pref_data[x][y][z]
- *
- * @param string|array $pref_name
- * @param mixed $pref_value
- * @return e_pref
- */
- public static function setThemePref($pref_name, $pref_value = null)
- {
- if(is_array($pref_name)) return e107::getConfig()->set('sitetheme_pref', $pref_name);
- return e107::getConfig()->updatePref('sitetheme_pref/'.$pref_name, $pref_value, false);
- }
- /**
- * Retrieve text parser singleton object
- *
- * @return e_parse
- */
- public static function getParser()
- {
- return self::getSingleton('e_parse', e_HANDLER.'e_parse_class.php'); //WARNING - don't change this - infinite loop!!!
- }
- /**
- * Retrieve sc parser singleton object
- *
- * @return e_parse_shortcode
- */
- public static function getScParser()
- {
- return self::getSingleton('e_parse_shortcode', true);
- }
-
-
- /**
- * Retrieve secure_image singleton object
- *
- * @return secure_image
- */
- public static function getSecureImg()
- {
- return self::getSingleton('secure_image', true); // more flexible.
- // return self::getObject('secure_image');
- }
- /**
- * Retrieve registered sc object (batch) by class name
- * Note - '_shortcodes' part of the class/override is added by the method
- * Override is possible only if class is not already instantiated by shortcode parser
- *
- * <code><?php
- *
- * // Core news shortcodes (news_shortcodes.php using class news_shortcodes )
- * e107::getScObject('news');
- *
- * // Core page shortcodes (page_shortcodes.php.php with class cpage_shortcode)
- * e107::getScObject('page', null,'cpage');
- *
- * // object of plugin_myplugin_my_shortcodes class -> myplugin/shortcodes/batch/my_shortcodes.php
- * e107::getScObject('my', 'myplugin');
- *
- * // news override - plugin_myplugin_news_shortcodes extends news_shortcodes -> myplugin/shortcodes/batch/news_shortcodes.php
- * e107::getScObject('news', 'myplugin', true);
- *
- * // news override - plugin_myplugin_mynews_shortcodes extends news_shortcodes -> myplugin/shortcodes/batch/mynews_shortcodes.php
- * e107::getScObject('news', 'myplugin', 'mynews');
- * </code>
- *
- * @param string $className
- * @param string $pluginName
- * @param string|true $overrideClass
- * @return e_shortcode
- */
- public static function getScBatch($className, $pluginName = null, $overrideClass = null)
- {
- if(is_string($overrideClass)) $overrideClass .= '_shortcodes';
- return self::getScParser()->getScObject($className.'_shortcodes', $pluginName, $overrideClass);
- }
- /**
- * Retrieve DB singleton object based on the
- * $instance_id
- *
- * @param string $instance_id
- * @return e_db_mysql
- */
- public static function getDb($instance_id = '')
- {
- return self::getSingleton('db', true, $instance_id);
- }
- /**
- * Retrieve cache singleton object
- *
- * @return ecache
- */
- public static function getCache()
- {
- return self::getSingleton('ecache', true);
- }
- /**
- * Retrieve bbcode singleton object
- *
- * @return e_bbcode
- */
- public static function getBB()
- {
- return self::getSingleton('e_bbcode', true);
- }
- /**
- * Retrieve user-session singleton object
- *
- * @return UserHandler
- */
- public static function getUserSession()
- {
- return self::getSingleton('UserHandler', true);
- }
- /**
- * Retrieve core session singleton object(s)
- *
- * @return e_core_session
- */
- public static function getSession($namespace = null)
- {
- $id = 'core/e107/session/'.(null === $namespace ? 'e107' : $namespace);
- if(self::getRegistry($id))
- {
- return self::getRegistry($id);
- }
- $session = self::getObject('e_core_session', array('namespace' => $namespace), true);
- self::setRegistry($id, $session);
- return $session;
- }
- /**
- * Retrieve redirection singleton object
- *
- * @return redirection
- */
- public static function getRedirect()
- {
- return self::getSingleton('redirection', true);
- }
-
-
- /**
- * Retrieve rater singleton object
- *
- * @return rate
- */
- public static function getRate()
- {
- return self::getSingleton('rater', true);
- }
- /**
- * Retrieve sitelinks singleton object
- *
- * @return sitelinks
- */
- public static function getSitelinks()
- {
- return self::getSingleton('sitelinks', true);
- }
- /**
- * Retrieve render singleton object
- *
- * @return e107table
- */
- public static function getRender()
- {
- return self::getSingleton('e107table');
- }
- /**
- * Retrieve e107Email singleton object
- *
- * @return e107Email
- */
- public static function getEmail()
- {
- return self::getSingleton('e107Email', true);
- }
- /**
- * Retrieve event singleton object
- *
- * @return e107_event
- */
- public static function getEvent()
- {
- return self::getSingleton('e107_event', true);
- }
- /**
- * Retrieve array storage singleton object
- *
- * @return e_array
- */
- public static function getArrayStorage()
- {
- return self::getSingleton('e_array', true);
- }
- /**
- * Retrieve menu handler singleton object
- *
- * @return e_menu
- */
- public static function getMenu()
- {
- return self::getSingleton('e_menu', true);
- }
- /**
- * Retrieve URL singleton object
- *
- * @return eURL
- */
- public static function getUrl()
- {
- return self::getSingleton('eUrl', true);
- }
- /**
- * Retrieve file handler singleton or new fresh object
- *
- * @param boolean $singleton default true
- * @return e_file
- */
- public static function getFile($singleton = false)
- {
- if($singleton)
- {
- return self::getSingleton('e_file', true);
- }
- return self::getObject('e_file', null, true);
- }
- /**
- * Retrieve form handler singleton or new fresh object
- *
- * @param boolean $singleton default false
- * @param boolean $tabindex passed to e_form when initialized as an object (not singleton)
- * @return e_form
- */
- public static function getForm($singleton = false, $tabindex = false)
- {
- if($singleton)
- {
- return self::getSingleton('e_form', true);
- }
- return self::getObject('e_form', $tabindex, true);
- }
- /**
- * Retrieve admin log singleton object
- *
- * @return e_admin_log
- */
- public static function getAdminLog()
- {
- return self::getSingleton('e_admin_log', true);
- }
- /**
- * Retrieve date handler singleton object
- *
- * @return convert
- */
- public static function getDateConvert()
- {
- return self::getSingleton('convert', true);
- }
-
- /**
- * Retrieve date handler singleton object - preferred method.
- *
- * @return convert
- */
- public static function getDate()
- {
- return self::getSingleton('convert', true);
- }
- /**
- * Retrieve date handler singleton object - preferred method.
- *
- * @return convert
- */
- public static function getDebug() //XXX Discuss - possible with current setup?
- {
- return self::getSingleton('e107_db_debug', true);
- }
- /**
- * Retrieve notify handler singleton object
- *
- * @return notify
- */
- public static function getNotify()
- {
- return self::getSingleton('notify', true);
- }
- /**
- * Retrieve override handler singleton object
- *
- * @return notify
- */
- public static function getOverride()
- {
- return self::getSingleton('override', true);
- }
- /**
- * Retrieve Language handler singleton object
- *
- * @return language
- */
- public static function getLanguage()
- {
- return self::getSingleton('language', true);
- }
- /**
- * Retrieve IP/ban handler singleton object
- *
- * @return eIPHandler
- */
- public static function getIPHandler()
- {
- return self::getSingleton('eIPHandler', true);
- }
- /**
- * Retrieve Xml handler singleton or new instance object
- * @param mixed $singleton false - new instance, true - singleton from default registry location, 'string' - registry path
- * @return xmlClass
- */
- public static function getXml($singleton = true)
- {
- if($singleton)
- {
- return self::getSingleton('xmlClass', true, (true === $singleton ? '' : $singleton));
- }
- return self::getObject('xmlClass', null, true);
- }
-
- /**
- * Retrieve HybridAuth object
- *
- * @return Hybrid_Auth
- */
- public static function getHybridAuth($config = null)
- {
- if(null === $config)
- {
- $config = array(
- 'base_url' => e107::getUrl()->create('system/xup/endpoint', array(), array('full' => true)),
- 'providers' => e107::getPref('social_login', array()),
- 'debug_mode' => false,
- 'debug_file' => ''
- );
- }
- return new Hybrid_Auth($config);
- }
- /**
- * Retrieve userclass singleton object
- *
- * @return user_class
- */
- public static function getUserClass()
- {
- return self::getSingleton('user_class', true);
- }
- /**
- * Retrieve user model object.
- *
- * @param integer $user_id target user
- * @param boolean $checkIfCurrent if tru user_id will be compared to current user, if there is a match
- * current user object will be returned
- * @return e_system_user
- */
- public static function getSystemUser($user_id, $checkIfCurrent = true)
- {
- if($checkIfCurrent && $user_id && $user_id === self::getUser()->getId())
- {
- return self::getUser();
- }
-
- if(!$user_id) return self::getObject('e_system_user');
-
- $user = self::getRegistry('core/e107/user/'.$user_id);
- if(null === $user)
- {
- $user = self::getObject('e_system_user');
- if($user_id) $user->load($user_id); // self registered on load
- }
- return $user;
- }
- /**
- * Simple replacement for deprecated get_user_data(). e107::user();
- * @param $uid integer user_id or leave empty for currently logged in user.
- * @return array of user data
- */
- public static function user($uid=null)
- {
- if(!$uid){ return false; }
-
- $user = self::getSystemUser($uid, true);
- $var = array();
- if($user)
- {
- $var = $user->getUserData();
- }
-
- return $var;
- }
- /**
- * Return a string containg exported array data. - preferred.
- *
- * @param array $ArrayData array to be stored
- * @param bool $AddSlashes default false, add slashes for db storage, else false
- * @return string
- */
- public static function serialize($ArrayData, $AddSlashes = false)
- {
- return self::getArrayStorage()->serialize($ArrayData, $AddSlashes);
- }
-
- /**
- * Returns an array from stored array data.
- *
- * @param string $ArrayData
- * @return array stored data
- */
- public static function unserialize($ArrayData)
- {
- return self::getArrayStorage()->unserialize($ArrayData);
- }
- /**
- * Retrieve current user model object.
- *
- * @return e_user
- */
- public static function getUser()
- {
- $user = self::getRegistry('core/e107/current_user');
- if(null === $user)
- {
- $user = self::getObject('e_user');
- self::setRegistry('core/e107/current_user', $user);
- }
- return $user;
- }
- /**
- * Retrieve user model object.
- *
- * @param integer $user_id target user
- * @return e_current_user
- */
- public static function getUserStructure()
- {
- return self::getSingleton('e_user_extended_structure_tree', true);
- }
- /**
- * Retrieve User Extended handler singleton object
- * @return e107_user_extended
- */
- public static function getUserExt()
- {
- return self::getSingleton('e107_user_extended', true);
- }
- /**
- * Retrieve User Perms (admin perms) handler singleton object
- * @return e_userperms
- */
- public static function getUserPerms()
- {
- return self::getSingleton('e_userperms', true);
- }
- /**
- * Retrieve online users handler singleton object
- * @return e_ranks
- */
- public static function getRank()
- {
- return self::getSingleton('e_ranks', true);
- }
-
- /**
- * Retrieve plugin handler singleton object
- * @return e107plugin
- */
- public static function getPlugin()
- {
- return self::getSingleton('e107plugin', true);
- }
- /**
- * Retrieve online users handler singleton object
- * @return e_online
- */
- public static function getOnline()
- {
- return self::getSingleton('e_online', true);
- }
- /**
- * Retrieve chart handler singleton object
- * @return e_chart
- */
- public static function getChart()
- {
- return self::getSingleton('e_chart', true);
- }
- /**
- * Retrieve comments handler singleton object
- * @return comment
- */
- public static function getComment()
- {
- return self::getSingleton('comment', true);
- }
- /**
- * Retrieve Media handler singleton object
- * @return e_media
- */
- public static function getMedia()
- {
- return self::getSingleton('e_media', true);
- }
-
- /**
- * Retrieve Navigation Menu handler singleton object
- * @return e_navigation
- */
- public static function getNav()
- {
- return self::getSingleton('e_navigation', true);
- }
- /**
- * Retrieve message handler singleton
- * @return eMessage
- */
- public static function getMessage()
- {
- // static $included = false;
- // if(!$included)
- // {
- // e107_require_once(e_HANDLER.'message_handler.php');
- // $included = true;
- // }
- // return eMessage::getInstance();
- return self::getSingleton('eMessage', true);
- }
- /**
- * Retrieve JS Manager singleton object
- *
- * @return e_jsmanager
- */
- public static function getJs()
- {
- static $included = false;
- if(!$included)
- {
- e107_require_once(e_HANDLER.'js_manager.php');
- $included = true;
- }
- return e_jsmanager::getInstance();
- }
-
- /**
- * JS Common Public Function. Prefered is shortcode script path
- * @param string $type core|theme|footer|inline|footer-inline|url or any existing plugin_name
- * @param string $data depends on the type - path/url or inline js source
- * @param integer $zone [optional] leave it null for default zone
- * @param string $dep dependence : null | prototype | jquery
- */
- public static function js($type, $data, $dep = null, $zone = null, $pre = '', $post = '')
- {
- $jshandler = e107::getJs();
- $jshandler->setDependency($dep);
-
- switch ($type)
- {
- case 'core':
- // data is e.g. 'core/tabs.js'
- if(null !== $zone) $jshandler->requireCoreLib($data, $zone);
- else $jshandler->requireCoreLib($data);
- break;
- case 'bootstrap': //TODO Eventually add own method and render for bootstrap.
- if(null !== $zone) $jshandler->requireCoreLib('bootstrap/js/'.$data, $zone);
- else $jshandler->requireCoreLib('bootstrap/js/'.$data);
- break;
-
- case 'theme':
- // data is e.g. 'jslib/mytheme.js'
- if(null !== $zone) $jshandler->headerTheme($data, $zone, $pre, $post);
- else $jshandler->headerTheme($data, 5, $pre, $post);
- break;
-
- case 'inline':
- // data is JS source (without script tags)
- if(null !== $zone) $jshandler->headerInline($data, $zone);
- else $jshandler->headerInline($data);
- break;
-
- case 'footer-inline':
- // data is JS source (without script tags)
- if(null !== $zone) $jshandler->footerInline($data, $zone);
- else $jshandler->footerInline($data);
- break;
-
- case 'url':
- // data is e.g. 'http://cdn.somesite.com/some.js'
- if(null !== $zone) $jshandler->headerFile($data, $zone, $pre, $post);
- else $jshandler->headerFile($data, 5, $pre, $post);
- break;
-
- case 'footer':
- // data is e.g. '{e_PLUGIN}myplugin/jslib/myplug.js'
- if(null !== $zone) $jshandler->footerFile($data, $zone);
- else $jshandler->footerFile($data);
- break;
-
- // $type is plugin name
- default:
- // data is e.g. 'jslib/myplug.js'
- if(!self::isInstalled($type)) return;
- if(null !== $zone) $jshandler->requirePluginLib($type, $data, $zone);
- else $jshandler->requirePluginLib($type, $data);
- break;
- }
- $jshandler->resetDependency();
- }
-
- /**
- * CSS Common Public Function. Prefered is shortcode script path
- * @param string $type core|theme|footer|inline|footer-inline|url or any existing plugin_name
- * @param string $data depends on the type - path/url or inline js source
- * @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
- * @param string $preComment possible comment e.g. <!--[if lt IE 7]>
- * @param string $postComment possible comment e.g. <![endif]-->
- */
- public static function css($type, $data, $dep = null, $media = 'all', $preComment = '', $postComment = '', $dependence = null)
- {
- if((strstr($data,'bootstrap.css') || strstr($data,'bootstrap.min.css')) && !defined("BOOTSTRAP")) // detect bootstrap is enabled. - used in nextprev.sc and forum currently.
- {
- define("BOOTSTRAP", true);
- }
-
- $jshandler = e107::getJs();
- $jshandler->setDependency($dep);
-
- switch ($type)
- {
- case 'core':
- // data is path relative to e_FILE/jslib/
- $jshandler->coreCSS($data, $media, $preComment, $postComment);
- break;
-
- case 'bootstrap':
- // data is path relative to e_FILE/jslib/
- $jshandler->coreCSS('bootstrap/css/'.$data, $media, $preComment, $postComment);
- break;
-
- case 'theme':
- // data is path relative to current theme
- $jshandler->themeCSS($data, $media, $preComment, $postComment);
- break;
-
- case 'inline':
- // data is CSS source (without style tags)
- $jshandler->inlineCSS($data, $media);
- break;
-
- case 'url':
- // data is e.g. 'http://cdn.somesite.com/some.css'
- $jshandler->otherCSS($data, $media, $preComment, $postComment);
- break;
-
- // $type is plugin name
- default:
- // data is e.g. 'css/myplug.css'
- if(self::isInstalled($type)) $jshandler->pluginCSS($type, $data, $media, $preComment, $postComment);
- break;
- }
- $jshandler->resetDependency();
- }
- /**
- * Retrieve JS Helper object
- *
- * @param boolean|string $singleton if true return singleton, if string return singleton object, use string as namespace, default false
- * @return e_jshelper
- */
- public static function getJshelper($singleton = false)
- {
- if($singleton)
- {
- return self::getSingleton('e_jshelper', true, (true === $singleton ? '' : $singleton));
- }
- return self::getObject('e_jshelper', null, true);
- }
-
- /**
- * @see eResponse::addMeta()
- * @return eResponse
- */
- public static function meta($name = null, $content = null, $extended = array())
- {
- if($name == 'description')
- {
- e107::getUrl()->response()->addMetaDescription($content); //Cam: TBD
- }
-
- if($name == 'keywords')
- {
- e107::getUrl()->response()->addMetaKeywords($content); //Cam: TBD
- }
-
- return e107::getUrl()->response()->addMeta($name, $content, $extended);
- }
- /**
- * Retrieve admin dispatcher instance.
- * It's instance is self registered (for now, this could change in the future) on initialization (__construct())
- *
- * @see e_admin_dispatcher
- * @return e_admin_dispatcher
- */
- public static function getAdminUI()
- {
- return self::getRegistry('admin/ui/dispatcher');
- }
- /**
- * Retrieves class Object for specific plugin's addon such as e_url.php, e_cron.php, e_sitelink.php
- * FIXME override from e.g. core/override/addons/
- *
- * @param string $pluginName e.g. faq, page
- * @param string $addonName eg. e_cron, e_url, e_module
- * @param mixed $className [optional] true - use default name, false - no object is returned (include only), any string will be used as class name
- * @return none
- */
- public static function getAddon($pluginName, $addonName, $className = true)
- {
- $filename = $addonName; // e.g. 'e_cron';
-
- // fixme, temporary adding 's' to className, should be core fixed, better naming
- if(true === $className) $className = $pluginName.'_'.substr($addonName, 2); // remove 'e_'
- $elist = self::getPref($filename.'_list');
- if(!isset($elist[$pluginName])) return null;
-
- // TODO override check comes here
- $path = e_PLUGIN.$pluginName.'/'.$filename.'.php';
- // e.g. include e_module, e_meta etc
- if(false === $className) return include_once($path);
- if(!class_exists($className, false))
- {
- include_once($path);
- }
-
- if(!class_exists($className, false))
- {
- return null;
- }
- return new $className;
- }
- /**
- * Retrieves config() from all plugins for addons such as e_url.php, e_cron.php, e_sitelink.php
- * @param string $addonName eg. e_cron, e_url
- * @param string $className [optional] (if different from addonName)
- * @return none
- */
- public function getAddonConfig($addonName, $className = '')
- {
- $new_addon = array();
- $sql = e107::getDb(); // Might be used by older plugins.
- $filename = $addonName; // e.g. 'e_cron';
- if(!$className)
- {
- $className = substr($filename, 2); // remove 'e_'
- }
- $elist = self::getPref($filename.'_list');
-
- if($e…
Large files files are truncated, but you can click here to view the full file