diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 3eebbc1a9..5a334292a 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -9,8 +9,8 @@ * News Administration * * $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ - * $Revision: 1.55 $ - * $Date: 2009-09-25 20:20:23 $ + * $Revision: 1.56 $ + * $Date: 2009-10-07 11:05:55 $ * $Author: secretr $ */ require_once("../class2.php"); @@ -254,7 +254,7 @@ class admin_newspost require_once(e_HANDLER."calendar/calendar_class.php"); $this->_cal = new DHTML_Calendar(true); - $this->_pst = &$pstobj; + $this->_pst = $pstobj; $this->fieldpref = varset($user_pref['admin_news_columns'], array('news_id', 'news_title', 'news_author', 'news_render_type', 'options')); diff --git a/e107_files/e_jslib.php b/e107_files/e_jslib.php index da9da2aa9..b89882fa5 100644 --- a/e107_files/e_jslib.php +++ b/e107_files/e_jslib.php @@ -9,8 +9,8 @@ * Javascript files consolidation script (gzip compression) * * $Source: /cvs_backup/e107_0.8/e107_files/e_jslib.php,v $ - * $Revision: 1.5 $ - * $Date: 2009-10-02 13:46:26 $ + * $Revision: 1.6 $ + * $Date: 2009-10-07 11:05:55 $ * $Author: secretr $ * */ @@ -39,7 +39,7 @@ else require_once ("../class2.php"); require_once (e_HANDLER.'jslib_handler.php'); $jslib = new e_jslib(); -$jslib->core_run(); +$jslib->getContent(); exit; diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index 7e6d2cabc..7d49d943b 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -7,8 +7,8 @@ * GNU General Public License (http://gnu.org). * * $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $ - * $Revision: 1.4 $ - * $Date: 2009-10-02 13:46:25 $ + * $Revision: 1.5 $ + * $Date: 2009-10-07 11:05:55 $ * $Author: secretr $ * */ @@ -175,7 +175,7 @@ class e_jsmanager { $theme_libs = array(); } - $this->themeLib($lib_paths); + $this->themeLib($theme_libs); } /** @@ -285,6 +285,46 @@ class e_jsmanager return $this; } + /** + * Add Core JS file for inclusion in site header, shorthand of headerFile() method + * + * @param string $file_path relative to {e_FILE}jslib/ folder + * @param integer $zone 1-5 (see header.php) + * @return e_jsmanager + */ + public function headerCore($file_path, $zone = 1) + { + $this->headerFile('{e_FILE}jslib/'.trim($file_path, '/'), $zone); + return $this; + } + + /** + * Add Theme JS file for inclusion in site header, shorthand of headerFile() method + * + * @param string $file_path relative to theme root folder + * @param integer $zone 1-5 (see header.php) + * @return e_jsmanager + */ + public function headerTheme($file_path, $zone = 5) + { + $this->headerFile(THEME.trim($file_path, '/'), $zone); + return $this; + } + + /** + * Add Plugin JS file for inclusion in site header, shorthand of headerFile() method + * + * @param string $plugname + * @param string $file_path relative to plugin root folder + * @param integer $zone 1-5 (see header.php) + * @return e_jsmanager + */ + public function headerPlugin($plugname, $file_path, $zone = 3) + { + $this->headerFile('{e_PLUGIN}'.$plugname.'/'.trim($file_path, '/'), $zone); + return $this; + } + /** * Add JS file(s) for inclusion in site header if possible, else * use {@link footerFile()} @@ -507,10 +547,11 @@ class e_jsmanager break; case 'plugin': //e_jslib - foreach($this->_e_jslib_plugin as $plugname => $paths) + /*foreach($this->_e_jslib_plugin as $plugname => $paths) { $this->setLastModfied($mod, $this->renderFile($paths, $external, $plugname.' libraries')); - } + }*/ + $this->setLastModfied($mod, $this->renderFile($this->_e_jslib_plugin, $external, $plugname.' libraries')); $this->_e_jslib_plugin = array(); break; @@ -744,4 +785,99 @@ class e_jsmanager { return (isset($this->_lastModified[$what]) ? $this->_lastModified[$what] : 0); } + + public function addLibPref($mod, $array_newlib) + { + + if(!$array_newlib || !is_array($array_newlib)) + { + return $this; + } + $core = e107::getConfig(); + $plugname = ''; + if(strpos($mod, 'plugin:') === 0) + { + $plugname = str_replace('plugin:', '', $mod); + $mod = 'plugin'; + } + + switch($mod) + { + case 'core': + case 'theme': + $key = 'e_jslib_'.$mod; + break; + + case 'plugin': + $key = 'e_jslib_plugin/'.$plugname; + break; + + default: + return $this; + break; + } + + + $libs = $core->getPref($key); + if(!$libs) $libs = array(); + foreach ($array_newlib as $path => $location) + { + $path = trim($path, '/'); + + if(!$path) continue; + + $newlocation = $location == 'all' || (varset($libs[$path]) && $libs[$path] != $location) ? 'all' : $location; + $libs[$path] = $newlocation; + } + + $core->setPref($key, $libs); + return $this; + } + + public function removeLibPref($mod, $array_removelib) + { + + if(!$array_removelib || !is_array($array_removelib)) + { + return $this; + } + $core = e107::getConfig(); + $plugname = ''; + if(strpos($mod, 'plugin:') === 0) + { + $plugname = str_replace('plugin:', '', $mod); + $mod = 'plugin'; + } + + switch($mod) + { + case 'core': + case 'theme': + $key = 'e_jslib_'.$mod; + break; + + case 'plugin': + $key = 'e_jslib_plugin/'.$plugname; + break; + + default: + return $this; + break; + } + + + $libs = $core->getPref($key); + if(!$libs) $libs = array(); + foreach ($array_removelib as $path => $location) + { + $path = trim($path, '/'); + if(!$path) continue; + + unset($libs[$path]); + } + + $core->setPref($key, $libs); + return $this; + } + } diff --git a/e107_handlers/jslib_handler.php b/e107_handlers/jslib_handler.php index 20e4fcfa5..cf33a1f32 100644 --- a/e107_handlers/jslib_handler.php +++ b/e107_handlers/jslib_handler.php @@ -7,8 +7,8 @@ * GNU General Public License (http://gnu.org). * * $Source: /cvs_backup/e107_0.8/e107_handlers/jslib_handler.php,v $ - * $Revision: 1.7 $ - * $Date: 2009-10-02 13:46:25 $ + * $Revision: 1.8 $ + * $Date: 2009-10-07 11:05:55 $ * $Author: secretr $ * */ @@ -23,7 +23,7 @@ class e_jslib } /** - * Collect & output all available JS libraries (requires e107 API) + * Collect & output content of all available JS libraries (requires e107 API) * FIXME * - cache jslib in a pref on plugin/theme install only (plugin.xml, theme.xml) * - [done - e_jslib_*] the structure of the cached pref array? @@ -34,7 +34,7 @@ class e_jslib * - how and when to add JS lans for core libraries? * - [done - js manager] separate methods for collecting & storing JS files (to be used in install/update routines) and output the JS content */ - function core_run() + function getContent() { //global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;