class Theme_View extends Theme_View_Core { protected $viewmode = "default"; protected $toolbar_large = FALSE; protected $paginator_album; protected $paginator_photo; protected $sidebarvisible; protected $sidebarallowed; protected $sidebar_hideguest = FALSE; protected $logopath; protected $favicon = "lib/images/favicon.ico"; protected $appletouchicon; protected $album_descmode = "hide"; protected $disablephotopage = FALSE; protected $hidecontextmenu = FALSE; protected $thumb_ratio = ""; protected $thumb_descmode_a = "overlay"; protected $thumb_descmode = "overlay"; protected $photo_descmode = "overlay_top"; protected $thumb_imgalign = "top"; protected $thumb_metamode = "default"; protected $is_blockheader_visible = TRUE; protected $is_photometa_visible = FALSE; protected $disable_seosupport = FALSE; protected $mainmenu_position = "bottom-left"; protected $breadcrumbs_position = "bottom-right"; protected $breadcrumbs_showinroot = FALSE; protected $copyright = null; protected $show_guest_menu = FALSE; protected $loginmenu_position = "default"; protected $visible_title_length = 15; protected $title_source = "default"; protected $desc_allowbbcode = FALSE; protected $enable_pagecache = FALSE; protected $flex_rows = FALSE; protected $photo_popupbox = "default"; protected $custom_css_path = ""; protected $thumb_inpage = FALSE; protected $thumb_random = FALSE; protected $row_count = 3; protected $column_count = 3; protected $crop_factor = -1; protected $crop_class = ""; protected $_thumb_size_x = 200; protected $_thumb_size_y = 200; protected $allow_root_page = FALSE; protected $show_root_page = FALSE; protected $show_root_desc = TRUE; protected $root_feed = "gallery/latest"; protected $root_cyclemode = "fade"; protected $root_delay = 15; protected $root_description; protected $permalinks = array("enter" => "?root=no", "root" => "?root=yes"); protected $last_update = 0; protected $colorpack = "greydragon"; protected $framepack = "greydragon"; protected $themename = ""; protected $themeversion = ""; protected $themecss = array(); protected $is_rtl = FALSE; protected function ensurevalue($value, $default) { if ((!isset($value)) or ($value == "")): return $default; else: return $value; endif; } protected function ensureoptionsvalue($key, $default) { return ($this->ensurevalue(module::get_var("th_greydragon", $key), $default)); } public function read_session_cmdparam($cmd, $cookie, $issession, $default) { try { $_cmd = $_GET[$cmd]; } catch (Exception $e) { }; if (isset($_cmd)): $_var = strtolower($_cmd); $_from_cmd = TRUE; if ($_var == "default"): $_var = $default; endif; else: $_from_cmd = FALSE; if ($cookie): try { $_var = $_COOKIE[$cookie]; } catch (Exception $e) { }; endif; endif; if (!isset($_var)): $_var = $default; endif; if ($issession): if ($_from_cmd): setcookie($cookie, $_var, 0); endif; else: setcookie($cookie, $_var, time() + 31536000); endif; return $_var; } public function load_sessioninfo() { // Sidebar position is kept for 360 days. Can be changed via url $this->sidebarallowed = $this->ensureoptionsvalue("sidebar_allowed", "any"); $_sb_visible = $this->ensureoptionsvalue("sidebar_visible", "right"); if ($this->sidebarallowed == "default"): $this->sidebarallowed = $_sb_visible; $this->sidebarvisible = $_sb_visible; else: $this->sidebarvisible = $this->read_session_cmdparam("sb", "gd_sidebar_pos", FALSE, $_sb_visible); endif; $this->colorpack = $this->read_session_cmdparam("colorpack", "gd_colorpack", TRUE, $this->ensureoptionsvalue("color_pack", "greydragon")); $this->framepack = $this->read_session_cmdparam("framepack", "gd_framepack", TRUE, $this->ensureoptionsvalue("frame_pack", "greydragon")); $this->viewmode = $this->read_session_cmdparam("viewmode", "gd_viewmode", TRUE, $this->ensureoptionsvalue("viewmode", "default")); $this->is_rtl = $this->read_session_cmdparam("is_rtl", "gd_rtl", TRUE, "no") == "yes"; $this->thumb_ratio = $this->read_session_cmdparam("ratio", "gd_ratio", TRUE, $this->ensureoptionsvalue("thumb_ratio", "photo")); if ($this->ensureoptionsvalue("allow_root_page", FALSE)): $_root = $this->read_session_cmdparam("root", "gd_rootpage", TRUE, "yes"); $this->show_root_page = ($_root == "yes"); $this->allow_root_page = TRUE; if ($this->show_root_page): $item = $this->item(); if (($item) && ($item->id == item::root()->id)): if (($this->sidebarvisible == "left") or ($this->sidebarvisible == "right")): $this->sidebarvisible = "bottom"; endif; else: $this->show_root_page = FALSE; setcookie("gd_rootpage", "no", 0); endif; if ($this->ensureoptionsvalue("hide_root_sidebar", FALSE)): $this->sidebarallowed = "none"; $this->sidebarvisible = "none"; endif; endif; endif; $this->sidebarvisible = $this->ensurevalue($this->sidebarvisible, "right"); switch ($this->sidebarallowed): case "default": break; case "right": $this->sidebarvisible = "right"; break; case "left": $this->sidebarvisible = "left"; break; case "bottom": $this->sidebarvisible = "bottom"; break; case "top": $this->sidebarvisible = "top"; break; endswitch; if ($this->item()): if ($this->ensureoptionsvalue("sidebar_albumonly", FALSE)): if (!$this->item()->is_album()): $this->sidebarvisible = "none"; $this->sidebarallowed = "none"; endif; endif; endif; $this->sidebar_hideguest = $this->ensureoptionsvalue("sidebar_hideguest", FALSE); if ((identity::active_user()->guest) & ($this->sidebar_hideguest)): $this->sidebarvisible = "none"; $this->sidebarallowed = "none"; endif; if (($this->page_subtype == "login") || ($this->page_subtype == "reauthenticate") || ($this->page_subtype == "error")): $this->sidebarvisible = "none"; $this->sidebarallowed = "none"; endif; $this->last_update = $this->ensureoptionsvalue("last_update", time()); $this->toolbar_large = $this->ensureoptionsvalue("toolbar_large", FALSE); $this->row_count = $this->ensureoptionsvalue("row_count", 3); $this->column_count = $this->ensureoptionsvalue("column_count", 3); $this->logopath = $this->ensureoptionsvalue("logo_path", url::file("lib/images/logo.png")); $this->favicon = $this->ensurevalue(module::get_var("gallery", "favicon_url"), url::file("lib/images/favicon.ico")); $this->appletouchicon = module::get_var("gallery", "apple_touch_icon_url"); $this->horizontal_crop = $this->ensureoptionsvalue("horizontal_crop", FALSE); $this->album_descmode = $this->ensureoptionsvalue("album_descmode", "hide"); $this->disablephotopage = $this->ensureoptionsvalue("disablephotopage", FALSE); $this->hidecontextmenu = $this->ensureoptionsvalue("hidecontextmenu", FALSE); $this->visible_title_length = module::get_var("gallery", "visible_title_length", 15); $this->title_source = $this->ensureoptionsvalue("title_source", "default"); $this->thumb_descmode_a = $this->ensureoptionsvalue("thumb_descmode_a", "overlay"); $this->thumb_descmode = $this->ensureoptionsvalue("thumb_descmode", "overlay"); $this->photo_descmode = $this->ensureoptionsvalue("photo_descmode", "overlay_top"); $this->thumb_random = $this->ensureoptionsvalue("thumb_random", FALSE); $this->thumb_imgalign = $this->ensureoptionsvalue("thumb_imgalign", "top"); if (module::is_active("info")): $this->thumb_metamode = $this->ensureoptionsvalue("thumb_metamode", "default"); $this->is_photometa_visible = (!$this->ensureoptionsvalue("hide_photometa", TRUE)); else: $this->thumb_metamode = "hide"; $this->is_photometa_visible = FALSE; endif; $this->disable_seosupport = $this->ensureoptionsvalue("disable_seosupport", FALSE); $this->is_blockheader_visible = (!$this->ensureoptionsvalue("hide_blockheader", FALSE)); $this->mainmenu_position = $this->ensureoptionsvalue("mainmenu_position", "default"); $this->show_guest_menu = $this->ensureoptionsvalue("show_guest_menu", FALSE); $this->breadcrumbs_position = $this->ensureoptionsvalue("breadcrumbs_position", "default"); $this->breadcrumbs_showinroot = $this->ensureoptionsvalue("breadcrumbs_showinroot", FALSE); $this->desc_allowbbcode = $this->ensureoptionsvalue("desc_allowbbcode", FALSE); $this->loginmenu_position = $this->ensureoptionsvalue("loginmenu_position", "default"); $this->copyright = $this->ensureoptionsvalue("copyright", null); $this->paginator_album = $this->ensureoptionsvalue("paginator_album", "top"); $this->paginator_photo = $this->ensureoptionsvalue("paginator_photo", "top"); $this->enable_pagecache = $this->ensureoptionsvalue("enable_pagecache", FALSE); $this->flex_rows = $this->ensureoptionsvalue("flex_rows", FALSE); $this->show_root_desc = !$this->ensureoptionsvalue("hide_root_desc", FALSE); $this->root_feed = $this->ensureoptionsvalue("root_feed", "gallery/latest"); $this->root_cyclemode = $this->ensureoptionsvalue("root_cyclemode", "fade"); $this->root_delay = $this->ensureoptionsvalue("root_delay", "15"); $this->root_description = module::get_var("th_greydragon", "root_description"); if ($this->ensureoptionsvalue("use_permalinks", FALSE)): $this->permalinks = array("enter" => "enter", "root" => "root"); endif; if (((module::is_active("shadowbox")) and (module::info("shadowbox"))) or ((module::is_active("fancybox")) and (module::info("fancybox"))) or ((module::is_active("colorbox")) and (module::info("colorbox"))) ): $this->photo_popupbox = $this->ensureoptionsvalue("photo_popupbox", "default"); else: $this->photo_popupbox = "none"; endif; try { $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . "greydragon/theme.info"), ArrayObject::ARRAY_AS_PROPS); $this->themename = $theme_info->name; $this->themeversion = $theme_info->version; } catch (Exception $e) { $this->themename = "Grey Dragon Theme"; $this->themeversion = "2.7.+"; } $this->custom_css_path = $this->ensureoptionsvalue("custom_css_path", ""); switch ($this->thumb_ratio): /* case "square": $this->crop_factor = 1; $this->thumb_type = 'g-thumbtype-sqr'; break; */ case "digital": $this->crop_factor = 4/3; $this->thumb_type = 'g-thumbtype-dgt'; break; case "digital_ex": $this->crop_factor = 4/3; $this->thumb_type = 'g-thumbtype-dgt'; $this->_thumb_size_x = 300; break; case "film": $this->crop_factor = 3/2; $this->thumb_type = 'g-thumbtype-flm'; break; case "film_ex": $this->crop_factor = 3/2; $this->thumb_type = 'g-thumbtype-flm'; $this->_thumb_size_x = 300; break; case "wide": $this->crop_factor = 16/9; $this->thumb_type = 'g-thumbtype-wd'; break; case "wide_ex": $this->crop_factor = 16/9; $this->thumb_type = 'g-thumbtype-wd'; $this->_thumb_size_x = 300; break; case "photo_ex": $this->crop_factor = 1; $this->thumb_type = 'g-thumbtype-sqr'; $this->_thumb_size_x = 300; break; case "photo": default: $this->crop_factor = 1; $this->thumb_type = 'g-thumbtype-sqr'; break; endswitch; $this->_thumb_size_y = intval($this->_thumb_size_x / $this->crop_factor); if (($this->sidebarvisible == "none") or ($this->sidebarvisible == "bottom") or ($this->sidebarvisible == "top") ): $this->thumb_inpage = $this->ensureoptionsvalue("thumb_inpage", FALSE); endif; } public function is_sidebarallowed($align) { return (($this->sidebarallowed == "any") or ($this->sidebarallowed == $align)); } public function custom_header() { if (Kohana::find_file('views', "header.html", FALSE)): return new View("header.html"); endif; } public function custom_footer() { if (Kohana::find_file('views', "footer.html", FALSE)): return new View("footer.html"); endif; } public function get_item_title($item, $allowbbcode = FALSE, $limit_title_length = 0) { if (!$item) return ""; if ($item->is_album()): $title = $item->title; else: switch ($this->title_source): case "description": $title = $item->description; break; case "no-filename": $title = $item->title; $filename = $item->name; if (strcasecmp($title, $filename) == 0): $title = ""; else: if (defined('PATHINFO_FILENAME')): $filename = pathinfo($filename, PATHINFO_FILENAME); elseif (strstr($item->filename, '.')): $filename = substr($filename, 0, strrpos($filename, '.')); endif; if (strcasecmp($title, $filename) == 0): $title = ""; else: $filename = item::convert_filename_to_title($filename); // Normalize filename to title format if (strcasecmp($title, $filename) == 0) $title = ""; endif; endif; break; default: $title = $item->title; break; endswitch; endif; $title = html::purify($title); if ($allowbbcode): $title = $this->bb2html($title, 1); else: $title = $this->bb2html($title, 2); endif; if ($limit_title_length): $title = text::limit_chars($title, $limit_title_length); endif; if ($title === "") $title = t(ucfirst($item->type)) . " " . $item->id; return $title; } public function breadcrumb_menu($theme, $parents) { $content = ""; if ($this->breadcrumbs_position == "hide"): // Begin rWatcher Edit -- Add support for $theme->breadcrumbs. elseif (!empty($theme->breadcrumbs)): $content .= '
'; // End rWatcher Edit. elseif ($this->item() and (!empty($parents) or (empty($parents) and $this->breadcrumbs_showinroot))): $content .= ' '; endif; return $content; } protected function sidebar_menu_item($type, $url, $caption, $css) { if (!$this->is_sidebarallowed($type)): return ""; endif; $iscurrent = ($this->sidebarvisible == $type); $content_menu = '", "#\\[code\\](.*?)\\[/code\\]#" => "$1
$1", "#\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]#" => "$2", "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2", "#\\[class=([^\\[]*)\\]([^\\[]*)\\[/class\\]#" => "$2", "#\\[center\\](.*?)\\[/center\\]#" => "