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


PHP PageRequestEvent::get_arg方法代码示例

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


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

示例1: get_list_pageinfo

 /**
  * Returns info about the current page number.
  *
  * @param PageRequestEvent $event
  * @return array
  */
 private function get_list_pageinfo(PageRequestEvent $event)
 {
     global $config, $database;
     // get the amount of images per page
     $images_per_page = $config->get_int('index_images');
     // if there are no tags, use default
     if (is_null($event->get_arg(1))) {
         $prefix = "";
         $page_number = int_escape($event->get_arg(0));
         $total_pages = ceil($database->get_one("SELECT COUNT(*) FROM images") / $images_per_page);
     } else {
         // if there are tags, use pages with tags
         $prefix = url_escape($event->get_arg(0)) . "/";
         $page_number = int_escape($event->get_arg(1));
         $total_pages = ceil($database->get_one("SELECT count FROM tags WHERE tag=:tag", array("tag" => $event->get_arg(0))) / $images_per_page);
     }
     // creates previous & next values
     // When previous first page, go to last page
     if ($page_number <= 1) {
         $prev = $total_pages;
     } else {
         $prev = $page_number - 1;
     }
     if ($page_number >= $total_pages) {
         $next = 1;
     } else {
         $next = $page_number + 1;
     }
     // Create return array
     $pageinfo = array("prev" => $prefix . $prev, "next" => $prefix . $next);
     return $pageinfo;
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:38,代码来源: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: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     $this->getTip();
     if ($event->page_matches("tips") && $user->is_admin()) {
         switch ($event->get_arg(0)) {
             case "list":
                 $this->manageTips();
                 $this->getAll();
                 break;
             case "save":
                 if ($user->check_auth_token()) {
                     $this->saveTip();
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("tips/list"));
                 }
                 break;
             case "status":
                 // FIXME: HTTP GET CSRF
                 $tipID = int_escape($event->get_arg(1));
                 $this->setStatus($tipID);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("tips/list"));
                 break;
             case "delete":
                 // FIXME: HTTP GET CSRF
                 $tipID = int_escape($event->get_arg(1));
                 $this->deleteTip($tipID);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("tips/list"));
                 break;
         }
     }
 }
开发者ID:JarJak,项目名称:shimmie2,代码行数:34,代码来源:main.php

示例4: 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

示例5: api_danbooru

 private function api_danbooru(PageRequestEvent $event)
 {
     global $page;
     $page->set_mode("data");
     if ($event->get_arg(1) == 'add_post' || $event->get_arg(1) == 'post' && $event->get_arg(2) == 'create.xml') {
         // No XML data is returned from this function
         $page->set_type("text/plain");
         $this->api_add_post();
     } elseif ($event->get_arg(1) == 'find_posts' || $event->get_arg(1) == 'post' && $event->get_arg(2) == 'index.xml') {
         $page->set_type("application/xml");
         $page->set_data($this->api_find_posts());
     } elseif ($event->get_arg(1) == 'find_tags') {
         $page->set_type("application/xml");
         $page->set_data($this->api_find_tags());
     } elseif ($event->get_arg(1) == 'post' && $event->get_arg(2) == 'show') {
         $fixedlocation = make_link("post/view/" . $event->get_arg(3));
         $page->set_mode("redirect");
         $page->set_redirect($fixedlocation);
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:20,代码来源:main.php

示例6: 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

示例7: 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


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