2007-09-07 00:33:58 +02:00
|
|
|
<?php
|
2009-01-20 05:01:45 +01:00
|
|
|
/**
|
|
|
|
* Blog Management Widget
|
|
|
|
* @package blog
|
|
|
|
*/
|
2007-09-07 00:33:58 +02:00
|
|
|
class BlogManagementWidget extends Widget {
|
2009-01-20 05:01:45 +01:00
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
static $db = array();
|
|
|
|
|
2009-01-20 05:01:45 +01:00
|
|
|
static $has_one = array();
|
|
|
|
|
|
|
|
static $has_many = array();
|
|
|
|
|
|
|
|
static $many_many = array();
|
|
|
|
|
|
|
|
static $belongs_many_many = array();
|
|
|
|
|
|
|
|
static $defaults = array();
|
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
static $title = "Blog Management";
|
|
|
|
static $cmsTitle = "Blog Management";
|
|
|
|
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
|
|
|
|
|
|
|
|
function CommentText() {
|
|
|
|
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
|
|
|
|
if($unmoderatedcount == 1) {
|
2007-12-18 02:41:51 +01:00
|
|
|
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
|
2007-09-07 00:33:58 +02:00
|
|
|
} else if($unmoderatedcount > 1) {
|
2007-12-18 02:41:51 +01:00
|
|
|
return sprintf(_t("BlogManagementWidget.UNMM", "You have %i unmoderated comments"), $unmoderatedcount);
|
2007-09-07 00:33:58 +02:00
|
|
|
} else {
|
2007-12-18 02:41:51 +01:00
|
|
|
return _t("BlogManagementWidget.COMADM", "Comment administration");
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function CommentLink() {
|
2009-02-07 03:19:27 +01:00
|
|
|
if(!Permission::check('ADMIN')) {
|
|
|
|
return false;
|
|
|
|
}
|
2007-09-07 00:33:58 +02:00
|
|
|
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
|
|
|
|
|
|
|
|
if($unmoderatedcount > 0) {
|
|
|
|
return "admin/comments/unmoderated";
|
|
|
|
} else {
|
|
|
|
return "admin/comments";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function WidgetHolder() {
|
2009-05-01 00:05:54 +02:00
|
|
|
$container = BlogTree::current();
|
|
|
|
|
2009-05-06 07:01:28 +02:00
|
|
|
if ($container && $container instanceof BlogHolder && $container->canAddChildren()) return $this->renderWith('WidgetHolder');
|
2009-02-07 03:19:27 +01:00
|
|
|
return '';
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function PostLink() {
|
2009-05-01 00:05:54 +02:00
|
|
|
$container = BlogTree::current();
|
|
|
|
if ($container) return $container->Link('post');
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-27 01:52:14 +02:00
|
|
|
?>
|