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


PHP send_event函数代码示例

本文整理汇总了PHP中send_event函数的典型用法代码示例。如果您正苦于以下问题:PHP send_event函数的具体用法?PHP send_event怎么用?PHP send_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: onPageRequest

 public function onPageRequest($event)
 {
     global $config, $page, $user;
     if ($event->page_matches("featured_image")) {
         if ($event->get_arg(0) == "set" && $user->check_auth_token()) {
             if ($user->is_admin() && isset($_POST['image_id'])) {
                 $id = int_escape($_POST['image_id']);
                 if ($id > 0) {
                     $config->set_int("featured_id", $id);
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("post/view/{$id}"));
                 }
             }
         }
         if ($event->get_arg(0) == "download") {
             $image = Image::by_id($config->get_int("featured_id"));
             if (!is_null($image)) {
                 $page->set_mode("data");
                 $page->set_type("image/jpeg");
                 $page->set_data(file_get_contents($image->get_image_filename()));
             }
         }
         if ($event->get_arg(0) == "view") {
             $image = Image::by_id($config->get_int("featured_id"));
             if (!is_null($image)) {
                 send_event(new DisplayingImageEvent($image, $page));
             }
         }
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:30,代码来源:main.php

示例2: onImageInfoSet

 public function onImageInfoSet(ImageInfoSetEvent $event)
 {
     global $user;
     if (isset($_POST["tag_edit__author"])) {
         send_event(new AuthorSetEvent($event->image, $user, $_POST["tag_edit__author"]));
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:7,代码来源:main.php

示例3: onPageRequest

 public function onPageRequest($event)
 {
     global $config, $database, $page, $user;
     if ($event->page_matches("random_image")) {
         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));
             }
         }
         $image = Image::by_random($search_terms);
         if ($event->get_arg(0) == "download") {
             if (!is_null($image)) {
                 $page->set_mode("data");
                 $page->set_type("image/jpeg");
                 $page->set_data(file_get_contents($image->get_image_filename()));
             }
         }
         if ($event->get_arg(0) == "view") {
             if (!is_null($image)) {
                 send_event(new DisplayingImageEvent($image, $page));
             }
         }
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:28,代码来源:main.php

示例4: testBulkAdd

 public function testBulkAdd()
 {
     $this->log_in_as_admin();
     $this->get_page('admin');
     $this->assert_title("Admin Tools");
     $bae = new BulkAddEvent('asdf');
     send_event($bae);
     $this->assertContains("Error, asdf is not a readable directory", $bae->results, implode("\n", $bae->results));
     // FIXME: have BAE return a list of successes as well as errors?
     $this->markTestIncomplete();
     $this->get_page('admin');
     $this->assert_title("Admin Tools");
     send_event(new BulkAddEvent('tests'));
     # FIXME: test that the output here makes sense, no "adding foo.php ... ok"
     $this->get_page("post/list/hash=17fc89f372ed3636e28bd25cc7f3bac1/1");
     $this->assert_title(new PatternExpectation("/^Image \\d+: data/"));
     $this->click("Delete");
     $this->get_page("post/list/hash=feb01bab5698a11dd87416724c7a89e3/1");
     $this->assert_title(new PatternExpectation("/^Image \\d+: data/"));
     $this->click("Delete");
     $this->get_page("post/list/hash=e106ea2983e1b77f11e00c0c54e53805/1");
     $this->assert_title(new PatternExpectation("/^Image \\d+: data/"));
     $this->click("Delete");
     $this->log_out();
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:25,代码来源:test.php

示例5: comment_to_html

 protected function comment_to_html($comment, $trim = false)
 {
     $inner_id = $this->inner_id;
     // because custom themes can't add params, because PHP
     global $user;
     $tfe = new TextFormattingEvent($comment->comment);
     send_event($tfe);
     //$i_uid = int_escape($comment->owner_id);
     $h_name = html_escape($comment->owner_name);
     //$h_poster_ip = html_escape($comment->poster_ip);
     $h_comment = $trim ? substr($tfe->stripped, 0, 50) . "..." : $tfe->formatted;
     $i_comment_id = int_escape($comment->comment_id);
     $i_image_id = int_escape($comment->image_id);
     $stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50));
     $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
     $h_userlink = "<a href='" . make_link("user/{$h_name}") . "'>{$h_name}</a>";
     $h_date = $comment->posted;
     $h_del = $user->can("delete_comment") ? ' - <a onclick="return confirm(\'Delete comment by ' . $h_name . ':\\n' . $stripped_nonl . '\');" ' . 'href="' . make_link('comment/delete/' . $i_comment_id . '/' . $i_image_id) . '">Del</a>' : '';
     $h_reply = "[<a href='" . make_link("post/view/{$i_image_id}") . "'>Reply</a>]";
     if ($inner_id == 0) {
         return "<div class='comment' style='margin-top: 8px;'>{$h_userlink}{$h_del} {$h_date} No.{$i_comment_id} {$h_reply}<p>{$h_comment}</p></div>";
     } else {
         return "<table><tr><td nowrap class='doubledash'>&gt;&gt;</td><td>" . "<div class='reply'>{$h_userlink}{$h_del} {$h_date} No.{$i_comment_id} {$h_reply}<p>{$h_comment}</p></div>" . "</td></tr></table>";
     }
 }
开发者ID:JarJak,项目名称:shimmie2,代码行数:25,代码来源:comment.theme.php

示例6: offerBounty

 /**
  * Command for the current user to offer their money as bounty on another player
  *
  * @param target String The username of the player to offer a bounty on
  * @param amount int The amount of gold to spend on offering the bounty
  * @return Array
  *
  * @TODO simplify the conditional branching
  */
 public function offerBounty()
 {
     $targetName = in('target');
     $char = new Player(self_char_id());
     $target = new Player($targetName);
     $amountIn = in('amount');
     $amount = intval($amountIn) !== 0 ? intval($amountIn) : null;
     $quickstat = false;
     $success = false;
     if (!$target->id()) {
         $error = 1;
         // Target not found
     } elseif ($target->id() === $char->id()) {
         $error = 6;
         // Can't put a bounty on yourself.
     } else {
         $error = $this->validateBountyOffer($char, $target->id(), $amount);
         $amount = self::calculateMaxOffer($target->bounty(), $amount);
         if (!$error) {
             $char->set_gold($char->gold() - $amount);
             // Subtract the gold.
             $target->set_bounty($target->bounty() + $amount);
             $target->save();
             $char = $char->save();
             send_event($char->id(), $target->id(), $char->name() . " has offered " . $amount . " gold in reward for your head!");
             $success = true;
             $quickstat = 'player';
         }
     }
     return $this->render(['error' => $error, 'success' => $success, 'quickstat' => $quickstat, 'amount_in' => $amountIn, 'amount' => $amount, 'command' => 'offer', 'location' => 0, 'target' => $target]);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:40,代码来源:DoshinController.php

示例7: onImageInfoSet

 public function onImageInfoSet($event)
 {
     global $user;
     if ($_POST['favorite_action'] == "set" || $_POST['favorite_action'] == "unset") {
         send_event(new FavoriteSetEvent($event->image_id, $user, $_POST['favorite_action'] == "set"));
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:7,代码来源:main.php

示例8: display_reported_images

 public function display_reported_images(Page $page, $reports)
 {
     global $config;
     $h_reportedimages = "";
     $n = 0;
     foreach ($reports as $report) {
         $image = $report['image'];
         $h_reason = format_text($report['reason']);
         if ($config->get_bool('report_image_show_thumbs')) {
             $image_link = $this->build_thumb_html($image);
         } else {
             $image_link = "<a href=\"" . make_link("post/view/{$image->id}") . "\">{$image->id}</a>";
         }
         $reporter_name = html_escape($report['reporter_name']);
         $userlink = "<a href='" . make_link("user/{$reporter_name}") . "'>{$reporter_name}</a>";
         global $user;
         $iabbe = new ImageAdminBlockBuildingEvent($image, $user);
         send_event($iabbe);
         ksort($iabbe->parts);
         $actions = join("<br>", $iabbe->parts);
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $h_reportedimages .= "\n\t\t\t\t<tr class='{$oe}'>\n\t\t\t\t\t<td>{$image_link}</td>\n\t\t\t\t\t<td>Report by {$userlink}: {$h_reason}</td>\n\t\t\t\t\t<td class='formstretch'>\n\t\t\t\t\t\t<form action='" . make_link("image_report/remove") . "' method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='id' value='{$report['id']}'>\n\t\t\t\t\t\t\t<input type='submit' value='Remove Report'>\n\t\t\t\t\t\t</form>\n\n\t\t\t\t\t\t<br>{$actions}\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t";
     }
     $thumb_width = $config->get_int("thumb_width");
     $html = "\n\t\t\t<table id='reportedimage' class='zebra'>\n\t\t\t\t<thead><td width='{$thumb_width}'>Image</td><td>Reason</td><td width='128'>Action</td></thead>\n\t\t\t\t{$h_reportedimages}\n\t\t\t</table>\n\t\t";
     $page->set_title("Reported Images");
     $page->set_heading("Reported Images");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Reported Images", $html));
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:30,代码来源:theme.php

示例9: sendMessage

function sendMessage($from, $to, $msg, $filter = false)
{
    // Filter argument is deprecated now.
    $from_id = (int) get_char_id($from);
    $to_id = get_char_id($to);
    send_event($from_id, $to_id, $msg);
}
开发者ID:reillo,项目名称:ninjawars,代码行数:7,代码来源:lib_events.php

示例10: add_image

 /**
  * Generate the necessary DataUploadEvent for a given image and tags.
  */
 private function add_image($tmpname, $filename, $tags, $source, $rating, $thumbfile)
 {
     assert(file_exists($tmpname));
     $pathinfo = pathinfo($filename);
     if (!array_key_exists('extension', $pathinfo)) {
         throw new UploadException("File has no extension");
     }
     $metadata = array();
     $metadata['filename'] = $pathinfo['basename'];
     $metadata['extension'] = $pathinfo['extension'];
     $metadata['tags'] = $tags;
     $metadata['source'] = $source;
     $event = new DataUploadEvent($tmpname, $metadata);
     send_event($event);
     if ($event->image_id == -1) {
         throw new UploadException("File type not recognised");
     } else {
         if (class_exists("RatingSetEvent") && in_array($rating, array("s", "q", "e"))) {
             $ratingevent = new RatingSetEvent(Image::by_id($event->image_id), $rating);
             send_event($ratingevent);
         }
         if (file_exists($thumbfile)) {
             copy($thumbfile, warehouse_path("thumbs", $event->hash));
         }
     }
 }
开发者ID:JarJak,项目名称:shimmie2,代码行数:29,代码来源:main.php

示例11: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_edit")) {
         if ($event->get_arg(0) == "replace") {
             if ($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
                 $search = $_POST['search'];
                 $replace = $_POST['replace'];
                 $this->mass_tag_edit($search, $replace);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof ImageInfoSetEvent) {
         if ($this->can_tag()) {
             send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
             if ($this->can_source()) {
                 send_event(new SourceSetEvent($event->image, $_POST['tag_edit__source']));
             }
         } else {
             $this->theme->display_error($page, "Error", "Anonymous tag editing is disabled");
         }
     }
     if ($event instanceof TagSetEvent) {
         $event->image->set_tags($event->tags);
     }
     if ($event instanceof SourceSetEvent) {
         $event->image->set_source($event->source);
     }
     if ($event instanceof ImageDeletionEvent) {
         $event->image->delete_tags_from_image();
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_mass_editor($page);
     }
     // When an alias is added, oldtag becomes inaccessable
     if ($event instanceof AddAliasEvent) {
         $this->mass_tag_edit($event->oldtag, $event->newtag);
     }
     if ($event instanceof ImageInfoBoxBuildingEvent) {
         if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_tag_editor_html($event->image), 40);
         }
         if ($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_source_editor_html($event->image), 41);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Editing");
         $sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
         $sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
         $event->panel->add_block($sb);
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:58,代码来源:main.php

示例12: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     if ($event->page_matches("regen_thumb") && $user->can("delete_image") && isset($_POST['image_id'])) {
         $image = Image::by_id(int_escape($_POST['image_id']));
         send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
         $this->theme->display_results($page, $image);
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:9,代码来源:main.php

示例13: _doThings

 public function _doThings($in, $out)
 {
     global $user;
     $this->log_in_as_user();
     $image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
     send_event(new CommentPostingEvent($image_id, $user, $in));
     $this->get_page("post/view/{$image_id}");
     $this->assert_text($out);
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:9,代码来源:test.php

示例14: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         if ($config->get_int("ext_ipban_version") < 5) {
             $this->install();
         }
         $this->check_ip_ban();
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("ip_ban")) {
         if ($user->is_admin()) {
             if ($event->get_arg(0) == "add" && $user->check_auth_token()) {
                 if (isset($_POST['ip']) && isset($_POST['reason']) && isset($_POST['end'])) {
                     if (empty($_POST['end'])) {
                         $end = null;
                     } else {
                         $end = $_POST['end'];
                     }
                     send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'], $end));
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("ip_ban/list"));
                 }
             } else {
                 if ($event->get_arg(0) == "remove" && $user->check_auth_token()) {
                     if (isset($_POST['id'])) {
                         send_event(new RemoveIPBanEvent($_POST['id']));
                         $page->set_mode("redirect");
                         $page->set_redirect(make_link("ip_ban/list"));
                     }
                 } else {
                     if ($event->get_arg(0) == "list") {
                         $bans = isset($_GET["all"]) ? $this->get_bans() : $this->get_active_bans();
                         $this->theme->display_bans($page, $bans);
                     }
                 }
             }
         } else {
             $this->theme->display_permission_denied($page);
         }
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("IP Bans", make_link("ip_ban/list"));
         }
     }
     if ($event instanceof AddIPBanEvent) {
         $this->add_ip_ban($event->ip, $event->reason, $event->end, $user);
     }
     if ($event instanceof RemoveIPBanEvent) {
         $database->Execute("DELETE FROM bans WHERE id = :id", array("id" => $event->id));
         $database->cache->delete("ip_bans");
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:56,代码来源:main.php

示例15: check_blocked

 public function check_blocked($image_id, $words)
 {
     global $user;
     try {
         send_event(new CommentPostingEvent($image_id, $user, $words));
         $this->fail("Exception not thrown");
     } catch (CommentPostingException $e) {
         $this->assertEquals($e->getMessage(), "Comment contains banned terms");
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:10,代码来源:test.php


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