diff --git a/e107_files/default_install.xml b/e107_files/default_install.xml
index 8b609795b..9f6fcc6db 100644
--- a/e107_files/default_install.xml
+++ b/e107_files/default_install.xml
@@ -55,6 +55,13 @@
0
0
0
+ 'all',
+ 'scriptaculous/scriptaculous.js' => 'all',
+ 'scriptaculous/effects.js' => 'all',
+ 'e107.js.php' => 'all',
+)]]>
+
0
default
diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index 4ef9dfdc3..16025055f 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -9,8 +9,8 @@
* Text processing and parsing functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
-* $Revision: 1.62 $
-* $Date: 2009-09-12 18:20:23 $
+* $Revision: 1.63 $
+* $Date: 2009-09-28 19:17:58 $
* $Author: secretr $
*
*/
@@ -1293,34 +1293,79 @@ class e_parse
return $matches[1];
}
+ /**
+ * Create and substitute e107 constants in passed URL
+ *
+ * @param string $url
+ * @param string $mode 0-folders, 1-relative, 2-absolute, 3-full (with domain), 4-absolute & relative (combination of 1,2,3)
+ * @return
+ */
function createConstants($url, $mode=0)
{
//FIXME - create constants for absolute paths and site URL's
- if($mode == 0) // folder name only.
+ $e107 = e107::getInstance();
+ switch($mode)
{
- $e107 = e107::getInstance();
- $tmp = array(
- '{e_IMAGE}' => $e107->getFolder('images'),
- '{e_PLUGIN}' => $e107->getFolder('plugins'),
- '{e_FILE}' => $e107->getFolder('files'),
- '{e_THEME}' => $e107->getFolder('themes'),
- '{e_DOWNLOAD}' => $e107->getFolder('downloads'),
- '{e_ADMIN}' => $e107->getFolder('admin'),
- '{e_HANDLER}' => $e107->getFolder('handlers')
- );
- }
- elseif($mode == 1) // relative path
- {
- $tmp = array(
- '{e_IMAGE}' => e_IMAGE,
- '{e_PLUGIN}' => e_PLUGIN,
- '{e_FILE}' => e_FILE,
- '{e_THEME}' => e_THEME,
- '{e_DOWNLOAD}' => e_DOWNLOAD,
- '{e_ADMIN}' => e_ADMIN,
- '{e_HANDLER}' => e_HANDLER
- );
+ case 0: // folder name only.
+ $tmp = array(
+ '{e_IMAGE}' => $e107->getFolder('images'),
+ '{e_PLUGIN}' => $e107->getFolder('plugins'),
+ '{e_FILE}' => $e107->getFolder('files'),
+ '{e_THEME}' => $e107->getFolder('themes'),
+ '{e_DOWNLOAD}' => $e107->getFolder('downloads'),
+ '{e_ADMIN}' => $e107->getFolder('admin'),
+ '{e_HANDLER}' => $e107->getFolder('handlers')
+ );
+ break;
+
+ case 1: // relative path only
+ $tmp = array(
+ '{e_IMAGE}' => e_IMAGE,
+ '{e_PLUGIN}' => e_PLUGIN,
+ '{e_FILE}' => e_FILE,
+ '{e_THEME}' => e_THEME,
+ '{e_DOWNLOAD}' => e_DOWNLOAD,
+ '{e_ADMIN}' => e_ADMIN,
+ '{e_HANDLER}' => e_HANDLER
+ );
+ break;
+
+ case 2: // absolute path only
+ $tmp = array(
+ '{e_IMAGE}' => e_IMAGE_ABS,
+ '{e_PLUGIN}' => e_PLUGIN_ABS,
+ '{e_FILE}' => e_FILE_ABS,
+ '{e_THEME}' => e_THEME_ABS,
+ '{e_DOWNLOAD}' => e_DOWNLOAD_ABS,
+ '{e_ADMIN}' => e_ADMIN_ABS,
+ '{e_HANDLER}' => e_HANDLER_ABS
+ );
+ break;
+
+ case 3: // full path (e.g http://domain.com/e107_images/)
+ $tmp = array(
+ '{e_IMAGE}' => SITEURL.$e107->getFolder('images'),
+ '{e_PLUGIN}' => SITEURL.$e107->getFolder('plugins'),
+ '{e_FILE}' => SITEURL.$e107->getFolder('files'),
+ '{e_THEME}' => SITEURL.$e107->getFolder('themes'),
+ '{e_DOWNLOAD}' => SITEURL.$e107->getFolder('downloads'),
+ '{e_ADMIN}' => SITEURL.$e107->getFolder('admin'),
+ '{e_HANDLER}' => SITEURL.$e107->getFolder('handlers')
+ );
+ break;
+
+ case 4: // absolute & relative paths
+ $url = $this->replaceConstants($url, 3);
+ $url = $this->replaceConstants($url, 2);
+ $url = $this->replaceConstants($url, 1);
+ return $url;
+ break;
+
+ default:
+ $tmp = array();
+ break;
}
+
foreach($tmp as $key=>$val)
{
$len = strlen($val);
diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php
new file mode 100644
index 000000000..845b8fbfc
--- /dev/null
+++ b/e107_handlers/js_manager.php
@@ -0,0 +1,428 @@
+addJs('core', $file_path, $runtime_location);
+ return $this;
+ }
+
+ /**
+ * Add Core JS library file(s) for inclusion from e_jslib routine
+ *
+ * @param string $plugname
+ * @param string|array $file_path relative to e107_plugins/myplug/jslib/ folder or array in format path - runtime location
+ * @param string $runtime_location admin|front|all - where should be JS used
+ * @return e_js_manager
+ */
+ public function pluginLib($plugname, $file_path, $runtime_location = 'front')
+ {
+ $this->addJs('plugin', array($plugname, $file_path), $runtime_location);
+ return $this;
+ }
+
+ /**
+ * Add JS file(s) for inclusion in site header
+ *
+ * @param string|array $file_path path shortcodes usage is prefered
+ * @param integer $zone 1-5 (see header.php)
+ * @return e_js_manager
+ */
+ public function headerFile($file_path, $zone = 5)
+ {
+ $this->addJs('header', $file_path, $zone);
+ return $this;
+ }
+
+
+ /**
+ * Add JS file(s) for inclusion in site footer
+ *
+ * @param string|array $file_path path shortcodes usage is prefered
+ * @return e_js_manager
+ */
+ public function footerFile($file_path)
+ {
+ $this->addJs('footer', $file_path);
+ return $this;
+ }
+
+ /**
+ * Add JS file(s) for inclusion in site header
+ *
+ * @param string|array $js_content path shortcodes usage is prefered
+ * @param integer $zone 1-5 (see header.php)
+ * @return e_js_manager
+ */
+ public function headerInline($js_content, $zone = 5)
+ {
+ $this->addJs('header_inline', $js_content, $zone);
+ return $this;
+ }
+
+
+ /**
+ * Add JS file(s) for inclusion in site footer
+ *
+ * @param string|array $js_content path shortcodes usage is prefered
+ * @return e_js_manager
+ */
+ public function footerInline($js_content)
+ {
+ $this->addJs('footer_inline', $js_content);
+ return $this;
+ }
+
+ /**
+ * Require JS file(s). Access could be changed to private soon so don't use this
+ * directly. Use corresponding proxy methods instead
+ *
+ * @see requirePluginLib()
+ * @see requireCoreLib()
+ * @param string $type core|plugin - jslib.php, header|footer|header_inline|footer_inline - runtime
+ * @param string|array $file_path
+ * @param string|integer $runtime_location admin|front|all (jslib), 0-5 (runtime inclusion)
+ * @return
+ */
+ public function addJs($type, $file_path, $runtime_location = '')
+ {
+ if(is_array($file_path))
+ {
+ foreach ($file_path as $fp => $loc)
+ {
+ $this->requireLib($type, $fp, $loc);
+ }
+ return $this;
+ }
+
+ $tp = e107::getParser();
+ $runtime = false;
+ switch($type)
+ {
+ case 'core':
+ $file_path = '{e_FILE}jslib/'.trim($file_path, '/');
+ $registry = &$this->_e_jslib_core;
+ break;
+
+ case 'plugin':
+ $file_path = '{e_PLUGIN}jslib/'.$file_path[0].'/'.trim($file_path[1], '/');
+ $registry = &$this->_e_jslib_plugin;
+ break;
+
+ case 'header':
+ $file_path = $tp->createConstants($file_path, 4);
+ $zone = intval($runtime_location);
+ if($zone > 5 || $zone < 1)
+ {
+ $zone = 5;
+ }
+ if(!isset($this->_runtime_header[$zone]))
+ {
+ $this->_runtime_header[$zone] = array();
+ }
+ $registry = &$this->_runtime_header[$zone];
+ $runtime = true;
+ break;
+
+ case 'footer':
+ $file_path = $tp->createConstants($file_path, 4);
+ $registry = &$this->_runtime_footer_src;
+ $runtime = true;
+ break;
+
+ case 'header_inline':
+ $file_path = $tp->createConstants($file_path, 4);
+ $zone = intval($runtime_location);
+ if($zone > 5 || $zone < 1)
+ {
+ $zone = 5;
+ }
+ if(!isset($this->_runtime_header_src[$zone]))
+ {
+ $this->_runtime_header_src[$zone] = array();
+ }
+ $registry = &$this->_runtime_header_src[$zone];
+ $runtime = true;
+ break;
+
+ case 'footer_inline':
+ $file_path = $tp->createConstants($file_path, 4);
+ $registry = &$this->_runtime_footer;
+ $runtime = true;
+ break;
+
+ default:
+ return $this;
+ break;
+ }
+
+ if(in_array($file_path, $this->_js_all) || (!$runtime && $runtime_location != 'all' && $runtime_location != $this->getCurrentLocation()))
+ {
+ return $this;
+ }
+ $this->_js_all[] = $file_path;
+ $registry[] = $file_path;
+
+ return $this;
+ }
+
+ /**
+ * Render registered JS
+ *
+ * @param string $what core|plugin|header|footer|header_inline|footer_inline
+ * @param integer $zone 1-5 - only needed when in 'header' and 'header_inline' render mode
+ * @return
+ */
+ public function renderJs($what, $zone = 5)
+ {
+ switch($what)
+ {
+ case 'core':
+ $this->renderFile($this->_e_jslib_core);
+ $this->_e_jslib_core = array();
+ break;
+
+ case 'plugin':
+ $this->renderFile($this->_e_jslib_plugin);
+ $this->_e_jslib_plugin = array();
+ break;
+
+ case 'header':
+ $this->renderFile(varsettrue($this->_runtime_header[$zone], array()));
+ unset($this->_runtime_header[$zone]);
+ break;
+
+ case 'footer':
+ $this->renderInline($this->_runtime_footer);
+ $this->_runtime_footer = array();
+ break;
+
+ case 'header_inline':
+ $this->renderInline(varsettrue($this->_runtime_header_src[$zone], array()));
+ unset($this->_runtime_header_src[$zone]);
+ break;
+
+ case 'footer_inline':
+ $this->renderInline($this->_runtime_footer_src);
+ $this->_runtime_footer_src = array();
+ break;
+ }
+ }
+
+ /**
+ * Render JS file array
+ * TODO - option to output ';
+ echo "\n\n";
+ }
+
+ /**
+ * Returns true if currently running in
+ * administration area.
+ *
+ * @return boolean
+ */
+ public function isInAdmin()
+ {
+ return $this->_in_admin;
+ }
+
+ /**
+ * Set current script location
+ *
+ * @param object $is true - back-end, false - front-end
+ * @return e_js_manager
+ */
+ public function setInAdmin($is)
+ {
+ $this->_in_admin = (boolean) $is;
+ return $this;
+ }
+
+ /**
+ * Get current location as a string (admin|front)
+ *
+ * @return string
+ */
+ public function getCurrentLocation()
+ {
+ return ($this->isInAdmin() ? 'admin' : 'front');
+ }
+
+
+}
diff --git a/e107_handlers/jslib_handler.php b/e107_handlers/jslib_handler.php
index 12d993c06..9f8b52097 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.4 $
- * $Date: 2008-11-21 16:24:48 $
+ * $Revision: 1.5 $
+ * $Date: 2009-09-28 19:17:58 $
* $Author: secretr $
*
*/
@@ -45,11 +45,11 @@ class e_jslib
header('Content-type: text/javascript', TRUE);
//array - uses the same format as $core_jslib
- if (! varset($THEME_CORE_JSLIB) || ! is_array($THEME_CORE_JSLIB))
+ if (!isset($THEME_CORE_JSLIB) || ! is_array($THEME_CORE_JSLIB))
$THEME_CORE_JSLIB = array();
//array - uses the same format as $core_jslib
- if (! varset($THEME_JSLIB) || ! is_array($THEME_JSLIB))
+ if (!isset($THEME_JSLIB) || ! is_array($THEME_JSLIB))
$THEME_JSLIB = array();
//available values - admin,front,all,none
@@ -61,7 +61,7 @@ class e_jslib
//'jslib/core/decorate.js' => 'all'
);
- $core_jslib = array_merge($core_jslib, $THEME_CORE_JSLIB, varsettrue($pref['e_jslib']['core'], array()));
+ $core_jslib = array_merge($core_jslib, $THEME_CORE_JSLIB, varsettrue($pref['e_jslib_core'], array()));
$where_now = $eplug_admin ? 'admin' : 'front';
//1. Core libs - prototype + scriptaculous effects
diff --git a/index.php b/index.php
index fd4085c07..680a5a058 100644
--- a/index.php
+++ b/index.php
@@ -1,113 +1,102 @@
-$fp)
- {
- if (in_array($fk,$class_list))
+{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
+ foreach ($pref['frontpage'] as $fk=>$fp)
{
- // Debateable whether we should append $query - we may be redirecting to a custom page, for example
- if (strpos($fp,'{') !== FALSE)
+ if (in_array($fk, $class_list))
{
- $location = $tp->replaceConstants($fp).$query;
+ // Debateable whether we should append $query - we may be redirecting to a custom page, for example
+ if (strpos($fp, '{') !== FALSE)
+ {
+ $location = $tp->replaceConstants($fp).$query;
+ }
+ else
+ {
+ $location = ((strpos($fp, 'http') === FALSE) ? e_BASE : '').$fp.$query;
+ }
+ break;
}
- else
- {
- $location = ((strpos($fp, 'http') === FALSE) ? e_BASE : '').$fp.$query;
- }
- break;
}
- }
}
-
if (!$location)
-{ // Try and use the 'old' method (this bit can go later)
- if (ADMIN)
- {
- $location = ((strpos($pref['frontpage'][e_UC_ADMIN], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_ADMIN].$query;
- }
- elseif (USER)
- { // This is the key bit - what to do for a 'normal' logged in user
- // We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
- foreach ($class_list as $fp_class)
+{ // Try and use the 'old' method (this bit can go later)
+ if (ADMIN)
{
- $inclass = false;
- if (!$inclass && check_class($fp_class['userclass_id']))
- {
- $location = ((strpos($pref['frontpage'][$fp_class['userclass_id']], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][$fp_class['userclass_id']].$query;
- $inclass = true;
- }
- }
- $location = $location ? $location : ((strpos($pref['frontpage'][e_UC_MEMBER], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_MEMBER].$query;
- }
- else
- {
- $location = ((strpos($pref['frontpage'][e_UC_GUEST], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_GUEST].$query;
- }
+ $location = ((strpos($pref['frontpage'][e_UC_ADMIN], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_ADMIN].$query;
+ }
+ elseif (USER)
+ { // This is the key bit - what to do for a 'normal' logged in user
+ // We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
+ foreach ($class_list as $fp_class)
+ {
+ $inclass = false;
+ if (!$inclass && check_class($fp_class['userclass_id']))
+ {
+ $location = ((strpos($pref['frontpage'][$fp_class['userclass_id']], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][$fp_class['userclass_id']].$query;
+ $inclass = true;
+ }
+ }
+ $location = $location ? $location : ((strpos($pref['frontpage'][e_UC_MEMBER], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_MEMBER].$query;
+ }
+ else
+ {
+ $location = ((strpos($pref['frontpage'][e_UC_GUEST], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_GUEST].$query;
+ }
}
-if (!trim($location)) $location = 'news.php';
-
-
- list($page,$str) = explode("?",$location."?"); // required to prevent infinite looping when queries are used on index.php.
- if($page == "index.php") // Welcome Message is the front-page.
- {
- require_once(HEADERF);
- require_once(FOOTERF);
- exit;
- }
- else
- { // redirect to different frontpage.
+if (!trim($location))
+ $location = 'news.php';
+
+list($page, $str) = explode("?", $location."?"); // required to prevent infinite looping when queries are used on index.php.
+if ($page == "index.php") // Welcome Message is the front-page.
+{
+ require_once (HEADERF);
+ require_once (FOOTERF);
+ exit;
+}
+else
+{ // redirect to different frontpage.
header("Location: {$location}");
- }
- exit();
+}
+exit();
-?>
+?>
\ No newline at end of file