本文整理汇总了PHP中PageRequestEvent::get_page_size方法的典型用法代码示例。如果您正苦于以下问题:PHP PageRequestEvent::get_page_size方法的具体用法?PHP PageRequestEvent::get_page_size怎么用?PHP PageRequestEvent::get_page_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageRequestEvent
的用法示例。
在下文中一共展示了PageRequestEvent::get_page_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPageRequest
public function onPageRequest(PageRequestEvent $event)
{
if ($event->page_matches("rss/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);
$this->do_rss($images, $search_terms, $page_number);
}
}
示例2: onPageRequest
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;
if ($event->page_matches("api/shimmie")) {
$page->set_mode("data");
$page->set_type("text/plain");
if ($event->page_matches("api/shimmie/get_tags")) {
$tag = $event->get_arg(0);
if (empty($tag) && isset($_GET['tag'])) {
$tag = $_GET['tag'];
}
$res = $this->api_get_tags($tag);
$page->set_data(json_encode($res));
} elseif ($event->page_matches("api/shimmie/get_image")) {
$arg = $event->get_arg(0);
if (empty($arg) && isset($_GET['id'])) {
$arg = $_GET['id'];
}
$image = Image::by_id(int_escape($arg));
// FIXME: handle null image
$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));
} elseif ($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));
} elseif ($event->page_matches("api/shimmie/get_user")) {
$query = $user->id;
$type = "id";
if ($event->count_args() == 1) {
$query = $event->get_arg(0);
$type = "name";
} elseif (isset($_GET['id'])) {
$query = $_GET['id'];
} elseif (isset($_GET['name'])) {
$query = $_GET['name'];
$type = "name";
}
$all = $this->api_get_user($type, $query);
$page->set_data(json_encode($all));
} else {
$page->set_mode("redirect");
$page->set_redirect(make_link("ext_doc/shimmie_api"));
}
}
}
示例3: 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));
}
}
}