Fishpigs_Attribute_Splash_Page - Version 3.3.7.3

Version Notes

Getting ready for the new FishPig SEO extension and adding support for the layered navigation features.

Download this release

Release Info

Developer fishpig
Extension Fishpigs_Attribute_Splash_Page
Version 3.3.7.3
Comparing to
See all releases


Version 3.3.7.3

Files changed (93) hide show
  1. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Dashboard.php +63 -0
  2. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Extend.php +12 -0
  3. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Form/Field/Urlkey.php +64 -0
  4. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group.php +21 -0
  5. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit.php +77 -0
  6. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Form.php +27 -0
  7. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Abstract.php +41 -0
  8. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Content.php +60 -0
  9. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Design.php +55 -0
  10. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/General.php +100 -0
  11. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Meta.php +50 -0
  12. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Seo.php +55 -0
  13. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tabs.php +38 -0
  14. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Grid.php +207 -0
  15. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page.php +21 -0
  16. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit.php +71 -0
  17. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Form.php +27 -0
  18. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Js.php +101 -0
  19. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Abstract.php +41 -0
  20. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Attributes.php +78 -0
  21. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Content.php +60 -0
  22. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Design.php +74 -0
  23. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/General.php +102 -0
  24. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Images.php +53 -0
  25. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Meta.php +50 -0
  26. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tabs.php +52 -0
  27. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Grid.php +218 -0
  28. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Helper/Image.php +24 -0
  29. app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Xmlsitemap.php +17 -0
  30. app/code/community/Fishpig/AttributeSplash/Block/Group/View.php +113 -0
  31. app/code/community/Fishpig/AttributeSplash/Block/Layer/View.php +38 -0
  32. app/code/community/Fishpig/AttributeSplash/Block/Page/View.php +132 -0
  33. app/code/community/Fishpig/AttributeSplash/Block/Page/View/Product/List.php +40 -0
  34. app/code/community/Fishpig/AttributeSplash/Controller/Router.php +202 -0
  35. app/code/community/Fishpig/AttributeSplash/FPAdmin/Block/Adminhtml/Extend.php +458 -0
  36. app/code/community/Fishpig/AttributeSplash/FPAdmin/etc/config.xml +114 -0
  37. app/code/community/Fishpig/AttributeSplash/FPAdmin/template/large.phtml +41 -0
  38. app/code/community/Fishpig/AttributeSplash/FPAdmin/template/small.phtml +39 -0
  39. app/code/community/Fishpig/AttributeSplash/Helper/Data.php +77 -0
  40. app/code/community/Fishpig/AttributeSplash/Helper/Image.php +354 -0
  41. app/code/community/Fishpig/AttributeSplash/Model/Abstract.php +225 -0
  42. app/code/community/Fishpig/AttributeSplash/Model/Group.php +133 -0
  43. app/code/community/Fishpig/AttributeSplash/Model/Indexer.php +62 -0
  44. app/code/community/Fishpig/AttributeSplash/Model/Layer.php +110 -0
  45. app/code/community/Fishpig/AttributeSplash/Model/Observer.php +169 -0
  46. app/code/community/Fishpig/AttributeSplash/Model/Page.php +142 -0
  47. app/code/community/Fishpig/AttributeSplash/Model/Resource/Abstract.php +252 -0
  48. app/code/community/Fishpig/AttributeSplash/Model/Resource/Collection/Abstract.php +129 -0
  49. app/code/community/Fishpig/AttributeSplash/Model/Resource/Group.php +122 -0
  50. app/code/community/Fishpig/AttributeSplash/Model/Resource/Group/Collection.php +51 -0
  51. app/code/community/Fishpig/AttributeSplash/Model/Resource/Page.php +320 -0
  52. app/code/community/Fishpig/AttributeSplash/Model/Resource/Page/Collection.php +111 -0
  53. app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Attribute/Abstract.php +103 -0
  54. app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Attribute/Splashable.php +31 -0
  55. app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Attribute/Splashed.php +30 -0
  56. app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Layout.php +22 -0
  57. app/code/community/Fishpig/AttributeSplash/controllers/Adminhtml/AttributeSplash/GroupController.php +128 -0
  58. app/code/community/Fishpig/AttributeSplash/controllers/Adminhtml/AttributeSplash/PageController.php +216 -0
  59. app/code/community/Fishpig/AttributeSplash/controllers/Adminhtml/AttributeSplashController.php +107 -0
  60. app/code/community/Fishpig/AttributeSplash/controllers/GroupController.php +107 -0
  61. app/code/community/Fishpig/AttributeSplash/controllers/PageController.php +132 -0
  62. app/code/community/Fishpig/AttributeSplash/controllers/SitemapController.php +37 -0
  63. app/code/community/Fishpig/AttributeSplash/etc/adminhtml.xml +46 -0
  64. app/code/community/Fishpig/AttributeSplash/etc/config.xml +159 -0
  65. app/code/community/Fishpig/AttributeSplash/etc/system.xml +120 -0
  66. app/code/community/Fishpig/AttributeSplash/license.txt +31 -0
  67. app/code/community/Fishpig/AttributeSplash/notes.txt +144 -0
  68. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-1.9.16-1.9.17.php +42 -0
  69. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-1.9.5-1.9.6.php +71 -0
  70. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.1-2.0.2.php +14 -0
  71. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.12-2.0.13.php +13 -0
  72. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.5-2.0.6.php +14 -0
  73. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.6-2.0.7.php +14 -0
  74. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.8-2.0.9.php +18 -0
  75. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.9-2.0.10.php +21 -0
  76. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.0.5-2.2.0.6.php +14 -0
  77. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.0.7-2.2.0.8.php +35 -0
  78. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.0.8-2.2.0.9.php +58 -0
  79. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.1.0-2.2.1.1.php +34 -0
  80. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.1.1-2.2.1.2.php +14 -0
  81. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.0.1.10-3.0.1.11.php +20 -0
  82. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.0.1.9-3.0.1.10.php +39 -0
  83. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.0.4.0-3.0.5.0.php +14 -0
  84. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.1.1.0-3.1.2.0.php +37 -0
  85. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.3.3.0-3.3.4.0.php +18 -0
  86. app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.3.6.2-3.3.6.3.php +13 -0
  87. app/design/adminhtml/default/default/layout/attribute-splash.xml +76 -0
  88. app/design/frontend/base/default/layout/attribute-splash.xml +44 -0
  89. app/design/frontend/base/default/template/attribute-splash/group/view.phtml +52 -0
  90. app/design/frontend/base/default/template/attribute-splash/page/view.phtml +39 -0
  91. app/etc/modules/Fishpig_AttributeSplash.xml +13 -0
  92. package.xml +18 -0
  93. skin/frontend/base/default/css/attribute-splash.css +70 -0
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Dashboard.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Dashboard extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->setId('splash_dashboard_tabs');
16
+ $this->setDestElementId('splash_tab_content');
17
+ $this->setTitle($this->__('Attribute Splash Pages'));
18
+ $this->setTemplate('widget/tabshoriz.phtml');
19
+ }
20
+
21
+ protected function _prepareLayout()
22
+ {
23
+ $tabs = array(
24
+ 'group' => 'Groups',
25
+ 'page' => 'Pages',
26
+ );
27
+
28
+ $_layout = $this->getLayout();
29
+
30
+ foreach($tabs as $alias => $label) {
31
+ $this->addTab($alias, array(
32
+ 'label' => Mage::helper('catalog')->__($label),
33
+ 'content' => $_layout->createBlock('attributeSplash/adminhtml_' . $alias)->toHtml(),
34
+ 'active' => $alias === 'page',
35
+ ));
36
+ }
37
+
38
+ Mage::dispatchEvent('attributesplash_dashboard_tabs_prepare_layout', array('tabs' => $this));
39
+
40
+ if (!isset($this->_tabs['xmlsitemap'])) {
41
+ $this->addTab('xmlsitemap', array(
42
+ 'label' => Mage::helper('catalog')->__('XML Sitemap'),
43
+ 'content' => $_layout->createBlock('attributeSplash/adminhtml_extend')
44
+ ->setTemplate('large.phtml')
45
+ ->setModule('Fishpig_AttributeSplash')
46
+ ->setMedium('XML Sitemap Tab')
47
+ ->setLimit(1)
48
+ ->setPreferred(array('Fishpig_AttributeSplash_Addon_XmlSitemap'))
49
+ ->toHtml(),
50
+ ));
51
+ }
52
+
53
+ if ($extend = $_layout->createBlock('attributeSplash/adminhtml_extend')) {
54
+ $extend->setNameInLayout('fishpig.extend')
55
+ ->setTabLabel($this->__('Add-Ons'))
56
+ ->setTabUrl('*/*/extend');
57
+
58
+ $this->addTab('extend', $extend);
59
+ }
60
+
61
+ return parent::_prepareLayout();
62
+ }
63
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Extend.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ // Include the FPAdmin Extend Block class
10
+ require_once(Mage::getModuleDir('', 'Fishpig_AttributeSplash') . DS . implode(DS, array('FPAdmin', 'Block', 'Adminhtml', 'Extend.php')));
11
+
12
+ class Fishpig_AttributeSplash_Block_Adminhtml_Extend extends Fishpig_FPAdmin_Block_Adminhtml_Extend {}
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Form/Field/Urlkey.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Form_Field_Urlkey extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ /**
12
+ * Retrieve the HTML for the element
13
+ *
14
+ * @param Varien_Data_Form_Element_Abstract $element
15
+ * @return string
16
+ */
17
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
18
+ {
19
+ if ($type = $this->getSplashType()) {
20
+ if (($object = Mage::registry('splash_' . $type)) !== null) {
21
+ $this->setSplashBaseUrl($object->getUrlBase());
22
+ $this->setUrlSuffix($object->getUrlSuffix());
23
+
24
+ return parent::_getElementHtml($element)
25
+ . $this->_getRouteJs($element);
26
+ }
27
+ }
28
+
29
+ return parent::_getElementHtml($element);
30
+ }
31
+
32
+ /**
33
+ * Retrieve the JS to display the route
34
+ *
35
+ * @param Varien_Data_Form_Element_Abstract $element
36
+ * @return string
37
+ */
38
+ protected function _getRouteJs($element)
39
+ {
40
+ return sprintf("
41
+ <script type=\"text/javascript\">
42
+ (function() {
43
+ var inp = $('%s');
44
+ var SPLASH_BASE_URL = '%s';
45
+ var URL_SUFFIX = '%s';
46
+
47
+ inp.insert({'after': new Element('p', {'class': 'note', 'id': inp.id + '-note'})});
48
+
49
+ var nt = $(inp.id + '-note');
50
+
51
+ inp.observe('blur', function(event) {
52
+ inp.setValue(inp.getValue().toLowerCase().replace(/([^a-z0-9\-\/]{1,})/, ''));
53
+ nt.innerHTML = SPLASH_BASE_URL + inp.getValue() + URL_SUFFIX;
54
+ });
55
+
56
+ setTimeout(function() {
57
+ inp.focus();
58
+ inp.blur();
59
+ }.bind(this), 1000);
60
+ })();
61
+ </script>
62
+ ", $element->getHtmlId(), $this->getSplashBaseUrl(), $this->getUrlSuffix());
63
+ }
64
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->_controller = 'adminhtml_group';
16
+ $this->_blockGroup = 'attributeSplash';
17
+ $this->_headerText = 'Splash: ' . $this->__('Groups');
18
+
19
+ $this->_removeButton('add');
20
+ }
21
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->_controller = 'adminhtml_group';
16
+ $this->_blockGroup = 'attributeSplash';
17
+ $this->_headerText = $this->_getHeaderText();
18
+
19
+ $this->_addButton('save_and_edit_button', array(
20
+ 'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
21
+ 'onclick' => 'editForm.submit(\''.$this->getSaveAndContinueUrl().'\')',
22
+ 'class' => 'save'
23
+ ));
24
+
25
+ if ($group = Mage::registry('splash_group')) {
26
+ if ($group->getId() && $group->canDelete()) {
27
+ # $this->_removeButton('delete');
28
+ }
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Retrieve the URL used for the save and continue link
34
+ * This is the same URL with the back parameter added
35
+ *
36
+ * @return string
37
+ */
38
+ public function getSaveAndContinueUrl()
39
+ {
40
+ return $this->getUrl('*/*/save', array(
41
+ '_current' => true,
42
+ 'back' => 'edit',
43
+ ));
44
+ }
45
+
46
+ /**
47
+ * Enable WYSIWYG editor
48
+ *
49
+ */
50
+ protected function _prepareLayout()
51
+ {
52
+ parent::_prepareLayout();
53
+
54
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
55
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
56
+ }
57
+
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Retrieve the header text
63
+ * If splash group exists, use name
64
+ *
65
+ * @return string
66
+ */
67
+ protected function _getHeaderText()
68
+ {
69
+ if ($group = Mage::registry('splash_group')) {
70
+ if ($displayName = $group->getDisplayName()) {
71
+ return $displayName;
72
+ }
73
+ }
74
+
75
+ return $this->__('Edit Attribute Splash Group');
76
+ }
77
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(
14
+ array(
15
+ 'id' => 'edit_form',
16
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
17
+ 'method' => 'post',
18
+ 'enctype' => 'multipart/form-data'
19
+ )
20
+ );
21
+
22
+ $form->setUseContainer(true);
23
+ $this->setForm($form);
24
+
25
+ return parent::_prepareForm();
26
+ }
27
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Abstract.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ abstract class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Abstract extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ /**
12
+ * Generate the form object
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ $form = new Varien_Data_Form();
19
+
20
+ $form->setHtmlIdPrefix('splash_');
21
+ $form->setFieldNameSuffix('splash');
22
+
23
+ $this->setForm($form);
24
+
25
+ return parent::_prepareForm();
26
+ }
27
+
28
+ /**
29
+ * Retrieve the data used for the form
30
+ *
31
+ * @return array
32
+ */
33
+ protected function _getFormData()
34
+ {
35
+ if ($page = Mage::registry('splash_group')) {
36
+ return $page->getData();
37
+ }
38
+
39
+ return array('is_enabled' => 1, 'store_id' => array(0));
40
+ }
41
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Content.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Content extends Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Prepare the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_group_content', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Content'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+ $htmlConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array(
26
+ 'add_widgets' => true,
27
+ 'add_variables' => true,
28
+ 'add_image' => true,
29
+ 'files_browser_window_url' => $this->getUrl('adminhtml/cms_wysiwyg_images/index')
30
+ ));
31
+
32
+ $fields = array(
33
+ 'short_description' => 'Short Description',
34
+ 'description' => 'Description',
35
+ );
36
+
37
+ foreach($fields as $field => $label) {
38
+ $fieldset->addField($field, 'editor', array(
39
+ 'name' => $field,
40
+ 'label' => $this->helper('adminhtml')->__($label),
41
+ 'title' => $this->helper('adminhtml')->__($label),
42
+ 'style' => 'width:100%; height:400px;',
43
+ 'config' => $htmlConfig,
44
+ ));
45
+ }
46
+
47
+ $this->getForm()->setValues($this->_getFormData());
48
+
49
+ return $this;
50
+ }
51
+
52
+ protected function _prepareLayout()
53
+ {
54
+ parent::_prepareLayout();
55
+
56
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
57
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
58
+ }
59
+ }
60
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Design.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Design extends Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Add the design elements to the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_design_menu', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Menu'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+ $fieldset->addField('include_in_menu', 'select', array(
26
+ 'name' => 'include_in_menu',
27
+ 'label' => $this->__('Include in Navigation Menu'),
28
+ 'title' => $this->__('Include in Navigation Menu'),
29
+ 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
30
+ ));
31
+
32
+ $fieldset = $this->getForm()->addFieldset('splash_design_group_layout', array(
33
+ 'legend'=> $this->helper('adminhtml')->__('Page Layout'),
34
+ 'class' => 'fieldset-wide',
35
+ ));
36
+
37
+ $fieldset->addField('page_layout', 'select', array(
38
+ 'name' => 'page_layout',
39
+ 'label' => $this->__('Page Layout'),
40
+ 'title' => $this->__('Page Layout'),
41
+ 'values' => Mage::getSingleton('attributeSplash/system_config_source_layout')->toOptionArray(),
42
+ ));
43
+
44
+ $fieldset->addField('layout_update_xml', 'editor', array(
45
+ 'name' => 'layout_update_xml',
46
+ 'label' => $this->__('Layout Update XML'),
47
+ 'title' => $this->__('Layout Update XML'),
48
+ 'style' => 'width:600px;',
49
+ ));
50
+
51
+ $this->getForm()->setValues($this->_getFormData());
52
+
53
+ return $this;
54
+ }
55
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/General.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_General extends Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Setup the form fields
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()
21
+ ->addFieldset('splash_page_information', array(
22
+ 'legend'=> $this->__('Page Information')
23
+ ));
24
+
25
+ $fieldset->addField('display_name', 'text', array(
26
+ 'name' => 'display_name',
27
+ 'label' => $this->__('Name'),
28
+ 'title' => $this->__('Name'),
29
+ 'required' => true,
30
+ 'class' => 'required-entry',
31
+ ));
32
+
33
+ $field = $fieldset->addField('url_key', 'text', array(
34
+ 'name' => 'url_key',
35
+ 'label' => $this->__('URL Key'),
36
+ 'title' => $this->__('URL Key'),
37
+ ));
38
+
39
+ $field->setRenderer(
40
+ $this->getLayout()->createBlock('attributeSplash/adminhtml_form_field_urlkey')
41
+ ->setSplashType('group')
42
+ );
43
+
44
+ $fieldset->addField('attribute_id', 'select', array(
45
+ 'name' => 'attribute_id',
46
+ 'label' => $this->__('Attribute'),
47
+ 'title' => $this->__('Attribute'),
48
+ 'values' => Mage::getSingleton('attributeSplash/system_config_source_attribute_splashable')->toOptionArray(true),
49
+ 'required' => true,
50
+ 'disabled' => !is_null(Mage::registry('splash_group')),
51
+ ));
52
+
53
+ $fieldset->addField('category_id', 'text', array(
54
+ 'name' => 'category_id',
55
+ 'label' => $this->__('Category ID'),
56
+ 'title' => $this->__('Category ID'),
57
+ 'note' => $this->__('Used to populate category filters in the layered navigation'),
58
+ ));
59
+
60
+ $group = Mage::registry('splash_group');
61
+
62
+
63
+ if (!Mage::app()->isSingleStoreMode() && (!$group || !$group->isGlobal())) {
64
+ $field = $fieldset->addField('store_ids', 'multiselect', array(
65
+ 'name' => 'store_ids[]',
66
+ 'label' => Mage::helper('cms')->__('Store View'),
67
+ 'title' => Mage::helper('cms')->__('Store View'),
68
+ 'required' => true,
69
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
70
+ ));
71
+
72
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
73
+
74
+ if ($renderer) {
75
+ $field->setRenderer($renderer);
76
+ }
77
+ }
78
+ else {
79
+ $fieldset->addField('store_ids_hidden', 'hidden', array(
80
+ 'name' => 'store_ids[]',
81
+ 'value' => Mage::app()->getStore()->getId(),
82
+ ));
83
+
84
+ if (($group = Mage::registry('splash_group')) !== null) {
85
+ $group->setStoreId(Mage::app()->getStore()->getId());
86
+ }
87
+ }
88
+
89
+ $fieldset->addField('is_enabled', 'select', array(
90
+ 'name' => 'is_enabled',
91
+ 'title' => $this->__('Enabled'),
92
+ 'label' => $this->__('Enabled'),
93
+ 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
94
+ ));
95
+
96
+ $this->getForm()->setValues($this->_getFormData());
97
+
98
+ return $this;
99
+ }
100
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Meta extends Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Add the meta fields to the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_page_meta', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Meta Data'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+
26
+ $fieldset->addField('page_title', 'text', array(
27
+ 'name' => 'page_title',
28
+ 'label' => $this->__('Page Title'),
29
+ 'title' => $this->__('Page Title'),
30
+ ));
31
+
32
+ $fieldset->addField('meta_description', 'editor', array(
33
+ 'name' => 'meta_description',
34
+ 'label' => $this->__('Description'),
35
+ 'title' => $this->__('Description'),
36
+ 'style' => 'width:98%; height:110px;',
37
+ ));
38
+
39
+ $fieldset->addField('meta_keywords', 'editor', array(
40
+ 'name' => 'meta_keywords',
41
+ 'label' => $this->__('Keywords'),
42
+ 'title' => $this->__('Keywords'),
43
+ 'style' => 'width:98%; height:110px;',
44
+ ));
45
+
46
+ $this->getForm()->setValues($this->_getFormData());
47
+
48
+ return $this;
49
+ }
50
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tab/Seo.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tab_Seo extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form();
14
+
15
+ $form->setHtmlIdPrefix('splash_');
16
+ $form->setFieldNameSuffix('splash');
17
+
18
+ $this->setForm($form);
19
+
20
+ $fieldset = $form->addFieldset('splash_seo', array('legend'=> $this->__('Search Engine Optimizations')));
21
+
22
+ $fieldset->addField('url_key', 'text', array(
23
+ 'name' => 'url_key',
24
+ 'label' => $this->__('URL Key'),
25
+ 'title' => $this->__('URL Key'),
26
+ 'note' => $this->__('If left empty the URL key will be automatically generated based on the name field'),
27
+ ));
28
+
29
+ $fieldset->addField('page_title', 'text', array(
30
+ 'name' => 'page_title',
31
+ 'label' => $this->__('Page Title'),
32
+ 'title' => $this->__('Page Title'),
33
+ ));
34
+
35
+ $fieldset->addField('meta_description', 'editor', array(
36
+ 'name' => 'meta_description',
37
+ 'label' => $this->__('Meta Description'),
38
+ 'title' => $this->__('Meta Description'),
39
+ 'style' => 'width:98%; height:110px;',
40
+ ));
41
+
42
+ $fieldset->addField('meta_keywords', 'editor', array(
43
+ 'name' => 'meta_keywords',
44
+ 'label' => $this->__('Meta Keywords'),
45
+ 'title' => $this->__('Meta Keywords'),
46
+ 'style' => 'width:98%; height:110px;',
47
+ ));
48
+
49
+ if ($splashGroup = Mage::registry('splash_group')) {
50
+ $form->setValues($splashGroup->getData());
51
+ }
52
+
53
+ return parent::_prepareForm();
54
+ }
55
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Edit/Tabs.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setId('splash_group_tabs');
15
+ $this->setDestElementId('edit_form');
16
+ $this->setTitle($this->__('Splash Group Information'));
17
+ }
18
+
19
+ protected function _beforeToHtml()
20
+ {
21
+ $tabs = array(
22
+ 'general' => 'Page Information',
23
+ 'content' => 'Content',
24
+ 'design' => 'Design',
25
+ 'meta' => 'Meta Data',
26
+ );
27
+
28
+ foreach($tabs as $alias => $label) {
29
+ $this->addTab($alias, array(
30
+ 'label' => $this->__($label),
31
+ 'title' => $this->__($label),
32
+ 'content' => $this->getLayout()->createBlock('attributeSplash/adminhtml_group_edit_tab_' . $alias)->toHtml(),
33
+ ));
34
+ }
35
+
36
+ return parent::_beforeToHtml();
37
+ }
38
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Group/Grid.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Group_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->setId('splash_group_grid');
16
+ $this->setDefaultSort('group_id');
17
+ $this->setDefaultDir('asc');
18
+ $this->setSaveParametersInSession(false);
19
+ $this->setUseAjax(true);
20
+ }
21
+
22
+ /**
23
+ * Insert the Add New button
24
+ *
25
+ * @return $this
26
+ */
27
+ protected function _prepareLayout()
28
+ {
29
+ $this->setChild('add_button',
30
+ $this->getLayout()->createBlock('adminhtml/widget_button')
31
+ ->setData(array(
32
+ 'label' => Mage::helper('adminhtml')->__('Add New Group'),
33
+ 'class' => 'add',
34
+ 'onclick' => "setLocation('" . $this->getUrl('*/attributeSplash_group/new') . "');",
35
+ ))
36
+ );
37
+
38
+ return parent::_prepareLayout();
39
+ }
40
+
41
+ /**
42
+ * Retrieve the main buttons html
43
+ *
44
+ * @return string
45
+ */
46
+ public function getMainButtonsHtml()
47
+ {
48
+ return parent::getMainButtonsHtml()
49
+ . $this->getChildHtml('add_button');
50
+ }
51
+
52
+ /**
53
+ * Initialise and set the collection for the grid
54
+ *
55
+ * @return $this
56
+ */
57
+ protected function _prepareCollection()
58
+ {
59
+ $this->setCollection(
60
+ Mage::getResourceModel('attributeSplash/group_collection')
61
+ );
62
+
63
+ return parent::_prepareCollection();
64
+ }
65
+
66
+ /**
67
+ * Add store information to pages
68
+ *
69
+ * @return $this
70
+ */
71
+ protected function _afterLoadCollection()
72
+ {
73
+ $this->getCollection()->walk('afterLoad');
74
+
75
+ parent::_afterLoadCollection();
76
+ }
77
+
78
+ /**
79
+ * Apply the store filter
80
+ *
81
+ * @param $collection
82
+ * @param $column
83
+ * @return void
84
+ */
85
+ protected function _filterStoreCondition($collection, $column)
86
+ {
87
+ if (!$value = $column->getFilter()->getValue()) {
88
+ return;
89
+ }
90
+
91
+ $this->getCollection()->addStoreFilter($value);
92
+ }
93
+
94
+ /**
95
+ * Add the columns to the grid
96
+ *
97
+ */
98
+ protected function _prepareColumns()
99
+ {
100
+ $this->addColumn('group_id', array(
101
+ 'header' => $this->__('ID'),
102
+ 'align' => 'right',
103
+ 'width' => 1,
104
+ 'index' => 'group_id',
105
+ ));
106
+
107
+ $this->addColumn('attribute_id', array(
108
+ 'header' => $this->__('Attribute'),
109
+ 'align' => 'left',
110
+ 'index' => 'attribute_id',
111
+ 'filter_index' => '_attribute_table.attribute_code',
112
+ 'type' => 'options',
113
+ 'options' => Mage::getSingleton('attributeSplash/system_config_source_attribute_splashed')->setLabelField('attribute_code')->toOptionHash(),
114
+ ));
115
+
116
+ $this->addColumn('display_name', array(
117
+ 'header' => $this->__('Name'),
118
+ 'align' => 'left',
119
+ 'index' => 'display_name',
120
+ ));
121
+
122
+ $this->addColumn('url_key', array(
123
+ 'header' => $this->__('URL Key'),
124
+ 'align' => 'left',
125
+ 'index' => 'url_key',
126
+ ));
127
+
128
+ $this->addColumn('include_in_menu', array(
129
+ 'header' => $this->__('Include in Menu'),
130
+ 'align' => 'left',
131
+ 'index' => 'include_in_menu',
132
+ 'type' => 'options',
133
+ 'options' => array(
134
+ 1 => $this->__('Enabled'),
135
+ 0 => $this->__('Disabled'),
136
+ ),
137
+ ));
138
+
139
+ if (!Mage::app()->isSingleStoreMode()) {
140
+ $this->addColumn('store_ids', array(
141
+ 'header' => $this->__('Store'),
142
+ 'align' => 'left',
143
+ 'index' => 'store_ids',
144
+ 'type' => 'store',
145
+ 'store_all' => true,
146
+ 'store_view' => true,
147
+ 'sortable' => false,
148
+ 'filter_condition_callback' => array($this, '_filterStoreCondition'),
149
+ 'options' => $this->getStores(),
150
+ ));
151
+ }
152
+
153
+ $this->addColumn('action', array(
154
+ 'type' => 'action',
155
+ 'getter' => 'getId',
156
+ 'actions' => array(
157
+ array(
158
+ 'caption' => Mage::helper('catalog')->__('Edit'),
159
+ 'url' => array(
160
+ 'base'=>'*/attributeSplash_group/edit',
161
+ ),
162
+ 'field' => 'id'
163
+ )),
164
+ 'filter' => false,
165
+ 'sortable' => false,
166
+ 'align' => 'center',
167
+ ));
168
+
169
+ return parent::_prepareColumns();
170
+ }
171
+
172
+ /**
173
+ * Retrieve the URL used to modify the grid via AJAX
174
+ *
175
+ * @return string
176
+ */
177
+ public function getGridUrl()
178
+ {
179
+ return $this->getUrl('*/*/groupGrid');
180
+ }
181
+
182
+ /**
183
+ * Retrieve the URL for the row
184
+ *
185
+ */
186
+ public function getRowUrl($row)
187
+ {
188
+ return $this->getUrl('*/attributeSplash_group/edit', array('id' => $row->getId()));
189
+ }
190
+
191
+ /**
192
+ * Retrieve an array of all of the stores
193
+ *
194
+ * @return array
195
+ */
196
+ protected function getStores()
197
+ {
198
+ $options = array(0 => $this->__('Global'));
199
+ $stores = Mage::getResourceModel('core/store_collection')->load();
200
+
201
+ foreach($stores as $store) {
202
+ $options[$store->getId()] = $store->getWebsite()->getName() . ' &gt; ' . $store->getName();
203
+ }
204
+
205
+ return $options;
206
+ }
207
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->_controller = 'adminhtml_page';
16
+ $this->_blockGroup = 'attributeSplash';
17
+ $this->_headerText = 'Splash: ' . $this->__('Pages');
18
+
19
+ $this->_removeButton('add');
20
+ }
21
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->_controller = 'adminhtml_page';
16
+ $this->_blockGroup = 'attributeSplash';
17
+ $this->_headerText = $this->_getHeaderText();
18
+
19
+ $this->_addButton('save_and_edit_button', array(
20
+ 'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
21
+ 'onclick' => 'editForm.submit(\''.$this->getSaveAndContinueUrl().'\')',
22
+ 'class' => 'save'
23
+ ));
24
+ }
25
+
26
+ /**
27
+ * Retrieve the URL used for the save and continue link
28
+ * This is the same URL with the back parameter added
29
+ *
30
+ * @return string
31
+ */
32
+ public function getSaveAndContinueUrl()
33
+ {
34
+ return $this->getUrl('*/*/save', array(
35
+ '_current' => true,
36
+ 'back' => 'edit',
37
+ ));
38
+ }
39
+
40
+ /**
41
+ * Enable WYSIWYG editor
42
+ *
43
+ */
44
+ protected function _prepareLayout()
45
+ {
46
+ parent::_prepareLayout();
47
+
48
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
49
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
50
+ }
51
+
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Retrieve the header text
57
+ * If splash page exists, use name
58
+ *
59
+ * @return string
60
+ */
61
+ protected function _getHeaderText()
62
+ {
63
+ if ($page = Mage::registry('splash_page')) {
64
+ if ($displayName = $page->getDisplayName()) {
65
+ return $displayName;
66
+ }
67
+ }
68
+
69
+ return $this->__('Edit Attribute Splash Page');
70
+ }
71
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(
14
+ array(
15
+ 'id' => 'edit_form',
16
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
17
+ 'method' => 'post',
18
+ 'enctype' => 'multipart/form-data'
19
+ )
20
+ );
21
+
22
+ $form->setUseContainer(true);
23
+ $this->setForm($form);
24
+
25
+ return parent::_prepareForm();
26
+ }
27
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Js.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Js extends Mage_Core_Block_Text
10
+ {
11
+ /**
12
+ * Add the JS
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareLayout()
17
+ {
18
+ $this->setText(sprintf("
19
+ <script type=\"text/javascript\">
20
+ //<![CDATA[
21
+ (function() {
22
+ var create = {
23
+ go: function() {
24
+ this.attr = $('splash_attribute_id');
25
+ this.opt = $('splash_option_id');
26
+
27
+ if (!this.attr || !this.opt) {
28
+ throw 'Missing required input fields';
29
+ }
30
+
31
+ this.name = $('splash_display_name');
32
+
33
+ this.options = new Array();
34
+ this.onAttributeChange();
35
+
36
+ this.attr.observe('change', this.onAttributeChange.bindAsEventListener(this));
37
+
38
+ this.opt.observe('change', this.onOptionChange.bindAsEventListener(this));
39
+ },
40
+ hasOptions: function() {
41
+ return typeof this.options[this.attr.getValue()] !== 'undefined';
42
+ },
43
+ updateOptions: function() {
44
+ this.opt.options = null;
45
+
46
+ this.opt.options[0] = new Option('%s', '');
47
+
48
+ this.options[this.attr.getValue()].each(function(elem, ind) {
49
+ this.opt.options[ind+1] = new Option(elem.label, elem.value);
50
+ }.bind(this));
51
+ },
52
+ getOptions: function() {
53
+ new Ajax.Request('%s?attribute=' + this.attr.getValue(), {
54
+ onSuccess: function(transport) {
55
+ var json = transport.responseText.evalJSON();
56
+
57
+ if (json.error) {
58
+ throw json.error;
59
+ }
60
+
61
+ this.options[this.attr.getValue()] = new Array();
62
+
63
+ json.options.each(function(elem, ind) {
64
+ this.options[this.attr.getValue()].push({'value': elem.value, 'label': elem.label});
65
+ }.bind(this));
66
+
67
+ this.updateOptions();
68
+ }.bind(this)
69
+ });
70
+ },
71
+ onAttributeChange: function() {
72
+ if (this.hasOptions()) {
73
+ this.updateOptions();
74
+ }
75
+ else {
76
+ this.getOptions();
77
+ }
78
+ },
79
+ onOptionChange: function() {
80
+ if (this.opt.getValue()) {
81
+ if (this.name.getValue() === '') {
82
+ this.name.setValue(this.opt.options[this.opt.selectedIndex].label);
83
+ }
84
+ }
85
+ }
86
+ };
87
+
88
+ try {
89
+ return create.go();
90
+ }
91
+ catch (e) {
92
+ alert(e);
93
+ }
94
+ })();
95
+ //]]>
96
+ </script>
97
+ ", Mage::helper('adminhtml')->__('-- Please Select --'), Mage::getModel('adminhtml/url')->getUrl('*/*/options')));
98
+
99
+ return parent::_prepareLayout();
100
+ }
101
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Abstract.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ abstract class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ /**
12
+ * Generate the form object
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ $form = new Varien_Data_Form();
19
+
20
+ $form->setHtmlIdPrefix('splash_');
21
+ $form->setFieldNameSuffix('splash');
22
+
23
+ $this->setForm($form);
24
+
25
+ return parent::_prepareForm();
26
+ }
27
+
28
+ /**
29
+ * Retrieve the data used for the form
30
+ *
31
+ * @return array
32
+ */
33
+ protected function _getFormData()
34
+ {
35
+ if ($page = Mage::registry('splash_page')) {
36
+ return $page->getData();
37
+ }
38
+
39
+ return array('is_enabled' => 1, 'store_ids' => array(0), 'include_in_menu' => 1);
40
+ }
41
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Attributes.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Attributes extends Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Add the design elements to the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_attributes', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Attributes'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+ $page = Mage::registry('splash_page');
26
+
27
+ $fieldset->addField('attribute_id', 'select', array(
28
+ 'name' => 'attribute_id',
29
+ 'label' => $this->__('Attribute'),
30
+ 'title' => $this->__('Attribute'),
31
+ 'values' => Mage::getSingleton('attributeSplash/system_config_source_attribute_splashable')->toOptionArray(true),
32
+ 'required' => true,
33
+ 'disabled' => !is_null($page),
34
+ ));
35
+
36
+ $fieldset->addField('option_id', 'select', array(
37
+ 'name' => 'option_id',
38
+ 'label' => $this->__('Option'),
39
+ 'title' => $this->__('Option'),
40
+ 'values' => $this->_getPageOptionValues($page),
41
+ 'required' => true,
42
+ 'disabled' => !is_null($page),
43
+ ));
44
+
45
+ $this->getForm()->setValues($this->_getFormData());
46
+
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Retrieve the option values for the page
52
+ *
53
+ * @param Fishpig_AttributeSplash_Model_Page $page = null
54
+ * @return array
55
+ */
56
+ protected function _getPageOptionValues($page = null)
57
+ {
58
+ if (is_null($page)) {
59
+ return array();
60
+ }
61
+
62
+ $option = Mage::getResourceModel('eav/entity_attribute_option_collection')
63
+ ->setStoreFilter($page->getStoreId())
64
+ ->addFieldToFilter('main_table.option_id', $page->getOptionId())
65
+ ->setPageSize(1)
66
+ ->load()
67
+ ->getFirstItem();
68
+
69
+ if (!$option->getId()) {
70
+ return array();
71
+ }
72
+
73
+ return array(array(
74
+ 'value' => $page->getOptionId(),
75
+ 'label' => $option->getValue(),
76
+ ));
77
+ }
78
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Content.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Content extends Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Prepare the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_page_content', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Content'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+ $htmlConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array(
26
+ 'add_widgets' => true,
27
+ 'add_variables' => true,
28
+ 'add_image' => true,
29
+ 'files_browser_window_url' => $this->getUrl('adminhtml/cms_wysiwyg_images/index')
30
+ ));
31
+
32
+ $fields = array(
33
+ 'short_description' => 'Short Description',
34
+ 'description' => 'Description',
35
+ );
36
+
37
+ foreach($fields as $field => $label) {
38
+ $fieldset->addField($field, 'editor', array(
39
+ 'name' => $field,
40
+ 'label' => $this->helper('adminhtml')->__($label),
41
+ 'title' => $this->helper('adminhtml')->__($label),
42
+ 'style' => 'width:100%; height:400px;',
43
+ 'config' => $htmlConfig,
44
+ ));
45
+ }
46
+
47
+ $this->getForm()->setValues($this->_getFormData());
48
+
49
+ return $this;
50
+ }
51
+
52
+ protected function _prepareLayout()
53
+ {
54
+ parent::_prepareLayout();
55
+
56
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
57
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
58
+ }
59
+ }
60
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Design.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Design extends Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Add the design elements to the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_design_menu', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Menu'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+ $fieldset->addField('include_in_menu', 'select', array(
26
+ 'name' => 'include_in_menu',
27
+ 'label' => $this->__('Include in Navigation Menu'),
28
+ 'title' => $this->__('Include in Navigation Menu'),
29
+ 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
30
+ ));
31
+
32
+ $fieldset = $this->getForm()->addFieldset('splash_design_page_layout', array(
33
+ 'legend'=> $this->helper('adminhtml')->__('Page Layout'),
34
+ 'class' => 'fieldset-wide',
35
+ ));
36
+
37
+ $fieldset->addField('page_layout', 'select', array(
38
+ 'name' => 'page_layout',
39
+ 'label' => $this->__('Page Layout'),
40
+ 'title' => $this->__('Page Layout'),
41
+ 'values' => Mage::getSingleton('attributeSplash/system_config_source_layout')->toOptionArray(),
42
+ ));
43
+
44
+ $fieldset->addField('layout_update_xml', 'editor', array(
45
+ 'name' => 'layout_update_xml',
46
+ 'label' => $this->__('Layout Update XML'),
47
+ 'title' => $this->__('Layout Update XML'),
48
+ 'style' => 'width:600px;',
49
+ ));
50
+
51
+ $fieldset = $this->getForm()->addFieldset('splash_design_display_settings', array(
52
+ 'legend'=> $this->helper('adminhtml')->__('Display Settings'),
53
+ 'class' => 'fieldset-wide',
54
+ ));
55
+
56
+ $fieldset->addField('display_mode', 'select', array(
57
+ 'name' => 'display_mode',
58
+ 'label' => $this->__('Display Mode'),
59
+ 'title' => $this->__('Display Mode'),
60
+ 'values' => Mage::getModel('catalog/category_attribute_source_mode')->getAllOptions(),
61
+ ));
62
+
63
+ $fieldset->addField('cms_block', 'select', array(
64
+ 'name' => 'cms_block',
65
+ 'label' => $this->__('CMS Block'),
66
+ 'title' => $this->__('CMS Block'),
67
+ 'values' => Mage::getModel('catalog/category_attribute_source_page')->getAllOptions(),
68
+ ));
69
+
70
+ $this->getForm()->setValues($this->_getFormData());
71
+
72
+ return $this;
73
+ }
74
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/General.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_General extends Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Setup the form fields
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()
21
+ ->addFieldset('splash_page_information', array(
22
+ 'legend'=> $this->__('Page Information')
23
+ ));
24
+
25
+ $fieldset->addField('display_name', 'text', array(
26
+ 'name' => 'display_name',
27
+ 'label' => $this->__('Name'),
28
+ 'title' => $this->__('Name'),
29
+ 'required' => true,
30
+ 'class' => 'required-entry',
31
+ ));
32
+
33
+ $field = $fieldset->addField('url_key', 'text', array(
34
+ 'name' => 'url_key',
35
+ 'label' => $this->__('URL Key'),
36
+ 'title' => $this->__('URL Key'),
37
+ ));
38
+
39
+ $field->setRenderer(
40
+ $this->getLayout()->createBlock('attributeSplash/adminhtml_form_field_urlkey')
41
+ ->setSplashType('page')
42
+ );
43
+
44
+ if ($page = Mage::registry('splash_page')) {
45
+ $fieldset->addField('attribute_id', 'hidden', array(
46
+ 'name' => 'attribute_id',
47
+ 'value' => $page->getAttributeId(),
48
+ ));
49
+
50
+ $fieldset->addField('option_id', 'hidden', array(
51
+ 'name' => 'option_id',
52
+ 'value' => $page->getOptionId(),
53
+ ));
54
+ }
55
+
56
+ $fieldset->addField('category_id', 'text', array(
57
+ 'name' => 'category_id',
58
+ 'label' => $this->__('Category ID'),
59
+ 'title' => $this->__('Category ID'),
60
+ 'note' => $this->__('Used to populate category filters in the layered navigation'),
61
+ ));
62
+
63
+ if (!Mage::app()->isSingleStoreMode()) {
64
+ $field = $fieldset->addField('store_ids', 'multiselect', array(
65
+ 'name' => 'store_ids[]',
66
+ 'label' => Mage::helper('cms')->__('Store View'),
67
+ 'title' => Mage::helper('cms')->__('Store View'),
68
+ 'required' => true,
69
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
70
+ ));
71
+
72
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
73
+
74
+ if ($renderer) {
75
+ $field->setRenderer($renderer);
76
+ }
77
+ }
78
+ else {
79
+ if (($page = Mage::registry('splash_page')) !== null) {
80
+ $page->setStoreId(Mage::app()->getStore()->getId());
81
+ }
82
+ }
83
+
84
+ $fieldset->addField('is_enabled', 'select', array(
85
+ 'name' => 'is_enabled',
86
+ 'title' => $this->__('Enabled'),
87
+ 'label' => $this->__('Enabled'),
88
+ 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
89
+ ));
90
+
91
+ $fieldset->addField('is_featured', 'select', array(
92
+ 'name' => 'is_featured',
93
+ 'title' => $this->__('Featured'),
94
+ 'label' => $this->__('Featured'),
95
+ 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
96
+ ));
97
+
98
+ $this->getForm()->setValues($this->_getFormData());
99
+
100
+ return $this;
101
+ }
102
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Images.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Images extends Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Retrieve Additional Element Types
13
+ *
14
+ * @return array
15
+ */
16
+ protected function _getAdditionalElementTypes()
17
+ {
18
+ return array(
19
+ 'image' => Mage::getConfig()->getBlockClassName('attributeSplash/adminhtml_page_helper_image')
20
+ );
21
+ }
22
+
23
+ /**
24
+ * Setup the form fields
25
+ *
26
+ * @return $this
27
+ */
28
+ protected function _prepareForm()
29
+ {
30
+ parent::_prepareForm();
31
+
32
+ $fieldset = $this->getForm()
33
+ ->addFieldset('splash_image', array('legend'=> $this->__('Images')));
34
+
35
+ $this->_addElementTypes($fieldset);
36
+
37
+ $fieldset->addField('image', 'image', array(
38
+ 'name' => 'image',
39
+ 'label' => $this->__('Banner'),
40
+ 'title' => $this->__('Banner'),
41
+ ));
42
+
43
+ $fieldset->addField('thumbnail', 'image', array(
44
+ 'name' => 'thumbnail',
45
+ 'label' => $this->__('Logo'),
46
+ 'title' => $this->__('Logo'),
47
+ ));
48
+
49
+ $this->getForm()->setValues($this->_getFormData());
50
+
51
+ return $this;
52
+ }
53
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Meta extends Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Add the meta fields to the form
13
+ *
14
+ * @return $this
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+
20
+ $fieldset = $this->getForm()->addFieldset('splash_page_meta', array(
21
+ 'legend'=> $this->helper('adminhtml')->__('Meta Data'),
22
+ 'class' => 'fieldset-wide',
23
+ ));
24
+
25
+
26
+ $fieldset->addField('page_title', 'text', array(
27
+ 'name' => 'page_title',
28
+ 'label' => $this->__('Page Title'),
29
+ 'title' => $this->__('Page Title'),
30
+ ));
31
+
32
+ $fieldset->addField('meta_description', 'editor', array(
33
+ 'name' => 'meta_description',
34
+ 'label' => $this->__('Description'),
35
+ 'title' => $this->__('Description'),
36
+ 'style' => 'width:98%; height:110px;',
37
+ ));
38
+
39
+ $fieldset->addField('meta_keywords', 'editor', array(
40
+ 'name' => 'meta_keywords',
41
+ 'label' => $this->__('Keywords'),
42
+ 'title' => $this->__('Keywords'),
43
+ 'style' => 'width:98%; height:110px;',
44
+ ));
45
+
46
+ $this->getForm()->setValues($this->_getFormData());
47
+
48
+ return $this;
49
+ }
50
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Edit/Tabs.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+ /**
12
+ * Init the tabs block
13
+ *
14
+ * @return void
15
+ */
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+ $this->setId('splash_page_tabs');
20
+ $this->setDestElementId('edit_form');
21
+ $this->setTitle($this->__('Splash Page Information'));
22
+ }
23
+
24
+ /**
25
+ * Add tabs to the block
26
+ *
27
+ * @return $this
28
+ */
29
+ protected function _beforeToHtml()
30
+ {
31
+ $tabs = array(
32
+ 'general' => 'Page Information',
33
+ 'attributes' => 'Attributes',
34
+ 'content' => 'Content',
35
+ 'images' => 'Images',
36
+ 'design' => 'Design',
37
+ 'meta' => 'Meta Data',
38
+ );
39
+
40
+ foreach($tabs as $alias => $label) {
41
+ $this->addTab($alias, array(
42
+ 'label' => $this->__($label),
43
+ 'title' => $this->__($label),
44
+ 'content' => $this->getLayout()->createBlock('attributeSplash/adminhtml_page_edit_tab_' . $alias)->toHtml(),
45
+ ));
46
+ }
47
+
48
+ Mage::dispatchEvent('attributesplash_adminhtml_page_edit_tabs', array('tabs' => $this));
49
+
50
+ return parent::_beforeToHtml();
51
+ }
52
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Grid.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->setId('splash_page_grid');
16
+ $this->setDefaultSort('page_id');
17
+ $this->setDefaultDir('asc');
18
+ $this->setSaveParametersInSession(false);
19
+ $this->setUseAjax(true);
20
+ }
21
+
22
+ /**
23
+ * Insert the Add New button
24
+ *
25
+ * @return $this
26
+ */
27
+ protected function _prepareLayout()
28
+ {
29
+ $this->setChild('add_button',
30
+ $this->getLayout()->createBlock('adminhtml/widget_button')
31
+ ->setData(array(
32
+ 'label' => Mage::helper('adminhtml')->__('Add New Page'),
33
+ 'class' => 'add',
34
+ 'onclick' => "setLocation('" . $this->getUrl('*/attributeSplash_page/new') . "');",
35
+ ))
36
+ );
37
+
38
+ return parent::_prepareLayout();
39
+ }
40
+
41
+ /**
42
+ * Retrieve the main buttons html
43
+ *
44
+ * @return string
45
+ */
46
+ public function getMainButtonsHtml()
47
+ {
48
+ return parent::getMainButtonsHtml()
49
+ . $this->getChildHtml('add_button');
50
+ }
51
+
52
+ /**
53
+ * Initialise and set the collection for the grid
54
+ *
55
+ */
56
+ protected function _prepareCollection()
57
+ {
58
+ $this->setCollection(
59
+ Mage::getResourceModel('attributeSplash/page_collection')
60
+ );
61
+
62
+ return parent::_prepareCollection();
63
+ }
64
+
65
+ /**
66
+ * Add store information to pages
67
+ *
68
+ * @return $this
69
+ */
70
+ protected function _afterLoadCollection()
71
+ {
72
+ $this->getCollection()->walk('afterLoad');
73
+
74
+ parent::_afterLoadCollection();
75
+ }
76
+
77
+ /**
78
+ * Apply the store filter
79
+ *
80
+ * @param $collection
81
+ * @param $column
82
+ * @return void
83
+ */
84
+ protected function _filterStoreCondition($collection, $column)
85
+ {
86
+ if (!$value = $column->getFilter()->getValue()) {
87
+ return;
88
+ }
89
+
90
+ $this->getCollection()->addStoreFilter($value);
91
+ }
92
+
93
+ /**
94
+ * Add the columns to the grid
95
+ *
96
+ */
97
+ protected function _prepareColumns()
98
+ {
99
+ $this->addColumn('page_id', array(
100
+ 'header' => $this->__('ID'),
101
+ 'align' => 'right',
102
+ 'width' => 1,
103
+ 'index' => 'page_id',
104
+ ));
105
+
106
+ $this->addColumn('attribute_id', array(
107
+ 'header' => $this->__('Attribute'),
108
+ 'align' => 'left',
109
+ 'index' => 'attribute_id',
110
+ 'filter_index' => '_attribute_table.attribute_id',
111
+ 'type' => 'options',
112
+ 'options' => Mage::getSingleton('attributeSplash/system_config_source_attribute_splashed')->setLabelField('attribute_code')->toOptionHash(),
113
+ ));
114
+
115
+ $this->addColumn('display_name', array(
116
+ 'header' => $this->__('Name'),
117
+ 'align' => 'left',
118
+ 'index' => 'display_name',
119
+ ));
120
+
121
+ $this->addColumn('url_key', array(
122
+ 'header' => $this->__('URL Key'),
123
+ 'align' => 'left',
124
+ 'index' => 'url_key',
125
+ ));
126
+
127
+ if (!Mage::app()->isSingleStoreMode()) {
128
+ $this->addColumn('store_ids', array(
129
+ 'header' => $this->__('Store'),
130
+ 'align' => 'left',
131
+ 'index' => 'store_ids',
132
+ 'type' => 'store',
133
+ 'store_all' => true,
134
+ 'store_view' => true,
135
+ 'sortable' => false,
136
+ 'filter_condition_callback' => array($this, '_filterStoreCondition'),
137
+ 'options' => $this->getStores(),
138
+ ));
139
+ }
140
+
141
+
142
+ $this->addColumn('is_enabled', array(
143
+ 'width' => 1,
144
+ 'header' => $this->__('Enabled'),
145
+ 'index' => 'is_enabled',
146
+ 'type' => 'options',
147
+ 'options' => array(
148
+ 1 => $this->__('Enabled'),
149
+ 0 => $this->__('Disabled'),
150
+ ),
151
+ ));
152
+
153
+ $this->addColumn('action', array(
154
+ 'type' => 'action',
155
+ 'getter' => 'getId',
156
+ 'actions' => array(array(
157
+ 'caption' => Mage::helper('catalog')->__('Edit'),
158
+ 'url' => array(
159
+ 'base'=>'*/attributeSplash_page/edit',
160
+ ),
161
+ 'field' => 'id'
162
+ )),
163
+ 'filter' => false,
164
+ 'sortable' => false,
165
+ 'align' => 'center',
166
+ ));
167
+
168
+ return parent::_prepareColumns();
169
+ }
170
+
171
+ protected function _prepareMassaction()
172
+ {
173
+ $this->setMassactionIdField('page_id');
174
+ $this->getMassactionBlock()->setFormFieldName('page');
175
+
176
+ $this->getMassactionBlock()->addItem('delete', array(
177
+ 'label'=> $this->__('Delete'),
178
+ 'url' => $this->getUrl('*/attributeSplash_page/massDelete'),
179
+ 'confirm' => Mage::helper('catalog')->__('Are you sure?')
180
+ ));
181
+ }
182
+
183
+ /**
184
+ * Retrieve the URL used to modify the grid via AJAX
185
+ *
186
+ * @return string
187
+ */
188
+ public function getGridUrl()
189
+ {
190
+ return $this->getUrl('*/*/pageGrid');
191
+ }
192
+
193
+ /**
194
+ * Retrieve the URL for the row
195
+ *
196
+ */
197
+ public function getRowUrl($row)
198
+ {
199
+ return $this->getUrl('*/attributeSplash_page/edit', array('id' => $row->getId()));
200
+ }
201
+
202
+ /**
203
+ * Retrieve an array of all of the stores
204
+ *
205
+ * @return array
206
+ */
207
+ protected function getStores()
208
+ {
209
+ $options = array(0 => $this->__('Global'));
210
+ $stores = Mage::getResourceModel('core/store_collection')->load();
211
+
212
+ foreach($stores as $store) {
213
+ $options[$store->getId()] = $store->getWebsite()->getName() . ' &gt; ' . $store->getName();
214
+ }
215
+
216
+ return $options;
217
+ }
218
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Page/Helper/Image.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Page_Helper_Image extends Varien_Data_Form_Element_Image
10
+ {
11
+ /**
12
+ * Prepend the base image URL to the image filename
13
+ *
14
+ * @return null|string
15
+ */
16
+ protected function _getUrl()
17
+ {
18
+ if ($this->getValue() && !is_array($this->getValue())) {
19
+ return Mage::helper('attributeSplash/image')->getImageUrl($this->getValue());
20
+ }
21
+
22
+ return null;
23
+ }
24
+ }
app/code/community/Fishpig/AttributeSplash/Block/Adminhtml/Xmlsitemap.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Adminhtml_Xmlsitemap extends Mage_Core_Block_Text
10
+ {
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->setText('You need the <a href="#">XML Sitemap</a> add-on.');
14
+
15
+ return parent::_beforeToHtml();
16
+ }
17
+ }
app/code/community/Fishpig/AttributeSplash/Block/Group/View.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Group_View extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Splash page collection
13
+ *
14
+ * @var Fishpig_AttributeSplash_Model_Mysql4_Page_Collection
15
+ */
16
+ protected $_splashPages = null;
17
+
18
+ /**
19
+ * Retrieve the splash group
20
+ *
21
+ * @return Fishpig_AttributeSplash_Model_Group
22
+ */
23
+ public function getSplashGroup()
24
+ {
25
+ if (!$this->hasSplashGroup()) {
26
+ return Mage::registry('splash_group');
27
+ }
28
+
29
+ return $this->_getData('splash_group');
30
+ }
31
+
32
+ /**
33
+ * Retrieve the splash page collection
34
+ *
35
+ * @return Fishpig_AttributeSplash_Model_Mysql4_Page_Collection
36
+ */
37
+ public function getSplashPages()
38
+ {
39
+ if (is_null($this->_splashPages)) {
40
+ $this->_splashPages = $this->getSplashGroup()
41
+ ->getSplashPages()
42
+ ->addOrderBySortOrder();
43
+ }
44
+
45
+ return $this->_splashPages;
46
+ }
47
+
48
+ /**
49
+ * Check if category display mode is "Products Only"
50
+ *
51
+ * @return bool
52
+ */
53
+ public function isProductMode()
54
+ {
55
+ return $this->getSplashGroup()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PRODUCT;
56
+ }
57
+
58
+ /**
59
+ * Check if category display mode is "Static Block and Products"
60
+ *
61
+ * @return bool
62
+ */
63
+ public function isMixedMode()
64
+ {
65
+ return $this->getSplashGroup()->getDisplayMode()==Mage_Catalog_Model_Category::DM_MIXED;
66
+ }
67
+
68
+ /**
69
+ * Determine whether it is content mode (Static Block)
70
+ *
71
+ * @return bool
72
+ */
73
+ public function isContentMode()
74
+ {
75
+ return $this->getSplashGroup()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PAGE;
76
+ }
77
+
78
+ /**
79
+ * Retrieves the HTML for the CMS block
80
+ *
81
+ * @return string
82
+ */
83
+ public function getCmsBlockHtml()
84
+ {
85
+ if (!$this->_getData('cms_block_html')) {
86
+ $html = $this->getLayout()->createBlock('cms/block')
87
+ ->setBlockId($this->getSplashGroup()->getCmsBlock())->toHtml();
88
+
89
+ $this->setCmsBlockHtml($html);
90
+ }
91
+
92
+ return $this->_getData('cms_block_html');
93
+ }
94
+
95
+ /**
96
+ * Retrieve the amount of columns for grid view
97
+ *
98
+ * @return int
99
+ */
100
+ public function getColumnCount()
101
+ {
102
+ return $this->hasColumnCount()
103
+ ? $this->_getData('column_count')
104
+ : Mage::getStoreConfig('attributeSplash/group/column_count');
105
+ }
106
+
107
+ public function getThumbnailUrl($page)
108
+ {
109
+ return $this->helper('attributeSplash/image')->init($page, 'thumbnail')
110
+ ->keepFrame($page->thumbnailShouldKeepFrame())
111
+ ->resize($page->getThumbnailWidth(), $page->getThumbnailHeight());
112
+ }
113
+ }
app/code/community/Fishpig/AttributeSplash/Block/Layer/View.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Layer_View extends Mage_Catalog_Block_Layer_View
10
+ {
11
+ /**
12
+ * Returns the layer object for the attributeSplash model
13
+ *
14
+ * @return Fishpig_AttributeSplash_Model_Layer
15
+ */
16
+ public function getLayer()
17
+ {
18
+ return Mage::getSingleton('attributeSplash/layer');
19
+ }
20
+
21
+ /**
22
+ * Ensure the default Magento blocks are used
23
+ *
24
+ * @return $this
25
+ */
26
+ protected function _initBlocks()
27
+ {
28
+ parent::_initBlocks();
29
+
30
+ $this->_stateBlockName = 'Mage_Catalog_Block_Layer_State';
31
+ $this->_categoryBlockName = 'Mage_Catalog_Block_Layer_Filter_Category';
32
+ $this->_attributeFilterBlockName = 'Mage_Catalog_Block_Layer_Filter_Attribute';
33
+ $this->_priceFilterBlockName = 'Mage_Catalog_Block_Layer_Filter_Price';
34
+ $this->_decimalFilterBlockName = 'Mage_Catalog_Block_Layer_Filter_Decimal';
35
+
36
+ return $this;
37
+ }
38
+ }
app/code/community/Fishpig/AttributeSplash/Block/Page/View.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Page_View extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Adds the META information to the resulting page
13
+ */
14
+ protected function _prepareLayout()
15
+ {
16
+ parent::_prepareLayout();
17
+
18
+ if ($layoutCode = Mage::getStoreConfig('attributeSplash/frontend/template')) {
19
+ if ($templateData = Mage::getSingleton('page/config')->getPageLayout($layoutCode)) {
20
+ if (isset($templateData['template'])) {
21
+ $this->getLayout()->getBlock('root')->setTemplate($templateData['template']);
22
+ }
23
+ }
24
+ }
25
+
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Retrieves the current Splash model
31
+ *
32
+ * @return Fishpig_AttributeSplash_Model_Splash|null
33
+ */
34
+ public function getSplashPage()
35
+ {
36
+ if (!$this->hasSplashPage()) {
37
+ if ($this->hasSplashPageId()) {
38
+ $this->setSplashPage(Mage::getModel('attributeSplash/splash')->load($this->getSplashPageId()));
39
+ }
40
+ else {
41
+ $this->setSplashPage(Mage::registry('splash_page'));
42
+ }
43
+ }
44
+
45
+ return $this->getData('splash_page');
46
+ }
47
+
48
+ /**
49
+ * Check if category display mode is "Products Only"
50
+ *
51
+ * @return bool
52
+ */
53
+ public function isProductMode()
54
+ {
55
+ return $this->getSplashPage()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PRODUCT;
56
+ }
57
+
58
+ /**
59
+ * Check if category display mode is "Static Block and Products"
60
+ *
61
+ * @return bool
62
+ */
63
+ public function isMixedMode()
64
+ {
65
+ return $this->getSplashPage()->getDisplayMode()==Mage_Catalog_Model_Category::DM_MIXED;
66
+ }
67
+
68
+ /**
69
+ * Determine whether it is content mode (Static Block)
70
+ *
71
+ * @return bool
72
+ */
73
+ public function isContentMode()
74
+ {
75
+ return $this->getSplashPage()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PAGE;
76
+ }
77
+
78
+ /**
79
+ * Retrieves and renders the product list block
80
+ *
81
+ * @return string
82
+ */
83
+ public function getProductListHtml()
84
+ {
85
+ return $this->getProductListBlock()->toHtml();
86
+ }
87
+
88
+ /**
89
+ * Retrieve the product list block
90
+ *
91
+ * @return Mage_Catalog_Block_Product_List
92
+ */
93
+ public function getProductListBlock()
94
+ {
95
+ if ($block = $this->getChild('product_list')) {
96
+ if (!$block->hasColumnCount()) {
97
+ $block->setColumnCount($this->getSplashPageProductsPerRow());
98
+ }
99
+
100
+ return $block;
101
+ }
102
+
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * Retrieve the number of products per row
108
+ *
109
+ * @return int
110
+ */
111
+ public function getSplashPageProductsPerRow()
112
+ {
113
+ return Mage::getStoreConfig('attributeSplash/page/column_count');
114
+ }
115
+
116
+ /**
117
+ * Retrieves the HTML for the CMS block
118
+ *
119
+ * @return string
120
+ */
121
+ public function getCmsBlockHtml()
122
+ {
123
+ if (!$this->getData('cms_block_html')) {
124
+ $html = $this->getLayout()->createBlock('cms/block')
125
+ ->setBlockId($this->getSplashPage()->getCmsBlock())->toHtml();
126
+
127
+ $this->setData('cms_block_html', $html);
128
+ }
129
+
130
+ return $this->getData('cms_block_html');
131
+ }
132
+ }
app/code/community/Fishpig/AttributeSplash/Block/Page/View/Product/List.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Block_Page_View_Product_List extends Mage_Catalog_Block_Product_List
10
+ {
11
+ /**
12
+ * Retrieves the current layer product collection
13
+ *
14
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
15
+ */
16
+ protected function _getProductCollection()
17
+ {
18
+ if (is_null($this->_productCollection)) {
19
+ $this->_productCollection = Mage::getSingleton('attributeSplash/layer')->getProductCollection();
20
+
21
+ if ($orders = Mage::getSingleton('catalog/config')->getAttributeUsedForSortByArray()) {
22
+ if (isset($orders['position'])) {
23
+ unset($orders['position']);
24
+ }
25
+
26
+ $this->setAvailableOrders($orders);
27
+
28
+ if (!$this->getSortBy()) {
29
+ $category = Mage::getModel('catalog/category')->setStoreId(
30
+ Mage::app()->getStore()->getId()
31
+ );
32
+
33
+ $this->setSortBy($category->getDefaultSortBy());
34
+ }
35
+ }
36
+ }
37
+
38
+ return $this->_productCollection;
39
+ }
40
+ }
app/code/community/Fishpig/AttributeSplash/Controller/Router.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <ben@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract
10
+ {
11
+ /**
12
+ * Cache for request object
13
+ *
14
+ * @var Zend_Controller_Request_Http
15
+ */
16
+ protected $_request = null;
17
+
18
+ /**
19
+ * Initialize Controller Router
20
+ *
21
+ * @param Varien_Event_Observer $observer
22
+ */
23
+ public function initControllerRouters(Varien_Event_Observer $observer)
24
+ {
25
+ $observer->getEvent()->getFront()->addRouter('attributeSplash', $this);
26
+ }
27
+
28
+ /**
29
+ * Get the request object
30
+ *
31
+ * @return Zend_Controller_Request_Http
32
+ */
33
+ public function getRequest()
34
+ {
35
+ return $this->_request;
36
+ }
37
+
38
+ /**
39
+ * Validate and Match Cms Page and modify request
40
+ *
41
+ * @param Zend_Controller_Request_Http $request
42
+ * @return bool
43
+ */
44
+ public function match(Zend_Controller_Request_Http $request)
45
+ {
46
+ $this->_request = $request;
47
+
48
+ if (($requestUri = $this->_preparePathInfo($request->getPathInfo())) === false) {
49
+ return false;
50
+ }
51
+
52
+ if ($this->_match($requestUri) !== false) {
53
+ $request->setAlias(
54
+ Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
55
+ $requestUri . Mage::getStoreConfig('attributeSplash/seo/url_suffix')
56
+ );
57
+
58
+ return true;
59
+ }
60
+
61
+ return false;
62
+ }
63
+
64
+ /**
65
+ * Match the request against all enabled splash routes
66
+ *
67
+ * @return bool
68
+ */
69
+ protected function _match(&$requestUri)
70
+ {
71
+ $includeGroupUrlKey = Mage::getStoreConfigFlag('attributeSplash/page/include_group_url_key');
72
+ $isDoubleBarrel = strpos($requestUri, '/') !== false;
73
+
74
+ if ($isDoubleBarrel) {
75
+ // Must be splash page
76
+ if (!$includeGroupUrlKey) {
77
+ // URL contains / but no group key so should be single
78
+ return false;
79
+ }
80
+
81
+ list($groupUrlKey, $pageUrlKey, $extra) = explode('/', $requestUri);
82
+
83
+ if ($extra) {
84
+ return false;
85
+ }
86
+
87
+ return $this->_loadSplashPage($pageUrlKey, $groupUrlKey);
88
+ }
89
+ else if ($includeGroupUrlKey) {
90
+ return $this->_loadSplashGroup($requestUri);
91
+ }
92
+
93
+ if ($this->_loadSplashPage($requestUri)) {
94
+ return true;
95
+ }
96
+
97
+ return $this->_loadSplashGroup($requestUri);
98
+ }
99
+
100
+ /**
101
+ * Prepare the path info variable
102
+ *
103
+ * @param string $pathInfo
104
+ * @return false|string
105
+ */
106
+ protected function _preparePathInfo($pathInfo)
107
+ {
108
+ $requestUri = trim($pathInfo, '/');
109
+
110
+ if (($urlSuffix = rtrim(Mage::getStoreConfig('attributeSplash/seo/url_suffix'), '/')) !== '') {
111
+ if (substr($requestUri, -strlen($urlSuffix)) !== $urlSuffix) {
112
+ if (substr($pathInfo, -4) === '.xml') {
113
+ return $pathInfo;
114
+ }
115
+
116
+ return false;
117
+ }
118
+
119
+ $requestUri = substr($requestUri, 0, -strlen($urlSuffix));
120
+ }
121
+
122
+ return $requestUri;
123
+ }
124
+
125
+ /**
126
+ * Load a splash page by it's URL key
127
+ * If the group URL key is present, this must match
128
+ *
129
+ * @param string $pageUrlKey
130
+ * @param string $groupUrlKey = null
131
+ * @return bool
132
+ */
133
+ protected function _loadSplashPage($pageUrlKey, $groupUrlKey = null)
134
+ {
135
+ $pages = Mage::getResourceModel('attributeSplash/page_collection')
136
+ ->addStoreFilter(Mage::app()->getStore()->getId())
137
+ ->addFieldToFilter('url_key', $pageUrlKey)
138
+ ->load();
139
+
140
+ if (count($pages) === 0) {
141
+ return false;
142
+ }
143
+
144
+ $page = false;
145
+
146
+ foreach($pages as $object) {
147
+ if (!$object->getIsEnabled() || !$object->getSplashGroup()) {
148
+ continue;
149
+ }
150
+
151
+ if (!is_null($groupUrlKey) && $object->getSplashGroup()->getUrlKey() !== $groupUrlKey) {
152
+ continue;
153
+ }
154
+
155
+ $page = $object;
156
+
157
+ break;
158
+ }
159
+
160
+ if (!$page) {
161
+ return false;
162
+ }
163
+
164
+ Mage::register('splash_page', $page);
165
+ Mage::register('splash_group', $page->getSplashGroup());
166
+
167
+ $this->getRequest()->setModuleName('splash')
168
+ ->setControllerName('page')
169
+ ->setActionName('view')
170
+ ->setParam('id', $page->getId())
171
+ ->setParam('group_id', $page->getSplashGroup()->getId());
172
+
173
+ return true;
174
+ }
175
+
176
+ /**
177
+ * Load a splash group by it's URL key
178
+ *
179
+ * @param string $groupUrlKey
180
+ * @return bool
181
+ */
182
+ protected function _loadSplashGroup($groupUrlKey)
183
+ {
184
+ $group = Mage::getModel('attributeSplash/group')
185
+ ->setStoreId(Mage::app()->getStore()->getId())
186
+ ->load($groupUrlKey, 'url_key');
187
+
188
+
189
+ if (!$group->getId()) {
190
+ return false;
191
+ }
192
+
193
+ Mage::register('splash_group', $group);
194
+
195
+ $this->getRequest()->setModuleName('splash')
196
+ ->setControllerName('group')
197
+ ->setActionName('view')
198
+ ->setParam('id', $group->getId());
199
+
200
+ return true;
201
+ }
202
+ }
app/code/community/Fishpig/AttributeSplash/FPAdmin/Block/Adminhtml/Extend.php ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_FPAdmin
5
+ * @author Ben Tideswell <help@fishpig.co.uk>
6
+ */
7
+
8
+ // Required for compiler as this is used in multiple modules
9
+ if (!defined('__fishpig_extend')) {
10
+ define('__fishpig_extend', true);
11
+
12
+ abstract class Fishpig_FPAdmin_Block_Adminhtml_Extend extends Mage_Core_Block_Template
13
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
14
+ {
15
+ /**
16
+ * Tracking string for GA
17
+ *
18
+ * @var const string
19
+ */
20
+ const TRACKING_STRING = '?utm_source=%s&utm_medium=%s&utm_term=%s&utm_campaign=Extend';
21
+
22
+ /**
23
+ * Base URL for links
24
+ *
25
+ * @var const string
26
+ */
27
+ const BASE_URL = 'http://fishpig.co.uk/';
28
+
29
+ /**
30
+ * The URL for the S3 bucket for images
31
+ *
32
+ * @var const string
33
+ */
34
+ const S3_BUCKET_URL = 'https://s3.amazonaws.com/FishPig-Extend/image/';
35
+
36
+ /**
37
+ * Cache for all available extensions
38
+ *
39
+ * @var array
40
+ */
41
+ static protected $_extensions = null;
42
+
43
+ protected function _construct()
44
+ {
45
+ $this->setTemplate('small.phtml');
46
+
47
+ return parent::_construct();
48
+ }
49
+
50
+ /**
51
+ * Retrieve extensions set via XML
52
+ *
53
+ * @return array
54
+ */
55
+ public function getSelectedExtensions()
56
+ {
57
+ return $this->getExtensions($this->getLimit(), $this->getPreferred() ? ($this->getPreferred()) : null);
58
+ }
59
+
60
+ /**
61
+ * Retrieve the available extensions taking into account $count and $pref
62
+ *
63
+ * @param int $count = 0
64
+ * @param array $pref = array()
65
+ * @return false|array
66
+ */
67
+ public function getExtensions($count = 0, array $pref = array(), $rand = false)
68
+ {
69
+ if (!isset($pref[0])) {
70
+ $pref = array_keys($pref);
71
+ }
72
+
73
+ if (($pool = $this->_getAllExtensions()) !== false) {
74
+ $winners = array();
75
+
76
+ foreach($pref as $code) {
77
+ if (isset($pool[$code])) {
78
+ $winners[$code] = $pool[$code];
79
+ unset($pool[$code]);
80
+ }
81
+
82
+ if (!$rand && $count > 0 && count($winners) >= $count) {
83
+ break;
84
+ }
85
+ }
86
+
87
+ if ($rand) {
88
+ $winners = $this->shuffleArray($winners);
89
+
90
+ if ($count > 0 && count($winners) > $count) {
91
+ $xcount = count($winners);
92
+
93
+ while($xcount-- > $count) {
94
+ array_pop($winners);
95
+ }
96
+ }
97
+ }
98
+
99
+ while(count($winners) < $count && count($pool) > 0) {
100
+ $code = key($pool);
101
+
102
+ $winners[$code] = $pool[$code];
103
+ unset($pool[$code]);
104
+ }
105
+
106
+ end($winners);
107
+
108
+ $winners[key($winners)]['last'] = true;
109
+
110
+ return $winners;
111
+ }
112
+
113
+ return false;
114
+ }
115
+
116
+ /**
117
+ * Retrieve all of the available extensions
118
+ *
119
+ * @return array
120
+ */
121
+ protected function _getAllExtensions()
122
+ {
123
+ if (!is_null(self::$_extensions)) {
124
+ return self::$_extensions;
125
+ }
126
+
127
+ $installedModules = array_keys((array)$this->_getConfig()->getNode('modules'));
128
+ $config = (array)$this->_getConfig()->getNode('fishpig/extend')->asArray();
129
+ self::$_extensions = array();
130
+
131
+ foreach($config as $code => $extension) {
132
+ $extension['module'] = $code;
133
+ $reqMultistore = isset($extension['require_multistore']) ? (int)$extension['require_multistore'] : null;
134
+
135
+ if (!isset($_SERVER['IS_FISHPIG']) && in_array($code, $installedModules)) {
136
+ continue;
137
+ }
138
+ else if (!is_null($reqMultistore) && $reqMultistore === (int)Mage::app()->isSingleStoreMode()) {
139
+ continue;
140
+ }
141
+ else if (isset($extension['depends'])) {
142
+ $depends = array_keys((array)$extension['depends']);
143
+
144
+ if (count(array_diff($depends, $installedModules)) > 0) {
145
+ continue;
146
+ }
147
+ }
148
+
149
+ self::$_extensions[$code] = (array)$extension;
150
+ }
151
+
152
+ if (count(self::$_extensions) === 0) {
153
+ self::$_extensions = false;
154
+ }
155
+
156
+ return self::$_extensions;
157
+ }
158
+
159
+ /**
160
+ * Retrieve the title of the extension
161
+ *
162
+ * @param array $e
163
+ * @return string
164
+ */
165
+ public function getTitle(array $e = null)
166
+ {
167
+ // Being called as a tab
168
+ if (is_null($e)) {
169
+ return $this->_getData('title');
170
+ }
171
+
172
+ return $this->_getField($e, 'title');
173
+ }
174
+
175
+ /**
176
+ * Retrieve the subtitle of the extension
177
+ *
178
+ * @param array $e
179
+ * @return string
180
+ */
181
+ public function getSubTitle(array $e)
182
+ {
183
+ return $this->_getField($e, 'subtitle');
184
+ }
185
+
186
+ /**
187
+ * Rertrieve the URL for $e with the tracking code
188
+ *
189
+ * @param array $e
190
+ * @param string $campaign
191
+ * @param string $source
192
+ * @param string $medium
193
+ * @return string
194
+ */
195
+ public function getTrackedUrl(array $e, $source, $content = null)
196
+ {
197
+ $term = $this->_getField($e, 'module');
198
+
199
+ $trackedUrl = sprintf(self::BASE_URL . $this->_getField($e, 'url') . self::TRACKING_STRING, $source, $this->getMedium(), $term);
200
+
201
+ if (!is_null($content)) {
202
+ $trackedUrl .= '&utm_content=' . $content;
203
+ }
204
+
205
+ return $trackedUrl;
206
+ }
207
+
208
+ /**
209
+ * Retrieve the utm_medium parameter
210
+ *
211
+ * @return string
212
+ */
213
+ public function getMedium()
214
+ {
215
+ return $this->_getData('medium')
216
+ ? $this->_getData('medium')
217
+ : 'Magento Admin';
218
+ }
219
+
220
+ /**
221
+ * Retrieve the short definition of the extension
222
+ *
223
+ * @param array $e
224
+ * @return string
225
+ */
226
+ public function getShortDefinition(array $e)
227
+ {
228
+ return $this->_getField($e, 'short_definition');
229
+ }
230
+
231
+ /**
232
+ * Retrieve the image URL of the extension
233
+ *
234
+ * @param array $e
235
+ * @return string
236
+ */
237
+ public function getImageUrl(array $e)
238
+ {
239
+ return self::S3_BUCKET_URL . $this->_getField($e, 'image');
240
+ }
241
+
242
+ /**
243
+ * Retrieve a field from the extension
244
+ *
245
+ * @param array $e
246
+ * @param string $field
247
+ * @return string
248
+ */
249
+ protected function _getField(array $e, $field)
250
+ {
251
+ return $e && is_array($e) && isset($e[$field]) ? $e[$field] : '';
252
+ }
253
+
254
+ /**
255
+ * Determine wether $e is the last $e in the array
256
+ *
257
+ * @param array $e
258
+ * @return bool
259
+ */
260
+ public function isLast(array $e)
261
+ {
262
+ return $this->_getField($e, 'last') === true;
263
+ }
264
+
265
+ /**
266
+ * Retrieve the Magento config model
267
+ *
268
+ * @return Mage_Core_Model_Config
269
+ */
270
+ protected function _getConfig()
271
+ {
272
+ return Mage::app()->getConfig();
273
+ }
274
+
275
+ /**
276
+ * Retrieve the ID
277
+ *
278
+ * @return string
279
+ */
280
+ public function getId()
281
+ {
282
+ if (!$this->_getData('id')) {
283
+ $this->setId('fp-extend-' . rand(1111, 9999));
284
+ }
285
+
286
+ return $this->_getData('id');
287
+ }
288
+
289
+ /**
290
+ * Retrieve the full path to the template
291
+ *
292
+ * @return string
293
+ */
294
+ public function getTemplateFile()
295
+ {
296
+ if (($dir = $this->_getFPAdminDir()) !== false) {
297
+ return $dir . 'template' . DS . $this->getTemplate();
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Set the template include path
303
+ *
304
+ * @param string $dir
305
+ * @return $this
306
+ */
307
+ public function setScriptPath($dir)
308
+ {
309
+ $this->_viewDir = '';
310
+
311
+ return $this;
312
+ }
313
+
314
+ /**
315
+ * Retrieve any available FPAdmin directory
316
+ *
317
+ * @return false|string
318
+ */
319
+ protected function _getFPAdminDir()
320
+ {
321
+ $candidates = array(
322
+ $this->getModule(),
323
+ 'Fishpig_Wordpress',
324
+ 'Fishpig_AttributeSplash',
325
+ 'Fishpig_iBanners'
326
+ );
327
+
328
+ foreach(array_unique($candidates) as $candidate) {
329
+ if (!$candidate) {
330
+ continue;
331
+ }
332
+
333
+ $dir = Mage::getModuleDir('', $candidate) . DS . 'FPAdmin' . DS;
334
+
335
+ if (is_dir($dir)) {
336
+ return $dir;
337
+ }
338
+ }
339
+
340
+ return false;
341
+ }
342
+
343
+ /**
344
+ * If tab, always show
345
+ *
346
+ * @return bool
347
+ */
348
+ public function canShowTab()
349
+ {
350
+ return true;
351
+ }
352
+
353
+ /**
354
+ * Don't hide if a tab
355
+ *
356
+ * @return bool
357
+ */
358
+ public function isHidden()
359
+ {
360
+ return false;
361
+ }
362
+
363
+ /**
364
+ * Retrieve the tab title
365
+ *
366
+ * @return string
367
+ */
368
+ public function getTabTitle()
369
+ {
370
+ return $this->getTabLabel();
371
+ }
372
+
373
+ /**
374
+ * Retrieve the tab label
375
+ *
376
+ * @return string
377
+ */
378
+ public function getTabLabel()
379
+ {
380
+ return $this->_getData('tab_label');
381
+ }
382
+
383
+ /**
384
+ * Determine whether to skip generate content
385
+ *
386
+ * @return bool
387
+ */
388
+ public function getSkipGenerateContent()
389
+ {
390
+ return true;
391
+ }
392
+
393
+ /**
394
+ * Retrieve the tab class name
395
+ *
396
+ * @return string
397
+ */
398
+ public function getTabClass()
399
+ {
400
+ if ($this->getSkipGenerateContent()) {
401
+ return 'ajax';
402
+ }
403
+
404
+ return parent::getTabClass();
405
+ }
406
+
407
+ /**
408
+ * Retrieve the URL used to load the tab content
409
+ *
410
+ * @return string
411
+ */
412
+ public function getTabUrl()
413
+ {
414
+ if ($tabUrl = $this->_getData('tab_url')) {
415
+ return $this->getUrl($tabUrl);
416
+ }
417
+
418
+ return '#';
419
+ }
420
+
421
+ /**
422
+ * Legacy fix that stops the HTML output from displaying
423
+ *
424
+ * @param string $fileName
425
+ * @return string
426
+ */
427
+ public function fetchView($fileName)
428
+ {
429
+ return is_file($fileName)
430
+ ? parent::fetchView($fileName)
431
+ : '';
432
+ }
433
+
434
+ /**
435
+ * Shuffle an array and preserve the keys
436
+ *
437
+ * @param array $a
438
+ * @return array
439
+ */
440
+ public function shuffleArray(array $a)
441
+ {
442
+ $keys = array_keys($a);
443
+
444
+ shuffle($keys);
445
+
446
+ $random = array();
447
+
448
+ foreach ($keys as $key) {
449
+ $random[$key] = $a[$key];
450
+ }
451
+
452
+ return $random;
453
+ }
454
+ }
455
+
456
+ // End of compilation fix
457
+ }
458
+
app/code/community/Fishpig/AttributeSplash/FPAdmin/etc/config.xml ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <fishpig>
4
+ <extend>
5
+ <Fishpig_Bolt>
6
+ <url><![CDATA[magento/extensions/bolt-full-page-cache/]]></url>
7
+ <image>bolt.png</image>
8
+ <title>Bolt</title>
9
+ <subtitle>Full Page Cache</subtitle>
10
+ <short_definition>Add enterprise level caching to Magento community with Bolt, Magento's fastest Full Page Cache extension.</short_definition>
11
+ </Fishpig_Bolt>
12
+ <Fishpig_NoBots>
13
+ <url><![CDATA[magento/extensions/block-robots-stop-spam/]]></url>
14
+ <image>nobots.png</image>
15
+ <title>NoBots</title>
16
+ <subtitle>Stop Magento Spam Bots</subtitle>
17
+ <short_definition>NoBots automatically blocks spam bots from your website giving you less spam and a faster server.</short_definition>
18
+ </Fishpig_NoBots>
19
+ <Fishpig_CrossLink>
20
+ <url><![CDATA[magento/extensions/seo-internal-links/]]></url>
21
+ <image>crosslink.png</image>
22
+ <title>Crosslink</title>
23
+ <subtitle>SEO Internal Links</subtitle>
24
+ <short_definition>Automatically cross link your products, categories, splash pages, CMS pages, blog posts and categories using Crosslinks.</short_definition>
25
+ </Fishpig_CrossLink>
26
+ <Fishpig_Opti>
27
+ <url><![CDATA[magento/extensions/optimisation-minification/]]></url>
28
+ <image>opti.png</image>
29
+ <title>Opti</title>
30
+ <subtitle>Minify Magento</subtitle>
31
+ <short_definition>Opti automatically minifies your HTML, CSS and Javascript and works on any server.</short_definition>
32
+ </Fishpig_Opti>
33
+ <Fishpig_AttributeSplashPro>
34
+ <url><![CDATA[magento/extensions/attribute-splash-pro/]]></url>
35
+ <image>splash-pro.png</image>
36
+ <title>AttributeSplash Pro</title>
37
+ <subtitle>SEO Landing Pages</subtitle>
38
+ <short_definition>Create SEO landing pages quickly and easily using AttributeSplash Pro. Decide which products you want to display based on multiple attribute filters, category filters and price filters.</short_definition>
39
+ </Fishpig_AttributeSplashPro>
40
+ <Fishpig_BasketShipping>
41
+ <url><![CDATA[magento/extensions/bolt-full-page-cache/]]></url>
42
+ <image>basket-shipping.png</image>
43
+ <title>Basket Shipping</title>
44
+ <subtitle>Automatically set the Shipping Method</subtitle>
45
+ <short_definition>Automatically set the shipping method as soon as your customer hits your shopping cart.</short_definition>
46
+ </Fishpig_BasketShipping>
47
+ <Fishpig_Wordpress_Addon_Multisite>
48
+ <url><![CDATA[magento/wordpress-integration/multisite/]]></url>
49
+ <image>wordpress-multisite.png</image>
50
+ <title>WordPress Integration</title>
51
+ <subtitle>Multi-Store Blog Integration</subtitle>
52
+ <short_definition>Integrate a WordPress blog into your Magento theme in minutes with this free extension.</short_definition>
53
+ <require_multistore>1</require_multistore>
54
+ <depends><Fishpig_Wordpress /></depends>
55
+ </Fishpig_Wordpress_Addon_Multisite>
56
+ <Fishpig_Wordpress>
57
+ <url><![CDATA[magento/wordpress-integration/]]></url>
58
+ <image>wordpress.png</image>
59
+ <title>WordPress Integration</title>
60
+ <subtitle>WordPress blog integration</subtitle>
61
+ <short_definition>Manage multiple blogs from a single WordPress Admin and integrate each blog with a different Magento store view</short_definition>
62
+ <require_multistore>0</require_multistore>
63
+ </Fishpig_Wordpress>
64
+ <Fishpig_Wordpress_Addon_CS>
65
+ <url><![CDATA[magento/wordpress-integration/customer-synchronisation/]]></url>
66
+ <image>cs.png</image>
67
+ <title>Customer Synchronisation</title>
68
+ <subtitle>Single Sign-on</subtitle>
69
+ <short_definition>Synchronise WordPress users and Magento customers and provide a single login for your customers.</short_definition>
70
+ <depends><Fishpig_Wordpress /></depends>
71
+ </Fishpig_Wordpress_Addon_CS>
72
+ <Fishpig_Wordpress_Addon_Facebook>
73
+ <url><![CDATA[magento/wordpress-integration/facebook/]]></url>
74
+ <image>facebook.png</image>
75
+ <title>Facebook</title>
76
+ <subtitle>Social Integration</subtitle>
77
+ <short_definition>Add Like buttons, Send buttons, Facebook comments and more!</short_definition>
78
+ <depends><Fishpig_Wordpress /></depends>
79
+ </Fishpig_Wordpress_Addon_Facebook>
80
+ <Fishpig_Wordpress_Addon_Root>
81
+ <url><![CDATA[magento/wordpress-integration/root/]]></url>
82
+ <image>root.gif</image>
83
+ <title>Root</title>
84
+ <subtitle>Use WordPress to create your CMS pages</subtitle>
85
+ <short_definition>Remove the blog sub-directory from your integrated blog URLs.</short_definition>
86
+ <depends><Fishpig_Wordpress /></depends>
87
+ </Fishpig_Wordpress_Addon_Root>
88
+ <Fishpig_Wordpress_Addon_IntegratedSearch>
89
+ <url><![CDATA[magento/wordpress-integration/integrated-search/]]></url>
90
+ <image>integrated-search.png</image>
91
+ <title>Integrated Search</title>
92
+ <subtitle>Magento and WordPress search</subtitle>
93
+ <short_definition>Integrate your Magento and WordPress search systems automatically and make searching your site easier for your customers.</short_definition>
94
+ <depends><Fishpig_Wordpress /></depends>
95
+ </Fishpig_Wordpress_Addon_IntegratedSearch>
96
+ <Fishpig_AttributeSplash_Addon_XmlSitemap>
97
+ <url><![CDATA[magento/extensions/attribute-splash-pages/xml-sitemap/]]></url>
98
+ <image>splash-pages.png</image>
99
+ <title>Attribute AttributeSplash</title>
100
+ <subtitle>XML Sitemap</subtitle>
101
+ <short_definition>Add an XML sitemap for your AttributeSplash Pages and AttributeSplash Group so search engines can index your pages.</short_definition>
102
+ <depends><Fishpig_AttributeSplash /></depends>
103
+ </Fishpig_AttributeSplash_Addon_XmlSitemap>
104
+ <Fishpig_AttributeSplash_Addon_QuickCreate>
105
+ <url><![CDATA[magento/extensions/attribute-splash-pages/quick-create/]]></url>
106
+ <image>splash-pages.png</image>
107
+ <title>Attribute AttributeSplash</title>
108
+ <subtitle>Quick Create</subtitle>
109
+ <short_definition>Quickly create AttributeSplash Pages for any attributes with this extension and save yourself from hours of manual work.</short_definition>
110
+ <depends><Fishpig_AttributeSplash /></depends>
111
+ </Fishpig_AttributeSplash_Addon_QuickCreate>
112
+ </extend>
113
+ </fishpig>
114
+ </config>
app/code/community/Fishpig/AttributeSplash/FPAdmin/template/large.phtml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ ?>
6
+ <?php if ($extensions = $this->getSelectedExtensions()): ?>
7
+ <div id="<?php echo $this->getId() ?>">
8
+ <ul id="<?php echo $this->getId() ?>-list">
9
+ <?php foreach($extensions as $extension): ?>
10
+ <li class="item<?php if ($this->isLast($extension)): ?> last<?php endif; ?>">
11
+ <div class="pad">
12
+ <a href="<?php echo $this->getTrackedUrl($extension, $this->getModule(), 'image') ?>" class="image" target="_blank">
13
+ <img src="<?php echo $this->getImageUrl($extension) ?>" alt="<?php echo $this->escapeHtml($this->getTitle($extension)) ?>" />
14
+ </a>
15
+ <h2>
16
+ <a href="<?php echo $this->getTrackedUrl($extension, $this->getModule(), 'title') ?>" target="_blank">
17
+ <strong><?php echo $this->escapeHtml($this->getTitle($extension)) ?></strong>
18
+ <span><?php echo $this->escapeHtml($this->getSubTitle($extension)) ?></span>
19
+ </a>
20
+ </h2>
21
+ <p><?php echo $this->getShortDefinition($extension) ?></p>
22
+ <div><a href="<?php echo $this->getTrackedUrl($extension, $this->getModule(), 'view-more') ?>" target="_blank"><?php echo $this->__('View Add-On') ?></a></div>
23
+ </div>
24
+ </li>
25
+ <?php endforeach; ?>
26
+ </ul>
27
+ </div>
28
+ <script type="text/javascript">$('<?php echo $this->getId() ?>').select('a').invoke('writeAttribute', 'target', '_blank');</script>
29
+ <style type="text/css">
30
+ #<?php echo $this->getId() ?> { max-width: 1600px; margin: 50px auto 0; }
31
+ #<?php echo $this->getId() ?> ul { /*height: 1%; overflow: hidden; */text-align: center; }
32
+ #<?php echo $this->getId() ?> li.item { display: inline-block; width: 24.5%; }
33
+ #<?php echo $this->getId() ?> li.item .pad { padding: 10% 8%; border-right: 1px solid #ccc; }
34
+ #<?php echo $this->getId() ?> li.item.last .pad { border-right: 0px none; }
35
+ #<?php echo $this->getId() ?> li.item .image { display: block; margin-bottom: 10px; }
36
+ #<?php echo $this->getId() ?> h2 a { color: #000; text-decoration: none; font-family: Tahoma, Verdana, Arial;, }
37
+ #<?php echo $this->getId() ?> h2 strong { display: block; text-transform: uppercase; line-height: 1em; }
38
+ #<?php echo $this->getId() ?> h2 span { font-size: 70%; font-family: Georgia, 'Times New Roman'; font-style: italic; }
39
+ #<?php echo $this->getId() ?> p { min-height: 80px; }
40
+ </style>
41
+ <?php endif; ?>
app/code/community/Fishpig/AttributeSplash/FPAdmin/template/small.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ ?>
6
+ <?php if ($extensions = $this->getSelectedExtensions()): ?>
7
+ <div id="<?php echo $this->getId() ?>">
8
+ <ul>
9
+ <?php foreach($extensions as $extension): ?>
10
+ <li class="item<?php if ($this->isLast($extension)): ?> last<?php endif; ?>">
11
+ <div class="pad">
12
+ <a href="<?php echo $this->getTrackedUrl($extension, $this->getModule(), 'image') ?>" class="image" target="_blank">
13
+ <img src="<?php echo $this->getImageUrl($extension) ?>" alt="" />
14
+ </a>
15
+ <h2>
16
+ <a href="<?php echo $this->getTrackedUrl($extension, $this->getModule(), 'title') ?>" target="_blank">
17
+ <strong><?php echo $this->escapeHtml($this->getTitle($extension)) ?></strong> <span><?php echo $this->escapeHtml($this->getSubTitle($extension)) ?></span>
18
+ </a>
19
+ </h2>
20
+ <p><?php echo $this->getShortDefinition($extension) ?> <a href="<?php echo $this->getTrackedUrl($extension, $this->getModule(), 'view-more') ?>" target="_blank">More info</a></p>
21
+ </div>
22
+ </li>
23
+ <?php endforeach; ?>
24
+ </ul>
25
+ </div>
26
+ <script type="text/javascript">decorateList($('<?php echo $this->getId() ?>').select('ul').first());</script>
27
+ <style type="text/css">
28
+ #<?php echo $this->getId() ?> { margin: 0; }
29
+ #<?php echo $this->getId() ?> ul { height: 1%; overflow: hidden; }
30
+ #<?php echo $this->getId() ?> li.item { margin: 0 0 10px; width: 50%; float: left; }
31
+ #<?php echo $this->getId() ?> li.item .pad {padding: 1%; height: 1%; overflow: hidden; border:1px solid #ddd; margin: 0 5px 0 0; }
32
+ #<?php echo $this->getId() ?> li.item.even .pad { margin: 0 0 0 5px; }
33
+ #<?php echo $this->getId() ?> a.image { float: left; display: block; margin-right: 10px; }
34
+ #<?php echo $this->getId() ?> a.image img { max-height: 60px; display: block; }
35
+ #<?php echo $this->getId() ?> h2 { font-size: 1.4em; font-family: Tahoma, Verdana, Arial; line-height: 1em; margin: 5px 0 2px; }
36
+ #<?php echo $this->getId() ?> h2 a { color: #000; text-decoration: none; }
37
+ #<?php echo $this->getId() ?> p { margin-bottom: 0; }
38
+ </style>
39
+ <?php endif; ?>
app/code/community/Fishpig/AttributeSplash/Helper/Data.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Retrieve a splash page for the product / attribute code combination
13
+ *
14
+ * @param Mage_Catalog_Model_Product $product
15
+ * @param $attributeCode
16
+ * @return Fishpig_AttributeSplash_Model_Splash|null
17
+ */
18
+ public function getProductSplashPage(Mage_Catalog_Model_Product $product, $attributeCode)
19
+ {
20
+ $key = $attributeCode . '_splash_page';
21
+
22
+ if (!$product->hasData($key)) {
23
+ $product->setData($key, false);
24
+
25
+ $collection = Mage::getResourceModel('attributeSplash/page_collection')
26
+ ->addStoreFilter(Mage::app()->getStore())
27
+ ->addAttributeCodeFilter($attributeCode)
28
+ ->addProductFilter($product)
29
+ ->setPageSize(1)
30
+ ->setCurPage(1)
31
+ ->load();
32
+
33
+ if (count($collection) > 0) {
34
+ $page = $collection->getFirstItem();
35
+
36
+ if ($page->getId()) {
37
+ $product->setData($key, $page);
38
+ }
39
+ }
40
+ }
41
+
42
+ return $product->getData($key);
43
+ }
44
+
45
+ /**
46
+ * Log an error message
47
+ *
48
+ * @param string $msg
49
+ * @return Fishpig_AttributeSplash_Helper_Data
50
+ */
51
+ public function log($msg)
52
+ {
53
+ Mage::log($msg, false, 'attributeSplash.log', true);
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Get the URL suffix
60
+ *
61
+ * @return string
62
+ */
63
+ public function getUrlSuffix()
64
+ {
65
+ return Mage::getStoreConfig('attributeSplash/seo/url_suffix');
66
+ }
67
+
68
+ /**
69
+ * Determine whether the group URL key is used in the page URL
70
+ *
71
+ * @return bool
72
+ */
73
+ public function includeGroupUrlKeyInPageUrl()
74
+ {
75
+ return Mage::getStoreConfigFlag('attributeSplash/page/include_group_url_key');
76
+ }
77
+ }
app/code/community/Fishpig/AttributeSplash/Helper/Image.php ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Helper_Image extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Storeage for image object, used for resizing images
13
+ *
14
+ * @var null/Varien_Image
15
+ */
16
+ protected $_imageObject = null;
17
+
18
+ /**
19
+ * Flag used to determine wether to recreate already cached image
20
+ *
21
+ * @var bool
22
+ */
23
+ protected $_forceRecreate = false;
24
+
25
+ /**
26
+ * Filename currently initialized in the image object
27
+ *
28
+ * @var null|string
29
+ */
30
+ protected $_filename = '';
31
+
32
+ /**
33
+ * The folder name used to store images
34
+ * This is relative to the media directory
35
+ *
36
+ * @var const string
37
+ */
38
+ const IMAGE_FOLDER = 'attributesplash';
39
+
40
+ /**
41
+ * Store for current image settings
42
+ * Used to cache image
43
+ *
44
+ * @var array
45
+ */
46
+ protected $_settings = array();
47
+
48
+ /**
49
+ * Retrieve the image URL where images are stored
50
+ *
51
+ * @return string
52
+ */
53
+ public function getBaseImageUrl()
54
+ {
55
+ return Mage::getBaseUrl('media', Mage::app()->getStore()->isCurrentlySecure()) . self::IMAGE_FOLDER . '/';
56
+ }
57
+
58
+ /**
59
+ * Retrieve the directory/path where images are stored
60
+ *
61
+ * @return string
62
+ */
63
+ public function getBaseImagePath()
64
+ {
65
+ return Mage::getBaseDir('media') . DS . self::IMAGE_FOLDER . DS;
66
+ }
67
+
68
+ /**
69
+ * Retrieve the full image URL
70
+ * Null returned if image does not exist
71
+ *
72
+ * @param string $image
73
+ * @return string|null
74
+ */
75
+ public function getImageUrl($image)
76
+ {
77
+ if ($this->imageExists($image)) {
78
+ return $this->getBaseImageUrl() . $image;
79
+ }
80
+
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * Retrieve the full image path
86
+ * Null returned if image does not exist
87
+ *
88
+ * @param string $image
89
+ * @return string|null
90
+ */
91
+ public function getImagePath($image)
92
+ {
93
+ if ($this->imageExists($image)) {
94
+ return $this->getBaseImagePath() . $image;
95
+ }
96
+
97
+ return null;
98
+ }
99
+
100
+ /**
101
+ * determine whether the image exists
102
+ *
103
+ * @param string $image
104
+ * @return bool
105
+ */
106
+ public function imageExists($image)
107
+ {
108
+ return is_file($this->getBaseImagePath() . $image);
109
+ }
110
+
111
+ /**
112
+ * Converts a filename, width and height into it's resized uri path
113
+ * returned path does not include base path
114
+ *
115
+ * @param string $filename
116
+ * @param int $width = null
117
+ * @param int $height = null
118
+ * @return string
119
+ */
120
+ public function getResizedImageUrl($filename, $width = null, $height = null)
121
+ {
122
+ return $this->getBaseImageUrl() . $this->_getRelativeResizedImagePath($filename, $width, $height);
123
+ }
124
+
125
+ /**
126
+ * Converts a filename, width and height into it's resized path
127
+ * returned path does not include base path
128
+ *
129
+ * @param string $filename
130
+ * @param int $width = null
131
+ * @param int $height = null
132
+ * @return string
133
+ */
134
+ public function getResizedImagePath($filename, $width = null, $height = null)
135
+ {
136
+ return $this->getBaseImagePath() . $this->_getRelativeResizedImagePath($filename, $width, $height);
137
+ }
138
+
139
+ /**
140
+ * Converts a filename, width and height into it's resized path
141
+ * returned path does not include base path
142
+ *
143
+ * @param string $filename
144
+ * @param int $width = null
145
+ * @param int $height = null
146
+ * @return string
147
+ */
148
+ protected function _getRelativeResizedImagePath($filename, $width = null, $height = null)
149
+ {
150
+ if (!is_null($width) || !is_null($height)) {
151
+ $cacheSettings = array();
152
+
153
+ foreach($this->_settings as $key => $value) {
154
+ $cacheSettings[] = $key . '__' . (int)$value;
155
+ }
156
+
157
+ $cacheKey = substr(md5(implode(',', $cacheSettings)), 0, 6);
158
+
159
+ return 'cache' . DS . $cacheKey . '_' . trim($width.'x'.$height, 'x') . DS . $filename;
160
+ }
161
+
162
+ return $filename;
163
+ }
164
+
165
+ /**
166
+ * Initialize the image object
167
+ * This sets up the image object for resizing and caching
168
+ *
169
+ * @param Fishpig_AttributeSplash_Model_Page $page
170
+ * @param string $attribute
171
+ * @return Fishpig_AttributeSplash_Helper_Image
172
+ */
173
+ public function init(Fishpig_AttributeSplash_Model_Page $page, $attribute = 'image')
174
+ {
175
+ $this->_imageObject = null;
176
+ $this->_forceRecreate = false;
177
+ $this->_filename = null;
178
+ $this->_settings = array();
179
+
180
+ if ($imagePath = $this->getImagePath($page->getData($attribute))) {
181
+ $this->_imageObject = new Varien_Image($imagePath);
182
+ $this->_filename = basename($imagePath);
183
+
184
+ $this->constrainOnly(true);
185
+ $this->keepTransparency(true);
186
+ $this->keepAspectRatio(true);
187
+ }
188
+
189
+ return $this;
190
+ }
191
+
192
+ /**
193
+ * Resize the image loaded into the image object
194
+ *
195
+ * @param int $width = null
196
+ * @param int $height = null
197
+ * @return string
198
+ */
199
+ public function resize($width = null, $height = null)
200
+ {
201
+ if ($this->isActive()) {
202
+ $cachedFilename = $this->getResizedImagePath($this->_filename, $width, $height);
203
+
204
+ if ($this->_forceRecreate || !is_file($cachedFilename)) {
205
+ if (is_null($width) && is_null($height)) {
206
+
207
+ }
208
+ elseif (is_null($width)) {
209
+ $this->_imageObject->resize($height);
210
+ }
211
+ else {
212
+ $this->_imageObject->resize($width, $height);
213
+ }
214
+
215
+ $this->_imageObject->save($cachedFilename);
216
+ }
217
+
218
+ return $this->getResizedImageUrl($this->_filename, $width, $height);;
219
+ }
220
+
221
+ return '';
222
+ }
223
+
224
+ /**
225
+ * Keep the transparency of the image
226
+ *
227
+ * @param bool $val
228
+ */
229
+ public function keepTransparency($val)
230
+ {
231
+ if ($this->isActive()) {
232
+ $this->_imageObject->keepTransparency($val);
233
+ }
234
+
235
+ return $this;
236
+ }
237
+
238
+ /**
239
+ * Keep the frame or add a white space
240
+ *
241
+ * @param bool $val
242
+ */
243
+ public function keepFrame($val)
244
+ {
245
+ if ($this->isActive()) {
246
+ $this->_settings['keep_frame'] = $val;
247
+ $this->_imageObject->keepFrame($val);
248
+ }
249
+
250
+ return $this;
251
+ }
252
+
253
+ /**
254
+ * Keep the aspect ratio of an image
255
+ *
256
+ * @param bool $val
257
+ */
258
+ public function keepAspectRatio($val)
259
+ {
260
+ if ($this->isActive()) {
261
+ $this->_settings['keep_aspect_ratio'] = $val;
262
+ $this->_imageObject->keepAspectRatio($val);
263
+ }
264
+
265
+ return $this;
266
+ }
267
+
268
+ /**
269
+ * Don't increase the size of an image, only decrease
270
+ *
271
+ * @param bool $val
272
+ */
273
+ public function constrainOnly($val)
274
+ {
275
+ if ($this->isActive()) {
276
+ $this->_settings['constrain_only'] = $val;
277
+ $this->_imageObject->constrainOnly($val);
278
+ }
279
+
280
+ return $this;
281
+ }
282
+
283
+ /**
284
+ * Determine whether to recreate image that already exists
285
+ *
286
+ * @param bool $val
287
+ */
288
+ public function forceRecreate($val)
289
+ {
290
+ if ($this->isActive()) {
291
+ $this->_forceRecreate = $val;
292
+ }
293
+
294
+ return $this;
295
+ }
296
+
297
+ /**
298
+ * Set the image background colour
299
+ *
300
+ * @param array $rgb
301
+ */
302
+ public function backgroundColor($rgb = null)
303
+ {
304
+ if ($this->isActive()) {
305
+ $this->_settings['background_color'] = is_array($rgb) ? implode(',', $rgb) : $rgb;
306
+ $this->_imageObject->backgroundColor($rgb);
307
+ }
308
+
309
+ return $this;
310
+ }
311
+
312
+ /**
313
+ * Determine whether the image object has been initialised
314
+ *
315
+ * @return bool
316
+ */
317
+ public function isActive()
318
+ {
319
+ return is_object($this->_imageObject);
320
+ }
321
+
322
+ /**
323
+ * Upload an image based on the $fileKey
324
+ *
325
+ * @param string $fileKey
326
+ * @param string|null $filename - set a custom filename
327
+ * @return null|string - returns saved filename
328
+ */
329
+ public function uploadImage($fileKey, $filename = null)
330
+ {
331
+ try {
332
+ $uploader = new Varien_File_Uploader($fileKey);
333
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
334
+ $uploader->setAllowRenameFiles(true);
335
+ $result = $uploader->save($this->getBaseImagePath());
336
+
337
+ return $result['file'];
338
+ }
339
+ catch (Exception $e) {
340
+ if (version_compare(Mage::getVersion(), '1.5.0.0', '<')) {
341
+ if ($e->getMessage() != 'File was not uploaded.') {
342
+ throw $e;
343
+ }
344
+ }
345
+ else {
346
+ if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
347
+ throw $e;
348
+ }
349
+ }
350
+ }
351
+
352
+ return null;
353
+ }
354
+ }
app/code/community/Fishpig/AttributeSplash/Model/Abstract.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ abstract class Fishpig_AttributeSplash_Model_Abstract extends Mage_Core_Model_Abstract
10
+ {
11
+ /**
12
+ * Retrieve the name of the splash page
13
+ * If display name isn't set, option value label will be returned
14
+ *
15
+ * @return string
16
+ */
17
+ public function getName()
18
+ {
19
+ return $this->getDisplayName() ? $this->getDisplayName() : $this->getFrontendLabel();
20
+ }
21
+
22
+ /**
23
+ * Retrieve the URL for the splash page
24
+ * If cannot find rewrite, return system URL
25
+ *
26
+ * @return string
27
+ */
28
+ protected function _getUrl($uri)
29
+ {
30
+ $url = Mage::getUrl('', array(
31
+ '_direct' => $uri,
32
+ '_secure' => false,
33
+ '_nosid' => true,
34
+ '_store' => $this->getStoreId(),
35
+ ));
36
+
37
+ if ($this->getStoreId() === 0 || Mage::getStoreConfigFlag('web/seo/use_rewrites')) {
38
+ $url = str_replace('/' . basename($_SERVER['SCRIPT_FILENAME']), '', $url);
39
+ }
40
+
41
+ if (Mage::getStoreConfigFlag('web/url/use_store') && $this->getStoreId() === 0) {
42
+ $url = str_replace('/admin/', '/', $url);
43
+ }
44
+
45
+ return $url;
46
+ }
47
+
48
+ /**
49
+ * Retrieve the URL Base
50
+ * This is used for url_key field in the Admin
51
+ *
52
+ * @return string
53
+ */
54
+ public function getUrlBase()
55
+ {
56
+ if (substr($this->_resourceName, -5) === 'group' || !Mage::getStoreConfigFlag('attributeSplash/page/include_group_url_key')) {
57
+ return $this->_getUrl('');
58
+ }
59
+
60
+ if ($this->getSplashGroup()) {
61
+ return $this->_getUrl(
62
+ $this->getSplashGroup()->getUrlKey() . '/'
63
+ );
64
+ }
65
+
66
+ return $this->_getUrl(
67
+ $this->getAttributeModel()->getAttributeCode() . '/'
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Retrieve the URL suffix from the config
73
+ *
74
+ * @return string
75
+ */
76
+ static public function getUrlSuffix()
77
+ {
78
+ return Mage::getStoreConfig('attributeSplash/seo/url_suffix');
79
+ }
80
+
81
+ /**
82
+ * Retrieve the description
83
+ * If $process is true, output will be filtered
84
+ *
85
+ * @param bool $process = true
86
+ * @return string
87
+ */
88
+ public function getDescription($process = true)
89
+ {
90
+ if ($process) {
91
+ return Mage::helper('cms')->getBlockTemplateProcessor()->filter($this->getData('description'));
92
+ }
93
+
94
+ return $this->getData('description');
95
+ }
96
+
97
+ /**
98
+ * Retrieve the short_description
99
+ *
100
+ * @return string
101
+ */
102
+ public function getShortDescription()
103
+ {
104
+ return Mage::helper('cms')->getBlockTemplateProcessor()->filter($this->getData('short_description'));
105
+ }
106
+
107
+ /**
108
+ * Retrieve the Meta description.
109
+ * If empty, use the short description
110
+ *
111
+ * @return string
112
+ */
113
+ public function getMetaDescription()
114
+ {
115
+ return $this->getData('meta_description') ? $this->getData('meta_description') : strip_tags($this->getShortDescription());
116
+ }
117
+
118
+ /**
119
+ * Retrieve the date/time the item was updated
120
+ *
121
+ * @param bool $includeTime = true
122
+ * @return string
123
+ */
124
+ public function getUpdatedAt($includeTime = true)
125
+ {
126
+ if ($str = $this->_getData('updated_at')) {
127
+ return $includeTime ? $str : trim(substr($str, 0, strpos($str, ' ')));
128
+ }
129
+
130
+ return '';
131
+ }
132
+
133
+ /**
134
+ * Retrieve the date/time the item was created
135
+ *
136
+ * @param bool $includeTime = true
137
+ * @return string
138
+ */
139
+ public function getCreatedAt($includeTime = true)
140
+ {
141
+ if ($str = $this->_getData('created_at')) {
142
+ return $includeTime ? $str : trim(substr($str, 0, strpos($str, ' ')));
143
+ }
144
+
145
+ return '';
146
+ }
147
+
148
+ /**
149
+ * Retrieve the menu node ID
150
+ *
151
+ * @return string
152
+ */
153
+ public function getMenuNodeId()
154
+ {
155
+ return 'splash-' . substr($this->_resourceName, strpos($this->_resourceName, '/')+1) . $this->getId();
156
+ }
157
+
158
+ /**
159
+ * Retrieve the store ID of the splash page
160
+ * This isn't always the only store it's associated with
161
+ * but the current store ID
162
+ *
163
+ * @return int
164
+ */
165
+ public function getStoreId()
166
+ {
167
+ if (!$this->hasStoreId() || (int)$this->_getData('store_id') === 0) {
168
+ return (int)Mage::app()->getStore(true)->getId();
169
+ }
170
+
171
+ return (int)$this->_getData('store_id');
172
+ }
173
+
174
+ /**
175
+ * Determine whether object has a store ID of 0
176
+ *
177
+ * @return bool
178
+ */
179
+ public function isGlobal()
180
+ {
181
+ if ($storeIds = $this->getStoreIds()) {
182
+ foreach($storeIds as $storeId) {
183
+ if ((int)$storeId === 0) {
184
+ return true;
185
+ }
186
+ }
187
+ }
188
+
189
+ return false;
190
+ }
191
+
192
+ /**
193
+ * Determine whether to include the object in the menu
194
+ *
195
+ * @return bool
196
+ */
197
+ public function canIncludeInMenu()
198
+ {
199
+ return (int)$this->_getData('include_in_menu') !== 0;
200
+ }
201
+
202
+ /**
203
+ * Get the category used for layered navigation category filters
204
+ *
205
+ * @return false|Mage_Catalog_Model_Category
206
+ */
207
+ public function getCategory()
208
+ {
209
+ if (!$this->hasCategory()) {
210
+ $this->setCategory(false);
211
+
212
+ if ($this->getCategoryId()) {
213
+ $category = Mage::getModel('catalog/category')
214
+ ->setStoreId($this->getStoreId())
215
+ ->load($this->getCategoryId());
216
+
217
+ if ($category->getId()) {
218
+ $this->setCategory($category);
219
+ }
220
+ }
221
+ }
222
+
223
+ return $this->_getData('category');
224
+ }
225
+ }
app/code/community/Fishpig/AttributeSplash/Model/Group.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Group extends Fishpig_AttributeSplash_Model_Abstract
10
+ {
11
+ /**
12
+ * Setup the model's resource
13
+ *
14
+ * @return void
15
+ */
16
+ public function _construct()
17
+ {
18
+ $this->_init('attributeSplash/group');
19
+ }
20
+
21
+ /**
22
+ * Retrieve the name of the splash page
23
+ * If display name isn't set, option value label will be returned
24
+ *
25
+ * @return string
26
+ */
27
+ public function getName()
28
+ {
29
+ return $this->getDisplayName() ? $this->getDisplayName() : $this->getFrontendLabel();
30
+ }
31
+
32
+ /**
33
+ * Determine whether the model is active
34
+ *
35
+ * @return bool
36
+ */
37
+ public function isActive()
38
+ {
39
+ return (($group = Mage::registry('splash_group')) !== null)
40
+ && $group->getId() === $this->getId();
41
+ }
42
+
43
+ /**
44
+ * Retrieve the URL for the splash group
45
+ * If cannot find rewrite, return system URL
46
+ *
47
+ * @return string
48
+ */
49
+ public function getUrl()
50
+ {
51
+ if (!$this->hasUrl()) {
52
+ $this->setUrl(
53
+ $this->_getUrl($this->getUrlKey() . $this->getUrlSuffix())
54
+ );
55
+ }
56
+
57
+ return $this->_getData('url');
58
+ }
59
+
60
+ /**
61
+ * Retrieve the attribute model for the page
62
+ *
63
+ * @return Mage_Eav_Model_Entity_Attribute
64
+ */
65
+ public function getAttributeModel()
66
+ {
67
+ if (!$this->hasAttributeModel()) {
68
+ $this->setAttributeModel($this->getResource()->getAttributeModel($this));
69
+ }
70
+
71
+ return $this->getData('attribute_model');
72
+ }
73
+
74
+ /**
75
+ * Retrieve a collection of products associated with the splash page
76
+ *
77
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
78
+ */
79
+ public function getSplashPages()
80
+ {
81
+ return $this->getResource()->getSplashPages($this);
82
+ }
83
+
84
+ /**
85
+ * Determine whether this group has any splash pages
86
+ *
87
+ * @return bool
88
+ */
89
+ public function hasSplashPages()
90
+ {
91
+ return count($this->getSplashPages()) > 0;
92
+ }
93
+
94
+ /**
95
+ * Retrieve the date/time the item was updated
96
+ *
97
+ * @param bool $includeTime = true
98
+ * @return string
99
+ */
100
+ public function getUpdatedAt($includeTime = true)
101
+ {
102
+ if ($str = $this->_getData('updated_at')) {
103
+ return $includeTime ? $str : trim(substr($str, 0, strpos($str, ' ')));
104
+ }
105
+
106
+ return '';
107
+ }
108
+
109
+ /**
110
+ * Retrieve the date/time the item was created
111
+ *
112
+ * @param bool $includeTime = true
113
+ * @return string
114
+ */
115
+ public function getCreatedAt($includeTime = true)
116
+ {
117
+ if ($str = $this->_getData('created_at')) {
118
+ return $includeTime ? $str : trim(substr($str, 0, strpos($str, ' ')));
119
+ }
120
+
121
+ return '';
122
+ }
123
+
124
+ /**
125
+ * Determine whether it's possible to delete the group
126
+ *
127
+ * @return bool
128
+ */
129
+ public function canDelete()
130
+ {
131
+ return $this->getResource()->canDelete($this);
132
+ }
133
+ }
app/code/community/Fishpig/AttributeSplash/Model/Indexer.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Indexer extends Mage_Index_Model_Indexer_Abstract
10
+ {
11
+ /**
12
+ *
13
+ * @var array
14
+ */
15
+ protected $_matchedEntities = array(
16
+ 'attributeSplash_page' => array(
17
+ Mage_Index_Model_Event::TYPE_SAVE
18
+ ),
19
+ 'attributeSplash_group' => array(
20
+ Mage_Index_Model_Event::TYPE_SAVE
21
+ )
22
+ );
23
+
24
+ /**
25
+ * Get the indexer name
26
+ *
27
+ * @return string
28
+ */
29
+ public function getName()
30
+ {
31
+ return Mage::helper('core')->__('Attribute Splash');
32
+ }
33
+
34
+ /**
35
+ * Get the indexer description
36
+ *
37
+ * @return string
38
+ */
39
+ public function getDescription()
40
+ {
41
+ return Mage::helper('core')->__('Attribute Splash page/group/store combination data.');
42
+ }
43
+
44
+ /**
45
+ * Abstract methods. required
46
+ *
47
+ * @return void
48
+ */
49
+ protected function _registerEvent(Mage_Index_Model_Event $event) {}
50
+ protected function _processEvent(Mage_Index_Model_Event $event) {}
51
+
52
+ /**
53
+ * Reindex all Splash entities
54
+ *
55
+ * @return $this
56
+ */
57
+ public function reindexAll()
58
+ {
59
+ Mage::getResourceModel('attributeSplash/group')->reindexAll();
60
+ Mage::getResourceModel('attributeSplash/page')->reindexAll();
61
+ }
62
+ }
app/code/community/Fishpig/AttributeSplash/Model/Layer.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Layer extends Mage_Catalog_Model_Layer
10
+ {
11
+ /**
12
+ * Retrieve the current category
13
+ *
14
+ * @return Mage_Catalog_Model_Category
15
+ */
16
+ public function getCurrentCategory()
17
+ {
18
+ if (!$this->hasCurrentCategory()) {
19
+ if ($category = $this->getSplashPage()->getCategory()) {
20
+ $this->setData('current_category', $category);
21
+ }
22
+ }
23
+
24
+ return parent::getCurrentCategory();
25
+ }
26
+
27
+ /**
28
+ * Retrieve the splash page
29
+ * We add an array to children_categories so that it can act as a category
30
+ *
31
+ * @return false|Fishpig_AttributeSplashPro_Model_Page
32
+ */
33
+ public function getSplashPage()
34
+ {
35
+ if ($page = Mage::registry('splash_page')) {
36
+ return $page;
37
+ }
38
+
39
+ return false;
40
+ }
41
+
42
+ /**
43
+ * Get the state key for caching
44
+ *
45
+ * @return string
46
+ */
47
+ public function getStateKey()
48
+ {
49
+ if ($this->_stateKey === null) {
50
+ $this->_stateKey = 'STORE_'.Mage::app()->getStore()->getId()
51
+ . '_SPLASH_' . $this->getSplashPage()->getId()
52
+ . '_CUSTGROUP_' . Mage::getSingleton('customer/session')->getCustomerGroupId();
53
+ }
54
+
55
+ return $this->_stateKey;
56
+ }
57
+
58
+ /**
59
+ * Get default tags for current layer state
60
+ *
61
+ * @param array $additionalTags
62
+ * @return array
63
+ */
64
+ public function getStateTags(array $additionalTags = array())
65
+ {
66
+ $additionalTags = array_merge($additionalTags, array(
67
+ Mage_Catalog_Model_Category::CACHE_TAG.$this->getSplashPage()->getId()
68
+ ));
69
+
70
+ return $additionalTags;
71
+ }
72
+
73
+ /**
74
+ * Retrieve the product collection for the Splash Page
75
+ *
76
+ * @return
77
+ */
78
+ public function getProductCollection()
79
+ {
80
+ $key = 'splash_' . $this->getSplashPage()->getId();
81
+
82
+ if (isset($this->_productCollections[$key])) {
83
+ $collection = $this->_productCollections[$key];
84
+ }
85
+ else {
86
+ $collection = $this->getSplashPage()->getProductCollection();
87
+ $this->prepareProductCollection($collection);
88
+ $this->_productCollections[$key] = $collection;
89
+ }
90
+
91
+ return $collection;
92
+ }
93
+
94
+ /**
95
+ * Stop the splash page attribute from dsplaying in the filter options
96
+ *
97
+ * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute_Collection $collection
98
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute_Collection
99
+ */
100
+ protected function _prepareAttributeCollection($collection)
101
+ {
102
+ parent::_prepareAttributeCollection($collection);
103
+
104
+ if ($splash = $this->getSplashPage()) {
105
+ $collection->addFieldToFilter('attribute_code', array('neq' => $splash->getAttributeCode()));
106
+ }
107
+
108
+ return $collection;
109
+ }
110
+ }
app/code/community/Fishpig/AttributeSplash/Model/Observer.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Observer
10
+ {
11
+ /**
12
+ * Inject links into the top navigation
13
+ *
14
+ * @param Varien_Event_Observer $observer
15
+ * @return $this
16
+ */
17
+ public function injectTopmenuLinksObserver(Varien_Event_Observer $observer)
18
+ {
19
+ if (Mage::getStoreConfigFlag('attributeSplash/navigation/enabled')) {
20
+ $groups = Mage::getResourceModel('attributeSplash/group_collection')
21
+ ->addStoreFilter(Mage::app()->getStore()->getId())
22
+ ->addOrderByName()
23
+ ->load();
24
+
25
+ $this->_injectLinks($groups, $observer->getEvent()->getMenu());
26
+ }
27
+
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Inject links into the top navigation
33
+ *
34
+ * @param Mage_Core_Model_Resource_Db_Collection_Abstract $items
35
+ * @param Varien_Data_Tree_Node $parentNode
36
+ * @return bool
37
+ */
38
+ protected function _injectLinks($items, $parentNode)
39
+ {
40
+ if (!$parentNode) {
41
+ return false;
42
+ }
43
+
44
+ foreach($items as $item) {
45
+ if (!$item->canIncludeInMenu()) {
46
+ continue;
47
+ }
48
+
49
+ $data = array(
50
+ 'name' => $item->getName(),
51
+ 'id' => $item->getMenuNodeId(),
52
+ 'url' => $item->getUrl(),
53
+ 'is_active' => $item->isActive(),
54
+ );
55
+
56
+ if ($data['is_active']) {
57
+ $parentNode->setIsActive(true);
58
+ $buffer = $parentNode;
59
+
60
+ while($buffer->getParent()) {
61
+ $buffer = $buffer->getParent();
62
+ $buffer->setIsActive(true);
63
+ }
64
+ }
65
+
66
+ $itemNode = new Varien_Data_Tree_Node($data, 'id', $parentNode->getTree(), $parentNode);
67
+ $parentNode->addChild($itemNode);
68
+
69
+ $children = $item->getSplashPages();
70
+
71
+ if ($children) {
72
+ $children->addOrderByName()
73
+ ->addFieldToFilter('include_in_menu', 1)
74
+ ->load();
75
+
76
+ $this->_injectLinks($children, $itemNode);
77
+ }
78
+ }
79
+
80
+ return true;
81
+ }
82
+
83
+ /**
84
+ * Remove the e.visibility where part
85
+ *
86
+ * @param Varien_Event_Observer $observer
87
+ * @return $this
88
+ */
89
+ public function prepareCatalogPriceSelectObserver(Varien_Event_Observer $observer)
90
+ {
91
+ $where = $observer->getEvent()
92
+ ->getSelect()
93
+ ->getPart(Zend_Db_Select::WHERE);
94
+
95
+ foreach($where as $key => $value) {
96
+ if (strpos($value, 'e.visibility') !== false) {
97
+ unset($where[$key]);
98
+ break;
99
+ }
100
+ }
101
+
102
+ $observer->getEvent()
103
+ ->getSelect()
104
+ ->setPart(Zend_Db_Select::WHERE, $where);
105
+
106
+ return $this;
107
+ }
108
+
109
+ public function fseoLayeredNavigationMatchEntityObserver(Varien_Event_Observer $observer)
110
+ {
111
+ $doubleBarrel = Mage::getStoreConfigFlag('attributeSplash/page/include_group_url_key');
112
+
113
+ $urlKey = $observer->getEvent()->getRequestUri();
114
+ $urlSuffix = Fishpig_AttributeSplash_Model_Page::getUrlSuffix();
115
+
116
+ if ($urlSuffix && $urlSuffix !== '/') {
117
+ if (substr($urlKey, -strlen($urlSuffix)) !== $urlSuffix) {
118
+ return false;
119
+ }
120
+
121
+ $urlKey = substr($urlKey, 0, -strlen($urlSuffix));
122
+ }
123
+
124
+ $expectedSlashCount = 1 + (int)$doubleBarrel;
125
+
126
+ if (substr_count($urlKey, '/') < $expectedSlashCount) {
127
+ return false;
128
+ }
129
+
130
+ if ($doubleBarrel) {
131
+ $baseUrlKey = substr($urlKey, 0, strpos($urlKey, '/', strpos($urlKey, '/')+1));
132
+ list($groupUrlKey, $pageUrlKey) = explode('/', $baseUrlKey);
133
+ }
134
+ else {
135
+ $baseUrlKey = substr($urlKey, 0, strpos($urlKey, '/'));
136
+ $groupUrlKey = null;
137
+ $pageUrlKey = null;
138
+ }
139
+
140
+ $splashIds = Mage::getResourceModel('attributeSplash/page')->getPageAndGroupIdByUrlKeys($pageUrlKey, $groupUrlKey);
141
+
142
+ if (!$splashIds) {
143
+ return false;
144
+ }
145
+
146
+ list($pageId, $groupId) = array_values($splashIds);
147
+
148
+ $tokens = explode('/', trim(substr($urlKey, strlen($baseUrlKey)), '/'));
149
+
150
+ $observer->getEvent()->getTransport()
151
+ ->setEntityData(
152
+ new Varien_Object(array(
153
+ 'entity_id' => $pageId,
154
+ 'entity_type' => 'attributeSplash_page',
155
+ 'entity_url_key' => $baseUrlKey,
156
+ 'url_suffix' => $urlSuffix,
157
+ 'tokens' => $tokens,
158
+ 'module_name' => 'splash',
159
+ 'controller_name' => 'page',
160
+ 'action_name' => 'view',
161
+ 'params' => array(
162
+ 'id' => $pageId,
163
+ 'group_id' => $groupId,
164
+ )
165
+ )));
166
+
167
+ return $this;
168
+ }
169
+ }
app/code/community/Fishpig/AttributeSplash/Model/Page.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Page extends Fishpig_AttributeSplash_Model_Abstract
10
+ {
11
+ /**
12
+ * Setup the model's resource
13
+ *
14
+ * @return void
15
+ */
16
+ public function _construct()
17
+ {
18
+ $this->_init('attributeSplash/page');
19
+ }
20
+
21
+ /**
22
+ * Retrieve the URL for the splash page
23
+ * If cannot find rewrite, return system URL
24
+ *
25
+ * @return string
26
+ */
27
+ public function getUrl()
28
+ {
29
+ if ($this->hasUrl()) {
30
+ return $this->_getData('url');
31
+ }
32
+
33
+ $uri = (Mage::getStoreConfigFlag('attributeSplash/page/include_group_url_key')
34
+ ? $this->getSplashGroup()->getUrlKey() . '/' : '')
35
+ . $this->getUrlKey() . $this->getUrlSuffix();
36
+
37
+ return $this->_getUrl($uri);
38
+ }
39
+
40
+ /**
41
+ * Determine whether the model is active
42
+ *
43
+ * @return bool
44
+ */
45
+ public function isActive()
46
+ {
47
+ return (($page = Mage::registry('splash_page')) !== null)
48
+ && $page->getId() === $this->getId();
49
+ }
50
+
51
+ /**
52
+ * Retrieve the full URL of the splash image
53
+ *
54
+ * @return string
55
+ */
56
+ public function getImage()
57
+ {
58
+ return Mage::helper('attributeSplash/image')->getImageUrl($this->getData('image'));
59
+ }
60
+
61
+ /**
62
+ * Retrieve the URL for the image
63
+ * This converts relative URL's to absolute
64
+ *
65
+ * @return string
66
+ */
67
+ public function getImageUrl()
68
+ {
69
+ if ($this->_getData('image_url')) {
70
+ if (strpos($this->_getData('image_url'), 'http://') === false) {
71
+ $this->setImageUrl(Mage::getBaseUrl() . ltrim($this->_getData('image_url'), '/ '));
72
+ }
73
+ }
74
+
75
+ return $this->_getData('image_url');
76
+ }
77
+
78
+ /**
79
+ * Retrieve the full URL of the splash thumbnail
80
+ *
81
+ * @return string
82
+ */
83
+ public function getThumbnail()
84
+ {
85
+ return Mage::helper('attributeSplash/image')->getImageUrl($this->getData('thumbnail'));
86
+ }
87
+
88
+ /**
89
+ * Retrieve the attribute model for the page
90
+ *
91
+ * @return Mage_Eav_Model_Entity_Attribute
92
+ */
93
+ public function getAttributeModel()
94
+ {
95
+ if (!$this->hasAttributeModel()) {
96
+ $this->setAttributeModel(
97
+ Mage::getModel('eav/entity_attribute')->load($this->getAttributeId())
98
+ );
99
+ }
100
+
101
+ return $this->getData('attribute_model');
102
+ }
103
+
104
+ /**
105
+ * Retrieve a collection of products associated with the splash page
106
+ *
107
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
108
+ */
109
+ public function getProductCollection()
110
+ {
111
+ if (!$this->hasProductCollection()) {
112
+ $this->setProductCollection($this->getResource()->getProductCollection($this));
113
+ }
114
+
115
+ return $this->getData('product_collection');
116
+ }
117
+
118
+ /**
119
+ * Retrieve the group associated with the splash page
120
+ * This will retrieve the most related group
121
+ * If there isn't a group for the same store, the admin group will be returned
122
+ *
123
+ * @return Fishpig_AttributeSplash_Model_Group|false
124
+ */
125
+ public function getSplashGroup()
126
+ {
127
+ if (!$this->hasSplashGroup()) {
128
+ $this->setSplashGroup($this->getResource()->getSplashGroup($this));
129
+ }
130
+
131
+ return $this->getData('splash_group');
132
+ }
133
+
134
+ public function getCategory()
135
+ {
136
+ if (($category = parent::getCategory()) !== false) {
137
+ return $category;
138
+ }
139
+
140
+ return $this->getSplashGroup()->getCategory();
141
+ }
142
+ }
app/code/community/Fishpig/AttributeSplash/Model/Resource/Abstract.php ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ abstract class Fishpig_AttributeSplash_Model_Resource_Abstract extends Mage_Core_Model_Resource_Db_Abstract
10
+ {
11
+ /**
12
+ * Retrieve the name of the unique field
13
+ *
14
+ * @return string
15
+ */
16
+ abstract public function getUniqueFieldName();
17
+
18
+ /**
19
+ * Retreieve the name of the index table
20
+ *
21
+ * @return string
22
+ */
23
+ abstract public function getIndexTable();
24
+
25
+ /**
26
+ * Retrieve select object for load object data
27
+ * This gets the default select, plus the attribute id and code
28
+ *
29
+ * @param string $field
30
+ * @param mixed $value
31
+ * @return Zend_Db_Select
32
+ */
33
+ protected function _getLoadSelect($field, $value, $object)
34
+ {
35
+ $select = $this->_getReadAdapter()->select()
36
+ ->from(array('main_table' => $this->getMainTable()))
37
+ ->where("`main_table`.`{$field}` = ?", $value)
38
+ ->limit(1);
39
+
40
+ $adminId = Mage_Core_Model_App::ADMIN_STORE_ID;
41
+
42
+ $storeId = $object->getStoreId();
43
+
44
+ if ($storeId !== $adminId) {
45
+ $cond = $this->_getReadAdapter()->quoteInto(
46
+ '`store`.`' . $this->getIdFieldName() . '` = `main_table`.`' . $this->getIdFieldName() . '` AND `store`.`store_id` IN (?)', array($adminId, $storeId)
47
+ );
48
+
49
+ $select->join(array('store' => $this->getStoreTable()), $cond, '')
50
+ ->order('store.store_id DESC');
51
+ }
52
+
53
+ return $select;
54
+ }
55
+
56
+ /**
57
+ * Get store ids to which specified item is assigned
58
+ *
59
+ * @param int $id
60
+ * @return array
61
+ */
62
+ public function lookupStoreIds($objectId)
63
+ {
64
+ $select = $this->_getReadAdapter()->select()
65
+ ->from($this->getStoreTable(), 'store_id')
66
+ ->where($this->getIdFieldName() . ' = ?', (int)$objectId);
67
+
68
+ return $this->_getReadAdapter()->fetchCol($select);
69
+ }
70
+
71
+ /**
72
+ * Determine whether the current store is the Admin store
73
+ *
74
+ * @return bool
75
+ */
76
+ public function isAdmin()
77
+ {
78
+ return (int)Mage::app()->getStore()->getId() === Mage_Core_Model_App::ADMIN_STORE_ID;
79
+ }
80
+
81
+ /**
82
+ * Set required fields before saving model
83
+ *
84
+ * @param Mage_Core_Model_Abstract $object
85
+ * @return $this
86
+ */
87
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
88
+ {
89
+ if (!$object->getDisplayName()) {
90
+ if (!$object->getFrontendLabel()) {
91
+ throw new Exception(Mage::helper('attributeSplash')->__('Splash object must have a name'));
92
+ }
93
+ else {
94
+ $object->setDisplayName($object->getFrontendLabel());
95
+ }
96
+ }
97
+
98
+ if ($object->getCategoryId()) {
99
+ $category = Mage::getModel('catalog/category')->load($object->getCategoryId());
100
+
101
+ if (!$category->getId()) {
102
+ $object->setCategoryId(null);
103
+ }
104
+ }
105
+ else {
106
+ $object->setCategoryId(null);
107
+ }
108
+
109
+ if (!$object->getUrlKey()) {
110
+ $object->setUrlKey($object->getname());
111
+ }
112
+
113
+ $object->setUrlKey($this->formatUrlKey($object->getUrlKey()));
114
+
115
+ $object->setUpdatedAt(now());
116
+
117
+ if (!$object->getCreatedAt()) {
118
+ $object->setCreatedAt(now());
119
+ }
120
+
121
+ return parent::_beforeSave($object);
122
+ }
123
+
124
+ /**
125
+ * Set store data after saving model
126
+ *
127
+ * @param Mage_Core_Model_Abstract $object
128
+ * @return $this
129
+ */
130
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
131
+ {
132
+ if ($object->getId()) {
133
+ $oldStores = $this->lookupStoreIds($object->getId());
134
+ $newStores = (array)$object->getStoreIds();
135
+
136
+ if (empty($newStores)) {
137
+ $newStores = (array)$object->getStoreId();
138
+ }
139
+
140
+ $table = $this->getStoreTable();
141
+ $insert = array_diff($newStores, $oldStores);
142
+ $delete = array_diff($oldStores, $newStores);
143
+
144
+ if ($delete) {
145
+ $this->_getWriteAdapter()->delete($table, array($this->getIdFieldName() . ' = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete));
146
+ }
147
+
148
+ if ($insert) {
149
+ $data = array();
150
+
151
+ foreach ($insert as $storeId) {
152
+ $data[] = array(
153
+ $this->getIdFieldName() => (int) $object->getId(),
154
+ 'store_id' => (int) $storeId
155
+ );
156
+ }
157
+
158
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
159
+ }
160
+
161
+ if (!$object->getSkipReindex()) {
162
+ $object->getResource()->reindexAll();
163
+ }
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Load store data after loading model
169
+ *
170
+ * @param Mage_Core_Model_Abstract $object
171
+ * @return $this
172
+ */
173
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
174
+ {
175
+ if ($object->getId()) {
176
+ $storeIds = $this->lookupStoreIds($object->getId());
177
+ $object->setData('store_ids', $storeIds);
178
+
179
+ if (!$this->isAdmin()) {
180
+ $object->setStoreId(Mage::app()->getStore(true)->getId());
181
+ }
182
+ }
183
+
184
+ return parent::_afterLoad($object);
185
+ }
186
+
187
+ /**
188
+ * Reindex all
189
+ *
190
+ * @return $this
191
+ */
192
+ public function reindexAll()
193
+ {
194
+ $stores = Mage::getResourceModel('core/store_collection')->load();
195
+
196
+ foreach($stores as $store) {
197
+ $this->reindexAllByStoreId($store->getId());
198
+ }
199
+
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * Reindex all by store ID
205
+ *
206
+ * @param int $storeId
207
+ * @return $this
208
+ */
209
+ public function reindexAllByStoreId($storeId)
210
+ {
211
+ $this->_getWriteAdapter()->delete($this->getIndexTable(), $this->_getWriteAdapter()->quoteInto('store_id=?', $storeId));
212
+
213
+ $subselect = $this->_getReadAdapter()
214
+ ->select()
215
+ ->from(array('main_table' => $this->getMainTable()), array($this->getIdFieldName(), $this->getUniqueFieldName()))
216
+ ->join(
217
+ array('_store' => $this->getStoreTable()),
218
+ '_store.' . $this->getIdFieldName() . '=main_table.' . $this->getIdFieldName(),
219
+ ''
220
+ )
221
+ ->where('_store.store_id IN (?)', array($storeId, 0))
222
+ ->order('_store.store_id DESC');
223
+
224
+ $select = $this->_getReadAdapter()->select()
225
+ ->from(array('main_table' => new Zend_Db_Expr('(' . (string)$subselect . ')')), $this->getIdFieldName())
226
+ ->columns(array('store_id' => new Zend_Db_Expr("'" . $storeId . "'")))
227
+ ->group($this->getUniqueFieldName());
228
+
229
+ if ($objectIds = $this->_getReadAdapter()->fetchAll($select)) {
230
+ $this->_getWriteAdapter()->insertMultiple($this->getIndexTable(), $objectIds);
231
+ }
232
+
233
+ return $this;
234
+ }
235
+
236
+ /**
237
+ * Format a string to a valid URL key
238
+ * Allow a-zA-Z0-9, hyphen and /
239
+ *
240
+ * @param string $str
241
+ * @return string
242
+ */
243
+ public function formatUrlKey($str)
244
+ {
245
+ $urlKey = str_replace("'", '', $str);
246
+ $urlKey = preg_replace('#[^0-9a-z\/]+#i', '-', Mage::helper('catalog/product_url')->format($urlKey));
247
+ $urlKey = strtolower($urlKey);
248
+ $urlKey = trim($urlKey, '-');
249
+
250
+ return $urlKey;
251
+ }
252
+ }
app/code/community/Fishpig/AttributeSplash/Model/Resource/Collection/Abstract.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <ben@fishpig.co.uk>
7
+ */
8
+
9
+ abstract class Fishpig_AttributeSplash_Model_Resource_Collection_Abstract extends Mage_Core_Model_Resource_Db_Collection_Abstract
10
+ {
11
+ /**
12
+ * Init the entity type
13
+ *
14
+ */
15
+ public function _construct()
16
+ {
17
+ $this->_map['fields'][$this->getResource()->getIdFieldName()] = 'main_table.' . $this->getResource()->getIdFieldName();
18
+ $this->_map['fields']['store'] = 'store_table.store_id';
19
+ }
20
+
21
+ /**
22
+ * Init collection select
23
+ *
24
+ * @return Mage_Core_Model_Resource_Collection_Abstract
25
+ */
26
+ protected function _initSelect()
27
+ {
28
+ $this->getSelect()->from(array('main_table' => $this->getResource()->getMainTable()));
29
+
30
+ $idFieldName = $this->getResource()->getIdFieldName();
31
+
32
+ if ((int)Mage::app()->getStore()->getId() !== 0) {
33
+ $this->getSelect()
34
+ ->join(array('store_table' => $this->getResource()->getIndexTable()),
35
+ 'main_table.' . $idFieldName . ' = store_table.' . $idFieldName,
36
+ array()
37
+ );
38
+ }
39
+ else {
40
+ $this->getSelect()->join(
41
+ array('store_table' => $this->getResource()->getStoreTable()),
42
+ 'main_table.' . $idFieldName . ' = store_table.' . $idFieldName,
43
+ array()
44
+ )->group('main_table.' . $idFieldName);
45
+ }
46
+
47
+ return $this->getSelect();
48
+ }
49
+
50
+ /**
51
+ * Add a store filter
52
+ *
53
+ * @param int $store
54
+ * @return $this
55
+ */
56
+ public function addStoreIdFilter($store)
57
+ {
58
+ return $this->addStoreFilter($store);
59
+ }
60
+
61
+ /**
62
+ * Add filter by store
63
+ *
64
+ * @param int|Mage_Core_Model_Store $store
65
+ * @param bool $withAdmin
66
+ * @return Mage_Cms_Model_Resource_Page_Collection
67
+ */
68
+ public function addStoreFilter($store, $withAdmin = true)
69
+ {
70
+ if ($store instanceof Mage_Core_Model_Store) {
71
+ $store = array($store->getId());
72
+ }
73
+
74
+ if (!is_array($store)) {
75
+ $store = array($store);
76
+ }
77
+
78
+ if ($withAdmin) {
79
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
80
+ }
81
+
82
+ return $this->addFieldtoFilter('store_table.store_id', array('in' => $store));
83
+ }
84
+
85
+ /**
86
+ * Filter the collection by attribute Code
87
+ *
88
+ * @param string $attributeCode
89
+ * @return $this
90
+ */
91
+ public function addAttributeCodeFilter($attributeCode)
92
+ {
93
+ return $this->addFieldToFilter('attribute_code', $attributeCode);
94
+ }
95
+
96
+ /**
97
+ * Filter the collection by attribute ID
98
+ *
99
+ * @param int $attributeId
100
+ * @return $this
101
+ */
102
+ public function addAttributeIdFilter($attributeId)
103
+ {
104
+ return $this->addFieldToFilter('attribute_id', $attributeId);
105
+ }
106
+
107
+ /**
108
+ * Filter the collection so only enabled pages are returned
109
+ *
110
+ * @param int $value = 1
111
+ * @return $this
112
+ */
113
+ public function addIsEnabledFilter($value = 1)
114
+ {
115
+ return $this->addFieldToFilter('is_enabled', $value);
116
+ }
117
+
118
+ /**
119
+ * Get SQL for get record count
120
+ * Modified because model uses GROUP BY
121
+ *
122
+ * @return Varien_Db_Select
123
+ */
124
+ public function getSelectCountSql()
125
+ {
126
+ return parent::getSelectCountSql()
127
+ ->reset(Zend_Db_Select::GROUP);
128
+ }
129
+ }
app/code/community/Fishpig/AttributeSplash/Model/Resource/Group.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Resource_Group extends Fishpig_AttributeSplash_Model_Resource_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ $this->_init('attributeSplash/group', 'group_id');
14
+ }
15
+
16
+ /**
17
+ * Retrieve select object for load object data
18
+ * This gets the default select, plus the attribute id and code
19
+ *
20
+ * @param string $field
21
+ * @param mixed $value
22
+ * @return Zend_Db_Select
23
+ */
24
+ protected function _getLoadSelect($field, $value, $object)
25
+ {
26
+ return parent::_getLoadSelect($field, $value, $object)
27
+ ->join(
28
+ array('_attribute_table' => $this->getTable('eav/attribute')),
29
+ '`_attribute_table`.`attribute_id` = `main_table`.`attribute_id`',
30
+ array('attribute_code', 'frontend_label')
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Retrieve the store table for the group model
36
+ *
37
+ * @return string
38
+ */
39
+ public function getStoreTable()
40
+ {
41
+ return $this->getTable('attributeSplash/group_store');
42
+ }
43
+
44
+ /**
45
+ * Retrieve the name of the unique field
46
+ *
47
+ * @return string
48
+ */
49
+ public function getUniqueFieldName()
50
+ {
51
+ return 'attribute_id';
52
+ }
53
+
54
+ /**
55
+ * Retrieve the attribute model for the group
56
+ *
57
+ * @param Fishpig_AttributeSplash_Model_Group $group
58
+ * @return Mage_Eav_Model_Entity_Attribute
59
+ */
60
+ public function getAttributeModel(Fishpig_AttributeSplash_Model_Group $group)
61
+ {
62
+ return $group->getAttributeId()
63
+ ? Mage::getModel('eav/entity_attribute')->load($group->getAttributeId())
64
+ : false;
65
+ }
66
+
67
+ /**
68
+ * Retrieve a collection of splash pages that belong to this group
69
+ *
70
+ * @param Fishpig_AttributeSplash_Model_Group $group
71
+ * @return Fishpig_AttributeSplash_Model_Resource_Page_Collection
72
+ */
73
+ public function getSplashPages(Fishpig_AttributeSplash_Model_Group $group)
74
+ {
75
+ $pages = Mage::getResourceModel('attributeSplash/page_collection')
76
+ ->addIsEnabledFilter();
77
+
78
+ if ($group->getStoreId() > 0) {
79
+ $pages->addStoreFilter($group->getStoreId());
80
+ }
81
+ else if (($storeId = Mage::app()->getStore()->getId()) > 0) {
82
+ $pages->addStoreFilter($storeId);
83
+ }
84
+
85
+ return $pages->addAttributeIdFilter($group->getAttributeId());
86
+ }
87
+
88
+ /**
89
+ * Get the index table name
90
+ *
91
+ * @return string
92
+ */
93
+ public function getIndexTable()
94
+ {
95
+ return $this->getTable('attributeSplash/group_index');
96
+ }
97
+
98
+ /**
99
+ * Determine whether the group can be deleted
100
+ *
101
+ * @param Fishpig_AttributeSplash_Model_Group $group
102
+ * @return bool
103
+ */
104
+ public function canDelete(Fishpig_AttributeSplash_Model_Group $group)
105
+ {
106
+ if (!$group->isGlobal()) {
107
+ return true;
108
+ }
109
+
110
+ $select = $this->_getReadAdapter()->select()
111
+ ->from(array('main_table' => $this->getTable('eav/attribute_option')), 'option_id')
112
+ ->join(
113
+ array('_splash' => $this->getTable('attributeSplash/page')),
114
+ '_splash.option_id = main_table.option_id'
115
+ )
116
+ ->where('main_table.attribute_id=?', $group->getAttributeModel()->getId())
117
+ ->limit(1);
118
+
119
+
120
+ return $this->_getReadAdapter()->fetchOne($select) === false;
121
+ }
122
+ }
app/code/community/Fishpig/AttributeSplash/Model/Resource/Group/Collection.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Resource_Group_Collection extends Fishpig_AttributeSplash_Model_Resource_Collection_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ $this->_init('attributeSplash/group');
14
+
15
+ $this->_map['fields']['attribute_id'] = '_attribute_table.attribute_id';
16
+ $this->_map['fields']['attribute_code'] = '_attribute_table.attribute_code';
17
+
18
+ return parent::_construct();
19
+ }
20
+
21
+ /**
22
+ * Init collection select
23
+ *
24
+ * @return Mage_Core_Model_Resource_Collection_Abstract
25
+ */
26
+ protected function _initSelect()
27
+ {
28
+ parent::_initSelect();
29
+
30
+ $this->getSelect()->join(
31
+ array('_attribute_table' => $this->getTable('eav/attribute')),
32
+ '`_attribute_table`.`attribute_id` = `main_table`.`attribute_id`',
33
+ array('attribute_code', 'frontend_label')
34
+ );
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Order the groups by name
41
+ *
42
+ * @return $this
43
+ */
44
+ public function addOrderByName()
45
+ {
46
+ $this->getSelect()->order('main_table.display_name ASC');
47
+ $this->getSelect()->order('_attribute_table.frontend_label ASC');
48
+
49
+ return $this;
50
+ }
51
+ }
app/code/community/Fishpig/AttributeSplash/Model/Resource/Page.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Resource_Page extends Fishpig_AttributeSplash_Model_Resource_Abstract
10
+ {
11
+ /**
12
+ * Fields to be serialized before saving
13
+ * This applies to the filter fields
14
+ *
15
+ * @var array
16
+ */
17
+ protected $_serializableFields = array(
18
+ 'other' => array('a:0:{}', array()),
19
+ );
20
+
21
+ public function _construct()
22
+ {
23
+ $this->_init('attributeSplash/page', 'page_id');
24
+ }
25
+
26
+ /**
27
+ * Retrieve select object for load object data
28
+ * This gets the default select, plus the attribute id and code
29
+ *
30
+ * @param string $field
31
+ * @param mixed $value
32
+ * @return Zend_Db_Select
33
+ */
34
+ protected function _getLoadSelect($field, $value, $object)
35
+ {
36
+ $select = parent::_getLoadSelect($field, $value, $object)
37
+ ->join(array('_option_table' => $this->getTable('eav/attribute_option')), '`_option_table`.`option_id` = `main_table`.`option_id`', '')
38
+ ->join(array('_attribute_table' => $this->getTable('eav/attribute')), '`_attribute_table`.`attribute_id`=`_option_table`.`attribute_id`', array('attribute_id', 'attribute_code', 'frontend_label'));
39
+
40
+ return $select;
41
+ }
42
+
43
+ /**
44
+ * Retrieve the store table name
45
+ *
46
+ * @return string
47
+ */
48
+ public function getStoreTable()
49
+ {
50
+ return $this->getTable('attributeSplash/page_store');
51
+ }
52
+
53
+ /**
54
+ * Retrieve the name of the unique field
55
+ *
56
+ * @return string
57
+ */
58
+ public function getUniqueFieldName()
59
+ {
60
+ return 'option_id';
61
+ }
62
+
63
+ /**
64
+ * Retrieve a collection of products associated with the splash page
65
+ *
66
+ * @return Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection
67
+ */
68
+ public function getProductCollection(Fishpig_AttributeSplash_Model_Page $page)
69
+ {
70
+ $collection = Mage::getResourceModel('catalog/product_collection')
71
+ ->setStoreId($page->getStoreId())
72
+ ->addAttributeToFilter('status', 1)
73
+ ->addAttributeToFilter('visibility', array('in' => array(
74
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
75
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH
76
+ )));
77
+
78
+ $alias = $page->getAttributeCode().'_index';
79
+
80
+ $collection->getSelect()
81
+ ->join(
82
+ array($alias => $this->getTable('catalog/product_index_eav')),
83
+ "`{$alias}`.`entity_id` = `e`.`entity_id`"
84
+ . $this->_getReadAdapter()->quoteInto(" AND `{$alias}`.`attribute_id` = ? ", $page->getAttributeId())
85
+ . $this->_getReadAdapter()->quoteInto(" AND `{$alias}`.`store_id` = ? ", $page->getStoreId())
86
+ . $this->_getReadAdapter()->quoteInto(" AND `{$alias}`.`value` = ?", $page->getOptionId()),
87
+ ''
88
+ );
89
+
90
+ if (!Mage::getStoreConfigFlag('cataloginventory/options/show_out_of_stock', $page->getStoreId())) {
91
+ Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
92
+ }
93
+
94
+ return $collection;
95
+ }
96
+
97
+ /**
98
+ * Set required fields before saving model
99
+ *
100
+ * @param Mage_Core_Model_Abstract $object
101
+ * @return $this
102
+ */
103
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
104
+ {
105
+ if (!$object->getData('store_ids')) {
106
+ $object->setData('store_ids', array(Mage::app()->getStore(true)->getId()));
107
+ }
108
+
109
+ if ($object->getId()) {
110
+ $object->getAttributeModel();
111
+
112
+ $object->unsetData('attribute_id');
113
+ }
114
+
115
+ if (!$this->_pageIsUniqueToStores($object)) {
116
+ throw new Exception('A page already exists for this attribute and store combination.');
117
+ }
118
+
119
+ return parent::_beforeSave($object);
120
+ }
121
+
122
+ /**
123
+ * Determine whether [ages scope if unique to store
124
+ *
125
+ * @param Mage_Core_Model_Abstract $object
126
+ * @return bool
127
+ */
128
+ protected function _pageIsUniqueToStores(Mage_Core_Model_Abstract $object)
129
+ {
130
+ if (Mage::app()->isSingleStoreMode() || !$object->hasStoreIds()) {
131
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
132
+ }
133
+ else {
134
+ $stores = (array)$object->getData('store_ids');
135
+ }
136
+
137
+ $select = $this->_getReadAdapter()
138
+ ->select()
139
+ ->from(array('main_table' => $this->getMainTable()), 'page_id')
140
+ ->join(array('_store' => $this->getStoreTable()), 'main_table.page_id = _store.page_id', '')
141
+ ->where('option_id=?', $object->getOptionId())
142
+ ->limit(1);
143
+
144
+ if (count($stores) === 1) {
145
+ $select->where('_store.store_id = ?', array_shift($stores));
146
+ }
147
+ else {
148
+ $select->where('_store.store_id IN (?)', $stores);
149
+ }
150
+
151
+ if ($object->getId()) {
152
+ $select->where('main_table.page_id <> ?', $object->getId());
153
+ }
154
+
155
+ return $this->_getWriteAdapter()->fetchOne($select) === false;
156
+ }
157
+
158
+ /**
159
+ * Auto-update splash group
160
+ *
161
+ * @param Mage_Core_Model_Abstract $object
162
+ * @return $this
163
+ */
164
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
165
+ {
166
+ parent::_afterSave($object);
167
+
168
+ if (!$object->getSkipAutoCreateGroup()) {
169
+ $this->updateSplashGroup($object);
170
+ }
171
+
172
+ return $this;
173
+ }
174
+
175
+ /**
176
+ * Check whether the attribute group exists
177
+ * If not, create the group
178
+ *
179
+ * @param Fishpig_AttributeSPlash_Model_Page $page
180
+ */
181
+ public function updateSplashGroup(Fishpig_AttributeSplash_Model_Page $page)
182
+ {
183
+ if (!$page->getSplashGroup()) {
184
+ $group = Mage::getModel('attributeSplash/group')
185
+ ->setAttributeId($page->getAttributeModel()->getId())
186
+ ->setDisplayName($page->getAttributeModel()->getFrontendLabel())
187
+ ->setStoreId(0)
188
+ ->setIsEnabled(1);
189
+
190
+ try {
191
+ $group->save();
192
+ }
193
+ catch (Exception $e) {
194
+ Mage::helper('attributeSplash')->log($e->getMessage());
195
+ }
196
+ }
197
+
198
+ return $this;
199
+ }
200
+
201
+ /**
202
+ * Retrieve the group associated with the splash page
203
+ * This will retrieve the most related group
204
+ * If there isn't a group for the same store, the admin group will be returned
205
+ *
206
+ * @param Fishpig_AttributeSplash_Model_Page $page
207
+ * @return Fishpig_AttributeSplash_Model_Group|false
208
+ */
209
+ public function getSplashGroup(Fishpig_AttributeSplash_Model_Page $page)
210
+ {
211
+ $groups = Mage::getResourceModel('attributeSplash/group_collection')
212
+ ->addAttributeIdFilter($page->getAttributeModel()->getAttributeId())
213
+ ->addStoreFilter($page->getStoreId())
214
+ ->setCurPage(1)
215
+ ->setPageSize(1)
216
+ ->load();
217
+
218
+ return count($groups) > 0
219
+ ? $groups->getFirstItem()
220
+ : false;
221
+ }
222
+
223
+ /**
224
+ * After loading object get other values
225
+ *
226
+ * @param Mage_Core_Model_Abstract $object
227
+ * @return $this
228
+ */
229
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
230
+ {
231
+ parent::_afterLoad($object);
232
+
233
+ $other = $object->getOther();
234
+
235
+ if (is_array($other)) {
236
+ foreach($other as $key => $value) {
237
+ if (!$object->hasData($key)) {
238
+ $object->setData($key, $value);
239
+ }
240
+ }
241
+ }
242
+
243
+ return $this;
244
+ }
245
+
246
+ /**
247
+ * Get the index table for pags
248
+ *
249
+ * @return string
250
+ */
251
+ public function getIndexTable()
252
+ {
253
+ return $this->getTable('attributeSplash/page_index');
254
+ }
255
+
256
+ /**
257
+ * Given a page URL key and maybe a group url key and store id,
258
+ * return page and group IDS
259
+ *
260
+ * @param string $pageUrlKey
261
+ * @param string $groupUrlKey = null
262
+ * @param int $storeId = null
263
+ * @return false|array
264
+ */
265
+ public function getPageAndGroupIdByUrlKeys($pageUrlKey, $groupUrlKey = null, $storeId = null)
266
+ {
267
+ if (is_null($storeId)) {
268
+ $storeId = Mage::app()->getStore()->getId();
269
+ }
270
+
271
+ $select = $this->_getReadAdapter()
272
+ ->select()
273
+ ->from(array('_index' => $this->getIndexTable()), 'page_id')
274
+ ->where('store_id=?', $storeId);
275
+
276
+ // Join page URL Key
277
+ $select->join(
278
+ array('_page' => $this->getMainTable()),
279
+ $this->_getReadAdapter()->quoteInto('_index.page_id=_page.page_id AND _page.url_key= ?', $pageUrlKey),
280
+ ''//array('page_url_key' => 'url_key')
281
+ );
282
+
283
+ $select->where('_page.is_enabled=?', 1);
284
+
285
+ if (!is_null($groupUrlKey)) {
286
+ // Join Attribute and Option tables
287
+ $select->join(
288
+ array('_option' => $this->getTable('eav/attribute_option')),
289
+ '_page.option_id=_option.option_id',
290
+ ''
291
+ )->join(
292
+ array('_attribute' => $this->getTable('eav/attribute')),
293
+ '_attribute.attribute_id=_option.attribute_id',
294
+ ''
295
+ );
296
+
297
+ // Join group URL Key
298
+ $select->join(
299
+ array('_group' => $this->getTable('attributeSplash/group')),
300
+ '_group.attribute_id=_attribute.attribute_id',
301
+ array('group_id')//array('group_url_key' => 'url_key', 'group_id')
302
+ );
303
+
304
+ // Remove results with no group URL key
305
+ $select->where('_group.url_key <> ?', '');
306
+ }
307
+
308
+ if ($results = $this->_getReadAdapter()->fetchAll($select)) {
309
+ if (count($results) === 1) {
310
+ return array_shift($results);
311
+ }
312
+
313
+ echo $select . '<br/><br/>';
314
+ echo sprintf('<pre>%s</pre>', print_r($results, true));
315
+ exit('more than 1 result.');
316
+ }
317
+
318
+ return false;
319
+ }
320
+ }
app/code/community/Fishpig/AttributeSplash/Model/Resource/Page/Collection.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_Resource_Page_Collection extends Fishpig_AttributeSplash_Model_Resource_Collection_Abstract
10
+ {
11
+ /**
12
+ * Setup the collection model
13
+ *
14
+ * @return $this
15
+ */
16
+ public function _construct()
17
+ {
18
+ $this->_init('attributeSplash/page');
19
+
20
+ $this->_map['fields']['attribute_id'] = '_attribute_table.attribute_id';
21
+ $this->_map['fields']['attribute_code'] = '_attribute_table.attribute_code';
22
+ $this->_map['fields']['option_id'] = 'main_table.option_id';
23
+
24
+ return parent::_construct();
25
+ }
26
+
27
+ /**
28
+ * Init collection select
29
+ *
30
+ * @return Mage_Core_Model_Resource_Collection_Abstract
31
+ */
32
+ protected function _initSelect()
33
+ {
34
+ parent::_initSelect();
35
+
36
+ $this->getSelect()->join(
37
+ array('_option_table' => $this->getTable('eav/attribute_option')),
38
+ '`_option_table`.`option_id` = `main_table`.`option_id`',
39
+ ''
40
+ )
41
+ ->join(
42
+ array('_attribute_table' => $this->getTable('eav/attribute')),
43
+ '`_attribute_table`.`attribute_id` = `_option_table`.`attribute_id`',
44
+ array('attribute_id', 'attribute_code', 'frontend_label')
45
+ );
46
+
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Order Splash Pges by the option value sort order field
52
+ *
53
+ * @return $this
54
+ */
55
+ public function addOrderBySortOrder()
56
+ {
57
+ $this->getSelect()->order('_option_table.sort_order ASC');
58
+ $this->getSelect()->order('display_name ASC');
59
+
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Filter the collection by a product ID
65
+ *
66
+ * @param Mage_Catalog_Model_Product $product
67
+ * @param int $storeId = null
68
+ * @return $this
69
+ */
70
+ public function addProductFilter(Mage_Catalog_Model_Product $product, $storeId = null)
71
+ {
72
+ if (is_null($storeId)) {
73
+ $storeId = Mage::app()->getStore()->getId();
74
+ }
75
+
76
+ $this->getSelect()
77
+ ->join(
78
+ array('_product_filter' => $this->getTable('catalog/product_index_eav')),
79
+ "`_product_filter`.`attribute_id`= `_attribute_table`.`attribute_id` AND `_product_filter`.`value` = `main_table`.`option_id`"
80
+ . $this->getConnection()->quoteInto(" AND `_product_filter`.`entity_id` = ?", $product->getId())
81
+ . $this->getConnection()->quoteInto(" AND `_product_filter`.`store_id`=? ", $storeId),
82
+ ''
83
+ );
84
+
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Order the groups by name
90
+ *
91
+ * @return $this
92
+ */
93
+ public function addOrderByName()
94
+ {
95
+ $this->getSelect()->order('main_table.display_name ASC');
96
+
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * After loading the collection, perform the afterLoad resource method on each item
102
+ *
103
+ * @return $this
104
+ */
105
+ protected function _afterLoad()
106
+ {
107
+ $this->walk('afterLoad');
108
+
109
+ return parent::_afterLoad();
110
+ }
111
+ }
app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Attribute/Abstract.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ abstract class Fishpig_AttributeSplash_Model_System_Config_Source_Attribute_Abstract
10
+ {
11
+ /**
12
+ * Cache for options
13
+ *
14
+ * @param
15
+ */
16
+ protected $_options = null;
17
+
18
+ /**
19
+ * Cache for collection
20
+ *
21
+ * @param
22
+ */
23
+ protected $_collection = null;
24
+
25
+ /**
26
+ * Cache for attribute options
27
+ *
28
+ * @var array
29
+ */
30
+ protected $_attributes = null;
31
+
32
+ /**
33
+ * Field name used for the label value of the options
34
+ *
35
+ * @var string
36
+ */
37
+ protected $_labelField = 'frontend_label';
38
+
39
+ /**
40
+ * Generate, cache and retrieve the collection
41
+ *
42
+ * @return
43
+ */
44
+ abstract public function getCollection();
45
+
46
+ /**
47
+ * Set the label field
48
+ *
49
+ * @param string $field
50
+ * @return $this
51
+ */
52
+ public function setLabelField($field)
53
+ {
54
+ if ($this->_labelField !== $field) {
55
+ $this->_options = null;
56
+ }
57
+
58
+ $this->_labelField = $field;
59
+
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Retrieve an option array of results
65
+ *
66
+ * @return array
67
+ */
68
+ public function toOptionArray($includeEmpty = false)
69
+ {
70
+ if (is_null($this->_options)) {
71
+ foreach($this->getCollection() as $attribute) {
72
+ $this->_options[] = array(
73
+ 'value' => $attribute->getAttributeId(),
74
+ 'label' => $attribute->getData($this->_labelField),
75
+ );
76
+ }
77
+ }
78
+
79
+ if ($includeEmpty) {
80
+ array_unshift($this->_options, array('value' => '', 'label' => Mage::helper('adminhtml')->__('-- Please Select --')));
81
+
82
+ }
83
+
84
+ return (array)$this->_options;
85
+ }
86
+
87
+ /**
88
+ * Retrieve an option hash
89
+ *
90
+ * @return array
91
+ */
92
+ public function toOptionHash()
93
+ {
94
+ $hash = array();
95
+
96
+ foreach($this->toOptionArray() as $option) {
97
+ $hash[$option['value']] = $option['label'];
98
+ }
99
+
100
+ return $hash;
101
+
102
+ }
103
+ }
app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Attribute/Splashable.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_System_Config_Source_Attribute_Splashable extends Fishpig_AttributeSplash_Model_System_Config_Source_Attribute_Abstract
10
+ {
11
+ /**
12
+ * Generate, cache and retrieve the collection
13
+ *
14
+ * @return
15
+ */
16
+ public function getCollection()
17
+ {
18
+ if (is_null($this->_collection)) {
19
+ $this->_collection = Mage::getResourceModel('eav/entity_attribute_collection')
20
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
21
+ ->addFieldToFilter('frontend_input', array('in' => array('select', 'multiselect')));
22
+
23
+ $this->_collection->getSelect()
24
+ ->where('`main_table`.`source_model` IS NULL OR `main_table`.`source_model` IN (?)', array('', 'eav/entity_attribute_source_table'))
25
+ ->order('main_table.frontend_label ASC');
26
+
27
+ }
28
+
29
+ return $this->_collection;
30
+ }
31
+ }
app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Attribute/Splashed.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_System_Config_Source_Attribute_Splashed extends Fishpig_AttributeSplash_Model_System_Config_Source_Attribute_Splashable
10
+ {
11
+ /**
12
+ * Generate, cache and retrieve the collection
13
+ *
14
+ * @return
15
+ */
16
+ public function getCollection()
17
+ {
18
+ if (is_null($this->_collection)) {
19
+ parent::getCollection()->getSelect()
20
+ ->distinct(true)
21
+ ->join(
22
+ array('_splash_group' => Mage::getSingleton('core/resource')->getTableName('attributeSplash/group')),
23
+ '_splash_group.attribute_id=main_table.attribute_id',
24
+ ''
25
+ );
26
+ }
27
+
28
+ return $this->_collection;
29
+ }
30
+ }
app/code/community/Fishpig/AttributeSplash/Model/System/Config/Source/Layout.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Model_System_Config_Source_Layout
10
+ {
11
+ public function toOptionArray()
12
+ {
13
+ $options = Mage::getModel('page/source_layout')->toOptionArray(false);
14
+
15
+ array_unshift($options, array(
16
+ 'value'=>'',
17
+ 'label'=>Mage::helper('adminhtml')->__('No layout updates')
18
+ ));
19
+
20
+ return $options;
21
+ }
22
+ }
app/code/community/Fishpig/AttributeSplash/controllers/Adminhtml/AttributeSplash/GroupController.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Adminhtml_AttributeSplash_GroupController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ /**
12
+ * Forward the request to the dashboard
13
+ *
14
+ * @return $this
15
+ */
16
+ public function indexAction()
17
+ {
18
+ return $this->_redirect('*/attributeSplash');
19
+ }
20
+
21
+ /**
22
+ * Add a new splash group
23
+ *
24
+ * @return $this
25
+ */
26
+ public function newAction()
27
+ {
28
+ return $this->_forward('edit');
29
+ }
30
+
31
+ /**
32
+ * Display the add/edit form for the splash group
33
+ *
34
+ * @return void
35
+ */
36
+ public function editAction()
37
+ {
38
+ $splash = $this->_initSplashGroup();
39
+ $this->loadLayout();
40
+ $this->_setActiveMenu('attributeSplash');
41
+
42
+ $this->_title('FishPig');
43
+ $this->_title('Attribute Splash');
44
+ $this->_title($this->__('Group'));
45
+
46
+ if ($splash) {
47
+ $this->_title($splash->getName());
48
+ }
49
+
50
+ $this->renderLayout();
51
+ }
52
+
53
+ /**
54
+ * Save the posted data
55
+ *
56
+ * @return void
57
+ */
58
+ public function saveAction()
59
+ {
60
+ if ($data = $this->getRequest()->getPost('splash')) {
61
+ $group = Mage::getModel('attributeSplash/group')
62
+ ->setData($data)
63
+ ->setId($this->getRequest()->getParam('id'));
64
+
65
+ try {
66
+ $group->save();
67
+ $this->_getSession()->addSuccess($this->__('Splash group was saved'));
68
+ }
69
+ catch (Exception $e) {
70
+ $this->_getSession()->addError($this->__($e->getMessage()));
71
+ }
72
+
73
+ if ($group->getId() && $this->getRequest()->getParam('back', false)) {
74
+ $this->_redirect('*/*/edit', array('id' => $group->getId()));
75
+ return;
76
+ }
77
+ }
78
+ else {
79
+ $this->_getSession()->addError($this->__('There was no data to save.'));
80
+ }
81
+
82
+ $this->_redirect('*/attributeSplash');
83
+ }
84
+
85
+ /**
86
+ * Initialise the splash group model
87
+ *
88
+ * @return false|Fishpig_AttributeSplash_Model_Group
89
+ */
90
+ protected function _initSplashGroup()
91
+ {
92
+ if (($group = Mage::registry('splash_group')) !== null) {
93
+ return $group;
94
+ }
95
+
96
+ if ($id = $this->getRequest()->getParam('id')) {
97
+ $group = Mage::getModel('attributeSplash/group')->load($id);
98
+
99
+ if ($group->getId()) {
100
+ Mage::register('splash_group', $group);
101
+ return $group;
102
+ }
103
+ }
104
+
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * Attempt to delete the group model
110
+ *
111
+ */
112
+ public function deleteAction()
113
+ {
114
+ $group = Mage::getModel('attributeSplash/group')->load($this->getRequest()->getParam('id'));
115
+
116
+ if ($group->getId() && $group->canDelete()) {
117
+ try {
118
+ $group->delete();
119
+ $this->_getSession()->addSuccess($this->__('Group was deleted'));
120
+ }
121
+ catch (Exception $e) {
122
+ $this->_getSession()->addError($this->__($e->getMessage()));
123
+ }
124
+ }
125
+
126
+ $this->_redirect('*/attributeSplash');
127
+ }
128
+ }
app/code/community/Fishpig/AttributeSplash/controllers/Adminhtml/AttributeSplash/PageController.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Adminhtml_AttributeSplash_PageController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ /**
12
+ * Forward the request to the dashboard
13
+ *
14
+ * @return $this
15
+ */
16
+ public function indexAction()
17
+ {
18
+ return $this->_redirect('*/attributeSplash');
19
+ }
20
+
21
+ /**
22
+ * Add a new splash page
23
+ *
24
+ * @return $this
25
+ */
26
+ public function newAction()
27
+ {
28
+ return $this->_forward('edit');
29
+ }
30
+
31
+ /**
32
+ * Display the add/edit form for the splash page
33
+ *
34
+ */
35
+ public function editAction()
36
+ {
37
+ $splash = $this->_initSplashPage();
38
+
39
+ $this->loadLayout();
40
+ $this->_setActiveMenu('attributeSplash');
41
+
42
+ $this->_title('FishPig');
43
+ $this->_title('Attribute Splash');
44
+ $this->_title($this->__('Page'));
45
+
46
+ if ($splash) {
47
+ $this->_title($splash->getName());
48
+ }
49
+
50
+ $this->renderLayout();
51
+ }
52
+
53
+ protected function _initValidAttributeSessionMessage()
54
+ {
55
+ if (($page = $this->_initSplashPage()) !== false) {
56
+ if ($page->getAttributeModel() && !$page->getAttributeModel()->getData('is_filterable')) {
57
+ $page->getAttributeModel()->setIsFilterable(1)->save();
58
+ }
59
+ }
60
+
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Save the posted data
66
+ *
67
+ */
68
+ public function saveAction()
69
+ {
70
+ if ($data = $this->getRequest()->getPost('splash')) {
71
+ $page = Mage::getModel('attributeSplash/page')
72
+ ->setData($data)
73
+ ->setId($this->getRequest()->getParam('id'));
74
+
75
+ try {
76
+ $this->_handleImageUpload($page, 'image');
77
+ $this->_handleImageUpload($page, 'thumbnail');
78
+
79
+ $page->save();
80
+ $this->_getSession()->addSuccess($this->__('Splash page was saved'));
81
+
82
+ $this->_initValidAttributeSessionMessage();
83
+ }
84
+ catch (Exception $e) {
85
+ $this->_getSession()->addError($this->__($e->getMessage()));
86
+ }
87
+
88
+ if ($page->getId() && $this->getRequest()->getParam('back', false)) {
89
+ return $this->_redirect('*/*/edit', array('id' => $page->getId()));
90
+ }
91
+
92
+ return $this->_redirect('*/attributeSplash');
93
+ }
94
+
95
+ $this->_getSession()->addError($this->__('There was no data to save.'));
96
+
97
+ return $this->_redirect('*/attributeSplash');
98
+ }
99
+
100
+ public function optionsAction()
101
+ {
102
+ try {
103
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $this->getRequest()->getParam('attribute', 0));
104
+
105
+ if (!$attribute->getId()) {
106
+ throw new Exception(Mage::helper('adminhtml')->__('This attribute no longer exists.'));
107
+ }
108
+
109
+
110
+ $this->getResponse()
111
+ ->setBody(
112
+ Mage::helper('core')->jsonEncode(array('options' => $attribute->getSource()->getAllOptions(false)))
113
+ );
114
+ }
115
+ catch (Exception $e) {
116
+ $this->getResponse()
117
+ ->setBody(
118
+ Mage::helper('core')->jsonEncode(array('error' => $e->getMessage()))
119
+ );
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Delete a splash page
125
+ *
126
+ */
127
+ public function deleteAction()
128
+ {
129
+ if ($pageId = $this->getRequest()->getParam('id')) {
130
+ $splashPage = Mage::getModel('attributeSplash/page')->load($pageId);
131
+
132
+ if ($splashPage->getId()) {
133
+ try {
134
+ $splashPage->delete();
135
+ $this->_getSession()->addSuccess($this->__('The Splash Page was deleted.'));
136
+ }
137
+ catch (Exception $e) {
138
+ $this->_getSession()->addError($e->getMessage());
139
+ }
140
+ }
141
+ }
142
+
143
+ $this->_redirect('*/attributeSplash');
144
+ }
145
+
146
+ public function massDeleteAction()
147
+ {
148
+ $pageIds = $this->getRequest()->getParam('page');
149
+
150
+ if (!is_array($pageIds)) {
151
+ $this->_getSession()->addError($this->__('Please select page(s).'));
152
+ }
153
+ else {
154
+ if (!empty($pageIds)) {
155
+ try {
156
+ foreach ($pageIds as $pageId) {
157
+ $page = Mage::getSingleton('attributeSplash/page')->load($pageId);
158
+
159
+ if ($page->getId()) {
160
+ Mage::dispatchEvent('attributeSplash_controller_page_delete', array('splash_page' => $page, 'page' => $page));
161
+
162
+ $page->delete();
163
+ }
164
+ }
165
+
166
+ $this->_getSession()->addSuccess($this->__('Total of %d record(s) have been deleted.', count($pageIds)));
167
+ }
168
+ catch (Exception $e) {
169
+ $this->_getSession()->addError($e->getMessage());
170
+ }
171
+ }
172
+ }
173
+
174
+ $this->_redirect('*/attributeSplash');
175
+ }
176
+
177
+ /**
178
+ * Initialise the splash page model
179
+ *
180
+ * @return false|Fishpig_AttributeSplash_Model_Page
181
+ */
182
+ protected function _initSplashPage()
183
+ {
184
+ if (($page = Mage::registry('splash_page')) !== null) {
185
+ return $page;
186
+ }
187
+
188
+ if ($id = $this->getRequest()->getParam('id')) {
189
+ $page = Mage::getModel('attributeSplash/page')->load($id);
190
+
191
+ if ($page->getId()) {
192
+ Mage::register('splash_page', $page);
193
+ return $page;
194
+ }
195
+ }
196
+
197
+ return false;
198
+ }
199
+
200
+ protected function _handleImageUpload(Fishpig_AttributeSplash_Model_Page $page, $field)
201
+ {
202
+ $data = $page->getData($field);
203
+
204
+ if (isset($data['value'])) {
205
+ $page->setData($field, $data['value']);
206
+ }
207
+
208
+ if (isset($data['delete']) && $data['delete'] == '1') {
209
+ $page->setData($field, '');
210
+ }
211
+
212
+ if ($filename = Mage::helper('attributeSplash/image')->uploadImage($field)) {
213
+ $page->setData($field, $filename);
214
+ }
215
+ }
216
+ }
app/code/community/Fishpig/AttributeSplash/controllers/Adminhtml/AttributeSplashController.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_Adminhtml_AttributeSplashController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ /**
12
+ * Display a grid of splash groups
13
+ *
14
+ */
15
+ public function indexAction()
16
+ {
17
+ $this->loadLayout();
18
+
19
+ $this->_title('FishPig');
20
+ $this->_title($this->__('Attribute Splash'));
21
+
22
+ $this->_setActiveMenu('attributeSplash');
23
+ $this->renderLayout();
24
+ }
25
+
26
+ /**
27
+ * Display the grid of splash groups without the container (header, footer etc)
28
+ * This is used to modify the grid via AJAX
29
+ *
30
+ */
31
+ public function groupGridAction()
32
+ {
33
+ $this->getResponse()
34
+ ->setBody(
35
+ $this->getLayout()->createBlock('attributeSplash/adminhtml_group_grid')->toHtml()
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Display the grid of splash pages without the container (header, footer etc)
41
+ * This is used to modify the grid via AJAX
42
+ *
43
+ */
44
+ public function pageGridAction()
45
+ {
46
+ $this->getResponse()
47
+ ->setBody(
48
+ $this->getLayout()->createBlock('attributeSplash/adminhtml_page_grid')->toHtml()
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Display the Extend tab
54
+ *
55
+ * @return void
56
+ */
57
+ public function extendAction()
58
+ {
59
+ $block = $this->getLayout()
60
+ ->createBlock('attributeSplash/adminhtml_extend')
61
+ ->setModule('Fishpig_AttributeSplash')
62
+ ->setMedium('Add-On Tab')
63
+ ->setTemplate('large.phtml')
64
+ ->setLimit(4)
65
+ ->setPreferred(array('Fishpig_AttributeSplash_Addon_QuickCreate', 'Fishpig_AttributeSplash_Addon_XmlSitemap', 'Fishpig_CrossLink', 'Fishpig_AttributeSplashPro', 'Fishpig_NoBots'));
66
+
67
+ $this->getResponse()
68
+ ->setBody(
69
+ $block->toHtml()
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Call an addon method
75
+ *
76
+ * @return void
77
+ */
78
+ public function addonAction()
79
+ {
80
+ $module = $this->getRequest()->getParam('module');
81
+ $data = $this->getRequest()->getPost($module);
82
+
83
+ if (!$module || !$data) {
84
+ return $this->_redirectReferer();
85
+ }
86
+
87
+ $helper = Mage::helper('attributeSplash_addon_' . $module);
88
+
89
+ if (!$helper) {
90
+ return $this->_redirectReferer();
91
+ }
92
+
93
+ try {
94
+ if (($count = $helper->process($data)) > 0) {
95
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('%d page(s) were created.', $count));
96
+ }
97
+ else {
98
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('0 pages were created due to conflicts with existing pages.'));
99
+ }
100
+ }
101
+ catch (Exception $e) {
102
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
103
+ }
104
+
105
+ return $this->_redirectReferer();
106
+ }
107
+ }
app/code/community/Fishpig/AttributeSplash/controllers/GroupController.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_GroupController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ public function viewAction()
12
+ {
13
+ if ($splashGroup = $this->_initSplashGroup()) {
14
+ $this->_applyCustomViewLayout($splashGroup);
15
+
16
+ if ($rootBlock = $this->getLayout()->getBlock('root')) {
17
+ $rootBlock->addBodyClass('splash-group-' . $splashGroup->getId());
18
+ }
19
+
20
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
21
+ if ($title = $splashGroup->getPageTitle()) {
22
+ $headBlock->setTitle($title);
23
+ }
24
+ else {
25
+ $this->_title($splashGroup->getDisplayName());
26
+ }
27
+
28
+ if ($description = $splashGroup->getMetaDescription()) {
29
+ $headBlock->setDescription($description);
30
+ }
31
+
32
+ if ($keywords = $splashGroup->getMetaKeywords()) {
33
+ $headBlock->setKeywords($keywords);
34
+ }
35
+
36
+ $headBlock->addItem('link_rel', $splashGroup->getUrl(), 'rel="canonical"');
37
+ }
38
+
39
+ if ($breadBlock = $this->getLayout()->getBlock('breadcrumbs')) {
40
+ $breadBlock->addCrumb('home', array('label' => $this->__('Home'), 'title' => $this->__('Home'), 'link' => Mage::getUrl()));
41
+ $breadBlock->addCrumb('splash_group', array('label' => $splashGroup->getName(), 'title' => $splashGroup->getName()));
42
+ }
43
+
44
+ $this->renderLayout();
45
+ }
46
+ else {
47
+ $this->_forward('noRoute');
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Apply custom layout handles to the splash page
53
+ *
54
+ * @param Fishpig_AttribtueSplash_Model_Page $splashPage
55
+ * @return Fishpig_AttribtueSplash_PageController
56
+ */
57
+ protected function _applyCustomViewLayout(Fishpig_AttributeSplash_Model_Group $splashGroup)
58
+ {
59
+ $update = $this->getLayout()->getUpdate();
60
+
61
+ $update->addHandle('default');
62
+ $this->addActionLayoutHandles();
63
+ $update->addHandle('attributesplash_group_view_' . $splashGroup->getId());
64
+ $update->addHandle('attributesplash_group_view_' . $splashGroup->getAttributeCode());
65
+
66
+ $this->loadLayoutUpdates();
67
+
68
+ $update->addUpdate($splashGroup->getLayoutUpdateXml());
69
+
70
+ $this->generateLayoutXml()->generateLayoutBlocks();
71
+
72
+ if ($splashGroup->getPageLayout()) {
73
+ $this->getLayout()->helper('page/layout')->applyTemplate($splashGroup->getPageLayout());
74
+ }
75
+ else if ($pageLayout = Mage::getStoreConfig('attributeSplash/group/template')) {
76
+ $this->getLayout()->helper('page/layout')->applyTemplate($pageLayout);
77
+ }
78
+
79
+ $this->_isLayoutLoaded = true;
80
+
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Initialise the Splash Gourp model
86
+ *
87
+ * @return false|Fishpig_AttributeSplash_Model_Gourp
88
+ */
89
+ protected function _initSplashGroup()
90
+ {
91
+ if (($group = Mage::registry('splash_group')) !== null) {
92
+ return $group;
93
+ }
94
+
95
+ $group = Mage::getModel('attributeSplash/group')->load(
96
+ (int) $this->getRequest()->getParam('id', false)
97
+ );
98
+
99
+ if (!$group->getId()) {
100
+ return false;
101
+ }
102
+
103
+ Mage::register('splash_group', $group);
104
+
105
+ return $group;
106
+ }
107
+ }
app/code/community/Fishpig/AttributeSplash/controllers/PageController.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_PageController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Display the splash page
13
+ *
14
+ * @return void
15
+ */
16
+ public function viewAction()
17
+ {
18
+ if (($splashPage = $this->_initSplashPage()) === false) {
19
+ return $this->_forward('noRoute');
20
+ }
21
+
22
+ // Register the splash layer model
23
+ Mage::register('current_layer', Mage::getSingleton('attributeSplash/layer'));
24
+
25
+ $this->_applyCustomViewLayout($splashPage);
26
+
27
+ if ($rootBlock = $this->getLayout()->getBlock('root')) {
28
+ $rootBlock->addBodyClass('splash-page-' . $splashPage->getId());
29
+ $rootBlock->addBodyClass('splash-page-' . $splashPage->getAttributeCode());
30
+ }
31
+
32
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
33
+ if ($title = $splashPage->getPageTitle()) {
34
+ $headBlock->setTitle($title);
35
+ }
36
+ else {
37
+ $this->_title($splashPage->getName());
38
+ }
39
+
40
+ if ($description = $splashPage->getMetaDescription()) {
41
+ $headBlock->setDescription($description);
42
+ }
43
+
44
+ if ($keywords = $splashPage->getMetaKeywords()) {
45
+ $headBlock->setKeywords($keywords);
46
+ }
47
+
48
+ $headBlock->addItem('link_rel', $splashPage->getUrl(), 'rel="canonical"');
49
+ }
50
+
51
+ if ($breadBlock = $this->getLayout()->getBlock('breadcrumbs')) {
52
+ if (!$breadBlock->getSkipSplashPageHomeCrumb()) {
53
+ $breadBlock->addCrumb('home', array('label' => $this->__('Home'), 'title' => $this->__('Home'), 'link' => Mage::getUrl()));
54
+ }
55
+
56
+ if (!$breadBlock->getSkipSplashPageGroupCrumb()) {
57
+ if ($splashGroup = $splashPage->getSplashGroup()) {
58
+ $breadBlock->addCrumb('splash_group', array('label' => $splashGroup->getName(), 'title' => $splashGroup->getName(), 'link' => $splashGroup->getUrl()));
59
+ }
60
+ }
61
+
62
+ if (!$breadBlock->getSkipSplashPageCrumb()) {
63
+ $breadBlock->addCrumb('splash_page', array('label' => $splashPage->getName(), 'title' => $splashPage->getName()));
64
+ }
65
+ }
66
+
67
+ $this->renderLayout();
68
+ }
69
+
70
+ /**
71
+ * Apply custom layout handles to the splash page
72
+ *
73
+ * @param Fishpig_AttribtueSplash_Model_Page $splashPage
74
+ * @return Fishpig_AttribtueSplash_PageController
75
+ */
76
+ protected function _applyCustomViewLayout(Fishpig_AttributeSplash_Model_Page $splashPage)
77
+ {
78
+ $update = $this->getLayout()->getUpdate();
79
+
80
+ $update->addHandle('default');
81
+
82
+ $this->addActionLayoutHandles();
83
+
84
+ $update->addHandle('attributesplash_page_view_' . $splashPage->getId());
85
+ $update->addHandle('attributesplash_page_view_' . $splashPage->getAttributeModel()->getAttributeCode());
86
+
87
+ $this->loadLayoutUpdates();
88
+
89
+ $update->addUpdate($splashPage->getLayoutUpdateXml());
90
+
91
+ $this->generateLayoutXml()->generateLayoutBlocks();
92
+
93
+ if ($splashPage->getPageLayout()) {
94
+ $this->getLayout()->helper('page/layout')->applyTemplate($splashPage->getPageLayout());
95
+ }
96
+ else if ($pageLayout = Mage::getStoreConfig('attributeSplash/page/template')) {
97
+ $this->getLayout()->helper('page/layout')->applyTemplate($pageLayout);
98
+ }
99
+
100
+ $this->_isLayoutLoaded = true;
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Initialise the Splash Page model
107
+ *
108
+ * @return false|Fishpig_AttributeSplash_Model_Page
109
+ */
110
+ protected function _initSplashPage()
111
+ {
112
+ if (($page = Mage::registry('splash_page')) !== null) {
113
+ return $page;
114
+ }
115
+
116
+ $splashPage = Mage::getModel('attributeSplash/page')
117
+ ->setStoreId(Mage::app()->getStore()->getId())
118
+ ->load((int) $this->getRequest()->getParam('id', false));
119
+
120
+ if (!$splashPage->getIsEnabled() || !$splashPage->getSplashGroup()) {
121
+ return false;
122
+ }
123
+
124
+ Mage::register('splash_page', $splashPage);
125
+
126
+ if ($group = $splashPage->getSplashGroup()) {
127
+ Mage::register('splash_group', $group);
128
+ }
129
+
130
+ return $splashPage;
131
+ }
132
+ }
app/code/community/Fishpig/AttributeSplash/controllers/SitemapController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_AttributeSplash_SitemapController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Display the splash page
13
+ *
14
+ * @return void
15
+ */
16
+ public function viewAction()
17
+ {
18
+ try {
19
+ $xmlSitemapBlock = Mage::getSingleton('core/layout')->createBlock('attributeSplash_addon_xmlsitemap/sitemap');
20
+
21
+ if (!$xmlSitemapBlock) {
22
+ throw new Exception('Required add-on (http://fishpig.co.uk/magento/extensions/attribute-splash-pages/xml-sitemap/) not installed.');
23
+ }
24
+
25
+ $output = $xmlSitemapBlock->toHtml();
26
+
27
+ return $this->getResponse()
28
+ ->setHeader('Content-Type', 'text/xml')
29
+ ->setBody($output);
30
+ }
31
+ catch (Exception $e) {
32
+ Mage::log($e->getMessage());
33
+ }
34
+
35
+ return $this->_forward('noRoute');
36
+ }
37
+ }
app/code/community/Fishpig/AttributeSplash/etc/adminhtml.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <attributeSplash translate="title" module="attributeSplash">
5
+ <title>Splash</title>
6
+ <sort_order>31</sort_order>
7
+ <children>
8
+ <dashboard translate="title">
9
+ <title>Manage Splash Pages</title>
10
+ <action>adminhtml/attributeSplash</action>
11
+ <sort_order>1</sort_order>
12
+ </dashboard>
13
+ </children>
14
+ </attributeSplash>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <attributeSplash translate="title" module="attributeSplash">
21
+ <title>Attribute Splash Pages</title>
22
+ <sort_order>120</sort_order>
23
+ <children>
24
+ <dashboard translate="title">
25
+ <title>Manage Splash Pages</title>
26
+ <sort_order>6</sort_order>
27
+ </dashboard>
28
+ </children>
29
+ </attributeSplash>
30
+ <system>
31
+ <children>
32
+ <config>
33
+ <children>
34
+ <attributeSplash translate="title" module="attributeSplash">
35
+ <title>Attribute Splash Pages</title>
36
+ <sort_order>990</sort_order>
37
+ </attributeSplash>
38
+ </children>
39
+ </config>
40
+ </children>
41
+ </system>
42
+ </children>
43
+ </admin>
44
+ </resources>
45
+ </acl>
46
+ </config>
app/code/community/Fishpig/AttributeSplash/etc/config.xml ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Fishpig_AttributeSplash>
5
+ <version>3.3.7.3</version>
6
+ </Fishpig_AttributeSplash>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <attributeSplash>
11
+ <class>Fishpig_AttributeSplash_Helper</class>
12
+ </attributeSplash>
13
+ </helpers>
14
+ <blocks>
15
+ <attributeSplash>
16
+ <class>Fishpig_AttributeSplash_Block</class>
17
+ </attributeSplash>
18
+ </blocks>
19
+ <models>
20
+ <attributeSplash>
21
+ <class>Fishpig_AttributeSplash_Model</class>
22
+ <resourceModel>attributeSplash_resource</resourceModel>
23
+ </attributeSplash>
24
+ <attributeSplash_resource>
25
+ <class>Fishpig_AttributeSplash_Model_Resource</class>
26
+ <entities>
27
+ <group><table>attributesplash_group</table></group>
28
+ <group_store><table>attributesplash_group_store</table></group_store>
29
+ <group_index><table>attributesplash_group_index</table></group_index>
30
+ <page><table>attributesplash_page</table></page>
31
+ <page_store><table>attributesplash_page_store</table></page_store>
32
+ <page_index><table>attributesplash_page_index</table></page_index>
33
+ </entities>
34
+ </attributeSplash_resource>
35
+ </models>
36
+ <resources>
37
+ <attributeSplash_setup>
38
+ <setup>
39
+ <module>Fishpig_AttributeSplash</module>
40
+ </setup>
41
+ <connection>
42
+ <use>core_setup</use>
43
+ </connection>
44
+ </attributeSplash_setup>
45
+ <attributeSplash_read>
46
+ <connection>
47
+ <use>core_read</use>
48
+ </connection>
49
+ </attributeSplash_read>
50
+ <attributeSplash_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </attributeSplash_write>
55
+ </resources>
56
+ <events>
57
+ <controller_front_init_routers>
58
+ <observers>
59
+ <attributeSplash>
60
+ <class>Fishpig_AttributeSplash_Controller_Router</class>
61
+ <method>initControllerRouters</method>
62
+ </attributeSplash>
63
+ </observers>
64
+ </controller_front_init_routers>
65
+ <catalog_prepare_price_select>
66
+ <observers>
67
+ <attributeSplash>
68
+ <class>attributeSplash/observer</class>
69
+ <method>prepareCatalogPriceSelectObserver</method>
70
+ </attributeSplash>
71
+ </observers>
72
+ </catalog_prepare_price_select>
73
+ <fseo_layered_navigation_match_entity>
74
+ <observers>
75
+ <attributeSplash>
76
+ <class>attributeSplash/observer</class>
77
+ <method>fseoLayeredNavigationMatchEntityObserver</method>
78
+ </attributeSplash>
79
+ </observers>
80
+ </fseo_layered_navigation_match_entity>
81
+ </events>
82
+ <index>
83
+ <indexer>
84
+ <attributeSplash>
85
+ <model>attributeSplash/indexer</model>
86
+ </attributeSplash>
87
+ </indexer>
88
+ </index>
89
+ </global>
90
+ <admin>
91
+ <routers>
92
+ <adminhtml>
93
+ <args>
94
+ <modules>
95
+ <attributeSplash before="Mage_Adminhtml">Fishpig_AttributeSplash_Adminhtml</attributeSplash>
96
+ </modules>
97
+ </args>
98
+ </adminhtml>
99
+ </routers>
100
+ </admin>
101
+ <adminhtml>
102
+ <layout>
103
+ <updates>
104
+ <attributeSplash>
105
+ <file>attribute-splash.xml</file>
106
+ </attributeSplash>
107
+ </updates>
108
+ </layout>
109
+ </adminhtml>
110
+ <frontend>
111
+ <routers>
112
+ <attributeSplash>
113
+ <use>standard</use>
114
+ <args>
115
+ <module>Fishpig_AttributeSplash</module>
116
+ <frontName>splash</frontName>
117
+ </args>
118
+ </attributeSplash>
119
+ </routers>
120
+ <layout>
121
+ <updates>
122
+ <attributeSplash>
123
+ <file>attribute-splash.xml</file>
124
+ </attributeSplash>
125
+ </updates>
126
+ </layout>
127
+ <events>
128
+ <page_block_html_topmenu_gethtml_before>
129
+ <observers>
130
+ <attributeSplash>
131
+ <type>singleton</type>
132
+ <class>attributeSplash/observer</class>
133
+ <method>injectTopmenuLinksObserver</method>
134
+ </attributeSplash>
135
+ </observers>
136
+ </page_block_html_topmenu_gethtml_before>
137
+ </events>
138
+ </frontend>
139
+ <default>
140
+ <attributeSplash>
141
+ <page>
142
+ <column_count>4</column_count>
143
+ </page>
144
+ <group>
145
+ <column_count>4</column_count>
146
+ </group>
147
+ <navigation>
148
+ <enabled>1</enabled>
149
+ </navigation>
150
+ <seo>
151
+ <url_suffix>.html</url_suffix>
152
+ </seo>
153
+ <missing_addon>
154
+ <quickcreate>1</quickcreate>
155
+ <xmlsitemap>1</xmlsitemap>
156
+ </missing_addon>
157
+ </attributeSplash>
158
+ </default>
159
+ </config>
app/code/community/Fishpig/AttributeSplash/etc/system.xml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <fishpig translate="label" module="attributeSplash">
5
+ <label>FishPig</label>
6
+ <sort_order>200</sort_order>
7
+ </fishpig>
8
+ </tabs>
9
+ <sections>
10
+ <attributeSplash translate="label" module="attributeSplash">
11
+ <label>Attribute Splash Pages</label>
12
+ <tab>fishpig</tab>
13
+ <sort_order>210</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <page>
19
+ <label>Pages</label>
20
+ <sort_order>6</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <template>
26
+ <label>Page Layout</label>
27
+ <frontend_type>select</frontend_type>
28
+ <source_model>attributeSplash/system_config_source_layout</source_model>
29
+ <sort_order>1</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </template>
34
+ <column_count>
35
+ <label>Column Count</label>
36
+ <comment>Number of Splash pages per row</comment>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>6</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
+ <validate>validate-number required-entry</validate>
43
+ </column_count>
44
+ <include_group_url_key>
45
+ <label>Add Group URL Key to URL</label>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>adminhtml/system_config_source_yesno</source_model>
48
+ <sort_order>106</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </include_group_url_key>
53
+ </fields>
54
+ </page>
55
+ <group>
56
+ <label>Groups</label>
57
+ <sort_order>11</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <fields>
62
+ <template>
63
+ <label>Page Layout</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>attributeSplash/system_config_source_layout</source_model>
66
+ <sort_order>1</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </template>
71
+ <column_count>
72
+ <label>Column Count</label>
73
+ <comment>Number of Splash pages per row</comment>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>6</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <validate>validate-number required-entry</validate>
80
+ </column_count>
81
+ </fields>
82
+ </group>
83
+ <seo>
84
+ <label>Search Engine Optimizations</label>
85
+ <sort_order>14</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
+ <fields>
90
+ <url_suffix>
91
+ <label>URL Suffix</label>
92
+ <frontend_type>text</frontend_type>
93
+ <sort_order>6</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ </url_suffix>
96
+ </fields>
97
+ </seo>
98
+ <navigation>
99
+ <label>Navigation</label>
100
+ <sort_order>19</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ <fields>
105
+ <enabled>
106
+ <label>Inject Links in Top Navigation</label>
107
+ <comment>Depends on your theme</comment>
108
+ <frontend_type>select</frontend_type>
109
+ <source_model>adminhtml/system_config_source_yesno</source_model>
110
+ <sort_order>1</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>1</show_in_store>
114
+ </enabled>
115
+ </fields>
116
+ </navigation>
117
+ </groups>
118
+ </attributeSplash>
119
+ </sections>
120
+ </config>
app/code/community/Fishpig/AttributeSplash/license.txt ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FishPig END USER LICENSE AGREEMENT (EULA)
2
+
3
+ - http://fishpig.co.uk/license.txt
4
+
5
+ This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this license. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
6
+
7
+ Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
8
+
9
+ 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
10
+
11
+ 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program. This modified program may not be distributed unless meeting the following conditions:
12
+
13
+ a) You have been granted explicit permission from the Licensee to distribute modified copies of the Program.
14
+
15
+ b) You include sufficient and prominent messages explicitly stating that the modified Program is based on the original Program.
16
+
17
+ c) You distribute the modified program under this license; all references to this Licensee and the licensee are retained in their original form.
18
+
19
+ These requirements apply to the modified work as a whole. If identifiable sections of the work are not derived from the original Program and can be considered independent and separate works in themselves, then this license and it's terms do not applu to thosre sections when you distribute them as separate works. But when you distribute the same sections as part of a whole, which is a worked based on the Program, the distribution of the whole must on the terms of this license, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
20
+
21
+ In addition, mere aggregation of another work not based on the Program with the Program on a volume of a storage does not bring the other work under the scope of this License.
22
+
23
+ 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
24
+
25
+ 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
26
+
27
+ 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
28
+
29
+ 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
30
+
31
+ For more information on terms set out in this document, email legal@fishpig.co.uk
app/code/community/Fishpig/AttributeSplash/notes.txt ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##
2
+ # Attribute Splash Pages
3
+ #
4
+ # Author: Ben Tideswell
5
+ # Company: FishPig
6
+ # Documentation: http://fishpig.co.uk/magento/extensions/attribute-splash-pages/
7
+ ##
8
+
9
+ 22/07/2013 - 3.3.7.3
10
+ - Getting ready for the new FishPig SEO extension and adding support for the layered navigation features.
11
+
12
+ 14/07/2013 - 3.3.7.0
13
+ - Added better fix for setLayer fatal error
14
+
15
+ 06/06/2013 - 3.3.6.4
16
+ - Added fix for Magento 1.9 rwd package
17
+
18
+ 02/06/2013 - 3.3.6.3
19
+ - Added 'others' field to pages to allow custom add-ons to add fields to pages easily
20
+
21
+ 27/05/2013 - 3.3.6.1
22
+ - Fix for XmlSitemap add-on
23
+
24
+ 14/04/2013 - 3.3.6.0
25
+ - Changed Image URLs so that secure URL is used when on an HTTPS page
26
+
27
+ 22/03/2013 - 3.3.4.0
28
+ - Fixed bug that stopped store scoped groups from being created
29
+
30
+ 21/03/2013 - 3.3.3.0
31
+ - Added _afterMatch to Router
32
+
33
+ 19/03/2014 - v3.3.2.0
34
+ - Fix that allows you to delete a group if it's not global or has no pages associated with it
35
+
36
+ 18/03/2014 - v3.3.0.0
37
+ - Added support for LayeredNavBridge add-on (http://fishpig.co.uk/magento/extensions/attribute-splash-pages/layered-navigation/)
38
+
39
+ 17/03/2014 - v3.2.3.0
40
+ - Added fix for product sort by attributes
41
+
42
+ 17/03/2014 - v3.2.2.0
43
+ - Display group in menu even if no splash pages are enabled for the menu
44
+
45
+ 04/03/2014 - v3.2.0.0
46
+ - Fixed e.visibility issue
47
+ - Added default store_ids = 0 to Adminhtml forms for Splash Pages
48
+
49
+ 20/02/2014 - v3.1.10.0
50
+ - Fix for URL's when using store codes
51
+
52
+ 16/02/2014 - v3.1.9.0
53
+ - Small fix for QuickCreate add-on
54
+
55
+ 05/02/2014 - v3.1.7.0
56
+ - Added is_featured back in to extension
57
+
58
+ 04/02/2014 - v3.1.5.0
59
+ - Fixed bug that stopped some splash pages from displaying correctly
60
+
61
+ 30/01/2014 - v3.1.4.0
62
+ - Processing added to getShortDescription so that {{...}} tags are parsed and rendered
63
+
64
+ 16/01/2014 - v3.1.3.0
65
+ - Fixed page/group count in Adminhtml grids
66
+
67
+ 13/01/2014 - v3.1.1.0
68
+ - Fixed issue with setStoreFilter method (should be addStoreFilter)
69
+
70
+ 02/01/2014 - v3.1.0.0
71
+ - Added support for Quick Create addon: http://fishpig.co.uk/magento/extensions/attribute-splash-pages/quick-create/
72
+
73
+ 02/01/2014 - v3.0.10.0
74
+ - Added support for XML Sitemap addon: http://fishpig.co.uk/magento/extensions/attribute-splash-pages/xml-sitemap/
75
+
76
+ 19/12/2013 - v3.0.9.0
77
+ - Fixed WYSIWYG editor image problem
78
+
79
+ 17/12/2013 - v3.0.8.0
80
+ - Fixed SQL installation issues
81
+
82
+ 14/12/2013 - v3.0.6.0
83
+ - Added column_count back in for pages
84
+
85
+ 13/12/2013 - v3.0.5.0
86
+ - Added category filters back into layered navigation
87
+
88
+ 13/12/2013 - v3.0.4.0
89
+ - Fixed multiple Adminhtml issues
90
+
91
+ 12/12/2013 - v3.0.3.0
92
+ - Fixed install issue
93
+
94
+ 02/12/2013 - v3.0.2.0
95
+ - Added indexes so that page/groups display for correct scope always
96
+
97
+ 02/12/2013 - v3.0.1.9
98
+ - Fixed Group and Page ordering issue
99
+
100
+ 29/11/2013 - v3.0.1.8
101
+ - Fixed page creation bug
102
+
103
+ 27/11/2013 - v3.0.1.7
104
+ - Fixed multiple bugs
105
+
106
+ 26/11/2013 - v3.0.1.4
107
+ - Fixed Group issue
108
+
109
+ 25/11/2013 - v3.0.1.1
110
+ - Fixed canDisplay() problem
111
+
112
+ 23/11/2013 - v3.0.1.0
113
+ - Added support for FPAdmin
114
+
115
+ 22/11/2013 - v3.0.0.10
116
+ - Fixed mysql install issue
117
+
118
+ 21/11/2013 - v3.0.0.9
119
+ - Added support for FPAdmin
120
+
121
+ 21/11/2013 - v3.0.0.7
122
+ - Removed sitemap.xml integration. Will soon be replaced with own sitemap
123
+
124
+ 20/11/2013 - v3.0.0.6
125
+ - Added CSS file to package
126
+
127
+ 20/11/2013 - v3.0.0.5
128
+ - Changed short_description to a HTML editor for groups and pages
129
+
130
+ 20/11/2013 - v3.0.0.4
131
+ - Setting a page layout from the config now works for Groups and Pages
132
+
133
+ 19/11/2013 - v3.0.0.3
134
+ - Setting a custom template for a group now works again
135
+ - Fixed Splash Page banner image error
136
+
137
+ 19/11/2013 - v3.0.0.2
138
+ - A few more bug fixes
139
+
140
+ 19/11/2013 - v3.0.0.1
141
+ - Fixed Adminhtml link
142
+
143
+ 17/11/2013 - v3.0.0.0
144
+ - Rewritten. Includes new routing system, speed improvements, UI improvements and much more.
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-1.9.16-1.9.17.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ /**
12
+ * Create new splash page table
13
+ *
14
+ */
15
+ $this->run("
16
+
17
+ CREATE TABLE IF NOT EXISTS {$this->getTable('attributesplash_group')} (
18
+ `group_id` int(11) unsigned NOT NULL auto_increment,
19
+ `attribute_id` smallint(5) unsigned NOT NULL default 0,
20
+ `store_id` smallint(5) unsigned NOT NULL default 0,
21
+ `display_name` varchar(255) NOT NULL default '',
22
+ `short_description` varchar(255) NOT NULL default '',
23
+ `description` TEXT NOT NULL default '',
24
+ `url_key` varchar(180) NOT NULL default '',
25
+ `page_title` varchar(255) NOT NULL default '',
26
+ `meta_description` varchar(255) NOT NULL default '',
27
+ `meta_keywords` varchar(255) NOT NULL default '',
28
+ `display_mode` tinyint(2) unsigned NOT NULL default 0,
29
+ `cms_block` int(11) unsigned NOT NULL default 0,
30
+ `is_enabled` int(1) unsigned NOT NULL default 1,
31
+ PRIMARY KEY (`group_id`),
32
+ KEY `FK_ATTRIBUTE_ID_SPLASH_GROUP` (`attribute_id`),
33
+ CONSTRAINT `FK_ATTRIBUTE_ID_SPLASH_GROUP` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
34
+ KEY `FK_STORE_ID_SPLASH_GROUP` (`store_id`),
35
+ CONSTRAINT `FK_STORE_ID_SPLASH_GROUP` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
36
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AttributeSplash: Group';
37
+
38
+ ALTER TABLE {$this->getTable('attributesplash_group')} ADD UNIQUE (attribute_id, store_id);
39
+
40
+ ");
41
+
42
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-1.9.5-1.9.6.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ /**
12
+ * Create new splash page table
13
+ *
14
+ */
15
+ $this->run("
16
+
17
+ CREATE TABLE IF NOT EXISTS {$this->getTable('attributesplash_page')} (
18
+ `page_id` int(11) unsigned NOT NULL auto_increment,
19
+ `option_id` int (11) unsigned NOT NULL default 0,
20
+ `store_id` smallint(5) unsigned NOT NULL default 0,
21
+ `display_name` varchar(255) NOT NULL default '',
22
+ `image` varchar(255) NOT NULL default '',
23
+ `short_description` varchar(255) NOT NULL default '',
24
+ `description` TEXT NOT NULL default '',
25
+ `url_key` varchar(180) NOT NULL default '',
26
+ `page_title` varchar(255) NOT NULL default '',
27
+ `meta_description` varchar(255) NOT NULL default '',
28
+ `meta_keywords` varchar(255) NOT NULL default '',
29
+ `display_mode` varchar(40) NOT NULL default 'PRODUCTS',
30
+ `cms_block` int(11) unsigned NOT NULL default 0,
31
+ `is_enabled` int(1) unsigned NOT NULL default 1,
32
+ PRIMARY KEY (`page_id`),
33
+ KEY `FK_OPTION_ID_SPLASH_PAGE` (`option_id`),
34
+ CONSTRAINT `FK_OPTION_ID_SPLASH_PAGE` FOREIGN KEY (`option_id`) REFERENCES `{$this->getTable('eav_attribute_option')}` (`option_id`) ON DELETE CASCADE ON UPDATE CASCADE,
35
+ KEY `FK_STORE_ID_SPLASH_PAGE` (`store_id`),
36
+ CONSTRAINT `FK_STORE_ID_SPLASH_PAGE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
37
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AttributeSplash: Page';
38
+
39
+ ALTER TABLE {$this->getTable('attributesplash_page')} ADD UNIQUE (option_id, store_id);
40
+
41
+ ");
42
+
43
+ /**
44
+ * Add the layout update XML field
45
+ *
46
+ */
47
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'layout_update_xml', " TEXT NOT NULL default ''");
48
+
49
+ /**
50
+ * Delete all of the old URL rewrites
51
+ *
52
+ */
53
+ $this->getConnection('core_write')->delete($this->getTable('core_url_rewrite'), $this->getConnection('core_write')->quoteInto('id_path LIKE (?)', 'splash/%'));
54
+
55
+ /**
56
+ * Migrate images
57
+ *
58
+ */
59
+ $old = Mage::getBaseDir('media') . DS . 'splash';
60
+ $new = Mage::getBaseDir('media') . DS . 'attributesplash';
61
+
62
+ try {
63
+ if (is_dir($old)) {
64
+ rename($old, $new);
65
+ }
66
+ }
67
+ catch (Exception $e) {
68
+ Mage::log($e->getMessage(), false, 'attributeSplash.log', true);
69
+ }
70
+
71
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.1-2.0.2.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'layout_update_xml', " TEXT NOT NULL default ''");
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'is_featured', " int(1) unsigned NOT NULL default 0");
13
+
14
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.12-2.0.13.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'image_url', " varchar(255) NOT NULL default '' AFTER image");
12
+
13
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.5-2.0.6.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->run("ALTER TABLE `{$this->getTable('attributesplash_group')}` CHANGE `short_description` `short_description` TEXT;");
12
+ $this->run("ALTER TABLE `{$this->getTable('attributesplash_page')}` CHANGE `short_description` `short_description` TEXT;");
13
+
14
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.6-2.0.7.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'include_in_menu', " int(1) unsigned NOT NULL default 1");
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'include_in_menu', " int(1) unsigned NOT NULL default 1");
13
+
14
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.8-2.0.9.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ try {
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'thumbnail', " varchar(255) NOT NULL default '' ");
13
+ }
14
+ catch (Exception $e) {
15
+ // Ignore exception. This is here to fix a silly issue
16
+ }
17
+
18
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.0.9-2.0.10.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'created_at', " timestamp");
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'updated_at', " timestamp");
13
+
14
+ $this->getConnection()->update($this->getTable('attributesplash_page'), array('updated_at' => now(), 'created_at' => now()), '');
15
+
16
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'created_at', " timestamp");
17
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'updated_at', " timestamp");
18
+
19
+ $this->getConnection()->update($this->getTable('attributesplash_group'), array('updated_at' => now(), 'created_at' => now()), '');
20
+
21
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.0.5-2.2.0.6.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->dropColumn($this->getTable('attributesplash_group'), 'display_mode');
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'display_mode', " varchar(40) NOT NULL default 'PRODUCTS' AFTER meta_keywords");
13
+
14
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.0.7-2.2.0.8.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $base = 'attributeSplash';
12
+
13
+ $configs = array(
14
+ 'frontend/template' => 'page/template',
15
+ 'frontend/grid_column_count' => 'page/column_count',
16
+ 'frontend/include_group_url_key' => 'page/include_group_url_key',
17
+ 'list_page/template' => 'group/template',
18
+ 'list_page/grid_column_count' => 'group/column_count',
19
+ 'product/inject_links' => 'page/inject_links',
20
+ );
21
+
22
+ foreach($configs as $from => $to) {
23
+ try {
24
+ $this->getConnection()->update(
25
+ $this->getTable('core/config_data'),
26
+ array('path' => $base . '/' . $to),
27
+ $this->getConnection()->quoteInto('path=?', $base . '/' . $from)
28
+ );
29
+ }
30
+ catch (Exception $e) {
31
+ Mage::logException($e);
32
+ }
33
+ }
34
+
35
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.0.8-2.2.0.9.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->run("
12
+
13
+ CREATE TABLE IF NOT EXISTS {$this->getTable('attributesplash_page_store')} (
14
+ `page_id` int(11) unsigned NOT NULL auto_increment,
15
+ `store_id` smallint(5) unsigned NOT NULL default 0,
16
+ PRIMARY KEY (`page_id`, `store_id`),
17
+ KEY `FK_PAGE_ID_SPLASH_PAGE_STORE` (`page_id`),
18
+ CONSTRAINT `FK_PAGE_ID_SPLASH_PAGE_STORE` FOREIGN KEY (`page_id`) REFERENCES `{$this->getTable('attributesplash_page')}` (`page_id`) ON DELETE CASCADE ON UPDATE CASCADE,
19
+ KEY `FK_STORE_ID_SPLASH_PAGE_STORE` (`store_id`),
20
+ CONSTRAINT `FK_STORE_ID_SPLASH_PAGE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
21
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AttributeSplash: Page / Store';
22
+
23
+ ALTER TABLE {$this->getTable('attributesplash_page_store')} ADD UNIQUE (`page_id`,`store_id`);
24
+
25
+ CREATE TABLE IF NOT EXISTS {$this->getTable('attributesplash_group_store')} (
26
+ `group_id` int(11) unsigned NOT NULL auto_increment,
27
+ `store_id` smallint(5) unsigned NOT NULL default 0,
28
+ PRIMARY KEY (`group_id`, `store_id`),
29
+ KEY `FK_PAGE_ID_SPLASH_GROUP_STORE` (`group_id`),
30
+ CONSTRAINT `FK_PAGE_ID_SPLASH_GROUP_STORE` FOREIGN KEY (`group_id`) REFERENCES `{$this->getTable('attributesplash_group')}` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
31
+ KEY `FK_STORE_ID_SPLASH_GROUP_STORE` (`store_id`),
32
+ CONSTRAINT `FK_STORE_ID_SPLASH_GROUP_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
33
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AttributeSplash: Group / Store';
34
+
35
+ ALTER TABLE {$this->getTable('attributesplash_group_store')} ADD UNIQUE (`group_id`,`store_id`);
36
+
37
+ ");
38
+
39
+ foreach(array('page', 'group') as $type) {
40
+ try {
41
+ $select = $this->getConnection()
42
+ ->select()
43
+ ->from($this->getTable('attributesplash_' . $type), array($type . '_id', 'store_id'));
44
+
45
+ if ($results = $this->getConnection()->fetchAll($select)) {
46
+ foreach($results as $result) {
47
+ $this->getConnection()->insert($this->getTable('attributesplash_' . $type . '_store'), $result);
48
+ }
49
+ }
50
+
51
+ $this->getConnection()->dropColumn($this->getTable('attributesplash_' . $type), 'store_id');
52
+ }
53
+ catch (Exception $e) {
54
+ Mage::logException($e);
55
+ }
56
+ }
57
+
58
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.1.0-2.2.1.1.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ try {
12
+ // Create temporary field
13
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'option_id_temp', " int(11) unsigned NOT NULL default 0 AFTER option_id");
14
+
15
+ // Copy over data
16
+ $this->run("UPDATE {$this->getTable('attributesplash_page')} SET option_id_temp = option_id");
17
+
18
+ // Drop old field
19
+ $this->run("ALTER TABLE {$this->getTable('attributesplash_page')} DROP KEY `FK_OPTION_ID_SPLASH_PAGE`");
20
+
21
+ // Drop column
22
+ $this->getConnection()->dropColumn($this->getTable('attributesplash_page'), 'option_id');
23
+
24
+ // Rename temp field
25
+ $this->getConnection()->changeColumn($this->getTable('attributesplash_page'), 'option_id_temp', 'option_id', 'int(11) unsigned NOT NULL default 0 AFTER page_id');
26
+
27
+ // Add constraint
28
+ $this->getConnection()->addConstraint('FK_OPTION_ID_SPLASH_PAGE', $this->getTable('attributesplash_page'), 'option_id', $this->getTable('eav_attribute_option'), 'option_id');
29
+
30
+ $this->endSetup();
31
+ }
32
+ catch (Exception $e) {
33
+ Mage::logException($e);
34
+ }
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-2.2.1.1-2.2.1.2.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'page_layout', " varchar(32) default NULL AFTER layout_update_xml");
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'page_layout', " varchar(32) default NULL AFTER layout_update_xml");
13
+
14
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.0.1.10-3.0.1.11.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ try {
12
+ Mage::getSingleton('attributeSplash/indexer')->reindexAll();
13
+ }
14
+ catch (Exception $e) {
15
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
16
+ Mage::getSingleton('adminhtml/session')->addError('Please reindex the Attribute Splash Pages');
17
+ Mage::logException($e);
18
+ }
19
+
20
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.0.1.9-3.0.1.10.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ /**
12
+ * Create new splash page table
13
+ *
14
+ */
15
+ $this->run("
16
+
17
+ CREATE TABLE IF NOT EXISTS {$this->getTable('attributesplash_group_index')} (
18
+ `group_id` int(11) unsigned NOT NULL,
19
+ `store_id` smallint(5) unsigned NOT NULL,
20
+ PRIMARY KEY (`group_id`, `store_id`),
21
+ KEY `FK_GROUP_ID_SPLASH_GROUP_INDEX` (`group_id`),
22
+ CONSTRAINT `FK_GROUP_ID_SPLASH_GROUP_INDEX` FOREIGN KEY (`group_id`) REFERENCES `{$this->getTable('attributesplash_group')}` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
23
+ KEY `FK_STORE_ID_SPLASH_GROUP_INDEX` (`store_id`),
24
+ CONSTRAINT `FK_STORE_ID_SPLASH_GROUP_INDEX` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AttributeSplash: Group Index';
26
+
27
+ CREATE TABLE IF NOT EXISTS {$this->getTable('attributesplash_page_index')} (
28
+ `page_id` int(11) unsigned NOT NULL,
29
+ `store_id` smallint(5) unsigned NOT NULL,
30
+ PRIMARY KEY (`page_id`, `store_id`),
31
+ KEY `FK_PAGE_ID_SPLASH_PAGE_INDEX` (`page_id`),
32
+ CONSTRAINT `FK_PAGE_ID_SPLASH_PAGE_INDEX` FOREIGN KEY (`page_id`) REFERENCES `{$this->getTable('attributesplash_page')}` (`page_id`) ON DELETE CASCADE ON UPDATE CASCADE,
33
+ KEY `FK_STORE_ID_SPLASH_PAGE_INDEX` (`store_id`),
34
+ CONSTRAINT `FK_STORE_ID_SPLASH_PAGE_INDEX` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
35
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AttributeSplash: Page Index';
36
+
37
+ ");
38
+
39
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.0.4.0-3.0.5.0.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_group'), 'category_id', "int(11) unsigned default NULL AFTER attribute_id");
12
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'category_id', "int(11) unsigned default NULL AFTER option_id");
13
+
14
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.1.1.0-3.1.2.0.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $baseDir = Mage::getModuleDir('', 'Fishpig_AttributeSplash') . DS . 'Addon' . DS;
12
+
13
+ $modules = array(
14
+ 'QuickCreate',
15
+ 'XmlSitemap',
16
+ );
17
+
18
+ foreach($modules as $module) {
19
+ $bootstrapFile = Mage::getBaseDir('app') . DS . 'etc' . DS . 'modules' . DS . 'Fishpig_AttributeSplash_Addon_' . $module . '.xml';
20
+
21
+ if (is_file($bootstrapFile)) {
22
+ continue;
23
+ }
24
+
25
+ $moduleDir = $baseDir . $module;
26
+
27
+ if (is_dir($moduleDir)) {
28
+ fp_rrmdir($moduleDir);
29
+ }
30
+ }
31
+
32
+
33
+ function fp_rrmdir($dir) {$files = array_unique(array_reverse(fp_rscandir($dir)));if (count($files) > 0) {foreach($files as $file) {if (is_file($file)){@unlink($file);}else if (is_dir($file)){@rmdir($file);}}}}
34
+ function fp_rscandir($dir, $reverse = false){$files = array($dir);foreach(scandir($dir) as $file) {if (trim($file, '.') === '') {continue;}$tmp = $dir . DS . $file;$files[] = $tmp;if (is_dir($tmp)) {$files = array_merge($files, fp_rscandir($tmp));}}if ($reverse){return array_reverse($files);}return $files;}
35
+
36
+
37
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.3.3.0-3.3.4.0.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ try {
12
+ $this->run("ALTER TABLE {$this->getTable('attributesplash_group')} DROP index attribute_id");
13
+ }
14
+ catch (Exception $e) {
15
+
16
+ }
17
+
18
+ $this->endSetup();
app/code/community/Fishpig/AttributeSplash/sql/attributeSplash_setup/mysql4-upgrade-3.3.6.2-3.3.6.3.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ $this->startSetup();
10
+
11
+ $this->getConnection()->addColumn($this->getTable('attributesplash_page'), 'other', " TEXT NOT NULL default '' AFTER `description`");
12
+
13
+ $this->endSetup();
app/design/adminhtml/default/default/layout/attribute-splash.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <!--
4
+ /**
5
+ * Splash Dashboard
6
+ */
7
+ -->
8
+ <adminhtml_attributesplash_index>
9
+ <reference name="content">
10
+ <block type="core/text" name="splash.dashboard.title">
11
+ <action method="setText">
12
+ <text><![CDATA[<div class="content-header"><h3>Attribute Splash Pages</h3></div>]]></text>
13
+ </action>
14
+ </block>
15
+ <block type="attributeSplash/adminhtml_dashboard" name="splash.dashboard" />
16
+ <block type="core/text" name="splash.tabs.content">
17
+ <action method="setText">
18
+ <text><![CDATA[
19
+ <div id="splash_tab_content"></div>
20
+ <style type="text/css">
21
+ #splash_dashboard_tabs_group_content .content-header { display: none; }
22
+ #splash_dashboard_tabs_page_content .content-header { display: none; }
23
+ </style>
24
+ ]]></text>
25
+ </action>
26
+ </block>
27
+ </reference>
28
+ </adminhtml_attributesplash_index>
29
+ <!--
30
+ /**
31
+ * Splash Page edit
32
+ */
33
+ -->
34
+ <adminhtml_attributesplash_page_edit>
35
+ <update handle="editor" />
36
+ <reference name="left">
37
+ <block type="attributeSplash/adminhtml_page_edit_tabs" name="splash_page.edit.tabs" />
38
+ </reference>
39
+ <reference name="content">
40
+ <block type="attributeSplash/adminhtml_page_edit" name="splash_page.edit" />
41
+ </reference>
42
+ <reference name="before_body_end">
43
+ <block type="attributeSplash/adminhtml_page_edit_js" name="splash_page.edit.js" />
44
+ <block type="core/text" name="splash.tabs.content">
45
+ <action method="setText" ifconfig="attributeSplash/missing_addon/quickcreate">
46
+ <text><![CDATA[
47
+ <style type="text/css">
48
+ #qc-go {font-size:110%;margin-top:-18px;padding:10px 0;text-align:right;}
49
+ </style>
50
+ <script type="text/javascript">
51
+ $('content').select('.content-header').first().insert({
52
+ after: new Element('div', {'id': 'qc-go'}).update(
53
+ 'Create 100\'s of Splash Pages a second with <a href="http://fishpig.co.uk/magento/extensions/attribute-splash-pages/quick-create/?utm_source=Fishpig_AttributeSplash&utm_medium=Edit%20Page&utm_term=Fishpig_AttributeSplash_Addon_QuickCreate&utm_campaign=Extend" target="_blank">Quick Create</a>.'
54
+ )
55
+ });
56
+ </script>
57
+ ]]></text>
58
+ </action>
59
+ </block>
60
+ </reference>
61
+ </adminhtml_attributesplash_page_edit>
62
+ <!--
63
+ /**
64
+ * Splash Group edit
65
+ */
66
+ -->
67
+ <adminhtml_attributesplash_group_edit>
68
+ <update handle="editor" />
69
+ <reference name="left">
70
+ <block type="attributeSplash/adminhtml_group_edit_tabs" name="splash_group.edit.tabs" />
71
+ </reference>
72
+ <reference name="content">
73
+ <block type="attributeSplash/adminhtml_group_edit" name="splash_group.edit" />
74
+ </reference>
75
+ </adminhtml_attributesplash_group_edit>
76
+ </layout>
app/design/frontend/base/default/layout/attribute-splash.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <!--
4
+ /**
5
+ *
6
+ */
7
+ -->
8
+ <attributesplash_page_view>
9
+ <reference name="head">
10
+ <action method="addCss"><style>css/attribute-splash.css</style></action>
11
+ </reference>
12
+ <reference name="left">
13
+ <block type="directory/currency" name="currency" before="-" template="directory/currency.phtml"/>
14
+ <block type="attributeSplash/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
15
+ <block type="core/text_list" name="catalog.leftnav.state.renderers" as="state_renderers" />
16
+ </block>
17
+ </reference>
18
+ <reference name="content">
19
+ <block type="attributeSplash/page_view" name="attributeSplash.view" template="attribute-splash/page/view.phtml">
20
+ <block type="attributeSplash/page_view_product_list" name="product_list" template="catalog/product/list.phtml">
21
+ <block type="core/text_list" name="product_list.name.after" as="name.after" />
22
+ <block type="core/text_list" name="product_list.after" as="after" />
23
+ <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
24
+ <block type="page/html_pager" name="product_list_toolbar_pager"/>
25
+ </block>
26
+ <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
27
+ </block>
28
+ </block>
29
+ </reference>
30
+ </attributesplash_page_view>
31
+ <!--
32
+ /**
33
+ *
34
+ */
35
+ -->
36
+ <attributesplash_group_view>
37
+ <reference name="head">
38
+ <action method="addCss"><style>css/attribute-splash.css</style></action>
39
+ </reference>
40
+ <reference name="content">
41
+ <block type="attributeSplash/group_view" name="attributeSplash.view.group" template="attribute-splash/group/view.phtml" />
42
+ </reference>
43
+ </attributesplash_group_view>
44
+ </layout>
app/design/frontend/base/default/template/attribute-splash/group/view.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+ ?>
9
+ <?php if ($splashGroup = $this->getSplashGroup()): ?>
10
+ <?php $splashPages = $this->getSplashPages() ?>
11
+ <div class="page-title category-title">
12
+ <h1><?php echo $this->escapeHtml($splashGroup->getName()) ?></h1>
13
+ </div>
14
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
15
+ <?php if ($splashGroup->getShortDescription()): ?>
16
+ <div class="category-description std"><?php echo $splashGroup->getShortDescription() ?></div>
17
+ <?php endif; ?>
18
+ <?php if($this->isContentMode()): ?>
19
+ <?php echo $this->getCmsBlockHtml() ?>
20
+ <?php elseif($this->isMixedMode()): ?>
21
+ <?php echo $this->getCmsBlockHtml() ?>
22
+ <?php endif; ?>
23
+ <?php if ($this->isProductMode() || $this->isMixedMode()): ?>
24
+ <div class="splash-groups">
25
+ <?php $_columnCount = $this->getColumnCount() ?>
26
+ <?php $_collectionSize = $splashPages->count() ?>
27
+ <?php $i = 0; foreach($splashPages as $splashPage): ?>
28
+ <?php if ($i++%$_columnCount==0): ?>
29
+ <ul class="splash-group-grid splash-group-grid-<?php echo $this->getColumnCount() ?>">
30
+ <?php endif ?>
31
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
32
+ <div class="inner">
33
+ <?php if ($splashPage->getThumbnail()): ?>
34
+ <a href="<?php echo $splashPage->getUrl() ?>" title="<?php echo $this->escapeHtml($splashPage->getName()) ?>" class="product-image">
35
+ <img src="<?php echo $this->helper('attributeSplash/image')->init($splashPage, 'thumbnail')->keepFrame(false)->constrainOnly(true)->resize(150, 150) ?>" alt="<?php echo $this->escapeHtml($splashPage->getName()) ?>" />
36
+ </a>
37
+ <?php endif; ?>
38
+ <h2 class="product-name">
39
+ <a href="<?php echo $splashPage->getUrl() ?>" title="<?php echo $this->escapeHtml($splashPage->getName()) ?>">
40
+ <?php echo $this->escapeHtml($splashPage->getName()) ?>
41
+ </a>
42
+ </h2>
43
+ </div>
44
+ </li>
45
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
46
+ </ul>
47
+ <?php endif ?>
48
+ <?php endforeach ?>
49
+ <script type="text/javascript">decorateGeneric($$('ul.splash-group-grid'), ['odd','even','first','last'])</script>
50
+ </div>
51
+ <?php endif; ?>
52
+ <?php endif; ?>
app/design/frontend/base/default/template/attribute-splash/page/view.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_AttributeSplash
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+ ?>
9
+ <?php if ($splashPage = $this->getSplashPage()): ?>
10
+ <div class="page-title category-title splash-title">
11
+ <h1><?php echo $this->escapeHtml($splashPage->getName()) ?></h1>
12
+ </div>
13
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
14
+ <?php if ($splashPage->getImage()): ?>
15
+ <p class="splash-image">
16
+ <?php if ($splashPage->getImageUrl()): ?>
17
+ <a href="<?php echo $splashPage->getImageUrl() ?>" title="<?php echo $this->escapeHtml($splashPage->getName()) ?>">
18
+ <?php endif; ?>
19
+ <img src="<?php echo $this->helper('attributeSplash/image')->init($splashPage, 'image')->resize(null, null) ?>" alt="<?php echo $this->escapeHtml($splashPage->getName()) ?>"/>
20
+ <?php if ($splashPage->getImageUrl()): ?>
21
+ </a>
22
+ <?php endif; ?>
23
+ </p>
24
+ <?php endif; ?>
25
+ <?php if ($shortDescription = $splashPage->getShortDescription()): ?>
26
+ <div class="splash-description std"><?php echo $shortDescription ?></div>
27
+ <?php endif; ?>
28
+ <?php if($this->isContentMode()): ?>
29
+ <?php echo $this->getCmsBlockHtml() ?>
30
+ <?php elseif($this->isMixedMode()): ?>
31
+ <?php echo $this->getCmsBlockHtml() ?>
32
+ <?php echo $this->getProductListHtml() ?>
33
+ <?php else: ?>
34
+ <?php echo $this->getProductListHtml() ?>
35
+ <?php endif; ?>
36
+ <?php if ($description = $splashPage->getDescription()): ?>
37
+ <div class="splash-description-full std"><?php echo $description ?></div>
38
+ <?php endif; ?>
39
+ <?php endif; ?>
app/etc/modules/Fishpig_AttributeSplash.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Fishpig_AttributeSplash>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Fishpig_AttributeSplash>
8
+ <Fishpig_AttributeSplash_FPAdmin>
9
+ <active>true</active>
10
+ <codePool>community</codePool>
11
+ </Fishpig_AttributeSplash_FPAdmin>
12
+ </modules>
13
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Fishpigs_Attribute_Splash_Page</name>
4
+ <version>3.3.7.3</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://fishpig.co.uk/license.txt">FishPig EULA</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Create SEO landing pages for your product attributes.</summary>
10
+ <description>This module allows you to create splash pages (landing pages) for your product attributes. These pages function much like category pages, allowing yo to display products, static blocks or both. The module works with the category navigation and layered navigation and includes fully customisable SEO URL's.</description>
11
+ <notes>Getting ready for the new FishPig SEO extension and adding support for the layered navigation features.</notes>
12
+ <authors><author><name>fishpig</name><user>fishpig</user><email>ben@fishpig.co.uk</email></author></authors>
13
+ <date>2014-07-22</date>
14
+ <time>08:52:50</time>
15
+ <contents><target name="magecommunity"><dir name="Fishpig"><dir name="AttributeSplash"><dir name="Block"><dir name="Adminhtml"><file name="Dashboard.php" hash="731dbb40a55071d02bd92e43473109fa"/><file name="Extend.php" hash="b953e4661405165bcf29b59aeda42a3b"/><dir name="Form"><dir name="Field"><file name="Urlkey.php" hash="b3f2e813188d6f8805b2caeb4f834bf6"/></dir></dir><dir name="Group"><dir name="Edit"><file name="Form.php" hash="fc927b79309df561773fe578fb1fad09"/><dir name="Tab"><file name="Abstract.php" hash="96e479a7eca8cb742f27a9eed619d65e"/><file name="Content.php" hash="30d24e08d83bb222f2b1a8169c4f3d48"/><file name="Design.php" hash="1fbc5babddc70729a1dcacb1fabbe034"/><file name="General.php" hash="c7c3d088f4a538c6b4d9a784aab88242"/><file name="Meta.php" hash="7058642a220347deeda6ea431fc054f1"/><file name="Seo.php" hash="a95471b43c44140ea07c24618f8b531e"/></dir><file name="Tabs.php" hash="b03a68cc45f8b68733d1627ab3538411"/></dir><file name="Edit.php" hash="79e7d29d23acd9c72ea37794c8d29231"/><file name="Grid.php" hash="de399b8df83efbc7d2442c9c0dc59ba4"/></dir><file name="Group.php" hash="7804d0272717593ef7afaa2261f7302c"/><dir name="Page"><dir name="Edit"><file name="Form.php" hash="ec8609e766d4e6e7176cc9e0c9e8b6bc"/><file name="Js.php" hash="45e4e33068189377e9bcac1a51b5ba47"/><dir name="Tab"><file name="Abstract.php" hash="577c17bec36fbffc6f8cd3231ba8a243"/><file name="Attributes.php" hash="dab45d890fa5566f8b940ced03ec48b1"/><file name="Content.php" hash="820db5968e8efcd80b8fcc70e74bff34"/><file name="Design.php" hash="48dc187093ec327a1877fb1ade16bb33"/><file name="General.php" hash="70c6893aca12ea2561cbf8119f19a799"/><file name="Images.php" hash="e1482076b30cfa9a60b71c5b9b9a68ac"/><file name="Meta.php" hash="c98f7455bfffe42a853d96e03fc38f07"/></dir><file name="Tabs.php" hash="59b6ef6fc4465a70cbb793b83a416910"/></dir><file name="Edit.php" hash="e381e3a218bab4fca9f73e13b38992ec"/><file name="Grid.php" hash="509c695f523f07d01a4932a55f1dbc1f"/><dir name="Helper"><file name="Image.php" hash="562c6c1db32c28dec6b82465515ca0ea"/></dir></dir><file name="Page.php" hash="563f0973d5ca0c292f47f0f58e9537e0"/><file name="Xmlsitemap.php" hash="2dad376de1cbb3315f0c21446f9d1388"/></dir><dir name="Group"><file name="View.php" hash="5c3cf0804007a5f74f5698dc80f78bbe"/></dir><dir name="Layer"><file name="View.php" hash="3923310b46b9ee394d45da99f3582f8f"/></dir><dir name="Page"><dir name="View"><dir name="Product"><file name="List.php" hash="90d4af1ec0a4570f8677927ae71cc42c"/></dir></dir><file name="View.php" hash="dbb394a410de1cb4cb23c1bb45d6212b"/></dir></dir><dir name="Controller"><file name="Router.php" hash="e2ea39b67df0379be71ccf315829d0fc"/></dir><dir name="FPAdmin"><dir name="Block"><dir name="Adminhtml"><file name="Extend.php" hash="75e04a5ca9087172cfab1b98cad7b263"/></dir></dir><dir name="etc"><file name="config.xml" hash="1fce386d2bb067be566d90b5d428b38a"/></dir><dir name="template"><file name="large.phtml" hash="0b2108b293d9dd694b2e31b0d3c84273"/><file name="small.phtml" hash="0aba9ac21006fa9f7811911d352bc89a"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f1d9b407e3f9d75f5f607859d9421bfc"/><file name="Image.php" hash="ebffad52f40a213d5ec19f3918cd3c15"/></dir><dir name="Model"><file name="Abstract.php" hash="9972251190a2706c3e643180606049ac"/><file name="Group.php" hash="f131e5dca3b850a025b9b3c96d121be2"/><file name="Indexer.php" hash="41ad895ca63e0ebe96c5cd767f97b1d2"/><file name="Layer.php" hash="917e65bfa003edbb8b408c61fddf7d7a"/><file name="Observer.php" hash="f6315405306761eec36515c8fbde6ec2"/><file name="Page.php" hash="247a78c4095843e24015accc207b98eb"/><dir name="Resource"><file name="Abstract.php" hash="0bb194c43fc1340c54e2c983064fae69"/><dir name="Collection"><file name="Abstract.php" hash="47b5eca5bd1a3753fafce198bf803f16"/></dir><dir name="Group"><file name="Collection.php" hash="b6a383408392624d962a0b71f5c94116"/></dir><file name="Group.php" hash="2aaf88ce5f041db66d5a0dfb6c163a1f"/><dir name="Page"><file name="Collection.php" hash="389e342252a9066cf4da11c80937a233"/></dir><file name="Page.php" hash="c81d95f58d045ddda75484b4c361702a"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Attribute"><file name="Abstract.php" hash="9ddfa2eb83e6ec8d257bcd2d6977f384"/><file name="Splashable.php" hash="40fa08332ff34bc41e201c31b96d51fd"/><file name="Splashed.php" hash="946174a3acd8a0c8ea31c19d1d304f59"/></dir><file name="Layout.php" hash="f51ca8be6325f2e62a181c891b14cbfe"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="AttributeSplash"><file name="GroupController.php" hash="8d26473d6c81cd82ce415e9935b5c83e"/><file name="PageController.php" hash="95fd049a25cba8d583db5282bb53b3ac"/></dir><file name="AttributeSplashController.php" hash="c54fb8e450d732e5f140878f6ebeee0d"/></dir><file name="GroupController.php" hash="9f25aa2a2019e3027370af6270fa1d38"/><file name="PageController.php" hash="87eed36981d16489060989397c80a9a9"/><file name="SitemapController.php" hash="09d50b324c03ad40c68a1aafbe42f279"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e23767be5435be89b79c1f67b99daf83"/><file name="config.xml" hash="a05cfc7e5850e8318ad3df9170ebca75"/><file name="system.xml" hash="5f0aa3086d8307cdb8d2ab182d2e0da7"/></dir><file name="license.txt" hash="e8fb4ab53f05a8b4b7fea01d7d0df63b"/><file name="notes.txt" hash="c7d961900382a4649f49bb381a5d675c"/><dir name="sql"><dir name="attributeSplash_setup"><file name="mysql4-upgrade-1.9.16-1.9.17.php" hash="b17056fe56a55367f3a4c78c47a16095"/><file name="mysql4-upgrade-1.9.5-1.9.6.php" hash="4ab561651fa49776d53ed07c415119fe"/><file name="mysql4-upgrade-2.0.1-2.0.2.php" hash="5e44951f6743161e4a966bb84dec5350"/><file name="mysql4-upgrade-2.0.12-2.0.13.php" hash="44e236b5c00275822f2766fb3aade050"/><file name="mysql4-upgrade-2.0.5-2.0.6.php" hash="da04923844a460181eb042ee865e898a"/><file name="mysql4-upgrade-2.0.6-2.0.7.php" hash="58f2c8462027ef87c6d002c2e7816762"/><file name="mysql4-upgrade-2.0.8-2.0.9.php" hash="b78dc758c2d8f11eb80e31652f92b317"/><file name="mysql4-upgrade-2.0.9-2.0.10.php" hash="d376bc97a149ff0ddac6b09b3eb466c4"/><file name="mysql4-upgrade-2.2.0.5-2.2.0.6.php" hash="b25fd508bc5cdc5058f1f88b02752c18"/><file name="mysql4-upgrade-2.2.0.7-2.2.0.8.php" hash="83cb47a19873315987be7811d9ace297"/><file name="mysql4-upgrade-2.2.0.8-2.2.0.9.php" hash="800a55579155ccae338b55b94a21106c"/><file name="mysql4-upgrade-2.2.1.0-2.2.1.1.php" hash="ccc977f076d9e2aef34a2aa02e3212b3"/><file name="mysql4-upgrade-2.2.1.1-2.2.1.2.php" hash="1f4021bd5efd583a9478790bddd77acc"/><file name="mysql4-upgrade-3.0.1.10-3.0.1.11.php" hash="687d031221740324a60fccb26fd12fea"/><file name="mysql4-upgrade-3.0.1.9-3.0.1.10.php" hash="f95f086b8a6856a0cff4d7a9defb9656"/><file name="mysql4-upgrade-3.0.4.0-3.0.5.0.php" hash="fe33155d0140875eba7b204a969bcc62"/><file name="mysql4-upgrade-3.1.1.0-3.1.2.0.php" hash="6ea402356d9faa250d5231725f8944b1"/><file name="mysql4-upgrade-3.3.3.0-3.3.4.0.php" hash="52d4acdb41e63f5b0a6f207048547569"/><file name="mysql4-upgrade-3.3.6.2-3.3.6.3.php" hash="003475ce5b5f3495a4433b827f3d54cb"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="attribute-splash.xml" hash="f7671383df6ec841b4e2c5080ac9132d"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="attribute-splash.xml" hash="6810e9a7e3135f390dc03c6f8beb067d"/></dir><dir name="template"><dir name="attribute-splash"><dir><dir name="group"><file name="view.phtml" hash="53b43ec1f23e6a0498be9b09f9b0e80e"/></dir><dir name="page"><file name="view.phtml" hash="7cf47164bc5d140de566294a93942677"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Fishpig_AttributeSplash.xml" hash="80fa9d54cefcd44305240d05508a56ee"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="attribute-splash.css" hash="c3b1103f0174a7b17496aaf75a2b4e78"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/attribute-splash.css ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @category Fishpig
3
+ * @package Fishpig_AttributeSplash
4
+ * @license http://fishpig.co.uk/license.txt
5
+ * @author Ben Tideswell <help@fishpig.co.uk>
6
+ */
7
+
8
+ .splash-group-grid {
9
+ height: 1%;
10
+ overflow: hidden;
11
+ }
12
+
13
+ .splash-group-grid li.item {
14
+ float: left;
15
+ text-align: center;
16
+ width: 25%;
17
+ }
18
+
19
+ .splash-group-grid li.item .inner {
20
+ padding: 2%;
21
+ }
22
+
23
+ .splash-group-grid li.item img {
24
+ margin-bottom: 1em;
25
+ max-width: 100%;
26
+ }
27
+
28
+ .splash-group-grid-2 li.item {
29
+ width: 50%;
30
+ }
31
+
32
+ .splash-group-grid-3 li.item {
33
+ width: 33.3%;
34
+ }
35
+
36
+ .splash-group-grid-4 li.item {
37
+ width: 25%;
38
+ }
39
+
40
+ .splash-group-grid-5 li.item {
41
+ width: 20%;
42
+ }
43
+
44
+ .splash-title {
45
+
46
+ }
47
+
48
+ .splash-image {
49
+
50
+ }
51
+
52
+ .splash-image img {
53
+ max-width: 100%;
54
+ }
55
+
56
+ .splash-description {
57
+ margin-bottom: 2em;
58
+ }
59
+
60
+ .splash-description img {
61
+ max-width: 100%;
62
+ }
63
+
64
+ .splash-description-full {
65
+ padding-top: 2em;
66
+ }
67
+
68
+ .splash-description-full img {
69
+ max-width: 100%;
70
+ }