AW_FPS - Version 0.9

Version Notes

To use the extension place the following code:
----------------------------------------------------------------
{{block type="catalog/product/aw_fps" template="catalog/product/aw_fps.phtml"}}
----------------------------------------------------------------
on any page with the help of Magento CMS. After this done, go to Admin->Catalog->Manage Products->edit a product and set "Rotate in featured products slideshow" to "Yes". Navigate to the page in which you inserted the block above and enjoy the slideshow.

Download this release

Release Info

Developer Magento Core Team
Extension AW_FPS
Version 0.9
Comparing to
See all releases


Version 0.9

app/code/local/AW/FPS/Helper/Data.php ADDED
@@ -0,0 +1,58 @@
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@magentocommerce.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
16
+ * versions in the future. If you wish to customize Magento for your
17
+ * needs please refer to http://www.magentocommerce.com for more information.
18
+ *
19
+ * @category AW
20
+ * @package AW_FPS
21
+ * @copyright Copyright (c) 2008 aheadWorks Co. (http://www.aheadworks.com)
22
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
23
+ */
24
+
25
+ class AW_FPS_Helper_Data extends Mage_Core_Helper_Abstract
26
+ {
27
+ function getFeaturedProducts(){
28
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
29
+ $_productIds = $db->fetchCol("SELECT * FROM aw_fps");
30
+
31
+ $__productCollection = null;
32
+ $_productCollection = Mage::getModel('catalog/product')
33
+ ->getCollection()
34
+ ->addIdFilter($_productIds)
35
+ ->addUrlRewrite();
36
+ $_productCollection->load();
37
+
38
+ $_res = array();
39
+ foreach($_productCollection as $_product){
40
+ $_product = Mage::getModel('catalog/product')->load($_product->getData('entity_id'));
41
+ $_title = str_replace("'", "\'", $_product->getName());
42
+ $_url = $_product->getProductUrl();
43
+ $_image = $_product->getSmallImageUrl();
44
+ $_price = Mage::helper('core')->formatCurrency($_product->getPrice());
45
+
46
+ array_push($_res, array(
47
+ 'title' => $_title,
48
+ 'url' => $_url,
49
+ 'image' => $_image,
50
+ 'price' => $_price
51
+ ));
52
+ }
53
+
54
+ return $_res;
55
+ }
56
+ }
57
+
58
+
app/code/local/AW/FPS/Model/Entity/Attribute/Backend/Boolean/Config.php ADDED
@@ -0,0 +1,65 @@
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@magentocommerce.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
16
+ * versions in the future. If you wish to customize Magento for your
17
+ * needs please refer to http://www.magentocommerce.com for more information.
18
+ *
19
+ * @category AW
20
+ * @package AW_FPS
21
+ * @copyright Copyright (c) 2008 aheadWorks Co. (http://www.aheadworks.com)
22
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
23
+ */
24
+
25
+ class AW_FPS_Model_Entity_Attribute_Backend_Boolean_Config extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
26
+ {
27
+ /**
28
+ * Set attribute default value if value empty
29
+ *
30
+ * @param Varien_Object $object
31
+ */
32
+ public function afterLoad($object)
33
+ {
34
+ if(!$object->hasData($this->getAttribute()->getAttributeCode())) {
35
+ $object->setData($this->getAttribute()->getAttributeCode(), $this->getDefaultValue());
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Set attribute default value if value empty
41
+ *
42
+ * @param Varien_Object $object
43
+ */
44
+ public function beforeSave($object)
45
+ {
46
+
47
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
48
+ $product_id = $object->getData('entity_id');
49
+
50
+ $code = $object->getData($this->getAttribute()->getAttributeCode());
51
+ if($code == 0) {
52
+ $object->unsData($this->getAttribute()->getAttributeCode());
53
+ //remove product ID
54
+ $write->query("DELETE FROM aw_fps WHERE product_id=$product_id");
55
+ }
56
+ else{
57
+ //add project ID to the rotation
58
+ $r = $write->fetchRow("SELECT * FROM aw_fps WHERE product_id=$product_id");
59
+ if(!$r)
60
+ $write->query("INSERT INTO aw_fps (product_id) VALUE ($product_id)");
61
+ }
62
+
63
+ }
64
+
65
+ }
app/code/local/AW/FPS/Model/Entity/Attribute/Source/Boolean/Config.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@magentocommerce.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
16
+ * versions in the future. If you wish to customize Magento for your
17
+ * needs please refer to http://www.magentocommerce.com for more information.
18
+ *
19
+ * @category AW
20
+ * @package AW_FPS
21
+ * @copyright Copyright (c) 2008 aheadWorks Co. (http://www.aheadworks.com)
22
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
23
+ */
24
+
25
+ class AW_FPS_Model_Entity_Attribute_Source_Boolean_Config extends Mage_Eav_Model_Entity_Attribute_Source_Boolean
26
+ {
27
+ /**
28
+ * Retrive all attribute options
29
+ *
30
+ * @return array
31
+ */
32
+ public function getAllOptions()
33
+ {
34
+ if (!$this->_options) {
35
+ $this->_options = array(
36
+ array(
37
+ 'label' => Mage::helper('awfps')->__('No'),
38
+ 'value' => 0
39
+ ),
40
+ array(
41
+ 'label' => Mage::helper('awfps')->__('Yes'),
42
+ 'value' => 1
43
+ )
44
+ );
45
+ }
46
+ return $this->_options;
47
+ }
48
+ }
app/code/local/AW/FPS/etc/config.xml ADDED
@@ -0,0 +1,43 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <AW_FPS>
5
+ <version>0.9</version>
6
+ </AW_FPS>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <awfps>
12
+ <class>AW_FPS_Model</class>
13
+ </awfps>
14
+ </models>
15
+
16
+ <helpers>
17
+ <awfps>
18
+ <class>AW_FPS_Helper</class>
19
+ </awfps>
20
+ </helpers>
21
+
22
+ <resources>
23
+ <awfps_setup>
24
+ <setup>
25
+ <module>AW_FPS</module>
26
+ </setup>
27
+ <connection>
28
+ <use>core_setup</use>
29
+ </connection>
30
+ </awfps_setup>
31
+ <awfps_write>
32
+ <connection>
33
+ <use>core_write</use>
34
+ </connection>
35
+ </awfps_write>
36
+ <awfps_read>
37
+ <connection>
38
+ <use>core_read</use>
39
+ </connection>
40
+ </awfps_read>
41
+ </resources>
42
+ </global>
43
+ </config>
app/code/local/AW/FPS/etc/system.xml ADDED
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0"?>
2
+ <config />
app/code/local/AW/FPS/sql/awfps_setup/mysql4-install-0.9.php ADDED
@@ -0,0 +1,58 @@
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@magentocommerce.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
16
+ * versions in the future. If you wish to customize Magento for your
17
+ * needs please refer to http://www.magentocommerce.com for more information.
18
+ *
19
+ * @category AW
20
+ * @package AW_FPS
21
+ * @copyright Copyright (c) 2008 aheadWorks Co. (http://www.aheadworks.com)
22
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
23
+ */
24
+
25
+ $installer = $this;
26
+
27
+ /* $installer Mage_Core_Model_Resource_Setup */
28
+
29
+ $installer->startSetup();
30
+
31
+ $installer->run("
32
+ DROP TABLE IF EXISTS {$this->getTable('aw_fps')};
33
+ CREATE TABLE {$this->getTable('aw_fps')} (
34
+ `product_id` int,
35
+ UNIQUE (`product_id`)
36
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
37
+
38
+ ");
39
+
40
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
41
+
42
+
43
+ $setup->addAttribute('catalog_product', 'aw_fps_available', array(
44
+ 'backend' => 'awfps/entity_attribute_backend_boolean_config',
45
+ 'source' => 'awfps/entity_attribute_source_boolean_config',
46
+ 'frontend' => '',
47
+ 'label' => 'Rotate in featured products slideshow',
48
+ 'input' => 'select',
49
+ 'class' => '',
50
+ 'global' => true,
51
+ 'visible' => true,
52
+ 'required' => false,
53
+ 'user_defined' => false,
54
+ 'default' => '0',
55
+ 'visible_on_front' => false
56
+ ));
57
+
58
+ $installer->endSetup();
app/design/frontend/default/default/template/catalog/product/aw_fps.phtml ADDED
@@ -0,0 +1,219 @@
1
+ <div id="aw_iss"></div>
2
+ <div id="aw_preloading_images" style="height:1px; width:1px; visibility:hidden;"></div>
3
+ <script language="javascript">
4
+
5
+
6
+ <?php
7
+
8
+ $fps = Mage::helper('awfps')->getFeaturedProducts();
9
+
10
+ $aw_iss_data = 'var aw_iss_data=[';
11
+ $i = 1;
12
+ foreach($fps as $fp){
13
+ echo "var aw_iss_fp_$i=['".$fp['url']."', '".$fp['title']."', '".$fp['price']."', '".$fp['image']."'];\n";
14
+ $aw_iss_data .= "aw_iss_fp_$i,";
15
+ $i++;
16
+ }
17
+ $aw_iss_data = chop($aw_iss_data, ',');
18
+ $aw_iss_data .= "];";
19
+ echo $aw_iss_data;
20
+
21
+ /*var aw_iss_fp_1=['10','Flash 5 for Windows and Macintosh','59.99','10'];
22
+ var aw_iss_fp_2=['70','Javascript (Definitive Guide)','39.50','70'];
23
+ var aw_iss_fp_3=['182','Hunting Knife w/sheath','250.00','182'];
24
+ var aw_iss_fp_4=['16123','PATRICK Maracana HG Cleats','41.95','16123'];
25
+ var aw_iss_data=[aw_iss_fp_1,aw_iss_fp_2,aw_iss_fp_3,aw_iss_fp_4];
26
+ */
27
+
28
+ ?>
29
+
30
+
31
+ // Parameters
32
+
33
+ var aw_fontColor = '#000000';
34
+ var aw_fontSize = '11px';
35
+ var aw_fontFamily = 'Arial';
36
+
37
+ var aw_bgColor = '#FFFFFF';
38
+
39
+ var aw_borderColor = '#000000';
40
+ var aw_borderSize = '1px'; //in pixels
41
+ var aw_borderStyle = 'solid';
42
+
43
+ var aw_padding = '1px 1px 1px 1px'; // paddings `top right bottom left` in pixels or 0 0 0 0 (without);
44
+
45
+ var aw_rotateTime = 3000; // in millisec (1 sec = 1000 millisec)
46
+
47
+
48
+ // Parameters
49
+
50
+ /// FROM Q
51
+ $cache = []; // All objects. for cache
52
+ $uid = []; // All objects by uid
53
+
54
+ $ = function(id){
55
+ //getElementById and extend it
56
+ // use cache if available
57
+ var obj = null;
58
+ if(typeof id == 'string'){
59
+ if(!$cache[id]){
60
+ if(!(obj = document.getElementById(id)))
61
+ return false;
62
+ }else{ obj = $cache[id]; }
63
+ }else{ obj = id;}
64
+ if(obj && !obj.alreadyExtended){
65
+ obj.alreadyExtended = true;
66
+ obj.$S = function(o){
67
+ for(var i in o){
68
+ obj.style[i] = o[i];
69
+ if(i=='opacity' && document.all &&!window.opera){
70
+ var oAlpha = obj.filters['DXImageTransform.Microsoft.alpha'] || obj.filters.alpha || false;
71
+ if (oAlpha) oAlpha.opacity = o[i]*100;
72
+ else obj.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+o[i]*100+")";
73
+ }
74
+ }
75
+ }
76
+ }
77
+ return obj;
78
+ }
79
+ // Mutagen - FX handling library. Part of Q-framework.
80
+
81
+ Mutation = function(el){
82
+ this.element = el;
83
+ this.FPS = 30;
84
+ this.duration = 1500;
85
+ this.framesCount = 0;
86
+ this.movies = [];
87
+ this.onPlay = function(){};
88
+ }
89
+
90
+ Mutation.prototype.set = function(from, to, frames){
91
+ for(var i in from){
92
+ var muta = new Mutagen();
93
+ if(muta['__'+i]){
94
+ muta['__'+i](from[i], to[i], frames);
95
+ this.movies.push(muta.movie);
96
+ }
97
+ }
98
+ }
99
+
100
+ Mutation.prototype.play = function(){
101
+ var interval = Math.round(1000/this.FPS);
102
+ var self = this;
103
+ var length = this.movies[0].length;
104
+ for(var i=0; i< length; i++){
105
+ for(var k=0; k< this.movies.length;k++){
106
+ var func = function(obj, style){
107
+ return function(){
108
+ obj.$S(style);
109
+ }
110
+ }(this.element, this.movies[k][i]);
111
+ setTimeout(func, interval*i);
112
+ }
113
+ }
114
+ setTimeout(self.onPlay, interval*length);
115
+ }
116
+
117
+ Mutagen = function(){
118
+ this.movie = [];
119
+ }
120
+
121
+ Mutagen.prototype.__opacity = function(from, to, frames){
122
+ to = parseFloat(to);
123
+ from = parseFloat(from);
124
+ var delta = (to-from)/frames;
125
+ var h = from;
126
+ for(var i=0;i<frames;i++){
127
+ h += delta;
128
+ this.movie.push({opacity: Math.round(h*100)/100});
129
+ }
130
+ }
131
+ ///-FROM Q
132
+ //Preloading pics
133
+ var imgPreloadBlock = '';
134
+ for(var i=0;i<aw_iss_data.length;i++){
135
+ imgPreloadBlock = imgPreloadBlock + '<img src="'+aw_iss_data[i][3]+'" height=0 width=0>';
136
+ (new Image(1,1)).src = aw_iss_data[i][3];
137
+ }
138
+ document.getElementById('aw_preloading_images').innerHTML = imgPreloadBlock;
139
+ window.onload = function(){
140
+ // Start operations with dom only on window load
141
+ mouseFollowedDiv = document.createElement('div');
142
+ document.body.appendChild(mouseFollowedDiv);
143
+ mouseFollowedDiv.style.position = 'absolute';
144
+ mouseFollowedDiv.style.border = aw_borderSize+' '+aw_borderStyle+' '+aw_borderColor;
145
+ mouseFollowedDiv.style.backgroundColor = aw_bgColor;
146
+ mouseFollowedDiv.style.display = 'none';
147
+ mouseFollowedDiv.style.font = aw_fontSize+' '+aw_fontFamily;
148
+ mouseFollowedDiv.style.color = aw_fontColor;
149
+ mouseFollowedDiv.style.padding = aw_padding;
150
+
151
+ var __captureCoord = function(){
152
+ //x-browser capture coordinates function
153
+ if(!document.all){
154
+ return function(e){
155
+ // gecko|opera|safari
156
+ var x = e.clientX;
157
+ var y = e.clientY;
158
+ var newX = x +20 + window.pageXOffset+'px';
159
+ var newY = y +20+ window.pageYOffset+'px';
160
+ var func = function(){
161
+ mouseFollowedDiv.style.left = newX
162
+ mouseFollowedDiv.style.top = newY;
163
+ }
164
+ var intId = setTimeout(func, 5);
165
+ }
166
+ }else{
167
+ if(navigator.appVersion.match('6')){
168
+ // ie 6
169
+ return function(){
170
+ mouseFollowedDiv.style.left = event.clientX +20 + document.body.scrollLeft +'px';
171
+ mouseFollowedDiv.style.top = event.clientY +20 + document.body.scrollTop+'px';
172
+ }
173
+ }else return function(){
174
+ // ie 7
175
+ mouseFollowedDiv.style.left = event.clientX + 20 + document.documentElement.scrollLeft +'px';
176
+ mouseFollowedDiv.style.top = event.clientY + 20 + document.documentElement.scrollTop+'px';
177
+ }
178
+ }
179
+ }
180
+ document.body.onmousemove = __captureCoord();
181
+ imgContainer = $('aw_iss');
182
+ imgContainer.onmouseover = function(){this.paused = true; mouseFollowedDiv.style.display = ''};
183
+ imgContainer.onmouseout = function(){this.paused = false; mouseFollowedDiv.style.display = 'none'};
184
+ // First element might be preloaded
185
+ imgContainer.innerHTML = '<a id="rotator_url" href="'+aw_iss_data[0][0]+'"><img id="rotator" src="' + aw_iss_data[0][3] + '" /></a>';
186
+ mouseFollowedDiv.innerHTML = aw_iss_data[0][1]+'<br/>'+aw_iss_data[0][2];
187
+ imgContainer.currentIndex = 0;
188
+
189
+ var muta = new Mutation($('rotator'));
190
+ muta.set({opacity:'1'},{opacity:'0'},15);
191
+ var muta2 = new Mutation($('rotator'));
192
+ muta2.set({opacity:'0'},{opacity:'1'},45);
193
+
194
+ var imgRotator = function(){
195
+ if(!imgContainer.paused){
196
+
197
+ muta.onPlay = function(){
198
+ imgContainer.currentIndex = (imgContainer.currentIndex!==null && imgContainer.currentIndex<aw_iss_data.length-1) ? imgContainer.currentIndex+1:0;
199
+ $('rotator_url').href = aw_iss_data[imgContainer.currentIndex][0];
200
+ op_fl = 0;
201
+ $('rotator').onload = function(){
202
+ muta2.play();
203
+ op_fl =1;
204
+ }
205
+
206
+
207
+ $('rotator').src = aw_iss_data[imgContainer.currentIndex][3];
208
+ if(window.opera && !op_fl)
209
+ muta2.play()
210
+ mouseFollowedDiv.innerHTML = aw_iss_data[imgContainer.currentIndex][1]+'<br/>'+aw_iss_data[imgContainer.currentIndex][2];
211
+ };
212
+ muta.play();
213
+ }
214
+ }
215
+ setInterval(imgRotator, aw_rotateTime);
216
+ }
217
+
218
+
219
+ </script>
package.xml ADDED
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>AW_FPS</name>
4
+ <version>0.9</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Featured Products Slideshow</summary>
10
+ <description>Featured Products Slideshow allows you to place slideshow of your featured products on any page of your Magento store. They'll be rotated by means of a JS script.</description>
11
+ <notes>To use the extension place the following code:
12
+ ----------------------------------------------------------------
13
+ {{block type="catalog/product/aw_fps" template="catalog/product/aw_fps.phtml"}}
14
+ ----------------------------------------------------------------
15
+ on any page with the help of Magento CMS. After this done, go to Admin-&gt;Catalog-&gt;Manage Products-&gt;edit a product and set "Rotate in featured products slideshow" to "Yes". Navigate to the page in which you inserted the block above and enjoy the slideshow.</notes>
16
+ <authors><author><name>Artyom</name><user>auto-converted</user><email>rabzonov@aheadworks.com</email></author></authors>
17
+ <date>2008-11-26</date>
18
+ <time>16:25:52</time>
19
+ <contents><target name="magelocal"><dir name="AW"><dir name="FPS"><dir name="etc"><file name="config.xml" hash="c53bc86055f88d93f6a039b544c3abcb"/><file name="system.xml" hash="c01edaeca8b08e8221cd08d8ac29ecd3"/></dir><dir name="Helper"><file name="Data.php" hash="46aea6822074dd2f08f23018f49c13f4"/></dir><dir name="Model"><dir name="Entity"><dir name="Attribute"><dir name="Backend"><dir name="Boolean"><file name="Config.php" hash="c9e85bca3b19f1e2003926f5f97b7543"/></dir></dir><dir name="Source"><dir name="Boolean"><file name="Config.php" hash="75a97e221006157620840c7c34e71506"/></dir></dir></dir></dir></dir><dir name="sql"><dir name="awfps_setup"><file name="mysql4-install-0.9.php" hash="e6742522f0be7e0d3b93bb8b9d285aea"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="aw_fps.phtml" hash="387667398ffad6b95494bbde9e0d24d3"/></dir></dir></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies/>
22
+ </package>