summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/comment/helpers/comment_theme.php4
-rw-r--r--modules/gallery/helpers/gallery_theme.php50
-rw-r--r--modules/gallery/libraries/Theme_View.php19
3 files changed, 46 insertions, 27 deletions
diff --git a/modules/comment/helpers/comment_theme.php b/modules/comment/helpers/comment_theme.php
index d9f1acf4..89b2f57c 100644
--- a/modules/comment/helpers/comment_theme.php
+++ b/modules/comment/helpers/comment_theme.php
@@ -19,8 +19,8 @@
*/
class comment_theme_Core {
static function head($theme) {
- $url = url::file("modules/comment/js/comment.js");
- return "<script src=\"$url\" type=\"text/javascript\"></script>\n";
+ $theme->script("modules/comment/js/comment.js");
+ return "";
}
static function photo_bottom($theme) {
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 0679087e..b6b24b27 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -21,22 +21,22 @@ class gallery_theme_Core {
static function head($theme) {
$session = Session::instance();
$buf = "";
- $buf .= html::script("lib/jquery.js");
- $buf .= html::script("lib/jquery.form.js");
- $buf .= html::script("lib/jquery-ui.js");
- $buf .= html::script("lib/gallery.common.js");
- $buf .= html::script("lib/gallery.dialog.js");
- $buf .= html::script("lib/gallery.form.js");
- $buf .= html::script("lib/superfish/js/superfish.js");
+ $theme->script("lib/jquery.js");
+ $theme->script("lib/jquery.form.js");
+ $theme->script("lib/jquery-ui.js");
+ $theme->script("lib/gallery.common.js");
+ $theme->script("lib/gallery.dialog.js");
+ $theme->script("lib/gallery.form.js");
+ $theme->script("lib/superfish/js/superfish.js");
if ($theme->page_type == 'photo') {
- $buf .= html::script("lib/jquery.scrollTo.js");
- $buf .= html::script("lib/jquery.localscroll.js");
- $buf .= html::script("lib/gallery.show_full_size.js");
+ $theme->script("lib/jquery.scrollTo.js");
+ $theme->script("lib/jquery.localscroll.js");
+ $theme->script("lib/gallery.show_full_size.js");
}
if ($theme->page_type == 'movie') {
- $buf .= html::script("lib/flowplayer.js");
+ $theme->script("lib/flowplayer.js");
}
- $buf .= html::script($theme->url("js/ui.init.js", false, true));
+ $theme->script($theme->url("js/ui.init.js", false, true));
if ($session->get("debug")) {
$buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file("modules/gallery/css/debug.css") . "\" />";
@@ -45,7 +45,7 @@ class gallery_theme_Core {
&& access::can("edit", $theme->item())) {
$buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file("modules/gallery/css/quick.css") . "\" />";
- $buf .= html::script("modules/gallery/js/quick.js");
+ $theme->script("modules/gallery/js/quick.js");
}
if (module::is_active("rss")) {
@@ -59,8 +59,8 @@ class gallery_theme_Core {
if ($session->get("l10n_mode", false)) {
$buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file("modules/gallery/css/l10n_client.css") . "\" />";
- $buf .= html::script("lib/jquery.cookie.js");
- $buf .= html::script("modules/gallery/js/l10n_client.js");
+ $theme->script("lib/jquery.cookie.js");
+ $theme->script("modules/gallery/js/l10n_client.js");
}
return $buf;
@@ -95,14 +95,14 @@ class gallery_theme_Core {
static function admin_head($theme) {
$session = Session::instance();
$buf = "";
- $buf .= html::script("lib/jquery.js");
- $buf .= html::script("lib/jquery.form.js");
- $buf .= html::script("lib/jquery-ui.js");
- $buf .= html::script("lib/gallery.common.js");
- $buf .= html::script("lib/gallery.dialog.js");
- $buf .= html::script("lib/superfish/js/superfish.js");
- $buf .= html::script($theme->url("js/jquery.dropshadow.js", false, true));
- $buf .= html::script($theme->url("js/ui.init.js", false, true));
+ $theme->script("lib/jquery.js");
+ $theme->script("lib/jquery.form.js");
+ $theme->script("lib/jquery-ui.js");
+ $theme->script("lib/gallery.common.js");
+ $theme->script("lib/gallery.dialog.js");
+ $theme->script("lib/superfish/js/superfish.js");
+ $theme->script($theme->url("js/jquery.dropshadow.js", false, true));
+ $theme->script($theme->url("js/ui.init.js", false, true));
if ($session->get("debug")) {
$buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file("modules/gallery/css/debug.css") . "\" />";
@@ -111,8 +111,8 @@ class gallery_theme_Core {
if ($session->get("l10n_mode", false)) {
$buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file("modules/gallery/css/l10n_client.css") . "\" />";
- $buf .= html::script("lib/jquery.cookie.js");
- $buf .= html::script("modules/gallery/js/l10n_client.js");
+ $theme->script("lib/jquery.cookie.js");
+ $theme->script("modules/gallery/js/l10n_client.js");
}
return $buf;
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 5235fabb..7696f3b0 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -19,6 +19,7 @@
*/
class Theme_View_Core extends View {
private $theme_name = null;
+ private $scripts = array();
/**
* Attempts to load a view and pre-load view data.
@@ -163,6 +164,19 @@ class Theme_View_Core extends View {
return message::get();
}
+ public function script($file) {
+ $this->scripts[$file] = 1;
+ }
+
+ private function _combine_script() {
+ $links = array();
+ Kohana::log("error", Kohana::debug($this->scripts));
+ foreach (array_keys($this->scripts) as $file) {
+ $links[] = html::script($file);
+ }
+ return empty($links) ? "" : implode("\n", $links);
+ }
+
/**
* Handle all theme functions that insert module content.
*/
@@ -221,6 +235,11 @@ class Theme_View_Core extends View {
array_merge(array($this), $args));
}
}
+
+ if ($function == "head" || $function == "admin_head") {
+ array_unshift($blocks, $this->_combine_script());
+ }
+
if (Session::instance()->get("debug")) {
if ($function != "head") {
array_unshift(