當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PageRequestEvent類代碼示例

本文整理匯總了PHP中PageRequestEvent的典型用法代碼示例。如果您正苦於以下問題:PHP PageRequestEvent類的具體用法?PHP PageRequestEvent怎麽用?PHP PageRequestEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PageRequestEvent類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     if ($event->page_matches("admin")) {
         if (!$user->can("manage_admintools")) {
             $this->theme->display_permission_denied();
         } else {
             if ($event->count_args() == 0) {
                 send_event(new AdminBuildingEvent($page));
             } else {
                 $action = $event->get_arg(0);
                 $aae = new AdminActionEvent($action);
                 if ($user->check_auth_token()) {
                     log_info("admin", "Util: {$action}");
                     set_time_limit(0);
                     send_event($aae);
                 }
                 if ($aae->redirect) {
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("admin"));
                 }
             }
         }
     }
 }
開發者ID:thelectronicnub,項目名稱:shimmie2,代碼行數:25,代碼來源: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: 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


注:本文中的PageRequestEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。