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


PHP PageRequestEvent::page_matches方法代码示例

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


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

示例1: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $config, $user, $page;
     if ($user->is_admin() && isset($_GET['sha'])) {
         if ($event->page_matches("update/download")) {
             $ok = $this->download_shimmie();
             $page->set_mode("redirect");
             if ($ok) {
                 $page->set_redirect(make_link("update/update", "sha=" . $_GET['sha']));
             } else {
                 $page->set_redirect(make_link("admin"));
             }
             //TODO: Show error?
         } elseif ($event->page_matches("update/update")) {
             $ok = $this->update_shimmie();
             $page->set_mode("redirect");
             if ($ok) {
                 $page->set_redirect(make_link("admin"));
             } else {
                 $page->set_redirect(make_link("admin"));
             }
             //TODO: Show error?
         }
     }
 }
开发者ID:JarJak,项目名称:shimmie2,代码行数:25,代码来源:main.php

示例2: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     if ($event->page_matches("source_history/revert")) {
         // this is a request to revert to a previous version of the source
         if ($user->can("edit_image_tag")) {
             if (isset($_POST['revert'])) {
                 $this->process_revert_request($_POST['revert']);
             }
         }
     } else {
         if ($event->page_matches("source_history/bulk_revert")) {
             if ($user->can("bulk_edit_image_tag") && $user->check_auth_token()) {
                 $this->process_bulk_revert_request();
             }
         } else {
             if ($event->page_matches("source_history/all")) {
                 $page_id = int_escape($event->get_arg(0));
                 $this->theme->display_global_page($page, $this->get_global_source_history($page_id), $page_id);
             } else {
                 if ($event->page_matches("source_history") && $event->count_args() == 1) {
                     // must be an attempt to view a source history
                     $image_id = int_escape($event->get_arg(0));
                     $this->theme->display_history_page($page, $image_id, $this->get_source_history_from_id($image_id));
                 }
             }
         }
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:29,代码来源:main.php

示例3: is_safe_page

 private function is_safe_page(PageRequestEvent $event)
 {
     if ($event->page_matches("user_admin/login")) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:8,代码来源:main.php

示例4: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     if ($event->page_matches("post/prev") || $event->page_matches("post/next")) {
         $image_id = int_escape($event->get_arg(0));
         if (isset($_GET['search'])) {
             $search_terms = explode(' ', $_GET['search']);
             $query = "#search=" . url_escape($_GET['search']);
         } else {
             $search_terms = array();
             $query = null;
         }
         $image = Image::by_id($image_id);
         if ($event->page_matches("post/next")) {
             $image = $image->get_next($search_terms);
         } else {
             $image = $image->get_prev($search_terms);
         }
         if (!is_null($image)) {
             $page->set_mode("redirect");
             $page->set_redirect(make_link("post/view/{$image->id}", $query));
         } else {
             $this->theme->display_error($page, "Image not found", "No more images");
         }
     }
     if ($event->page_matches("post/view")) {
         $image_id = int_escape($event->get_arg(0));
         $image = Image::by_id($image_id);
         if (!is_null($image)) {
             send_event(new DisplayingImageEvent($image));
             $iabbe = new ImageAdminBlockBuildingEvent($image, $user);
             send_event($iabbe);
             ksort($iabbe->parts);
             $this->theme->display_admin_block($page, $iabbe->parts);
         } else {
             $this->theme->display_error($page, "Image not found", "No image in the database has the ID #{$image_id}");
         }
     }
     if ($event->page_matches("post/set")) {
         $image_id = int_escape($_POST['image_id']);
         send_event(new ImageInfoSetEvent(Image::by_id($image_id)));
         $page->set_mode("redirect");
         $page->set_redirect(make_link("post/view/{$image_id}", url_escape($_POST['query'])));
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:45,代码来源:main.php

示例5: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $database, $page;
     if ($event->page_matches("api/shimmie")) {
         $page->set_mode("data");
         $page->set_type("text/plain");
         if ($event->page_matches("api/shimmie/get_tags")) {
             if ($event->count_args() == 2) {
                 $all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE ?", array($event->get_arg(0) . "%"));
             } else {
                 $all = $database->get_all("SELECT tag FROM tags");
             }
             $res = array();
             foreach ($all as $row) {
                 $res[] = $row["tag"];
             }
             $page->set_data(json_encode($res));
         }
         if ($event->page_matches("api/shimmie/get_image")) {
             $image = Image::by_id(int_escape($event->get_arg(0)));
             $image->get_tag_array();
             // tag data isn't loaded into the object until necessary
             $safe_image = new _SafeImage($image);
             $page->set_data(json_encode($safe_image));
         }
         if ($event->page_matches("api/shimmie/find_images")) {
             $search_terms = $event->get_search_terms();
             $page_number = $event->get_page_number();
             $page_size = $event->get_page_size();
             $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms);
             $safe_images = array();
             foreach ($images as $image) {
                 $image->get_tag_array();
                 $safe_images[] = new _SafeImage($image);
             }
             $page->set_data(json_encode($safe_images));
         }
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:39,代码来源:main.php

示例6: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $config, $database, $page, $user;
     if ($event->page_matches("image_hash_ban")) {
         if ($user->is_admin()) {
             if ($event->get_arg(0) == "dnp") {
                 $image = Image::by_id(int_escape($event->get_arg(1)));
                 if ($image) {
                     send_event(new AddImageHashBanEvent($image->hash, "DNP"));
                     send_event(new ImageDeletionEvent($image));
                 }
                 $page->set_mode("redirect");
                 $page->set_redirect($_SERVER["HTTP_REFERER"]);
             } else {
                 if ($event->get_arg(0) == "add") {
                     if (isset($_POST['hash']) && isset($_POST['reason'])) {
                         send_event(new AddImageHashBanEvent($_POST['hash'], $_POST['reason']));
                         $page->set_mode("redirect");
                         $page->set_redirect(make_link("image_hash_ban/list/1"));
                     }
                     if (isset($_POST['image_id'])) {
                         $image = Image::by_id(int_escape($_POST['image_id']));
                         if ($image) {
                             send_event(new ImageDeletionEvent($image));
                             $page->set_mode("redirect");
                             $page->set_redirect(make_link("post/list"));
                         }
                     }
                 } else {
                     if ($event->get_arg(0) == "remove") {
                         if (isset($_POST['hash'])) {
                             send_event(new RemoveImageHashBanEvent($_POST['hash']));
                             $page->set_mode("redirect");
                             $page->set_redirect(make_link("image_hash_ban/list/1"));
                         }
                     } else {
                         if ($event->get_arg(0) == "list") {
                             $page_num = 0;
                             if ($event->count_args() == 2) {
                                 $page_num = int_escape($event->get_arg(1));
                             }
                             $page_size = 100;
                             $page_count = ceil($database->get_one("SELECT COUNT(id) FROM image_bans") / $page_size);
                             $this->theme->display_Image_hash_Bans($page, $page_num, $page_count, $this->get_image_hash_bans($page_num, $page_size));
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:51,代码来源:main.php


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