From 5b3b675b6d8a1cd9a5f2b9455c551791e18d88ff Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Thu, 16 Jul 2009 11:19:34 -0700
Subject: Non-trivial changes to the event handling code:
1) The item_updated event no longer takes the old and new items.
Instead we overload ORM to track the original data and make
that available via the item. This will allow us to move event
publishing down into the API methods which in turn will give us
more stability since we won't require each controller to remember
to do it.
2) ORM class now tracks the original values. It doesn't track
the original relationships (no need for that, yet)
3) Added new events:
item_deleted
group_deleted
user_deleted
---
modules/akismet/helpers/akismet_event.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'modules/akismet/helpers')
diff --git a/modules/akismet/helpers/akismet_event.php b/modules/akismet/helpers/akismet_event.php
index 80fe0127..bffc0fd7 100644
--- a/modules/akismet/helpers/akismet_event.php
+++ b/modules/akismet/helpers/akismet_event.php
@@ -40,14 +40,14 @@ class akismet_event_Core {
$comment->save();
}
- static function comment_updated($old, $new) {
+ static function comment_updated($comment) {
if (!module::get_var("akismet", "api_key")) {
return;
}
- if ($old->state != "spam" && $new->state == "spam") {
+ if ($comment->original("state") != "spam" && $comment->state == "spam") {
akismet::submit_spam($new);
- } else if ($old->state == "spam" && $new->state != "spam") {
+ } else if ($comment->original("state") == "spam" && $comment->state != "spam") {
akismet::submit_ham($new);
}
}
--
cgit v1.2.3
From 1e90e40d3a9fe2cb826b56686f23a33879418048 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 28 Jul 2009 13:47:22 -0700
Subject: Use events to generate menus, instead of having xxx_menu helpers.
This is the first step towards having a simple, lightweight and unified API
for module interaction.
---
modules/akismet/helpers/akismet_event.php | 16 ++
modules/akismet/helpers/akismet_menu.php | 36 -----
modules/comment/helpers/comment_event.php | 17 +++
modules/comment/helpers/comment_menu.php | 37 -----
modules/digibug/helpers/digibug_event.php | 50 +++++++
modules/digibug/helpers/digibug_menu.php | 50 -------
modules/g2_import/helpers/g2_import_event.php | 9 ++
modules/g2_import/helpers/g2_import_menu.php | 29 ----
modules/gallery/helpers/gallery_menu.php | 164 ---------------------
modules/gallery/libraries/Admin_View.php | 70 +++++++--
modules/gallery/libraries/Theme_View.php | 105 +++++++++----
.../notification/helpers/notification_event.php | 19 +++
modules/notification/helpers/notification_menu.php | 39 -----
modules/organize/helpers/organize_event.php | 33 +++++
modules/organize/helpers/organize_menu.php | 33 -----
modules/recaptcha/helpers/recaptcha_event.php | 8 +
modules/recaptcha/helpers/recaptcha_menu.php | 28 ----
modules/server_add/helpers/server_add_event.php | 64 ++++++++
modules/server_add/helpers/server_add_menu.php | 64 --------
modules/slideshow/helpers/slideshow_event.php | 30 ++++
modules/slideshow/helpers/slideshow_menu.php | 51 -------
modules/tag/helpers/tag_event.php | 8 +
modules/tag/helpers/tag_menu.php | 28 ----
modules/user/helpers/user_event.php | 8 +
modules/user/helpers/user_menu.php | 28 ----
modules/watermark/helpers/watermark_event.php | 29 ++++
modules/watermark/helpers/watermark_menu.php | 29 ----
27 files changed, 426 insertions(+), 656 deletions(-)
delete mode 100644 modules/akismet/helpers/akismet_menu.php
delete mode 100644 modules/comment/helpers/comment_menu.php
create mode 100644 modules/digibug/helpers/digibug_event.php
delete mode 100644 modules/digibug/helpers/digibug_menu.php
delete mode 100644 modules/g2_import/helpers/g2_import_menu.php
delete mode 100644 modules/gallery/helpers/gallery_menu.php
delete mode 100644 modules/notification/helpers/notification_menu.php
create mode 100644 modules/organize/helpers/organize_event.php
delete mode 100644 modules/organize/helpers/organize_menu.php
delete mode 100644 modules/recaptcha/helpers/recaptcha_menu.php
create mode 100644 modules/server_add/helpers/server_add_event.php
delete mode 100644 modules/server_add/helpers/server_add_menu.php
delete mode 100644 modules/slideshow/helpers/slideshow_menu.php
delete mode 100644 modules/tag/helpers/tag_menu.php
delete mode 100644 modules/user/helpers/user_menu.php
create mode 100644 modules/watermark/helpers/watermark_event.php
delete mode 100644 modules/watermark/helpers/watermark_menu.php
(limited to 'modules/akismet/helpers')
diff --git a/modules/akismet/helpers/akismet_event.php b/modules/akismet/helpers/akismet_event.php
index bffc0fd7..d6cde222 100644
--- a/modules/akismet/helpers/akismet_event.php
+++ b/modules/akismet/helpers/akismet_event.php
@@ -51,4 +51,20 @@ class akismet_event_Core {
akismet::submit_ham($new);
}
}
+
+ static function admin_menu($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("akismet")
+ ->label(t("Akismet"))
+ ->url(url::site("admin/akismet")));
+
+ if (module::get_var("akismet", "api_key")) {
+ $menu->get("statistics_menu")
+ ->append(Menu::factory("link")
+ ->id("akismet")
+ ->label(t("Akismet"))
+ ->url(url::site("admin/akismet/stats")));
+ }
+ }
}
diff --git a/modules/akismet/helpers/akismet_menu.php b/modules/akismet/helpers/akismet_menu.php
deleted file mode 100644
index ebd948d6..00000000
--- a/modules/akismet/helpers/akismet_menu.php
+++ /dev/null
@@ -1,36 +0,0 @@
-get("settings_menu")
- ->append(Menu::factory("link")
- ->id("akismet")
- ->label(t("Akismet"))
- ->url(url::site("admin/akismet")));
-
- if (module::get_var("akismet", "api_key")) {
- $menu->get("statistics_menu")
- ->append(Menu::factory("link")
- ->id("akismet")
- ->label(t("Akismet"))
- ->url(url::site("admin/akismet/stats")));
- }
- }
-}
diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php
index 3850a001..614c7c65 100644
--- a/modules/comment/helpers/comment_event.php
+++ b/modules/comment/helpers/comment_event.php
@@ -21,4 +21,21 @@ class comment_event_Core {
static function item_deleted($item) {
Database::instance()->delete("comments", array("item_id" => $item->id));
}
+
+ static function admin_menu($menu, $theme) {
+ $menu->get("content_menu")
+ ->append(Menu::factory("link")
+ ->id("comments")
+ ->label(t("Comments"))
+ ->url(url::site("admin/comments")));
+ }
+
+ static function photo_menu($menu, $theme) {
+ $menu
+ ->append(Menu::factory("link")
+ ->id("comments")
+ ->label(t("View comments on this item"))
+ ->url("#comments")
+ ->css_id("gCommentsLink"));
+ }
}
diff --git a/modules/comment/helpers/comment_menu.php b/modules/comment/helpers/comment_menu.php
deleted file mode 100644
index 01881921..00000000
--- a/modules/comment/helpers/comment_menu.php
+++ /dev/null
@@ -1,37 +0,0 @@
-get("content_menu")
- ->append(Menu::factory("link")
- ->id("comments")
- ->label(t("Comments"))
- ->url(url::site("admin/comments")));
- }
-
- static function photo($menu, $theme) {
- $menu
- ->append(Menu::factory("link")
- ->id("comments")
- ->label(t("View comments on this item"))
- ->url("#comments")
- ->css_id("gCommentsLink"));
- }
-}
diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php
new file mode 100644
index 00000000..c4f9e560
--- /dev/null
+++ b/modules/digibug/helpers/digibug_event.php
@@ -0,0 +1,50 @@
+get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("digibug_menu")
+ ->label(t("Digibug"))
+ ->url(url::site("admin/digibug")));
+ }
+
+ static function photo_menu($menu, $theme) {
+ $item = $theme->item();
+ $menu->append(
+ Menu::factory("link")
+ ->id("digibug")
+ ->label(t("Print with Digibug"))
+ ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf"))
+ ->css_id("gDigibugLink"));
+ }
+
+ static function thumb_menu($menu, $theme, $item) {
+ if ($item->type == "photo") {
+ $menu->get("options_menu")
+ ->append(
+ Menu::factory("link")
+ ->id("digibug")
+ ->label(t("Print with Digibug"))
+ ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf"))
+ ->css_id("gDigibugLink"));
+ }
+ }
+}
diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php
deleted file mode 100644
index 3f70fa24..00000000
--- a/modules/digibug/helpers/digibug_menu.php
+++ /dev/null
@@ -1,50 +0,0 @@
-get("settings_menu")
- ->append(Menu::factory("link")
- ->id("digibug_menu")
- ->label(t("Digibug"))
- ->url(url::site("admin/digibug")));
- }
-
- static function photo($menu, $theme) {
- $item = $theme->item();
- $menu->append(
- Menu::factory("link")
- ->id("digibug")
- ->label(t("Print with Digibug"))
- ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf"))
- ->css_id("gDigibugLink"));
- }
-
- static function thumb($menu, $theme, $item) {
- if ($item->type == "photo") {
- $menu->get("options_menu")
- ->append(
- Menu::factory("link")
- ->id("digibug")
- ->label(t("Print with Digibug"))
- ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf"))
- ->css_id("gDigibugLink"));
- }
- }
-}
diff --git a/modules/g2_import/helpers/g2_import_event.php b/modules/g2_import/helpers/g2_import_event.php
index 77b489a7..609e1a45 100644
--- a/modules/g2_import/helpers/g2_import_event.php
+++ b/modules/g2_import/helpers/g2_import_event.php
@@ -25,4 +25,13 @@ class g2_import_event_Core {
static function item_created($item) {
g2_import::copy_matching_thumbnails_and_resizes($item);
}
+
+ static function admin_menu($menu, $theme) {
+ $menu
+ ->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("g2_import")
+ ->label(t("Gallery 2 Import"))
+ ->url(url::site("admin/g2_import")));
+ }
}
diff --git a/modules/g2_import/helpers/g2_import_menu.php b/modules/g2_import/helpers/g2_import_menu.php
deleted file mode 100644
index 68d75cb4..00000000
--- a/modules/g2_import/helpers/g2_import_menu.php
+++ /dev/null
@@ -1,29 +0,0 @@
-get("settings_menu")
- ->append(Menu::factory("link")
- ->id("g2_import")
- ->label(t("Gallery 2 Import"))
- ->url(url::site("admin/g2_import")));
- }
-}
diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php
deleted file mode 100644
index 040b19e1..00000000
--- a/modules/gallery/helpers/gallery_menu.php
+++ /dev/null
@@ -1,164 +0,0 @@
-append(Menu::factory("link")
- ->id("home")
- ->label(t("Home"))
- ->url(url::site("albums/1")));
-
- $item = $theme->item();
-
- $can_edit = $item && access::can("edit", $item);
- $can_add = $item && access::can("add", $item);
-
- if ($can_add) {
- $menu->append(Menu::factory("dialog")
- ->id("add_photos_item")
- ->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
- }
-
- $menu->append($options_menu = Menu::factory("submenu")
- ->id("options_menu")
- ->label(t("Options")));
- if ($item && ($can_edit || $can_add)) {
- if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_item")
- ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
- ->url(url::site("form/edit/{$item->type}s/$item->id")));
- }
-
- // @todo Move album options menu to the album quick edit pane
- if ($item->is_album()) {
- if ($can_add) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("add_album")
- ->label(t("Add an album"))
- ->url(url::site("form/add/albums/$item->id?type=album")));
- }
-
- if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_permissions")
- ->label(t("Edit permissions"))
- ->url(url::site("permissions/browse/$item->id")));
- }
- }
- }
-
- if (user::active()->admin) {
- $menu->append($admin_menu = Menu::factory("submenu")
- ->id("admin_menu")
- ->label(t("Admin")));
- self::admin($admin_menu, $theme);
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "admin")) {
- call_user_func_array(array($class, "admin"), array(&$admin_menu, $theme));
- }
- }
- }
- }
-
- static function album($menu, $theme) {
- }
-
- static function tag($menu, $theme) {
- }
-
- static function thumb($menu, $theme, $item) {
- $menu->append(Menu::factory("submenu")
- ->id("options_menu")
- ->label(t("Options"))
- ->css_class("gThumbMenu"));
- }
-
- static function photo($menu, $theme) {
- if (access::can("view_full", $theme->item())) {
- $menu->append(Menu::factory("link")
- ->id("fullsize")
- ->label(t("View full size"))
- ->url($theme->item()->file_url())
- ->css_class("gFullSizeLink"));
- }
- }
-
- static function admin($menu, $theme) {
- $menu
- ->append(Menu::factory("link")
- ->id("dashboard")
- ->label(t("Dashboard"))
- ->url(url::site("admin")))
- ->append(Menu::factory("submenu")
- ->id("settings_menu")
- ->label(t("Settings"))
- ->append(Menu::factory("link")
- ->id("graphics_toolkits")
- ->label(t("Graphics"))
- ->url(url::site("admin/graphics")))
- ->append(Menu::factory("link")
- ->id("languages")
- ->label(t("Languages"))
- ->url(url::site("admin/languages")))
- ->append(Menu::factory("link")
- ->id("l10n_mode")
- ->label(Session::instance()->get("l10n_mode", false)
- ? t("Stop translating") : t("Start translating"))
- ->url(url::site("l10n_client/toggle_l10n_mode?csrf=" .
- access::csrf_token())))
- ->append(Menu::factory("link")
- ->id("advanced")
- ->label(t("Advanced"))
- ->url(url::site("admin/advanced_settings"))))
- ->append(Menu::factory("link")
- ->id("modules")
- ->label(t("Modules"))
- ->url(url::site("admin/modules")))
- ->append(Menu::factory("submenu")
- ->id("content_menu")
- ->label(t("Content")))
- ->append(Menu::factory("submenu")
- ->id("appearance_menu")
- ->label(t("Appearance"))
- ->append(Menu::factory("link")
- ->id("themes")
- ->label(t("Theme Choice"))
- ->url(url::site("admin/themes")))
- ->append(Menu::factory("link")
- ->id("theme_options")
- ->label(t("Theme Options"))
- ->url(url::site("admin/theme_options"))))
- ->append(Menu::factory("submenu")
- ->id("statistics_menu")
- ->label(t("Statistics")))
- ->append(Menu::factory("link")
- ->id("maintenance")
- ->label(t("Maintenance"))
- ->url(url::site("admin/maintenance")));
- }
-}
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 47770a90..2a48d1e3 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -44,22 +44,66 @@ class Admin_View_Core extends Gallery_View {
$this->set_global("user", user::active());
}
- public function admin_menu() {
- $menu = Menu::factory("root");
- gallery_menu::admin($menu, $this);
-
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "admin")) {
- call_user_func_array(array($class, "admin"), array(&$menu, $this));
- }
+ public function admin_menu($menu=null) {
+ if (!$menu) {
+ $menu = Menu::factory("root");
}
+ $menu
+ ->append(Menu::factory("link")
+ ->id("dashboard")
+ ->label(t("Dashboard"))
+ ->url(url::site("admin")))
+ ->append(Menu::factory("submenu")
+ ->id("settings_menu")
+ ->label(t("Settings"))
+ ->append(Menu::factory("link")
+ ->id("graphics_toolkits")
+ ->label(t("Graphics"))
+ ->url(url::site("admin/graphics")))
+ ->append(Menu::factory("link")
+ ->id("languages")
+ ->label(t("Languages"))
+ ->url(url::site("admin/languages")))
+ ->append(Menu::factory("link")
+ ->id("l10n_mode")
+ ->label(Session::instance()->get("l10n_mode", false)
+ ? t("Stop translating") : t("Start translating"))
+ ->url(url::site("l10n_client/toggle_l10n_mode?csrf=" .
+ access::csrf_token())))
+ ->append(Menu::factory("link")
+ ->id("advanced")
+ ->label(t("Advanced"))
+ ->url(url::site("admin/advanced_settings"))))
+ ->append(Menu::factory("link")
+ ->id("modules")
+ ->label(t("Modules"))
+ ->url(url::site("admin/modules")))
+ ->append(Menu::factory("submenu")
+ ->id("content_menu")
+ ->label(t("Content")))
+ ->append(Menu::factory("submenu")
+ ->id("appearance_menu")
+ ->label(t("Appearance"))
+ ->append(Menu::factory("link")
+ ->id("themes")
+ ->label(t("Theme Choice"))
+ ->url(url::site("admin/themes")))
+ ->append(Menu::factory("link")
+ ->id("theme_options")
+ ->label(t("Theme Options"))
+ ->url(url::site("admin/theme_options"))))
+ ->append(Menu::factory("submenu")
+ ->id("statistics_menu")
+ ->label(t("Statistics")))
+ ->append(Menu::factory("link")
+ ->id("maintenance")
+ ->label(t("Maintenance"))
+ ->url(url::site("admin/maintenance")));
+
+ module::event("admin_menu", $menu, $this);
$menu->compact();
- print $menu;
+ return $menu;
}
/**
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index fa45ec89..60471f75 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -81,52 +81,103 @@ class Theme_View_Core extends Gallery_View {
public function site_menu() {
$menu = Menu::factory("root");
if ($this->page_type != "login") {
- gallery_menu::site($menu, $this);
+ $menu->append(Menu::factory("link")
+ ->id("home")
+ ->label(t("Home"))
+ ->url(url::site("albums/1")));
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
+ $item = $this->item();
+
+ $can_edit = $item && access::can("edit", $item);
+ $can_add = $item && access::can("add", $item);
+
+ if ($can_add) {
+ $menu->append(Menu::factory("dialog")
+ ->id("add_photos_item")
+ ->label(t("Add photos"))
+ ->url(url::site("simple_uploader/app/$item->id")));
+ }
+
+ $menu->append($options_menu = Menu::factory("submenu")
+ ->id("options_menu")
+ ->label(t("Options")));
+ if ($item && ($can_edit || $can_add)) {
+ if ($can_edit) {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("edit_item")
+ ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
+ ->url(url::site("form/edit/{$item->type}s/$item->id")));
}
- $class = "{$module->name}_menu";
- if (method_exists($class, "site")) {
- call_user_func_array(array($class, "site"), array(&$menu, $this));
+
+ // @todo Move album options menu to the album quick edit pane
+ if ($item->is_album()) {
+ if ($can_add) {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("add_album")
+ ->label(t("Add an album"))
+ ->url(url::site("form/add/albums/$item->id?type=album")));
+ }
+
+ if ($can_edit) {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("edit_permissions")
+ ->label(t("Edit permissions"))
+ ->url(url::site("permissions/browse/$item->id")));
+ }
}
}
+
+ if (user::active()->admin) {
+ $menu->append($admin_menu = Menu::factory("submenu")
+ ->id("admin_menu")
+ ->label(t("Admin")));
+ Admin_View::admin_menu($admin_menu, $this);
+ module::event("admin_menu", $admin_menu, $this);
+ }
+
+ module::event("site_menu", $menu, $this);
}
- $menu->compact();
- print $menu;
+ return $menu->compact();
}
public function album_menu() {
- print $this->_menu("album");
+ $menu = Menu::factory("root");
+ module::event("album_menu", $menu, $this);
+ return $menu->compact();
}
public function tag_menu() {
- print $this->_menu("tag");
+ $menu = Menu::factory("root");
+ module::event("tag_menu", $menu, $this);
+ return $menu->compact();
}
public function photo_menu() {
- print $this->_menu("photo");
- }
+ $menu = Menu::factory("root");
+ if (access::can("view_full", $this->item())) {
+ $menu->append(Menu::factory("link")
+ ->id("fullsize")
+ ->label(t("View full size"))
+ ->url($this->item()->file_url())
+ ->css_class("gFullSizeLink"));
+ }
- public function thumb_menu($item) {
- print $this->_menu("thumb", $item)->css_class("gThumbMenu");
+ module::event("photo_menu", $menu, $this);
+ return $menu->compact();
}
- private function _menu($type, $item=null) {
- $menu = Menu::factory("root");
- call_user_func_array(array("gallery_menu", $type), array(&$menu, $this, $item));
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, $type)) {
- call_user_func_array(array($class, $type), array(&$menu, $this, $item));
- }
- }
+ public function thumb_menu($item) {
+ $menu = Menu::factory("root")
+ ->append(Menu::factory("submenu")
+ ->id("options_menu")
+ ->label(t("Options"))
+ ->css_class("gThumbMenu"));
+ module::event("thumb_menu", $menu, $this, $item);
return $menu->compact();
}
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index 536557c6..c6e770a7 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -55,4 +55,23 @@ class notification_event_Core {
static function batch_complete() {
notification::send_pending_notifications();
}
+
+ static function site_menu($menu, $theme) {
+ if (!user::active()->guest) {
+ $item = $theme->item();
+
+ if ($item && $item->is_album() && access::can("view", $item)) {
+ $watching = notification::is_watching($item);
+
+ $label = $watching ? t("Remove notifications") : t("Enable notifications");
+
+ $menu->get("options_menu")
+ ->append(Menu::factory("link")
+ ->id("watch")
+ ->label($label)
+ ->css_id("gNotifyLink")
+ ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token())));
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/notification/helpers/notification_menu.php b/modules/notification/helpers/notification_menu.php
deleted file mode 100644
index 73d1dd03..00000000
--- a/modules/notification/helpers/notification_menu.php
+++ /dev/null
@@ -1,39 +0,0 @@
-guest) {
- $item = $theme->item();
-
- if ($item && $item->is_album() && access::can("view", $item)) {
- $watching = notification::is_watching($item);
-
- $label = $watching ? t("Remove notifications") : t("Enable notifications");
-
- $menu->get("options_menu")
- ->append(Menu::factory("link")
- ->id("watch")
- ->label($label)
- ->css_id("gNotifyLink")
- ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token())));
- }
- }
- }
-}
diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php
new file mode 100644
index 00000000..99a28673
--- /dev/null
+++ b/modules/organize/helpers/organize_event.php
@@ -0,0 +1,33 @@
+item();
+
+ if ($item && access::can("edit", $item) && $item->is_album()) {
+ $menu->get("options_menu")
+ ->append(Menu::factory("link")
+ ->id("organize")
+ ->label(t("Organize Album"))
+ ->css_id("gOrganizeLink")
+ ->url(url::site("organize/index/{$item->id}")));
+ }
+ }
+}
diff --git a/modules/organize/helpers/organize_menu.php b/modules/organize/helpers/organize_menu.php
deleted file mode 100644
index 850c1eab..00000000
--- a/modules/organize/helpers/organize_menu.php
+++ /dev/null
@@ -1,33 +0,0 @@
-item();
-
- if ($item && access::can("edit", $item) && $item->is_album()) {
- $menu->get("options_menu")
- ->append(Menu::factory("link")
- ->id("organize")
- ->label(t("Organize Album"))
- ->css_id("gOrganizeLink")
- ->url(url::site("organize/index/{$item->id}")));
- }
- }
-}
diff --git a/modules/recaptcha/helpers/recaptcha_event.php b/modules/recaptcha/helpers/recaptcha_event.php
index 932ddee6..d23a0c74 100644
--- a/modules/recaptcha/helpers/recaptcha_event.php
+++ b/modules/recaptcha/helpers/recaptcha_event.php
@@ -23,4 +23,12 @@ class recaptcha_event_Core {
$form->add_comment->recaptcha("recaptcha")->label("")->id("gRecaptcha");
}
}
+
+ static function admin_menu($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("recaptcha")
+ ->label(t("reCAPTCHA"))
+ ->url(url::site("admin/recaptcha")));
+ }
}
diff --git a/modules/recaptcha/helpers/recaptcha_menu.php b/modules/recaptcha/helpers/recaptcha_menu.php
deleted file mode 100644
index 047abf8f..00000000
--- a/modules/recaptcha/helpers/recaptcha_menu.php
+++ /dev/null
@@ -1,28 +0,0 @@
-get("settings_menu")
- ->append(Menu::factory("link")
- ->id("recaptcha")
- ->label(t("reCAPTCHA"))
- ->url(url::site("admin/recaptcha")));
- }
-}
diff --git a/modules/server_add/helpers/server_add_event.php b/modules/server_add/helpers/server_add_event.php
new file mode 100644
index 00000000..b53e72d1
--- /dev/null
+++ b/modules/server_add/helpers/server_add_event.php
@@ -0,0 +1,64 @@
+get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("server_add")
+ ->label(t("Server Add"))
+ ->url(url::site("admin/server_add")));
+ }
+
+ static function site_menu($menu, $theme) {
+ $item = $theme->item();
+ $paths = unserialize(module::get_var("server_add", "authorized_paths"));
+
+ if ($item && user::active()->admin && $item->is_album() && !empty($paths)) {
+ // This is a little tricky. Normally there's an "Add Photo" menu option, but we want to
+ // turn that into a dropdown if there are two different ways to add things. Do that in a
+ // portable way for now. If we find ourselves duplicating this pattern, we should make an
+ // API method for this.
+ $server_add = Menu::factory("dialog")
+ ->id("server_add")
+ ->label(t("Add from server"))
+ ->url(url::site("server_add/browse/$item->id"));
+ $add_photos_item = $menu->get("add_photos_item");
+ $add_photos_menu = $menu->get("add_photos_menu");
+
+ if ($add_photos_item && !$add_photos_menu) {
+ // Assuming that $add_menu is unset, create add_menu and add our item
+ $menu->add_after(
+ "add_photos_item",
+ Menu::factory("submenu")
+ ->id("add_photos_menu")
+ ->label($add_photos_item->label)
+ ->append(Menu::factory("dialog")
+ ->id("add_photos_submenu_item")
+ ->label(t("Simple Uploader"))
+ ->url($add_photos_item->url))
+ ->append($server_add));
+ $menu->remove("add_photos_item");
+ } else if ($add_photos_menu) {
+ // Append to the existing sub-menu
+ $add_photos_menu->append($server_add);
+ }
+ }
+ }
+}
diff --git a/modules/server_add/helpers/server_add_menu.php b/modules/server_add/helpers/server_add_menu.php
deleted file mode 100644
index 0f01eb64..00000000
--- a/modules/server_add/helpers/server_add_menu.php
+++ /dev/null
@@ -1,64 +0,0 @@
-get("settings_menu")
- ->append(Menu::factory("link")
- ->id("server_add")
- ->label(t("Server Add"))
- ->url(url::site("admin/server_add")));
- }
-
- static function site($menu, $theme) {
- $item = $theme->item();
- $paths = unserialize(module::get_var("server_add", "authorized_paths"));
-
- if ($item && user::active()->admin && $item->is_album() && !empty($paths)) {
- // This is a little tricky. Normally there's an "Add Photo" menu option, but we want to
- // turn that into a dropdown if there are two different ways to add things. Do that in a
- // portable way for now. If we find ourselves duplicating this pattern, we should make an
- // API method for this.
- $server_add = Menu::factory("dialog")
- ->id("server_add")
- ->label(t("Add from server"))
- ->url(url::site("server_add/browse/$item->id"));
- $add_photos_item = $menu->get("add_photos_item");
- $add_photos_menu = $menu->get("add_photos_menu");
-
- if ($add_photos_item && !$add_photos_menu) {
- // Assuming that $add_menu is unset, create add_menu and add our item
- $menu->add_after(
- "add_photos_item",
- Menu::factory("submenu")
- ->id("add_photos_menu")
- ->label($add_photos_item->label)
- ->append(Menu::factory("dialog")
- ->id("add_photos_submenu_item")
- ->label(t("Simple Uploader"))
- ->url($add_photos_item->url))
- ->append($server_add));
- $menu->remove("add_photos_item");
- } else if ($add_photos_menu) {
- // Append to the existing sub-menu
- $add_photos_menu->append($server_add);
- }
- }
- }
-}
diff --git a/modules/slideshow/helpers/slideshow_event.php b/modules/slideshow/helpers/slideshow_event.php
index c6cd7dc7..cf79f71a 100644
--- a/modules/slideshow/helpers/slideshow_event.php
+++ b/modules/slideshow/helpers/slideshow_event.php
@@ -29,4 +29,34 @@ class slideshow_event_Core {
site_status::clear("slideshow_needs_rss");
}
}
+
+ static function album_menu($menu, $theme) {
+ $menu
+ ->append(Menu::factory("link")
+ ->id("slideshow")
+ ->label(t("View slideshow"))
+ ->url("javascript:PicLensLite.start(" .
+ "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})")
+ ->css_id("gSlideshowLink"));
+ }
+
+ static function photo_menu($menu, $theme) {
+ $menu
+ ->append(Menu::factory("link")
+ ->id("slideshow")
+ ->label(t("View slideshow"))
+ ->url("javascript:PicLensLite.start(" .
+ "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})")
+ ->css_id("gSlideshowLink"));
+ }
+
+ static function tag_menu($menu, $theme) {
+ $menu
+ ->append(Menu::factory("link")
+ ->id("slideshow")
+ ->label(t("View slideshow"))
+ ->url("javascript:PicLensLite.start(" .
+ "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})")
+ ->css_id("gSlideshowLink"));
+ }
}
diff --git a/modules/slideshow/helpers/slideshow_menu.php b/modules/slideshow/helpers/slideshow_menu.php
deleted file mode 100644
index ee975d88..00000000
--- a/modules/slideshow/helpers/slideshow_menu.php
+++ /dev/null
@@ -1,51 +0,0 @@
-append(Menu::factory("link")
- ->id("slideshow")
- ->label(t("View slideshow"))
- ->url("javascript:PicLensLite.start(" .
- "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})")
- ->css_id("gSlideshowLink"));
- }
-
- static function photo($menu, $theme) {
- $menu
- ->append(Menu::factory("link")
- ->id("slideshow")
- ->label(t("View slideshow"))
- ->url("javascript:PicLensLite.start(" .
- "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})")
- ->css_id("gSlideshowLink"));
- }
-
- static function tag($menu, $theme) {
- $menu
- ->append(Menu::factory("link")
- ->id("slideshow")
- ->label(t("View slideshow"))
- ->url("javascript:PicLensLite.start(" .
- "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})")
- ->css_id("gSlideshowLink"));
- }
-
-}
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index 0fe8a393..f5fa6d4c 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -85,4 +85,12 @@ class tag_event_Core {
}
tag::compact();
}
+
+ static function admin_menu($menu, $theme) {
+ $menu->get("content_menu")
+ ->append(Menu::factory("link")
+ ->id("tags")
+ ->label(t("Tags"))
+ ->url(url::site("admin/tags")));
+ }
}
diff --git a/modules/tag/helpers/tag_menu.php b/modules/tag/helpers/tag_menu.php
deleted file mode 100644
index e1b61a93..00000000
--- a/modules/tag/helpers/tag_menu.php
+++ /dev/null
@@ -1,28 +0,0 @@
-get("content_menu")
- ->append(Menu::factory("link")
- ->id("tags")
- ->label(t("Tags"))
- ->url(url::site("admin/tags")));
- }
-}
diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php
index 6515fbfb..4bde224b 100644
--- a/modules/user/helpers/user_event.php
+++ b/modules/user/helpers/user_event.php
@@ -30,4 +30,12 @@ class user_event_Core {
I18n::instance()->locale($locale);
}
}
+
+ static function admin_menu($menu, $theme) {
+ $menu->add_after("appearance_menu",
+ Menu::factory("link")
+ ->id("users_groups")
+ ->label(t("Users/Groups"))
+ ->url(url::site("admin/users")));
+ }
}
diff --git a/modules/user/helpers/user_menu.php b/modules/user/helpers/user_menu.php
deleted file mode 100644
index 05e401f9..00000000
--- a/modules/user/helpers/user_menu.php
+++ /dev/null
@@ -1,28 +0,0 @@
-add_after("appearance_menu",
- Menu::factory("link")
- ->id("users_groups")
- ->label(t("Users/Groups"))
- ->url(url::site("admin/users")));
- }
-}
diff --git a/modules/watermark/helpers/watermark_event.php b/modules/watermark/helpers/watermark_event.php
new file mode 100644
index 00000000..45b410f9
--- /dev/null
+++ b/modules/watermark/helpers/watermark_event.php
@@ -0,0 +1,29 @@
+get("content_menu")
+ ->append(
+ Menu::factory("link")
+ ->id("watermarks")
+ ->label(t("Watermarks"))
+ ->url(url::site("admin/watermarks")));
+ }
+}
diff --git a/modules/watermark/helpers/watermark_menu.php b/modules/watermark/helpers/watermark_menu.php
deleted file mode 100644
index bc3a4fed..00000000
--- a/modules/watermark/helpers/watermark_menu.php
+++ /dev/null
@@ -1,29 +0,0 @@
-get("content_menu")
- ->append(
- Menu::factory("link")
- ->id("watermarks")
- ->label(t("Watermarks"))
- ->url(url::site("admin/watermarks")));
- }
-}
--
cgit v1.2.3
From 7ad0808a117fd1db4e94da8d7763ccca1d69350a Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 2 Aug 2009 12:09:00 -0700
Subject: Change the API for getting to the original state of an ORM. Old
API: $obj->original("field_name") New API: $obj->original()->field_name
This allows us to revert the varous xxx_updated events back to passing
an original ORM as well as the the updated one. This makes for a
cleaner event API.
Old API: comment_updated($comment) { $comment->original("field_name") }
Old API: comment_updated($old, $new) { $old->field_name }
---
modules/akismet/helpers/akismet_event.php | 6 +++---
modules/comment/models/comment.php | 8 ++++----
modules/gallery/libraries/MY_ORM.php | 12 ++++++------
modules/gallery/models/item.php | 2 +-
modules/gallery/tests/Item_Model_Test.php | 2 +-
modules/notification/helpers/notification_event.php | 8 ++++----
modules/search/helpers/search_event.php | 4 ++--
modules/user/models/group.php | 2 +-
modules/user/models/user.php | 2 +-
9 files changed, 23 insertions(+), 23 deletions(-)
(limited to 'modules/akismet/helpers')
diff --git a/modules/akismet/helpers/akismet_event.php b/modules/akismet/helpers/akismet_event.php
index d6cde222..cec6d95d 100644
--- a/modules/akismet/helpers/akismet_event.php
+++ b/modules/akismet/helpers/akismet_event.php
@@ -40,14 +40,14 @@ class akismet_event_Core {
$comment->save();
}
- static function comment_updated($comment) {
+ static function comment_updated($original, $new) {
if (!module::get_var("akismet", "api_key")) {
return;
}
- if ($comment->original("state") != "spam" && $comment->state == "spam") {
+ if ($original->state != "spam" && $new->state == "spam") {
akismet::submit_spam($new);
- } else if ($comment->original("state") == "spam" && $comment->state != "spam") {
+ } else if ($original->state == "spam" && $new->state != "spam") {
akismet::submit_ham($new);
}
}
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index d052a39c..83d0888a 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -64,17 +64,17 @@ class Comment_Model extends ORM {
$created = true;
}
}
+ $visible_change = $this->original()->state == "published" || $this->state == "published";
parent::save();
if (isset($created)) {
module::event("comment_created", $this);
} else {
- module::event("comment_updated", $this);
+ module::event("comment_updated", $this->original(), $this);
}
- // We only notify on the related items if we're making a visible change, which means moving in
- // or out of a published state
- if ($this->original("state") == "published" || $this->state == "published") {
+ // We only notify on the related items if we're making a visible change.
+ if ($visible_change) {
module::event("item_related_update", $this->item());
}
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php
index 1d3c1ef3..de8adc1d 100644
--- a/modules/gallery/libraries/MY_ORM.php
+++ b/modules/gallery/libraries/MY_ORM.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class ORM extends ORM_Core {
- // Track the original value of this ORM instance so that we can look it up in ORM::original()
+ // Track the original value of this ORM so that we can look it up in ORM::original()
protected $original = null;
public function open_paren() {
@@ -34,13 +34,13 @@ class ORM extends ORM_Core {
public function save() {
model_cache::clear();
$result = parent::save();
- $this->original = $this->object;
+ $this->original = clone $this;
return $result;
}
public function __set($column, $value) {
if (!isset($this->original)) {
- $this->original = $this->object;
+ $this->original = clone $this;
}
return parent::__set($column, $value);
@@ -48,14 +48,14 @@ class ORM extends ORM_Core {
public function __unset($column) {
if (!isset($this->original)) {
- $this->original = $this->object;
+ $this->original = clone $this;
}
return parent::__unset($column);
}
- public function original($column) {
- return $this->original[$column];
+ public function original() {
+ return $this->original;
}
}
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index b3c7998b..f3e6b8f3 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -365,7 +365,7 @@ class Item_Model extends ORM_MPTT {
}
parent::save();
if (isset($send_event)) {
- module::event("item_updated", $this);
+ module::event("item_updated", $this->original(), $this);
}
return $this;
}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index c2773097..0940d076 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -147,7 +147,7 @@ class Item_Model_Test extends Unit_Test_Case {
$item->save();
$item->title = "NEW_VALUE";
- $this->assert_same("ORIGINAL_VALUE", $item->original("title"));
+ $this->assert_same("ORIGINAL_VALUE", $item->original()->title);
$this->assert_same("NEW_VALUE", $item->title);
}
}
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index c6e770a7..d1b76e93 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class notification_event_Core {
- static function item_updated($item) {
- notification::send_item_updated($item);
+ static function item_updated($original, $new) {
+ notification::send_item_updated($new);
}
static function item_created($item) {
@@ -40,8 +40,8 @@ class notification_event_Core {
}
}
- static function comment_updated($item) {
- if ($item->state == "published" && $item->original("state") != "published") {
+ static function comment_updated($original, $new) {
+ if ($new->state == "published" && $original->state != "published") {
notification::send_comment_published($new);
}
}
diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php
index 764fdd18..b65763af 100644
--- a/modules/search/helpers/search_event.php
+++ b/modules/search/helpers/search_event.php
@@ -22,8 +22,8 @@ class search_event_Core {
search::update($item);
}
- static function item_updated($item) {
- search::update($item);
+ static function item_updated($original, $new) {
+ search::update($new);
}
static function item_deleted($item) {
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index bb3fb58b..8af78012 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -41,7 +41,7 @@ class Group_Model extends ORM {
if (isset($created)) {
module::event("group_created", $this);
} else {
- module::event("group_updated", $this);
+ module::event("group_updated", $this->original(), $this);
}
return $this;
}
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index def65a6f..4b43adff 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -68,7 +68,7 @@ class User_Model extends ORM {
if (isset($created)) {
module::event("user_created", $this);
} else {
- module::event("user_updated", $this);
+ module::event("user_updated", $this->original(), $this);
}
return $this;
}
--
cgit v1.2.3
From b4b638be44375c93f5222c7b48ed547845d6d7e5 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 29 Aug 2009 16:28:30 -0700
Subject: Undo url helper changes - url methods no longer return a SafeString.
Adding SafeString::of_safe_html() calls where urls are passed as parameters to t() and t2().
---
modules/akismet/helpers/akismet.php | 2 +-
modules/digibug/views/admin_digibug.html.php | 2 +-
modules/exif/helpers/exif.php | 2 +-
modules/g2_import/views/admin_g2_import.html.php | 10 ++++-----
modules/gallery/helpers/MY_url.php | 24 +---------------------
modules/gallery/helpers/graphics.php | 2 +-
modules/gallery/tests/Xss_Security_Test.php | 15 +++++++++++---
modules/gallery/views/admin_block_welcome.html.php | 10 ++++-----
modules/gallery/views/upgrader.html.php | 2 +-
modules/recaptcha/helpers/recaptcha.php | 2 +-
modules/search/helpers/search.php | 2 +-
modules/server_add/helpers/server_add.php | 2 +-
modules/user/views/reset_password.html.php | 4 +++-
system/helpers/request.php | 2 +-
14 files changed, 35 insertions(+), 46 deletions(-)
(limited to 'modules/akismet/helpers')
diff --git a/modules/akismet/helpers/akismet.php b/modules/akismet/helpers/akismet.php
index db45a6ab..abca78d2 100644
--- a/modules/akismet/helpers/akismet.php
+++ b/modules/akismet/helpers/akismet.php
@@ -94,7 +94,7 @@ class akismet_Core {
if (empty($api_key)) {
site_status::warning(
t("Akismet is not quite ready! Please provide an API Key",
- array("url" => url::site("admin/akismet"))),
+ array("url" => SafeString::of_safe_html(url::site("admin/akismet")))),
"akismet_config");
} else {
site_status::clear("akismet_config");
diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php
index 7e4436ff..5f27a3fd 100644
--- a/modules/digibug/views/admin_digibug.html.php
+++ b/modules/digibug/views/admin_digibug.html.php
@@ -16,7 +16,7 @@
= t("You don't need an account with Digibug, but if you register with Digibug and enter your Digibug id in the Advanced Settings page you can make money off of your photos!",
array("signup_url" => "http://www.digibug.com/signup.php",
- "advanced_settings_url" => url::site("admin/advanced_settings"))) ?>
+ "advanced_settings_url" => SafeString::of_safe_html(url::site("admin/advanced_settings")))) ?>
diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php
index 20ecd0cb..d4e60338 100644
--- a/modules/exif/helpers/exif.php
+++ b/modules/exif/helpers/exif.php
@@ -164,7 +164,7 @@ class exif_Core {
if ($remaining) {
site_status::warning(
t('Your Exif index needs to be updated. Fix this now',
- array("url" => url::site("admin/maintenance/start/exif_task::update_index?csrf=__CSRF__"))),
+ array("url" => SafeString::of_safe_html(url::site("admin/maintenance/start/exif_task::update_index?csrf=__CSRF__")))),
"exif_index_out_of_date");
}
}
diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php
index da2bb5d1..f53510f6 100644
--- a/modules/g2_import/views/admin_g2_import.html.php
+++ b/modules/g2_import/views/admin_g2_import.html.php
@@ -37,9 +37,9 @@
if ($g2_sizes["thumb"]["size"] && $thumb_size != $g2_sizes["thumb"]["size"]): ?>
= t("Your most common thumbnail size in Gallery 2 is %g2_pixels pixels, but your Gallery 3 thumbnail size is set to %g3_pixels pixels. Using the same value will speed up your import.",
- array("g2_pixels" => $g2_sizes["thumb"]["size"],
- "g3_pixels" => $thumb_size,
- "url" => url::site("admin/theme_options"))) ?>
+ array("g2_pixels" => $g2_sizes["thumb"]["size"],
+ "g3_pixels" => $thumb_size,
+ "url" => SafeString::of_safe_html(url::site("admin/theme_options")))) ?>
endif ?>
@@ -47,8 +47,8 @@
= t("Your most common intermediate size in Gallery 2 is %g2_pixels pixels, but your Gallery 3 thumbnail size is set to %g3_pixels pixels. Using the same value will speed up your import.",
array("g2_pixels" => $g2_sizes["resize"]["size"],
- "g3_pixels" => $resize_size,
- "url" => url::site("admin/theme_options"))) ?>
+ "g3_pixels" => $resize_size,
+ "url" => SafeString::of_safe_html(url::site("admin/theme_options")))) ?>
endif ?>
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index 6092a9d8..c4967c52 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -30,8 +30,7 @@ class url extends url_Core {
if ($parts[0] == "albums" || $parts[0] == "photos") {
$uri = model_cache::get("item", $parts[1])->relative_path();
}
- $url = parent::site($uri . $query, $protocol);
- return SafeString::of_safe_html($url);
+ return parent::site($uri . $query, $protocol);
}
static function parse_url() {
@@ -100,25 +99,4 @@ class url extends url_Core {
static function abs_current($qs=false) {
return self::abs_site(url::current($qs));
}
-
- public static function base($index=false, $protocol=false) {
- $url = parent::base($index, $protocol);
- return SafeString::of_safe_html($url);
- }
-
- public static function current($qs=false) {
- $url = parent::current($qs);
- return SafeString::of_safe_html($url);
- }
-
- public static function file($file, $index=false) {
- $url = parent::file($file, $index);
- return SafeString::of_safe_html($url);
- }
-
- public static function merge(array $arguments) {
- $url = parent::merge($arguments);
- return SafeString::of_safe_html($url);
- }
-
}
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 7dc46eeb..fbb85bec 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -442,7 +442,7 @@ class graphics_Core {
if (!module::get_var("gallery", "graphics_toolkit")) {
site_status::warning(
t("Graphics toolkit missing! Please choose a toolkit",
- array("url" => url::site("admin/graphics"))),
+ array("url" => SafeString::of_safe_html(url::site("admin/graphics")))),
"missing_graphics_toolkit");
}
}
diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php
index 690dc760..a2d3d59b 100644
--- a/modules/gallery/tests/Xss_Security_Test.php
+++ b/modules/gallery/tests/Xss_Security_Test.php
@@ -130,14 +130,14 @@ class Xss_Security_Test extends Unit_Test_Case {
$token = $tokens[$token_number];
}
} else if ($token[1] == "url") {
- // url methods return a SafeString
+ // url methods return safe HTML
if (self::_token_matches(array(T_DOUBLE_COLON, "::"), $tokens, $token_number + 1) &&
self::_token_matches(array(T_STRING), $tokens, $token_number + 2) &&
in_array($tokens[$token_number + 2][1],
array("site", "current", "base", "file", "abs_site", "abs_current",
"abs_file", "merge")) &&
self::_token_matches("(", $tokens, $token_number + 3)) {
- $frame->is_safestring(true);
+ $frame->is_safe_html(true);
$method = $tokens[$token_number + 2][1];
$frame->expr_append("::$method(");
@@ -203,7 +203,8 @@ class Xss_Security_Test extends Unit_Test_Case {
$state = "CLEAN";
}
} else {
- if ($frame->is_safestring() || $frame->purified_html_called() || $frame->for_html_called()) {
+ if ($frame->is_safe_html() || $frame->is_safestring() ||
+ $frame->purified_html_called() || $frame->for_html_called()) {
$state = "CLEAN";
}
}
@@ -259,6 +260,7 @@ class Xss_Security_Test_Frame {
private $_for_html_called = false;
private $_purified_html_called = false;
private $_json_encode_called = false;
+ private $_is_safe_html = false;
private $_line;
function __construct($line_number, $in_script_block) {
@@ -288,6 +290,13 @@ class Xss_Security_Test_Frame {
return $this->_is_safestring;
}
+ function is_safe_html($new_val=NULL) {
+ if ($new_val !== NULL) {
+ $this->_is_safe_html = (bool) $new_val;
+ }
+ return $this->_is_safe_html;
+ }
+
function json_encode_called($new_val=NULL) {
if ($new_val !== NULL) {
$this->_json_encode_called = (bool) $new_val;
diff --git a/modules/gallery/views/admin_block_welcome.html.php b/modules/gallery/views/admin_block_welcome.html.php
index 38d2bd56..c6ccdbf3 100644
--- a/modules/gallery/views/admin_block_welcome.html.php
+++ b/modules/gallery/views/admin_block_welcome.html.php
@@ -5,16 +5,16 @@
-
= t("General Settings - choose your graphics and language settings.",
- array("graphics_url" => url::site("admin/graphics"),
- "language_url" => url::site("admin/languages"))) ?>
+ array("graphics_url" => SafeString::of_safe_html(url::site("admin/graphics")),
+ "language_url" => SafeString::of_safe_html(url::site("admin/languages")))) ?>
-
= t("Appearance - choose a theme, or customize the way it looks.",
- array("theme_url" => url::site("admin/themes"),
- "theme_options_url" => url::site("admin/theme_options"))) ?>
+ array("theme_url" => SafeString::of_safe_html(url::site("admin/themes")),
+ "theme_options_url" => SafeString::of_safe_html(url::site("admin/theme_options")))) ?>
-
= t("Customize - install modules to add cool features!",
- array("modules_url" => url::site("admin/modules"))) ?>
+ array("modules_url" => SafeString::of_safe_html(url::site("admin/modules")))) ?>
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 37578855..ccc86da8 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -18,7 +18,7 @@
= t("That's it!") ?>
= t("Your Gallery is up to date.",
- array("url" => url::site("albums/1"))) ?>
+ array("url" => SafeString::of_safe_html(url::site("albums/1")))) ?>
diff --git a/modules/recaptcha/helpers/recaptcha.php b/modules/recaptcha/helpers/recaptcha.php
index 501dd972..35d9febd 100644
--- a/modules/recaptcha/helpers/recaptcha.php
+++ b/modules/recaptcha/helpers/recaptcha.php
@@ -43,7 +43,7 @@ class recaptcha_Core {
if (empty($public_key) || empty($private_key)) {
site_status::warning(
t("reCAPTCHA is not quite ready! Please configure the reCAPTCHA Keys",
- array("url" => url::site("admin/recaptcha"))),
+ array("url" => SafeString::of_safe_html(url::site("admin/recaptcha")))),
"recaptcha_config");
} else {
site_status::clear("recaptcha_config");
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php
index 355c4493..4be04039 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -58,7 +58,7 @@ class search_Core {
if ($remaining) {
site_status::warning(
t('Your search index needs to be updated. Fix this now',
- array("url" => url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__"))),
+ array("url" => SafeString::of_safe_html(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))),
"search_index_out_of_date");
}
}
diff --git a/modules/server_add/helpers/server_add.php b/modules/server_add/helpers/server_add.php
index 74f51ad9..57afac12 100644
--- a/modules/server_add/helpers/server_add.php
+++ b/modules/server_add/helpers/server_add.php
@@ -25,7 +25,7 @@ class server_add_Core {
if (empty($paths)) {
site_status::warning(
t("Server Add needs configuration. Configure it now!",
- array("url" => url::site("admin/server_add"))),
+ array("url" => SafeString::of_safe_html(url::site("admin/server_add")))),
"server_add_configuration");
} else {
site_status::clear("server_add_configuration");
diff --git a/modules/user/views/reset_password.html.php b/modules/user/views/reset_password.html.php
index 3dc7aebf..6fa92d54 100644
--- a/modules/user/views/reset_password.html.php
+++ b/modules/user/views/reset_password.html.php
@@ -9,7 +9,9 @@
= t("Hello, %name,", array("name" => $user->full_name ? $user->full_name : $user->name)) ?>
- = t("We received a request to reset your password for %site_url. If you made this request, you can confirm it by clicking this link. If you didn't request this password reset, it's ok to ignore this mail.", array("site_url" => url::base(false, "http"), "confirm_url" => $confirm_url)) ?>
+ = t("We received a request to reset your password for %site_url. If you made this request, you can confirm it by clicking this link. If you didn't request this password reset, it's ok to ignore this mail.",
+ array("site_url" => SafeString::of_safe_html(url::base(false, "http")),
+ "confirm_url" => $confirm_url)) ?>