mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
JS Manager - headerCore/Plugin/Theme shorthands, add/removeLibPref methods for handling core prefs
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
* News Administration
|
* News Administration
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
||||||
* $Revision: 1.55 $
|
* $Revision: 1.56 $
|
||||||
* $Date: 2009-09-25 20:20:23 $
|
* $Date: 2009-10-07 11:05:55 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
require_once("../class2.php");
|
require_once("../class2.php");
|
||||||
@@ -254,7 +254,7 @@ class admin_newspost
|
|||||||
require_once(e_HANDLER."calendar/calendar_class.php");
|
require_once(e_HANDLER."calendar/calendar_class.php");
|
||||||
$this->_cal = new DHTML_Calendar(true);
|
$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'));
|
$this->fieldpref = varset($user_pref['admin_news_columns'], array('news_id', 'news_title', 'news_author', 'news_render_type', 'options'));
|
||||||
|
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
* Javascript files consolidation script (gzip compression)
|
* Javascript files consolidation script (gzip compression)
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_files/e_jslib.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_files/e_jslib.php,v $
|
||||||
* $Revision: 1.5 $
|
* $Revision: 1.6 $
|
||||||
* $Date: 2009-10-02 13:46:26 $
|
* $Date: 2009-10-07 11:05:55 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -39,7 +39,7 @@ else
|
|||||||
require_once ("../class2.php");
|
require_once ("../class2.php");
|
||||||
require_once (e_HANDLER.'jslib_handler.php');
|
require_once (e_HANDLER.'jslib_handler.php');
|
||||||
$jslib = new e_jslib();
|
$jslib = new e_jslib();
|
||||||
$jslib->core_run();
|
$jslib->getContent();
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
* GNU General Public License (http://gnu.org).
|
* GNU General Public License (http://gnu.org).
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2009-10-02 13:46:25 $
|
* $Date: 2009-10-07 11:05:55 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -175,7 +175,7 @@ class e_jsmanager
|
|||||||
{
|
{
|
||||||
$theme_libs = array();
|
$theme_libs = array();
|
||||||
}
|
}
|
||||||
$this->themeLib($lib_paths);
|
$this->themeLib($theme_libs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,6 +285,46 @@ class e_jsmanager
|
|||||||
return $this;
|
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
|
* Add JS file(s) for inclusion in site header if possible, else
|
||||||
* use {@link footerFile()}
|
* use {@link footerFile()}
|
||||||
@@ -507,10 +547,11 @@ class e_jsmanager
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'plugin': //e_jslib
|
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($paths, $external, $plugname.' libraries'));
|
||||||
}
|
}*/
|
||||||
|
$this->setLastModfied($mod, $this->renderFile($this->_e_jslib_plugin, $external, $plugname.' libraries'));
|
||||||
$this->_e_jslib_plugin = array();
|
$this->_e_jslib_plugin = array();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -744,4 +785,99 @@ class e_jsmanager
|
|||||||
{
|
{
|
||||||
return (isset($this->_lastModified[$what]) ? $this->_lastModified[$what] : 0);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
* GNU General Public License (http://gnu.org).
|
* GNU General Public License (http://gnu.org).
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/jslib_handler.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/jslib_handler.php,v $
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.8 $
|
||||||
* $Date: 2009-10-02 13:46:25 $
|
* $Date: 2009-10-07 11:05:55 $
|
||||||
* $Author: secretr $
|
* $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
|
* FIXME
|
||||||
* - cache jslib in a pref on plugin/theme install only (plugin.xml, theme.xml)
|
* - cache jslib in a pref on plugin/theme install only (plugin.xml, theme.xml)
|
||||||
* - [done - e_jslib_*] the structure of the cached pref array?
|
* - [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?
|
* - 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
|
* - [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;
|
//global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user