Merge branch 'master' of git@github.com:gallery/gallery3

Conflicts:
	modules/gallery/libraries/Theme_View.php
	themes/admin_default/views/admin.html.php
This commit is contained in:
Tim Almdal
2009-06-29 06:44:05 -07:00
19 changed files with 240 additions and 193 deletions

View File

@@ -17,11 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Theme_View_Core extends View {
private $theme_name = null;
private $scripts = array();
private $css = array();
class Theme_View_Core extends Gallery_View {
/**
* Attempts to load a view and pre-load view data.
*
@@ -70,11 +66,6 @@ class Theme_View_Core extends View {
return module::get_var("gallery", "thumb_size", 200) / 200;
}
public function url($path, $absolute_url=false, $no_root=false) {
$arg = "themes/{$this->theme_name}/$path";
return $absolute_url ? url::abs_file($arg) : $no_root ? $arg : url::file($arg);
}
public function item() {
return $this->item;
}
@@ -87,10 +78,6 @@ class Theme_View_Core extends View {
return $this->page_type;
}
public function display($page_name, $view_class="View") {
return new $view_class($page_name);
}
public function site_menu() {
$menu = Menu::factory("root");
if ($this->page_type != "login") {
@@ -169,68 +156,6 @@ class Theme_View_Core extends View {
return message::get();
}
public function script($file) {
$this->scripts[$file] = 1;
}
public function css($file) {
$this->css[$file] = 1;
}
/**
* Combine a series of Javascript files into a single one and cache it in the database, then
* return a single <script> element to refer to it.
*/
private function _combine_script() {
$links = array();
$key = "";
foreach (array_keys($this->scripts) as $file) {
$path = DOCROOT . $file;
if (file_exists($path)) {
$stats = stat($path);
$links[] = $path;
// 7 == size, 9 == mtime, see http://php.net/stat
$key = "{$key}$file $stats[7] $stats[9],";
} else {
Kohana::log("warn", "Javascript file missing: " . $file);
}
}
$key = md5($key);
$cache = Cache::instance();
$contents = $cache->get($key);
if (empty($contents)) {
$contents = "";
foreach ($links as $link) {
$contents .= file_get_contents($link);
}
$cache->set($key, $contents, array("javascript"), 30 * 84600);
if (function_exists("gzencode")) {
$cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP),
array("javascript", "gzip"), 30 * 84600);
}
}
// Handcraft the script link because html::script will add a .js extenstion
return "<script type=\"text/javascript\" src=\"" . url::site("combined/javascript/$key") .
"\"></script>";
}
/**
* Combine a series of Javascript files into a single one and cache it in the database, then
* return a single <script> element to refer to it.
*/
private function _combine_css() {
$links = array();
$key = "";
foreach (array_keys($this->css) as $file) {
$links[] = "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file($file) . "\" />";
}
return implode("\n", $links);
}
/**
* Handle all theme functions that insert module content.
*/
@@ -278,12 +203,6 @@ class Theme_View_Core extends View {
}
}
// Give the theme a chance to add its blocks
$helper_class = "{$this->theme_name}_theme";
$blocks[] = call_user_func_array(
array($helper_class, $function),
array_merge(array($this), $args));
foreach (module::active() as $module) {
if ($module->name == "gallery") {
continue;
@@ -296,9 +215,9 @@ class Theme_View_Core extends View {
}
}
if ($function == "head" || $function == "admin_head") {
array_unshift($blocks, $this->_combine_css());
array_unshift($blocks, $this->_combine_script());
if ($function == "head") {
array_unshift($blocks, $this->combine_css());
array_unshift($blocks, $this->combine_script());
}
if (Session::instance()->get("debug")) {