本文整理汇总了PHP中block_manager::add方法的典型用法代码示例。如果您正苦于以下问题:PHP block_manager::add方法的具体用法?PHP block_manager::add怎么用?PHP block_manager::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block_manager
的用法示例。
在下文中一共展示了block_manager::add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
static function upgrade($version)
{
if ($version == 1) {
block_manager::add("site.sidebar", "image_block", "random_image");
module::set_version("image_block", 2);
}
}
示例2: install
static function install()
{
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {comments} (\n `author_id` int(9) default NULL,\n `created` int(9) NOT NULL,\n `guest_email` varchar(128) default NULL,\n `guest_name` varchar(128) default NULL,\n `guest_url` varchar(255) default NULL,\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `server_http_accept_charset` varchar(64) default NULL,\n `server_http_accept_encoding` varchar(64) default NULL,\n `server_http_accept_language` varchar(64) default NULL,\n `server_http_accept` varchar(128) default NULL,\n `server_http_connection` varchar(64) default NULL,\n `server_http_host` varchar(64) default NULL,\n `server_http_referer` varchar(255) default NULL,\n `server_http_user_agent` varchar(128) default NULL,\n `server_query_string` varchar(64) default NULL,\n `server_remote_addr` varchar(32) default NULL,\n `server_remote_host` varchar(64) default NULL,\n `server_remote_port` varchar(16) default NULL,\n `state` varchar(15) default 'unpublished',\n `text` text,\n `updated` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;");
block_manager::add("dashboard_center", "comment", "recent_comments");
module::set_var("comment", "spam_caught", 0);
module::set_version("comment", 2);
}
示例3: activate_blocks
static function activate_blocks($module_name)
{
$block_class = "{$module_name}_block";
if (class_exists($block_class) && method_exists($block_class, "get_site_list")) {
$blocks = call_user_func(array($block_class, "get_site_list"));
foreach (array_keys($blocks) as $block_id) {
block_manager::add("site_sidebar", $module_name, $block_id);
}
}
}
示例4: add_block
public function add_block()
{
$form = core_block::get_add_block_form();
if ($form->validate()) {
list($module_name, $block_id) = explode(":", $form->add_block->id->value);
$available = block_manager::get_available();
if ($form->add_block->center->value) {
block_manager::add("dashboard_center", $module_name, $block_id);
message::success(t("Added <b>%title</b> block to the dashboard center", array("title" => $available["{$module_name}:{$id}"])));
} else {
block_manager::add("dashboard_sidebar", $module_name, $block_id);
message::success(t("Added <b>%title</b> to the dashboard sidebar", array("title" => $available["{$module_name}:{$id}"])));
}
}
url::redirect("admin/dashboard");
}
示例5: install
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);
}
示例6: install
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");
}
示例7: install
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");
}
}