Merge branch 'master' of github.com:shish/shimmie2

This commit is contained in:
Shish 2012-01-30 03:49:52 +00:00
commit f6567d17d5
3 changed files with 100 additions and 105 deletions

View File

@ -35,16 +35,11 @@ class AdminBuildingEvent extends Event {
}
}
class AdminPage implements Extension {
var $theme;
class AdminPage extends SimpleExtension {
public function onPageRequest($event) {
global $page, $user;
public function get_priority() {return 50;}
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("admin")) {
if($event->page_matches("admin")) {
if(!$user->is_admin()) {
$this->theme->display_permission_denied($page);
}
@ -53,7 +48,7 @@ class AdminPage implements Extension {
}
}
if(($event instanceof PageRequestEvent) && $event->page_matches("admin_utils")) {
if($event->page_matches("admin_utils")) {
if($user->is_admin() && $user->check_auth_token()) {
log_info("admin", "Util: {$_POST['action']}");
set_time_limit(0);
@ -91,18 +86,20 @@ class AdminPage implements Extension {
}
}
}
}
if($event instanceof AdminBuildingEvent) {
public function onAdminBuilding($event) {
global $page;
$this->theme->display_page($page);
$this->theme->display_form($page);
}
if($event instanceof UserBlockBuildingEvent) {
public function onUserBlockBuilding($event) {
global $user;
if($user->is_admin()) {
$event->add_link("Board Admin", make_link("admin"));
}
}
}
private function delete_by_query($query) {
global $page, $user;

View File

@ -5,17 +5,12 @@
* Description: Keep a record of tag changes, and allows you to revert changes.
*/
class Tag_History implements Extension {
var $theme;
class Tag_History extends SimpleExtension {
// in before tags are actually set, so that "get current tags" works
public function get_priority() {return 40;}
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)) {
public function onInitExtEvent($event) {
global $config;
$config->set_default_int("history_limit", -1);
// shimmie is being installed so call install to create the table.
@ -24,10 +19,10 @@ class Tag_History implements Extension {
}
}
if(($event instanceof AdminBuildingEvent))
{
if(isset($_POST['revert_ip']) && $user->is_admin() && $user->check_auth_token())
{
public function onAdminBuildingEvent($event) {
global $user;
if(isset($_POST['revert_ip']) && $user->is_admin() && $user->check_auth_token()) {
$revert_ip = filter_var($_POST['revert_ip'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
if ($revert_ip === false) {
@ -43,7 +38,8 @@ class Tag_History implements Extension {
$this->theme->display_admin_block('Invalid Date');
return;
}
} else {
}
else {
$revert_date = null;
}
@ -54,16 +50,16 @@ class Tag_History implements Extension {
// output results
$this->theme->display_revert_ip_results();
}
else
{
else {
$this->theme->display_admin_block(); // add a block to the admin panel
}
}
if (($event instanceof PageRequestEvent) && ($event->page_matches("tag_history")))
{
if($event->get_arg(0) == "revert")
{
public function onPageRequest($event) {
global $config, $page;
if ($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()) {
if(isset($_POST['revert'])) {
@ -71,8 +67,7 @@ class Tag_History implements Extension {
}
}
}
else if($event->count_args() == 1)
{
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));
@ -81,18 +76,20 @@ class Tag_History implements Extension {
$this->theme->display_global_page($page, $this->get_global_tag_history());
}
}
}
if(($event instanceof DisplayingImageEvent))
{
public function onDisplayingImage($event) {
global $page;
// handle displaying a link on the view page
$this->theme->display_history_link($page, $event->image->id);
}
if(($event instanceof ImageDeletionEvent))
{
public function onImageDeletion($event) {
// handle removing of history when an image is deleted
$this->delete_all_tag_history($event->image->id);
}
if(($event instanceof SetupBuildingEvent)) {
public function onSetupBuilding($event) {
$sb = new SetupBlock("Tag History");
$sb->add_label("Limit to ");
$sb->add_int_option("history_limit");
@ -100,15 +97,17 @@ class Tag_History implements Extension {
$sb->add_label("<br>(-1 for unlimited)");
$event->panel->add_block($sb);
}
if(($event instanceof TagSetEvent)) {
public function onTagSetEvent($event) {
$this->add_tag_history($event->image, $event->tags);
}
if($event instanceof UserBlockBuildingEvent) {
public function onUserBlockBuilding($event) {
global $user;
if($user->is_admin()) {
$event->add_link("Tag Changes", make_link("tag_history"));
}
}
}
protected function install()
{

View File

@ -6,22 +6,21 @@
* Description: Simple search and replace
*/
class WordFilter implements Extension {
class WordFilter extends SimpleExtension {
// before emoticon filter
public function get_priority() {return 40;}
public function receive_event(Event $event) {
if($event instanceof TextFormattingEvent) {
public function onTextFormatting($event) {
$event->formatted = $this->filter($event->formatted);
$event->stripped = $this->filter($event->stripped);
}
if(($event instanceof SetupBuildingEvent)) {
public function onSetupBuilding($event) {
$sb = new SetupBlock("Word Filter");
$sb->add_longtext_option("word_filter");
$sb->add_label("<br>(each line should be search term and replace term, separated by a comma)");
$event->panel->add_block($sb);
}
}
private function filter($text) {
$map = $this->get_map();