• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP module类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中module的典型用法代码示例。如果您正苦于以下问题:PHP module类的具体用法?PHP module怎么用?PHP module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了module类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: upgrade

 public function upgrade()
 {
     if (php_sapi_name() == "cli") {
         // @todo this may screw up some module installers, but we don't have a better answer at
         // this time.
         $_SERVER["HTTP_HOST"] = "example.com";
     } else {
         if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
     }
     // Upgrade gallery and user first
     module::install("gallery");
     module::install("user");
     // Then upgrade the rest
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             module::install($id);
         }
     }
     if (php_sapi_name() == "cli") {
         print "Upgrade complete\n";
     } else {
         url::redirect("upgrader?done=1");
     }
 }
开发者ID:kstyrvoll,项目名称:gallery3,代码行数:29,代码来源:upgrader.php


示例2: save

 function save($album_id)
 {
     access::verify_csrf();
     $album = ORM::factory("item", $album_id);
     access::required("edit", $album);
     if (Input::instance()->post("save")) {
         $titles = Input::instance()->post("title");
         $descriptions = Input::instance()->post("description");
         $filenames = Input::instance()->post("filename");
         $internetaddresses = Input::instance()->post("internetaddress");
         $tags = Input::instance()->post("tags");
         $enable_tags = module::is_active("tag");
         foreach (array_keys($titles) as $id) {
             $item = ORM::factory("item", $id);
             if ($item->loaded() && access::can("edit", $item)) {
                 $item->title = $titles[$id];
                 $item->description = $descriptions[$id];
                 $item->name = $filenames[$id];
                 $item->slug = $internetaddresses[$id];
                 $item->save();
                 if ($enable_tags) {
                     tag::clear_all($item);
                     foreach (explode(",", $tags[$id]) as $tag_name) {
                         if ($tag_name) {
                             tag::add($item, trim($tag_name));
                         }
                     }
                     tag::compact();
                 }
             }
         }
         message::success(t("Captions saved"));
     }
     url::redirect($album->abs_url());
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:35,代码来源:captionator.php


示例3: get

 static function get($block_id, $theme)
 {
     $block = "";
     switch ($block_id) {
         case "random_image":
             // The random_query approach is flawed and doesn't always return a
             // result when there actually is one. Retry a *few* times.
             // @todo Consider another fallback if further optimizations are necessary.
             $image_count = module::get_var("image_block", "image_count");
             $items = array();
             for ($i = 0; $i < $image_count; $i++) {
                 $attempts = 0;
                 $item = null;
                 do {
                     $item = item::random_query()->where("type", "!=", "album")->find_all(1)->current();
                 } while (!$item && $attempts++ < 3);
                 if ($item) {
                     $items[] = $item;
                 }
             }
             if ($items) {
                 $block = new Block();
                 $block->css_id = "g-image-block";
                 $block->title = t2("Random image", "Random images", $image_count);
                 $block->content = new View("image_block_block.html");
                 $block->content->items = $items;
             }
             break;
     }
     return $block;
 }
开发者ID:Joe7,项目名称:gallery3,代码行数:31,代码来源:image_block_block.php


示例4: uninstall

 static function uninstall()
 {
     // Delete the face mapping table before uninstalling.
     $db = Database::instance();
     $db->query("DROP TABLE IF EXISTS {picasa_faces};");
     module::delete("picasa_faces");
 }
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:7,代码来源:picasa_faces_installer.php


示例5: _dump_database

 private function _dump_database()
 {
     // We now have a clean install with just the packages that we want.  Make sure that the
     // database is clean too.
     $i = 1;
     foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $key) {
         $blocks = array();
         foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) {
             $blocks[++$i] = $value;
         }
         module::set_var("gallery", "blocks_{$key}", serialize($blocks));
     }
     Database::instance()->query("TRUNCATE {caches}");
     Database::instance()->query("TRUNCATE {sessions}");
     Database::instance()->query("TRUNCATE {logs}");
     db::build()->update("users")->set(array("password" => ""))->where("id", "in", array(1, 2))->execute();
     $dbconfig = Kohana::config('database.default');
     $conn = $dbconfig["connection"];
     $sql_file = DOCROOT . "installer/install.sql";
     if (!is_writable($sql_file)) {
         print "{$sql_file} is not writeable";
         return;
     }
     $command = sprintf("mysqldump --compact --skip-extended-insert --add-drop-table %s %s %s %s > {$sql_file}", escapeshellarg("-h{$conn['host']}"), escapeshellarg("-u{$conn['user']}"), $conn['pass'] ? escapeshellarg("-p{$conn['pass']}") : "", escapeshellarg($conn['database']));
     exec($command, $output, $status);
     if ($status) {
         print "<pre>";
         print "{$command}\n";
         print "Failed to dump database\n";
         print implode("\n", $output);
         return;
     }
     // Post-process the sql file
     $buf = "";
     $root = ORM::factory("item", 1);
     $root_created_timestamp = $root->created;
     $root_updated_timestamp = $root->updated;
     $table_name = "";
     foreach (file($sql_file) as $line) {
         // Prefix tables
         $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line);
         if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) {
             $table_name = $matches[1];
         }
         // Normalize dates
         $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM
         if ($table_name != "search_records") {
             $line = preg_replace("/ENGINE=\\S+ /", "", $line);
         }
         // Null out ids in the vars table since it's an auto_increment table and this will result in
         // more stable values so we'll have less churn in install.sql.
         $line = preg_replace("/^INSERT INTO {vars} VALUES \\(\\d+/", "INSERT INTO {vars} VALUES (NULL", $line);
         $buf .= $line;
     }
     $fd = fopen($sql_file, "wb");
     fwrite($fd, $buf);
     fclose($fd);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:60,代码来源:packager.php


示例6: photo_menu

 static function photo_menu($menu, $theme)
 {
     if (module::get_var("ecard", "location") == "top") {
         $item = $theme->item();
         $menu->append(Menu::factory("link")->id("ecard")->label(t("Send as eCard"))->url(url::site("ecard/form_send/{$item->id}"))->css_class("g-dialog-link ui-icon-ecard")->css_id("g-send-ecard"));
     }
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:7,代码来源:ecard_event.php


示例7: _show

 private function _show($album)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = Input::instance()->get("page", "1");
     $album_defn = unserialize(module::get_var("dynamic", $album));
     $children_count = $album_defn->limit;
     if (empty($children_count)) {
         $children_count = ORM::factory("item")->viewable()->where("type", "!=", "album")->count_all();
     }
     $offset = ($page - 1) * $page_size;
     $max_pages = ceil($children_count / $page_size);
     // Make sure that the page references a valid offset
     if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) {
         throw new Kohana_404_Exception();
     }
     $template = new Theme_View("page.html", "collection", "dynamic");
     $template->set_global("page", $page);
     $template->set_global("page_size", $page_size);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("children", ORM::factory("item")->viewable()->where("type", "!=", "album")->order_by($album_defn->key_field, "DESC")->find_all($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     $template->content->title = t($album_defn->title);
     print $template;
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:25,代码来源:dynamic.php


示例8: install

 static function install()
 {
     $db = Database::instance();
     $db->query("CREATE TABLE IF NOT EXISTS {item_links} (\n               `id` int(9) NOT NULL auto_increment,\n               `item_id` int(9) NOT NULL,\n               `url` text default NULL,\n               PRIMARY KEY (`id`),\n               KEY(`item_id`, `id`))\n               DEFAULT CHARSET=utf8;");
     // Set the module's version number.
     module::set_version("item_links", 1);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:7,代码来源:item_links_installer.php


示例9: admin

 static function admin($menu, $theme)
 {
     $menu->get("settings_menu")->append(Menu::factory("link")->id("akismet")->label(t("Akismet"))->url(url::site("admin/akismet")));
     if (module::get_var("akismet", "api_key")) {
         $menu->get("statistics_menu")->append(Menu::factory("link")->id("akismet")->label(t("Akismet"))->url(url::site("admin/akismet/stats")));
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:7,代码来源:akismet_menu.php


示例10: googlemap

 public function googlemap($fullsize)
 {
     // Display all tags with GPS coordinates on a google map.
     // Generate a list of GPS coordinates.
     $tagsGPS = ORM::factory("tags_gps")->find_all();
     // Set up and display the actual page.
     //  If fullsize is true, allow the map to take up the entire browser window,
     //  if not, then display the map in the gallery theme.
     if ($fullsize == true) {
         $view = new View("tagsmap_googlemap.html");
         $view->map_fullsize = true;
         // Load in module preferences.
         $view->tags_gps = $tagsGPS;
         $view->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
         $view->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
         $view->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
         $view->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
         $view->google_map_type = module::get_var("tagsmap", "googlemap_type");
         print $view;
     } else {
         $template = new Theme_View("page.html", "TagsMap");
         $template->page_title = t("Gallery :: Map");
         $template->content = new View("tagsmap_googlemap.html");
         // Load in module preferences.
         $template->content->tags_gps = $tagsGPS;
         $template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
         $template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
         $template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
         $template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
         $template->content->google_map_type = module::get_var("tagsmap", "googlemap_type");
         print $template;
     }
 }
开发者ID:ChrisRut,项目名称:gallery3-contrib,代码行数:33,代码来源:tagsmap.php


示例11: _update

 /**
  * @see REST_Controller::_update($resource)
  */
 public function _update($photo)
 {
     access::verify_csrf();
     access::required("view", $photo);
     access::required("edit", $photo);
     $form = photo::get_edit_form($photo);
     if ($valid = $form->validate()) {
         if ($form->edit_photo->filename->value != $photo->name) {
             // Make sure that there's not a conflict
             if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_photo->filename->value)->count_records()) {
                 $form->edit_photo->filename->add_error("conflict", 1);
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $photo->title = $form->edit_photo->title->value;
         $photo->description = $form->edit_photo->description->value;
         $photo->rename($form->edit_photo->filename->value);
         $photo->save();
         module::event("photo_edit_form_completed", $photo, $form);
         log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
         message::success(t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
         print json_encode(array("result" => "success", "location" => url::site("photos/{$photo->id}")));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:hiwilson,项目名称:gallery3,代码行数:31,代码来源:photos.php


示例12: uninstall

 static function uninstall()
 {
     $db = Database::instance();
     $sql = "SELECT `item_id` FROM {comments}";
     module::event("item_related_update_batch", $sql);
     $db->query("DROP TABLE IF EXISTS {comments};");
 }
开发者ID:xafr,项目名称:gallery3,代码行数:7,代码来源:comment_installer.php


示例13: api_key

 static function api_key($api_key = null)
 {
     if ($api_key !== null) {
         module::set_var("gallery", "l10n_client_key", $api_key);
     }
     return module::get_var("gallery", "l10n_client_key", "");
 }
开发者ID:shai,项目名称:gallery3,代码行数:7,代码来源:l10n_client.php


示例14: create

 /**
  * Create a new album.
  * @param integer $parent_id id of parent album
  * @param string  $name the name of this new album (it will become the directory name on disk)
  * @param integer $title the title of the new album
  * @param string  $description (optional) the longer description of this album
  * @return Item_Model
  */
 static function create($parent, $name, $title, $description = null, $owner_id = null)
 {
     if (!$parent->loaded || !$parent->is_album()) {
         throw new Exception("@todo INVALID_PARENT");
     }
     if (strpos($name, "/")) {
         throw new Exception("@todo NAME_CANNOT_CONTAIN_SLASH");
     }
     // We don't allow trailing periods as a security measure
     // ref: http://dev.kohanaphp.com/issues/684
     if (rtrim($name, ".") != $name) {
         throw new Exception("@todo NAME_CANNOT_END_IN_PERIOD");
     }
     $album = ORM::factory("item");
     $album->type = "album";
     $album->title = $title;
     $album->description = $description;
     $album->name = $name;
     $album->owner_id = $owner_id;
     $album->thumb_dirty = 1;
     $album->resize_dirty = 1;
     $album->rand_key = (double) mt_rand() / (double) mt_getrandmax();
     $album->sort_column = "weight";
     $album->sort_order = "ASC";
     while (ORM::factory("item")->where("parent_id", $parent->id)->where("name", $album->name)->find()->id) {
         $album->name = "{$name}-" . rand();
     }
     $album = $album->add_to_parent($parent);
     mkdir($album->file_path());
     mkdir(dirname($album->thumb_path()));
     mkdir(dirname($album->resize_path()));
     module::event("item_created", $album);
     return $album;
 }
开发者ID:xafr,项目名称:gallery3,代码行数:42,代码来源:album.php


示例15: save

 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;
     }
 }
开发者ID:brocki,项目名称:gallery3,代码行数:31,代码来源:admin_theme_options.php


示例16: save

 public function save()
 {
     access::verify_csrf();
     $changes->activate = array();
     $changes->deactivate = array();
     $activated_names = array();
     $deactivated_names = array();
     foreach (module::available() as $module_name => $info) {
         if ($info->locked) {
             continue;
         }
         $desired = $this->input->post($module_name) == 1;
         if ($info->active && !$desired && module::is_active($module_name)) {
             $changes->deactivate[] = $module_name;
             $deactivated_names[] = $info->name;
             module::deactivate($module_name);
         } else {
             if (!$info->active && $desired && !module::is_active($module_name)) {
                 $changes->activate[] = $module_name;
                 $activated_names[] = $info->name;
                 module::install($module_name);
                 module::activate($module_name);
             }
         }
     }
     module::event("module_change", $changes);
     // @todo this type of collation is questionable from a i18n perspective
     if ($activated_names) {
         message::success(t("Activated: %names", array("names" => join(", ", $activated_names))));
     }
     if ($deactivated_names) {
         message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names))));
     }
     url::redirect("admin/modules");
 }
开发者ID:xafr,项目名称:gallery3,代码行数:35,代码来源:admin_modules.php


示例17: start

 function start($id)
 {
     access::verify_csrf();
     $paths = unserialize(module::get_var("server_add", "authorized_paths"));
     $input_files = $this->input->post("path");
     $files = array();
     $total_count = 0;
     foreach (array_keys($paths) as $valid_path) {
         $path_length = strlen($valid_path);
         foreach ($input_files as $key => $path) {
             if ($valid_path != $path && strpos($path, $valid_path) === 0) {
                 $relative_path = substr(dirname($path), $path_length);
                 $name = basename($path);
                 $files[$valid_path][] = array("path" => $relative_path, "parent_id" => $id, "name" => basename($path), "type" => is_dir($path) ? "album" : "file");
                 $total_count++;
                 unset($input_files[$key]);
             }
         }
     }
     if ($total_count == 0) {
         print json_encode(array("result" => "success", "url" => "", "task" => array("id" => -1, "done" => 1, "percent_complete" => 100, "status" => t("No Eligible files, import cancelled"))));
         return;
     }
     $task_def = Task_Definition::factory()->callback("server_add_task::add_from_server")->description(t("Add photos or movies from the local server"))->name(t("Add from server"));
     $task = task::create($task_def, array("item_id" => $id, "next_path" => 0, "files" => $files, "counter" => 0, "position" => 0, "total" => $total_count));
     batch::start();
     print json_encode(array("result" => "started", "url" => url::site("server_add/add_photo/{$task->id}?csrf=" . access::csrf_token()), "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:28,代码来源:server_add.php


示例18: required

 static function required($perm_name, $item)
 {
     // Original code from the required function in modules/gallery/helpers/access.php.
     if (!access::can($perm_name, $item)) {
         if ($perm_name == "view") {
             // Treat as if the item didn't exist, don't leak any information.
             throw new Kohana_404_Exception();
         } else {
             access::forbidden();
         }
         // Begin rWatcher modifications.
         //   Throw a 404 error when a user attempts to access a protected item,
         //   unless the password has been provided, or the user is the item's owner.
     } elseif (module::get_var("albumpassword", "hideonly") == false) {
         $item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
         if (count($item_protected) > 0) {
             $existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
             if ($existing_password->loaded()) {
                 if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
                     throw new Kohana_404_Exception();
                 }
             }
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:25,代码来源:MY_access.php


示例19: _get_admin_form

 private function _get_admin_form()
 {
     $form = new Forge("admin/star/save", "", "post", array("id" => "g-star-admin-form"));
     $form->dropdown("show")->label(t("Default to showing..."))->options(array(0 => "All", 1 => "Starred"))->selected(module::get_var("star", "show"));
     $form->submit("save")->value(t("Save"));
     return $form;
 }
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:7,代码来源:admin_star.php


示例20: save

 public function save($module_name, $var_name)
 {
     access::verify_csrf();
     module::set_var($module_name, $var_name, Input::instance()->post("value"));
     message::success(t("Saved value for %var (%module_name)", array("var" => $var_name, "module_name" => $module_name)));
     json::reply(array("result" => "success"));
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:7,代码来源:admin_advanced_settings.php



注:本文中的module类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP module_config类代码示例发布时间:2022-05-23
下一篇:
PHP model_cache类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap