Version Notes
Initial release. Easily add a custom notification bar to the top of your site.
Download this release
Release Info
Developer | Justin Stern |
Extension | FoxRunSoftware_NotificationBar |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/FoxRunSoftware/NotificationBar/Block/Adminhtml/Config/Form/Field/Datepicker.php +71 -0
- app/code/community/FoxRunSoftware/NotificationBar/Block/Html/Notifications.php +158 -0
- app/code/community/FoxRunSoftware/NotificationBar/Block/Html/Styles.php +71 -0
- app/code/community/FoxRunSoftware/NotificationBar/etc/config.xml +46 -0
- app/code/community/FoxRunSoftware/NotificationBar/etc/system.xml +114 -0
- app/design/frontend/base/default/layout/notificationbar.xml +20 -0
- app/design/frontend/base/default/template/notificationbar/html/notifications.phtml +31 -0
- app/design/frontend/base/default/template/notificationbar/html/styles.phtml +40 -0
- app/etc/modules/FoxRunSoftware_NotificationBar.xml +9 -0
- package.xml +37 -0
app/code/community/FoxRunSoftware/NotificationBar/Block/Adminhtml/Config/Form/Field/Datepicker.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Datepicker adminhtml configuration control 'model' based on the
|
4 |
+
* Mage_Adminhtml_Block_Report_Config_Form_Field_YtdStart control.
|
5 |
+
*
|
6 |
+
* Use this control to add a Magento configuration Year Month Day selector,
|
7 |
+
* configured in a system.xml as follows:
|
8 |
+
*
|
9 |
+
* <frontend_type>select</frontend_type>
|
10 |
+
* <frontend_model>notificationbar/adminhtml_config_form_field_datepicker</frontend_model>
|
11 |
+
*
|
12 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
13 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
14 |
+
* @license FoxRunSoftware License Agreement
|
15 |
+
*
|
16 |
+
* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
17 |
+
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
18 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
19 |
+
* PARTICULAR PURPOSE.
|
20 |
+
*
|
21 |
+
* @category FoxRunSoftware
|
22 |
+
* @package FoxRunSoftware_NotificationBar
|
23 |
+
*/
|
24 |
+
class FoxRunSoftware_NotificationBar_Block_Adminhtml_Config_Form_Field_Datepicker extends Mage_Adminhtml_Block_System_Config_Form_Field
|
25 |
+
{
|
26 |
+
|
27 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
28 |
+
{
|
29 |
+
$_years = array(null => "Year");
|
30 |
+
for($i = 0, $y = (int)date("Y"); $i < 5; $i++, $y++) {
|
31 |
+
$_years[$y] = $y;
|
32 |
+
}
|
33 |
+
|
34 |
+
$_months = array(null => "Month");
|
35 |
+
for ($i = 1; $i <= 12; $i++) {
|
36 |
+
$_months[$i] = Mage::app()->getLocale()
|
37 |
+
->date(mktime(null,null,null,$i))
|
38 |
+
->get(Zend_date::MONTH_NAME);
|
39 |
+
}
|
40 |
+
|
41 |
+
$_days = array(null => "Day");
|
42 |
+
for ($i = 1; $i <= 31; $i++) {
|
43 |
+
$_days[$i] = $i < 10 ? '0'.$i : $i;
|
44 |
+
}
|
45 |
+
|
46 |
+
if ($element->getValue()) {
|
47 |
+
$values = explode(',', $element->getValue());
|
48 |
+
} else {
|
49 |
+
$values = array();
|
50 |
+
}
|
51 |
+
|
52 |
+
$element->setName($element->getName() . '[]');
|
53 |
+
|
54 |
+
$_yearsHtml = $element->setStyle('width:75px;')
|
55 |
+
->setValues($_years)
|
56 |
+
->setValue(isset($values[0]) ? $values[0] : null)
|
57 |
+
->getElementHtml();
|
58 |
+
|
59 |
+
$_monthsHtml = $element->setStyle('width:100px;')
|
60 |
+
->setValues($_months)
|
61 |
+
->setValue(isset($values[1]) ? $values[1] : null)
|
62 |
+
->getElementHtml();
|
63 |
+
|
64 |
+
$_daysHtml = $element->setStyle('width:50px;')
|
65 |
+
->setValues($_days)
|
66 |
+
->setValue(isset($values[2]) ? $values[2] : null)
|
67 |
+
->getElementHtml();
|
68 |
+
|
69 |
+
return sprintf('%s %s %s', $_yearsHtml, $_monthsHtml, $_daysHtml);
|
70 |
+
}
|
71 |
+
}
|
app/code/community/FoxRunSoftware/NotificationBar/Block/Html/Notifications.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Notifications block
|
4 |
+
*
|
5 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
6 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
7 |
+
* @license FoxRunSoftware License Agreement
|
8 |
+
*
|
9 |
+
* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
10 |
+
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
11 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
12 |
+
* PARTICULAR PURPOSE.
|
13 |
+
*
|
14 |
+
* @category FoxRunSoftware
|
15 |
+
* @package FoxRunSoftware_NotificationBar
|
16 |
+
*/
|
17 |
+
class FoxRunSoftware_NotificationBar_Block_Html_Notifications extends Mage_Core_Block_Template
|
18 |
+
{
|
19 |
+
|
20 |
+
const XML_PATH_NOTIFICATIONBAR_DISPLAY = 'design/notificationbar/display';
|
21 |
+
const XML_PATH_NOTIFICATIONBAR_CONTENT = 'design/notificationbar/content';
|
22 |
+
const XML_PATH_NOTIFICATIONBAR_CLEAR_CONTROL = 'design/notificationbar/clearcontrol';
|
23 |
+
const XML_PATH_NOTIFICATIONBAR_IDENTIFIER = 'design/notificationbar/identifier';
|
24 |
+
const XML_PATH_NOTIFICATIONBAR_FIXED = 'design/notificationbar/fixed';
|
25 |
+
const XML_PATH_NOTIFICATIONBAR_START_DATE = 'design/notificationbar/start_date';
|
26 |
+
const XML_PATH_NOTIFICATIONBAR_END_DATE = 'design/notificationbar/end_date';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Check if the notifications bar should be displayed
|
30 |
+
*
|
31 |
+
* @return boolean
|
32 |
+
*/
|
33 |
+
public function displayNotifications()
|
34 |
+
{
|
35 |
+
// notification bar enabled
|
36 |
+
// AND bar is either not cleared OR bar is not allowed to be cleared
|
37 |
+
// AND after start date
|
38 |
+
// AND before end date
|
39 |
+
return Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_DISPLAY) &&
|
40 |
+
$this->_hasNotificationContent() &&
|
41 |
+
(!$this->isNotificationCleared() || !$this->allowClearControl()) &&
|
42 |
+
$this->_afterStartDate() &&
|
43 |
+
$this->_beforeEndDate();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Fetches the notification bar content
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function getNotificationContent()
|
52 |
+
{
|
53 |
+
$content = Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_CONTENT);
|
54 |
+
|
55 |
+
// tentatively translate Template Tags, using the CMS helper (tried with catalog helper but no-go)
|
56 |
+
$helper = Mage::helper('cms');
|
57 |
+
if($helper) {
|
58 |
+
$processor = $helper->getBlockTemplateProcessor();
|
59 |
+
if($processor) {
|
60 |
+
$content = $processor->filter($content);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
return $content;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Returns true if there is notification content to display
|
69 |
+
*
|
70 |
+
* @return boolean
|
71 |
+
*/
|
72 |
+
protected function _hasNotificationContent() {
|
73 |
+
$content = $this->getNotificationContent();
|
74 |
+
return !empty($content);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Returns true if the notification bar should be able to be closed/cleared
|
79 |
+
*
|
80 |
+
* @return boolean
|
81 |
+
*/
|
82 |
+
public function allowClearControl() {
|
83 |
+
return Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_CLEAR_CONTROL);
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Returns the notification bar cookie name, which includes the current
|
88 |
+
* notification bar identifier, if any.
|
89 |
+
*
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
+
public function getNotificationClearCookieName() {
|
93 |
+
return 'clear_notification_bar_'.preg_replace("/\W/", '', Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_IDENTIFIER));
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Returns true if the currently identified notification bar has been cleared
|
98 |
+
* by the client, false otherwise
|
99 |
+
*
|
100 |
+
* @return boolean
|
101 |
+
*/
|
102 |
+
public function isNotificationCleared() {
|
103 |
+
return Mage::getSingleton('core/cookie')->get($this->getNotificationClearCookieName());
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Return true if the notification bar should be fixed in place at the top
|
108 |
+
*
|
109 |
+
* @return boolean
|
110 |
+
*/
|
111 |
+
public function isFixed() {
|
112 |
+
return Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_FIXED);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Returns true if the notification bar should be displayed based on the
|
117 |
+
* start_date.
|
118 |
+
*
|
119 |
+
* @return boolean true if either no start date is defined, or the current
|
120 |
+
* date is after the start date, false otherwise.
|
121 |
+
*/
|
122 |
+
protected function _afterStartDate() {
|
123 |
+
list($year,$month,$day) = explode(',',Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_START_DATE));
|
124 |
+
$str = null;
|
125 |
+
if($year) {
|
126 |
+
$str .= $year;
|
127 |
+
if($month) {
|
128 |
+
$str .= "-".$month;
|
129 |
+
if($day) $str .= "-".$day;
|
130 |
+
}
|
131 |
+
|
132 |
+
return time() >= strtotime($str); // current time is after the start date?
|
133 |
+
}
|
134 |
+
return true; // no start date set, so the notification bar is always on
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Returns true if the notification bar should be displayed based on the
|
139 |
+
* end_date.
|
140 |
+
*
|
141 |
+
* @return boolean true if either no end date is defined, or the current
|
142 |
+
* date is after the start date, false otherwise.
|
143 |
+
*/
|
144 |
+
protected function _beforeEndDate() {
|
145 |
+
list($year,$month,$day) = explode(',',Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_END_DATE));
|
146 |
+
$str = null;
|
147 |
+
if($year) {
|
148 |
+
$str .= $year;
|
149 |
+
if($month) {
|
150 |
+
$str .= "-".$month;
|
151 |
+
if($day) $str .= "-".$day;
|
152 |
+
}
|
153 |
+
|
154 |
+
return time() < strtotime($str); // current time is before end date?
|
155 |
+
}
|
156 |
+
return true; // no end date set, so the notification bar is always on
|
157 |
+
}
|
158 |
+
}
|
app/code/community/FoxRunSoftware/NotificationBar/Block/Html/Styles.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Styles block
|
4 |
+
*
|
5 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
6 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
7 |
+
* @license FoxRunSoftware License Agreement
|
8 |
+
*
|
9 |
+
* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
10 |
+
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
11 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
12 |
+
* PARTICULAR PURPOSE.
|
13 |
+
*
|
14 |
+
* @category FoxRunSoftware
|
15 |
+
* @package FoxRunSoftware_NotificationBar
|
16 |
+
*/
|
17 |
+
class FoxRunSoftware_NotificationBar_Block_Html_Styles extends Mage_Core_Block_Template
|
18 |
+
{
|
19 |
+
const XML_PATH_NOTIFICATIONBAR_DEFAULT_STYLE = 'design/notificationbar/default_style';
|
20 |
+
const XML_PATH_NOTIFICATIONBAR_FIXED_MARGIN = 'design/notificationbar/fixed_margin';
|
21 |
+
const XML_NOTIFICATIONBAR_BLOCK_NAME = 'notificationbar_notifications';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Return true if the default styling should be used
|
25 |
+
*
|
26 |
+
* @return boolean
|
27 |
+
*/
|
28 |
+
public function useDefaultStyles()
|
29 |
+
{
|
30 |
+
return Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_DEFAULT_STYLE);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Return true if the notification bar should be fixed in place at the top
|
35 |
+
*
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
public function isFixed() {
|
39 |
+
return $this->_getNotificationBlock()->isFixed();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Returns the top margin value to apply to the body element when the
|
44 |
+
* notification bar is fixed in place
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getFixedMargin() {
|
49 |
+
return Mage::getStoreConfig(self::XML_PATH_NOTIFICATIONBAR_FIXED_MARGIN);
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Check if the notifications bar should be displayed
|
54 |
+
*
|
55 |
+
* @return boolean
|
56 |
+
*/
|
57 |
+
public function displayNotifications()
|
58 |
+
{
|
59 |
+
return $this->_getNotificationBlock()->displayNotifications();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Return the notification bar block object, which is used to query the
|
64 |
+
* state of the notification bar configurations
|
65 |
+
*
|
66 |
+
* @return FoxRunSoftware_NotificationBar_Block_Html_Notifications
|
67 |
+
*/
|
68 |
+
protected function _getNotificationBlock() {
|
69 |
+
return $this->getLayout()->getBlock(self::XML_NOTIFICATIONBAR_BLOCK_NAME);
|
70 |
+
}
|
71 |
+
}
|
app/code/community/FoxRunSoftware/NotificationBar/etc/config.xml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
5 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
6 |
+
* @license FoxRunSoftware License Agreement
|
7 |
+
*
|
8 |
+
* @package FoxRunSoftware_NotificationBar
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<FoxRunSoftware_NotificationBar>
|
14 |
+
<version>1.0.0</version>
|
15 |
+
</FoxRunSoftware_NotificationBar>
|
16 |
+
</modules>
|
17 |
+
|
18 |
+
<global>
|
19 |
+
<blocks>
|
20 |
+
<notificationbar>
|
21 |
+
<class>FoxRunSoftware_NotificationBar_Block</class>
|
22 |
+
</notificationbar>
|
23 |
+
</blocks>
|
24 |
+
</global>
|
25 |
+
<frontend>
|
26 |
+
<layout>
|
27 |
+
<updates>
|
28 |
+
<notificationbar>
|
29 |
+
<file>notificationbar.xml</file>
|
30 |
+
</notificationbar>
|
31 |
+
</updates>
|
32 |
+
</layout>
|
33 |
+
</frontend>
|
34 |
+
|
35 |
+
<default>
|
36 |
+
<design>
|
37 |
+
<notificationbar>
|
38 |
+
<display>0</display>
|
39 |
+
<clearcontrol>0</clearcontrol>
|
40 |
+
<default_style>1</default_style>
|
41 |
+
<fixed>0</fixed>
|
42 |
+
<fixed_margin>28px</fixed_margin>
|
43 |
+
</notificationbar>
|
44 |
+
</design>
|
45 |
+
</default>
|
46 |
+
</config>
|
app/code/community/FoxRunSoftware/NotificationBar/etc/system.xml
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
5 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
6 |
+
* @license FoxRunSoftware License Agreement
|
7 |
+
*
|
8 |
+
* @package FoxRunSoftware_NotificationBar
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<sections>
|
13 |
+
<design>
|
14 |
+
<groups>
|
15 |
+
<notificationbar translate="label">
|
16 |
+
<label>Notification Bar</label>
|
17 |
+
<frontend_type>text</frontend_type>
|
18 |
+
<sort_order>20</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
<fields>
|
23 |
+
<display translate="label">
|
24 |
+
<label>Notification Enabled</label>
|
25 |
+
<frontend_type>select</frontend_type>
|
26 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
27 |
+
<sort_order>10</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
</display>
|
32 |
+
<default_style translate="label comment">
|
33 |
+
<label>Include Default Styling</label>
|
34 |
+
<comment>Disabling this allows you to more easily style the notification bar to match your theme</comment>
|
35 |
+
<frontend_type>select</frontend_type>
|
36 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
37 |
+
<sort_order>20</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>1</show_in_website>
|
40 |
+
<show_in_store>1</show_in_store>
|
41 |
+
</default_style>
|
42 |
+
<content translate="label comment">
|
43 |
+
<label>Notification Content</label>
|
44 |
+
<comment>HTML is allowed</comment>
|
45 |
+
<frontend_type>textarea</frontend_type>
|
46 |
+
<sort_order>30</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>1</show_in_store>
|
50 |
+
</content>
|
51 |
+
<clearcontrol translate="label comment">
|
52 |
+
<label>Allow Notification to be Closed</label>
|
53 |
+
<comment>Enabling this will allow the user to close the notification bar</comment>
|
54 |
+
<frontend_type>select</frontend_type>
|
55 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
56 |
+
<sort_order>40</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
</clearcontrol>
|
61 |
+
<identifier translate="label comment">
|
62 |
+
<label>Notification Bar Identifier</label>
|
63 |
+
<comment>Optional; internally identifies the current notification bar. Setting this to a new value will cause the notification bar to display to all users, even those who cleared a previously identified bar.</comment>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>50</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
</identifier>
|
70 |
+
<start_date translate="label comment">
|
71 |
+
<label>Start Date</label>
|
72 |
+
<comment>Optional date to start displaying the notification bar</comment>
|
73 |
+
<frontend_type>select</frontend_type>
|
74 |
+
<frontend_model>notificationbar/adminhtml_config_form_field_datepicker</frontend_model>
|
75 |
+
<sort_order>60</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
</start_date>
|
80 |
+
<end_date translate="label comment">
|
81 |
+
<label>End Date</label>
|
82 |
+
<comment>Optional date to stop displaying the notification bar</comment>
|
83 |
+
<frontend_type>select</frontend_type>
|
84 |
+
<frontend_model>notificationbar/adminhtml_config_form_field_datepicker</frontend_model>
|
85 |
+
<sort_order>70</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
</end_date>
|
90 |
+
<fixed translate="label comment">
|
91 |
+
<label>Fixed Notification Bar</label>
|
92 |
+
<comment>Enabling this will fix the notification bar to the top of the browser, even when scrolling.</comment>
|
93 |
+
<frontend_type>select</frontend_type>
|
94 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
95 |
+
<sort_order>80</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>1</show_in_store>
|
99 |
+
</fixed>
|
100 |
+
<fixed_margin translate="label comment">
|
101 |
+
<label>Fixed Body Margin</label>
|
102 |
+
<comment>Used only when Fixed Notification Bar is enabled; this must be the height of the notification bar, in CSS units</comment>
|
103 |
+
<frontend_type>text</frontend_type>
|
104 |
+
<sort_order>90</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
</fixed_margin>
|
109 |
+
</fields>
|
110 |
+
</notificationbar>
|
111 |
+
</groups>
|
112 |
+
</design>
|
113 |
+
</sections>
|
114 |
+
</config>
|
app/design/frontend/base/default/layout/notificationbar.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
5 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
6 |
+
* @license FoxRunSoftware License Agreement
|
7 |
+
*
|
8 |
+
* @package FoxRunSoftware_NotificationBar
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<layout version="0.1.0">
|
12 |
+
<default>
|
13 |
+
<reference name="head">
|
14 |
+
<block type="notificationbar/html_styles" name="notification_bar_style" as="notification_bar_style" template="notificationbar/html/styles.phtml" />
|
15 |
+
</reference>
|
16 |
+
<reference name="after_body_start">
|
17 |
+
<block type="notificationbar/html_notifications" name="notificationbar_notifications" template="notificationbar/html/notifications.phtml" />
|
18 |
+
</reference>
|
19 |
+
</default>
|
20 |
+
</layout>
|
app/design/frontend/base/default/template/notificationbar/html/notifications.phtml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Datepicker adminhtml configuration control based on the
|
4 |
+
* Mage_Adminhtml_Block_Report_Config_Form_Field_YtdStart control.
|
5 |
+
*
|
6 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
7 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
8 |
+
* @license FoxRunSoftware License Agreement
|
9 |
+
*
|
10 |
+
* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
11 |
+
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
12 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
13 |
+
* PARTICULAR PURPOSE.
|
14 |
+
*
|
15 |
+
* @category design
|
16 |
+
* @package base_default
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php
|
20 |
+
/**
|
21 |
+
* @see FoxRunSoftware_NotificationBar_Block_Html_Notifications
|
22 |
+
*/
|
23 |
+
?>
|
24 |
+
<?php if ($this->displayNotifications()): ?>
|
25 |
+
<div id="notification-bar"><div id="notification"><span class="notification-content"><?php echo $this->getNotificationContent(); ?></span><?php if($this->allowClearControl()) : ?><span class="notification-close"><a title="dismiss this notification">×</a></span><?php endif; ?></div></div>
|
26 |
+
<?php if($this->allowClearControl()) : ?>
|
27 |
+
<script type="text/javascript">
|
28 |
+
$$('#notification-bar .notification-close').first().observe('click',function(event) { var callback = <?php echo ($this->isFixed() ? "function() { \$\$('body').first().setStyle({marginTop:0}); }" : "function(){}") ?>; event.element().up('#notification-bar').fade({duration:0.5, afterFinish:callback}); Mage.Cookies.set("<?php echo $this->getNotificationClearCookieName() ?>","1",new Date((new Date()).getTime() + 365*24*60*60*1000),"/"); });
|
29 |
+
</script>
|
30 |
+
<?php endif; ?>
|
31 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/notificationbar/html/styles.phtml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Notification bar styling
|
4 |
+
*
|
5 |
+
* @author Justin Stern (www.foxrunsoftware.net)
|
6 |
+
* @copyright Copyright (c) 2012 All Rights Reserved, http://www.foxrunsoftware.net
|
7 |
+
* @license FoxRunSoftware License Agreement
|
8 |
+
*
|
9 |
+
* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
10 |
+
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
11 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
12 |
+
* PARTICULAR PURPOSE.
|
13 |
+
*
|
14 |
+
* @category design
|
15 |
+
* @package base_default
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
<?php
|
19 |
+
/**
|
20 |
+
* @see FoxRunSoftware_NotificationBar_Block_Html_Styles
|
21 |
+
*/
|
22 |
+
?>
|
23 |
+
<?php if($this->displayNotifications()) : ?>
|
24 |
+
<?php if($this->useDefaultStyles() || $this->isFixed()) : ?>
|
25 |
+
<style type="text/css">
|
26 |
+
<?php endif; ?>
|
27 |
+
<?php if($this->useDefaultStyles()) : ?>
|
28 |
+
#notification-bar { text-align:center;background-color:#D75F07;color:white;line-height:normal;padding:7px 0; }
|
29 |
+
#notification-bar span.notification-close { background-color: #FAD163;border: 2px solid #735005;cursor: pointer;display: block;float: right;margin-right: 10px;padding-left: 4px;padding-right: 4px;text-decoration: none; }
|
30 |
+
#notification-bar .notification-close a { text-decoration: none; color: #735005; }
|
31 |
+
#notification-bar .notification-close a:hover { text-decoration: none; }
|
32 |
+
<?php endif; ?>
|
33 |
+
<?php if($this->isFixed()) : ?>
|
34 |
+
#notification-bar { position: fixed;top: 0;width: 100%;z-index: 100;border-bottom: 1px solid black; }
|
35 |
+
body { margin-top: <?php echo $this->getFixedMargin() ?>; }
|
36 |
+
<?php endif; ?>
|
37 |
+
<?php if($this->useDefaultStyles() || $this->isFixed()) : ?>
|
38 |
+
</style>
|
39 |
+
<?php endif; ?>
|
40 |
+
<?php endif; ?>
|
app/etc/modules/FoxRunSoftware_NotificationBar.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<FoxRunSoftware_NotificationBar>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</FoxRunSoftware_NotificationBar>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>FoxRunSoftware_NotificationBar</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.foxrunsoftware.net/about-us/magento-extension-license/">License For One Magento Installation</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Easily add and customize a notification bar across the top of your site.</summary>
|
10 |
+
<description><h2>Overview</h2>
|
11 |
+
<p>This extension allows you to create and manage a notification bar for displaying important announcements and notices to your customers and site visitors.</p>
|
12 |
+

|
13 |
+
<h2>Features</h2>
|
14 |
+
<ul>
|
15 |
+
<li>Configure from System > Configuration > Design > Notification Bar</li>
|
16 |
+
<li>Style notification bar to match your theme</li>
|
17 |
+
<li>Enter notification bar content from Magento admin where plain text, HTML and template tags are allowed</li>
|
18 |
+
<li>Optionally allow users to close and dismiss the notification bar</li>
|
19 |
+
<li>Optionally name the current notification bar so that when you have a new message to announce, it will be displayed for all users of your site, even those who closed a previous notification</li>
|
20 |
+
<li>Optionally set a notification start date, to set your message to automatically display on a specified date</li>
|
21 |
+
<li>Optionally set a notification end date, to hide your message automatically on a specified date</li>
|
22 |
+
<li>Optionally fix the notification bar to the top of the browser so that it scrolls with the page, always on top.</li>
|
23 |
+
</ul>
|
24 |
+

|
25 |
+
<h2>Notes</h2>
|
26 |
+
<p>'Close Notification Bar' functionality requires prototype/scriptaculous javascript libraries, which are part of Magento by default.</p>
|
27 |
+

|
28 |
+
<h2>Support</h2>
|
29 |
+
<p>If you run into any issues using this extension, or have a feature request or bug to report, please <a href=”http://www.foxrunsoftware.net/contact-us/”>contact us</a></p></description>
|
30 |
+
<notes>Initial release. Easily add a custom notification bar to the top of your site.</notes>
|
31 |
+
<authors><author><name>Justin Stern</name><user>foxrunsoftware</user><email>justin@foxrunsoftware.net</email></author></authors>
|
32 |
+
<date>2012-03-19</date>
|
33 |
+
<time>20:14:14</time>
|
34 |
+
<contents><target name="mageetc"><dir name="modules"><file name="FoxRunSoftware_NotificationBar.xml" hash="0bba3eba8d687c10ca6ca78da69bb06b"/></dir></target><target name="magecommunity"><dir name="FoxRunSoftware"><dir name="NotificationBar"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Datepicker.php" hash="145dba82d3873863f6109bcedb18c4b0"/></dir></dir></dir></dir><dir name="Html"><file name="Notifications.php" hash="b7f22fc381ad6ddd59ac6234afdc5711"/><file name="Styles.php" hash="9a1ec3ad33368bb1e4bcadf8af178e7e"/></dir></dir><dir name="etc"><file name="config.xml" hash="b95fcb0a38e18826200e3af8f936b60d"/><file name="system.xml" hash="f04088fbd3f7a8f28fe46f132fd7f480"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="notificationbar.xml" hash="45f27fdff6a5be42e436d7200bed3c65"/></dir><dir name="template"><dir name="notificationbar"><dir name="html"><file name="notifications.phtml" hash="ecd00581ee488babcb7e847e7f9000c2"/><file name="styles.phtml" hash="5615d7e938a597b3af997fd374eeec52"/></dir></dir></dir></dir></dir></dir></target></contents>
|
35 |
+
<compatible/>
|
36 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
37 |
+
</package>
|