00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Adminhtml 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Adminhtml AdminNotification toolbar 00030 * 00031 * @category Mage 00032 * @package Mage_Adminhtml 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 class Mage_Adminhtml_Block_Notification_Toolbar extends Mage_Adminhtml_Block_Template 00036 { 00037 /** 00038 * Initialize Toolbar block 00039 * 00040 */ 00041 protected function _construct() 00042 {} 00043 00044 /** 00045 * Retrieve helper 00046 * 00047 * @return Mage_AdminNotification_Helper_Data 00048 */ 00049 protected function _getHelper() 00050 { 00051 return Mage::helper('adminnotification'); 00052 } 00053 00054 /** 00055 * Check is show toolbar 00056 * 00057 * @return bool 00058 */ 00059 public function isShow() 00060 { 00061 if (!$this->isOutputEnabled('Mage_AdminNotification')) { 00062 return false; 00063 } 00064 if ($this->getRequest()->getControllerName() == 'notification') { 00065 return false; 00066 } 00067 if ($this->getCriticalCount() == 0 && $this->getMajorCount() == 0 && $this->getMinorCount() == 0 && $this->getNoticeCount() == 0) { 00068 return false; 00069 } 00070 return true; 00071 } 00072 00073 /** 00074 * Retrieve count of critical errors 00075 * 00076 * @return int 00077 */ 00078 public function getCriticalCount() 00079 { 00080 return $this->_getHelper() 00081 ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL); 00082 } 00083 00084 /** 00085 * Retrieve count of major errors 00086 * 00087 * @return int 00088 */ 00089 public function getMajorCount() 00090 { 00091 return $this->_getHelper() 00092 ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR); 00093 } 00094 00095 /** 00096 * Retrieve count of minor errors 00097 * 00098 * @return int 00099 */ 00100 public function getMinorCount() 00101 { 00102 return $this->_getHelper() 00103 ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR); 00104 } 00105 00106 /** 00107 * Retrieve count of notices 00108 * 00109 * @return int 00110 */ 00111 public function getNoticeCount() 00112 { 00113 return $this->_getHelper() 00114 ->getUnreadNoticeCount(Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE); 00115 } 00116 00117 /** 00118 * Retrieve Notices Inbox URL 00119 * 00120 * @return string 00121 */ 00122 public function getNoticesInboxUrl() 00123 { 00124 return $this->getUrl('adminhtml/notification'); 00125 } 00126 00127 /** 00128 * Retrieve last notice Title 00129 * 00130 * @return string 00131 */ 00132 public function getLatestNotice() 00133 { 00134 return $this->_getHelper() 00135 ->getLatestNotice()->getTitle(); 00136 } 00137 00138 /** 00139 * Retrieve Last Notice URL 00140 * 00141 * @return string 00142 */ 00143 public function getLatestNoticeUrl() 00144 { 00145 return $this->_getHelper()->getLatestNotice()->getUrl(); 00146 } 00147 00148 /** 00149 * Check is Message Window Available 00150 * 00151 * @return bool 00152 */ 00153 public function isMessageWindowAvailable() 00154 { 00155 $block = $this->getLayout()->getBlock('notification_window'); 00156 if ($block) { 00157 return $block->canShow(); 00158 } 00159 return false; 00160 } 00161 }