e7b2a9baa900411a6121c63d7174dcd5 - Version 0.1.0

Version Notes

0.1.0 Version Release -
Allows saving filters on any and all filterable grids in the Magento admin.

Allows use of PHP Date Interval Syntax
http://php.net/manual/en/class.dateinterval.php
To store filters by relative dates

Download this release

Release Info

Developer Mediotype
Extension e7b2a9baa900411a6121c63d7174dcd5
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (49) hide show
  1. app/code/community/Mage/Adminhtml/Block/Widget/Grid.php +121 -0
  2. app/code/community/Mediotype/AgileGrid/Block/Adminhtml/Original/Block/Widget/Grid.php +1678 -0
  3. app/code/community/Mediotype/AgileGrid/Block/Adminhtml/Widget/Grid/Column/Filter/Date.php +29 -0
  4. app/code/community/Mediotype/AgileGrid/Block/Adminhtml/Widget/Grid/Column/Filter/Datetime.php +11 -0
  5. app/code/community/Mediotype/AgileGrid/Helper/Data.php +29 -0
  6. app/code/community/Mediotype/AgileGrid/Model/Filter.php +14 -0
  7. app/code/community/Mediotype/AgileGrid/Model/Resource/Filter.php +15 -0
  8. app/code/community/Mediotype/AgileGrid/Model/Resource/Filter/Collection.php +15 -0
  9. app/code/community/Mediotype/AgileGrid/controllers/Adminhtml/FiltersController.php +77 -0
  10. app/code/community/Mediotype/AgileGrid/etc/adminhtml.xml +34 -0
  11. app/code/community/Mediotype/AgileGrid/etc/config.xml +67 -0
  12. app/code/community/Mediotype/AgileGrid/sql/Mediotype_AgileGrid_setup/install-0.1.0.php +57 -0
  13. app/code/community/Mediotype/Core/Block/Entity/Attribute/Input/Renderer/Datetime.php +40 -0
  14. app/code/community/Mediotype/Core/Block/Instructions.php +80 -0
  15. app/code/community/Mediotype/Core/Controller/Front/Action.php +31 -0
  16. app/code/community/Mediotype/Core/Exception.php +48 -0
  17. app/code/community/Mediotype/Core/Helper/Abstract.php +22 -0
  18. app/code/community/Mediotype/Core/Helper/Acl.php +35 -0
  19. app/code/community/Mediotype/Core/Helper/Data.php +110 -0
  20. app/code/community/Mediotype/Core/Helper/Debugger.php +142 -0
  21. app/code/community/Mediotype/Core/Helper/Forms.php +18 -0
  22. app/code/community/Mediotype/Core/Helper/Mschema.php +373 -0
  23. app/code/community/Mediotype/Core/Helper/Mschema/Exception.php +17 -0
  24. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Abstract.php +37 -0
  25. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Cast.php +58 -0
  26. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Datatype.php +53 -0
  27. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Parseavp.php +85 -0
  28. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Regex.php +44 -0
  29. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Strip.php +42 -0
  30. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Trim.php +38 -0
  31. app/code/community/Mediotype/Core/Helper/Mschema/Validator/Ucwords.php +41 -0
  32. app/code/community/Mediotype/Core/Helper/XML.php +34 -0
  33. app/code/community/Mediotype/Core/Model/Entity/Attribute/Backend/Datetime.php +51 -0
  34. app/code/community/Mediotype/Core/Model/Resource/Abstract.php +166 -0
  35. app/code/community/Mediotype/Core/Model/Resource/Db/Collection/Abstract.php +140 -0
  36. app/code/community/Mediotype/Core/Model/Response.php +121 -0
  37. app/code/community/Mediotype/Core/Model/Systems/Api/Json/Request.php +138 -0
  38. app/code/community/Mediotype/Core/Model/Systems/Magento.php +102 -0
  39. app/code/community/Mediotype/Core/data/mediotype_core/install-0.0.1.php +32 -0
  40. app/code/community/Mediotype/Core/etc/adminhtml.xml +25 -0
  41. app/code/community/Mediotype/Core/etc/config.xml +58 -0
  42. app/code/community/Mediotype/Core/etc/system.xml +46 -0
  43. app/design/adminhtml/default/default/layout/mediotype-core/core.xml +8 -0
  44. app/design/adminhtml/default/default/template/mediotype/core/grid.phtml +243 -0
  45. app/etc/modules/Mediotype_AgileGrid.xml +12 -0
  46. app/etc/modules/Mediotype_Core.xml +9 -0
  47. package.xml +42 -0
  48. skin/adminhtml/default/default/mediotype/images/mediotype_section_logo.png +0 -0
  49. skin/adminhtml/default/default/mediotype/mediotype-adminhtml.css +44 -0
app/code/community/Mage/Adminhtml/Block/Widget/Grid.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Adminhtml_Block_Widget_Grid extends Mediotype_AgileGrid_Block_Adminhtml_Original_Block_Widget_Grid
3
+ {
4
+ protected function _prepareLayout()
5
+ {
6
+ parent::_prepareLayout();
7
+ if (Mage::helper('mediotype_core/acl')->isAllowed('adminhtml_filters', 'usefilters', 'mediotype_agilegrid')) {
8
+ if (Mage::helper('mediotype_core/acl')->isAllowed('adminhtml_filters', 'save', 'mediotype_agilegrid')) {
9
+ $this->setChild(
10
+ 'save_filter_button',
11
+ $this->getLayout()->createBlock('adminhtml/widget_button')
12
+ ->setData(
13
+ array(
14
+ 'label' => Mage::helper('adminhtml')->__('Save Filter'),
15
+ 'onclick' => "saveFilter('" . $this->getHtmlId() . "', '" . $this->getUrl(
16
+ 'Mediotype_AgileGrid/Adminhtml_Filters/save'
17
+ ) . "')",
18
+ 'class' => 'save'
19
+ )
20
+ )
21
+ );
22
+ }
23
+
24
+ if (Mage::helper('mediotype_core/acl')->isAllowed('adminhtml_filters', 'delete', 'mediotype_agilegrid')) {
25
+ $this->setChild(
26
+ 'delete_filter_button',
27
+ $this->getLayout()->createBlock('adminhtml/widget_button')
28
+ ->setData(
29
+ array(
30
+ 'label' => Mage::helper('adminhtml')->__('Delete Filter'),
31
+ 'onclick' => "deleteFilter('" . $this->getHtmlId() . "', '" . $this->getUrl(
32
+ 'Mediotype_AgileGrid/Adminhtml_Filters/delete'
33
+ ) . "')",
34
+ 'class' => 'delete'
35
+ )
36
+ )
37
+ );
38
+ }
39
+
40
+ $this->setChild(
41
+ 'reset_filter_button',
42
+ $this->getLayout()->createBlock('adminhtml/widget_button')
43
+ ->setData(
44
+ array(
45
+ 'label' => Mage::helper('adminhtml')->__('Reset Filter'),
46
+ 'onclick' => "loadFilter('" . $this->getHtmlId() . "', '','')",
47
+ )
48
+ )
49
+ );
50
+ }
51
+
52
+ return $this;
53
+ }
54
+
55
+ public function getMainButtonsHtml()
56
+ {
57
+ if (Mage::helper('mediotype_core/acl')->isAllowed('adminhtml_filters', 'usefilters', 'mediotype_agilegrid')) {
58
+ $selectedFilterName = $this->getRequest()->getParam('selectedFilterName', '');
59
+ $filtersCollection = Mage::getModel('mediotype_agilegrid/filter')
60
+ ->getCollection()
61
+ ->addFieldToFilter('grid_id', $this->getId())
62
+ ->load();
63
+ $html = '';
64
+ if ($this->getFilterVisibility()) {
65
+ $html .= "<b>Filters&nbsp;</b>";
66
+ $html .= "<select id='filters'>";
67
+ if (Mage::helper('mediotype_core/acl')->isAllowed('adminhtml_filters', 'save', 'mediotype_agilegrid')) {
68
+ $html .= "<option value=''>New Filter</option>";
69
+ } else {
70
+ $html .= "<option value=''></option>";
71
+ }
72
+
73
+ foreach ($filtersCollection as $filterModel) {
74
+ /** @var $filterModel Mediotype_AgileGrid_Model_Filter */
75
+ $html .=
76
+ "<option value='" . $filterModel->getData(
77
+ 'filter'
78
+ ) . "' " . (($selectedFilterName == $filterModel->getData('name')) ? 'selected' : null) . ">";
79
+ $html .= $filterModel->getData('name');
80
+ $html .= "</option>";
81
+ }
82
+
83
+ $html .= "</select>";
84
+ $html .= $this->getChildHtml('save_filter_button');
85
+
86
+ if ($selectedFilterName) {
87
+ $html .= $this->getChildHtml('delete_filter_button');
88
+ }
89
+
90
+ $html .= $this->getResetFilterButtonHtml();
91
+ $html .= $this->getSearchButtonHtml();
92
+ }
93
+ return $html;
94
+ }
95
+ return parent::getMainButtonsHtml();
96
+ }
97
+
98
+ protected function _toHtml()
99
+ {
100
+ if (Mage::helper('mediotype_core/acl')->isAllowed('adminhtml_filters', 'usefilters', 'mediotype_agilegrid')) {
101
+ $html = parent::_toHtml();
102
+ $html .= "\r\n
103
+ <script type=\"text/javascript\">
104
+ $$('#" . $this->getHtmlId() . " #filters')[0].observe('change', function (event) {
105
+ console.log(event.target.selectedOptions[0].label)
106
+ if (event.target.value != '') {
107
+ loadFilter('" . $this->getHtmlId() . "', event.target.value, event.target.selectedOptions[0].label);
108
+ } else {
109
+ " . $this->getJsObjectName() . ".addVarToUrl('selectedFilterName', '');
110
+ " . $this->getJsObjectName() . ".resetFilter();
111
+ }
112
+ });
113
+ </script>";
114
+ return $html;
115
+ } else {
116
+ return parent::_toHtml();
117
+ }
118
+
119
+ }
120
+
121
+ }
app/code/community/Mediotype/AgileGrid/Block/Adminhtml/Original/Block/Widget/Grid.php ADDED
@@ -0,0 +1,1678 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml grid widget block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mediotype_AgileGrid_Block_Adminhtml_Original_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
35
+ {
36
+ /**
37
+ * Columns array
38
+ *
39
+ * array(
40
+ * 'header' => string,
41
+ * 'width' => int,
42
+ * 'sortable' => bool,
43
+ * 'index' => string,
44
+ * //'renderer' => Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Interface,
45
+ * 'format' => string
46
+ * 'total' => string (sum, avg)
47
+ * )
48
+ * @var array
49
+ */
50
+ protected $_columns = array();
51
+
52
+ protected $_lastColumnId;
53
+
54
+ /**
55
+ * Collection object
56
+ *
57
+ * @var Varien_Data_Collection
58
+ */
59
+ protected $_collection = null;
60
+
61
+ /**
62
+ * Page and sorting var names
63
+ *
64
+ * @var string
65
+ */
66
+ protected $_varNameLimit = 'limit';
67
+ protected $_varNamePage = 'page';
68
+ protected $_varNameSort = 'sort';
69
+ protected $_varNameDir = 'dir';
70
+ protected $_varNameFilter = 'filter';
71
+
72
+ protected $_defaultLimit = 20;
73
+ protected $_defaultPage = 1;
74
+ protected $_defaultSort = false;
75
+ protected $_defaultDir = 'desc';
76
+ protected $_defaultFilter = array();
77
+
78
+ /**
79
+ * Export flag
80
+ *
81
+ * @var bool
82
+ */
83
+ protected $_isExport = false;
84
+
85
+ /**
86
+ * Empty grid text
87
+ *
88
+ * @var sting|null
89
+ */
90
+ protected $_emptyText;
91
+
92
+ /**
93
+ * Empty grid text CSS class
94
+ *
95
+ * @var sting|null
96
+ */
97
+ protected $_emptyTextCss = 'a-center';
98
+
99
+ /**
100
+ * Pager visibility
101
+ *
102
+ * @var boolean
103
+ */
104
+ protected $_pagerVisibility = true;
105
+
106
+ /**
107
+ * Column headers visibility
108
+ *
109
+ * @var boolean
110
+ */
111
+ protected $_headersVisibility = true;
112
+
113
+ /**
114
+ * Filter visibility
115
+ *
116
+ * @var boolean
117
+ */
118
+ protected $_filterVisibility = true;
119
+
120
+ /**
121
+ * Massage block visibility
122
+ *
123
+ * @var boolean
124
+ */
125
+ protected $_messageBlockVisibility = false;
126
+
127
+ protected $_saveParametersInSession = false;
128
+
129
+ /**
130
+ * Count totals
131
+ *
132
+ * @var boolean
133
+ */
134
+ protected $_countTotals = false;
135
+
136
+ /**
137
+ * Count subtotals
138
+ *
139
+ * @var boolean
140
+ */
141
+ protected $_countSubTotals = false;
142
+
143
+ /**
144
+ * Totals
145
+ *
146
+ * @var Varien_Object
147
+ */
148
+ protected $_varTotals;
149
+
150
+ /**
151
+ * SubTotals
152
+ *
153
+ * @var array
154
+ */
155
+ protected $_subtotals = array();
156
+
157
+ /**
158
+ * Grid export types
159
+ *
160
+ * @var array
161
+ */
162
+ protected $_exportTypes = array();
163
+
164
+ /**
165
+ * Rows per page for import
166
+ *
167
+ * @var int
168
+ */
169
+ protected $_exportPageSize = 1000;
170
+
171
+ /**
172
+ * Massaction row id field
173
+ *
174
+ * @var string
175
+ */
176
+ protected $_massactionIdField = null;
177
+
178
+ /**
179
+ * Massaction row id filter
180
+ *
181
+ * @var string
182
+ */
183
+ protected $_massactionIdFilter = null;
184
+
185
+ /**
186
+ * Massaction block name
187
+ *
188
+ * @var string
189
+ */
190
+ protected $_massactionBlockName = 'adminhtml/widget_grid_massaction';
191
+
192
+ /**
193
+ * RSS list
194
+ *
195
+ * @var array
196
+ */
197
+ protected $_rssLists = array();
198
+
199
+ /**
200
+ * Columns view order
201
+ *
202
+ * @var array
203
+ */
204
+ protected $_columnsOrder = array();
205
+
206
+ /**
207
+ * Columns to group by
208
+ *
209
+ * @var array
210
+ */
211
+ protected $_groupedColumn = array();
212
+
213
+ /**
214
+ * Label for empty cell
215
+ *
216
+ * @var string
217
+ */
218
+ protected $_emptyCellLabel = '';
219
+
220
+ public function __construct($attributes=array())
221
+ {
222
+ parent::__construct($attributes);
223
+ $this->setTemplate('widget/grid.phtml');
224
+ $this->setRowClickCallback('openGridRow');
225
+ $this->_emptyText = Mage::helper('adminhtml')->__('No records found.');
226
+ }
227
+
228
+ protected function _prepareLayout()
229
+ {
230
+ $this->setChild('export_button',
231
+ $this->getLayout()->createBlock('adminhtml/widget_button')
232
+ ->setData(array(
233
+ 'label' => Mage::helper('adminhtml')->__('Export'),
234
+ 'onclick' => $this->getJsObjectName().'.doExport()',
235
+ 'class' => 'task'
236
+ ))
237
+ );
238
+ $this->setChild('reset_filter_button',
239
+ $this->getLayout()->createBlock('adminhtml/widget_button')
240
+ ->setData(array(
241
+ 'label' => Mage::helper('adminhtml')->__('Reset Filter'),
242
+ 'onclick' => $this->getJsObjectName().'.resetFilter()',
243
+ ))
244
+ );
245
+ $this->setChild('search_button',
246
+ $this->getLayout()->createBlock('adminhtml/widget_button')
247
+ ->setData(array(
248
+ 'label' => Mage::helper('adminhtml')->__('Search'),
249
+ 'onclick' => $this->getJsObjectName().'.doFilter()',
250
+ 'class' => 'task'
251
+ ))
252
+ );
253
+ return parent::_prepareLayout();
254
+ }
255
+
256
+ public function getExportButtonHtml()
257
+ {
258
+ return $this->getChildHtml('export_button');
259
+ }
260
+
261
+ public function getResetFilterButtonHtml()
262
+ {
263
+ return $this->getChildHtml('reset_filter_button');
264
+ }
265
+
266
+ public function getSearchButtonHtml()
267
+ {
268
+ return $this->getChildHtml('search_button');
269
+ }
270
+
271
+ public function getMainButtonsHtml()
272
+ {
273
+ $html = '';
274
+ if($this->getFilterVisibility()){
275
+ $html.= $this->getResetFilterButtonHtml();
276
+ $html.= $this->getSearchButtonHtml();
277
+ }
278
+ return $html;
279
+ }
280
+
281
+ /**
282
+ * set collection object
283
+ *
284
+ * @param Varien_Data_Collection $collection
285
+ */
286
+ //public function setCollection(Varien_Data_Collection $collection)
287
+ public function setCollection($collection)
288
+ {
289
+ $this->_collection = $collection;
290
+ }
291
+
292
+ /**
293
+ * get collection object
294
+ *
295
+ * @return Varien_Data_Collection
296
+ */
297
+ public function getCollection()
298
+ {
299
+ return $this->_collection;
300
+ }
301
+
302
+ /**
303
+ * Add column to grid
304
+ *
305
+ * @param string $columnId
306
+ * @param array || Varien_Object $column
307
+ * @return Mage_Adminhtml_Block_Widget_Grid
308
+ */
309
+ public function addColumn($columnId, $column)
310
+ {
311
+ if (is_array($column)) {
312
+ $this->_columns[$columnId] = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
313
+ ->setData($column)
314
+ ->setGrid($this);
315
+ }
316
+ /*elseif ($column instanceof Varien_Object) {
317
+ $this->_columns[$columnId] = $column;
318
+ }*/
319
+ else {
320
+ throw new Exception(Mage::helper('adminhtml')->__('Wrong column format.'));
321
+ }
322
+
323
+ $this->_columns[$columnId]->setId($columnId);
324
+ $this->_lastColumnId = $columnId;
325
+ return $this;
326
+ }
327
+
328
+ /**
329
+ * Remove existing column
330
+ *
331
+ * @param string $columnId
332
+ * @return Mage_Adminhtml_Block_Widget_Grid
333
+ */
334
+ public function removeColumn($columnId)
335
+ {
336
+ if (isset($this->_columns[$columnId])) {
337
+ unset($this->_columns[$columnId]);
338
+ if ($this->_lastColumnId == $columnId) {
339
+ $this->_lastColumnId = key($this->_columns);
340
+ }
341
+ }
342
+ return $this;
343
+ }
344
+
345
+ /**
346
+ * Add column to grid after specified column.
347
+ *
348
+ * @param string $columnId
349
+ * @param array|Varien_Object $column
350
+ * @param string $after
351
+ * @return Mage_Adminhtml_Block_Widget_Grid
352
+ */
353
+ public function addColumnAfter($columnId, $column, $after)
354
+ {
355
+ $this->addColumn($columnId, $column);
356
+ $this->addColumnsOrder($columnId, $after);
357
+ return $this;
358
+ }
359
+
360
+ /**
361
+ * Add column view order
362
+ *
363
+ * @param string $columnId
364
+ * @param string $after
365
+ * @return Mage_Adminhtml_Block_Widget_Grid
366
+ */
367
+ public function addColumnsOrder($columnId, $after)
368
+ {
369
+ $this->_columnsOrder[$columnId] = $after;
370
+ return $this;
371
+ }
372
+
373
+ /**
374
+ * Retrieve columns order
375
+ *
376
+ * @return array
377
+ */
378
+ public function getColumnsOrder()
379
+ {
380
+ return $this->_columnsOrder;
381
+ }
382
+
383
+ /**
384
+ * Sort columns by predefined order
385
+ *
386
+ * @return Mage_Adminhtml_Block_Widget_Grid
387
+ */
388
+ public function sortColumnsByOrder()
389
+ {
390
+ $keys = array_keys($this->_columns);
391
+ $values = array_values($this->_columns);
392
+
393
+ foreach ($this->getColumnsOrder() as $columnId => $after) {
394
+ if (array_search($after, $keys) !== false) {
395
+ // Moving grid column
396
+ $positionCurrent = array_search($columnId, $keys);
397
+
398
+ $key = array_splice($keys, $positionCurrent, 1);
399
+ $value = array_splice($values, $positionCurrent, 1);
400
+
401
+ $positionTarget = array_search($after, $keys) + 1;
402
+
403
+ array_splice($keys, $positionTarget, 0, $key);
404
+ array_splice($values, $positionTarget, 0, $value);
405
+
406
+ $this->_columns = array_combine($keys, $values);
407
+ }
408
+ }
409
+
410
+ end($this->_columns);
411
+ $this->_lastColumnId = key($this->_columns);
412
+ return $this;
413
+ }
414
+
415
+ public function getLastColumnId()
416
+ {
417
+ return $this->_lastColumnId;
418
+ }
419
+
420
+ public function getColumnCount()
421
+ {
422
+ return count($this->getColumns());
423
+ }
424
+
425
+ /**
426
+ * Retrieve grid column by column id
427
+ *
428
+ * @param string $columnId
429
+ * @return Varien_Object || false
430
+ */
431
+ public function getColumn($columnId)
432
+ {
433
+ if (!empty($this->_columns[$columnId])) {
434
+ return $this->_columns[$columnId];
435
+ }
436
+ return false;
437
+ }
438
+
439
+ /**
440
+ * Retrieve all grid columns
441
+ *
442
+ * @return array
443
+ */
444
+ public function getColumns()
445
+ {
446
+ return $this->_columns;
447
+ }
448
+
449
+ protected function _setFilterValues($data)
450
+ {
451
+ foreach ($this->getColumns() as $columnId => $column) {
452
+ if (isset($data[$columnId])
453
+ && (!empty($data[$columnId]) || strlen($data[$columnId]) > 0)
454
+ && $column->getFilter()
455
+ ) {
456
+ $column->getFilter()->setValue($data[$columnId]);
457
+ $this->_addColumnFilterToCollection($column);
458
+ }
459
+ }
460
+ return $this;
461
+ }
462
+
463
+ protected function _addColumnFilterToCollection($column)
464
+ {
465
+ if ($this->getCollection()) {
466
+ $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
467
+ if ($column->getFilterConditionCallback()) {
468
+ call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
469
+ } else {
470
+ $cond = $column->getFilter()->getCondition();
471
+ if ($field && isset($cond)) {
472
+ $this->getCollection()->addFieldToFilter($field , $cond);
473
+ }
474
+ }
475
+ }
476
+ return $this;
477
+ }
478
+
479
+ /**
480
+ * Sets sorting order by some column
481
+ *
482
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
483
+ * @return Mage_Adminhtml_Block_Widget_Grid
484
+ */
485
+ protected function _setCollectionOrder($column)
486
+ {
487
+ $collection = $this->getCollection();
488
+ if ($collection) {
489
+ $columnIndex = $column->getFilterIndex() ?
490
+ $column->getFilterIndex() : $column->getIndex();
491
+ $collection->setOrder($columnIndex, strtoupper($column->getDir()));
492
+ }
493
+ return $this;
494
+ }
495
+
496
+ /**
497
+ * Prepare grid collection object
498
+ *
499
+ * @return Mage_Adminhtml_Block_Widget_Grid
500
+ */
501
+ protected function _prepareCollection()
502
+ {
503
+ if ($this->getCollection()) {
504
+
505
+ $this->_preparePage();
506
+
507
+ $columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
508
+ $dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir);
509
+ $filter = $this->getParam($this->getVarNameFilter(), null);
510
+
511
+ if (is_null($filter)) {
512
+ $filter = $this->_defaultFilter;
513
+ }
514
+
515
+ if (is_string($filter)) {
516
+ $data = $this->helper('adminhtml')->prepareFilterString($filter);
517
+ $this->_setFilterValues($data);
518
+ }
519
+ else if ($filter && is_array($filter)) {
520
+ $this->_setFilterValues($filter);
521
+ }
522
+ else if(0 !== sizeof($this->_defaultFilter)) {
523
+ $this->_setFilterValues($this->_defaultFilter);
524
+ }
525
+
526
+ if (isset($this->_columns[$columnId]) && $this->_columns[$columnId]->getIndex()) {
527
+ $dir = (strtolower($dir)=='desc') ? 'desc' : 'asc';
528
+ $this->_columns[$columnId]->setDir($dir);
529
+ $this->_setCollectionOrder($this->_columns[$columnId]);
530
+ }
531
+
532
+ if (!$this->_isExport) {
533
+ $this->getCollection()->load();
534
+ $this->_afterLoadCollection();
535
+ }
536
+ }
537
+
538
+ return $this;
539
+ }
540
+
541
+ /**
542
+ * Decode URL encoded filter value recursive callback method
543
+ *
544
+ * @var string $value
545
+ */
546
+ protected function _decodeFilter(&$value)
547
+ {
548
+ $value = $this->helper('adminhtml')->decodeFilter($value);
549
+ }
550
+
551
+ protected function _preparePage()
552
+ {
553
+ $this->getCollection()->setPageSize((int) $this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
554
+ $this->getCollection()->setCurPage((int) $this->getParam($this->getVarNamePage(), $this->_defaultPage));
555
+ }
556
+
557
+ protected function _prepareColumns()
558
+ {
559
+ $this->sortColumnsByOrder();
560
+ return $this;
561
+ }
562
+
563
+ /**
564
+ * Prepare grid massaction block
565
+ *
566
+ * @return Mage_Adminhtml_Block_Widget_Grid
567
+ */
568
+ protected function _prepareMassactionBlock()
569
+ {
570
+ $this->setChild('massaction', $this->getLayout()->createBlock($this->getMassactionBlockName()));
571
+ $this->_prepareMassaction();
572
+ if($this->getMassactionBlock()->isAvailable()) {
573
+ $this->_prepareMassactionColumn();
574
+ }
575
+ return $this;
576
+ }
577
+
578
+ /**
579
+ * Prepare grid massaction actions
580
+ *
581
+ * @return Mage_Adminhtml_Block_Widget_Grid
582
+ */
583
+ protected function _prepareMassaction()
584
+ {
585
+
586
+ return $this;
587
+ }
588
+
589
+ /**
590
+ * Prepare grid massaction column
591
+ *
592
+ * @return unknown
593
+ */
594
+ protected function _prepareMassactionColumn()
595
+ {
596
+ $columnId = 'massaction';
597
+ $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
598
+ ->setData(array(
599
+ 'index' => $this->getMassactionIdField(),
600
+ 'filter_index' => $this->getMassactionIdFilter(),
601
+ 'type' => 'massaction',
602
+ 'name' => $this->getMassactionBlock()->getFormFieldName(),
603
+ 'align' => 'center',
604
+ 'is_system' => true
605
+ ));
606
+
607
+ if ($this->getNoFilterMassactionColumn()) {
608
+ $massactionColumn->setData('filter', false);
609
+ }
610
+
611
+ $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
612
+ ->setGrid($this)
613
+ ->setId($columnId);
614
+
615
+ $oldColumns = $this->_columns;
616
+ $this->_columns = array();
617
+ $this->_columns[$columnId] = $massactionColumn;
618
+ $this->_columns = array_merge($this->_columns, $oldColumns);
619
+ return $this;
620
+ }
621
+
622
+ protected function _prepareGrid()
623
+ {
624
+ $this->_prepareColumns();
625
+ $this->_prepareMassactionBlock();
626
+ $this->_prepareCollection();
627
+ return $this;
628
+ }
629
+
630
+ protected function _beforeToHtml()
631
+ {
632
+ $this->_prepareGrid();
633
+ return parent::_beforeToHtml();
634
+ }
635
+
636
+ protected function _afterLoadCollection()
637
+ {
638
+ return $this;
639
+ }
640
+
641
+ public function getVarNameLimit()
642
+ {
643
+ return $this->_varNameLimit;
644
+ }
645
+
646
+ public function getVarNamePage()
647
+ {
648
+ return $this->_varNamePage;
649
+ }
650
+
651
+ public function getVarNameSort()
652
+ {
653
+ return $this->_varNameSort;
654
+ }
655
+
656
+ public function getVarNameDir()
657
+ {
658
+ return $this->_varNameDir;
659
+ }
660
+
661
+ public function getVarNameFilter()
662
+ {
663
+ return $this->_varNameFilter;
664
+ }
665
+
666
+ public function setVarNameLimit($name)
667
+ {
668
+ return $this->_varNameLimit = $name;
669
+ }
670
+
671
+ public function setVarNamePage($name)
672
+ {
673
+ return $this->_varNamePage = $name;
674
+ }
675
+
676
+ public function setVarNameSort($name)
677
+ {
678
+ return $this->_varNameSort = $name;
679
+ }
680
+
681
+ public function setVarNameDir($name)
682
+ {
683
+ return $this->_varNameDir = $name;
684
+ }
685
+
686
+ public function setVarNameFilter($name)
687
+ {
688
+ return $this->_varNameFilter = $name;
689
+ }
690
+
691
+ /**
692
+ * Set visibility of column headers
693
+ *
694
+ * @param boolean $visible
695
+ */
696
+ public function setHeadersVisibility($visible=true)
697
+ {
698
+ $this->_headersVisibility = $visible;
699
+ }
700
+
701
+ /**
702
+ * Return visibility of column headers
703
+ *
704
+ * @return boolean
705
+ */
706
+ public function getHeadersVisibility()
707
+ {
708
+ return $this->_headersVisibility;
709
+ }
710
+
711
+ /**
712
+ * Set visibility of pager
713
+ *
714
+ * @param boolean $visible
715
+ */
716
+ public function setPagerVisibility($visible=true)
717
+ {
718
+ $this->_pagerVisibility = $visible;
719
+ }
720
+
721
+ /**
722
+ * Return visibility of pager
723
+ *
724
+ * @return boolean
725
+ */
726
+ public function getPagerVisibility()
727
+ {
728
+ return $this->_pagerVisibility;
729
+ }
730
+
731
+ /**
732
+ * Set visibility of filter
733
+ *
734
+ * @param boolean $visible
735
+ */
736
+ public function setFilterVisibility($visible=true)
737
+ {
738
+ $this->_filterVisibility = $visible;
739
+ }
740
+
741
+ /**
742
+ * Return visibility of filter
743
+ *
744
+ * @return boolean
745
+ */
746
+ public function getFilterVisibility()
747
+ {
748
+ return $this->_filterVisibility;
749
+ }
750
+
751
+ /**
752
+ * Set visibility of filter
753
+ *
754
+ * @param boolean $visible
755
+ */
756
+ public function setMessageBlockVisibility($visible=true)
757
+ {
758
+ $this->_messageBlockVisibility = $visible;
759
+ }
760
+
761
+ /**
762
+ * Return visibility of filter
763
+ *
764
+ * @return boolean
765
+ */
766
+ public function getMessageBlockVisibility()
767
+ {
768
+ return $this->_messageBlockVisibility;
769
+ }
770
+
771
+ public function setDefaultLimit($limit)
772
+ {
773
+ $this->_defaultLimit = $limit;
774
+ return $this;
775
+ }
776
+
777
+ public function setDefaultPage($page)
778
+ {
779
+ $this->_defaultPage = $page;
780
+ return $this;
781
+ }
782
+
783
+ public function setDefaultSort($sort)
784
+ {
785
+ $this->_defaultSort = $sort;
786
+ return $this;
787
+ }
788
+
789
+ public function setDefaultDir($dir)
790
+ {
791
+ $this->_defaultDir = $dir;
792
+ return $this;
793
+ }
794
+
795
+ public function setDefaultFilter($filter)
796
+ {
797
+ $this->_defaultFilter = $filter;
798
+ return $this;
799
+ }
800
+
801
+ /**
802
+ * Retrieve grid export types
803
+ *
804
+ * @return array|false
805
+ */
806
+ public function getExportTypes()
807
+ {
808
+ return empty($this->_exportTypes) ? false : $this->_exportTypes;
809
+ }
810
+
811
+ /**
812
+ * Add new export type to grid
813
+ *
814
+ * @param string $url
815
+ * @param string $label
816
+ * @return Mage_Adminhtml_Block_Widget_Grid
817
+ */
818
+ public function addExportType($url, $label)
819
+ {
820
+ $this->_exportTypes[] = new Varien_Object(
821
+ array(
822
+ 'url' => $this->getUrl($url, array('_current'=>true)),
823
+ 'label' => $label
824
+ )
825
+ );
826
+ return $this;
827
+ }
828
+
829
+ /**
830
+ * Retrieve rss lists types
831
+ *
832
+ * @return array
833
+ */
834
+ public function getRssLists()
835
+ {
836
+ return empty($this->_rssLists) ? false : $this->_rssLists;
837
+ }
838
+
839
+ /**
840
+ * Returns url for RSS
841
+ * Can be overloaded in descendant classes to perform custom changes to url passed to addRssList()
842
+ *
843
+ * @param string $url
844
+ * @return string
845
+ */
846
+ protected function _getRssUrl($url)
847
+ {
848
+ $urlModel = Mage::getModel('core/url');
849
+ if (Mage::app()->getStore()->getStoreInUrl()) {
850
+ // Url in 'admin' store view won't be accessible, so form it in default store view frontend
851
+ $urlModel->setStore(Mage::app()->getDefaultStoreView());
852
+ }
853
+ return $urlModel->getUrl($url);
854
+ }
855
+
856
+ /**
857
+ * Add new rss list to grid
858
+ *
859
+ * @param string $url
860
+ * @param string $label
861
+ * @return Mage_Adminhtml_Block_Widget_Grid
862
+ */
863
+ public function addRssList($url, $label)
864
+ {
865
+ $this->_rssLists[] = new Varien_Object(
866
+ array(
867
+ 'url' => $this->_getRssUrl($url),
868
+ 'label' => $label
869
+ )
870
+ );
871
+ return $this;
872
+ }
873
+
874
+ /**
875
+ * Retrieve grid HTML
876
+ *
877
+ * @return string
878
+ */
879
+ public function getHtml()
880
+ {
881
+ return $this->toHtml();
882
+ }
883
+
884
+ /**
885
+ * Retrieve file content from file container array
886
+ *
887
+ * @param array $fileData
888
+ * @return string
889
+ */
890
+ protected function _getFileContainerContent(array $fileData)
891
+ {
892
+ $io = new Varien_Io_File();
893
+ $path = $io->dirname($fileData['value']);
894
+ $io->open(array('path' => $path));
895
+ return $io->read($fileData['value']);
896
+ }
897
+
898
+ /**
899
+ * Retrieve Headers row array for Export
900
+ *
901
+ * @return array
902
+ */
903
+ protected function _getExportHeaders()
904
+ {
905
+ $row = array();
906
+ foreach ($this->_columns as $column) {
907
+ if (!$column->getIsSystem()) {
908
+ $row[] = $column->getExportHeader();
909
+ }
910
+ }
911
+ return $row;
912
+ }
913
+
914
+ /**
915
+ * Retrieve Totals row array for Export
916
+ *
917
+ * @return array
918
+ */
919
+ protected function _getExportTotals()
920
+ {
921
+ $totals = $this->getTotals();
922
+ $row = array();
923
+ foreach ($this->_columns as $column) {
924
+ if (!$column->getIsSystem()) {
925
+ $row[] = ($column->hasTotalsLabel()) ? $column->getTotalsLabel() : $column->getRowFieldExport($totals);
926
+ }
927
+ }
928
+ return $row;
929
+ }
930
+
931
+ /**
932
+ * Iterate collection and call callback method per item
933
+ * For callback method first argument always is item object
934
+ *
935
+ * @param string $callback
936
+ * @param array $args additional arguments for callback method
937
+ * @return Mage_Adminhtml_Block_Widget_Grid
938
+ */
939
+ public function _exportIterateCollection($callback, array $args)
940
+ {
941
+ $originalCollection = $this->getCollection();
942
+ $count = null;
943
+ $page = 1;
944
+ $lPage = null;
945
+ $break = false;
946
+
947
+ while ($break !== true) {
948
+ $collection = clone $originalCollection;
949
+ $collection->setPageSize($this->_exportPageSize);
950
+ $collection->setCurPage($page);
951
+ $collection->load();
952
+ if (is_null($count)) {
953
+ $count = $collection->getSize();
954
+ $lPage = $collection->getLastPageNumber();
955
+ }
956
+ if ($lPage == $page) {
957
+ $break = true;
958
+ }
959
+ $page ++;
960
+
961
+ foreach ($collection as $item) {
962
+ call_user_func_array(array($this, $callback), array_merge(array($item), $args));
963
+ }
964
+ }
965
+ }
966
+
967
+ /**
968
+ * Write item data to csv export file
969
+ *
970
+ * @param Varien_Object $item
971
+ * @param Varien_Io_File $adapter
972
+ */
973
+ protected function _exportCsvItem(Varien_Object $item, Varien_Io_File $adapter)
974
+ {
975
+ $row = array();
976
+ foreach ($this->_columns as $column) {
977
+ if (!$column->getIsSystem()) {
978
+ $row[] = $column->getRowFieldExport($item);
979
+ }
980
+ }
981
+ $adapter->streamWriteCsv($row);
982
+ }
983
+
984
+ /**
985
+ * Retrieve a file container array by grid data as CSV
986
+ *
987
+ * Return array with keys type and value
988
+ *
989
+ * @return array
990
+ */
991
+ public function getCsvFile()
992
+ {
993
+ $this->_isExport = true;
994
+ $this->_prepareGrid();
995
+
996
+ $io = new Varien_Io_File();
997
+
998
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS;
999
+ $name = md5(microtime());
1000
+ $file = $path . DS . $name . '.csv';
1001
+
1002
+ $io->setAllowCreateFolders(true);
1003
+ $io->open(array('path' => $path));
1004
+ $io->streamOpen($file, 'w+');
1005
+ $io->streamLock(true);
1006
+ $io->streamWriteCsv($this->_getExportHeaders());
1007
+
1008
+ $this->_exportIterateCollection('_exportCsvItem', array($io));
1009
+
1010
+ if ($this->getCountTotals()) {
1011
+ $io->streamWriteCsv($this->_getExportTotals());
1012
+ }
1013
+
1014
+ $io->streamUnlock();
1015
+ $io->streamClose();
1016
+
1017
+ return array(
1018
+ 'type' => 'filename',
1019
+ 'value' => $file,
1020
+ 'rm' => true // can delete file after use
1021
+ );
1022
+ }
1023
+
1024
+ /**
1025
+ * Retrieve Grid data as CSV
1026
+ *
1027
+ * @return string
1028
+ */
1029
+ public function getCsv()
1030
+ {
1031
+ $csv = '';
1032
+ $this->_isExport = true;
1033
+ $this->_prepareGrid();
1034
+ $this->getCollection()->getSelect()->limit();
1035
+ $this->getCollection()->setPageSize(0);
1036
+ $this->getCollection()->load();
1037
+ $this->_afterLoadCollection();
1038
+
1039
+ $data = array();
1040
+ foreach ($this->_columns as $column) {
1041
+ if (!$column->getIsSystem()) {
1042
+ $data[] = '"'.$column->getExportHeader().'"';
1043
+ }
1044
+ }
1045
+ $csv.= implode(',', $data)."\n";
1046
+
1047
+ foreach ($this->getCollection() as $item) {
1048
+ $data = array();
1049
+ foreach ($this->_columns as $column) {
1050
+ if (!$column->getIsSystem()) {
1051
+ $data[] = '"' . str_replace(array('"', '\\'), array('""', '\\\\'),
1052
+ $column->getRowFieldExport($item)) . '"';
1053
+ }
1054
+ }
1055
+ $csv.= implode(',', $data)."\n";
1056
+ }
1057
+
1058
+ if ($this->getCountTotals())
1059
+ {
1060
+ $data = array();
1061
+ foreach ($this->_columns as $column) {
1062
+ if (!$column->getIsSystem()) {
1063
+ $data[] = '"' . str_replace(array('"', '\\'), array('""', '\\\\'),
1064
+ $column->getRowFieldExport($this->getTotals())) . '"';
1065
+ }
1066
+ }
1067
+ $csv.= implode(',', $data)."\n";
1068
+ }
1069
+
1070
+ return $csv;
1071
+ }
1072
+
1073
+ public function getXml()
1074
+ {
1075
+ $this->_isExport = true;
1076
+ $this->_prepareGrid();
1077
+ $this->getCollection()->getSelect()->limit();
1078
+ $this->getCollection()->setPageSize(0);
1079
+ $this->getCollection()->load();
1080
+ $this->_afterLoadCollection();
1081
+ $indexes = array();
1082
+ foreach ($this->_columns as $column) {
1083
+ if (!$column->getIsSystem()) {
1084
+ $indexes[] = $column->getIndex();
1085
+ }
1086
+ }
1087
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
1088
+ $xml.= '<items>';
1089
+ foreach ($this->getCollection() as $item) {
1090
+ $xml.= $item->toXml($indexes);
1091
+ }
1092
+ if ($this->getCountTotals())
1093
+ {
1094
+ $xml.= $this->getTotals()->toXml($indexes);
1095
+ }
1096
+ $xml.= '</items>';
1097
+ return $xml;
1098
+ }
1099
+
1100
+ /**
1101
+ * Write item data to Excel 2003 XML export file
1102
+ *
1103
+ * @param Varien_Object $item
1104
+ * @param Varien_Io_File $adapter
1105
+ * @param Varien_Convert_Parser_Xml_Excel $parser
1106
+ */
1107
+ protected function _exportExcelItem(Varien_Object $item, Varien_Io_File $adapter, $parser = null)
1108
+ {
1109
+ if (is_null($parser)) {
1110
+ $parser = new Varien_Convert_Parser_Xml_Excel();
1111
+ }
1112
+
1113
+ $row = array();
1114
+ foreach ($this->_columns as $column) {
1115
+ if (!$column->getIsSystem()) {
1116
+ $row[] = $column->getRowFieldExport($item);
1117
+ }
1118
+ }
1119
+ $data = $parser->getRowXml($row);
1120
+ $adapter->streamWrite($data);
1121
+ }
1122
+
1123
+ /**
1124
+ * Retrieve a file container array by grid data as MS Excel 2003 XML Document
1125
+ *
1126
+ * Return array with keys type and value
1127
+ *
1128
+ * @return string
1129
+ */
1130
+ public function getExcelFile($sheetName = '')
1131
+ {
1132
+ $this->_isExport = true;
1133
+ $this->_prepareGrid();
1134
+
1135
+ $parser = new Varien_Convert_Parser_Xml_Excel();
1136
+ $io = new Varien_Io_File();
1137
+
1138
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS;
1139
+ $name = md5(microtime());
1140
+ $file = $path . DS . $name . '.xml';
1141
+
1142
+ $io->setAllowCreateFolders(true);
1143
+ $io->open(array('path' => $path));
1144
+ $io->streamOpen($file, 'w+');
1145
+ $io->streamLock(true);
1146
+ $io->streamWrite($parser->getHeaderXml($sheetName));
1147
+ $io->streamWrite($parser->getRowXml($this->_getExportHeaders()));
1148
+
1149
+ $this->_exportIterateCollection('_exportExcelItem', array($io, $parser));
1150
+
1151
+ if ($this->getCountTotals()) {
1152
+ $io->streamWrite($parser->getRowXml($this->_getExportTotals()));
1153
+ }
1154
+
1155
+ $io->streamWrite($parser->getFooterXml());
1156
+ $io->streamUnlock();
1157
+ $io->streamClose();
1158
+
1159
+ return array(
1160
+ 'type' => 'filename',
1161
+ 'value' => $file,
1162
+ 'rm' => true // can delete file after use
1163
+ );
1164
+ }
1165
+
1166
+ /**
1167
+ * Retrieve grid data as MS Excel 2003 XML Document
1168
+ *
1169
+ * @param string $filename the Workbook sheet name
1170
+ * @return string
1171
+ */
1172
+ public function getExcel($filename = '')
1173
+ {
1174
+ $this->_isExport = true;
1175
+ $this->_prepareGrid();
1176
+ $this->getCollection()->getSelect()->limit();
1177
+ $this->getCollection()->setPageSize(0);
1178
+ $this->getCollection()->load();
1179
+ $this->_afterLoadCollection();
1180
+ $headers = array();
1181
+ $data = array();
1182
+ foreach ($this->_columns as $column) {
1183
+ if (!$column->getIsSystem()) {
1184
+ $headers[] = $column->getHeader();
1185
+ }
1186
+ }
1187
+ $data[] = $headers;
1188
+
1189
+ foreach ($this->getCollection() as $item) {
1190
+ $row = array();
1191
+ foreach ($this->_columns as $column) {
1192
+ if (!$column->getIsSystem()) {
1193
+ $row[] = $column->getRowField($item);
1194
+ }
1195
+ }
1196
+ $data[] = $row;
1197
+ }
1198
+
1199
+ if ($this->getCountTotals())
1200
+ {
1201
+ $row = array();
1202
+ foreach ($this->_columns as $column) {
1203
+ if (!$column->getIsSystem()) {
1204
+ $row[] = $column->getRowField($this->getTotals());
1205
+ }
1206
+ }
1207
+ $data[] = $row;
1208
+ }
1209
+
1210
+ $xmlObj = new Varien_Convert_Parser_Xml_Excel();
1211
+ $xmlObj->setVar('single_sheet', $filename);
1212
+ $xmlObj->setData($data);
1213
+ $xmlObj->unparse();
1214
+
1215
+ return $xmlObj->getData();
1216
+ }
1217
+
1218
+ public function canDisplayContainer()
1219
+ {
1220
+ if ($this->getRequest()->getQuery('ajax')) {
1221
+ return false;
1222
+ }
1223
+ return true;
1224
+ }
1225
+
1226
+ /**
1227
+ * Grid url getter
1228
+ *
1229
+ * @deprecated after 1.3.2.3 Use getAbsoluteGridUrl() method instead
1230
+ *
1231
+ * @return string current grid url
1232
+ */
1233
+ public function getGridUrl()
1234
+ {
1235
+ return $this->getCurrentUrl();
1236
+ }
1237
+
1238
+ /**
1239
+ * Grid url getter
1240
+ * Version of getGridUrl() but with parameters
1241
+ *
1242
+ * @param array $params url parameters
1243
+ * @return string current grid url
1244
+ */
1245
+ public function getAbsoluteGridUrl($params = array())
1246
+ {
1247
+ return $this->getCurrentUrl($params);
1248
+ }
1249
+
1250
+ /**
1251
+ * Retrieve grid
1252
+ *
1253
+ * @param string $paramName
1254
+ * @param mixed $default
1255
+ * @return mixed
1256
+ */
1257
+ public function getParam($paramName, $default=null)
1258
+ {
1259
+ $session = Mage::getSingleton('adminhtml/session');
1260
+ $sessionParamName = $this->getId().$paramName;
1261
+ if ($this->getRequest()->has($paramName)) {
1262
+ $param = $this->getRequest()->getParam($paramName);
1263
+ if ($this->_saveParametersInSession) {
1264
+ $session->setData($sessionParamName, $param);
1265
+ }
1266
+ return $param;
1267
+ }
1268
+ elseif ($this->_saveParametersInSession && ($param = $session->getData($sessionParamName)))
1269
+ {
1270
+ return $param;
1271
+ }
1272
+
1273
+ return $default;
1274
+ }
1275
+
1276
+ public function setSaveParametersInSession($flag)
1277
+ {
1278
+ $this->_saveParametersInSession = $flag;
1279
+ return $this;
1280
+ }
1281
+
1282
+ public function getJsObjectName()
1283
+ {
1284
+ return $this->getId().'JsObject';
1285
+ }
1286
+
1287
+ /**
1288
+ * Deprecated since 1.1.7
1289
+ *
1290
+ * @return string
1291
+ */
1292
+ public function getRowId($row)
1293
+ {
1294
+ return $this->getRowUrl($row);
1295
+ }
1296
+
1297
+ /**
1298
+ * Retrieve massaction row identifier field
1299
+ *
1300
+ * @return string
1301
+ */
1302
+ public function getMassactionIdField()
1303
+ {
1304
+ return $this->_massactionIdField;
1305
+ }
1306
+
1307
+ /**
1308
+ * Set massaction row identifier field
1309
+ *
1310
+ * @param string $idField
1311
+ * @return Mage_Adminhtml_Block_Widget_Grid
1312
+ */
1313
+ public function setMassactionIdField($idField)
1314
+ {
1315
+ $this->_massactionIdField = $idField;
1316
+ return $this;
1317
+ }
1318
+
1319
+ /**
1320
+ * Retrieve massaction row identifier filter
1321
+ *
1322
+ * @return string
1323
+ */
1324
+ public function getMassactionIdFilter()
1325
+ {
1326
+ return $this->_massactionIdFilter;
1327
+ }
1328
+
1329
+ /**
1330
+ * Set massaction row identifier filter
1331
+ *
1332
+ * @param string $idFilter
1333
+ * @return Mage_Adminhtml_Block_Widget_Grid
1334
+ */
1335
+ public function setMassactionIdFilter($idFilter)
1336
+ {
1337
+ $this->_massactionIdFilter = $idFilter;
1338
+ return $this;
1339
+ }
1340
+
1341
+ /**
1342
+ * Retrive massaction block name
1343
+ *
1344
+ * @return string
1345
+ */
1346
+ public function getMassactionBlockName()
1347
+ {
1348
+ return $this->_massactionBlockName;
1349
+ }
1350
+
1351
+ /**
1352
+ * Set massaction block name
1353
+ *
1354
+ * @param string $blockName
1355
+ * @return Mage_Adminhtml_Block_Widget_Grid
1356
+ */
1357
+ public function setMassactionBlockName($blockName)
1358
+ {
1359
+ $this->_massactionBlockName = $blockName;
1360
+ return $this;
1361
+ }
1362
+
1363
+ /**
1364
+ * Retrive massaction block
1365
+ *
1366
+ * @return Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract
1367
+ */
1368
+ public function getMassactionBlock()
1369
+ {
1370
+ return $this->getChild('massaction');
1371
+ }
1372
+
1373
+ public function getMassactionBlockHtml()
1374
+ {
1375
+ return $this->getChildHtml('massaction');
1376
+ }
1377
+
1378
+ /**
1379
+ * Set empty text for grid
1380
+ *
1381
+ * @param string $text
1382
+ * @return Mage_Adminhtml_Block_Widget_Grid
1383
+ */
1384
+ public function setEmptyText($text)
1385
+ {
1386
+ $this->_emptyText = $text;
1387
+ return $this;
1388
+ }
1389
+
1390
+ /**
1391
+ * Return empty text for grid
1392
+ *
1393
+ * @return string
1394
+ */
1395
+ public function getEmptyText()
1396
+ {
1397
+ return $this->_emptyText;
1398
+ }
1399
+
1400
+ /**
1401
+ * Set empty text CSS class
1402
+ *
1403
+ * @param string $cssClass
1404
+ * @return Mage_Adminhtml_Block_Widget_Grid
1405
+ */
1406
+ public function setEmptyTextClass($cssClass)
1407
+ {
1408
+ $this->_emptyTextCss = $cssClass;
1409
+ return $this;
1410
+ }
1411
+
1412
+ /**
1413
+ * Return empty text CSS class
1414
+ *
1415
+ * @return string
1416
+ */
1417
+ public function getEmptyTextClass()
1418
+ {
1419
+ return $this->_emptyTextCss;
1420
+ }
1421
+
1422
+ /**
1423
+ * Set count totals
1424
+ *
1425
+ * @param boolean $visible
1426
+ */
1427
+ public function setCountTotals($count=true)
1428
+ {
1429
+ $this->_countTotals = $count;
1430
+ }
1431
+
1432
+ /**
1433
+ * Return count totals
1434
+ *
1435
+ * @return boolean
1436
+ */
1437
+ public function getCountTotals()
1438
+ {
1439
+ return $this->_countTotals;
1440
+ }
1441
+
1442
+ /**
1443
+ * Set totals
1444
+ *
1445
+ * @param boolean $visible
1446
+ */
1447
+ public function setTotals(Varien_Object $totals)
1448
+ {
1449
+ $this->_varTotals = $totals;
1450
+ }
1451
+
1452
+ /**
1453
+ * Retrieve totals
1454
+ *
1455
+ * @return Varien_Object
1456
+ */
1457
+ public function getTotals()
1458
+ {
1459
+ return $this->_varTotals;
1460
+ }
1461
+
1462
+ /**
1463
+ * Set subtotals
1464
+ *
1465
+ * @param boolean $flag
1466
+ * @return Mage_Adminhtml_Block_Widget_Grid
1467
+ */
1468
+ public function setCountSubTotals($flag = true)
1469
+ {
1470
+ $this->_countSubTotals = $flag;
1471
+ return $this;
1472
+ }
1473
+
1474
+ /**
1475
+ * Return count subtotals
1476
+ *
1477
+ * @return boolean
1478
+ */
1479
+ public function getCountSubTotals()
1480
+ {
1481
+ return $this->_countSubTotals;
1482
+ }
1483
+
1484
+ /**
1485
+ * Set subtotal items
1486
+ *
1487
+ * @param array $items
1488
+ * @return Mage_Adminhtml_Block_Widget_Grid
1489
+ */
1490
+ public function setSubTotals(array $items)
1491
+ {
1492
+ $this->_subtotals = $items;
1493
+ return $this;
1494
+ }
1495
+
1496
+ /**
1497
+ * Retrieve subtotal item
1498
+ *
1499
+ * @param Varien_Object $item
1500
+ * @return Varien_Object
1501
+ */
1502
+ public function getSubTotalItem($item)
1503
+ {
1504
+ foreach ($this->_subtotals as $subtotalItem) {
1505
+ foreach ($this->_groupedColumn as $groupedColumn) {
1506
+ if ($subtotalItem->getData($groupedColumn) == $item->getData($groupedColumn)) {
1507
+ return $subtotalItem;
1508
+ }
1509
+ }
1510
+ }
1511
+ return '';
1512
+ }
1513
+
1514
+ /**
1515
+ * Retrieve subtotal items
1516
+ *
1517
+ * @return array
1518
+ */
1519
+ public function getSubTotals()
1520
+ {
1521
+ return $this->_subtotals;
1522
+ }
1523
+
1524
+ /**
1525
+ * Check whether subtotal should be rendered
1526
+ *
1527
+ * @param Varien_Object $item
1528
+ * @return boolean
1529
+ */
1530
+ public function shouldRenderSubTotal($item) {
1531
+ return ($this->_countSubTotals && count($this->_subtotals) > 0 && count($this->getMultipleRows($item)) > 0);
1532
+ }
1533
+
1534
+ /**
1535
+ * Retrieve columns to render
1536
+ *
1537
+ * @return unknown
1538
+ */
1539
+ public function getSubTotalColumns() {
1540
+ return $this->getColumns();
1541
+ }
1542
+
1543
+ /**
1544
+ * Retrieve rowspan number
1545
+ *
1546
+ * @param Varien_Object $item
1547
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
1548
+ * @return integer|boolean
1549
+ */
1550
+ public function getRowspan($item, $column)
1551
+ {
1552
+ if ($this->isColumnGrouped($column)) {
1553
+ return count($this->getMultipleRows($item)) + count($this->_groupedColumn);
1554
+ }
1555
+ return false;
1556
+ }
1557
+
1558
+ /**
1559
+ * Enter description here...
1560
+ *
1561
+ * @param string|object $column
1562
+ * @param string $value
1563
+ * @return boolean|Mage_Adminhtml_Block_Widget_Grid
1564
+ */
1565
+ public function isColumnGrouped($column, $value = null)
1566
+ {
1567
+ if (null === $value) {
1568
+ if (is_object($column)) {
1569
+ return in_array($column->getIndex(), $this->_groupedColumn);
1570
+ }
1571
+ return in_array($column, $this->_groupedColumn);
1572
+ }
1573
+ $this->_groupedColumn[] = $column;
1574
+ return $this;
1575
+ }
1576
+
1577
+ /**
1578
+ * Get children of specified item
1579
+ *
1580
+ * @param Varien_Object $item
1581
+ * @return array
1582
+ */
1583
+ public function getMultipleRows($item)
1584
+ {
1585
+ return $item->getChildren();
1586
+ }
1587
+
1588
+ /**
1589
+ * Retrieve columns for multiple rows
1590
+ *
1591
+ * @param Varien_Object $item
1592
+ * @return array
1593
+ */
1594
+ public function getMultipleRowColumns()
1595
+ {
1596
+ $columns = $this->getColumns();
1597
+ foreach ($this->_groupedColumn as $column) {
1598
+ unset($columns[$column]);
1599
+ }
1600
+ return $columns;
1601
+ }
1602
+
1603
+ /**
1604
+ * Check whether should render cell
1605
+ *
1606
+ * @param Varien_Object $item
1607
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
1608
+ * @return boolean
1609
+ */
1610
+ public function shouldRenderCell($item, $column)
1611
+ {
1612
+ if ($this->isColumnGrouped($column) && $item->getIsEmpty()) {
1613
+ return true;
1614
+ }
1615
+ if (!$item->getIsEmpty()) {
1616
+ return true;
1617
+ }
1618
+ return false;
1619
+ }
1620
+
1621
+ /**
1622
+ * Check whether should render empty cell
1623
+ *
1624
+ * @param Varien_Object $item
1625
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
1626
+ * @return boolean
1627
+ */
1628
+ public function shouldRenderEmptyCell($item, $column)
1629
+ {
1630
+ return ($item->getIsEmpty() && in_array($column['index'], $this->_groupedColumn));
1631
+ }
1632
+
1633
+ /**
1634
+ * Retrieve colspan for empty cell
1635
+ *
1636
+ * @param Varien_Object $item
1637
+ * @return integer
1638
+ */
1639
+ public function getEmptyCellColspan()
1640
+ {
1641
+ return $this->getColumnCount() - count($this->_groupedColumn);
1642
+ }
1643
+
1644
+ /**
1645
+ * Retrieve label for empty cell
1646
+ *
1647
+ * @return string
1648
+ */
1649
+ public function getEmptyCellLabel()
1650
+ {
1651
+ return $this->_emptyCellLabel;
1652
+ }
1653
+
1654
+ /**
1655
+ * Set label for empty cell
1656
+ *
1657
+ * @param string $label
1658
+ * @return Mage_Adminhtml_Block_Widget_Grid
1659
+ */
1660
+ public function setEmptyCellLabel($label)
1661
+ {
1662
+ $this->_emptyCellLabel = $label;
1663
+ return $this;
1664
+ }
1665
+
1666
+ /**
1667
+ * Return row url for js event handlers
1668
+ *
1669
+ * @param Mage_Catalog_Model_Product|Varien_Object
1670
+ * @return string
1671
+ */
1672
+ public function getRowUrl($item)
1673
+ {
1674
+ $res = parent::getRowUrl($item);
1675
+ return ($res ? $res : '#');
1676
+ }
1677
+
1678
+ }
app/code/community/Mediotype/AgileGrid/Block/Adminhtml/Widget/Grid/Column/Filter/Date.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/9/14
6
+ * Time: 10:24 AM
7
+ */
8
+ class Mediotype_AgileGrid_Block_Adminhtml_Widget_Grid_Column_Filter_Date extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date
9
+ {
10
+ /**
11
+ * @desc Process DateInterval Strings http://www.php.net/manual/en/dateinterval.construct.php
12
+ * @param $value
13
+ * @return $this
14
+ */
15
+ public function setValue($value)
16
+ {
17
+ if (isset($value['locale'])) {
18
+ if (!empty($value['from'])) {
19
+ $value['from'] = Mage::helper('mediotype_agilegrid')->parseDateIntervalString($value['from']);
20
+ }
21
+
22
+ if (!empty($value['to'])) {
23
+ $value['to'] = Mage::helper('mediotype_agilegrid')->parseDateIntervalString($value['to']);
24
+ }
25
+ }
26
+
27
+ return parent::setValue($value);
28
+ }
29
+ }
app/code/community/Mediotype/AgileGrid/Block/Adminhtml/Widget/Grid/Column/Filter/Datetime.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/10/14
6
+ * Time: 10:42 AM
7
+ */
8
+ class Mediotype_AgileGrid_Block_Adminhtml_Widget_Grid_Column_Filter_Datetime extends Mediotype_AgileGrid_Block_Adminhtml_Widget_Grid_Column_Filter_Date
9
+ {
10
+
11
+ }
app/code/community/Mediotype/AgileGrid/Helper/Data.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/9/14
6
+ * Time: 12:12 PM
7
+ */
8
+ class Mediotype_AgileGrid_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+
11
+ public function parseDateIntervalString($value, $dateFormat = 'm/d/Y')
12
+ {
13
+
14
+ if (substr($value, 0, 1) == 'P' || substr($value, 0, 2) == '-P') {
15
+ $action = 'add';
16
+ if (substr($value, 0, 1) == '-') {
17
+ $value = ltrim($value, '-');
18
+ $action = 'sub';
19
+ }
20
+
21
+ $timeStamp = Mage::getModel('core/date')->timestamp(time());
22
+ $today = new DateTime(date("Y-m-d 00:00:00", $timeStamp));
23
+
24
+ $today->$action(new DateInterval($value));
25
+ $value = $today->format($dateFormat);
26
+ }
27
+ return $value;
28
+ }
29
+ }
app/code/community/Mediotype/AgileGrid/Model/Filter.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/15/14
6
+ * Time: 5:58 PM
7
+ */
8
+ class Mediotype_AgileGrid_Model_Filter extends Mage_Core_Model_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ $this->_init('mediotype_agilegrid/filter', 'id');
13
+ }
14
+ }
app/code/community/Mediotype/AgileGrid/Model/Resource/Filter.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/15/14
6
+ * Time: 7:24 PM
7
+ */
8
+
9
+ class Mediotype_AgileGrid_Model_Resource_Filter extends Mediotype_Core_Model_Resource_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ $this->_init('mediotype_agilegrid/filter', 'id');
14
+ }
15
+ }
app/code/community/Mediotype/AgileGrid/Model/Resource/Filter/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/15/14
6
+ * Time: 7:26 PM
7
+ */
8
+
9
+ class Mediotype_AgileGrid_Model_Resource_Filter_Collection extends Mediotype_Core_Model_Resource_Db_Collection_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('mediotype_agilegrid/filter');
14
+ }
15
+ }
app/code/community/Mediotype/AgileGrid/controllers/Adminhtml/FiltersController.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/7/14
6
+ * Time: 3:35 PM
7
+ */
8
+ class Mediotype_AgileGrid_Adminhtml_FiltersController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ public function saveAction()
11
+ {
12
+ $targetFilterName = trim($this->getRequest()->getParam('name'));
13
+ try {
14
+ $update = false;
15
+
16
+ $filterModel = Mage::getModel('mediotype_agilegrid/filter');
17
+ $filterModel->load(
18
+ array(
19
+ "name" => $targetFilterName,
20
+ 'grid_id' => trim($this->getRequest()->getParam('grid_id'))
21
+ )
22
+ );
23
+ if ($filterModel->getId()) {
24
+ $update = true;
25
+ }
26
+
27
+ $filterModel->setData('name', $targetFilterName);
28
+ $filterModel->setData('grid_id', trim($this->getRequest()->getParam('grid_id')));
29
+ $filterModel->setData('filter', $this->getRequest()->getParam('filter'));
30
+
31
+ $filterModel->save();
32
+
33
+ if ($update) {
34
+ $this->_getSession()->addSuccess("Filter '$targetFilterName' UPDATED.");
35
+ return;
36
+ }
37
+
38
+ $this->_getSession()->addSuccess("Filter '$targetFilterName' CREATED.");
39
+ return;
40
+
41
+ } catch (Exception $e) {
42
+ $this->_getSession()->addError("ERROR saving filter '$targetFilterName'.");
43
+ Mage::logException($e);
44
+ }
45
+
46
+ return;
47
+ }
48
+
49
+ public function deleteAction()
50
+ {
51
+ $targetFilterName = $this->getRequest()->getParam('name');
52
+ try {
53
+ /** @var Mediotype_AgileGrid_Model_Filter $filterModel */
54
+ $filterModel = Mage::getModel('mediotype_agilegrid/filter');
55
+ $filterModel->load(
56
+ array(
57
+ "name" => $targetFilterName,
58
+ 'grid_id' => $this->getRequest()->getParam('grid_id')
59
+ )
60
+ );
61
+ if ($filterModel->getId()) {
62
+ $filterModel->delete();
63
+ $this->_getSession()->addSuccess("Filter '$targetFilterName' DELETED");
64
+ } else {
65
+ $this->_getSession()->addError("ERROR deleting filter - Could not find record $targetFilterName.");
66
+ }
67
+ } catch (Exception $e) {
68
+ $this->_getSession()->addError("ERROR deleting filter '$targetFilterName'.");
69
+ Mage::logException($e);
70
+ }
71
+ }
72
+
73
+ protected function _isAllowed()
74
+ {
75
+ return Mage::helper('mediotype_core/acl')->isAllowed($this);
76
+ }
77
+ }
app/code/community/Mediotype/AgileGrid/etc/adminhtml.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <mediotype_agilegrid>
8
+ <title>Agile Grid</title>
9
+ <sort_order>9</sort_order>
10
+ <children>
11
+ <adminhtml_filters>
12
+ <title>Filters</title>
13
+ <children>
14
+ <usefilters>
15
+ <title>Use Filters</title>
16
+ <sort_order>0</sort_order>
17
+ </usefilters>
18
+ <save>
19
+ <title>Save Filters</title>
20
+ <sort_order>1</sort_order>
21
+ </save>
22
+ <delete>
23
+ <title>Delete Filters</title>
24
+ <sort_order>2</sort_order>
25
+ </delete>
26
+ </children>
27
+ </adminhtml_filters>
28
+ </children>
29
+ </mediotype_agilegrid>
30
+ </children>
31
+ </admin>
32
+ </resources>
33
+ </acl>
34
+ </config>
app/code/community/Mediotype/AgileGrid/etc/config.xml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mediotype_AgileGrid>
5
+ <version>0.1.0</version>
6
+ </Mediotype_AgileGrid>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <mediotype_agilegrid>
11
+ <class>Mediotype_AgileGrid_Model</class>
12
+ <resourceModel>Mediotype_AgileGrid_resource</resourceModel>
13
+ </mediotype_agilegrid>
14
+ <Mediotype_AgileGrid_resource>
15
+ <class>Mediotype_AgileGrid_Model_Resource</class>
16
+ <entities>
17
+ <filter>
18
+ <table>mediotype_filter</table>
19
+ </filter>
20
+ </entities>
21
+ </Mediotype_AgileGrid_resource>
22
+ </models>
23
+ <blocks>
24
+ <mediotype_agilegrid>
25
+ <class>Mediotype_AgileGrid_Block</class>
26
+ </mediotype_agilegrid>
27
+ <adminhtml>
28
+ <rewrite>
29
+ <widget_grid_column_filter_date>Mediotype_AgileGrid_Block_Adminhtml_Widget_Grid_Column_Filter_Date</widget_grid_column_filter_date>
30
+ <widget_grid_column_filter_datetime>Mediotype_AgileGrid_Block_Adminhtml_Widget_Grid_Column_Filter_Datetime</widget_grid_column_filter_datetime>
31
+ </rewrite>
32
+ </adminhtml>
33
+ </blocks>
34
+ <helpers>
35
+ <mediotype_agilegrid>
36
+ <class>Mediotype_AgileGrid_Helper</class>
37
+ </mediotype_agilegrid>
38
+ </helpers>
39
+ <resources>
40
+ <Mediotype_AgileGrid_setup>
41
+ <setup>
42
+ <module>Mediotype_AgileGrid</module>
43
+ </setup>
44
+ </Mediotype_AgileGrid_setup>
45
+ </resources>
46
+ </global>
47
+ <adminhtml>
48
+ <layout>
49
+ <updates>
50
+ <mediotype_agilegrid>
51
+ <file>mediotype/AgileGrid.xml</file>
52
+ </mediotype_agilegrid>
53
+ </updates>
54
+ </layout>
55
+ </adminhtml>
56
+ <admin>
57
+ <routers>
58
+ <Mediotype_AgileGrid>
59
+ <use>admin</use>
60
+ <args>
61
+ <module>Mediotype_AgileGrid</module>
62
+ <frontName>Mediotype_AgileGrid</frontName>
63
+ </args>
64
+ </Mediotype_AgileGrid>
65
+ </routers>
66
+ </admin>
67
+ </config>
app/code/community/Mediotype/AgileGrid/sql/Mediotype_AgileGrid_setup/install-0.1.0.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: szurek
5
+ * Date: 7/9/14
6
+ * Time: 12:12 PM
7
+ */
8
+ /* @var $installer Mage_Core_Model_Resource_Setup */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ $agileGridTable = $installer->getConnection()->newTable($this->getTable('mediotype_agilegrid/filter'));
14
+
15
+ $agileGridTable->addColumn('id',
16
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
17
+ null,
18
+ array(
19
+ 'primary' => true,
20
+ 'identity' => true,
21
+ 'nullable' => false,
22
+ 'unsigned' => true,
23
+ )
24
+ );
25
+
26
+ $agileGridTable->addColumn('name',
27
+ Varien_Db_Ddl_Table::TYPE_VARCHAR,
28
+ 255,
29
+ array(
30
+ 'nullable' => false,
31
+ )
32
+ );
33
+
34
+ $agileGridTable->addColumn('grid_id',
35
+ Varien_Db_Ddl_Table::TYPE_VARCHAR,
36
+ 511,
37
+ array(
38
+ 'nullable' => false,
39
+ )
40
+ );
41
+
42
+ $agileGridTable->addColumn('filter',
43
+ Varien_Db_Ddl_Table::TYPE_TEXT,
44
+ null,
45
+ array(
46
+ 'nullable' => false,
47
+ )
48
+ );
49
+
50
+ $agileGridTable->addIndex(
51
+ $this->getIdxName('mediotype_agilegrid/filter', array('id')),
52
+ array('id')
53
+ );
54
+
55
+ $installer->getConnection()->createTable($agileGridTable);
56
+
57
+ $installer->endSetup();
app/code/community/Mediotype/Core/Block/Entity/Attribute/Input/Renderer/Datetime.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Block_Entity_Attribute_Input_Renderer_Datetime
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Block_Entity_Attribute_Input_Renderer_Datetime extends Varien_Data_Form_Element_Date
16
+ {
17
+ /**
18
+ * @param array $attributes
19
+ */
20
+ public function __construct($attributes = array())
21
+ {
22
+ parent::__construct($attributes);
23
+ $this->setImage($this->getSkinUrl('images/grid-cal.gif'));
24
+ $this->setFormat(Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
25
+ $this->setTime(true);
26
+ }
27
+
28
+ /**
29
+ * Retrieve url of skins file
30
+ *
31
+ * @param string $file path to file in skin
32
+ * @param array $params
33
+ * @return string
34
+ */
35
+ public function getSkinUrl($file = null, array $params = array())
36
+ {
37
+ return Mage::getDesign()->getSkinUrl($file, $params);
38
+ }
39
+
40
+ }
app/code/community/Mediotype/Core/Block/Instructions.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ * @desc Drives Instructions Blocks Content For Modules
6
+ * Allows override of instructions from module shipped html to
7
+ * updated Mediotype html
8
+ * @usage extend this class, add a configuration node to reference the mothership URI
9
+ * Assign endpoint in the _construct(). Use Layout.xml to declare blocktype of
10
+ * your instruction block and embed in an adminhtml view.
11
+ * TO EXECUTE OFFLINE HTML
12
+ * add a function named
13
+ * @category Mediotype
14
+ * @package Mediotype_Core
15
+ * @class Mediotype_Core_Block_Instructions
16
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
17
+ * Copyright, 2013, Mediotype, LLC - US license
18
+ * @license http://mediotype.com/LICENSE.txt
19
+ * @author Mediotype (SZ, JH) <diveinto@mediotype.com>
20
+ */
21
+ abstract class Mediotype_Core_Block_Instructions extends Mage_Core_Block_Template {
22
+
23
+ protected $_endPoint; //Required by module instruction to talk home
24
+ protected $_jsonRequest; //Required to send communication (can be an empty key:val)
25
+
26
+ protected $_requestMethod;
27
+ protected $_remoteHtml;
28
+
29
+ abstract protected function _offlineHtml(); // required to feed offline instructions
30
+
31
+ public function _construct(){
32
+ $this->_requestMethod = Mage::getModel('mediotype_core/systems_magento');
33
+ parent::_construct();
34
+ }
35
+
36
+ protected function _afterToHtml($html){
37
+
38
+ if( $remoteHtml = $this->_hasRemoteInstructions() ){
39
+ $html .= $remoteHtml;
40
+ } else {
41
+ $html .= $this->_offlineHtml();
42
+ }
43
+
44
+ return $html;
45
+ }
46
+
47
+ protected function _hasRemoteInstructions(){
48
+
49
+ $remoteMessage =
50
+ $this->_requestMethod
51
+ ->setEndPoint($this->_endPoint)
52
+ ->setJsonRequest($this->_jsonRequest)
53
+ ->doRequest();
54
+
55
+ $responseObj = json_decode($remoteMessage);
56
+
57
+ $html = "";
58
+
59
+ if( $responseObj->disposition !== NULL
60
+ && $responseObj->disposition == Mediotype_Core_Model_Systems_Magento::RESPONSE_DISPOSITION_OK){
61
+
62
+ }
63
+
64
+ if( strlen( $responseObj->alertHtml ) > 0){
65
+ $html .= $responseObj->alertHtml;
66
+ }
67
+
68
+ if( strlen($responseObj->html) > 0 ){
69
+
70
+ $html .= "<div class='mediotype-notification'>";
71
+ $html .= "<span class='mediotype-notification-span'>";
72
+ $html .= $remoteMessage;
73
+ $html .= "</span></div>";
74
+ return $html;
75
+ }
76
+
77
+ return false;
78
+ }
79
+
80
+ }
app/code/community/Mediotype/Core/Controller/Front/Action.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Joel Hart
5
+ */
6
+ class Mediotype_Core_Controller_Front_Action extends Mage_Core_Controller_Front_Action{
7
+
8
+ /**
9
+ * Calls normal __construct THEN if Mediotype debugger is enabled provides additional developer output
10
+ *
11
+ * @param Zend_Controller_Request_Abstract $request
12
+ * @param Zend_Controller_Response_Abstract $response
13
+ * @param array $invokeArgs
14
+ */
15
+ public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()){
16
+ parent::__construct( $request, $response, $invokeArgs = array());
17
+
18
+ if(Mediotype_Core_Helper_Debugger::getEnabled()){
19
+ Mediotype_Core_Helper_Debugger::log(
20
+ array(
21
+ "ACTION NAME" => $this->getRequest()->getActionName(),
22
+ "FULL ACTION NAME" => $this->getFullActionName(),
23
+ "ACTION METHOD EXISTS" => method_exists($this, $this->getActionMethodName($this->getRequest()->getActionName())),
24
+ "REQUEST PARAMETERS" => $this->getRequest()->getParams(),
25
+ )
26
+ );
27
+ }
28
+
29
+ }
30
+
31
+ }
app/code/community/Mediotype/Core/Exception.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Exception
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Exception extends Mage_Core_Exception
16
+ {
17
+
18
+ /**
19
+ * @param string $message
20
+ * @param int $code
21
+ * @param Exception $previous
22
+ */
23
+ public function __construct($message = "", $code = 0, Exception $previous = null)
24
+ {
25
+ parent::__construct($message, $code, $previous);
26
+ /** @var $debugger Mediotype_Core_Helper_Debugger */
27
+ $debugger = Mage::helper('mediotype_core/debugger');
28
+
29
+ $datetime = new DateTime("now", new DateTimeZone('America/Denver'));
30
+ $stamp = "[T:" . $datetime->format('Y-m-d h:i:s A') . "]";
31
+ try {
32
+ $debug_backtrace = debug_backtrace();
33
+ $first = array_shift($debug_backtrace);
34
+ if (array_key_exists('file', $first)) {
35
+ $stamp .= "[F:{$first['file']}]";
36
+ }
37
+
38
+ if (array_key_exists('line', $first)) {
39
+ $stamp .= "[L:{$first['line']}]";
40
+ }
41
+
42
+ } catch (Exception $e) {
43
+
44
+ }
45
+
46
+ $debugger->Write($stamp . " Mediotype_Core_Exception Thrown. ('" . $this->getMessage() . "')");
47
+ }
48
+ }
app/code/community/Mediotype/Core/Helper/Abstract.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Joel Hart
5
+ */
6
+
7
+ class Mediotype_Core_Helper_Abstract extends Mage_Core_Helper_Abstract
8
+ {
9
+
10
+ /**
11
+ * @param $xmlNode xml path to config group
12
+ *
13
+ * @return array system config values ($key => $value)
14
+ */
15
+ public function getExtensionSystemConfig($xmlNode)
16
+ {
17
+ if (Mage::helper('mediotype_core/debugger')->getEnabled()) {
18
+ Mediotype_Core_Helper_Debugger::log(array("xmlnode" => $xmlNode));
19
+ }
20
+ return Mage::getStoreConfig($xmlNode);
21
+ }
22
+ }
app/code/community/Mediotype/Core/Helper/Acl.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mediotype_Core_Helper_Acl extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ public function isAllowed($controller, $action = null, $moduleName = null)
6
+ {
7
+ $aclPath = $this->getAclPath($controller, $action, $moduleName);
8
+ Mage::log($aclPath, null, "acl.log");
9
+ return Mage::getSingleton('admin/session')
10
+ ->isAllowed($aclPath);
11
+ }
12
+
13
+ protected function getAclPath($controller, $action = null, $moduleName = null)
14
+ {
15
+ /** @var $helper Mediotype_Core_Helper_Data */
16
+ $helper = Mage::helper("mediotype_core");
17
+
18
+ $controllerName = $controller;
19
+ if (is_null($moduleName)) {
20
+ $controllerName = strtolower($controller->getRequest()->getControllerName());
21
+ $moduleName = strtolower($controller->getRequest()->getModuleName());
22
+ }
23
+
24
+ if (is_null($action)) {
25
+ $action = $helper->explodeCamelCase($controller->getRequest()->getActionName());
26
+ $action = strtolower(implode("/", $action));
27
+ } elseif (is_array($action)) {
28
+ $action = implode("/", $action);
29
+ }
30
+
31
+ $aclPath = "$moduleName/$controllerName/$action";
32
+
33
+ return $aclPath;
34
+ }
35
+ }
app/code/community/Mediotype/Core/Helper/Data.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Data
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Data extends Mage_Core_Helper_Abstract
16
+ {
17
+
18
+ /**
19
+ * This method works like addFieldToFilter with a having call instead of a where call
20
+
21
+ * Example of attaching to a column inside a grid, using filter condition callback (in the addColumn function:
22
+ $this->addColumn(
23
+ 'lateBy',
24
+ array(
25
+ 'header' => $this->__('Late By'),
26
+ 'index' => 'late_by',
27
+ 'type' => 'number',
28
+ 'filter_condition_callback' => "Mediotype_Core_Helper_Data::filterHaving"
29
+ )
30
+ );
31
+ *
32
+ *
33
+ *
34
+ * @param $collection
35
+ * @param $column
36
+ */
37
+ public static function filterHaving($collection, $column)
38
+ {
39
+ /** @var $collection Checkerboard_Workorder_Model_Resource_Workorder_Collection */
40
+ $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
41
+ $cond = $column->getFilter()->getCondition();
42
+ if ($field && isset($cond)) {
43
+ $collection->addFieldToFilterHaving($field, $cond);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * @param $collection
49
+ * @param $mainTableForeignKey
50
+ * @param $eavType
51
+ * @param int $startIndex
52
+ * @return mixed
53
+ */
54
+ public function joinEavTablesIntoCollection($collection, $mainTableForeignKey, $eavType, $startIndex = 1)
55
+ {
56
+
57
+ $entityType = Mage::getModel('eav/entity_type')->loadByCode($eavType);
58
+ $attributes = $entityType->getAttributeCollection();
59
+ $entityTable = $collection->getTable($entityType->getEntityTable());
60
+
61
+ //Use an incremented index to make sure all of the aliases for the eav attribute tables are unique.
62
+ $index = $startIndex;
63
+ foreach ($attributes->getItems() as $attribute) {
64
+ $alias = 'table' . $index;
65
+ if ($attribute->getBackendType() != 'static') {
66
+ $table = $entityTable . '_' . $attribute->getBackendType();
67
+ $field = $alias . '.value';
68
+ $collection->getSelect()
69
+ ->joinLeft(array($alias => $table),
70
+ 'main_table.' . $mainTableForeignKey . ' = ' . $alias . '.entity_id and ' . $alias . '.attribute_id = ' . $attribute->getAttributeId(),
71
+ array($attribute->getAttributeCode() => $field)
72
+ );
73
+ }
74
+ $index++;
75
+ }
76
+ //Join in all of the static attributes by joining the base entity table.
77
+ $collection->getSelect()->joinLeft($entityTable, 'main_table.' . $mainTableForeignKey . ' = ' . $entityTable . '.entity_id');
78
+
79
+ return $collection;
80
+
81
+ }
82
+
83
+ /**
84
+ * @param string $string
85
+ * @return array|null
86
+ */
87
+ public function explodeCamelCase($string)
88
+ {
89
+ $results = array();
90
+ if (!is_string($string) || strlen($string) == 0) {
91
+ return null;
92
+ }
93
+ $anchor_position = 0;
94
+ for ($cur_position = 0; $cur_position < strlen($string); $cur_position++) {
95
+ if (ctype_upper(substr($string, $cur_position, 1))) {
96
+ $subject = strtolower(substr($string, $anchor_position, $cur_position - $anchor_position));
97
+ $results[] = $subject;
98
+ $anchor_position = $cur_position;
99
+ }
100
+ }
101
+
102
+ if ($anchor_position == 0) {
103
+ $results[] = $string;
104
+ } else {
105
+ $results[] = strtolower(substr($string, $anchor_position, strlen($string) - $anchor_position));
106
+ }
107
+
108
+ return $results;
109
+ }
110
+ }
app/code/community/Mediotype/Core/Helper/Debugger.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Debugger
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Debugger extends Mage_Core_Helper_Abstract
16
+ {
17
+ /**
18
+ * @var
19
+ */
20
+ static protected $_logFilePath;
21
+ /**
22
+ * @var
23
+ */
24
+ static protected $_IOHandler;
25
+
26
+ /**
27
+ * @param $depth
28
+ * @param $string
29
+ */
30
+ public function logRecursion($depth, $string)
31
+ {
32
+ if ($this->getEnabled()) {
33
+ $marker = "";
34
+ for ($i = 0; $i < ($depth * 2); $i++) {
35
+ $marker = $marker . "*";
36
+ }
37
+ $this->Write("$depth ]$marker " . $string . "<br/>\r");
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @param string $data
43
+ */
44
+ static public function log($data = '')
45
+ {
46
+ $output = array();
47
+ if ($data instanceof Varien_Object) {
48
+ $output['class'] = get_class($data);
49
+ $output['data'] = array();
50
+ foreach ($data->getData() as $index => $value) {
51
+ $output['data'][$index]['type'] = gettype($value);
52
+ is_object($value) ? $output['data'][$index]['class'] = get_class($value) : NULL;
53
+ $output['data'][$index]['size'] = sizeof($value);
54
+ !is_object($value) && !is_array($value) ? $output['data'][$index]['value'] = $value : NULL;
55
+ }
56
+ } elseif (is_object($data)) {
57
+ $output['class'] = get_class($data);
58
+ $output['data'] = array();
59
+ foreach ($data as $index => $value) {
60
+ $output['data'][$index]['type'] = gettype($value);
61
+ is_object($value) ? $output['data'][$index]['class'] = get_class($value) : NULL;
62
+ $output['data'][$index]['size'] = sizeof($value);
63
+ !is_object($value) && !is_array($value) ? $output['data'][$index]['value'] = $value : NULL;
64
+ }
65
+ } elseif (is_array($data)) {
66
+ $output['class'] = "Array";
67
+ $output['data'] = array();
68
+ foreach ($data as $index => $value) {
69
+ $output['data'][$index]['type'] = gettype($value);
70
+ is_object($value) ? $output['data'][$index]['class'] = get_class($value) : NULL;
71
+ $output['data'][$index]['size'] = sizeof($value);
72
+ !is_object($value) && !is_array($value) ? $output['data'][$index]['value'] = $value : NULL;
73
+ }
74
+ } else {
75
+ $output = print_r($data, true);
76
+ }
77
+
78
+ $datetime = new DateTime("now", new DateTimeZone('America/Denver'));
79
+ $stamp = "[T:" . $datetime->format('Y-m-d h:i:s A') . "]";
80
+ try {
81
+ $debug_backtrace = debug_backtrace();
82
+ $first = array_shift($debug_backtrace);
83
+ if (array_key_exists('file', $first)) {
84
+ $stamp .= "[F:{$first['file']}]";
85
+ }
86
+
87
+ if (array_key_exists('line', $first)) {
88
+ $stamp .= "[L:{$first['line']}]";
89
+ }
90
+
91
+ } catch (Exception $e) {
92
+
93
+ }
94
+
95
+ self::Write($stamp . print_r($output, true));
96
+ }
97
+
98
+ /**
99
+ * @param $string
100
+ */
101
+ static public function Write($string)
102
+ {
103
+ if (self::getEnabled()) {
104
+ self::_openStream();
105
+ fseek(self::$_IOHandler, 0, SEEK_END);
106
+ fwrite(self::$_IOHandler, "\n" . $string);
107
+ self::_closeStream();
108
+ }
109
+ }
110
+
111
+ /**
112
+ *
113
+ */
114
+ static protected function _openStream()
115
+ {
116
+ if (self::$_logFilePath == '') {
117
+ self::$_logFilePath = Mage::getBaseDir('var') . DS . 'log' . DS . 'Mediotype.log';
118
+ }
119
+ // self::$_IOHandler = file_exists(self::$_logFilePath) ? fopen(self::$_logFilePath, 'a') : fopen(self::$_logFilePath, 'w+');
120
+ self::$_IOHandler = fopen(self::$_logFilePath, 'a');
121
+ }
122
+
123
+ /**
124
+ *
125
+ */
126
+ static protected function _closeStream()
127
+ {
128
+ if (self::$_IOHandler) {
129
+ fclose(self::$_IOHandler);
130
+ }
131
+ }
132
+
133
+ /**
134
+ * @return bool
135
+ */
136
+ static public function getEnabled()
137
+ {
138
+ return (bool)Mage::getStoreConfig('mediotype_general/debug_settings/logging_enabled');
139
+ }
140
+
141
+
142
+ }
app/code/community/Mediotype/Core/Helper/Forms.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Forms
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Forms extends Mage_Core_Helper_Abstract
16
+ {
17
+
18
+ }
app/code/community/Mediotype/Core/Helper/Mschema.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema
16
+ {
17
+ /**
18
+ *
19
+ */
20
+ const EC_REQUIRED_NODE = 1001;
21
+ /**
22
+ *
23
+ */
24
+ const EC_STRUCTURE_MALFORMED = 1003;
25
+
26
+
27
+ /**
28
+ * @var
29
+ */
30
+ protected $_validationObject;
31
+ /**
32
+ * @var null
33
+ */
34
+ protected $_currentValidationNode;
35
+ /**
36
+ * @var
37
+ */
38
+ protected $_lastNode;
39
+
40
+ /**
41
+ * @var array
42
+ */
43
+ protected $_validators;
44
+
45
+ /**
46
+ * @var Mage_Core_Helper_Abstract
47
+ */
48
+ private $debug;
49
+
50
+ /**
51
+ *
52
+ */
53
+ public function __construct()
54
+ {
55
+ // ************* DEBUG SETTINGS *************
56
+ $this->debug = Mage::helper('mediotype_core/debugger');
57
+ $this->debug->setEnabled(false);
58
+
59
+ // ************* LOAD CORE VALIDATORS *************
60
+ $this->_validators = array(
61
+ "mediotype_core/mschema_validator_strip",
62
+ "mediotype_core/mschema_validator_trim",
63
+ "mediotype_core/mschema_validator_ucwords",
64
+ "mediotype_core/mschema_validator_regex",
65
+ "mediotype_core/mschema_validator_datatype",
66
+ "mediotype_core/mschema_validator_cast",
67
+ "mediotype_core/mschema_validator_parseavp"
68
+ );
69
+
70
+ $this->_currentValidationNode = null;
71
+ }
72
+
73
+ /**
74
+ * @return array
75
+ */
76
+ public function getValidators()
77
+ {
78
+ return $this->_validators;
79
+ }
80
+
81
+ /**
82
+ * @param $class
83
+ * @return Mediotype_Core_Helper_Mschema
84
+ */
85
+ public function addValidator($class)
86
+ {
87
+ if (is_string($class)) {
88
+ $this->_validators[$class] = $class;
89
+ }
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * @param $target
95
+ * @return bool
96
+ */
97
+ public function removeValidator($target)
98
+ {
99
+ if(array_key_exists($target, $this->_validators)){
100
+ unset($this->_validators[$target]);
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * @param $filePath
108
+ * @return Mediotype_Core_Helper_Mschema|null
109
+ * @throws Mediotype_Core_Helper_Mschema_Exception
110
+ */
111
+ public function LoadSchema($filePath)
112
+ {
113
+ // ************* LOAD/VALIDATE VALIDATION OBJECT *************
114
+ if (is_string($filePath)) {
115
+ $this->debug->log("Loading Validation Object");
116
+
117
+ // LOAD JSON DOCUMENT
118
+ if ($ioHandler = fopen($filePath, "r")) {
119
+ $json = fread($ioHandler, filesize($filePath));
120
+ fclose($ioHandler);
121
+
122
+ //PARSE JSON
123
+ $this->_validationObject = json_decode($json);
124
+
125
+ // HANDLE ERRORS
126
+ if (is_null($this->_validationObject)) {
127
+ throw new Mediotype_Core_Helper_Mschema_Exception("Failed to parse json,", 1000);
128
+ } else {
129
+ $this->_currentValidationNode = $this->_validationObject;
130
+ return $this;
131
+ }
132
+ } else {
133
+ throw new Mediotype_Core_Helper_Mschema_Exception("Failed to open file,", 1000);
134
+ }
135
+
136
+ }
137
+
138
+ return NULL;
139
+ }
140
+
141
+ /**
142
+ * @param $data
143
+ * @param int $depth
144
+ * @return Mediotype_Core_Model_Response
145
+ */
146
+ public function Validate($data, $depth = 0) //$validationObject, $data, $depth = 0)
147
+ {
148
+ // ************* SET STARTING VARIABLES *************
149
+ $returnObject = new Mediotype_Core_Model_Response(__METHOD__, array(), Mediotype_Core_Model_Response::OK); // OBJECT USED FOR COLLECTING NODES THAT FAILED VALIDATION
150
+ $depth += 1; // TRACK DEPTH OF RECURSION
151
+
152
+ // ************* MAIN PARSING LOOP *************
153
+ foreach ($this->_currentValidationNode as $index => $value) {
154
+ $errorMessages = array(); // USED TO HOLD DETAILS AS TO WHY A NODE FAILED VALIDATION
155
+
156
+
157
+ $this->debug->logRecursion($depth, " foreach index of the validationSchema ($index)");
158
+
159
+ // ************* DEFAULT DATA MERGE ****************
160
+ if (!isset($data->$index) && isset($this->_currentValidationNode->$index->default)) {
161
+ $this->debug->logRecursion($depth, "MERGING DEFAULT DATA ON ($index)");
162
+ $data->$index = $this->_currentValidationNode->$index->default;
163
+ }
164
+
165
+ if (isset($data->$index)) { // If the index is found in the data
166
+ $this->debug->logRecursion($depth, "($index) WAS FOUND IN THE DATA");
167
+ // ************* OBJECT VALIDATION *************
168
+ if (is_object($this->_currentValidationNode->$index)) { // CHECK IF THE NODE IS AN OBJECT
169
+ $this->debug->logRecursion($depth, "OBJECT VALIDATION ($index)");
170
+ // ************* END NODE DETECTION *************
171
+ if ($this->_isEndNode($this->_currentValidationNode->$index)) {
172
+ // ************* END NODE ****************
173
+ $this->debug->logRecursion($depth, "NODE ($index) IS A END NODE");
174
+
175
+ // ************* LOOP THROUGH VALIDATION OBJECTS ****************
176
+ foreach ($this->getValidators() as $className) {
177
+
178
+ $validator = NULL;
179
+ if (strstr($className, "/")) {
180
+ $validator = Mage::helper($className);
181
+ }
182
+
183
+ if (is_null($validator)) {
184
+ $this->debug->logRecursion($depth, "FAILED TO LOAD VALIDATOR ($className)");
185
+ continue;
186
+ }
187
+
188
+ if ($validator->canRead($this->_currentValidationNode->$index)) {
189
+ $this->debug->logRecursion($depth, "VALIDATING NODE ($index) USING $className");
190
+
191
+ $response = $validator->Validate($this->_currentValidationNode->$index, $data->$index);
192
+
193
+ $this->debug->logRecursion($depth, "$className RESULTS : " . print_r($response, true));
194
+
195
+ // ************* CATCH ANY ERROR MSGS ****************
196
+ if ($response->disposition !== Mediotype_Core_Model_Response::OK) {
197
+ $this->debug->logRecursion($depth, "($index) HAS FAILED VALIDATION");
198
+ $returnObject->data[$index] = $response;
199
+ $returnObject->disposition = Mediotype_Core_Model_Response::FATAL;
200
+ }
201
+ }
202
+ }
203
+
204
+ if ($returnObject->disposition == Mediotype_Core_Model_Response::OK) {
205
+ $this->debug->logRecursion($depth, "($index) HAS PASSED VALIDATION");
206
+ }
207
+
208
+ } else {
209
+ // ************* NOT END NODE ****************
210
+ $this->debug->logRecursion($depth, "NODE ($index) *IS NOT* A END NODE");
211
+ $this->debug->logRecursion($depth, "NODE ($index) FOUND IN SUPPLIED DATA");
212
+
213
+ $this->_lastNode = $this->cloneObject($this->_currentValidationNode);
214
+ $this->_currentValidationNode = $this->cloneObject($this->_currentValidationNode->$index);
215
+
216
+ // ************* RECURSION *************
217
+ $this->debug->logRecursion($depth, "+START Recursion on index ( $index )");
218
+ $objectRecursionResponse = $this->Validate($data->$index, $depth); //
219
+ $this->_currentValidationNode = $this->cloneObject($this->_lastNode);
220
+ $this->debug->logRecursion($depth, "-END Recursion on index ( $index )");
221
+
222
+ if ($objectRecursionResponse->disposition !== Mediotype_Core_Model_Response::OK) {
223
+ $returnObject->data[$index] = $objectRecursionResponse;
224
+ $returnObject->disposition = Mediotype_Core_Model_Response::FATAL;
225
+
226
+ $this->debug->logRecursion($depth, "FAILURE IN CHILD NODE");
227
+ }
228
+ }
229
+ }
230
+
231
+ // ************* ARRAY VALIDATION *************
232
+ if (is_array($this->_currentValidationNode->$index)) {
233
+ $this->debug->logRecursion($depth, "ARRAY VALIDATION");
234
+
235
+ $failedArrayResponseCollection = array();
236
+ // CHECK IF SUPPLIED DATA IS AN ARRAY
237
+ if (is_array($data->$index)) {
238
+
239
+ $this->_lastNode = $this->cloneObject($this->_currentValidationNode);
240
+ $this->_currentValidationNode = $this->cloneObject(array_shift($this->_currentValidationNode->$index));
241
+
242
+ // TODO: REVIEW THIS
243
+ // REMOVE KEYWORDS FROM DATA
244
+ if (isset($this->_currentValidationNode->$index) && is_bool(($this->_currentValidationNode->$index))) {
245
+ unset($this->_currentValidationNode->$index);
246
+ }
247
+
248
+ foreach ($data->$index as $key => $node) {
249
+ $this->debug->logRecursion($depth, "+START Recursion on array ( $index )");
250
+ $arrayRecursionResults = $this->Validate($node, $depth);
251
+ $this->debug->logRecursion($depth, "-END Recursion on array ( $index )");
252
+
253
+ if ($arrayRecursionResults->disposition !== Mediotype_Core_Model_Response::OK) {
254
+ $this->debug->logRecursion($depth, "FAILURE IN CHILD NODE");
255
+ $failedArrayResponseCollection[$key] = $arrayRecursionResults;
256
+ }
257
+ }
258
+
259
+ if (count($failedArrayResponseCollection) > 0) {
260
+ $returnObject->data[$index] = $failedArrayResponseCollection;
261
+ $returnObject->disposition = Mediotype_Core_Model_Response::FATAL;
262
+ }
263
+
264
+ $this->_currentValidationNode = $this->cloneObject($this->_lastNode);
265
+
266
+ } else {
267
+ $this->debug->logRecursion($depth, "NODE IN SUPPLIED DATA SHOULD BE AN ARRAY ($index)");
268
+
269
+ $returnObject->disposition = Mediotype_Core_Model_Response::FATAL;
270
+ $returnObject->data[$index] = new Mediotype_Core_Model_Response(
271
+ __METHOD__,
272
+ $index,
273
+ Mediotype_Core_Model_Response::FATAL,
274
+ "NODE IN SUPPLIED DATA SHOULD BE AN ARRAY",
275
+ Mediotype_Core_Helper_Mschema::EC_STRUCTURE_MALFORMED);
276
+
277
+ }
278
+
279
+ }
280
+
281
+ } else {
282
+ $this->debug->logRecursion($depth, "NODE ($index) *WAS NOT* FOUND IN SUPPLIED DATA");
283
+ $isNodeRequired = FALSE;
284
+ if (is_array($this->_currentValidationNode->$index)) {
285
+ if (isset($this->_currentValidationNode->$index[0]->required)) {
286
+ $isNodeRequired = $this->_currentValidationNode->$index[0]->required;
287
+ } else {
288
+ $isNodeRequired = FALSE;
289
+ }
290
+
291
+ }
292
+ if (is_object($this->_currentValidationNode->$index)) {
293
+ if (isset($this->_currentValidationNode->$index->required)) {
294
+ $isNodeRequired = $this->_currentValidationNode->$index->required;
295
+ } else {
296
+ $isNodeRequired = FALSE;
297
+ }
298
+ }
299
+ if ($isNodeRequired) {
300
+ $this->debug->logRecursion($depth, "NODE ($index) IS REQUIRED");
301
+ $returnObject->disposition = Mediotype_Core_Model_Response::FATAL;
302
+ $returnObject->data[$index] = new Mediotype_Core_Model_Response(
303
+ __METHOD__,
304
+ $index,
305
+ Mediotype_Core_Model_Response::FATAL,
306
+ "MISSING REQUIRED NODE $index",
307
+ Mediotype_Core_Helper_Mschema::EC_REQUIRED_NODE
308
+ );
309
+ } else {
310
+ $this->debug->logRecursion($depth, "NODE ($index) *IS NOT* REQUIRED");
311
+ }
312
+ }
313
+
314
+ }
315
+ //</editor-fold>
316
+
317
+ // FORMAT RETURN DATA
318
+
319
+ //NOTE: THE ORDER IN WHICH THE RETURN OBJECT IS BUILT WILL BE THE ORDER IN WHICH IT IS RETURNED
320
+ if ($returnObject->disposition !== Mediotype_Core_Model_Response::OK) {
321
+ $returnObject->description = "Failed mSchema Validation";
322
+ } else {
323
+ $returnObject->description = "Passed mSchema Validation";
324
+ }
325
+ return $returnObject;
326
+ }
327
+
328
+ /**
329
+ * @param $object
330
+ * @return bool
331
+ */
332
+ protected function _hasRequiredFields($object)
333
+ {
334
+ $requiredFieldsDetected = false;
335
+ foreach ($object as $index => $node) {
336
+ if (is_object($object->$index)) { // IF KEY IS AN OBJECT THEN
337
+ if ($this->_isEndNode($object->$index)) { // If the key is a end node
338
+ if (ucwords($object->$index->required) == TRUE) {
339
+ $requiredFieldsDetected = true;
340
+ }
341
+ } else { // IF NOT END NODE
342
+ $requiredFieldsDetected = $this->_hasRequiredFields($object->$index);
343
+ }
344
+ }
345
+ }
346
+ return $requiredFieldsDetected;
347
+ }
348
+
349
+ /**
350
+ * @param $object
351
+ * @return bool
352
+ */
353
+ protected function _isEndNode($object)
354
+ {
355
+ $isEndNode = true;
356
+
357
+ foreach ($object as $index => $node) {
358
+ if ($isEndNode && (is_object($node) || is_array($node))) {
359
+ $isEndNode = false;
360
+ }
361
+ }
362
+ return $isEndNode;
363
+ }
364
+
365
+ /**
366
+ * @param object $obj
367
+ * @return mixed
368
+ */
369
+ protected function cloneObject($obj)
370
+ {
371
+ return unserialize(serialize($obj));
372
+ }
373
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Exception.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Exception
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Exception extends Mediotype_Core_Exception {
16
+
17
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Abstract.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Abstract
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ abstract class Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+ /**
18
+ * @param $validationObject
19
+ * @param $data
20
+ * @return bool
21
+ */
22
+ abstract public function Validate($validationObject, &$data);
23
+
24
+ /**
25
+ * @return string
26
+ */
27
+ abstract protected function getKeyword();
28
+
29
+ /**
30
+ * @param $validationObject
31
+ * @return bool
32
+ */
33
+ public function CanRead($validationObject)
34
+ {
35
+ return isset($validationObject->{$this->getKeyword()});
36
+ }
37
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Cast.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Cast
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Cast extends Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+ /*
18
+
19
+ "boolean"
20
+ "integer"
21
+ "double" (for historical reasons "double" is returned in case of a float, and not simply "float")
22
+ "string"
23
+ "array"
24
+ "object"
25
+ "resource"
26
+ "NULL"
27
+ "unknown type"
28
+
29
+ */
30
+
31
+ /**
32
+ * @param $validationObject
33
+ * @param $data
34
+ * @return Mediotype_Core_Model_Response
35
+ */
36
+ public function Validate($validationObject, &$data)
37
+ {
38
+
39
+ $response = new Mediotype_Core_Model_Response(__METHOD__, NULL, Mediotype_Core_Model_Response::OK);
40
+ if ($this->CanRead($validationObject)) {
41
+ if (!settype($data, $validationObject->cast)) {
42
+ $response->disposition = Mediotype_Core_Model_Response::FATAL;
43
+ $response->description = "Failed to cast variable to type '{$validationObject->cast}'";
44
+ }
45
+ }
46
+ $response->data = gettype($data);
47
+ return $response;
48
+ }
49
+
50
+ /**
51
+ * @return string
52
+ */
53
+ public function getKeyword()
54
+ {
55
+ return "cast";
56
+ }
57
+
58
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Datatype.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Datatype
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Datatype extends Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+ /*
18
+ "boolean"
19
+ "integer"
20
+ "double" (for historical reasons "double" is returned in case of a float, and not simply "float")
21
+ "string"
22
+ "array"
23
+ "object"
24
+ "resource"
25
+ "NULL"
26
+ "unknown type"
27
+
28
+ */
29
+
30
+ /**
31
+ * @param $validationObject
32
+ * @param $data
33
+ * @return bool|Mediotype_Core_Model_Response
34
+ */
35
+ public function Validate($validationObject, &$data)
36
+ {
37
+ $response = new Mediotype_Core_Model_Response(__METHOD__, NULL, Mediotype_Core_Model_Response::OK);
38
+ if ($this->CanRead($validationObject)) {
39
+ if(gettype($data) != $validationObject->datatype){
40
+ $response->disposition = Mediotype_Core_Model_Response::FATAL;
41
+ $response->description = "FAILED DATATYPE VALIDATION. PARAMETER PROVIDED IS A " . gettype($data);
42
+ }
43
+ }
44
+ return $response;
45
+ }
46
+
47
+ /**
48
+ * @return string
49
+ */
50
+ public function getKeyword(){
51
+ return "datatype";
52
+ }
53
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Parseavp.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Parseavp
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Parseavp extends Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+ /**
18
+ * @param $validationObject
19
+ * @param $data
20
+ * @return bool|Mediotype_Core_Model_Response
21
+ */
22
+ public function Validate($validationObject, &$data)
23
+ {
24
+ $response = new Mediotype_Core_Model_Response(__METHOD__);
25
+ if ($this->CanRead($validationObject)) {
26
+ $originalData = $data;
27
+
28
+ $data = explode(',', $data);
29
+ print_r($data);
30
+ foreach ($data as $key => $value) {
31
+ $data[$key] = trim($value);
32
+ if ($data[$key] == '') {
33
+ $data = $originalData;
34
+ if (!is_array($response->data)) {
35
+ $response->data = array();
36
+ }
37
+ $response->disposition = Mediotype_Core_Model_Response::FATAL;
38
+ $response->data[] = $data;
39
+ $response->description = "Malformed string";
40
+ return $response;
41
+ }
42
+ }
43
+
44
+ if (count($data) == 0) {
45
+ $data = null;
46
+ } else {
47
+
48
+
49
+ foreach ($data as $key => $value) {
50
+ $data[$key] = trim(trim($value), '`');
51
+ $data[$key] = explode(':', $data[$key]);
52
+ }
53
+
54
+ $tempArray = array();
55
+ foreach ($data as $key => $value) {
56
+ if (count($data[$key]) != 2) {
57
+ $data = $originalData;
58
+ if (!is_array($response->data)) {
59
+ $response->data = array();
60
+ }
61
+ $response->disposition = Mediotype_Core_Model_Response::FATAL;
62
+ $response->data[] = $data;
63
+ $response->description = "Malformed string";
64
+ return $response;
65
+ }
66
+
67
+ $attribute_name = $data[$key][0];
68
+ $attribute_value = $data[$key][1];
69
+ $tempArray[$attribute_name] = $attribute_value;
70
+
71
+ }
72
+ $data = $tempArray;
73
+ }
74
+ }
75
+ return $response;
76
+ }
77
+
78
+ /**
79
+ * @return string
80
+ */
81
+ public function getKeyword()
82
+ {
83
+ return "parse_avp";
84
+ }
85
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Regex.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Regex
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Regex extends Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+
18
+ /**
19
+ * @param $validationObject
20
+ * @param $data
21
+ * @return Mediotype_Core_Model_Response
22
+ */
23
+ public function Validate($validationObject, &$data)
24
+ {
25
+ $response = new Mediotype_Core_Model_Response(__METHOD__, NULL, Mediotype_Core_Model_Response::OK);
26
+ if ($this->CanRead($validationObject)) {
27
+ if (preg_match($validationObject->regex, $data) == 0) {
28
+ $response->disposition = Mediotype_Core_Model_Response::FATAL;
29
+ $response->description = "FAILED REGEX VALIDATION";
30
+ }
31
+ }
32
+ return $response;
33
+ }
34
+
35
+ /**
36
+ * @return string
37
+ */
38
+ protected function getKeyword()
39
+ {
40
+ return "regex";
41
+ }
42
+
43
+
44
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Strip.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Strip
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Strip extends Mediotype_Core_Helper_Mschema_Validator_Abstract{
16
+ /**
17
+ * @param $validationObject
18
+ * @param $data
19
+ * @return Mediotype_Core_Model_Response
20
+ */
21
+ public function Validate($validationObject, &$data)
22
+ {
23
+ $response = new Mediotype_Core_Model_Response(__METHOD__, NULL, Mediotype_Core_Model_Response::OK);
24
+ if($this->CanRead($validationObject)){
25
+ $remove = $validationObject->strip;
26
+ for($pos = 0; $pos < strlen($remove); $pos++){
27
+ $data = str_replace(substr($remove, $pos, 1), '', $data);
28
+ }
29
+ }
30
+ return $response;
31
+ }
32
+
33
+ /**
34
+ * @return string
35
+ */
36
+ protected function getKeyword()
37
+ {
38
+ return "strip";
39
+ }
40
+
41
+
42
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Trim.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Trim
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Trim extends Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+ /**
18
+ * @param $validationObject
19
+ * @param $data
20
+ * @return Mediotype_Core_Model_Response
21
+ */
22
+ public function Validate($validationObject, &$data)
23
+ {
24
+ if (is_string($data)) {
25
+ $data = trim($data);
26
+ }
27
+ return new Mediotype_Core_Model_Response(__METHOD__, NULL, Mediotype_Core_Model_Response::OK);
28
+ }
29
+
30
+ /**
31
+ * @return string
32
+ */
33
+ protected function getKeyword()
34
+ {
35
+ return "trim";
36
+ }
37
+
38
+ }
app/code/community/Mediotype/Core/Helper/Mschema/Validator/Ucwords.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Mschema_Validator_Ucwords
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Mschema_Validator_Ucwords extends Mediotype_Core_Helper_Mschema_Validator_Abstract
16
+ {
17
+ /**
18
+ * @param $validationObject
19
+ * @param $data
20
+ * @return Mediotype_Core_Model_Response
21
+ */
22
+ public function Validate($validationObject, &$data)
23
+ {
24
+ $response = new Mediotype_Core_Model_Response(__METHOD__, NULL, Mediotype_Core_Model_Response::OK);
25
+ if ($this->CanRead($validationObject)) {
26
+ $data = ucwords($data);
27
+ }
28
+ return $response;
29
+
30
+ }
31
+
32
+ /**
33
+ * @return string
34
+ */
35
+ protected function getKeyword()
36
+ {
37
+ return "ucwords";
38
+ }
39
+
40
+
41
+ }
app/code/community/Mediotype/Core/Helper/XML.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Helper_Xml
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Helper_Xml extends Mage_Core_Helper_Abstract {
16
+ /**
17
+ * @param $XML
18
+ * @return array
19
+ */
20
+ public function XMLToArray($XML) {
21
+ $returnData = array();
22
+ $XML = simplexml_load_string($XML);
23
+
24
+ foreach ($XML as $node) {
25
+ if ($node->count() > 0) {
26
+ $returnData[$node->getName()] = $this->XMLToArray($node->asXML());
27
+ } else {
28
+ $returnData[$node->getName()] = urldecode((string) $node);
29
+ }
30
+ }
31
+ return $returnData;
32
+ }
33
+ }
34
+
app/code/community/Mediotype/Core/Model/Entity/Attribute/Backend/Datetime.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Model_Entity_Attribute_Backend_Datetime
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Model_Entity_Attribute_Backend_Datetime extends Mage_Eav_Model_Entity_Attribute_Backend_Datetime
16
+ {
17
+
18
+ /**
19
+ * Prepare date for save in DB
20
+ *
21
+ * string format used from input fields (all date input fields need apply locale settings)
22
+ * int value can be declared in code (this meen whot we use valid date)
23
+ *
24
+ * @param string | int $date
25
+ * @return string
26
+ */
27
+ public function formatDate($date)
28
+ {
29
+ if (empty($date)) {
30
+ return null;
31
+ }
32
+ // unix timestamp given - simply instantiate date object
33
+ if (preg_match('/^[0-9]+$/', $date)) {
34
+ $date = new Zend_Date((int)$date);
35
+ }
36
+ // international format
37
+ else if (preg_match('#^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$#', $date)) {
38
+ $zendDate = new Zend_Date();
39
+ $date = $zendDate->setIso($date);
40
+ }
41
+ // parse this date in current locale, do not apply GMT offset
42
+ else {
43
+ $date = Mage::app()->getLocale()->date($date,
44
+ Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
45
+ null, false
46
+ );
47
+ }
48
+ return $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
49
+ }
50
+
51
+ }
app/code/community/Mediotype/Core/Model/Resource/Abstract.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Joel Hart
5
+ */
6
+ class Mediotype_Core_Model_Resource_Abstract extends Mage_Core_Model_Resource_Db_Abstract
7
+ {
8
+
9
+ protected function _construct()
10
+ {
11
+ }
12
+
13
+ /**
14
+ * Serialize serializable fields of the object
15
+ *
16
+ * @param Mage_Core_Model_Abstract $object
17
+ */
18
+ protected function _serializeFields(Mage_Core_Model_Abstract $object)
19
+ {
20
+ foreach ($this->_serializableFields as $field => $parameters) {
21
+ if (count($parameters) >= 2) {
22
+ $serializeDefault = $parameters[0];
23
+ if (count($parameters) > 3) {
24
+ $unsetEmpty = (bool)$parameters[2];
25
+ $callback = $parameters[3];
26
+ } else {
27
+ $unsetEmpty = isset($parameters[2]);
28
+ $callback = null;
29
+ }
30
+ $this->_serializeField($object, $field, $serializeDefault, $unsetEmpty, $callback);
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Serialize serializable fields of the object
37
+ *
38
+ * @param Mage_Core_Model_Abstract $object
39
+ */
40
+ public function serializeFields(Mage_Core_Model_Abstract $object)
41
+ {
42
+ $this->_serializeFields($object);
43
+ }
44
+
45
+
46
+ /**
47
+ * Unserialize serializable object fields
48
+ *
49
+ * @param Mage_Core_Model_Abstract $object
50
+ */
51
+ public function unserializeFields(Mage_Core_Model_Abstract $object)
52
+ {
53
+ foreach ($this->_serializableFields as $field => $parameters) {
54
+ if (count($parameters) >= 2) {
55
+ $unserializeDefault = $parameters[1];
56
+ if (count($parameters) > 4) {
57
+ $callback = $parameters[4];
58
+ } else {
59
+ $callback = null;
60
+ }
61
+ $this->_unserializeField($object, $field, $unserializeDefault, $callback);
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Serialize specified field in an object
68
+ *
69
+ * @param Varien_Object $object
70
+ * @param string $field
71
+ * @param mixed $defaultValue
72
+ * @param bool $unsetEmpty
73
+ *
74
+ * @return Mage_Core_Model_Resource_Abstract
75
+ */
76
+ /**
77
+ * @param Varien_Object $object
78
+ * @param string $field
79
+ * @param null $defaultValue
80
+ * @param bool $unsetEmpty
81
+ * @param callable $callback
82
+ *
83
+ * @author Joel Hart
84
+ * @return $this|Mage_Core_Model_Resource_Abstract
85
+ */
86
+ protected function _serializeField(
87
+ Varien_Object $object,
88
+ $field,
89
+ $defaultValue = null,
90
+ $unsetEmpty = false,
91
+ $callback = null
92
+ ) {
93
+ if (!is_callable($callback)) {
94
+ $callback = 'serialize';
95
+ }
96
+
97
+ $value = $object->getData($field);
98
+ if (empty($value)) {
99
+ if ($unsetEmpty) {
100
+ $object->unsetData($field);
101
+ } else {
102
+ if (is_object($defaultValue) || is_array($defaultValue)) {
103
+ $defaultValue = $callback($defaultValue);
104
+ }
105
+ $object->setData($field, $defaultValue);
106
+ }
107
+ } elseif (is_array($value) || is_object($value)) {
108
+ $object->setData($field, $callback($value));
109
+ }
110
+
111
+ return $this;
112
+ }
113
+
114
+ /**
115
+ * Unserialize Varien_Object field in an object
116
+ *
117
+ * @param Varien_Object $object
118
+ * @param string $field
119
+ * @param mixed $defaultValue
120
+ * @param callable $callback
121
+ *
122
+ * @author Joel Hart
123
+ */
124
+ protected function _unserializeField(Varien_Object $object, $field, $defaultValue = null, $callback = null)
125
+ {
126
+ if (!is_callable($callback)) {
127
+ $callback = 'unserialize';
128
+ }
129
+
130
+ $value = $object->getData($field);
131
+ if (empty($value)) {
132
+ $object->setData($field, $defaultValue);
133
+ } elseif (!is_array($value) && !is_object($value)) {
134
+ $object->setData($field, call_user_func($callback, $value));
135
+ }
136
+ }
137
+
138
+
139
+ /**
140
+ * Retrieve select object for load object data
141
+ * Extended to allow for array's to be passed to the load function
142
+ *
143
+ * @param string $field
144
+ * @param mixed $value
145
+ * @param Mage_Core_Model_Abstract $object
146
+ * @return Zend_Db_Select
147
+ */
148
+ protected function _getLoadSelect($field, $value, $object)
149
+ {
150
+ $values = $value;
151
+ if (is_array($value)) {
152
+ $conditions = array();
153
+ foreach ($values as $field => $value) {
154
+ $field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field));
155
+ $conditions[] = $this->_getReadAdapter()->quoteInto($field . '=?', $value);
156
+ }
157
+ $select = $this->_getReadAdapter()->select()
158
+ ->from($this->getMainTable())
159
+ ->where(implode(' AND ', $conditions));
160
+ return $select;
161
+ } else {
162
+ return parent::_getLoadSelect($field, $value, $object);
163
+ }
164
+
165
+ }
166
+ }
app/code/community/Mediotype/Core/Model/Resource/Db/Collection/Abstract.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Joel Hart
5
+ */
6
+ class Mediotype_Core_Model_Resource_Db_Collection_Abstract extends Mage_Core_Model_Resource_Db_Collection_Abstract{
7
+
8
+ /**
9
+ * Over-rides Mage_Core_Model_Resource_Db_Collection_Abstract->getAllIds() because using ajax for mass action on a grid
10
+ * when the collection has joins from other tables is faulty in out of the box Magento
11
+ *
12
+ * @return array
13
+ */
14
+ public function getAllIds()
15
+ {
16
+ $this->_renderFilters();
17
+ $idsSelect = "SELECT `core_query`.`".$this->getResource()->getIdFieldName()."` FROM (" . $this->getSelect() . ") as core_query";
18
+ return $this->getConnection()->fetchCol($idsSelect);
19
+ }
20
+
21
+ /**
22
+ * Over-rides Zend_Db_Select -> This original function fails often when using ->having on grids with resource models that use joins
23
+ *
24
+ * @return string|Varien_Db_Select
25
+ */
26
+ public function getSelectCountSql()
27
+ {
28
+
29
+ $this->_renderFilters();
30
+ $countSelect = "SELECT COUNT(*) FROM (" . $this->getSelect() . ") as core_query";
31
+ return $countSelect;
32
+
33
+ }
34
+
35
+ /**
36
+ * @param array|string $field
37
+ * @param null $condition
38
+ *
39
+ * @return $this|Mage_Eav_Model_Entity_Collection_Abstract
40
+ */
41
+ public function addFieldToFilterHaving($field, $condition = null)
42
+ {
43
+ if (!is_array($field)) {
44
+ $resultCondition = $this->_translateCondition($field, $condition);
45
+ } else {
46
+ $conditions = array();
47
+ foreach ($field as $key => $currField) {
48
+ $conditions[] = $this->_translateCondition(
49
+ $currField,
50
+ isset($condition[$key]) ? $condition[$key] : null
51
+ );
52
+ }
53
+
54
+ $resultCondition = '(' . join(') ' . Zend_Db_Select::SQL_OR . ' (', $conditions) . ')';
55
+ }
56
+
57
+ $this->_select->having($resultCondition);
58
+
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Post-process collection items to run afterLoad on each
64
+ *
65
+ * @return $this
66
+ * @author Joel Hart
67
+ */
68
+ protected function _afterLoad()
69
+ {
70
+ foreach ($this->_items as $item) {
71
+ $this->getResource()->unserializeFields($item);
72
+ $item->afterLoad();
73
+ }
74
+
75
+ return parent::_afterLoad();
76
+ }
77
+
78
+ /**
79
+ * Join table to collection select
80
+ *
81
+ * @param string $table
82
+ * @param string $cond
83
+ * @param string $cols
84
+ * @return Mage_Core_Model_Resource_Db_Collection_Abstract
85
+ */
86
+ public function join($table, $cond, $cols = '*')
87
+ {
88
+ if (is_array($table)) {
89
+ foreach ($table as $k => $v) {
90
+ $alias = $k;
91
+ $table = $v;
92
+ break;
93
+ }
94
+ } else {
95
+ $alias = $table;
96
+ }
97
+
98
+ if (!isset($this->_joinedTables[$alias])) {
99
+ $this->getSelect()->join(
100
+ array($alias => $this->getTable($table)),
101
+ $cond,
102
+ $cols
103
+ );
104
+ $this->_joinedTables[$alias] = true;
105
+ }
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Join table to collection select
111
+ *
112
+ * @param string $table
113
+ * @param string $cond
114
+ * @param string $cols
115
+ * @return Mage_Core_Model_Resource_Db_Collection_Abstract
116
+ */
117
+ public function joinLeft($table, $cond, $cols = '*')
118
+ {
119
+ if (is_array($table)) {
120
+ foreach ($table as $k => $v) {
121
+ $alias = $k;
122
+ $table = $v;
123
+ break;
124
+ }
125
+ } else {
126
+ $alias = $table;
127
+ }
128
+
129
+ if (!isset($this->_joinedTables[$alias])) {
130
+ $this->getSelect()->joinLeft(
131
+ array($alias => $this->getTable($table)),
132
+ $cond,
133
+ $cols
134
+ );
135
+ $this->_joinedTables[$alias] = true;
136
+ }
137
+ return $this;
138
+ }
139
+
140
+ }
app/code/community/Mediotype/Core/Model/Response.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Model_Response
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Model_Response {
16
+
17
+ /**
18
+ *
19
+ */
20
+ const OK = 1;
21
+ /**
22
+ *
23
+ */
24
+ const MESSAGE = 2;
25
+ /**
26
+ *
27
+ */
28
+ const WARNING = 3;
29
+ /**
30
+ *
31
+ */
32
+ const FATAL = 4;
33
+
34
+ /**
35
+ * @var
36
+ */
37
+ public $method;
38
+ /**
39
+ * @var string
40
+ */
41
+ public $description;
42
+ /**
43
+ * @var null
44
+ */
45
+ public $data;
46
+ /**
47
+ * @var int
48
+ */
49
+ public $errorCode;
50
+ /**
51
+ * @var int
52
+ */
53
+ public $disposition;
54
+
55
+ /**
56
+ * @var int
57
+ */
58
+ private $_startTime;
59
+ /**
60
+ * @var int
61
+ */
62
+ private $_stopTime;
63
+
64
+ /**
65
+ * @var
66
+ */
67
+ private $_startMemory;
68
+ /**
69
+ * @var
70
+ */
71
+ private $_stopMemory;
72
+
73
+ /**
74
+ * @param $method
75
+ * @param null $data
76
+ * @param int $disposition
77
+ * @param string $description
78
+ * @param int $errorCode
79
+ */
80
+ public function __construct($method, $data = NULL, $disposition = self::OK, $description = '', $errorCode = 0) {
81
+ $this->method = $method;
82
+ $this->data = $data;
83
+ $this->disposition = $disposition;
84
+ $this->description = $description;
85
+ $this->errorCode = $errorCode;
86
+
87
+ $this->_startTime = 0;
88
+ $this->_stopTime = 0;
89
+ }
90
+
91
+ /**
92
+ * @return float
93
+ */
94
+ public function getElapsedTime() {
95
+ return round($this->_stopTime - $this->_startTime, 10);
96
+ }
97
+
98
+ /**
99
+ * @return mixed
100
+ */
101
+ public function getMemoryDif(){
102
+ return $this->_stopMemory - $this->_startMemory;
103
+ }
104
+
105
+ /**
106
+ *
107
+ */
108
+ public function startTimer() {
109
+ $this->_startTime = microtime(true);
110
+ $this->_startMemory = memory_get_usage();
111
+ }
112
+
113
+ /**
114
+ *
115
+ */
116
+ public function stopTimer() {
117
+ $this->_stopTime = microtime(true);
118
+ $this->_stopMemory = memory_get_usage();
119
+ }
120
+
121
+ }
app/code/community/Mediotype/Core/Model/Systems/Api/Json/Request.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ *
6
+ * @desc Simple CURL protocol to pass parameters to Mothership
7
+ * @category Mediotype
8
+ * @package Mediotype_Core
9
+ * @class Mediotype_Core_Model_Systems_Api_Json_Request
10
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
11
+ * Copyright, 2013, Mediotype, LLC - US license
12
+ * @license http://mediotype.com/LICENSE.txt
13
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
14
+ */
15
+ class Mediotype_Core_Model_Systems_Api_Json_Request extends Mage_HTTP_Client_Curl{
16
+
17
+ /**
18
+ * Stream resource
19
+ * @var object
20
+ */
21
+ protected $_sock = null;
22
+
23
+ /**
24
+ * Request headers
25
+ * @var array
26
+ */
27
+ protected $_headers = array();
28
+
29
+
30
+ /**
31
+ * Fields for POST method - hash
32
+ * @var array
33
+ */
34
+ protected $_postFields = array();
35
+
36
+ /**
37
+ * Response headers
38
+ * @var array
39
+ */
40
+ protected $_responseHeaders = array();
41
+
42
+ /**
43
+ * Response body
44
+ * @var string
45
+ */
46
+ public $responseBody = '';
47
+
48
+ /**
49
+ * Response status
50
+ * @var int
51
+ */
52
+ protected $_responseStatus = 0;
53
+
54
+
55
+ /**
56
+ * Request timeout
57
+ * @var int
58
+ */
59
+ protected $_timeout = 300;
60
+
61
+ /**
62
+ * Curl
63
+ * @var object
64
+ */
65
+ protected $_ch;
66
+
67
+
68
+ /**
69
+ * User ovverides options hash
70
+ * Are applied before curl_exec
71
+ *
72
+ * @var array();
73
+ */
74
+ protected $_curlUserOptions = array();
75
+
76
+
77
+ /**
78
+ * Header count, used while parsing headers
79
+ * in CURL callback function
80
+ * @var int
81
+ */
82
+ protected $_headerCount = 0;
83
+
84
+ /**
85
+ * @param string $uri
86
+ * @param array $params
87
+ * @param string $method
88
+ */
89
+ public function makeRequest($uri, $params = array(), $method = "POST")
90
+ {
91
+ $this->_ch = curl_init();
92
+ $this->curlOption(CURLOPT_URL, $uri);
93
+ if($method == 'POST') {
94
+ $this->curlOption(CURLOPT_POST, 1);
95
+ $this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
96
+ } elseif($method == "GET") {
97
+ $this->curlOption(CURLOPT_HTTPGET, 1);
98
+ } else {
99
+ $this->curlOption(CURLOPT_CUSTOMREQUEST, $method);
100
+ }
101
+
102
+ if(count($this->_headers)) {
103
+ $heads = array();
104
+ foreach($this->_headers as $k=>$v) {
105
+ $heads[] = $k.': '.$v;
106
+ }
107
+ $this->curlOption(CURLOPT_HTTPHEADER, $heads);
108
+ }
109
+
110
+ if($this->_timeout) {
111
+ $this->curlOption(CURLOPT_TIMEOUT, $this->_timeout);
112
+ }
113
+
114
+ if($this->_port != 80) {
115
+ $this->curlOption(CURLOPT_PORT, $this->_port);
116
+ }
117
+
118
+ //$this->curlOption(CURLOPT_HEADER, 1);
119
+ $this->curlOption(CURLOPT_RETURNTRANSFER, 1);
120
+ $this->curlOption(CURLOPT_HEADERFUNCTION, array($this,'parseHeaders'));
121
+
122
+ if(count($this->_curlUserOptions)) {
123
+ foreach($this->_curlUserOptions as $k=>$v) {
124
+ $this->curlOption($k, $v);
125
+ }
126
+ }
127
+
128
+ $this->_headerCount = 0;
129
+ $this->_responseHeaders = array();
130
+ $this->responseBody = curl_exec($this->_ch);
131
+ $err = curl_errno($this->_ch);
132
+ if($err) {
133
+ $this->doError(curl_error($this->_ch));
134
+ }
135
+ curl_close($this->_ch);
136
+ }
137
+
138
+ }
app/code/community/Mediotype/Core/Model/Systems/Magento.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento / Mediotype Module
4
+ *
5
+ * @desc
6
+ * @category Mediotype
7
+ * @package Mediotype_Core
8
+ * @class Mediotype_Core_Model_Systems_Magento
9
+ * @copyright Copyright (c) 2013 Mediotype (http://www.mediotype.com)
10
+ * Copyright, 2013, Mediotype, LLC - US license
11
+ * @license http://mediotype.com/LICENSE.txt
12
+ * @author Mediotype (SZ,JH) <diveinto@mediotype.com>
13
+ */
14
+ class Mediotype_Core_Model_Systems_Magento extends Mage_Core_Model_Abstract{
15
+
16
+ /**
17
+ *
18
+ */
19
+ const RESPONSE_DISPOSITION_OK = "OK";
20
+ /**
21
+ *
22
+ */
23
+ const RESPONSE_DISPOSITION_FATAL = "FATAL";
24
+
25
+ /**
26
+ * @var
27
+ */
28
+ protected $_endPoint;
29
+ /**
30
+ * @var
31
+ */
32
+ protected $_originDomain;
33
+ /**
34
+ * @var
35
+ */
36
+ protected $_originIp;
37
+ /**
38
+ * @var
39
+ */
40
+ protected $_requestMethod;
41
+ /**
42
+ * @var
43
+ */
44
+ protected $_request;
45
+ /**
46
+ * @var
47
+ */
48
+ protected $_response;
49
+ /**
50
+ * @var
51
+ */
52
+ protected $_activeAdmin;
53
+
54
+ /**
55
+ *
56
+ */
57
+ public function _construct(){
58
+ $this->_requestMethod = Mage::getModel('mediotype_core/systems_api_json_request');
59
+ $this->_originDomain = Mage::getBaseUrl();
60
+ $this->_originIp = $_SERVER['REMOTE_ADDR'];
61
+ $admin = Mage::getSingleton('admin/session');
62
+ $this->_activeAdmin = $admin->getUser()->getName();
63
+ parent::_construct();
64
+ }
65
+
66
+ /**
67
+ * @param $uri
68
+ * @return Mediotype_Core_Model_Systems_Magento
69
+ */
70
+ public function setEndPoint($uri){
71
+ $this->_endPoint = $uri;
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * @param $json
77
+ * @return Mediotype_Core_Model_Systems_Magento
78
+ */
79
+ public function setJsonRequest($json){
80
+ $this->_request = $json;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * @return String (most likely json string)
86
+ */
87
+ public function doRequest(){
88
+ $params = array(
89
+ "origin_domain" => $this->_originDomain,
90
+ "origin_ip" => $this->_originIp,
91
+ "admin_user" => $this->_activeAdmin,
92
+ "request" => $this->_request
93
+ );
94
+ try{
95
+ $this->_requestMethod->makeRequest( $this->_endPoint, $params );
96
+ return $this->_requestMethod->responseBody;
97
+ } catch (Exception $e){
98
+ Mediotype_Core_Helper_Debugger::log(array("CAN NOT TALK TO MOTHERSHIP" , "PARAMS" => $params));
99
+ }
100
+ }
101
+
102
+ }
app/code/community/Mediotype/Core/data/mediotype_core/install-0.0.1.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Joel Hart
4
+ * @var $this Mage_Core_Model_Resource_Setup
5
+ */
6
+
7
+ $installer = $this;
8
+
9
+ $installer->startSetup();
10
+ //
11
+ //$coreDefaultSym = (bool)Mage::getStoreConfig('mediotype_core/use_simlinks');
12
+ //
13
+ //if ($coreDefaultSym) {
14
+ // try {
15
+ // /** @var $sysConfig Mage_Core_Model_Config_Data */
16
+ // $sysConfig = Mage::getModel('core/config_data');
17
+ // $sysConfig->load('dev/template/allow_symlink', 'path');
18
+ // if ($sysConfig->getId()) {
19
+ // $sysConfig->setValue('1');
20
+ // $sysConfig->save();
21
+ // } else {
22
+ // $sysConfig->setPath('dev/template/allow_symlink');
23
+ // $sysConfig->setValue('1');
24
+ // $sysConfig->save();
25
+ // }
26
+ // } catch (Exception $e) {
27
+ // Mediotype_Core_Helper_Debugger::log('failed to set system config use symlinks to true');
28
+ // Mage::logException($e);
29
+ // }
30
+ //}
31
+
32
+ $installer->endSetup();
app/code/community/Mediotype/Core/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <mediotype>
8
+ <title>Mediotype</title>
9
+ </mediotype>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <mediotype_general>
15
+ <title>Mediotype General</title>
16
+ </mediotype_general>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/Mediotype/Core/etc/config.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mediotype_Core>
5
+ <version>0.0.1</version>
6
+ </Mediotype_Core>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <mediotype_core>
11
+ <class>Mediotype_Core_Block</class>
12
+ </mediotype_core>
13
+ </blocks>
14
+ <helpers>
15
+ <mediotype_core>
16
+ <class>Mediotype_Core_Helper</class>
17
+ </mediotype_core>
18
+ </helpers>
19
+ <models>
20
+ <mediotype_core>
21
+ <class>Mediotype_Core_Model</class>
22
+ <resourceModel>Mediotype_Core_Model_Resource</resourceModel>
23
+ </mediotype_core>
24
+ </models>
25
+ <resources>
26
+ <mediotype_core>
27
+ <setup>
28
+ <class>Mage_Core_Model_Resource_Setup</class>
29
+ </setup>
30
+ </mediotype_core>
31
+ </resources>
32
+ </global>
33
+ <adminhtml>
34
+ <layout>
35
+ <updates>
36
+ <mediotype_core>
37
+ <file>mediotype-core/core.xml</file>
38
+ </mediotype_core>
39
+ </updates>
40
+ </layout>
41
+ </adminhtml>
42
+ <admin>
43
+ <routers>
44
+ <mediotype_core>
45
+ <use>admin</use>
46
+ <args>
47
+ <module>Mediotype_Core</module>
48
+ <frontName>mediotype_core</frontName>
49
+ </args>
50
+ </mediotype_core>
51
+ </routers>
52
+ </admin>
53
+ <defaults>
54
+ <mediotype_core>
55
+ <use_simlinks>1</use_simlinks>
56
+ </mediotype_core>
57
+ </defaults>
58
+ </config>
app/code/community/Mediotype/Core/etc/system.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <mediotype translate="label" module="mediotype_core">
5
+ <label><![CDATA[<div>Mediotype</div>]]></label>
6
+ <class>mediotype-section</class>
7
+ <sort_order>101</sort_order>
8
+ </mediotype>
9
+ </tabs>
10
+ <sections>
11
+ <mediotype_general translate="label" module="mediotype_core">
12
+ <label>General</label>
13
+ <tab>mediotype</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1000</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <header>
21
+ <frontend_type>text</frontend_type>
22
+ <frontend_model>mediotype_core/test</frontend_model>
23
+ </header>
24
+ <debug_settings translate="label">
25
+ <label>Debug Settings</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <fields>
32
+ <logging_enabled translate="label">
33
+ <label>Logging Enabled</label>
34
+ <comment>Enables logging for all Mediotype extensions</comment>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>0</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ </logging_enabled>
41
+ </fields>
42
+ </debug_settings>
43
+ </groups>
44
+ </mediotype_general>
45
+ </sections>
46
+ </config>
app/design/adminhtml/default/default/layout/mediotype-core/core.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_system_config_edit>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>mediotype/mediotype-adminhtml.css</stylesheet></action>
6
+ </reference>
7
+ </adminhtml_system_config_edit>
8
+ </layout>
app/design/adminhtml/default/default/template/mediotype/core/grid.phtml ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Mage_Adminhtml_Block_Widget_Grid
4
+ *
5
+ * getId()
6
+ * getCollection()
7
+ * getColumns()
8
+ * getPagerVisibility()
9
+ * getVarNamePage()
10
+ */
11
+ $numColumns = sizeof($this->getColumns());
12
+ ?>
13
+ <?php if($this->getCollection()): ?>
14
+ <?php if($this->canDisplayContainer()): ?>
15
+ <?php if($this->getGridHeader()): ?>
16
+ <div class="content-header">
17
+ <table cellspacing="0">
18
+ <tr>
19
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
20
+ </tr>
21
+ </table>
22
+ </div>
23
+ <?php endif ?>
24
+
25
+ <div id="<?php echo $this->getId() ?>">
26
+ <?php else: ?>
27
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
28
+ <?php endif; ?>
29
+ <?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
30
+ <table cellspacing="0" class="actions">
31
+ <tr>
32
+ <?php if($this->getDateFilterVisibility()): ?>
33
+ <td class="a-left filter">
34
+ <div class="f-left">
35
+
36
+ <div><?php echo $this->__('Start Date') ?>:&nbsp;<input class="input-text no-changes required-entry" type="text" id="period_date_from" name="start_date" value="<?php echo $this->getFilter('start_date') ?>" style="width:6em" /> <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" title="<?php echo $this->__('Select Date') ?>" id="period_date_from_trig" alt="<?php echo $this->__('Select Date') ?>" class="v-middle"/>&nbsp;&nbsp;</div>
37
+
38
+ <div id="period_date_from_advaice"></div>
39
+
40
+ </div>
41
+
42
+ <div class="f-left">
43
+ <div><?php echo $this->__('End Date') ?>:&nbsp;<input class="input-text no-changes required-entry" type="text" id="period_date_to" name="end_date" value="<?php echo $this->getFilter('end_date') ?>" style="width:6em" /> <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" class="v-middle" title="<?php echo $this->__('Select Date') ?>"id="period_date_to_trig" alt="<?php echo $this->__('Select Date') ?>"/>&nbsp;&nbsp;</div>
44
+
45
+ <div id="period_date_to_advaice"></div>
46
+
47
+ </div>
48
+
49
+ <div class="f-left">
50
+ <?php echo $this->getRefreshButtonHtml() ?>
51
+ </div>
52
+
53
+ <script type="text/javascript">
54
+ <!--
55
+ Calendar.setup({
56
+ inputField : 'period_date_from',
57
+ ifFormat : '<?php echo $this->getDateFormat() ?>',
58
+ button : 'period_date_from_trig',
59
+ align : 'Bl',
60
+ singleClick : true
61
+ });
62
+ Calendar.setup({
63
+ inputField : 'period_date_to',
64
+ ifFormat : '<?php echo $this->getDateFormat() ?>',
65
+ button : 'period_date_to_trig',
66
+ align : 'Bl',
67
+ singleClick : true
68
+ });
69
+ //-->
70
+ </script>
71
+ </td>
72
+ <?php endif; ?>
73
+ <?php if($this->getPagerVisibility()): ?>
74
+ <td class="pager">
75
+ <?php echo $this->__('Page') ?>
76
+
77
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
78
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
79
+ <?php if($_curPage>1): ?>
80
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
81
+ <?php else: ?>
82
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
83
+ <?php endif; ?>
84
+
85
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
86
+
87
+ <?php if($_curPage < $_lastPage): ?>
88
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
89
+ <?php else: ?>
90
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
91
+ <?php endif; ?>
92
+
93
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
94
+ <span class="separator">|</span>
95
+ <?php echo $this->__('View') ?>
96
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
97
+ <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
98
+ <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
99
+ <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
100
+ <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
101
+ <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
102
+ </select>
103
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
104
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
105
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
106
+ <?php if($this->getRssLists()): ?>
107
+ <?php foreach ($this->getRssLists() as $_rss): ?>
108
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
109
+ <?php endforeach ?>
110
+ <?php endif; ?>
111
+ </td>
112
+ <?php endif ?>
113
+ <?php if($this->getExportTypes()): ?>
114
+ <td class="export a-right">
115
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
116
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
117
+ <?php foreach ($this->getExportTypes() as $_type): ?>
118
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
119
+ <?php endforeach; ?>
120
+ </select>
121
+ <?php echo $this->getExportButtonHtml() ?>
122
+ </td>
123
+ <?php endif; ?>
124
+ <td class="filter-actions a-right">
125
+ <?php echo $this->getMainButtonsHtml() ?>
126
+ </td>
127
+ </tr>
128
+ </table>
129
+ <?php endif; ?>
130
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
131
+ <?php echo $this->getMassactionBlockHtml() ?>
132
+ <?php endif ?>
133
+ <div class="grid">
134
+ <div class="hor-scroll">
135
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table" style="min-width: <?php echo $this->getTableWidth(); ?>px;">
136
+ <?php foreach ($this->getColumns() as $_column): ?>
137
+ <col <?php echo $_column->getHtmlProperty() ?> />
138
+ <?php endforeach; ?>
139
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
140
+ <thead>
141
+ <?php if ($this->getHeadersVisibility()): ?>
142
+ <tr class="headings">
143
+ <?php foreach ($this->getColumns() as $_column): ?>
144
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
145
+ <?php endforeach; ?>
146
+ </tr>
147
+ <?php endif; ?>
148
+ <?php if ($this->getFilterVisibility()): ?>
149
+ <tr class="filter">
150
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
151
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
152
+ <?php endforeach; ?>
153
+ </tr>
154
+ <?php endif ?>
155
+ </thead>
156
+ <?php endif; ?>
157
+ <?php if ($this->getCountTotals()): ?>
158
+ <tfoot>
159
+ <tr class="totals">
160
+ <?php foreach ($this->getColumns() as $_column): ?>
161
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
162
+ <?php endforeach; ?>
163
+ </tr>
164
+ </tfoot>
165
+ <?php endif; ?>
166
+
167
+ <tbody>
168
+ <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
169
+ <?php foreach ($this->getCollection() as $_index=>$_item): ?>
170
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
171
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
172
+
173
+ <?php if ($this->shouldRenderCell($_item, $_column)):?>
174
+ <?php $_rowspan = $this->getRowspan($_item, $_column);?>
175
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
176
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
177
+ </td>
178
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
179
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
180
+ <?php endif;?>
181
+ <?php endif;?>
182
+
183
+ <?php endforeach; ?>
184
+ </tr>
185
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
186
+ <?php foreach ($_multipleRows as $_i):?>
187
+ <tr>
188
+ <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
189
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
190
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
191
+ </td>
192
+ <?php endforeach; ?>
193
+ </tr>
194
+ <?php endforeach;?>
195
+ <?php endif;?>
196
+
197
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
198
+ <tr class="subtotals">
199
+ <?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
200
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
201
+ <?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
202
+ $_column->getRowField($this->getSubTotalItem($_item))
203
+ );
204
+ ?>
205
+ </td>
206
+ <?php endforeach; ?>
207
+ </tr>
208
+ <?php endif; ?>
209
+ <?php endforeach; ?>
210
+ <?php elseif ($this->getEmptyText()): ?>
211
+ <tr>
212
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
213
+ </tr>
214
+ <?php endif; ?>
215
+ </tbody>
216
+
217
+ </table>
218
+ </div>
219
+ </div>
220
+ <?php if($this->canDisplayContainer()): ?>
221
+ </div>
222
+ <script type="text/javascript">
223
+ //<![CDATA[
224
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
225
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
226
+ <?php if($this->getRowClickCallback()): ?>
227
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
228
+ <?php endif; ?>
229
+ <?php if($this->getCheckboxCheckCallback()): ?>
230
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
231
+ <?php endif; ?>
232
+ <?php if($this->getRowInitCallback()): ?>
233
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
234
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
235
+ <?php endif; ?>
236
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
237
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
238
+ <?php endif ?>
239
+ <?php echo $this->getAdditionalJavaScript(); ?>
240
+ //]]>
241
+ </script>
242
+ <?php endif; ?>
243
+ <?php endif ?>
app/etc/modules/Mediotype_AgileGrid.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mediotype_AgileGrid>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mediotype_Core/>
9
+ </depends>
10
+ </Mediotype_AgileGrid>
11
+ </modules>
12
+ </config>
app/etc/modules/Mediotype_Core.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mediotype_Core>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Mediotype_Core>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>e7b2a9baa900411a6121c63d7174dcd5</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Agile Grid Extension by Mediotype allows Magento admins to save custom made filters for all filterable Magento grids turning the Magento admin system in to an Agile and powerful reporting tool.</summary>
10
+ <description>Simplicity is the ultimate sophistication.&#xD;
11
+ &#xD;
12
+ This operational extension is perfect for managers running a storefront who need a reliable and efficient reporting system in place to either analyze data, or to send analyzed data to other team members for use. What was once before a manual and tedious process of manually creating filters every time for every field can now be saved and automated. This free Agile Magento extension is one of the most useful to date.&#xD;
13
+ &#xD;
14
+ Further more, the agile grid filters you create and save can be used throughout various sections within the Magento system. Any grid in the system found within the admin panel, products, orders, invoices, or shipments can be preconfigured. You can then save these custom made filters for later use, on any filterable grid found in the Magento admin.&#xD;
15
+ &#xD;
16
+ The Magento Agile Grid Extension is perfect for custom reports. If your business faces constant changes and daily tweaks to performance or expectations, you will want to be able to filter grid views, custom made for your businesses target goals or to help safeguard against potential problems.&#xD;
17
+ &#xD;
18
+ Management will be able to preset these important filters for future use by other employees. Employees can then log into the system, hit the created custom filter, and understand exactly the concerns management had in mind. For instance, if a custom filter has been designed to show within a specific date range, how many products an individual or group of customers have purchased. You can then quickly ensure that expected sales are still being completed by quickly and easily applying your saved filter.&#xD;
19
+ &#xD;
20
+ The ability to save relative Date Ranges allows for monthly reports to be created that display all orders, and other actions; relative to the current date, using PHP&#x2019;s dateinterval syntax. PHP&#x2019;s date interval syntax is well documented here: http://php.net/manual/en/dateinterval.construct.php . As another example, perhaps you care to keep an eye on the monthly site content being created. Let&#x2019;s say you expected 8 pieces of content to be uploaded every month. With the custom made reporting system, you will be able to isolate specific date ranges for targeted pages that have been updated within the set time frame.&#xD;
21
+ &#xD;
22
+ In the end, the Mediotype Magento Agile Grid System increases the bottom line efficiency of report generation. Don&#x2019;t make your work harder than it has to be. Save time, energy, and increase the worth of the reports you create in the Magento system with Mediotype&#x2019;s Agile Grid for Magento.&#xD;
23
+ &#xD;
24
+ Features:&#xD;
25
+ &#x2022; Create Custom Filters&#xD;
26
+ &#x2022; Save Custom Created Filters&#xD;
27
+ &#x2022; Use Custom Filters On Every Filterable Grid in The Magento Admin&#xD;
28
+ &#x2022; Use Magento Agile Grid to reclaim your time&#xD;
29
+ </description>
30
+ <notes>0.1.0 Version Release -&#xD;
31
+ Allows saving filters on any and all filterable grids in the Magento admin.&#xD;
32
+ &#xD;
33
+ Allows use of PHP Date Interval Syntax&#xD;
34
+ http://php.net/manual/en/class.dateinterval.php&#xD;
35
+ To store filters by relative dates</notes>
36
+ <authors><author><name>Mediotype</name><user>mprototype</user><email>joel@mediotype.com</email></author></authors>
37
+ <date>2014-07-22</date>
38
+ <time>06:35:19</time>
39
+ <contents><target name="magecommunity"><dir name="Mediotype"><dir name="Core"><dir name="Block"><dir name="Entity"><dir name="Attribute"><dir name="Input"><dir name="Renderer"><file name="Datetime.php" hash="7a7f9b67564ca5fe454da4a3a232a018"/></dir></dir></dir></dir><file name="Instructions.php" hash="04bddba8179153bf4561c30f199f7c7d"/></dir><dir name="Controller"><dir name="Front"><file name="Action.php" hash="2992859e63b2583f0171bb0c27812728"/></dir></dir><file name="Exception.php" hash="3f61c426ca0a23493fe5d667e8af958f"/><dir name="Helper"><file name="Abstract.php" hash="18098231559b5a47391e118458159aef"/><file name="Acl.php" hash="a2a700880fec1eaae2f8babe1bf5b6c1"/><file name="Data.php" hash="1606aa4a3cefd95bf1fa5c3eb19c43c4"/><file name="Debugger.php" hash="5875f58d237646356c84f9e52c393edc"/><file name="Forms.php" hash="f8abbf8d5194ff817a0f037d126bd5ad"/><dir name="Mschema"><file name="Exception.php" hash="516688ec4c0c108075c100f3940b22a2"/><dir name="Validator"><file name="Abstract.php" hash="02f927e4655835227d365e7d1c042de4"/><file name="Cast.php" hash="81781870f0da508faf3aaf3db9d1d420"/><file name="Datatype.php" hash="136e140e8f024b3c6f9574f12a8e5fe9"/><file name="Parseavp.php" hash="5c37d5a8d7859d9651438b7080a8962d"/><file name="Regex.php" hash="739af99ed4cf7bb0df0f6fa0e1748217"/><file name="Strip.php" hash="82a89284b38a5c7bb9af25c32c4ad244"/><file name="Trim.php" hash="b8417398a3251b7d987bca07a40cab78"/><file name="Ucwords.php" hash="322f1b84b6c98bf7bafcf0b3ba1a5574"/></dir></dir><file name="Mschema.php" hash="4932b68a8005fb2c2a235583da6e4fa9"/><file name="XML.php" hash="ca059e790fe1a285ed3c6e5af669badf"/></dir><dir name="Model"><dir name="Entity"><dir name="Attribute"><dir name="Backend"><file name="Datetime.php" hash="002659350f7bd057ccd1a3070e74fa14"/></dir></dir></dir><dir name="Resource"><file name="Abstract.php" hash="eddcce6a2048687d5449f7868c065036"/><dir name="Db"><dir name="Collection"><file name="Abstract.php" hash="b6dff9fe723999aa1e0077c92f31d8d9"/></dir></dir></dir><file name="Response.php" hash="3bd3ed06a9f74ea2d3da1cb83bc089bd"/><dir name="Systems"><dir name="Api"><dir name="Json"><file name="Request.php" hash="874d7427bb9578282a779cca5c19b78d"/></dir></dir><file name="Magento.php" hash="6a41d7e0f85d9f05b97fcf3251ca4467"/></dir></dir><dir name="data"><dir name="mediotype_core"><file name="install-0.0.1.php" hash="935f0aad9e8f3c7d03adfba909d22d48"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="6cecd25a12b43efaa8b1ed1a6150da2b"/><file name="config.xml" hash="6455aac235aa47cd14646a2c77db144b"/><file name="system.xml" hash="971c32388d2f9233f605698b9a26ccf5"/></dir></dir><dir name="AgileGrid"><dir name="Block"><dir name="Adminhtml"><dir name="Original"><dir name="Block"><dir name="Widget"><file name="Grid.php" hash="bcb5d2804e610580ccee32d6947d5849"/></dir></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Filter"><file name="Date.php" hash="b0f2d592a80bbc8c93dce4357496e2ad"/><file name="Datetime.php" hash="6c423f8f29ddc73f49fd7e166350ab97"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="636a77d0585b855ad39b4400fca34506"/></dir><dir name="Model"><file name="Filter.php" hash="f692b1419fb9788c3b0a6808e47bf616"/><dir name="Resource"><dir name="Filter"><file name="Collection.php" hash="bf755c541e8597007e65c7a2334f8144"/></dir><file name="Filter.php" hash="8830a3c1fba74953fff459ea41262e55"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="FiltersController.php" hash="555488d619c29485332188c8bb52d56e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="cdac0af42b79fc9bae3920f519abca8e"/><file name="config.xml" hash="f71a0f6dc393085299e222c14faabad1"/></dir><dir name="sql"><dir name="Mediotype_AgileGrid_setup"><file name="install-0.1.0.php" hash="ffbbf7a0d44739e05f530ed84cec7a15"/></dir></dir></dir></dir><dir name="Mage"><dir name="Adminhtml"><dir name="Block"><dir name="Widget"><file name="Grid.php" hash="eed8f03a7f1491fa2a879aa41e7deddb"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><dir name="modules"><file name="Mediotype_Core.xml" hash="822fd6cc5a06ff062b7f8a51ca6c0e08"/><file name="Mediotype_AgileGrid.xml" hash="e9a2815c3b5fbf2d93df173480ce3367"/></dir></dir></target><target name="magedesign"><dir name="."><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mediotype"><dir name="core"><file name="grid.phtml" hash="b0c44cd30319b3c99d498756a8014d87"/></dir></dir></dir><dir name="layout"><dir name="mediotype-core"><file name="core.xml" hash="9b2cf0fa4ef635ed0857aaa0d3f8303e"/></dir><dir name="mediotype"><file name="AgileGrid.xml" hash=""/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="."><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="mediotype"><dir name="images"><file name="mediotype_section_logo.png" hash="26368eb8147fb10b2431ea47bfc6c18e"/></dir><file name="mediotype-adminhtml.css" hash="e5166d6f8ae713ddc5829d9159917990"/></dir></dir></dir></dir></dir></target></contents>
40
+ <compatible/>
41
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
42
+ </package>
skin/adminhtml/default/default/mediotype/images/mediotype_section_logo.png ADDED
Binary file
skin/adminhtml/default/default/mediotype/mediotype-adminhtml.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mediotype-section > dl > dt.label {
2
+ padding: .25em 0 0 0;
3
+ }
4
+
5
+ .mediotype-section > dl > dt.label {
6
+ background: url(images/mediotype_section_logo.png) no-repeat ;
7
+ height: 22px;
8
+ text-indent: -9999px;
9
+ border-bottom: 1px solid #3f3e3f;
10
+ }
11
+
12
+ .mediotype-section-description { background: #f4f9f5; padding: 1em 1em .5em 1em; margin: 10px 0; border: solid 1px #a92000; color: #3f3e3f }
13
+
14
+ /* This code is tested with latest version of Firefox and Chrome */
15
+ .mediotype-box {
16
+ position: relative;
17
+ width: 95%;
18
+ height: 200px;
19
+ background-color: #fff;
20
+ box-shadow: 0 1px 5px rgba(0,0,0,0.25), 0 0 50px rgba(0,0,0,0.1) inset;
21
+ border-radius: 1% 1% 1% 1% / 1% 1% 1% 1%;
22
+ }
23
+ .mediotype-box:before {
24
+ position: absolute;
25
+ width: 84%;
26
+ height: 29%;
27
+ left: 8%;
28
+ border-radius: 50%;
29
+ z-index: -1;
30
+ top: 0%;
31
+ content: "";
32
+ box-shadow: 0 -9px 40px rgba(0,0,0,0.3);
33
+ }
34
+ .mediotype-box:after {
35
+ position: absolute;
36
+ width: 84%;
37
+ height: 29%;
38
+ left: 8%;
39
+ border-radius: 50%;
40
+ z-index: -1;
41
+ bottom: 0%;
42
+ content: "";
43
+ box-shadow: 0 9px 40px rgba(0,0,0,0.3);
44
+ }