mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-06-06 11:39:12 -04:00
Create a theme_view function script which allows modules in the head or admin_head functions to specify javascript files that are required for this page.
In this commit, these script files are expressed at the end of the head or admin_head calls and appended to the beginning of the block stack. In a future commit these will be combined and gzipped for download.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user