Joomi_MasonryGallery - Version 1.0.0

Version Notes

# First release
# Known bugs:
- unable to add gallery widget from widget window in editor

Download this release

Release Info

Developer joomi
Extension Joomi_MasonryGallery
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (118) hide show
  1. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Catalog/Product/Edit/Tab/Gallery.php +197 -0
  2. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Abstract.php +194 -0
  3. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit.php +41 -0
  4. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Form.php +215 -0
  5. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tab/Form.php +116 -0
  6. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tab/Meta.php +52 -0
  7. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tab/Stores.php +49 -0
  8. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tabs.php +71 -0
  9. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Tree.php +323 -0
  10. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Widget/Chooser.php +150 -0
  11. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery.php +40 -0
  12. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit.php +63 -0
  13. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Form.php +46 -0
  14. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Form.php +161 -0
  15. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Meta.php +52 -0
  16. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Product.php +212 -0
  17. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Stores.php +49 -0
  18. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tabs.php +77 -0
  19. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Grid.php +286 -0
  20. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Widget/Chooser.php +158 -0
  21. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Helper/Column/Renderer/Parent.php +74 -0
  22. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Helper/Column/Renderer/Relation.php +54 -0
  23. app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Helper/Wysiwyg.php +44 -0
  24. app/code/community/Joomi/MasonryGallery/Block/Category/Children.php +45 -0
  25. app/code/community/Joomi/MasonryGallery/Block/Category/Gallery/List.php +56 -0
  26. app/code/community/Joomi/MasonryGallery/Block/Category/List.php +135 -0
  27. app/code/community/Joomi/MasonryGallery/Block/Category/View.php +35 -0
  28. app/code/community/Joomi/MasonryGallery/Block/Category/Widget/Link.php +27 -0
  29. app/code/community/Joomi/MasonryGallery/Block/Category/Widget/Subtree.php +59 -0
  30. app/code/community/Joomi/MasonryGallery/Block/Category/Widget/View.php +48 -0
  31. app/code/community/Joomi/MasonryGallery/Block/Gallery/Catalog/Product/List.php +49 -0
  32. app/code/community/Joomi/MasonryGallery/Block/Gallery/List.php +62 -0
  33. app/code/community/Joomi/MasonryGallery/Block/Gallery/View.php +35 -0
  34. app/code/community/Joomi/MasonryGallery/Block/Gallery/Widget/Link.php +27 -0
  35. app/code/community/Joomi/MasonryGallery/Block/Gallery/Widget/View.php +48 -0
  36. app/code/community/Joomi/MasonryGallery/Controller/Adminhtml/MasonryGallery.php +61 -0
  37. app/code/community/Joomi/MasonryGallery/Controller/Router.php +118 -0
  38. app/code/community/Joomi/MasonryGallery/Helper/Category.php +57 -0
  39. app/code/community/Joomi/MasonryGallery/Helper/Data.php +42 -0
  40. app/code/community/Joomi/MasonryGallery/Helper/Gallery.php +47 -0
  41. app/code/community/Joomi/MasonryGallery/Helper/Product.php +55 -0
  42. app/code/community/Joomi/MasonryGallery/Model/Adminhtml/Observer.php +81 -0
  43. app/code/community/Joomi/MasonryGallery/Model/Adminhtml/Search/Gallery.php +55 -0
  44. app/code/community/Joomi/MasonryGallery/Model/Category.php +395 -0
  45. app/code/community/Joomi/MasonryGallery/Model/Category/Source.php +108 -0
  46. app/code/community/Joomi/MasonryGallery/Model/Gallery.php +199 -0
  47. app/code/community/Joomi/MasonryGallery/Model/Gallery/Attribute/Source/Bigimage.php +86 -0
  48. app/code/community/Joomi/MasonryGallery/Model/Gallery/Attribute/Source/Thumbnail.php +86 -0
  49. app/code/community/Joomi/MasonryGallery/Model/Gallery/Product.php +61 -0
  50. app/code/community/Joomi/MasonryGallery/Model/Resource/Category.php +700 -0
  51. app/code/community/Joomi/MasonryGallery/Model/Resource/Category/Collection.php +241 -0
  52. app/code/community/Joomi/MasonryGallery/Model/Resource/Category/Tree.php +409 -0
  53. app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery.php +251 -0
  54. app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery/Collection.php +139 -0
  55. app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery/Product.php +83 -0
  56. app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery/Product/Collection.php +65 -0
  57. app/code/community/Joomi/MasonryGallery/Model/Resource/Setup.php +26 -0
  58. app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/Category/WidgetController.php +69 -0
  59. app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/CategoryController.php +316 -0
  60. app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/Gallery/Catalog/ProductController.php +62 -0
  61. app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/Gallery/WidgetController.php +39 -0
  62. app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/GalleryController.php +395 -0
  63. app/code/community/Joomi/MasonryGallery/controllers/CategoryController.php +143 -0
  64. app/code/community/Joomi/MasonryGallery/controllers/GalleryController.php +130 -0
  65. app/code/community/Joomi/MasonryGallery/data/joomi_masonrygallery_setup/data-install-1.0.0.php +31 -0
  66. app/code/community/Joomi/MasonryGallery/etc/adminhtml.xml +70 -0
  67. app/code/community/Joomi/MasonryGallery/etc/config.xml +177 -0
  68. app/code/community/Joomi/MasonryGallery/etc/system.xml +252 -0
  69. app/code/community/Joomi/MasonryGallery/etc/widget.xml +138 -0
  70. app/code/community/Joomi/MasonryGallery/sql/joomi_masonrygallery_setup/install-1.0.0.php +215 -0
  71. app/design/adminhtml/default/default/layout/joomi_masonrygallery.xml +110 -0
  72. app/design/adminhtml/default/default/template/joomi_masonrygallery/category/edit.phtml +151 -0
  73. app/design/adminhtml/default/default/template/joomi_masonrygallery/category/edit/form.phtml +160 -0
  74. app/design/adminhtml/default/default/template/joomi_masonrygallery/category/tree.phtml +376 -0
  75. app/design/adminhtml/default/default/template/joomi_masonrygallery/category/widget/tree.phtml +172 -0
  76. app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/edit.phtml +151 -0
  77. app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/edit/form.phtml +217 -0
  78. app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/tree.phtml +376 -0
  79. app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/widget/tree.phtml +172 -0
  80. app/design/frontend/base/default/layout/joomi_masonrygallery.xml +65 -0
  81. app/design/frontend/base/default/template/joomi_masonrygallery/category/children.phtml +50 -0
  82. app/design/frontend/base/default/template/joomi_masonrygallery/category/gallery/list.phtml +48 -0
  83. app/design/frontend/base/default/template/joomi_masonrygallery/category/list.phtml +55 -0
  84. app/design/frontend/base/default/template/joomi_masonrygallery/category/view.phtml +44 -0
  85. app/design/frontend/base/default/template/joomi_masonrygallery/category/widget/link.phtml +30 -0
  86. app/design/frontend/base/default/template/joomi_masonrygallery/category/widget/subtree.phtml +36 -0
  87. app/design/frontend/base/default/template/joomi_masonrygallery/category/widget/view.phtml +42 -0
  88. app/design/frontend/base/default/template/joomi_masonrygallery/gallery/catalog/product/list.phtml +68 -0
  89. app/design/frontend/base/default/template/joomi_masonrygallery/gallery/headerInsert.phtml +34 -0
  90. app/design/frontend/base/default/template/joomi_masonrygallery/gallery/list.phtml +54 -0
  91. app/design/frontend/base/default/template/joomi_masonrygallery/gallery/view.phtml +105 -0
  92. app/design/frontend/base/default/template/joomi_masonrygallery/gallery/widget/link.phtml +30 -0
  93. app/design/frontend/base/default/template/joomi_masonrygallery/gallery/widget/view.phtml +156 -0
  94. app/etc/modules/Joomi_MasonryGallery.xml +29 -0
  95. app/locale/en_US/Joomi_MasonryGallery.csv +128 -0
  96. package.xml +21 -0
  97. skin/frontend/base/default/css/joomi_masonrygallery/jquery.fancybox.css +274 -0
  98. skin/frontend/base/default/css/joomi_masonrygallery/masonry.css +57 -0
  99. skin/frontend/base/default/css/joomi_masonrygallery/tree.css +32 -0
  100. skin/frontend/base/default/images/joomi_masonrygallery/blank.gif +0 -0
  101. skin/frontend/base/default/images/joomi_masonrygallery/collapsed.gif +0 -0
  102. skin/frontend/base/default/images/joomi_masonrygallery/collapsed.png +0 -0
  103. skin/frontend/base/default/images/joomi_masonrygallery/expanded.gif +0 -0
  104. skin/frontend/base/default/images/joomi_masonrygallery/expanded.png +0 -0
  105. skin/frontend/base/default/images/joomi_masonrygallery/fancybox_loading.gif +0 -0
  106. skin/frontend/base/default/images/joomi_masonrygallery/fancybox_loading@2x.gif +0 -0
  107. skin/frontend/base/default/images/joomi_masonrygallery/fancybox_overlay.png +0 -0
  108. skin/frontend/base/default/images/joomi_masonrygallery/fancybox_sprite.png +0 -0
  109. skin/frontend/base/default/images/joomi_masonrygallery/fancybox_sprite@2x.png +0 -0
  110. skin/frontend/base/default/images/joomi_masonrygallery/line1.gif +0 -0
  111. skin/frontend/base/default/images/joomi_masonrygallery/line1.png +0 -0
  112. skin/frontend/base/default/images/joomi_masonrygallery/line2.gif +0 -0
  113. skin/frontend/base/default/images/joomi_masonrygallery/line2.png +0 -0
  114. skin/frontend/base/default/images/joomi_masonrygallery/transform.png +0 -0
  115. skin/frontend/base/default/js/joomi_masonrygallery/jquery.fancybox.pack.js +46 -0
  116. skin/frontend/base/default/js/joomi_masonrygallery/jquery.js +6 -0
  117. skin/frontend/base/default/js/joomi_masonrygallery/jquery_masonry.js +9 -0
  118. skin/frontend/base/default/js/joomi_masonrygallery/tree.js +47 -0
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Catalog/Product/Edit/Tab/Gallery.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery tab on product edit form
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Catalog_Product_Edit_Tab_Gallery
25
+ extends Mage_Adminhtml_Block_Widget_Grid {
26
+ /**
27
+ * Set grid params
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct() {
32
+ parent::__construct();
33
+ $this->setId('gallery_grid');
34
+ $this->setDefaultSort('position');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setUseAjax(true);
37
+ if ($this->getProduct()->getId()) {
38
+ $this->setDefaultFilter(array('in_galleries'=>1));
39
+ }
40
+ }
41
+ /**
42
+ * prepare the gallery collection
43
+ * @access protected
44
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Catalog_Product_Edit_Tab_Gallery
45
+ * @author Ultimate Module Creator
46
+ */
47
+ protected function _prepareCollection() {
48
+ $collection = Mage::getResourceModel('joomi_masonrygallery/gallery_collection');
49
+ if ($this->getProduct()->getId()){
50
+ $constraint = 'related.product_id='.$this->getProduct()->getId();
51
+ }
52
+ else{
53
+ $constraint = 'related.product_id=0';
54
+ }
55
+ $collection->getSelect()->joinLeft(
56
+ array('related'=>$collection->getTable('joomi_masonrygallery/gallery_product')),
57
+ 'related.gallery_id=main_table.entity_id AND '.$constraint,
58
+ array('position')
59
+ );
60
+ $this->setCollection($collection);
61
+ parent::_prepareCollection();
62
+ return $this;
63
+ }
64
+ /**
65
+ * prepare mass action grid
66
+ * @access protected
67
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Catalog_Product_Edit_Tab_Gallery
68
+ * @author Ultimate Module Creator
69
+ */
70
+ protected function _prepareMassaction(){
71
+ return $this;
72
+ }
73
+ /**
74
+ * prepare the grid columns
75
+ * @access protected
76
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Catalog_Product_Edit_Tab_Gallery
77
+ * @author Ultimate Module Creator
78
+ */
79
+ protected function _prepareColumns(){
80
+ $this->addColumn('in_galleries', array(
81
+ 'header_css_class' => 'a-center',
82
+ 'type' => 'checkbox',
83
+ 'name' => 'in_galleries',
84
+ 'values'=> $this->_getSelectedGalleries(),
85
+ 'align' => 'center',
86
+ 'index' => 'entity_id'
87
+ ));
88
+ $this->addColumn('title', array(
89
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Title'),
90
+ 'align' => 'left',
91
+ 'index' => 'title',
92
+ 'renderer' => 'joomi_masonrygallery/adminhtml_helper_column_renderer_relation',
93
+ 'params' => array(
94
+ 'id'=>'getId'
95
+ ),
96
+ 'base_link' => 'adminhtml/masonrygallery_gallery/edit',
97
+ ));
98
+ $this->addColumn('position', array(
99
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Position'),
100
+ 'name' => 'position',
101
+ 'width' => 60,
102
+ 'type' => 'number',
103
+ 'validate_class'=> 'validate-number',
104
+ 'index' => 'position',
105
+ 'editable' => true,
106
+ ));
107
+ return parent::_prepareColumns();
108
+ }
109
+ /**
110
+ * Retrieve selected galleries
111
+ * @access protected
112
+ * @return array
113
+ * @author Ultimate Module Creator
114
+ */
115
+ protected function _getSelectedGalleries(){
116
+ $galleries = $this->getProductGalleries();
117
+ if (!is_array($galleries)) {
118
+ $galleries = array_keys($this->getSelectedGalleries());
119
+ }
120
+ return $galleries;
121
+ }
122
+ /**
123
+ * Retrieve selected galleries
124
+ * @access protected
125
+ * @return array
126
+ * @author Ultimate Module Creator
127
+ */
128
+ public function getSelectedGalleries() {
129
+ $galleries = array();
130
+ //used helper here in order not to override the product model
131
+ $selected = Mage::helper('joomi_masonrygallery/product')->getSelectedGalleries(Mage::registry('current_product'));
132
+ if (!is_array($selected)){
133
+ $selected = array();
134
+ }
135
+ foreach ($selected as $gallery) {
136
+ $galleries[$gallery->getId()] = array('position' => $gallery->getPosition());
137
+ }
138
+ return $galleries;
139
+ }
140
+ /**
141
+ * get row url
142
+ * @access public
143
+ * @param Joomi_MasonryGallery_Model_Gallery
144
+ * @return string
145
+ * @author Ultimate Module Creator
146
+ */
147
+ public function getRowUrl($item){
148
+ return '#';
149
+ }
150
+ /**
151
+ * get grid url
152
+ * @access public
153
+ * @return string
154
+ * @author Ultimate Module Creator
155
+ */
156
+ public function getGridUrl(){
157
+ return $this->getUrl('*/*/galleriesGrid', array(
158
+ 'id'=>$this->getProduct()->getId()
159
+ ));
160
+ }
161
+ /**
162
+ * get the current product
163
+ * @access public
164
+ * @return Mage_Catalog_Model_Product
165
+ * @author Ultimate Module Creator
166
+ */
167
+ public function getProduct(){
168
+ return Mage::registry('current_product');
169
+ }
170
+ /**
171
+ * Add filter
172
+ * @access protected
173
+ * @param object $column
174
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Catalog_Product_Edit_Tab_Gallery
175
+ * @author Ultimate Module Creator
176
+ */
177
+ protected function _addColumnFilterToCollection($column){
178
+ if ($column->getId() == 'in_galleries') {
179
+ $galleryIds = $this->_getSelectedGalleries();
180
+ if (empty($galleryIds)) {
181
+ $galleryIds = 0;
182
+ }
183
+ if ($column->getFilter()->getValue()) {
184
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$galleryIds));
185
+ }
186
+ else {
187
+ if($galleryIds) {
188
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$galleryIds));
189
+ }
190
+ }
191
+ }
192
+ else {
193
+ parent::_addColumnFilterToCollection($column);
194
+ }
195
+ return $this;
196
+ }
197
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Abstract.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin block abstract
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Abstract
25
+ extends Mage_Adminhtml_Block_Template {
26
+ /**
27
+ * get current category
28
+ * @access public
29
+ * @return Joomi_MasonryGallery_Model_Entity
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getCategory() {
33
+ return Mage::registry('category');
34
+ }
35
+ /**
36
+ * get current category id
37
+ * @access public
38
+ * @return int
39
+ * @author Ultimate Module Creator
40
+ */
41
+ public function getCategoryId() {
42
+ if ($this->getCategory()) {
43
+ return $this->getCategory()->getId();
44
+ }
45
+ return null;
46
+ }
47
+ /**
48
+ * get current category Title
49
+ * @access public
50
+ * @return string
51
+ * @author Ultimate Module Creator
52
+ */
53
+ public function getCategoryTitle() {
54
+ return $this->getCategory()->getTitle();
55
+ }
56
+ /**
57
+ * get current category path
58
+ * @access public
59
+ * @return string
60
+ * @author Ultimate Module Creator
61
+ */
62
+ public function getCategoryPath() {
63
+ if ($this->getCategory()) {
64
+ return $this->getCategory()->getPath();
65
+ }
66
+ return Mage::helper('joomi_masonrygallery/category')->getRootCategoryId();
67
+ }
68
+ /**
69
+ * check if there is a root category
70
+ * @access public
71
+ * @return bool
72
+ * @author Ultimate Module Creator
73
+ */
74
+ public function hasRootCategory() {
75
+ $root = $this->getRoot();
76
+ if ($root && $root->getId()) {
77
+ return true;
78
+ }
79
+ return false;
80
+ }
81
+ /**
82
+ * get the root
83
+ * @access publoc
84
+ * @param Joomi_MasonryGallery_Model_Category|null $parentNodeCategory
85
+ * @param int $recursionLevel
86
+ * @return Varien_Data_Tree_Node
87
+ * @author Ultimate Module Creator
88
+ */
89
+ public function getRoot($parentNodeCategory = null, $recursionLevel = 3) {
90
+ if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
91
+ return $this->getNode($parentNodeCategory, $recursionLevel);
92
+ }
93
+ $root = Mage::registry('root');
94
+ if (is_null($root)) {
95
+ $rootId = Mage::helper('joomi_masonrygallery/category')->getRootCategoryId();
96
+ $tree = Mage::getResourceSingleton('joomi_masonrygallery/category_tree')
97
+ ->load(null, $recursionLevel);
98
+ if ($this->getCategory()) {
99
+ $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId));
100
+ }
101
+ $tree->addCollectionData($this->getCategoryCollection());
102
+ $root = $tree->getNodeById($rootId);
103
+ if ($root && $rootId != Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()) {
104
+ $root->setIsVisible(true);
105
+ }
106
+ elseif($root && $root->getId() == Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()) {
107
+ $root->setTitle(Mage::helper('joomi_masonrygallery')->__('Root'));
108
+ }
109
+ Mage::register('root', $root);
110
+ }
111
+ return $root;
112
+ }
113
+
114
+ /**
115
+ * Get and register categories root by specified categories IDs
116
+ * @accsess public
117
+ * @param array $ids
118
+ * @return Varien_Data_Tree_Node
119
+ * @author Ultimate Module Creator
120
+ */
121
+ public function getRootByIds($ids) {
122
+ $root = Mage::registry('root');
123
+ if (null === $root) {
124
+ $categoryTreeResource = Mage::getResourceSingleton('joomi_masonrygallery/category_tree');
125
+ $ids = $categoryTreeResource->getExistingCategoryIdsBySpecifiedIds($ids);
126
+ $tree = $categoryTreeResource->loadByIds($ids);
127
+ $rootId = Mage::helper('joomi_masonrygallery/category')->getRootCategoryId();
128
+ $root = $tree->getNodeById($rootId);
129
+ if ($root && $rootId != Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()) {
130
+ $root->setIsVisible(true);
131
+ }
132
+ else if($root && $root->getId() == Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()) {
133
+ $root->setName(Mage::helper('joomi_masonrygallery')->__('Root'));
134
+ }
135
+ $tree->addCollectionData($this->getCategoryCollection());
136
+ Mage::register('root', $root);
137
+ }
138
+ return $root;
139
+ }
140
+ /**
141
+ * get specific node
142
+ * @access public
143
+ * @param Joomi_MasonryGallery_Model_Category $parentNodeCategory
144
+ * @param $int $recursionLevel
145
+ * @return Varien_Data_Tree_Node
146
+ * @author Ultimate Module Creator
147
+ */
148
+ public function getNode($parentNodeCategory, $recursionLevel = 2) {
149
+ $tree = Mage::getResourceModel('joomi_masonrygallery/category_tree');
150
+ $nodeId = $parentNodeCategory->getId();
151
+ $parentId = $parentNodeCategory->getParentId();
152
+ $node = $tree->loadNode($nodeId);
153
+ $node->loadChildren($recursionLevel);
154
+ if ($node && $nodeId != Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()) {
155
+ $node->setIsVisible(true);
156
+ }
157
+ elseif($node && $node->getId() == Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()) {
158
+ $node->setTitle(Mage::helper('joomi_masonrygallery')->__('Root'));
159
+ }
160
+ $tree->addCollectionData($this->getCategoryCollection());
161
+ return $node;
162
+ }
163
+ /**
164
+ * get url for saving data
165
+ * @access public
166
+ * @param array $args
167
+ * @return string
168
+ * @author Ultimate Module Creator
169
+ */
170
+ public function getSaveUrl(array $args = array()) {
171
+ $params = array('_current'=>true);
172
+ $params = array_merge($params, $args);
173
+ return $this->getUrl('*/*/save', $params);
174
+ }
175
+ /**
176
+ * get url for edit
177
+ * @access public
178
+ * @param array $args
179
+ * @return string
180
+ * @author Ultimate Module Creator
181
+ */
182
+ public function getEditUrl() {
183
+ return $this->getUrl("*/masonrygallery_category/edit", array('_current'=>true, '_query'=>false, 'id'=>null, 'parent'=>null));
184
+ }
185
+ /**
186
+ * Return root ids
187
+ * @access public
188
+ * @return array
189
+ * @author Ultimate Module Creator
190
+ */
191
+ public function getRootIds() {
192
+ return array(Mage::helper('joomi_masonrygallery/category')->getRootCategoryId());
193
+ }
194
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin edit form
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Edit
25
+ extends Mage_Adminhtml_Block_Widget_Form_Container {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct(){
33
+ $this->_objectId = 'entity_id';
34
+ $this->_blockGroup = 'joomi_masonrygallery';
35
+ $this->_controller = 'adminhtml_category';
36
+ $this->_mode = 'edit';
37
+ parent::__construct();
38
+ $this->setTemplate('joomi_masonrygallery/category/edit.phtml');
39
+ }
40
+ }
41
+
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Form.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category edit form
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+
25
+
26
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Form
27
+ extends Joomi_MasonryGallery_Block_Adminhtml_Category_Abstract {
28
+
29
+ /**
30
+ * Additional buttons on category page
31
+ * @var array
32
+ */
33
+ protected $_additionalButtons = array();
34
+ /**
35
+ * constructor
36
+ * set template
37
+ * @access public
38
+ * @author Ultimate Module Creator
39
+ */
40
+ public function __construct() {
41
+ parent::__construct();
42
+ $this->setTemplate('joomi_masonrygallery/category/edit/form.phtml');
43
+ }
44
+ /**
45
+ * prepare the layout
46
+ * @access protected
47
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Form
48
+ * @author Ultimate Module Creator
49
+ */
50
+ protected function _prepareLayout() {
51
+ $category = $this->getCategory();
52
+ $categoryId = (int)$category->getId();
53
+ $this->setChild('tabs',
54
+ $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_edit_tabs', 'tabs')
55
+ );
56
+ $this->setChild('save_button',
57
+ $this->getLayout()->createBlock('adminhtml/widget_button')
58
+ ->setData(array(
59
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Save Category'),
60
+ 'onclick' => "categorySubmit('" . $this->getSaveUrl() . "', true)",
61
+ 'class' => 'save'
62
+ ))
63
+ );
64
+ // Delete button
65
+ if (!in_array($categoryId, $this->getRootIds())) {
66
+ $this->setChild('delete_button',
67
+ $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Delete Category'),
70
+ 'onclick' => "categoryDelete('" . $this->getUrl('*/*/delete', array('_current' => true)) . "', true, {$categoryId})",
71
+ 'class' => 'delete'
72
+ ))
73
+ );
74
+ }
75
+
76
+ // Reset button
77
+ $resetPath = $category ? '*/*/edit' : '*/*/add';
78
+ $this->setChild('reset_button',
79
+ $this->getLayout()->createBlock('adminhtml/widget_button')
80
+ ->setData(array(
81
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Reset'),
82
+ 'onclick' => "categoryReset('".$this->getUrl($resetPath, array('_current'=>true))."',true)"
83
+ ))
84
+ );
85
+ return parent::_prepareLayout();
86
+ }
87
+ /**
88
+ * get html for delete button
89
+ * @access public
90
+ * @return string
91
+ * @author Ultimate Module Creator
92
+ */
93
+ public function getDeleteButtonHtml() {
94
+ return $this->getChildHtml('delete_button');
95
+ }
96
+ /**
97
+ * get html for save button
98
+ * @access public
99
+ * @return string
100
+ * @author Ultimate Module Creator
101
+ */
102
+ public function getSaveButtonHtml() {
103
+ return $this->getChildHtml('save_button');
104
+ }
105
+ /**
106
+ * get html for reset button
107
+ * @access public
108
+ * @return string
109
+ * @author Ultimate Module Creator
110
+ */
111
+ public function getResetButtonHtml() {
112
+ return $this->getChildHtml('reset_button');
113
+ }
114
+ /**
115
+ * Retrieve additional buttons html
116
+ * @access public
117
+ * @return string
118
+ * @author Ultimate Module Creator
119
+ */
120
+ public function getAdditionalButtonsHtml() {
121
+ $html = '';
122
+ foreach ($this->_additionalButtons as $childName) {
123
+ $html .= $this->getChildHtml($childName);
124
+ }
125
+ return $html;
126
+ }
127
+
128
+ /**
129
+ * Add additional button
130
+ *
131
+ * @param string $alias
132
+ * @param array $config
133
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Form
134
+ * @author Ultimate Module Creator
135
+ */
136
+ public function addAdditionalButton($alias, $config){
137
+ if (isset($config['name'])) {
138
+ $config['element_name'] = $config['name'];
139
+ }
140
+ $this->setChild($alias . '_button',
141
+ $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
142
+ $this->_additionalButtons[$alias] = $alias . '_button';
143
+ return $this;
144
+ }
145
+ /**
146
+ * Remove additional button
147
+ * @access public
148
+ * @param string $alias
149
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Form
150
+ * @author Ultimate Module Creator
151
+ */
152
+ public function removeAdditionalButton($alias) {
153
+ if (isset($this->_additionalButtons[$alias])) {
154
+ $this->unsetChild($this->_additionalButtons[$alias]);
155
+ unset($this->_additionalButtons[$alias]);
156
+ }
157
+ return $this;
158
+ }
159
+ /**
160
+ * get html for tabs
161
+ * @access public
162
+ * @return string
163
+ * @author Ultimate Module Creator
164
+ */
165
+ public function getTabsHtml() {
166
+ return $this->getChildHtml('tabs');
167
+ }
168
+ /**
169
+ * get the form header
170
+ * @access public
171
+ * @return string
172
+ * @author Ultimate Module Creator
173
+ */
174
+ public function getHeader() {
175
+ if ($this->getCategoryId()) {
176
+ return $this->getCategoryTitle();
177
+ }
178
+ else {
179
+ return Mage::helper('joomi_masonrygallery')->__('New Root Category');
180
+ }
181
+ }
182
+ /**
183
+ * get the delete url
184
+ * @access public
185
+ * @param array $args
186
+ * @return string
187
+ * @author Ultimate Module Creator
188
+ */
189
+ public function getDeleteUrl(array $args = array()) {
190
+ $params = array('_current'=>true);
191
+ $params = array_merge($params, $args);
192
+ return $this->getUrl('*/*/delete', $params);
193
+ }
194
+ /**
195
+ * Return URL for refresh input element 'path' in form
196
+ * @access public
197
+ * @param array $args
198
+ * @return string
199
+ * @author Ultimate Module Creator
200
+ */
201
+ public function getRefreshPathUrl(array $args = array()) {
202
+ $params = array('_current'=>true);
203
+ $params = array_merge($params, $args);
204
+ return $this->getUrl('*/*/refreshPath', $params);
205
+ }
206
+ /**
207
+ * check if request is ajax
208
+ * @access public
209
+ * @return bool
210
+ * @author Ultimate Module Creator
211
+ */
212
+ public function isAjax() {
213
+ return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
214
+ }
215
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tab/Form.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category edit form tab
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tab_Form
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare the form
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tab_Form
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareForm(){
33
+ $form = new Varien_Data_Form();
34
+ $form->setHtmlIdPrefix('category_');
35
+ $form->setFieldNameSuffix('category');
36
+ $this->setForm($form);
37
+ $fieldset = $form->addFieldset('category_form', array('legend'=>Mage::helper('joomi_masonrygallery')->__('Category')));
38
+ $fieldset->addType('editor', Mage::getConfig()->getBlockClassName('joomi_masonrygallery/adminhtml_helper_wysiwyg'));
39
+ if (!$this->getCategory()->getId()) {
40
+ $parentId = $this->getRequest()->getParam('parent');
41
+ if (!$parentId) {
42
+ $parentId = Mage::helper('joomi_masonrygallery/category')->getRootCategoryId();
43
+ }
44
+ $fieldset->addField('path', 'hidden', array(
45
+ 'name' => 'path',
46
+ 'value' => $parentId
47
+ ));
48
+ }
49
+ else {
50
+ $fieldset->addField('id', 'hidden', array(
51
+ 'name' => 'id',
52
+ 'value' => $this->getCategory()->getId()
53
+ ));
54
+ $fieldset->addField('path', 'hidden', array(
55
+ 'name' => 'path',
56
+ 'value' => $this->getCategory()->getPath()
57
+ ));
58
+ }
59
+
60
+ $fieldset->addField('title', 'text', array(
61
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Title'),
62
+ 'name' => 'title',
63
+ 'required' => true,
64
+ 'class' => 'required-entry',
65
+
66
+ ));
67
+
68
+ $fieldset->addField('description', 'editor', array(
69
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Description'),
70
+ 'name' => 'description',
71
+
72
+ ));
73
+
74
+ $fieldset->addField('ordering', 'text', array(
75
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Ordering'),
76
+ 'name' => 'ordering',
77
+
78
+ ));
79
+ $fieldset->addField('url_key', 'text', array(
80
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Url key'),
81
+ 'name' => 'url_key',
82
+ 'note' => Mage::helper('joomi_masonrygallery')->__('Relative to Website Base URL')
83
+ ));
84
+ $fieldset->addField('status', 'select', array(
85
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Status'),
86
+ 'name' => 'status',
87
+ 'values'=> array(
88
+ array(
89
+ 'value' => 1,
90
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Enabled'),
91
+ ),
92
+ array(
93
+ 'value' => 0,
94
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Disabled'),
95
+ ),
96
+ ),
97
+ ));
98
+ if (Mage::app()->isSingleStoreMode()){
99
+ $fieldset->addField('store_id', 'hidden', array(
100
+ 'name' => 'stores[]',
101
+ 'value' => Mage::app()->getStore(true)->getId()
102
+ ));
103
+ Mage::registry('current_category')->setStoreId(Mage::app()->getStore(true)->getId());
104
+ }
105
+ $form->addValues($this->getCategory()->getData());
106
+ return parent::_prepareForm();
107
+ }
108
+ /**
109
+ * get the current category
110
+ * @access public
111
+ * @return Joomi_MasonryGallery_Model_Category
112
+ */
113
+ public function getCategory(){
114
+ return Mage::registry('category');
115
+ }
116
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * meta information tab
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tab_Meta
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare the form
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tab_Meta
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareForm(){
33
+ $form = new Varien_Data_Form();
34
+ $form->setFieldNameSuffix('category');
35
+ $this->setForm($form);
36
+ $fieldset = $form->addFieldset('category_meta_form', array('legend'=>Mage::helper('joomi_masonrygallery')->__('Meta information')));
37
+ $fieldset->addField('meta_title', 'text', array(
38
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta-title'),
39
+ 'name' => 'meta_title',
40
+ ));
41
+ $fieldset->addField('meta_description', 'textarea', array(
42
+ 'name' => 'meta_description',
43
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta-description'),
44
+ ));
45
+ $fieldset->addField('meta_keywords', 'textarea', array(
46
+ 'name' => 'meta_keywords',
47
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta-keywords'),
48
+ ));
49
+ $form->addValues(Mage::registry('current_category')->getData());
50
+ return parent::_prepareForm();
51
+ }
52
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tab/Stores.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * store selection tab
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tab_Stores
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare the form
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tab_Stores
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareForm(){
33
+ $form = new Varien_Data_Form();
34
+ $form->setFieldNameSuffix('category');
35
+ $this->setForm($form);
36
+ $fieldset = $form->addFieldset('category_stores_form', array('legend'=>Mage::helper('joomi_masonrygallery')->__('Store views')));
37
+ $field = $fieldset->addField('store_id', 'multiselect', array(
38
+ 'name' => 'stores[]',
39
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Store Views'),
40
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Store Views'),
41
+ 'required' => true,
42
+ 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
43
+ ));
44
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
45
+ $field->setRenderer($renderer);
46
+ $form->addValues(Mage::registry('current_category')->getData());
47
+ return parent::_prepareForm();
48
+ }
49
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Edit/Tabs.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin edit tabs
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tabs
25
+ extends Mage_Adminhtml_Block_Widget_Tabs {
26
+ /**
27
+ * Initialize Tabs
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct() {
32
+ $this->setId('category_info_tabs');
33
+ $this->setDestElementId('category_tab_content');
34
+ $this->setTitle(Mage::helper('joomi_masonrygallery')->__('Category'));
35
+ $this->setTemplate('widget/tabshoriz.phtml');
36
+ }
37
+ /**
38
+ * Prepare Layout Content
39
+ * @access public
40
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Edit_Tabs
41
+ */
42
+ protected function _prepareLayout(){
43
+ $this->addTab('form_category', array(
44
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Category'),
45
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Category'),
46
+ 'content' => $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_edit_tab_form')->toHtml(),
47
+ ));
48
+ $this->addTab('form_meta_category', array(
49
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta'),
50
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Meta'),
51
+ 'content' => $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_edit_tab_meta')->toHtml(),
52
+ ));
53
+ if (!Mage::app()->isSingleStoreMode()){
54
+ $this->addTab('form_store_category', array(
55
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Store views'),
56
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Store views'),
57
+ 'content' => $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_edit_tab_stores')->toHtml(),
58
+ ));
59
+ }
60
+ return parent::_beforeToHtml();
61
+ }
62
+ /**
63
+ * Retrieve category entity
64
+ * @access public
65
+ * @return Joomi_MasonryGallery_Model_Category
66
+ * @author Ultimate Module Creator
67
+ */
68
+ public function getCategory(){
69
+ return Mage::registry('current_category');
70
+ }
71
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Tree.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin tree block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Tree
25
+ extends Joomi_MasonryGallery_Block_Adminhtml_Category_Abstract {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct(){
33
+ parent::__construct();
34
+ $this->setTemplate('joomi_masonrygallery/category/tree.phtml');
35
+ $this->setUseAjax(true);
36
+ $this->_withProductCount = true;
37
+ }
38
+ /**
39
+ * prepare the layout
40
+ * @access protected
41
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Tree
42
+ * @author Ultimate Module Creator
43
+ */
44
+ protected function _prepareLayout(){
45
+ $addUrl = $this->getUrl("*/*/add", array(
46
+ '_current'=>true,
47
+ 'id'=>null,
48
+ '_query' => false
49
+ ));
50
+
51
+ $this->setChild('add_sub_button',
52
+ $this->getLayout()->createBlock('adminhtml/widget_button')
53
+ ->setData(array(
54
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Add Child Category'),
55
+ 'onclick' => "addNew('".$addUrl."', false)",
56
+ 'class' => 'add',
57
+ 'id'=> 'add_child_category_button',
58
+ 'style' => $this->canAddChild() ? '' : 'display: none;'
59
+ ))
60
+ );
61
+
62
+ $this->setChild('add_root_button',
63
+ $this->getLayout()->createBlock('adminhtml/widget_button')
64
+ ->setData(array(
65
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Add Root Category'),
66
+ 'onclick' => "addNew('".$addUrl."', true)",
67
+ 'class' => 'add',
68
+ 'id'=> 'add_root_category_button'
69
+ ))
70
+ );
71
+ return parent::_prepareLayout();
72
+ }
73
+ /**
74
+ * get the category collection
75
+ * @access public
76
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
77
+ * @author Ultimate Module Creator
78
+ */
79
+ public function getCategoryCollection(){
80
+ $collection = $this->getData('category_collection');
81
+ if (is_null($collection)) {
82
+ $collection = Mage::getModel('joomi_masonrygallery/category')->getCollection();
83
+ $this->setData('category_collection', $collection);
84
+ }
85
+ return $collection;
86
+ }
87
+ /**
88
+ * get html for add root button
89
+ * @access public
90
+ * @return string
91
+ * @author Ultimate Module Creator
92
+ */
93
+ public function getAddRootButtonHtml(){
94
+ return $this->getChildHtml('add_root_button');
95
+ }
96
+ /**
97
+ * get html for add child button
98
+ * @access public
99
+ * @return string
100
+ * @author Ultimate Module Creator
101
+ */
102
+ public function getAddSubButtonHtml(){
103
+ return $this->getChildHtml('add_sub_button');
104
+ }
105
+ /**
106
+ * get html for expand button
107
+ * @access public
108
+ * @return string
109
+ * @author Ultimate Module Creator
110
+ */
111
+ public function getExpandButtonHtml(){
112
+ return $this->getChildHtml('expand_button');
113
+ }
114
+ /**
115
+ * get html for add collapse button
116
+ * @access public
117
+ * @return string
118
+ * @author Ultimate Module Creator
119
+ */
120
+ public function getCollapseButtonHtml(){
121
+ return $this->getChildHtml('collapse_button');
122
+ }
123
+ /**
124
+ * get url for tree load
125
+ * @access public
126
+ * @param mxed $expanded
127
+ * @return string
128
+ * @author Ultimate Module Creator
129
+ */
130
+ public function getLoadTreeUrl($expanded=null){
131
+ $params = array('_current'=>true, 'id'=>null,'store'=>null);
132
+ if ((is_null($expanded) && Mage::getSingleton('admin/session')->getCategoryIsTreeWasExpanded())|| $expanded == true) {
133
+ $params['expand_all'] = true;
134
+ }
135
+ return $this->getUrl('*/*/categoriesJson', $params);
136
+ }
137
+ /**
138
+ * get url for loading nodes
139
+ * @access public
140
+ * @return string
141
+ * @author Ultimate Module Creator
142
+ */
143
+ public function getNodesUrl(){
144
+ return $this->getUrl('*/masonrygallery_categories/jsonTree');
145
+ }
146
+ /**
147
+ * check if tree is expanded
148
+ * @access public
149
+ * @return string
150
+ * @author Ultimate Module Creator
151
+ */
152
+ public function getIsWasExpanded(){
153
+ return Mage::getSingleton('admin/session')->getCategoryIsTreeWasExpanded();
154
+ }
155
+ /**
156
+ * get url for moving category
157
+ * @access public
158
+ * @return string
159
+ * @author Ultimate Module Creator
160
+ */
161
+ public function getMoveUrl(){
162
+ return $this->getUrl('*/masonrygallery_category/move');
163
+ }
164
+ /**
165
+ * get the tree as json
166
+ * @access public
167
+ * @param mixed $parentNodeCategory
168
+ * @return string
169
+ * @author Ultimate Module Creator
170
+ */
171
+ public function getTree($parentNodeCategory = null){
172
+ $rootArray = $this->_getNodeJson($this->getRoot($parentNodeCategory));
173
+ $tree = isset($rootArray['children']) ? $rootArray['children'] : array();
174
+ return $tree;
175
+ }
176
+ /**
177
+ * get the tree as json
178
+ * @access public
179
+ * @param mixed $parentNodeCategory
180
+ * @return string
181
+ * @author Ultimate Module Creator
182
+ */
183
+ public function getTreeJson($parentNodeCategory = null){
184
+ $rootArray = $this->_getNodeJson($this->getRoot($parentNodeCategory));
185
+ $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
186
+ return $json;
187
+ }
188
+
189
+ /**
190
+ * Get JSON of array of categories, that are breadcrumbs for specified category path
191
+ * @access public
192
+ * @param string $path
193
+ * @param string $javascriptVarName
194
+ * @return string
195
+ * @author Ultimate Module Creator
196
+ */
197
+ public function getBreadcrumbsJavascript($path, $javascriptVarName){
198
+ if (empty($path)) {
199
+ return '';
200
+ }
201
+
202
+ $categories = Mage::getResourceSingleton('joomi_masonrygallery/category_tree')->loadBreadcrumbsArray($path);
203
+ if (empty($categories)) {
204
+ return '';
205
+ }
206
+ foreach ($categories as $key => $category) {
207
+ $categories[$key] = $this->_getNodeJson($category);
208
+ }
209
+ return
210
+ '<script type="text/javascript">'
211
+ . $javascriptVarName . ' = ' . Mage::helper('core')->jsonEncode($categories) . ';'
212
+ . ($this->canAddChild() ? '$("add_child_category_button").show();' : '$("add_child_category_button").hide();')
213
+ . '</script>';
214
+ }
215
+
216
+ /**
217
+ * Get JSON of a tree node or an associative array
218
+ * @access protected
219
+ * @param Varien_Data_Tree_Node|array $node
220
+ * @param int $level
221
+ * @return string
222
+ * @author Ultimate Module Creator
223
+ */
224
+ protected function _getNodeJson($node, $level = 0){
225
+ // create a node from data array
226
+ if (is_array($node)) {
227
+ $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
228
+ }
229
+ $item = array();
230
+ $item['text'] = $this->buildNodeName($node);
231
+ $item['id'] = $node->getId();
232
+ $item['path'] = $node->getData('path');
233
+ $item['cls'] = 'folder';
234
+ if ($node->getStatus()){
235
+ $item['cls'] .= ' active-category';
236
+ }
237
+ else{
238
+ $item['cls'] .= ' no-active-category';
239
+ }
240
+ $item['allowDrop'] = true;
241
+ $item['allowDrag'] = true;
242
+ if ((int)$node->getChildrenCount()>0) {
243
+ $item['children'] = array();
244
+ }
245
+ $isParent = $this->_isParentSelectedCategory($node);
246
+ if ($node->hasChildren()) {
247
+ $item['children'] = array();
248
+ if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
249
+ foreach ($node->getChildren() as $child) {
250
+ $item['children'][] = $this->_getNodeJson($child, $level+1);
251
+ }
252
+ }
253
+ }
254
+ if ($isParent || $node->getLevel() < 1) {
255
+ $item['expanded'] = true;
256
+ }
257
+ return $item;
258
+ }
259
+ /**
260
+ * Get node label
261
+ * @access public
262
+ * @param Varien_Object $node
263
+ * @return string
264
+ * @author Ultimate Module Creator
265
+ */
266
+ public function buildNodeName($node){
267
+ $result = $this->escapeHtml($node->getTitle());
268
+ return $result;
269
+ }
270
+ /**
271
+ * check if entity is movable
272
+ * @access protected
273
+ * @param Varien_Object $node
274
+ * @return bool
275
+ * @author Ultimate Module Creator
276
+ */
277
+ protected function _isCategoryMoveable($node){
278
+ return true;
279
+ }
280
+ /**
281
+ * check if parent is selected
282
+ * @access protected
283
+ * @param Varien_Object $node
284
+ * @return bool
285
+ * @author Ultimate Module Creator
286
+ */
287
+ protected function _isParentSelectedCategory($node){
288
+ if ($node && $this->getCategory()) {
289
+ $pathIds = $this->getCategory()->getPathIds();
290
+ if (in_array($node->getId(), $pathIds)) {
291
+ return true;
292
+ }
293
+ }
294
+ return false;
295
+ }
296
+
297
+ /**
298
+ * Check if page loaded by outside link to category edit
299
+ * @access public
300
+ * @return boolean
301
+ * @author Ultimate Module Creator
302
+ */
303
+ public function isClearEdit(){
304
+ return (bool) $this->getRequest()->getParam('clear');
305
+ }
306
+ /**
307
+ * Check availability of adding root category
308
+ * @access public
309
+ * @return boolean
310
+ * @author Ultimate Module Creator
311
+ */
312
+ public function canAddRootCategory(){
313
+ return true;
314
+ }
315
+ /**
316
+ * Check availability of adding child category
317
+ * @access public
318
+ * @return boolean
319
+ */
320
+ public function canAddChild(){
321
+ return true;
322
+ }
323
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Category/Widget/Chooser.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin widget chooser
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+
25
+ class Joomi_MasonryGallery_Block_Adminhtml_Category_Widget_Chooser
26
+ extends Joomi_MasonryGallery_Block_Adminhtml_Category_Tree {
27
+ protected $_selectedCategories = array();
28
+ /**
29
+ * Block construction
30
+ * Defines tree template and init tree params
31
+ * @access public
32
+ * @return void
33
+ * @author Ultimate Module Creator
34
+ */
35
+ public function __construct(){
36
+ parent::__construct();
37
+ $this->setTemplate('joomi_masonrygallery/category/widget/tree.phtml');
38
+ }
39
+ /**
40
+ * Setter
41
+ * @access public
42
+ * @param array $selectedCategories
43
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Widget_Chooser
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function setSelectedCategories($selectedCategories){
47
+ $this->_selectedCategories = $selectedCategories;
48
+ return $this;
49
+ }
50
+ /**
51
+ * Getter
52
+ * @access public
53
+ * @return array
54
+ * @author Ultimate Module Creator
55
+ */
56
+ public function getSelectedCategories(){
57
+ return $this->_selectedCategories;
58
+ }
59
+ /**
60
+ * Prepare chooser element HTML
61
+ * @access public
62
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
63
+ * @return Varien_Data_Form_Element_Abstract
64
+ * @author Ultimate Module Creator
65
+ */
66
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element){
67
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
68
+ $sourceUrl = $this->getUrl('*/masonrygallery_category_widget/chooser', array('uniq_id' => $uniqId, 'use_massaction' => false));
69
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
70
+ ->setElement($element)
71
+ ->setTranslationHelper($this->getTranslationHelper())
72
+ ->setConfig($this->getConfig())
73
+ ->setFieldsetId($this->getFieldsetId())
74
+ ->setSourceUrl($sourceUrl)
75
+ ->setUniqId($uniqId);
76
+ $value = $element->getValue();
77
+ $categoryId = false;
78
+ if ($value) {
79
+ $categoryId = $value;
80
+ }
81
+ if ($categoryId) {
82
+ $label = Mage::getSingleton('joomi_masonrygallery/category')->load($categoryId)->getTitle();
83
+ $chooser->setLabel($label);
84
+ }
85
+ $element->setData('after_element_html', $chooser->toHtml());
86
+ return $element;
87
+ }
88
+ /**
89
+ * onClick listener js function
90
+ * @access public
91
+ * @return string
92
+ * @author Ultimate Module Creator
93
+ */
94
+ public function getNodeClickListener(){
95
+ if ($this->getData('node_click_listener')) {
96
+ return $this->getData('node_click_listener');
97
+ }
98
+ if ($this->getUseMassaction()) {
99
+ $js = '
100
+ function (node, e) {
101
+ if (node.ui.toggleCheck) {
102
+ node.ui.toggleCheck(true);
103
+ }
104
+ }
105
+ ';
106
+ }
107
+ else {
108
+ $chooserJsObject = $this->getId();
109
+ $js = '
110
+ function (node, e) {
111
+ '.$chooserJsObject.'.setElementValue(node.attributes.id);
112
+ '.$chooserJsObject.'.setElementLabel(node.text);
113
+ '.$chooserJsObject.'.close();
114
+ }
115
+ ';
116
+ }
117
+ return $js;
118
+ }
119
+
120
+ /**
121
+ * Get JSON of a tree node or an associative array
122
+ * @access protected
123
+ * @param Varien_Data_Tree_Node|array $node
124
+ * @param int $level
125
+ * @return string
126
+ * @author Ultimate Module Creator
127
+ */
128
+ protected function _getNodeJson($node, $level = 0){
129
+ $item = parent::_getNodeJson($node, $level);
130
+ if (in_array($node->getId(), $this->getSelectedCategories())) {
131
+ $item['checked'] = true;
132
+ }
133
+ return $item;
134
+ }
135
+
136
+ /**
137
+ * Tree JSON source URL
138
+ * @access public
139
+ * @param mixed $expanded
140
+ * @return string
141
+ * @author Ultimate Module Creator
142
+ */
143
+ public function getLoadTreeUrl($expanded=null){
144
+ return $this->getUrl('*/masonrygallery_category_widget/categoriesJson', array(
145
+ '_current'=>true,
146
+ 'uniq_id' => $this->getId(),
147
+ 'use_massaction' => $this->getUseMassaction()
148
+ ));
149
+ }
150
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery
25
+ extends Mage_Adminhtml_Block_Widget_Grid_Container {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct(){
33
+ $this->_controller = 'adminhtml_gallery';
34
+ $this->_blockGroup = 'joomi_masonrygallery';
35
+ parent::__construct();
36
+ $this->_headerText = Mage::helper('joomi_masonrygallery')->__('Gallery');
37
+ $this->_updateButton('add', 'label', Mage::helper('joomi_masonrygallery')->__('Add Gallery'));
38
+
39
+ }
40
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin edit form
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit
25
+ extends Mage_Adminhtml_Block_Widget_Form_Container {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct(){
33
+ parent::__construct();
34
+ $this->_blockGroup = 'joomi_masonrygallery';
35
+ $this->_controller = 'adminhtml_gallery';
36
+ $this->_updateButton('save', 'label', Mage::helper('joomi_masonrygallery')->__('Save Gallery'));
37
+ $this->_updateButton('delete', 'label', Mage::helper('joomi_masonrygallery')->__('Delete Gallery'));
38
+ $this->_addButton('saveandcontinue', array(
39
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Save And Continue Edit'),
40
+ 'onclick' => 'saveAndContinueEdit()',
41
+ 'class' => 'save',
42
+ ), -100);
43
+ $this->_formScripts[] = "
44
+ function saveAndContinueEdit(){
45
+ editForm.submit($('edit_form').action+'back/edit/');
46
+ }
47
+ ";
48
+ }
49
+ /**
50
+ * get the edit form header
51
+ * @access public
52
+ * @return string
53
+ * @author Ultimate Module Creator
54
+ */
55
+ public function getHeaderText(){
56
+ if( Mage::registry('current_gallery') && Mage::registry('current_gallery')->getId() ) {
57
+ return Mage::helper('joomi_masonrygallery')->__("Edit Gallery '%s'", $this->escapeHtml(Mage::registry('current_gallery')->getTitle()));
58
+ }
59
+ else {
60
+ return Mage::helper('joomi_masonrygallery')->__('Add Gallery');
61
+ }
62
+ }
63
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Form.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery edit form
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+
25
+
26
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Form
27
+ extends Mage_Adminhtml_Block_Widget_Form {
28
+ /**
29
+ * prepare form
30
+ * @access protected
31
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Form
32
+ * @author Ultimate Module Creator
33
+ */
34
+ protected function _prepareForm() {
35
+ $form = new Varien_Data_Form(array(
36
+ 'id' => 'edit_form',
37
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
38
+ 'method' => 'post',
39
+ 'enctype' => 'multipart/form-data'
40
+ )
41
+ );
42
+ $form->setUseContainer(true);
43
+ $this->setForm($form);
44
+ return parent::_prepareForm();
45
+ }
46
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Form.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery edit form tab
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Form
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare the form
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Form
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareForm(){
33
+ $form = new Varien_Data_Form();
34
+ $form->setHtmlIdPrefix('gallery_');
35
+ $form->setFieldNameSuffix('gallery');
36
+ $this->setForm($form);
37
+ $fieldset = $form->addFieldset('gallery_form', array('legend'=>Mage::helper('joomi_masonrygallery')->__('Gallery')));
38
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig();
39
+ $values = Mage::getResourceModel('joomi_masonrygallery/category_collection')->toOptionArray();
40
+ array_unshift($values, array('label'=>'', 'value'=>''));
41
+
42
+ $html = '<a href="{#url}" id="gallery_category_id_link" target="_blank"></a>';
43
+ $html .= '<script type="text/javascript">
44
+ function changeCategoryIdLink(){
45
+ if ($(\'gallery_category_id\').value == \'\') {
46
+ $(\'gallery_category_id_link\').hide();
47
+ }
48
+ else {
49
+ $(\'gallery_category_id_link\').show();
50
+ var url = \''.$this->getUrl('adminhtml/masonrygallery_category/edit', array('id'=>'{#id}', 'clear'=>1)).'\';
51
+ var text = \''.Mage::helper('core')->escapeHtml($this->__('View {#name}')).'\';
52
+ var realUrl = url.replace(\'{#id}\', $(\'gallery_category_id\').value);
53
+ $(\'gallery_category_id_link\').href = realUrl;
54
+ $(\'gallery_category_id_link\').innerHTML = text.replace(\'{#name}\', $(\'gallery_category_id\').options[$(\'gallery_category_id\').selectedIndex].innerHTML);
55
+ }
56
+ }
57
+ $(\'gallery_category_id\').observe(\'change\', changeCategoryIdLink);
58
+ changeCategoryIdLink();
59
+ </script>';
60
+
61
+ $fieldset->addField('category_id', 'select', array(
62
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Category'),
63
+ 'name' => 'category_id',
64
+ 'required' => false,
65
+ 'values' => $values,
66
+ 'after_element_html' => $html
67
+ ));
68
+
69
+ $fieldset->addField('title', 'text', array(
70
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Title'),
71
+ 'name' => 'title',
72
+ 'required' => true,
73
+ 'class' => 'required-entry',
74
+
75
+ ));
76
+
77
+ $fieldset->addField('description', 'editor', array(
78
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Description'),
79
+ 'name' => 'description',
80
+ 'config' => $wysiwygConfig,
81
+
82
+ ));
83
+
84
+ $fieldset->addField('column_width', 'text', array(
85
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Column Width'),
86
+ 'name' => 'column_width',
87
+ 'required' => true,
88
+ 'class' => 'required-entry',
89
+
90
+ ));
91
+
92
+ $fieldset->addField('thumbnail', 'select', array(
93
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Thumbnail'),
94
+ 'name' => 'thumbnail',
95
+ 'required' => true,
96
+ 'class' => 'required-entry',
97
+
98
+ 'values'=> Mage::getModel('joomi_masonrygallery/gallery_attribute_source_thumbnail')->getAllOptions(true),
99
+ ));
100
+
101
+ $fieldset->addField('big_image', 'select', array(
102
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Big Image'),
103
+ 'name' => 'big_image',
104
+ 'required' => true,
105
+ 'class' => 'required-entry',
106
+
107
+ 'values'=> Mage::getModel('joomi_masonrygallery/gallery_attribute_source_bigimage')->getAllOptions(true),
108
+ ));
109
+
110
+ $fieldset->addField('ordering', 'text', array(
111
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Ordering'),
112
+ 'name' => 'ordering',
113
+
114
+ ));
115
+
116
+ $fieldset->addField('limit_first_load', 'text', array(
117
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Limit First Load'),
118
+ 'name' => 'limit_first_load',
119
+
120
+ ));
121
+ $fieldset->addField('url_key', 'text', array(
122
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Url key'),
123
+ 'name' => 'url_key',
124
+ 'note' => Mage::helper('joomi_masonrygallery')->__('Relative to Website Base URL')
125
+ ));
126
+ $fieldset->addField('status', 'select', array(
127
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Status'),
128
+ 'name' => 'status',
129
+ 'values'=> array(
130
+ array(
131
+ 'value' => 1,
132
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Enabled'),
133
+ ),
134
+ array(
135
+ 'value' => 0,
136
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Disabled'),
137
+ ),
138
+ ),
139
+ ));
140
+ if (Mage::app()->isSingleStoreMode()){
141
+ $fieldset->addField('store_id', 'hidden', array(
142
+ 'name' => 'stores[]',
143
+ 'value' => Mage::app()->getStore(true)->getId()
144
+ ));
145
+ Mage::registry('current_gallery')->setStoreId(Mage::app()->getStore(true)->getId());
146
+ }
147
+ $formValues = Mage::registry('current_gallery')->getDefaultValues();
148
+ if (!is_array($formValues)){
149
+ $formValues = array();
150
+ }
151
+ if (Mage::getSingleton('adminhtml/session')->getGalleryData()){
152
+ $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getGalleryData());
153
+ Mage::getSingleton('adminhtml/session')->setGalleryData(null);
154
+ }
155
+ elseif (Mage::registry('current_gallery')){
156
+ $formValues = array_merge($formValues, Mage::registry('current_gallery')->getData());
157
+ }
158
+ $form->setValues($formValues);
159
+ return parent::_prepareForm();
160
+ }
161
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * meta information tab
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Meta
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare the form
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Meta
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareForm(){
33
+ $form = new Varien_Data_Form();
34
+ $form->setFieldNameSuffix('gallery');
35
+ $this->setForm($form);
36
+ $fieldset = $form->addFieldset('gallery_meta_form', array('legend'=>Mage::helper('joomi_masonrygallery')->__('Meta information')));
37
+ $fieldset->addField('meta_title', 'text', array(
38
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta-title'),
39
+ 'name' => 'meta_title',
40
+ ));
41
+ $fieldset->addField('meta_description', 'textarea', array(
42
+ 'name' => 'meta_description',
43
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta-description'),
44
+ ));
45
+ $fieldset->addField('meta_keywords', 'textarea', array(
46
+ 'name' => 'meta_keywords',
47
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta-keywords'),
48
+ ));
49
+ $form->addValues(Mage::registry('current_gallery')->getData());
50
+ return parent::_prepareForm();
51
+ }
52
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Product.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery - product relation edit block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Product
25
+ extends Mage_Adminhtml_Block_Widget_Grid {
26
+ /**
27
+ * Set grid params
28
+ * @access protected
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->setId('product_grid');
34
+ $this->setDefaultSort('position');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setUseAjax(true);
37
+ if ($this->getGallery()->getId()) {
38
+ $this->setDefaultFilter(array('in_products'=>1));
39
+ }
40
+ }
41
+ /**
42
+ * prepare the product collection
43
+ * @access protected
44
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Product
45
+ * @author Ultimate Module Creator
46
+ */
47
+ protected function _prepareCollection() {
48
+ $collection = Mage::getResourceModel('catalog/product_collection');
49
+ $collection->addAttributeToSelect('price');
50
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
51
+ $collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore);
52
+ if ($this->getGallery()->getId()){
53
+ $constraint = '{{table}}.gallery_id='.$this->getGallery()->getId();
54
+ }
55
+ else{
56
+ $constraint = '{{table}}.gallery_id=0';
57
+ }
58
+ $collection->joinField('position',
59
+ 'joomi_masonrygallery/gallery_product',
60
+ 'position',
61
+ 'product_id=entity_id',
62
+ $constraint,
63
+ 'left');
64
+ $this->setCollection($collection);
65
+ parent::_prepareCollection();
66
+ return $this;
67
+ }
68
+ /**
69
+ * prepare mass action grid
70
+ * @access protected
71
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Product
72
+ * @author Ultimate Module Creator
73
+ */
74
+ protected function _prepareMassaction(){
75
+ return $this;
76
+ }
77
+ /**
78
+ * prepare the grid columns
79
+ * @access protected
80
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Product
81
+ * @author Ultimate Module Creator
82
+ */
83
+ protected function _prepareColumns(){
84
+ $this->addColumn('in_products', array(
85
+ 'header_css_class' => 'a-center',
86
+ 'type' => 'checkbox',
87
+ 'name' => 'in_products',
88
+ 'values'=> $this->_getSelectedProducts(),
89
+ 'align' => 'center',
90
+ 'index' => 'entity_id'
91
+ ));
92
+ $this->addColumn('product_name', array(
93
+ 'header'=> Mage::helper('catalog')->__('Name'),
94
+ 'align' => 'left',
95
+ 'index' => 'product_name',
96
+ 'renderer' => 'joomi_masonrygallery/adminhtml_helper_column_renderer_relation',
97
+ 'params' => array(
98
+ 'id'=>'getId'
99
+ ),
100
+ 'base_link' => 'adminhtml/catalog_product/edit',
101
+ ));
102
+ $this->addColumn('sku', array(
103
+ 'header'=> Mage::helper('catalog')->__('SKU'),
104
+ 'align' => 'left',
105
+ 'index' => 'sku',
106
+ ));
107
+ $this->addColumn('price', array(
108
+ 'header'=> Mage::helper('catalog')->__('Price'),
109
+ 'type' => 'currency',
110
+ 'width' => '1',
111
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
112
+ 'index' => 'price'
113
+ ));
114
+ $this->addColumn('position', array(
115
+ 'header'=> Mage::helper('catalog')->__('Position'),
116
+ 'name' => 'position',
117
+ 'width' => 60,
118
+ 'type' => 'number',
119
+ 'validate_class'=> 'validate-number',
120
+ 'index' => 'position',
121
+ 'editable' => true,
122
+ ));
123
+ }
124
+ /**
125
+ * Retrieve selected products
126
+ * @access protected
127
+ * @return array
128
+ * @author Ultimate Module Creator
129
+ */
130
+ protected function _getSelectedProducts(){
131
+ $products = $this->getGalleryProducts();
132
+ if (!is_array($products)) {
133
+ $products = array_keys($this->getSelectedProducts());
134
+ }
135
+ return $products;
136
+ }
137
+ /**
138
+ * Retrieve selected products
139
+ * @access protected
140
+ * @return array
141
+ * @author Ultimate Module Creator
142
+ */
143
+ public function getSelectedProducts() {
144
+ $products = array();
145
+ $selected = Mage::registry('current_gallery')->getSelectedProducts();
146
+ if (!is_array($selected)){
147
+ $selected = array();
148
+ }
149
+ foreach ($selected as $product) {
150
+ $products[$product->getId()] = array('position' => $product->getPosition());
151
+ }
152
+ return $products;
153
+ }
154
+ /**
155
+ * get row url
156
+ * @access public
157
+ * @param Joomi_MasonryGallery_Model_Product
158
+ * @return string
159
+ * @author Ultimate Module Creator
160
+ */
161
+ public function getRowUrl($item){
162
+ return '#';
163
+ }
164
+ /**
165
+ * get grid url
166
+ * @access public
167
+ * @return string
168
+ * @author Ultimate Module Creator
169
+ */
170
+ public function getGridUrl(){
171
+ return $this->getUrl('*/*/productsGrid', array(
172
+ 'id'=>$this->getGallery()->getId()
173
+ ));
174
+ }
175
+ /**
176
+ * get the current gallery
177
+ * @access public
178
+ * @return Joomi_MasonryGallery_Model_Gallery
179
+ * @author Ultimate Module Creator
180
+ */
181
+ public function getGallery(){
182
+ return Mage::registry('current_gallery');
183
+ }
184
+ /**
185
+ * Add filter
186
+ * @access protected
187
+ * @param object $column
188
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Product
189
+ * @author Ultimate Module Creator
190
+ */
191
+ protected function _addColumnFilterToCollection($column){
192
+ // Set custom filter for in product flag
193
+ if ($column->getId() == 'in_products') {
194
+ $productIds = $this->_getSelectedProducts();
195
+ if (empty($productIds)) {
196
+ $productIds = 0;
197
+ }
198
+ if ($column->getFilter()->getValue()) {
199
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
200
+ }
201
+ else {
202
+ if($productIds) {
203
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
204
+ }
205
+ }
206
+ }
207
+ else {
208
+ parent::_addColumnFilterToCollection($column);
209
+ }
210
+ return $this;
211
+ }
212
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tab/Stores.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * store selection tab
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Stores
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare the form
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tab_Stores
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareForm(){
33
+ $form = new Varien_Data_Form();
34
+ $form->setFieldNameSuffix('gallery');
35
+ $this->setForm($form);
36
+ $fieldset = $form->addFieldset('gallery_stores_form', array('legend'=>Mage::helper('joomi_masonrygallery')->__('Store views')));
37
+ $field = $fieldset->addField('store_id', 'multiselect', array(
38
+ 'name' => 'stores[]',
39
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Store Views'),
40
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Store Views'),
41
+ 'required' => true,
42
+ 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
43
+ ));
44
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
45
+ $field->setRenderer($renderer);
46
+ $form->addValues(Mage::registry('current_gallery')->getData());
47
+ return parent::_prepareForm();
48
+ }
49
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Edit/Tabs.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin edit tabs
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tabs
25
+ extends Mage_Adminhtml_Block_Widget_Tabs {
26
+ /**
27
+ * Initialize Tabs
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct() {
32
+ parent::__construct();
33
+ $this->setId('gallery_tabs');
34
+ $this->setDestElementId('edit_form');
35
+ $this->setTitle(Mage::helper('joomi_masonrygallery')->__('Gallery'));
36
+ }
37
+ /**
38
+ * before render html
39
+ * @access protected
40
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Edit_Tabs
41
+ * @author Ultimate Module Creator
42
+ */
43
+ protected function _beforeToHtml(){
44
+ $this->addTab('form_gallery', array(
45
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Gallery'),
46
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Gallery'),
47
+ 'content' => $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_edit_tab_form')->toHtml(),
48
+ ));
49
+ $this->addTab('form_meta_gallery', array(
50
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Meta'),
51
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Meta'),
52
+ 'content' => $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_edit_tab_meta')->toHtml(),
53
+ ));
54
+ if (!Mage::app()->isSingleStoreMode()){
55
+ $this->addTab('form_store_gallery', array(
56
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Store views'),
57
+ 'title' => Mage::helper('joomi_masonrygallery')->__('Store views'),
58
+ 'content' => $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_edit_tab_stores')->toHtml(),
59
+ ));
60
+ }
61
+ $this->addTab('products', array(
62
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Associated products'),
63
+ 'url' => $this->getUrl('*/*/products', array('_current' => true)),
64
+ 'class' => 'ajax'
65
+ ));
66
+ return parent::_beforeToHtml();
67
+ }
68
+ /**
69
+ * Retrieve gallery entity
70
+ * @access public
71
+ * @return Joomi_MasonryGallery_Model_Gallery
72
+ * @author Ultimate Module Creator
73
+ */
74
+ public function getGallery(){
75
+ return Mage::registry('current_gallery');
76
+ }
77
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Grid.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin grid block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Grid
25
+ extends Mage_Adminhtml_Block_Widget_Grid {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $this->setId('galleryGrid');
34
+ $this->setDefaultSort('entity_id');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setSaveParametersInSession(true);
37
+ $this->setUseAjax(true);
38
+ }
39
+ /**
40
+ * prepare collection
41
+ * @access protected
42
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Grid
43
+ * @author Ultimate Module Creator
44
+ */
45
+ protected function _prepareCollection(){
46
+ $collection = Mage::getModel('joomi_masonrygallery/gallery')->getCollection();
47
+ $this->setCollection($collection);
48
+ return parent::_prepareCollection();
49
+ }
50
+ /**
51
+ * prepare grid collection
52
+ * @access protected
53
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Grid
54
+ * @author Ultimate Module Creator
55
+ */
56
+ protected function _prepareColumns(){
57
+ $this->addColumn('entity_id', array(
58
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Id'),
59
+ 'index' => 'entity_id',
60
+ 'type' => 'number'
61
+ ));
62
+ $this->addColumn('category_id', array(
63
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Category'),
64
+ 'index' => 'category_id',
65
+ 'type' => 'options',
66
+ 'options' => Mage::getResourceModel('joomi_masonrygallery/category_collection')->toOptionHash(),
67
+ 'renderer' => 'joomi_masonrygallery/adminhtml_helper_column_renderer_parent',
68
+ 'params' => array(
69
+ 'id'=>'getCategoryId'
70
+ ),
71
+ 'static' => array(
72
+ 'clear' => 1
73
+ ),
74
+ 'base_link' => 'adminhtml/masonrygallery_category/edit'
75
+ ));
76
+ $this->addColumn('title', array(
77
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Title'),
78
+ 'align' => 'left',
79
+ 'index' => 'title',
80
+ ));
81
+ $this->addColumn('status', array(
82
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Status'),
83
+ 'index' => 'status',
84
+ 'type' => 'options',
85
+ 'options' => array(
86
+ '1' => Mage::helper('joomi_masonrygallery')->__('Enabled'),
87
+ '0' => Mage::helper('joomi_masonrygallery')->__('Disabled'),
88
+ )
89
+ ));
90
+ $this->addColumn('column_width', array(
91
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Column Width'),
92
+ 'index' => 'column_width',
93
+ 'type'=> 'number',
94
+
95
+ ));
96
+ $this->addColumn('thumbnail', array(
97
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Thumbnail'),
98
+ 'index' => 'thumbnail',
99
+ 'type' => 'options',
100
+ 'options' => Mage::helper('joomi_masonrygallery')->convertOptions(Mage::getModel('joomi_masonrygallery/gallery_attribute_source_thumbnail')->getAllOptions(false))
101
+
102
+ ));
103
+ $this->addColumn('big_image', array(
104
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Big Image'),
105
+ 'index' => 'big_image',
106
+ 'type' => 'options',
107
+ 'options' => Mage::helper('joomi_masonrygallery')->convertOptions(Mage::getModel('joomi_masonrygallery/gallery_attribute_source_bigimage')->getAllOptions(false))
108
+
109
+ ));
110
+ $this->addColumn('ordering', array(
111
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Ordering'),
112
+ 'index' => 'ordering',
113
+ 'type'=> 'number',
114
+
115
+ ));
116
+ $this->addColumn('url_key', array(
117
+ 'header' => Mage::helper('joomi_masonrygallery')->__('URL key'),
118
+ 'index' => 'url_key',
119
+ ));
120
+ if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
121
+ $this->addColumn('store_id', array(
122
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Store Views'),
123
+ 'index' => 'store_id',
124
+ 'type' => 'store',
125
+ 'store_all' => true,
126
+ 'store_view'=> true,
127
+ 'sortable' => false,
128
+ 'filter_condition_callback'=> array($this, '_filterStoreCondition'),
129
+ ));
130
+ }
131
+ $this->addColumn('created_at', array(
132
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Created at'),
133
+ 'index' => 'created_at',
134
+ 'width' => '120px',
135
+ 'type' => 'datetime',
136
+ ));
137
+ $this->addColumn('updated_at', array(
138
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Updated at'),
139
+ 'index' => 'updated_at',
140
+ 'width' => '120px',
141
+ 'type' => 'datetime',
142
+ ));
143
+ $this->addColumn('action',
144
+ array(
145
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Action'),
146
+ 'width' => '100',
147
+ 'type' => 'action',
148
+ 'getter'=> 'getId',
149
+ 'actions' => array(
150
+ array(
151
+ 'caption' => Mage::helper('joomi_masonrygallery')->__('Edit'),
152
+ 'url' => array('base'=> '*/*/edit'),
153
+ 'field' => 'id'
154
+ )
155
+ ),
156
+ 'filter'=> false,
157
+ 'is_system' => true,
158
+ 'sortable' => false,
159
+ ));
160
+ $this->addExportType('*/*/exportCsv', Mage::helper('joomi_masonrygallery')->__('CSV'));
161
+ $this->addExportType('*/*/exportExcel', Mage::helper('joomi_masonrygallery')->__('Excel'));
162
+ $this->addExportType('*/*/exportXml', Mage::helper('joomi_masonrygallery')->__('XML'));
163
+ return parent::_prepareColumns();
164
+ }
165
+ /**
166
+ * prepare mass action
167
+ * @access protected
168
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Grid
169
+ * @author Ultimate Module Creator
170
+ */
171
+ protected function _prepareMassaction(){
172
+ $this->setMassactionIdField('entity_id');
173
+ $this->getMassactionBlock()->setFormFieldName('gallery');
174
+ $this->getMassactionBlock()->addItem('delete', array(
175
+ 'label'=> Mage::helper('joomi_masonrygallery')->__('Delete'),
176
+ 'url' => $this->getUrl('*/*/massDelete'),
177
+ 'confirm' => Mage::helper('joomi_masonrygallery')->__('Are you sure?')
178
+ ));
179
+ $this->getMassactionBlock()->addItem('status', array(
180
+ 'label'=> Mage::helper('joomi_masonrygallery')->__('Change status'),
181
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
182
+ 'additional' => array(
183
+ 'status' => array(
184
+ 'name' => 'status',
185
+ 'type' => 'select',
186
+ 'class' => 'required-entry',
187
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Status'),
188
+ 'values' => array(
189
+ '1' => Mage::helper('joomi_masonrygallery')->__('Enabled'),
190
+ '0' => Mage::helper('joomi_masonrygallery')->__('Disabled'),
191
+ )
192
+ )
193
+ )
194
+ ));
195
+ $this->getMassactionBlock()->addItem('thumbnail', array(
196
+ 'label'=> Mage::helper('joomi_masonrygallery')->__('Change Thumbnail'),
197
+ 'url' => $this->getUrl('*/*/massThumbnail', array('_current'=>true)),
198
+ 'additional' => array(
199
+ 'flag_thumbnail' => array(
200
+ 'name' => 'flag_thumbnail',
201
+ 'type' => 'select',
202
+ 'class' => 'required-entry',
203
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Thumbnail'),
204
+ 'values' => Mage::getModel('joomi_masonrygallery/gallery_attribute_source_thumbnail')->getAllOptions(true),
205
+
206
+ )
207
+ )
208
+ ));
209
+ $this->getMassactionBlock()->addItem('big_image', array(
210
+ 'label'=> Mage::helper('joomi_masonrygallery')->__('Change Big Image'),
211
+ 'url' => $this->getUrl('*/*/massBigImage', array('_current'=>true)),
212
+ 'additional' => array(
213
+ 'flag_big_image' => array(
214
+ 'name' => 'flag_big_image',
215
+ 'type' => 'select',
216
+ 'class' => 'required-entry',
217
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Big Image'),
218
+ 'values' => Mage::getModel('joomi_masonrygallery/gallery_attribute_source_bigimage')->getAllOptions(true),
219
+
220
+ )
221
+ )
222
+ ));
223
+ $values = Mage::getResourceModel('joomi_masonrygallery/category_collection')->toOptionHash();
224
+ $values = array_reverse($values, true);
225
+ $values[''] = '';
226
+ $values = array_reverse($values, true);
227
+ $this->getMassactionBlock()->addItem('category_id', array(
228
+ 'label'=> Mage::helper('joomi_masonrygallery')->__('Change Category'),
229
+ 'url' => $this->getUrl('*/*/massCategoryId', array('_current'=>true)),
230
+ 'additional' => array(
231
+ 'flag_category_id' => array(
232
+ 'name' => 'flag_category_id',
233
+ 'type' => 'select',
234
+ 'class' => 'required-entry',
235
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Category'),
236
+ 'values' => $values
237
+ )
238
+ )
239
+ ));
240
+ return $this;
241
+ }
242
+ /**
243
+ * get the row url
244
+ * @access public
245
+ * @param Joomi_MasonryGallery_Model_Gallery
246
+ * @return string
247
+ * @author Ultimate Module Creator
248
+ */
249
+ public function getRowUrl($row){
250
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
251
+ }
252
+ /**
253
+ * get the grid url
254
+ * @access public
255
+ * @return string
256
+ * @author Ultimate Module Creator
257
+ */
258
+ public function getGridUrl(){
259
+ return $this->getUrl('*/*/grid', array('_current'=>true));
260
+ }
261
+ /**
262
+ * after collection load
263
+ * @access protected
264
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Grid
265
+ * @author Ultimate Module Creator
266
+ */
267
+ protected function _afterLoadCollection(){
268
+ $this->getCollection()->walk('afterLoad');
269
+ parent::_afterLoadCollection();
270
+ }
271
+ /**
272
+ * filter store column
273
+ * @access protected
274
+ * @param Joomi_MasonryGallery_Model_Resource_Gallery_Collection $collection
275
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
276
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Grid
277
+ * @author Ultimate Module Creator
278
+ */
279
+ protected function _filterStoreCondition($collection, $column){
280
+ if (!$value = $column->getFilter()->getValue()) {
281
+ return;
282
+ }
283
+ $collection->addStoreFilter($value);
284
+ return $this;
285
+ }
286
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Gallery/Widget/Chooser.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin widget chooser
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+
25
+ class Joomi_MasonryGallery_Block_Adminhtml_Gallery_Widget_Chooser
26
+ extends Mage_Adminhtml_Block_Widget_Grid {
27
+ /**
28
+ * Block construction, prepare grid params
29
+ * @access public
30
+ * @param array $arguments Object data
31
+ * @return void
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function __construct($arguments=array()){
35
+ parent::__construct($arguments);
36
+ $this->setDefaultSort('entity_id');
37
+ $this->setDefaultDir('ASC');
38
+ $this->setUseAjax(true);
39
+ $this->setDefaultFilter(array('chooser_status' => '1'));
40
+ }
41
+ /**
42
+ * Prepare chooser element HTML
43
+ * @access public
44
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
45
+ * @return Varien_Data_Form_Element_Abstract
46
+ * @author Ultimate Module Creator
47
+ */
48
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element){
49
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
50
+ $sourceUrl = $this->getUrl('joomi_masonrygallery/adminhtml_masonrygallery_gallery_widget/chooser', array('uniq_id' => $uniqId));
51
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
52
+ ->setElement($element)
53
+ ->setTranslationHelper($this->getTranslationHelper())
54
+ ->setConfig($this->getConfig())
55
+ ->setFieldsetId($this->getFieldsetId())
56
+ ->setSourceUrl($sourceUrl)
57
+ ->setUniqId($uniqId);
58
+ if ($element->getValue()) {
59
+ $gallery = Mage::getModel('joomi_masonrygallery/gallery')->load($element->getValue());
60
+ if ($gallery->getId()) {
61
+ $chooser->setLabel($gallery->getTitle());
62
+ }
63
+ }
64
+ $element->setData('after_element_html', $chooser->toHtml());
65
+ return $element;
66
+ }
67
+ /**
68
+ * Grid Row JS Callback
69
+ * @access public
70
+ * @return string
71
+ * @author Ultimate Module Creator
72
+ */
73
+ public function getRowClickCallback(){
74
+ $chooserJsObject = $this->getId();
75
+ $js = '
76
+ function (grid, event) {
77
+ var trElement = Event.findElement(event, "tr");
78
+ var galleryId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,"");
79
+ var galleryTitle = trElement.down("td").next().innerHTML;
80
+ '.$chooserJsObject.'.setElementValue(galleryId);
81
+ '.$chooserJsObject.'.setElementLabel(galleryTitle);
82
+ '.$chooserJsObject.'.close();
83
+ }
84
+ ';
85
+ return $js;
86
+ }
87
+ /**
88
+ * Prepare a static blocks collection
89
+ * @access protected
90
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Widget_Chooser
91
+ * @author Ultimate Module Creator
92
+ */
93
+ protected function _prepareCollection(){
94
+ $collection = Mage::getModel('joomi_masonrygallery/gallery')->getCollection();
95
+ $this->setCollection($collection);
96
+ return parent::_prepareCollection();
97
+ }
98
+ /**
99
+ * Prepare columns for the a grid
100
+ * @access protected
101
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Widget_Chooser
102
+ * @author Ultimate Module Creator
103
+ */
104
+ protected function _prepareColumns(){
105
+ $this->addColumn('chooser_id', array(
106
+ 'header' => Mage::helper('joomi_masonrygallery')->__('Id'),
107
+ 'align' => 'right',
108
+ 'index' => 'entity_id',
109
+ 'type' => 'number',
110
+ 'width' => 50
111
+ ));
112
+
113
+ $this->addColumn('chooser_title', array(
114
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Title'),
115
+ 'align' => 'left',
116
+ 'index' => 'title',
117
+ ));
118
+ if (!Mage::app()->isSingleStoreMode()) {
119
+ $this->addColumn('store_id', array(
120
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Store Views'),
121
+ 'index' => 'store_id',
122
+ 'type' => 'store',
123
+ 'store_all' => true,
124
+ 'store_view'=> true,
125
+ 'sortable' => false,
126
+ ));
127
+ }
128
+ $this->addColumn('chooser_status', array(
129
+ 'header'=> Mage::helper('joomi_masonrygallery')->__('Status'),
130
+ 'index' => 'status',
131
+ 'type' => 'options',
132
+ 'options' => array(
133
+ 0 => Mage::helper('joomi_masonrygallery')->__('Disabled'),
134
+ 1 => Mage::helper('joomi_masonrygallery')->__('Enabled')
135
+ ),
136
+ ));
137
+ return parent::_prepareColumns();
138
+ }
139
+ /**
140
+ * get url for grid
141
+ * @access public
142
+ * @return string
143
+ * @author Ultimate Module Creator
144
+ */
145
+ public function getGridUrl(){
146
+ return $this->getUrl('adminhtml/masonrygallery_gallery_widget/chooser', array('_current' => true));
147
+ }
148
+ /**
149
+ * after collection load
150
+ * @access protected
151
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Gallery_Widget_Chooser
152
+ * @author Ultimate Module Creator
153
+ */
154
+ protected function _afterLoadCollection(){
155
+ $this->getCollection()->walk('afterLoad');
156
+ parent::_afterLoadCollection();
157
+ }
158
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Helper/Column/Renderer/Parent.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * parent entities column renderer
19
+ * @category Joomi
20
+ * @package Joomi_MasonryGallery
21
+ * @author Ultimate Module Creator
22
+ */
23
+ class Joomi_MasonryGallery_Block_Adminhtml_Helper_Column_Renderer_Parent
24
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Options {
25
+ /**
26
+ * render the column
27
+ * @access public
28
+ * @param Varien_Object $row
29
+ * @return string
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function render(Varien_Object $row) {
33
+ $base = $this->getColumn()->getBaseLink();
34
+ if (!$base) {
35
+ return parent::render($row);
36
+ }
37
+ $paramsData = $this->getColumn()->getData('params');
38
+ $params = array();
39
+ if (is_array($paramsData)) {
40
+ foreach ($paramsData as $name=>$getter) {
41
+ if (is_callable(array($row, $getter))) {
42
+ $params[$name] = call_user_func(array($row, $getter));
43
+ }
44
+ }
45
+ }
46
+ $staticParamsData = $this->getColumn()->getData('static');
47
+ if (is_array($staticParamsData)) {
48
+ foreach ($staticParamsData as $key=>$value) {
49
+ $params[$key] = $value;
50
+ }
51
+ }
52
+ $options = $this->getColumn()->getOptions();
53
+ $showMissingOptionValues = (bool)$this->getColumn()->getShowMissingOptionValues();
54
+ if (!empty($options) && is_array($options)) {
55
+ $value = $row->getData($this->getColumn()->getIndex());
56
+ if (is_array($value)) {
57
+ $res = array();
58
+ foreach ($value as $item) {
59
+ if (isset($options[$item])) {
60
+ $res[] = '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->escapeHtml($options[$item]).'</a>';
61
+ }
62
+ elseif ($showMissingOptionValues) {
63
+ $res[] = '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->escapeHtml($item).'</a>';
64
+ }
65
+ }
66
+ return implode('<br />', $res);
67
+ } elseif (isset($options[$value])) {
68
+ return '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->escapeHtml($options[$value]).'</a>';
69
+ } elseif (in_array($value, $options)) {
70
+ return '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->escapeHtml($value).'</a>';
71
+ }
72
+ }
73
+ }
74
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Helper/Column/Renderer/Relation.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * related entities column renderer
19
+ * @category Joomi
20
+ * @package Joomi_MasonryGallery
21
+ * @author Ultimate Module Creator
22
+ */
23
+ class Joomi_MasonryGallery_Block_Adminhtml_Helper_Column_Renderer_Relation
24
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text {
25
+ /**
26
+ * render the column
27
+ * @access public
28
+ * @param Varien_Object $row
29
+ * @return string
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function render(Varien_Object $row) {
33
+ $base = $this->getColumn()->getBaseLink();
34
+ if (!$base) {
35
+ return parent::render($row);
36
+ }
37
+ $paramsData = $this->getColumn()->getData('params');
38
+ $params = array();
39
+ if (is_array($paramsData)) {
40
+ foreach ($paramsData as $name=>$getter) {
41
+ if (is_callable(array($row, $getter))) {
42
+ $params[$name] = call_user_func(array($row, $getter));
43
+ }
44
+ }
45
+ }
46
+ $staticParamsData = $this->getColumn()->getData('static');
47
+ if (is_array($staticParamsData)) {
48
+ foreach ($staticParamsData as $key=>$value) {
49
+ $params[$key] = $value;
50
+ }
51
+ }
52
+ return '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->_getValue($row).'</a>';
53
+ }
54
+ }
app/code/community/Joomi/MasonryGallery/Block/Adminhtml/Helper/Wysiwyg.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MasonryGallery textarea attribute WYSIWYG button
19
+ * @category Joomi
20
+ * @package Joomi_MasonryGallery
21
+ * @author Ultimate Module Creator
22
+ */
23
+ class Joomi_MasonryGallery_Block_Adminhtml_Helper_Wysiwyg
24
+ extends Varien_Data_Form_Element_Textarea {
25
+ /**
26
+ * Retrieve additional html and put it at the end of element html
27
+ * @access public
28
+ * @return string
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function getAfterElementHtml(){
32
+ $html = parent::getAfterElementHtml();
33
+ $disabled = ($this->getDisabled() || $this->getReadonly());
34
+ $html .= Mage::getSingleton('core/layout')
35
+ ->createBlock('adminhtml/widget_button', '', array(
36
+ 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'),
37
+ 'type'=> 'button',
38
+ 'disabled' => $disabled,
39
+ 'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg',
40
+ 'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')'
41
+ ))->toHtml();
42
+ return $html;
43
+ }
44
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/Children.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category children list block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_Children
25
+ extends Joomi_MasonryGallery_Block_Category_List {
26
+ /**
27
+ * prepare the layout
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Block_Category_Children
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _prepareLayout(){
33
+ $this->getCategories()->addFieldToFilter('parent_id', $this->getCurrentCategory()->getId());
34
+ return $this;
35
+ }
36
+ /**
37
+ * ge the current category
38
+ * @access protected
39
+ * @return Joomi_MasonryGallery_Model_Category
40
+ * @author Ultimate Module Creator
41
+ */
42
+ public function getCurrentCategory(){
43
+ return Mage::registry('current_category');
44
+ }
45
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/Gallery/List.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category Galleries list block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_Gallery_List
25
+ extends Joomi_MasonryGallery_Block_Gallery_List {
26
+ /**
27
+ * initialize
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $category = $this->getCategory();
34
+ if ($category){
35
+ $this->getGalleries()->addFieldToFilter('category_id', $category->getId());
36
+ }
37
+ }
38
+ /**
39
+ * prepare the layout - actually do nothing
40
+ * @access protected
41
+ * @return Joomi_MasonryGallery_Block_Category_Gallery_List
42
+ * @author Ultimate Module Creator
43
+ */
44
+ protected function _prepareLayout(){
45
+ return $this;
46
+ }
47
+ /**
48
+ * get the current category
49
+ * @access public
50
+ * @return Joomi_MasonryGallery_Model_Category
51
+ * @author Ultimate Module Creator
52
+ */
53
+ public function getCategory(){
54
+ return Mage::registry('current_category');
55
+ }
56
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/List.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category list block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_List
25
+ extends Mage_Core_Block_Template {
26
+ /**
27
+ * initialize
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $categories = Mage::getResourceModel('joomi_masonrygallery/category_collection')
34
+ ->addStoreFilter(Mage::app()->getStore())
35
+ ->addFieldToFilter('status', 1);
36
+ ;
37
+ $categories->getSelect()->order('main_table.position');
38
+ $this->setCategories($categories);
39
+ }
40
+ /**
41
+ * prepare the layout
42
+ * @access protected
43
+ * @return Joomi_MasonryGallery_Block_Category_List
44
+ * @author Ultimate Module Creator
45
+ */
46
+ protected function _prepareLayout(){
47
+ parent::_prepareLayout();
48
+ $this->getCategories()->addFieldToFilter('level', 1);
49
+ if ($this->_getDisplayMode() == 0){
50
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'joomi_masonrygallery.categories.html.pager')
51
+ ->setCollection($this->getCategories());
52
+ $this->setChild('pager', $pager);
53
+ $this->getCategories()->load();
54
+ }
55
+ return $this;
56
+ }
57
+ /**
58
+ * get the pager html
59
+ * @access public
60
+ * @return string
61
+ * @author Ultimate Module Creator
62
+ */
63
+ public function getPagerHtml(){
64
+ return $this->getChildHtml('pager');
65
+ }
66
+ /**
67
+ * get the display mode
68
+ * @access protected
69
+ * @return int
70
+ * @author Ultimate Module Creator
71
+ */
72
+ protected function _getDisplayMode(){
73
+ return Mage::getStoreConfigFlag('joomi_masonrygallery/category/tree');
74
+ }
75
+ /**
76
+ * draw category
77
+ * @access public
78
+ * @param Joomi_MasonryGallery_Model_Category
79
+ * @param int $level
80
+ * @return int
81
+ * @author Ultimate Module Creator
82
+ */
83
+ public function drawCategory($category, $level = 0){
84
+ $html = '';
85
+ $recursion = $this->getRecursion();
86
+ if ($recursion !== '0' && $level >= $recursion){
87
+ return '';
88
+ }
89
+ $storeIds = Mage::getResourceSingleton('joomi_masonrygallery/category')->lookupStoreIds($category->getId());
90
+ $validStoreIds = array(0, Mage::app()->getStore()->getId());
91
+ if (!array_intersect($storeIds, $validStoreIds)){
92
+ return '';
93
+ }
94
+ if (!$category->getStatus()){
95
+ return '';
96
+ }
97
+ $children = $category->getChildrenCategories();
98
+ $activeChildren = array();
99
+ if ($recursion == 0 || $level < $recursion-1){
100
+ foreach ($children as $child) {
101
+ $childStoreIds = Mage::getResourceSingleton('joomi_masonrygallery/category')->lookupStoreIds($child->getId());
102
+ $validStoreIds = array(0, Mage::app()->getStore()->getId());
103
+ if (!array_intersect($childStoreIds, $validStoreIds)){
104
+ continue;
105
+ }
106
+ if ($child->getStatus()) {
107
+ $activeChildren[] = $child;
108
+ }
109
+ }
110
+ }
111
+ $html .= '<li>';
112
+ $html .= '<a href="'.$category->getCategoryUrl().'">'.$category->getTitle().'</a>';
113
+ if (count($activeChildren) > 0) {
114
+ $html .= '<ul>';
115
+ foreach ($children as $child){
116
+ $html .= $this->drawCategory($child, $level+1);
117
+ }
118
+ $html .= '</ul>';
119
+ }
120
+ $html .= '</li>';
121
+ return $html;
122
+ }
123
+ /**
124
+ * get recursion
125
+ * @access public
126
+ * @return int
127
+ * @author Ultimate Module Creator
128
+ */
129
+ public function getRecursion(){
130
+ if (!$this->hasData('recursion')){
131
+ $this->setData('recursion', Mage::getStoreConfig('joomi_masonrygallery/category/recursion'));
132
+ }
133
+ return $this->getData('recursion');
134
+ }
135
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/View.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category view block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_View
25
+ extends Mage_Core_Block_Template {
26
+ /**
27
+ * get the current category
28
+ * @access public
29
+ * @return mixed (Joomi_MasonryGallery_Model_Category|null)
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getCurrentCategory(){
33
+ return Mage::registry('current_category');
34
+ }
35
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/Widget/Link.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category link widget block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_Widget_Link
25
+ extends Joomi_MasonryGallery_Block_Category_Widget_View {
26
+ protected $_htmlTemplate = 'joomi_masonrygallery/category/widget/link.phtml';
27
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/Widget/Subtree.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category subtree block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_Widget_Subtree
25
+ extends Joomi_MasonryGallery_Block_Category_List
26
+ implements Mage_Widget_Block_Interface {
27
+ protected $_template = 'joomi_masonrygallery/category/widget/subtree.phtml';
28
+ /**
29
+ * prepare the layout
30
+ * @access protected
31
+ * @return Joomi_MasonryGallery_Block_Category_Widget_Subtree
32
+ * @author Ultimate Module Creator
33
+ */
34
+ protected function _prepareLayout(){
35
+ $this->getCategories()->addFieldToFilter('entity_id', $this->getCategoryId());
36
+ return $this;
37
+ }
38
+ /**
39
+ * get the display mode
40
+ * @access protected
41
+ * @return int
42
+ * @author Ultimate Module Creator
43
+ */
44
+ protected function _getDisplayMode(){
45
+ return 1;
46
+ }
47
+ /**
48
+ * get the element id
49
+ * @access protected
50
+ * @return int
51
+ * @author Ultimate Module Creator
52
+ */
53
+ public function getUniqueId(){
54
+ if (!$this->getData('uniq_id')){
55
+ $this->setData('uniq_id', uniqid('subtree'));
56
+ }
57
+ return $this->getData('uniq_id');
58
+ }
59
+ }
app/code/community/Joomi/MasonryGallery/Block/Category/Widget/View.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category widget block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Category_Widget_View
25
+ extends Mage_Core_Block_Template
26
+ implements Mage_Widget_Block_Interface {
27
+ protected $_htmlTemplate = 'joomi_masonrygallery/category/widget/view.phtml';
28
+ /**
29
+ * Prepare a for widget
30
+ * @access protected
31
+ * @return Joomi_MasonryGallery_Block_Category_Widget_View
32
+ * @author Ultimate Module Creator
33
+ */
34
+ protected function _beforeToHtml() {
35
+ parent::_beforeToHtml();
36
+ $categoryId = $this->getData('category_id');
37
+ if ($categoryId) {
38
+ $category = Mage::getModel('joomi_masonrygallery/category')
39
+ ->setStoreId(Mage::app()->getStore()->getId())
40
+ ->load($categoryId);
41
+ if ($category->getStatusPath()) {
42
+ $this->setCurrentCategory($category);
43
+ $this->setTemplate($this->_htmlTemplate);
44
+ }
45
+ }
46
+ return $this;
47
+ }
48
+ }
app/code/community/Joomi/MasonryGallery/Block/Gallery/Catalog/Product/List.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery product list
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Gallery_Catalog_Product_List extends Mage_Core_Block_Template {
25
+ /**
26
+ * get the list of products
27
+ * @access public
28
+ * @return Mage_Catalog_Model_Resource_Product_Collection
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function getProductCollection() {
32
+ $collection = $this->getGallery()->getSelectedProductsCollection();
33
+ $collection->addAttributeToSelect('name');
34
+ $collection->addUrlRewrite();
35
+ $collection->getSelect()->order('related.position');
36
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
37
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
38
+ return $collection;
39
+ }
40
+ /**
41
+ * get current gallery
42
+ * @access public
43
+ * @return Joomi_MasonryGallery_Model_Gallery
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function getGallery() {
47
+ return Mage::registry('current_gallery');
48
+ }
49
+ }
app/code/community/Joomi/MasonryGallery/Block/Gallery/List.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery list block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Gallery_List
25
+ extends Mage_Core_Block_Template {
26
+ /**
27
+ * initialize
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function __construct(){
32
+ parent::__construct();
33
+ $galleries = Mage::getResourceModel('joomi_masonrygallery/gallery_collection')
34
+ ->addStoreFilter(Mage::app()->getStore())
35
+ ->addFieldToFilter('status', 1);
36
+ $galleries->setOrder('ordering', 'asc');
37
+ $this->setGalleries($galleries);
38
+ }
39
+ /**
40
+ * prepare the layout
41
+ * @access protected
42
+ * @return Joomi_MasonryGallery_Block_Gallery_List
43
+ * @author Ultimate Module Creator
44
+ */
45
+ protected function _prepareLayout(){
46
+ parent::_prepareLayout();
47
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'joomi_masonrygallery.gallery.html.pager')
48
+ ->setCollection($this->getGalleries());
49
+ $this->setChild('pager', $pager);
50
+ $this->getGalleries()->load();
51
+ return $this;
52
+ }
53
+ /**
54
+ * get the pager html
55
+ * @access public
56
+ * @return string
57
+ * @author Ultimate Module Creator
58
+ */
59
+ public function getPagerHtml(){
60
+ return $this->getChildHtml('pager');
61
+ }
62
+ }
app/code/community/Joomi/MasonryGallery/Block/Gallery/View.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery view block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Gallery_View
25
+ extends Mage_Core_Block_Template {
26
+ /**
27
+ * get the current gallery
28
+ * @access public
29
+ * @return mixed (Joomi_MasonryGallery_Model_Gallery|null)
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getCurrentGallery(){
33
+ return Mage::registry('current_gallery');
34
+ }
35
+ }
app/code/community/Joomi/MasonryGallery/Block/Gallery/Widget/Link.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery link widget block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Gallery_Widget_Link
25
+ extends Joomi_MasonryGallery_Block_Gallery_Widget_View {
26
+ protected $_htmlTemplate = 'joomi_masonrygallery/gallery/widget/link.phtml';
27
+ }
app/code/community/Joomi/MasonryGallery/Block/Gallery/Widget/View.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery widget block
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Block_Gallery_Widget_View
25
+ extends Mage_Core_Block_Template
26
+ implements Mage_Widget_Block_Interface {
27
+ protected $_htmlTemplate = 'joomi_masonrygallery/gallery/widget/view.phtml';
28
+ /**
29
+ * Prepare a for widget
30
+ * @access protected
31
+ * @return Joomi_MasonryGallery_Block_Gallery_Widget_View
32
+ * @author Ultimate Module Creator
33
+ */
34
+ protected function _beforeToHtml() {
35
+ parent::_beforeToHtml();
36
+ $galleryId = $this->getData('gallery_id');
37
+ if ($galleryId) {
38
+ $gallery = Mage::getModel('joomi_masonrygallery/gallery')
39
+ ->setStoreId(Mage::app()->getStore()->getId())
40
+ ->load($galleryId);
41
+ if ($gallery->getStatus()) {
42
+ $this->setCurrentGallery($gallery);
43
+ $this->setTemplate($this->_htmlTemplate);
44
+ }
45
+ }
46
+ return $this;
47
+ }
48
+ }
app/code/community/Joomi/MasonryGallery/Controller/Adminhtml/MasonryGallery.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * module base admin controller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Controller_Adminhtml_MasonryGallery
25
+ extends Mage_Adminhtml_Controller_Action {
26
+ /**
27
+ * upload file and get the uploaded name
28
+ * @access public
29
+ * @param string $input
30
+ * @param string $destinationFolder
31
+ * @param array $data
32
+ * @return string
33
+ * @author Ultimate Module Creator
34
+ */
35
+ protected function _uploadAndGetName($input, $destinationFolder, $data) {
36
+ try{
37
+ if (isset($data[$input]['delete'])){
38
+ return '';
39
+ }
40
+ else{
41
+ $uploader = new Varien_File_Uploader($input);
42
+ $uploader->setAllowRenameFiles(true);
43
+ $uploader->setFilesDispersion(true);
44
+ $uploader->setAllowCreateFolders(true);
45
+ $result = $uploader->save($destinationFolder);
46
+ return $result['file'];
47
+ }
48
+ }
49
+ catch (Exception $e) {
50
+ if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
51
+ throw $e;
52
+ }
53
+ else{
54
+ if (isset($data[$input]['value'])){
55
+ return $data[$input]['value'];
56
+ }
57
+ }
58
+ }
59
+ return '';
60
+ }
61
+ }
app/code/community/Joomi/MasonryGallery/Controller/Router.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Router
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Controller_Router
25
+ extends Mage_Core_Controller_Varien_Router_Abstract {
26
+ /**
27
+ * init routes
28
+ * @access public
29
+ * @param Varien_Event_Observer $observer
30
+ * @return Joomi_MasonryGallery_Controller_Router
31
+ * @author Ultimate Module Creator
32
+ */
33
+ public function initControllerRouters($observer){
34
+ $front = $observer->getEvent()->getFront();
35
+ $front->addRouter('joomi_masonrygallery', $this);
36
+ return $this;
37
+ }
38
+ /**
39
+ * Validate and match entities and modify request
40
+ * @access public
41
+ * @param Zend_Controller_Request_Http $request
42
+ * @return bool
43
+ * @author Ultimate Module Creator
44
+ */
45
+ public function match(Zend_Controller_Request_Http $request){
46
+ if (!Mage::isInstalled()) {
47
+ Mage::app()->getFrontController()->getResponse()
48
+ ->setRedirect(Mage::getUrl('install'))
49
+ ->sendResponse();
50
+ exit;
51
+ }
52
+ $urlKey = trim($request->getPathInfo(), '/');
53
+ $check = array();
54
+ $check['category'] = new Varien_Object(array(
55
+ 'prefix' => Mage::getStoreConfig('joomi_masonrygallery/category/url_prefix'),
56
+ 'suffix' => Mage::getStoreConfig('joomi_masonrygallery/category/url_suffix'),
57
+ 'list_key' => Mage::getStoreConfig('joomi_masonrygallery/category/url_rewrite_list'),
58
+ 'list_action' => 'index',
59
+ 'model' =>'joomi_masonrygallery/category',
60
+ 'controller' => 'category',
61
+ 'action' => 'view',
62
+ 'param' => 'id',
63
+ 'check_path' => 1
64
+ ));
65
+ $check['gallery'] = new Varien_Object(array(
66
+ 'prefix' => Mage::getStoreConfig('joomi_masonrygallery/gallery/url_prefix'),
67
+ 'suffix' => Mage::getStoreConfig('joomi_masonrygallery/gallery/url_suffix'),
68
+ 'list_key' => Mage::getStoreConfig('joomi_masonrygallery/gallery/url_rewrite_list'),
69
+ 'list_action' => 'index',
70
+ 'model' =>'joomi_masonrygallery/gallery',
71
+ 'controller' => 'gallery',
72
+ 'action' => 'view',
73
+ 'param' => 'id',
74
+ 'check_path' => 0
75
+ ));
76
+ foreach ($check as $key=>$settings) {
77
+ if ($settings->getListKey()) {
78
+ if ($urlKey == $settings->getListKey()) {
79
+ $request->setModuleName('masonry')
80
+ ->setControllerName($settings->getController())
81
+ ->setActionName($settings->getListAction());
82
+ $request->setAlias(
83
+ Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
84
+ $urlKey
85
+ );
86
+ return true;
87
+ }
88
+ }
89
+ if ($settings['prefix']){
90
+ $parts = explode('/', $urlKey);
91
+ if ($parts[0] != $settings['prefix'] || count($parts) != 2){
92
+ continue;
93
+ }
94
+ $urlKey = $parts[1];
95
+ }
96
+ if ($settings['suffix']){
97
+ $urlKey = substr($urlKey, 0 , -strlen($settings['suffix']) - 1);
98
+ }
99
+ $model = Mage::getModel($settings->getModel());
100
+ $id = $model->checkUrlKey($urlKey, Mage::app()->getStore()->getId());
101
+ if ($id){
102
+ if ($settings->getCheckPath() && !$model->load($id)->getStatusPath()) {
103
+ continue;
104
+ }
105
+ $request->setModuleName('masonry')
106
+ ->setControllerName($settings->getController())
107
+ ->setActionName($settings->getAction())
108
+ ->setParam($settings->getParam(), $id);
109
+ $request->setAlias(
110
+ Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
111
+ $urlKey
112
+ );
113
+ return true;
114
+ }
115
+ }
116
+ return false;
117
+ }
118
+ }
app/code/community/Joomi/MasonryGallery/Helper/Category.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category helper
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Helper_Category
25
+ extends Mage_Core_Helper_Abstract {
26
+ /**
27
+ * get the url to the categories list page
28
+ * @access public
29
+ * @return string
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getCategoriesUrl(){
33
+ if ($listKey = Mage::getStoreConfig('joomi_masonrygallery/category/url_rewrite_list')) {
34
+ return Mage::getUrl('', array('_direct'=>$listKey));
35
+ }
36
+ return Mage::getUrl('joomi_masonrygallery/category/index');
37
+ }
38
+ /**
39
+ * check if breadcrumbs can be used
40
+ * @access public
41
+ * @return bool
42
+ * @author Ultimate Module Creator
43
+ */
44
+ public function getUseBreadcrumbs(){
45
+ return Mage::getStoreConfigFlag('joomi_masonrygallery/category/breadcrumbs');
46
+ }
47
+ const CATEGORY_ROOT_ID = 1;
48
+ /**
49
+ * get the root id
50
+ * @access public
51
+ * @return int
52
+ * @author Ultimate Module Creator
53
+ */
54
+ public function getRootCategoryId(){
55
+ return self::CATEGORY_ROOT_ID;
56
+ }
57
+ }
app/code/community/Joomi/MasonryGallery/Helper/Data.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MasonryGallery default helper
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Helper_Data
25
+ extends Mage_Core_Helper_Abstract {
26
+ /**
27
+ * convert array to options
28
+ * @access public
29
+ * @param $options
30
+ * @return array
31
+ * @author Ultimate Module Creator
32
+ */
33
+ public function convertOptions($options){
34
+ $converted = array();
35
+ foreach ($options as $option){
36
+ if (isset($option['value']) && !is_array($option['value']) && isset($option['label']) && !is_array($option['label'])){
37
+ $converted[$option['value']] = $option['label'];
38
+ }
39
+ }
40
+ return $converted;
41
+ }
42
+ }
app/code/community/Joomi/MasonryGallery/Helper/Gallery.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery helper
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Helper_Gallery
25
+ extends Mage_Core_Helper_Abstract {
26
+ /**
27
+ * get the url to the galleries list page
28
+ * @access public
29
+ * @return string
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getGalleriesUrl(){
33
+ if ($listKey = Mage::getStoreConfig('joomi_masonrygallery/gallery/url_rewrite_list')) {
34
+ return Mage::getUrl('', array('_direct'=>$listKey));
35
+ }
36
+ return Mage::getUrl('joomi_masonrygallery/gallery/index');
37
+ }
38
+ /**
39
+ * check if breadcrumbs can be used
40
+ * @access public
41
+ * @return bool
42
+ * @author Ultimate Module Creator
43
+ */
44
+ public function getUseBreadcrumbs(){
45
+ return Mage::getStoreConfigFlag('joomi_masonrygallery/gallery/breadcrumbs');
46
+ }
47
+ }
app/code/community/Joomi/MasonryGallery/Helper/Product.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Product helper
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Helper_Product
25
+ extends Joomi_MasonryGallery_Helper_Data {
26
+ /**
27
+ * get the selected galleries for a product
28
+ * @access public
29
+ * @param Mage_Catalog_Model_Product $product
30
+ * @return array()
31
+ * @author Ultimate Module Creator
32
+ */
33
+ public function getSelectedGalleries(Mage_Catalog_Model_Product $product){
34
+ if (!$product->hasSelectedGalleries()) {
35
+ $galleries = array();
36
+ foreach ($this->getSelectedGalleriesCollection($product) as $gallery) {
37
+ $galleries[] = $gallery;
38
+ }
39
+ $product->setSelectedGalleries($galleries);
40
+ }
41
+ return $product->getData('selected_galleries');
42
+ }
43
+ /**
44
+ * get gallery collection for a product
45
+ * @access public
46
+ * @param Mage_Catalog_Model_Product $product
47
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Collection
48
+ * @author Ultimate Module Creator
49
+ */
50
+ public function getSelectedGalleriesCollection(Mage_Catalog_Model_Product $product){
51
+ $collection = Mage::getResourceSingleton('joomi_masonrygallery/gallery_collection')
52
+ ->addProductFilter($product);
53
+ return $collection;
54
+ }
55
+ }
app/code/community/Joomi/MasonryGallery/Model/Adminhtml/Observer.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Adminhtml observer
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Adminhtml_Observer {
25
+ /**
26
+ * check if tab can be added
27
+ * @access protected
28
+ * @param Mage_Catalog_Model_Product $product
29
+ * @return bool
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _canAddTab($product){
33
+ if ($product->getId()){
34
+ return true;
35
+ }
36
+ if (!$product->getAttributeSetId()){
37
+ return false;
38
+ }
39
+ $request = Mage::app()->getRequest();
40
+ if ($request->getParam('type') == 'configurable'){
41
+ if ($request->getParam('attributes')){
42
+ return true;
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+ /**
48
+ * add the gallery tab to products
49
+ * @access public
50
+ * @param Varien_Event_Observer $observer
51
+ * @return Joomi_MasonryGallery_Model_Adminhtml_Observer
52
+ * @author Ultimate Module Creator
53
+ */
54
+ public function addProductGalleryBlock($observer){
55
+ $block = $observer->getEvent()->getBlock();
56
+ $product = Mage::registry('product');
57
+ if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)){
58
+ $block->addTab('galleries', array(
59
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Galleries'),
60
+ 'url' => Mage::helper('adminhtml')->getUrl('adminhtml/masonrygallery_gallery_catalog_product/galleries', array('_current' => true)),
61
+ 'class' => 'ajax',
62
+ ));
63
+ }
64
+ return $this;
65
+ }
66
+ /**
67
+ * save gallery - product relation
68
+ * @access public
69
+ * @param Varien_Event_Observer $observer
70
+ * @return Joomi_MasonryGallery_Model_Adminhtml_Observer
71
+ * @author Ultimate Module Creator
72
+ */
73
+ public function saveProductGalleryData($observer){
74
+ $post = Mage::app()->getRequest()->getPost('galleries', -1);
75
+ if ($post != '-1') {
76
+ $post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post);
77
+ $product = Mage::registry('product');
78
+ $galleryProduct = Mage::getResourceSingleton('joomi_masonrygallery/gallery_product')->saveProductRelation($product, $post);
79
+ }
80
+ return $this;
81
+ }}
app/code/community/Joomi/MasonryGallery/Model/Adminhtml/Search/Gallery.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Admin search model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Adminhtml_Search_Gallery
25
+ extends Varien_Object {
26
+ /**
27
+ * Load search results
28
+ * @access public
29
+ * @return Joomi_MasonryGallery_Model_Adminhtml_Search_Gallery
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function load(){
33
+ $arr = array();
34
+ if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
35
+ $this->setResults($arr);
36
+ return $this;
37
+ }
38
+ $collection = Mage::getResourceModel('joomi_masonrygallery/gallery_collection')
39
+ ->addFieldToFilter('title', array('like' => $this->getQuery().'%'))
40
+ ->setCurPage($this->getStart())
41
+ ->setPageSize($this->getLimit())
42
+ ->load();
43
+ foreach ($collection->getItems() as $gallery) {
44
+ $arr[] = array(
45
+ 'id'=> 'gallery/1/'.$gallery->getId(),
46
+ 'type' => Mage::helper('joomi_masonrygallery')->__('Gallery'),
47
+ 'name' => $gallery->getTitle(),
48
+ 'description' => $gallery->getTitle(),
49
+ 'url' => Mage::helper('adminhtml')->getUrl('*/masonrygallery_gallery/edit', array('id'=>$gallery->getId())),
50
+ );
51
+ }
52
+ $this->setResults($arr);
53
+ return $this;
54
+ }
55
+ }
app/code/community/Joomi/MasonryGallery/Model/Category.php ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Category
25
+ extends Mage_Core_Model_Abstract {
26
+ /**
27
+ * Entity code.
28
+ * Can be used as part of method name for entity processing
29
+ */
30
+ const ENTITY = 'joomi_masonrygallery_category';
31
+ const CACHE_TAG = 'joomi_masonrygallery_category';
32
+ /**
33
+ * Prefix of model events names
34
+ * @var string
35
+ */
36
+ protected $_eventPrefix = 'joomi_masonrygallery_category';
37
+
38
+ /**
39
+ * Parameter name in event
40
+ * @var string
41
+ */
42
+ protected $_eventObject = 'category';
43
+ /**
44
+ * constructor
45
+ * @access public
46
+ * @return void
47
+ * @author Ultimate Module Creator
48
+ */
49
+ public function _construct(){
50
+ parent::_construct();
51
+ $this->_init('joomi_masonrygallery/category');
52
+ }
53
+ /**
54
+ * before save category
55
+ * @access protected
56
+ * @return Joomi_MasonryGallery_Model_Category
57
+ * @author Ultimate Module Creator
58
+ */
59
+ protected function _beforeSave(){
60
+ parent::_beforeSave();
61
+ $now = Mage::getSingleton('core/date')->gmtDate();
62
+ if ($this->isObjectNew()){
63
+ $this->setCreatedAt($now);
64
+ }
65
+ $this->setUpdatedAt($now);
66
+ return $this;
67
+ }
68
+ /**
69
+ * get the url to the category details page
70
+ * @access public
71
+ * @return string
72
+ * @author Ultimate Module Creator
73
+ */
74
+ public function getCategoryUrl(){
75
+ if ($this->getUrlKey()){
76
+ $urlKey = '';
77
+ if ($prefix = Mage::getStoreConfig('joomi_masonrygallery/category/url_prefix')){
78
+ $urlKey .= $prefix.'/';
79
+ }
80
+ $urlKey .= $this->getUrlKey();
81
+ if ($suffix = Mage::getStoreConfig('joomi_masonrygallery/category/url_suffix')){
82
+ $urlKey .= '.'.$suffix;
83
+ }
84
+ return Mage::getUrl('', array('_direct'=>$urlKey));
85
+ }
86
+ return Mage::getUrl('joomi_masonrygallery/category/view', array('id'=>$this->getId()));
87
+ }
88
+ /**
89
+ * check URL key
90
+ * @access public
91
+ * @param string $urlKey
92
+ * @param bool $active
93
+ * @return mixed
94
+ * @author Ultimate Module Creator
95
+ */
96
+ public function checkUrlKey($urlKey, $active = true){
97
+ return $this->_getResource()->checkUrlKey($urlKey, $active);
98
+ }
99
+
100
+ /**
101
+ * get the category Description
102
+ * @access public
103
+ * @return string
104
+ * @author Ultimate Module Creator
105
+ */
106
+ public function getDescription(){
107
+ $description = $this->getData('description');
108
+ $helper = Mage::helper('cms');
109
+ $processor = $helper->getBlockTemplateProcessor();
110
+ $html = $processor->filter($description);
111
+ return $html;
112
+ }
113
+ /**
114
+ * save category relation
115
+ * @access public
116
+ * @return Joomi_MasonryGallery_Model_Category
117
+ * @author Ultimate Module Creator
118
+ */
119
+ protected function _afterSave() {
120
+ return parent::_afterSave();
121
+ }
122
+ /**
123
+ * Retrieve collection
124
+ * @access public
125
+ * @return Joomi_MasonryGallery_Model_Gallery_Collection
126
+ * @author Ultimate Module Creator
127
+ */
128
+ public function getSelectedGalleriesCollection(){
129
+ if (!$this->hasData('_gallery_collection')) {
130
+ if (!$this->getId()) {
131
+ return new Varien_Data_Collection();
132
+ }
133
+ else {
134
+ $collection = Mage::getResourceModel('joomi_masonrygallery/gallery_collection')
135
+ ->addFieldToFilter('category_id', $this->getId());
136
+ $this->setData('_gallery_collection', $collection);
137
+ }
138
+ }
139
+ return $this->getData('_gallery_collection');
140
+ }
141
+ /**
142
+ * get the tree model
143
+ * @access public
144
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
145
+ * @author Ultimate Module Creator
146
+ */
147
+ public function getTreeModel(){
148
+ return Mage::getResourceModel('joomi_masonrygallery/category_tree');
149
+ }
150
+ /**
151
+ * get tree model instance
152
+ * @access public
153
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
154
+ * @author Ultimate Module Creator
155
+ */
156
+ public function getTreeModelInstance(){
157
+ if (is_null($this->_treeModel)) {
158
+ $this->_treeModel = Mage::getResourceSingleton('joomi_masonrygallery/category_tree');
159
+ }
160
+ return $this->_treeModel;
161
+ }
162
+ /**
163
+ * Move category
164
+ * @access public
165
+ * @param int $parentId new parent category id
166
+ * @param int $afterCategoryId category id after which we have put current category
167
+ * @return Joomi_MasonryGallery_Model_Category
168
+ * @author Ultimate Module Creator
169
+ */
170
+ public function move($parentId, $afterCategoryId){
171
+ $parent = Mage::getModel('joomi_masonrygallery/category')->load($parentId);
172
+ if (!$parent->getId()) {
173
+ Mage::throwException(
174
+ Mage::helper('joomi_masonrygallery')->__('Category move operation is not possible: the new parent category was not found.')
175
+ );
176
+ }
177
+ if (!$this->getId()) {
178
+ Mage::throwException(
179
+ Mage::helper('joomi_masonrygallery')->__('Category move operation is not possible: the current category was not found.')
180
+ );
181
+ }
182
+ elseif ($parent->getId() == $this->getId()) {
183
+ Mage::throwException(
184
+ Mage::helper('joomi_masonrygallery')->__('Category move operation is not possible: parent category is equal to child category.')
185
+ );
186
+ }
187
+ $this->setMovedCategoryId($this->getId());
188
+ $eventParams = array(
189
+ $this->_eventObject => $this,
190
+ 'parent' => $parent,
191
+ 'category_id' => $this->getId(),
192
+ 'prev_parent_id' => $this->getParentId(),
193
+ 'parent_id' => $parentId
194
+ );
195
+ $moveComplete = false;
196
+ $this->_getResource()->beginTransaction();
197
+ try {
198
+ $this->getResource()->changeParent($this, $parent, $afterCategoryId);
199
+ $this->_getResource()->commit();
200
+ $this->setAffectedCategoryIds(array($this->getId(), $this->getParentId(), $parentId));
201
+ $moveComplete = true;
202
+ }
203
+ catch (Exception $e) {
204
+ $this->_getResource()->rollBack();
205
+ throw $e;
206
+ }
207
+ if ($moveComplete) {
208
+ Mage::app()->cleanCache(array(self::CACHE_TAG));
209
+ }
210
+ return $this;
211
+ }
212
+ /**
213
+ * Get the parent category
214
+ * @access public
215
+ * @return Joomi_MasonryGallery_Model_Category
216
+ * @author Ultimate Module Creator
217
+ */
218
+ public function getParentCategory(){
219
+ if (!$this->hasData('parent_category')) {
220
+ $this->setData('parent_category', Mage::getModel('joomi_masonrygallery/category')->load($this->getParentId()));
221
+ }
222
+ return $this->_getData('parent_category');
223
+ }
224
+ /**
225
+ * Get the parent id
226
+ * @access public
227
+ * @return int
228
+ * @author Ultimate Module Creator
229
+ */
230
+ public function getParentId(){
231
+ $parentIds = $this->getParentIds();
232
+ return intval(array_pop($parentIds));
233
+ }
234
+ /**
235
+ * Get all parent categories ids
236
+ * @access public
237
+ * @return array
238
+ * @author Ultimate Module Creator
239
+ */
240
+ public function getParentIds(){
241
+ return array_diff($this->getPathIds(), array($this->getId()));
242
+ }
243
+ /**
244
+ * Get all categories children
245
+ * @access public
246
+ * @param bool $asArray
247
+ * @return mixed (array|string)
248
+ * @author Ultimate Module Creator
249
+ */
250
+ public function getAllChildren($asArray = false){
251
+ $children = $this->getResource()->getAllChildren($this);
252
+ if ($asArray) {
253
+ return $children;
254
+ }
255
+ else {
256
+ return implode(',', $children);
257
+ }
258
+ }
259
+ /**
260
+ * Get all categories children
261
+ * @access public
262
+ * @return string
263
+ * @author Ultimate Module Creator
264
+ */
265
+ public function getChildCategories(){
266
+ return implode(',', $this->getResource()->getChildren($this, false));
267
+ }
268
+ /**
269
+ * check the id
270
+ * @access public
271
+ * @return bool
272
+ * @author Ultimate Module Creator
273
+ */
274
+ public function checkId($id){
275
+ return $this->_getResource()->checkId($id);
276
+ }
277
+ /**
278
+ * Get array categories ids which are part of category path
279
+ * @access public
280
+ * @return array
281
+ * @author Ultimate Module Creator
282
+ */
283
+ public function getPathIds(){
284
+ $ids = $this->getData('path_ids');
285
+ if (is_null($ids)) {
286
+ $ids = explode('/', $this->getPath());
287
+ $this->setData('path_ids', $ids);
288
+ }
289
+ return $ids;
290
+ }
291
+ /**
292
+ * Retrieve level
293
+ * @access public
294
+ * @return int
295
+ * @author Ultimate Module Creator
296
+ */
297
+ public function getLevel(){
298
+ if (!$this->hasLevel()) {
299
+ return count(explode('/', $this->getPath())) - 1;
300
+ }
301
+ return $this->getData('level');
302
+ }
303
+ /**
304
+ * Verify category ids
305
+ * @access public
306
+ * @param array $ids
307
+ * @return bool
308
+ * @author Ultimate Module Creator
309
+ */
310
+ public function verifyIds(array $ids){
311
+ return $this->getResource()->verifyIds($ids);
312
+ }
313
+ /**
314
+ * check if category has children
315
+ * @access public
316
+ * @return bool
317
+ * @author Ultimate Module Creator
318
+ */
319
+ public function hasChildren(){
320
+ return $this->_getResource()->getChildrenAmount($this) > 0;
321
+ }
322
+ /**
323
+ * check if category can be deleted
324
+ * @access protected
325
+ * @return Joomi_MasonryGallery_Model_Category
326
+ * @author Ultimate Module Creator
327
+ */
328
+ protected function _beforeDelete(){
329
+ if ($this->getResource()->isForbiddenToDelete($this->getId())) {
330
+ Mage::throwException(Mage::helper('joomi_masonrygallery')->__("Can't delete root category."));
331
+ }
332
+ return parent::_beforeDelete();
333
+ }
334
+ /**
335
+ * get the categories
336
+ * @access public
337
+ * @param Joomi_MasonryGallery_Model_Category $parent
338
+ * @param int $recursionLevel
339
+ * @param bool $sorted
340
+ * @param bool $asCollection
341
+ * @param bool $toLoad
342
+ * @author Ultimate Module Creator
343
+ */
344
+ public function getCategories($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true){
345
+ return $this->getResource()->getCategories($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
346
+ }
347
+ /**
348
+ * Return parent categories of current category
349
+ * @access public
350
+ * @return array
351
+ * @author Ultimate Module Creator
352
+ */
353
+ public function getParentCategories(){
354
+ return $this->getResource()->getParentCategories($this);
355
+ }
356
+ /**
357
+ * Retuen children categories of current category
358
+ * @access public
359
+ * @return array
360
+ * @author Ultimate Module Creator
361
+ */
362
+ public function getChildrenCategories(){
363
+ return $this->getResource()->getChildrenCategories($this);
364
+ }
365
+ /**
366
+ * check if parents are enabled
367
+ * @access public
368
+ * @return bool
369
+ * @author Ultimate Module Creator
370
+ */
371
+ public function getStatusPath(){
372
+ $parents = $this->getParentCategories();
373
+ $rootId = Mage::helper('joomi_masonrygallery/category')->getRootCategoryId();
374
+ foreach ($parents as $parent){
375
+ if ($parent->getId() == $rootId) {
376
+ continue;
377
+ }
378
+ if (!$parent->getStatus()){
379
+ return false;
380
+ }
381
+ }
382
+ return $this->getStatus();
383
+ }
384
+ /**
385
+ * get default values
386
+ * @access public
387
+ * @return array
388
+ * @author Ultimate Module Creator
389
+ */
390
+ public function getDefaultValues() {
391
+ $values = array();
392
+ $values['status'] = 1;
393
+ return $values;
394
+ }
395
+ }
app/code/community/Joomi/MasonryGallery/Model/Category/Source.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category source model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Category_Source
25
+ extends Mage_Eav_Model_Entity_Attribute_Source_Abstract {
26
+ /**
27
+ * Get all options
28
+ * @access public
29
+ * @return array
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function getAllOptions($withEmpty = false) {
33
+ if (is_null($this->_options)) {
34
+ $this->_options = Mage::getResourceModel('joomi_masonrygallery/category_collection')
35
+
36
+ ->load()
37
+ ->toOptionArray();
38
+ }
39
+ $options = $this->_options;
40
+ if ($withEmpty) {
41
+ array_unshift($options, array('value'=>'', 'label'=>''));
42
+ }
43
+ return $options;
44
+ }
45
+
46
+ /**
47
+ * Get a text for option value
48
+ * @access public
49
+ * @param string|integer $value
50
+ * @return string
51
+ * @author Ultimate Module Creator
52
+ */
53
+ public function getOptionText($value) {
54
+ $options = $this->getAllOptions(false);
55
+ foreach ($options as $item) {
56
+ if ($item['value'] == $value) {
57
+ return $item['label'];
58
+ }
59
+ }
60
+ return false;
61
+ }
62
+
63
+ /**
64
+ * Convert to options array
65
+ * @access public
66
+ * @return array
67
+ * @author Ultimate Module Creator
68
+ */
69
+ public function toOptionArray() {
70
+ return $this->getAllOptions();
71
+ }
72
+
73
+ /**
74
+ * Retrieve flat column definition
75
+ * @access public
76
+ * @return array
77
+ * @author Ultimate Module Creator
78
+ */
79
+ public function getFlatColums() {
80
+ $attributeCode = $this->getAttribute()->getAttributeCode();
81
+ $column = array(
82
+ 'unsigned' => true,
83
+ 'default' => null,
84
+ 'extra' => null
85
+ );
86
+ if (Mage::helper('core')->useDbCompatibleMode()) {
87
+ $column['type'] = 'int';
88
+ $column['is_null'] = true;
89
+ } else {
90
+ $column['type'] = Varien_Db_Ddl_Table::TYPE_INTEGER;
91
+ $column['nullable'] = true;
92
+ $column['comment'] = $attributeCode . ' Category column';
93
+ }
94
+ return array($attributeCode => $column);
95
+ }
96
+
97
+ /**
98
+ * Retrieve Select for update attribute value in flat table
99
+ * @access public
100
+ * @param int $store
101
+ * @return Varien_Db_Select|null
102
+ * @author Ultimate Module Creator
103
+ */
104
+ public function getFlatUpdateSelect($store) {
105
+ return Mage::getResourceModel('eav/entity_attribute_option')
106
+ ->getFlatUpdateSelect($this->getAttribute(), $store, false);
107
+ }
108
+ }
app/code/community/Joomi/MasonryGallery/Model/Gallery.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Gallery
25
+ extends Mage_Core_Model_Abstract {
26
+ /**
27
+ * Entity code.
28
+ * Can be used as part of method name for entity processing
29
+ */
30
+ const ENTITY = 'joomi_masonrygallery_gallery';
31
+ const CACHE_TAG = 'joomi_masonrygallery_gallery';
32
+ /**
33
+ * Prefix of model events names
34
+ * @var string
35
+ */
36
+ protected $_eventPrefix = 'joomi_masonrygallery_gallery';
37
+
38
+ /**
39
+ * Parameter name in event
40
+ * @var string
41
+ */
42
+ protected $_eventObject = 'gallery';
43
+ protected $_productInstance = null;
44
+ /**
45
+ * constructor
46
+ * @access public
47
+ * @return void
48
+ * @author Ultimate Module Creator
49
+ */
50
+ public function _construct(){
51
+ parent::_construct();
52
+ $this->_init('joomi_masonrygallery/gallery');
53
+ }
54
+ /**
55
+ * before save gallery
56
+ * @access protected
57
+ * @return Joomi_MasonryGallery_Model_Gallery
58
+ * @author Ultimate Module Creator
59
+ */
60
+ protected function _beforeSave(){
61
+ parent::_beforeSave();
62
+ $now = Mage::getSingleton('core/date')->gmtDate();
63
+ if ($this->isObjectNew()){
64
+ $this->setCreatedAt($now);
65
+ }
66
+ $this->setUpdatedAt($now);
67
+ return $this;
68
+ }
69
+ /**
70
+ * get the url to the gallery details page
71
+ * @access public
72
+ * @return string
73
+ * @author Ultimate Module Creator
74
+ */
75
+ public function getGalleryUrl(){
76
+ if ($this->getUrlKey()){
77
+ $urlKey = '';
78
+ if ($prefix = Mage::getStoreConfig('joomi_masonrygallery/gallery/url_prefix')){
79
+ $urlKey .= $prefix.'/';
80
+ }
81
+ $urlKey .= $this->getUrlKey();
82
+ if ($suffix = Mage::getStoreConfig('joomi_masonrygallery/gallery/url_suffix')){
83
+ $urlKey .= '.'.$suffix;
84
+ }
85
+ return Mage::getUrl('', array('_direct'=>$urlKey));
86
+ }
87
+ return Mage::getUrl('joomi_masonrygallery/gallery/view', array('id'=>$this->getId()));
88
+ }
89
+ /**
90
+ * check URL key
91
+ * @access public
92
+ * @param string $urlKey
93
+ * @param bool $active
94
+ * @return mixed
95
+ * @author Ultimate Module Creator
96
+ */
97
+ public function checkUrlKey($urlKey, $active = true){
98
+ return $this->_getResource()->checkUrlKey($urlKey, $active);
99
+ }
100
+
101
+ /**
102
+ * get the gallery Description
103
+ * @access public
104
+ * @return string
105
+ * @author Ultimate Module Creator
106
+ */
107
+ public function getDescription(){
108
+ $description = $this->getData('description');
109
+ $helper = Mage::helper('cms');
110
+ $processor = $helper->getBlockTemplateProcessor();
111
+ $html = $processor->filter($description);
112
+ return $html;
113
+ }
114
+ /**
115
+ * save gallery relation
116
+ * @access public
117
+ * @return Joomi_MasonryGallery_Model_Gallery
118
+ * @author Ultimate Module Creator
119
+ */
120
+ protected function _afterSave() {
121
+ $this->getProductInstance()->saveGalleryRelation($this);
122
+ return parent::_afterSave();
123
+ }
124
+ /**
125
+ * get product relation model
126
+ * @access public
127
+ * @return Joomi_MasonryGallery_Model_Gallery_Product
128
+ * @author Ultimate Module Creator
129
+ */
130
+ public function getProductInstance(){
131
+ if (!$this->_productInstance) {
132
+ $this->_productInstance = Mage::getSingleton('joomi_masonrygallery/gallery_product');
133
+ }
134
+ return $this->_productInstance;
135
+ }
136
+ /**
137
+ * get selected products array
138
+ * @access public
139
+ * @return array
140
+ * @author Ultimate Module Creator
141
+ */
142
+ public function getSelectedProducts(){
143
+ if (!$this->hasSelectedProducts()) {
144
+ $products = array();
145
+ foreach ($this->getSelectedProductsCollection() as $product) {
146
+ $products[] = $product;
147
+ }
148
+ $this->setSelectedProducts($products);
149
+ }
150
+ return $this->getData('selected_products');
151
+ }
152
+ /**
153
+ * Retrieve collection selected products
154
+ * @access public
155
+ * @return Joomi_MasonryGallery_Resource_Gallery_Product_Collection
156
+ * @author Ultimate Module Creator
157
+ */
158
+ public function getSelectedProductsCollection(){
159
+ $collection = $this->getProductInstance()->getProductCollection($this);
160
+ return $collection;
161
+ }
162
+ /**
163
+ * Retrieve parent
164
+ * @access public
165
+ * @return null|Joomi_MasonryGallery_Model_Category
166
+ * @author Ultimate Module Creator
167
+ */
168
+ public function getParentCategory(){
169
+ if (!$this->hasData('_parent_category')) {
170
+ if (!$this->getCategoryId()) {
171
+ return null;
172
+ }
173
+ else {
174
+ $category = Mage::getModel('joomi_masonrygallery/category')->load($this->getCategoryId());
175
+ if ($category->getId()) {
176
+ $this->setData('_parent_category', $category);
177
+ }
178
+ else {
179
+ $this->setData('_parent_category', null);
180
+ }
181
+ }
182
+ }
183
+ return $this->getData('_parent_category');
184
+ }
185
+ /**
186
+ * get default values
187
+ * @access public
188
+ * @return array
189
+ * @author Ultimate Module Creator
190
+ */
191
+ public function getDefaultValues() {
192
+ $values = array();
193
+ $values['status'] = 1;
194
+ $values['column_width'] = '200';
195
+ $values['limit_first_load'] = '30';
196
+
197
+ return $values;
198
+ }
199
+ }
app/code/community/Joomi/MasonryGallery/Model/Gallery/Attribute/Source/Bigimage.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Admin source model for Big Image
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Gallery_Attribute_Source_Bigimage
25
+ extends Mage_Eav_Model_Entity_Attribute_Source_Table {
26
+ /**
27
+ * get possible values
28
+ * @access public
29
+ * @param bool $withEmpty
30
+ * @param bool $defaultValues
31
+ * @return array
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function getAllOptions($withEmpty = true, $defaultValues = false){
35
+ $product = Mage::getModel('catalog/product')->load();
36
+ $productAttributes = $product->getTypeInstance(true)->getEditableAttributes($product);
37
+ $options=array();
38
+ foreach ($productAttributes as $attribute) {
39
+ if($attribute->getFrontend()->getInputType() == 'media_image') {
40
+ $option=array(
41
+ 'label' => $attribute->getFrontendLabel(),
42
+ 'value' => $attribute->getAttributeCode()
43
+ );
44
+ array_push($options,$option);
45
+ }
46
+ }
47
+ if ($withEmpty) {
48
+ array_unshift($options, array('label'=>'', 'value'=>''));
49
+ }
50
+ return $options;
51
+ }
52
+ /**
53
+ * get options as array
54
+ * @access public
55
+ * @param bool $withEmpty
56
+ * @return string
57
+ * @author Ultimate Module Creator
58
+ */
59
+ public function getOptionsArray($withEmpty = true) {
60
+ $options = array();
61
+ foreach ($this->getAllOptions($withEmpty) as $option) {
62
+ $options[$option['value']] = $option['label'];
63
+ }
64
+ return $options;
65
+ }
66
+ /**
67
+ * get option text
68
+ * @access public
69
+ * @param mixed $value
70
+ * @return string
71
+ * @author Ultimate Module Creator
72
+ */
73
+ public function getOptionText($value) {
74
+ $options = $this->getOptionsArray();
75
+ if (!is_array($value)) {
76
+ $value = array($value);
77
+ }
78
+ $texts = array();
79
+ foreach ($value as $v) {
80
+ if (isset($options[$v])) {
81
+ $texts[] = $options[$v];
82
+ }
83
+ }
84
+ return implode(', ', $texts);
85
+ }
86
+ }
app/code/community/Joomi/MasonryGallery/Model/Gallery/Attribute/Source/Thumbnail.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Admin source model for Thumbnail
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Gallery_Attribute_Source_Thumbnail
25
+ extends Mage_Eav_Model_Entity_Attribute_Source_Table {
26
+ /**
27
+ * get possible values
28
+ * @access public
29
+ * @param bool $withEmpty
30
+ * @param bool $defaultValues
31
+ * @return array
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function getAllOptions($withEmpty = true, $defaultValues = false){
35
+ $product = Mage::getModel('catalog/product')->load();
36
+ $productAttributes = $product->getTypeInstance(true)->getEditableAttributes($product);
37
+ $options=array();
38
+ foreach ($productAttributes as $attribute) {
39
+ if($attribute->getFrontend()->getInputType() == 'media_image') {
40
+ $option=array(
41
+ 'label' => $attribute->getFrontendLabel(),
42
+ 'value' => $attribute->getAttributeCode()
43
+ );
44
+ array_push($options,$option);
45
+ }
46
+ }
47
+ if ($withEmpty) {
48
+ array_unshift($options, array('label'=>'', 'value'=>''));
49
+ }
50
+ return $options;
51
+ }
52
+ /**
53
+ * get options as array
54
+ * @access public
55
+ * @param bool $withEmpty
56
+ * @return string
57
+ * @author Ultimate Module Creator
58
+ */
59
+ public function getOptionsArray($withEmpty = true) {
60
+ $options = array();
61
+ foreach ($this->getAllOptions($withEmpty) as $option) {
62
+ $options[$option['value']] = $option['label'];
63
+ }
64
+ return $options;
65
+ }
66
+ /**
67
+ * get option text
68
+ * @access public
69
+ * @param mixed $value
70
+ * @return string
71
+ * @author Ultimate Module Creator
72
+ */
73
+ public function getOptionText($value) {
74
+ $options = $this->getOptionsArray();
75
+ if (!is_array($value)) {
76
+ $value = array($value);
77
+ }
78
+ $texts = array();
79
+ foreach ($value as $v) {
80
+ if (isset($options[$v])) {
81
+ $texts[] = $options[$v];
82
+ }
83
+ }
84
+ return implode(', ', $texts);
85
+ }
86
+ }
app/code/community/Joomi/MasonryGallery/Model/Gallery/Product.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery product model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Gallery_Product
25
+ extends Mage_Core_Model_Abstract {
26
+ /**
27
+ * Initialize resource
28
+ * @access protected
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _construct(){
33
+ $this->_init('joomi_masonrygallery/gallery_product');
34
+ }
35
+ /**
36
+ * Save data for gallery-product relation
37
+ * @access public
38
+ * @param Joomi_MasonryGallery_Model_Gallery $gallery
39
+ * @return Joomi_MasonryGallery_Model_Gallery_Product
40
+ * @author Ultimate Module Creator
41
+ */
42
+ public function saveGalleryRelation($gallery){
43
+ $data = $gallery->getProductsData();
44
+ if (!is_null($data)) {
45
+ $this->_getResource()->saveGalleryRelation($gallery, $data);
46
+ }
47
+ return $this;
48
+ }
49
+ /**
50
+ * get products for gallery
51
+ * @access public
52
+ * @param Joomi_MasonryGallery_Model_Gallery $gallery
53
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Product_Collection
54
+ * @author Ultimate Module Creator
55
+ */
56
+ public function getProductCollection($gallery){
57
+ $collection = Mage::getResourceModel('joomi_masonrygallery/gallery_product_collection')
58
+ ->addGalleryFilter($gallery);
59
+ return $collection;
60
+ }
61
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Category.php ADDED
@@ -0,0 +1,700 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category resource model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Category
25
+ extends Mage_Core_Model_Resource_Db_Abstract {
26
+ /**
27
+ * Category tree object
28
+ * @var Varien_Data_Tree_Db
29
+ */
30
+ protected $_tree;
31
+ /**
32
+ * constructor
33
+ * @access public
34
+ * @author Ultimate Module Creator
35
+ */
36
+ public function _construct(){
37
+ $this->_init('joomi_masonrygallery/category', 'entity_id');
38
+ }
39
+ /**
40
+ * Get store ids to which specified item is assigned
41
+ * @access public
42
+ * @param int $categoryId
43
+ * @return array
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function lookupStoreIds($categoryId){
47
+ $adapter = $this->_getReadAdapter();
48
+ $select = $adapter->select()
49
+ ->from($this->getTable('joomi_masonrygallery/category_store'), 'store_id')
50
+ ->where('category_id = ?',(int)$categoryId);
51
+ return $adapter->fetchCol($select);
52
+ }
53
+ /**
54
+ * Perform operations after object load
55
+ * @access public
56
+ * @param Mage_Core_Model_Abstract $object
57
+ * @return Joomi_MasonryGallery_Model_Resource_Category
58
+ * @author Ultimate Module Creator
59
+ */
60
+ protected function _afterLoad(Mage_Core_Model_Abstract $object){
61
+ if ($object->getId()) {
62
+ $stores = $this->lookupStoreIds($object->getId());
63
+ $object->setData('store_id', $stores);
64
+ }
65
+ return parent::_afterLoad($object);
66
+ }
67
+
68
+ /**
69
+ * Retrieve select object for load object data
70
+ *
71
+ * @param string $field
72
+ * @param mixed $value
73
+ * @param Joomi_MasonryGallery_Model_Category $object
74
+ * @return Zend_Db_Select
75
+ */
76
+ protected function _getLoadSelect($field, $value, $object){
77
+ $select = parent::_getLoadSelect($field, $value, $object);
78
+ if ($object->getStoreId()) {
79
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
80
+ $select->join(
81
+ array('masonrygallery_category_store' => $this->getTable('joomi_masonrygallery/category_store')),
82
+ $this->getMainTable() . '.entity_id = masonrygallery_category_store.category_id',
83
+ array()
84
+ )
85
+ ->where('masonrygallery_category_store.store_id IN (?)', $storeIds)
86
+ ->order('masonrygallery_category_store.store_id DESC')
87
+ ->limit(1);
88
+ }
89
+ return $select;
90
+ }
91
+ /**
92
+ * Retrieve category tree object
93
+ * @access protected
94
+ * @return Varien_Data_Tree_Db
95
+ * @author Ultimate Module Creator
96
+ */
97
+ protected function _getTree(){
98
+ if (!$this->_tree) {
99
+ $this->_tree = Mage::getResourceModel('joomi_masonrygallery/category_tree')->load();
100
+ }
101
+ return $this->_tree;
102
+ }
103
+ /**
104
+ * Process category data before delete
105
+ * update children count for parent category
106
+ * delete child categories
107
+ * @access protected
108
+ * @param Varien_Object $object
109
+ * @return Joomi_MasonryGallery_Model_Resource_Category
110
+ * @author Ultimate Module Creator
111
+ */
112
+ protected function _beforeDelete(Mage_Core_Model_Abstract $object){
113
+ parent::_beforeDelete($object);
114
+ /**
115
+ * Update children count for all parent categories
116
+ */
117
+ $parentIds = $object->getParentIds();
118
+ if ($parentIds) {
119
+ $childDecrease = $object->getChildrenCount() + 1; // +1 is itself
120
+ $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease));
121
+ $where = array('entity_id IN(?)' => $parentIds);
122
+ $this->_getWriteAdapter()->update( $this->getMainTable(), $data, $where);
123
+ }
124
+ $this->deleteChildren($object);
125
+ return $this;
126
+ }
127
+ /**
128
+ * Delete children categories of specific category
129
+ * @access public
130
+ * @param Varien_Object $object
131
+ * @return Joomi_MasonryGallery_Model_Resource_Category
132
+ * @author Ultimate Module Creator
133
+ */
134
+ public function deleteChildren(Varien_Object $object){
135
+ $adapter = $this->_getWriteAdapter();
136
+ $pathField = $adapter->quoteIdentifier('path');
137
+ $select = $adapter->select()
138
+ ->from($this->getMainTable(), array('entity_id'))
139
+ ->where($pathField . ' LIKE :c_path');
140
+ $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%'));
141
+ if (!empty($childrenIds)) {
142
+ $adapter->delete(
143
+ $this->getMainTable(),
144
+ array('entity_id IN (?)' => $childrenIds)
145
+ );
146
+ }
147
+ /**
148
+ * Add deleted children ids to object
149
+ * This data can be used in after delete event
150
+ */
151
+ $object->setDeletedChildrenIds($childrenIds);
152
+ return $this;
153
+ }
154
+ /**
155
+ * Process category data after save category object
156
+ * @access protected
157
+ * @param Varien_Object $object
158
+ * @return Joomi_MasonryGallery_Model_Resource_Category
159
+ * @author Ultimate Module Creator
160
+ */
161
+ protected function _afterSave(Mage_Core_Model_Abstract $object){
162
+ if (substr($object->getPath(), -1) == '/') {
163
+ $object->setPath($object->getPath() . $object->getId());
164
+ $this->_savePath($object);
165
+ }
166
+
167
+
168
+ $oldStores = $this->lookupStoreIds($object->getId());
169
+ $newStores = (array)$object->getStores();
170
+ if (empty($newStores)) {
171
+ $newStores = (array)$object->getStoreId();
172
+ }
173
+ $table = $this->getTable('joomi_masonrygallery/category_store');
174
+ $insert = array_diff($newStores, $oldStores);
175
+ $delete = array_diff($oldStores, $newStores);
176
+ if ($delete) {
177
+ $where = array(
178
+ 'category_id = ?' => (int) $object->getId(),
179
+ 'store_id IN (?)' => $delete
180
+ );
181
+ $this->_getWriteAdapter()->delete($table, $where);
182
+ }
183
+ if ($insert) {
184
+ $data = array();
185
+ foreach ($insert as $storeId) {
186
+ $data[] = array(
187
+ 'category_id' => (int) $object->getId(),
188
+ 'store_id' => (int) $storeId
189
+ );
190
+ }
191
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
192
+ }
193
+ return parent::_afterSave($object);
194
+ }
195
+
196
+ /**
197
+ * Update path field
198
+ * @access protected
199
+ * @param Joomi_MasonryGallery_Model_Category $object
200
+ * @return Joomi_MasonryGallery_Model_Resource_Category
201
+ * @author Ultimate Module Creator
202
+ */
203
+ protected function _savePath($object){
204
+ if ($object->getId()) {
205
+ $this->_getWriteAdapter()->update(
206
+ $this->getMainTable(),
207
+ array('path' => $object->getPath()),
208
+ array('entity_id = ?' => $object->getId())
209
+ );
210
+ }
211
+ return $this;
212
+ }
213
+
214
+ /**
215
+ * Get maximum position of child categories by specific tree path
216
+ * @access protected
217
+ * @param string $path
218
+ * @return int
219
+ * @author Ultimate Module Creator
220
+ */
221
+ protected function _getMaxPosition($path){
222
+ $adapter = $this->getReadConnection();
223
+ $positionField = $adapter->quoteIdentifier('position');
224
+ $level = count(explode('/', $path));
225
+ $bind = array(
226
+ 'c_level' => $level,
227
+ 'c_path' => $path . '/%'
228
+ );
229
+ $select = $adapter->select()
230
+ ->from($this->getMainTable(), 'MAX(' . $positionField . ')')
231
+ ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path')
232
+ ->where($adapter->quoteIdentifier('level') . ' = :c_level');
233
+
234
+ $position = $adapter->fetchOne($select, $bind);
235
+ if (!$position) {
236
+ $position = 0;
237
+ }
238
+ return $position;
239
+ }
240
+ /**
241
+ * Get children categories count
242
+ * @access public
243
+ * @param int $categoryId
244
+ * @return int
245
+ * @author Ultimate Module Creator
246
+ */
247
+ public function getChildrenCount($categoryId){
248
+ $select = $this->_getReadAdapter()->select()
249
+ ->from($this->getMainTable(), 'children_count')
250
+ ->where('entity_id = :entity_id');
251
+ $bind = array('entity_id' => $categoryId);
252
+ return $this->_getReadAdapter()->fetchOne($select, $bind);
253
+ }
254
+ /**
255
+ * Check if category id exist
256
+ * @access public
257
+ * @param int $entityId
258
+ * @return bool
259
+ * @author Ultimate Module Creator
260
+ */
261
+ public function checkId($entityId){
262
+ $select = $this->_getReadAdapter()->select()
263
+ ->from($this->getMainTable(), 'entity_id')
264
+ ->where('entity_id = :entity_id');
265
+ $bind = array('entity_id' => $entityId);
266
+ return $this->_getReadAdapter()->fetchOne($select, $bind);
267
+ }
268
+
269
+ /**
270
+ * Check array of categories identifiers
271
+ * @access public
272
+ * @param array $ids
273
+ * @return array
274
+ * @author Ultimate Module Creator
275
+ */
276
+ public function verifyIds(array $ids){
277
+ if (empty($ids)) {
278
+ return array();
279
+ }
280
+ $select = $this->_getReadAdapter()->select()
281
+ ->from($this->getMainTable(), 'entity_id')
282
+ ->where('entity_id IN(?)', $ids);
283
+
284
+ return $this->_getReadAdapter()->fetchCol($select);
285
+ }
286
+ /**
287
+ * Get count of active/not active children categories
288
+ *
289
+ * @param Joomi_MasonryGallery_Model_Category $category
290
+ * @param bool $isActiveFlag
291
+ * @return int
292
+ * @author Ultimate Module Creator
293
+ */
294
+ public function getChildrenAmount($category, $isActiveFlag = true){
295
+ $bind = array(
296
+ 'active_flag' => $isActiveFlag,
297
+ 'c_path' => $category->getPath() . '/%'
298
+ );
299
+ $select = $this->_getReadAdapter()->select()
300
+ ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)'))
301
+ ->where('m.path LIKE :c_path')
302
+ ->where('status' . ' = :active_flag');
303
+ return $this->_getReadAdapter()->fetchOne($select, $bind);
304
+ }
305
+ /**
306
+ * Return parent categories of category
307
+ * @access public
308
+ * @param Joomi_MasonryGallery_Model_Category $category
309
+ * @return array
310
+ * @author Ultimate Module Creator
311
+ */
312
+ public function getParentCategories($category){
313
+ $pathIds = array_reverse(explode('/', $category->getPath()));
314
+ $categories = Mage::getResourceModel('joomi_masonrygallery/category_collection')
315
+ ->addFieldToFilter('entity_id', array('in' => $pathIds))
316
+ ->load()
317
+ ->getItems();
318
+ return $categories;
319
+ }
320
+ /**
321
+ * Return child categories
322
+ * @access public
323
+ * @param Joomi_MasonryGallery_Model_Category $category
324
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
325
+ * @author Ultimate Module Creator
326
+ */
327
+ public function getChildrenCategories($category){
328
+ $collection = $category->getCollection();
329
+ $collection
330
+ ->addIdFilter($category->getChildCategories())
331
+ ->setOrder('position', Varien_Db_Select::SQL_ASC)
332
+ ->load();
333
+ return $collection;
334
+ }
335
+ /**
336
+ * Return children ids of category
337
+ * @access public
338
+ * @param Joomi_MasonryGallery_Model_Category $category
339
+ * @param boolean $recursive
340
+ * @return array
341
+ * @author Ultimate Module Creator
342
+ */
343
+ public function getChildren($category, $recursive = true){
344
+ $bind = array(
345
+ 'c_path' => $category->getPath() . '/%'
346
+ );
347
+ $select = $this->_getReadAdapter()->select()
348
+ ->from(array('m' => $this->getMainTable()), 'entity_id')
349
+ ->where('status = ?', 1)
350
+ ->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path');
351
+ if (!$recursive) {
352
+ $select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level');
353
+ $bind['c_level'] = $category->getLevel() + 1;
354
+ }
355
+ return $this->_getReadAdapter()->fetchCol($select, $bind);
356
+ }
357
+ /**
358
+ * Process category data before saving
359
+ * prepare path and increment children count for parent categories
360
+ * @access protected
361
+ * @param Varien_Object $object
362
+ * @return Joomi_MasonryGallery_Model_Resource_Category
363
+ * @author Ultimate Module Creator
364
+ */
365
+ protected function _beforeSave(Mage_Core_Model_Abstract $object){
366
+ if (!$object->getInitialSetupFlag()){
367
+ $urlKey = $object->getData('url_key');
368
+ if ($urlKey == '') {
369
+ $urlKey = $object->getTitle();
370
+ }
371
+ $urlKey = $this->formatUrlKey($urlKey);
372
+ $validKey = false;
373
+ while (!$validKey) {
374
+ $entityId = $this->checkUrlKey($urlKey, $object->getStoreId(), false);
375
+ if ($entityId == $object->getId() || empty($entityId)) {
376
+ $validKey = true;
377
+ }
378
+ else {
379
+ $parts = explode('-', $urlKey);
380
+ $last = $parts[count($parts) - 1];
381
+ if (!is_numeric($last)){
382
+ $urlKey = $urlKey.'-1';
383
+ }
384
+ else {
385
+ $suffix = '-'.($last + 1);
386
+ unset($parts[count($parts) - 1]);
387
+ $urlKey = implode('-', $parts).$suffix;
388
+ }
389
+ }
390
+ }
391
+ $object->setData('url_key', $urlKey);
392
+ }
393
+ parent::_beforeSave($object);
394
+ if (!$object->getChildrenCount()) {
395
+ $object->setChildrenCount(0);
396
+ }
397
+ if ($object->getLevel() === null) {
398
+ $object->setLevel(1);
399
+ }
400
+ if (!$object->getId() && !$object->getInitialSetupFlag()) {
401
+ $object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
402
+ $path = explode('/', $object->getPath());
403
+ $level = count($path);
404
+ $object->setLevel($level);
405
+ if ($level) {
406
+ $object->setParentId($path[$level - 1]);
407
+ }
408
+ $object->setPath($object->getPath() . '/');
409
+ $toUpdateChild = explode('/',$object->getPath());
410
+ $this->_getWriteAdapter()->update(
411
+ $this->getMainTable(),
412
+ array('children_count' => new Zend_Db_Expr('children_count+1')),
413
+ array('entity_id IN(?)' => $toUpdateChild)
414
+ );
415
+ }
416
+ return $this;
417
+ }
418
+ /**
419
+ * Retrieve categories
420
+ * @access public
421
+ * @param integer $parent
422
+ * @param integer $recursionLevel
423
+ * @param boolean|string $sorted
424
+ * @param boolean $asCollection
425
+ * @param boolean $toLoad
426
+ * @return Varien_Data_Tree_Node_Collection|Joomi_MasonryGallery_Model_Resource_Category_Collection
427
+ * @author Ultimate Module Creator
428
+ */
429
+ public function getCategories($parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true){
430
+ $tree = Mage::getResourceModel('joomi_masonrygallery/category_tree');
431
+ $nodes = $tree->loadNode($parent)
432
+ ->loadChildren($recursionLevel)
433
+ ->getChildren();
434
+ $tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
435
+ if ($asCollection) {
436
+ return $tree->getCollection();
437
+ }
438
+ return $nodes;
439
+ }
440
+ /**
441
+ * Return all children ids of category (with category id)
442
+ * @access public
443
+ * @param Joomi_MasonryGallery_Model_Category $category
444
+ * @return array
445
+ * @author Ultimate Module Creator
446
+ */
447
+ public function getAllChildren($category){
448
+ $children = $this->getChildren($category);
449
+ $myId = array($category->getId());
450
+ $children = array_merge($myId, $children);
451
+ return $children;
452
+ }
453
+ /**
454
+ * Check category is forbidden to delete.
455
+ * @access public
456
+ * @param integer $categoryId
457
+ * @return boolean
458
+ * @author Ultimate Module Creator
459
+ */
460
+ public function isForbiddenToDelete($categoryId){
461
+ return ($categoryId == Mage::helper('joomi_masonrygallery/category')->getRootCategoryId());
462
+ }
463
+ /**
464
+ * Get category path value by its id
465
+ * @access public
466
+ * @param int $categoryId
467
+ * @return string
468
+ * @author Ultimate Module Creator
469
+ */
470
+ public function getCategoryPathById($categoryId){
471
+ $select = $this->getReadConnection()->select()
472
+ ->from($this->getMainTable(), array('path'))
473
+ ->where('entity_id = :entity_id');
474
+ $bind = array('entity_id' => (int)$categoryId);
475
+ return $this->getReadConnection()->fetchOne($select, $bind);
476
+ }
477
+ /**
478
+ * Move category to another parent node
479
+ * @access public
480
+ * @param Joomi_MasonryGallery_Model_Category $category
481
+ * @param Joomi_MasonryGallery_Model_Category $newParent
482
+ * @param null|int $afterCategoryId
483
+ * @return Joomi_MasonryGallery_Model_Resource_Category
484
+ * @author Ultimate Module Creator
485
+ */
486
+ public function changeParent(Joomi_MasonryGallery_Model_Category $category, Joomi_MasonryGallery_Model_Category $newParent, $afterCategoryId = null){
487
+ $childrenCount = $this->getChildrenCount($category->getId()) + 1;
488
+ $table = $this->getMainTable();
489
+ $adapter = $this->_getWriteAdapter();
490
+ $levelFiled = $adapter->quoteIdentifier('level');
491
+ $pathField = $adapter->quoteIdentifier('path');
492
+
493
+ /**
494
+ * Decrease children count for all old category parent categories
495
+ */
496
+ $adapter->update(
497
+ $table,
498
+ array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)),
499
+ array('entity_id IN(?)' => $category->getParentIds())
500
+ );
501
+ /**
502
+ * Increase children count for new category parents
503
+ */
504
+ $adapter->update(
505
+ $table,
506
+ array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)),
507
+ array('entity_id IN(?)' => $newParent->getPathIds())
508
+ );
509
+
510
+ $position = $this->_processPositions($category, $newParent, $afterCategoryId);
511
+
512
+ $newPath = sprintf('%s/%s', $newParent->getPath(), $category->getId());
513
+ $newLevel = $newParent->getLevel() + 1;
514
+ $levelDisposition = $newLevel - $category->getLevel();
515
+
516
+ /**
517
+ * Update children nodes path
518
+ */
519
+ $adapter->update(
520
+ $table,
521
+ array(
522
+ 'path' => new Zend_Db_Expr('REPLACE(' . $pathField . ','.
523
+ $adapter->quote($category->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')'
524
+ ),
525
+ 'level' => new Zend_Db_Expr( $levelFiled . ' + ' . $levelDisposition)
526
+ ),
527
+ array($pathField . ' LIKE ?' => $category->getPath() . '/%')
528
+ );
529
+ /**
530
+ * Update moved category data
531
+ */
532
+ $data = array(
533
+ 'path' => $newPath,
534
+ 'level' => $newLevel,
535
+ 'position' =>$position,
536
+ 'parent_id' =>$newParent->getId()
537
+ );
538
+ $adapter->update($table, $data, array('entity_id = ?' => $category->getId()));
539
+ // Update category object to new data
540
+ $category->addData($data);
541
+ return $this;
542
+ }
543
+ /**
544
+ * Process positions of old parent category children and new parent category children.
545
+ * Get position for moved category
546
+ * @access protected
547
+ * @param Joomi_MasonryGallery_Model_Category $category
548
+ * @param Joomi_MasonryGallery_Model_Category $newParent
549
+ * @param null|int $afterCategoryId
550
+ * @return int
551
+ * @author Ultimate Module Creator
552
+ */
553
+ protected function _processPositions($category, $newParent, $afterCategoryId){
554
+ $table = $this->getMainTable();
555
+ $adapter= $this->_getWriteAdapter();
556
+ $positionField = $adapter->quoteIdentifier('position');
557
+
558
+ $bind = array(
559
+ 'position' => new Zend_Db_Expr($positionField . ' - 1')
560
+ );
561
+ $where = array(
562
+ 'parent_id = ?' => $category->getParentId(),
563
+ $positionField . ' > ?' => $category->getPosition()
564
+ );
565
+ $adapter->update($table, $bind, $where);
566
+
567
+ /**
568
+ * Prepare position value
569
+ */
570
+ if ($afterCategoryId) {
571
+ $select = $adapter->select()
572
+ ->from($table,'position')
573
+ ->where('entity_id = :entity_id');
574
+ $position = $adapter->fetchOne($select, array('entity_id' => $afterCategoryId));
575
+ $bind = array(
576
+ 'position' => new Zend_Db_Expr($positionField . ' + 1')
577
+ );
578
+ $where = array(
579
+ 'parent_id = ?' => $newParent->getId(),
580
+ $positionField . ' > ?' => $position
581
+ );
582
+ $adapter->update($table, $bind, $where);
583
+ }
584
+ elseif ($afterCategoryId !== null) {
585
+ $position = 0;
586
+ $bind = array(
587
+ 'position' => new Zend_Db_Expr($positionField . ' + 1')
588
+ );
589
+ $where = array(
590
+ 'parent_id = ?' => $newParent->getId(),
591
+ $positionField . ' > ?' => $position
592
+ );
593
+ $adapter->update($table, $bind, $where);
594
+ }
595
+ else {
596
+ $select = $adapter->select()
597
+ ->from($table,array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')')))
598
+ ->where('parent_id = :parent_id');
599
+ $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId()));
600
+ }
601
+ $position += 1;
602
+ return $position;
603
+ }
604
+ /**
605
+ * check url key
606
+ * @access public
607
+ * @param string $urlKey
608
+ * @param int $storeId
609
+ * @param bool $active
610
+ * @return mixed
611
+ * @author Ultimate Module Creator
612
+ */
613
+ public function checkUrlKey($urlKey, $storeId, $active = true){
614
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId);
615
+ $select = $this->_initCheckUrlKeySelect($urlKey, $stores);
616
+ if ($active) {
617
+ $select->where('e.status = ?', $active);
618
+ }
619
+ $select->reset(Zend_Db_Select::COLUMNS)
620
+ ->columns('e.entity_id')
621
+ ->limit(1);
622
+
623
+ return $this->_getReadAdapter()->fetchOne($select);
624
+ }
625
+
626
+ /**
627
+ * Check for unique URL key
628
+ * @access public
629
+ * @param Mage_Core_Model_Abstract $object
630
+ * @return bool
631
+ * @author Ultimate Module Creator
632
+ */
633
+ public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object){
634
+ if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) {
635
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
636
+ }
637
+ else {
638
+ $stores = (array)$object->getData('stores');
639
+ }
640
+ $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores);
641
+ if ($object->getId()) {
642
+ $select->where('e.entity_id <> ?', $object->getId());
643
+ }
644
+ if ($this->_getWriteAdapter()->fetchRow($select)) {
645
+ return false;
646
+ }
647
+ return true;
648
+ }
649
+ /**
650
+ * Check if the URL key is numeric
651
+ * @access public
652
+ * @param Mage_Core_Model_Abstract $object
653
+ * @return bool
654
+ * @author Ultimate Module Creator
655
+ */
656
+ protected function isNumericUrlKey(Mage_Core_Model_Abstract $object){
657
+ return preg_match('/^[0-9]+$/', $object->getData('url_key'));
658
+ }
659
+ /**
660
+ * Checkif the URL key is valid
661
+ * @access public
662
+ * @param Mage_Core_Model_Abstract $object
663
+ * @return bool
664
+ * @author Ultimate Module Creator
665
+ */
666
+ protected function isValidUrlKey(Mage_Core_Model_Abstract $object){
667
+ return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key'));
668
+ }
669
+ /**
670
+ * format string as url key
671
+ * @access public
672
+ * @param string $str
673
+ * @return string
674
+ * @author Ultimate Module Creator
675
+ */
676
+ public function formatUrlKey($str) {
677
+ $urlKey = preg_replace('#[^0-9a-z]+#i', '-', Mage::helper('catalog/product_url')->format($str));
678
+ $urlKey = strtolower($urlKey);
679
+ $urlKey = trim($urlKey, '-');
680
+ return $urlKey;
681
+ }
682
+ /**
683
+ * init the check select
684
+ * @access protected
685
+ * @param string $urlKey
686
+ * @param array $store
687
+ * @return Zend_Db_Select
688
+ * @author Ultimate Module Creator
689
+ */
690
+ protected function _initCheckUrlKeySelect($urlKey, $store){
691
+ $select = $this->_getReadAdapter()->select()
692
+ ->from(array('e' => $this->getMainTable()))
693
+ ->join(
694
+ array('es' => $this->getTable('joomi_masonrygallery/category_store')),
695
+ 'e.entity_id = es.category_id',
696
+ array())
697
+ ->where('e.url_key = ?', $urlKey)
698
+ ->where('es.store_id IN (?)', $store);
699
+ return $select;
700
+ }}
app/code/community/Joomi/MasonryGallery/Model/Resource/Category/Collection.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category collection resource model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Category_Collection
25
+ extends Mage_Core_Model_Resource_Db_Collection_Abstract {
26
+ protected $_joinedFields = array();
27
+ /**
28
+ * constructor
29
+ * @access public
30
+ * @return void
31
+ * @author Ultimate Module Creator
32
+ */
33
+ protected function _construct(){
34
+ parent::_construct();
35
+ $this->_init('joomi_masonrygallery/category');
36
+ $this->_map['fields']['store'] = 'store_table.store_id';
37
+ }
38
+ /**
39
+ * Add filter by store
40
+ * @access public
41
+ * @param int|Mage_Core_Model_Store $store
42
+ * @param bool $withAdmin
43
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function addStoreFilter($store, $withAdmin = true){
47
+ if (!isset($this->_joinedFields['store'])){
48
+ if ($store instanceof Mage_Core_Model_Store) {
49
+ $store = array($store->getId());
50
+ }
51
+ if (!is_array($store)) {
52
+ $store = array($store);
53
+ }
54
+ if ($withAdmin) {
55
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
56
+ }
57
+ $this->addFilter('store', array('in' => $store), 'public');
58
+ $this->_joinedFields['store'] = true;
59
+ }
60
+ return $this;
61
+ }
62
+ /**
63
+ * Join store relation table if there is store filter
64
+ * @access protected
65
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
66
+ * @author Ultimate Module Creator
67
+ */
68
+ protected function _renderFiltersBefore(){
69
+ if ($this->getFilter('store')) {
70
+ $this->getSelect()->join(
71
+ array('store_table' => $this->getTable('joomi_masonrygallery/category_store')),
72
+ 'main_table.entity_id = store_table.category_id',
73
+ array()
74
+ )->group('main_table.entity_id');
75
+ /*
76
+ * Allow analytic functions usage because of one field grouping
77
+ */
78
+ $this->_useAnalyticFunction = true;
79
+ }
80
+ return parent::_renderFiltersBefore();
81
+ }
82
+ /**
83
+ * Add Id filter
84
+ * @access public
85
+ * @param array $categoryIds
86
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
87
+ * @author Ultimate Module Creator
88
+ */
89
+ public function addIdFilter($categoryIds){
90
+ if (is_array($categoryIds)) {
91
+ if (empty($categoryIds)) {
92
+ $condition = '';
93
+ }
94
+ else {
95
+ $condition = array('in' => $categoryIds);
96
+ }
97
+ }
98
+ elseif (is_numeric($categoryIds)) {
99
+ $condition = $categoryIds;
100
+ }
101
+ elseif (is_string($categoryIds)) {
102
+ $ids = explode(',', $categoryIds);
103
+ if (empty($ids)) {
104
+ $condition = $categoryIds;
105
+ }
106
+ else {
107
+ $condition = array('in' => $ids);
108
+ }
109
+ }
110
+ $this->addFieldToFilter('entity_id', $condition);
111
+ return $this;
112
+ }
113
+ /**
114
+ * Add category path filter
115
+ * @access public
116
+ * @param string $regexp
117
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
118
+ * @author Ultimate Module Creator
119
+ */
120
+ public function addPathFilter($regexp){
121
+ $this->addFieldToFilter('path', array('regexp' => $regexp));
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Add category path filter
127
+ * @access public
128
+ * @param array|string $paths
129
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
130
+ * @author Ultimate Module Creator
131
+ */
132
+ public function addPathsFilter($paths){
133
+ if (!is_array($paths)) {
134
+ $paths = array($paths);
135
+ }
136
+ $write = $this->getResource()->getWriteConnection();
137
+ $cond = array();
138
+ foreach ($paths as $path) {
139
+ $cond[] = $write->quoteInto('e.path LIKE ?', "$path%");
140
+ }
141
+ if ($cond) {
142
+ $this->getSelect()->where(join(' OR ', $cond));
143
+ }
144
+ return $this;
145
+ }
146
+ /**
147
+ * Add category level filter
148
+ * @access public
149
+ * @param int|string $level
150
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
151
+ * @author Ultimate Module Creator
152
+ */
153
+ public function addLevelFilter($level){
154
+ $this->addFieldToFilter('level', array('lteq' => $level));
155
+ return $this;
156
+ }
157
+ /**
158
+ * Add root category filter
159
+ * @access public
160
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
161
+ */
162
+ public function addRootLevelFilter(){
163
+ $this->addFieldToFilter('path', array('neq' => '1'));
164
+ $this->addLevelFilter(1);
165
+ return $this;
166
+ }
167
+ /**
168
+ * Add order field
169
+ * @access public
170
+ * @param string $field
171
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
172
+ */
173
+ public function addOrderField($field){
174
+ $this->setOrder($field, self::SORT_ORDER_ASC);
175
+ return $this;
176
+ }
177
+ /**
178
+ * Add active category filter
179
+ * @access public
180
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
181
+ */
182
+ public function addStatusFilter($status = 1){
183
+ $this->addFieldToFilter('status', $status);
184
+ return $this;
185
+ }
186
+ /**
187
+ * get categories as array
188
+ * @access protected
189
+ * @param string $valueField
190
+ * @param string $labelField
191
+ * @param array $additional
192
+ * @return array
193
+ * @author Ultimate Module Creator
194
+ */
195
+ protected function _toOptionArray($valueField='entity_id', $labelField='title', $additional=array()){
196
+ $res = array();
197
+ $additional['value'] = $valueField;
198
+ $additional['label'] = $labelField;
199
+
200
+ foreach ($this as $item) {
201
+ if ($item->getId() == Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()){
202
+ continue;
203
+ }
204
+ foreach ($additional as $code => $field) {
205
+ $data[$code] = $item->getData($field);
206
+ }
207
+ $res[] = $data;
208
+ }
209
+ return $res;
210
+ }
211
+ /**
212
+ * get options hash
213
+ * @access protected
214
+ * @param string $valueField
215
+ * @param string $labelField
216
+ * @return array
217
+ * @author Ultimate Module Creator
218
+ */
219
+ protected function _toOptionHash($valueField='entity_id', $labelField='title'){
220
+ $res = array();
221
+ foreach ($this as $item) {
222
+ if ($item->getId() == Mage::helper('joomi_masonrygallery/category')->getRootCategoryId()){
223
+ continue;
224
+ }
225
+ $res[$item->getData($valueField)] = $item->getData($labelField);
226
+ }
227
+ return $res;
228
+ }
229
+ /**
230
+ * Get SQL for get record count.
231
+ * Extra GROUP BY strip added.
232
+ * @access public
233
+ * @return Varien_Db_Select
234
+ * @author Ultimate Module Creator
235
+ */
236
+ public function getSelectCountSql(){
237
+ $countSelect = parent::getSelectCountSql();
238
+ $countSelect->reset(Zend_Db_Select::GROUP);
239
+ return $countSelect;
240
+ }
241
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Category/Tree.php ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category tree resource model
19
+ * @category Joomi
20
+ * @package Joomi_MasonryGallery
21
+ * @author Ultimate Module Creator
22
+ */
23
+ class Joomi_MasonryGallery_Model_Resource_Category_Tree
24
+ extends Varien_Data_Tree_Dbp {
25
+ const ID_FIELD = 'entity_id';
26
+ const PATH_FIELD = 'path';
27
+ const ORDER_FIELD = 'order';
28
+ const LEVEL_FIELD = 'level';
29
+ /**
30
+ * Categories resource collection
31
+ * @var Joomi_MasonryGallery_Model_Resource_Category_Collection
32
+ */
33
+ protected $_collection;
34
+ protected $_storeId;
35
+ /**
36
+ * Inactive categories ids
37
+ * @var array
38
+ */
39
+ protected $_inactiveCategoryIds = null;
40
+ /**
41
+ * Initialize tree
42
+ * @access public
43
+ * @return void
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function __construct(){
47
+ $resource = Mage::getSingleton('core/resource');
48
+ parent::__construct(
49
+ $resource->getConnection('joomi_masonrygallery_write'),
50
+ $resource->getTableName('joomi_masonrygallery/category'),
51
+ array(
52
+ Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id',
53
+ Varien_Data_Tree_Dbp::PATH_FIELD => 'path',
54
+ Varien_Data_Tree_Dbp::ORDER_FIELD=> 'position',
55
+ Varien_Data_Tree_Dbp::LEVEL_FIELD=> 'level',
56
+ )
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Get categories collection
62
+ * @access public
63
+ * @param boolean $sorted
64
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
65
+ * @author Ultimate Module Creator
66
+ */
67
+ public function getCollection($sorted = false){
68
+ if (is_null($this->_collection)) {
69
+ $this->_collection = $this->_getDefaultCollection($sorted);
70
+ }
71
+ return $this->_collection;
72
+ }
73
+ /**
74
+ * set the collection
75
+ * @access public
76
+ * @param Joomi_MasonryGallery_Model_Resource_Category_Collection $collection
77
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
78
+ */
79
+ public function setCollection($collection){
80
+ if (!is_null($this->_collection)) {
81
+ destruct($this->_collection);
82
+ }
83
+ $this->_collection = $collection;
84
+ return $this;
85
+ }
86
+ /**
87
+ * get the default collection
88
+ * @access protected
89
+ * @param boolean $sorted
90
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Collection
91
+ */
92
+ protected function _getDefaultCollection($sorted = false){
93
+ $collection = Mage::getModel('joomi_masonrygallery/category')->getCollection();
94
+ if ($sorted) {
95
+ if (is_string($sorted)) {
96
+ $collection->setOrder($sorted);
97
+ }
98
+ else {
99
+ $collection->setOrder('title');
100
+ }
101
+ }
102
+ return $collection;
103
+ }
104
+ /**
105
+ * Executing parents move method and cleaning cache after it
106
+ * @access public
107
+ * @param unknown_type $category
108
+ * @param unknown_type $newParent
109
+ * @param unknown_type $prevNode
110
+ * @author Ultimate Module Creator
111
+ */
112
+ public function move($category, $newParent, $prevNode = null){
113
+ Mage::getResourceSingleton('joomi_masonrygallery/category')->move($category->getId(), $newParent->getId());
114
+ parent::move($category, $newParent, $prevNode);
115
+ $this->_afterMove($category, $newParent, $prevNode);
116
+ }
117
+
118
+ /**
119
+ * Move tree after
120
+ * @access protected
121
+ * @param unknown_type $category
122
+ * @param Varien_Data_Tree_Node $newParent
123
+ * @param Varien_Data_Tree_Node $prevNode
124
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
125
+ */
126
+ protected function _afterMove($category, $newParent, $prevNode){
127
+ Mage::app()->cleanCache(array(Joomi_MasonryGallery_Model_Category::CACHE_TAG));
128
+ return $this;
129
+ }
130
+ /**
131
+ * Load whole category tree, that will include specified categories ids.
132
+ * @access public
133
+ * @param array $ids
134
+ * @param bool $addCollectionData
135
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
136
+ * @author Ultimate Module Creator
137
+ */
138
+ public function loadByIds($ids, $addCollectionData = true){
139
+ $levelField = $this->_conn->quoteIdentifier('level');
140
+ $pathField = $this->_conn->quoteIdentifier('path');
141
+ // load first two levels, if no ids specified
142
+ if (empty($ids)) {
143
+ $select = $this->_conn->select()
144
+ ->from($this->_table, 'entity_id')
145
+ ->where($levelField . ' <= 2');
146
+ $ids = $this->_conn->fetchCol($select);
147
+ }
148
+ if (!is_array($ids)) {
149
+ $ids = array($ids);
150
+ }
151
+ foreach ($ids as $key => $id) {
152
+ $ids[$key] = (int)$id;
153
+ }
154
+ // collect paths of specified IDs and prepare to collect all their parents and neighbours
155
+ $select = $this->_conn->select()
156
+ ->from($this->_table, array('path', 'level'))
157
+ ->where('entity_id IN (?)', $ids);
158
+ $where = array($levelField . '=0' => true);
159
+
160
+ foreach ($this->_conn->fetchAll($select) as $item) {
161
+ $pathIds = explode('/', $item['path']);
162
+ $level = (int)$item['level'];
163
+ while ($level > 0) {
164
+ $pathIds[count($pathIds) - 1] = '%';
165
+ $path = implode('/', $pathIds);
166
+ $where["$levelField=$level AND $pathField LIKE '$path'"] = true;
167
+ array_pop($pathIds);
168
+ $level--;
169
+ }
170
+ }
171
+ $where = array_keys($where);
172
+
173
+ // get all required records
174
+ if ($addCollectionData) {
175
+ $select = $this->_createCollectionDataSelect();
176
+ }
177
+ else {
178
+ $select = clone $this->_select;
179
+ $select->order($this->_orderField . ' ' . Varien_Db_Select::SQL_ASC);
180
+ }
181
+ $select->where(implode(' OR ', $where));
182
+
183
+ // get array of records and add them as nodes to the tree
184
+ $arrNodes = $this->_conn->fetchAll($select);
185
+ if (!$arrNodes) {
186
+ return false;
187
+ }
188
+ $childrenItems = array();
189
+ foreach ($arrNodes as $key => $nodeInfo) {
190
+ $pathToParent = explode('/', $nodeInfo[$this->_pathField]);
191
+ array_pop($pathToParent);
192
+ $pathToParent = implode('/', $pathToParent);
193
+ $childrenItems[$pathToParent][] = $nodeInfo;
194
+ }
195
+ $this->addChildNodes($childrenItems, '', null);
196
+ return $this;
197
+ }
198
+ /**
199
+ * Load array of category parents
200
+ * @access public
201
+ * @param string $path
202
+ * @param bool $addCollectionData
203
+ * @param bool $withRootNode
204
+ * @return array
205
+ * @author Ultimate Module Creator
206
+ */
207
+ public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRootNode = false){
208
+ $pathIds = explode('/', $path);
209
+ if (!$withRootNode) {
210
+ array_shift($pathIds);
211
+ }
212
+ $result = array();
213
+ if (!empty($pathIds)) {
214
+ if ($addCollectionData) {
215
+ $select = $this->_createCollectionDataSelect(false);
216
+ }
217
+ else {
218
+ $select = clone $this->_select;
219
+ }
220
+ $select
221
+ ->where('main_table.entity_id IN(?)', $pathIds)
222
+ ->order($this->_conn->getLengthSql('main_table.path') . ' ' . Varien_Db_Select::SQL_ASC);
223
+ $result = $this->_conn->fetchAll($select);
224
+ }
225
+ return $result;
226
+ }
227
+ /**
228
+ * Obtain select for categories
229
+ * By default everything from entity table is selected
230
+ * + name
231
+ * @access public
232
+ * @param bool $sorted
233
+ * @param array $optionalAttributes
234
+ * @return Zend_Db_Select
235
+ * @author Ultimate Module Creator
236
+ */
237
+ protected function _createCollectionDataSelect($sorted = true){
238
+ $select = $this->_getDefaultCollection($sorted ? $this->_orderField : false)->getSelect();
239
+ $categoriesTable = Mage::getSingleton('core/resource')->getTableName('joomi_masonrygallery/category');
240
+ $subConcat = $this->_conn->getConcatSql(array('main_table.path', $this->_conn->quote('/%')));
241
+ $subSelect = $this->_conn->select()
242
+ ->from(array('see' => $categoriesTable), null)
243
+ ->where('see.entity_id = main_table.entity_id')
244
+ ->orWhere('see.path LIKE ?', $subConcat);
245
+ return $select;
246
+ } /**
247
+ * Get real existing category ids by specified ids
248
+ * @access public
249
+ * @param array $ids
250
+ * @return array
251
+ * @author Ultimate Module Creator
252
+ */
253
+ public function getExistingCategoryIdsBySpecifiedIds($ids){
254
+ if (empty($ids)) {
255
+ return array();
256
+ }
257
+ if (!is_array($ids)) {
258
+ $ids = array($ids);
259
+ }
260
+ $select = $this->_conn->select()
261
+ ->from($this->_table, array('entity_id'))
262
+ ->where('entity_id IN (?)', $ids);
263
+ return $this->_conn->fetchCol($select);
264
+ }
265
+ /**
266
+ * add collection data
267
+ * @access public
268
+ * @param Joomi_MasonryGallery_Model_Resource_Category_Collection $collection
269
+ * @param boolean $sorted
270
+ * @param array $exclude
271
+ * @param boolean $toLoad
272
+ * @param boolean $onlyActive
273
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
274
+ * @author Ultimate Module Creator
275
+ */
276
+ public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true, $onlyActive = false){
277
+ if (is_null($collection)) {
278
+ $collection = $this->getCollection($sorted);
279
+ } else {
280
+ $this->setCollection($collection);
281
+ }
282
+ if (!is_array($exclude)) {
283
+ $exclude = array($exclude);
284
+ }
285
+ $nodeIds = array();
286
+ foreach ($this->getNodes() as $node) {
287
+ if (!in_array($node->getId(), $exclude)) {
288
+ $nodeIds[] = $node->getId();
289
+ }
290
+ }
291
+ $collection->addIdFilter($nodeIds);
292
+ if ($onlyActive) {
293
+ $disabledIds = $this->_getDisabledIds($collection);
294
+ if ($disabledIds) {
295
+ $collection->addFieldToFilter('entity_id', array('nin' => $disabledIds));
296
+ }
297
+ $collection->addFieldToFilter('status', 1);
298
+ }
299
+ if ($toLoad) {
300
+ $collection->load();
301
+ foreach ($collection as $category) {
302
+ if ($this->getNodeById($category->getId())) {
303
+ $this->getNodeById($category->getId())->addData($category->getData());
304
+ }
305
+ }
306
+ foreach ($this->getNodes() as $node) {
307
+ if (!$collection->getItemById($node->getId()) && $node->getParent()) {
308
+ $this->removeNode($node);
309
+ }
310
+ }
311
+ }
312
+ return $this;
313
+ }
314
+ /**
315
+ * Add inactive categories ids
316
+ * @access public
317
+ * @param unknown_type $ids
318
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
319
+ * @author Ultimate Module Creator
320
+ */
321
+ public function addInactiveCategoryIds($ids){
322
+ if (!is_array($this->_inactiveCategoryIds)) {
323
+ $this->_initInactiveCategoryIds();
324
+ }
325
+ $this->_inactiveCategoryIds = array_merge($ids, $this->_inactiveCategoryIds);
326
+ return $this;
327
+ }
328
+ /**
329
+ * Retrieve inactive categories ids
330
+ * @access protected
331
+ * @return Joomi_MasonryGallery_Model_Resource_Category_Tree
332
+ * @author Ultimate Module Creator
333
+ */
334
+ protected function _initInactiveCategoryIds(){
335
+ $this->_inactiveCategoryIds = array();
336
+ return $this;
337
+ }
338
+ /**
339
+ * Retrieve inactive categories ids
340
+ * @access public
341
+ * @return array
342
+ * @author Ultimate Module Creator
343
+ */
344
+ public function getInactiveCategoryIds(){
345
+ if (!is_array($this->_inactiveCategoryIds)) {
346
+ $this->_initInactiveCategoryIds();
347
+ }
348
+ return $this->_inactiveCategoryIds;
349
+ }
350
+ /**
351
+ * Return disable category ids
352
+ * @access protected
353
+ * @param Joomi_MasonryGallery_Model_Resource_Category_Collection $collection
354
+ * @return array
355
+ * @author Ultimate Module Creator
356
+ */
357
+ protected function _getDisabledIds($collection){
358
+ $this->_inactiveItems = $this->getInactiveCategoryIds();
359
+ $this->_inactiveItems = array_merge(
360
+ $this->_getInactiveItemIds($collection),
361
+ $this->_inactiveItems
362
+ );
363
+ $allIds = $collection->getAllIds();
364
+ $disabledIds = array();
365
+
366
+ foreach ($allIds as $id) {
367
+ $parents = $this->getNodeById($id)->getPath();
368
+ foreach ($parents as $parent) {
369
+ if (!$this->_getItemIsActive($parent->getId())){
370
+ $disabledIds[] = $id;
371
+ continue;
372
+ }
373
+ }
374
+ }
375
+ return $disabledIds;
376
+ }
377
+ /**
378
+ * Retrieve inactive category item ids
379
+ * @access protecte
380
+ * @param Joomi_MasonryGallery_Model_Resource_Category_Collection $collection
381
+ * @return array
382
+ * @author Ultimate Module Creator
383
+ */
384
+ protected function _getInactiveItemIds($collection){
385
+ $filter = $collection->getAllIdsSql();
386
+ $table = Mage::getSingleton('core/resource')->getTable('joomi_masonrygallery/category');
387
+ $bind = array(
388
+ 'cond' => 0,
389
+ );
390
+ $select = $this->_conn->select()
391
+ ->from(array('d'=>$table), array('d.entity_id'))
392
+ ->where('d.entity_id IN (?)', new Zend_Db_Expr($filter))
393
+ ->where('status = :cond');
394
+ return $this->_conn->fetchCol($select, $bind);
395
+ }
396
+ /**
397
+ * Check is category items active
398
+ * @access protecte
399
+ * @param int $id
400
+ * @return boolean
401
+ * @author Ultimate Module Creator
402
+ */
403
+ protected function _getItemIsActive($id){
404
+ if (!in_array($id, $this->_inactiveItems)) {
405
+ return true;
406
+ }
407
+ return false;
408
+ }
409
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery resource model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Gallery
25
+ extends Mage_Core_Model_Resource_Db_Abstract {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @author Ultimate Module Creator
30
+ */
31
+ public function _construct(){
32
+ $this->_init('joomi_masonrygallery/gallery', 'entity_id');
33
+ }
34
+ /**
35
+ * Get store ids to which specified item is assigned
36
+ * @access public
37
+ * @param int $galleryId
38
+ * @return array
39
+ * @author Ultimate Module Creator
40
+ */
41
+ public function lookupStoreIds($galleryId){
42
+ $adapter = $this->_getReadAdapter();
43
+ $select = $adapter->select()
44
+ ->from($this->getTable('joomi_masonrygallery/gallery_store'), 'store_id')
45
+ ->where('gallery_id = ?',(int)$galleryId);
46
+ return $adapter->fetchCol($select);
47
+ }
48
+ /**
49
+ * Perform operations after object load
50
+ * @access public
51
+ * @param Mage_Core_Model_Abstract $object
52
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery
53
+ * @author Ultimate Module Creator
54
+ */
55
+ protected function _afterLoad(Mage_Core_Model_Abstract $object){
56
+ if ($object->getId()) {
57
+ $stores = $this->lookupStoreIds($object->getId());
58
+ $object->setData('store_id', $stores);
59
+ }
60
+ return parent::_afterLoad($object);
61
+ }
62
+
63
+ /**
64
+ * Retrieve select object for load object data
65
+ *
66
+ * @param string $field
67
+ * @param mixed $value
68
+ * @param Joomi_MasonryGallery_Model_Gallery $object
69
+ * @return Zend_Db_Select
70
+ */
71
+ protected function _getLoadSelect($field, $value, $object){
72
+ $select = parent::_getLoadSelect($field, $value, $object);
73
+ if ($object->getStoreId()) {
74
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
75
+ $select->join(
76
+ array('masonrygallery_gallery_store' => $this->getTable('joomi_masonrygallery/gallery_store')),
77
+ $this->getMainTable() . '.entity_id = masonrygallery_gallery_store.gallery_id',
78
+ array()
79
+ )
80
+ ->where('masonrygallery_gallery_store.store_id IN (?)', $storeIds)
81
+ ->order('masonrygallery_gallery_store.store_id DESC')
82
+ ->limit(1);
83
+ }
84
+ return $select;
85
+ }
86
+ /**
87
+ * Assign gallery to store views
88
+ * @access protected
89
+ * @param Mage_Core_Model_Abstract $object
90
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery
91
+ * @author Ultimate Module Creator
92
+ */
93
+ protected function _afterSave(Mage_Core_Model_Abstract $object){
94
+ $oldStores = $this->lookupStoreIds($object->getId());
95
+ $newStores = (array)$object->getStores();
96
+ if (empty($newStores)) {
97
+ $newStores = (array)$object->getStoreId();
98
+ }
99
+ $table = $this->getTable('joomi_masonrygallery/gallery_store');
100
+ $insert = array_diff($newStores, $oldStores);
101
+ $delete = array_diff($oldStores, $newStores);
102
+ if ($delete) {
103
+ $where = array(
104
+ 'gallery_id = ?' => (int) $object->getId(),
105
+ 'store_id IN (?)' => $delete
106
+ );
107
+ $this->_getWriteAdapter()->delete($table, $where);
108
+ }
109
+ if ($insert) {
110
+ $data = array();
111
+ foreach ($insert as $storeId) {
112
+ $data[] = array(
113
+ 'gallery_id' => (int) $object->getId(),
114
+ 'store_id' => (int) $storeId
115
+ );
116
+ }
117
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
118
+ }
119
+ return parent::_afterSave($object);
120
+ } /**
121
+ * check url key
122
+ * @access public
123
+ * @param string $urlKey
124
+ * @param int $storeId
125
+ * @param bool $active
126
+ * @return mixed
127
+ * @author Ultimate Module Creator
128
+ */
129
+ public function checkUrlKey($urlKey, $storeId, $active = true){
130
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId);
131
+ $select = $this->_initCheckUrlKeySelect($urlKey, $stores);
132
+ if ($active) {
133
+ $select->where('e.status = ?', $active);
134
+ }
135
+ $select->reset(Zend_Db_Select::COLUMNS)
136
+ ->columns('e.entity_id')
137
+ ->limit(1);
138
+
139
+ return $this->_getReadAdapter()->fetchOne($select);
140
+ }
141
+
142
+ /**
143
+ * Check for unique URL key
144
+ * @access public
145
+ * @param Mage_Core_Model_Abstract $object
146
+ * @return bool
147
+ * @author Ultimate Module Creator
148
+ */
149
+ public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object){
150
+ if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) {
151
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
152
+ }
153
+ else {
154
+ $stores = (array)$object->getData('stores');
155
+ }
156
+ $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores);
157
+ if ($object->getId()) {
158
+ $select->where('e.entity_id <> ?', $object->getId());
159
+ }
160
+ if ($this->_getWriteAdapter()->fetchRow($select)) {
161
+ return false;
162
+ }
163
+ return true;
164
+ }
165
+ /**
166
+ * Check if the URL key is numeric
167
+ * @access public
168
+ * @param Mage_Core_Model_Abstract $object
169
+ * @return bool
170
+ * @author Ultimate Module Creator
171
+ */
172
+ protected function isNumericUrlKey(Mage_Core_Model_Abstract $object){
173
+ return preg_match('/^[0-9]+$/', $object->getData('url_key'));
174
+ }
175
+ /**
176
+ * Checkif the URL key is valid
177
+ * @access public
178
+ * @param Mage_Core_Model_Abstract $object
179
+ * @return bool
180
+ * @author Ultimate Module Creator
181
+ */
182
+ protected function isValidUrlKey(Mage_Core_Model_Abstract $object){
183
+ return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key'));
184
+ }
185
+ /**
186
+ * format string as url key
187
+ * @access public
188
+ * @param string $str
189
+ * @return string
190
+ * @author Ultimate Module Creator
191
+ */
192
+ public function formatUrlKey($str) {
193
+ $urlKey = preg_replace('#[^0-9a-z]+#i', '-', Mage::helper('catalog/product_url')->format($str));
194
+ $urlKey = strtolower($urlKey);
195
+ $urlKey = trim($urlKey, '-');
196
+ return $urlKey;
197
+ }
198
+ /**
199
+ * init the check select
200
+ * @access protected
201
+ * @param string $urlKey
202
+ * @param array $store
203
+ * @return Zend_Db_Select
204
+ * @author Ultimate Module Creator
205
+ */
206
+ protected function _initCheckUrlKeySelect($urlKey, $store){
207
+ $select = $this->_getReadAdapter()->select()
208
+ ->from(array('e' => $this->getMainTable()))
209
+ ->join(
210
+ array('es' => $this->getTable('joomi_masonrygallery/gallery_store')),
211
+ 'e.entity_id = es.gallery_id',
212
+ array())
213
+ ->where('e.url_key = ?', $urlKey)
214
+ ->where('es.store_id IN (?)', $store);
215
+ return $select;
216
+ } /**
217
+ * validate before saving
218
+ * @access protected
219
+ * @param $object
220
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery
221
+ * @author Ultimate Module Creator
222
+ */
223
+ protected function _beforeSave(Mage_Core_Model_Abstract $object){
224
+ $urlKey = $object->getData('url_key');
225
+ if ($urlKey == '') {
226
+ $urlKey = $object->getTitle();
227
+ }
228
+ $urlKey = $this->formatUrlKey($urlKey);
229
+ $validKey = false;
230
+ while (!$validKey) {
231
+ $entityId = $this->checkUrlKey($urlKey, $object->getStoreId(), false);
232
+ if ($entityId == $object->getId() || empty($entityId)) {
233
+ $validKey = true;
234
+ }
235
+ else {
236
+ $parts = explode('-', $urlKey);
237
+ $last = $parts[count($parts) - 1];
238
+ if (!is_numeric($last)){
239
+ $urlKey = $urlKey.'-1';
240
+ }
241
+ else {
242
+ $suffix = '-'.($last + 1);
243
+ unset($parts[count($parts) - 1]);
244
+ $urlKey = implode('-', $parts).$suffix;
245
+ }
246
+ }
247
+ }
248
+ $object->setData('url_key', $urlKey);
249
+ return parent::_beforeSave($object);
250
+ }
251
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery/Collection.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery collection resource model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Gallery_Collection
25
+ extends Mage_Core_Model_Resource_Db_Collection_Abstract {
26
+ protected $_joinedFields = array();
27
+ /**
28
+ * constructor
29
+ * @access public
30
+ * @return void
31
+ * @author Ultimate Module Creator
32
+ */
33
+ protected function _construct(){
34
+ parent::_construct();
35
+ $this->_init('joomi_masonrygallery/gallery');
36
+ $this->_map['fields']['store'] = 'store_table.store_id';
37
+ }
38
+ /**
39
+ * Add filter by store
40
+ * @access public
41
+ * @param int|Mage_Core_Model_Store $store
42
+ * @param bool $withAdmin
43
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Collection
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function addStoreFilter($store, $withAdmin = true){
47
+ if (!isset($this->_joinedFields['store'])){
48
+ if ($store instanceof Mage_Core_Model_Store) {
49
+ $store = array($store->getId());
50
+ }
51
+ if (!is_array($store)) {
52
+ $store = array($store);
53
+ }
54
+ if ($withAdmin) {
55
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
56
+ }
57
+ $this->addFilter('store', array('in' => $store), 'public');
58
+ $this->_joinedFields['store'] = true;
59
+ }
60
+ return $this;
61
+ }
62
+ /**
63
+ * Join store relation table if there is store filter
64
+ * @access protected
65
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Collection
66
+ * @author Ultimate Module Creator
67
+ */
68
+ protected function _renderFiltersBefore(){
69
+ if ($this->getFilter('store')) {
70
+ $this->getSelect()->join(
71
+ array('store_table' => $this->getTable('joomi_masonrygallery/gallery_store')),
72
+ 'main_table.entity_id = store_table.gallery_id',
73
+ array()
74
+ )->group('main_table.entity_id');
75
+ /*
76
+ * Allow analytic functions usage because of one field grouping
77
+ */
78
+ $this->_useAnalyticFunction = true;
79
+ }
80
+ return parent::_renderFiltersBefore();
81
+ }
82
+ /**
83
+ * get galleries as array
84
+ * @access protected
85
+ * @param string $valueField
86
+ * @param string $labelField
87
+ * @param array $additional
88
+ * @return array
89
+ * @author Ultimate Module Creator
90
+ */
91
+ protected function _toOptionArray($valueField='entity_id', $labelField='title', $additional=array()){
92
+ return parent::_toOptionArray($valueField, $labelField, $additional);
93
+ }
94
+ /**
95
+ * get options hash
96
+ * @access protected
97
+ * @param string $valueField
98
+ * @param string $labelField
99
+ * @return array
100
+ * @author Ultimate Module Creator
101
+ */
102
+ protected function _toOptionHash($valueField='entity_id', $labelField='title'){
103
+ return parent::_toOptionHash($valueField, $labelField);
104
+ }
105
+ /**
106
+ * add the product filter to collection
107
+ * @access public
108
+ * @param mixed (Mage_Catalog_Model_Product|int) $product
109
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Collection
110
+ * @author Ultimate Module Creator
111
+ */
112
+ public function addProductFilter($product){
113
+ if ($product instanceof Mage_Catalog_Model_Product){
114
+ $product = $product->getId();
115
+ }
116
+ if (!isset($this->_joinedFields['product'])){
117
+ $this->getSelect()->join(
118
+ array('related_product' => $this->getTable('joomi_masonrygallery/gallery_product')),
119
+ 'related_product.gallery_id = main_table.entity_id',
120
+ array('position')
121
+ );
122
+ $this->getSelect()->where('related_product.product_id = ?', $product);
123
+ $this->_joinedFields['product'] = true;
124
+ }
125
+ return $this;
126
+ }
127
+ /**
128
+ * Get SQL for get record count.
129
+ * Extra GROUP BY strip added.
130
+ * @access public
131
+ * @return Varien_Db_Select
132
+ * @author Ultimate Module Creator
133
+ */
134
+ public function getSelectCountSql(){
135
+ $countSelect = parent::getSelectCountSql();
136
+ $countSelect->reset(Zend_Db_Select::GROUP);
137
+ return $countSelect;
138
+ }
139
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery/Product.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery - product relation model
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Gallery_Product
25
+ extends Mage_Core_Model_Resource_Db_Abstract {
26
+ /**
27
+ * initialize resource model
28
+ * @access protected
29
+ * @see Mage_Core_Model_Resource_Abstract::_construct()
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _construct(){
33
+ $this->_init('joomi_masonrygallery/gallery_product', 'rel_id');
34
+ }
35
+ /**
36
+ * Save gallery - product relations
37
+ * @access public
38
+ * @param Joomi_MasonryGallery_Model_Gallery $gallery
39
+ * @param array $data
40
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Product
41
+ * @author Ultimate Module Creator
42
+ */
43
+ public function saveGalleryRelation($gallery, $data){
44
+ if (!is_array($data)) {
45
+ $data = array();
46
+ }
47
+ $deleteCondition = $this->_getWriteAdapter()->quoteInto('gallery_id=?', $gallery->getId());
48
+ $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
49
+
50
+ foreach ($data as $productId => $info) {
51
+ $this->_getWriteAdapter()->insert($this->getMainTable(), array(
52
+ 'gallery_id' => $gallery->getId(),
53
+ 'product_id' => $productId,
54
+ 'position' => @$info['position']
55
+ ));
56
+ }
57
+ return $this;
58
+ }
59
+ /**
60
+ * Save product - gallery relations
61
+ * @access public
62
+ * @param Mage_Catalog_Model_Product $prooduct
63
+ * @param array $data
64
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Product
65
+ * @@author Ultimate Module Creator
66
+ */
67
+ public function saveProductRelation($product, $data){
68
+ if (!is_array($data)) {
69
+ $data = array();
70
+ }
71
+ $deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId());
72
+ $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
73
+
74
+ foreach ($data as $galleryId => $info) {
75
+ $this->_getWriteAdapter()->insert($this->getMainTable(), array(
76
+ 'gallery_id' => $galleryId,
77
+ 'product_id' => $product->getId(),
78
+ 'position' => @$info['position']
79
+ ));
80
+ }
81
+ return $this;
82
+ }
83
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Gallery/Product/Collection.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery - product relation resource model collection
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Gallery_Product_Collection
25
+ extends Mage_Catalog_Model_Resource_Product_Collection {
26
+ /**
27
+ * remember if fields have been joined
28
+ * @var bool
29
+ */
30
+ protected $_joinedFields = false;
31
+ /**
32
+ * join the link table
33
+ * @access public
34
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Product_Collection
35
+ * @author Ultimate Module Creator
36
+ */
37
+ public function joinFields(){
38
+ if (!$this->_joinedFields){
39
+ $this->getSelect()->join(
40
+ array('related' => $this->getTable('joomi_masonrygallery/gallery_product')),
41
+ 'related.product_id = e.entity_id',
42
+ array('position')
43
+ );
44
+ $this->_joinedFields = true;
45
+ }
46
+ return $this;
47
+ }
48
+ /**
49
+ * add gallery filter
50
+ * @access public
51
+ * @param Joomi_MasonryGallery_Model_Gallery | int $gallery
52
+ * @return Joomi_MasonryGallery_Model_Resource_Gallery_Product_Collection
53
+ * @author Ultimate Module Creator
54
+ */
55
+ public function addGalleryFilter($gallery){
56
+ if ($gallery instanceof Joomi_MasonryGallery_Model_Gallery){
57
+ $gallery = $gallery->getId();
58
+ }
59
+ if (!$this->_joinedFields){
60
+ $this->joinFields();
61
+ }
62
+ $this->getSelect()->where('related.gallery_id = ?', $gallery);
63
+ return $this;
64
+ }
65
+ }
app/code/community/Joomi/MasonryGallery/Model/Resource/Setup.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MasonryGallery setup
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Model_Resource_Setup
25
+ extends Mage_Catalog_Model_Resource_Setup {
26
+ }
app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/Category/WidgetController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin widget controller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Adminhtml_Masonrygallery_Category_WidgetController
25
+ extends Mage_Adminhtml_Controller_Action {
26
+ /**
27
+ * Chooser Source action
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function chooserAction(){
33
+ $uniqId = $this->getRequest()->getParam('uniq_id');
34
+ $grid = $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_widget_chooser', '', array(
35
+ 'id' => $uniqId,
36
+ ));
37
+ $this->getResponse()->setBody($grid->toHtml());
38
+ }
39
+ /**
40
+ * categories json action
41
+ * @access public
42
+ * @return void
43
+ * @author Ultimate Module Creator
44
+ */
45
+ public function categoriesJsonAction(){
46
+ if ($categoryId = (int) $this->getRequest()->getPost('id')) {
47
+ $category = Mage::getModel('joomi_masonrygallery/category')->load($categoryId);
48
+ if ($category->getId()) {
49
+ Mage::register('category', $category);
50
+ Mage::register('current_category', $category);
51
+ }
52
+ $this->getResponse()->setBody(
53
+ $this->_getCategoryTreeBlock()->getTreeJson($category)
54
+ );
55
+ }
56
+ }
57
+ /**
58
+ * get category tree block
59
+ * @access protected
60
+ * @return Joomi_MasonryGallery_Block_Adminhtml_Category_Widget_Chooser
61
+ * @author Ultimate Module Creator
62
+ */
63
+ protected function _getCategoryTreeBlock(){
64
+ return $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_widget_chooser', '', array(
65
+ 'id' => $this->getRequest()->getParam('uniq_id'),
66
+ 'use_massaction' => $this->getRequest()->getParam('use_massaction', false)
67
+ ));
68
+ }
69
+ }
app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/CategoryController.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category admin controller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Adminhtml_Masonrygallery_CategoryController
25
+ extends Joomi_MasonryGallery_Controller_Adminhtml_MasonryGallery {
26
+ /**
27
+ * init category
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Model_Category
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _initCategory(){
33
+ $categoryId = (int) $this->getRequest()->getParam('id',false);
34
+ $category = Mage::getModel('joomi_masonrygallery/category');
35
+ if ($categoryId) {
36
+ $category->load($categoryId);
37
+ }
38
+ else {
39
+ $category->setData($category->getDefaultValues());
40
+ }
41
+ if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) {
42
+ Mage::getSingleton('admin/session')->setCategoryActiveTabId($activeTabId);
43
+ }
44
+ Mage::register('category', $category);
45
+ Mage::register('current_category', $category);
46
+ return $category;
47
+ }
48
+ /**
49
+ * default action
50
+ * @access public
51
+ * @return void
52
+ * @author Ultimate Module Creator
53
+ */
54
+ public function indexAction(){
55
+ $this->_forward('edit');
56
+ }
57
+
58
+ /**
59
+ * Add new category form
60
+ * @access public
61
+ * @return void
62
+ * @author Ultimate Module Creator
63
+ */
64
+ public function addAction(){
65
+ Mage::getSingleton('admin/session')->unsCategoryActiveTabId();
66
+ $this->_forward('edit');
67
+ }
68
+ /**
69
+ * Edit category page
70
+ * @access public
71
+ * @return void
72
+ * @author Ultimate Module Creator
73
+ */
74
+ public function editAction(){
75
+ $params['_current'] = true;
76
+ $redirect = false;
77
+ $parentId = (int) $this->getRequest()->getParam('parent');
78
+ $categoryId = (int) $this->getRequest()->getParam('id');
79
+ $_prevCategoryId = Mage::getSingleton('admin/session')->getLastEditedCategory(true);
80
+ if ($_prevCategoryId && !$this->getRequest()->getQuery('isAjax') && !$this->getRequest()->getParam('clear')) {
81
+ $this->getRequest()->setParam('id',$_prevCategoryId);
82
+ }
83
+ if ($redirect) {
84
+ $this->_redirect('*/*/edit', $params);
85
+ return;
86
+ }
87
+ if (!($category = $this->_initCategory())) {
88
+ return;
89
+ }
90
+ $this->_title($categoryId ? $category->getTitle() : $this->__('New Category'));
91
+ $data = Mage::getSingleton('adminhtml/session')->getCategoryData(true);
92
+ if (isset($data['category'])) {
93
+ $category->addData($data['category']);
94
+ }
95
+ if ($this->getRequest()->getQuery('isAjax')) {
96
+ $breadcrumbsPath = $category->getPath();
97
+ if (empty($breadcrumbsPath)) {
98
+ $breadcrumbsPath = Mage::getSingleton('admin/session')->getCategoryDeletedPath(true);
99
+ if (!empty($breadcrumbsPath)) {
100
+ $breadcrumbsPath = explode('/', $breadcrumbsPath);
101
+ if (count($breadcrumbsPath) <= 1) {
102
+ $breadcrumbsPath = '';
103
+ }
104
+ else {
105
+ array_pop($breadcrumbsPath);
106
+ $breadcrumbsPath = implode('/', $breadcrumbsPath);
107
+ }
108
+ }
109
+ }
110
+ Mage::getSingleton('admin/session')->setLastEditedCategory($category->getId());
111
+ $this->loadLayout();
112
+ $eventResponse = new Varien_Object(array(
113
+ 'content' => $this->getLayout()->getBlock('category.edit')->getFormHtml(). $this->getLayout()->getBlock('category.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'),
114
+ 'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(),
115
+ ));
116
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($eventResponse->getData()));
117
+ return;
118
+ }
119
+ $this->loadLayout();
120
+ $this->_title(Mage::helper('joomi_masonrygallery')->__('Masonry Gallery'))
121
+ ->_title(Mage::helper('joomi_masonrygallery')->__('Categories'));
122
+ $this->_setActiveMenu('joomi_masonrygallery/category');
123
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
124
+ ->setContainerCssClass('category');
125
+
126
+ $this->_addBreadcrumb(
127
+ Mage::helper('joomi_masonrygallery')->__('Manage Categories'),
128
+ Mage::helper('joomi_masonrygallery')->__('Manage Categories')
129
+ );
130
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
131
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
132
+ }
133
+ $this->renderLayout();
134
+ }
135
+ /**
136
+ * Get tree node (Ajax version)
137
+ * @access public
138
+ * @return void
139
+ * @author Ultimate Module Creator
140
+ */
141
+ public function categoriesJsonAction(){
142
+ if ($this->getRequest()->getParam('expand_all')) {
143
+ Mage::getSingleton('admin/session')->setCategoryIsTreeWasExpanded(true);
144
+ }
145
+ else {
146
+ Mage::getSingleton('admin/session')->setCategoryIsTreeWasExpanded(false);
147
+ }
148
+ if ($categoryId = (int) $this->getRequest()->getPost('id')) {
149
+ $this->getRequest()->setParam('id', $categoryId);
150
+ if (!$category = $this->_initCategory()) {
151
+ return;
152
+ }
153
+ $this->getResponse()->setBody(
154
+ $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_tree')->getTreeJson($category)
155
+ );
156
+ }
157
+ }
158
+ /**
159
+ * Move category action
160
+ */
161
+ public function moveAction(){
162
+ $category = $this->_initCategory();
163
+ if (!$category) {
164
+ $this->getResponse()->setBody(Mage::helper('joomi_masonrygallery')->__('Category move error'));
165
+ return;
166
+ }
167
+ $parentNodeId = $this->getRequest()->getPost('pid', false);
168
+ $prevNodeId = $this->getRequest()->getPost('aid', false);
169
+ try {
170
+ $category->move($parentNodeId, $prevNodeId);
171
+ $this->getResponse()->setBody("SUCCESS");
172
+ }
173
+ catch (Mage_Core_Exception $e) {
174
+ $this->getResponse()->setBody($e->getMessage());
175
+ }
176
+ catch (Exception $e){
177
+ $this->getResponse()->setBody(Mage::helper('joomi_masonrygallery')->__('Category move error'));
178
+ Mage::logException($e);
179
+ }
180
+ }
181
+ /**
182
+ * Tree Action
183
+ * Retrieve category tree
184
+ * @access public
185
+ * @return void
186
+ * @author Ultimate Module Creator
187
+ */
188
+ public function treeAction(){
189
+ $categoryId = (int) $this->getRequest()->getParam('id');
190
+ $category = $this->_initCategory();
191
+ $block = $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_category_tree');
192
+ $root = $block->getRoot();
193
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(
194
+ array(
195
+ 'data' => $block->getTree(),
196
+ 'parameters' => array(
197
+ 'text'=> $block->buildNodeName($root),
198
+ 'draggable' => false,
199
+ 'allowDrop' => ($root->getIsVisible()) ? true : false,
200
+ 'id' => (int) $root->getId(),
201
+ 'expanded'=> (int) $block->getIsWasExpanded(),
202
+ 'category_id' => (int) $category->getId(),
203
+ 'root_visible'=> (int) $root->getIsVisible()
204
+ )
205
+ )
206
+ ));
207
+ }
208
+ /**
209
+ * Build response for refresh input element 'path' in form
210
+ * @access public
211
+ * @return void
212
+ * @author Ultimate Module Creator
213
+ */
214
+ public function refreshPathAction(){
215
+ if ($id = (int) $this->getRequest()->getParam('id')) {
216
+ $category = Mage::getModel('joomi_masonrygallery/category')->load($id);
217
+ $this->getResponse()->setBody(
218
+ Mage::helper('core')->jsonEncode(array(
219
+ 'id' => $id,
220
+ 'path' => $category->getPath(),
221
+ ))
222
+ );
223
+ }
224
+ }
225
+ /**
226
+ * Delete category action
227
+ * @access public
228
+ * @return void
229
+ * @author Ultimate Module Creator
230
+ */
231
+ public function deleteAction(){
232
+ if ($id = (int) $this->getRequest()->getParam('id')) {
233
+ try {
234
+ $category = Mage::getModel('joomi_masonrygallery/category')->load($id);
235
+ Mage::getSingleton('admin/session')->setCategoryDeletedPath($category->getPath());
236
+
237
+ $category->delete();
238
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('joomi_masonrygallery')->__('The category has been deleted.'));
239
+ }
240
+ catch (Mage_Core_Exception $e){
241
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
242
+ $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
243
+ return;
244
+ }
245
+ catch (Exception $e){
246
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('An error occurred while trying to delete the category.'));
247
+ $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
248
+ Mage::logException($e);
249
+ return;
250
+ }
251
+ }
252
+ $this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current'=>true, 'id'=>null)));
253
+ }
254
+ /**
255
+ * Check if admin has permissions to visit related pages
256
+ * @access protected
257
+ * @return boolean
258
+ * @author Ultimate Module Creator
259
+ */
260
+ protected function _isAllowed(){
261
+ return Mage::getSingleton('admin/session')->isAllowed('joomi_masonrygallery/category');
262
+ } /**
263
+ * wyisiwyg action
264
+ * @access public
265
+ * @return void
266
+ * @author Ultimate Module Creator
267
+ */
268
+ public function wysiwygAction(){
269
+ $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
270
+ $storeMediaUrl = Mage::app()->getStore(0)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
271
+
272
+ $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
273
+ 'editor_element_id' => $elementId,
274
+ 'store_id' => 0,
275
+ 'store_media_url' => $storeMediaUrl,
276
+ ));
277
+ $this->getResponse()->setBody($content->toHtml());
278
+ }
279
+ /**
280
+ * Category save action
281
+ * @access public
282
+ * @return void
283
+ * @author Ultimate Module Creator
284
+ */
285
+ public function saveAction(){
286
+ if (!$category = $this->_initCategory()) {
287
+ return;
288
+ }
289
+ $refreshTree = 'false';
290
+ if ($data = $this->getRequest()->getPost('category')) {
291
+ $category->addData($data);
292
+ if (!$category->getId()) {
293
+ $parentId = $this->getRequest()->getParam('parent');
294
+ if (!$parentId) {
295
+ $parentId = Mage::helper('joomi_masonrygallery/category')->getRootCategoryId();
296
+ }
297
+ $parentCategory = Mage::getModel('joomi_masonrygallery/category')->load($parentId);
298
+ $category->setPath($parentCategory->getPath());
299
+ }
300
+ try {
301
+ $category->save();
302
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('joomi_masonrygallery')->__('The category has been saved.'));
303
+ $refreshTree = 'true';
304
+ }
305
+ catch (Exception $e){
306
+ $this->_getSession()->addError($e->getMessage())->setCategoryData($data);
307
+ Mage::logException($e);
308
+ $refreshTree = 'false';
309
+ }
310
+ }
311
+ $url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => $category->getId()));
312
+ $this->getResponse()->setBody(
313
+ '<script type="text/javascript">parent.updateContent("' . $url . '", {}, '.$refreshTree.');</script>'
314
+ );
315
+ }
316
+ }
app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/Gallery/Catalog/ProductController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery - product controller
19
+ * @category Joomi
20
+ * @package Joomi_MasonryGallery
21
+ * @author Ultimate Module Creator
22
+ */
23
+ require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
24
+ class Joomi_MasonryGallery_Adminhtml_Masonrygallery_Gallery_Catalog_ProductController
25
+ extends Mage_Adminhtml_Catalog_ProductController {
26
+ /**
27
+ * construct
28
+ * @access protected
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ protected function _construct(){
33
+ // Define module dependent translate
34
+ $this->setUsedModuleName('Joomi_MasonryGallery');
35
+ }
36
+ /**
37
+ * galleries in the catalog page
38
+ * @access public
39
+ * @return void
40
+ * @author Ultimate Module Creator
41
+ */
42
+ public function galleriesAction(){
43
+ $this->_initProduct();
44
+ $this->loadLayout();
45
+ $this->getLayout()->getBlock('product.edit.tab.gallery')
46
+ ->setProductGalleries($this->getRequest()->getPost('product_galleries', null));
47
+ $this->renderLayout();
48
+ }
49
+ /**
50
+ * galleries grid in the catalog page
51
+ * @access public
52
+ * @return void
53
+ * @author Ultimate Module Creator
54
+ */
55
+ public function galleriesGridAction(){
56
+ $this->_initProduct();
57
+ $this->loadLayout();
58
+ $this->getLayout()->getBlock('product.edit.tab.gallery')
59
+ ->setProductGalleries($this->getRequest()->getPost('product_galleries', null));
60
+ $this->renderLayout();
61
+ }
62
+ }
app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/Gallery/WidgetController.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin widget controller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Adminhtml_Masonrygallery_Gallery_WidgetController
25
+ extends Mage_Adminhtml_Controller_Action {
26
+ /**
27
+ * Chooser Source action
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function chooserAction(){
33
+ $uniqId = $this->getRequest()->getParam('uniq_id');
34
+ $grid = $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_widget_chooser', '', array(
35
+ 'id' => $uniqId,
36
+ ));
37
+ $this->getResponse()->setBody($grid->toHtml());
38
+ }
39
+ }
app/code/community/Joomi/MasonryGallery/controllers/Adminhtml/Masonrygallery/GalleryController.php ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery admin controller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_Adminhtml_Masonrygallery_GalleryController
25
+ extends Joomi_MasonryGallery_Controller_Adminhtml_MasonryGallery {
26
+ /**
27
+ * init the gallery
28
+ * @access protected
29
+ * @return Joomi_MasonryGallery_Model_Gallery
30
+ */
31
+ protected function _initGallery(){
32
+ $galleryId = (int) $this->getRequest()->getParam('id');
33
+ $gallery = Mage::getModel('joomi_masonrygallery/gallery');
34
+ if ($galleryId) {
35
+ $gallery->load($galleryId);
36
+ }
37
+ Mage::register('current_gallery', $gallery);
38
+ return $gallery;
39
+ }
40
+ /**
41
+ * default action
42
+ * @access public
43
+ * @return void
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function indexAction() {
47
+ $this->loadLayout();
48
+ $this->_title(Mage::helper('joomi_masonrygallery')->__('Masonry Gallery'))
49
+ ->_title(Mage::helper('joomi_masonrygallery')->__('Galleries'));
50
+ $this->renderLayout();
51
+ }
52
+ /**
53
+ * grid action
54
+ * @access public
55
+ * @return void
56
+ * @author Ultimate Module Creator
57
+ */
58
+ public function gridAction() {
59
+ $this->loadLayout()->renderLayout();
60
+ }
61
+ /**
62
+ * edit gallery - action
63
+ * @access public
64
+ * @return void
65
+ * @author Ultimate Module Creator
66
+ */
67
+ public function editAction() {
68
+ $galleryId = $this->getRequest()->getParam('id');
69
+ $gallery = $this->_initGallery();
70
+ if ($galleryId && !$gallery->getId()) {
71
+ $this->_getSession()->addError(Mage::helper('joomi_masonrygallery')->__('This gallery no longer exists.'));
72
+ $this->_redirect('*/*/');
73
+ return;
74
+ }
75
+ $data = Mage::getSingleton('adminhtml/session')->getGalleryData(true);
76
+ if (!empty($data)) {
77
+ $gallery->setData($data);
78
+ }
79
+ Mage::register('gallery_data', $gallery);
80
+ $this->loadLayout();
81
+ $this->_title(Mage::helper('joomi_masonrygallery')->__('Masonry Gallery'))
82
+ ->_title(Mage::helper('joomi_masonrygallery')->__('Galleries'));
83
+ if ($gallery->getId()){
84
+ $this->_title($gallery->getTitle());
85
+ }
86
+ else{
87
+ $this->_title(Mage::helper('joomi_masonrygallery')->__('Add gallery'));
88
+ }
89
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
90
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
91
+ }
92
+ $this->renderLayout();
93
+ }
94
+ /**
95
+ * new gallery action
96
+ * @access public
97
+ * @return void
98
+ * @author Ultimate Module Creator
99
+ */
100
+ public function newAction() {
101
+ $this->_forward('edit');
102
+ }
103
+ /**
104
+ * save gallery - action
105
+ * @access public
106
+ * @return void
107
+ * @author Ultimate Module Creator
108
+ */
109
+ public function saveAction() {
110
+ if ($data = $this->getRequest()->getPost('gallery')) {
111
+ try {
112
+ $gallery = $this->_initGallery();
113
+ $gallery->addData($data);
114
+ $products = $this->getRequest()->getPost('products', -1);
115
+ if ($products != -1) {
116
+ $gallery->setProductsData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($products));
117
+ }
118
+ $gallery->save();
119
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('joomi_masonrygallery')->__('Gallery was successfully saved'));
120
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
121
+ if ($this->getRequest()->getParam('back')) {
122
+ $this->_redirect('*/*/edit', array('id' => $gallery->getId()));
123
+ return;
124
+ }
125
+ $this->_redirect('*/*/');
126
+ return;
127
+ }
128
+ catch (Mage_Core_Exception $e){
129
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
130
+ Mage::getSingleton('adminhtml/session')->setGalleryData($data);
131
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
132
+ return;
133
+ }
134
+ catch (Exception $e) {
135
+ Mage::logException($e);
136
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was a problem saving the gallery.'));
137
+ Mage::getSingleton('adminhtml/session')->setGalleryData($data);
138
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
139
+ return;
140
+ }
141
+ }
142
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Unable to find gallery to save.'));
143
+ $this->_redirect('*/*/');
144
+ }
145
+ /**
146
+ * delete gallery - action
147
+ * @access public
148
+ * @return void
149
+ * @author Ultimate Module Creator
150
+ */
151
+ public function deleteAction() {
152
+ if( $this->getRequest()->getParam('id') > 0) {
153
+ try {
154
+ $gallery = Mage::getModel('joomi_masonrygallery/gallery');
155
+ $gallery->setId($this->getRequest()->getParam('id'))->delete();
156
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('joomi_masonrygallery')->__('Gallery was successfully deleted.'));
157
+ $this->_redirect('*/*/');
158
+ return;
159
+ }
160
+ catch (Mage_Core_Exception $e){
161
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
162
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
163
+ }
164
+ catch (Exception $e) {
165
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was an error deleting gallery.'));
166
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
167
+ Mage::logException($e);
168
+ return;
169
+ }
170
+ }
171
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Could not find gallery to delete.'));
172
+ $this->_redirect('*/*/');
173
+ }
174
+ /**
175
+ * mass delete gallery - action
176
+ * @access public
177
+ * @return void
178
+ * @author Ultimate Module Creator
179
+ */
180
+ public function massDeleteAction() {
181
+ $galleryIds = $this->getRequest()->getParam('gallery');
182
+ if(!is_array($galleryIds)) {
183
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Please select galleries to delete.'));
184
+ }
185
+ else {
186
+ try {
187
+ foreach ($galleryIds as $galleryId) {
188
+ $gallery = Mage::getModel('joomi_masonrygallery/gallery');
189
+ $gallery->setId($galleryId)->delete();
190
+ }
191
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('joomi_masonrygallery')->__('Total of %d galleries were successfully deleted.', count($galleryIds)));
192
+ }
193
+ catch (Mage_Core_Exception $e){
194
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
195
+ }
196
+ catch (Exception $e) {
197
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was an error deleting galleries.'));
198
+ Mage::logException($e);
199
+ }
200
+ }
201
+ $this->_redirect('*/*/index');
202
+ }
203
+ /**
204
+ * mass status change - action
205
+ * @access public
206
+ * @return void
207
+ * @author Ultimate Module Creator
208
+ */
209
+ public function massStatusAction(){
210
+ $galleryIds = $this->getRequest()->getParam('gallery');
211
+ if(!is_array($galleryIds)) {
212
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Please select galleries.'));
213
+ }
214
+ else {
215
+ try {
216
+ foreach ($galleryIds as $galleryId) {
217
+ $gallery = Mage::getSingleton('joomi_masonrygallery/gallery')->load($galleryId)
218
+ ->setStatus($this->getRequest()->getParam('status'))
219
+ ->setIsMassupdate(true)
220
+ ->save();
221
+ }
222
+ $this->_getSession()->addSuccess($this->__('Total of %d galleries were successfully updated.', count($galleryIds)));
223
+ }
224
+ catch (Mage_Core_Exception $e){
225
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
226
+ }
227
+ catch (Exception $e) {
228
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was an error updating galleries.'));
229
+ Mage::logException($e);
230
+ }
231
+ }
232
+ $this->_redirect('*/*/index');
233
+ }
234
+ /**
235
+ * mass Thumbnail change - action
236
+ * @access public
237
+ * @return void
238
+ * @author Ultimate Module Creator
239
+ */
240
+ public function massThumbnailAction(){
241
+ $galleryIds = $this->getRequest()->getParam('gallery');
242
+ if(!is_array($galleryIds)) {
243
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Please select galleries.'));
244
+ }
245
+ else {
246
+ try {
247
+ foreach ($galleryIds as $galleryId) {
248
+ $gallery = Mage::getSingleton('joomi_masonrygallery/gallery')->load($galleryId)
249
+ ->setThumbnail($this->getRequest()->getParam('flag_thumbnail'))
250
+ ->setIsMassupdate(true)
251
+ ->save();
252
+ }
253
+ $this->_getSession()->addSuccess($this->__('Total of %d galleries were successfully updated.', count($galleryIds)));
254
+ }
255
+ catch (Mage_Core_Exception $e){
256
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
257
+ }
258
+ catch (Exception $e) {
259
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was an error updating galleries.'));
260
+ Mage::logException($e);
261
+ }
262
+ }
263
+ $this->_redirect('*/*/index');
264
+ }
265
+ /**
266
+ * mass Big Image change - action
267
+ * @access public
268
+ * @return void
269
+ * @author Ultimate Module Creator
270
+ */
271
+ public function massBigImageAction(){
272
+ $galleryIds = $this->getRequest()->getParam('gallery');
273
+ if(!is_array($galleryIds)) {
274
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Please select galleries.'));
275
+ }
276
+ else {
277
+ try {
278
+ foreach ($galleryIds as $galleryId) {
279
+ $gallery = Mage::getSingleton('joomi_masonrygallery/gallery')->load($galleryId)
280
+ ->setBigImage($this->getRequest()->getParam('flag_big_image'))
281
+ ->setIsMassupdate(true)
282
+ ->save();
283
+ }
284
+ $this->_getSession()->addSuccess($this->__('Total of %d galleries were successfully updated.', count($galleryIds)));
285
+ }
286
+ catch (Mage_Core_Exception $e){
287
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
288
+ }
289
+ catch (Exception $e) {
290
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was an error updating galleries.'));
291
+ Mage::logException($e);
292
+ }
293
+ }
294
+ $this->_redirect('*/*/index');
295
+ }
296
+ /**
297
+ * mass category change - action
298
+ * @access public
299
+ * @return void
300
+ * @author Ultimate Module Creator
301
+ */
302
+ public function massCategoryIdAction(){
303
+ $galleryIds = $this->getRequest()->getParam('gallery');
304
+ if(!is_array($galleryIds)) {
305
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('Please select galleries.'));
306
+ }
307
+ else {
308
+ try {
309
+ foreach ($galleryIds as $galleryId) {
310
+ $gallery = Mage::getSingleton('joomi_masonrygallery/gallery')->load($galleryId)
311
+ ->setCategoryId($this->getRequest()->getParam('flag_category_id'))
312
+ ->setIsMassupdate(true)
313
+ ->save();
314
+ }
315
+ $this->_getSession()->addSuccess($this->__('Total of %d galleries were successfully updated.', count($galleryIds)));
316
+ }
317
+ catch (Mage_Core_Exception $e){
318
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
319
+ }
320
+ catch (Exception $e) {
321
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('joomi_masonrygallery')->__('There was an error updating galleries.'));
322
+ Mage::logException($e);
323
+ }
324
+ }
325
+ $this->_redirect('*/*/index');
326
+ }
327
+ /**
328
+ * get grid of products action
329
+ * @access public
330
+ * @return void
331
+ * @author Ultimate Module Creator
332
+ */
333
+ public function productsAction(){
334
+ $this->_initGallery();
335
+ $this->loadLayout();
336
+ $this->getLayout()->getBlock('gallery.edit.tab.product')
337
+ ->setGalleryProducts($this->getRequest()->getPost('gallery_products', null));
338
+ $this->renderLayout();
339
+ }
340
+ /**
341
+ * get grid of products action
342
+ * @access public
343
+ * @return void
344
+ * @author Ultimate Module Creator
345
+ */
346
+ public function productsgridAction(){
347
+ $this->_initGallery();
348
+ $this->loadLayout();
349
+ $this->getLayout()->getBlock('gallery.edit.tab.product')
350
+ ->setGalleryProducts($this->getRequest()->getPost('gallery_products', null));
351
+ $this->renderLayout();
352
+ }
353
+ /**
354
+ * export as csv - action
355
+ * @access public
356
+ * @return void
357
+ * @author Ultimate Module Creator
358
+ */
359
+ public function exportCsvAction(){
360
+ $fileName = 'gallery.csv';
361
+ $content = $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_grid')->getCsv();
362
+ $this->_prepareDownloadResponse($fileName, $content);
363
+ }
364
+ /**
365
+ * export as MsExcel - action
366
+ * @access public
367
+ * @return void
368
+ * @author Ultimate Module Creator
369
+ */
370
+ public function exportExcelAction(){
371
+ $fileName = 'gallery.xls';
372
+ $content = $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_grid')->getExcelFile();
373
+ $this->_prepareDownloadResponse($fileName, $content);
374
+ }
375
+ /**
376
+ * export as xml - action
377
+ * @access public
378
+ * @return void
379
+ * @author Ultimate Module Creator
380
+ */
381
+ public function exportXmlAction(){
382
+ $fileName = 'gallery.xml';
383
+ $content = $this->getLayout()->createBlock('joomi_masonrygallery/adminhtml_gallery_grid')->getXml();
384
+ $this->_prepareDownloadResponse($fileName, $content);
385
+ }
386
+ /**
387
+ * Check if admin has permissions to visit related pages
388
+ * @access protected
389
+ * @return boolean
390
+ * @author Ultimate Module Creator
391
+ */
392
+ protected function _isAllowed() {
393
+ return Mage::getSingleton('admin/session')->isAllowed('joomi_masonrygallery/gallery');
394
+ }
395
+ }
app/code/community/Joomi/MasonryGallery/controllers/CategoryController.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category front contrller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_CategoryController
25
+ extends Mage_Core_Controller_Front_Action {
26
+ /**
27
+ * default action
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function indexAction(){
33
+ $this->loadLayout();
34
+ $this->_initLayoutMessages('catalog/session');
35
+ $this->_initLayoutMessages('customer/session');
36
+ $this->_initLayoutMessages('checkout/session');
37
+ if (Mage::helper('joomi_masonrygallery/category')->getUseBreadcrumbs()){
38
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
39
+ $breadcrumbBlock->addCrumb('home', array(
40
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Home'),
41
+ 'link' => Mage::getUrl(),
42
+ )
43
+ );
44
+ $breadcrumbBlock->addCrumb('categories', array(
45
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Categories'),
46
+ 'link' => '',
47
+ )
48
+ );
49
+ }
50
+ }
51
+ $headBlock = $this->getLayout()->getBlock('head');
52
+ if ($headBlock) {
53
+ $headBlock->setTitle(Mage::getStoreConfig('joomi_masonrygallery/category/meta_title'));
54
+ $headBlock->setKeywords(Mage::getStoreConfig('joomi_masonrygallery/category/meta_keywords'));
55
+ $headBlock->setDescription(Mage::getStoreConfig('joomi_masonrygallery/category/meta_description'));
56
+ }
57
+ $this->renderLayout();
58
+ }
59
+ /**
60
+ * init Category
61
+ * @access protected
62
+ * @return Joomi_MasonryGallery_Model_Entity
63
+ * @author Ultimate Module Creator
64
+ */
65
+ protected function _initCategory(){
66
+ $categoryId = $this->getRequest()->getParam('id', 0);
67
+ $category = Mage::getModel('joomi_masonrygallery/category')
68
+ ->setStoreId(Mage::app()->getStore()->getId())
69
+ ->load($categoryId);
70
+ if (!$category->getId()){
71
+ return false;
72
+ }
73
+ elseif (!$category->getStatus()){
74
+ return false;
75
+ }
76
+ return $category;
77
+ }
78
+ /**
79
+ * view category action
80
+ * @access public
81
+ * @return void
82
+ * @author Ultimate Module Creator
83
+ */
84
+ public function viewAction(){
85
+ $category = $this->_initCategory();
86
+ if (!$category) {
87
+ $this->_forward('no-route');
88
+ return;
89
+ }
90
+ if (!$category->getStatusPath()){
91
+ $this->_forward('no-route');
92
+ return;
93
+ }
94
+ Mage::register('current_category', $category);
95
+ $this->loadLayout();
96
+ $this->_initLayoutMessages('catalog/session');
97
+ $this->_initLayoutMessages('customer/session');
98
+ $this->_initLayoutMessages('checkout/session');
99
+ if ($root = $this->getLayout()->getBlock('root')) {
100
+ $root->addBodyClass('masonrygallery-category masonrygallery-category' . $category->getId());
101
+ }
102
+ if (Mage::helper('joomi_masonrygallery/category')->getUseBreadcrumbs()){
103
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
104
+ $breadcrumbBlock->addCrumb('home', array(
105
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Home'),
106
+ 'link' => Mage::getUrl(),
107
+ )
108
+ );
109
+ $breadcrumbBlock->addCrumb('categories', array(
110
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Categories'),
111
+ 'link' => Mage::helper('joomi_masonrygallery/category')->getCategoriesUrl(),
112
+ )
113
+ );
114
+ $parents = $category->getParentCategories();
115
+ foreach ($parents as $parent){
116
+ if ($parent->getId() != Mage::helper('joomi_masonrygallery/category')->getRootCategoryId() && $parent->getId() != $category->getId()){
117
+ $breadcrumbBlock->addCrumb('category-'.$parent->getId(), array(
118
+ 'label' => $parent->getTitle(),
119
+ 'link' => $link = $parent->getCategoryUrl(),
120
+ ));
121
+ }
122
+ }
123
+ $breadcrumbBlock->addCrumb('category', array(
124
+ 'label' => $category->getTitle(),
125
+ 'link' => '',
126
+ )
127
+ );
128
+ }
129
+ }
130
+ $headBlock = $this->getLayout()->getBlock('head');
131
+ if ($headBlock) {
132
+ if ($category->getMetaTitle()){
133
+ $headBlock->setTitle($category->getMetaTitle());
134
+ }
135
+ else{
136
+ $headBlock->setTitle($category->getTitle());
137
+ }
138
+ $headBlock->setKeywords($category->getMetaKeywords());
139
+ $headBlock->setDescription($category->getMetaDescription());
140
+ }
141
+ $this->renderLayout();
142
+ }
143
+ }
app/code/community/Joomi/MasonryGallery/controllers/GalleryController.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery front contrller
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Joomi_MasonryGallery_GalleryController
25
+ extends Mage_Core_Controller_Front_Action {
26
+ /**
27
+ * default action
28
+ * @access public
29
+ * @return void
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function indexAction(){
33
+ $this->loadLayout();
34
+ $this->_initLayoutMessages('catalog/session');
35
+ $this->_initLayoutMessages('customer/session');
36
+ $this->_initLayoutMessages('checkout/session');
37
+ if (Mage::helper('joomi_masonrygallery/gallery')->getUseBreadcrumbs()){
38
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
39
+ $breadcrumbBlock->addCrumb('home', array(
40
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Home'),
41
+ 'link' => Mage::getUrl(),
42
+ )
43
+ );
44
+ $breadcrumbBlock->addCrumb('galleries', array(
45
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Galleries'),
46
+ 'link' => '',
47
+ )
48
+ );
49
+ }
50
+ }
51
+ $headBlock = $this->getLayout()->getBlock('head');
52
+ if ($headBlock) {
53
+ $headBlock->setTitle(Mage::getStoreConfig('joomi_masonrygallery/gallery/meta_title'));
54
+ $headBlock->setKeywords(Mage::getStoreConfig('joomi_masonrygallery/gallery/meta_keywords'));
55
+ $headBlock->setDescription(Mage::getStoreConfig('joomi_masonrygallery/gallery/meta_description'));
56
+ }
57
+ $this->renderLayout();
58
+ }
59
+ /**
60
+ * init Gallery
61
+ * @access protected
62
+ * @return Joomi_MasonryGallery_Model_Entity
63
+ * @author Ultimate Module Creator
64
+ */
65
+ protected function _initGallery(){
66
+ $galleryId = $this->getRequest()->getParam('id', 0);
67
+ $gallery = Mage::getModel('joomi_masonrygallery/gallery')
68
+ ->setStoreId(Mage::app()->getStore()->getId())
69
+ ->load($galleryId);
70
+ if (!$gallery->getId()){
71
+ return false;
72
+ }
73
+ elseif (!$gallery->getStatus()){
74
+ return false;
75
+ }
76
+ return $gallery;
77
+ }
78
+ /**
79
+ * view gallery action
80
+ * @access public
81
+ * @return void
82
+ * @author Ultimate Module Creator
83
+ */
84
+ public function viewAction(){
85
+ $gallery = $this->_initGallery();
86
+ if (!$gallery) {
87
+ $this->_forward('no-route');
88
+ return;
89
+ }
90
+ Mage::register('current_gallery', $gallery);
91
+ $this->loadLayout();
92
+ $this->_initLayoutMessages('catalog/session');
93
+ $this->_initLayoutMessages('customer/session');
94
+ $this->_initLayoutMessages('checkout/session');
95
+ if ($root = $this->getLayout()->getBlock('root')) {
96
+ $root->addBodyClass('masonrygallery-gallery masonrygallery-gallery' . $gallery->getId());
97
+ }
98
+ if (Mage::helper('joomi_masonrygallery/gallery')->getUseBreadcrumbs()){
99
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')){
100
+ $breadcrumbBlock->addCrumb('home', array(
101
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Home'),
102
+ 'link' => Mage::getUrl(),
103
+ )
104
+ );
105
+ $breadcrumbBlock->addCrumb('galleries', array(
106
+ 'label' => Mage::helper('joomi_masonrygallery')->__('Galleries'),
107
+ 'link' => Mage::helper('joomi_masonrygallery/gallery')->getGalleriesUrl(),
108
+ )
109
+ );
110
+ $breadcrumbBlock->addCrumb('gallery', array(
111
+ 'label' => $gallery->getTitle(),
112
+ 'link' => '',
113
+ )
114
+ );
115
+ }
116
+ }
117
+ $headBlock = $this->getLayout()->getBlock('head');
118
+ if ($headBlock) {
119
+ if ($gallery->getMetaTitle()){
120
+ $headBlock->setTitle($gallery->getMetaTitle());
121
+ }
122
+ else{
123
+ $headBlock->setTitle($gallery->getTitle());
124
+ }
125
+ $headBlock->setKeywords($gallery->getMetaKeywords());
126
+ $headBlock->setDescription($gallery->getMetaDescription());
127
+ }
128
+ $this->renderLayout();
129
+ }
130
+ }
app/code/community/Joomi/MasonryGallery/data/joomi_masonrygallery_setup/data-install-1.0.0.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /*
18
+ * @category Joomi
19
+ * @package Joomi_MasonryGallery
20
+ * @author Ultimate Module Creator
21
+ */
22
+ Mage::getModel('joomi_masonrygallery/category')
23
+ ->load(1)
24
+ ->setParentId(0)
25
+ ->setPath(1)
26
+ ->setLevel(0)
27
+ ->setPosition(0)
28
+ ->setChildrenCount(0)
29
+ ->setTitle('ROOT')
30
+ ->setInitialSetupFlag(true)
31
+ ->save();
app/code/community/Joomi/MasonryGallery/etc/adminhtml.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <joomi_masonrygallery translate="title" module="joomi_masonrygallery">
29
+ <title>MasonryGallery</title>
30
+ </joomi_masonrygallery>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <joomi_masonrygallery translate="title" module="joomi_masonrygallery">
36
+ <title>Masonry Gallery</title>
37
+ <children>
38
+ <category translate="title" module="joomi_masonrygallery">
39
+ <title>Category</title>
40
+ <sort_order>0</sort_order>
41
+ </category>
42
+ <gallery translate="title" module="joomi_masonrygallery">
43
+ <title>Gallery</title>
44
+ <sort_order>10</sort_order>
45
+ </gallery>
46
+ </children>
47
+ </joomi_masonrygallery>
48
+ </children>
49
+ </admin>
50
+ </resources>
51
+ </acl>
52
+ <menu>
53
+ <joomi_masonrygallery translate="title" module="joomi_masonrygallery">
54
+ <title>Masonry Gallery</title>
55
+ <sort_order>85</sort_order>
56
+ <children>
57
+ <category translate="title" module="joomi_masonrygallery">
58
+ <title>Category</title>
59
+ <action>adminhtml/masonrygallery_category</action>
60
+ <sort_order>0</sort_order>
61
+ </category>
62
+ <gallery translate="title" module="joomi_masonrygallery">
63
+ <title>Gallery</title>
64
+ <action>adminhtml/masonrygallery_gallery</action>
65
+ <sort_order>10</sort_order>
66
+ </gallery>
67
+ </children>
68
+ </joomi_masonrygallery>
69
+ </menu>
70
+ </config>
app/code/community/Joomi/MasonryGallery/etc/config.xml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Joomi_MasonryGallery>
22
+ <version>1.0.0</version>
23
+ </Joomi_MasonryGallery>
24
+ </modules>
25
+ <global>
26
+ <resources>
27
+ <joomi_masonrygallery_setup>
28
+ <setup>
29
+ <module>Joomi_MasonryGallery</module>
30
+ <class>Joomi_MasonryGallery_Model_Resource_Setup</class>
31
+ </setup>
32
+ </joomi_masonrygallery_setup>
33
+ </resources>
34
+ <blocks>
35
+ <joomi_masonrygallery>
36
+ <class>Joomi_MasonryGallery_Block</class>
37
+ </joomi_masonrygallery>
38
+ </blocks>
39
+ <helpers>
40
+ <joomi_masonrygallery>
41
+ <class>Joomi_MasonryGallery_Helper</class>
42
+ </joomi_masonrygallery>
43
+ </helpers>
44
+ <models>
45
+ <joomi_masonrygallery>
46
+ <class>Joomi_MasonryGallery_Model</class>
47
+ <resourceModel>joomi_masonrygallery_resource</resourceModel>
48
+ </joomi_masonrygallery>
49
+ <joomi_masonrygallery_resource>
50
+ <class>Joomi_MasonryGallery_Model_Resource</class>
51
+ <entities>
52
+ <category>
53
+ <table>joomi_masonrygallery_category</table>
54
+ </category>
55
+ <gallery>
56
+ <table>joomi_masonrygallery_gallery</table>
57
+ </gallery>
58
+ <category_store>
59
+ <table>joomi_masonrygallery_category_store</table>
60
+ </category_store>
61
+ <gallery_store>
62
+ <table>joomi_masonrygallery_gallery_store</table>
63
+ </gallery_store>
64
+ <gallery_product>
65
+ <table>joomi_masonrygallery_gallery_product</table>
66
+ </gallery_product>
67
+ </entities>
68
+ </joomi_masonrygallery_resource>
69
+ </models>
70
+ <events>
71
+ <controller_front_init_routers>
72
+ <observers>
73
+ <joomi_masonrygallery>
74
+ <class>Joomi_MasonryGallery_Controller_Router</class>
75
+ <method>initControllerRouters</method>
76
+ </joomi_masonrygallery>
77
+ </observers>
78
+ </controller_front_init_routers>
79
+ </events>
80
+ </global>
81
+ <adminhtml>
82
+ <layout>
83
+ <updates>
84
+ <joomi_masonrygallery>
85
+ <file>joomi_masonrygallery.xml</file>
86
+ </joomi_masonrygallery>
87
+ </updates>
88
+ </layout>
89
+ <translate>
90
+ <modules>
91
+ <Joomi_MasonryGallery>
92
+ <files>
93
+ <default>Joomi_MasonryGallery.csv</default>
94
+ </files>
95
+ </Joomi_MasonryGallery>
96
+ </modules>
97
+ </translate>
98
+ <events>
99
+ <core_block_abstract_prepare_layout_after>
100
+ <observers>
101
+ <joomi_masonrygallery_gallery_product>
102
+ <type>singleton</type>
103
+ <class>joomi_masonrygallery/adminhtml_observer</class>
104
+ <method>addProductGalleryBlock</method>
105
+ </joomi_masonrygallery_gallery_product>
106
+ </observers>
107
+ </core_block_abstract_prepare_layout_after>
108
+ <catalog_product_save_after>
109
+ <observers>
110
+ <joomi_masonrygallery_gallery_product>
111
+ <type>singleton</type>
112
+ <class>joomi_masonrygallery/adminhtml_observer</class>
113
+ <method>saveProductGalleryData</method>
114
+ </joomi_masonrygallery_gallery_product>
115
+ </observers>
116
+ </catalog_product_save_after>
117
+ </events>
118
+ <global_search>
119
+ <gallery>
120
+ <class>joomi_masonrygallery/adminhtml_search_gallery</class>
121
+ <acl>joomi_masonrygallery</acl>
122
+ </gallery>
123
+ </global_search>
124
+ </adminhtml>
125
+ <admin>
126
+ <routers>
127
+ <adminhtml>
128
+ <args>
129
+ <modules>
130
+ <Joomi_MasonryGallery before="Mage_Adminhtml">Joomi_MasonryGallery_Adminhtml</Joomi_MasonryGallery>
131
+ </modules>
132
+ </args>
133
+ </adminhtml>
134
+ </routers>
135
+ </admin>
136
+ <frontend>
137
+ <routers>
138
+ <joomi_masonrygallery>
139
+ <use>standard</use>
140
+ <args>
141
+ <module>Joomi_MasonryGallery</module>
142
+ <frontName>masonry</frontName>
143
+ </args>
144
+ </joomi_masonrygallery>
145
+ </routers>
146
+ <layout>
147
+ <updates>
148
+ <joomi_masonrygallery>
149
+ <file>joomi_masonrygallery.xml</file>
150
+ </joomi_masonrygallery>
151
+ </updates>
152
+ </layout>
153
+ <translate>
154
+ <modules>
155
+ <Joomi_MasonryGallery>
156
+ <files>
157
+ <default>Joomi_MasonryGallery.csv</default>
158
+ </files>
159
+ </Joomi_MasonryGallery>
160
+ </modules>
161
+ </translate>
162
+ </frontend>
163
+ <default>
164
+ <joomi_masonrygallery>
165
+ <category>
166
+ <breadcrumbs>1</breadcrumbs>
167
+ <meta_title>Categories</meta_title>
168
+ <tree>1</tree>
169
+ <recursion>0</recursion>
170
+ </category>
171
+ <gallery>
172
+ <breadcrumbs>1</breadcrumbs>
173
+ <meta_title>Galleries</meta_title>
174
+ </gallery>
175
+ </joomi_masonrygallery>
176
+ </default>
177
+ </config>
app/code/community/Joomi/MasonryGallery/etc/system.xml ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <tabs>
21
+ <joomi translate="label" module="joomi_masonrygallery">
22
+ <label>MasonryGallery</label>
23
+ <sort_order>2000</sort_order>
24
+ </joomi>
25
+ </tabs>
26
+ <sections>
27
+ <joomi_masonrygallery translate="label" module="joomi_masonrygallery">
28
+ <class>separator-top</class>
29
+ <label>Masonry Gallery</label>
30
+ <tab>joomi</tab>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>100</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <groups>
37
+ <category translate="label" module="joomi_masonrygallery">
38
+ <label>Category</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>0</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <fields>
45
+ <breadcrumbs translate="label">
46
+ <label>Use Breadcrumbs</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </breadcrumbs>
54
+ <url_rewrite_list translate="label comment">
55
+ <label>URL key for list page</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>20</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
+ <comment>Leave empty to use default URL module/controller/action</comment>
62
+ </url_rewrite_list>
63
+ <url_prefix translate="label comment">
64
+ <label>URL prefix</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>30</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
+ <comment>Leave empty for no prefix</comment>
71
+ </url_prefix>
72
+ <url_suffix translate="label comment">
73
+ <label>Url suffix</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>40</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
+ <comment>What goes after the dot. Leave empty for no suffix.</comment>
80
+ </url_suffix>
81
+ <tree translate="label">
82
+ <label>Display as tree</label>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>adminhtml/system_config_source_yesno</source_model>
85
+ <sort_order>50</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
+ </tree>
90
+ <recursion translate="label">
91
+ <label>Recursion level</label>
92
+ <frontend_type>text</frontend_type>
93
+ <sort_order>60</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </recursion>
98
+ <meta_title translate="label">
99
+ <label>Meta title for categories list page</label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>70</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </meta_title>
106
+ <meta_description translate="label">
107
+ <label>Meta description for categories list page</label>
108
+ <frontend_type>textarea</frontend_type>
109
+ <sort_order>80</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ </meta_description>
114
+ <meta_keywords translate="label">
115
+ <label>Meta keywords for categories list page</label>
116
+ <frontend_type>textarea</frontend_type>
117
+ <sort_order>90</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ </meta_keywords>
122
+ </fields>
123
+ </category>
124
+ <gallery translate="label" module="joomi_masonrygallery">
125
+ <label>Gallery</label>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>10</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>1</show_in_store>
131
+ <fields>
132
+ <breadcrumbs translate="label">
133
+ <label>Use Breadcrumbs</label>
134
+ <frontend_type>select</frontend_type>
135
+ <source_model>adminhtml/system_config_source_yesno</source_model>
136
+ <sort_order>10</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ </breadcrumbs>
141
+ <url_rewrite_list translate="label comment">
142
+ <label>URL key for list page</label>
143
+ <frontend_type>text</frontend_type>
144
+ <sort_order>20</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ <comment>Leave empty to use default URL module/controller/action</comment>
149
+ </url_rewrite_list>
150
+ <url_prefix translate="label comment">
151
+ <label>URL prefix</label>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>30</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ <comment>Leave empty for no prefix</comment>
158
+ </url_prefix>
159
+ <url_suffix translate="label comment">
160
+ <label>Url suffix</label>
161
+ <frontend_type>text</frontend_type>
162
+ <sort_order>40</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ <comment>What goes after the dot. Leave empty for no suffix.</comment>
167
+ </url_suffix>
168
+ <meta_title translate="label">
169
+ <label>Meta title for galleries list page</label>
170
+ <frontend_type>text</frontend_type>
171
+ <sort_order>50</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </meta_title>
176
+ <meta_description translate="label">
177
+ <label>Meta description for galleries list page</label>
178
+ <frontend_type>textarea</frontend_type>
179
+ <sort_order>60</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ </meta_description>
184
+ <meta_keywords translate="label">
185
+ <label>Meta keywords for galleries list page</label>
186
+ <frontend_type>textarea</frontend_type>
187
+ <sort_order>70</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
+ </meta_keywords>
192
+ </fields>
193
+ </gallery>
194
+ <global translate="label" module="joomi_masonrygallery">
195
+ <label>Masonry Gallery Configuration</label>
196
+ <frontend_type>text</frontend_type>
197
+ <sort_order>20</sort_order>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ <fields>
202
+ <load_jquery translate="label">
203
+ <label>Load Jquery</label>
204
+ <frontend_type>select</frontend_type>
205
+ <sort_order>0</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ <source_model>adminhtml/system_config_source_yesno</source_model>
210
+ </load_jquery>
211
+ <load_masonry_jquery translate="label">
212
+ <label>Load Masonry Jquery</label>
213
+ <frontend_type>select</frontend_type>
214
+ <sort_order>20</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ <source_model>adminhtml/system_config_source_yesno</source_model>
219
+ </load_masonry_jquery>
220
+ <load_fancy_box translate="label">
221
+ <label>Load Fancy Box</label>
222
+ <frontend_type>select</frontend_type>
223
+ <sort_order>30</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ <source_model>adminhtml/system_config_source_yesno</source_model>
228
+ </load_fancy_box>
229
+ <grow_image_effect translate="label">
230
+ <label>Grow Image Effect</label>
231
+ <frontend_type>select</frontend_type>
232
+ <sort_order>40</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>1</show_in_store>
236
+ <source_model>adminhtml/system_config_source_yesno</source_model>
237
+ </grow_image_effect>
238
+ <open_popup_prod translate="label">
239
+ <label>Open product in popup</label>
240
+ <frontend_type>select</frontend_type>
241
+ <sort_order>50</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ <source_model>adminhtml/system_config_source_yesno</source_model>
246
+ </open_popup_prod>
247
+ </fields>
248
+ </global>
249
+ </groups>
250
+ </joomi_masonrygallery>
251
+ </sections>
252
+ </config>
app/code/community/Joomi/MasonryGallery/etc/widget.xml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <widgets>
20
+ <!--<masonrygallery_category_view type="joomi_masonrygallery/category_widget_view" translate="name description" module="joomi_masonrygallery">-->
21
+ <!--<name>Category view</name>-->
22
+ <!--<description>Category view widget</description>-->
23
+ <!--<is_email_compatible>0</is_email_compatible>-->
24
+ <!--<parameters>-->
25
+ <!--<category_id type="complex" translate="label">-->
26
+ <!--<visible>1</visible>-->
27
+ <!--<required>1</required>-->
28
+ <!--<label>Category</label>-->
29
+ <!--<type>label</type>-->
30
+ <!--<helper_block>-->
31
+ <!--<type>joomi_masonrygallery/adminhtml_category_widget_chooser</type>-->
32
+ <!--<data>-->
33
+ <!--<button translate="open">-->
34
+ <!--<open>Select Category</open>-->
35
+ <!--</button>-->
36
+ <!--</data>-->
37
+ <!--</helper_block>-->
38
+ <!--<sort_order>120</sort_order>-->
39
+ <!--</category_id>-->
40
+ <!--</parameters>-->
41
+ <!--</masonrygallery_category_view>-->
42
+ <masonrygallery_category_link type="joomi_masonrygallery/category_widget_link" translate="name description" module="joomi_masonrygallery">
43
+ <name>Category link</name>
44
+ <description>Category link widget</description>
45
+ <is_email_compatible>0</is_email_compatible>
46
+ <parameters>
47
+ <category_id type="complex" translate="label">
48
+ <visible>1</visible>
49
+ <required>1</required>
50
+ <label>Category</label>
51
+ <type>label</type>
52
+ <helper_block>
53
+ <type>joomi_masonrygallery/adminhtml_category_widget_chooser</type>
54
+ <data>
55
+ <button translate="open">
56
+ <open>Select Category</open>
57
+ </button>
58
+ </data>
59
+ </helper_block>
60
+ <sort_order>130</sort_order>
61
+ </category_id>
62
+ </parameters>
63
+ </masonrygallery_category_link>
64
+ <masonrygallery_gallery_view type="joomi_masonrygallery/gallery_widget_view" translate="name description" module="joomi_masonrygallery">
65
+ <name>Gallery view</name>
66
+ <description>Gallery view widget</description>
67
+ <is_email_compatible>0</is_email_compatible>
68
+ <parameters>
69
+ <gallery_id type="complex" translate="label">
70
+ <visible>1</visible>
71
+ <required>1</required>
72
+ <label>Gallery</label>
73
+ <type>label</type>
74
+ <helper_block>
75
+ <type>joomi_masonrygallery/adminhtml_gallery_widget_chooser</type>
76
+ <data>
77
+ <button translate="open">
78
+ <open>Select Gallery</open>
79
+ </button>
80
+ </data>
81
+ </helper_block>
82
+ <sort_order>120</sort_order>
83
+ </gallery_id>
84
+ </parameters>
85
+ </masonrygallery_gallery_view>
86
+ <masonrygallery_gallery_link type="joomi_masonrygallery/gallery_widget_link" translate="name description" module="joomi_masonrygallery">
87
+ <name>Gallery link</name>
88
+ <description>Gallery link widget</description>
89
+ <is_email_compatible>0</is_email_compatible>
90
+ <parameters>
91
+ <gallery_id type="complex" translate="label">
92
+ <visible>1</visible>
93
+ <required>1</required>
94
+ <label>Gallery</label>
95
+ <type>label</type>
96
+ <helper_block>
97
+ <type>joomi_masonrygallery/adminhtml_gallery_widget_chooser</type>
98
+ <data>
99
+ <button translate="open">
100
+ <open>Select Gallery</open>
101
+ </button>
102
+ </data>
103
+ </helper_block>
104
+ <sort_order>130</sort_order>
105
+ </gallery_id>
106
+ </parameters>
107
+ </masonrygallery_gallery_link>
108
+ <!--<masonrygallery_category_subtree type="joomi_masonrygallery/category_widget_subtree" translate="name description" module="joomi_masonrygallery">-->
109
+ <!--<name>Category subtree</name>-->
110
+ <!--<description>Category subtree widget</description>-->
111
+ <!--<is_email_compatible>0</is_email_compatible>-->
112
+ <!--<parameters>-->
113
+ <!--<category_id type="complex" translate="label">-->
114
+ <!--<visible>1</visible>-->
115
+ <!--<required>1</required>-->
116
+ <!--<label>Category</label>-->
117
+ <!--<type>label</type>-->
118
+ <!--<helper_block>-->
119
+ <!--<type>joomi_masonrygallery/adminhtml_category_widget_chooser</type>-->
120
+ <!--<data>-->
121
+ <!--<button translate="open">-->
122
+ <!--<open>Select Category</open>-->
123
+ <!--</button>-->
124
+ <!--</data>-->
125
+ <!--</helper_block>-->
126
+ <!--<sort_order>10</sort_order>-->
127
+ <!--</category_id>-->
128
+ <!--<recursion type="complex" translate="label">-->
129
+ <!--<visible>1</visible>-->
130
+ <!--<required>1</required>-->
131
+ <!--<value>0</value>-->
132
+ <!--<label>Levels to show (0 for all)</label>-->
133
+ <!--<type>text</type>-->
134
+ <!--<sort_order>20</sort_order>-->
135
+ <!--</recursion>-->
136
+ <!--</parameters>-->
137
+ <!--</masonrygallery_category_subtree>-->
138
+ </widgets>
app/code/community/Joomi/MasonryGallery/sql/joomi_masonrygallery_setup/install-1.0.0.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MasonryGallery module install script
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ $this->startSetup();
25
+ $table = $this->getConnection()
26
+ ->newTable($this->getTable('joomi_masonrygallery/category'))
27
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
28
+ 'identity' => true,
29
+ 'nullable' => false,
30
+ 'primary' => true,
31
+ ), 'Category ID')
32
+ ->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
33
+ 'nullable' => false,
34
+ ), 'Title')
35
+
36
+ ->addColumn('description', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
37
+ ), 'Description')
38
+
39
+ ->addColumn('ordering', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
40
+ 'unsigned' => true,
41
+ ), 'Ordering')
42
+
43
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
44
+ ), 'Enabled')
45
+
46
+ ->addColumn('url_key', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
47
+ ), 'URL key')
48
+
49
+ ->addColumn('parent_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
50
+ 'unsigned' => true,
51
+ ), 'Parent id')
52
+
53
+ ->addColumn('path', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
54
+ ), 'Path')
55
+
56
+ ->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
57
+ 'unsigned' => true,
58
+ ), 'Position')
59
+
60
+ ->addColumn('level', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
61
+ 'unsigned' => true,
62
+ ), 'Level')
63
+
64
+ ->addColumn('children_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
65
+ 'unsigned' => true,
66
+ ), 'Children count')
67
+
68
+ ->addColumn('meta_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
69
+ ), 'Meta title')
70
+
71
+ ->addColumn('meta_keywords', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
72
+ ), 'Meta keywords')
73
+
74
+ ->addColumn('meta_description', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
75
+ ), 'Meta description')
76
+
77
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
78
+ ), 'Category Status')
79
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
80
+ ), 'Category Modification Time')
81
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
82
+ ), 'Category Creation Time')
83
+ ->setComment('Category Table');
84
+ $this->getConnection()->createTable($table);
85
+ $table = $this->getConnection()
86
+ ->newTable($this->getTable('joomi_masonrygallery/gallery'))
87
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
88
+ 'identity' => true,
89
+ 'nullable' => false,
90
+ 'primary' => true,
91
+ ), 'Gallery ID')
92
+ ->addColumn('category_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
93
+ 'unsigned' => true,
94
+ ), 'Category ID')
95
+
96
+ ->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
97
+ 'nullable' => false,
98
+ ), 'Title')
99
+
100
+ ->addColumn('description', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
101
+ ), 'Description')
102
+
103
+ ->addColumn('column_width', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
104
+ 'nullable' => false,
105
+ 'unsigned' => true,
106
+ ), 'Column Width')
107
+
108
+ ->addColumn('thumbnail', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
109
+ 'nullable' => false,
110
+ ), 'Thumbnail')
111
+
112
+ ->addColumn('big_image', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
113
+ 'nullable' => false,
114
+ ), 'Big Image')
115
+
116
+ ->addColumn('ordering', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
117
+ 'unsigned' => true,
118
+ ), 'Ordering')
119
+
120
+ ->addColumn('limit_first_load', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
121
+ 'unsigned' => true,
122
+ ), 'Limit First Load')
123
+
124
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
125
+ ), 'Enabled')
126
+
127
+ ->addColumn('url_key', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
128
+ ), 'URL key')
129
+
130
+ ->addColumn('meta_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
131
+ ), 'Meta title')
132
+
133
+ ->addColumn('meta_keywords', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
134
+ ), 'Meta keywords')
135
+
136
+ ->addColumn('meta_description', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
137
+ ), 'Meta description')
138
+
139
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
140
+ ), 'Gallery Status')
141
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
142
+ ), 'Gallery Modification Time')
143
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
144
+ ), 'Gallery Creation Time')
145
+ ->addIndex($this->getIdxName('joomi_masonrygallery/category', array('category_id')), array('category_id'))
146
+ ->setComment('Gallery Table');
147
+ $this->getConnection()->createTable($table);
148
+ $table = $this->getConnection()
149
+ ->newTable($this->getTable('joomi_masonrygallery/category_store'))
150
+ ->addColumn('category_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
151
+ 'nullable' => false,
152
+ 'primary' => true,
153
+ ), 'Category ID')
154
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
155
+ 'unsigned' => true,
156
+ 'nullable' => false,
157
+ 'primary' => true,
158
+ ), 'Store ID')
159
+ ->addIndex($this->getIdxName('joomi_masonrygallery/category_store', array('store_id')), array('store_id'))
160
+ ->addForeignKey($this->getFkName('joomi_masonrygallery/category_store', 'category_id', 'joomi_masonrygallery/category', 'entity_id'), 'category_id', $this->getTable('joomi_masonrygallery/category'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
161
+ ->addForeignKey($this->getFkName('joomi_masonrygallery/category_store', 'store_id', 'core/store', 'store_id'), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
162
+ ->setComment('Categories To Store Linkage Table');
163
+ $this->getConnection()->createTable($table);
164
+ $table = $this->getConnection()
165
+ ->newTable($this->getTable('joomi_masonrygallery/gallery_store'))
166
+ ->addColumn('gallery_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
167
+ 'nullable' => false,
168
+ 'primary' => true,
169
+ ), 'Gallery ID')
170
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
171
+ 'unsigned' => true,
172
+ 'nullable' => false,
173
+ 'primary' => true,
174
+ ), 'Store ID')
175
+ ->addIndex($this->getIdxName('joomi_masonrygallery/gallery_store', array('store_id')), array('store_id'))
176
+ ->addForeignKey($this->getFkName('joomi_masonrygallery/gallery_store', 'gallery_id', 'joomi_masonrygallery/gallery', 'entity_id'), 'gallery_id', $this->getTable('joomi_masonrygallery/gallery'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
177
+ ->addForeignKey($this->getFkName('joomi_masonrygallery/gallery_store', 'store_id', 'core/store', 'store_id'), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
178
+ ->setComment('Galleries To Store Linkage Table');
179
+ $this->getConnection()->createTable($table);
180
+ $table = $this->getConnection()
181
+ ->newTable($this->getTable('joomi_masonrygallery/gallery_product'))
182
+ ->addColumn('rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
183
+ 'unsigned' => true,
184
+ 'identity' => true,
185
+ 'nullable' => false,
186
+ 'primary' => true,
187
+ ), 'Relation ID')
188
+ ->addColumn('gallery_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
189
+ 'unsigned' => true,
190
+ 'nullable' => false,
191
+ 'default' => '0',
192
+ ), 'Gallery ID')
193
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
194
+ 'unsigned' => true,
195
+ 'nullable' => false,
196
+ 'default' => '0',
197
+ ), 'Product ID')
198
+ ->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
199
+ 'nullable' => false,
200
+ 'default' => '0',
201
+ ), 'Position')
202
+ ->addIndex($this->getIdxName('joomi_masonrygallery/gallery_product', array('product_id')), array('product_id'))
203
+ ->addForeignKey($this->getFkName('joomi_masonrygallery/gallery_product', 'gallery_id', 'joomi_masonrygallery/gallery', 'entity_id'), 'gallery_id', $this->getTable('joomi_masonrygallery/gallery'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
204
+ ->addForeignKey($this->getFkName('joomi_masonrygallery/gallery_product', 'product_id', 'catalog/product', 'entity_id'), 'product_id', $this->getTable('catalog/product'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
205
+ ->addIndex(
206
+ $this->getIdxName(
207
+ 'joomi_masonrygallery/gallery_product',
208
+ array('gallery_id', 'product_id'),
209
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
210
+ ),
211
+ array('gallery_id', 'product_id'),
212
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
213
+ ->setComment('Gallery to Product Linkage Table');
214
+ $this->getConnection()->createTable($table);
215
+ $this->endSetup();
app/design/adminhtml/default/default/layout/joomi_masonrygallery.xml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <adminhtml_masonrygallery_gallery_index>
21
+ <reference name="menu">
22
+ <action method="setActive">
23
+ <menupath>joomi_masonrygallery/gallery</menupath>
24
+ </action>
25
+ </reference>
26
+ <reference name="content">
27
+ <block type="joomi_masonrygallery/adminhtml_gallery" name="gallery" />
28
+
29
+ </reference>
30
+ </adminhtml_masonrygallery_gallery_index>
31
+ <adminhtml_masonrygallery_gallery_grid>
32
+ <block type="core/text_list" name="root" output="toHtml">
33
+ <block type="joomi_masonrygallery/adminhtml_gallery_grid" name="gallery_grid"/>
34
+ </block>
35
+ </adminhtml_masonrygallery_gallery_grid>
36
+ <!-- Gallery add/edit action -->
37
+ <adminhtml_masonrygallery_gallery_edit>
38
+ <update handle="editor"/>
39
+ <reference name="menu">
40
+ <action method="setActive">
41
+ <menupath>joomi_masonrygallery/gallery</menupath>
42
+ </action>
43
+ </reference>
44
+ <reference name="content">
45
+ <block type="joomi_masonrygallery/adminhtml_gallery_edit" name="gallery_edit"></block>
46
+ </reference>
47
+ <reference name="left">
48
+ <block type="joomi_masonrygallery/adminhtml_gallery_edit_tabs" name="gallery_tabs"></block>
49
+ </reference>
50
+ </adminhtml_masonrygallery_gallery_edit>
51
+
52
+ <adminhtml_masonrygallery_gallery_catalog_product_galleries>
53
+ <block type="core/text_list" name="root" output="toHtml">
54
+ <block type="joomi_masonrygallery/adminhtml_catalog_product_edit_tab_gallery" name="product.edit.tab.gallery"/>
55
+ <block type="adminhtml/widget_grid_serializer" name="gallery_grid_serializer">
56
+ <reference name="gallery_grid_serializer">
57
+ <action method="initSerializerBlock">
58
+ <grid_block_name>product.edit.tab.gallery</grid_block_name>
59
+ <data_callback>getSelectedGalleries</data_callback>
60
+ <hidden_input_name>galleries</hidden_input_name>
61
+ <reload_param_name>product_galleries</reload_param_name>
62
+ </action>
63
+ <action method="addColumnInputName">
64
+ <input_name>position</input_name>
65
+ </action>
66
+ </reference>
67
+ </block>
68
+ </block>
69
+ </adminhtml_masonrygallery_gallery_catalog_product_galleries>
70
+ <adminhtml_masonrygallery_gallery_catalog_product_galleriesgrid>
71
+ <block type="core/text_list" name="root" output="toHtml">
72
+ <block type="joomi_masonrygallery/adminhtml_catalog_product_edit_tab_gallery" name="product.edit.tab.gallery"/>
73
+ </block>
74
+ </adminhtml_masonrygallery_gallery_catalog_product_galleriesgrid>
75
+ <adminhtml_masonrygallery_gallery_products>
76
+ <block type="core/text_list" name="root" output="toHtml">
77
+ <block type="joomi_masonrygallery/adminhtml_gallery_edit_tab_product" name="gallery.edit.tab.product"/>
78
+ <block type="adminhtml/widget_grid_serializer" name="product_grid_serializer">
79
+ <reference name="product_grid_serializer">
80
+ <action method="initSerializerBlock">
81
+ <grid_block_name>gallery.edit.tab.product</grid_block_name>
82
+ <data_callback>getSelectedProducts</data_callback>
83
+ <hidden_input_name>products</hidden_input_name>
84
+ <reload_param_name>gallery_products</reload_param_name>
85
+ </action>
86
+ <action method="addColumnInputName">
87
+ <input_name>position</input_name>
88
+ </action>
89
+ </reference>
90
+ </block>
91
+ </block>
92
+ </adminhtml_masonrygallery_gallery_products>
93
+ <adminhtml_masonrygallery_gallery_productsgrid>
94
+ <block type="core/text_list" name="root" output="toHtml">
95
+ <block type="joomi_masonrygallery/adminhtml_gallery_edit_tab_product" name="gallery.edit.tab.product"/>
96
+ </block>
97
+ </adminhtml_masonrygallery_gallery_productsgrid>
98
+ <adminhtml_masonrygallery_category_edit>
99
+ <update handle="editor"/>
100
+ <reference name="left">
101
+ <block name="category.tree" type="joomi_masonrygallery/adminhtml_category_tree" />
102
+ </reference>
103
+ <reference name="content">
104
+ <block name="category.edit" type="joomi_masonrygallery/adminhtml_category_edit" template="joomi_masonrygallery/category/edit.phtml" />
105
+ </reference>
106
+ <reference name="js">
107
+ <block type="core/template" template="catalog/wysiwyg/js.phtml" name="catalog.wysiwyg.js" />
108
+ </reference>
109
+ </adminhtml_masonrygallery_category_edit>
110
+ </layout>
app/design/adminhtml/default/default/template/joomi_masonrygallery/category/edit.phtml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div id="category-edit-container" class="category-content">
19
+ <?php echo $this->getChildHtml('form') ?>
20
+ </div>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ function categoryReset(url,useAjax){
24
+ if(useAjax){
25
+ var params = {active_tab_id:false};
26
+ updateContent(url, params);
27
+ }
28
+ else{
29
+ location.href = url;
30
+ }
31
+ }
32
+ function categoryDelete(url, useAjax, categoryId) {
33
+ if (confirm('<?php echo Mage::helper('joomi_masonrygallery')->__('Are you sure?') ?>')){
34
+ if (useAjax){
35
+ tree.nodeForDelete = categoryId;
36
+ updateContent(url, {}, true);
37
+ }
38
+ else {
39
+ location.href = url;
40
+ }
41
+ }
42
+ }
43
+ function updateContent(url, params, refreshTree) {
44
+ if (!params) {
45
+ params = {};
46
+ }
47
+ if (!params.form_key) {
48
+ params.form_key = FORM_KEY;
49
+ }
50
+ toolbarToggle.stop();
51
+ var categoryContainer = $('category-edit-container');
52
+ var messagesContainer = $('messages');
53
+ var thisObj = this;
54
+ new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
55
+ parameters: params,
56
+ evalScripts: true,
57
+ onComplete: function () {
58
+ setTimeout(function() {
59
+ try {
60
+ if (refreshTree) {
61
+ thisObj.refreshTreeArea();
62
+ }
63
+ toolbarToggle.start();
64
+ }
65
+ catch (e) {
66
+ alert(e.message);
67
+ };
68
+ }, 25);
69
+ },
70
+ onSuccess: function(transport) {
71
+ try {
72
+ if (transport.responseText.isJSON()) {
73
+ var response = transport.responseText.evalJSON();
74
+ var needUpdate = true;
75
+ if (response.error) {
76
+ alert(response.message);
77
+ needUpdate = false;
78
+ }
79
+ if(response.ajaxExpired && response.ajaxRedirect) {
80
+ setLocation(response.ajaxRedirect);
81
+ needUpdate = false;
82
+ }
83
+ if (needUpdate){
84
+ if (response.content){
85
+ $(categoryContainer).update(response.content);
86
+ }
87
+ if (response.messages){
88
+ $(messagesContainer).update(response.messages);
89
+ }
90
+ }
91
+ }
92
+ else {
93
+ $(categoryContainer).update(transport.responseText);
94
+ }
95
+ }
96
+ catch (e) {
97
+ $(categoryContainer).update(transport.responseText);
98
+ }
99
+ }
100
+ });
101
+ }
102
+ function refreshTreeArea(transport){
103
+ if (tree && window.editingCategoryBreadcrumbs) {
104
+ if (tree.nodeForDelete) {
105
+ var node = tree.getNodeById(tree.nodeForDelete);
106
+ tree.nodeForDelete = false;
107
+ if (node) {
108
+ node.parentNode.removeChild(node);
109
+ tree.currentNodeId = false;
110
+ }
111
+ }
112
+ else if (tree.addNodeTo) {
113
+ var parent = tree.getNodeById(tree.addNodeTo);
114
+ tree.addNodeTo = false;
115
+ if (parent) {
116
+ var node = new Ext.tree.AsyncTreeNode(editingCategoryBreadcrumbs[editingCategoryBreadcrumbs.length - 1]);
117
+ node.loaded = true;
118
+ tree.currentNodeId = node.id;
119
+ parent.appendChild(node);
120
+ if (parent.expanded) {
121
+ tree.selectCurrentNode();
122
+ }
123
+ else {
124
+ var timer;
125
+ parent.expand();
126
+ var f = function(){
127
+ if(parent.expanded){
128
+ clearInterval(timer);
129
+ tree.selectCurrentNode();
130
+ }
131
+ };
132
+ timer = setInterval(f, 200);
133
+ }
134
+ }
135
+ }
136
+ for (var i = 0; i < editingCategoryBreadcrumbs.length; i++) {
137
+ var node = tree.getNodeById(editingCategoryBreadcrumbs[i].id);
138
+ if (node) {
139
+ node.setText(editingCategoryBreadcrumbs[i].text);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ function displayLoadingMask(){
145
+ var loaderArea = $$('#html-body .wrapper')[0];
146
+ Position.clone($(loaderArea), $('loading-mask'), {offsetLeft:-2});
147
+ toggleSelectsUnderBlock($('loading-mask'), false);
148
+ Element.show('loading-mask');
149
+ }
150
+ //]]>
151
+ </script>
app/design/adminhtml/default/default/template/joomi_masonrygallery/category/edit/form.phtml ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div class="content-header">
19
+ <h3 class="icon-head head-categories">
20
+ <?php echo $this->htmlEscape($this->getHeader()) . ($this->getCategoryId() ? ' (' . Mage::helper('joomi_masonrygallery')->__('ID: %s', $this->getCategoryId()) . ')' : '') ?>
21
+ </h3>
22
+ <p class="content-buttons form-buttons">
23
+ <?php echo $this->getResetButtonHtml() ?>
24
+ <?php if($this->getCategoryId()): ?>
25
+ <?php echo $this->getDeleteButtonHtml() ?>
26
+ <?php endif; ?>
27
+ <?php echo $this->getAdditionalButtonsHtml(); ?>
28
+ <?php echo $this->getSaveButtonHtml() ?>
29
+ </p>
30
+ </div>
31
+ <?php echo $this->getTabsHtml() ?>
32
+ <iframe name="iframeSave" style="display:none; width:100%;" src="<?php echo $this->getJsUrl() ?>blank.html"></iframe>
33
+ <form target="iframeSave" id="category_edit_form" action="<?php echo $this->getSaveUrl() ?>" method="post" enctype="multipart/form-data">
34
+ <div class="no-display">
35
+ <input type="hidden" name="isIframe" value="1" />
36
+ <input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>" />
37
+ <input type="hidden" name="active_tab_id" id="active_tab_id" value="" />
38
+ </div>
39
+ <div id="category_tab_content"></div>
40
+ </form>
41
+ <script type="text/javascript">
42
+ //<![CDATA[
43
+ categoryForm = new varienForm('category_edit_form');
44
+ categoryForm.submit= function (url) {
45
+ this.errorSections = $H({});
46
+ this.canShowError = true;
47
+ this.submitUrl = url;
48
+ if (this.validator && this.validator.validate()) {
49
+ if(this.validationUrl){
50
+ this._validate();
51
+ }
52
+ else{
53
+ if (this.isSubmitted) {
54
+ return false;
55
+ }
56
+ this.isSubmitted = true;
57
+ this._submit();
58
+ }
59
+ displayLoadingMask();
60
+ return true;
61
+ }
62
+ return false;
63
+ };
64
+ categoryForm.refreshPath = function () {
65
+ categoryId = this.getCategoryId();
66
+ if (!categoryId) {
67
+ return false;
68
+ }
69
+ var refreshPathSuccess = function(transport) {
70
+ if (transport.responseText.isJSON()) {
71
+ response = transport.responseText.evalJSON()
72
+ if (response.error) {
73
+ alert(response.message);
74
+ }
75
+ else {
76
+ if (categoryForm.getCategoryId() == response['id']) {
77
+ categoryForm.setCategoryPath(response['path']);
78
+ }
79
+ }
80
+ }
81
+ };
82
+ new Ajax.Request(
83
+ '<?php echo $this->getRefreshPathUrl() ?>',
84
+ {
85
+ method: 'POST',
86
+ evalScripts: true,
87
+ onSuccess: refreshPathSuccess
88
+ }
89
+ );
90
+ };
91
+
92
+ categoryForm.getCategoryId = function () {
93
+ collection = $(this.formId).getInputs('hidden','category[id]');
94
+ if (collection.size() > 0) {
95
+ return collection.first().value;
96
+ }
97
+ return false;
98
+ };
99
+ categoryForm.setCategoryPath = function (path) {
100
+ collection = $(this.formId).getInputs('hidden','category[path]');
101
+ if (collection.size() > 0) {
102
+ return collection.first().value = path;
103
+ }
104
+ };
105
+ function categorySubmit(url, useAjax) {
106
+ var activeTab = $('active_tab_id');
107
+ if (activeTab) {
108
+ if (activeTab.tabsJsObject && activeTab.tabsJsObject.activeTab) {
109
+ activeTab.value = activeTab.tabsJsObject.activeTab.id;
110
+ }
111
+ }
112
+ var params = {};
113
+ var fields = $('category_edit_form').getElementsBySelector('input', 'select');
114
+ for(var i=0;i<fields.length;i++){
115
+ if (!fields[i].name) {
116
+ continue;
117
+ }
118
+ params[fields[i].name] = fields[i].getValue();
119
+ }
120
+ var categoryId = params['category[id]'] ? params['category[id]'] : 0;
121
+ var isCreating = categoryId == 0;
122
+ var path = params['category[path]'].split('/');
123
+ var parentId = path.pop();
124
+ if (parentId == categoryId) {
125
+ parentId = path.pop();
126
+ }
127
+ if (isCreating) {
128
+ if (!tree.currentNodeId) {
129
+ tree.currentNodeId = parentId;
130
+ }
131
+ tree.addNodeTo = parentId;
132
+ }
133
+ else {
134
+ var currentNode = tree.getNodeById(categoryId);
135
+ var oldClass = 'active-category';
136
+ var newClass = 'active-category';
137
+ if (currentNode) {
138
+ if (parseInt(params['category[status]'])) {
139
+ var oldClass = 'no-active-category';
140
+ var newClass = 'active-category';
141
+ }
142
+ else {
143
+ var oldClass = 'active-category';
144
+ var newClass = 'no-active-category';
145
+ }
146
+ Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
147
+ Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
148
+ }
149
+ }
150
+ categoryForm.submit();
151
+ }
152
+ <?php if($this->isAjax() && ($block = $this->getLayout()->getBlock('tabs')) && ($_tabsJsObject=$block->getJsObjectName())): ?>
153
+ <?php echo $_tabsJsObject ?>.moveTabContentInDest();
154
+ if (<?php echo $_tabsJsObject ?>.activeTab) {
155
+ $('active_tab_id').value = <?php echo $_tabsJsObject ?>.activeTab.id;
156
+ }
157
+ $('active_tab_id').tabsJsObject = <?php echo $_tabsJsObject ?>;
158
+ <?php endif; ?>
159
+ //]]>
160
+ </script>
app/design/adminhtml/default/default/template/joomi_masonrygallery/category/tree.phtml ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div class="categories-side-col">
19
+ <div class="content-header">
20
+ <h3 class="icon-head head-categories">
21
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Categories') ?>
22
+ </h3>
23
+ <?php if ($this->getRoot()): ?>
24
+ <?php echo $this->getAddRootButtonHtml() ?><br />
25
+ <?php echo $this->getAddSubButtonHtml() ?>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div class="tree-actions">
29
+ <?php if($this->getRoot()): ?>
30
+ <a href="#" onclick="tree.collapseTree(); return false;">
31
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Collapse All'); ?>
32
+ </a>
33
+ <span class="separator">|</span>
34
+ <a href="#" onclick="tree.expandTree(); return false;">
35
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Expand All'); ?>
36
+ </a>
37
+ <?php endif; ?>
38
+ </div>
39
+ <?php if ($this->getRoot()): ?>
40
+ <div class="tree-holder">
41
+ <div id="tree-div" style="width:100%; overflow:auto;"></div>
42
+ </div>
43
+ </div>
44
+ <script type="text/javascript">
45
+ //<![CDATA[
46
+ var tree;
47
+ /**
48
+ * Fix ext compatibility with prototype 1.6
49
+ */
50
+ Ext.lib.Event.getTarget = function(e) {
51
+ var ee = e.browserEvent || e;
52
+ return ee.target ? Event.element(ee) : null;
53
+ };
54
+ Ext.tree.TreePanel.Enhanced = function(el, config){
55
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
56
+ };
57
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
58
+ loadTree : function(config, firstLoad){
59
+ var parameters = config['parameters'];
60
+ var data = config['data'];
61
+ if ((typeof parameters['root_visible']) != 'undefined') {
62
+ this.rootVisible = parameters['root_visible']*1;
63
+ }
64
+ var root = new Ext.tree.TreeNode(parameters);
65
+ this.nodeHash = {};
66
+ this.setRootNode(root);
67
+ if (firstLoad) {
68
+ this.addListener('click', this.categoryClick);
69
+ this.addListener('beforenodedrop', categoryMove.createDelegate(this));
70
+ }
71
+ this.loader.buildCategoryTree(root, data);
72
+ this.el.dom.innerHTML = '';
73
+ // render the tree
74
+ this.render();
75
+ if (parameters['expanded']) {
76
+ this.expandAll();
77
+ }
78
+ else {
79
+ root.expand();
80
+ }
81
+ var selectedNode = this.getNodeById(parameters['category_id']);
82
+ if (selectedNode) {
83
+ this.currentNodeId = parameters['category_id'];
84
+ }
85
+ this.selectCurrentNode();
86
+ },
87
+ request : function(url, params){
88
+ if (!params) {
89
+ if (category_info_tabsJsTabs.activeTab) {
90
+ var params = {active_tab_id:category_info_tabsJsTabs.activeTab.id};
91
+ }
92
+ else {
93
+ var params = {};
94
+ }
95
+ }
96
+ if (!params.form_key) {
97
+ params.form_key = FORM_KEY;
98
+ }
99
+ var result = new Ajax.Request(
100
+ url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
101
+ {
102
+ parameters: params,
103
+ method: 'post'
104
+ }
105
+ );
106
+ return result;
107
+ },
108
+ selectCurrentNode : function(){
109
+ if (this.currentNodeId) {
110
+ var selectedNode = this.getNodeById(this.currentNodeId);
111
+ if ((typeof selectedNode.attributes.path)!='undefined') {
112
+ var path = selectedNode.attributes.path;
113
+ path = '0/'+path;
114
+ this.selectPath(path);
115
+ }
116
+ else {
117
+ this.getSelectionModel().select(selectedNode);
118
+ }
119
+ }
120
+ },
121
+ collapseTree : function(){
122
+ this.collapseAll();
123
+ this.selectCurrentNode();
124
+ if (!this.collapsed) {
125
+ this.collapsed = true;
126
+ this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(false) ?>';
127
+ this.request(this.loader.dataUrl, false);
128
+ }
129
+ },
130
+ expandTree : function(){
131
+ this.expandAll();
132
+ if (this.collapsed) {
133
+ this.collapsed = false;
134
+ this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(true) ?>';
135
+ this.request(this.loader.dataUrl, false);
136
+ }
137
+ },
138
+ categoryClick : function(node, e){
139
+ var baseUrl = '<?php echo $this->getEditUrl() ?>';
140
+ var urlExt = 'id/'+node.id+'/';
141
+ var url = parseSidUrl(baseUrl, urlExt);
142
+ this.currentNodeId = node.id;
143
+ if (!this.useAjax) {
144
+ setLocation(url);
145
+ return;
146
+ }
147
+ if (category_info_tabsJsTabs.activeTab) {
148
+ var params = {active_tab_id:category_info_tabsJsTabs.activeTab.id};
149
+ }
150
+ updateContent(url, params);
151
+ }
152
+ });
153
+ function reRenderTree(event){
154
+ if (tree && event) {
155
+ var obj = event.target;
156
+ if ($('add_root_category_button')) {
157
+ $('add_root_category_button').show();
158
+ }
159
+ // retain current selected category id
160
+ var url = tree.switchTreeUrl;
161
+ // load from cache
162
+ // load from ajax
163
+ new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
164
+ parameters : {form_key: FORM_KEY},
165
+ method : 'post',
166
+ onComplete : function(transport) {
167
+ var response = eval('(' + transport.responseText + ')');
168
+ if (!response['parameters']) {
169
+ return false;
170
+ }
171
+ _renderNewTree(response);
172
+ }
173
+ });
174
+ }
175
+ // render default tree
176
+ else {
177
+ _renderNewTree();
178
+ }
179
+ }
180
+ function _renderNewTree(config){
181
+ if (!config) {
182
+ var config = defaultLoadTreeParams;
183
+ }
184
+ if (tree) {
185
+ tree.purgeListeners();
186
+ tree.el.dom.innerHTML = '';
187
+ }
188
+ tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams);
189
+ tree.loadTree(config, true);
190
+ // try to select current category
191
+ var selectedNode = tree.getNodeById(config.parameters.category_id);
192
+ if (selectedNode) {
193
+ tree.currentNodeId = config.parameters.category_id;
194
+ }
195
+ tree.selectCurrentNode();
196
+ // update content area
197
+ var url = tree.editUrl;
198
+ <?php if ($this->isClearEdit()):?>
199
+ if (selectedNode) {
200
+ url = url + 'id/' + config.parameters.category_id;
201
+ }
202
+ <?php endif;?>
203
+ updateContent(url);
204
+ }
205
+ Ext.onReady(function(){
206
+ categoryLoader = new Ext.tree.TreeLoader({
207
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
208
+ });
209
+ categoryLoader.createNode = function(config) {
210
+ var node;
211
+ var _node = Object.clone(config);
212
+ if (config.children && !config.children.length) {
213
+ delete(config.children);
214
+ node = new Ext.tree.AsyncTreeNode(config);
215
+ }
216
+ else {
217
+ node = new Ext.tree.TreeNode(config);
218
+ }
219
+ return node;
220
+ };
221
+ categoryLoader.buildCategoryTree = function(parent, config){
222
+ if (!config) {
223
+ return null;
224
+ }
225
+ if (parent && config && config.length){
226
+ for (var i = 0; i < config.length; i++) {
227
+ var node;
228
+ var _node = Object.clone(config[i]);
229
+ if (_node.children && !_node.children.length) {
230
+ delete(_node.children);
231
+ node = new Ext.tree.AsyncTreeNode(_node);
232
+ }
233
+ else {
234
+ node = new Ext.tree.TreeNode(config[i]);
235
+ }
236
+ parent.appendChild(node);
237
+ node.loader = node.getOwnerTree().loader;
238
+ if (_node.children) {
239
+ this.buildCategoryTree(node, _node.children);
240
+ }
241
+ }
242
+ }
243
+ };
244
+ categoryLoader.buildHash = function(node){
245
+ var hash = {};
246
+ hash = this.toArray(node.attributes);
247
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
248
+ hash['children'] = new Array;
249
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
250
+ if (!hash['children']) {
251
+ hash['children'] = new Array;
252
+ }
253
+ hash['children'].push(this.buildHash(node.childNodes[i]));
254
+ }
255
+ }
256
+ return hash;
257
+ };
258
+ categoryLoader.toArray = function(attributes) {
259
+ var data = {form_key: FORM_KEY};
260
+ for (var key in attributes) {
261
+ var value = attributes[key];
262
+ data[key] = value;
263
+ }
264
+ return data;
265
+ };
266
+ categoryLoader.on("beforeload", function(treeLoader, node) {
267
+ treeLoader.baseParams.id = node.attributes.id;
268
+ treeLoader.baseParams.form_key = FORM_KEY;
269
+ });
270
+ categoryLoader.on("load", function(treeLoader, node, config) {
271
+ varienWindowOnload();
272
+ });
273
+ newTreeParams = {
274
+ animate : false,
275
+ loader : categoryLoader,
276
+ enableDD: true,
277
+ containerScroll : true,
278
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
279
+ rootVisible : false,
280
+ useAjax : <?php echo $this->getUseAjax() ?>,
281
+ switchTreeUrl : '<?php echo $this->getSwitchTreeUrl() ?>',
282
+ editUrl : '<?php echo $this->getEditUrl() ?>',
283
+ currentNodeId : <?php echo (int) $this->getCategoryId() ?>
284
+ };
285
+ defaultLoadTreeParams = {
286
+ parameters : {
287
+ text: '<?php echo htmlentities($this->getRoot()->getTitle()) ?>',
288
+ draggable : false,
289
+ allowDrop : true,
290
+ id : <?php echo (int) $this->getRoot()->getId() ?>,
291
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
292
+ category_id : <?php echo (int) $this->getCategoryId() ?>
293
+ },
294
+ data : <?php echo $this->getTreeJson() ?>
295
+ };
296
+ reRenderTree();
297
+ });
298
+
299
+ function addNew(url, isRoot){
300
+ if (isRoot) {
301
+ tree.currentNodeId = tree.root.id;
302
+ }
303
+ url+= 'parent/'+tree.currentNodeId;
304
+ updateContent(url);
305
+ }
306
+ function categoryMove(obj){
307
+ var data = {id: obj.dropNode.id, form_key: FORM_KEY};
308
+ data.point = obj.point;
309
+ switch (obj.point) {
310
+ case 'above' :
311
+ data.pid = obj.target.parentNode.id;
312
+ data.paid = obj.dropNode.parentNode.id;
313
+ if (obj.target.previousSibling) {
314
+ data.aid = obj.target.previousSibling.id;
315
+ }
316
+ else {
317
+ data.aid = 0;
318
+ }
319
+ break;
320
+ case 'below' :
321
+ data.pid = obj.target.parentNode.id;
322
+ data.aid = obj.target.id;
323
+ break;
324
+ case 'append' :
325
+ data.pid = obj.target.id;
326
+ data.paid = obj.dropNode.parentNode.id;
327
+ if (obj.target.lastChild) {
328
+ data.aid = obj.target.lastChild.id;
329
+ } else {
330
+ data.aid = 0;
331
+ }
332
+ break;
333
+ default :
334
+ obj.cancel = true;
335
+ return obj;
336
+ }
337
+ var success = function(o) {
338
+ try {
339
+ if(o.responseText){
340
+ if(o.responseText==='SUCCESS'){
341
+ categoryForm.refreshPath();
342
+ }
343
+ else {
344
+ alert(o.responseText);
345
+ location.reload();
346
+ }
347
+ }
348
+ }
349
+ catch(e) {}
350
+ };
351
+ var failure = function(o) {
352
+ try {
353
+ console.log(o.statusText);
354
+ } catch (e2) {
355
+ alert(o.statusText);
356
+ }
357
+ location.reload();
358
+ };
359
+ var pd = [];
360
+ for(var key in data) {
361
+ pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&");
362
+ }
363
+ pd.splice(pd.length-1,1);
364
+ new Ajax.Request(
365
+ '<?php echo $this->getMoveUrl() ?>',
366
+ {
367
+ method: 'POST',
368
+ parameters: pd.join(""),
369
+ onSuccess : success,
370
+ onFailure : failure
371
+ }
372
+ );
373
+ }
374
+ //]]>
375
+ </script>
376
+ <?php endif; ?>
app/design/adminhtml/default/default/template/joomi_masonrygallery/category/widget/tree.phtml ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <?php $_divId = 'tree' . $this->getId() ?>
19
+ <div id="<?php echo $_divId ?>" class="tree"></div>
20
+ <script type="text/javascript">
21
+ //<![CDATA[
22
+ var tree<?php echo $this->getId() ?>;
23
+ var useMassaction = <?php echo $this->getUseMassaction()?1:0; ?>;
24
+ Ext.tree.TreePanel.Enhanced = function(el, config){
25
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
26
+ };
27
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
28
+ loadTree : function(config, firstLoad){
29
+ var parameters = config['parameters'];
30
+ var data = config['data'];
31
+ if ((typeof parameters['root_visible']) != 'undefined') {
32
+ this.rootVisible = parameters['root_visible']*1;
33
+ }
34
+ var root = new Ext.tree.TreeNode(parameters);
35
+ this.nodeHash = {};
36
+ this.setRootNode(root);
37
+ if (firstLoad) {
38
+ <?php if ($this->getNodeClickListener()): ?>
39
+ this.addListener('click', <?php echo $this->getNodeClickListener() ?>.createDelegate(this));
40
+ <?php endif; ?>
41
+ }
42
+ this.loader.buildCategoryTree(root, data);
43
+ this.el.dom.innerHTML = '';
44
+ this.render();
45
+ }
46
+ });
47
+
48
+ Ext.onReady(function(){
49
+ var emptyNodeAdded = <?php echo ($this->getWithEmptyNode() ? 'false' : 'true') ?>;
50
+ var categoryLoader = new Ext.tree.TreeLoader({
51
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
52
+ });
53
+
54
+ categoryLoader.buildCategoryTree = function(parent, config){
55
+ if (!config) {
56
+ return null;
57
+ }
58
+ if (parent && config && config.length){
59
+ for (var i = 0; i < config.length; i++) {
60
+ var node;
61
+ if (useMassaction) {
62
+ config[i].uiProvider = Ext.tree.CheckboxNodeUI;
63
+ }
64
+ var _node = Object.clone(config[i]);
65
+
66
+ if(!emptyNodeAdded) {
67
+ var empty = Object.clone(_node);
68
+ empty.text = '<?php echo $this->__('None') ?>';
69
+ empty.children = [];
70
+ empty.id = 'none';
71
+ empty.path = '1/none';
72
+ empty.cls = 'leaf';
73
+ parent.appendChild(new Ext.tree.TreeNode(empty));
74
+ emptyNodeAdded = true;
75
+ }
76
+
77
+ if (_node.children && !_node.children.length) {
78
+ delete(_node.children);
79
+ node = new Ext.tree.AsyncTreeNode(_node);
80
+ }
81
+ else {
82
+ node = new Ext.tree.TreeNode(config[i]);
83
+ }
84
+ parent.appendChild(node);
85
+ node.loader = node.getOwnerTree().loader;
86
+ node.loader = node.getOwnerTree().loader;
87
+ if (_node.children) {
88
+ this.buildCategoryTree(node, _node.children);
89
+ }
90
+ }
91
+ }
92
+ };
93
+
94
+ categoryLoader.createNode = function(config) {
95
+ var node;
96
+ if (useMassaction) {
97
+ config.uiProvider = Ext.tree.CheckboxNodeUI;
98
+ }
99
+ var _node = Object.clone(config);
100
+ if (config.children && !config.children.length) {
101
+ delete(config.children);
102
+ node = new Ext.tree.AsyncTreeNode(config);
103
+ }
104
+ else {
105
+ node = new Ext.tree.TreeNode(config);
106
+ }
107
+ return node;
108
+ };
109
+
110
+ categoryLoader.buildHash = function(node){
111
+ var hash = {};
112
+
113
+ hash = this.toArray(node.attributes);
114
+
115
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
116
+ hash['children'] = new Array;
117
+
118
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
119
+ if (!hash['children']) {
120
+ hash['children'] = new Array;
121
+ }
122
+ hash['children'].push(this.buildHash(node.childNodes[i]));
123
+ }
124
+ }
125
+
126
+ return hash;
127
+ };
128
+
129
+ categoryLoader.toArray = function(attributes) {
130
+ var data = {};
131
+ for (var key in attributes) {
132
+ var value = attributes[key];
133
+ data[key] = value;
134
+ }
135
+ return data;
136
+ };
137
+
138
+ categoryLoader.on("beforeload", function(treeLoader, node) {
139
+ treeLoader.baseParams.id = node.attributes.id;
140
+ });
141
+
142
+ tree<?php echo $this->getId() ?> = new Ext.tree.TreePanel.Enhanced('<?php echo $_divId ?>', {
143
+ animate: false,
144
+ loader: categoryLoader,
145
+ enableDD: false,
146
+ containerScroll: true,
147
+ rootVisible: '<?php echo $this->getRoot()->getIsVisible() ?>',
148
+ useAjax: true,
149
+ currentNodeId:<?php echo (int) $this->getCategoryId() ?>,
150
+ addNodeTo:false
151
+ });
152
+
153
+ if (useMassaction) {
154
+ tree<?php echo $this->getId() ?>.on('check', function(node) {
155
+ $('<?php echo $_divId; ?>').fire('node:changed', {node:node});
156
+ }, tree<?php echo $this->getId() ?>);
157
+ }
158
+
159
+ // set the root node
160
+ var parameters = {
161
+ text:'Psw',
162
+ draggable: false,
163
+ id: <?php echo (int) $this->getRoot()->getId() ?>,
164
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
165
+ category_id: <?php echo (int) $this->getCategoryId() ?>
166
+ };
167
+
168
+ tree<?php echo $this->getId() ?>.loadTree({parameters:parameters, data:<?php echo $this->getTreeJson() ?>},true);
169
+
170
+ });
171
+ //]]>
172
+ </script>
app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/edit.phtml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div id="gallery-edit-container" class="category-content">
19
+ <?php echo $this->getChildHtml('form') ?>
20
+ </div>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ function galleryReset(url,useAjax){
24
+ if(useAjax){
25
+ var params = {active_tab_id:false};
26
+ updateContent(url, params);
27
+ }
28
+ else{
29
+ location.href = url;
30
+ }
31
+ }
32
+ function galleryDelete(url, useAjax, galleryId) {
33
+ if (confirm('<?php echo Mage::helper('joomi_masonrygallery')->__('Are you sure?') ?>')){
34
+ if (useAjax){
35
+ tree.nodeForDelete = galleryId;
36
+ updateContent(url, {}, true);
37
+ }
38
+ else {
39
+ location.href = url;
40
+ }
41
+ }
42
+ }
43
+ function updateContent(url, params, refreshTree) {
44
+ if (!params) {
45
+ params = {};
46
+ }
47
+ if (!params.form_key) {
48
+ params.form_key = FORM_KEY;
49
+ }
50
+ toolbarToggle.stop();
51
+ var galleryContainer = $('gallery-edit-container');
52
+ var messagesContainer = $('messages');
53
+ var thisObj = this;
54
+ new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
55
+ parameters: params,
56
+ evalScripts: true,
57
+ onComplete: function () {
58
+ setTimeout(function() {
59
+ try {
60
+ if (refreshTree) {
61
+ thisObj.refreshTreeArea();
62
+ }
63
+ toolbarToggle.start();
64
+ }
65
+ catch (e) {
66
+ alert(e.message);
67
+ };
68
+ }, 25);
69
+ },
70
+ onSuccess: function(transport) {
71
+ try {
72
+ if (transport.responseText.isJSON()) {
73
+ var response = transport.responseText.evalJSON();
74
+ var needUpdate = true;
75
+ if (response.error) {
76
+ alert(response.message);
77
+ needUpdate = false;
78
+ }
79
+ if(response.ajaxExpired && response.ajaxRedirect) {
80
+ setLocation(response.ajaxRedirect);
81
+ needUpdate = false;
82
+ }
83
+ if (needUpdate){
84
+ if (response.content){
85
+ $(galleryContainer).update(response.content);
86
+ }
87
+ if (response.messages){
88
+ $(messagesContainer).update(response.messages);
89
+ }
90
+ }
91
+ }
92
+ else {
93
+ $(galleryContainer).update(transport.responseText);
94
+ }
95
+ }
96
+ catch (e) {
97
+ $(galleryContainer).update(transport.responseText);
98
+ }
99
+ }
100
+ });
101
+ }
102
+ function refreshTreeArea(transport){
103
+ if (tree && window.editingGalleryBreadcrumbs) {
104
+ if (tree.nodeForDelete) {
105
+ var node = tree.getNodeById(tree.nodeForDelete);
106
+ tree.nodeForDelete = false;
107
+ if (node) {
108
+ node.parentNode.removeChild(node);
109
+ tree.currentNodeId = false;
110
+ }
111
+ }
112
+ else if (tree.addNodeTo) {
113
+ var parent = tree.getNodeById(tree.addNodeTo);
114
+ tree.addNodeTo = false;
115
+ if (parent) {
116
+ var node = new Ext.tree.AsyncTreeNode(editingGalleryBreadcrumbs[editingGalleryBreadcrumbs.length - 1]);
117
+ node.loaded = true;
118
+ tree.currentNodeId = node.id;
119
+ parent.appendChild(node);
120
+ if (parent.expanded) {
121
+ tree.selectCurrentNode();
122
+ }
123
+ else {
124
+ var timer;
125
+ parent.expand();
126
+ var f = function(){
127
+ if(parent.expanded){
128
+ clearInterval(timer);
129
+ tree.selectCurrentNode();
130
+ }
131
+ };
132
+ timer = setInterval(f, 200);
133
+ }
134
+ }
135
+ }
136
+ for (var i = 0; i < editingGalleryBreadcrumbs.length; i++) {
137
+ var node = tree.getNodeById(editingGalleryBreadcrumbs[i].id);
138
+ if (node) {
139
+ node.setText(editingGalleryBreadcrumbs[i].text);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ function displayLoadingMask(){
145
+ var loaderArea = $$('#html-body .wrapper')[0];
146
+ Position.clone($(loaderArea), $('loading-mask'), {offsetLeft:-2});
147
+ toggleSelectsUnderBlock($('loading-mask'), false);
148
+ Element.show('loading-mask');
149
+ }
150
+ //]]>
151
+ </script>
app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/edit/form.phtml ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div class="content-header">
19
+ <h3 class="icon-head head-categories">
20
+ <?php echo $this->htmlEscape($this->getHeader()) . ($this->getGalleryId() ? ' (' . Mage::helper('joomi_masonrygallery')->__('ID: %s', $this->getGalleryId()) . ')' : '') ?>
21
+ </h3>
22
+ <p class="content-buttons form-buttons">
23
+ <?php echo $this->getResetButtonHtml() ?>
24
+ <?php if($this->getGalleryId()): ?>
25
+ <?php echo $this->getDeleteButtonHtml() ?>
26
+ <?php endif; ?>
27
+ <?php echo $this->getAdditionalButtonsHtml(); ?>
28
+ <?php echo $this->getSaveButtonHtml() ?>
29
+ </p>
30
+ </div>
31
+ <?php echo $this->getTabsHtml() ?>
32
+ <iframe name="iframeSave" style="display:none; width:100%;" src="<?php echo $this->getJsUrl() ?>blank.html"></iframe>
33
+ <form target="iframeSave" id="gallery_edit_form" action="<?php echo $this->getSaveUrl() ?>" method="post" enctype="multipart/form-data">
34
+ <div class="no-display">
35
+ <input type="hidden" name="isIframe" value="1" />
36
+ <input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>" />
37
+ <input type="hidden" name="active_tab_id" id="active_tab_id" value="" />
38
+ <input type="hidden" name="gallery_products" id="in_gallery_products" value="" />
39
+ </div>
40
+ <div id="gallery_tab_content"></div>
41
+ </form>
42
+ <script type="text/javascript">
43
+ //<![CDATA[
44
+ galleryForm = new varienForm('gallery_edit_form');
45
+ galleryForm.submit= function (url) {
46
+ this.errorSections = $H({});
47
+ this.canShowError = true;
48
+ this.submitUrl = url;
49
+ if (this.validator && this.validator.validate()) {
50
+ if(this.validationUrl){
51
+ this._validate();
52
+ }
53
+ else{
54
+ if (this.isSubmitted) {
55
+ return false;
56
+ }
57
+ this.isSubmitted = true;
58
+ this._submit();
59
+ }
60
+ displayLoadingMask();
61
+ return true;
62
+ }
63
+ return false;
64
+ };
65
+ galleryForm.refreshPath = function () {
66
+ galleryId = this.getGalleryId();
67
+ if (!galleryId) {
68
+ return false;
69
+ }
70
+ var refreshPathSuccess = function(transport) {
71
+ if (transport.responseText.isJSON()) {
72
+ response = transport.responseText.evalJSON()
73
+ if (response.error) {
74
+ alert(response.message);
75
+ }
76
+ else {
77
+ if (galleryForm.getGalleryId() == response['id']) {
78
+ galleryForm.setGalleryPath(response['path']);
79
+ }
80
+ }
81
+ }
82
+ };
83
+ new Ajax.Request(
84
+ '<?php echo $this->getRefreshPathUrl() ?>',
85
+ {
86
+ method: 'POST',
87
+ evalScripts: true,
88
+ onSuccess: refreshPathSuccess
89
+ }
90
+ );
91
+ };
92
+
93
+ galleryForm.getGalleryId = function () {
94
+ collection = $(this.formId).getInputs('hidden','gallery[id]');
95
+ if (collection.size() > 0) {
96
+ return collection.first().value;
97
+ }
98
+ return false;
99
+ };
100
+ galleryForm.setGalleryPath = function (path) {
101
+ collection = $(this.formId).getInputs('hidden','gallery[path]');
102
+ if (collection.size() > 0) {
103
+ return collection.first().value = path;
104
+ }
105
+ };
106
+ function gallerySubmit(url, useAjax) {
107
+ var activeTab = $('active_tab_id');
108
+ if (activeTab) {
109
+ if (activeTab.tabsJsObject && activeTab.tabsJsObject.activeTab) {
110
+ activeTab.value = activeTab.tabsJsObject.activeTab.id;
111
+ }
112
+ }
113
+ var params = {};
114
+ var fields = $('gallery_edit_form').getElementsBySelector('input', 'select');
115
+ for(var i=0;i<fields.length;i++){
116
+ if (!fields[i].name) {
117
+ continue;
118
+ }
119
+ params[fields[i].name] = fields[i].getValue();
120
+ }
121
+ var galleryId = params['gallery[id]'] ? params['gallery[id]'] : 0;
122
+ var isCreating = galleryId == 0;
123
+ var path = params['gallery[path]'].split('/');
124
+ var parentId = path.pop();
125
+ if (parentId == galleryId) {
126
+ parentId = path.pop();
127
+ }
128
+ if (isCreating) {
129
+ if (!tree.currentNodeId) {
130
+ tree.currentNodeId = parentId;
131
+ }
132
+ tree.addNodeTo = parentId;
133
+ }
134
+ else {
135
+ var currentNode = tree.getNodeById(galleryId);
136
+ var oldClass = 'active-category';
137
+ var newClass = 'active-category';
138
+ if (currentNode) {
139
+ if (parseInt(params['gallery[status]'])) {
140
+ var oldClass = 'no-active-category';
141
+ var newClass = 'active-category';
142
+ }
143
+ else {
144
+ var oldClass = 'active-category';
145
+ var newClass = 'no-active-category';
146
+ }
147
+ Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
148
+ Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
149
+ }
150
+ }
151
+ galleryForm.submit();
152
+ }
153
+ <?php if(($block = $this->getLayout()->getBlock('gallery.product.grid')) && ($_gridJsObject=$block->getJsObjectName())): ?>
154
+ var galleryProducts = $H(<?php echo $this->getProductsJson() ?>);
155
+ $('in_gallery_products').value = galleryProducts.toQueryString();
156
+ function registerGalleryProduct(grid, element, checked){
157
+ if(checked){
158
+ if(element.positionElement){
159
+ element.positionElement.disabled = false;
160
+ galleryProducts.set(element.value, element.positionElement.value);
161
+ }
162
+ }
163
+ else{
164
+ if(element.positionElement){
165
+ element.positionElement.disabled = true;
166
+ }
167
+ galleryProducts.unset(element.value);
168
+ }
169
+ $('in_gallery_products').value = galleryProducts.toQueryString();
170
+ grid.reloadParams = {'selected_products[]':galleryProducts.keys()};
171
+ }
172
+ function galleryProductRowClick(grid, event){
173
+ var trElement = Event.findElement(event, 'tr');
174
+ var isInput = Event.element(event).tagName == 'INPUT';
175
+ if(trElement){
176
+ var checkbox = Element.getElementsBySelector(trElement, 'input');
177
+ if(checkbox[0]){
178
+ var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
179
+ <?php echo $_gridJsObject ?>.setCheckboxChecked(checkbox[0], checked);
180
+ }
181
+ }
182
+ }
183
+ function positionChange(event){
184
+ var element = Event.element(event);
185
+ if(element && element.checkboxElement && element.checkboxElement.checked){
186
+ galleryProducts.set(element.checkboxElement.value, element.value);
187
+ $('in_gallery_products').value = galleryProducts.toQueryString();
188
+ }
189
+ }
190
+ var tabIndex = 1000;
191
+ function galleryProductRowInit(grid, row){
192
+ var checkbox = $(row).getElementsByClassName('checkbox')[0];
193
+ var position = $(row).getElementsByClassName('input-text')[0];
194
+ if(checkbox && position){
195
+ checkbox.positionElement = position;
196
+ position.checkboxElement = checkbox;
197
+ position.disabled = !checkbox.checked;
198
+ position.tabIndex = tabIndex++;
199
+ Event.observe(position,'keyup',positionChange);
200
+ }
201
+ }
202
+ <?php echo $_gridJsObject ?>.rowClickCallback = galleryProductRowClick;
203
+ <?php echo $_gridJsObject ?>.initRowCallback = galleryProductRowInit;
204
+ <?php echo $_gridJsObject ?>.checkboxCheckCallback = registerGalleryProduct;
205
+ <?php echo $_gridJsObject ?>.rows.each(function(row){
206
+ galleryProductRowInit(<?php echo $_gridJsObject ?>, row)
207
+ });
208
+ <?php endif; ?>
209
+ <?php if($this->isAjax() && ($block = $this->getLayout()->getBlock('tabs')) && ($_tabsJsObject=$block->getJsObjectName())): ?>
210
+ <?php echo $_tabsJsObject ?>.moveTabContentInDest();
211
+ if (<?php echo $_tabsJsObject ?>.activeTab) {
212
+ $('active_tab_id').value = <?php echo $_tabsJsObject ?>.activeTab.id;
213
+ }
214
+ $('active_tab_id').tabsJsObject = <?php echo $_tabsJsObject ?>;
215
+ <?php endif; ?>
216
+ //]]>
217
+ </script>
app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/tree.phtml ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div class="categories-side-col">
19
+ <div class="content-header">
20
+ <h3 class="icon-head head-galleries">
21
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Galleries') ?>
22
+ </h3>
23
+ <?php if ($this->getRoot()): ?>
24
+ <?php echo $this->getAddRootButtonHtml() ?><br />
25
+ <?php echo $this->getAddSubButtonHtml() ?>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div class="tree-actions">
29
+ <?php if($this->getRoot()): ?>
30
+ <a href="#" onclick="tree.collapseTree(); return false;">
31
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Collapse All'); ?>
32
+ </a>
33
+ <span class="separator">|</span>
34
+ <a href="#" onclick="tree.expandTree(); return false;">
35
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Expand All'); ?>
36
+ </a>
37
+ <?php endif; ?>
38
+ </div>
39
+ <?php if ($this->getRoot()): ?>
40
+ <div class="tree-holder">
41
+ <div id="tree-div" style="width:100%; overflow:auto;"></div>
42
+ </div>
43
+ </div>
44
+ <script type="text/javascript">
45
+ //<![CDATA[
46
+ var tree;
47
+ /**
48
+ * Fix ext compatibility with prototype 1.6
49
+ */
50
+ Ext.lib.Event.getTarget = function(e) {
51
+ var ee = e.browserEvent || e;
52
+ return ee.target ? Event.element(ee) : null;
53
+ };
54
+ Ext.tree.TreePanel.Enhanced = function(el, config){
55
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
56
+ };
57
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
58
+ loadTree : function(config, firstLoad){
59
+ var parameters = config['parameters'];
60
+ var data = config['data'];
61
+ if ((typeof parameters['root_visible']) != 'undefined') {
62
+ this.rootVisible = parameters['root_visible']*1;
63
+ }
64
+ var root = new Ext.tree.TreeNode(parameters);
65
+ this.nodeHash = {};
66
+ this.setRootNode(root);
67
+ if (firstLoad) {
68
+ this.addListener('click', this.galleryClick);
69
+ this.addListener('beforenodedrop', galleryMove.createDelegate(this));
70
+ }
71
+ this.loader.buildGalleryTree(root, data);
72
+ this.el.dom.innerHTML = '';
73
+ // render the tree
74
+ this.render();
75
+ if (parameters['expanded']) {
76
+ this.expandAll();
77
+ }
78
+ else {
79
+ root.expand();
80
+ }
81
+ var selectedNode = this.getNodeById(parameters['gallery_id']);
82
+ if (selectedNode) {
83
+ this.currentNodeId = parameters['gallery_id'];
84
+ }
85
+ this.selectCurrentNode();
86
+ },
87
+ request : function(url, params){
88
+ if (!params) {
89
+ if (gallery_info_tabsJsTabs.activeTab) {
90
+ var params = {active_tab_id:gallery_info_tabsJsTabs.activeTab.id};
91
+ }
92
+ else {
93
+ var params = {};
94
+ }
95
+ }
96
+ if (!params.form_key) {
97
+ params.form_key = FORM_KEY;
98
+ }
99
+ var result = new Ajax.Request(
100
+ url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
101
+ {
102
+ parameters: params,
103
+ method: 'post'
104
+ }
105
+ );
106
+ return result;
107
+ },
108
+ selectCurrentNode : function(){
109
+ if (this.currentNodeId) {
110
+ var selectedNode = this.getNodeById(this.currentNodeId);
111
+ if ((typeof selectedNode.attributes.path)!='undefined') {
112
+ var path = selectedNode.attributes.path;
113
+ path = '0/'+path;
114
+ this.selectPath(path);
115
+ }
116
+ else {
117
+ this.getSelectionModel().select(selectedNode);
118
+ }
119
+ }
120
+ },
121
+ collapseTree : function(){
122
+ this.collapseAll();
123
+ this.selectCurrentNode();
124
+ if (!this.collapsed) {
125
+ this.collapsed = true;
126
+ this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(false) ?>';
127
+ this.request(this.loader.dataUrl, false);
128
+ }
129
+ },
130
+ expandTree : function(){
131
+ this.expandAll();
132
+ if (this.collapsed) {
133
+ this.collapsed = false;
134
+ this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(true) ?>';
135
+ this.request(this.loader.dataUrl, false);
136
+ }
137
+ },
138
+ galleryClick : function(node, e){
139
+ var baseUrl = '<?php echo $this->getEditUrl() ?>';
140
+ var urlExt = 'id/'+node.id+'/';
141
+ var url = parseSidUrl(baseUrl, urlExt);
142
+ this.currentNodeId = node.id;
143
+ if (!this.useAjax) {
144
+ setLocation(url);
145
+ return;
146
+ }
147
+ if (gallery_info_tabsJsTabs.activeTab) {
148
+ var params = {active_tab_id:gallery_info_tabsJsTabs.activeTab.id};
149
+ }
150
+ updateContent(url, params);
151
+ }
152
+ });
153
+ function reRenderTree(event){
154
+ if (tree && event) {
155
+ var obj = event.target;
156
+ if ($('add_root_gallery_button')) {
157
+ $('add_root_gallery_button').show();
158
+ }
159
+ // retain current selected gallery id
160
+ var url = tree.switchTreeUrl;
161
+ // load from cache
162
+ // load from ajax
163
+ new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
164
+ parameters : {form_key: FORM_KEY},
165
+ method : 'post',
166
+ onComplete : function(transport) {
167
+ var response = eval('(' + transport.responseText + ')');
168
+ if (!response['parameters']) {
169
+ return false;
170
+ }
171
+ _renderNewTree(response);
172
+ }
173
+ });
174
+ }
175
+ // render default tree
176
+ else {
177
+ _renderNewTree();
178
+ }
179
+ }
180
+ function _renderNewTree(config){
181
+ if (!config) {
182
+ var config = defaultLoadTreeParams;
183
+ }
184
+ if (tree) {
185
+ tree.purgeListeners();
186
+ tree.el.dom.innerHTML = '';
187
+ }
188
+ tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams);
189
+ tree.loadTree(config, true);
190
+ // try to select current gallery
191
+ var selectedNode = tree.getNodeById(config.parameters.gallery_id);
192
+ if (selectedNode) {
193
+ tree.currentNodeId = config.parameters.gallery_id;
194
+ }
195
+ tree.selectCurrentNode();
196
+ // update content area
197
+ var url = tree.editUrl;
198
+ <?php if ($this->isClearEdit()):?>
199
+ if (selectedNode) {
200
+ url = url + 'id/' + config.parameters.gallery_id;
201
+ }
202
+ <?php endif;?>
203
+ updateContent(url);
204
+ }
205
+ Ext.onReady(function(){
206
+ galleryLoader = new Ext.tree.TreeLoader({
207
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
208
+ });
209
+ galleryLoader.createNode = function(config) {
210
+ var node;
211
+ var _node = Object.clone(config);
212
+ if (config.children && !config.children.length) {
213
+ delete(config.children);
214
+ node = new Ext.tree.AsyncTreeNode(config);
215
+ }
216
+ else {
217
+ node = new Ext.tree.TreeNode(config);
218
+ }
219
+ return node;
220
+ };
221
+ galleryLoader.buildGalleryTree = function(parent, config){
222
+ if (!config) {
223
+ return null;
224
+ }
225
+ if (parent && config && config.length){
226
+ for (var i = 0; i < config.length; i++) {
227
+ var node;
228
+ var _node = Object.clone(config[i]);
229
+ if (_node.children && !_node.children.length) {
230
+ delete(_node.children);
231
+ node = new Ext.tree.AsyncTreeNode(_node);
232
+ }
233
+ else {
234
+ node = new Ext.tree.TreeNode(config[i]);
235
+ }
236
+ parent.appendChild(node);
237
+ node.loader = node.getOwnerTree().loader;
238
+ if (_node.children) {
239
+ this.buildGalleryTree(node, _node.children);
240
+ }
241
+ }
242
+ }
243
+ };
244
+ galleryLoader.buildHash = function(node){
245
+ var hash = {};
246
+ hash = this.toArray(node.attributes);
247
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
248
+ hash['children'] = new Array;
249
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
250
+ if (!hash['children']) {
251
+ hash['children'] = new Array;
252
+ }
253
+ hash['children'].push(this.buildHash(node.childNodes[i]));
254
+ }
255
+ }
256
+ return hash;
257
+ };
258
+ galleryLoader.toArray = function(attributes) {
259
+ var data = {form_key: FORM_KEY};
260
+ for (var key in attributes) {
261
+ var value = attributes[key];
262
+ data[key] = value;
263
+ }
264
+ return data;
265
+ };
266
+ galleryLoader.on("beforeload", function(treeLoader, node) {
267
+ treeLoader.baseParams.id = node.attributes.id;
268
+ treeLoader.baseParams.form_key = FORM_KEY;
269
+ });
270
+ galleryLoader.on("load", function(treeLoader, node, config) {
271
+ varienWindowOnload();
272
+ });
273
+ newTreeParams = {
274
+ animate : false,
275
+ loader : galleryLoader,
276
+ enableDD: true,
277
+ containerScroll : true,
278
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
279
+ rootVisible : false,
280
+ useAjax : <?php echo $this->getUseAjax() ?>,
281
+ switchTreeUrl : '<?php echo $this->getSwitchTreeUrl() ?>',
282
+ editUrl : '<?php echo $this->getEditUrl() ?>',
283
+ currentNodeId : <?php echo (int) $this->getGalleryId() ?>
284
+ };
285
+ defaultLoadTreeParams = {
286
+ parameters : {
287
+ text: '<?php echo htmlentities($this->getRoot()->getTitle()) ?>',
288
+ draggable : false,
289
+ allowDrop : true,
290
+ id : <?php echo (int) $this->getRoot()->getId() ?>,
291
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
292
+ gallery_id : <?php echo (int) $this->getGalleryId() ?>
293
+ },
294
+ data : <?php echo $this->getTreeJson() ?>
295
+ };
296
+ reRenderTree();
297
+ });
298
+
299
+ function addNew(url, isRoot){
300
+ if (isRoot) {
301
+ tree.currentNodeId = tree.root.id;
302
+ }
303
+ url+= 'parent/'+tree.currentNodeId;
304
+ updateContent(url);
305
+ }
306
+ function galleryMove(obj){
307
+ var data = {id: obj.dropNode.id, form_key: FORM_KEY};
308
+ data.point = obj.point;
309
+ switch (obj.point) {
310
+ case 'above' :
311
+ data.pid = obj.target.parentNode.id;
312
+ data.paid = obj.dropNode.parentNode.id;
313
+ if (obj.target.previousSibling) {
314
+ data.aid = obj.target.previousSibling.id;
315
+ }
316
+ else {
317
+ data.aid = 0;
318
+ }
319
+ break;
320
+ case 'below' :
321
+ data.pid = obj.target.parentNode.id;
322
+ data.aid = obj.target.id;
323
+ break;
324
+ case 'append' :
325
+ data.pid = obj.target.id;
326
+ data.paid = obj.dropNode.parentNode.id;
327
+ if (obj.target.lastChild) {
328
+ data.aid = obj.target.lastChild.id;
329
+ } else {
330
+ data.aid = 0;
331
+ }
332
+ break;
333
+ default :
334
+ obj.cancel = true;
335
+ return obj;
336
+ }
337
+ var success = function(o) {
338
+ try {
339
+ if(o.responseText){
340
+ if(o.responseText==='SUCCESS'){
341
+ galleryForm.refreshPath();
342
+ }
343
+ else {
344
+ alert(o.responseText);
345
+ location.reload();
346
+ }
347
+ }
348
+ }
349
+ catch(e) {}
350
+ };
351
+ var failure = function(o) {
352
+ try {
353
+ console.log(o.statusText);
354
+ } catch (e2) {
355
+ alert(o.statusText);
356
+ }
357
+ location.reload();
358
+ };
359
+ var pd = [];
360
+ for(var key in data) {
361
+ pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&");
362
+ }
363
+ pd.splice(pd.length-1,1);
364
+ new Ajax.Request(
365
+ '<?php echo $this->getMoveUrl() ?>',
366
+ {
367
+ method: 'POST',
368
+ parameters: pd.join(""),
369
+ onSuccess : success,
370
+ onFailure : failure
371
+ }
372
+ );
373
+ }
374
+ //]]>
375
+ </script>
376
+ <?php endif; ?>
app/design/adminhtml/default/default/template/joomi_masonrygallery/gallery_/widget/tree.phtml ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <?php $_divId = 'tree' . $this->getId() ?>
19
+ <div id="<?php echo $_divId ?>" class="tree"></div>
20
+ <script type="text/javascript">
21
+ //<![CDATA[
22
+ var tree<?php echo $this->getId() ?>;
23
+ var useMassaction = <?php echo $this->getUseMassaction()?1:0; ?>;
24
+ Ext.tree.TreePanel.Enhanced = function(el, config){
25
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
26
+ };
27
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
28
+ loadTree : function(config, firstLoad){
29
+ var parameters = config['parameters'];
30
+ var data = config['data'];
31
+ if ((typeof parameters['root_visible']) != 'undefined') {
32
+ this.rootVisible = parameters['root_visible']*1;
33
+ }
34
+ var root = new Ext.tree.TreeNode(parameters);
35
+ this.nodeHash = {};
36
+ this.setRootNode(root);
37
+ if (firstLoad) {
38
+ <?php if ($this->getNodeClickListener()): ?>
39
+ this.addListener('click', <?php echo $this->getNodeClickListener() ?>.createDelegate(this));
40
+ <?php endif; ?>
41
+ }
42
+ this.loader.buildGalleryTree(root, data);
43
+ this.el.dom.innerHTML = '';
44
+ this.render();
45
+ }
46
+ });
47
+
48
+ Ext.onReady(function(){
49
+ var emptyNodeAdded = <?php echo ($this->getWithEmptyNode() ? 'false' : 'true') ?>;
50
+ var galleryLoader = new Ext.tree.TreeLoader({
51
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
52
+ });
53
+
54
+ galleryLoader.buildGalleryTree = function(parent, config){
55
+ if (!config) {
56
+ return null;
57
+ }
58
+ if (parent && config && config.length){
59
+ for (var i = 0; i < config.length; i++) {
60
+ var node;
61
+ if (useMassaction) {
62
+ config[i].uiProvider = Ext.tree.CheckboxNodeUI;
63
+ }
64
+ var _node = Object.clone(config[i]);
65
+
66
+ if(!emptyNodeAdded) {
67
+ var empty = Object.clone(_node);
68
+ empty.text = '<?php echo $this->__('None') ?>';
69
+ empty.children = [];
70
+ empty.id = 'none';
71
+ empty.path = '1/none';
72
+ empty.cls = 'leaf';
73
+ parent.appendChild(new Ext.tree.TreeNode(empty));
74
+ emptyNodeAdded = true;
75
+ }
76
+
77
+ if (_node.children && !_node.children.length) {
78
+ delete(_node.children);
79
+ node = new Ext.tree.AsyncTreeNode(_node);
80
+ }
81
+ else {
82
+ node = new Ext.tree.TreeNode(config[i]);
83
+ }
84
+ parent.appendChild(node);
85
+ node.loader = node.getOwnerTree().loader;
86
+ node.loader = node.getOwnerTree().loader;
87
+ if (_node.children) {
88
+ this.buildGalleryTree(node, _node.children);
89
+ }
90
+ }
91
+ }
92
+ };
93
+
94
+ galleryLoader.createNode = function(config) {
95
+ var node;
96
+ if (useMassaction) {
97
+ config.uiProvider = Ext.tree.CheckboxNodeUI;
98
+ }
99
+ var _node = Object.clone(config);
100
+ if (config.children && !config.children.length) {
101
+ delete(config.children);
102
+ node = new Ext.tree.AsyncTreeNode(config);
103
+ }
104
+ else {
105
+ node = new Ext.tree.TreeNode(config);
106
+ }
107
+ return node;
108
+ };
109
+
110
+ galleryLoader.buildHash = function(node){
111
+ var hash = {};
112
+
113
+ hash = this.toArray(node.attributes);
114
+
115
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
116
+ hash['children'] = new Array;
117
+
118
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
119
+ if (!hash['children']) {
120
+ hash['children'] = new Array;
121
+ }
122
+ hash['children'].push(this.buildHash(node.childNodes[i]));
123
+ }
124
+ }
125
+
126
+ return hash;
127
+ };
128
+
129
+ galleryLoader.toArray = function(attributes) {
130
+ var data = {};
131
+ for (var key in attributes) {
132
+ var value = attributes[key];
133
+ data[key] = value;
134
+ }
135
+ return data;
136
+ };
137
+
138
+ galleryLoader.on("beforeload", function(treeLoader, node) {
139
+ treeLoader.baseParams.id = node.attributes.id;
140
+ });
141
+
142
+ tree<?php echo $this->getId() ?> = new Ext.tree.TreePanel.Enhanced('<?php echo $_divId ?>', {
143
+ animate: false,
144
+ loader: galleryLoader,
145
+ enableDD: false,
146
+ containerScroll: true,
147
+ rootVisible: '<?php echo $this->getRoot()->getIsVisible() ?>',
148
+ useAjax: true,
149
+ currentNodeId:<?php echo (int) $this->getGalleryId() ?>,
150
+ addNodeTo:false
151
+ });
152
+
153
+ if (useMassaction) {
154
+ tree<?php echo $this->getId() ?>.on('check', function(node) {
155
+ $('<?php echo $_divId; ?>').fire('node:changed', {node:node});
156
+ }, tree<?php echo $this->getId() ?>);
157
+ }
158
+
159
+ // set the root node
160
+ var parameters = {
161
+ text:'Psw',
162
+ draggable: false,
163
+ id: <?php echo (int) $this->getRoot()->getId() ?>,
164
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
165
+ gallery_id: <?php echo (int) $this->getGalleryId() ?>
166
+ };
167
+
168
+ tree<?php echo $this->getId() ?>.loadTree({parameters:parameters, data:<?php echo $this->getTreeJson() ?>},true);
169
+
170
+ });
171
+ //]]>
172
+ </script>
app/design/frontend/base/default/layout/joomi_masonrygallery.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <default>
21
+ <reference name="head">
22
+ <action method="addCss"><js>css/joomi_masonrygallery/tree.css</js></action>
23
+ </reference>
24
+ </default>
25
+ <joomi_masonrygallery_category_index translate="label" module="joomi_masonrygallery">
26
+ <label>Categories list</label>
27
+ <update handle="page_one_column" />
28
+ <reference name="head">
29
+ <action method="addItem" ifconfig="joomi_masonrygallery/category/tree"><type>skin_js</type><js>js/joomi_masonrygallery/tree.js</js></action>
30
+ </reference>
31
+ <reference name="content">
32
+ <block type="joomi_masonrygallery/category_list" name="category_list" template="joomi_masonrygallery/category/list.phtml" />
33
+ </reference>
34
+ </joomi_masonrygallery_category_index>
35
+ <joomi_masonrygallery_gallery_index translate="label" module="joomi_masonrygallery">
36
+ <label>Galleries list</label>
37
+ <update handle="page_one_column" />
38
+ <reference name="content">
39
+ <block type="joomi_masonrygallery/gallery_list" name="gallery_list" template="joomi_masonrygallery/gallery/list.phtml" />
40
+ </reference>
41
+ </joomi_masonrygallery_gallery_index>
42
+ <joomi_masonrygallery_category_view translate="label" module="joomi_masonrygallery">
43
+ <label>Category view page</label>
44
+ <update handle="page_one_column" />
45
+ <reference name="head">
46
+ <action method="addItem" ifconfig="joomi_masonrygallery/category/tree"><type>skin_js</type><js>js/joomi_masonrygallery/tree.js</js></action>
47
+ </reference>
48
+ <reference name="content">
49
+ <block type="joomi_masonrygallery/category_view" name="category_view" template="joomi_masonrygallery/category/view.phtml" />
50
+ <block type="joomi_masonrygallery/category_children" name="category_children" template="joomi_masonrygallery/category/children.phtml" />
51
+ <block type="joomi_masonrygallery/category_gallery_list" name="category.gallery_list" as="category_categories" template="joomi_masonrygallery/category/gallery/list.phtml" />
52
+ </reference>
53
+ </joomi_masonrygallery_category_view>
54
+ <joomi_masonrygallery_gallery_view translate="label" module="joomi_masonrygallery">
55
+ <label>Gallery view page</label>
56
+ <update handle="page_one_column" />
57
+ <reference name="head">
58
+ <block type="core/template" name="headerInsert" template="joomi_masonrygallery/gallery/headerInsert.phtml"/>
59
+ </reference>
60
+ <reference name="content">
61
+ <block type="joomi_masonrygallery/gallery_view" name="gallery_view" template="joomi_masonrygallery/gallery/view.phtml" />
62
+ <block type="joomi_masonrygallery/gallery_catalog_product_list" name="gallery.info.products" as="gallery_products" template="joomi_masonrygallery/gallery/catalog/product/list.phtml" />
63
+ </reference>
64
+ </joomi_masonrygallery_gallery_view>
65
+ </layout>
app/design/frontend/base/default/template/joomi_masonrygallery/category/children.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category children list template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_categories = $this->getCategories(); ?>
26
+ <?php if ($_categories->getSize() > 0) :?>
27
+ <div class="page-title category-title">
28
+ <h2><?php echo $this->getCurrentCategory()->getTitle(); ?>:<?php echo $this->__('Children')?></h2>
29
+ </div>
30
+ <?php if ($this->_getDisplayMode() == 0) : ?>
31
+ <div class="category-list-container">
32
+ <?php foreach ($_categories as $_category) : ?>
33
+ <div class="category-list-item">
34
+ <a href="<?php echo $_category->getCategoryUrl();?>" title="<?php echo $this->htmlEscape($_category->getTitle()) ?>">
35
+ <?php echo $_category->getTitle(); ?>
36
+ </a>
37
+ </div>
38
+ <?php endforeach;?>
39
+ </div>
40
+ <?php else : ?>
41
+ <ul id="categories-list">
42
+ <?php foreach ($_categories as $_category) : ?>
43
+ <?php echo $this->drawCategory($_category);?>
44
+ <?php endforeach;?>
45
+ </ul>
46
+ <script type="text/javascript">
47
+ masonrygalleryTree('categories-list');
48
+ </script>
49
+ <?php endif;?>
50
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/category/gallery/list.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category Gallery list template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_galleries = $this->getGalleries();
26
+ ?>
27
+ <?php if ($_galleries->getSize() > 0) :?>
28
+ <div class="gallery-title">
29
+ <h2><?php echo Mage::helper('joomi_masonrygallery')->__('Galleries') ?></h2>
30
+ </div>
31
+ <ul class="galleries-list-container">
32
+ <?php foreach ($_galleries as $_gallery) :
33
+ $thumb=$_gallery->getThumbnail();
34
+ $first_prod_id=$_gallery->getSelectedProductsCollection()->getFirstItem()->getId();
35
+ $detailsProd=Mage::getModel('catalog/product')->load($first_prod_id);
36
+ if($detailsProd[$big]=='no_selection'||$detailsProd[$thumb]=='no_selection')continue;
37
+ $thumb_img = Mage::helper('catalog/image')->init($detailsProd, $thumb);
38
+ ?>
39
+
40
+ <li>
41
+ <a style="display: block" href="<?php echo $_gallery->getGalleryUrl()?>">
42
+ <img style="display: inline" src="<?php echo $thumb_img ?>" alt="<?php echo $_gallery->getTitle() ?>" width="30">
43
+ <span style="vertical-align: top;"><?php echo $_gallery->getTitle();?></span>
44
+ </a>
45
+ </li>
46
+ <?php endforeach;?>
47
+ </ul>
48
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/category/list.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category list template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
26
+ <?php $_categories = $this->getCategories(); ?>
27
+ <div class="page-title category-title">
28
+ <h1><?php echo Mage::helper('joomi_masonrygallery')->__('Categories') ?></h1>
29
+ </div>
30
+ <?php if ($_categories->getSize() > 0) :?>
31
+ <?php if ($this->_getDisplayMode() == 0) : ?>
32
+ <?php echo $this->getPagerHtml(); ?>
33
+ <div class="category-list-container">
34
+ <?php foreach ($_categories as $_category) : ?>
35
+ <div class="category-list-item">
36
+ <a href="<?php echo $_category->getCategoryUrl()?>">
37
+ <?php echo $_category->getTitle();?>
38
+ </a><br />
39
+ </div>
40
+ <?php endforeach;?>
41
+ </div>
42
+ <?php echo $this->getPagerHtml(); ?>
43
+ <?php else : ?>
44
+ <ul id="categories-list">
45
+ <?php foreach ($_categories as $_category) : ?>
46
+ <?php echo $this->drawCategory($_category);?>
47
+ <?php endforeach;?>
48
+ </ul>
49
+ <script type="text/javascript">
50
+ masonrygalleryTree('categories-list');
51
+ </script>
52
+ <?php endif;?>
53
+ <?php else : ?>
54
+ <?php echo Mage::helper('joomi_masonrygallery')->__('There are no categories at this moment');?>
55
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/category/view.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category view template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_category = $this->getCurrentCategory();?>
26
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
27
+ <div class="page-title category-title">
28
+ <h1><?php echo $_category->getTitle(); ?></h1>
29
+ </div>
30
+ <div class="category-view">
31
+ <!-- <div class="category-title">-->
32
+ <!-- --><?php //echo Mage::helper('joomi_masonrygallery')->__('Title');?><!--:--><?php //echo $_category->getTitle();?>
33
+ <!---->
34
+ <!-- </div>-->
35
+ <!-- <div class="category-description">-->
36
+ <!-- --><?php //echo Mage::helper('joomi_masonrygallery')->__('Description');?><!--:--><?php //echo $_category->getDescription();?>
37
+ <!---->
38
+ <!-- </div>-->
39
+ <!-- <div class="category-ordering">-->
40
+ <!-- --><?php //echo Mage::helper('joomi_masonrygallery')->__('Ordering');?><!--:--><?php //echo $_category->getOrdering();?>
41
+ <!---->
42
+ <!-- </div>-->
43
+
44
+ </div>
app/design/frontend/base/default/template/joomi_masonrygallery/category/widget/link.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category link widget template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_category = $this->getCurrentCategory();?>
26
+ <?php if ($_category) :?>
27
+ <div class="category-widget-link">
28
+ <a href="<?php echo $_category->getCategoryUrl()?>"><?php echo $_category->getTitle()?></a>
29
+ </div>
30
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/category/widget/subtree.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category subtree template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_categories = $this->getCategories(); ?>
26
+ <?php if ($_categories->getSize() > 0) :?>
27
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/tree.js')?>"></script>
28
+ <ul id="<?php echo $this->getUniqueId()?>">
29
+ <?php foreach ($_categories as $_category) : ?>
30
+ <?php echo $this->drawCategory($_category);?>
31
+ <?php endforeach;?>
32
+ </ul>
33
+ <script type="text/javascript">
34
+ masonrygalleryTree('<?php echo $this->getUniqueId()?>');
35
+ </script>
36
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/category/widget/view.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Category view widget template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_category = $this->getCurrentCategory();?>
26
+ <?php if ($_category) :?>
27
+ <div class="category-widget-view">
28
+ <h3><?php echo $_category->getTitle()?></h3>
29
+ <div>
30
+ <div class="title-widget">
31
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Title');?>:<?php echo $_category->getTitle();?>
32
+ </div>
33
+ <div class="description-widget">
34
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Description');?>:<?php echo $_category->getDescription();?>
35
+ </div>
36
+ <div class="ordering-widget">
37
+ <?php echo Mage::helper('joomi_masonrygallery')->__('Ordering');?>:<?php echo $_category->getOrdering();?>
38
+ </div>
39
+
40
+ </div>
41
+ </div>
42
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/gallery/catalog/product/list.phtml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery product list template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php
26
+ $_gallery=Mage::registry('current_gallery');
27
+ $products = $this->getProductCollection();
28
+ $limit = $_gallery->getLimitFirstLoad() ? $_gallery->getLimitFirstLoad() : 9999;
29
+ $columnWidth = $_gallery->getColumnWidth();
30
+ $grow_image_effect = Mage::getStoreConfig('joomi_masonrygallery/global/grow_image_effect');
31
+ $open_popup_prod = Mage::getStoreConfig('joomi_masonrygallery/global/open_popup_prod');
32
+ $class=' ';
33
+ if($grow_image_effect) $class.='grow';
34
+ if($open_popup_prod) $class.=' masonry_popup';
35
+ ?>
36
+ <?php if ($products->count() > 0) :?>
37
+
38
+ <div class="item_fields gallery-view clearfix grid">
39
+ <?php
40
+ $ind=0;
41
+ $thumb=$_gallery->getThumbnail();
42
+ $big=$_gallery->getBigImage();
43
+ foreach($products as $product){
44
+ $detailsProd=Mage::getModel('catalog/product')->load($product->getId());
45
+ if(!$detailsProd[$big]||!$detailsProd[$thumb]||$detailsProd[$big]=='no_selection'||$detailsProd[$thumb]=='no_selection')continue;
46
+ $big_img= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product' .$detailsProd[$big];
47
+ $thumb_img= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product' .$detailsProd[$thumb];
48
+
49
+ $height = $this->helper('catalog/image')->init($detailsProd, $thumb)->getOriginalHeight();
50
+
51
+
52
+ $ind++;
53
+
54
+ $url = $ind<=$limit? $thumb_img :'';
55
+ $class2=$ind<=$limit?'': ' hide';
56
+ ?>
57
+ <a data-href="<?php echo $product->getProductUrl() ?>" style="height:<?php echo $height ?>px; width: <?php echo $columnWidth ?>px " title="<?php echo strip_tags($product->getName()); ?>" class="masonry_item <?php echo $class .$class2 ?>" data-fancybox-group="gallery" target="<?php echo $open_popup_prod? '_blank' : '_self' ?>" href="<?php echo $open_popup_prod ? $big_img:$product->getProductUrl() ?>" data-caption="<?php echo $product->getName() ?>">
58
+
59
+ <img data-src="<?php echo $thumb_img ?>" style="height:<?php echo $height ?>px" src="<?php echo $thumb_img ?>" alt="<?php echo $image->description ?>" >
60
+ <div class="item_media_text"><?php echo $product->getName(); ?></div>
61
+
62
+
63
+ </a>
64
+ <?php } ?>
65
+
66
+ </div>
67
+
68
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/gallery/headerInsert.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/joomi_masonrygallery/masonry.css') ?>" media="all">
19
+ <?php
20
+
21
+ $load_masonry = Mage::getStoreConfig('joomi_masonrygallery/global/load_masonry_jquery');
22
+ $load_jquery = Mage::getStoreConfig('joomi_masonrygallery/global/load_jquery');
23
+ $load_fancy_box = Mage::getStoreConfig('joomi_masonrygallery/global/load_fancy_box');
24
+
25
+ if($load_jquery) {?>
26
+ <script src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/jquery.js')?>"></script>
27
+ <?php }
28
+ if($load_masonry) {?>
29
+ <script src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/jquery_masonry.js')?>"></script>
30
+ <?php }
31
+ if($load_fancy_box) { ?>
32
+ <script src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/jquery.fancybox.pack.js')?>"></script>
33
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/joomi_masonrygallery/jquery.fancybox.css') ?>" media="all">
34
+ <?php }
app/design/frontend/base/default/template/joomi_masonrygallery/gallery/list.phtml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery list template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
26
+ <?php $_galleries = $this->getGalleries(); ?>
27
+ <div class="page-title gallery-title">
28
+ <h1><?php echo Mage::helper('joomi_masonrygallery')->__('Galleries') ?></h1>
29
+ </div>
30
+ <?php if ($_galleries->getSize() > 0) :?>
31
+ <?php echo $this->getPagerHtml(); ?>
32
+ <ul class="gallery-list-container galleries_item">
33
+ <?php foreach ($_galleries as $_gallery) :
34
+ $thumb=$_gallery->getThumbnail();
35
+ $first_prod_id=$_gallery->getSelectedProductsCollection()->getFirstItem()->getId();
36
+ $detailsProd=Mage::getModel('catalog/product')->load($first_prod_id);
37
+ if($detailsProd[$big]=='no_selection'||$detailsProd[$thumb]=='no_selection')continue;
38
+ $thumb_img = Mage::helper('catalog/image')->init($detailsProd, $thumb);
39
+ ?>
40
+
41
+ <li>
42
+ <a style="display: block" href="<?php echo $_gallery->getGalleryUrl()?>">
43
+ <img style="display: inline" src="<?php echo $thumb_img ?>" alt="<?php echo $_gallery->getTitle() ?>" width="30">
44
+ <span style="vertical-align: top;"><?php echo $_gallery->getTitle();?></span>
45
+ </a>
46
+ </li>
47
+
48
+
49
+ <?php endforeach;?>
50
+ </ul>
51
+ <?php echo $this->getPagerHtml(); ?>
52
+ <?php else : ?>
53
+ <?php echo Mage::helper('joomi_masonrygallery')->__('There are no galleries at this moment');?>
54
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/gallery/view.phtml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery view template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_gallery = $this->getCurrentGallery();
26
+ $limit = $_gallery->getLimitFirstLoad() ? $_gallery->getLimitFirstLoad() : 9999;
27
+ $columnWidth = $_gallery->getColumnWidth();
28
+ ?>
29
+ <script>
30
+ jQuery(document).ready(function($){
31
+ var $grid=jQuery('.grid').masonry({
32
+ itemSelector: '.masonry_item',
33
+ columnWidth: <?php echo $columnWidth+10 ?>
34
+ });
35
+ setTimeout(function(){
36
+ $grid.masonry('layout');
37
+ }, 500);
38
+
39
+
40
+ $('.masonry_item.masonry_popup').fancybox({
41
+ autoDimensions: false,
42
+ fitToView:false,
43
+ autoSize : false,
44
+ maxWidth:'100%',
45
+ maxHeight:'100%',
46
+ helpers: {
47
+ title : {
48
+ type : 'outside'
49
+ }},
50
+ beforeLoad: function() {
51
+ var url = $(this.element).attr('data-href');
52
+ var caption = $(this.element).attr('data-caption');
53
+ this.title = '<a class="masonry_prod_link" href="'+url+'">'+caption+'</a>';
54
+ },
55
+ beforeShow : function() {
56
+ $('.fancybox-wrap').addClass('mediaFancy');
57
+ }
58
+ });
59
+
60
+ var limit=<?php echo $limit ?>;
61
+
62
+ $(window).scroll(function() {
63
+
64
+ if ( document.documentElement.clientHeight + $(document).scrollTop() >= document.body.offsetHeight )
65
+ {
66
+ if(limit) {
67
+ $('.masonry_item.hide').each(function (ind) {
68
+ if(ind<limit){
69
+ var src=$('img',this).attr('data-src');
70
+ $('img',this).attr('src',src);
71
+ $(this).addClass('show');
72
+ }
73
+ });
74
+ $('.masonry_item.hide.show').removeClass('hide');
75
+ $grid.masonry('layout');
76
+ }
77
+
78
+ }
79
+ });
80
+
81
+
82
+
83
+
84
+
85
+ });
86
+
87
+
88
+
89
+ </script>
90
+ <?php
91
+ $load_masonry = Mage::getStoreConfig('joomi_masonrygallery/global/load_masonry_jquery');
92
+ ?>
93
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
94
+ <div class="page-title gallery-title">
95
+ <h1><?php echo $_gallery->getTitle(); ?></h1>
96
+ </div>
97
+ <div class="gallery-view">
98
+
99
+ <h3 class="gallery-description">
100
+ <?php echo $_gallery->getDescription();?>
101
+ </h3>
102
+ </div>
103
+
104
+
105
+
app/design/frontend/base/default/template/joomi_masonrygallery/gallery/widget/link.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery link widget template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <?php $_gallery = $this->getCurrentGallery();?>
26
+ <?php if ($_gallery) :?>
27
+ <div class="gallery-widget-link">
28
+ <a href="<?php echo $_gallery->getGalleryUrl()?>"><?php echo $_gallery->getTitle()?></a>
29
+ </div>
30
+ <?php endif;?>
app/design/frontend/base/default/template/joomi_masonrygallery/gallery/widget/view.phtml ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Joomi_MasonryGallery extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Joomi
13
+ * @package Joomi_MasonryGallery
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Gallery view widget template
19
+ *
20
+ * @category Joomi
21
+ * @package Joomi_MasonryGallery
22
+ * @author Ultimate Module Creator
23
+ */
24
+ ?>
25
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/joomi_masonrygallery/masonry.css') ?>" media="all">
26
+ <?php
27
+
28
+ $load_masonry = Mage::getStoreConfig('joomi_masonrygallery/global/load_masonry_jquery');
29
+ $load_jquery = Mage::getStoreConfig('joomi_masonrygallery/global/load_jquery');
30
+ $load_fancy_box = Mage::getStoreConfig('joomi_masonrygallery/global/load_fancy_box');
31
+
32
+ if($load_jquery) {?>
33
+ <script src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/jquery.js')?>"></script>
34
+ <?php }
35
+ if($load_masonry) {?>
36
+ <script src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/jquery_masonry.js')?>"></script>
37
+ <?php }
38
+ if($load_fancy_box) { ?>
39
+ <script src="<?php echo $this->getSkinUrl('js/joomi_masonrygallery/jquery.fancybox.pack.js')?>"></script>
40
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/joomi_masonrygallery/jquery.fancybox.css') ?>" media="all">
41
+ <?php }
42
+
43
+ $_gallery = $this->getCurrentGallery();
44
+ $limit = $_gallery->getLimitFirstLoad() ? $_gallery->getLimitFirstLoad() : 9999;
45
+ $columnWidth = $_gallery->getColumnWidth();
46
+ ?>
47
+ <script>
48
+ jQuery(document).ready(function($){
49
+ var $grid=jQuery('.grid').masonry({
50
+ itemSelector: '.masonry_item',
51
+ columnWidth: <?php echo $columnWidth+10 ?>
52
+ });
53
+ setTimeout(function(){
54
+ $grid.masonry('layout');
55
+ }, 500);
56
+
57
+
58
+ $('.masonry_item.masonry_popup').fancybox({
59
+ autoDimensions: false,
60
+ fitToView:false,
61
+ autoSize : false,
62
+ maxWidth:'100%',
63
+ maxHeight:'100%',
64
+ helpers: {
65
+ title : {
66
+ type : 'outside'
67
+ }},
68
+ beforeLoad: function() {
69
+ var url = $(this.element).attr('data-href');
70
+ var caption = $(this.element).attr('data-caption');
71
+ this.title = '<a class="masonry_prod_link" href="'+url+'">'+caption+'</a>';
72
+ },
73
+ beforeShow : function() {
74
+ $('.fancybox-wrap').addClass('mediaFancy');
75
+ }
76
+ });
77
+
78
+ var limit=<?php echo $limit ?>;
79
+
80
+ $(window).scroll(function() {
81
+
82
+ if ( document.documentElement.clientHeight + $(document).scrollTop() >= document.body.offsetHeight )
83
+ {
84
+ if(limit) {
85
+ $('.masonry_item.hide').each(function (ind) {
86
+ if(ind<limit){
87
+ var src=$('img',this).attr('data-src');
88
+ $('img',this).attr('src',src);
89
+ $(this).addClass('show');
90
+ }
91
+ });
92
+ $('.masonry_item.hide.show').removeClass('hide');
93
+ $grid.masonry('layout');
94
+ }
95
+
96
+ }
97
+ });
98
+
99
+
100
+
101
+
102
+
103
+ });
104
+
105
+
106
+
107
+ </script>
108
+ <?php
109
+ $load_masonry = Mage::getStoreConfig('joomi_masonrygallery/global/load_masonry_jquery');
110
+ ?>
111
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
112
+ <div class="page-title gallery-title">
113
+ <h1><?php echo $_gallery->getTitle(); ?></h1>
114
+ </div>
115
+ <div class="gallery-view">
116
+
117
+ <h3 class="gallery-description">
118
+ <?php echo $_gallery->getDescription();?>
119
+ </h3>
120
+ </div>
121
+ <?php
122
+ $cur_gallery=Mage::getModel('joomi_masonrygallery/gallery')->load($_gallery->getId());
123
+ $products= $cur_gallery->getSelectedProductsCollection();
124
+ $grow_image_effect = Mage::getStoreConfig('joomi_masonrygallery/global/grow_image_effect');
125
+ $open_popup_prod = Mage::getStoreConfig('joomi_masonrygallery/global/open_popup_prod');
126
+ $class=' ';
127
+ if($grow_image_effect) $class.='grow';
128
+ if($open_popup_prod) $class.=' masonry_popup';
129
+ ?>
130
+ <?php if ($products->count() > 0) :?>
131
+
132
+ <div class="item_fields gallery-view clearfix grid">
133
+ <?php
134
+ $ind=0;
135
+ $thumb=$_gallery->getThumbnail();
136
+ $big=$_gallery->getBigImage();
137
+ foreach($products as $product){
138
+ $detailsProd=Mage::getModel('catalog/product')->load($product->getId());
139
+ if(!$detailsProd[$big]||!$detailsProd[$thumb]||$detailsProd[$big]=='no_selection'||$detailsProd[$thumb]=='no_selection')continue;
140
+ $big_img= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product' .$detailsProd[$big];
141
+ $thumb_img= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product' .$detailsProd[$thumb];
142
+ $height = $this->helper('catalog/image')->init($detailsProd, $thumb)->getOriginalHeight();
143
+ $ind++;
144
+ $url = $ind<=$limit? $thumb_img :'';
145
+ $class2=$ind<=$limit?'': ' hide';
146
+ ?>
147
+ <a data-href="<?php echo $product->getProductUrl() ?>" style="height:<?php echo $height ?>px; width: <?php echo $columnWidth ?>px " title="<?php echo strip_tags($detailsProd->getName()); ?>" class="masonry_item <?php echo $class .$class2 ?>" data-fancybox-group="gallery" target="<?php echo $open_popup_prod? '_blank' : '_self' ?>" href="<?php echo $open_popup_prod ? $big_img:$product->getProductUrl() ?>" data-caption="<?php echo $detailsProd->getName() ?>">
148
+ <img data-src="<?php echo $thumb_img ?>" style="height:<?php echo $height ?>px" src="<?php echo $thumb_img ?>" alt="<?php echo strip_tags($detailsProd->getName()) ?>" >
149
+ <div class="item_media_text"><?php echo $detailsProd->getName(); ?></div>
150
+ </a>
151
+ <?php } ?>
152
+
153
+ </div>
154
+
155
+ <?php endif;?>
156
+
app/etc/modules/Joomi_MasonryGallery.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Joomi_MasonryGallery extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Joomi
14
+ * @package Joomi_MasonryGallery
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Joomi_MasonryGallery>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ <depends>
25
+ <Mage_Catalog />
26
+ </depends>
27
+ </Joomi_MasonryGallery>
28
+ </modules>
29
+ </config>
app/locale/en_US/Joomi_MasonryGallery.csv ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ " - Edit"," - Edit"
2
+ "",""
3
+ "Action","Action"
4
+ "Add Category","Add Category"
5
+ "Add Child Category","Add Child Category"
6
+ "Add Gallery","Add Gallery"
7
+ "Add Root Category","Add Root Category"
8
+ "An error occurred while trying to delete the category.","An error occurred while trying to delete the category."
9
+ "An error occurred while updating the categories.","An error occurred while updating the categories."
10
+ "An error occurred while updating the galleries.","An error occurred while updating the galleries."
11
+ "Are you sure?","Are you sure?"
12
+ "Associated products","Associated products"
13
+ "Big Image","Big Image"
14
+ "CSV","CSV"
15
+ "Can't delete root category.","Can't delete root category."
16
+ "Categories","Categories"
17
+ "Category move error","Category move error"
18
+ "Category move operation is not possible: parent category is equal to child category.","Category move operation is not possible: parent category is equal to child category."
19
+ "Category move operation is not possible: the current category was not found.","Category move operation is not possible: the current category was not found."
20
+ "Category move operation is not possible: the new parent category was not found.","Category move operation is not possible: the new parent category was not found."
21
+ "Category subtree widget","Category subtree widget"
22
+ "Category subtree","Category subtree"
23
+ "Category was saved","Category was saved"
24
+ "Category was successfully deleted.","Category was successfully deleted."
25
+ "Category was successfully saved","Category was successfully saved"
26
+ "Category","Category"
27
+ "Change Category","Change Category"
28
+ "Change status","Change status"
29
+ "Collapse All","Collapse All"
30
+ "Column Width","Column Width"
31
+ "Could not find category to delete.","Could not find category to delete."
32
+ "Could not find gallery to delete.","Could not find gallery to delete."
33
+ "Created at","Created at"
34
+ "Delete Category","Delete Category"
35
+ "Delete Gallery","Delete Gallery"
36
+ "Delete","Delete"
37
+ "Description","Description"
38
+ "Disabled","Disabled"
39
+ "Display as tree","Display as tree"
40
+ "Edit Category '%s'","Edit Category '%s'"
41
+ "Edit Gallery '%s'","Edit Gallery '%s'"
42
+ "Edit","Edit"
43
+ "Enabled","Enabled"
44
+ "Error saving category","Error saving category"
45
+ "Error saving gallery","Error saving gallery"
46
+ "Excel","Excel"
47
+ "Expand All","Expand All"
48
+ "Galleries","Galleries"
49
+ "Gallery was saved","Gallery was saved"
50
+ "Gallery was successfully deleted.","Gallery was successfully deleted."
51
+ "Gallery was successfully saved","Gallery was successfully saved"
52
+ "Gallery","Gallery"
53
+ "Home","Home"
54
+ "ID: %s","ID: %s"
55
+ "Id","Id"
56
+ "Leave empty for no prefix","Leave empty for no prefix"
57
+ "Leave empty to use default URL module/controller/action","Leave empty to use default URL module/controller/action"
58
+ "Levels to show (0 for all)","Levels to show (0 for all)"
59
+ "Limit First Load","Limit First Load"
60
+ "Manage Categories","Manage Categories"
61
+ "Meta description for categories list page","Meta description for categories list page"
62
+ "Meta description for galleries list page","Meta description for galleries list page"
63
+ "Meta information","Meta information"
64
+ "Meta keywords for categories list page","Meta keywords for categories list page"
65
+ "Meta keywords for galleries list page","Meta keywords for galleries list page"
66
+ "Meta title for categories list page","Meta title for categories list page"
67
+ "Meta title for galleries list page","Meta title for galleries list page"
68
+ "Meta","Meta"
69
+ "Meta-description","Meta-description"
70
+ "Meta-keywords","Meta-keywords"
71
+ "Meta-title","Meta-title"
72
+ "New Category","New Category"
73
+ "New Root Category","New Root Category"
74
+ "No","No"
75
+ "None","None"
76
+ "Ordering","Ordering"
77
+ "Please select categories to delete.","Please select categories to delete."
78
+ "Please select categories.","Please select categories."
79
+ "Please select galleries to delete.","Please select galleries to delete."
80
+ "Please select galleries.","Please select galleries."
81
+ "Position","Position"
82
+ "Recursion level","Recursion level"
83
+ "Relative to Website Base URL","Relative to Website Base URL"
84
+ "Reset","Reset"
85
+ "Root","Root"
86
+ "Save And Continue Edit","Save And Continue Edit"
87
+ "Save Category","Save Category"
88
+ "Save Gallery","Save Gallery"
89
+ "Select Category","Select Category"
90
+ "Status","Status"
91
+ "Store views","Store views"
92
+ "The URL key cannot consist only of numbers.","The URL key cannot consist only of numbers."
93
+ "The URL key contains capital letters or disallowed symbols.","The URL key contains capital letters or disallowed symbols."
94
+ "The categories has been deleted.","The categories has been deleted."
95
+ "The category has been saved.","The category has been saved."
96
+ "The galleries has been deleted.","The galleries has been deleted."
97
+ "There was a problem saving the category.","There was a problem saving the category."
98
+ "There was a problem saving the gallery.","There was a problem saving the gallery."
99
+ "There was an error deleting categories.","There was an error deleting categories."
100
+ "There was an error deleting category.","There was an error deleting category."
101
+ "There was an error deleting galleries.","There was an error deleting galleries."
102
+ "There was an error deleting gallery.","There was an error deleting gallery."
103
+ "There was an error updating categories.","There was an error updating categories."
104
+ "There was an error updating galleries.","There was an error updating galleries."
105
+ "This category no longer exists.","This category no longer exists."
106
+ "This gallery no longer exists.","This gallery no longer exists."
107
+ "Thumbnail","Thumbnail"
108
+ "Title","Title"
109
+ "Total of %d categories were successfully deleted.","Total of %d categories were successfully deleted."
110
+ "Total of %d categories were successfully updated.","Total of %d categories were successfully updated."
111
+ "Total of %d galleries were successfully deleted.","Total of %d galleries were successfully deleted."
112
+ "Total of %d galleries were successfully updated.","Total of %d galleries were successfully updated."
113
+ "Total of %d record(s) have been deleted.","Total of %d record(s) have been deleted."
114
+ "Total of %d record(s) have been updated.","Total of %d record(s) have been updated."
115
+ "URL key already exists.","URL key already exists."
116
+ "URL key for list page","URL key for list page"
117
+ "URL key","URL key"
118
+ "URL prefix","URL prefix"
119
+ "URL suffix","URL suffix"
120
+ "Unable to find category to save.","Unable to find category to save."
121
+ "Unable to find gallery to save.","Unable to find gallery to save."
122
+ "Updated at","Updated at"
123
+ "Use Breadcrumbs","Use Breadcrumbs"
124
+ "View {#name}","View {#name}"
125
+ "WYSIWYG Editor","WYSIWYG Editor"
126
+ "What goes after the dot. Leave empty for no suffix.","What goes after the dot. Leave empty for no suffix."
127
+ "XML","XML"
128
+ "Yes","Yes"
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Joomi_MasonryGallery</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.txt">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Masonry gallery for product images.</summary>
10
+ <description>Display your products like a masonry gallery.</description>
11
+ <notes># First release &#xD;
12
+ # Known bugs:&#xD;
13
+ - unable to add gallery widget from widget window in editor&#xD;
14
+ </notes>
15
+ <authors><author><name>joomi</name><user>joomi</user><email>info@joomi.co.il</email></author></authors>
16
+ <date>2016-01-31</date>
17
+ <time>11:56:42</time>
18
+ <contents><target name="magecommunity"><dir name="Joomi"><dir name="MasonryGallery"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Gallery.php" hash="7e11de8c1e547d97c91958e593388c72"/></dir></dir></dir></dir><dir name="Category"><file name="Abstract.php" hash="3bffd7bbd931eaf75f3993bca89a98c6"/><dir name="Edit"><file name="Form.php" hash="ba789c38e1a085244a4d7f2182d3c1e1"/><dir name="Tab"><file name="Form.php" hash="103de42f909f2bf631a7cc43db9edea9"/><file name="Meta.php" hash="fc5d4113ce05846a526b281df2208e37"/><file name="Stores.php" hash="28b9d9daae882e96f654dc9a13f61de0"/></dir><file name="Tabs.php" hash="eccbee68899c5f48e71c28443fb727e6"/></dir><file name="Edit.php" hash="86df12a77ccde9d5b9f796440e16fa00"/><file name="Tree.php" hash="9826031d46bf32e97edd4363d0b2b06e"/><dir name="Widget"><file name="Chooser.php" hash="af4faf13fce5a9c4d0989100ed685a7d"/></dir></dir><dir name="Gallery"><dir name="Edit"><file name="Form.php" hash="532c69803c09ef276680d754cd574c69"/><dir name="Tab"><file name="Form.php" hash="60f613aa9ac57961ac27a6071c34b846"/><file name="Meta.php" hash="5639a04626ced15034ed62142be40310"/><file name="Product.php" hash="2ddfbbbcdbc5c72b66f6d58373b178ff"/><file name="Stores.php" hash="921a271603d06d4572f865f496696cf5"/></dir><file name="Tabs.php" hash="bfa38072f8e8f0c3d8afc0005c096310"/></dir><file name="Edit.php" hash="64bef9010a2788707996df117af2ca40"/><file name="Grid.php" hash="0066c8013838c4b68a2dc86fac944453"/><dir name="Widget"><file name="Chooser.php" hash="0f33114542ce569bf942f7e3fa704d25"/></dir></dir><file name="Gallery.php" hash="8ff799e2fbe1b77130f01d8bd33c2673"/><dir name="Helper"><dir name="Column"><dir name="Renderer"><file name="Parent.php" hash="b2f64aad0496e41ec8970300a6abe466"/><file name="Relation.php" hash="16bd8744db997dff374b8efa7f764f3d"/></dir></dir><file name="Wysiwyg.php" hash="01102280646bc9f7b69587860dc0c89a"/></dir></dir><dir name="Category"><file name="Children.php" hash="4de1ca1053ef5068d29df70b60e89402"/><dir name="Gallery"><file name="List.php" hash="07e93f43acb92463529f2bb4861286fb"/></dir><file name="List.php" hash="0104e059a16870f8235c0cde7f3dd2f1"/><file name="View.php" hash="8c15bfd2bbc17a419892836c31ca1a18"/><dir name="Widget"><file name="Link.php" hash="7d3fc3f0d1a407f657f350a695891d5a"/><file name="Subtree.php" hash="b9b2fd7f79dc019d85b94606dfaf39d8"/><file name="View.php" hash="cae652d0cc7de105a656ac36b9878df5"/></dir></dir><dir name="Gallery"><dir name="Catalog"><dir name="Product"><file name="List.php" hash="24bc0f615ec8fe6cde9042479fcaed33"/></dir></dir><file name="List.php" hash="763b94d0ea1d20ee3c4c0e1b85fcb6f7"/><file name="View.php" hash="83c3f90d2f9f4ef2ddf6e269a7d27632"/><dir name="Widget"><file name="Link.php" hash="a0581dca28f15b07621277e8cb35cb0d"/><file name="View.php" hash="18aaf0155c829b8bcd850d3ed46e045f"/></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="MasonryGallery.php" hash="2fe93c7eafb2eb69413fc5875e40171a"/></dir><file name="Router.php" hash="4c8f1ad93723baf01d5ad23d05cef150"/></dir><dir name="Helper"><file name="Category.php" hash="3fc13c142e8d79e2ab9b7b37666cb072"/><file name="Data.php" hash="9e65776bf5225ddad62e904f32b99d83"/><file name="Gallery.php" hash="cc98a74f0dff7cb4ec80ecc2c6478c58"/><file name="Product.php" hash="cbf1cb4d9759299a7b3ef4c05d62cf77"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="ae984557c2c1fb62a615b25c6a9957b0"/><dir name="Search"><file name="Gallery.php" hash="0803fcb53e488c88dc463755f5b1f652"/></dir></dir><dir name="Category"><file name="Source.php" hash="bc43e1d49fad8950323cd76b3cc81180"/></dir><file name="Category.php" hash="ab2fc8fad2666b9bd184776463fa3953"/><dir name="Gallery"><dir name="Attribute"><dir name="Source"><file name="Bigimage.php" hash="7d3a46bc6b0423e1f913e7f700d164e7"/><file name="Thumbnail.php" hash="6813dad8d6ae3526beb46d85d5952a0f"/></dir></dir><file name="Product.php" hash="e6d107ae97de0b9f976d6d0c5f23c2cf"/></dir><file name="Gallery.php" hash="e90be2560f7992d8529f72ca3d751c01"/><dir name="Resource"><dir name="Category"><file name="Collection.php" hash="60ec4be3422eb702421c7ef221c2ee93"/><file name="Tree.php" hash="2abc095f7b148212a7a1a709afb4cfa7"/></dir><file name="Category.php" hash="891319de1da3a3b91836d64f5096fce9"/><dir name="Gallery"><file name="Collection.php" hash="3d7dd7e69f3362ccfbbfbf562707a14d"/><dir name="Product"><file name="Collection.php" hash="a4bed1727b87d32b43d6c20bf34cac53"/></dir><file name="Product.php" hash="c7e8cc3a8c46766cb01d9ebe28c3c130"/></dir><file name="Gallery.php" hash="09a25a1c05414a7c2f6396d0ad0b74f4"/><file name="Setup.php" hash="30a98aa575512032db6d42849b747b90"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Masonrygallery"><dir name="Category"><file name="WidgetController.php" hash="5f552614ccd50554c36dcd1e59a7a2df"/></dir><file name="CategoryController.php" hash="561ccb870969e69d3744cc0627d9e07e"/><dir name="Gallery"><dir name="Catalog"><file name="ProductController.php" hash="59d6483960ad96f48c81408181bbcc13"/></dir><file name="WidgetController.php" hash="8364218a601678c6536425375e8c14c8"/></dir><file name="GalleryController.php" hash="6a5499b4f944e07a825e4bc5048ba806"/></dir></dir><file name="CategoryController.php" hash="12de5ec897d65248c3da6bf057ddbec4"/><file name="GalleryController.php" hash="914fa1add339358487fb7961aa0f9a15"/></dir><dir name="data"><dir name="joomi_masonrygallery_setup"><file name="data-install-1.0.0.php" hash="812b8756d577beefedf6135d0931140d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c01b3b9ab59637bbe0b88d77197adab3"/><file name="config.xml" hash="b44bd8a1e130f697bda54d024559b71c"/><file name="system.xml" hash="8f1f9bc145ef6cdc9d3f4849c4325e28"/><file name="widget.xml" hash="e033153fe9b4569fb97fbea717354eac"/></dir><dir name="sql"><dir name="joomi_masonrygallery_setup"><file name="install-1.0.0.php" hash="eeb687e2c15f30e3d0a48f2219268f92"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="joomi_masonrygallery.xml" hash="fc6cea6d5040985f0b79d0a3954d54a5"/></dir><dir name="template"><dir name="joomi_masonrygallery"><dir name="category"><dir name="edit"><file name="form.phtml" hash="6a0cacca1e8fa6185afbbbe9bdc05abc"/></dir><file name="edit.phtml" hash="31505cd2773c7b48e8accde7b32b5603"/><file name="tree.phtml" hash="5782a13f3e2d2d56854ea20db6751cd4"/><dir name="widget"><file name="tree.phtml" hash="8049421a3a341a1bbcad1945906f9e20"/></dir></dir><dir name="gallery_"><dir name="edit"><file name="form.phtml" hash="2848d8f90ff9060a2cd89863367c3d54"/></dir><file name="edit.phtml" hash="1a96ea99e1f8065cfc09cb94d2008601"/><file name="tree.phtml" hash="7edcc1bb691d57acac0e39b6283aa343"/><dir name="widget"><file name="tree.phtml" hash="71a8d710f9132154bfedbd948df524c6"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="joomi_masonrygallery.xml" hash="6e9a4d607b899761b6c9d3a1771ef4b0"/></dir><dir name="template"><dir name="joomi_masonrygallery"><dir name="category"><file name="children.phtml" hash="ba94a6478b5285de29b8b44b9b4b11e5"/><dir name="gallery"><file name="list.phtml" hash="e79819bb27f2f62e409c0219571d36cf"/></dir><file name="list.phtml" hash="f515b24d8e9072fc5b4c95187652e3aa"/><file name="view.phtml" hash="f024045dbb1ba015a2c19f87614e0fac"/><dir name="widget"><file name="link.phtml" hash="06a5d4727eaed631b3cdb47f5bc88e26"/><file name="subtree.phtml" hash="a9c225ffa31961b082577dbaed8ee45e"/><file name="view.phtml" hash="77bd8f347bd2f245da395326db1dd3e3"/></dir></dir><dir name="gallery"><dir name="catalog"><dir name="product"><file name="list.phtml" hash="0583d53e9c5f640b1ee82bcb21c0cd9a"/></dir></dir><file name="headerInsert.phtml" hash="361d4dccdd4d8fcda2cd4a87c5e276f0"/><file name="list.phtml" hash="755bbbe131497ce38e95d1e7be7e9cc8"/><file name="view.phtml" hash="cabbce5c42290198086a33521c4fd361"/><dir name="widget"><file name="link.phtml" hash="7d18684d30844a8fb652d819adbd2cc8"/><file name="view.phtml" hash="23087d47de0885342b3d53ced4586ac4"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Joomi_MasonryGallery.xml" hash="6c6f94a55fac4d8f982652270637b3c5"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Joomi_MasonryGallery.csv" hash="44dfacc44d0d96a0b5cf8148b1772e00"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="joomi_masonrygallery"><file name="jquery.fancybox.css" hash="9ea8fe36a3ae6a3037775affa4fbf72b"/><file name="masonry.css" hash="1d235e1ada61bd228b7dcb36d8ef5daf"/><file name="tree.css" hash="14272ba46ad921eb75fc5888a29d7f47"/></dir></dir><dir name="images"><dir name="joomi_masonrygallery"><file name="blank.gif" hash="325472601571f31e1bf00674c368d335"/><file name="collapsed.gif" hash="ef74c08289e94b7aae81766fb00d4195"/><file name="collapsed.png" hash="0613450d25c762b6a40c51768b02462d"/><file name="expanded.gif" hash="3f5512a54f359343273caf7b3787ee8a"/><file name="expanded.png" hash="f7f28ae897708c78b28ead22c3692bb8"/><file name="fancybox_loading.gif" hash="328cc0f6c78211485058d460e80f4fa8"/><file name="fancybox_loading@2x.gif" hash="f92938639fa894a0e8ded1c3368abe98"/><file name="fancybox_overlay.png" hash="77aeaa52715b898b73c74d68c630330e"/><file name="fancybox_sprite.png" hash="783d4031fe50c3d83c960911e1fbc705"/><file name="fancybox_sprite@2x.png" hash="ed9970ce22242421e66ff150aa97fe5f"/><file name="line1.gif" hash="65b0c812c8d57ea72b84fc69a077a40a"/><file name="line1.png" hash="4e01064a2c78b8885f65ff7a40f78c02"/><file name="line2.gif" hash="95fc5c58069ece5eb44e198ee53b3fe1"/><file name="line2.png" hash="6adbb4ca64d943f5ee5528d713757fde"/><file name="transform.png" hash="d682bf089b03d4d4c07c41adeec71c59"/></dir></dir><dir name="js"><dir name="joomi_masonrygallery"><file name="jquery.fancybox.pack.js" hash="5d3ed80727040babcc0789e15d8087c9"/><file name="jquery.js" hash="61050f91ca0c4bb6cf299accd60efba3"/><file name="jquery_masonry.js" hash="d5761132889fee4a606e54d26675d2ea"/><file name="tree.js" hash="09e6fe5f6f34d99d82086f4aee1db764"/></dir></dir></dir></dir></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
21
+ </package>
skin/frontend/base/default/css/joomi_masonrygallery/jquery.fancybox.css ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
2
+ .fancybox-wrap,
3
+ .fancybox-skin,
4
+ .fancybox-outer,
5
+ .fancybox-inner,
6
+ .fancybox-image,
7
+ .fancybox-wrap iframe,
8
+ .fancybox-wrap object,
9
+ .fancybox-nav,
10
+ .fancybox-nav span,
11
+ .fancybox-tmp
12
+ {
13
+ padding: 0;
14
+ margin: 0;
15
+ border: 0;
16
+ outline: none;
17
+ vertical-align: top;
18
+ }
19
+
20
+ .fancybox-wrap {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ z-index: 8020;
25
+ }
26
+
27
+ .fancybox-skin {
28
+ position: relative;
29
+ background: #f9f9f9;
30
+ color: #444;
31
+ text-shadow: none;
32
+ -webkit-border-radius: 4px;
33
+ -moz-border-radius: 4px;
34
+ border-radius: 4px;
35
+ }
36
+
37
+ .fancybox-opened {
38
+ z-index: 8030;
39
+ }
40
+
41
+ .fancybox-opened .fancybox-skin {
42
+ -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
43
+ -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
44
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
45
+ }
46
+
47
+ .fancybox-outer, .fancybox-inner {
48
+ position: relative;
49
+ }
50
+
51
+ .fancybox-inner {
52
+ overflow: hidden;
53
+ }
54
+
55
+ .fancybox-type-iframe .fancybox-inner {
56
+ -webkit-overflow-scrolling: touch;
57
+ }
58
+
59
+ .fancybox-error {
60
+ color: #444;
61
+ font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
62
+ margin: 0;
63
+ padding: 15px;
64
+ white-space: nowrap;
65
+ }
66
+
67
+ .fancybox-image, .fancybox-iframe {
68
+ display: block;
69
+ width: 100%;
70
+ height: 100%;
71
+ }
72
+
73
+ .fancybox-image {
74
+ max-width: 100%;
75
+ max-height: 100%;
76
+ }
77
+
78
+ #fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
79
+ background-image: url('../../images/joomi_masonrygallery/fancybox_sprite.png');
80
+ }
81
+
82
+ #fancybox-loading {
83
+ position: fixed;
84
+ top: 50%;
85
+ left: 50%;
86
+ margin-top: -22px;
87
+ margin-left: -22px;
88
+ background-position: 0 -108px;
89
+ opacity: 0.8;
90
+ cursor: pointer;
91
+ z-index: 8060;
92
+ }
93
+
94
+ #fancybox-loading div {
95
+ width: 44px;
96
+ height: 44px;
97
+ background: url('../../images/joomi_masonrygallery/fancybox_loading.gif') center center no-repeat;
98
+ }
99
+
100
+ .fancybox-close {
101
+ position: absolute;
102
+ top: -18px;
103
+ right: -18px;
104
+ width: 36px;
105
+ height: 36px;
106
+ cursor: pointer;
107
+ z-index: 8040;
108
+ }
109
+
110
+ .fancybox-nav {
111
+ position: absolute;
112
+ top: 0;
113
+ width: 40%;
114
+ height: 100%;
115
+ cursor: pointer;
116
+ text-decoration: none;
117
+ background: transparent url('../../images/joomi_masonrygallery/blank.gif'); /* helps IE */
118
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
119
+ z-index: 8040;
120
+ }
121
+
122
+ .fancybox-prev {
123
+ left: 0;
124
+ }
125
+
126
+ .fancybox-next {
127
+ right: 0;
128
+ }
129
+
130
+ .fancybox-nav span {
131
+ position: absolute;
132
+ top: 50%;
133
+ width: 36px;
134
+ height: 34px;
135
+ margin-top: -18px;
136
+ cursor: pointer;
137
+ z-index: 8040;
138
+ visibility: hidden;
139
+ }
140
+
141
+ .fancybox-prev span {
142
+ left: 10px;
143
+ background-position: 0 -36px;
144
+ }
145
+
146
+ .fancybox-next span {
147
+ right: 10px;
148
+ background-position: 0 -72px;
149
+ }
150
+
151
+ .fancybox-nav:hover span {
152
+ visibility: visible;
153
+ }
154
+
155
+ .fancybox-tmp {
156
+ position: absolute;
157
+ top: -99999px;
158
+ left: -99999px;
159
+ visibility: hidden;
160
+ max-width: 99999px;
161
+ max-height: 99999px;
162
+ overflow: visible !important;
163
+ }
164
+
165
+ /* Overlay helper */
166
+
167
+ .fancybox-lock {
168
+ overflow: hidden !important;
169
+ width: auto;
170
+ }
171
+
172
+ .fancybox-lock body {
173
+ overflow: hidden !important;
174
+ }
175
+
176
+ .fancybox-lock-test {
177
+ overflow-y: hidden !important;
178
+ }
179
+
180
+ .fancybox-overlay {
181
+ position: absolute;
182
+ top: 0;
183
+ left: 0;
184
+ overflow: hidden;
185
+ display: none;
186
+ z-index: 8010;
187
+ background: url('../../images/joomi_masonrygallery/fancybox_overlay.png');
188
+ }
189
+
190
+ .fancybox-overlay-fixed {
191
+ position: fixed;
192
+ bottom: 0;
193
+ right: 0;
194
+ }
195
+
196
+ .fancybox-lock .fancybox-overlay {
197
+ overflow: auto;
198
+ overflow-y: scroll;
199
+ }
200
+
201
+ /* Title helper */
202
+
203
+ .fancybox-title {
204
+ visibility: hidden;
205
+ font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
206
+ position: relative;
207
+ text-shadow: none;
208
+ z-index: 8050;
209
+ }
210
+
211
+ .fancybox-opened .fancybox-title {
212
+ visibility: visible;
213
+ }
214
+
215
+ .fancybox-title-float-wrap {
216
+ position: absolute;
217
+ bottom: 0;
218
+ right: 50%;
219
+ margin-bottom: -35px;
220
+ z-index: 8050;
221
+ text-align: center;
222
+ }
223
+
224
+ .fancybox-title-float-wrap .child {
225
+ display: inline-block;
226
+ margin-right: -100%;
227
+ padding: 2px 20px;
228
+ background: transparent; /* Fallback for web browsers that doesn't support RGBa */
229
+ background: rgba(0, 0, 0, 0.8);
230
+ -webkit-border-radius: 15px;
231
+ -moz-border-radius: 15px;
232
+ border-radius: 15px;
233
+ text-shadow: 0 1px 2px #222;
234
+ color: #FFF;
235
+ font-weight: bold;
236
+ line-height: 24px;
237
+ white-space: nowrap;
238
+ }
239
+
240
+ .fancybox-title-outside-wrap {
241
+ position: relative;
242
+ margin-top: 10px;
243
+ color: #fff;
244
+ }
245
+
246
+ .fancybox-title-inside-wrap {
247
+ padding-top: 10px;
248
+ }
249
+
250
+ .fancybox-title-over-wrap {
251
+ position: absolute;
252
+ bottom: 0;
253
+ left: 0;
254
+ color: #fff;
255
+ padding: 10px;
256
+ background: #000;
257
+ background: rgba(0, 0, 0, .8);
258
+ }
259
+
260
+ /*Retina graphics!*/
261
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
262
+ only screen and (min--moz-device-pixel-ratio: 1.5),
263
+ only screen and (min-device-pixel-ratio: 1.5){
264
+
265
+ #fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
266
+ background-image: url('../../images/joomi_masonrygallery/fancybox_sprite@2x.png');
267
+ background-size: 44px 152px; /*The size of the normal image, half the size of the hi-res image*/
268
+ }
269
+
270
+ #fancybox-loading div {
271
+ background-image: url('../../images/joomi_masonrygallery/fancybox_loading@2x.gif');
272
+ background-size: 24px 24px; /*The size of the normal image, half the size of the hi-res image*/
273
+ }
274
+ }
skin/frontend/base/default/css/joomi_masonrygallery/masonry.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ a.masonry_item{
2
+ margin-bottom: 10px;
3
+ overflow: hidden;
4
+ text-decoration: none;
5
+ }
6
+ a.masonry_prod_link{
7
+ text-align: center;
8
+ display: block;
9
+ }
10
+ .masonry_item.hide{
11
+ display: none;
12
+ }
13
+ .item_media_text {
14
+ position: absolute;
15
+ bottom: 0;
16
+ right: 0;
17
+ width: 100%;
18
+ max-width: 100%;
19
+ text-align: center;
20
+ font-size: 20px;
21
+ color: #0a3f6d;
22
+ background: #fff;
23
+ font-weight: bold;
24
+ display: none;
25
+ }
26
+ .masonry_item:hover .item_media_text {
27
+ display: block;
28
+ }
29
+ /*GROW*/
30
+ .masonry_item.grow{
31
+ overflow: hidden;
32
+ }
33
+ .grow img {
34
+ /* height: 300px; */
35
+ width: 100%;
36
+ max-width: 115%;
37
+ -webkit-transition: all 1s ease;
38
+ -moz-transition: all 1s ease;
39
+ -o-transition: all 1s ease;
40
+ -ms-transition: all 1s ease;
41
+ transition: all 1s ease;
42
+ }
43
+
44
+ .grow img:hover {
45
+ width: 115%;
46
+ height:115%!important;
47
+ }
48
+ /*galleries page*/
49
+ .galleries_item{
50
+ list-style: none;
51
+ }
52
+ .galleries_item a {
53
+ display: block;
54
+ }
55
+ .galleries_item a img{
56
+ max-width: 100%;
57
+ }
skin/frontend/base/default/css/joomi_masonrygallery/tree.css ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Joomi_MasonryGallery extension
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the MIT License
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/mit-license.php
10
+ *
11
+ * @category Joomi
12
+ * @package Joomi_MasonryGallery
13
+ * @copyright Copyright (c) 2016
14
+ * @license http://opensource.org/licenses/mit-license.php MIT License
15
+ */
16
+ .tree,.tree ul,.tree li{list-style:none;margin:0;padding:0;}
17
+ .tree{background:url(../../images/joomi_masonrygallery/line1.png) repeat-y;}
18
+ .tree li{line-height:20px;margin-top:1px;position:relative;width:100%;}
19
+ * html .tree li{float:left;display:inline;}
20
+ .tree li a{padding-left:28px;}
21
+ .tree li span{cursor:auto;float:left;font-size:0;height:13px;left:5px;position:absolute;top:5px;width:13px;}
22
+ .tree li span,.tree li span.collapsed{background:url(../../images/joomi_masonrygallery/collapsed.png) no-repeat 0 0;}
23
+ .tree li span.expanded{background:url(../../images/joomi_masonrygallery/expanded.png) no-repeat 0 0;}
24
+ .tree li ul{margin-left:28px;background:url(../../images/joomi_masonrygallery/line1.png) repeat-y;}
25
+ .tree li li{background:url(../../images/joomi_masonrygallery/line2.png) no-repeat 0 0;}
26
+ .tree:after,.tree ul:after{clear:both;content:".";display:block;height:0;visibility:hidden;}
27
+ .tree,.tree ul{display:block;}
28
+ .tree li.map-category{font-weight:bold;}
29
+ .tree li.map-product{font-weight:normal;}
30
+ .tree li.map-product a{color:#203548;}
31
+ /* \*/ .tree,.tree ul{min-height:1%;}
32
+ * html .tree,* html .tree ul{height:1%;}
skin/frontend/base/default/images/joomi_masonrygallery/blank.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/collapsed.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/collapsed.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/expanded.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/expanded.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/fancybox_loading.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/fancybox_loading@2x.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/fancybox_overlay.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/fancybox_sprite.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/fancybox_sprite@2x.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/line1.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/line1.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/line2.gif ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/line2.png ADDED
Binary file
skin/frontend/base/default/images/joomi_masonrygallery/transform.png ADDED
Binary file
skin/frontend/base/default/js/joomi_masonrygallery/jquery.fancybox.pack.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
2
+ (function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0<a.indexOf("%")},l=function(a,d){var e=parseInt(a,10)||0;d&&E(a)&&(e*=b.getViewport()[d]/100);return Math.ceil(e)},w=function(a,b){return l(a,b)+"px"};f.extend(b,{version:"2.1.5",defaults:{padding:15,margin:20,
3
+ width:800,height:600,minWidth:100,minHeight:100,maxWidth:9999,maxHeight:9999,pixelRatio:1,autoSize:!0,autoHeight:!1,autoWidth:!1,autoResize:!0,autoCenter:!s,fitToView:!0,aspectRatio:!1,topRatio:0.5,leftRatio:0.5,scrolling:"auto",wrapCSS:"",arrows:!0,closeBtn:!0,closeClick:!1,nextClick:!1,mouseWheel:!0,autoPlay:!1,playSpeed:3E3,preload:3,modal:!1,loop:!0,ajax:{dataType:"html",headers:{"X-fancyBox":!0}},iframe:{scrolling:"auto",preload:!0},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},
4
+ keys:{next:{13:"left",34:"up",39:"left",40:"up"},prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:!0,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+
5
+ (I?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0,
6
+ openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1,
7
+ isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k,
8
+ c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&&
9
+ k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current||
10
+ b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer=
11
+ setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index<b.group.length-1))b.player.isActive=!0,p.bind({"onCancel.player beforeClose.player":c,"onUpdate.player":e,"beforeLoad.player":d}),e(),b.trigger("onPlayStart")}else c()},next:function(a){var d=b.current;d&&(q(a)||(a=d.direction.next),b.jumpto(d.index+1,a,"next"))},prev:function(a){var d=b.current;
12
+ d&&(q(a)||(a=d.direction.prev),b.jumpto(d.index-1,a,"prev"))},jumpto:function(a,d,e){var c=b.current;c&&(a=l(a),b.direction=d||c.direction[a>=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d=
13
+ a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")),
14
+ b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(),
15
+ y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement;
16
+ if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1<a.group.length&&k[c]!==v)return b[d](k[c]),e.preventDefault(),!1;if(-1<f.inArray(c,k))return b[d](),e.preventDefault(),!1})}),f.fn.mousewheel&&a.mouseWheel&&b.wrap.bind("mousewheel.fb",function(d,c,k,g){for(var h=f(d.target||null),j=!1;h.length&&!j&&!h.is(".fancybox-skin")&&!h.is(".fancybox-wrap");)j=h[0]&&!(h[0].style.overflow&&"hidden"===h[0].style.overflow)&&
17
+ (h[0].clientWidth&&h[0].scrollWidth>h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1<b.group.length&&!a.canShrink){if(0<g||0<k)b.prev(0<g?"down":"left");else if(0>g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0,
18
+ {},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,
19
+ mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=
20
+ !0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");
21
+ "image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload=
22
+ this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href);
23
+ f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,
24
+ e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,
25
+ outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("<div>").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}",
26
+ g);break;case "swf":e='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+g+'"></param>',h="",f.each(a.swf,function(a,b){e+='<param name="'+a+'" value="'+b+'"></param>';h+=" "+a+'="'+b+'"'}),e+='<embed src="'+g+'" type="application/x-shockwave-flash" width="100%" height="100%"'+h+"></embed></object>"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll":
27
+ "no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside?
28
+ h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth||
29
+ h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),c<m&&(c=m,j=l(c/D)),j<u&&(j=u,c=l(j*D))):(c=Math.max(m,Math.min(c,n)),h.autoHeight&&
30
+ "iframe"!==h.type&&(g.width(c),j=g.height()),j=Math.max(u,Math.min(j,p)));if(h.fitToView)if(g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height(),h.aspectRatio)for(;(a>z||y>r)&&(c>m&&j>u)&&!(19<d++);)j=Math.max(u,Math.min(p,j-10)),c=l(j*D),c<m&&(c=m,j=l(c/D)),c>n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&j<A&&c+x+q<z)&&(c+=q);g.width(c).height(j);e.width(c+x);a=e.width();
31
+ y=e.height();e=(a>z||y>r)&&c>m&&j>u;c=h.aspectRatio?c<F&&j<B&&c<C&&j<A:(c<F||j<B)&&(c<C||j<A);f.extend(h,{dim:{width:w(a),height:w(y)},origWidth:C,origHeight:A,canShrink:e,canExpand:c,wPadding:x,hPadding:v,wrapSpace:y-k.outerHeight(!0),skinSpace:k.height()-j});!H&&(h.autoHeight&&j>u&&j<p&&!c)&&g.height("auto")},_getPosition:function(a){var d=b.current,e=b.getViewport(),c=d.margin,f=b.wrap.width()+c[1]+c[3],g=b.wrap.height()+c[0]+c[2],c={position:"absolute",top:c[0],left:c[3]};d.autoCenter&&d.fixed&&
32
+ !a&&g<=e.h&&f<=e.w?c.position="fixed":d.locked||(c.top+=e.y,c.left+=e.x);c.top=w(Math.max(c.top,c.top+(e.h-g)*d.topRatio));c.left=w(Math.max(c.left,c.left+(e.w-f)*d.leftRatio));return c},_afterZoomIn:function(){var a=b.current;a&&(b.isOpen=b.isOpened=!0,b.wrap.css("overflow","visible").addClass("fancybox-opened"),b.update(),(a.closeClick||a.nextClick&&1<b.group.length)&&b.inner.css("cursor","pointer").bind("click.fb",function(d){!f(d.target).is("a")&&!f(d.target).parent().is("a")&&(d.preventDefault(),
33
+ b[a.closeClick?"close":"next"]())}),a.closeBtn&&f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb",function(a){a.preventDefault();b.close()}),a.arrows&&1<b.group.length&&((a.loop||0<a.index)&&f(a.tpl.prev).appendTo(b.outer).bind("click.fb",b.prev),(a.loop||a.index<b.group.length-1)&&f(a.tpl.next).appendTo(b.outer).bind("click.fb",b.next)),b.trigger("afterShow"),!a.loop&&a.index===a.group.length-1?b.play(!1):b.opts.autoPlay&&!b.player.isActive&&(b.opts.autoPlay=!1,b.play()))},_afterZoomOut:function(a){a=
34
+ a||b.current;f(".fancybox-wrap").trigger("onReset").remove();f.extend(b,{group:{},opts:{},router:!1,current:null,isActive:!1,isOpened:!1,isOpen:!1,isClosing:!1,wrap:null,skin:null,outer:null,inner:null});b.trigger("afterClose",a)}});b.transitions={getOrigPosition:function(){var a=b.current,d=a.element,e=a.orig,c={},f=50,g=50,h=a.hPadding,j=a.wPadding,m=b.getViewport();!e&&(a.isDom&&d.is(":visible"))&&(e=d.find("img:first"),e.length||(e=d));t(e)?(c=e.offset(),e.is("img")&&(f=e.outerWidth(),g=e.outerHeight())):
35
+ (c.top=m.y+(m.h-g)*a.topRatio,c.left=m.x+(m.w-f)*a.leftRatio);if("fixed"===b.wrap.css("position")||a.locked)c.top-=m.y,c.left-=m.x;return c={top:w(c.top-h*a.topRatio),left:w(c.left-j*a.leftRatio),width:w(f+j),height:w(g+h)}},step:function(a,d){var e,c,f=d.prop;c=b.current;var g=c.wrapSpace,h=c.skinSpace;if("width"===f||"height"===f)e=d.end===d.start?1:(a-d.start)/(d.end-d.start),b.isClosing&&(e=1-e),c="width"===f?c.wPadding:c.hPadding,c=a-c,b.skin[f](l("width"===f?c:c-g*e)),b.inner[f](l("width"===
36
+ f?c:c-g*e-h*e))},zoomIn:function(){var a=b.current,d=a.pos,e=a.openEffect,c="elastic"===e,k=f.extend({opacity:1},d);delete k.position;c?(d=this.getOrigPosition(),a.openOpacity&&(d.opacity=0.1)):"fade"===e&&(d.opacity=0.1);b.wrap.css(d).animate(k,{duration:"none"===e?0:a.openSpeed,easing:a.openEasing,step:c?this.step:null,complete:b._afterZoomIn})},zoomOut:function(){var a=b.current,d=a.closeEffect,e="elastic"===d,c={opacity:0.1};e&&(c=this.getOrigPosition(),a.closeOpacity&&(c.opacity=0.1));b.wrap.animate(c,
37
+ {duration:"none"===d?0:a.closeSpeed,easing:a.closeEasing,step:e?this.step:null,complete:b._afterZoomOut})},changeIn:function(){var a=b.current,d=a.nextEffect,e=a.pos,c={opacity:1},f=b.direction,g;e.opacity=0.1;"elastic"===d&&(g="down"===f||"up"===f?"top":"left","down"===f||"right"===f?(e[g]=w(l(e[g])-200),c[g]="+=200px"):(e[g]=w(l(e[g])+200),c[g]="-=200px"));"none"===d?b._afterZoomIn():b.wrap.css(e).animate(c,{duration:a.nextSpeed,easing:a.nextEasing,complete:b._afterZoomIn})},changeOut:function(){var a=
38
+ b.previous,d=a.prevEffect,e={opacity:0.1},c=b.direction;"elastic"===d&&(e["down"===c||"up"===c?"top":"left"]=("up"===c||"left"===c?"-":"+")+"=200px");a.wrap.animate(e,{duration:"none"===d?0:a.prevSpeed,easing:a.prevEasing,complete:function(){f(this).trigger("onReset").remove()}})}};b.helpers.overlay={defaults:{closeClick:!0,speedOut:200,showEarly:!0,css:{},locked:!s,fixed:!0},overlay:null,fixed:!1,el:f("html"),create:function(a){a=f.extend({},this.defaults,a);this.overlay&&this.close();this.overlay=
39
+ f('<div class="fancybox-overlay"></div>').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive?
40
+ b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth),
41
+ p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"===
42
+ f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=
43
+ b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('<div class="fancybox-title fancybox-title-'+c+'-wrap">'+e+"</div>");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner('<span class="child"></span>'),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,
44
+ e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+
45
+ ":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('<div style="position:fixed;top:20px;"></div>').appendTo("body");var e=20===
46
+ d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("<style type='text/css'>.fancybox-margin{margin-right:"+(d-a)+"px;}</style>").appendTo("head")})})(window,document,jQuery);
skin/frontend/base/default/js/joomi_masonrygallery/jquery.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
2
+ //@ sourceMappingURL=jquery-1.10.2.min.map
3
+ */
4
+ (function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t
5
+ }({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);
6
+ u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
skin/frontend/base/default/js/joomi_masonrygallery/jquery_masonry.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Masonry PACKAGED v4.0.0
3
+ * Cascading grid layout library
4
+ * http://masonry.desandro.com
5
+ * MIT License
6
+ * by David DeSandro
7
+ */
8
+
9
+ !function(t,e){"use strict";"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,r,a){function h(t,e,n){var o,r="$()."+i+'("'+e+'")';return t.each(function(t,h){var u=a.data(h,i);if(!u)return void s(i+" not initialized. Cannot call methods, i.e. "+r);var d=u[e];if(!d||"_"==e.charAt(0))return void s(r+" is not a valid method");var c=d.apply(u,n);o=void 0===o?c:o}),void 0!==o?o:t}function u(t,e){t.each(function(t,n){var o=a.data(n,i);o?(o.option(e),o._init()):(o=new r(n,e),a.data(n,i,o))})}a=a||e||t.jQuery,a&&(r.prototype.option||(r.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=o.call(arguments,1);return h(this,t,e)}return u(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=i)}var o=Array.prototype.slice,r=t.console,s="undefined"==typeof r?function(){}:function(t){r.error(t)};return n(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}(this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||[];return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,o=i[n];e=e||[];for(var r=this._onceEvents&&this._onceEvents[t];o;){var s=r&&r[o];s&&(this.off(t,o),delete r[o]),o.apply(this,e),n+=s?0:1,o=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){"use strict";function t(t){var e=parseFloat(t),i=-1==t.indexOf("%")&&!isNaN(e);return i&&e}function e(){}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;u>e;e++){var i=h[e];t[i]=0}return t}function n(t){var e=getComputedStyle(t);return e||a("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}function o(){if(!d){d=!0;var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(e);var o=n(e);r.isBoxSizeOuter=s=200==t(o.width),i.removeChild(e)}}function r(e){if(o(),"string"==typeof e&&(e=document.querySelector(e)),e&&"object"==typeof e&&e.nodeType){var r=n(e);if("none"==r.display)return i();var a={};a.width=e.offsetWidth,a.height=e.offsetHeight;for(var d=a.isBorderBox="border-box"==r.boxSizing,c=0;u>c;c++){var l=h[c],f=r[l],m=parseFloat(f);a[l]=isNaN(m)?0:m}var p=a.paddingLeft+a.paddingRight,g=a.paddingTop+a.paddingBottom,y=a.marginLeft+a.marginRight,v=a.marginTop+a.marginBottom,_=a.borderLeftWidth+a.borderRightWidth,E=a.borderTopWidth+a.borderBottomWidth,z=d&&s,b=t(r.width);b!==!1&&(a.width=b+(z?0:p+_));var x=t(r.height);return x!==!1&&(a.height=x+(z?0:g+E)),a.innerWidth=a.width-(p+_),a.innerHeight=a.height-(g+E),a.outerWidth=a.width+y,a.outerHeight=a.height+v,a}}var s,a="undefined"==typeof console?e:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],u=h.length,d=!1;return r}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("matches-selector/matches-selector",e):"object"==typeof module&&module.exports?module.exports=e():t.matchesSelector=e()}(window,function(){"use strict";var t=function(){var t=Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],i=0;i<e.length;i++){var n=e[i],o=n+"MatchesSelector";if(t[o])return o}}();return function(e,i){return e[t](i)}}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("fizzy-ui-utils/utils",["matches-selector/matches-selector"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("desandro-matches-selector")):t.fizzyUIUtils=e(t,t.matchesSelector)}(window,function(t,e){var i={};i.extend=function(t,e){for(var i in e)t[i]=e[i];return t},i.modulo=function(t,e){return(t%e+e)%e},i.makeArray=function(t){var e=[];if(Array.isArray(t))e=t;else if(t&&"number"==typeof t.length)for(var i=0;i<t.length;i++)e.push(t[i]);else e.push(t);return e},i.removeFrom=function(t,e){var i=t.indexOf(e);-1!=i&&t.splice(i,1)},i.getParent=function(t,i){for(;t!=document.body;)if(t=t.parentNode,e(t,i))return t},i.getQueryElement=function(t){return"string"==typeof t?document.querySelector(t):t},i.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},i.filterFindElements=function(t,n){t=i.makeArray(t);var o=[];return t.forEach(function(t){if(t instanceof HTMLElement){if(!n)return void o.push(t);e(t,n)&&o.push(t);for(var i=t.querySelectorAll(n),r=0;r<i.length;r++)o.push(i[r])}}),o},i.debounceMethod=function(t,e,i){var n=t.prototype[e],o=e+"Timeout";t.prototype[e]=function(){var t=this[o];t&&clearTimeout(t);var e=arguments,r=this;this[o]=setTimeout(function(){n.apply(r,e),delete r[o]},i||100)}},i.docReady=function(t){"complete"==document.readyState?t():document.addEventListener("DOMContentLoaded",t)},i.toDashed=function(t){return t.replace(/(.)([A-Z])/g,function(t,e,i){return e+"-"+i}).toLowerCase()};var n=t.console;return i.htmlInit=function(e,o){i.docReady(function(){var r=i.toDashed(o),s="data-"+r,a=document.querySelectorAll("["+s+"]"),h=document.querySelectorAll(".js-"+r),u=i.makeArray(a).concat(i.makeArray(h)),d=s+"-options",c=t.jQuery;u.forEach(function(t){var i,r=t.getAttribute(s)||t.getAttribute(d);try{i=r&&JSON.parse(r)}catch(a){return void(n&&n.error("Error parsing "+s+" on "+t.className+": "+a))}var h=new e(t,i);c&&c.data(t,o,h)})})},i}),function(t,e){"function"==typeof define&&define.amd?define("outlayer/item",["ev-emitter/ev-emitter","get-size/get-size"],function(i,n){return e(t,i,n)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter"),require("get-size")):(t.Outlayer={},t.Outlayer.Item=e(t,t.EvEmitter,t.getSize))}(window,function(t,e,i){"use strict";function n(t){for(var e in t)return!1;return e=null,!0}function o(t,e){t&&(this.element=t,this.layout=e,this.position={x:0,y:0},this._create())}function r(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}var s=document.documentElement.style,a="string"==typeof s.transition?"transition":"WebkitTransition",h="string"==typeof s.transform?"transform":"WebkitTransform",u={WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[a],d=[h,a,a+"Duration",a+"Property"],c=o.prototype=Object.create(e.prototype);c.constructor=o,c._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},c.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},c.getSize=function(){this.size=i(this.element)},c.css=function(t){var e=this.element.style;for(var i in t){var n=d[i]||i;e[n]=t[i]}},c.getPosition=function(){var t=getComputedStyle(this.element),e=this.layout._getOption("originLeft"),i=this.layout._getOption("originTop"),n=t[e?"left":"right"],o=t[i?"top":"bottom"],r=this.layout.size,s=-1!=n.indexOf("%")?parseFloat(n)/100*r.width:parseInt(n,10),a=-1!=o.indexOf("%")?parseFloat(o)/100*r.height:parseInt(o,10);s=isNaN(s)?0:s,a=isNaN(a)?0:a,s-=e?r.paddingLeft:r.paddingRight,a-=i?r.paddingTop:r.paddingBottom,this.position.x=s,this.position.y=a},c.layoutPosition=function(){var t=this.layout.size,e={},i=this.layout._getOption("originLeft"),n=this.layout._getOption("originTop"),o=i?"paddingLeft":"paddingRight",r=i?"left":"right",s=i?"right":"left",a=this.position.x+t[o];e[r]=this.getXValue(a),e[s]="";var h=n?"paddingTop":"paddingBottom",u=n?"top":"bottom",d=n?"bottom":"top",c=this.position.y+t[h];e[u]=this.getYValue(c),e[d]="",this.css(e),this.emitEvent("layout",[this])},c.getXValue=function(t){var e=this.layout._getOption("horizontal");return this.layout.options.percentPosition&&!e?t/this.layout.size.width*100+"%":t+"px"},c.getYValue=function(t){var e=this.layout._getOption("horizontal");return this.layout.options.percentPosition&&e?t/this.layout.size.height*100+"%":t+"px"},c._transitionTo=function(t,e){this.getPosition();var i=this.position.x,n=this.position.y,o=parseInt(t,10),r=parseInt(e,10),s=o===this.position.x&&r===this.position.y;if(this.setPosition(t,e),s&&!this.isTransitioning)return void this.layoutPosition();var a=t-i,h=e-n,u={};u.transform=this.getTranslate(a,h),this.transition({to:u,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},c.getTranslate=function(t,e){var i=this.layout._getOption("originLeft"),n=this.layout._getOption("originTop");return t=i?t:-t,e=n?e:-e,"translate3d("+t+"px, "+e+"px, 0)"},c.goTo=function(t,e){this.setPosition(t,e),this.layoutPosition()},c.moveTo=c._transitionTo,c.setPosition=function(t,e){this.position.x=parseInt(t,10),this.position.y=parseInt(e,10)},c._nonTransition=function(t){this.css(t.to),t.isCleaning&&this._removeStyles(t.to);for(var e in t.onTransitionEnd)t.onTransitionEnd[e].call(this)},c._transition=function(t){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(t);var e=this._transn;for(var i in t.onTransitionEnd)e.onEnd[i]=t.onTransitionEnd[i];for(i in t.to)e.ingProperties[i]=!0,t.isCleaning&&(e.clean[i]=!0);if(t.from){this.css(t.from);var n=this.element.offsetHeight;n=null}this.enableTransition(t.to),this.css(t.to),this.isTransitioning=!0};var l="opacity,"+r(d.transform||"transform");c.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:l,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(u,this,!1))},c.transition=o.prototype[a?"_transition":"_nonTransition"],c.onwebkitTransitionEnd=function(t){this.ontransitionend(t)},c.onotransitionend=function(t){this.ontransitionend(t)};var f={"-webkit-transform":"transform"};c.ontransitionend=function(t){if(t.target===this.element){var e=this._transn,i=f[t.propertyName]||t.propertyName;if(delete e.ingProperties[i],n(e.ingProperties)&&this.disableTransition(),i in e.clean&&(this.element.style[t.propertyName]="",delete e.clean[i]),i in e.onEnd){var o=e.onEnd[i];o.call(this),delete e.onEnd[i]}this.emitEvent("transitionEnd",[this])}},c.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(u,this,!1),this.isTransitioning=!1},c._removeStyles=function(t){var e={};for(var i in t)e[i]="";this.css(e)};var m={transitionProperty:"",transitionDuration:""};return c.removeTransitionStyles=function(){this.css(m)},c.removeElem=function(){this.element.parentNode.removeChild(this.element),this.css({display:""}),this.emitEvent("remove",[this])},c.remove=function(){return a&&parseFloat(this.layout.options.transitionDuration)?(this.once("transitionEnd",function(){this.removeElem()}),void this.hide()):void this.removeElem()},c.reveal=function(){delete this.isHidden,this.css({display:""});var t=this.layout.options,e={},i=this.getHideRevealTransitionEndProperty("visibleStyle");e[i]=this.onRevealTransitionEnd,this.transition({from:t.hiddenStyle,to:t.visibleStyle,isCleaning:!0,onTransitionEnd:e})},c.onRevealTransitionEnd=function(){this.isHidden||this.emitEvent("reveal")},c.getHideRevealTransitionEndProperty=function(t){var e=this.layout.options[t];if(e.opacity)return"opacity";for(var i in e)return i},c.hide=function(){this.isHidden=!0,this.css({display:""});var t=this.layout.options,e={},i=this.getHideRevealTransitionEndProperty("hiddenStyle");e[i]=this.onHideTransitionEnd,this.transition({from:t.visibleStyle,to:t.hiddenStyle,isCleaning:!0,onTransitionEnd:e})},c.onHideTransitionEnd=function(){this.isHidden&&(this.css({display:"none"}),this.emitEvent("hide"))},c.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},o}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("outlayer/outlayer",["ev-emitter/ev-emitter","get-size/get-size","fizzy-ui-utils/utils","./item"],function(i,n,o,r){return e(t,i,n,o,r)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter"),require("get-size"),require("fizzy-ui-utils"),require("./item")):t.Outlayer=e(t,t.EvEmitter,t.getSize,t.fizzyUIUtils,t.Outlayer.Item)}(window,function(t,e,i,n,o){"use strict";function r(t,e){var i=n.getQueryElement(t);if(!i)return void(a&&a.error("Bad element for "+this.constructor.namespace+": "+(i||t)));this.element=i,h&&(this.$element=h(this.element)),this.options=n.extend({},this.constructor.defaults),this.option(e);var o=++d;this.element.outlayerGUID=o,c[o]=this,this._create();var r=this._getOption("initLayout");r&&this.layout()}function s(t){function e(){t.apply(this,arguments)}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e}var a=t.console,h=t.jQuery,u=function(){},d=0,c={};r.namespace="outlayer",r.Item=o,r.defaults={containerStyle:{position:"relative"},initLayout:!0,originLeft:!0,originTop:!0,resize:!0,resizeContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}};var l=r.prototype;return n.extend(l,e.prototype),l.option=function(t){n.extend(this.options,t)},l._getOption=function(t){var e=this.constructor.compatOptions[t];return e&&void 0!==this.options[e]?this.options[e]:this.options[t]},r.compatOptions={initLayout:"isInitLayout",horizontal:"isHorizontal",layoutInstant:"isLayoutInstant",originLeft:"isOriginLeft",originTop:"isOriginTop",resize:"isResizeBound",resizeContainer:"isResizingContainer"},l._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),n.extend(this.element.style,this.options.containerStyle);var t=this._getOption("resize");t&&this.bindResize()},l.reloadItems=function(){this.items=this._itemize(this.element.children)},l._itemize=function(t){for(var e=this._filterFindItemElements(t),i=this.constructor.Item,n=[],o=0;o<e.length;o++){var r=e[o],s=new i(r,this);n.push(s)}return n},l._filterFindItemElements=function(t){return n.filterFindElements(t,this.options.itemSelector)},l.getItemElements=function(){return this.items.map(function(t){return t.element})},l.layout=function(){this._resetLayout(),this._manageStamps();var t=this._getOption("layoutInstant"),e=void 0!==t?t:!this._isLayoutInited;this.layoutItems(this.items,e),this._isLayoutInited=!0},l._init=l.layout,l._resetLayout=function(){this.getSize()},l.getSize=function(){this.size=i(this.element)},l._getMeasurement=function(t,e){var n,o=this.options[t];o?("string"==typeof o?n=this.element.querySelector(o):o instanceof HTMLElement&&(n=o),this[t]=n?i(n)[e]:o):this[t]=0},l.layoutItems=function(t,e){t=this._getItemsForLayout(t),this._layoutItems(t,e),this._postLayout()},l._getItemsForLayout=function(t){return t.filter(function(t){return!t.isIgnored})},l._layoutItems=function(t,e){if(this._emitCompleteOnItems("layout",t),t&&t.length){var i=[];t.forEach(function(t){var n=this._getItemLayoutPosition(t);n.item=t,n.isInstant=e||t.isLayoutInstant,i.push(n)},this),this._processLayoutQueue(i)}},l._getItemLayoutPosition=function(){return{x:0,y:0}},l._processLayoutQueue=function(t){t.forEach(function(t){this._positionItem(t.item,t.x,t.y,t.isInstant)},this)},l._positionItem=function(t,e,i,n){n?t.goTo(e,i):t.moveTo(e,i)},l._postLayout=function(){this.resizeContainer()},l.resizeContainer=function(){var t=this._getOption("resizeContainer");if(t){var e=this._getContainerSize();e&&(this._setContainerMeasure(e.width,!0),this._setContainerMeasure(e.height,!1))}},l._getContainerSize=u,l._setContainerMeasure=function(t,e){if(void 0!==t){var i=this.size;i.isBorderBox&&(t+=e?i.paddingLeft+i.paddingRight+i.borderLeftWidth+i.borderRightWidth:i.paddingBottom+i.paddingTop+i.borderTopWidth+i.borderBottomWidth),t=Math.max(t,0),this.element.style[e?"width":"height"]=t+"px"}},l._emitCompleteOnItems=function(t,e){function i(){o.dispatchEvent(t+"Complete",null,[e])}function n(){s++,s==r&&i()}var o=this,r=e.length;if(!e||!r)return void i();var s=0;e.forEach(function(e){e.once(t,n)})},l.dispatchEvent=function(t,e,i){var n=e?[e].concat(i):i;if(this.emitEvent(t,n),h)if(this.$element=this.$element||h(this.element),e){var o=h.Event(e);o.type=t,this.$element.trigger(o,i)}else this.$element.trigger(t,i)},l.ignore=function(t){var e=this.getItem(t);e&&(e.isIgnored=!0)},l.unignore=function(t){var e=this.getItem(t);e&&delete e.isIgnored},l.stamp=function(t){t=this._find(t),t&&(this.stamps=this.stamps.concat(t),t.forEach(this.ignore,this))},l.unstamp=function(t){t=this._find(t),t&&t.forEach(function(t){n.removeFrom(this.stamps,t),this.unignore(t)},this)},l._find=function(t){return t?("string"==typeof t&&(t=this.element.querySelectorAll(t)),t=n.makeArray(t)):void 0},l._manageStamps=function(){this.stamps&&this.stamps.length&&(this._getBoundingRect(),this.stamps.forEach(this._manageStamp,this))},l._getBoundingRect=function(){var t=this.element.getBoundingClientRect(),e=this.size;this._boundingRect={left:t.left+e.paddingLeft+e.borderLeftWidth,top:t.top+e.paddingTop+e.borderTopWidth,right:t.right-(e.paddingRight+e.borderRightWidth),bottom:t.bottom-(e.paddingBottom+e.borderBottomWidth)}},l._manageStamp=u,l._getElementOffset=function(t){var e=t.getBoundingClientRect(),n=this._boundingRect,o=i(t),r={left:e.left-n.left-o.marginLeft,top:e.top-n.top-o.marginTop,right:n.right-e.right-o.marginRight,bottom:n.bottom-e.bottom-o.marginBottom};return r},l.handleEvent=n.handleEvent,l.bindResize=function(){t.addEventListener("resize",this),this.isResizeBound=!0},l.unbindResize=function(){t.removeEventListener("resize",this),this.isResizeBound=!1},l.onresize=function(){this.resize()},n.debounceMethod(r,"onresize",100),l.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},l.needsResizeLayout=function(){var t=i(this.element),e=this.size&&t;return e&&t.innerWidth!==this.size.innerWidth},l.addItems=function(t){var e=this._itemize(t);return e.length&&(this.items=this.items.concat(e)),e},l.appended=function(t){var e=this.addItems(t);e.length&&(this.layoutItems(e,!0),this.reveal(e))},l.prepended=function(t){var e=this._itemize(t);if(e.length){var i=this.items.slice(0);this.items=e.concat(i),this._resetLayout(),this._manageStamps(),this.layoutItems(e,!0),this.reveal(e),this.layoutItems(i)}},l.reveal=function(t){this._emitCompleteOnItems("reveal",t),t&&t.length&&t.forEach(function(t){t.reveal()})},l.hide=function(t){this._emitCompleteOnItems("hide",t),t&&t.length&&t.forEach(function(t){t.hide()})},l.revealItemElements=function(t){var e=this.getItems(t);this.reveal(e)},l.hideItemElements=function(t){var e=this.getItems(t);this.hide(e)},l.getItem=function(t){for(var e=0;e<this.items.length;e++){var i=this.items[e];if(i.element==t)return i}},l.getItems=function(t){t=n.makeArray(t);var e=[];return t.forEach(function(t){var i=this.getItem(t);i&&e.push(i)},this),e},l.remove=function(t){var e=this.getItems(t);this._emitCompleteOnItems("remove",e),e&&e.length&&e.forEach(function(t){t.remove(),n.removeFrom(this.items,t)},this)},l.destroy=function(){var t=this.element.style;t.height="",t.position="",t.width="",this.items.forEach(function(t){t.destroy()}),this.unbindResize();var e=this.element.outlayerGUID;delete c[e],delete this.element.outlayerGUID,h&&h.removeData(this.element,this.constructor.namespace)},r.data=function(t){t=n.getQueryElement(t);var e=t&&t.outlayerGUID;return e&&c[e]},r.create=function(t,e){var i=s(r);return i.defaults=n.extend({},r.defaults),n.extend(i.defaults,e),i.compatOptions=n.extend({},r.compatOptions),i.namespace=t,i.data=r.data,i.Item=s(o),n.htmlInit(i,t),h&&h.bridget&&h.bridget(t,i),i},r.Item=o,r}),function(t,e){"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size"],e):"object"==typeof module&&module.exports?module.exports=e(require("outlayer"),require("get-size")):t.Masonry=e(t.Outlayer,t.getSize)}(window,function(t,e){var i=t.create("masonry");return i.compatOptions.fitWidth="isFitWidth",i.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns(),this.colYs=[];for(var t=0;t<this.cols;t++)this.colYs.push(0);this.maxY=0},i.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var t=this.items[0],i=t&&t.element;this.columnWidth=i&&e(i).outerWidth||this.containerWidth}var n=this.columnWidth+=this.gutter,o=this.containerWidth+this.gutter,r=o/n,s=n-o%n,a=s&&1>s?"round":"floor";r=Math[a](r),this.cols=Math.max(r,1)},i.prototype.getContainerWidth=function(){var t=this._getOption("fitWidth"),i=t?this.element.parentNode:this.element,n=e(i);this.containerWidth=n&&n.innerWidth},i.prototype._getItemLayoutPosition=function(t){t.getSize();var e=t.size.outerWidth%this.columnWidth,i=e&&1>e?"round":"ceil",n=Math[i](t.size.outerWidth/this.columnWidth);n=Math.min(n,this.cols);for(var o=this._getColGroup(n),r=Math.min.apply(Math,o),s=o.indexOf(r),a={x:this.columnWidth*s,y:r},h=r+t.size.outerHeight,u=this.cols+1-o.length,d=0;u>d;d++)this.colYs[s+d]=h;return a},i.prototype._getColGroup=function(t){if(2>t)return this.colYs;for(var e=[],i=this.cols+1-t,n=0;i>n;n++){var o=this.colYs.slice(n,n+t);e[n]=Math.max.apply(Math,o)}return e},i.prototype._manageStamp=function(t){var i=e(t),n=this._getElementOffset(t),o=this._getOption("originLeft"),r=o?n.left:n.right,s=r+i.outerWidth,a=Math.floor(r/this.columnWidth);a=Math.max(0,a);var h=Math.floor(s/this.columnWidth);h-=s%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var u=this._getOption("originTop"),d=(u?n.top:n.bottom)+i.outerHeight,c=a;h>=c;c++)this.colYs[c]=Math.max(d,this.colYs[c])},i.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var t={height:this.maxY};return this._getOption("fitWidth")&&(t.width=this._getContainerFitWidth()),t},i.prototype._getContainerFitWidth=function(){for(var t=0,e=this.cols;--e&&0===this.colYs[e];)t++;return(this.cols-t)*this.columnWidth-this.gutter},i.prototype.needsResizeLayout=function(){var t=this.containerWidth;return this.getContainerWidth(),t!=this.containerWidth},i});
skin/frontend/base/default/js/joomi_masonrygallery/tree.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Joomi_MasonryGallery extension
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the MIT License
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/mit-license.php
10
+ *
11
+ * @category Joomi
12
+ * @package Joomi_MasonryGallery
13
+ * @copyright Copyright (c) 2016
14
+ * @license http://opensource.org/licenses/mit-license.php MIT License
15
+ */
16
+ function masonrygalleryTree(treeId){
17
+ var tree = $(treeId);
18
+ if(tree){
19
+ tree.addClassName('tree');
20
+ tree.select('ul').each(function(list){
21
+ $(list).hide();
22
+ })
23
+ tree.select('li').each(function(item){
24
+ var children = $(item).childElements().grep(new Selector('ul'));
25
+ if (children.length > 0) {
26
+ var span = new Element('span').addClassName('collapsed');
27
+ span.observe('click', function(el){
28
+ if ($(this).hasClassName('collapsed')){
29
+ this.addClassName('expanded');
30
+ this.removeClassName('collapsed');
31
+ $(item).childElements().grep(new Selector('ul')).each(function(list){
32
+ $(list).show();
33
+ });
34
+ }
35
+ else{
36
+ this.removeClassName('expanded');
37
+ this.addClassName('collapsed');
38
+ $(item).childElements().grep(new Selector('ul')).each(function(list){
39
+ $(list).hide();
40
+ });
41
+ }
42
+ });
43
+ $(item).insert({top:span});
44
+ }
45
+ });
46
+ };
47
+ };