load_theme_info(); return ($theme_info->version); } private function get_theme_name() { $theme_info = $this->load_theme_info(); return ($theme_info->name); } private function get_colorpacks() { $colorpacks = array(); $colorpackroot = THEMEPATH . 'greydragon/css/colorpacks/'; foreach (scandir($colorpackroot) as $colorpack_name): if (file_exists($colorpackroot . "$colorpack_name/colors.css")): if ($colorpack_name[0] == "."): continue; endif; $colorpacks[$colorpack_name] = t($colorpack_name); endif; endforeach; return $colorpacks; } private function prerequisite_check($group, $id, $is_ok, $caption, $caption_ok, $caption_failed, $iswarning, $msg_error) { $confirmation_caption = ($is_ok)? $caption_ok : $caption_failed; $checkbox = $group->checkbox($id) ->label($caption . " " . $confirmation_caption) ->checked($is_ok) ->disabled(true); if ($is_ok): $checkbox->class("g-success"); elseif ($iswarning): $checkbox->class("g-prerequisite g-warning")->error_messages("failed", $msg_error)->add_error("failed", 1); else: $checkbox->class("g-error")->error_messages("failed", $msg_error)->add_error("failed", 1); endif; } protected function get_edit_form_admin() { $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form")); $group = $form->group("requirements")->label("Prerequisites Checklist"); $gallery_ver = module::get_version("gallery"); $this->prerequisite_check($group, "vercheck", $gallery_ver >= $this->min_gallery_ver, t("Gallery 3 Core v.") . $this->min_gallery_ver, "Installed", "Required", FALSE, t("Check Failed. Minimum Required Version") . " " . $gallery_ver); $this->prerequisite_check($group, "shadowbox", ((module::is_active("shadowbox")) and (module::info("shadowbox"))), t("Shadowbox Module"), "Found", "Required", FALSE, t("Check Failed. Shadowbox Module not Installed.")); if (!module::get_var("th_greydragon", "hide_thumbmeta")): $this->prerequisite_check($group, "info", (module::is_active("info") and module::info("info")), t("Info Module"), "Found", "Required", FALSE, t("Check Failed. Module is required to display Thumb metadata.")); endif; $group = $form->group("recommended")->label("Module Recommendations"); $organize_active = ((module::is_active("organize")) and (module::info("organize"))); $this->prerequisite_check($group, "organizecheck", !$organize_active, t("Organize Module"), "not Used", "Found", TRUE, t("Default Organize module is active but is not supported in full by the theme.")); $kbdnav_active = ((module::is_active("kbd_nav")) and (module::info("kbd_nav"))); $this->prerequisite_check($group, "kbdnavcheck", $kbdnav_active, t("Kbd Navigation Module"), "Found", "not Found", TRUE, t('Install module to enable keyboard navigation support.')); $sidebar_allowed = module::get_var("th_greydragon", "sidebar_allowed"); $sidebar_visible = module::get_var("th_greydragon", "sidebar_visible"); $pagesize = module::get_var("gallery", "page_size"); if (($sidebar_allowed == "none") and ($sidebar_visible == "none")): $pagesize = $pagesize / 4; else: $pagesize = $pagesize / 3; endif; $group = $form->group("edit_theme")->label(t("General Settings")); $group->input("row_count") ->label(t("Rows per Album Page")) ->rules("required|valid_digit") ->error_messages("required", t("You must enter a number")) ->error_messages("valid_digit", t("You must enter a number")) ->value($pagesize); $group->input("resize_size") ->label(t("Resized Image Size (in pixels)")) ->rules("required|valid_digit") ->error_messages("required", t("You must enter a number")) ->error_messages("valid_digit", t("You must enter a number")) ->value(module::get_var("gallery", "resize_size")); $group->input("logo_path") ->label(t("Alternate Logo Image")) ->value(module::get_var("th_greydragon", "logo_path")); $group->input("header_text") ->label(t("Header Text")) ->value(module::get_var("gallery", "header_text")); $group->input("footer_text") ->label(t("Footer Text")) ->value(module::get_var("gallery", "footer_text")); $group->input("copyright") ->label(t("Copyright Message")) ->value(module::get_var("th_greydragon", "copyright")); $group->dropdown("colorpack") ->label(t("Selected Color Pack")) ->options(self::get_colorpacks()) ->selected(module::get_var("th_greydragon", "color_pack", "greydragon")); $group = $form->group("edit_theme_adv_main")->label(t("Advanced Options - Main")); $group->checkbox("show_credits") ->label(t("Show Site Credits")) ->checked(module::get_var("gallery", "show_credits")); $group->checkbox("show_guest_menu") ->label(t("Show Main Menu for Guest Users")) ->checked(module::get_var("th_greydragon", "show_guest_menu")); $group->checkbox("loginmenu_position") ->label(t("Place Login Link in the Header")) ->checked(module::get_var("th_greydragon", "loginmenu_position") == "header"); $group->checkbox("mainmenu_position") ->label(t("Alternate Header Layout")) ->checked(module::get_var("th_greydragon", "mainmenu_position") == "top"); $group->checkbox("hide_breadcrumbs") ->label(t("Hide Breadcrumbs")) ->checked(module::get_var("th_greydragon", "hide_breadcrumbs")); $group->dropdown("photonav_position") ->label(t("Item Navigator Position")) ->options(array("top" => t("Top"), "bottom" => t("Bottom"), "both" => t("Both"), "none" => t("None"))) ->selected(module::get_var("th_greydragon", "photonav_position")); $group->checkbox("disable_seosupport") ->label(t("Disallow Search Engine Indexing")) ->checked(module::get_var("th_greydragon", "disable_seosupport")); $group->checkbox("enable_pagecache") ->label(t("Enable Page Cache (60 seconds)")) ->checked(module::get_var("th_greydragon", "enable_pagecache")); $group = $form->group("edit_theme_adv_thumb")->label(t("Advanced Options - Album page/Thumbs")); $group->dropdown("thumb_ratio") ->label(t("Aspect Ratio")) ->options(array("photo" => t("Actual Size"), "digital" => t("Digital 4:3"), "film" => t("Film 3:2") /* , "square" => t("Square 1:1") */ )) ->selected(module::get_var("th_greydragon", "thumb_ratio")); $group->dropdown("thumb_descmode") ->label(t("Title Display Mode")) ->options(array("overlay" => t("Overlay"), "bottom" => t("Bottom"), "hide" => t("Hide"))) ->selected(module::get_var("th_greydragon", "thumb_descmode")); $group->checkbox("hide_thumbmeta") ->label(t("Hide Item Meta Data")) ->checked(module::get_var("th_greydragon", "hide_thumbmeta")); $group = $form->group("edit_theme_adv_photo")->label(t("Advanced Options - Photo page")); $group->dropdown("photo_descmode") ->label(t("Description Display Mode")) ->options(array("overlay" => t("Overlay"), "bottom" => t("Bottom"), "top" => t("Top"), "hide" => t("Hide"))) ->selected(module::get_var("th_greydragon", "photo_descmode")); $group->checkbox("desc_allowbbcode") ->label(t("Allow BBCode/HTML in Descriptions")) ->checked(module::get_var("th_greydragon", "desc_allowbbcode")); $group->checkbox("hide_photometa") ->label(t("Hide Item Meta Data")) ->checked(module::get_var("th_greydragon", "hide_photometa", TRUE)); $group = $form->group("edit_theme_side")->label(t("Sidebar Options")); $group->checkbox("hide_blockheader") ->label(t("Hide Block Header")) ->checked(module::get_var("th_greydragon", "hide_blockheader")); $group->checkbox("sidebar_albumonly") ->label(t("Show Sidebar for Albums Only")) ->checked(module::get_var("th_greydragon", "sidebar_albumonly")); $group->dropdown("sidebar_allowed") ->label(t("Allowed Sidebar Positions")) ->options(array("any" => t("Any"), "left" => t("Left"), "right" => t("Right"), "none" => t("Default Only"))) ->selected($sidebar_allowed); $group->dropdown("sidebar_visible") ->label(t("Default Sidebar Position")) ->options(array("right" => t("Right"), "left" => t("Left"), "none" => t("No sidebar"))) ->selected($sidebar_visible); $group = $form->group("maintenance")->label("Maintenance"); $group->checkbox("build_resize")->label(t("Mark all Image Resizes for Rebuild"))->checked(false); $group->checkbox("build_thumbs")->label(t("Mark all Thumbnails for Rebuild"))->checked(false); $group->checkbox("build_exif")->label(t("Reset Exif Info"))->checked(false); $group->checkbox("reset_theme")->label(t("Reset Theme to a Default State"))->checked(false); module::event("theme_edit_form", $form); $form->submit("g-theme-options-save")->value(t("Save Changes")); return $form; } protected function get_edit_form_help() { $help = '
'; $help .= 'Help
'; return $help; } private function save_item_state($statename, $state, $value) { if ($state): module::set_var("th_greydragon", $statename, $value); else: module::clear_var("th_greydragon", $statename); endif; } public function save() { site_status::clear("gd_init_configuration"); access::verify_csrf(); $form = self::get_edit_form_admin(); if ($form->validate()): module::clear_var("th_greydragon", "photonav_top"); module::clear_var("th_greydragon", "photonav_bottom"); module::clear_var("th_greydragon", "hide_sidebar_photo"); module::clear_var("th_greydragon", "hide_thumbdesc"); module::clear_var("th_greydragon", "use_detailview"); if ($form->maintenance->reset_theme->value): module::set_var("gallery", "page_size", 9); module::set_var("gallery", "resize_size", 640); module::set_var("gallery", "thumb_size", 200); module::set_var("gallery", "header_text", ""); module::set_var("gallery", "footer_text", ""); module::clear_var("th_greydragon", "copyright"); module::clear_var("th_greydragon", "logo_path"); module::clear_var("th_greydragon", "color_pack"); module::clear_var("th_greydragon", "enable_pagecache"); module::set_var("gallery", "show_credits", FALSE); module::clear_var("th_greydragon", "show_guest_menu"); module::clear_var("th_greydragon", "mainmenu_position"); module::clear_var("th_greydragon", "loginmenu_position"); module::clear_var("th_greydragon", "hide_breadcrumbs"); module::clear_var("th_greydragon", "horizontal_crop"); module::clear_var("th_greydragon", "thumb_descmode"); module::clear_var("th_greydragon", "hide_thumbmeta"); module::clear_var("th_greydragon", "hide_blockheader"); module::clear_var("th_greydragon", "photonav_position"); module::clear_var("th_greydragon", "photo_descmode"); module::clear_var("th_greydragon", "desc_allowbbcode"); module::clear_var("th_greydragon", "hide_photometa"); module::clear_var("th_greydragon", "disable_seosupport"); module::clear_var("th_greydragon", "sidebar_albumonly"); module::clear_var("th_greydragon", "sidebar_allowed"); module::clear_var("th_greydragon", "sidebar_visible"); module::event("theme_edit_form_completed", $form); message::success(t("Theme details are reset")); else: // * General Settings **************************************************** $_priorratio = module::get_var("th_greydragon", "thumb_ratio"); if (!$_priorratio): $_priorratio = "digital"; endif; $resize_size = $form->edit_theme->resize_size->value; $thumb_size = 200; $build_resize = $form->maintenance->build_resize->value; $build_thumbs = $form->maintenance->build_thumbs->value; $build_exif = $form->maintenance->build_exif->value; $thumb_ratio = $form->edit_theme_adv_thumb->thumb_ratio->value; if ($thumb_ratio == "photo") { $rule = Image::AUTO; } else { $rule = Image::WIDTH; } $color_pack = $form->edit_theme->colorpack->value; $thumb_descmode = $form->edit_theme_adv_thumb->thumb_descmode->value; $photo_descmode = $form->edit_theme_adv_photo->photo_descmode->value; if ($build_resize): graphics::remove_rule("gallery", "resize", "gallery_graphics::resize"); graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100); endif; if (module::get_var("gallery", "resize_size") != $resize_size): module::set_var("gallery", "resize_size", $resize_size); endif; if ($build_thumbs): graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize"); graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => $rule), 100); endif; if ($build_exif): db::build() ->delete("exif_records") ->execute(); endif; if (module::get_var("gallery", "thumb_size") != $thumb_size): module::set_var("gallery", "thumb_size", $thumb_size); endif; module::set_var("gallery", "header_text", $form->edit_theme->header_text->value); module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); $this->save_item_state("copyright", $form->edit_theme->copyright->value, $form->edit_theme->copyright->value); $this->save_item_state("logo_path", $form->edit_theme->logo_path->value, $form->edit_theme->logo_path->value); $this->save_item_state("color_pack", (($color_pack) and ($color_pack != "greydragon")), $color_pack); // * Advanced Options - main ********************************************* module::set_var("gallery", "show_credits", $form->edit_theme_adv_main->show_credits->value); $this->save_item_state("show_guest_menu", $form->edit_theme_adv_main->show_guest_menu->value, TRUE); $this->save_item_state("loginmenu_position", $form->edit_theme_adv_main->loginmenu_position->value == "1", "header"); $this->save_item_state("mainmenu_position", $form->edit_theme_adv_main->mainmenu_position->value == "1", "top"); $this->save_item_state("hide_breadcrumbs", $form->edit_theme_adv_main->hide_breadcrumbs->value, TRUE); $this->save_item_state("photonav_position", $form->edit_theme_adv_main->photonav_position->value != "top", $form->edit_theme_adv->photonav_position->value); $this->save_item_state("enable_pagecache", $form->edit_theme_adv_main->enable_pagecache->value, TRUE); $this->save_item_state("disable_seosupport", $form->edit_theme_adv_main->disable_seosupport->value, TRUE); // * Advanced Options - Album page *************************************** $this->save_item_state("thumb_ratio", $thumb_ratio != "photo", $thumb_ratio); $this->save_item_state("thumb_descmode", $thumb_descmode != "overlay", $thumb_descmode); $this->save_item_state("hide_thumbmeta", $form->edit_theme_adv_thumb->hide_thumbmeta->value, TRUE); // * Advanced Options - Photo page *************************************** $this->save_item_state("photo_descmode", $photo_descmode != "overlay", $photo_descmode); $this->save_item_state("desc_allowbbcode", $form->edit_theme_adv_photo->desc_allowbbcode->value, TRUE); $this->save_item_state("hide_photometa", !$form->edit_theme_adv_photo->hide_photometa->value, FALSE); // * Sidebar Options **************************************************** $sidebar_allowed = $form->edit_theme_side->sidebar_allowed->value; $sidebar_visible = $form->edit_theme_side->sidebar_visible->value; if ($sidebar_allowed == "right"): $sidebar_visible = "right"; endif; if ($sidebar_allowed == "left"): $sidebar_visible = "left"; endif; $this->save_item_state("hide_blockheader", $form->edit_theme_side->hide_blockheader->value, TRUE); $this->save_item_state("sidebar_albumonly", $form->edit_theme_side->sidebar_albumonly->value, TRUE); $this->save_item_state("sidebar_allowed", $sidebar_allowed != "any", $sidebar_allowed); $this->save_item_state("sidebar_visible", $sidebar_visible != "right", $sidebar_visible); if (($sidebar_allowed == "none") and ($sidebar_visible == "none")): module::set_var("gallery", "page_size", $form->edit_theme->row_count->value * 4); else: module::set_var("gallery", "page_size", $form->edit_theme->row_count->value * 3); endif; module::event("theme_edit_form_completed", $form); if ($_priorratio != $thumb_ratio): message::warning(t("Thumb aspect ratio has been changed. Consider rebuilding thumbs if needed.")); endif; message::success(t("Updated theme details")); endif; url::redirect("admin/theme_options"); else: $view = new Admin_View("admin.html"); $view->content = $form; print $view; endif; } public function index() { site_status::clear("gd_init_configuration"); $view = new Admin_View("admin.html"); $view->page_title = t("Grey Dragon Theme"); $view->content = new View("admin_theme_options.html"); $view->content->name = self::get_theme_name(); $view->content->version = self::get_theme_version(); $view->content->form = self::get_edit_form_admin(); $view->content->help = self::get_edit_form_help(); print $view; } }