class type hints for hiphop's benefit
This commit is contained in:
parent
629c03036c
commit
0d7efd0256
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
class Home extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
global $config;
|
||||
$config->set_default_string("home_links", '[$base/post/list|Posts]
|
||||
[$base/comment/list|Comments]
|
||||
@ -24,7 +24,8 @@ class Home extends SimpleExtension {
|
||||
[$base/wiki|Wiki]
|
||||
[$base/wiki/more|»]');
|
||||
}
|
||||
public function onPageRequest($event) {
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $page;
|
||||
if($event->page_matches("home")) {
|
||||
$base_href = $config->get_string('base_href');
|
||||
@ -38,7 +39,7 @@ class Home extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
|
||||
public function onSetupBuilding($event) {
|
||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||
$counters = array();
|
||||
foreach(glob("ext/home/counters/*") as $counter_dirname) {
|
||||
$name = str_replace("ext/home/counters/", "", $counter_dirname);
|
||||
@ -53,8 +54,7 @@ class Home extends SimpleExtension {
|
||||
}
|
||||
|
||||
|
||||
private function get_body()
|
||||
{
|
||||
private function get_body() {
|
||||
// returns just the contents of the body
|
||||
global $database;
|
||||
global $config;
|
||||
|
@ -22,14 +22,11 @@ class AddAliasEvent extends Event {
|
||||
|
||||
class AddAliasException extends SCoreException {}
|
||||
|
||||
class AliasEditor implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
class AliasEditor extends SimpleExtension {
|
||||
public function onPageRequest(PageRequestEvent $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->page_matches("alias")) {
|
||||
if($event->get_arg(0) == "add") {
|
||||
if($user->is_admin()) {
|
||||
if(isset($_POST['oldtag']) && isset($_POST['newtag'])) {
|
||||
@ -104,23 +101,24 @@ class AliasEditor implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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}");
|
||||
}
|
||||
public function onAddAlias(AddAliasEvent $event) {
|
||||
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"));
|
||||
}
|
||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Alias Editor", make_link("alias/list"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,5 +141,4 @@ class AliasEditor implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new AliasEditor());
|
||||
?>
|
||||
|
@ -111,7 +111,7 @@ class CommentList extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $page, $user;
|
||||
if($event->page_matches("comment")) {
|
||||
if($event->get_arg(0) == "add") {
|
||||
@ -151,7 +151,7 @@ class CommentList extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
|
||||
public function onPostListBuilding($event) {
|
||||
public function onPostListBuilding(PostListBuildingEvent $event) {
|
||||
global $config;
|
||||
$cc = $config->get_int("comment_count");
|
||||
if($cc > 0) {
|
||||
@ -162,14 +162,14 @@ class CommentList extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserPageBuilding(Event $event) {
|
||||
public function onUserPageBuilding(UserPageBuildingEvent $event) {
|
||||
$i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
|
||||
$i_comment_count = Comment::count_comments_by_user($event->display_user);
|
||||
$h_comment_rate = sprintf("%.1f", ($i_comment_count / $i_days_old));
|
||||
$event->add_stats("Comments made: $i_comment_count, $h_comment_rate per day");
|
||||
}
|
||||
|
||||
public function onDisplayingImage($event) {
|
||||
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||
$this->theme->display_image_comments(
|
||||
$event->image,
|
||||
$this->get_comments($event->image->id),
|
||||
@ -177,7 +177,7 @@ class CommentList extends SimpleExtension {
|
||||
);
|
||||
}
|
||||
|
||||
public function onImageDeletion($event) {
|
||||
public function onImageDeletion(ImageDeletionEvent $event) {
|
||||
global $database;
|
||||
$image_id = $event->image->id;
|
||||
$database->Execute("DELETE FROM comments WHERE image_id=?", array($image_id));
|
||||
@ -185,17 +185,17 @@ class CommentList extends SimpleExtension {
|
||||
}
|
||||
|
||||
// TODO: split akismet into a separate class, which can veto the event
|
||||
public function onCommentPosting($event) {
|
||||
public function onCommentPosting(CommentPostingEvent $event) {
|
||||
$this->add_comment_wrapper($event->image_id, $event->user, $event->comment, $event);
|
||||
}
|
||||
|
||||
public function onCommentDeletion($event) {
|
||||
public function onCommentDeletion(CommentDeletionEvent $event) {
|
||||
global $database;
|
||||
$database->Execute("DELETE FROM comments WHERE id=?", array($event->comment_id));
|
||||
log_info("comment", "Deleting Comment #{$event->comment_id}");
|
||||
}
|
||||
|
||||
public function onSetupBuilding($event) {
|
||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||
$sb = new SetupBlock("Comment Options");
|
||||
$sb->add_bool_option("comment_anon", "Allow anonymous comments: ");
|
||||
$sb->add_bool_option("comment_captcha", "<br>Require CAPTCHA for anonymous comments: ");
|
||||
@ -213,7 +213,7 @@ class CommentList extends SimpleExtension {
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onSearchTermParse($event) {
|
||||
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||
$matches = array();
|
||||
if(preg_match("/comments(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
|
@ -87,7 +87,7 @@ class ExtensionInfo {
|
||||
}
|
||||
|
||||
class ExtManager extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $page, $user;
|
||||
if($event->page_matches("ext_manager")) {
|
||||
if($user->is_admin()) {
|
||||
@ -127,7 +127,7 @@ class ExtManager extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding($event) {
|
||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Extension Manager", make_link("ext_manager"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user