00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_AdminNotification_Helper_Data extends Mage_Core_Helper_Abstract
00036 {
00037 const XML_PATH_POPUP_URL = 'system/adminnotification/popup_url';
00038
00039
00040
00041
00042
00043
00044 protected $_popupUrl;
00045
00046
00047
00048
00049
00050
00051 protected $_popupReadable;
00052
00053
00054
00055
00056
00057
00058 protected $_latestNotice;
00059
00060
00061
00062
00063
00064
00065 protected $_unreadNoticeCounts;
00066
00067
00068
00069
00070
00071
00072 public function getLatestNotice()
00073 {
00074 if (is_null($this->_latestNotice)) {
00075 $this->_latestNotice = Mage::getModel('adminnotification/inbox')->loadLatestNotice();
00076 }
00077 return $this->_latestNotice;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086 public function getUnreadNoticeCount($severity)
00087 {
00088 if (is_null($this->_unreadNoticeCounts)) {
00089 $this->_unreadNoticeCounts = Mage::getModel('adminnotification/inbox')->getNoticeStatus();
00090 }
00091 return isset($this->_unreadNoticeCounts[$severity]) ? $this->_unreadNoticeCounts[$severity] : 0;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100 public function getPopupObjectUrl($withExt = false)
00101 {
00102 if (is_null($this->_popupUrl)) {
00103 $sheme = Mage::app()->getFrontController()->getRequest()->isSecure()
00104 ? 'https://'
00105 : 'http://';
00106
00107 $this->_popupUrl = $sheme . Mage::getStoreConfig(self::XML_PATH_POPUP_URL);
00108 }
00109 return $this->_popupUrl . ($withExt ? '.swf' : '');
00110 }
00111
00112
00113
00114
00115
00116
00117 public function isReadablePopupObject()
00118 {
00119 if (is_null($this->_popupReadable)) {
00120 $this->_popupReadable = false;
00121 $curl = new Varien_Http_Adapter_Curl();
00122 $curl->setConfig(array(
00123 'timeout' => 2
00124 ));
00125 $curl->write(Zend_Http_Client::GET, $this->getPopupObjectUrl(true));
00126 if ($curl->read()) {
00127 if ($curl->getInfo(CURLINFO_HTTP_CODE) == 200) {
00128 $this->_popupReadable = true;
00129 }
00130 }
00131 }
00132 return $this->_popupReadable;
00133 }
00134 }