Example #1
0
 /**
  * Deactivate modules that are unavailable or missing, yet still active.
  * This happens when a user deletes a module without deactivating it.
  */
 static function deactivate_missing_modules()
 {
     foreach (self::$modules as $module_name => $module) {
         if (module::is_active($module_name) && !module::info($module_name)) {
             module::deactivate($module_name);
         }
     }
 }
<?php

defined("SYSPATH") or die("No direct script access.");
$indent_provider = module::get_var("gallery", "identity_provider");
foreach ($modules as $ref => $text) {
    $moduleinfo = module::info($text);
    if ($text == "gallery" || $text == $indent_provider || $moduleinfo->name == "") {
        ?>
<li style="background-color:#A8A8A8; margin:0.5em; padding:0.3em 0.8em; display: none" ref="<?php 
        echo $ref;
        ?>
"><?php 
        echo $text;
        ?>
</li>
<?php 
    } else {
        ?>
<li class="g-draggable" ref="<?php 
        echo $ref;
        ?>
"><?php 
        echo $moduleinfo->name;
        ?>
</li>
<?php 
    }
}
 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."));
     }
     $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 <a href="http://codex.gallery2.org/Gallery3:Modules:kbd_nav" target="_blank">module</a> 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;
     }
     $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")))->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;
 }
 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 get_thumb_element($item, $addcontext = FALSE, $linkonly = FALSE)
 {
     $thumb_item = $item;
     if ($this->thumb_random) {
         if ($item->is_album() && ($rnd = item::random_query()->where("parent_id", "=", $item->id)->find()) && $rnd->loaded()) {
             $thumb_item = $rnd;
         }
     }
     $item_class = $item->is_album() ? "g-album" : "g-photo";
     $content = '<li id="g-item-id-' . $item->id . '" class="g-item ' . $item_class . ' ' . $this->thumb_type;
     if ($item->is_album()) {
         $_thumb_descmode = $this->thumb_descmode_a;
     } else {
         $_thumb_descmode = $this->thumb_descmode;
     }
     $content .= $_thumb_descmode == "bottom" ? " g-expanded" : " g-default";
     if ($thumb_item->has_thumb()) {
         $is_portrait = $thumb_item->thumb_height > $thumb_item->thumb_width;
         $_shift = "";
         switch ($this->thumb_imgalign) {
             case "center":
                 if ($this->crop_factor == 1 and !$is_portrait) {
                     $_shift = 'style="margin-top: ' . intval(($this->_thumb_size_y - $thumb_item->thumb_height) / 2) . 'px;"';
                 } elseif ($this->crop_factor > 0) {
                     $_shift = 'style="margin-top: -' . intval(($thumb_item->thumb_height - $this->_thumb_size_y) / 2) . 'px;"';
                 }
                 break;
             case "bottom":
                 if ($this->crop_factor == 1 and !$is_portrait) {
                     $_shift = 'style="margin-top: ' . intval($this->_thumb_size_y - $thumb_item->thumb_height) . 'px;"';
                 } elseif ($this->crop_factor > 0) {
                     $_shift = 'style="margin-top: -' . intval($thumb_item->thumb_height - $this->_thumb_size_y) . 'px;"';
                 }
                 break;
             case "fit":
                 break;
             case "top":
             default:
                 break;
         }
     } else {
         $is_portrait = FALSE;
         $_shift = 'style="margin-top: 0px;"';
     }
     $content .= $is_portrait ? " g-portrait" : " g-landscape";
     $content .= '">' . $this->thumb_top($item);
     $content .= '<div class="g-thumbslide">';
     $thumb_content = '<p class="g-thumbcrop">';
     $use_direct_link = $this->disablephotopage && !$item->is_album();
     $class_name = "g-thumblink";
     if ($use_direct_link) {
         $class_name .= ' g-sb-preview" rel="g-preview';
         if (access::can("view_full", $item)) {
             $direct_link = $item->file_url();
         } else {
             $direct_link = $item->resize_url();
         }
     } else {
         $direct_link = $item->url();
     }
     if ($use_direct_link && module::is_active("exif") && module::info("exif")) {
         $thumb_content .= '<a class="g-meta-exif-link g-dialog-link" href="' . url::site("exif/show/{$item->id}") . '" title="' . t("Photo details")->for_html_attr() . '">&nbsp;</a>';
     }
     $thumb_content .= '<a title="' . $this->get_item_title($item) . '" ' . $_shift . ' class="' . $class_name . '" href="' . $direct_link . '">';
     if ($thumb_item->has_thumb()) {
         if ($this->crop_factor > 1 && $this->thumb_imgalign == "fit") {
             if ($thumb_item->thumb_height > $this->_thumb_size_y) {
                 if ($is_portrait) {
                     $_max = $this->_thumb_size_y;
                 } else {
                     $_max = intval($this->_thumb_size_x * ($this->_thumb_size_y / $thumb_item->thumb_height));
                 }
             } else {
                 $_max = $this->_thumb_size_x;
             }
             $_max = min($thumb_item->thumb_width, $_max);
             $thumb_content .= $thumb_item->thumb_img(array(), $_max);
         } else {
             $thumb_content .= $thumb_item->thumb_img();
         }
     } else {
         $thumb_content .= '<img title="No Image" alt="No Image" src="' . $this->url("images/missing-img.png") . '"/>';
     }
     $thumb_content .= '</a></p>';
     if ($this->thumb_metamode != "hide" and $_thumb_descmode == "overlay_bottom") {
         $_thumb_metamode = "merged";
     } else {
         $_thumb_metamode = $this->thumb_metamode;
     }
     if ($_thumb_descmode == "overlay" or $_thumb_descmode == "overlay_top" or $_thumb_descmode == "overlay_bottom") {
         $thumb_content .= '<ul class="g-description ';
         if ($_thumb_descmode == "overlay_top") {
             $thumb_content .= 'g-overlay-top';
         }
         if ($_thumb_descmode == "overlay_bottom") {
             $thumb_content .= 'g-overlay-bottom';
         }
         $thumb_content .= '"><li class="g-title">' . $this->get_item_title($item, FALSE, $this->visible_title_length) . '</li>';
         if ($_thumb_metamode == "merged") {
             $thumb_content .= $this->thumb_info($item);
         }
         $thumb_content .= '</ul>';
     }
     if ($_thumb_metamode == "default" and $_thumb_descmode != "overlay_bottom") {
         $thumb_content .= '<ul class="g-metadata">' . $this->thumb_info($item) . '</ul>';
     }
     if ($_thumb_descmode == "bottom") {
         $thumb_content .= '<ul class="g-description">';
         $thumb_content .= '<li class="g-title">' . $this->get_item_title($item) . '</li>';
         if ($_thumb_metamode == "merged") {
             $thumb_content .= $this->thumb_info($item);
         }
         $thumb_content .= '</ul>';
     }
     if ($addcontext) {
         $_text = $this->context_menu($item, "#g-item-id-{$item->id} .g-thumbnail");
         $thumb_content .= stripos($_text, '<li>') ? $_text : null;
     }
     try {
         $view = new View("frame.html");
         $view->thumb_content = $thumb_content;
         $content .= $view;
     } catch (Exception $e) {
         $content .= $thumb_content;
     }
     $content .= '</div>';
     $content .= $this->thumb_bottom($item);
     $content .= '</li>';
     return $content;
 }