本文整理汇总了PHP中PageRequestEvent::count_args方法的典型用法代码示例。如果您正苦于以下问题:PHP PageRequestEvent::count_args方法的具体用法?PHP PageRequestEvent::count_args怎么用?PHP PageRequestEvent::count_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageRequestEvent
的用法示例。
在下文中一共展示了PageRequestEvent::count_args方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
}
}
}
示例2: onPageRequest
public function onPageRequest(PageRequestEvent $event)
{
global $page;
if ($event->page_matches("random_image")) {
$action = '';
if ($event->count_args() == 1) {
$action = $event->get_arg(0);
$search_terms = array();
} else {
if ($event->count_args() == 2) {
$action = $event->get_arg(0);
$search_terms = explode(' ', $event->get_arg(1));
} else {
throw new SCoreException("Error: too many arguments.");
}
}
$image = Image::by_random($search_terms);
if ($action === "download") {
if (!is_null($image)) {
$page->set_mode("data");
$page->set_type($image->get_mime_type());
$page->set_data(file_get_contents($image->get_image_filename()));
}
} else {
if ($action === "view") {
if (!is_null($image)) {
send_event(new DisplayingImageEvent($image, $page));
}
} else {
if ($action === "widget") {
if (!is_null($image)) {
$page->set_mode("data");
$page->set_type("text/html");
$page->set_data($this->theme->build_thumb_html($image));
}
}
}
}
}
}
示例3: 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) == "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->db->getone("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));
}
}
}
}
}
}
示例4: onPageRequest
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;
if ($event->page_matches("comment")) {
if ($event->get_arg(0) == "add") {
if (isset($_POST['image_id']) && isset($_POST['comment'])) {
try {
$cpe = new CommentPostingEvent($_POST['image_id'], $user, $_POST['comment']);
send_event($cpe);
$page->set_mode("redirect");
$page->set_redirect(make_link("post/view/" . int_escape($_POST['image_id'])));
} catch (CommentPostingException $ex) {
$this->theme->display_error($page, "Comment Blocked", $ex->getMessage());
}
}
} else {
if ($event->get_arg(0) == "delete") {
if ($user->is_admin()) {
// FIXME: post, not args
if ($event->count_args() == 3) {
send_event(new CommentDeletionEvent($event->get_arg(1)));
$page->set_mode("redirect");
if (!empty($_SERVER['HTTP_REFERER'])) {
$page->set_redirect($_SERVER['HTTP_REFERER']);
} else {
$page->set_redirect(make_link("post/view/" . $event->get_arg(2)));
}
}
} else {
$this->theme->display_permission_denied($page);
}
} else {
if ($event->get_arg(0) == "list") {
$this->build_page($event->get_arg(1));
}
}
}
}
}
示例5: onPageRequest_delete
private function onPageRequest_delete(PageRequestEvent $event)
{
global $user, $page;
if ($user->can("delete_comment")) {
// FIXME: post, not args
if ($event->count_args() === 3) {
send_event(new CommentDeletionEvent($event->get_arg(1)));
flash_message("Deleted comment");
$page->set_mode("redirect");
if (!empty($_SERVER['HTTP_REFERER'])) {
$page->set_redirect($_SERVER['HTTP_REFERER']);
} else {
$page->set_redirect(make_link("post/view/" . $event->get_arg(2)));
}
}
} else {
$this->theme->display_permission_denied();
}
}