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; } }
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; } }
static function install() { // Insert a rule into the thumbnail generation pipeline that converts the source image to the // right aspect ratio such that when we resize it down, it comes out to the right dimensions. graphics::add_rule("rectangle_thumbs", "thumb", "rectangle_thumbs_graphics::crop_to_aspect_ratio", array(), 50); module::set_var("rectangle_thumbs", "aspect_ratio", "3:1"); module::set_version("rectangle_thumbs", 1); }
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); } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE {access_caches} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {access_intents} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {caches} (\n `id` int(9) NOT NULL auto_increment,\n `key` varchar(255) NOT NULL,\n `tags` varchar(255),\n `expiration` int(9) NOT NULL,\n `cache` longblob,\n PRIMARY KEY (`id`),\n KEY (`tags`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {graphics_rules} (\n `id` int(9) NOT NULL auto_increment,\n `active` BOOLEAN default 0,\n `args` varchar(255) default NULL,\n `module_name` varchar(64) NOT NULL,\n `operation` varchar(64) NOT NULL,\n `priority` int(9) NOT NULL,\n `target` varchar(32) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {incoming_translations} (\n `id` int(9) NOT NULL auto_increment,\n `key` char(32) NOT NULL,\n `locale` char(10) NOT NULL,\n `message` text NOT NULL,\n `revision` int(9) DEFAULT NULL,\n `translation` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`, `locale`),\n KEY `locale_key` (`locale`, `key`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {items} (\n `id` int(9) NOT NULL auto_increment,\n `album_cover_item_id` int(9) default NULL,\n `captured` int(9) default NULL,\n `created` int(9) default NULL,\n `description` varchar(2048) default NULL,\n `height` int(9) default NULL,\n `left_ptr` int(9) NOT NULL,\n `level` int(9) NOT NULL,\n `mime_type` varchar(64) default NULL,\n `name` varchar(255) default NULL,\n `owner_id` int(9) default NULL,\n `parent_id` int(9) NOT NULL,\n `rand_key` float default NULL,\n `relative_path_cache` varchar(255) default NULL,\n `relative_url_cache` varchar(255) default NULL,\n `resize_dirty` boolean default 1,\n `resize_height` int(9) default NULL,\n `resize_width` int(9) default NULL,\n `right_ptr` int(9) NOT NULL,\n `slug` varchar(255) default NULL,\n `sort_column` varchar(64) default NULL,\n `sort_order` char(4) default 'ASC',\n `thumb_dirty` boolean default 1,\n `thumb_height` int(9) default NULL,\n `thumb_width` int(9) default NULL,\n `title` varchar(255) default NULL,\n `type` varchar(32) NOT NULL,\n `updated` int(9) default NULL,\n `view_count` int(9) default 0,\n `weight` int(9) NOT NULL default 0,\n `width` int(9) default NULL,\n PRIMARY KEY (`id`),\n KEY `parent_id` (`parent_id`),\n KEY `type` (`type`),\n KEY `random` (`rand_key`),\n KEY `weight` (`weight` DESC))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {logs} (\n `id` int(9) NOT NULL auto_increment,\n `category` varchar(64) default NULL,\n `html` varchar(255) default NULL,\n `message` text default NULL,\n `referer` varchar(255) default NULL,\n `severity` int(9) default 0,\n `timestamp` int(9) default 0,\n `url` varchar(255) default NULL,\n `user_id` int(9) default 0,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {messages} (\n `id` int(9) NOT NULL auto_increment,\n `key` varchar(255) default NULL,\n `severity` varchar(32) default NULL,\n `value` varchar(255) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {modules} (\n `id` int(9) NOT NULL auto_increment,\n `active` BOOLEAN default 0,\n `name` varchar(64) default NULL,\n `version` int(9) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {outgoing_translations} (\n `id` int(9) NOT NULL auto_increment,\n `base_revision` int(9) DEFAULT NULL,\n `key` char(32) NOT NULL,\n `locale` char(10) NOT NULL,\n `message` text NOT NULL,\n `translation` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`, `locale`),\n KEY `locale_key` (`locale`, `key`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {permissions} (\n `id` int(9) NOT NULL auto_increment,\n `display_name` varchar(64) default NULL,\n `name` varchar(64) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {sessions} (\n `session_id` varchar(127) NOT NULL,\n `data` text NOT NULL,\n `last_activity` int(10) UNSIGNED NOT NULL,\n PRIMARY KEY (`session_id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {tasks} (\n `id` int(9) NOT NULL auto_increment,\n `callback` varchar(128) default NULL,\n `context` text NOT NULL,\n `done` boolean default 0,\n `name` varchar(128) default NULL,\n `owner_id` int(9) default NULL,\n `percent_complete` int(9) default 0,\n `state` varchar(32) default NULL,\n `status` varchar(255) default NULL,\n `updated` int(9) default NULL,\n PRIMARY KEY (`id`),\n KEY (`owner_id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {themes} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(64) default NULL,\n `version` int(9) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {vars} (\n `id` int(9) NOT NULL auto_increment,\n `module_name` varchar(64) NOT NULL,\n `name` varchar(64) NOT NULL,\n `value` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`module_name`, `name`))\n DEFAULT CHARSET=utf8;"); foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { @mkdir(VARPATH . $dir); } access::register_permission("view", "View"); access::register_permission("view_full", "View full size"); access::register_permission("edit", "Edit"); access::register_permission("add", "Add"); // Mark for translation (must be the same strings as used above) t("View full size"); t("View"); t("Edit"); t("Add"); $root = ORM::factory("item"); $root->type = "album"; $root->title = "Gallery"; $root->description = ""; $root->left_ptr = 1; $root->right_ptr = 2; $root->parent_id = 0; $root->level = 1; $root->thumb_dirty = 1; $root->resize_dirty = 1; $root->sort_column = "weight"; $root->sort_order = "ASC"; $root->save(); access::add_item($root); module::set_var("gallery", "active_site_theme", "wind"); module::set_var("gallery", "active_admin_theme", "admin_wind"); module::set_var("gallery", "page_size", 9); module::set_var("gallery", "thumb_size", 200); module::set_var("gallery", "resize_size", 640); module::set_var("gallery", "default_locale", "en_US"); module::set_var("gallery", "image_quality", 75); module::set_var("gallery", "image_sharpen", 15); // Add rules for generating our thumbnails and resizes graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => 200, "height" => 200, "master" => Image::AUTO), 100); graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => 640, "height" => 480, "master" => Image::AUTO), 100); // Instantiate default themes (site and admin) foreach (array("wind", "admin_wind") as $theme_name) { $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), ArrayObject::ARRAY_AS_PROPS); $theme = ORM::factory("theme"); $theme->name = $theme_name; $theme->version = $theme_info->version; $theme->save(); } block_manager::add("dashboard_sidebar", "gallery", "block_adder"); block_manager::add("dashboard_sidebar", "gallery", "stats"); block_manager::add("dashboard_sidebar", "gallery", "platform_info"); block_manager::add("dashboard_sidebar", "gallery", "project_news"); block_manager::add("dashboard_center", "gallery", "welcome"); block_manager::add("dashboard_center", "gallery", "photo_stream"); block_manager::add("dashboard_center", "gallery", "log_entries"); module::set_var("gallery", "choose_default_tookit", 1); module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); module::set_var("gallery", "simultaneous_upload_limit", 5); module::set_version("gallery", 21); }
private function _update_graphics_rules() { graphics::remove_rules("watermark"); if ($name = module::get_var("watermark", "name")) { foreach (array("thumb", "resize") as $target) { graphics::add_rule("watermark", $target, "gallery_graphics::composite", array("file" => VARPATH . "modules/watermark/{$name}", "width" => module::get_var("watermark", "width"), "height" => module::get_var("watermark", "height"), "position" => module::get_var("watermark", "position"), "transparency" => 101 - module::get_var("watermark", "transparency")), 1000); } } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE {access_caches} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n PRIMARY KEY (`id`),\n KEY (`item_id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {access_intents} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); // Using a simple index instead of a unique key for the // key column to avoid handling of concurrency issues // on insert. Thus allowing concurrent inserts on the // same cache key, as does Memcache / xcache. $db->query("CREATE TABLE {caches} (\n `id` int(9) NOT NULL auto_increment,\n `key` varchar(255) NOT NULL,\n `tags` varchar(255),\n `expiration` int(9) NOT NULL,\n `cache` longblob,\n PRIMARY KEY (`id`),\n UNIQUE KEY (`key`),\n KEY (`tags`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {failed_auths} (\n `id` int(9) NOT NULL auto_increment,\n `count` int(9) NOT NULL,\n `name` varchar(255) NOT NULL,\n `time` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {graphics_rules} (\n `id` int(9) NOT NULL auto_increment,\n `active` BOOLEAN default 0,\n `args` varchar(255) default NULL,\n `module_name` varchar(64) NOT NULL,\n `operation` varchar(64) NOT NULL,\n `priority` int(9) NOT NULL,\n `target` varchar(32) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {incoming_translations} (\n `id` int(9) NOT NULL auto_increment,\n `key` char(32) NOT NULL,\n `locale` char(10) NOT NULL,\n `message` text NOT NULL,\n `revision` int(9) DEFAULT NULL,\n `translation` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`, `locale`),\n KEY `locale_key` (`locale`, `key`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {items} (\n `id` int(9) NOT NULL auto_increment,\n `album_cover_item_id` int(9) default NULL,\n `captured` int(9) default NULL,\n `created` int(9) default NULL,\n `description` text default NULL,\n `height` int(9) default NULL,\n `left_ptr` int(9) NOT NULL,\n `level` int(9) NOT NULL,\n `mime_type` varchar(64) default NULL,\n `name` varchar(255) default NULL,\n `owner_id` int(9) default NULL,\n `parent_id` int(9) NOT NULL,\n `rand_key` decimal(11,10) default NULL,\n `relative_path_cache` varchar(255) default NULL,\n `relative_url_cache` varchar(255) default NULL,\n `resize_dirty` boolean default 1,\n `resize_height` int(9) default NULL,\n `resize_width` int(9) default NULL,\n `right_ptr` int(9) NOT NULL,\n `slug` varchar(255) default NULL,\n `sort_column` varchar(64) default NULL,\n `sort_order` char(4) default 'ASC',\n `thumb_dirty` boolean default 1,\n `thumb_height` int(9) default NULL,\n `thumb_width` int(9) default NULL,\n `title` varchar(255) default NULL,\n `type` varchar(32) NOT NULL,\n `updated` int(9) default NULL,\n `view_count` int(9) default 0,\n `weight` int(9) NOT NULL default 0,\n `width` int(9) default NULL,\n PRIMARY KEY (`id`),\n KEY `parent_id` (`parent_id`),\n KEY `type` (`type`),\n KEY `random` (`rand_key`),\n KEY `weight` (`weight` DESC),\n KEY `left_ptr` (`left_ptr`),\n KEY `relative_path_cache` (`relative_path_cache`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {logs} (\n `id` int(9) NOT NULL auto_increment,\n `category` varchar(64) default NULL,\n `html` varchar(255) default NULL,\n `message` text default NULL,\n `referer` varchar(255) default NULL,\n `severity` int(9) default 0,\n `timestamp` int(9) default 0,\n `url` varchar(255) default NULL,\n `user_id` int(9) default 0,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {messages} (\n `id` int(9) NOT NULL auto_increment,\n `key` varchar(255) default NULL,\n `severity` varchar(32) default NULL,\n `value` text default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {modules} (\n `id` int(9) NOT NULL auto_increment,\n `active` BOOLEAN default 0,\n `name` varchar(64) default NULL,\n `version` int(9) default NULL,\n `weight` int(9) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`),\n KEY (`weight`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {outgoing_translations} (\n `id` int(9) NOT NULL auto_increment,\n `base_revision` int(9) DEFAULT NULL,\n `key` char(32) NOT NULL,\n `locale` char(10) NOT NULL,\n `message` text NOT NULL,\n `translation` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`, `locale`),\n KEY `locale_key` (`locale`, `key`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {permissions} (\n `id` int(9) NOT NULL auto_increment,\n `display_name` varchar(64) default NULL,\n `name` varchar(64) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {sessions} (\n `session_id` varchar(127) NOT NULL,\n `data` text NOT NULL,\n `last_activity` int(10) UNSIGNED NOT NULL,\n PRIMARY KEY (`session_id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {tasks} (\n `id` int(9) NOT NULL auto_increment,\n `callback` varchar(128) default NULL,\n `context` text NOT NULL,\n `done` boolean default 0,\n `name` varchar(128) default NULL,\n `owner_id` int(9) default NULL,\n `percent_complete` int(9) default 0,\n `state` varchar(32) default NULL,\n `status` varchar(255) default NULL,\n `updated` int(9) default NULL,\n PRIMARY KEY (`id`),\n KEY (`owner_id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {themes} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(64) default NULL,\n `version` int(9) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {vars} (\n `id` int(9) NOT NULL auto_increment,\n `module_name` varchar(64) NOT NULL,\n `name` varchar(64) NOT NULL,\n `value` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`module_name`, `name`))\n DEFAULT CHARSET=utf8;"); foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { @mkdir(VARPATH . $dir); if (in_array($dir, array("logs", "tmp", "uploads"))) { self::_protect_directory(VARPATH . $dir); } } access::register_permission("view", "View"); access::register_permission("view_full", "View full size"); access::register_permission("edit", "Edit"); access::register_permission("add", "Add"); // Mark for translation (must be the same strings as used above) t("View full size"); t("View"); t("Edit"); t("Add"); // Hardcode the first item to sidestep ORM validation rules $now = time(); db::build()->insert("items", array("created" => $now, "description" => "", "left_ptr" => 1, "level" => 1, "parent_id" => 0, "resize_dirty" => 1, "right_ptr" => 2, "sort_column" => "weight", "sort_order" => "ASC", "thumb_dirty" => 1, "title" => "Gallery", "type" => "album", "updated" => $now, "weight" => 1))->execute(); $root = ORM::factory("item", 1); access::add_item($root); module::set_var("gallery", "active_site_theme", "wind"); module::set_var("gallery", "active_admin_theme", "admin_wind"); module::set_var("gallery", "page_size", 9); module::set_var("gallery", "thumb_size", 200); module::set_var("gallery", "resize_size", 640); module::set_var("gallery", "default_locale", "en_US"); module::set_var("gallery", "image_quality", 75); module::set_var("gallery", "image_sharpen", 15); module::set_var("gallery", "upgrade_checker_auto_enabled", true); // Add rules for generating our thumbnails and resizes graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => 200, "height" => 200, "master" => Image::AUTO), 100); graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => 640, "height" => 640, "master" => Image::AUTO), 100); // Instantiate default themes (site and admin) foreach (array("wind", "admin_wind") as $theme_name) { $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), ArrayObject::ARRAY_AS_PROPS); $theme = ORM::factory("theme"); $theme->name = $theme_name; $theme->version = $theme_info->version; $theme->save(); } block_manager::add("dashboard_sidebar", "gallery", "block_adder"); block_manager::add("dashboard_sidebar", "gallery", "stats"); block_manager::add("dashboard_sidebar", "gallery", "platform_info"); block_manager::add("dashboard_sidebar", "gallery", "project_news"); block_manager::add("dashboard_center", "gallery", "welcome"); block_manager::add("dashboard_center", "gallery", "upgrade_checker"); block_manager::add("dashboard_center", "gallery", "photo_stream"); block_manager::add("dashboard_center", "gallery", "log_entries"); module::set_var("gallery", "choose_default_tookit", 1); module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); module::set_var("gallery", "show_credits", 1); // Mark string for translation $powered_by_string = t("Powered by <a href=\"%url\">%gallery_version</a>", array("locale" => "root")); module::set_var("gallery", "credits", (string) $powered_by_string); module::set_var("gallery", "simultaneous_upload_limit", 5); module::set_var("gallery", "admin_area_timeout", 90 * 60); module::set_var("gallery", "maintenance_mode", 0); module::set_var("gallery", "visible_title_length", 15); module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); module::set_var("gallery", "email_from", ""); module::set_var("gallery", "email_reply_to", ""); module::set_var("gallery", "email_line_length", 70); module::set_var("gallery", "email_header_separator", serialize("\n")); module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); module::set_var("gallery", "timezone", null); module::set_var("gallery", "lock_timeout", 1); module::set_var("gallery", "movie_extract_frame_time", 3); module::set_var("gallery", "movie_allow_uploads", "autodetect"); }
static function install() { // Add rules for generating our thumbnails and resizes graphics::add_rule("square_thumbs", "thumb", "square_thumbs_graphics::crop_to_square", array(), 50); module::set_version("square_thumbs", 1); }
static function install() { $db = Database::instance(); $version = 0; try { $version = module::get_version("core"); } catch (Exception $e) { if ($e->getCode() != E_DATABASE_ERROR) { Kohana::log("error", $e); throw $e; } } if ($version == 0) { $db->query("CREATE TABLE `access_caches` (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `access_intents` (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `graphics_rules` (\n `id` int(9) NOT NULL auto_increment,\n `priority` int(9) NOT NULL,\n `module_name` varchar(64) NOT NULL,\n `target` varchar(32) NOT NULL,\n `operation` varchar(64) NOT NULL,\n `args` varchar(255) default NULL,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `items` (\n `album_cover_item_id` int(9) default NULL,\n `created` int(9) default NULL,\n `description` varchar(255) default NULL,\n `height` int(9) default NULL,\n `id` int(9) NOT NULL auto_increment,\n `left` int(9) NOT NULL,\n `level` int(9) NOT NULL,\n `mime_type` varchar(64) default NULL,\n `name` varchar(255) default NULL,\n `owner_id` int(9) default NULL,\n `parent_id` int(9) NOT NULL,\n `resize_height` int(9) default NULL,\n `resize_width` int(9) default NULL,\n `resize_dirty` boolean default 1,\n `right` int(9) NOT NULL,\n `thumb_height` int(9) default NULL,\n `thumb_width` int(9) default NULL,\n `thumb_dirty` boolean default 1,\n `title` varchar(255) default NULL,\n `type` varchar(32) NOT NULL,\n `updated` int(9) default NULL,\n `view_count` int(9) default 0,\n `width` int(9) default NULL,\n PRIMARY KEY (`id`),\n KEY `parent_id` (`parent_id`),\n KEY `type` (`type`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `logs` (\n `id` int(9) NOT NULL auto_increment,\n `category` varchar(64) default NULL,\n `html` varchar(255) default NULL,\n `message` text default NULL,\n `referer` varchar(255) default NULL,\n `severity` int(9) default 0,\n `timestamp` int(9) default 0,\n `url` varchar(255) default NULL,\n `user_id` int(9) default 0,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `messages` (\n `id` int(9) NOT NULL auto_increment,\n `key` varchar(255) default NULL,\n `value` varchar(255) default NULL,\n `severity` varchar(32) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `modules` (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(64) default NULL,\n `version` int(9) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `themes` (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(64) default NULL,\n `version` int(9) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `permissions` (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(64) default NULL,\n `display_name` varchar(64) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `incoming_translations` (\n `id` int(9) NOT NULL auto_increment,\n `key` binary(16) NOT NULL,\n `locale` char(10) NOT NULL,\n `message` text NOT NULL,\n `translation` text,\n `revision` int(9) DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`key`, `locale`),\n KEY `locale_key` (`locale`, `key`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `sessions` (\n `session_id` varchar(127) NOT NULL,\n `last_activity` int(10) UNSIGNED NOT NULL,\n `data` text NOT NULL,\n PRIMARY KEY (`session_id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `tasks` (\n `callback` varchar(128) default NULL,\n `context` text NOT NULL,\n `done` boolean default 0,\n `id` int(9) NOT NULL auto_increment,\n `updated` int(9) default NULL,\n `name` varchar(128) default NULL,\n `percent_complete` int(9) default 0,\n `state` varchar(32) default NULL,\n `status` varchar(255) default NULL,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `vars` (\n `id` int(9) NOT NULL auto_increment,\n `module_name` varchar(64) NOT NULL,\n `name` varchar(64) NOT NULL,\n `value` text,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`module_name`, `name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); foreach (array("albums", "resizes", "thumbs", "uploads", "modules") as $dir) { @mkdir(VARPATH . $dir); } access::register_permission("view", "View"); access::register_permission("view_full", "View Full Size"); access::register_permission("edit", "Edit"); $root = ORM::factory("item"); $root->type = 'album'; $root->title = "Gallery"; $root->description = "Welcome to your Gallery3"; $root->left = 1; $root->right = 2; $root->parent_id = 0; $root->level = 1; $root->thumb_dirty = 1; $root->resize_dirty = 1; $root->save(); access::add_item($root); module::set_var("core", "active_site_theme", "default"); module::set_var("core", "active_admin_theme", "admin_default"); module::set_var("core", "page_size", 9); module::set_var("core", "thumb_size", 200); module::set_var("core", "resize_size", 640); // Add rules for generating our thumbnails and resizes graphics::add_rule("core", "thumb", "resize", array("width" => 200, "height" => 200, "master" => Image::AUTO), 100); graphics::add_rule("core", "resize", "resize", array("width" => 640, "height" => 480, "master" => Image::AUTO), 100); // Detect a graphics toolkit $toolkits = graphics::detect_toolkits(); foreach (array("imagemagick", "graphicsmagick", "gd") as $tk) { if ($toolkits[$tk]) { module::set_var("core", "graphics_toolkit", $tk); if ($tk != "gd") { module::set_var("core", "graphics_toolkit_path", $toolkits[$tk]); } break; } } if (!module::get_var("core", "graphics_toolkit")) { site_status::warning(t("Graphics toolkit missing! Please <a href=\"%url\">choose a toolkit</a>", array("url" => url::site("admin/graphics"))), "missing_graphics_toolkit"); } // Instantiate default themes (site and admin) foreach (array("default", "admin_default") as $theme_name) { $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), ArrayObject::ARRAY_AS_PROPS); $theme = ORM::factory("theme"); $theme->name = $theme_name; $theme->version = $theme_info->version; $theme->save(); } block_manager::add("dashboard_sidebar", "core", "block_adder"); block_manager::add("dashboard_sidebar", "core", "stats"); block_manager::add("dashboard_sidebar", "core", "platform_info"); block_manager::add("dashboard_sidebar", "core", "project_news"); block_manager::add("dashboard_center", "core", "welcome"); block_manager::add("dashboard_center", "core", "photo_stream"); block_manager::add("dashboard_center", "core", "log_entries"); module::set_version("core", 1); module::set_var("core", "version", "3.0"); } }
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; } }