1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Adminhtml AdminNotification toolbar
30: *
31: * @category Mage
32: * @package Mage_Adminhtml
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Adminhtml_Block_Notification_Toolbar extends Mage_Adminhtml_Block_Template
36: {
37: /**
38: * Initialize Toolbar block
39: *
40: */
41: protected function _construct()
42: {}
43:
44: /**
45: * Retrieve helper
46: *
47: * @return Mage_AdminNotification_Helper_Data
48: */
49: protected function _getHelper()
50: {
51: return Mage::helper('adminnotification');
52: }
53:
54: /**
55: * Check is show toolbar
56: *
57: * @return bool
58: */
59: public function isShow()
60: {
61: if (!$this->isOutputEnabled('Mage_AdminNotification')) {
62: return false;
63: }
64: if ($this->getRequest()->getControllerName() == 'notification') {
65: return false;
66: }
67: if ($this->getCriticalCount() == 0 && $this->getMajorCount() == 0 && $this->getMinorCount() == 0
68: && $this->getNoticeCount() == 0
69: ) {
70: return false;
71: }
72:
73: return true;
74: }
75:
76: /**
77: * Retrieve count of critical errors
78: *
79: * @return int
80: */
81: public function getCriticalCount()
82: {
83: return $this->_getHelper()
84: ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL);
85: }
86:
87: /**
88: * Retrieve count of major errors
89: *
90: * @return int
91: */
92: public function getMajorCount()
93: {
94: return $this->_getHelper()
95: ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR);
96: }
97:
98: /**
99: * Retrieve count of minor errors
100: *
101: * @return int
102: */
103: public function getMinorCount()
104: {
105: return $this->_getHelper()
106: ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
107: }
108:
109: /**
110: * Retrieve count of notices
111: *
112: * @return int
113: */
114: public function getNoticeCount()
115: {
116: return $this->_getHelper()
117: ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE);
118: }
119:
120: /**
121: * Retrieve Notices Inbox URL
122: *
123: * @return string
124: */
125: public function getNoticesInboxUrl()
126: {
127: return $this->getUrl('adminhtml/notification');
128: }
129:
130: /**
131: * Retrieve last notice Title
132: *
133: * @return string
134: */
135: public function getLatestNotice()
136: {
137: return $this->_getHelper()
138: ->getLatestNotice()->getTitle();
139: }
140:
141: /**
142: * Retrieve Last Notice URL
143: *
144: * @return string
145: */
146: public function getLatestNoticeUrl()
147: {
148: return $this->_getHelper()->getLatestNotice()->getUrl();
149: }
150:
151: /**
152: * Check is Message Window Available
153: *
154: * @return bool
155: */
156: public function isMessageWindowAvailable()
157: {
158: $block = $this->getLayout()->getBlock('notification_window');
159: if ($block) {
160: return $block->canShow();
161: }
162: return false;
163: }
164: }
165: