本文整理汇总了PHP中Event::add_link方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::add_link方法的具体用法?PHP Event::add_link怎么用?PHP Event::add_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event::add_link方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onUserBlockBuilding
public function onUserBlockBuilding(Event $event)
{
global $user;
if ($user->is_admin()) {
$event->add_link("Blotter Editor", make_link("blotter/editor"));
}
}
示例2: 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) {
$config->set_default_int("history_limit", -1);
// shimmie is being installed so call install to create the table.
if ($config->get_int("ext_tag_history_version") < 3) {
$this->install();
}
}
if ($event instanceof PageRequestEvent && $event->page_matches("tag_history")) {
if ($event->get_arg(0) == "revert") {
// this is a request to revert to a previous version of the tags
if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
$this->process_revert_request($_POST['revert']);
}
} else {
if ($event->count_args() == 1) {
// must be an attempt to view a tag history
$image_id = int_escape($event->get_arg(0));
$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
} else {
$this->theme->display_global_page($page, $this->get_global_tag_history());
}
}
}
if ($event instanceof DisplayingImageEvent) {
// handle displaying a link on the view page
$this->theme->display_history_link($page, $event->image->id);
}
if ($event instanceof ImageDeletionEvent) {
// handle removing of history when an image is deleted
$this->delete_all_tag_history($event->image->id);
}
if ($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Tag History");
$sb->add_label("Limit to ");
$sb->add_int_option("history_limit");
$sb->add_label(" entires per image");
$sb->add_label("<br>(-1 for unlimited)");
$event->panel->add_block($sb);
}
if ($event instanceof TagSetEvent) {
$this->add_tag_history($event->image, $event->tags);
}
if ($event instanceof UserBlockBuildingEvent) {
if ($user->is_admin()) {
$event->add_link("Tag Changes", make_link("tag_history"));
}
}
}
示例3: 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("system_info")) {
if ($user->is_admin()) {
$this->theme->display_info_page($page, $this->get_info());
}
}
if ($event instanceof UserBlockBuildingEvent) {
if ($user->is_admin()) {
$event->add_link("System Info", make_link("system_info"));
}
}
}
示例4: onUserBlockBuilding
public function onUserBlockBuilding(Event $event)
{
$event->add_link("My Profile", make_link("user"));
$event->add_link("Log Out", make_link("user_admin/logout"), 99);
}
示例5: 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");
}
}
示例6: 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("alias")) {
if ($event->get_arg(0) == "add") {
if ($user->is_admin()) {
if (isset($_POST['oldtag']) && isset($_POST['newtag'])) {
try {
$aae = new AddAliasEvent($_POST['oldtag'], $_POST['newtag']);
send_event($aae);
$page->set_mode("redirect");
$page->set_redirect(make_link("alias/list"));
} catch (AddAliasException $ex) {
$this->theme->display_error($page, "Error adding alias", $ex->getMessage());
}
}
}
} else {
if ($event->get_arg(0) == "remove") {
if ($user->is_admin()) {
if (isset($_POST['oldtag'])) {
$database->Execute("DELETE FROM aliases WHERE oldtag=?", array($_POST['oldtag']));
log_info("alias_editor", "Deleted alias for " . $_POST['oldtag']);
$page->set_mode("redirect");
$page->set_redirect(make_link("alias/list"));
}
}
} else {
if ($event->get_arg(0) == "list") {
$page_number = $event->get_arg(1);
if (is_null($page_number) || !is_numeric($page_number)) {
$page_number = 0;
} else {
if ($page_number <= 0) {
$page_number = 0;
} else {
$page_number--;
}
}
$alias_per_page = $config->get_int('alias_items_per_page', 30);
if ($database->engine->name == "mysql") {
$query = "SELECT oldtag, newtag FROM aliases ORDER BY newtag ASC LIMIT ?, ?";
} else {
$query = "SELECT oldtag, newtag FROM aliases ORDER BY newtag ASC OFFSET ? LIMIT ?";
}
$alias = $database->db->GetAssoc($query, array($page_number * $alias_per_page, $alias_per_page));
$total_pages = ceil($database->db->GetOne("SELECT COUNT(*) FROM aliases") / $alias_per_page);
$this->theme->display_aliases($page, $alias, $user->is_admin(), $page_number + 1, $total_pages);
} else {
if ($event->get_arg(0) == "export") {
$page->set_mode("data");
$page->set_type("text/plain");
$page->set_data($this->get_alias_csv($database));
} else {
if ($event->get_arg(0) == "import") {
if ($user->is_admin()) {
print_r($_FILES);
if (count($_FILES) > 0) {
global $database;
$tmp = $_FILES['alias_file']['tmp_name'];
$contents = file_get_contents($tmp);
$this->add_alias_csv($database, $contents);
$page->set_mode("redirect");
$page->set_redirect(make_link("alias/list"));
} else {
$this->theme->display_error($page, "No File Specified", "You have to upload a file");
}
} else {
$this->theme->display_error($page, "Admins Only", "Only admins can edit the alias list");
}
}
}
}
}
}
}
if ($event instanceof AddAliasEvent) {
global $database;
$pair = array($event->oldtag, $event->newtag);
if ($database->db->GetRow("SELECT * FROM aliases WHERE oldtag=? AND lower(newtag)=lower(?)", $pair)) {
throw new AddAliasException("That alias already exists");
} else {
$database->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", $pair);
log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}");
}
}
if ($event instanceof UserBlockBuildingEvent) {
if ($user->is_admin()) {
$event->add_link("Alias Editor", make_link("alias/list"));
}
}
}