Version Notes
Stable Release.
Download this release
Release Info
Developer | SafeMage |
Extension | SafeMage_QuoteWidget |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/SafeMage/QuoteWidget/Block/Widget.php +130 -0
- app/code/community/SafeMage/QuoteWidget/Block/Widget/Date.php +30 -0
- app/code/community/SafeMage/QuoteWidget/Helper/Data.php +15 -0
- app/code/community/SafeMage/QuoteWidget/data/safemage_quotewidget_setup/data-install-1.0.0.php +68 -0
- app/code/community/SafeMage/QuoteWidget/etc/config.xml +56 -0
- app/code/community/SafeMage/QuoteWidget/etc/widget.xml +60 -0
- app/design/frontend/base/default/layout/safemage/quotewidget.xml +17 -0
- app/design/frontend/base/default/template/safemage/quotewidget/widget.phtml +57 -0
- app/etc/modules/SafeMage_QuoteWidget.xml +21 -0
- app/locale/en_US/SafeMage_QuoteWidget.csv +9 -0
- package.xml +18 -0
- skin/frontend/base/default/safemage/js/quotewidget.js +40 -0
app/code/community/SafeMage/QuoteWidget/Block/Widget.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
*/
|
11 |
+
|
12 |
+
class SafeMage_QuoteWidget_Block_Widget extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface
|
13 |
+
{
|
14 |
+
const AUTHOR_DELIMITER = '|';
|
15 |
+
const ITEMS_DELIMITER = "\n";
|
16 |
+
|
17 |
+
const DAY_SEC = 86399;
|
18 |
+
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->setTemplate('safemage/quotewidget/widget.phtml');
|
22 |
+
parent::_construct();
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getAuthorDelimiter()
|
26 |
+
{
|
27 |
+
return self::AUTHOR_DELIMITER;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getItemsDelimiter()
|
31 |
+
{
|
32 |
+
return self::ITEMS_DELIMITER;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getDaySeconds()
|
36 |
+
{
|
37 |
+
return self::DAY_SEC;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getItems()
|
41 |
+
{
|
42 |
+
$items = explode($this->getItemsDelimiter(), $this->getList() . $this->getCopyright());
|
43 |
+
$objects = array();
|
44 |
+
if (count($items)) {
|
45 |
+
foreach($items as $item) {
|
46 |
+
$parts = explode($this->getAuthorDelimiter(), $item, 2);
|
47 |
+
$object = new Varien_Object(
|
48 |
+
array('quote' => $parts[0], 'author' => $parts[1])
|
49 |
+
);
|
50 |
+
$objects[] = $object;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
return $objects;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getFromTime()
|
57 |
+
{
|
58 |
+
$from = $this->getData('from_date');
|
59 |
+
if (empty($from)) {
|
60 |
+
return null;
|
61 |
+
}
|
62 |
+
|
63 |
+
$time = strtotime($from);
|
64 |
+
return $time;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getToTime()
|
68 |
+
{
|
69 |
+
$to = $this->getData('to_date');
|
70 |
+
if (empty($to)) {
|
71 |
+
return null;
|
72 |
+
}
|
73 |
+
|
74 |
+
$time = strtotime($to) + $this->getDaySeconds();
|
75 |
+
return $time;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getDuration()
|
79 |
+
{
|
80 |
+
$duration = (int)$this->getData('animation_duration');
|
81 |
+
$duration = $duration ? $duration : 6;
|
82 |
+
return $duration;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function canShow()
|
86 |
+
{
|
87 |
+
$currentLocaleTime = Mage::getModel('core/date')->timestamp(time());
|
88 |
+
$from = $this->getFromTime();
|
89 |
+
$to = $this->getToTime();
|
90 |
+
|
91 |
+
$can = true;
|
92 |
+
if (!empty($from)) {
|
93 |
+
$can = ($from <= $currentLocaleTime);
|
94 |
+
}
|
95 |
+
if (!empty($to)) {
|
96 |
+
$can = $can && ($currentLocaleTime <= $to);
|
97 |
+
}
|
98 |
+
|
99 |
+
return $can;
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function _getUniqueId()
|
103 |
+
{
|
104 |
+
return $this->getNameInLayout();
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getWrapperClassName()
|
108 |
+
{
|
109 |
+
$className = 'quotesWrapper' . $this->_getUniqueId();
|
110 |
+
return $className;
|
111 |
+
}
|
112 |
+
|
113 |
+
public function getJsObjectName()
|
114 |
+
{
|
115 |
+
$jsObjName = 'safeMageQuoteWidget' . $this->_getUniqueId();
|
116 |
+
return $jsObjName;
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getCopyright()
|
120 |
+
{
|
121 |
+
return "\n" . 'Here you will find complex eCommerce solutions! | ' .
|
122 |
+
'<a href="https://www.safemage.com/">SafeMage.com</a>';
|
123 |
+
}
|
124 |
+
|
125 |
+
public function getQuotesSelector()
|
126 |
+
{
|
127 |
+
$selector = ".{$this->getWrapperClassName()} .random-quote-widget-item";
|
128 |
+
return $selector;
|
129 |
+
}
|
130 |
+
}
|
app/code/community/SafeMage/QuoteWidget/Block/Widget/Date.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
*/
|
11 |
+
|
12 |
+
class SafeMage_QuoteWidget_Block_Widget_Date extends Mage_Core_Block_Template
|
13 |
+
{
|
14 |
+
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$element->setFormat('M/d/yyyy');
|
17 |
+
$this->_fix($element);
|
18 |
+
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
|
19 |
+
return $element;
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _fix(Varien_Data_Form_Element_Abstract $element)
|
23 |
+
{
|
24 |
+
if ($element->getValue()) {
|
25 |
+
$parts = explode('/', $element->getValue());
|
26 |
+
$value = $parts[0] . '/' . $parts[1] . '/' . $parts[2];
|
27 |
+
$element->setValue($value);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
app/code/community/SafeMage/QuoteWidget/Helper/Data.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
*/
|
11 |
+
|
12 |
+
class SafeMage_QuoteWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
}
|
app/code/community/SafeMage/QuoteWidget/data/safemage_quotewidget_setup/data-install-1.0.0.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
*/
|
11 |
+
|
12 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
13 |
+
$installer = $this;
|
14 |
+
|
15 |
+
$installer->startSetup();
|
16 |
+
|
17 |
+
try {
|
18 |
+
$widgetParams = array(
|
19 |
+
'title' => 'Random Quote',
|
20 |
+
'list' => 'Try not to become a man of success, but rather try to become a man of value. | Albert Einstein
|
21 |
+
Look deep into nature, and then you will understand everything better. | Albert Einstein
|
22 |
+
Whoever is careless with the truth in small matters cannot be trusted with important matters. | Albert Einstein
|
23 |
+
A person who never made a mistake never tried anything new. | Albert Einstein',
|
24 |
+
'from_date' => '',
|
25 |
+
'to_date' => '',
|
26 |
+
'animation_duration' => '6',
|
27 |
+
'cache_lifetime' => '',
|
28 |
+
);
|
29 |
+
|
30 |
+
$package = Mage::getSingleton('core/design_package')->getPackageName();
|
31 |
+
$theme = Mage::getSingleton('core/design_package')->getTheme('frontend');
|
32 |
+
$storeIds = array();
|
33 |
+
foreach(Mage::app()->getStores() as $storeId => $data) {
|
34 |
+
$storeIds[]= $storeId;
|
35 |
+
}
|
36 |
+
|
37 |
+
$widgetInstance = Mage::getModel('widget/widget_instance')
|
38 |
+
->addData(array(
|
39 |
+
'instance_type' => 'safemage_quotewidget/widget',
|
40 |
+
'package_theme' => "{$package}/{$theme}",
|
41 |
+
'title' => 'Random Quote',
|
42 |
+
'widget_parameters' => serialize($widgetParams),
|
43 |
+
'page_groups' => array(
|
44 |
+
array(
|
45 |
+
'group' => 'pages',
|
46 |
+
'page_group' => 'pages',
|
47 |
+
'layout_handle' => 'cms_index_index',
|
48 |
+
'block_reference' => 'bottom.container',
|
49 |
+
'entities' => '',
|
50 |
+
'template' => '',
|
51 |
+
'pages' => array(
|
52 |
+
'page_id' => '',
|
53 |
+
'layout_handle' => 'cms_index_index',
|
54 |
+
'template' => '',
|
55 |
+
'block' => 'top.menu',
|
56 |
+
'for' => 'all',
|
57 |
+
)
|
58 |
+
)
|
59 |
+
),
|
60 |
+
'store_ids' => $storeIds
|
61 |
+
))
|
62 |
+
->save();
|
63 |
+
|
64 |
+
} catch (Exception $e) {
|
65 |
+
Mage::logException($e);
|
66 |
+
}
|
67 |
+
|
68 |
+
$installer->endSetup();
|
app/code/community/SafeMage/QuoteWidget/etc/config.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<SafeMage_QuoteWidget>
|
14 |
+
<version>1.0.0</version>
|
15 |
+
</SafeMage_QuoteWidget>
|
16 |
+
</modules>
|
17 |
+
<frontend>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<safemage_quotewidget>
|
21 |
+
<file>safemage/quotewidget.xml</file>
|
22 |
+
</safemage_quotewidget>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<adminhtml>
|
27 |
+
<translate>
|
28 |
+
<modules>
|
29 |
+
<SafeMage_Plugin>
|
30 |
+
<files>
|
31 |
+
<default>SafeMage_QuoteWidget.csv</default>
|
32 |
+
</files>
|
33 |
+
</SafeMage_Plugin>
|
34 |
+
</modules>
|
35 |
+
</translate>
|
36 |
+
</adminhtml>
|
37 |
+
<global>
|
38 |
+
<blocks>
|
39 |
+
<safemage_quotewidget>
|
40 |
+
<class>SafeMage_QuoteWidget_Block</class>
|
41 |
+
</safemage_quotewidget>
|
42 |
+
</blocks>
|
43 |
+
<helpers>
|
44 |
+
<safemage_quotewidget>
|
45 |
+
<class>SafeMage_QuoteWidget_Helper</class>
|
46 |
+
</safemage_quotewidget>
|
47 |
+
</helpers>
|
48 |
+
<resources>
|
49 |
+
<safemage_quotewidget_setup>
|
50 |
+
<setup>
|
51 |
+
<module>SafeMage_QuoteWidget</module>
|
52 |
+
</setup>
|
53 |
+
</safemage_quotewidget_setup>
|
54 |
+
</resources>
|
55 |
+
</global>
|
56 |
+
</config>
|
app/code/community/SafeMage/QuoteWidget/etc/widget.xml
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
-->
|
11 |
+
<widgets>
|
12 |
+
<safemage_quotewidget type="safemage_quotewidget/widget" translate="name description" module="safemage_quotewidget">
|
13 |
+
<name>Random Quote</name>
|
14 |
+
<description>Quotes by some Authors</description>
|
15 |
+
<is_email_compatible>1</is_email_compatible>
|
16 |
+
<parameters>
|
17 |
+
<title translate="label">
|
18 |
+
<visible>1</visible>
|
19 |
+
<required>1</required>
|
20 |
+
<label>Title</label>
|
21 |
+
<type>text</type>
|
22 |
+
</title>
|
23 |
+
<list translate="label description">
|
24 |
+
<visible>1</visible>
|
25 |
+
<required>1</required>
|
26 |
+
<label>Quotes</label>
|
27 |
+
<type>textarea</type>
|
28 |
+
<description>Quotes separated by new line</description>
|
29 |
+
</list>
|
30 |
+
<from_date translate="label">
|
31 |
+
<visible>1</visible>
|
32 |
+
<label>Show from Date</label>
|
33 |
+
<type>date</type>
|
34 |
+
<helper_block>
|
35 |
+
<type>safemage_quotewidget/widget_date</type>
|
36 |
+
</helper_block>
|
37 |
+
</from_date>
|
38 |
+
<to_date translate="label">
|
39 |
+
<visible>1</visible>
|
40 |
+
<label>Show to Date</label>
|
41 |
+
<type>date</type>
|
42 |
+
<helper_block>
|
43 |
+
<type>safemage_quotewidget/widget_date</type>
|
44 |
+
</helper_block>
|
45 |
+
</to_date>
|
46 |
+
<animation_duration translate="label">
|
47 |
+
<visible>1</visible>
|
48 |
+
<required>1</required>
|
49 |
+
<label>Animation Duration (Seconds)</label>
|
50 |
+
<type>text</type>
|
51 |
+
</animation_duration>
|
52 |
+
<cache_lifetime translate="label description">
|
53 |
+
<label>Cache Lifetime (Seconds)</label>
|
54 |
+
<description>86400 by default, if not set. To refresh instantly, Clear the Blocks HTML Output Cache.</description>
|
55 |
+
<visible>1</visible>
|
56 |
+
<type>text</type>
|
57 |
+
</cache_lifetime>
|
58 |
+
</parameters>
|
59 |
+
</safemage_quotewidget>
|
60 |
+
</widgets>
|
app/design/frontend/base/default/layout/safemage/quotewidget.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
-->
|
11 |
+
<layout version="0.1.0">
|
12 |
+
<default>
|
13 |
+
<reference name="head">
|
14 |
+
<action method="addItem"><type>skin_js</type><name>safemage/js/quotewidget.js</name></action>
|
15 |
+
</reference>
|
16 |
+
</default>
|
17 |
+
</layout>
|
app/design/frontend/base/default/template/safemage/quotewidget/widget.phtml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
*/
|
11 |
+
?>
|
12 |
+
<?php if ($this->canShow()): ?>
|
13 |
+
<style type="text/css">
|
14 |
+
.random-quote-widget{
|
15 |
+
border: 1px solid red;
|
16 |
+
float: right;
|
17 |
+
padding: 6px;
|
18 |
+
width: 44%;
|
19 |
+
}
|
20 |
+
.random-quote-widget-item {
|
21 |
+
opacity: 1;
|
22 |
+
-webkit-animation: fadeinout <?php echo $this->getDuration(); ?>s linear 1 forwards;
|
23 |
+
animation: fadeinout <?php echo $this->getDuration(); ?>s linear 1 forwards;
|
24 |
+
}
|
25 |
+
@-webkit-keyframes fadeinout {
|
26 |
+
0% { opacity: 0; }
|
27 |
+
15% { opacity: 1; }
|
28 |
+
85% { opacity: 1; }
|
29 |
+
100% { opacity: 0; }
|
30 |
+
}
|
31 |
+
@keyframes fadeinout {
|
32 |
+
0% { opacity: 0; }
|
33 |
+
15% { opacity: 1; }
|
34 |
+
85% { opacity: 1; }
|
35 |
+
100% { opacity: 0; }
|
36 |
+
}
|
37 |
+
</style>
|
38 |
+
|
39 |
+
<div class="random-quote-widget <?php echo $this->getWrapperClassName(); ?>">
|
40 |
+
<h3><?php echo $this->getTitle() ?></h3>
|
41 |
+
<?php foreach($this->getItems() as $item): ?>
|
42 |
+
<div class="random-quote-widget-item">
|
43 |
+
<?php echo $item->getQuote() ?>
|
44 |
+
<?php if ($item->getAuthor()): ?><div align="right"><i><?php echo $item->getAuthor() ?></i></div><?php endif; ?>
|
45 |
+
</div>
|
46 |
+
<?php endforeach; ?>
|
47 |
+
</div>
|
48 |
+
|
49 |
+
<script type="text/javascript">
|
50 |
+
//<![CDATA[
|
51 |
+
<?php echo $this->getJsObjectName(); ?> = new SafeMageQuoteWidget({
|
52 |
+
quotesSelector: '<?php echo $this->getQuotesSelector(); ?>',
|
53 |
+
animationTime: <?php echo $this->getDuration(); ?>
|
54 |
+
});
|
55 |
+
//]]>
|
56 |
+
</script>
|
57 |
+
<?php endif; ?>
|
app/etc/modules/SafeMage_QuoteWidget.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
NOTICE OF LICENSE
|
4 |
+
|
5 |
+
This source file is subject to the SafeMageEULA that is bundled with this package in the file LICENSE.txt.
|
6 |
+
|
7 |
+
It is also available at this URL: https://www.safemage.com/LICENSE_EULA.txt
|
8 |
+
|
9 |
+
Copyright (c) SafeMage (https://www.safemage.com/)
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<SafeMage_QuoteWidget>
|
14 |
+
<active>true</active>
|
15 |
+
<codePool>community</codePool>
|
16 |
+
<extension_name>Random Quote Widget</extension_name>
|
17 |
+
<cache_key>random</cache_key>
|
18 |
+
<url>random-quote-widget-extension-for-magento</url>
|
19 |
+
</SafeMage_QuoteWidget>
|
20 |
+
</modules>
|
21 |
+
</config>
|
app/locale/en_US/SafeMage_QuoteWidget.csv
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Title,Title
|
2 |
+
Quotes,Quotes
|
3 |
+
Quotes separated by new line,Quotes separated by new line
|
4 |
+
Show from Date,Show from Date
|
5 |
+
Show to Date,Show to Date
|
6 |
+
Animation Duration (Seconds),Animation Duration (Seconds)
|
7 |
+
Cache Lifetime (Seconds),Cache Lifetime (Seconds)
|
8 |
+
Random Quote,Random Quote
|
9 |
+
Quotes by some Authors,Quotes by some Authors
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>SafeMage_QuoteWidget</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.safemage.com/LICENSE_EULA.txt">SafeMage EULA</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Random Quote Widget</summary>
|
10 |
+
<description>Random Quote Widget</description>
|
11 |
+
<notes>Stable Release.</notes>
|
12 |
+
<authors><author><name>SafeMage</name><user>safemage</user><email>info@safemage.com</email></author></authors>
|
13 |
+
<date>2017-03-21</date>
|
14 |
+
<time>16:01:58</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="SafeMage"><dir name="QuoteWidget"><dir name="Block"><dir name="Widget"><file name="Date.php" hash="914bb54807be821be3d7429d1ca0cd99"/></dir><file name="Widget.php" hash="dffba283a499e2789d7346ba5c12b3e3"/></dir><dir name="Helper"><file name="Data.php" hash="978cbe67fe5aba09b0db8020879aca6f"/></dir><dir name="data"><dir name="safemage_quotewidget_setup"><file name="data-install-1.0.0.php" hash="74585def62bbe513e1a96a315c055ccb"/></dir></dir><dir name="etc"><file name="config.xml" hash="414ef100d105fc20cbcba4fe84a632cf"/><file name="widget.xml" hash="d2d3d9e1638b4a41432567ee92f592ca"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SafeMage_QuoteWidget.xml" hash="2cf4d755fc127b09b1e62606db16be73"/></dir></target><target name="magelocale"><dir name="en_US"><file name="SafeMage_QuoteWidget.csv" hash="327a1a424a51566838483f4abc364493"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="safemage"><dir name="js"><file name="quotewidget.js" hash="ae33335b49c62eb9933724f58704aa32"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="safemage"><file name="quotewidget.xml" hash="de98f5dc5a1470a2272d7d0ac26cd2e3"/></dir></dir><dir name="template"><dir name="safemage"><dir name="quotewidget"><file name="widget.phtml" hash="7288f73f0c498a12801f0075236f03e2"/></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/base/default/safemage/js/quotewidget.js
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
SafeMageQuoteWidget = Class.create();
|
2 |
+
SafeMageQuoteWidget.prototype = {
|
3 |
+
initialize: function(config){
|
4 |
+
var me = this;
|
5 |
+
this.quotesSelector = config.quotesSelector;
|
6 |
+
this.animationTime = config.animationTime * 1000;
|
7 |
+
this.quotes = $$(config.quotesSelector);
|
8 |
+
this.indexToShow = 0;
|
9 |
+
|
10 |
+
this.showNext(this);
|
11 |
+
this.start();
|
12 |
+
},
|
13 |
+
|
14 |
+
start: function() {
|
15 |
+
var me = this;
|
16 |
+
setInterval(function(){
|
17 |
+
me.showNext(me);
|
18 |
+
}, this.animationTime);
|
19 |
+
},
|
20 |
+
|
21 |
+
showNext: function(me) {
|
22 |
+
me.hideAll();
|
23 |
+
|
24 |
+
if (typeof(me.quotes[me.indexToShow + 1]) == 'undefined') {
|
25 |
+
me.indexToShow = 0;
|
26 |
+
}
|
27 |
+
|
28 |
+
if (typeof(me.quotes[me.indexToShow]) != 'undefined') {
|
29 |
+
me.quotes[me.indexToShow].show();
|
30 |
+
}
|
31 |
+
|
32 |
+
me.indexToShow++;
|
33 |
+
},
|
34 |
+
|
35 |
+
hideAll: function() {
|
36 |
+
$$(this.quotesSelector).each(function(item){
|
37 |
+
item.hide();
|
38 |
+
});
|
39 |
+
}
|
40 |
+
};
|