diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-10-31 07:41:42 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-10-31 07:41:42 +0400 |
commit | ac7ef829763634bb0c27990854e0ad9fd9781563 (patch) | |
tree | c487da15816b61032e05ae8cc91cc07168355080 /plugins/ExampleUI | |
parent | 8adffe2953a254163ab69e6d301aa6e8f13a31cf (diff) |
refs #4179 added some notification examples
Diffstat (limited to 'plugins/ExampleUI')
-rw-r--r-- | plugins/ExampleUI/Controller.php | 27 | ||||
-rw-r--r-- | plugins/ExampleUI/ExampleUI.php | 12 | ||||
-rw-r--r-- | plugins/ExampleUI/templates/notifications.twig | 9 |
3 files changed, 46 insertions, 2 deletions
diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php index 06bd38fd1f..0480ae83cf 100644 --- a/plugins/ExampleUI/Controller.php +++ b/plugins/ExampleUI/Controller.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\ExampleUI; use Piwik\Common; +use Piwik\Notification; use Piwik\Piwik; use Piwik\View; use Piwik\ViewDataTable\Factory; @@ -53,6 +54,32 @@ class Controller extends \Piwik\Plugin\Controller echo $view->render(); } + public function notifications() + { + $notification = new Notification('Lorem ipsum dolor sit amet, consectetur adipiscing elit.'); + Notification\Manager::notify('ExampleUI_InfoSimple', $notification); + + $notification = new Notification('Neque porro quisquam est qui dolorem ipsum quia dolor sit amet.'); + $notification->title = 'Warning:'; + $notification->context = Notification::CONTEXT_WARNING; + $notification->flags = null; + Notification\Manager::notify('ExampleUI_warningWithClose', $notification); + + $notification = new Notification('Phasellus tincidunt arcu at justo faucibus, et lacinia est accumsan. '); + $notification->title = 'Well done'; + $notification->context = Notification::CONTEXT_SUCCESS; + $notification->type = Notification::TYPE_TOAST; + Notification\Manager::notify('ExampleUI_successToast', $notification); + + $notification = new Notification('Phasellus tincidunt arcu at justo <a href="#">faucibus</a>, et lacinia est accumsan. '); + $notification->context = Notification::CONTEXT_ERROR; + Notification\Manager::notify('ExampleUI_error', $notification); + + $view = new View('@ExampleUI/notifications'); + $this->setGeneralVariablesView($view); + echo $view->render(); + } + public function getEvolutionGraph($fetch = false, array $columns = array()) { if (empty($columns)) { diff --git a/plugins/ExampleUI/ExampleUI.php b/plugins/ExampleUI/ExampleUI.php index e5d11ffddd..46449d51b2 100644 --- a/plugins/ExampleUI/ExampleUI.php +++ b/plugins/ExampleUI/ExampleUI.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\ExampleUI; use Piwik\Menu\MenuMain; +use Piwik\Menu\MenuTop; /** * @package ExampleUI @@ -23,11 +24,12 @@ class ExampleUI extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'Menu.Reporting.addItems' => 'addMenus', + 'Menu.Reporting.addItems' => 'addReportingMenuItems', + 'Menu.Top.addItems' => 'addTopMenuItems', ); } - function addMenus() + function addReportingMenuItems() { MenuMain::getInstance()->add('UI Framework', '', array('module' => 'ExampleUI', 'action' => 'dataTables'), true, 30); @@ -39,6 +41,12 @@ class ExampleUI extends \Piwik\Plugin $this->addSubMenu('Evolution Graph', 'evolutionGraph', 6); } + function addTopMenuItems() + { + $urlParams = array('module' => 'ExampleUI', 'action' => 'notifications'); + MenuTop::getInstance()->addEntry('Example UI Notifications', $urlParams, $displayedForCurrentUser = true, $order = 3); + } + private function addSubMenu($subMenu, $action, $order) { MenuMain::getInstance()->add('UI Framework', $subMenu, array('module' => 'ExampleUI', 'action' => $action), true, $order); diff --git a/plugins/ExampleUI/templates/notifications.twig b/plugins/ExampleUI/templates/notifications.twig new file mode 100644 index 0000000000..2212ead3d9 --- /dev/null +++ b/plugins/ExampleUI/templates/notifications.twig @@ -0,0 +1,9 @@ +{% extends 'dashboard.twig' %} + +{% block content %} + <h2>Inline notification example:</h2> + + <div style="display:inline-block;margin-top:10px;" id="exampleUI_notifications"> + {{ 'This is an example for an inline notification. Have you noticed the success message disappeared after a few seconds?'|notification({'placeAt': '#exampleUI_notifications', 'title': 'Info: ', 'noclear': true, 'context': 'info'}) }} + </div> +{% endblock %}
\ No newline at end of file |