dreystone-page-thumbnail - Version 1.0.0

Version Notes

Initial Release

Download this release

Release Info

Developer Dreystone
Extension dreystone-page-thumbnail
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Dreystone/PageThumbnail/Block/Adminhtml/Config/Copyright.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Block_Adminhtml_Config_Copyright
21
+ extends Mage_Adminhtml_Block_Abstract
22
+ implements Varien_Data_Form_Element_Renderer_Interface
23
+ {
24
+ /**
25
+ * Render element html
26
+ *
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ */
30
+ public function render(Varien_Data_Form_Element_Abstract $element)
31
+ {
32
+ return sprintf(
33
+ '<tr class="system-fieldset-sub-head" id="row_%s">
34
+ <td class="label"><label for="%s">%s</label></td>
35
+ <td class="value" colspan="4">%s - <a href="%s">%s</a></td>
36
+ </tr>',
37
+ $element->getHtmlId(),
38
+ $element->getHtmlId(),
39
+ $element->getLabel(),
40
+ '&copy; Copyright ' . date('Y') . ' Dreystone Software',
41
+ 'http://dreystone.com/',
42
+ 'http://dreystone.com/'
43
+ );
44
+ }
45
+ }
app/code/community/Dreystone/PageThumbnail/Block/Adminhtml/Config/Support.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Block_Adminhtml_Config_Support
21
+ extends Mage_Adminhtml_Block_Abstract
22
+ implements Varien_Data_Form_Element_Renderer_Interface
23
+ {
24
+ /**
25
+ * Render element html
26
+ *
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ */
30
+ public function render(Varien_Data_Form_Element_Abstract $element)
31
+ {
32
+ return sprintf(
33
+ '<tr class="system-fieldset-sub-head" id="row_%s">
34
+ <td class="label"><label for="%s">%s</label></td>
35
+ <td class="value" colspan="4">%s</td>
36
+ </tr>',
37
+ $element->getHtmlId(),
38
+ $element->getHtmlId(),
39
+ $element->getLabel(),
40
+ '<a href="mailto:magento@dreystone.com">magento@dreystone.com</a>'
41
+ );
42
+ }
43
+ }
app/code/community/Dreystone/PageThumbnail/Block/Adminhtml/Config/Version.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Block_Adminhtml_Config_Version
21
+ extends Mage_Adminhtml_Block_Abstract
22
+ implements Varien_Data_Form_Element_Renderer_Interface
23
+ {
24
+ /**
25
+ * Render element html
26
+ *
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ */
30
+ public function render(Varien_Data_Form_Element_Abstract $element)
31
+ {
32
+ return sprintf(
33
+ '<tr class="system-fieldset-sub-head" id="row_%s">
34
+ <td class="label"><label for="%s">%s</label></td>
35
+ <td class="value" colspan="4">v%s</td>
36
+ </tr>',
37
+ $element->getHtmlId(),
38
+ $element->getHtmlId(),
39
+ $element->getLabel(),
40
+ $this->_getVersion()
41
+ );
42
+ }
43
+
44
+
45
+ /**
46
+ * Get the current version string from extension config.xml
47
+ *
48
+ * @return string
49
+ */
50
+ protected function _getVersion()
51
+ {
52
+ $cls = explode('_Block_', get_class($this));
53
+ $ext = array_shift($cls);
54
+
55
+ return (string) Mage::getConfig()->getNode("modules/{$ext}/version");
56
+ }
57
+ }
app/code/community/Dreystone/PageThumbnail/Block/Link.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Block_Link extends Mage_Core_Block_Template
21
+ {
22
+ protected function _toHtml()
23
+ {
24
+ $imageUrl = Mage::registry('dspagethumb_image_src');
25
+ $metaTags = array();
26
+
27
+ if (!empty($imageUrl)) {
28
+ $metaTags[] = $this->_getMetaTag('image_src', $imageUrl);
29
+ $helper = Mage::helper('dspagethumb');
30
+ $og = $helper->getConfig('include_og_image');
31
+
32
+ // also add the Open Graph image (if set in config)
33
+ if ($og == Dreystone_PageThumbnail_Model_Source_Opengraph_Image::TYPE_NAME) {
34
+ $metaTags[] = $this->_getMetaTag('og:image', $imageUrl);
35
+ } elseif ($og == Dreystone_PageThumbnail_Model_Source_Opengraph_Image::TYPE_PROPERTY) {
36
+ $metaTags[] = $this->_getMetaProperty('og:image', $imageUrl);
37
+ }
38
+ }
39
+
40
+ return implode("\n", $metaTags);
41
+ }
42
+
43
+
44
+ /**
45
+ * Prepares the meta tag
46
+ *
47
+ * @param string $name
48
+ * @param string $content
49
+ * @param string $type
50
+ * @return string
51
+ */
52
+ protected function _getMetaTag($name, $content, $type = '')
53
+ {
54
+ return sprintf(
55
+ '<meta name="%s" content="%s" %s/>',
56
+ $name,
57
+ $content,
58
+ (!empty($type)) ? 'type="' . $type . '" ' : ''
59
+ );
60
+ }
61
+
62
+
63
+ /**
64
+ * Prepares the meta property
65
+ *
66
+ * @param string $name
67
+ * @param string $content
68
+ * @param string $type
69
+ * @return string
70
+ */
71
+ protected function _getMetaProperty($name, $content)
72
+ {
73
+ return sprintf(
74
+ '<meta property="%s" content="%s" />',
75
+ $name,
76
+ $content
77
+ );
78
+ }
79
+ }
app/code/community/Dreystone/PageThumbnail/Helper/Data.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Helper_Data extends Mage_Core_Helper_Abstract
21
+ {
22
+ /**
23
+ * Check if the feature is enabled
24
+ *
25
+ * @return boolean
26
+ */
27
+ public function getIsActive()
28
+ {
29
+ return (boolean) $this->getConfig('active');
30
+ }
31
+
32
+
33
+ /**
34
+ * Get the config value for field
35
+ *
36
+ * @param string $field
37
+ * @param string $store
38
+ * @return mixed
39
+ */
40
+ public function getConfig($field, $store = null)
41
+ {
42
+ return Mage::getStoreConfig('design/dspagethumb/' . $field, $store);
43
+ }
44
+ }
app/code/community/Dreystone/PageThumbnail/Model/Observer.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Model_Observer
21
+ {
22
+ /**
23
+ * Records the image for the category
24
+ *
25
+ * Event: catalog_controller_category_init_after
26
+ *
27
+ * @param Varien_Event_Observer $observer
28
+ */
29
+ public function bindActiveCategory(Varien_Event_Observer $observer)
30
+ {
31
+ $category = $observer->getEvent()->getCategory();
32
+ $helper = Mage::helper('dspagethumb');
33
+
34
+ if ($helper->getIsActive()
35
+ && $category
36
+ && $category instanceof Mage_Catalog_Model_Category
37
+ ) {
38
+ $option = $helper->getConfig('category_option');
39
+ $image = null;
40
+
41
+ if ($option == Dreystone_PageThumbnail_Model_Source_Category_Image::TYPE_NONE) {
42
+ // don't display any, so return early
43
+ return;
44
+
45
+ } elseif ($option == Dreystone_PageThumbnail_Model_Source_Category_Image::TYPE_THUMBNAIL) {
46
+ $image = $this->_getCategoryThumbnailUrl($category);
47
+ } elseif ($option == Dreystone_PageThumbnail_Model_Source_Category_Image::TYPE_IMAGE) {
48
+ $image = $category->getImageUrl();
49
+ }
50
+
51
+ // fallback is always logo
52
+ if (!$image) {
53
+ $image = $this->_getSiteLogoUrl();
54
+ }
55
+
56
+ // save the image in registry for later use (might be null)
57
+ Mage::register('dspagethumb_image_src', $image);
58
+ }
59
+ }
60
+
61
+
62
+ /**
63
+ * Records the image for the product
64
+ *
65
+ * Event: catalog_controller_product_init_after
66
+ *
67
+ * @param Varien_Event_Observer $observer
68
+ */
69
+ public function bindActiveProduct(Varien_Event_Observer $observer)
70
+ {
71
+ $product = $observer->getEvent()->getProduct();
72
+ $helper = Mage::helper('dspagethumb');
73
+
74
+ if ($helper->getIsActive()
75
+ && $product
76
+ && $product instanceof Mage_Catalog_Model_Product
77
+ && $product->getImage()
78
+ && ($product->getImage() != 'no_selection')
79
+ ) {
80
+ $image = $product->getImage();
81
+ $image = Mage::getBaseUrl('media') . 'catalog/product' . $image;
82
+
83
+ // save the image in registry for later use (might be null)
84
+ Mage::register('dspagethumb_image_src', (string) $image);
85
+ }
86
+ }
87
+
88
+
89
+ /**
90
+ * Records the image for the CMS page
91
+ *
92
+ * Event: cms_page_render
93
+ *
94
+ * @param Varien_Event_Observer $observer
95
+ */
96
+ public function bindActiveCmsPage(Varien_Event_Observer $observer)
97
+ {
98
+ $page = $observer->getEvent()->getPage();
99
+ $helper = Mage::helper('dspagethumb');
100
+
101
+ if ($helper->getIsActive()
102
+ && $page
103
+ && $page instanceof Mage_Cms_Model_Page
104
+ ) {
105
+ $option = $helper->getConfig('cms_option');
106
+
107
+ if ($option == Dreystone_PageThumbnail_Model_Source_Cms_Image::TYPE_NONE) {
108
+ // don't display any, so return early
109
+ return;
110
+ }
111
+
112
+ $image = $this->_getSiteLogoUrl();
113
+
114
+ // save the image in registry for later use (might be null)
115
+ Mage::register('dspagethumb_image_src', $image);
116
+ }
117
+ }
118
+
119
+
120
+ /**
121
+ * Gets the URL for the category thumbnail (if set)
122
+ *
123
+ * @param Mage_Catalog_Model_Category $category
124
+ * @return string|null
125
+ */
126
+ protected function _getCategoryThumbnailUrl($category)
127
+ {
128
+ $url = null;
129
+ $image = $category->getThumbnail();
130
+
131
+ if ($image) {
132
+ $url = Mage::getBaseUrl('media') . 'catalog/category/' . $image;
133
+ }
134
+
135
+ return $url;
136
+ }
137
+
138
+
139
+ /**
140
+ * Gets the site logo URL
141
+ *
142
+ * @return string|null
143
+ */
144
+ protected function _getSiteLogoUrl()
145
+ {
146
+ $image = null;
147
+ $logo = Mage::getStoreConfig('design/header/logo_src');
148
+
149
+ if (!empty($logo)) {
150
+ $image = Mage::getDesign()->getSkinUrl($logo);
151
+ }
152
+
153
+ return $image;
154
+ }
155
+ }
app/code/community/Dreystone/PageThumbnail/Model/Source/Category/Image.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Model_Source_Category_Image
21
+ {
22
+ const TYPE_NONE = 'none';
23
+ const TYPE_SITE_LOGO = 'logo';
24
+ const TYPE_THUMBNAIL = 'thumbnail';
25
+ const TYPE_IMAGE = 'image';
26
+
27
+
28
+ /**
29
+ * Default option array
30
+ *
31
+ * @var string
32
+ */
33
+ protected $_options = null;
34
+
35
+
36
+ /**
37
+ * Retrieve font style options
38
+ *
39
+ * @return array
40
+ */
41
+ public function getOptions()
42
+ {
43
+ if ($this->_options === null) {
44
+ $helper = Mage::helper('adminhtml');
45
+
46
+ $this->_options = array(
47
+ self::TYPE_NONE => $helper->__('None'),
48
+ self::TYPE_SITE_LOGO => $helper->__('Site Logo'),
49
+ self::TYPE_THUMBNAIL => $helper->__('Category Thumbnail OR Logo'),
50
+ self::TYPE_IMAGE => $helper->__('Category Image OR Logo'),
51
+ );
52
+ }
53
+
54
+ return $this->_options;
55
+ }
56
+
57
+
58
+ /**
59
+ * Convert options into option array format with optional 'Please Select'
60
+ *
61
+ * @return array
62
+ */
63
+ public function toOptionArray($withEmpty = false)
64
+ {
65
+ $options = array();
66
+
67
+ foreach ($this->getOptions() as $value => $label) {
68
+ $options[] = array(
69
+ 'label' => $label,
70
+ 'value' => $value
71
+ );
72
+ }
73
+
74
+ if ($withEmpty) {
75
+ $label = Mage::helper('adminhtml')->__('-- Please Select --');
76
+ array_unshift($options, array('value' => '', 'label' => $label));
77
+ }
78
+
79
+ return $options;
80
+ }
81
+ }
app/code/community/Dreystone/PageThumbnail/Model/Source/Cms/Image.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Model_Source_Cms_Image
21
+ {
22
+ const TYPE_NONE = 'none';
23
+ const TYPE_SITE_LOGO = 'logo';
24
+
25
+
26
+ /**
27
+ * Default option array
28
+ *
29
+ * @var string
30
+ */
31
+ protected $_options = null;
32
+
33
+
34
+ /**
35
+ * Retrieve font style options
36
+ *
37
+ * @return array
38
+ */
39
+ public function getOptions()
40
+ {
41
+ if ($this->_options === null) {
42
+ $helper = Mage::helper('adminhtml');
43
+
44
+ $this->_options = array(
45
+ self::TYPE_NONE => $helper->__('None'),
46
+ self::TYPE_SITE_LOGO => $helper->__('Site Logo'),
47
+ );
48
+ }
49
+
50
+ return $this->_options;
51
+ }
52
+
53
+
54
+ /**
55
+ * Convert options into option array format with optional 'Please Select'
56
+ *
57
+ * @return array
58
+ */
59
+ public function toOptionArray($withEmpty = false)
60
+ {
61
+ $options = array();
62
+
63
+ foreach ($this->getOptions() as $value => $label) {
64
+ $options[] = array(
65
+ 'label' => $label,
66
+ 'value' => $value
67
+ );
68
+ }
69
+
70
+ if ($withEmpty) {
71
+ $label = Mage::helper('adminhtml')->__('-- Please Select --');
72
+ array_unshift($options, array('value' => '', 'label' => $label));
73
+ }
74
+
75
+ return $options;
76
+ }
77
+ }
app/code/community/Dreystone/PageThumbnail/Model/Source/Opengraph/Image.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dreystone Page Thumbnail Extension
4
+ *
5
+ * Do not edit or add to this file!! If you wish to customize this extension for
6
+ * your needs please contact us at: <magento@dreystone.com>.
7
+ *
8
+ * =============================================================================
9
+ * NOTICE OF LICENSE
10
+ * =============================================================================
11
+ * This source code is subject to the EULA at http://dreystone.com/license.
12
+ *
13
+ * @category Dreystone
14
+ * @package Dreystone_PageThumbnail
15
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * @author Dreystone Software <magento@dreystone.com>
18
+ */
19
+
20
+ class Dreystone_PageThumbnail_Model_Source_Opengraph_Image
21
+ {
22
+ const TYPE_NONE = 0;
23
+ const TYPE_NAME = 1;
24
+ const TYPE_PROPERTY = 2;
25
+
26
+
27
+ /**
28
+ * Default option array
29
+ *
30
+ * @var string
31
+ */
32
+ protected $_options = null;
33
+
34
+
35
+ /**
36
+ * Retrieve font style options
37
+ *
38
+ * @return array
39
+ */
40
+ public function getOptions()
41
+ {
42
+ if ($this->_options === null) {
43
+ $helper = Mage::helper('adminhtml');
44
+
45
+ $this->_options = array(
46
+ self::TYPE_NONE => $helper->__('Disabled'),
47
+ self::TYPE_NAME => $helper->__('As Meta Name'),
48
+ self::TYPE_PROPERTY => $helper->__('As Meta Property'),
49
+ );
50
+ }
51
+
52
+ return $this->_options;
53
+ }
54
+
55
+
56
+ /**
57
+ * Convert options into option array format with optional 'Please Select'
58
+ *
59
+ * @return array
60
+ */
61
+ public function toOptionArray($withEmpty = false)
62
+ {
63
+ $options = array();
64
+
65
+ foreach ($this->getOptions() as $value => $label) {
66
+ $options[] = array(
67
+ 'label' => $label,
68
+ 'value' => $value
69
+ );
70
+ }
71
+
72
+ if ($withEmpty) {
73
+ $label = Mage::helper('adminhtml')->__('-- Please Select --');
74
+ array_unshift($options, array('value' => '', 'label' => $label));
75
+ }
76
+
77
+ return $options;
78
+ }
79
+ }
app/code/community/Dreystone/PageThumbnail/etc/config.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Dreystone Page Thumbnail Extension
5
+ *
6
+ * Do not edit or add to this file!! If you wish to customize this extension for
7
+ * your needs please contact us at: <magento@dreystone.com>.
8
+ *
9
+ * =============================================================================
10
+ * NOTICE OF LICENSE
11
+ * =============================================================================
12
+ * This source code is subject to the EULA at http://dreystone.com/license.
13
+ *
14
+ * @category Dreystone
15
+ * @package Dreystone_PageThumbnail
16
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Dreystone Software <magento@dreystone.com>
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Dreystone_PageThumbnail>
24
+ <version>1.0.0</version>
25
+ </Dreystone_PageThumbnail>
26
+ </modules>
27
+ <global>
28
+ <blocks>
29
+ <dspagethumb>
30
+ <class>Dreystone_PageThumbnail_Block</class>
31
+ </dspagethumb>
32
+ </blocks>
33
+ <helpers>
34
+ <dspagethumb>
35
+ <class>Dreystone_PageThumbnail_Helper</class>
36
+ </dspagethumb>
37
+ </helpers>
38
+ <models>
39
+ <dspagethumb>
40
+ <class>Dreystone_PageThumbnail_Model</class>
41
+ </dspagethumb>
42
+ </models>
43
+ </global>
44
+ <frontend>
45
+ <layout>
46
+ <updates>
47
+ <dspagethumb>
48
+ <file>dreystone/pagethumb.xml</file>
49
+ </dspagethumb>
50
+ </updates>
51
+ </layout>
52
+ <events>
53
+ <catalog_controller_category_init_after>
54
+ <observers>
55
+ <dspagethumb>
56
+ <type>singleton</type>
57
+ <class>dspagethumb/observer</class>
58
+ <method>bindActiveCategory</method>
59
+ </dspagethumb>
60
+ </observers>
61
+ </catalog_controller_category_init_after>
62
+ <catalog_controller_product_init_after>
63
+ <observers>
64
+ <dspagethumb>
65
+ <type>singleton</type>
66
+ <class>dspagethumb/observer</class>
67
+ <method>bindActiveProduct</method>
68
+ </dspagethumb>
69
+ </observers>
70
+ </catalog_controller_product_init_after>
71
+ <cms_page_render>
72
+ <observers>
73
+ <dspagethumb>
74
+ <type>singleton</type>
75
+ <class>dspagethumb/observer</class>
76
+ <method>bindActiveCmsPage</method>
77
+ </dspagethumb>
78
+ </observers>
79
+ </cms_page_render>
80
+ </events>
81
+ </frontend>
82
+ <default>
83
+ <design>
84
+ <dspagethumb>
85
+ <active>0</active>
86
+ <include_og_image>0</include_og_image>
87
+ <category_option>logo</category_option>
88
+ <cms_option>logo</cms_option>
89
+ </dspagethumb>
90
+ </design>
91
+ </default>
92
+ </config>
app/code/community/Dreystone/PageThumbnail/etc/system.xml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Dreystone Page Thumbnail Extension
5
+ *
6
+ * Do not edit or add to this file!! If you wish to customize this extension for
7
+ * your needs please contact us at: <magento@dreystone.com>.
8
+ *
9
+ * =============================================================================
10
+ * NOTICE OF LICENSE
11
+ * =============================================================================
12
+ * This source code is subject to the EULA at http://dreystone.com/license.
13
+ *
14
+ * @category Dreystone
15
+ * @package Dreystone_PageThumbnail
16
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Dreystone Software <magento@dreystone.com>
19
+ */
20
+ -->
21
+ <config>
22
+ <sections>
23
+ <design>
24
+ <groups>
25
+ <dspagethumb translate="label" module="dspagethumb">
26
+ <label>Dreystone Page Thumbnail</label>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>600</sort_order>
29
+ <expanded>1</expanded>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>0</show_in_website>
32
+ <show_in_store>0</show_in_store>
33
+ <fields>
34
+ <active translate="label">
35
+ <label>Enabled</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </active>
43
+ <category_option translate="label">
44
+ <label>Category Image Option</label>
45
+ <frontend_type>select</frontend_type>
46
+ <source_model>dspagethumb/source_category_image</source_model>
47
+ <sort_order>100</sort_order>
48
+ <depends>
49
+ <active>1</active>
50
+ </depends>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <tooltip>Image and Thumbnail are category attributes</tooltip>
55
+ </category_option>
56
+ <cms_option translate="label">
57
+ <label>Cms Image Option</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>dspagethumb/source_cms_image</source_model>
60
+ <sort_order>110</sort_order>
61
+ <depends>
62
+ <active>1</active>
63
+ </depends>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </cms_option>
68
+ <include_og_image translate="label">
69
+ <label>Include OpenGraph Tag (Facebook)</label>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>dspagethumb/source_opengraph_image</source_model>
72
+ <sort_order>130</sort_order>
73
+ <depends>
74
+ <active>1</active>
75
+ </depends>
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
+ <tooltip>OpenGraph Meta Name is more compatible with HTML Validators, but Meta Property is recommended by Facebook</tooltip>
80
+ </include_og_image>
81
+
82
+ <heading_support translate="label">
83
+ <label>Support</label>
84
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
85
+ <sort_order>200</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
+ </heading_support>
90
+ <version translate="label">
91
+ <label>Product Version</label>
92
+ <frontend_type>note</frontend_type>
93
+ <frontend_model>dspagethumb/adminhtml_config_version</frontend_model>
94
+ <sort_order>210</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </version>
99
+ <copyright translate="label">
100
+ <label>Copyright</label>
101
+ <frontend_type>note</frontend_type>
102
+ <frontend_model>dspagethumb/adminhtml_config_copyright</frontend_model>
103
+ <sort_order>250</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
+ </copyright>
108
+ <support translate="label">
109
+ <label>Support Contact</label>
110
+ <frontend_type>note</frontend_type>
111
+ <frontend_model>dspagethumb/adminhtml_config_support</frontend_model>
112
+ <sort_order>260</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </support>
117
+ </fields>
118
+ </dspagethumb>
119
+ </groups>
120
+ </design>
121
+ </sections>
122
+ </config>
app/design/frontend/base/default/layout/dreystone/pagethumb.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Dreystone Page Thumbnail Extension
5
+ *
6
+ * Do not edit or add to this file!! If you wish to customize this extension for
7
+ * your needs please contact us at: <magento@dreystone.com>.
8
+ *
9
+ * =============================================================================
10
+ * NOTICE OF LICENSE
11
+ * =============================================================================
12
+ * This source code is subject to the EULA at http://dreystone.com/license.
13
+ *
14
+ * @category Dreystone
15
+ * @package Dreystone_PageThumbnail
16
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Dreystone Software <magento@dreystone.com>
19
+ */
20
+ -->
21
+ <layout version="0.1.0">
22
+ <default>
23
+ <reference name="head">
24
+ <block type="dspagethumb/link" name="ds.page.thumbnail.link" />
25
+ </reference>
26
+ </default>
27
+ </layout>
app/etc/modules/Dreystone_PageThumbnail.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Dreystone Page Thumbnail Extension
5
+ *
6
+ * Do not edit or add to this file!! If you wish to customize this extension for
7
+ * your needs please contact us at: <magento@dreystone.com>.
8
+ *
9
+ * =============================================================================
10
+ * NOTICE OF LICENSE
11
+ * =============================================================================
12
+ * This source code is subject to the EULA at http://dreystone.com/license.
13
+ *
14
+ * @category Dreystone
15
+ * @package Dreystone_PageThumbnail
16
+ * @copyright Copyright (c) 2014 Dreystone Software. (http://dreystone.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Dreystone Software <magento@dreystone.com>
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Dreystone_PageThumbnail>
24
+ <active>true</active>
25
+ <codePool>community</codePool>
26
+ <depends>
27
+ <Mage_Catalog />
28
+ <Mage_Cms />
29
+ <Mage_Page />
30
+ </depends>
31
+ </Dreystone_PageThumbnail>
32
+ </modules>
33
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>dreystone-page-thumbnail</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Dreystone Page Thumbnail Extension</summary>
10
+ <description>Adds HTML tags to pages for social media sites to identify the page image. Uses the main product image on Product pages, options for "Thumbnail", "Image" and "Site Logo" for category pages, and the "Site Logo" for CMS pages.&#xD;
11
+ &#xD;
12
+ Optional inclusion of the OpenGraph tags (Facebook) for the page image.</description>
13
+ <notes>Initial Release</notes>
14
+ <authors><author><name>Dreystone</name><user>Dreystone</user><email>magento@dreystone.com</email></author></authors>
15
+ <date>2014-01-26</date>
16
+ <time>06:54:55</time>
17
+ <contents><target name="magecommunity"><dir name="Dreystone"><dir name="PageThumbnail"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><file name="Copyright.php" hash="79b3e54510e14ce3d36ecd264b14bc86"/><file name="Support.php" hash="eddd16e420322f769c0d68072088fea0"/><file name="Version.php" hash="7af88653d18e2c514a43593503d272c0"/></dir></dir><file name="Link.php" hash="d22b9d2377979d42d95e270ff0295773"/></dir><dir name="Helper"><file name="Data.php" hash="70a9384369a03e06ba9a70775122b105"/></dir><dir name="Model"><file name="Observer.php" hash="93d4897d7f1a1a0f6c2c4c84bcc9a285"/><dir name="Source"><dir name="Category"><file name="Image.php" hash="0b6c300704296cec50aef522096c4ffa"/></dir><dir name="Cms"><file name="Image.php" hash="1fc4f47f393e64775ca9ebd1faeac318"/></dir><dir name="Opengraph"><file name="Image.php" hash="9cd725f4d27e1133253651406639832f"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="51a06f491954ad268605d8e79e368069"/><file name="system.xml" hash="d3e6b6b4c0f12903c6a3528b85771508"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="dreystone"><file name="pagethumb.xml" hash="ff5393ed3b59b6996c71ab69a535c01a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dreystone_PageThumbnail.xml" hash="b3d81dbee69cb25db2a49a666e89df24"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.13</min><max>5.3.24</max></php></required></dependencies>
20
+ </package>