本文整理汇总了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;
}
}
}
示例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"));
}
}
}
}
}
示例3: is_safe_page
private function is_safe_page(PageRequestEvent $event)
{
if ($event->page_matches("user_admin/login")) {
return true;
} else {
return false;
}
}
示例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'])));
}
}
示例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;
}