Exemplo n.º 1
0
 public function save()
 {
     access::verify_csrf();
     $form = $this->_get_edit_form_admin();
     if ($form->validate()) {
         module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
         $thumb_size = $form->edit_theme->thumb_size->value;
         if (module::get_var("gallery", "thumb_size") != $thumb_size) {
             graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
             graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "thumb_size", $thumb_size);
         }
         $resize_size = $form->edit_theme->resize_size->value;
         if (module::get_var("gallery", "resize_size") != $resize_size) {
             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);
             module::set_var("gallery", "resize_size", $resize_size);
         }
         module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
         // Sanitize values that get placed directly in HTML output by theme.
         module::set_var("gallery", "header_text", html::purify($form->edit_theme->header_text->value));
         module::set_var("gallery", "footer_text", html::purify($form->edit_theme->footer_text->value));
         module::set_var("gallery", "favicon_url", html::purify($form->edit_theme->favicon_url->value));
         module::set_var("gallery", "apple_touch_icon_url", html::purify($form->edit_theme->apple_touch_icon_url->value));
         module::event("theme_edit_form_completed", $form);
         message::success(t("Updated theme details"));
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = new View("admin_theme_options.html");
         $view->content->form = $form;
         print $view;
     }
 }
Exemplo n.º 2
0
 public function save()
 {
     access::verify_csrf();
     $form = theme::get_edit_form_admin();
     if ($form->validate()) {
         module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
         $thumb_size = $form->edit_theme->thumb_size->value;
         $thumb_dirty = false;
         if (module::get_var("gallery", "thumb_size") != $thumb_size) {
             graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
             graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "thumb_size", $thumb_size);
         }
         $resize_size = $form->edit_theme->resize_size->value;
         $resize_dirty = false;
         if (module::get_var("gallery", "resize_size") != $resize_size) {
             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);
             module::set_var("gallery", "resize_size", $resize_size);
         }
         module::set_var("gallery", "header_text", $form->edit_theme->header_text->value);
         module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
         module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
         message::success(t("Updated theme details"));
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = $form;
         print $view;
     }
 }
Exemplo n.º 3
0
 public function save()
 {
     access::verify_csrf();
     $form = self::get_edit_form_admin();
     if ($form->validate()) {
         $edit_theme = $form->edit_theme;
         module::set_var("gallery", "page_size", $edit_theme->row_count->value * 3);
         $resize_size = $edit_theme->resize_size->value;
         $thumb_size = 200;
         $build_resize = $edit_theme->build_resize->value;
         $build_thumbs = $edit_theme->build_thumbs->value;
         if (module::get_var("gallery", "resize_size") != $resize_size) {
             module::set_var("gallery", "resize_size", $resize_size);
             $build_resize = true;
         }
         if (module::get_var("gallery", "thumb_size") != $thumb_size) {
             module::set_var("gallery", "thumb_size", $thumb_size);
         }
         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);
         }
         if ($build_thumbs) {
             graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
             graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => 200, "height" => 200, "master" => Image::AUTO), 100);
         }
         module::set_var("th_greydragon", "photonav_top", $edit_theme->photonav_top->value);
         module::set_var("th_greydragon", "photonav_bottom", $edit_theme->photonav_bottom->value);
         $sidebar_allowed = $edit_theme->sidebar_allowed->value;
         $sidebar_visible = $edit_theme->sidebar_visible->value;
         if ($sidebar_allowed == "none") {
             $sidebar_visible = "none";
         }
         if ($sidebar_allowed == "right") {
             $sidebar_visible = "right";
         }
         if ($sidebar_allowed == "left") {
             $sidebar_visible = "left";
         }
         module::set_var("th_greydragon", "sidebar_allowed", $sidebar_allowed);
         module::set_var("th_greydragon", "sidebar_visible", $sidebar_visible);
         module::set_var("gallery", "header_text", $edit_theme->header_text->value);
         module::set_var("gallery", "footer_text", $edit_theme->footer_text->value);
         module::set_var("gallery", "show_credits", $edit_theme->show_credits->value);
         module::set_var("th_greydragon", "copyright", $edit_theme->copyright->value);
         module::set_var("th_greydragon", "logo_path", $edit_theme->logo_path->value);
         module::event("theme_edit_form_completed", $form);
         message::success(t("Updated theme details"));
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = $form;
         print $view;
     }
 }
 static function update_rules()
 {
     // Make sure our thumb size matches the gallery one
     $thumb_size = module::get_var("gallery", "thumb_size");
     if ($thumb_size != module::get_var("custom_albums", "thumb_size")) {
         // Remove and readd our rule with the latest thumb size
         graphics::remove_rule("custom_albums", "thumb", "custom_albums_graphics::build_thumb");
         graphics::add_rule("custom_albums", "thumb", "custom_albums_graphics::build_thumb", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 101);
         // Deactivate the gallery thumbnail generation, we'll handle it now
         graphics::deactivate_rules("gallery");
         module::set_var("custom_albums", "thumb_size", $thumb_size);
     }
     // Make sure our resize size matches the gallery one
     $resize_size = module::get_var("gallery", "resize_size");
     if ($resize_size != module::get_var("custom_albums", "resize_size")) {
         // Remove and readd our rule with the latest resize size
         graphics::remove_rule("custom_albums", "resize", "custom_albums_graphics::build_resize");
         graphics::add_rule("custom_albums", "resize", "custom_albums_graphics::build_resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 101);
         // Deactivate the gallery resize, we'll handle it now
         graphics::deactivate_rules("gallery");
         module::set_var("custom_albums", "resize_size", $resize_size);
     }
 }
Exemplo n.º 5
0
 /**
  * Uninstall a deactivated module.  This will call <module>_installer::uninstall() which should
  * take whatever steps necessary to make sure that all traces of a module are gone.
  * @param string $module_name
  */
 static function uninstall($module_name)
 {
     $installer_class = "{$module_name}_installer";
     if (method_exists($installer_class, "uninstall")) {
         call_user_func(array($installer_class, "uninstall"));
     }
     graphics::remove_rule($module_name);
     $module = self::get($module_name);
     if ($module->loaded) {
         $module->delete();
     }
     module::load_modules();
     // We could delete the module vars here too, but it's nice to leave them around
     // in case the module gets reinstalled.
     log::success("module", t("Uninstalled module %module_name", array("module_name" => $module_name)));
 }
 public function save()
 {
     site_status::clear("gd_init_configuration");
     access::verify_csrf();
     $form = self::get_edit_form_admin();
     if ($form->validate()) {
         $this->legacy();
         if ($form->maintenance->reset_theme->value) {
             $this->reset_theme();
             module::event("theme_edit_form_completed", $form);
             message::success(t("Theme details are reset"));
         } else {
             // * General Settings ****************************************************
             $old_resize_size = module::get_var("gallery", "resize_size", 800);
             module::set_var("gallery", "resize_size", filter_var($form->edit_theme_adv_photo->resize_size->value, FILTER_VALIDATE_INT, array('options' => array('default' => 800, 'min_range' => 640))));
             $resize_size = module::get_var("gallery", "resize_size", 800);
             $build_resize = $form->maintenance->build_resize->value;
             $build_thumbs = $form->maintenance->build_thumbs->value;
             $build_exif = $form->maintenance->build_exif->value;
             if (module::is_active("iptc") and module::info("iptc")) {
                 $build_iptc = $form->maintenance->build_iptc->value;
             } else {
                 $build_iptc = FALSE;
             }
             $purge_cache = $form->maintenance->purge_cache->value;
             if ($build_resize || $old_resize_size != $resize_size) {
                 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);
             }
             if (module::get_var("gallery", "resize_size") != $resize_size) {
                 module::set_var("gallery", "resize_size", $resize_size);
             }
             $thumb_size = 200;
             $rule = Image::AUTO;
             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);
             }
             if (module::get_var("gallery", "thumb_size") != $thumb_size) {
                 module::set_var("gallery", "thumb_size", $thumb_size);
             }
             module::set_var("gallery", "page_size", 50);
             module::set_var("gallery", "favicon_url", $form->edit_theme->favicon->value);
             module::set_var("gallery", "appletouchicon_url", $form->edit_theme->appletouchicon->value);
             $this->save_item_state("logo_path", $form->edit_theme->logo_path->value, $form->edit_theme->logo_path->value);
             $this->save_item_state("slideshow_time", $form->edit_theme->slideshow_time->value != 5000, filter_var($form->edit_theme->slideshow_time->value, FILTER_VALIDATE_INT, array('options' => array('default' => 5000, 'min_range' => 1000))));
             // * Advanced Options - General ******************************************
             $this->save_item_state("hide_item_count", $form->edit_theme_adv_main->hide_item_count->value, TRUE);
             $this->save_item_state("hide_logo", $form->edit_theme_adv_main->hide_logo->value, TRUE);
             $this->save_item_state("mainmenu_view", $form->edit_theme_adv_main->mainmenu_view->value != "grid", $form->edit_theme_adv_main->mainmenu_view->value);
             $this->save_item_state("show_guest_menu", $form->edit_theme_adv_main->show_guest_menu->value, TRUE);
             $this->save_item_state("background", $form->edit_theme_adv_main->background->value != "black", $form->edit_theme_adv_main->background->value);
             $this->save_item_state("show_breadcrumbs", $form->edit_theme_adv_main->show_breadcrumbs->value, TRUE);
             $this->save_item_state("sidebar_view", $form->edit_theme_adv_main->sidebar_view->value != "hidden", $form->edit_theme_adv_main->sidebar_view->value);
             $this->save_item_state("ga_code", $form->edit_theme_adv_main->ga_code->value, $form->edit_theme_adv_main->ga_code->value);
             $this->save_item_state("skimm_lim", $form->edit_theme_adv_main->skimm_lim->value != 50, $form->edit_theme_adv_main->skimm_lim->value);
             // * Advanced Options - Photo page ***************************************
             $this->save_item_state("mosaic_effect", $form->edit_theme_adv_mosaic->mosaic_effect->value != "blind", $form->edit_theme_adv_mosaic->mosaic_effect->value);
             /*
                     $this->save_item_state("photo_popupbox",   $photo_popupbox != "default", $photo_popupbox);
                     $this->save_item_state("thumb_inpage",     $form->edit_theme_adv_photo->thumb_inpage->value, TRUE);
                     $this->save_item_state("hide_photometa",   !$form->edit_theme_adv_photo->hide_photometa->value, FALSE);
                     $this->save_item_state("desc_allowbbcode", $form->edit_theme_adv_photo->desc_allowbbcode->value, TRUE);
             */
             module::event("theme_edit_form_completed", $form);
             message::success(t("Updated theme details"));
             if ($build_exif) {
                 db::update('exif_records')->set(array('dirty' => '1'))->execute();
             }
             if ($build_iptc) {
                 db::update('iptc_records')->set(array('dirty' => '1'))->execute();
             }
             if ($purge_cache) {
                 db::build()->delete("caches")->execute();
             }
         }
         url::redirect("admin/theme_options");
     } else {
         print $this->get_admin_view();
     }
 }
 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";
             }
             $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);
             }
             if (module::get_var("gallery", "resize_size") != $resize_size) {
                 module::set_var("gallery", "resize_size", $resize_size);
             }
             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);
             }
             if ($build_exif) {
                 db::build()->delete("exif_records")->execute();
             }
             if (module::get_var("gallery", "thumb_size") != $thumb_size) {
                 module::set_var("gallery", "thumb_size", $thumb_size);
             }
             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";
             }
             if ($sidebar_allowed == "left") {
                 $sidebar_visible = "left";
             }
             $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);
             }
             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."));
             }
             message::success(t("Updated theme details"));
         }
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = $form;
         print $view;
     }
 }