diff --git a/library/Director/Dashboard/Dashlet/Dashlet.php b/library/Director/Dashboard/Dashlet/Dashlet.php index 97e8b86a..8c950326 100644 --- a/library/Director/Dashboard/Dashlet/Dashlet.php +++ b/library/Director/Dashboard/Dashlet/Dashlet.php @@ -178,6 +178,55 @@ abstract class Dashlet return $this->view->translate($msg); } + public function getStats($type, $name = null) + { + if ($name === null) { + return $this->stats[$type]; + } else { + return $this->stats[$type]->{'cnt_' . $name}; + } + } + + protected function getTemplateSummaryText($type) + { + $view = $this->view; + $stat = $this->stats[$type]; + $cnt = (int) $this->stats[$type]->cnt_template; + + if ($cnt === 0) { + return $view->translate('No template has been defined yet'); + } + + if ($cnt === 1) { + return $view->translate('One template has been defined'); + } + + return sprintf( + $view->translate('%d templates have been defined'), + $cnt + ); + } + + protected function getApplySummaryText($type) + { + $view = $this->view; + $stat = $this->stats[$type]; + $cnt = (int) $this->stats[$type]->cnt_apply; + + if ($cnt === 0) { + return $view->translate('No apply rule has been defined yet'); + } + + if ($cnt === 1) { + return $view->translate('One apply rule has been defined'); + } + + return sprintf( + $view->translate('%d apply rules have been defined'), + $cnt + ); + } + protected function statSummary($type) { $view = $this->view; diff --git a/library/Director/Dashboard/Dashlet/NotificationObjectDashlet.php b/library/Director/Dashboard/Dashlet/NotificationObjectDashlet.php deleted file mode 100644 index f7d87b0e..00000000 --- a/library/Director/Dashboard/Dashlet/NotificationObjectDashlet.php +++ /dev/null @@ -1,26 +0,0 @@ -translate('Notifications.'); - } - - public function getSummary() - { - return $this->translate('Schedule your notifications.') - . ' ' . parent::getSummary(); - } - - public function getUrl() - { - return 'director/notifications'; - } -} diff --git a/library/Director/Dashboard/Dashlet/NotificationsDashlet.php b/library/Director/Dashboard/Dashlet/NotificationsDashlet.php new file mode 100644 index 00000000..c8c81a75 --- /dev/null +++ b/library/Director/Dashboard/Dashlet/NotificationsDashlet.php @@ -0,0 +1,28 @@ +translate('Notifications'); + } + + public function getSummary() + { + return $this->translate( + 'Schedule your notifications. Define who should be notified, when,' + . ' and for which kind of problem' + ); + } + + public function getUrl() + { + return 'director/dashboard?name=notifications'; + } +}