当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::get_arg方法代码示例

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


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

示例1: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         if ($config->get_int("ext_ipban_version") < 5) {
             $this->install();
         }
         $this->check_ip_ban();
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("ip_ban")) {
         if ($user->is_admin()) {
             if ($event->get_arg(0) == "add" && $user->check_auth_token()) {
                 if (isset($_POST['ip']) && isset($_POST['reason']) && isset($_POST['end'])) {
                     if (empty($_POST['end'])) {
                         $end = null;
                     } else {
                         $end = $_POST['end'];
                     }
                     send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'], $end));
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("ip_ban/list"));
                 }
             } else {
                 if ($event->get_arg(0) == "remove" && $user->check_auth_token()) {
                     if (isset($_POST['id'])) {
                         send_event(new RemoveIPBanEvent($_POST['id']));
                         $page->set_mode("redirect");
                         $page->set_redirect(make_link("ip_ban/list"));
                     }
                 } else {
                     if ($event->get_arg(0) == "list") {
                         $bans = isset($_GET["all"]) ? $this->get_bans() : $this->get_active_bans();
                         $this->theme->display_bans($page, $bans);
                     }
                 }
             }
         } else {
             $this->theme->display_permission_denied($page);
         }
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("IP Bans", make_link("ip_ban/list"));
         }
     }
     if ($event instanceof AddIPBanEvent) {
         $this->add_ip_ban($event->ip, $event->reason, $event->end, $user);
     }
     if ($event instanceof RemoveIPBanEvent) {
         $database->Execute("DELETE FROM bans WHERE id = :id", array("id" => $event->id));
         $database->cache->delete("ip_bans");
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:56,代码来源:main.php

示例2: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int("history_limit", -1);
         // shimmie is being installed so call install to create the table.
         if ($config->get_int("ext_tag_history_version") < 3) {
             $this->install();
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_history")) {
         if ($event->get_arg(0) == "revert") {
             // this is a request to revert to a previous version of the tags
             if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
                 $this->process_revert_request($_POST['revert']);
             }
         } else {
             if ($event->count_args() == 1) {
                 // must be an attempt to view a tag history
                 $image_id = int_escape($event->get_arg(0));
                 $this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
             } else {
                 $this->theme->display_global_page($page, $this->get_global_tag_history());
             }
         }
     }
     if ($event instanceof DisplayingImageEvent) {
         // handle displaying a link on the view page
         $this->theme->display_history_link($page, $event->image->id);
     }
     if ($event instanceof ImageDeletionEvent) {
         // handle removing of history when an image is deleted
         $this->delete_all_tag_history($event->image->id);
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag History");
         $sb->add_label("Limit to ");
         $sb->add_int_option("history_limit");
         $sb->add_label(" entires per image");
         $sb->add_label("<br>(-1 for unlimited)");
         $event->panel->add_block($sb);
     }
     if ($event instanceof TagSetEvent) {
         $this->add_tag_history($event->image, $event->tags);
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("Tag Changes", make_link("tag_history"));
         }
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:54,代码来源:main.php

示例3: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_edit")) {
         if ($event->get_arg(0) == "replace") {
             if ($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
                 $search = $_POST['search'];
                 $replace = $_POST['replace'];
                 $this->mass_tag_edit($search, $replace);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof ImageInfoSetEvent) {
         if ($this->can_tag()) {
             send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
             if ($this->can_source()) {
                 send_event(new SourceSetEvent($event->image, $_POST['tag_edit__source']));
             }
         } else {
             $this->theme->display_error($page, "Error", "Anonymous tag editing is disabled");
         }
     }
     if ($event instanceof TagSetEvent) {
         $event->image->set_tags($event->tags);
     }
     if ($event instanceof SourceSetEvent) {
         $event->image->set_source($event->source);
     }
     if ($event instanceof ImageDeletionEvent) {
         $event->image->delete_tags_from_image();
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_mass_editor($page);
     }
     // When an alias is added, oldtag becomes inaccessable
     if ($event instanceof AddAliasEvent) {
         $this->mass_tag_edit($event->oldtag, $event->newtag);
     }
     if ($event instanceof ImageInfoBoxBuildingEvent) {
         if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_tag_editor_html($event->image), 40);
         }
         if ($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_source_editor_html($event->image), 41);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Editing");
         $sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
         $sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
         $event->panel->add_block($sb);
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:58,代码来源:main.php

示例4: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("bookmark")) {
         if ($event->get_arg(0) == "add") {
             if (isset($_POST['url'])) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("user"));
             }
         } else {
             if ($event->get_arg(0) == "remove") {
                 if (isset($_POST['id'])) {
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("user"));
                 }
             }
         }
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:22,代码来源:main.php

示例5: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if ($this->theme == null) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int("tag_list_length", 15);
         $config->set_default_int("popular_tag_list_length", 15);
         $config->set_default_int("tags_min", 3);
         $config->set_default_string("info_link", 'http://en.wikipedia.org/wiki/$tag');
         $config->set_default_string("tag_list_image_type", 'related');
         $config->set_default_bool("tag_list_pages", false);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tags")) {
         $this->theme->set_navigation($this->build_navigation());
         switch ($event->get_arg(0)) {
             default:
             case 'map':
                 $this->theme->set_heading("Tag Map");
                 $this->theme->set_tag_list($this->build_tag_map());
                 break;
             case 'alphabetic':
                 $this->theme->set_heading("Alphabetic Tag List");
                 $this->theme->set_tag_list($this->build_tag_alphabetic());
                 break;
             case 'popularity':
                 $this->theme->set_heading("Tag List by Popularity");
                 $this->theme->set_tag_list($this->build_tag_popularity());
                 break;
             case 'categories':
                 $this->theme->set_heading("Popular Categories");
                 $this->theme->set_tag_list($this->build_tag_categories());
                 break;
         }
         $this->theme->display_page($page);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("api/internal/tag_list/complete")) {
         $all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 LIMIT 10", array("search" => $_GET["s"] . "%"));
         $res = array();
         foreach ($all as $row) {
             $res[] = $row["tag"];
         }
         $page->set_mode("data");
         $page->set_type("text/plain");
         $page->set_data(implode("\n", $res));
     }
     if ($event instanceof PostListBuildingEvent) {
         if ($config->get_int('tag_list_length') > 0) {
             if (!empty($event->search_terms)) {
                 $this->add_refine_block($page, $event->search_terms);
             } else {
                 $this->add_popular_block($page);
             }
         }
     }
     if ($event instanceof DisplayingImageEvent) {
         if ($config->get_int('tag_list_length') > 0) {
             if ($config->get_string('tag_list_image_type') == 'related') {
                 $this->add_related_block($page, $event->image);
             } else {
                 $this->add_tags_block($page, $event->image);
             }
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Map Options");
         $sb->add_int_option("tags_min", "Only show tags used at least ");
         $sb->add_label(" times");
         $sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: ");
         $event->panel->add_block($sb);
         $sb = new SetupBlock("Popular / Related Tag List");
         $sb->add_int_option("tag_list_length", "Show top ");
         $sb->add_label(" related tags");
         $sb->add_int_option("popular_tag_list_length", "<br>Show top ");
         $sb->add_label(" popular tags");
         $sb->add_text_option("info_link", "<br>Tag info link: ");
         $sb->add_choice_option("tag_list_image_type", array("Image's tags only" => "tags", "Show related" => "related"), "<br>Image tag list: ");
         $sb->add_bool_option("tag_list_numbers", "<br>Show tag counts: ");
         $event->panel->add_block($sb);
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:82,代码来源:main.php

示例6: onPageRequest

 public function onPageRequest(Event $event)
 {
     global $config, $database, $page, $user;
     // user info is shown on all pages
     if ($user->is_anonymous()) {
         $this->theme->display_login_block($page);
     } else {
         $ubbe = new UserBlockBuildingEvent();
         send_event($ubbe);
         ksort($ubbe->parts);
         $this->theme->display_user_block($page, $user, $ubbe->parts);
     }
     if ($event->page_matches("user_admin")) {
         if ($event->get_arg(0) == "login") {
             if (isset($_POST['user']) && isset($_POST['pass'])) {
                 $this->login($page);
             } else {
                 $this->theme->display_login_page($page);
             }
         } else {
             if ($event->get_arg(0) == "logout") {
                 set_prefixed_cookie("session", "", time() + 60 * 60 * 24 * $config->get_int('login_memory'), "/");
                 if (CACHE_HTTP) {
                     # to keep as few versions of content as possible,
                     # make cookies all-or-nothing
                     set_prefixed_cookie("user", "", time() + 60 * 60 * 24 * $config->get_int('login_memory'), "/");
                 }
                 log_info("user", "Logged out");
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link());
             } else {
                 if ($event->get_arg(0) == "change_pass") {
                     $this->change_password_wrapper($page);
                 } else {
                     if ($event->get_arg(0) == "change_email") {
                         $this->change_email_wrapper($page);
                     } else {
                         if ($event->get_arg(0) == "recover") {
                             $user = User::by_name($_POST['username']);
                             if (is_null($user)) {
                                 $this->theme->display_error($page, "Error", "There's no user with that name");
                             }
                             if (is_null($user->email)) {
                                 //
                             }
                         } else {
                             if ($event->get_arg(0) == "create") {
                                 if (!$config->get_bool("login_signup_enabled")) {
                                     $this->theme->display_signups_disabled($page);
                                 } else {
                                     if (!isset($_POST['name'])) {
                                         $this->theme->display_signup_page($page);
                                     } else {
                                         if ($_POST['pass1'] != $_POST['pass2']) {
                                             $this->theme->display_error($page, "Password Mismatch", "Passwords don't match");
                                         } else {
                                             try {
                                                 if (!captcha_check()) {
                                                     throw new UserCreationException("Error in captcha");
                                                 }
                                                 $uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email']);
                                                 send_event($uce);
                                                 $this->set_login_cookie($uce->username, $uce->password);
                                                 $page->set_mode("redirect");
                                                 $page->set_redirect(make_link("user"));
                                             } catch (UserCreationException $ex) {
                                                 $this->theme->display_error($page, "User Creation Error", $ex->getMessage());
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if ($event->get_arg(0) == "set_more") {
                                     $this->set_more_wrapper($page);
                                 } else {
                                     if ($event->get_arg(0) == "list") {
                                         // select users.id,name,joindate,admin,
                                         // (select count(*) from images where images.owner_id=users.id) as images,
                                         // (select count(*) from comments where comments.owner_id=users.id) as comments from users;
                                         // select users.id,name,joindate,admin,image_count,comment_count
                                         // from users
                                         // join (select owner_id,count(*) as image_count from images group by owner_id) as _images on _images.owner_id=users.id
                                         // join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id;
                                         $this->theme->display_user_list($page, User::by_list(0), $user);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("user")) {
         $display_user = $event->count_args() == 0 ? $user : User::by_name($event->get_arg(0));
         if ($event->count_args() == 0 && $user->is_anonymous()) {
             $this->theme->display_error($page, "Not Logged In", "You aren't logged in. First do that, then you can see your stats.");
         } else {
             if (!is_null($display_user)) {
                 send_event(new UserPageBuildingEvent($display_user));
//.........这里部分代码省略.........
开发者ID:nsuan,项目名称:shimmie2,代码行数:101,代码来源:main.php

示例7: onPageRequest

 public function onPageRequest(Event $event)
 {
     global $page, $database, $user;
     if ($event->page_matches("blotter")) {
         switch ($event->get_arg(0)) {
             case "editor":
                 /**
                  * Displays the blotter editor.
                  */
                 if (!$user->is_admin()) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC");
                     $this->theme->display_editor($entries);
                 }
                 break;
             case "add":
                 /**
                  * Adds an entry
                  */
                 if (!$user->is_admin() || !$user->check_auth_token()) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     $entry_text = $_POST['entry_text'];
                     if ($entry_text == "") {
                         die("No entry message!");
                     }
                     if (isset($_POST['important'])) {
                         $important = 'Y';
                     } else {
                         $important = 'N';
                     }
                     // Now insert into db:
                     $database->execute("INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), ?, ?)", array($entry_text, $important));
                     log_info("blotter", "Added Message: {$entry_text}");
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("blotter/editor"));
                 }
                 break;
             case "remove":
                 /**
                  * Removes an entry
                  */
                 if (!$user->is_admin() || !$user->check_auth_token()) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     $id = int_escape($_POST['id']);
                     if (!isset($id)) {
                         die("No ID!");
                     }
                     $database->Execute("DELETE FROM blotter WHERE id=:id", array("id" => $id));
                     log_info("blotter", "Removed Entry #{$id}");
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("blotter/editor"));
                 }
                 break;
             case "":
                 /**
                  * Displays all blotter entries
                  */
                 $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC");
                 $this->theme->display_blotter_page($entries);
                 break;
         }
     }
     /**
      * Finally, display the blotter on whatever page we're viewing.
      */
     $this->display_blotter();
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:70,代码来源:main.php


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