forkel_counter - Version 1.1.0

Version Notes

===== 1.1.0 =====
* Removed jQuery because I have replaced the counter plugin ( https://github.com/bfintal/Counter-Up ) with ( https://inorganik.github.io/countUp.js ) that allows you to count up and down without a JavaScript framework.
* Removed ( http://imakewebthings.com/waypoints ). Please add it to your theme manually.
* Added new parameter decimals and duration.
* Added default counter options in System > Forkel Counter > General
* Added new parameter options that allows you to set different ( https://inorganik.github.io/countUp.js ) settings for each counter.

Download this release

Release Info

Developer Tobias Forkel
Extension forkel_counter
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/community/Forkel/Counter/Block/Base.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Forkel Counter
4
+ *
5
+ * @category Forkel
6
+ * @package Forkel_Counter
7
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ class Forkel_Counter_Block_Base extends Mage_Core_Block_Template
12
+ {
13
+ /**
14
+ * Array with filter options
15
+ * @var array
16
+ */
17
+ protected $_filter = [];
18
+
19
+ /**
20
+ * Get the numeric for the counter
21
+ * or explode the string with all options, like "collection:catalog/product;from:-14days;to:yesterday".
22
+ *
23
+ * @param string $key Access key from array
24
+ * @return mixed
25
+ */
26
+ protected function getFilter($key)
27
+ {
28
+ $to = trim($this->getData('to'));
29
+
30
+ if (strpos($to, ':'))
31
+ {
32
+ $to = explode(',', $to);
33
+
34
+ foreach ($to as $value)
35
+ {
36
+ $filter = explode(':', $value);
37
+ $this->_filter[$filter[0]] = trim($filter[1]);
38
+ }
39
+ }
40
+
41
+ return (array_key_exists($key, $this->_filter) ? $this->_filter[$key] : false);
42
+ }
43
+
44
+ /**
45
+ * Return the name of a collection.
46
+ *
47
+ * @return mixed
48
+ */
49
+ public function getCollectionName()
50
+ {
51
+ $name = $this->getFilter('collection');
52
+
53
+ $collection = array('sales/order', 'catalog/product', 'customer/customer', 'customer/session');
54
+
55
+ return (in_array($name, $collection) ? $name : false);
56
+ }
57
+
58
+ /**
59
+ * Return an condition array, depending on the collection.
60
+ *
61
+ * @return mixed
62
+ */
63
+ public function getFieldToFilter()
64
+ {
65
+ $name = $this->getFilter('collection');
66
+
67
+ $settings = [
68
+ 'sales/order' => [
69
+ 'field' => 'created_at',
70
+ ],
71
+ 'catalog/product' => [
72
+ 'field' => 'created_at',
73
+ ],
74
+ 'customer/customer' => [
75
+ 'field' => 'created_at',
76
+ ],
77
+ 'customer/session' => [
78
+ 'field' => 'login_at',
79
+ ]
80
+ ];
81
+
82
+ $from = ($this->getFilter('from') ? $this->getFilter('from') : Forkel_Counter_Helper_Data::COLLECTION_FILTER_DATETIME_FROM);
83
+ $to = ($this->getFilter('to') ? $this->getFilter('to') : Forkel_Counter_Helper_Data::COLLECTION_FILTER_DATETIME_TO);
84
+
85
+ $condition = ['from' => date('Y-m-d H:i:s', strtotime($from)), 'to' => date('Y-m-d H:i:s', strtotime($to))];
86
+
87
+ $settings[$name]['condition'] = $condition;
88
+
89
+ return (array_key_exists($name, $settings) ? $settings[$name] : false);
90
+ }
91
+ }
app/code/community/Forkel/Counter/Block/Frontend/Counter.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Forkel Counter
4
+ *
5
+ * @category Forkel
6
+ * @package Forkel_Counter
7
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ class Forkel_Counter_Block_Frontend_Counter extends Forkel_Counter_Block_Base
12
+ {
13
+ protected function _construct()
14
+ {
15
+ $this->setTemplate(Forkel_Counter_Helper_Data::TEMPLATE_BLOCK_COUNTER);
16
+ }
17
+
18
+ /**
19
+ * Merge array and override values with the same keys
20
+ *
21
+ * @param array Array with original values
22
+ * @param array Array with values
23
+ *
24
+ * @return array Numeric
25
+ */
26
+ public function mergeArray($array, $merge)
27
+ {
28
+
29
+ // Return original array if there is nothing to merge
30
+ if (!is_array($merge))
31
+ {
32
+
33
+ return $array;
34
+ }
35
+
36
+ // Override values of the original array
37
+ foreach($merge as $key => $value)
38
+ {
39
+ $array[$key] = $value;
40
+ }
41
+
42
+ return $array;
43
+ }
44
+
45
+ /**
46
+ * Return the number from where the counter should start.
47
+ *
48
+ * @return number Numeric
49
+ */
50
+ public function getTo()
51
+ {
52
+ if ($name = $this->getCollectionName())
53
+ {
54
+ $collection = Mage::getModel($name)->getCollection();
55
+
56
+ $filter = $this->getFieldToFilter();
57
+ $collection->addFieldToFilter($filter['field'], $filter['condition']);
58
+
59
+ return $collection->getSize();
60
+ }
61
+
62
+ return str_replace(array(',', '.'), array('',''), $this->getData('to'));
63
+ }
64
+
65
+ /**
66
+ * Define the number where the counter should starting from.
67
+ *
68
+ * @return number Return a number or 0
69
+ */
70
+ public function getFrom()
71
+ {
72
+ return ($this->getData('from')) ? $this->getData('from') : 0;
73
+ }
74
+
75
+ /**
76
+ * Display icon before the counter. Using Fonts Awesome.
77
+ *
78
+ * @return mixed String|Boolean
79
+ */
80
+ public function getIcon()
81
+ {
82
+
83
+ return ($this->getData('icon')) ? $this->getData('icon') : false;
84
+ }
85
+
86
+ /**
87
+ * Display any kind of prefix in text format.
88
+ *
89
+ * @return mixed String|Boolean
90
+ */
91
+ public function getPrefix()
92
+ {
93
+
94
+ return ($this->getData('prefix')) ? $this->getData('prefix') : false;
95
+ }
96
+
97
+ /**
98
+ * Display any kind of suffix in text format.
99
+ *
100
+ * @return mixed String|Boolean
101
+ */
102
+ public function getSuffix()
103
+ {
104
+
105
+ return ($this->getData('suffix')) ? $this->getData('suffix') : false;
106
+ }
107
+
108
+ /**
109
+ * Get how many decimals should display after counter
110
+ *
111
+ * @return string
112
+ */
113
+ public function getDecimals()
114
+ {
115
+
116
+ return ($this->getData('decimals')) ? $this->getData('decimals') : 0;
117
+ }
118
+
119
+ /**
120
+ * Get how long the counter should run
121
+ *
122
+ * @return string
123
+ */
124
+ public function getDuration()
125
+ {
126
+
127
+ return ($this->getData('duration')) ? $this->getData('duration') : 0;
128
+ }
129
+
130
+ /**
131
+ * Return options for countUp plugin
132
+ *
133
+ * @return string
134
+ */
135
+ public function getOptions()
136
+ {
137
+ $defaults = Mage::getStoreConfig('forkel_counter/general/options');
138
+
139
+ return json_encode($this->mergeArray(json_decode($defaults, true), json_decode($this->getData('options'), true)));
140
+ }
141
+
142
+ }
app/code/community/Forkel/Counter/Helper/Data.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Maintenance Counter
4
+ *
5
+ * @category Forkel
6
+ * @package Forkel_Counter
7
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ class Forkel_Counter_Helper_Data extends Mage_Core_Helper_Abstract
12
+ {
13
+ const MODULE_NAME = 'forkel_counter';
14
+ const TEMPLATE_BLOCK_COUNTER = 'forkel/counter/counter.phtml';
15
+ const COLLECTION_FILTER_DATETIME_FROM = '01/01/1970';
16
+ const COLLECTION_FILTER_DATETIME_TO = 'now';
17
+ }
app/code/community/Forkel/Counter/Model/Observer.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Maintenance Counter
4
+ *
5
+ * @category Forkel
6
+ * @package Forkel_Counter
7
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ class Forkel_Counter_Model_Observer {
12
+
13
+ public function layoutLoadBefore(Varien_Event_Observer $observer)
14
+ {
15
+ $layout = $observer->getEvent()->getLayout();
16
+
17
+ $layout->getUpdate()->addHandle('forkel_counter_js');
18
+ $layout->getUpdate()->addHandle('forkel_counter_css');
19
+ $layout->getUpdate()->addHandle('forkel_counter');
20
+ }
21
+ }
app/code/community/Forkel/Counter/etc/adminhtml.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Forkel Counter
5
+ *
6
+ * @category Forkel
7
+ * @package Forkel_Counter
8
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+
13
+ <config>
14
+ <acl>
15
+ <resources>
16
+ <admin>
17
+ <children>
18
+
19
+ <system>
20
+ <children>
21
+ <config>
22
+ <children>
23
+ <forkel_counter>
24
+ <title>Forkel Counter</title>
25
+ </forkel_counter>
26
+ </children>
27
+ </config>
28
+ </children>
29
+ </system>
30
+
31
+ </children>
32
+ </admin>
33
+ </resources>
34
+ </acl>
35
+ </config>
app/code/community/Forkel/Counter/etc/config.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Forkel Counter
5
+ *
6
+ * @category Forkel
7
+ * @package Forkel_Counter
8
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+
13
+ <config>
14
+ <modules>
15
+ <Forkel_Counter>
16
+ <version>1.1.0</version>
17
+ </Forkel_Counter>
18
+ </modules>
19
+ <global>
20
+ <blocks>
21
+ <forkel_counter>
22
+ <class>Forkel_Counter_Block</class>
23
+ </forkel_counter>
24
+ </blocks>
25
+ <helpers>
26
+ <forkel_counter>
27
+ <class>Forkel_Counter_Helper</class>
28
+ </forkel_counter>
29
+ </helpers>
30
+ </global>
31
+ <frontend>
32
+ <events>
33
+ <controller_action_layout_load_before>
34
+ <observers>
35
+ <forkel_counter_layout_load_before>
36
+ <class>Forkel_Counter_Model_Observer</class>
37
+ <method>layoutLoadBefore</method>
38
+ </forkel_counter_layout_load_before>
39
+ </observers>
40
+ </controller_action_layout_load_before>
41
+ </events>
42
+ <layout>
43
+ <updates>
44
+ <forkel_counter>
45
+ <file>forkel/counter.xml</file>
46
+ </forkel_counter>
47
+ </updates>
48
+ </layout>
49
+ </frontend>
50
+ <default>
51
+ <forkel_counter>
52
+ <general>
53
+ <options>{ "separator" : ",", "decimal" : ".", "useEasing" : true, "useGrouping" : true }</options>
54
+ </general>
55
+ <css>
56
+ <default>1</default>
57
+ <font_awesome>1</font_awesome>
58
+ </css>
59
+ <js>
60
+ <default>1</default>
61
+ </js>
62
+ </forkel_counter>
63
+ </default>
64
+ </config>
app/code/community/Forkel/Counter/etc/system.xml ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Forkel Counter
5
+ *
6
+ * @category Forkel
7
+ * @package Forkel_Counter
8
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+
13
+ <config>
14
+ <tabs>
15
+ <forkel_counter translate="label" module="forkel_counter">
16
+ <label>Forkel Counter</label>
17
+ <sort_order>9000</sort_order>
18
+ </forkel_counter>
19
+ </tabs>
20
+ <sections>
21
+ <forkel_counter translate="label" module="forkel_counter">
22
+ <label>Forkel Counter</label>
23
+ <tab>general</tab>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>100</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <groups>
30
+
31
+ <general translate="label">
32
+ <label>General</label>
33
+ <frontend_type>select</frontend_type>
34
+ <sort_order>50</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <fields>
39
+
40
+ <options translate="label">
41
+ <label>Options</label>
42
+ <frontend_type>text</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>10</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <comment><![CDATA[
49
+ <p>
50
+ <div>Set default options for the <a href="https://inorganik.github.io/countUp.js/" target="_blank">countUp</a> plugin.</div>
51
+ </p>
52
+ ]]></comment>
53
+ </options>
54
+
55
+ </fields>
56
+ </general>
57
+
58
+ <css translate="label">
59
+ <label>CSS</label>
60
+ <frontend_type>select</frontend_type>
61
+ <sort_order>100</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ <fields>
66
+
67
+ <default translate="label">
68
+ <label>Default</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ <sort_order>10</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment><![CDATA[
76
+ <p>
77
+ <div>Load CSS <i>css/forkel/counter/counter.min.css</i> in front-end.</div>
78
+ </p>
79
+ ]]></comment>
80
+ </default>
81
+
82
+ <font_awesome translate="label">
83
+ <label>Font Awesome</label>
84
+ <frontend_type>select</frontend_type>
85
+ <source_model>adminhtml/system_config_source_yesno</source_model>
86
+ <sort_order>20</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <comment><![CDATA[
91
+ <p>
92
+ <div>Load <a href="https://fortawesome.github.io/Font-Awesome/" target="_blank">Font Awesome</a> from CDN in front-end. Disable if it's already loaded in your theme.</div>
93
+ </p>
94
+ ]]></comment>
95
+ </font_awesome>
96
+
97
+ </fields>
98
+ </css>
99
+
100
+ <js translate="label">
101
+ <label>JavaScript</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>200</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ <fields>
108
+
109
+ <default translate="label">
110
+ <label>Default</label>
111
+ <frontend_type>select</frontend_type>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <sort_order>10</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ <comment><![CDATA[
118
+ <p>
119
+ <div>Load JavaScript <i>js/community/forkel/counter/init.min.js</i> and <i>js/community/forkel/counter/countUp.min.js</i> in front-end.</div>
120
+ </p>
121
+ ]]></comment>
122
+ </default>
123
+
124
+ </fields>
125
+ </js>
126
+ </groups>
127
+ </forkel_counter>
128
+ </sections>
129
+ </config>
app/design/frontend/base/default/layout/forkel/counter.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Forkel Counter
5
+ *
6
+ * @category Forkel
7
+ * @package Forkel_Counter
8
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+
13
+ <layout>
14
+
15
+ <forkel_counter_css>
16
+ <reference name="head">
17
+ <action method="addCss" ifconfig="forkel_counter/css/default">
18
+ <stylesheet>css/forkel/counter/counter.min.css</stylesheet>
19
+ </action>
20
+ <action method="addLinkRel" ifconfig="forkel_counter/css/font_awesome">
21
+ <rel>stylesheet</rel>
22
+ <href>https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css</href>
23
+ </action>
24
+ </reference>
25
+ </forkel_counter_css>
26
+
27
+ <forkel_counter_js>
28
+ <reference name="head" ifconfig="forkel_counter/css/font_awesome">
29
+ <action method="addJs"><script>community/forkel/counter/countUp.min.js</script></action>
30
+ </reference>
31
+ <reference name="head" ifconfig="forkel_counter/css/font_awesome">
32
+ <action method="addJs"><script>community/forkel/counter/init.min.js</script></action>
33
+ </reference>
34
+ </forkel_counter_js>
35
+
36
+ <forkel_counter>
37
+ <reference name="right">
38
+ <block type="forkel_counter/frontend_counter" name="forkel_counter_frontend_counter" after="catalog.compare.sidebar">
39
+ <action method="setData">
40
+ <name>className</name><value>forkel_class</value>
41
+ </action>
42
+ <action method="setData">
43
+ <name>icon</name><value>fa-umbrella</value>
44
+ </action>
45
+ <action method="setData">
46
+ <name>prefix</name><value>$</value>
47
+ </action>
48
+ <action method="setData">
49
+ <name>suffix</name><value>per month</value>
50
+ </action>
51
+ <action method="setData">
52
+ <name>from</name><value>0</value>
53
+ </action>
54
+ <action method="setData">
55
+ <name>to</name><value>1999</value>
56
+ </action>
57
+ <action method="setData">
58
+ <name>decimals</name><value>0</value>
59
+ </action>
60
+ <action method="setData">
61
+ <name>duration</name><value>5</value>
62
+ </action>
63
+ <action method="setData">
64
+ <name>options</name><value>{ "separator" : ",", "decimal" : ".", "useEasing" : true, "useGrouping" : true }</value>
65
+ </action>
66
+ </block>
67
+ </reference>
68
+ </forkel_counter>
69
+
70
+ </layout>
app/design/frontend/base/default/template/forkel/counter/counter.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Forkel Counter
4
+ *
5
+ * @category Forkel
6
+ * @package Forkel_Counter
7
+ * @copyright Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ ?>
11
+
12
+ <span class="forkel_counter <?php echo ($className = $this->getData('className')) ? $className : ''; ?>">
13
+
14
+ <?php if ($icon = $this->getIcon()): ?>
15
+ <span class="fa <?php echo $icon; ?>"></span>
16
+ <?php endif; ?>
17
+
18
+ <?php if ($prefix = $this->getPrefix()): ?>
19
+ <span class="prefix"><?php echo $prefix; ?></span>
20
+ <?php endif; ?>
21
+
22
+ <?php if ($to = $this->getTo()): ?>
23
+ <span class="counter" data-from="<?php echo $this->getFrom(); ?>" data-to="<?php echo $to; ?>" data-decimals="<?php echo $this->getDecimals(); ?>" data-duration="<?php echo $this->getDuration(); ?>" data-options='<?php echo $this->getOptions(); ?>'>0</span>
24
+ <?php endif; ?>
25
+
26
+ <?php if ($suffix = $this->getSuffix()): ?>
27
+ <span class="suffix"><?php echo $suffix; ?></span>
28
+ <?php endif; ?>
29
+
30
+ </span>
31
+
32
+ <span class="forkel_counter_alert">
33
+ <span class="alert warning">
34
+ <?php echo $this->__('Something is wrong here. Probably countUp.min.js is not loaded or has a conflict with another library.'); ?>
35
+ </span>
36
+ </span>
app/etc/modules/Forkel_Counter.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Forkel_Counter>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Forkel_Counter>
8
+ </modules>
9
+ </config>
js/community/forkel/counter/countUp.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* countUp.js - (c) 2014-2015 @inorganik - Licensed under the MIT license. */
2
+ var CountUp=function(t,a,n,e,i,r){for(var o=0,s=["webkit","moz","ms","o"],l=0;l<s.length&&!window.requestAnimationFrame;++l)window.requestAnimationFrame=window[s[l]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[s[l]+"CancelAnimationFrame"]||window[s[l]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t,a){var n=(new Date).getTime(),e=Math.max(0,16-(n-o)),i=window.setTimeout(function(){t(n+e)},e);return o=n+e,i}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),this.easeOutExpo=function(t,a,n,e){return n*(-Math.pow(2,-10*t/e)+1)*1024/1023+a},this.options={useEasing:!0,useGrouping:!0,separator:",",decimal:".",postFormatter:null,easingFn:null};for(var m in r)r.hasOwnProperty(m)&&(this.options[m]=r[m]);""===this.options.separator&&(this.options.useGrouping=!1),this.options.prefix||(this.options.prefix=""),this.options.suffix||(this.options.suffix=""),this.options.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.d="string"==typeof t?document.getElementById(t):t,this.startVal=Number(a),this.endVal=Number(n),this.countDown=this.startVal>this.endVal,this.frameVal=this.startVal,this.decimals=Math.max(0,e||0),this.dec=Math.pow(10,this.decimals),this.duration=1e3*Number(i)||2e3;var u=this;this.version=function(){return"1.6.1"},this.printValue=function(t){var a=isNaN(t)?"--":u.formatNumber(t);"INPUT"==u.d.tagName?this.d.value=a:"text"==u.d.tagName||"tspan"==u.d.tagName?this.d.textContent=a:this.d.innerHTML=a},this.count=function(t){u.startTime||(u.startTime=t),u.timestamp=t;var a=t-u.startTime;u.remaining=u.duration-a,u.options.useEasing?u.countDown?u.frameVal=u.startVal-u.options.easingFn.call(u,a,0,u.startVal-u.endVal,u.duration):u.frameVal=u.options.easingFn.call(u,a,u.startVal,u.endVal-u.startVal,u.duration):u.countDown?u.frameVal=u.startVal-(u.startVal-u.endVal)*(a/u.duration):u.frameVal=u.startVal+(u.endVal-u.startVal)*(a/u.duration),u.countDown?u.frameVal=u.frameVal<u.endVal?u.endVal:u.frameVal:u.frameVal=u.frameVal>u.endVal?u.endVal:u.frameVal,u.frameVal=Math.floor(u.frameVal*u.dec)/u.dec,u.printValue(u.frameVal),a<u.duration?u.rAF=requestAnimationFrame(u.count):u.callback&&u.callback()},this.start=function(t){return u.callback=t,u.rAF=requestAnimationFrame(u.count),!1},this.pauseResume=function(){u.paused?(u.paused=!1,delete u.startTime,u.duration=u.remaining,u.startVal=u.frameVal,requestAnimationFrame(u.count)):(u.paused=!0,cancelAnimationFrame(u.rAF))},this.reset=function(){u.paused=!1,delete u.startTime,u.startVal=a,cancelAnimationFrame(u.rAF),u.printValue(u.startVal)},this.update=function(t){cancelAnimationFrame(u.rAF),u.paused=!1,delete u.startTime,u.startVal=u.frameVal,u.endVal=Number(t),u.countDown=u.startVal>u.endVal,u.rAF=requestAnimationFrame(u.count)},this.formatNumber=function(t){t=t.toFixed(u.decimals),t+="";var a,n,e,i;if(a=t.split("."),n=a[0],e=a.length>1?u.options.decimal+a[1]:"",i=/(\d+)(\d{3})/,u.options.useGrouping)for(;i.test(n);)n=n.replace(i,"$1"+u.options.separator+"$2");var r=u.options.prefix+n+e+u.options.suffix;return null!=u.options.postFormatter&&(r=u.options.postFormatter(r)),r},u.printValue(u.startVal)};
js/community/forkel/counter/init.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* init.min.js - Copyright (c) 2016 Tobias Forkel (http://www.tobiasforkel.de) - http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */
2
+ document.observe("dom:loaded",function(){function t(t){[].forEach.call(document.querySelectorAll(t),function(t){t.style.display="block"})}if("undefined"==typeof CountUp)return void t(".forkel_counter_alert .alert");for(var e=document.querySelectorAll(".counter"),o=0;o<e.length;o++){var r=e[o],a=r.getAttribute("data-from"),n=r.getAttribute("data-to"),u=r.getAttribute("data-decimals"),d=r.getAttribute("data-duration"),l=JSON.parse(r.getAttribute("data-options"));c=new CountUp(r,a,n,u,d,l),c.start()}});
package.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>forkel_counter</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://opensource.org/licenses/OSL-3.0">Open Software License v. 3.0 (OSL-3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>A customizable counter that allows you to count up or down from any number.</summary>
10
+ <description>&lt;p&gt;Add a customizable counter that allows you to count up or down from any number. With a specific option like &lt;i&gt;collection:catalog/product,from:-30 days,to:now&lt;/i&gt; you can get the size of a predefined collection. This module is using the class CountUp that works without a JavaScript framework.&lt;/p&gt;&#xD;
11
+ &#xD;
12
+ &lt;img src="http://www.tobiasforkel.de/public/magento/forkel_counter/version/1.1/screenshots/frontend/frontend_cms.gif" /&gt;&#xD;
13
+ &lt;br /&gt;&#xD;
14
+ &lt;br /&gt;&#xD;
15
+ &#xD;
16
+ &lt;p&gt;A JavaScript fallback will display a warning message in case of issues.&lt;/p&gt;&#xD;
17
+ &#xD;
18
+ &lt;img src="http://www.tobiasforkel.de/public/magento/forkel_counter/version/1.1/screenshots/frontend/frontend_fallback.jpg" /&gt;&#xD;
19
+ &lt;br /&gt;&#xD;
20
+ &lt;br /&gt;&#xD;
21
+ &#xD;
22
+ &lt;img src="http://www.tobiasforkel.de/public/magento/forkel_counter/version/1.1/screenshots/backend/backend_system.jpg" /&gt;&#xD;
23
+ &lt;br /&gt;&#xD;
24
+ &lt;br /&gt;&#xD;
25
+ &#xD;
26
+ &lt;h3&gt;Installation&lt;/h3&gt;&#xD;
27
+ - 1. Pull the code.&lt;br /&gt;&#xD;
28
+ - 2. Copy the code in your document root directory where the /app/ folder is located.&lt;br /&gt;&#xD;
29
+ - 3. Clear all caches and reload your Admin Panel to run the installation process.&lt;br /&gt;&#xD;
30
+ - 4. After installation you should see a new menu item &lt;i&gt;Forkel Counter&lt;/i&gt; inside of &lt;i&gt;System &amp;gt; Configuration &amp;gt; General&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&#xD;
31
+ &#xD;
32
+ &lt;h3&gt;Features&lt;/h3&gt;&#xD;
33
+ - Blocks are available for CMS pages and XML layout files.&lt;br /&gt;&#xD;
34
+ - Disable or enable JavaScript and CSS in &lt;i&gt;System &amp;gt; Configuration &amp;gt; General &amp;gt; Forkel Counter&lt;/i&gt; to prevent conflicts with your theme.&lt;br /&gt;&#xD;
35
+ - Display a Front Awesome icon.&lt;br /&gt;&#xD;
36
+ - Display a custom prefix like $ or &#x20AC;.&lt;br /&gt;&#xD;
37
+ - Display a custom suffix.&lt;br /&gt;&#xD;
38
+ - Set a number ( -99 or 99 ) from where the counter should start.&lt;br /&gt;&#xD;
39
+ - Set a number ( 290 or 10000 ) where the counter should stop.&lt;br /&gt;&#xD;
40
+ - Set the amount of decimals.&lt;br /&gt;&#xD;
41
+ - Set the counter duration in seconds.&lt;br /&gt;&#xD;
42
+ - Override default options such as &lt;i&gt;{ &amp;quot;separator&amp;quot; : &amp;quot;,&amp;quot;, &amp;quot;decimal&amp;quot; : &amp;quot;.&amp;quot;, &amp;quot;useEasing&amp;quot; : true, &amp;quot;useGrouping&amp;quot; : true }&lt;/i&gt;&lt;br /&gt;&#xD;
43
+ - Count rows from collections like sales/order or catalog/product in combination with a date filter.&lt;br /&gt;&lt;br /&gt;&#xD;
44
+ &#xD;
45
+ &lt;h3&gt;Usage and Examples&lt;/h3&gt;&#xD;
46
+ &lt;p&gt;Please visit the Forkel Counter project on &lt;a href="https://github.com/tobias-forkel/Forkel_Counter#usage"&gt;GitHub&lt;/a&gt; for further details and examples.&lt;/p&gt;&#xD;
47
+ &#xD;
48
+ &lt;h3&gt;Online Guides&lt;/h3&gt;&#xD;
49
+ &lt;p&gt;- In Progress&lt;/p&gt;&#xD;
50
+ &#xD;
51
+ &#xD;
52
+ &lt;h3&gt;Warranty&lt;/h3&gt;&#xD;
53
+ &lt;p&gt;This module is provided as-is, with no warranty.&lt;/p&gt;&#xD;
54
+ &#xD;
55
+ &lt;h3&gt;Updates&lt;/h3&gt;&#xD;
56
+ &lt;p&gt;All &lt;strong&gt;micro&lt;/strong&gt;, &lt;strong&gt;major&lt;/strong&gt; and &lt;strong&gt;minor&lt;/strong&gt; updates are available for free on &lt;a href="https://github.com/tobias-forkel/Forkel_Counter"&gt;GitHub&lt;/a&gt; and Magento Connect.&#xD;
57
+ &lt;/p&gt;&#xD;
58
+ &#xD;
59
+ &lt;h3&gt;Support&lt;/h3&gt;&#xD;
60
+ &lt;p&gt;This module is provided as-is, with no support. If you have technical problems, please open a new issue on &lt;a href="https://github.com/tobias-forkel/Forkel_Counter/issues"&gt;GitHub&lt;/a&gt; or contact me on Magento Connect or &lt;a href="http://www.tobiasforkel.de"&gt;http://www.tobiasforkel.de&lt;/a&gt;.&lt;/p&gt;</description>
61
+ <notes>===== 1.1.0 =====&#xD;
62
+ * Removed jQuery because I have replaced the counter plugin ( https://github.com/bfintal/Counter-Up ) with ( https://inorganik.github.io/countUp.js ) that allows you to count up and down without a JavaScript framework.&#xD;
63
+ * Removed ( http://imakewebthings.com/waypoints ). Please add it to your theme manually.&#xD;
64
+ * Added new parameter decimals and duration.&#xD;
65
+ * Added default counter options in System &gt; Forkel Counter &gt; General&#xD;
66
+ * Added new parameter options that allows you to set different ( https://inorganik.github.io/countUp.js ) settings for each counter.</notes>
67
+ <authors><author><name>Tobias Forkel</name><user>tforkel</user><email>magento@tobiasforkel.de</email></author></authors>
68
+ <date>2016-04-02</date>
69
+ <time>16:05:16</time>
70
+ <contents><target name="magecommunity"><dir name="Forkel"><dir name="Counter"><dir name="Block"><file name="Base.php" hash="0fb7db1a9d7a8cc6be259d1539950c0a"/><dir name="Frontend"><file name="Counter.php" hash="286507f4d5e6900c9b41e2e05b189b31"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="57e53875d049d0ea005ca12cf69eb0ac"/><file name="config.xml" hash="6415e6e34b01859c7da247b749c8de55"/><file name="system.xml" hash="45a6182a614112f9a1a4af2335e760e9"/></dir><dir name="Helper"><file name="Data.php" hash="469375d9492dcb6fce5d1160d4555ff6"/></dir><dir name="Model"><file name="Observer.php" hash="5796a0d31338261a8c705e35e2c23a92"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="forkel"><file name="counter.xml" hash="b24deaf69a80e9d151fc7dfb284500e1"/></dir></dir><dir name="template"><dir name="forkel"><dir name="counter"><file name="counter.phtml" hash="dd64c914216a511f9bc909743f7d31b2"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Forkel_Counter.xml" hash="36bc38d8ac906af039d0893a080e9dbc"/></dir></target><target name="mage"><dir name="js"><dir name="community"><dir name="forkel"><dir name="counter"><file name="init.min.js" hash="67cb56f84caff4e59c64ecfc27266346"/><file name="countUp.min.js" hash="d6c5a099ba0190b173d13b19a133a7f2"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="forkel"><dir name="counter"><file name="counter.min.css" hash="9754c3e411d6d5ebeca3115be10dd1c5"/></dir></dir></dir></dir></dir></dir></target></contents>
71
+ <compatible/>
72
+ <dependencies><required><php><min>5.4.0</min><max>5.6.16</max></php></required></dependencies>
73
+ </package>
skin/frontend/base/default/css/forkel/counter/counter.min.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ span.forkel_counter {
2
+ padding: 30px 0;
3
+ font-weight: bold;
4
+ font-size: 38px;
5
+ }
6
+
7
+ span.forkel_counter_alert .alert {
8
+ padding: 15px;
9
+ margin-bottom: 20px;
10
+ border: 1px solid transparent;
11
+ border-radius: 4px;
12
+ display: none;
13
+ }
14
+
15
+ span.forkel_counter_alert .warning {
16
+ color: #8a6d3b;
17
+ background-color: #fcf8e3;
18
+ border-color: #faebcc;
19
+ }