summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/comment/controllers/admin_comments.php34
-rw-r--r--modules/comment/views/admin_comments.html.php32
2 files changed, 43 insertions, 23 deletions
diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php
index 9d7e1222..a4b1a94c 100644
--- a/modules/comment/controllers/admin_comments.php
+++ b/modules/comment/controllers/admin_comments.php
@@ -19,25 +19,14 @@
*/
class Admin_Comments_Controller extends Admin_Controller {
- public function index() {
- $this->queue("all");
- }
-
- public function queue($state) {
+ private function _get_base_view() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_comments.html");
- $view->content->all = $this->_query(array("published", "unpublished"));
$view->content->published = $this->_query(array("published"));
$view->content->unpublished = $this->_query(array("unpublished"));
$view->content->spam = $this->_query(array("spam"));
$view->content->menu = Menu::factory("root")
->append(Menu::factory("link")
- ->id("all")
- ->label(t(array("one" => "All Comments ({{count}})",
- "other" => "All Comments ({{count}})"),
- array("count" => $view->content->all->count())))
- ->url(url::site("admin/comments/queue/all")))
- ->append(Menu::factory("link")
->id("unpublished")
->label(t(array("one" => "Awaiting Moderation ({{count}})",
"other" => "Awaiting Moderation ({{count}})"),
@@ -55,13 +44,24 @@ class Admin_Comments_Controller extends Admin_Controller {
"other" => "Spam ({{count}})"),
array("count" => $view->content->spam->count())))
->url(url::site("admin/comments/queue/spam")));
+ return $view;
+ }
- switch ($state) {
- case "all":
- $view->content->comments = $view->content->all;
- $view->content->title = t("All Comments");
- break;
+ public function index() {
+ $this->queue("unpublished");
+ }
+
+ public function menu_labels($state) {
+ $view = $this->_get_base_view();
+ print json_encode(array($view->content->menu->get("unpublished")->label,
+ $view->content->menu->get("published")->label,
+ $view->content->menu->get("spam")->label));
+ }
+ public function queue($state) {
+ $view = $this->_get_base_view();
+
+ switch ($state) {
case "published":
$view->content->comments = $view->content->published;
$view->content->title = t("Approved Comments");
diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php
index 1cbdcd70..ae3051ad 100644
--- a/modules/comment/views/admin_comments.html.php
+++ b/modules/comment/views/admin_comments.html.php
@@ -3,16 +3,36 @@
var set_state_url =
"<?= url::site("admin/comments/set_state/__ID__/__STATE__?csrf=" . access::csrf_token()) ?>";
function set_state(state, id) {
- $.get(set_state_url.replace("__STATE__", state).replace("__ID__", id));
- $("#gComment-" + id).slideUp();
+ $.get(set_state_url.replace("__STATE__", state).replace("__ID__", id),
+ {},
+ function() {
+ $("#gComment-" + id).slideUp();
+ update_menu();
+ });
}
var delete_url =
"<?= url::site("admin/comments/delete/__ID__?csrf=" . access::csrf_token()) ?>";
- function del(id) {
- $.get(delete_url.replace("__ID__", id));
- $("#gComment-" + id).slideUp();
- }
+
+function del(id) {
+ $.get(delete_url.replace("__ID__", id),
+ {},
+ function() {
+ $("#gComment-" + id).slideUp();
+ update_menu();
+ });
+}
+
+function update_menu() {
+ $.get("<?= url::site("admin/comments/menu_labels") ?>", {},
+ function(data) {
+ for (var i = 0; i < data.length; i++) {
+ $("#gAdminCommentsMenu li:eq(" + i + ") a").html(data[i]);
+ }
+ },
+ "json");
+}
+
</script>
<div id="gAdminComments">