Phxsolution_Formbuilder - Version 0.1.0

Version Notes

Fixed some minor bugs.

Download this release

Release Info

Developer Prakash Vaniya
Extension Phxsolution_Formbuilder
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (68) hide show
  1. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder.php +38 -0
  2. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit.php +82 -0
  3. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Elements/Jscolorblock.php +46 -0
  4. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Form.php +44 -0
  5. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Fieldsgrid.php +147 -0
  6. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Form.php +189 -0
  7. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options.php +60 -0
  8. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Option.php +416 -0
  9. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/Date.php +37 -0
  10. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/File.php +37 -0
  11. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/Select.php +81 -0
  12. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/Text.php +38 -0
  13. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Recordsgrid.php +141 -0
  14. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tabs.php +66 -0
  15. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Grid.php +185 -0
  16. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Fieldtitle.php +38 -0
  17. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Formtitle.php +37 -0
  18. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Getoptions.php +48 -0
  19. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Image.php +41 -0
  20. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Numberoffields.php +40 -0
  21. app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Recordvalue.php +111 -0
  22. app/code/community/Phxsolution/Formbuilder/Block/Frontend/Date.php +178 -0
  23. app/code/community/Phxsolution/Formbuilder/Block/Frontend/File.php +44 -0
  24. app/code/community/Phxsolution/Formbuilder/Block/Frontend/Form.php +140 -0
  25. app/code/community/Phxsolution/Formbuilder/Block/Frontend/Formbuilder.php +34 -0
  26. app/code/community/Phxsolution/Formbuilder/Block/Frontend/Select.php +151 -0
  27. app/code/community/Phxsolution/Formbuilder/Block/Frontend/Text.php +43 -0
  28. app/code/community/Phxsolution/Formbuilder/Helper/Data.php +374 -0
  29. app/code/community/Phxsolution/Formbuilder/Model/Fields.php +255 -0
  30. app/code/community/Phxsolution/Formbuilder/Model/Forms.php +41 -0
  31. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Fields.php +34 -0
  32. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Fields/Collection.php +65 -0
  33. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Forms.php +34 -0
  34. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Forms/Collection.php +65 -0
  35. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Options.php +34 -0
  36. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Options/Collection.php +65 -0
  37. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Records.php +34 -0
  38. app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Records/Collection.php +65 -0
  39. app/code/community/Phxsolution/Formbuilder/Model/Observer.php +62 -0
  40. app/code/community/Phxsolution/Formbuilder/Model/Options.php +162 -0
  41. app/code/community/Phxsolution/Formbuilder/Model/Records.php +55 -0
  42. app/code/community/Phxsolution/Formbuilder/Model/Status.php +40 -0
  43. app/code/community/Phxsolution/Formbuilder/controllers/Adminhtml/FormbuilderController.php +409 -0
  44. app/code/community/Phxsolution/Formbuilder/controllers/IndexController.php +571 -0
  45. app/code/community/Phxsolution/Formbuilder/etc/config.xml +269 -0
  46. app/code/community/Phxsolution/Formbuilder/etc/system.xml +204 -0
  47. app/code/community/Phxsolution/Formbuilder/sql/formbuilder_setup/mysql4-install-0.1.0.php +114 -0
  48. app/design/adminhtml/default/default/layout/formbuilder.xml +83 -0
  49. app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options.phtml +57 -0
  50. app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/option.phtml +396 -0
  51. app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/date.phtml +51 -0
  52. app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/file.phtml +59 -0
  53. app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/select.phtml +172 -0
  54. app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/text.phtml +53 -0
  55. app/design/frontend/base/default/layout/formbuilder.xml +105 -0
  56. app/design/frontend/base/default/template/formbuilder/date.phtml +95 -0
  57. app/design/frontend/base/default/template/formbuilder/file.phtml +141 -0
  58. app/design/frontend/base/default/template/formbuilder/form.phtml +119 -0
  59. app/design/frontend/base/default/template/formbuilder/formbuilder.phtml +52 -0
  60. app/design/frontend/base/default/template/formbuilder/select.phtml +82 -0
  61. app/design/frontend/base/default/template/formbuilder/text.phtml +56 -0
  62. js/formbuilder/jscolor/arrow.gif +0 -0
  63. js/formbuilder/jscolor/cross.gif +0 -0
  64. js/formbuilder/jscolor/hs.png +0 -0
  65. js/formbuilder/jscolor/hv.png +0 -0
  66. js/formbuilder/jscolor/jscolor.js +997 -0
  67. package.xml +18 -0
  68. skin/frontend/base/default/css/formbuilder/custom.css +27 -0
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder extends Mage_Adminhtml_Block_Widget_Grid_Container
29
+ {
30
+ public function __construct()
31
+ {
32
+ $this->_controller = 'adminhtml_formbuilder';
33
+ $this->_blockGroup = 'formbuilder';
34
+ $this->_headerText = Mage::helper('formbuilder')->__('Form Builder');
35
+ $this->_addButtonLabel = Mage::helper('formbuilder')->__('Add Form');
36
+ parent::__construct();
37
+ }
38
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+
34
+ $this->_objectId = 'id';
35
+ $this->_blockGroup = 'formbuilder';
36
+ $this->_controller = 'adminhtml_formbuilder';
37
+
38
+ $this->_updateButton('save', 'label', Mage::helper('formbuilder')->__('Save Form'));
39
+ $this->_updateButton('delete', 'label', Mage::helper('formbuilder')->__('Delete Form'));
40
+
41
+ $this->_addButton('saveandcontinue', array(
42
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
43
+ 'onclick' => 'saveAndContinueEdit()',
44
+ 'class' => 'save',
45
+ ), -100);
46
+
47
+ $this->_formScripts[] = "
48
+ function toggleEditor() {
49
+ if (tinyMCE.getInstanceById('formbuilder_content') == null) {
50
+ tinyMCE.execCommand('mceAddControl', false, 'formbuilder_content');
51
+ } else {
52
+ tinyMCE.execCommand('mceRemoveControl', false, 'formbuilder_content');
53
+ }
54
+ }
55
+
56
+ function saveAndContinueEdit(){
57
+ editForm.submit($('edit_form').action+'back/edit/');
58
+ }
59
+ ";
60
+ }
61
+ protected function _prepareLayout()
62
+ {
63
+ parent::_prepareLayout();
64
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
65
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
66
+ }
67
+ }
68
+ public function getHeaderText()
69
+ {
70
+ if( Mage::registry('formbuilder_data') && Mage::registry('formbuilder_data')->getFormsIndex() )
71
+ {
72
+ $currentFormId = Mage::registry('formbuilder_data')->getFormsIndex();
73
+ Mage::getSingleton('core/session')->setCurrentFormId($currentFormId);
74
+ return Mage::helper('formbuilder')->__("Edit Form '%s'", $this->htmlEscape(Mage::registry('formbuilder_data')->getTitle()));
75
+ }
76
+ else
77
+ {
78
+ Mage::getSingleton('core/session')->setCurrentFormId(0);
79
+ return Mage::helper('formbuilder')->__('Add Form');
80
+ }
81
+ }
82
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Elements/Jscolorblock.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Edit_Elements_Jscolorblock extends Varien_Data_Form_Element_Text
29
+ {
30
+ protected function _getElementHtml( Varien_Data_Form_Element_Abstract $element )
31
+ {
32
+ $color = new Varien_Data_Form_Element_Text();
33
+ $data = array(
34
+ 'name' => $element->getName(),
35
+ 'html_id' => $element->getId(),
36
+ );
37
+ $color->setData( $data );
38
+ $color->setValue( $element->getValue(), $format );
39
+ $color->setForm( $element->getForm() );
40
+ $color->addClass( 'color ' . $element->getClass() );
41
+
42
+ return $color->getElementHtml();
43
+ }
44
+ }
45
+ //Elements_Jscolorblock
46
+ //<input class="color {required:false, adjust:false, hash:true}">
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Form.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
29
+ {
30
+ protected function _prepareForm()
31
+ {
32
+ $form = new Varien_Data_Form(array(
33
+ 'id' => 'edit_form',
34
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
35
+ 'method' => 'post',
36
+ 'enctype' => 'multipart/form-data'
37
+ )
38
+ );
39
+
40
+ $form->setUseContainer(true);
41
+ $this->setForm($form);
42
+ return parent::_prepareForm();
43
+ }
44
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Fieldsgrid.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Fieldsgrid extends Mage_Adminhtml_Block_Widget_Grid
29
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
30
+ {
31
+ public function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->setId('expert_advice_grid');
35
+ $this->setDefaultSort('sort_order');
36
+ $this->setDefaultDir('ASC');
37
+ //enable ajax grid
38
+ $this->setUseAjax(true);
39
+ $this->setSaveParametersInSession(true);
40
+ }
41
+ protected function _prepareCollection()
42
+ {
43
+ //$collection = Mage::helper('formbuilder')->getcurrentFormFieldsCollection();
44
+ $currentFormId = Mage::getSingleton('core/session')->getCurrentFormId();
45
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
46
+ $collection = $fieldsModel->getcurrentFormFieldsCollection($currentFormId);
47
+ $this->setCollection($collection);
48
+ return parent::_prepareCollection();
49
+ }
50
+ protected function _prepareColumns()
51
+ {
52
+ $this->addColumn('fields_index', array(
53
+ 'header' => Mage::helper('formbuilder')->__('ID'),
54
+ 'width' => '25px',
55
+ 'align' => 'left',
56
+ 'index' => 'fields_index',
57
+ ));
58
+ /*$this->addColumn('forms_index', array(
59
+ 'header' => Mage::helper('formbuilder')->__('Form'),
60
+ 'align' => 'left',
61
+ 'index' => 'forms_index',
62
+ 'renderer' => 'formbuilder/adminhtml_formbuilder_renderer_formtitle'
63
+ ));*/
64
+ $this->addColumn('title', array(
65
+ 'header' => Mage::helper('formbuilder')->__('Title'),
66
+ 'width' => '250px',
67
+ 'align' => 'left',
68
+ 'index' => 'title',
69
+ ));
70
+ $this->addColumn('previous_group', array(
71
+ 'header' => Mage::helper('formbuilder')->__('Input Type'),
72
+ 'width' => '50px',
73
+ 'align' => 'left',
74
+ 'index' => 'previous_group',
75
+ ));
76
+ $this->addColumn('type', array(
77
+ 'header' => Mage::helper('formbuilder')->__('Sub Type'),
78
+ 'width' => '50px',
79
+ 'align' => 'left',
80
+ 'index' => 'type',
81
+ ));
82
+ $this->addColumn('options', array(
83
+ 'header' => Mage::helper('formbuilder')->__('Options'),
84
+ 'width' => '200px',
85
+ 'align' => 'left',
86
+ 'index' => 'options',
87
+ 'renderer' => 'formbuilder/adminhtml_formbuilder_renderer_getoptions'
88
+ ));
89
+ $this->addColumn('is_require', array(
90
+ 'header' => Mage::helper('formbuilder')->__('Is Required'),
91
+ 'width' => '25px',
92
+ 'align' => 'left',
93
+ 'index' => 'is_require',
94
+ 'type' => 'options',
95
+ 'options' => array(
96
+ 1 => 'Yes',
97
+ 0 => 'No',
98
+ ),
99
+ ));
100
+ $this->addColumn('sort_order', array(
101
+ 'header' => Mage::helper('formbuilder')->__('Sort Order'),
102
+ 'width' => '25px',
103
+ 'align' => 'left',
104
+ 'index' => 'sort_order',
105
+ ));
106
+ $this->addColumn('max_characters', array(
107
+ 'header' => Mage::helper('formbuilder')->__('Max Characters'),
108
+ 'width' => '25px',
109
+ 'align' => 'left',
110
+ 'index' => 'max_characters',
111
+ ));
112
+ $this->addColumn('status', array(
113
+ 'header' => Mage::helper('formbuilder')->__('Status'),
114
+ 'width' => '25px',
115
+ 'align' => 'left',
116
+ 'index' => 'status',
117
+ 'type' => 'options',
118
+ 'options' => array(
119
+ 1 => 'Enabled',
120
+ 0 => 'Disabled',
121
+ ),
122
+ ));
123
+
124
+ return parent::_prepareColumns();
125
+ }
126
+ //this method is reuired if you want ajax grid
127
+ public function getGridUrl()
128
+ {
129
+ return $this->getUrl('*/*/fieldsgrid', array('_current' => true));
130
+ }
131
+ public function canShowTab()
132
+ {
133
+ return true;
134
+ }
135
+ public function isHidden()
136
+ {
137
+ return false;
138
+ }
139
+ public function getTabLabel()
140
+ {
141
+ return $this->__('Fields List');
142
+ }
143
+ public function getTabTitle()
144
+ {
145
+ return $this->__('Fields List');
146
+ }
147
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Form.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
29
+ {
30
+ protected function _prepareForm()
31
+ {
32
+ $model = Mage::registry('formbuilder_data');
33
+
34
+ if($model->getStores())
35
+ {
36
+ //$_model->setPageId(Mage::helper('core')->jsonDecode($_model->getPageId()));
37
+ $model->setStores(explode(',',$model->getStores()));
38
+ }
39
+ $form = new Varien_Data_Form();
40
+ $this->setForm($form);
41
+ $fieldset = $form->addFieldset('formbuilder_form', array('legend'=>Mage::helper('formbuilder')->__('Form Information')));
42
+ $fieldset->addType('bgcolor', 'Phxsolution_Formbuilder_Block_Adminhtml_Edit_Elements_Jscolorblock');
43
+ //$fieldset->addType('procolorblock', 'Phxsolution_Formbuilder_Block_Adminhtml_Edit_Elements_Procolorblock');
44
+
45
+ /*$fieldset->addField('some_field', 'text', array(
46
+ 'label' => Mage::helper('core')->__('Some label'),
47
+ 'name' => 'some_name',
48
+ 'after_element_html' => '<button type="button" onclick="alert(\'Stop clicking me!!\')">Do not click</button>'
49
+ ));*/
50
+ $fieldset->addField('title', 'text', array(
51
+ 'label' => Mage::helper('formbuilder')->__('Title'),
52
+ 'class' => 'required-entry',
53
+ 'required' => true,
54
+ 'name' => 'title',
55
+ ));
56
+ $fieldset->addField('bgcolor','text',array(
57
+ 'label' => Mage::helper('formbuilder')->__('Form Background Color'),
58
+ 'name' => 'bgcolor',
59
+ 'class' => 'color {required:false, adjust:true, hash:true}',
60
+ 'style' => 'width:75px;',
61
+ ));
62
+ /*$fieldset->addField('procolorblock','text',array(
63
+ 'label' => Mage::helper('formbuilder')->__('Form Color 2'),
64
+ 'required' => true,
65
+ 'name' => 'procolorblock',
66
+ 'class' => 'color {required:false, adjust:true, hash:true}',
67
+ 'value' => '#150150'
68
+ ));*/
69
+ /*$fieldset->addField('date', 'date', array(
70
+ 'name' => 'date',
71
+ 'label' => Mage::helper('formbuilder')->__('Date'),
72
+ 'after_element_html' => '<small>Comments</small>',
73
+ 'tabindex' => 1,
74
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
75
+ 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ,
76
+ 'value' => date( Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
77
+ strtotime('next weekday') )
78
+ ));*/
79
+ $fieldset->addField('title_image', 'image', array(
80
+ 'label' => Mage::helper('formbuilder')->__('Title Image'),
81
+ 'name' => 'title_image',
82
+ 'note' => '(*.jpg, *.png, *.gif)',
83
+ ));
84
+ $fieldset->addField('header_content', 'editor', array(
85
+ 'name' => 'header_content',
86
+ 'label' => Mage::helper('formbuilder')->__('Content Before Form'),
87
+ 'title' => Mage::helper('formbuilder')->__('Content Before Form'),
88
+ 'style' => 'height:15em',
89
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
90
+ 'wysiwyg' => true,
91
+ 'required' => false,
92
+ ));
93
+ $fieldset->addField('footer_content', 'editor', array(
94
+ 'name' => 'footer_content',
95
+ 'label' => Mage::helper('formbuilder')->__('Content After Form'),
96
+ 'title' => Mage::helper('formbuilder')->__('Content After Form'),
97
+ 'style' => 'height:15em',
98
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
99
+ 'wysiwyg' => true,
100
+ 'required' => false,
101
+ ));
102
+ if (!Mage::app()->isSingleStoreMode())
103
+ {
104
+ $field = $fieldset->addField('stores', 'multiselect', array(
105
+ 'name' => 'stores[]',
106
+ 'label' => Mage::helper('cms')->__('Store View'),
107
+ 'title' => Mage::helper('cms')->__('Store View'),
108
+ 'required' => true,
109
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
110
+ 'value' => $model->getStores()
111
+ //'value' => array('0'=>'1','1'=>'2'),
112
+ ));
113
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
114
+ $field->setRenderer($renderer);
115
+ }
116
+ else
117
+ {
118
+ $fieldset->addField('stores', 'hidden', array(
119
+ 'name' => 'stores[]',
120
+ 'value' => Mage::app()->getStore(true)->getId()
121
+ ));
122
+ $model->setStores(Mage::app()->getStore(true)->getId());
123
+ }
124
+ $fieldset->addField('success_msg', 'text', array(
125
+ 'label' => Mage::helper('formbuilder')->__('Success Message'),
126
+ 'name' => 'success_msg',
127
+ 'style' => 'width:500px;',
128
+ ));
129
+ $fieldset->addField('failure_msg', 'text', array(
130
+ 'label' => Mage::helper('formbuilder')->__('Failure Message'),
131
+ 'name' => 'failure_msg',
132
+ 'style' => 'width:500px;',
133
+ ));
134
+ $fieldset->addField('submit_text', 'text', array(
135
+ 'label' => Mage::helper('formbuilder')->__('Submit Button Text'),
136
+ 'name' => 'submit_text',
137
+ ));
138
+ $fieldset->addField('in_menu', 'select', array(
139
+ 'label' => Mage::helper('formbuilder')->__('Display in Menu'),
140
+ 'name' => 'in_menu',
141
+ 'values' => array(
142
+ array(
143
+ 'value' => 1,
144
+ 'label' => Mage::helper('formbuilder')->__('Yes'),
145
+ ),
146
+ array(
147
+ 'value' => 2,
148
+ 'label' => Mage::helper('formbuilder')->__('No'),
149
+ ),
150
+ ),
151
+ ));
152
+ /*$fieldset->addField('in_toplinks', 'select', array(
153
+ 'label' => Mage::helper('formbuilder')->__('Display in Toplinks'),
154
+ 'name' => 'in_toplinks',
155
+ 'values' => array(
156
+ array(
157
+ 'value' => 1,
158
+ 'label' => Mage::helper('formbuilder')->__('Yes'),
159
+ ),
160
+ array(
161
+ 'value' => 2,
162
+ 'label' => Mage::helper('formbuilder')->__('No'),
163
+ ),
164
+ ),
165
+ ));*/
166
+ $fieldset->addField('status', 'select', array(
167
+ 'label' => Mage::helper('formbuilder')->__('Is Active'),
168
+ 'name' => 'status',
169
+ 'values' => array(
170
+ array(
171
+ 'value' => 1,
172
+ 'label' => Mage::helper('formbuilder')->__('Yes'),
173
+ ),
174
+ array(
175
+ 'value' => 2,
176
+ 'label' => Mage::helper('formbuilder')->__('No'),
177
+ ),
178
+ ),
179
+ ));
180
+ if (Mage::getSingleton('adminhtml/session')->getFormData())
181
+ {
182
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getFormData());
183
+ Mage::getSingleton('adminhtml/session')->setFormData(null);
184
+ } elseif ( Mage::registry('formbuilder_data') ) {
185
+ $form->setValues(Mage::registry('formbuilder_data')->getData());
186
+ }
187
+ return parent::_prepareForm();
188
+ }
189
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ //class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget
29
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options
30
+ {
31
+ public function __construct()
32
+ {
33
+ parent::__construct();
34
+ $this->setTemplate('formbuilder/catalog/product/edit/options.phtml');
35
+ }
36
+ protected function _prepareLayout()
37
+ {
38
+ parent::_prepareLayout();
39
+ $this->setChild('add_button',
40
+ $this->getLayout()->createBlock('adminhtml/widget_button')
41
+ ->setData(array(
42
+ 'label' => Mage::helper('catalog')->__('Add New Field'),
43
+ 'class' => 'add',
44
+ 'id' => 'add_new_defined_option'
45
+ ))
46
+ );
47
+
48
+ $this->setChild('options_box',
49
+ $this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tab_options_option')
50
+ );
51
+ }
52
+ /*public function getAddButtonHtml()
53
+ {
54
+ return $this->getChildHtml('add_button');
55
+ }
56
+ public function getOptionsBoxHtml()
57
+ {
58
+ return $this->getChildHtml('options_box');
59
+ }*/
60
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Option.php ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Option extends Mage_Adminhtml_Block_Widget
29
+ //class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Option extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
30
+ {
31
+ protected $_product;
32
+
33
+ protected $_productInstance;
34
+
35
+ protected $_values;
36
+ protected $_values2;
37
+
38
+ protected $_itemCount = 1;
39
+
40
+ /**
41
+ * Class constructor
42
+ */
43
+ public function __construct()
44
+ {
45
+ parent::__construct();
46
+ $this->setTemplate('formbuilder/catalog/product/edit/options/option.phtml');
47
+ $this->setCanReadPrice(false);
48
+ $this->setCanEditPrice(false);
49
+ }
50
+ public function getItemCount()
51
+ {
52
+ return $this->_itemCount;
53
+ }
54
+ public function setItemCount($itemCount)
55
+ {
56
+ $this->_itemCount = max($this->_itemCount, $itemCount);
57
+ return $this;
58
+ }
59
+ /**
60
+ * Get Product
61
+ *
62
+ * @return Mage_Catalog_Model_Product
63
+ */
64
+ public function getProduct()
65
+ {
66
+ if (!$this->_productInstance) {
67
+ if ($product = Mage::registry('product')) {
68
+ $this->_productInstance = $product;
69
+ } else {
70
+ $this->_productInstance = Mage::getSingleton('catalog/product');
71
+ }
72
+ }
73
+
74
+ return $this->_productInstance;
75
+ }
76
+ public function setProduct($product)
77
+ {
78
+ $this->_productInstance = $product;
79
+ return $this;
80
+ }
81
+ /**
82
+ * Retrieve options field name prefix
83
+ *
84
+ * @return string
85
+ */
86
+ public function getFieldName()
87
+ {
88
+ return 'product[options]';
89
+ }
90
+ /**
91
+ * Retrieve options field id prefix
92
+ *
93
+ * @return string
94
+ */
95
+ public function getFieldId()
96
+ {
97
+ return 'product_option';
98
+ }
99
+ /**
100
+ * Check block is readonly
101
+ *
102
+ * @return boolean
103
+ */
104
+ public function isReadonly()
105
+ {
106
+ return $this->getProduct()->getOptionsReadonly();
107
+ }
108
+ protected function _prepareLayout()
109
+ {
110
+ $this->setChild('delete_button',
111
+ $this->getLayout()->createBlock('adminhtml/widget_button')
112
+ ->setData(array(
113
+ 'label' => Mage::helper('catalog')->__('Delete Field'),
114
+ 'class' => 'delete delete-product-option '
115
+ ))
116
+ );
117
+
118
+ $path = 'global/catalog/product/options/custom/groups';
119
+
120
+ foreach (Mage::getConfig()->getNode($path)->children() as $group) {
121
+ $this->setChild($group->getName() . '_option_type',
122
+ $this->getLayout()->createBlock(
123
+ (string) Mage::getConfig()->getNode($path . '/' . $group->getName() . '/render')
124
+ )
125
+ );
126
+ }
127
+ return parent::_prepareLayout();
128
+ }
129
+ public function getAddButtonId()
130
+ {
131
+ $buttonId = $this->getLayout()
132
+ ->getBlock('admin.product.options')
133
+ ->getChild('add_button')->getId();
134
+ return $buttonId;
135
+ }
136
+ public function getDeleteButtonHtml()
137
+ {
138
+ return $this->getChildHtml('delete_button');
139
+ }
140
+ public function getTypeSelectHtml()
141
+ {
142
+ $select = $this->getLayout()->createBlock('adminhtml/html_select')
143
+ ->setData(array(
144
+ 'id' => $this->getFieldId().'_{{id}}_type',
145
+ 'class' => 'select select-product-option-type required-option-select'
146
+ ))
147
+ ->setName($this->getFieldName().'[{{id}}][type]')
148
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_product_options_type')->toOptionArray());
149
+
150
+ return $select->getHtml();
151
+ }
152
+ public function getStatusHtml()
153
+ {
154
+ $select = $this->getLayout()->createBlock('adminhtml/html_select')
155
+ ->setData(array(
156
+ 'id' => $this->getFieldId().'_{{id}}_field_status',
157
+ 'class' => 'select'
158
+ ))
159
+ ->setName($this->getFieldName().'[{{id}}][field_status]')
160
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray());
161
+
162
+ return $select->getHtml();
163
+ }
164
+ public function getRequireSelectHtml()
165
+ {
166
+ $select = $this->getLayout()->createBlock('adminhtml/html_select')
167
+ ->setData(array(
168
+ 'id' => $this->getFieldId().'_{{id}}_is_require',
169
+ 'class' => 'select'
170
+ ))
171
+ ->setName($this->getFieldName().'[{{id}}][is_require]')
172
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray());
173
+
174
+ return $select->getHtml();
175
+ }
176
+ /**
177
+ * Retrieve html templates for different types of product custom options
178
+ *
179
+ * @return string
180
+ */
181
+ public function getTemplatesHtml()
182
+ {
183
+ $canEditPrice = $this->getCanEditPrice();
184
+ $canReadPrice = $this->getCanReadPrice();
185
+ $this->getChild('select_option_type')
186
+ ->setCanReadPrice($canReadPrice)
187
+ ->setCanEditPrice($canEditPrice);
188
+
189
+ $this->getChild('file_option_type')
190
+ ->setCanReadPrice($canReadPrice)
191
+ ->setCanEditPrice($canEditPrice);
192
+
193
+ $this->getChild('date_option_type')
194
+ ->setCanReadPrice($canReadPrice)
195
+ ->setCanEditPrice($canEditPrice);
196
+
197
+ $this->getChild('text_option_type')
198
+ ->setCanReadPrice($canReadPrice)
199
+ ->setCanEditPrice($canEditPrice);
200
+
201
+ $templates = $this->getChildHtml('text_option_type') . "\n" .
202
+ $this->getChildHtml('file_option_type') . "\n" .
203
+ $this->getChildHtml('select_option_type') . "\n" .
204
+ $this->getChildHtml('date_option_type');
205
+
206
+ return $templates;
207
+ }
208
+ public function getOptionValues()
209
+ {
210
+ $optionsArr = array_reverse($this->getProduct()->getOptions(), true);
211
+ //$optionsArr = $this->getProduct()->getOptions();
212
+
213
+ if (!$this->_values)
214
+ {
215
+ $showPrice = $this->getCanReadPrice();
216
+ $values = array();
217
+ $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
218
+ foreach ($optionsArr as $option)
219
+ {
220
+ /* @var $option Mage_Catalog_Model_Product_Option */
221
+
222
+ $this->setItemCount($option->getOptionId());
223
+
224
+ $value = array();
225
+
226
+ $value['id'] = $option->getOptionId();
227
+ $value['item_count'] = $this->getItemCount();
228
+ $value['option_id'] = $option->getOptionId();
229
+ $value['title'] = $this->escapeHtml($option->getTitle());
230
+ $value['type'] = $option->getType();
231
+ $value['is_require'] = $option->getIsRequire();
232
+ $value['sort_order'] = $option->getSortOrder();
233
+ $value['can_edit_price'] = $this->getCanEditPrice();
234
+
235
+ if ($this->getProduct()->getStoreId() != '0')
236
+ {
237
+ $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title',
238
+ is_null($option->getStoreTitle()));
239
+ $value['scopeTitleDisabled'] = is_null($option->getStoreTitle())?'disabled':null;
240
+ }
241
+ if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT)
242
+ {
243
+ //$valuesArr = array_reverse($option->getValues(), true);
244
+
245
+ $i = 0;
246
+ $itemCount = 0;
247
+ foreach ($option->getValues() as $_value)
248
+ {
249
+ /* @var $_value Mage_Catalog_Model_Product_Option_Value */
250
+ $value['optionValues'][$i] = array(
251
+ 'item_count' => max($itemCount, $_value->getOptionTypeId()),
252
+ 'option_id' => $_value->getOptionId(),
253
+ 'option_type_id' => $_value->getOptionTypeId(),
254
+ 'title' => $this->escapeHtml($_value->getTitle()),
255
+ 'price' => ($showPrice)
256
+ ? $this->getPriceValue($_value->getPrice(), $_value->getPriceType()) : '',
257
+ 'price_type' => ($showPrice) ? $_value->getPriceType() : 0,
258
+ 'sku' => $this->escapeHtml($_value->getSku()),
259
+ 'sort_order' => $_value->getSortOrder(),
260
+ );
261
+
262
+ if ($this->getProduct()->getStoreId() != '0')
263
+ {
264
+ $value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
265
+ $_value->getOptionId(), 'title', is_null($_value->getStoreTitle()),
266
+ $_value->getOptionTypeId());
267
+ $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle())
268
+ ? 'disabled' : null;
269
+ if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE)
270
+ {
271
+ $value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
272
+ $_value->getOptionId(), 'price', is_null($_value->getstorePrice()),
273
+ $_value->getOptionTypeId());
274
+ $value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice())
275
+ ? 'disabled' : null;
276
+ }
277
+ }
278
+ $i++;
279
+ }
280
+ }
281
+ else
282
+ {
283
+ $value['price'] = ($showPrice)
284
+ ? $this->getPriceValue($option->getPrice(), $option->getPriceType()) : '';
285
+ $value['price_type'] = $option->getPriceType();
286
+ $value['sku'] = $this->escapeHtml($option->getSku());
287
+ $value['max_characters'] = $option->getMaxCharacters();
288
+ $value['file_extension'] = $option->getFileExtension();
289
+ $value['image_size_x'] = $option->getImageSizeX();
290
+ $value['image_size_y'] = $option->getImageSizeY();
291
+ if ($this->getProduct()->getStoreId() != '0' &&
292
+ $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE)
293
+ {
294
+ $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(),
295
+ 'price', is_null($option->getStorePrice()));
296
+ $value['scopePriceDisabled'] = is_null($option->getStorePrice())?'disabled':null;
297
+ }
298
+ }
299
+ $values[] = new Varien_Object($value);
300
+ }// foreach ($optionsArr as $option)
301
+ $this->_values = $values;
302
+ }// if (!$this->_values)
303
+
304
+
305
+
306
+
307
+
308
+ if($this->_values) // if product-id found then
309
+ return $this->_values; // return custom options collection of current product
310
+ else // else return formbuilder custom options collection of current form
311
+ {
312
+ $currentFormId = Mage::getSingleton('core/session')->getCurrentFormId();
313
+ if($currentFormId)
314
+ {
315
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
316
+ $fieldsCollection = $fieldsModel->getFieldsCollection($currentFormId);
317
+ $fieldsCollection->setOrder('field_id','asc');
318
+
319
+ if (!$this->_values2)
320
+ {
321
+ $values2 = array();
322
+ foreach ($fieldsCollection as $key => $field)
323
+ {
324
+ //if($field['forms_index']==$currentFormId && !$field['is_delete'])
325
+ if(!$field['is_delete'])
326
+ {
327
+ $value2 = array();
328
+ $value2['id'] = $field['field_id'];
329
+ $value2['item_count'] = $field['field_id'];
330
+ $value2['option_id'] = $field['field_id'];
331
+ $value2['title'] = $field['title'];
332
+ //$value2['previous_group'] = $field['previous_group'];
333
+ $value2['type'] = $field['type'];
334
+ $value2['is_require'] = $field['is_require'];
335
+ $value2['field_status'] = $field['status'];
336
+ $value2['sort_order'] = $field['sort_order'];
337
+ $value2['can_edit_price'] = 1;
338
+ if($field['previous_group']=='text')
339
+ {
340
+ $value2['price'] = 0.00;
341
+ $value2['price_type'] = 'fixed';
342
+ $value2['sku'] = '';
343
+ $value2['max_characters'] = $field['max_characters'];
344
+ $value2['image_size_x'] = $field['image_size_x'];
345
+ $value2['image_size_y'] = $field['image_size_y'];
346
+ }
347
+ elseif($field['previous_group']=='file')
348
+ $value2['file_extension'] = $field['file_extension'];
349
+ if($field['previous_group']=='select')
350
+ {
351
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
352
+ $optionsCollection = $optionsModel->getOptionsCollection( $field['fields_index'] );
353
+ //$optionsCollection = Mage::getModel('formbuilder/options')->getCollection();
354
+ $i=0;
355
+ foreach ($optionsCollection as $key => $option)
356
+ {
357
+ //if($field['fields_index']==$option['fields_index'])
358
+ //{
359
+ $value2['optionValues'][$i]['item_count'] = $option['option_id'];
360
+ $value2['optionValues'][$i]['option_id'] = $field['field_id'];
361
+ $value2['optionValues'][$i]['option_type_id'] = $option['option_id'];
362
+ $value2['optionValues'][$i]['title'] = $option['title'];
363
+ $value2['optionValues'][$i]['price'] = 0.00;
364
+ $value2['optionValues'][$i]['price_type'] = 'fixed';
365
+ $value2['optionValues'][$i]['sku'] = '';
366
+ $value2['optionValues'][$i]['sort_order'] = $option['sort_order'];
367
+ $i++;
368
+ //}
369
+ }
370
+ }
371
+ $values2[] = new Varien_Object($value2);
372
+ }
373
+ }
374
+ return $this->_values2 = $values2;
375
+ }
376
+ }
377
+ }
378
+ }
379
+ /**
380
+ * Retrieve html of scope checkbox
381
+ *
382
+ * @param string $id
383
+ * @param string $name
384
+ * @param boolean $checked
385
+ * @param string $select_id
386
+ * @return string
387
+ */
388
+ public function getCheckboxScopeHtml($id, $name, $checked=true, $select_id='-1')
389
+ {
390
+ $checkedHtml = '';
391
+ if ($checked) {
392
+ $checkedHtml = ' checked="checked"';
393
+ }
394
+ $selectNameHtml = '';
395
+ $selectIdHtml = '';
396
+ if ($select_id != '-1') {
397
+ $selectNameHtml = '[values][' . $select_id . ']';
398
+ $selectIdHtml = 'select_' . $select_id . '_';
399
+ }
400
+ $checkbox = '<input type="checkbox" id="' . $this->getFieldId() . '_' . $id . '_' .
401
+ $selectIdHtml . $name . '_use_default" class="product-option-scope-checkbox" name="' .
402
+ $this->getFieldName() . '['.$id.']' . $selectNameHtml . '[scope][' . $name . ']" value="1" ' .
403
+ $checkedHtml . '/>';
404
+ $checkbox .= '<label class="normal" for="' . $this->getFieldId() . '_' . $id . '_' .
405
+ $selectIdHtml . $name . '_use_default">' . $this->__('Use Default Value') . '</label>';
406
+ return $checkbox;
407
+ }
408
+ public function getPriceValue($value, $type)
409
+ {
410
+ if ($type == 'percent') {
411
+ return number_format($value, 2, null, '');
412
+ } elseif ($type == 'fixed') {
413
+ return number_format($value, 2, null, '');
414
+ }
415
+ }
416
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/Date.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_Date extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Date
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $isProductEdit = Mage::helper('formbuilder')->isProductEdit();
34
+ if(!$isProductEdit)
35
+ $this->setTemplate('formbuilder/catalog/product/edit/options/type/date.phtml');
36
+ }
37
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/File.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_File extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_File
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $isProductEdit = Mage::helper('formbuilder')->isProductEdit();
34
+ if(!$isProductEdit)
35
+ $this->setTemplate('formbuilder/catalog/product/edit/options/type/file.phtml');
36
+ }
37
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/Select.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_Select extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select
29
+ {
30
+ /**
31
+ * Class constructor
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ $isProductEdit = Mage::helper('formbuilder')->isProductEdit();
37
+ if(!$isProductEdit)
38
+ $this->setTemplate('formbuilder/catalog/product/edit/options/type/select.phtml');
39
+
40
+ $this->setCanEditPrice(false);
41
+ $this->setCanReadPrice(false);
42
+ }
43
+ protected function _prepareLayout()
44
+ {
45
+ $this->setChild('add_select_row_button',
46
+ $this->getLayout()->createBlock('adminhtml/widget_button')
47
+ ->setData(array(
48
+ 'label' => Mage::helper('catalog')->__('Add New Rowwww'),
49
+ 'class' => 'add add-select-row',
50
+ 'id' => 'add_select_row_button_{{option_id}}'
51
+ ))
52
+ );
53
+
54
+ $this->setChild('delete_select_row_button',
55
+ $this->getLayout()->createBlock('adminhtml/widget_button')
56
+ ->setData(array(
57
+ 'label' => Mage::helper('catalog')->__('Delete Row'),
58
+ 'class' => 'delete delete-select-row icon-btn',
59
+ 'id' => 'delete_select_row_button'
60
+ ))
61
+ );
62
+
63
+ return parent::_prepareLayout();
64
+ }
65
+ public function getAddButtonHtml()
66
+ {
67
+ return $this->getChildHtml('add_select_row_button');
68
+ }
69
+ public function getDeleteButtonHtml()
70
+ {
71
+ return $this->getChildHtml('delete_select_row_button');
72
+ }
73
+ public function getPriceTypeSelectHtml()
74
+ {
75
+ $this->getChild('option_price_type')
76
+ ->setData('id', 'product_option_{{id}}_select_{{select_id}}_price_type')
77
+ ->setName('product[options][{{id}}][values][{{select_id}}][price_type]');
78
+
79
+ return parent::getPriceTypeSelectHtml();
80
+ }
81
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Options/Type/Text.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ //Mage_Adminhtml_Block_Template
29
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_Text extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Text
30
+ {
31
+ public function __construct()
32
+ {
33
+ parent::__construct();
34
+ $isProductEdit = Mage::helper('formbuilder')->isProductEdit();
35
+ if(!$isProductEdit)
36
+ $this->setTemplate('formbuilder/catalog/product/edit/options/type/text.phtml');
37
+ }
38
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tab/Recordsgrid.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Recordsgrid extends Mage_Adminhtml_Block_Widget_Grid
29
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
30
+ {
31
+ public function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->setId('records_grid');
35
+ $this->setDefaultSort('records_index');
36
+ $this->setDefaultDir('ASC');
37
+ //enable ajax grid
38
+ $this->setUseAjax(true);
39
+ $this->setSaveParametersInSession(true);
40
+ }
41
+ protected function _prepareCollection()
42
+ {
43
+ /*if(!Mage::helper('formbuilder')->isEnabled())
44
+ {
45
+ Mage::getSingleton('adminhtml/session')->addError('Extension is disabled');
46
+ return;
47
+ }*/
48
+ $currentFormId = $this->getRequest()->getParam('id');
49
+ $recordsModel = Mage::helper('formbuilder')->getRecordsModel();
50
+ $collection = $recordsModel->getRecordsCollection($currentFormId);
51
+ $this->setCollection($collection);
52
+ return parent::_prepareCollection();
53
+ }
54
+ protected function _prepareColumns()
55
+ {
56
+ //$titleArray = array(8=>'First Name',9=>'Last Name',10=>'12th Result');
57
+ $currentFormId = $this->getRequest()->getParam('id');
58
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
59
+ $prepareFieldTitles = array();
60
+ $prepareFieldTitles = $fieldsModel->prepareFieldTitles($currentFormId);
61
+
62
+ /*echo "<pre>";
63
+ print_r($prepareFieldTitles);
64
+ echo "</pre>";*/
65
+
66
+ if(count($prepareFieldTitles))
67
+ {
68
+ $this->addColumn('records_index', array(
69
+ 'header' => Mage::helper('formbuilder')->__('ID'),
70
+ 'align' => 'left',
71
+ 'index' => 'records_index',
72
+ ));
73
+ $this->addColumn('customer', array(
74
+ 'header' => Mage::helper('formbuilder')->__('Customer'),
75
+ 'align' => 'left',
76
+ 'index' => 'customer',
77
+ ));
78
+ $i=1;
79
+ foreach ($prepareFieldTitles as $fieldId => $fieldTitle)
80
+ {
81
+ $this->addColumn($fieldId, array(
82
+ 'header' => Mage::helper('formbuilder')->__($fieldTitle),
83
+ 'align' => 'left',
84
+ 'name' => $i++,
85
+ 'index' => $fieldId,
86
+ 'renderer' => 'formbuilder/adminhtml_formbuilder_renderer_recordvalue'
87
+ ));
88
+ }
89
+ }
90
+
91
+
92
+ /*$this->addColumn('records_index', array(
93
+ 'header' => Mage::helper('formbuilder')->__('ID'),
94
+ 'align' => 'left',
95
+ 'index' => 'records_index',
96
+ ));
97
+ $this->addColumn('forms_index', array(
98
+ 'header' => Mage::helper('formbuilder')->__('FORM'),
99
+ 'align' => 'left',
100
+ 'index' => 'forms_index',
101
+ ));
102
+ $this->addColumn('fields_index', array(
103
+ 'header' => Mage::helper('formbuilder')->__('FIELD ID'),
104
+ 'align' => 'left',
105
+ 'index' => 'fields_index',
106
+ 'renderer' => 'formbuilder/adminhtml_formbuilder_renderer_fieldtitle'
107
+ ));
108
+ $this->addColumn('options_index', array(
109
+ 'header' => Mage::helper('formbuilder')->__('OPTION ID'),
110
+ 'align' => 'left',
111
+ 'index' => 'options_index',
112
+ ));
113
+ $this->addColumn('value', array(
114
+ 'header' => Mage::helper('formbuilder')->__('VALUE'),
115
+ 'align' => 'left',
116
+ 'index' => 'value',
117
+ ));*/
118
+ return parent::_prepareColumns();
119
+ }
120
+ //this method is reuired if you want ajax grid
121
+ public function getGridUrl()
122
+ {
123
+ return $this->getUrl('*/*/recordsgrid', array('_current' => true));
124
+ }
125
+ public function canShowTab()
126
+ {
127
+ return true;
128
+ }
129
+ public function isHidden()
130
+ {
131
+ return false;
132
+ }
133
+ public function getTabLabel()
134
+ {
135
+ return $this->__('Fields List');
136
+ }
137
+ public function getTabTitle()
138
+ {
139
+ return $this->__('Fields List');
140
+ }
141
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Edit/Tabs.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('formbuilder_tabs');
34
+ $this->setName('formbuilder_tabs');
35
+ $this->setDestElementId('edit_form');
36
+ $this->setTitle(Mage::helper('formbuilder')->__('Form Information'));
37
+ }
38
+ protected function _beforeToHtml()
39
+ {
40
+ $this->addTab('general_section', array(
41
+ 'label' => Mage::helper('formbuilder')->__('Form Information'),
42
+ 'title' => Mage::helper('formbuilder')->__('Form Information'),
43
+ 'content' => $this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tab_form')->toHtml(),
44
+ ));
45
+
46
+ //$fieldsCollection = Mage::helper('formbuilder')->getcurrentFormFieldsCollection();
47
+ //if(count($fieldsCollection))
48
+ //{
49
+ $this->addTab('fieldsgrid_section', array(
50
+ 'label' => Mage::helper('formbuilder')->__('Fields List'),
51
+ 'title' => Mage::helper('formbuilder')->__('Fields List'),
52
+ 'url' => $this->getUrl('*/*/fieldsgrid', array('_current' => true)),
53
+ 'class' => 'ajax',
54
+ ));
55
+ //}
56
+
57
+ $this->addTab('fields_section', array(
58
+ 'label' => Mage::helper('formbuilder')->__('Form Creator'),
59
+ 'title' => Mage::helper('formbuilder')->__('Form Creator'),
60
+ 'url' => $this->getUrl('*/*/options', array('_current' => true)),
61
+ 'class' => 'ajax',
62
+ ));
63
+
64
+ return parent::_beforeToHtml();
65
+ }
66
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Grid.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Grid extends Mage_Adminhtml_Block_Widget_Grid
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('formbuilderGrid');
34
+ $this->setDefaultSort('forms_index');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setSaveParametersInSession(true);
37
+ }
38
+ protected function _prepareCollection()
39
+ {
40
+ $collection = Mage::getModel('formbuilder/forms')->getResourceCollection();
41
+
42
+ foreach ($collection as $view) {
43
+ if ( $view->getStores() && $view->getStores() != 0 ) {
44
+ $view->setStores(explode(',',$view->getStores()));
45
+ } else {
46
+ $view->setStores(array('0'));
47
+ }
48
+ }
49
+ $this->setCollection($collection);
50
+ return parent::_prepareCollection();
51
+ }
52
+ protected function _prepareColumns()
53
+ {
54
+ $this->addColumn('forms_index', array(
55
+ 'header' => Mage::helper('formbuilder')->__('ID'),
56
+ 'align' =>'left',
57
+ 'width' => '50px',
58
+ 'index' => 'forms_index',
59
+ ));
60
+ $this->addColumn('title', array(
61
+ 'header' => Mage::helper('formbuilder')->__('Title'),
62
+ 'align' =>'left',
63
+ 'width' => '250px',
64
+ 'index' => 'title',
65
+ ));
66
+ $this->addColumn('no_of_fields', array(
67
+ 'header' => Mage::helper('formbuilder')->__('Fields'),
68
+ 'align' =>'left',
69
+ 'width' => '50px',
70
+ 'index' => 'no_of_fields',
71
+ 'renderer' => 'formbuilder/adminhtml_formbuilder_renderer_numberoffields'
72
+ ));
73
+ $this->addColumn('form_image', array(
74
+ 'header' => Mage::helper('formbuilder')->__('Title Image'),
75
+ 'align' =>'left',
76
+ "width" => "80px",
77
+ 'index' => 'form_image',
78
+ 'renderer' => 'formbuilder/adminhtml_formbuilder_renderer_image'
79
+ ));
80
+ $this->addColumn('created_time', array(
81
+ 'header' => Mage::helper('formbuilder')->__('Created Time'),
82
+ 'align' => 'left',
83
+ 'width' => '150px',
84
+ 'index' => 'created_time',
85
+ ));
86
+ $this->addColumn('update_time', array(
87
+ 'header' => Mage::helper('formbuilder')->__('Updated Time'),
88
+ 'align' => 'left',
89
+ 'width' => '150px',
90
+ 'index' => 'update_time',
91
+ ));
92
+ $this->addColumn('status', array(
93
+ 'header' => Mage::helper('formbuilder')->__('Status'),
94
+ 'align' => 'left',
95
+ 'width' => '80px',
96
+ 'index' => 'status',
97
+ 'type' => 'options',
98
+ 'options' => array(
99
+ 1 => 'Enabled',
100
+ 2 => 'Disabled',
101
+ ),
102
+ ));
103
+ if ( !Mage::app()->isSingleStoreMode() )
104
+ {
105
+ $this->addColumn('stores', array(
106
+ 'header' => Mage::helper('formbuilder')->__('Store View'),
107
+ 'width' => '150px',
108
+ 'index' => 'stores',
109
+ 'type' => 'store',
110
+ 'store_all' => true,
111
+ 'store_view' => true,
112
+ 'sortable' => true,
113
+ 'filter_condition_callback' => array($this, '_filterStoreCondition'),
114
+ ));
115
+ }
116
+ $this->addColumn('action',
117
+ array(
118
+ 'header' => Mage::helper('formbuilder')->__('Action'),
119
+ 'width' => '100px',
120
+ 'type' => 'action',
121
+ 'getter' => 'getId',
122
+ 'actions' => array(
123
+ array(
124
+ 'caption' => Mage::helper('formbuilder')->__('Edit'),
125
+ 'url' => array('base'=> '*/*/edit'),
126
+ 'field' => 'id'
127
+ ),
128
+ array(
129
+ 'caption' => Mage::helper('formbuilder')->__('View Results'),
130
+ 'url' => array('base'=> 'formbuilder/adminhtml_formbuilder/recordsgrid'),
131
+ 'field' => 'id'
132
+ )
133
+ ),
134
+ 'filter' => false,
135
+ 'sortable' => false,
136
+ 'index' => 'stores',
137
+ 'is_system' => true,
138
+ ));
139
+
140
+ //$this->addExportType('*/*/exportCsv', Mage::helper('formbuilder')->__('CSV'));
141
+ //$this->addExportType('*/*/exportXml', Mage::helper('formbuilder')->__('XML'));
142
+
143
+ return parent::_prepareColumns();
144
+ }
145
+ protected function _filterStoreCondition($collection, $column)
146
+ {
147
+ if ( !$value = $column->getFilter()->getValue() ) {
148
+ return;
149
+ }
150
+ $this->getCollection()->addStoreFilter($value);
151
+ }
152
+ protected function _prepareMassaction()
153
+ {
154
+ $this->setMassactionIdField('forms_index');
155
+ $this->getMassactionBlock()->setFormFieldName('formbuilder');
156
+
157
+ $this->getMassactionBlock()->addItem('delete', array(
158
+ 'label' => Mage::helper('formbuilder')->__('Delete'),
159
+ 'url' => $this->getUrl('*/*/massDelete'),
160
+ 'confirm' => Mage::helper('formbuilder')->__('Are you sure?')
161
+ ));
162
+
163
+ $statuses = Mage::getSingleton('formbuilder/status')->getOptionArray();
164
+
165
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
166
+ $this->getMassactionBlock()->addItem('status', array(
167
+ 'label'=> Mage::helper('formbuilder')->__('Change status'),
168
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
169
+ 'additional' => array(
170
+ 'visibility' => array(
171
+ 'name' => 'status',
172
+ 'type' => 'select',
173
+ 'class' => 'required-entry',
174
+ 'label' => Mage::helper('formbuilder')->__('Status'),
175
+ 'values' => $statuses
176
+ )
177
+ )
178
+ ));
179
+ return $this;
180
+ }
181
+ public function getRowUrl($row)
182
+ {
183
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
184
+ }
185
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Fieldtitle.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block renderer
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Renderer_Fieldtitle extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $fieldId = intval($row->getData('fields_index'));
33
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
34
+ $fieldsModel->load($fieldId);
35
+ $fieldTitle = $fieldsModel->getTitle();
36
+ return $fieldTitle;
37
+ }
38
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Formtitle.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block renderer
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Renderer_Formtitle extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $formId = intval($row->getData('forms_index'));
33
+ $formsModel = Mage::getModel('formbuilder/forms')->load($formId);
34
+ $formTitle = $formsModel->getTitle();
35
+ return $formTitle;
36
+ }
37
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Getoptions.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block renderer
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Renderer_Getoptions extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $currentFieldsIndex = intval($row->getData('fields_index'));
33
+ $optionsCollection = Mage::getModel('formbuilder/options')->getCollection();
34
+ $optionsArray = array();
35
+
36
+ if(count($optionsCollection))
37
+ {
38
+ foreach ($optionsCollection as $optionsItem)
39
+ {
40
+ if($optionsItem['fields_index']==$currentFieldsIndex)
41
+ $optionsArray[] = $optionsItem['title'];
42
+ }
43
+ if($optionsArray)
44
+ return implode(', ', $optionsArray);
45
+ }
46
+ return;
47
+ }
48
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Image.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block renderer
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $html = '<img ';
33
+ $html .= 'id="' . $this->getColumn()->getId() . '" ';
34
+ $html .= 'src="'. Mage::getBaseUrl('media') . $row->getData('title_image') . '"';
35
+ $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss().'"';
36
+ $html .= 'style="weight:75px;height:75px"' . '"/>';
37
+ if($row->getData('title_image'))
38
+ return $html;
39
+ return "No Image";
40
+ }
41
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Numberoffields.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block renderer
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Renderer_Numberoffields extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $currentFormId = intval($row->getData('forms_index'));
33
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
34
+ $fieldsCollection = $fieldsModel->getcurrentFormFieldsCollection($currentFormId);
35
+ $numberoffields = '0';
36
+ if(count($fieldsCollection))
37
+ $numberoffields = count($fieldsCollection);
38
+ return $numberoffields;
39
+ }
40
+ }
app/code/community/Phxsolution/Formbuilder/Block/Adminhtml/Formbuilder/Renderer/Recordvalue.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml block renderer
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Renderer_Recordvalue extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ /*$recordId = intval($row->getData('records_index'));
33
+ $fieldId = intval($this->getColumn()->getIndex());
34
+ $i = intval($this->getColumn()->getName());
35
+ //return "recordId=".$recordId.", fieldId=".$fieldId;
36
+
37
+ $recordsModel = Mage::helper('formbuilder')->getRecordsModel();
38
+ $recordsModel->load($recordId);
39
+ if($recordsModel['fields_index']==$fieldId)
40
+ return "($fieldId) ".$recordsModel['value'];
41
+ return "($fieldId)";*/
42
+
43
+ $recordId = intval($row->getData('records_index'));
44
+ $fieldId = intval($this->getColumn()->getIndex());
45
+ $i = intval($this->getColumn()->getName());
46
+ $found = false;
47
+
48
+ //$serialized = 'a:3:{i:8;s:16:"test first name3";i:9;s:15:"test last name3";i:10;s:1:"7";}';
49
+ $serialized = $row->getData('value');
50
+ $unserialized = unserialize($serialized);
51
+ $recordsModel = Mage::helper('formbuilder')->getRecordsModel();
52
+ foreach ($unserialized as $key => $value)
53
+ {
54
+ $recordsModel->load($recordId);
55
+ if($key==$fieldId)
56
+ {
57
+ $found = true;
58
+ $returnValue = $value;
59
+ break;
60
+ }
61
+ }
62
+ if($found)
63
+ {
64
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
65
+ if(is_array($returnValue))
66
+ {
67
+ foreach ($returnValue as $key)
68
+ {
69
+ $optionsModel->load($key);
70
+ if($title = $optionsModel['title'])
71
+ $temp[] = $title;
72
+ else
73
+ $temp[] = $returnValue;
74
+ }
75
+ return implode(',',$temp);
76
+ }
77
+ else
78
+ {
79
+ if(is_numeric($returnValue))
80
+ {
81
+ $optionsModel->load($returnValue);
82
+ if($title = $optionsModel['title'])
83
+ return $title;
84
+ }
85
+ else
86
+ {
87
+ $supported_image = array('gif','jpg','jpeg','png');
88
+ $src_file_name = $returnValue;
89
+ $ext = strtolower(pathinfo($src_file_name, PATHINFO_EXTENSION)); // Using strtolower to overcome case sensitive
90
+ if (in_array($ext, $supported_image))
91
+ {
92
+ $file_path = Mage::getBaseUrl('media') . $returnValue;
93
+ $gd = @imagecreatefromstring(file_get_contents($file_path));
94
+ if ($gd === false)
95
+ return "Image seems corrupted or not found";
96
+ //else
97
+ $html = '<img height=75 width=75 ';
98
+ $html .= 'src="'. Mage::getBaseUrl('media') . $returnValue . '"';
99
+ $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss().'"';
100
+ $html .= 'style="weight:75px;height:75px"' . '"/>';
101
+ return $html;
102
+
103
+ }
104
+ else
105
+ return $returnValue;
106
+ }
107
+ }
108
+ }
109
+ return "";
110
+ }
111
+ }
app/code/community/Phxsolution/Formbuilder/Block/Frontend/Date.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Frontend_Date extends Mage_Core_Block_Template
29
+ {
30
+ protected $_option = array();
31
+ protected function _prepareLayout()
32
+ {
33
+ //echo "<h1>test</h1>";
34
+ }
35
+ public function useCalendar()
36
+ {
37
+ //return Mage::getSingleton('catalog/product_option_type_date')->useCalendar();
38
+ return Mage::getStoreConfig('formbuilder_section/custom_options/use_calendar');
39
+ }
40
+ public function getCalendarDateHtml()
41
+ {
42
+ $option = $this->_option;
43
+ //$value = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $option->getId() . '/date');
44
+
45
+ //$require = $this->_option->getIsRequire() ? ' required-entry' : '';
46
+ $require = '';
47
+
48
+ /*$yearStart = Mage::getSingleton('catalog/product_option_type_date')->getYearStart();
49
+ $yearEnd = Mage::getSingleton('catalog/product_option_type_date')->getYearEnd();*/
50
+ $year_range = Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
51
+ list($yearStart,$yearEnd) = explode(',', $year_range);
52
+ //$yearStart = Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
53
+ //$yearEnd = Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
54
+
55
+ $calendar = $this->getLayout()
56
+ ->createBlock('core/html_date')
57
+ ->setId('options_'.$this->_option->getFieldsIndex().'_date')
58
+ ->setName('options['.$this->_option->getFieldsIndex().'][date]')
59
+ ->setClass('product-custom-option datetime-picker input-text' . $require)
60
+ ->setImage($this->getSkinUrl('images/calendar.gif'))
61
+ ->setFormat(Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT))
62
+ ->setValue($value)
63
+ ->setYearsRange('[' . $yearStart . ', ' . $yearEnd . ']');
64
+ /*if (!$this->getSkipJsReloadPrice()) {
65
+ $calendar->setExtraParams('onchange="opConfig.reloadPrice()"');
66
+ }*/
67
+
68
+ return $calendar->getHtml();
69
+ }
70
+ protected function _getValueWithLeadingZeros($value)
71
+ {
72
+ if (!$this->_fillLeadingZeros) {
73
+ return $value;
74
+ }
75
+ return $value < 10 ? '0'.$value : $value;
76
+ }
77
+ protected function _getHtmlSelect($name, $value = null)
78
+ {
79
+ $option = $this->_option;
80
+
81
+ //$require = $this->_option->getIsRequire() ? ' required-entry' : '';
82
+ $require = '';
83
+ $select = $this->getLayout()->createBlock('core/html_select')
84
+ ->setId('options_' . $option['fields_index'] . '_' . $name)
85
+ ->setClass('product-custom-option datetime-picker' . $require)
86
+ ->setExtraParams()
87
+ ->setName('options[' . $option['fields_index'] . '][' . $name . ']');
88
+
89
+ $extraParams = 'style="width:auto"';
90
+ /*if (!$this->getSkipJsReloadPrice()) {
91
+ $extraParams .= ' onchange="opConfig.reloadPrice()"';
92
+ }*/
93
+ $select->setExtraParams($extraParams);
94
+
95
+ /*if (is_null($value)) {
96
+ $value = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $option->getFieldsIndex() . '/' . $name);
97
+ }
98
+ if (!is_null($value)) {
99
+ $select->setValue($value);
100
+ }*/
101
+
102
+ return $select;
103
+ }
104
+ protected function _getSelectFromToHtml($name, $from, $to, $value = null)
105
+ {
106
+ $options = array(
107
+ array('value' => '', 'label' => '-')
108
+ );
109
+ for ($i = $from; $i <= $to; $i++) {
110
+ $options[] = array('value' => $i, 'label' => $this->_getValueWithLeadingZeros($i));
111
+ }
112
+ return $this->_getHtmlSelect($name, $value)
113
+ ->setOptions($options)
114
+ ->getHtml();
115
+ }
116
+ public function getDropDownsDateHtml()
117
+ {
118
+ $fieldsSeparator = '&nbsp;';
119
+ //$fieldsOrder = Mage::getSingleton('catalog/product_option_type_date')->getConfigData('date_fields_order');
120
+ $fieldsOrder = Mage::getStoreConfig('formbuilder_section/custom_options/date_fields_order');
121
+ $fieldsOrder = str_replace(',', $fieldsSeparator, $fieldsOrder);
122
+
123
+ $monthsHtml = $this->_getSelectFromToHtml('month', 1, 12);
124
+ $daysHtml = $this->_getSelectFromToHtml('day', 1, 31);
125
+
126
+ $year_range = Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
127
+ list($yearStart,$yearEnd) = explode(',', $year_range);
128
+ //$yearStart = Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
129
+ //$yearEnd = Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
130
+ $yearsHtml = $this->_getSelectFromToHtml('year', $yearStart, $yearEnd);
131
+
132
+ $translations = array(
133
+ 'd' => $daysHtml,
134
+ 'm' => $monthsHtml,
135
+ 'y' => $yearsHtml
136
+ );
137
+ return strtr($fieldsOrder, $translations);
138
+ }
139
+ public function getDateHtml($currentField)
140
+ {
141
+ $this->_option = $currentField;
142
+
143
+ if ($this->useCalendar()) {
144
+ return $this->getCalendarDateHtml();
145
+ } else {
146
+ return $this->getDropDownsDateHtml();
147
+ }
148
+ }
149
+ public function getTimeHtml($currentField)
150
+ {
151
+ $this->_option = $currentField;
152
+ $timeFormat = Mage::getStoreConfig('formbuilder_section/custom_options/time_format');
153
+ //if (Mage::getSingleton('catalog/product_option_type_date')->is24hTimeFormat()) {
154
+ if ($timeFormat=='24h')
155
+ {
156
+ $hourStart = 0;
157
+ $hourEnd = 23;
158
+ $dayPartHtml = '';
159
+ } else {
160
+ $hourStart = 1;
161
+ $hourEnd = 12;
162
+ $dayPartHtml = $this->_getHtmlSelect('day_part')
163
+ ->setOptions(array(
164
+ 'am' => Mage::helper('catalog')->__('AM'),
165
+ 'pm' => Mage::helper('catalog')->__('PM')
166
+ ))
167
+ ->getHtml();
168
+ }
169
+ $hoursHtml = $this->_getSelectFromToHtml('hour', $hourStart, $hourEnd);
170
+ $minutesHtml = $this->_getSelectFromToHtml('minute', 0, 59);
171
+
172
+ return $hoursHtml . '&nbsp;<b>:</b>&nbsp;' . $minutesHtml . '&nbsp;' . $dayPartHtml;
173
+ }
174
+ public function getDefaultValue()
175
+ {
176
+ return $this->getProduct()->getPreconfiguredValues()->getData('options/' . $this->_option->getId());
177
+ }
178
+ }
app/code/community/Phxsolution/Formbuilder/Block/Frontend/File.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Frontend_File extends Mage_Core_Block_Template
29
+ {
30
+ protected $_currentField;
31
+ protected function _prepareLayout()
32
+ {
33
+ //echo "<h1>test</h1>";
34
+ }
35
+ public function getFileHtml($currentField)
36
+ {
37
+ $this->_currentField = $currentField;
38
+ return $this->_currentField['file_extension'];
39
+ }
40
+ public function getDefaultValue()
41
+ {
42
+ return $this->getProduct()->getPreconfiguredValues()->getData('options/' . $this->getOption()->getId());
43
+ }
44
+ }
app/code/community/Phxsolution/Formbuilder/Block/Frontend/Form.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Frontend_Form extends Mage_Core_Block_Template
29
+ {
30
+ protected function _prepareLayout()
31
+ {
32
+ //echo "<h1>test</h1>";
33
+ }
34
+ public function getCurrentFormUsingBlock($passFormId)
35
+ {
36
+ if($passFormId)
37
+ $currentFormArray = Mage::getModel('formbuilder/forms')->load($passFormId);
38
+ return $currentFormArray;
39
+ }
40
+ public function getCurrentFormFields($currentFormId=0)
41
+ {
42
+ if(!$currentFormId)
43
+ $currentFormId = intval($this->getRequest()->getParam('id'));
44
+ if($currentFormId)
45
+ {
46
+ $currentFormFieldsCollection = Mage::getModel('formbuilder/fields')->getCollection();
47
+ $currentFormFieldsCollection->addFieldToFilter('forms_index',array('eq'=>$currentFormId));
48
+ $currentFormFieldsCollection->addFieldToFilter('status',array('eq'=>1));
49
+ $currentFormFieldsCollection->setOrder('sort_order','ASC');
50
+ }
51
+ return $currentFormFieldsCollection;
52
+ }
53
+ public function getTextHtml($field)
54
+ {
55
+ echo $this->getLayout()
56
+ ->createBlock('formbuilder/frontend_text')
57
+ ->setData('field', $field)
58
+ ->setTemplate('formbuilder/text.phtml')
59
+ ->toHtml();
60
+ }
61
+ public function getSelectHtml($field)
62
+ {
63
+ echo $this->getLayout()
64
+ ->createBlock('formbuilder/frontend_select')
65
+ ->setData('field', $field)
66
+ ->setTemplate('formbuilder/select.phtml')
67
+ ->toHtml();
68
+ }
69
+ public function getDateHtml($field)
70
+ {
71
+ echo $this->getLayout()
72
+ ->createBlock('formbuilder/frontend_date')
73
+ ->setData('field', $field)
74
+ ->setTemplate('formbuilder/date.phtml')
75
+ ->toHtml();
76
+ }
77
+ public function getFileHtml($field)
78
+ {
79
+ echo $this->getLayout()
80
+ ->createBlock('formbuilder/frontend_file')
81
+ ->setData('field', $field)
82
+ ->setTemplate('formbuilder/file.phtml')
83
+ ->toHtml();
84
+ }
85
+ /*protected $_catfaq;
86
+ protected $_catfaqcCollection;
87
+
88
+ protected function _prepareLayout()
89
+ {
90
+ $categoryfaq = $this->getCategory();
91
+ if ($categoryfaq !== false && $head = $this->getLayout()->getBlock('head'))
92
+ {
93
+ $head->setTitle($this->htmlEscape($categoryfaq->getName()) . ' - ' . $head->getTitle());
94
+ }
95
+ }
96
+ public function getCategory()
97
+ {
98
+ if (!$this->_catfaq)
99
+ {
100
+ $id = intval($this->getRequest()->getParam('cat_id'));
101
+ try
102
+ {
103
+ $this->_catfaq = Mage :: getModel('faq/category')->load($id);
104
+ if ($this->_catfaq->getIsActive() != 1)
105
+ {
106
+ Mage::throwException('Catagory is not active');
107
+ }
108
+ }
109
+ catch (Exception $e)
110
+ {
111
+ $this->_catfaq = false;
112
+ }
113
+ }
114
+ return $this->_catfaq;
115
+ }
116
+ /**
117
+ * Function to gather the current faq item
118
+ *
119
+ * @return Inic_Faq_Model_Faq The current faq item
120
+ */
121
+ /*public function getcatFaqCollection()
122
+ {
123
+ try
124
+ {
125
+ if (!$this->_catfaq)
126
+ {
127
+ Mage::throwException('Please Select Category');
128
+ }
129
+ else
130
+ {
131
+ $this->_catfaqcCollection=$this->_catfaq->getItemCollection()->addIsActiveFilter()->addStoreFilter(Mage::app()->getStore());
132
+ }
133
+ }
134
+ catch (Exception $e)
135
+ {
136
+ $this->_catfaqcCollection = false;
137
+ }
138
+ return $this->_catfaqcCollection;
139
+ }*/
140
+ }
app/code/community/Phxsolution/Formbuilder/Block/Frontend/Formbuilder.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Frontend_Formbuilder extends Mage_Core_Block_Template
29
+ {
30
+ protected function _prepareLayout()
31
+ {
32
+ //echo "<h1>test</h1>";
33
+ }
34
+ }
app/code/community/Phxsolution/Formbuilder/Block/Frontend/Select.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Frontend_Select extends Mage_Core_Block_Template
29
+ {
30
+ protected function _prepareLayout()
31
+ {
32
+ //echo "<h1>test</h1>";
33
+ }
34
+ public function getValuesByField($_optionId)
35
+ {
36
+ $fieldValues = Mage::getModel('formbuilder/options')->getCollection();
37
+ $fieldValues->addFieldToFilter('fields_index',array('eq'=>$_optionId));
38
+ $fieldValues->setOrder('sort_order','ASC');
39
+ return $fieldValues;
40
+ }
41
+ public function getSelectHtml($_option)
42
+ {
43
+ $_optionId = $_option['fields_index'];
44
+ if($_option['type']=='drop_down' || $_option['type']=='multiple')
45
+ {
46
+ $require = ($_option->getIsRequire()) ? 'required-entry validate-select' : 'not-required';
47
+ $extraParams = '';
48
+ $select = $this->getLayout()->createBlock('core/html_select')
49
+ ->setData(array(
50
+ 'id' => 'select_'.$_option->getFieldsIndex(),
51
+ 'class' => $require.' product-custom-option'
52
+ ));
53
+ if ($_option['type']=='drop_down')
54
+ {
55
+ $select->setName('options['.$_option->getFieldsIndex().']')
56
+ ->addOption('', $this->__('-- Please Select --'));
57
+ }
58
+ else
59
+ {
60
+ $select->setName('options['.$_option->getFieldsIndex().'][]');
61
+ $select->setClass('multiselect'.$require.' product-custom-option');
62
+ $select->addOption( '' , 'HIDDEN', array('hidden'=>'hidden','selected'=>'selected') );
63
+ }
64
+
65
+ $fieldValues = $this->getValuesByField($_optionId);
66
+ foreach ($fieldValues as $_value)
67
+ {
68
+ $select->addOption( $_value->getOptionsIndex() , $_value->getTitle() );
69
+ }
70
+ if ($_option['type']=='multiple')
71
+ {
72
+ $extraParams = ' multiple="multiple"';
73
+ }
74
+ $select->setExtraParams($extraParams);
75
+ /*if ($configValue) {
76
+ $select->setValue($configValue);
77
+ }*/
78
+ return $select->getHtml();
79
+ }
80
+ elseif($_option['type']=='radio' || $_option['type']=='checkbox')
81
+ {
82
+ //$require = ($_option->getIsRequire()) ? ' required-entry' : 'not-required';
83
+ //return $require;
84
+ $selectHtml = '<ul id="options-'.$_option['fields_index'].'-list" class="options-list">';
85
+ $require = ($_option->getIsRequire()) ? 'validate-one-required-by-name' : '';
86
+ $arraySign = '';
87
+ switch ($_option->getType()) {
88
+ case 'radio':
89
+ $type = 'radio';
90
+ $class = 'radio';
91
+ if (!$_option->getIsRequire())
92
+ {
93
+ $selectHtml .= '<li><input type="radio" id="options_' . $_option['fields_index'] . '" class="'
94
+ . $class . ' product-custom-option" name="options[' . $_option['fields_index'] . ']"'
95
+ . ' value="" checked="checked" /><span class="label"><label for="options_'
96
+ . $_option['fields_index'] . '">' . $this->__('None') . '</label></span></li>';
97
+ }
98
+ break;
99
+ case 'checkbox':
100
+ $type = 'checkbox';
101
+ $class = 'checkbox';
102
+ $arraySign = '[]';
103
+ /*$selectHtml .= '<input type="' . $type . '"';
104
+ $selectHtml .= 'class="checkbox product-custom-option"';
105
+ $selectHtml .= ' name="options[' . $_option['fields_index'] . ']' . $arraySign . '"';
106
+ $selectHtml .= ' value="hidden" hidden />';*/
107
+ break;
108
+ }
109
+ $count = 1;
110
+ $classHtml = $class." product-custom-option";
111
+ $fieldValues = $this->getValuesByField($_optionId);
112
+ $lastItemId = $fieldValues->getLastItem()->getOptionsIndex();
113
+ foreach ($fieldValues as $_value)
114
+ {
115
+ $count++;
116
+ $configValue = "";
117
+ $htmlValue = $_value['options_index'];
118
+ if ($arraySign) {
119
+ $checked = (is_array($configValue) && in_array($htmlValue, $configValue)) ? 'checked' : '';
120
+ } else {
121
+ $checked = $configValue == $htmlValue ? 'checked' : '';
122
+ }
123
+
124
+ if($lastItemId==$_value['options_index'])
125
+ $classHtml .= " ".$require;
126
+ $selectHtml .= '<li>';
127
+ $selectHtml .= '<input type="' . $type . '"';
128
+ $selectHtml .= ' class="' . $classHtml . '"';
129
+ $selectHtml .= ' name="options[' . $_option['fields_index'] . ']' . $arraySign . '"';
130
+ $selectHtml .= ' id="options_' . $_option['fields_index'] . '_' . $count . '"';
131
+ $selectHtml .= ' value="' . $htmlValue . '" ' . $checked . ' />';
132
+ $selectHtml .= '<span class="label"><label for="options_' . $_option['fields_index'] . '_' . $count . '">'
133
+ . $_value->getTitle() . ' ' . '</label></span>';
134
+ if ($_option->getIsRequire()) {
135
+ $selectHtml .= '<script type="text/javascript">' . '$(\'options_' . $_option['fields_index'] . '_'
136
+ . $count . '\').advaiceContainer = \'options-' . $_option['fields_index'] . '-container\';'
137
+ . '$(\'options_' . $_option['fields_index'] . '_' . $count
138
+ . '\').callbackFunction = \'validateOptionsCallback\';' . '</script>';
139
+ }
140
+ $selectHtml .= '</li>';
141
+ }
142
+ $selectHtml .= '</ul>';
143
+
144
+ return $selectHtml;
145
+ }
146
+ }
147
+ public function getDefaultValue()
148
+ {
149
+ return $this->getProduct()->getPreconfiguredValues()->getData('options/' . $this->getOption()->getId());
150
+ }
151
+ }
app/code/community/Phxsolution/Formbuilder/Block/Frontend/Text.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend block
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Block_Frontend_Text extends Mage_Core_Block_Template
29
+ {
30
+ protected function _prepareLayout()
31
+ {
32
+ //echo "<h1>test</h1>";
33
+ }
34
+ public function getDefaultValue()
35
+ {
36
+ /*return $this->getProduct()->getPreconfiguredValues()->getData('options/' . $this->getOption()->getId());*/
37
+ /*return "Enter text for ".$this->field['fields_index'];*/
38
+ /*$helper = Mage::helper('formbuilder');
39
+ $getFormData = $helper->getFormData();
40
+ return "getFormData = ".$getFormData;*/
41
+ return "";
42
+ }
43
+ }
app/code/community/Phxsolution/Formbuilder/Helper/Data.php ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category helper
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Helper_Data extends Mage_Core_Helper_Abstract
29
+ {
30
+ protected $_formData;
31
+
32
+ public function isProductEdit()
33
+ {
34
+ $currentProduct = Mage::registry('product');
35
+ if(isset($currentProduct))
36
+ return true;
37
+ else
38
+ return false;
39
+ }
40
+ public function setFormData($data)
41
+ {
42
+ $this->_formData = $data;
43
+ }
44
+ public function getFormData()
45
+ {
46
+ return $this->_formData;
47
+ }
48
+ public function getRedirectUrl()
49
+ {
50
+ return Mage::getStoreConfig('formbuilder_section/form_submission/redirect_url');
51
+ }
52
+ public function getLimitFormSubmissionForRegistered()
53
+ {
54
+ return Mage::getStoreConfig('formbuilder_section/form_submission/limit_form_submission_for_registered');
55
+ }
56
+ public function getLimitFormSubmissionForGuest()
57
+ {
58
+ return Mage::getStoreConfig('formbuilder_section/form_submission/limit_form_submission_for_guest');
59
+ }
60
+ public function getYearRange()
61
+ {
62
+ return Mage::getStoreConfig('formbuilder_section/custom_options/year_range');
63
+ }
64
+ public function getTimeFormat()
65
+ {
66
+ return Mage::getStoreConfig('formbuilder_section/custom_options/time_format');
67
+ }
68
+ public function getDateFieldsOrder()
69
+ {
70
+ return Mage::getStoreConfig('formbuilder_section/custom_options/date_fields_order');
71
+ }
72
+ public function useCalendar()
73
+ {
74
+ return Mage::getStoreConfig('formbuilder_section/custom_options/use_calendar');
75
+ }
76
+ public function getCustomerInfo()
77
+ {
78
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
79
+ return $customer;
80
+ }
81
+ public function getFormsModel()
82
+ {
83
+ return Mage::getModel('formbuilder/forms');
84
+ }
85
+ public function getFieldsModel()
86
+ {
87
+ return Mage::getModel('formbuilder/fields');
88
+ }
89
+ public function getOptionsModel()
90
+ {
91
+ return Mage::getModel('formbuilder/options');
92
+ }
93
+ public function getRecordsModel()
94
+ {
95
+ return Mage::getModel('formbuilder/records');
96
+ }
97
+ public function isEnabled()
98
+ {
99
+ return Mage::getStoreConfig('formbuilder_section/general/active');
100
+ }
101
+ public function registeredOnly()
102
+ {
103
+ return Mage::getStoreConfig('formbuilder_section/form_submission/registered_only');
104
+ }
105
+ public function showLinkinToplinks()
106
+ {
107
+ return Mage::getStoreConfig('formbuilder_section/general/in_toplinks');
108
+ }
109
+ public function showLinkinTopmenu()
110
+ {
111
+ return Mage::getStoreConfig('formbuilder_section/general/in_topmenu');
112
+ }
113
+ public function showLinkinFooterlinks()
114
+ {
115
+ return Mage::getStoreConfig('formbuilder_section/general/in_footerlinks');
116
+ }
117
+ public function getFormCollection()
118
+ {
119
+ $formCollection = array();
120
+ $formCollection = Mage::getModel('formbuilder/forms')->getCollection();
121
+ return $formCollection;
122
+ }
123
+ public function getCurrentFormDetails($currentFormId)
124
+ {
125
+ $currentForm = array();
126
+ $currentForm = Mage::getModel('formbuilder/forms')->load($currentFormId);
127
+ return $currentForm;
128
+ }
129
+ /*public function getcurrentFormFieldsCollection($currentFormId=0)
130
+ {
131
+ $fieldsCollection = array();
132
+ //$currentFormId = Mage::getSingleton('core/session')->getCurrentFormId();
133
+ if(!$currentFormId)
134
+ $currentFormId = $this->getCurrentFormId();
135
+ $fieldsCollection = Mage::getModel('formbuilder/fields')->getCollection();
136
+ $fieldsCollection->addFieldToFilter('forms_index',array('eq'=>$currentFormId));
137
+ return $fieldsCollection;
138
+ }*/
139
+ public function getCurrentFormId()
140
+ {
141
+ $sessionFormId = intval(Mage::getSingleton('core/session')->getCurrentFormId());
142
+ //$registryFormId = intval(Mage::registry('formbuilder_data')->getId());
143
+ //$currentFormId = $sessionFormId ? $sessionFormId : $registryFormId;
144
+ if(is_int($currentFormId = $sessionFormId))
145
+ return $currentFormId;
146
+ }
147
+ /*public function saveFields($fieldsArray)
148
+ {
149
+ $fieldsCollection = Mage::getModel('formbuilder/fields')->getCollection();
150
+ if(count($fieldsCollection))
151
+ {
152
+ foreach ($fieldsArray as $fieldsArrayItem)
153
+ {
154
+ foreach ($fieldsCollection as $fieldsItem)
155
+ {
156
+ if($fieldsArrayItem['id']==$fieldsItem['field_id'] && $this->getCurrentFormId()==$fieldsItem['forms_index'])
157
+ {
158
+ $this->_isNewField = false;
159
+ break;
160
+ }
161
+ }
162
+ if($this->_isNewField)
163
+ {
164
+ // adding new field to existing collection
165
+ if(!$fieldsArrayItem['is_delete'])
166
+ $this->addField($fieldsArrayItem);
167
+ }
168
+ else
169
+ {
170
+ // editing existing field
171
+ $this->removeField( $fieldsItem['fields_index'] );
172
+ if(!$fieldsArrayItem['is_delete'])
173
+ $this->addField($fieldsArrayItem);
174
+ }
175
+ }
176
+ }
177
+ elseif($this->_isNewField)
178
+ {
179
+ // adding first field
180
+ foreach ($fieldsArray as $fieldsArrayItem)
181
+ {
182
+ if(!$fieldsArrayItem['is_delete'])
183
+ $this->addField($fieldsArrayItem);
184
+ }
185
+ }
186
+ }
187
+ public function addField($fieldsArrayItem)
188
+ {
189
+ //add field then save options if any
190
+ $fieldsModel = Mage::getModel('formbuilder/fields');
191
+ $data = array();
192
+
193
+ $data['forms_index'] = $this->getCurrentFormId();
194
+ $data['field_id'] = $fieldsArrayItem['id'];
195
+ $data['previous_group'] = $fieldsArrayItem['previous_group'];
196
+ $data['type'] = $fieldsArrayItem['type'];
197
+ $data['title'] = $fieldsArrayItem['title'];
198
+ if(array_key_exists('values', $fieldsArrayItem))
199
+ $data['options'] = 1;
200
+ else
201
+ $data['options'] = 0;
202
+ $data['sort_order'] = $fieldsArrayItem['sort_order'];
203
+ $data['is_require'] = $fieldsArrayItem['is_require'];
204
+ $data['is_delete'] = $fieldsArrayItem['is_delete'];
205
+ $data['option_id'] = $fieldsArrayItem['option_id'];
206
+ $data['previous_type'] = $fieldsArrayItem['previous_type'];
207
+
208
+ if($fieldsArrayItem['previous_group']=='text')
209
+ $data['max_characters'] = $fieldsArrayItem['max_characters'];
210
+ elseif($fieldsArrayItem['previous_group']=='file')
211
+ {
212
+ $data['file_extension'] = $fieldsArrayItem['file_extension'];
213
+ $data['image_size_x'] = $fieldsArrayItem['image_size_x'];
214
+ $data['image_size_y'] = $fieldsArrayItem['image_size_y'];
215
+ }
216
+
217
+ $fieldsModel->setData($data);
218
+ $fieldsModel->save();
219
+
220
+ if(array_key_exists('values', $fieldsArrayItem))
221
+ {
222
+ $optionsArray = array();
223
+ $optionsArray = $fieldsArrayItem['values'];
224
+ $getFieldsIndex = $fieldsModel->getFieldsIndex();
225
+ $this->saveOptions($optionsArray,$getFieldsIndex);
226
+ }
227
+ }
228
+ public function removeField($getFieldsIndex)
229
+ {
230
+ //remove field then remove options
231
+ $fieldsModel = Mage::getModel('formbuilder/fields')->load($getFieldsIndex);
232
+ $fieldsModel->setFieldsIndex($getFieldsIndex);
233
+ $fieldsModel->delete();
234
+ $this->removeOptions($getFieldsIndex);
235
+ }*/
236
+ /*public function saveOptions($optionsArray,$getFieldsIndex)
237
+ {
238
+ if($this->_isNewField)
239
+ {
240
+ $this->addOptions($optionsArray,$getFieldsIndex);
241
+ }
242
+ else
243
+ {
244
+ $this->removeOptions($getFieldsIndex);
245
+ $this->addOptions($optionsArray,$getFieldsIndex);
246
+ }
247
+ }
248
+ public function addOptions($optionsArray,$getFieldsIndex)
249
+ {
250
+ $optionsModel = Mage::getModel('formbuilder/options');
251
+ $data = array();
252
+ foreach ($optionsArray as $key => $optionsArrayItem)
253
+ {
254
+ if(!$optionsArrayItem['is_delete'])
255
+ {
256
+ $data['fields_index'] = $getFieldsIndex;
257
+ $data['is_delete'] = $optionsArrayItem['is_delete'];
258
+ $data['title'] = $optionsArrayItem['title'];
259
+ $data['sort_order'] = $optionsArrayItem['sort_order'];
260
+ $optionsModel->setData($data);
261
+ $optionsModel->save();
262
+ }
263
+ }
264
+ }
265
+ public function removeOptions($getFieldsIndex)
266
+ {
267
+ $optionsCollection = Mage::getModel('formbuilder/options')->getCollection();
268
+ foreach ($optionsCollection as $key => $option)
269
+ {
270
+ if($option['fields_index']==$getFieldsIndex)
271
+ {
272
+ $currentOptionIndex = $option['options_index'];
273
+ $optionsModel = Mage::getModel('formbuilder/options')->load($currentOptionIndex);
274
+ $optionsModel->setOptionsIndex($currentOptionIndex);
275
+ $optionsModel->delete();
276
+ }
277
+ }
278
+ }*/
279
+ /**
280
+ * Path for config.
281
+ */
282
+ const XML_CONFIG_PATH = 'formbuilder/general/';
283
+
284
+ /**
285
+ * Name library directory.
286
+ */
287
+ const NAME_DIR_JS = 'formbuilder/jquery/';
288
+
289
+ /**
290
+ * List files for include.
291
+ *
292
+ * @var array
293
+ */
294
+ protected $_files = array(
295
+ 'jquery-1.8.1.min.js',
296
+ 'jquery.noconflict.js',
297
+ );
298
+
299
+ /**
300
+ * Check enabled.
301
+ *
302
+ * @return bool
303
+ */
304
+ public function isJqueryEnabled()
305
+ {
306
+ return (bool) $this->_getConfigValue('jquery', $store = '');
307
+ }
308
+
309
+ /**
310
+ * Return path file.
311
+ *
312
+ * @param $file
313
+ *
314
+ * @return string
315
+ */
316
+ public function getJQueryPath($file)
317
+ {
318
+ return self::NAME_DIR_JS . $file;
319
+ }
320
+
321
+ /**
322
+ * Return list files.
323
+ *
324
+ * @return array
325
+ */
326
+ public function getFiles()
327
+ {
328
+ return $this->_files;
329
+ }
330
+
331
+ public function isformbuilderModuleEnabled()
332
+ {
333
+ return (bool) $this->_getConfigValue('active', $store = '');
334
+ }
335
+
336
+ public function isResponsiveBannerEnabled()
337
+ {
338
+ return (bool) $this->_getConfigValue('responsive_banner', $store = '');
339
+ }
340
+
341
+ protected function _getConfigValue($key, $store)
342
+ {
343
+ return Mage::getStoreConfig(self::XML_CONFIG_PATH . $key, $store = '');
344
+ }
345
+
346
+ public function resizeImg($fileName,$width='',$height='')
347
+ {
348
+ $baseURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
349
+ $imageURL = $baseURL .'/'.'formbuilder'.'/'.$fileName;
350
+
351
+ $basePath = Mage::getBaseDir('media');
352
+ $imagePath = $basePath.DS.'formbuilder'.str_replace('/', DS,$fileName);
353
+
354
+ $extra =$width . 'x' . $height;
355
+ $newPath = Mage::getBaseDir('media') . DS .'formbuilder'.DS."resized".DS.$extra.str_replace('/', DS,$fileName);
356
+ //if width empty then return original size image's URL
357
+ if ($width != '' && $height != '') {
358
+ //if image has already resized then just return URL
359
+ if (file_exists($imagePath) && is_file($imagePath) && !file_exists($newPath)) {
360
+ $imageObj = new Varien_Image($imagePath);
361
+ $imageObj->constrainOnly(TRUE);
362
+ $imageObj->keepAspectRatio(FALSE);
363
+ $imageObj->keepFrame(FALSE);
364
+ //$width, $height - sizes you need (Note: when keepAspectRatio(TRUE), height would be ignored)
365
+ $imageObj->resize($width, $height);
366
+ $imageObj->save($newPath);
367
+ }
368
+ $resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "formbuilder".'/'."resized".'/'.$extra.'/'.$fileName;
369
+ } else {
370
+ $resizedURL = $imageURL;
371
+ }
372
+ return $resizedURL;
373
+ }
374
+ }
app/code/community/Phxsolution/Formbuilder/Model/Fields.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Fields extends Mage_Core_Model_Abstract
29
+ {
30
+ protected $_isNewField = true;
31
+ protected $_currentFormId = 0;
32
+
33
+ public function _construct()
34
+ {
35
+ parent::_construct();
36
+ $this->_init('formbuilder/fields');
37
+ }
38
+ public function getCheckboxTypeIds($currentFormId=0)
39
+ {
40
+ if($currentFormId)
41
+ {
42
+ $fieldsCollection = $this->getFieldsCollection($currentFormId);
43
+ $fieldsCollection->addFieldToFilter('status',array('eq'=>1));
44
+ $fieldsCollection->addFieldToFilter('type',array('eq'=>'checkbox'));
45
+ $fieldsCollection->addFieldToSelect('fields_index');
46
+ if(count($fieldsCollection))
47
+ return $fieldsCollection->getData();
48
+ }
49
+ return false;
50
+ }
51
+ public function prepareFieldTitles($currentFormId=0)
52
+ {
53
+ $fieldsArray = array();
54
+
55
+ if($currentFormId)
56
+ {
57
+ $fieldsCollection = $this->getFieldsCollection($currentFormId);
58
+ $fieldsCollection->addFieldToFilter('status',array('eq'=>1));
59
+ $fieldsCollection->setOrder('sort_order','asc');
60
+ if(count($fieldsCollection))
61
+ {
62
+ foreach ($fieldsCollection as $key => $value)
63
+ {
64
+ $fieldTitle = $value['title'];
65
+ $fieldsArray[$key] = $fieldTitle;
66
+ }
67
+ }
68
+ if(count($fieldsArray))
69
+ return $fieldsArray;
70
+ }
71
+ return false;
72
+ }
73
+ public function getcurrentFormFieldsCollection($currentFormId=0)
74
+ {
75
+ $fieldsCollection = array();
76
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
77
+ $fieldsCollection = $fieldsModel->getCollection();
78
+ $fieldsCollection->addFieldToFilter('forms_index',array('eq'=>$currentFormId));
79
+ $fieldsCollection->setOrder('sort_order','asc');
80
+ return $fieldsCollection;
81
+ }
82
+ public function getFieldsCollection($currentFormId=0)
83
+ {
84
+ $fieldsCollection = array();
85
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
86
+ $fieldsCollection = $fieldsModel->getCollection();
87
+ if($currentFormId)
88
+ $fieldsCollection->addFieldToFilter('forms_index',array('eq'=>$currentFormId));
89
+ //$fieldsCollection->setOrder('field_id','asc');
90
+ return $fieldsCollection;
91
+ }
92
+ public function saveFields($fieldsArray,$currentFormId=0)
93
+ {
94
+ //$fieldsCollection = Mage::getModel('formbuilder/fields')->getCollection();
95
+ $this->_currentFormId = $currentFormId;
96
+ if($this->_currentFormId)
97
+ {
98
+ $fieldsCollection = $this->getFieldsCollection($this->_currentFormId);
99
+ if(count($fieldsCollection))
100
+ {
101
+ foreach ($fieldsArray as $fieldsArrayItem)
102
+ {
103
+ foreach ($fieldsCollection as $fieldsItem)
104
+ {
105
+ if($fieldsArrayItem['id']==$fieldsItem['field_id'])
106
+ {
107
+ $this->_isNewField = false;
108
+ break;
109
+ }
110
+ }
111
+ if($this->_isNewField)
112
+ {
113
+ // adding new field to existing collection
114
+ if(!$fieldsArrayItem['is_delete'])
115
+ $this->addField($fieldsArrayItem);
116
+ }
117
+ else
118
+ {
119
+ // editing existing field
120
+ if($fieldsArrayItem['is_delete'])
121
+ $this->removeField( $fieldsItem['fields_index'] );
122
+ else
123
+ $this->editField( $fieldsArrayItem,$fieldsItem['fields_index'] );
124
+ /*$this->removeField( $fieldsItem['fields_index'] );
125
+ if(!$fieldsArrayItem['is_delete'])
126
+ $this->addField($fieldsArrayItem);*/
127
+ }
128
+ }
129
+ }
130
+ elseif($this->_isNewField)
131
+ {
132
+ // adding first field
133
+ foreach ($fieldsArray as $fieldsArrayItem)
134
+ {
135
+ if(!$fieldsArrayItem['is_delete'])
136
+ $this->addField($fieldsArrayItem);
137
+ }
138
+ }
139
+ }
140
+ }
141
+ public function editField( $fieldsArrayItem,$getFieldsIndex )
142
+ {
143
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
144
+ $data = array();
145
+ if($fieldsModel->load($getFieldsIndex))
146
+ {
147
+ $data['fields_index'] = $getFieldsIndex;
148
+ $data['forms_index'] = $this->_currentFormId;
149
+ $data['field_id'] = $fieldsArrayItem['id'];
150
+ $data['previous_group'] = $fieldsArrayItem['previous_group'];
151
+ $data['type'] = $fieldsArrayItem['type'];
152
+ $data['title'] = $fieldsArrayItem['title'];
153
+
154
+ $inputType = $fieldsArrayItem['type'];
155
+ $allowedTypes = array("drop_down","radio","checkbox","multiple");
156
+ if( array_key_exists('values', $fieldsArrayItem) && in_array($inputType,$allowedTypes) )
157
+ $data['options'] = 1;
158
+ else
159
+ $data['options'] = 0;
160
+
161
+ $data['sort_order'] = $fieldsArrayItem['sort_order'];
162
+ $data['status'] = $fieldsArrayItem['field_status'];
163
+ $data['is_require'] = $fieldsArrayItem['is_require'];
164
+ $data['is_delete'] = $fieldsArrayItem['is_delete'];
165
+ $data['option_id'] = $fieldsArrayItem['option_id'];
166
+ $data['previous_type'] = $fieldsArrayItem['previous_type'];
167
+
168
+ if($fieldsArrayItem['previous_group']=='text')
169
+ $data['max_characters'] = $fieldsArrayItem['max_characters'];
170
+ elseif($fieldsArrayItem['previous_group']=='file')
171
+ {
172
+ $data['file_extension'] = $fieldsArrayItem['file_extension'];
173
+ $data['image_size_x'] = $fieldsArrayItem['image_size_x'];
174
+ $data['image_size_y'] = $fieldsArrayItem['image_size_y'];
175
+ }
176
+
177
+ $fieldsModel->setData($data);
178
+ $fieldsModel->save();
179
+
180
+ if( array_key_exists('values', $fieldsArrayItem) )
181
+ {
182
+ if( in_array($inputType,$allowedTypes) )
183
+ {
184
+ $optionsArray = array();
185
+ $optionsArray = $fieldsArrayItem['values'];
186
+ //$getFieldsIndex = $fieldsModel->getFieldsIndex();
187
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
188
+ $optionsModel->saveOptions($optionsArray,$getFieldsIndex,$this->_isNewField);
189
+ }
190
+ else
191
+ {
192
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
193
+ $optionsModel->removeOptions($getFieldsIndex);
194
+ }
195
+ }
196
+ }
197
+ }
198
+ public function addField($fieldsArrayItem)
199
+ {
200
+ //add field then save options if any
201
+ //$fieldsModel = Mage::getModel('formbuilder/fields');
202
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
203
+ $data = array();
204
+
205
+ $data['forms_index'] = $this->_currentFormId;
206
+ $data['field_id'] = $fieldsArrayItem['id'];
207
+ $data['previous_group'] = $fieldsArrayItem['previous_group'];
208
+ $data['type'] = $fieldsArrayItem['type'];
209
+ $data['title'] = $fieldsArrayItem['title'];
210
+ if(array_key_exists('values', $fieldsArrayItem))
211
+ $data['options'] = 1;
212
+ else
213
+ $data['options'] = 0;
214
+ $data['sort_order'] = $fieldsArrayItem['sort_order'];
215
+ $data['status'] = $fieldsArrayItem['field_status'];
216
+ $data['is_require'] = $fieldsArrayItem['is_require'];
217
+ $data['is_delete'] = $fieldsArrayItem['is_delete'];
218
+ $data['option_id'] = $fieldsArrayItem['option_id'];
219
+ $data['previous_type'] = $fieldsArrayItem['previous_type'];
220
+
221
+ if($fieldsArrayItem['previous_group']=='text')
222
+ $data['max_characters'] = $fieldsArrayItem['max_characters'];
223
+ elseif($fieldsArrayItem['previous_group']=='file')
224
+ {
225
+ $data['file_extension'] = $fieldsArrayItem['file_extension'];
226
+ $data['image_size_x'] = $fieldsArrayItem['image_size_x'];
227
+ $data['image_size_y'] = $fieldsArrayItem['image_size_y'];
228
+ }
229
+
230
+ $fieldsModel->setData($data);
231
+ $fieldsModel->save();
232
+
233
+ if(array_key_exists('values', $fieldsArrayItem))
234
+ {
235
+ $optionsArray = array();
236
+ $optionsArray = $fieldsArrayItem['values'];
237
+ $getFieldsIndex = $fieldsModel->getFieldsIndex();
238
+ //$this->saveOptions($optionsArray,$getFieldsIndex,$this->_isNewField);
239
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
240
+ $optionsModel->saveOptions($optionsArray,$getFieldsIndex,$this->_isNewField);
241
+ }
242
+ }
243
+ public function removeField($getFieldsIndex)
244
+ {
245
+ //remove field then remove options
246
+ //$fieldsModel = Mage::getModel('formbuilder/fields')->load($getFieldsIndex);
247
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
248
+ $fieldsModel->load($getFieldsIndex);
249
+ $fieldsModel->setFieldsIndex($getFieldsIndex);
250
+ $fieldsModel->delete();
251
+ //$this->removeOptions($getFieldsIndex);
252
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
253
+ $optionsModel->removeOptions($getFieldsIndex);
254
+ }
255
+ }
app/code/community/Phxsolution/Formbuilder/Model/Forms.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Forms extends Mage_Core_Model_Abstract
29
+ {
30
+ protected $_currentFormId=0;
31
+
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('formbuilder/forms');
36
+ }
37
+ /*public function getSuccessText($currentFormId=0)
38
+ {
39
+ $this->_currentFormId = $currentFormId;
40
+ }*/
41
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Fields.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Fields extends Mage_Core_Model_Mysql4_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ $this->_init('formbuilder/fields', 'fields_index');
33
+ }
34
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Fields/Collection.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Fields_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('formbuilder/fields');
34
+ }
35
+ /*public function addEnableFilter($status = 1) {
36
+ $this->getSelect()->where('main_table.status = ?', $status);
37
+ return $this;
38
+ }
39
+
40
+ public function addStoreFilter($store) {
41
+ if (!Mage::app()->isSingleStoreMode()) {
42
+
43
+ $this->getSelect()->where('(FIND_IN_SET('.$store.',main_table.stores) or main_table.stores in (0))');
44
+ // $this->getSelect()->where('main_table.stores in (?)', array(0, $store));
45
+ return $this;
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ public function addPageFilter($page) {
51
+ //$this->getSelect()->where('main_table.page_id in (?)', $page);
52
+ $this->getSelect()->where('FIND_IN_SET('.$page.',main_table.page_id)');
53
+ return $this;
54
+ }
55
+
56
+ public function addPositionFilter($position) {
57
+ $this->getSelect()->where('main_table.position = ?', $position);
58
+ return $this;
59
+ }
60
+
61
+ public function addCategoryFilter($category) {
62
+ $this->getSelect()->where('FIND_IN_SET('.$category.',main_table.category_id)');
63
+ return $this;
64
+ }*/
65
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Forms.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Forms extends Mage_Core_Model_Mysql4_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ $this->_init('formbuilder/forms', 'forms_index');
33
+ }
34
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Forms/Collection.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Forms_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('formbuilder/forms');
34
+ }
35
+ /*public function addEnableFilter($status = 1) {
36
+ $this->getSelect()->where('main_table.status = ?', $status);
37
+ return $this;
38
+ }
39
+
40
+ public function addStoreFilter($store) {
41
+ if (!Mage::app()->isSingleStoreMode()) {
42
+
43
+ $this->getSelect()->where('(FIND_IN_SET('.$store.',main_table.stores) or main_table.stores in (0))');
44
+ // $this->getSelect()->where('main_table.stores in (?)', array(0, $store));
45
+ return $this;
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ public function addPageFilter($page) {
51
+ //$this->getSelect()->where('main_table.page_id in (?)', $page);
52
+ $this->getSelect()->where('FIND_IN_SET('.$page.',main_table.page_id)');
53
+ return $this;
54
+ }
55
+
56
+ public function addPositionFilter($position) {
57
+ $this->getSelect()->where('main_table.position = ?', $position);
58
+ return $this;
59
+ }
60
+
61
+ public function addCategoryFilter($category) {
62
+ $this->getSelect()->where('FIND_IN_SET('.$category.',main_table.category_id)');
63
+ return $this;
64
+ }*/
65
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Options.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Options extends Mage_Core_Model_Mysql4_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ $this->_init('formbuilder/options', 'options_index');
33
+ }
34
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Options/Collection.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Options_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('formbuilder/options');
34
+ }
35
+ /*public function addEnableFilter($status = 1) {
36
+ $this->getSelect()->where('main_table.status = ?', $status);
37
+ return $this;
38
+ }
39
+
40
+ public function addStoreFilter($store) {
41
+ if (!Mage::app()->isSingleStoreMode()) {
42
+
43
+ $this->getSelect()->where('(FIND_IN_SET('.$store.',main_table.stores) or main_table.stores in (0))');
44
+ // $this->getSelect()->where('main_table.stores in (?)', array(0, $store));
45
+ return $this;
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ public function addPageFilter($page) {
51
+ //$this->getSelect()->where('main_table.page_id in (?)', $page);
52
+ $this->getSelect()->where('FIND_IN_SET('.$page.',main_table.page_id)');
53
+ return $this;
54
+ }
55
+
56
+ public function addPositionFilter($position) {
57
+ $this->getSelect()->where('main_table.position = ?', $position);
58
+ return $this;
59
+ }
60
+
61
+ public function addCategoryFilter($category) {
62
+ $this->getSelect()->where('FIND_IN_SET('.$category.',main_table.category_id)');
63
+ return $this;
64
+ }*/
65
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Records.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Records extends Mage_Core_Model_Mysql4_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ $this->_init('formbuilder/records', 'records_index');
33
+ }
34
+ }
app/code/community/Phxsolution/Formbuilder/Model/Mysql4/Records/Collection.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Mysql4_Records_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('formbuilder/records');
34
+ }
35
+ /*public function addEnableFilter($status = 1) {
36
+ $this->getSelect()->where('main_table.status = ?', $status);
37
+ return $this;
38
+ }
39
+
40
+ public function addStoreFilter($store) {
41
+ if (!Mage::app()->isSingleStoreMode()) {
42
+
43
+ $this->getSelect()->where('(FIND_IN_SET('.$store.',main_table.stores) or main_table.stores in (0))');
44
+ // $this->getSelect()->where('main_table.stores in (?)', array(0, $store));
45
+ return $this;
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ public function addPageFilter($page) {
51
+ //$this->getSelect()->where('main_table.page_id in (?)', $page);
52
+ $this->getSelect()->where('FIND_IN_SET('.$page.',main_table.page_id)');
53
+ return $this;
54
+ }
55
+
56
+ public function addPositionFilter($position) {
57
+ $this->getSelect()->where('main_table.position = ?', $position);
58
+ return $this;
59
+ }
60
+
61
+ public function addCategoryFilter($category) {
62
+ $this->getSelect()->where('FIND_IN_SET('.$category.',main_table.category_id)');
63
+ return $this;
64
+ }*/
65
+ }
app/code/community/Phxsolution/Formbuilder/Model/Observer.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Observer
29
+ {
30
+ public function addToTopmenu(Varien_Event_Observer $observer)
31
+ {
32
+ if(Mage::helper('formbuilder')->showLinkinTopmenu())
33
+ {
34
+ $menu = $observer->getMenu();
35
+ $tree = $menu->getTree();
36
+
37
+ $node = new Varien_Data_Tree_Node(array(
38
+ 'name' => 'Formbuilder',
39
+ 'id' => 'formbuilder',
40
+ 'url' => Mage::getUrl('formbuilder'), // point somewhere
41
+ ), 'id', $tree, $menu);
42
+
43
+ $menu->addChild($node);
44
+
45
+ // Children menu items
46
+ $collection = Mage::getModel('formbuilder/forms')->getCollection();
47
+ $collection->addFieldToFilter('status',array('eq'=>1));
48
+ $collection->addFieldToFilter('in_menu',array('eq'=>1));
49
+ foreach ($collection as $category)
50
+ {
51
+ $tree = $node->getTree();
52
+ $data = array(
53
+ 'name' => $category->getTitle(),
54
+ 'id' => 'category-node-'.$category->getFormsIndex(),
55
+ 'url' => Mage::getUrl('formbuilder/index/view').'id/'.$category->getFormsIndex(),
56
+ );
57
+ $subNode = new Varien_Data_Tree_Node($data, 'id', $tree, $node);
58
+ $node->addChild($subNode);
59
+ }
60
+ }
61
+ }
62
+ }
app/code/community/Phxsolution/Formbuilder/Model/Options.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Options extends Mage_Core_Model_Abstract
29
+ {
30
+ protected $_isNewField = true;
31
+ protected $_isNewOption;
32
+ protected $_currentFieldId = 0;
33
+
34
+ public function _construct()
35
+ {
36
+ parent::_construct();
37
+ $this->_init('formbuilder/options');
38
+ }
39
+ public function getOptionsCollection($currentFieldId=0)
40
+ {
41
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
42
+ $optionsCollection = $optionsModel->getCollection();
43
+ if($currentFieldId)
44
+ $optionsCollection->addFieldToFilter('fields_index',array('eq'=>$currentFieldId));
45
+ $optionsCollection->setOrder('sort_order','asc');
46
+ return $optionsCollection;
47
+ }
48
+ public function saveOptions($optionsArray,$currentFieldId=0,$isNewField=true)
49
+ {
50
+ $this->_currentFieldId = $currentFieldId;
51
+ $this->_isNewField = $isNewField;
52
+ if($this->_isNewField)
53
+ {
54
+ $this->addOptions($optionsArray,$this->_currentFieldId);
55
+ }
56
+ else
57
+ {
58
+ //$this->removeOptions($this->_currentFieldId);
59
+ //$this->addOptions($optionsArray,$this->_currentFieldId);
60
+ $this->EditOptions($optionsArray,$this->_currentFieldId);
61
+ }
62
+ }
63
+ public function EditOptions($optionsArray,$getFieldsIndex)
64
+ {
65
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
66
+ $data = array();
67
+ $optionsCollection = $this->getOptionsCollection($getFieldsIndex);
68
+ if(count($optionsCollection))
69
+ {
70
+ foreach ($optionsArray as $optionId => $optionsArrayItem)
71
+ {
72
+ foreach ($optionsCollection as $key2 => $value2)
73
+ {
74
+ if($value2['option_id']==$optionId)
75
+ {
76
+ $this->_isNewOption = false;
77
+ break;
78
+ }
79
+ else
80
+ $this->_isNewOption = true;
81
+ }
82
+ if($this->_isNewOption)
83
+ {
84
+ if(!$optionsArrayItem['is_delete'])
85
+ $this->addOption($optionsArrayItem,$optionId);
86
+ }
87
+ else
88
+ {
89
+ if($optionsArrayItem['is_delete'])
90
+ $this->removeOption( $value2['options_index'] );
91
+ else
92
+ $this->editOption( $optionsArrayItem,$value2['options_index'] );
93
+ }
94
+ }
95
+ }
96
+ }
97
+ public function addOption($optionsArrayItem,$optionId)
98
+ {
99
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
100
+ $data = array();
101
+ $data['fields_index'] = $this->_currentFieldId;
102
+ $data['is_delete'] = $optionsArrayItem['is_delete'];
103
+ $data['title'] = $optionsArrayItem['title'];
104
+ $data['sort_order'] = $optionsArrayItem['sort_order'];
105
+ $data['option_id'] = $optionId;
106
+ $optionsModel->setData($data);
107
+ $optionsModel->save();
108
+ }
109
+ public function removeOption($getOptionsIndex)
110
+ {
111
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
112
+ $optionsModel->load($getOptionsIndex);
113
+ $optionsModel->delete();
114
+ }
115
+ public function editOption($optionsArrayItem,$getOptionsIndex)
116
+ {
117
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
118
+ $data = array();
119
+ $optionsModel->load($getOptionsIndex);
120
+ $data['options_index'] = $getOptionsIndex;
121
+ $data['title'] = $optionsArrayItem['title'];
122
+ $data['sort_order'] = $optionsArrayItem['sort_order'];
123
+ $optionsModel->setData($data);
124
+ $optionsModel->save();
125
+ }
126
+ public function addOptions($optionsArray,$getFieldsIndex)
127
+ {
128
+ //$optionsModel = Mage::getModel('formbuilder/options');
129
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
130
+ $data = array();
131
+ foreach ($optionsArray as $key => $optionsArrayItem)
132
+ {
133
+ if(!$optionsArrayItem['is_delete'])
134
+ {
135
+ $data['fields_index'] = $getFieldsIndex;
136
+ $data['is_delete'] = $optionsArrayItem['is_delete'];
137
+ $data['title'] = $optionsArrayItem['title'];
138
+ $data['sort_order'] = $optionsArrayItem['sort_order'];
139
+ $data['option_id'] = $key;
140
+ $optionsModel->setData($data);
141
+ $optionsModel->save();
142
+ }
143
+ }
144
+ }
145
+ public function removeOptions($getFieldsIndex)
146
+ {
147
+ //$optionsCollection = Mage::getModel('formbuilder/options')->getCollection();
148
+ $optionsCollection = $this->getOptionsCollection($getFieldsIndex);
149
+ foreach ($optionsCollection as $key => $option)
150
+ {
151
+ if($option['fields_index']==$getFieldsIndex)
152
+ {
153
+ $currentOptionIndex = $option['options_index'];
154
+ //$optionsModel = Mage::getModel('formbuilder/options')->load($currentOptionIndex);
155
+ $optionsModel = Mage::helper('formbuilder')->getOptionsModel();
156
+ $optionsModel->load($currentOptionIndex);
157
+ $optionsModel->setOptionsIndex($currentOptionIndex);
158
+ $optionsModel->delete();
159
+ }
160
+ }
161
+ }
162
+ }
app/code/community/Phxsolution/Formbuilder/Model/Records.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Records extends Mage_Core_Model_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('formbuilder/records');
34
+ }
35
+ public function checkFormSubmissionLimit($customer=0,$currentFormId=0)
36
+ {
37
+ //return "customer=$customer, currentFormId=$currentFormId";
38
+ $collection = array();
39
+ if($customer && $currentFormId)
40
+ {
41
+ $collection = $this->getRecordsCollection($currentFormId);
42
+ $collection->addFieldToFilter('customer',array('eq'=>$customer));
43
+ }
44
+ return count($collection);
45
+ }
46
+ public function getRecordsCollection($currentFormId=0)
47
+ {
48
+ $recordsModel = Mage::helper('formbuilder')->getRecordsModel();
49
+ $recordsCollection = $recordsModel->getCollection();
50
+ if($currentFormId)
51
+ $recordsCollection->addFieldToFilter('forms_index',array('eq'=>$currentFormId));
52
+ //$recordsCollection->setOrder('fields_index','asc');
53
+ return $recordsCollection;
54
+ }
55
+ }
app/code/community/Phxsolution/Formbuilder/Model/Status.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category model
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Model_Status extends Varien_Object
29
+ {
30
+ const STATUS_ENABLED = 1;
31
+ const STATUS_DISABLED = 2;
32
+
33
+ static public function getOptionArray()
34
+ {
35
+ return array(
36
+ self::STATUS_ENABLED => Mage::helper('formbuilder')->__('Enabled'),
37
+ self::STATUS_DISABLED => Mage::helper('formbuilder')->__('Disabled')
38
+ );
39
+ }
40
+ }
app/code/community/Phxsolution/Formbuilder/controllers/Adminhtml/FormbuilderController.php ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml controller
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_Adminhtml_FormbuilderController extends Mage_Adminhtml_Controller_Action
29
+ {
30
+ //this is ajax grid request action
31
+ public function fieldsgridAction()
32
+ {
33
+ echo $this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tab_fieldsgrid')->toHtml();
34
+ }
35
+ public function recordsgridAction()
36
+ {
37
+ $this->loadLayout();
38
+ $this->_addContent($this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tab_recordsgrid'));
39
+ $this->renderLayout();
40
+ //echo $this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tab_fieldsgrid')->toHtml();
41
+ }
42
+ public function optionsAction()
43
+ {
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ public function getBaseTmpMediaUrl()
48
+ {
49
+ return Mage::getBaseUrl('media') . 'formbuilder';
50
+ }
51
+ public function getBaseTmpMediaPath()
52
+ {
53
+ return Mage::getBaseDir('media') . DS . 'formbuilder';
54
+ }
55
+ protected function _initAction()
56
+ {
57
+ $this->loadLayout()
58
+ ->_setActiveMenu('formbuilder/items')
59
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Form Manager'));
60
+
61
+ return $this;
62
+ }
63
+ public function indexAction()
64
+ {
65
+ $this->_initAction()
66
+ //$this->getLayout()->getBlock('head')->setTitle($this->__('Banner'));
67
+ ->renderLayout();
68
+ }
69
+ /*public function editAction()
70
+ {
71
+ $id = $this->getRequest()->getParam('id');
72
+ $model = Mage::getModel('formbuilder/forms')->load($id);
73
+
74
+ if ($model->getId() || $id == 0)
75
+ {
76
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
77
+ if (!empty($data))
78
+ {
79
+ $model->setData($data);
80
+ }
81
+ //echo '<pre>';
82
+ //$model->setData('stores',json_decode($model->getData('stores')));
83
+ //print_R($model->getData());exit;
84
+ Mage::register('formbuilder_data', $model);
85
+
86
+ $this->loadLayout();
87
+ $this->_setActiveMenu('formbuilder/items');
88
+
89
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Form Manager'), Mage::helper('adminhtml')->__('Form Manager'));
90
+
91
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
92
+
93
+ $this->_addContent($this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit'))
94
+ ->_addLeft($this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tabs'));
95
+
96
+ $this->renderLayout();
97
+ }
98
+ else
99
+ {
100
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('formbuilder')->__('Form does not exist'));
101
+ $this->_redirect('*//**//*');
102
+ }
103
+ }
104
+ public function newAction()
105
+ {
106
+ $this->_title($this->__('New Form'));
107
+
108
+ $_model = Mage::getModel('formbuilder/forms');
109
+ Mage::register('formbuilder_data', $_model);
110
+ Mage::register('current_Form', $_model);
111
+
112
+ $this->_initAction();
113
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Form Manager'), Mage::helper('adminhtml')->__('Form Manager'), $this->getUrl('*'));
114
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Add Form'), Mage::helper('adminhtml')->__('Add Form'));
115
+
116
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
117
+
118
+ $this->_addContent($this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit'))
119
+ ->_addLeft($this->getLayout()->createBlock('formbuilder/adminhtml_formbuilder_edit_tabs'));
120
+
121
+ $this->renderLayout();
122
+ }*/
123
+ public function editAction()
124
+ {
125
+ $this->_title($this->__("Form"));
126
+ $this->_title($this->__("Form Listing"));
127
+ $this->_title($this->__("Edit Form"));
128
+
129
+ $id = $this->getRequest()->getParam("id");
130
+ $model = Mage::getModel("formbuilder/forms")->load($id);
131
+
132
+ //echo "model->getFormsIndex() = ".$model->getFormsIndex();
133
+ //exit();
134
+
135
+ if ($model->getFormsIndex() || $id==0)
136
+ {
137
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
138
+ if (!empty($data))
139
+ {
140
+ $model->setData($data);
141
+ }
142
+ Mage::register("formbuilder_data", $model);
143
+ $this->loadLayout();
144
+ $this->_setActiveMenu("formbuilder/items");
145
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Form Manager"), Mage::helper("adminhtml")->__("Form Manager"));
146
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Form Description"), Mage::helper("adminhtml")->__("Form Description"));
147
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
148
+ $this->_addContent($this->getLayout()->createBlock("formbuilder/adminhtml_formbuilder_edit"))->_addLeft($this->getLayout()->createBlock("formbuilder/adminhtml_formbuilder_edit_tabs"));
149
+ $this->renderLayout();
150
+ }
151
+ else {
152
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("formbuilder")->__("Form does not exist."));
153
+ $this->_redirect("*/*/");
154
+ }
155
+ }
156
+ public function newAction()
157
+ {
158
+ $this->_title($this->__("Form"));
159
+ //$this->_title($this->__("Form"));
160
+ $this->_title($this->__("New Form"));
161
+
162
+ $id = $this->getRequest()->getParam("id");
163
+ $model = Mage::getModel("formbuilder/forms")->load($id);
164
+
165
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
166
+ if (!empty($data)) {
167
+ $model->setData($data);
168
+ }
169
+ Mage::register("formbuilder_data", $model);
170
+
171
+ $this->loadLayout();
172
+ $this->_setActiveMenu("formbuilder/items");
173
+
174
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
175
+
176
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Form Manager"), Mage::helper("adminhtml")->__("Form Manager"));
177
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Form Description"), Mage::helper("adminhtml")->__("Form Description"));
178
+
179
+ $this->_addContent($this->getLayout()->createBlock("formbuilder/adminhtml_formbuilder_edit"))->_addLeft($this->getLayout()->createBlock("formbuilder/adminhtml_formbuilder_edit_tabs"));
180
+
181
+ $this->renderLayout();
182
+ }
183
+ public function saveAction()
184
+ {
185
+ if ($data = $this->getRequest()->getPost())
186
+ {
187
+ /*echo "<pre>";
188
+ print_r($data);
189
+ echo "</pre>";
190
+ exit();*/
191
+
192
+ $model = Mage::getModel("formbuilder/forms")->load($this->getRequest()->getParam("id"));
193
+ $currentFormId = $this->getRequest()->getParam("id");
194
+
195
+ //save image
196
+ try
197
+ {
198
+ if((bool)$data['title_image']['delete']==1)
199
+ {
200
+ $data['title_image']='';
201
+ }
202
+ else
203
+ {
204
+ unset($data['title_image']);
205
+ if (isset($_FILES))
206
+ {
207
+ if ($_FILES['title_image']['name'])
208
+ {
209
+ if($this->getRequest()->getParam("id"))
210
+ {
211
+ //$model = Mage::getModel("formbuilder/forms")->load($this->getRequest()->getParam("id"));
212
+ if($model->getData('title_image'))
213
+ {
214
+ $io = new Varien_Io_File();
215
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('title_image'))));
216
+ }
217
+ }
218
+ $path = Mage::getBaseDir('media') . DS . 'formbuilder/images' . DS;
219
+ $uploader = new Varien_File_Uploader('title_image');
220
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
221
+ $uploader->setAllowRenameFiles(false);
222
+ $uploader->setFilesDispersion(false);
223
+ $destFile = $path.$_FILES['title_image']['name'];
224
+ $filename = $uploader->getNewFileName($destFile);
225
+ $uploader->save($path, $filename);
226
+
227
+ $data['title_image']='formbuilder/images/'.$filename;
228
+ }
229
+ }
230
+ }
231
+ }
232
+ catch (Exception $e)
233
+ {
234
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
235
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
236
+ return;
237
+ }
238
+ //save image ends
239
+ try
240
+ {
241
+ //$model = Mage::getModel("formbuilder/forms")->load($this->getRequest()->getParam("id"));
242
+ if(isset($data['stores']) && !empty($data['stores']))
243
+ {
244
+ if(in_array('0',$data['stores'])){
245
+ $data['stores'] = array(0);
246
+ }
247
+ //$stores = Mage::helper('core')->jsonEncode($data['stores']);
248
+ $data['stores'] = implode(',',$data['stores']);
249
+ }
250
+ if ($model->getCreatedTime() == NULL)
251
+ {
252
+ $data['created_time'] = now();
253
+ }
254
+ $data['update_time'] = now();
255
+
256
+ /*$fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
257
+ $getFieldsCollection = $fieldsModel->getFieldsCollection($currentFormId);
258
+ $getNoOfFields = count($getFieldsCollection);
259
+ $data['no_of_fields'] = $getNoOfFields;*/
260
+
261
+ /*if($data['title']=='' || $data['title']==NULL)
262
+ $data['title'] = $model['title'];*/
263
+
264
+ /*$data['title'] = $data['in_toplinks'];
265
+ $data['title_image'] = $data['in_menu'];*/
266
+
267
+ $model->addData($data)
268
+ ->setFormsIndex($this->getRequest()->getParam("id"))
269
+ ->save();
270
+
271
+ if(!$currentFormId)
272
+ $currentFormId = $model->getFormsIndex();
273
+ // saveFields
274
+ $fieldsArray = $data['product']['options'];
275
+ //Mage::helper('formbuilder')->saveFields($fieldsArray);
276
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
277
+ $fieldsModel->saveFields($fieldsArray,$currentFormId);
278
+ // saveFields
279
+
280
+ //save no of fields
281
+ $fieldsModel = Mage::helper('formbuilder')->getFieldsModel();
282
+ $getFieldsCollection = $fieldsModel->getFieldsCollection($currentFormId);
283
+ $getNoOfFields = count($getFieldsCollection);
284
+ //$data['no_of_fields'] = $getNoOfFields;
285
+ $formsModel = Mage::helper('formbuilder')->getFormsModel();
286
+ $formsModel->load($currentFormId);
287
+ $formsModel->setNoOfFields($getNoOfFields);
288
+ $formsModel->save();
289
+ //save no of fields ends
290
+
291
+ //$this->createCmsPage($model);
292
+
293
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('formbuilder')->__('Form was successfully saved'));
294
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
295
+
296
+ if ($this->getRequest()->getParam('back')) {
297
+ $this->_redirect('*/*/edit', array('id' => $model->getFormsIndex()));
298
+ return;
299
+ }
300
+ $this->_redirect('*/*/');
301
+ return;
302
+ }
303
+ catch (Exception $e)
304
+ {
305
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
306
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
307
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
308
+ return;
309
+ }
310
+ }
311
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('formbuilder')->__('Unable to find Form to save'));
312
+ $this->_redirect('*/*/');
313
+ }
314
+ public function createCmsPage($currentModel)
315
+ {
316
+ $title = $currentModel['title'];
317
+ $identifier = strtolower($title);
318
+ $identifier = str_replace(" ","-",$identifier);
319
+
320
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
321
+ $cmsPage = array(
322
+ 'title' => $title,
323
+ 'identifier' => $identifier,
324
+ 'content' => '{{block type="formbuilder/frontend_form" name="frontend_form" template="formbuilder/form.phtml"}}',
325
+ 'is_active' => 1,
326
+ 'sort_order' => 0,
327
+ 'stores' => array(0),
328
+ 'root_template' => 'one_column'
329
+ );
330
+ Mage::getModel('cms/page')->setData($cmsPage)->save();
331
+ }
332
+ public function deleteAction()
333
+ {
334
+ if( $this->getRequest()->getParam('id') > 0 )
335
+ {
336
+ try
337
+ {
338
+ $model = Mage::getModel('formbuilder/forms');
339
+
340
+ $model->setFormsIndex($this->getRequest()->getParam('id'))
341
+ ->delete();
342
+
343
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Form was successfully deleted'));
344
+ $this->_redirect('*/*/');
345
+ }
346
+ catch (Exception $e)
347
+ {
348
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
349
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
350
+ }
351
+ }
352
+ $this->_redirect('*/*/');
353
+ }
354
+ public function massDeleteAction()
355
+ {
356
+ $formbuilderIds = $this->getRequest()->getParam('formbuilder');
357
+ if(!is_array($formbuilderIds))
358
+ {
359
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Form(s)'));
360
+ }
361
+ else
362
+ {
363
+ try
364
+ {
365
+ foreach ($formbuilderIds as $formbuilderId)
366
+ {
367
+ $formbuilder = Mage::getModel('formbuilder/forms')->load($formbuilderId);
368
+ $formbuilder->delete();
369
+ }
370
+ Mage::getSingleton('adminhtml/session')->addSuccess(
371
+ Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($formbuilderIds)));
372
+ }
373
+ catch (Exception $e)
374
+ {
375
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
376
+ }
377
+ }
378
+ $this->_redirect('*/*/index');
379
+ }
380
+ public function massStatusAction()
381
+ {
382
+ $formbuilderIds = $this->getRequest()->getParam('formbuilder');
383
+ if(!is_array($formbuilderIds))
384
+ {
385
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Form(s)'));
386
+ }
387
+ else
388
+ {
389
+ try
390
+ {
391
+ foreach ($formbuilderIds as $formbuilderId)
392
+ {
393
+ $formbuilder = Mage::getSingleton('formbuilder/forms')
394
+ ->load($formbuilderId)
395
+ ->setStatus($this->getRequest()->getParam('status'))
396
+ ->setIsMassupdate(true)
397
+ ->save();
398
+ }
399
+ $this->_getSession()->addSuccess(
400
+ $this->__('Total of %d record(s) were successfully updated', count($formbuilderIds)));
401
+ }
402
+ catch (Exception $e)
403
+ {
404
+ $this->_getSession()->addError($e->getMessage());
405
+ }
406
+ }
407
+ $this->_redirect('*/*/index');
408
+ }
409
+ }
app/code/community/Phxsolution/Formbuilder/controllers/IndexController.php ADDED
@@ -0,0 +1,571 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend controller
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Formbuilder_IndexController extends Mage_Core_Controller_Front_Action
29
+ {
30
+ protected $_errors = array();
31
+ protected $_fieldsModel;
32
+ protected $_fieldTitle;
33
+ protected $_currentFormId;
34
+ protected $_fileType;
35
+ protected $_recordsModel;
36
+ protected $_fileObject;
37
+
38
+ public function preDispatch()
39
+ {
40
+ parent::preDispatch();
41
+ if(!Mage::helper('formbuilder')->isEnabled())
42
+ {
43
+ //$this->_redirectUrl(Mage::helper('core/url')->getHomeUrl());
44
+ $helper = Mage::helper('formbuilder');
45
+ $session = Mage::getSingleton('core/session');
46
+ $session->addError($helper->__("Formbuilder Extension seems disabled."));
47
+ }
48
+ }
49
+ public function indexAction()
50
+ {
51
+ $this->loadLayout();
52
+ $this->getLayout()->getBlock("head")->setTitle($this->__("Formbuilder"));
53
+
54
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
55
+ $breadcrumbs->addCrumb("home", array(
56
+ "label" => $this->__("Home"),
57
+ "title" => $this->__("Home"),
58
+ "link" => Mage::getBaseUrl()
59
+ ));
60
+ $breadcrumbs->addCrumb("formbuilder", array(
61
+ "label" => $this->__("Formbuilder"),
62
+ "title" => $this->__("Formbuilder")
63
+ ));
64
+ $this->renderLayout();
65
+ }
66
+ public function viewAction()
67
+ {
68
+ $id = $this->getRequest()->getParam('id');
69
+ $formsModel = Mage::helper('formbuilder')->getFormsModel();
70
+ $formsModel->load($id);
71
+ if(empty($formsModel['forms_index']))
72
+ {
73
+ Mage::getSingleton('core/session')->addError('Form not found');
74
+ //$this->_redirectUrl(Mage::helper('core/url')->getHomeUrl());
75
+ $this->_redirectUrl( Mage::getUrl('formbuilder') );
76
+ }
77
+ Mage::register('frontend_form',$formsModel);
78
+
79
+ $this->loadLayout();
80
+
81
+ $this->_currentFormId = intval($id);
82
+ $currentForm = Mage::helper('formbuilder')->getCurrentFormDetails($this->_currentFormId);
83
+ $currentFormTitle = "";
84
+ $currentFormTitle = $currentForm['title'];
85
+
86
+ if($currentFormTitle)
87
+ $this->getLayout()->getBlock("head")->setTitle($this->__($currentFormTitle));
88
+ else
89
+ $this->getLayout()->getBlock("head")->setTitle($this->__("Formbuilder"));
90
+
91
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
92
+ $breadcrumbs->addCrumb("home", array(
93
+ "label" => $this->__("Home"),
94
+ "title" => $this->__("Home"),
95
+ "link" => Mage::getBaseUrl()
96
+ ));
97
+ if($currentFormTitle)
98
+ {
99
+ $breadcrumbs->addCrumb("formbuilder", array(
100
+ "label" => $this->__("Formbuilder"),
101
+ "title" => $this->__("Formbuilder"),
102
+ "link" => Mage::getUrl('formbuilder')
103
+ ));
104
+ $breadcrumbs->addCrumb($currentFormTitle, array(
105
+ "label" => $this->__($currentFormTitle),
106
+ "title" => $this->__($currentFormTitle)
107
+ ));
108
+ }
109
+ else
110
+ {
111
+ $breadcrumbs->addCrumb("formbuilder", array(
112
+ "label" => $this->__("Formbuilder"),
113
+ "title" => $this->__("Formbuilder")
114
+ ));
115
+ }
116
+ $this->renderLayout();
117
+ }
118
+ public function checkEmpty($value)
119
+ {
120
+ $error = false;
121
+ if(!Zend_Validate::is($value, 'NotEmpty'))
122
+ $error = $this->_helper->__("'".$this->_fieldTitle."'".' is a required field');
123
+ return $error;
124
+ }
125
+ public function checkLength($value,$lengthLimit)
126
+ {
127
+ $error = false;
128
+ if(strlen($value)>$lengthLimit)
129
+ $error = $this->_helper->__("'".$this->_fieldTitle."'".' text length must be less then or equal to '.$lengthLimit);
130
+ return $error;
131
+ }
132
+ public function checkFile()
133
+ {
134
+ $fileErrorsArray = array();
135
+ foreach ($this->_fileObject as $key => $value)
136
+ {
137
+ $this->_fileCanBeUploaded = true;
138
+
139
+ list($pre,$fileKey,$post) = explode('_',$key);
140
+ $this->_fieldsModel->load($fileKey);
141
+ $this->_fieldTitle = $this->_fieldsModel['title'];
142
+ if($value['name']=='')
143
+ {
144
+ $this->_fileCanBeUploaded = false;
145
+ if($this->_fieldsModel['is_require'])
146
+ {
147
+ $fileErrorsArray[] = "'".$this->_fieldTitle."' is a required field";
148
+ }
149
+ }
150
+ else
151
+ {
152
+ $allowed = explode(',',$this->_fieldsModel['file_extension']);
153
+ $filename = $value['name'];
154
+ $ext = pathinfo($filename, PATHINFO_EXTENSION);
155
+
156
+ $fileTypeString = $value['type'];
157
+ list($fileType,$fileExtension) = explode('/',$fileTypeString);
158
+
159
+ if(!in_array($ext,$allowed) )
160
+ {
161
+ $fileErrorsArray[] = "'".$this->_fieldTitle."' has invalid extension";
162
+ $this->_fileCanBeUploaded = false;
163
+ }
164
+ elseif($fileType=='image' && $this->_fieldsModel['image_size_x'] || $this->_fieldsModel['image_size_y'])
165
+ {
166
+ $image_info = getimagesize($value['tmp_name']);
167
+ $image_width = $image_info[0];
168
+ $image_height = $image_info[1];
169
+ $specified_width=$this->_fieldsModel['image_size_x'];
170
+ $specified_height=$this->_fieldsModel['image_size_y'];
171
+ if( $image_width > $specified_width && $image_height > $specified_height )
172
+ {
173
+ $fileErrorsArray[] = "'".$this->_fieldTitle."' has invalid size";
174
+ $this->_fileCanBeUploaded = false;
175
+ }
176
+ }
177
+ }
178
+ if($this->_validateDataErrorsCount==0 && $this->_fileCanBeUploaded)
179
+ $this->_filesToBeUploaded[] = $key;
180
+ }
181
+ return $fileErrorsArray;
182
+ }
183
+ public function validateDate($month,$day,$year,$fieldId)
184
+ {
185
+ $yearRange = $this->_helper->getYearRange();
186
+ list($yearFrom,$yearTo) = explode(',',$yearRange);
187
+
188
+ if( !checkDate($month,$day,$year) || $year<$yearFrom || $year>$yearTo )
189
+ return "'".$this->_fieldTitle."' is not valid";
190
+ $day += 1;
191
+ $dateToFormat = "$year-$month-$day";
192
+ //$dateToFormat = '2011-12-11';
193
+ $this->_dateToBeSaved[$fieldId] = Mage::helper('core')->formatDate($dateToFormat, 'long', false);
194
+ return;
195
+ }
196
+ public function validateTime($hour="",$minute="",$day_part="",$fieldId)
197
+ {
198
+ $timeFormat = $this->_helper->getTimeFormat();
199
+ if($timeFormat=='12h' && $hour && $minute && $day_part)
200
+ {
201
+ //12 hour format (12:50PM)
202
+ $time12 = "$hour:$minute$day_part";
203
+ $res = preg_match('/^(0[1-9]|1[0-2]):([0-5][0-9])(am|pm)$/', $time12);
204
+ if (!$time12 || !$res)
205
+ return "'".$this->_fieldTitle."' is not valid";
206
+ if($this->_fieldsModel['type']=='date_time')
207
+ $this->_dateToBeSaved[$fieldId] .= ", $time12";
208
+ elseif($this->_fieldsModel['type']=='time')
209
+ $this->_dateToBeSaved[$fieldId] .= "$time12";
210
+ return;
211
+ }
212
+ elseif($timeFormat=='24h' && $hour && $minute)
213
+ {
214
+ //24 hour format (00:00:00)
215
+ $time24 = "$hour:$minute:00";
216
+ $res = preg_match("/^([0-2][0-3]|[01]?[1-9]):([0-5]?[0-9]):([0-5]?[0-9])$/", $time24);
217
+ if (!$time24 || !$res)
218
+ return "'".$this->_fieldTitle."' is not valid";
219
+ if($this->_fieldsModel['type']=='date_time')
220
+ $this->_dateToBeSaved[$fieldId] .= ", $time24";
221
+ elseif($this->_fieldsModel['type']=='time')
222
+ $this->_dateToBeSaved[$fieldId] .= "$time24";
223
+ return;
224
+ }
225
+ return "'".$this->_fieldTitle."' is not valid";
226
+ }
227
+ public function checkDate( $dateArray,$fieldId )
228
+ {
229
+ $month=$day=$year=$hour=$minute=$day_part="";
230
+ foreach ($dateArray as $key => $value)
231
+ {
232
+ if($key=='date')
233
+ list($month,$day,$year) = explode('/',$value);
234
+ elseif($key=='day')
235
+ $day = $value;
236
+ elseif($key=='month')
237
+ $month = $value;
238
+ elseif($key=='year')
239
+ $year = $value;
240
+ elseif($key=='hour')
241
+ {
242
+ if($value>=0 && $value<=9)
243
+ $hour = '0'.$value;
244
+ else
245
+ $hour = $value;
246
+ }
247
+ elseif($key=='minute')
248
+ {
249
+ if($value>=0 && $value<=9)
250
+ $minute = '0'.$value;
251
+ else
252
+ $minute = $value;
253
+ }
254
+ elseif($key=='day_part')
255
+ $day_part = $value;
256
+ }
257
+ $this->_dateToBeSaved[$fieldId] = "";
258
+ if($this->_fieldsModel['type']=='date')
259
+ {
260
+ if($month && $day && $year)
261
+ return $this->validateDate($month,$day,$year,$fieldId);
262
+ }
263
+ elseif($this->_fieldsModel['type']=='date_time')
264
+ {
265
+ if($month && $day && $year)
266
+ {
267
+ if($error = $this->validateDate($month,$day,$year,$fieldId))
268
+ return $error;
269
+ else
270
+ return $this->validateTime($hour,$minute,$day_part,$fieldId);
271
+ }
272
+ }
273
+ elseif($this->_fieldsModel['type']=='time')
274
+ {
275
+ if($hour && $minute)
276
+ return $this->validateTime($hour,$minute,$day_part,$fieldId);
277
+ }
278
+ return false;
279
+ }
280
+ public function checkCheckbox($checkboxArray,$fieldId)
281
+ {
282
+ return "checkboxArray = ".implode(',',$checkboxArray);
283
+ }
284
+ public function _validateData($data)
285
+ {
286
+ $this->_currentFormId = $data['current_form_id'];
287
+ $errorsArray = $this->_fileErrorsArray = array();
288
+ $this->_fieldsModel = $this->_helper->getFieldsModel();
289
+ $previousKey = 0;
290
+
291
+ $optionsDataArray = $verifiedCheckboxIds = $allCheckboxTypeIds = array();
292
+ $optionsDataArray = $data['options'];
293
+ foreach ($optionsDataArray as $key => $value)
294
+ {
295
+ $this->_fieldsModel->load($key);
296
+ $this->_fieldTitle = $this->_fieldsModel['title'];
297
+ if($this->_fieldsModel['forms_index']==$this->_currentFormId)
298
+ {
299
+ if(is_array($value))
300
+ {
301
+ foreach ($value as $key2 => $value2)
302
+ {
303
+ if($previousKey!=$key)
304
+ {
305
+ if($this->_fieldsModel['is_require'])
306
+ {
307
+ $errorsArray[] = $this->checkEmpty($value2);
308
+ if($this->_fieldsModel['type']=='checkbox')
309
+ $verifiedCheckboxIds[] = $key;
310
+ }
311
+ if($lengthLimit = $this->_fieldsModel['max_characters'])
312
+ $errorsArray[] = $this->checkLength($value2,$lengthLimit);
313
+ if($this->_fieldsModel['previous_group']=='date')
314
+ {
315
+ $fieldId = $key;
316
+ $errorsArray[] = $this->checkDate( $optionsDataArray[$key],$fieldId );
317
+ }
318
+ //$errorsArray[] = "key = ".$key;
319
+ }
320
+ $previousKey = $key;
321
+ }
322
+ }
323
+ else
324
+ {
325
+ if($this->_fieldsModel['is_require'])
326
+ $errorsArray[] = $this->checkEmpty($value);
327
+ if($lengthLimit = $this->_fieldsModel['max_characters'])
328
+ $errorsArray[] = $this->checkLength($value,$lengthLimit);
329
+ //$errorsArray[] = "key = ".$key;
330
+ }
331
+ }
332
+ }
333
+ // validate checkbox
334
+ $allCheckboxTypeIds = $this->_fieldsModel->getCheckboxTypeIds($this->_currentFormId);
335
+ if(count($allCheckboxTypeIds))
336
+ {
337
+ foreach ($allCheckboxTypeIds as $key => $value)
338
+ {
339
+ $checkboxId = implode(',',$value);
340
+ $this->_fieldsModel->load($checkboxId);
341
+ $title = $this->_fieldsModel['title'];
342
+ $isRequired = ($this->_fieldsModel['is_require']) ? true : false;
343
+ if( !in_array( $checkboxId,$verifiedCheckboxIds ) && $isRequired )
344
+ $errorsArray[] = "'".$title."' is a required field";
345
+ }
346
+ }
347
+ $count=0;
348
+ $errorsArrayFinal = array();
349
+ foreach ($errorsArray as $key => $value)
350
+ {
351
+ if(!empty($value))
352
+ {
353
+ $count++;
354
+ $errorsArrayFinal[] = $value;
355
+ }
356
+ }
357
+ $this->_validateDataErrorsCount = $count;
358
+ $this->_fileErrorsArray = $this->checkFile();
359
+ foreach ($this->_fileErrorsArray as $key => $value)
360
+ {
361
+ if(!empty($value))
362
+ $errorsArrayFinal[] = $value;
363
+ }
364
+ return $errorsArrayFinal;
365
+ }
366
+ public function uploadFile($key)
367
+ {
368
+ try
369
+ {
370
+ $path = Mage::getBaseDir('media') . DS . 'formbuilder/frontend/uploaded_files' . DS;
371
+ $uploader = new Varien_File_Uploader($key);
372
+ //$uploader->setAllowedExtensions(array('jpg','png','gif'));
373
+ $uploader->setAllowRenameFiles(false);
374
+ $uploader->setFilesDispersion(false);
375
+ $destFile = $path.$this->_fileObject[$key]['name'];
376
+ $filename = $uploader->getNewFileName($destFile);
377
+ $uploader->save($path, $filename);
378
+
379
+ return "formbuilder/frontend/uploaded_files/".$filename;
380
+ }
381
+ catch (Exception $e)
382
+ {
383
+ $this->_session->addError($this->_helper->__("Error uploading file"));
384
+ return false;
385
+ }
386
+ }
387
+ public function _saveData($data)
388
+ {
389
+ $this->_fieldsModel = $this->_helper->getFieldsModel();
390
+ $this->_optionsModel = $this->_helper->getOptionsModel();
391
+ $returnStatus = false;
392
+
393
+ $optionsDataArray = array();
394
+ $optionsDataArray = $data['options'];
395
+
396
+ $serialized = serialize($optionsDataArray);
397
+ $data['forms_index'] = $this->_currentFormId;
398
+ $data['value'] = $serialized;
399
+ $this->_recordsModel->setData($data);
400
+ if($this->_recordsModel->save())
401
+ $returnStatus = true;
402
+ else
403
+ $returnStatus = false;
404
+ return $returnStatus;
405
+
406
+ }
407
+ public function formsubmitAction()
408
+ {
409
+ $errors = array();
410
+ $this->_helper = Mage::helper('formbuilder');
411
+ $session = Mage::getSingleton('core/session');
412
+ $this->_session = $session;
413
+ $customerSession = Mage::getSingleton('customer/session');
414
+ $this->_getLimitFormSubmissionForGuest = $this->_helper->getLimitFormSubmissionForGuest();
415
+ $this->_getLimitFormSubmissionForRegistered = $this->_helper->getLimitFormSubmissionForRegistered();
416
+ $this->_getRedirectUrl = $this->_helper->getRedirectUrl();
417
+
418
+ if (!$this->_helper->isEnabled())
419
+ {
420
+ $session->addError($this->_helper->__('Formbuilder Extension seems disabled, Please contact Administrator.'));
421
+ $this->_redirectUrl(Mage::helper('core/url')->getHomeUrl());
422
+ return;
423
+ }
424
+ else
425
+ {
426
+ if($data = $this->getRequest()->getPost())
427
+ {
428
+ //field=11, form=9
429
+ $this->_helper->setFormData($data['options'][11]);
430
+ $this->_currentFormId = $data['current_form_id'];
431
+ $this->_recordsModel = $this->_helper->getRecordsModel();
432
+
433
+ if($this->_helper->registeredOnly() && !$customerSession->isLoggedIn())
434
+ {
435
+ if(!$customerSession->isLoggedIn())
436
+ {
437
+ $session->addError($this->_helper->__('You must be logged in to submit.'));
438
+ $this->_redirectReferer();
439
+ return;
440
+ }
441
+ else//logged in user
442
+ {
443
+ $customer = $this->_helper->getCustomerInfo();
444
+ //save customer id
445
+ $customerId = $customer->getId();
446
+ //check form submission
447
+ if($this->_getLimitFormSubmissionForRegistered)
448
+ {
449
+ $totalRecords = $this->_recordsModel->checkFormSubmissionLimit($customerId,$this->_currentFormId);
450
+ if($totalRecords>=$this->_getLimitFormSubmissionForRegistered)
451
+ {
452
+ $this->_session->addError($this->_helper->__('Can not submit form, limitation of form submission for current user is reached.'));
453
+ $this->_redirectReferer();
454
+ return;
455
+ }
456
+ }
457
+ $data['customer'] = $customerId;
458
+ }
459
+ }
460
+ elseif(!$customerSession->isLoggedIn())//guest user
461
+ {
462
+ $customer = $this->_helper->getCustomerInfo();
463
+ //save customer ip address
464
+ $customerIp = Mage::helper('core/http')->getRemoteAddr();
465
+ //check form submission
466
+ if($this->_getLimitFormSubmissionForGuest)
467
+ {
468
+ $totalRecords = $this->_recordsModel->checkFormSubmissionLimit($customerIp,$this->_currentFormId);
469
+ if($totalRecords>=$this->_getLimitFormSubmissionForGuest)
470
+ {
471
+ $this->_session->addError($this->_helper->__('Can not submit form, limitation of form submission for current user is reached.'));
472
+ $this->_redirectReferer();
473
+ return;
474
+ }
475
+ }
476
+ $data['customer'] = $customerIp;
477
+ }
478
+ elseif($customerSession->isLoggedIn())//logged in user
479
+ {
480
+ $customer = $this->_helper->getCustomerInfo();
481
+ //save customer id
482
+ $customerId = $customer->getId();
483
+ //check form submission
484
+ if($this->_getLimitFormSubmissionForRegistered)
485
+ {
486
+ $totalRecords = $this->_recordsModel->checkFormSubmissionLimit($customerId,$this->_currentFormId);
487
+ if($totalRecords>=$this->_getLimitFormSubmissionForRegistered)
488
+ {
489
+ $this->_session->addError($this->_helper->__('Can not submit form, limitation of form submission for current user is reached.'));
490
+ $this->_redirectReferer();
491
+ return;
492
+ }
493
+ }
494
+ $data['customer'] = $customerId;
495
+ }
496
+ if(isset($_FILES))
497
+ {
498
+ $this->_fileObject = $_FILES;
499
+ }
500
+ $errors = $this->_validateData($data);
501
+ if (!empty($errors))
502
+ {
503
+ foreach ($errors as $error)
504
+ {
505
+ $session->addError($error);
506
+ }
507
+ $this->_redirectReferer();
508
+ return;
509
+ }
510
+ if( count($this->_filesToBeUploaded) )
511
+ {
512
+ foreach ($this->_filesToBeUploaded as $key)
513
+ {
514
+ list($pre,$fileKey,$post) = explode('_',$key);
515
+ if( $res = $this->uploadFile($key) )
516
+ $data['options'][$fileKey] = $res;
517
+ else
518
+ {
519
+ $this->_redirectReferer();
520
+ return;
521
+ }
522
+ }
523
+ }
524
+ if(count($this->_dateToBeSaved))
525
+ {
526
+ foreach ($this->_dateToBeSaved as $id => $date)
527
+ {
528
+ //$this->_session->addError("(id=$id) = ".$date);
529
+ $data['options'][$id] = $date;
530
+ }
531
+ }
532
+
533
+ /*echo "<pre>";
534
+ echo "<h1>printing data</h1>";
535
+ print_r($data);
536
+ echo "<h1>printing data['options']</h1>";
537
+ print_r($data['options']);
538
+ echo "</pre>";
539
+ exit();*/
540
+
541
+ $formsModel = $this->_helper->getFormsModel();
542
+ $formsModel->load($this->_currentFormId);
543
+ if($this->_saveData($data))
544
+ {
545
+ $successText = $formsModel['success_msg'];
546
+ if(!$successText)
547
+ $successText = 'Form submitted successfully, we will reach you soon.';
548
+ $session->addSuccess($this->_helper->__($successText));
549
+ if($this->_getRedirectUrl)
550
+ $this->_redirectUrl(Mage::getUrl($this->_getRedirectUrl));
551
+ //return;
552
+ }
553
+ else
554
+ {
555
+ $failureText = $formsModel['failure_msg'];
556
+ if(!$failureText)
557
+ $failureText = 'Problem occured submitting form.';
558
+ $session->addError($this->_helper->__($failureText));
559
+ }
560
+ $this->_redirectReferer();
561
+ return;
562
+ }
563
+ else
564
+ {
565
+ $session->addNotice($this->_helper->__('The requested page could not be found'));
566
+ $this->_redirectReferer();
567
+ return false;
568
+ }
569
+ }//else extension is enabled
570
+ }
571
+ }
app/code/community/Phxsolution/Formbuilder/etc/config.xml ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category module configuration
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <config>
28
+ <modules>
29
+ <Phxsolution_Formbuilder>
30
+ <version>0.1.0</version>
31
+ </Phxsolution_Formbuilder>
32
+ </modules>
33
+ <frontend>
34
+ <routers>
35
+ <formbuilder>
36
+ <use>standard</use>
37
+ <args>
38
+ <module>Phxsolution_Formbuilder</module>
39
+ <frontName>formbuilder</frontName>
40
+ </args>
41
+ </formbuilder>
42
+ </routers>
43
+ <layout>
44
+ <updates>
45
+ <formbuilder module="Phxsolution_Formbuilder">
46
+ <file>formbuilder.xml</file>
47
+ </formbuilder>
48
+ </updates>
49
+ </layout>
50
+ <events>
51
+ <page_block_html_topmenu_gethtml_before>
52
+ <observers>
53
+ <formbuilder>
54
+ <class>formbuilder/observer</class>
55
+ <method>addToTopmenu</method>
56
+ </formbuilder>
57
+ </observers>
58
+ </page_block_html_topmenu_gethtml_before>
59
+ </events>
60
+ <!-- <translate>
61
+ <modules>
62
+ <Phxsolution_Formbuilder>
63
+ <files>
64
+ <default>Phxsolution_Formbuilder.csv</default>
65
+ </files>
66
+ </Phxsolution_Formbuilder>
67
+ </modules>
68
+ </translate> -->
69
+ <!-- <events>
70
+ <core_block_abstract_prepare_layout_before>
71
+ <observers>
72
+ <nextbits_jquery_prepare_layout_before>
73
+ <class>formbuilder/observer</class>
74
+ <method>prepareLayoutBefore</method>
75
+ </nextbits_jquery_prepare_layout_before>
76
+ </observers>
77
+ </core_block_abstract_prepare_layout_before>
78
+ </events> -->
79
+ </frontend>
80
+ <admin>
81
+ <routers>
82
+ <formbuilder>
83
+ <use>admin</use>
84
+ <args>
85
+ <module>Phxsolution_Formbuilder</module>
86
+ <frontName>formbuilder</frontName>
87
+ </args>
88
+ </formbuilder>
89
+ </routers>
90
+ </admin>
91
+ <adminhtml>
92
+ <menu>
93
+ <formbuilder module="formbuilder">
94
+ <depends>
95
+ <config>formbuilder_section/general/active</config>
96
+ </depends>
97
+ <title>Form Builder</title>
98
+ <sort_order>71</sort_order>
99
+ <children>
100
+ <items module="formbuilder">
101
+ <title>Manage Forms</title>
102
+ <sort_order>0</sort_order>
103
+ <action>formbuilder/adminhtml_formbuilder</action>
104
+ </items>
105
+ <items2 module="formbuilder">
106
+ <title>Add Form</title>
107
+ <sort_order>1</sort_order>
108
+ <action>formbuilder/adminhtml_formbuilder/new</action>
109
+ </items2>
110
+ <items3 module="formbuilder">
111
+ <title>Formbuilder Settings</title>
112
+ <sort_order>2</sort_order>
113
+ <action>adminhtml/system_config/edit/section/formbuilder_section</action>
114
+ </items3>
115
+ <!-- <items4 module="formbuilder">
116
+ <title>Form with Results</title>
117
+ <sort_order>3</sort_order>
118
+ <action>adminhtml/system_config/edit/section/formbuilder_section</action>
119
+ </items4> -->
120
+ </children>
121
+ </formbuilder>
122
+ </menu>
123
+ <acl>
124
+ <resources>
125
+ <all>
126
+ <title>Allow Everything</title>
127
+ </all>
128
+ <admin>
129
+ <children>
130
+ <formbuilder module="formbuilder">
131
+ <title>Phxsolution</title>
132
+ <sort_order>71</sort_order>
133
+ <children>
134
+ <items module="formbuilder">
135
+ <title>Manage Forms</title>
136
+ <sort_order>0</sort_order>
137
+ <action>formbuilder/adminhtml_formbuilder</action>
138
+ </items>
139
+ <items2 module="formbuilder">
140
+ <title>Add Form</title>
141
+ <sort_order>1</sort_order>
142
+ <action>formbuilder/adminhtml_formbuilder/new</action>
143
+ </items2>
144
+ <items3 module="formbuilder">
145
+ <title>Formbuilder Settings</title>
146
+ <sort_order>2</sort_order>
147
+ <action>adminhtml/system_config/edit/section/formbuilder_section</action>
148
+ </items3>
149
+ </children>
150
+ </formbuilder>
151
+ <system>
152
+ <children>
153
+ <config>
154
+ <children>
155
+ <formbuilder_section translate="title" module="formbuilder">
156
+ <title>Phxsolution Formbuilder Section</title>
157
+ </formbuilder_section>
158
+ </children>
159
+ </config>
160
+ </children>
161
+ </system>
162
+ </children>
163
+ </admin>
164
+ </resources>
165
+ </acl>
166
+ <layout>
167
+ <updates>
168
+ <formbuilder>
169
+ <file>formbuilder.xml</file>
170
+ </formbuilder>
171
+ </updates>
172
+ </layout>
173
+ </adminhtml>
174
+ <global>
175
+ <models>
176
+ <formbuilder>
177
+ <class>Phxsolution_Formbuilder_Model</class>
178
+ <resourceModel>formbuilder_mysql4</resourceModel>
179
+ </formbuilder>
180
+ <formbuilder_mysql4>
181
+ <class>Phxsolution_Formbuilder_Model_Mysql4</class>
182
+ <entities>
183
+ <forms>
184
+ <table>formbuilder_forms</table>
185
+ </forms>
186
+ <fields>
187
+ <table>formbuilder_fields</table>
188
+ </fields>
189
+ <options>
190
+ <table>formbuilder_fields_options</table>
191
+ </options>
192
+ <records>
193
+ <table>formbuilder_records</table>
194
+ </records>
195
+ </entities>
196
+ </formbuilder_mysql4>
197
+ </models>
198
+ <resources>
199
+ <formbuilder_setup>
200
+ <setup>
201
+ <module>Phxsolution_Formbuilder</module>
202
+ </setup>
203
+ <connection>
204
+ <use>core_setup</use>
205
+ </connection>
206
+ </formbuilder_setup>
207
+ <formbuilder_write>
208
+ <connection>
209
+ <use>core_write</use>
210
+ </connection>
211
+ </formbuilder_write>
212
+ <formbuilder_read>
213
+ <connection>
214
+ <use>core_read</use>
215
+ </connection>
216
+ </formbuilder_read>
217
+ </resources>
218
+ <blocks>
219
+ <formbuilder>
220
+ <class>Phxsolution_Formbuilder_Block</class>
221
+ </formbuilder>
222
+ <!-- <adminhtml>
223
+ <rewrite>
224
+ <page_menu>Phxsolution_Formbuilder_Block_Adminhtml_Menu</page_menu>
225
+ </rewrite>
226
+ </adminhtml> -->
227
+ <adminhtml>
228
+ <rewrite>
229
+ <catalog_product_edit_tab_options_type_text>Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_Text</catalog_product_edit_tab_options_type_text>
230
+ <catalog_product_edit_tab_options_type_select>Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_Select</catalog_product_edit_tab_options_type_select>
231
+ <catalog_product_edit_tab_options_type_file>Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_File</catalog_product_edit_tab_options_type_file>
232
+ <catalog_product_edit_tab_options_type_date>Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Type_Date</catalog_product_edit_tab_options_type_date>
233
+ </rewrite>
234
+
235
+ </adminhtml>
236
+ <!-- <adminhtml> -->
237
+ <!-- <rewrite>
238
+ <catalog_product_edit_tab_options>Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options</catalog_product_edit_tab_options>
239
+ </rewrite> -->
240
+ <!-- <rewrite>
241
+ <catalog_product_edit_tab_options_option>Phxsolution_Formbuilder_Block_Adminhtml_Formbuilder_Edit_Tab_Options_Option</catalog_product_edit_tab_options_option>
242
+ </rewrite> -->
243
+ <!-- </adminhtml> -->
244
+ </blocks>
245
+ <helpers>
246
+ <formbuilder>
247
+ <class>Phxsolution_Formbuilder_Helper</class>
248
+ </formbuilder>
249
+ </helpers>
250
+ </global>
251
+ <default>
252
+ <formbuilder_section>
253
+ <general>
254
+ <active>1</active>
255
+ </general>
256
+ </formbuilder_section>
257
+ </default>
258
+ <adminhtml>
259
+ <translate>
260
+ <modules>
261
+ <Phxsolution_Formbuilder>
262
+ <files>
263
+ <default>Phxsolution_Formbuilder.csv</default>
264
+ </files>
265
+ </Phxsolution_Formbuilder>
266
+ </modules>
267
+ </translate>
268
+ </adminhtml>
269
+ </config>
app/code/community/Phxsolution/Formbuilder/etc/system.xml ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category module system configuration
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <config>
28
+ <tabs>
29
+ <formbuilder_tab translate="label" module="formbuilder">
30
+ <label>Phxsolution Extensions</label>
31
+ <sort_order>0</sort_order>
32
+ </formbuilder_tab>
33
+ </tabs>
34
+ <sections>
35
+ <formbuilder_section>
36
+ <label>Formbuilder</label>
37
+ <tab>formbuilder_tab</tab>
38
+ <!-- <class>phxsolution-formbuilder</class> -->
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>150</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <groups>
45
+ <general translate="label">
46
+ <label>General Settings</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>11</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <!-- <expanded>1</expanded> -->
53
+ <fields>
54
+ <active translate="label">
55
+ <label>Enable Formbuilder</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>1</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </active>
63
+ </fields>
64
+ <fields>
65
+ <in_toplinks translate="label">
66
+ <label>Display Extension Link in Toplinks</label>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>adminhtml/system_config_source_yesno</source_model>
69
+ <sort_order>2</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </in_toplinks>
74
+ </fields>
75
+ <fields>
76
+ <in_topmenu translate="label">
77
+ <label>Display Extension Link in Topmenu</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>adminhtml/system_config_source_yesno</source_model>
80
+ <sort_order>3</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ </in_topmenu>
85
+ </fields>
86
+ <fields>
87
+ <in_footerlinks translate="label">
88
+ <label>Display Extension Link in Footerlinks</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>adminhtml/system_config_source_yesno</source_model>
91
+ <sort_order>4</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ </in_footerlinks>
96
+ </fields>
97
+ </general>
98
+ <form_submission translate="label">
99
+ <label>Frontend - Form Submission Settings</label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>12</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ <fields>
106
+ <registered_only translate="label">
107
+ <label>Registered customers only</label>
108
+ <frontend_type>select</frontend_type>
109
+ <source_model>adminhtml/system_config_source_yesno</source_model>
110
+ <comment>Set form submission facility only for registered customers.</comment>
111
+ <sort_order>5</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ </registered_only>
116
+ </fields>
117
+ <fields>
118
+ <limit_form_submission_for_guest translate="label">
119
+ <label>Limit form submission for Guest user</label>
120
+ <frontend_type>text</frontend_type>
121
+ <comment>Limit form submission per customer. Customers are identified by IP Address (Guest user), Blank will take unlimited.</comment>
122
+ <sort_order>6</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ <validate>validate-zero-or-greater</validate>
127
+ </limit_form_submission_for_guest>
128
+ <limit_form_submission_for_registered translate="label">
129
+ <label>Limit form submission for Registered user</label>
130
+ <frontend_type>text</frontend_type>
131
+ <comment>Limit form submission per customer. Customers are identified by Customer Id (Registered user), Blank will take unlimited.</comment>
132
+ <sort_order>6</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ <validate>validate-zero-or-greater</validate>
137
+ </limit_form_submission_for_registered>
138
+ </fields>
139
+ <fields>
140
+ <redirect_url translate="label">
141
+ <label>Redirect URL</label>
142
+ <frontend_type>text</frontend_type>
143
+ <comment>Redirect customer to specified URL after successful form submission. Example: customer/account or home or customer-service. (URL added here will be added to base url)</comment>
144
+ <sort_order>7</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ <width>500</width>
149
+ <!-- <validate>validate-url</validate> -->
150
+ </redirect_url>
151
+ </fields>
152
+ </form_submission>
153
+ <custom_options translate="label">
154
+ <label>Frontend - Date &amp; Time Settings</label>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>13</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ <fields>
161
+ <use_calendar translate="label">
162
+ <label>Use JavaScript Calendar</label>
163
+ <frontend_type>select</frontend_type>
164
+ <source_model>adminhtml/system_config_source_yesno</source_model>
165
+ <sort_order>1</sort_order>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>1</show_in_store>
169
+ </use_calendar>
170
+ <date_fields_order translate="label">
171
+ <label>Date Fields Order</label>
172
+ <frontend_type>select</frontend_type>
173
+ <frontend_model>adminhtml/catalog_form_renderer_config_dateFieldsOrder</frontend_model>
174
+ <sort_order>2</sort_order>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>1</show_in_website>
177
+ <show_in_store>1</show_in_store>
178
+ <depends><use_calendar>0</use_calendar></depends>
179
+ </date_fields_order>
180
+ <time_format translate="label">
181
+ <label>Time Format</label>
182
+ <frontend_type>select</frontend_type>
183
+ <source_model>adminhtml/system_config_source_catalog_timeFormat</source_model>
184
+ <sort_order>3</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ </time_format>
189
+ <year_range translate="label comment">
190
+ <label>Year Range</label>
191
+ <comment>Use four-digit year format.</comment>
192
+ <frontend_type>text</frontend_type>
193
+ <frontend_model>adminhtml/catalog_form_renderer_config_yearRange</frontend_model>
194
+ <sort_order>4</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>1</show_in_store>
198
+ </year_range>
199
+ </fields>
200
+ </custom_options>
201
+ </groups>
202
+ </formbuilder_section>
203
+ </sections>
204
+ </config>
app/code/community/Phxsolution/Formbuilder/sql/formbuilder_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category database configuration
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+
29
+ $installer = $this;
30
+
31
+ $installer->startSetup();
32
+
33
+ $installer->run("
34
+
35
+ -- DROP TABLE IF EXISTS {$this->getTable('formbuilder_forms')};
36
+ CREATE TABLE {$this->getTable('formbuilder_forms')} (
37
+ `forms_index` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
38
+ `title` VARCHAR(255) NOT NULL,
39
+ `no_of_fields` INT(50) NULL DEFAULT '0',
40
+ `status` SMALLINT(6) NOT NULL DEFAULT '2',
41
+ `stores` TEXT NULL,
42
+ `header_content` text NOT NULL ,
43
+ `footer_content` text NOT NULL ,
44
+ `success_msg` VARCHAR(255) NULL,
45
+ `failure_msg` VARCHAR(255) NULL,
46
+ `submit_text` VARCHAR(255) NULL,
47
+ `in_menu` SMALLINT(6) NULL DEFAULT '0',
48
+ `in_toplinks` SMALLINT(6) NULL DEFAULT '0',
49
+ `title_image` VARCHAR(255) NULL,
50
+ `bgcolor` VARCHAR(25) NULL DEFAULT '#fbfaf6',
51
+ `created_time` DATETIME NULL DEFAULT NULL,
52
+ `update_time` DATETIME NULL DEFAULT NULL,
53
+ PRIMARY KEY (`forms_index`)
54
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
55
+
56
+ ");
57
+
58
+ $installer->run("
59
+
60
+ -- DROP TABLE IF EXISTS {$this->getTable('formbuilder_fields')};
61
+ CREATE TABLE {$this->getTable('formbuilder_fields')} (
62
+ `fields_index` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
63
+ `forms_index` INT(11) NOT NULL,
64
+ `status` SMALLINT(6) NOT NULL DEFAULT '0',
65
+ `previous_group` VARCHAR(25) NOT NULL,
66
+ `type` VARCHAR(25) NOT NULL,
67
+ `title` VARCHAR(255) NOT NULL,
68
+ `field_id` INT(11) NOT NULL,
69
+ `options` SMALLINT(6) NOT NULL DEFAULT '0',
70
+ `max_characters` INT(11) NULL,
71
+ `sort_order` INT(11) NULL,
72
+ `is_require` SMALLINT(6) NOT NULL DEFAULT '0',
73
+ `is_delete` SMALLINT(6) NULL,
74
+ `file_extension` VARCHAR(255) NULL,
75
+ `image_size_x` INT(11) NULL,
76
+ `image_size_y` INT(11) NULL,
77
+ `previous_type` VARCHAR(25) NULL,
78
+ `option_id` INT(11) NOT NULL DEFAULT '0',
79
+ PRIMARY KEY (`fields_index`)
80
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
81
+
82
+ ");
83
+
84
+ $installer->run("
85
+
86
+ -- DROP TABLE IF EXISTS {$this->getTable('formbuilder_fields_options')};
87
+ CREATE TABLE {$this->getTable('formbuilder_fields_options')} (
88
+ `options_index` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
89
+ `option_id` INT(11) UNSIGNED NOT NULL,
90
+ `fields_index` INT(11) NOT NULL,
91
+ `is_delete` SMALLINT(6) NULL,
92
+ `title` VARCHAR(255) NOT NULL,
93
+ `sort_order` INT(11) NULL,
94
+ PRIMARY KEY (`options_index`)
95
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
96
+
97
+ ");
98
+
99
+ $installer->run("
100
+
101
+ -- DROP TABLE IF EXISTS {$this->getTable('formbuilder_records')};
102
+ CREATE TABLE {$this->getTable('formbuilder_records')} (
103
+ `records_index` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
104
+ `forms_index` INT(11) NOT NULL,
105
+ `customer` VARCHAR(255) NOT NULL,
106
+ `fields_index` INT(11) NOT NULL,
107
+ `options_index` VARCHAR(255) NULL,
108
+ `value` text NULL,
109
+ PRIMARY KEY (`records_index`)
110
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
111
+
112
+ ");
113
+
114
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/formbuilder.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml layout
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <layout version="0.1.0">
28
+ <default>
29
+ <reference name="head">
30
+ <!-- <action method="addItem"><type>skin_js</type><name>js/formbuilder/jscolor/jscolor.js</name></action> -->
31
+ <action method="addJs">
32
+ <script>formbuilder/jscolor/jscolor.js</script>
33
+ <!-- <script>formbuilder/procolor-1.0/procolor.compressed.js</script> -->
34
+ </action>
35
+ <!-- <action method="setCanLoadExtJs"><flag>1</flag></action>
36
+ <action method="setCanLoadTinyMce"><flag>1</flag></action>
37
+ <action method="addJs"><script>prototype/prototype.js</script></action>
38
+ <action method="addJs"><script>mage/adminhtml/variables.js</script></action>
39
+ <action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
40
+ <action method="addJs"><script>lib/flex.js</script></action>
41
+ <action method="addJs"><script>lib/FABridge.js</script></action>
42
+ <action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
43
+ <action method="addJs"><script>mage/adminhtml/browser.js</script></action>
44
+ <action method="addJs"><script>prototype/window.js</script></action>
45
+ <action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
46
+ <action method="addCss"><name>lib/prototype/windows/themes/magento.css</name></action> -->
47
+ </reference>
48
+ </default>
49
+ <formbuilder_adminhtml_formbuilder_index>
50
+ <update handle="editor_index_index"/>
51
+ <reference name="content">
52
+ <block type="formbuilder/adminhtml_formbuilder" name="formbuilder" />
53
+ </reference>
54
+ </formbuilder_adminhtml_formbuilder_index>
55
+ <!-- <formbuilder_adminhtml_formbuilder_product>
56
+ <block type="core/text_list" name="root" output="toHtml">
57
+ <block type="formbuilder/adminhtml_formbuilder_edit_tab_product" name="product.grid"/>
58
+ <block type="adminhtml/widget_grid_serializer" name="grid_serializer">
59
+ <reference name="grid_serializer">
60
+ <action method="initSerializerBlock">
61
+ <grid_block_name>product.grid</grid_block_name>
62
+ <data_callback>getSelectedProducts</data_callback>
63
+ <hidden_input_name>links[products]</hidden_input_name>
64
+ <reload_param_name>products</reload_param_name>
65
+ </action>
66
+ <action method="addColumnInputName">
67
+ <input_name>position</input_name>
68
+ </action>
69
+ </reference>
70
+ </block>
71
+ </block>
72
+ </formbuilder_adminhtml_formbuilder_product>-->
73
+ <!-- <formbuilder_adminhtml_formbuilder_productgrid>
74
+ <block type="core/text_list" name="root" output="toHtml">
75
+ <block type="formbuilder/adminhtml_formbuilder_edit_tab_product" name="product.grid"/>
76
+ </block>
77
+ </formbuilder_adminhtml_formbuilder_productgrid> -->
78
+ <formbuilder_adminhtml_formbuilder_options>
79
+ <block type="core/text_list" name="root" output="toHtml">
80
+ <block type="formbuilder/adminhtml_formbuilder_edit_tab_options" name="admin.product.options"/>
81
+ </block>
82
+ </formbuilder_adminhtml_formbuilder_options>
83
+ </layout>
app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options.phtml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <div class="entry-edit custom-options product-custom-options">
28
+ <div id="dynamic-price-warrning" style="display:none">
29
+ <ul class="messages">
30
+ <li class="error-msg">
31
+ <ul>
32
+ <li><?php echo $this->__('Bundle with dynamic pricing cannot include custom defined options. Options will not be saved.') ?></li>
33
+ </ul>
34
+ </li>
35
+ </ul>
36
+ </div>
37
+ <div class="entry-edit-head">
38
+ <h4><?php echo Mage::helper('catalog')->__('Form Creator') ?></h4>
39
+ <div class="right"><?php echo $this->getAddButtonHtml() ?></div>
40
+ </div>
41
+
42
+ <div id="product_options_container" class="box">
43
+ <div id="product_options_container_top"></div>
44
+ <?php echo $this->getOptionsBoxHtml() ?>
45
+ </div>
46
+ </div>
47
+
48
+ <script type="text/javascript">
49
+ // re-bind form elements onchange
50
+ varienWindowOnload(true);
51
+ //show error message
52
+ if ($('price_type')) {
53
+ if ($('price_type').value == '0' && $('dynamic-price-warrning')) {
54
+ $('dynamic-price-warrning').show();
55
+ }
56
+ }
57
+ </script>
app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/option.phtml ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php echo $this->getTemplatesHtml() ?>
28
+
29
+ <script type="text/javascript">
30
+ //<![CDATA[
31
+ var firstStepTemplate = '<div class="option-box" id="option_{{id}}">'+
32
+ '<table id="<?php echo $this->getFieldId() ?>_{{id}}" class="option-header" cellpadding="0" cellspacing="0">'+
33
+ '<input type="hidden" id="<?php echo $this->getFieldId() ?>_{{id}}_is_delete" name="<?php echo $this->getFieldName() ?>[{{id}}][is_delete]" value="" />'+
34
+ '<input type="hidden" id="<?php echo $this->getFieldId() ?>_{{id}}_previous_type" name="<?php echo $this->getFieldName() ?>[{{id}}][previous_type]" value="{{type}}" />'+
35
+ '<input type="hidden" id="<?php echo $this->getFieldId() ?>_{{id}}_previous_group" name="<?php echo $this->getFieldName() ?>[{{id}}][previous_group]" value="" />'+
36
+ '<input type="hidden" id="<?php echo $this->getFieldId() ?>_{{id}}_id" name="<?php echo $this->getFieldName() ?>[{{id}}][id]" value="{{id}}" />'+
37
+ '<input type="hidden" id="<?php echo $this->getFieldId() ?>_{{id}}_option_id" name="<?php echo $this->getFieldName() ?>[{{id}}][option_id]" value="{{option_id}}" />'+
38
+ '<thead>'+
39
+ '<tr>'+
40
+ '<th class="opt-title"><?php echo Mage::helper('catalog')->__('Title') ?> <span class="required">*</span></th>'+
41
+ '<th class="opt-type"><?php echo Mage::helper('catalog')->__('Input Type') ?> <span class="required">*</span></th>'+
42
+ '<th class="opt-req"><?php echo $this->jsQuoteEscape(Mage::helper('catalog')->__('Is Required')) ?></th>'+
43
+ '<th class="opt-req"><?php echo $this->jsQuoteEscape(Mage::helper('catalog')->__('Enable')) ?></th>'+
44
+ '<th class="opt-order"><?php echo Mage::helper('catalog')->__('Sort Order') ?></th>'+
45
+ '<th class="a-right"><?php echo $this->jsQuoteEscape($this->getDeleteButtonHtml()) ?></th>'+
46
+ '</tr>'+
47
+ '</thead>'+
48
+ '<tr>'+
49
+ '<td><input type="text" class="required-entry input-text" id="<?php echo $this->getFieldId() ?>_{{id}}_title" name="<?php echo $this->getFieldName() ?>[{{id}}][title]" value="{{title}}">{{checkboxScopeTitle}}</td>'+
50
+ '<td><?php echo $this->getTypeSelectHtml() ?></td>'+
51
+ '<td class="opt-req"><?php echo $this->getRequireSelectHtml() ?></td>'+
52
+ '<td class="opt-req"><?php echo $this->getStatusHtml() ?></td>'+
53
+ '<td><input type="text" class="validate-zero-or-greater input-text" name="<?php echo $this->getFieldName() ?>[{{id}}][sort_order]" value="{{sort_order}}"></td>'+
54
+ '<td>&nbsp;</td>'+
55
+ '</tr></table></div>';
56
+
57
+ var productOption = {
58
+ div : $('product_options_container_top'),
59
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
60
+ templateText : firstStepTemplate,
61
+ itemCount : 1,
62
+ add : function(data) {
63
+ this.template = new Template(this.templateText, this.templateSyntax);
64
+
65
+ if(!data.id){
66
+ data = {};
67
+ data.id = this.itemCount;
68
+ data.type = '';
69
+ data.option_id = 0;
70
+ } else {
71
+ this.itemCount = data.item_count;
72
+ }
73
+
74
+ Element.insert(this.div, {'after':this.template.evaluate(data)});
75
+
76
+ //set selected type
77
+ if (data.type) {
78
+ $A($('<?php echo $this->getFieldId() ?>_'+data.id+'_type').options).each(function(option){
79
+ if (option.value==data.type) option.selected = true;
80
+ });
81
+ }
82
+
83
+ //set selected is_require
84
+ if (data.is_require) {
85
+ $A($('<?php echo $this->getFieldId() ?>_'+data.id+'_is_require').options).each(function(option){
86
+ if (option.value==data.is_require) option.selected = true;
87
+ });
88
+ }
89
+ //set selected field_status
90
+ if (data.field_status) {
91
+ $A($('<?php echo $this->getFieldId() ?>_'+data.id+'_field_status').options).each(function(option){
92
+ if (option.value==data.field_status) option.selected = true;
93
+ });
94
+ }
95
+
96
+ if (data.checkboxScopeTitle) {
97
+ //set disabled
98
+ if ($('<?php echo $this->getFieldId() ?>_'+data.option_id+'_title') && data.scopeTitleDisabled) {
99
+ $('<?php echo $this->getFieldId() ?>_'+data.option_id+'_title').disable();
100
+ }
101
+ }
102
+
103
+ this.itemCount++;
104
+ this.bindRemoveButtons();
105
+ productOptionType.bindSelectInputType();
106
+ },
107
+ remove : function(event){
108
+ var element = $(Event.findElement(event, 'div'));
109
+ if(element){
110
+ $('product_'+element.readAttribute('id')+'_'+'is_delete').value = '1';
111
+ element.addClassName('no-display');
112
+ element.addClassName('ignore-validate');
113
+ element.hide();
114
+ }
115
+ },
116
+ bindRemoveButtons : function(){
117
+ var buttons = $$('div.product-custom-options .delete-product-option');
118
+ for(var i=0;i<buttons.length;i++){
119
+ if(!$(buttons[i]).binded){
120
+ $(buttons[i]).binded = true;
121
+ Event.observe(buttons[i], 'click', this.remove.bind(this));
122
+ }
123
+ }
124
+ var inputs = $$('div.product-custom-options button', 'div.product-custom-options input', 'div.product-custom-options select', 'div.product-custom-options textarea');
125
+ <?php if ($this->isReadonly()):?>
126
+ for (var i=0, l = inputs.length; i < l; i ++) {
127
+ inputs[i].disabled = true;
128
+ if (inputs[i].tagName.toLowerCase()=='button') {
129
+ inputs[i].addClassName('disabled');
130
+ }
131
+ }
132
+ <?php else: ?>
133
+ inputs.each(function(el) { Event.observe(el, 'change', el.setHasChanges.bind(el)); } )
134
+ <?php endif;?>
135
+ }
136
+ }
137
+
138
+
139
+ var productOptionType = {
140
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
141
+ loadStepTwo : function(event){
142
+ var element = $(Event.findElement(event, 'select'));
143
+
144
+ var group = '';
145
+ var previousGroupElm = $(element.readAttribute('id').sub('_type', '_previous_group'));
146
+
147
+ switch(element.getValue()){
148
+ case 'field':
149
+ case 'area':
150
+ template = OptionTemplateText;
151
+ group = 'text';
152
+ break;
153
+ case 'file':
154
+ template = OptionTemplateFile;
155
+ group = 'file';
156
+ break;
157
+ case 'drop_down':
158
+ case 'radio':
159
+ case 'checkbox':
160
+ case 'multiple':
161
+ template = OptionTemplateSelect;
162
+ group = 'select';
163
+ break;
164
+ case 'date':
165
+ case 'date_time':
166
+ case 'time':
167
+ template = OptionTemplateDate;
168
+ group = 'date';
169
+ break;
170
+ // Instagram image
171
+ /*case 'instagramimage_type':
172
+ template = OptionTemplateInstagramimage;
173
+ group = 'instagramimage';
174
+ break;*/
175
+ default:
176
+ template = '';
177
+ group = 'unknown';
178
+ break;
179
+ }
180
+
181
+ if (previousGroupElm.getValue() != group) {
182
+ if ($(element.readAttribute('id')+'_'+previousGroupElm.getValue())) {
183
+ formElm = $(element.readAttribute('id')+'_'+previousGroupElm.getValue()).descendants();
184
+ formElm.each(function(elm){
185
+ if (elm.tagName == 'input' || elm.tagName == 'select') {
186
+ elm.name = '__delete__'+elm.readAttribute('name');
187
+ }
188
+ });
189
+
190
+ $(element.readAttribute('id')+'_'+previousGroupElm.getValue()).addClassName('no-display');
191
+ $(element.readAttribute('id')+'_'+previousGroupElm.getValue()).addClassName('ignore-validate');
192
+ $(element.readAttribute('id')+'_'+previousGroupElm.getValue()).hide();
193
+ }
194
+
195
+ previousGroupElm.value = group;
196
+
197
+ if ($(element.readAttribute('id')+'_'+group)) {
198
+ formElm = $(element.readAttribute('id')+'_'+group).descendants();
199
+ formElm.each(function(elm){
200
+ if (elm.match('input') || elm.match('select')) {
201
+ elm.name = elm.readAttribute('name').sub('__delete__', '');
202
+ }
203
+ });
204
+ $(element.readAttribute('id')+'_'+group).removeClassName('no-display');
205
+ $(element.readAttribute('id')+'_'+group).removeClassName('ignore-validate');
206
+ $(element.readAttribute('id')+'_'+group).show();
207
+
208
+ } else {
209
+ template = '<div id="'+element.readAttribute('id')+'_'+group+'" class="grid tier form-list">'+template+'</div><div id="'+element.readAttribute('id')+'_'+group+'_advice"></div';
210
+ this.secondTemplate = new Template(template, this.templateSyntax);
211
+
212
+ data = {};
213
+ if (!data.option_id) {
214
+ data = {};
215
+ data.option_id = $(element.readAttribute('id').sub('_type', '_id')).getValue();
216
+ }
217
+
218
+ Element.insert(element.readAttribute('id').sub('_type', ''), {'after':this.secondTemplate.evaluate(data)});
219
+
220
+ switch(element.getValue()){
221
+ case 'drop_down':
222
+ case 'radio':
223
+ case 'checkbox':
224
+ case 'multiple':
225
+ selectOptionType.bindAddButton();
226
+ break;
227
+ }
228
+ }
229
+ }
230
+ },
231
+ addDataToValues : function(data){
232
+
233
+ switch(data.type){
234
+ case 'field':
235
+ case 'area':
236
+ template = OptionTemplateText;
237
+ group = 'text';
238
+ break;
239
+ case 'file':
240
+ template = OptionTemplateFile;
241
+ group = 'file';
242
+ break;
243
+ case 'drop_down':
244
+ case 'radio':
245
+ case 'checkbox':
246
+ case 'multiple':
247
+ template = OptionTemplateSelect;
248
+ group = 'select';
249
+ break;
250
+ case 'date':
251
+ case 'date_time':
252
+ case 'time':
253
+ template = OptionTemplateDate;
254
+ group = 'date';
255
+ break;
256
+ }
257
+
258
+ $('<?php echo $this->getFieldId() ?>_'+data.id+'_previous_group').value = group;
259
+
260
+ template = '<div id="<?php echo $this->getFieldId() ?>_{{id}}_type_'+group+'" class="grid tier form-list">'+template+'</div><div id="<?php echo $this->getFieldId() ?>_{{id}}_type_'+group+'_advice"></div>';
261
+
262
+ this.secondTemplate = new Template(template, this.templateSyntax);
263
+
264
+ Element.insert($('<?php echo $this->getFieldId() ?>_'+data.option_id), {'after':this.secondTemplate.evaluate(data)});
265
+
266
+ if (data.checkboxScopePrice) {
267
+ //set disabled
268
+ if ($('<?php echo $this->getFieldId() ?>_'+data.option_id+'_price') && data.scopePriceDisabled) {
269
+ $('<?php echo $this->getFieldId() ?>_'+data.option_id+'_price').disable();
270
+ $('<?php echo $this->getFieldId() ?>_'+data.option_id+'_price_type').disable();
271
+ }
272
+ }
273
+
274
+ switch(data.type){
275
+ case 'drop_down':
276
+ case 'radio':
277
+ case 'checkbox':
278
+ case 'multiple':
279
+ data.optionValues.each(function(value) {
280
+ selectOptionType.add(value);
281
+ });
282
+ selectOptionType.bindAddButton();
283
+ break;
284
+ }
285
+
286
+ if (data.price_type) {
287
+ $A($('<?php echo $this->getFieldId() ?>_'+data.option_id+'_price_type').options).each(function(option){
288
+ if (option.value==data.price_type) option.selected = true;
289
+ });
290
+ }
291
+
292
+ },
293
+ bindSelectInputType : function(){
294
+ var types = $$('.select-product-option-type');
295
+ for(var i=0;i<types.length;i++){
296
+ if(!$(types[i]).binded){
297
+ $(types[i]).binded = true;
298
+ Event.observe(types[i], 'change', function(event){
299
+ productOptionType.loadStepTwo(event);
300
+ });
301
+ }
302
+ }
303
+ }
304
+ }
305
+
306
+ var productOptionScope = {
307
+ addScope : function(event){
308
+ var element = $(Event.element(event));
309
+ fieldToDisable = $(element.readAttribute('id').sub('_use_default', ''));
310
+
311
+ if (fieldToDisable.disabled) {
312
+ if (fieldToDisable.hasClassName('product-option-price')) {//need change to cheking value of element
313
+ $(fieldToDisable.readAttribute('id')+'_type').enable();
314
+ }
315
+ fieldToDisable.enable();
316
+ } else {
317
+ if (fieldToDisable.hasClassName('product-option-price')) {//need change to cheking value of element
318
+ $(fieldToDisable.readAttribute('id')+'_type').disable();
319
+ }
320
+ fieldToDisable.disable();
321
+ }
322
+ },
323
+ bindScopeCheckbox : function(){
324
+ var checkboxes = $$('.product-option-scope-checkbox');
325
+ for (var i=0;i<checkboxes.length;i++) {
326
+ if (!$(checkboxes[i]).binded) {
327
+ $(checkboxes[i]).binded = true;
328
+ Event.observe(checkboxes[i], 'click', this.addScope.bind(this));
329
+ }
330
+ }
331
+ }
332
+ }
333
+
334
+ if($('option_panel')){
335
+ $('option_panel').remove();
336
+ }
337
+
338
+ productOption.bindRemoveButtons();
339
+
340
+ if($('<?php echo $this->getAddButtonId() ?>')){
341
+ Event.observe('<?php echo $this->getAddButtonId() ?>', 'click', productOption.add.bind(productOption));
342
+ }
343
+
344
+ //validation for selected input type
345
+ Validation.addAllThese([
346
+ ['required-option-select', <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('Select type of option')) ?>, function(v, elm) {
347
+ if (elm.getValue() == '') {
348
+ return false;
349
+ }
350
+ return true;
351
+ }]]);
352
+
353
+ //adding data to templates
354
+
355
+ <?php foreach ($this->getOptionValues() as $_value): ?>
356
+ productOption.add(<?php echo $_value->toJson() ?>);
357
+ productOptionType.addDataToValues(<?php echo $_value->toJson() ?>);
358
+ <?php endforeach; ?>
359
+
360
+ //bind scope checkboxes
361
+ productOptionScope.bindScopeCheckbox();
362
+ //]]>
363
+ </script>
364
+
365
+ <div><?php if (!$this->isReadonly()):?><input type="hidden" name="affect_product_custom_options" value="1" /><?php endif;?></div>
366
+
367
+
368
+
369
+ <?php
370
+ //echo "<br/>printing array";
371
+ /*foreach ($this->getOptionValues() as $_value):
372
+ echo "<pre>";
373
+ echo "<br/>".$_value->toJson();
374
+ endforeach;*/
375
+ /*$formData = $this->getFormData();
376
+ echo "getFormData = ".print_r($formData);
377
+ echo "<br/>printing array";*/
378
+ /*foreach ($this->getOptionValues() as $_value):
379
+ echo "<br/>".$_value;
380
+ echo "<pre>";
381
+ print_r($_value);
382
+ endforeach;*/
383
+ ?>
384
+
385
+ <?php
386
+ /*$fieldsCollection = Mage::getModel('formbuilder/fields')->getCollection();
387
+ if(count($fieldsCollection))
388
+ {
389
+ foreach ($fieldsCollection as $key => $value)
390
+ {
391
+ echo "<br/>key = ".$key;
392
+ echo "<br/>title = ".$value['title'];
393
+ echo "<br/>previous_group = ".$value['previous_group'];
394
+ }
395
+ }*/
396
+ ?>
app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/date.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <script type="text/javascript">
28
+
29
+ OptionTemplateDate = '<table class="border" cellpadding="0" cellspacing="0">'+
30
+ '<tr class="headings">'+
31
+ <?php if ($this->getCanReadPrice() !== false) : ?>
32
+ '<th class="type-price"><?php echo Mage::helper('catalog')->__('Price') ?></th>' +
33
+ '<th class="type-type"><?php echo Mage::helper('catalog')->__('Price Type') ?></th>' +
34
+ <?php endif; ?>
35
+ '</tr>'+
36
+ '<tr>'+
37
+ <?php if ($this->getCanReadPrice() !== false) : ?>
38
+ '<td><input type="text" class="input-text validate-number product-option-price" id="product_option_{{option_id}}_price" name="product[options][{{option_id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?>></td>' +
39
+ '<td><?php echo $this->getPriceTypeSelectHtml() ?>{{checkboxScopePrice}}</td>' +
40
+ <?php else : ?>
41
+ '<input type="hidden" id="product_option_{{option_id}}_price" name="product[options][{{option_id}}][price]">' +
42
+ '<input type="hidden" name="product[options][{{option_id}}][price_type]" id="product_option_{{option_id}}_price_type">' +
43
+ <?php endif; ?>
44
+ '</tr>'+
45
+ '</table>';
46
+
47
+ if ($('option_panel_type_date')) {
48
+ $('option_panel_type_date').remove();
49
+ }
50
+
51
+ </script>
app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/file.phtml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <script type="text/javascript">
28
+
29
+ OptionTemplateFile = '<table class="border" cellpadding="0" cellspacing="0">'+
30
+ '<tr class="headings">'+
31
+ <?php if ($this->getCanReadPrice() !== false) : ?>
32
+ '<th class="type-price">' + <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('Price')); ?> + '</th>' +
33
+ '<th class="type-type">' + <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('Price Type')); ?> + '</th>' +
34
+ <?php endif; ?>
35
+ '<th class="type-title">' + <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('Allowed File Extensions')); ?> + '</th>'+
36
+ '<th class="last">' + <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('Maximum Image Size')); ?> + '</th>' +
37
+ '</tr>' +
38
+ '<tr>' +
39
+ <?php if ($this->getCanReadPrice() !== false) : ?>
40
+ '<td><input class="input-text validate-zero-or-greater" type="text" name="product[options][{{option_id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?>></td>' +
41
+ '<td>' + <?php echo $this->helper('core')->jsonEncode($this->getPriceTypeSelectHtml()) ?> + '</td>' +
42
+ <?php else : ?>
43
+ '<input type="hidden" name="product[options][{{option_id}}][price]">' +
44
+ '<input type="hidden" name="product[options][{{option_id}}][price_type]" id="product_option_{{option_id}}_price_type">' +
45
+ <?php endif; ?>
46
+ '<td><input class="input-text" type="text" name="product[options][{{option_id}}][file_extension]" value="{{file_extension}}"></td>' +
47
+ '<td class="type-last last" nowrap><input class="input-text" type="text" name="product[options][{{option_id}}][image_size_x]" value="{{image_size_x}}">' +
48
+ <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('x')) ?> +
49
+ '<input class="input-text" type="text" name="product[options][{{option_id}}][image_size_y]" value="{{image_size_y}}">' +
50
+ <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('px.')) ?> +
51
+ '<br/>' + <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('leave blank if its not an image')) ?> + '</td>' +
52
+ '</tr>'+
53
+ '</table>';
54
+
55
+ if ($('option_panel_type_file')) {
56
+ $('option_panel_type_file').remove();
57
+ }
58
+
59
+ </script>
app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/select.phtml ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <script type="text/javascript">
28
+ //<![CDATA[
29
+ OptionTemplateSelect = '<table class="border" cellpadding="0" cellspacing="0">'+
30
+ '<input type="hidden" class="required-option-select-type-rows" name="validation_{{option_id}}_result" value="" >'+
31
+ '<thead>'+
32
+ '<tr class="headings">'+
33
+ '<th class="type-title"><?php echo Mage::helper('catalog')->__('Title') ?> <span class="required">*</span></th>'+
34
+ <?php if ($this->getCanReadPrice() !== false) : ?>
35
+ '<th class="type-price"><?php echo Mage::helper('catalog')->__('Price') ?></th>' +
36
+ '<th class="type-type"><?php echo Mage::helper('catalog')->__('Price Type') ?></th>' +
37
+ <?php endif; ?>
38
+ //'<th class="type-sku"><?php echo Mage::helper('catalog')->__('SKU') ?></th>'+
39
+ '<th class="type-order"><?php echo Mage::helper('catalog')->__('Sort Order') ?></th>'+
40
+ '<th class="type-butt last">&nbsp;</th>'+
41
+ '</tr>'+
42
+ '</thead>'+
43
+ '<tbody id="select_option_type_row_{{option_id}}">'+
44
+ '</tbody>'+
45
+ '<tfoot>'+
46
+ '<tr>'+
47
+ '<td colspan="100" class="a-right"><?php echo $this->getAddButtonHtml() ?></td>'+
48
+ '</tr>'+
49
+ '</tfoot>'+
50
+ '</table>';
51
+
52
+ OptionTemplateSelectRow = '<tr id="product_option_{{id}}_select_{{select_id}}">'+
53
+ '<td>'+
54
+ '<input type="hidden" name="product[options][{{id}}][values][{{select_id}}][option_type_id]" value="{{option_type_id}}">'+
55
+ '<input type="hidden" id="product_option_{{id}}_select_{{select_id}}_is_delete" name="product[options][{{id}}][values][{{select_id}}][is_delete]" value="">'+
56
+ '<input type="text" class="required-entry input-text select-type-title" id="product_option_{{id}}_select_{{select_id}}_title" name="product[options][{{id}}][values][{{select_id}}][title]" value="{{title}}">{{checkboxScopeTitle}}</td>'+
57
+ <?php if ($this->getCanReadPrice() !== false) : ?>
58
+ '<td><input type="text" class="input-text validate-number product-option-price" id="product_option_{{id}}_select_{{select_id}}_price" name="product[options][{{id}}][values][{{select_id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?>></td>' +
59
+ '<td><?php echo $this->getPriceTypeSelectHtml() ?>{{checkboxScopePrice}}</td>' +
60
+ <?php else : ?>
61
+ '<input type="hidden" id="product_option_{{id}}_select_{{select_id}}_price" name="product[options][{{id}}][values][{{select_id}}][price]">' +
62
+ '<input type="hidden" name="product[options][{{id}}][values][{{select_id}}][price_type]" id="product_option_{{id}}_select_{{select_id}}_price_type">' +
63
+ <?php endif; ?>
64
+ //'<td><input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][sku]" value="{{sku}}"></td>'+
65
+ '<td><input type="text" class="validate-zero-or-greater input-text" name="product[options][{{id}}][values][{{select_id}}][sort_order]" value="{{sort_order}}"></td>'+
66
+ '<td class="last"><span title="Delete row"><?php echo $this->getDeleteButtonHtml() ?></span></td>'+
67
+ '</tr>';
68
+
69
+ selectOptionType = {
70
+ div : 'select_option_type_row',
71
+ itemCount : 0,
72
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
73
+ templateText : OptionTemplateSelectRow,
74
+ add : function(data) {
75
+
76
+ this.template = new Template(this.templateText, this.templateSyntax);
77
+
78
+ if (data.target || data.srcElement) {//data is Event (work in IE and Firefox)
79
+ element = $(Event.findElement(data, 'button'));
80
+ optionId = element.readAttribute('id').sub('add_select_row_button_', '');
81
+ data = {};
82
+ data.option_type_id = '-1';
83
+ data.select_id = this.itemCount;
84
+ } else {
85
+ optionId = data.option_id;
86
+ data.select_id = data.option_type_id;
87
+ this.itemCount = data.item_count;
88
+ }
89
+
90
+ data.id = optionId;
91
+
92
+ Element.insert($(this.div+'_'+data.id), {'bottom':this.template.evaluate(data)});
93
+
94
+ if (data.checkboxScopeTitle) {
95
+ //set disabled
96
+ if ($('product_option_'+data.id+'_select_'+data.select_id+'_title') && data.scopeTitleDisabled) {
97
+ $('product_option_'+data.id+'_select_'+data.select_id+'_title').disable();
98
+ }
99
+ }
100
+ if (data.checkboxScopePrice) {
101
+ //set disabled
102
+ if ($('product_option_'+data.id+'_select_'+data.select_id+'_price') && data.scopePriceDisabled) {
103
+ $('product_option_'+data.id+'_select_'+data.select_id+'_price').disable();
104
+ $('product_option_'+data.id+'_select_'+data.select_id+'_price_type').disable();
105
+ }
106
+ }
107
+
108
+ if (data.price_type) {
109
+ $A($('product_option_'+data.id+'_select_'+data.select_id+'_price_type').options).each(function(option){
110
+ if (option.value==data.price_type) option.selected = true;
111
+ });
112
+ }
113
+
114
+ this.itemCount++;
115
+ this.bindRemoveButtons();
116
+ },
117
+ remove : function(event){
118
+ var element = $(Event.findElement(event, 'tr'));
119
+
120
+ if(element){
121
+ $(element.readAttribute('id')+'_is_delete').value = '1';
122
+ element.addClassName('no-display');
123
+ element.addClassName('ignore-validate');
124
+ element.hide();
125
+ }
126
+ },
127
+ bindRemoveButtons : function(){
128
+ var buttons = $$('.delete-select-row');
129
+ for(var i=0;i<buttons.length;i++){
130
+ if(!$(buttons[i]).binded){
131
+ $(buttons[i]).binded = true;
132
+ Event.observe(buttons[i], 'click', this.remove.bind(this));
133
+ }
134
+ }
135
+ },
136
+ bindAddButton : function()
137
+ {
138
+ var buttons = $$('.add-select-row');
139
+ for(var i=0;i<buttons.length;i++){
140
+ if(!$(buttons[i]).binded){
141
+ $(buttons[i]).binded = true;
142
+ Event.observe(buttons[i], 'click', this.add.bind(this));
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ if ($('option_panel_type_select')) {
149
+ $('option_panel_type_select').remove();
150
+ }
151
+
152
+ selectOptionType.bindRemoveButtons();
153
+
154
+ Validation.addAllThese([
155
+ ['required-option-select-type-rows', <?php echo $this->helper('core')->jsonEncode(Mage::helper('catalog')->__('Please add rows to option.')); ?>, function(v, elm) {
156
+ var optionContainerElm = elm.up('div.grid');
157
+ var selectTypesFlag = false;
158
+ selectTypeElements = $$('#'+optionContainerElm.id+' .select-type-title');
159
+ selectTypeElements.each(function(elm){
160
+ if (elm.id && elm.up('tr').visible()) {
161
+ selectTypesFlag = true;
162
+ }
163
+ });
164
+ elm.advaiceContainer = optionContainerElm.id+'_advice';
165
+ return selectTypesFlag;
166
+ }]]);
167
+
168
+ if($('add_select_row_button')){
169
+ Event.observe('add_select_row_button', 'click', selectOptionType.add.bind(selectOptionType));
170
+ }
171
+ //]]>
172
+ </script>
app/design/adminhtml/default/default/template/formbuilder/catalog/product/edit/options/type/text.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category adminhtml template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <script type="text/javascript">
28
+ //<![CDATA[
29
+ OptionTemplateText = '<table class="border" cellpadding="0" cellspacing="0">'+
30
+ '<tr class="headings">'+
31
+ <?php if ($this->getCanReadPrice() !== false) : ?>
32
+ '<th class="type-price"><?php echo Mage::helper('catalog')->__('Price') ?></th>' +
33
+ '<th class="type-type"><?php echo Mage::helper('catalog')->__('Price Type') ?></th>' +
34
+ <?php endif; ?>
35
+ '<th class="type-last last"><?php echo Mage::helper('catalog')->__('Max Characters') ?> </th>'+
36
+ '</tr>'+
37
+ '<tr>'+
38
+ <?php if ($this->getCanReadPrice() !== false) : ?>
39
+ '<td><input type="text" class="input-text validate-number product-option-price" id="product_option_{{option_id}}_price" name="product[options][{{option_id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?>></td>' +
40
+ '<td><?php echo $this->getPriceTypeSelectHtml() ?>{{checkboxScopePrice}}</td>' +
41
+ <?php else : ?>
42
+ '<input type="hidden" name="product[options][{{option_id}}][price]">' +
43
+ '<input type="hidden" name="product[options][{{option_id}}][price_type]" id="product_option_{{option_id}}_price_type">' +
44
+ <?php endif; ?>
45
+ '<td class="type-last last"><input type="text" class="input-text validate-zero-or-greater" name="product[options][{{option_id}}][max_characters]" value="{{max_characters}}"></td>'+
46
+ '</tr>'+
47
+ '</table>';
48
+
49
+ if ($('option_panel_type_text')) {
50
+ $('option_panel_type_text').remove();
51
+ }
52
+ //]]>
53
+ </script>
app/design/frontend/base/default/layout/formbuilder.xml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend layout
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <layout version="0.1.0">
28
+ <default translate="label" module="formbuilder">
29
+ <reference name="head">
30
+ <action method="addCss">
31
+ <stylesheet>css/formbuilder/custom.css</stylesheet>
32
+ </action>
33
+ </reference>
34
+
35
+ <reference name="head">
36
+ <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
37
+ <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
38
+ <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
39
+ </reference>
40
+ <reference name="content">
41
+ <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml" />
42
+ </reference>
43
+
44
+ <reference name="top.links">
45
+ <action method="addLink" translate="label title" module="formbuilder" ifconfig="formbuilder_section/general/in_toplinks">
46
+ <label>Formbuilder</label>
47
+ <url>formbuilder</url>
48
+ <title>Formbuilder</title>
49
+ <prepare>true</prepare>
50
+ <urlParams/>
51
+ <position>200</position>
52
+ <liParams/><aParams/>
53
+ </action>
54
+ </reference>
55
+ <reference name="footer_links">
56
+ <action method="addLink" translate="label title" module="formbuilder" ifconfig="formbuilder_section/general/in_footerlinks">
57
+ <label>Formbuilder</label>
58
+ <url>formbuilder</url>
59
+ <title>Formbuilder</title>
60
+ <prepare>true</prepare>
61
+ </action>
62
+ </reference>
63
+ </default>
64
+ <formbuilder_index_index>
65
+ <reference name="root">
66
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
67
+ </reference>
68
+
69
+
70
+ <!-- <reference name="head">
71
+ <action method="addCss">
72
+ <stylesheet>css/formbuilder/bootstrap-responsive.css</stylesheet>
73
+ </action>
74
+ <action method="addCss">
75
+ <stylesheet>css/formbuilder/bootstrap.min.css</stylesheet>
76
+ </action>
77
+ <action method="addJs">
78
+ <script>formbuilder/jquery-1.11.1.min.js</script>
79
+ </action>
80
+ <action method="addJs">
81
+ <script>formbuilder/bootstrap.min.js</script>
82
+ </action>
83
+ </reference> -->
84
+
85
+
86
+
87
+ <reference name="content">
88
+ <block type="formbuilder/frontend_formbuilder" name="frontend_formbuilder" template="formbuilder/formbuilder.phtml" />
89
+ </reference>
90
+ </formbuilder_index_index>
91
+ <formbuilder_index_view>
92
+ <reference name="root">
93
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
94
+ </reference>
95
+ <reference name="content">
96
+ <block type="formbuilder/frontend_form" name="frontend_form" template="formbuilder/form.phtml" />
97
+ <!-- <block type="formbuilder/frontend_text" name="frontend_text" template="formbuilder/text.phtml" />
98
+ <block type="formbuilder/frontend_select" name="frontend_select" template="formbuilder/select.phtml" />
99
+ <block type="formbuilder/frontend_file" name="frontend_file" template="formbuilder/file.phtml" />
100
+ <block type="formbuilder/frontend_date" name="frontend_date" template="formbuilder/date.phtml" /> -->
101
+ <!-- <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/> -->
102
+ <!-- <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml" /> -->
103
+ </reference>
104
+ </formbuilder_index_view>
105
+ </layout>
app/design/frontend/base/default/template/formbuilder/date.phtml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $title = $this->field['title'];
29
+ $id = $this->field['fields_index'];
30
+ $isRequire = $this->field['is_require'];
31
+ $defaultValue = $this->field['default_value'];
32
+
33
+ $labelHtml = '<label for="">'.$title.'</label>';
34
+ if($isRequire)
35
+ $labelHtml = '<label class="required" for=""><em>*</em>'.$title.'</label>';
36
+ ?>
37
+ <li>
38
+ <?php echo $labelHtml; ?>
39
+ <div class="input-box">
40
+ <?php if($this->field['type']=='date_time' || $this->field['type']=='date'): ?>
41
+ <?php echo $this->getDateHtml($this->field) ?>
42
+ <?php if (!$this->useCalendar()): ?>
43
+ <script type="text/javascript">
44
+ //<![CDATA[
45
+ Event.observe('options_<?php echo $id ?>_month', 'change', dateOption.reloadMonth.bind(dateOption));
46
+ Event.observe('options_<?php echo $id ?>_year', 'change', dateOption.reloadMonth.bind(dateOption));
47
+ //]]>
48
+ </script>
49
+ <?php endif; ?>
50
+ <?php endif; ?>
51
+ <?php if($this->field['type']=='date_time' || $this->field['type']=='time'): ?>
52
+ <span class="time-picker">
53
+ <?php echo $this->getTimeHtml($this->field) ?>
54
+ </span>
55
+ <?php endif; ?>
56
+ <input type="hidden" name="validate_datetime_<?php echo $id ?>" class="validate-datetime-<?php echo $id ?>" value="" />
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+ <?php if ($isRequire): ?>
60
+ Validation.addAllThese(
61
+ [
62
+ ['validate-datetime-<?php echo $id ?>', '<?php echo $this->jsQuoteEscape( Mage::helper('catalog')->__('This is a required option') )?>', function(v) {
63
+ var dateTimeParts = $$('.datetime-picker[id^="options_<?php echo $id ?>"]');
64
+ for (var i=0; i < dateTimeParts.length; i++) {
65
+ if (dateTimeParts[i].value == "") return false;
66
+ }
67
+ return true;
68
+ }]
69
+ ]
70
+ );
71
+ <?php else: ?>
72
+ Validation.add(
73
+ 'validate-datetime-<?php echo $id ?>',
74
+ '<?php echo $this->jsQuoteEscape( Mage::helper('catalog')->__('Field is not complete') )?>',
75
+ function(v) {
76
+ var dateTimeParts = $$('.datetime-picker[id^="options_<?php echo $id ?>"]');
77
+ var hasWithValue = false, hasWithNoValue = false;
78
+ var pattern = /day_part$/i;
79
+ for (var i=0; i < dateTimeParts.length; i++) {
80
+ if (! pattern.test(dateTimeParts[i].id)) {
81
+ if (dateTimeParts[i].value === "") {
82
+ hasWithValue = true;
83
+ } else {
84
+ hasWithNoValue = true;
85
+ }
86
+ }
87
+ }
88
+ return hasWithValue ^ hasWithNoValue;
89
+ }
90
+ );
91
+ <?php endif; ?>
92
+ //]]>
93
+ </script>
94
+ </div>
95
+ </li>
app/design/frontend/base/default/template/formbuilder/file.phtml ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php /*
28
+ $title = $this->field['title'];
29
+ $id = $this->field['fields_index'];
30
+ $isRequire = $this->field['is_require'];
31
+ $defaultValue = $this->field['default_value'];
32
+ $type = $this->field['type'];
33
+
34
+ $labelHtml = '<label for="">'.$title.'</label>';
35
+ if($isRequire)
36
+ $labelHtml = '<label class="required" for=""><em>*</em>'.$title.'</label>';
37
+ ?>
38
+ <li>
39
+ <?php echo $labelHtml; ?>
40
+ <div class="input-box">
41
+ <?php echo $this->getFileHtml($this->field); ?>
42
+ </div>
43
+ </li>
44
+ */ ?>
45
+
46
+
47
+
48
+
49
+
50
+
51
+ <?php $_option = $this->field; ?>
52
+ <?php $_fileExists = false; ?>
53
+ <?php $_fileName = 'options_' . $_option['fields_index'] . '_file'; ?>
54
+ <?php $_fieldNameAction = $_fileName . '_action'; ?>
55
+ <?php $_fieldValueAction = $_fileExists ? 'save_old' : 'save_new'; ?>
56
+ <?php $_fileNamed = $_fileName . '_name'; ?>
57
+ <?php $_rand = rand(); ?>
58
+ <?php $id = $_option['fields_index']; ?>
59
+
60
+ <script type="text/javascript">
61
+ //<![CDATA[
62
+ opFile<?php echo $_rand; ?> = {
63
+ initializeFile: function(inputBox) {
64
+ this.inputFile = inputBox.select('input[name="<?php echo $_fileName; ?>"]')[0];
65
+ this.inputFileAction = inputBox.select('input[name="<?php echo $_fieldNameAction; ?>"]')[0];
66
+ this.fileNameBox = inputBox.up('dd').select('.<?php echo $_fileNamed ?>')[0];
67
+ },
68
+
69
+ toggleFileChange: function(inputBox) {
70
+ this.initializeFile(inputBox);
71
+ inputBox.toggle();
72
+ this.fileChangeFlag = this.fileChangeFlag ? false : true;
73
+ if (!this.fileDeleteFlag) {
74
+ if (this.fileChangeFlag) {
75
+ this.inputFileAction.value = 'save_new';
76
+ this.inputFile.disabled = false;
77
+ } else {
78
+ this.inputFileAction.value = 'save_old';
79
+ this.inputFile.disabled = true;
80
+ }
81
+ }
82
+ },
83
+
84
+ toggleFileDelete: function(fileDeleteFlag, inputBox) {
85
+ this.initializeFile(inputBox);
86
+ this.fileDeleteFlag = fileDeleteFlag.checked ? true : false;
87
+ if (this.fileDeleteFlag) {
88
+ this.inputFileAction.value = '';
89
+ this.inputFile.disabled = true;
90
+ this.fileNameBox.setStyle({'text-decoration': 'line-through'});
91
+ } else {
92
+ this.inputFileAction.value = this.fileChangeFlag ? 'save_new' : 'save_old';
93
+ this.inputFile.disabled = (this.fileChangeFlag == 'save_old');
94
+ this.fileNameBox.setStyle({'text-decoration': 'none'});
95
+ }
96
+ }
97
+ };
98
+ //]]>
99
+ </script>
100
+
101
+ <?php
102
+ $title = $this->field['title'];
103
+ $id = $this->field['fields_index'];
104
+ $isRequire = $this->field['is_require'];
105
+ $defaultValue = $this->field['default_value'];
106
+ $type = $this->field['type'];
107
+
108
+ //$_fileName = "options[".$id."][file]";
109
+ $_fieldNameAction = "options[".$id."][file_action]";
110
+
111
+ $labelHtml = '<label for="">'.$title.'</label>';
112
+ if($isRequire)
113
+ $labelHtml = '<label class="required" for=""><em>*</em>'.$title.'</label>';
114
+ ?>
115
+
116
+ <li>
117
+ <?php echo $labelHtml; ?>
118
+ <?php if ($_fileExists): ?>
119
+ <span class="<?php echo $_fileNamed ?>"><?php echo $_fileInfo->getTitle(); ?></span>
120
+ <a href="javascript:void(0)" class="label" onclick="opFile<?php echo $_rand; ?>.toggleFileChange($(this).next('.input-box'))">
121
+ <?php echo Mage::helper('catalog')->__('Change') ?>
122
+ </a>&nbsp;
123
+ <?php if (!$_option->getIsRequire()): ?>
124
+ <input type="checkbox" onclick="opFile<?php echo $_rand; ?>.toggleFileDelete($(this), $(this).next('.input-box'))" />
125
+ <span class="label"><?php echo Mage::helper('catalog')->__('Delete') ?></span>
126
+ <?php endif; ?>
127
+ <?php endif; ?>
128
+ <div class="input-box" <?php echo $_fileExists ? 'style="display:none"' : '' ?>>
129
+ <input type="file" name="<?php echo $_fileName; ?>" class="product-custom-option<?php echo $_option->getIsRequire() ? ' required-entry' : '' ?>" <?php echo $_fileExists ? 'disabled="disabled"' : '' ?> onchange="opConfig.reloadPrice()" />
130
+ <!-- <input type="hidden" name="<?php echo $_fieldNameAction; ?>" value="<?php echo $_fieldValueAction; ?>" /> -->
131
+ <?php if ($_option->getFileExtension()): ?>
132
+ <p class="no-margin"><?php echo Mage::helper('catalog')->__('Allowed file extensions to upload')?>: <strong><?php echo $_option->getFileExtension() ?></strong></p>
133
+ <?php endif; ?>
134
+ <?php if ($_option->getImageSizeX() > 0): ?>
135
+ <p class="no-margin"><?php echo Mage::helper('catalog')->__('Maximum image width')?>: <strong><?php echo $_option->getImageSizeX() ?> <?php echo Mage::helper('catalog')->__('px.')?></strong></p>
136
+ <?php endif; ?>
137
+ <?php if ($_option->getImageSizeY() > 0): ?>
138
+ <p class="no-margin"><?php echo Mage::helper('catalog')->__('Maximum image height')?>: <strong><?php echo $_option->getImageSizeY() ?> <?php echo Mage::helper('catalog')->__('px.')?></strong></p>
139
+ <?php endif; ?>
140
+ </div>
141
+ </li>
app/design/frontend/base/default/template/formbuilder/form.phtml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $formIdfromCms = $this->getFormId();
29
+ $formIdfromUrl = $this->getRequest()->getParam('id');
30
+ $passFormId = $formIdfromCms ? $formIdfromCms : $formIdfromUrl;
31
+
32
+ $helper = Mage::helper('formbuilder');
33
+ $session = Mage::getSingleton('core/session');
34
+ if ($helper->isEnabled()): ?>
35
+ <div class="formbuilder">
36
+ <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
37
+ <div class="formbuilder-form">
38
+ <?php
39
+ //$passFormId = intval($this->getRequest()->getParam('id'));
40
+ $currentForm = $currentFormFieldsCollection = array();
41
+ $currentForm = $this->getCurrentFormUsingBlock($passFormId);
42
+ if(isset($currentForm) && $currentForm!=NULL && count($currentForm)):
43
+ $titleImage = Mage::getBaseUrl('media').$currentForm->getTitleImage();
44
+ $currentFormFieldsCollection = $this->getCurrentFormFields($passFormId);
45
+ if(count($currentFormFieldsCollection)):
46
+ $currentFormId = $currentForm['forms_index'];
47
+ $formBgcolor = $currentForm['bgcolor'];
48
+ $formRedirectUrl = Mage::getUrl('formbuilder/index/formsubmit');
49
+ $submitButtonText = $currentForm['submit_text'];
50
+ if(!$submitButtonText)
51
+ $submitButtonText = "Submit";
52
+ ?>
53
+ <?php //echo $this->getLayout()->createBlock('core/template')->setTemplate('formbuilder/fields_validation.phtml')->toHtml(); ?>
54
+ <script type="text/javascript">
55
+ function validateOptionsCallback(elmId, result)
56
+ {
57
+ var container = $(elmId).up('ul.options-list');
58
+ if (result == 'failed') {
59
+ container.removeClassName('validation-passed');
60
+ container.addClassName('validation-failed');
61
+ } else {
62
+ container.removeClassName('validation-failed');
63
+ container.addClassName('validation-passed');
64
+ }
65
+ }
66
+ </script>
67
+ <?php if($currentForm['title_image']): ?>
68
+ <div class="title_image">
69
+ <h1><?php echo "<img src='$titleImage' height='100' width='900' />" ?></h1>
70
+ </div>
71
+ <?php endif; ?>
72
+ <form method="post" id="custom_form" action="<?php echo $formRedirectUrl ?>" name="custom_form" enctype="multipart/form-data">
73
+ <div class="fieldset">
74
+ <h2 class="legend">
75
+ <?php echo $currentForm->getTitle(); ?>
76
+ </h2>
77
+ <?php if($currentForm['header_content']): ?>
78
+ <div class="header_content">
79
+ <?php echo $currentForm['header_content']; ?>
80
+ </div>
81
+ <?php endif; ?>
82
+ <ul class="form-list product-options">
83
+ <?php
84
+ foreach ($currentFormFieldsCollection as $key => $field)
85
+ {
86
+ $functionName = "get".ucfirst($field['previous_group'])."Html";
87
+ echo $this->$functionName($field);
88
+ }
89
+ ?>
90
+ </ul>
91
+ <?php if($currentForm['footer_content']): ?>
92
+ <div class="footer_content">
93
+ <?php echo $currentForm['footer_content']; ?>
94
+ </div>
95
+ <?php endif; ?>
96
+ </div>
97
+ <div class="buttons-set">
98
+ <p class="required">* Required Fields</p>
99
+ <!-- <input type="text" style="display:none !important;" value="" id="hideit" name="hideit"> -->
100
+ <input type="hidden" name="current_form_id" id="current_form_id" value="<?php echo $currentFormId ?>">
101
+ <button class="button" title="<?php echo $this->__($submitButtonText) ?>" type="submit"><span><span><?php echo $this->__($submitButtonText) ?></span></span></button>
102
+ </div>
103
+ </form>
104
+ <script type="text/javascript">
105
+ var myForm = new VarienForm('custom_form', true);
106
+ </script>
107
+ <style type="text/css">
108
+ <?php
109
+ $formStyle = "#custom_form .fieldset, #custom_form .form-list {background-color: ".$formBgcolor."}";
110
+ echo $formStyle;
111
+ ?>
112
+ </style>
113
+ <?php else: ?>
114
+ <p class="note-msg"><?php echo $this->__('There are no fields enabled/available in the requested form.') ?></p>
115
+ <?php endif; ?><!--if(count($currentFormFieldsCollection))-->
116
+ <?php endif; ?><!--if(isset($currentForm))-->
117
+ </div><!--formbuilder-form-->
118
+ </div><!--formbuilder-->
119
+ <?php endif; ?>
app/design/frontend/base/default/template/formbuilder/formbuilder.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $helper = Mage::helper('formbuilder');
29
+ $session = Mage::getSingleton('core/session');
30
+ if ($helper->isEnabled()): ?>
31
+ <div class="formbuilder">
32
+ <div class="page-title">
33
+ <h1><?php echo $this->__('Formbuilder Extension'); ?></h1>
34
+ </div>
35
+ <div class="">
36
+ <?php
37
+ $formCollection = array();
38
+ $formCollection = Mage::helper('formbuilder')->getFormCollection();
39
+ if(count($formCollection))
40
+ {
41
+ echo "<ul>";
42
+ foreach ($formCollection as $form)
43
+ {
44
+ $formUrl = Mage::getUrl('formbuilder/index/view')."id/".$form['forms_index'];
45
+ echo "<li><a href='$formUrl'>".$form['title']."</a></li>";
46
+ }
47
+ echo "</ul>";
48
+ }
49
+ ?>
50
+ </div>
51
+ </div>
52
+ <?php endif; ?>
app/design/frontend/base/default/template/formbuilder/select.phtml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $title = $this->field['title'];
29
+ $id = $this->field['fields_index'];
30
+ $isRequire = $this->field['is_require'];
31
+ $defaultValue = $this->field['default_value'];
32
+ $type = $this->field['type'];
33
+
34
+ $labelHtml = '<label for="">'.$title.'</label>';
35
+ if($isRequire)
36
+ $labelHtml = '<label class="required" for=""><em>*</em>'.$title.'</label>';
37
+ ?>
38
+ <li>
39
+ <?php echo $labelHtml; ?>
40
+ <div class="input-box">
41
+ <?php echo $this->getSelectHtml($this->field); ?>
42
+ <?php if ($isRequire): ?>
43
+ <?php if ($type == 'radio' || $type == 'checkbox'): ?>
44
+ <span id="options-<?php echo $id ?>-container"></span>
45
+ <?php endif; ?>
46
+ <?php endif;?>
47
+ </div>
48
+ </li>
49
+
50
+
51
+
52
+
53
+
54
+ <?php /*if($this->field['type']=='field'): ?>
55
+ <li>
56
+ <?php echo $labelHtml; ?>
57
+ <div class="input-box">
58
+ <input type="text" class="input-text<?php echo $isRequire ? ' required-entry' : '' ?> <?php echo $maxCharacters ? ' validate-length maximum-length-'.$maxCharacters : '' ?> product-custom-option" title="<?php echo $title; ?>" id="options_<?php echo $id ?>_text" name="options[<?php echo $id ?>]" value="<?php echo $defaultValue ?>" />
59
+ </div>
60
+ </li>
61
+ <?php elseif($this->field['type']=='area'): ?>
62
+ <li class="wide">
63
+ <?php echo $labelHtml; ?>
64
+ <div class="input-box">
65
+ <textarea rows="5" cols="25" class="input-text<?php echo $isRequire ? ' required-entry' : '' ?> <?php echo $maxCharacters ? ' validate-length maximum-length-'.$maxCharacters : '' ?> product-custom-option" title="<?php echo $title; ?>" id="options_<?php echo $id ?>_text" name="options[<?php echo $id ?>]"><?php echo $defaultValue ?></textarea>
66
+ </div>
67
+ </li>
68
+ <?php endif; ?>
69
+
70
+ <?php $_option = $this->getOption() ?>
71
+ <dt><label<?php if ($_option->getIsRequire()) echo ' class="required"' ?>><?php if ($_option->getIsRequire()) echo '<em>*</em>' ?><?php echo $this->escapeHtml($_option->getTitle()) ?></label></dt>
72
+ <dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
73
+ <div class="input-box">
74
+ <?php echo $this->getValuesHtml() ?>
75
+ <?php if ($_option->getIsRequire()): ?>
76
+ <?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX): ?>
77
+ <span id="options-<?php echo $_option->getId() ?>-container"></span>
78
+ <?php endif; ?>
79
+ <?php endif;?>
80
+ </div>
81
+ </dd>
82
+ */ ?>
app/design/frontend/base/default/template/formbuilder/text.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * Phxsolution Formbuilder
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category frontend template
19
+ * @package Phxsolution_Formbuilder
20
+ * @author Murad Ali
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $title = $this->field['title'];
29
+ $id = $this->field['fields_index'];
30
+ $isRequire = $this->field['is_require'];
31
+ $maxCharacters = $this->field['max_characters'];
32
+ $defaultValue = $this->getDefaultValue();
33
+ $liClass = "";
34
+ if($this->field['type']=='area')
35
+ $liClass = "wide";
36
+
37
+ $labelHtml = '<label for="">'.$title.'</label>';
38
+ if($isRequire)
39
+ $labelHtml = '<label class="required" for=""><em>*</em>'.$title.'</label>';
40
+ ?>
41
+ <li class="<?php echo $liClass ?>">
42
+ <?php echo $labelHtml; ?>
43
+ <div class="input-box">
44
+ <?php if($this->field['type']=='field'): ?>
45
+ <input type="text" class="input-text<?php echo $isRequire ? ' required-entry' : '' ?> <?php echo $maxCharacters ? ' validate-length maximum-length-'.$maxCharacters : '' ?> product-custom-option" title="<?php echo $title; ?>" id="options_<?php echo $id ?>_text" name="options[<?php echo $id ?>]" value="<?php echo $defaultValue ?>" />
46
+ <?php elseif($this->field['type']=='area'): ?>
47
+ <textarea rows="5" cols="25" class="input-text<?php echo $isRequire ? ' required-entry' : '' ?> <?php echo $maxCharacters ? ' validate-length maximum-length-'.$maxCharacters : '' ?> product-custom-option" title="<?php echo $title; ?>" id="options_<?php echo $id ?>_text" name="options[<?php echo $id ?>]"><?php echo $defaultValue ?></textarea>
48
+ <?php endif; ?>
49
+ <?php if ($maxCharacters): ?>
50
+ <p class="note">
51
+ <?php echo Mage::helper('formbuilder')->__('Maximum number of characters:')?>
52
+ <strong><?php echo $maxCharacters ?></strong>
53
+ </p>
54
+ <?php endif; ?>
55
+ </div>
56
+ </li>
js/formbuilder/jscolor/arrow.gif ADDED
Binary file
js/formbuilder/jscolor/cross.gif ADDED
Binary file
js/formbuilder/jscolor/hs.png ADDED
Binary file
js/formbuilder/jscolor/hv.png ADDED
Binary file
js/formbuilder/jscolor/jscolor.js ADDED
@@ -0,0 +1,997 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jscolor, JavaScript Color Picker
3
+ *
4
+ * @version 1.4.2
5
+ * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
6
+ * @author Jan Odvarko, http://odvarko.cz
7
+ * @created 2008-06-15
8
+ * @updated 2013-11-25
9
+ * @link http://jscolor.com
10
+ */
11
+
12
+
13
+ var jscolor = {
14
+
15
+
16
+ dir : BLANK_URL.replace( 'blank.html', 'formbuilder/jscolor/' ), // location of jscolor directory (leave empty to autodetect)
17
+ bindClass : 'color', // class name
18
+ binding : true, // automatic binding via <input class="...">
19
+ preloading : true, // use image preloading?
20
+
21
+
22
+ install : function() {
23
+ jscolor.addEvent(window, 'load', jscolor.init);
24
+ },
25
+
26
+
27
+ init : function() {
28
+ if(jscolor.binding) {
29
+ jscolor.bind();
30
+ }
31
+ if(jscolor.preloading) {
32
+ jscolor.preload();
33
+ }
34
+ },
35
+
36
+
37
+ getDir : function() {
38
+ if(!jscolor.dir) {
39
+ var detected = jscolor.detectDir();
40
+ jscolor.dir = detected!==false ? detected : 'jscolor/';
41
+ }
42
+ return jscolor.dir;
43
+ },
44
+
45
+
46
+ detectDir : function() {
47
+ var base = location.href;
48
+
49
+ var e = document.getElementsByTagName('base');
50
+ for(var i=0; i<e.length; i+=1) {
51
+ if(e[i].href) { base = e[i].href; }
52
+ }
53
+
54
+ var e = document.getElementsByTagName('script');
55
+ for(var i=0; i<e.length; i+=1) {
56
+ if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
57
+ var src = new jscolor.URI(e[i].src);
58
+ var srcAbs = src.toAbsolute(base);
59
+ srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
60
+ srcAbs.query = null;
61
+ srcAbs.fragment = null;
62
+ return srcAbs.toString();
63
+ }
64
+ }
65
+ return false;
66
+ },
67
+
68
+
69
+ bind : function() {
70
+ var matchClass = new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?', 'i');
71
+ var e = document.getElementsByTagName('input');
72
+ for(var i=0; i<e.length; i+=1) {
73
+ var m;
74
+ if(!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
75
+ var prop = {};
76
+ if(m[3]) {
77
+ try {
78
+ prop = (new Function ('return (' + m[3] + ')'))();
79
+ } catch(eInvalidProp) {}
80
+ }
81
+ e[i].color = new jscolor.color(e[i], prop);
82
+ }
83
+ }
84
+ },
85
+
86
+
87
+ preload : function() {
88
+ for(var fn in jscolor.imgRequire) {
89
+ if(jscolor.imgRequire.hasOwnProperty(fn)) {
90
+ jscolor.loadImage(fn);
91
+ }
92
+ }
93
+ },
94
+
95
+
96
+ images : {
97
+ pad : [ 181, 101 ],
98
+ sld : [ 16, 101 ],
99
+ cross : [ 15, 15 ],
100
+ arrow : [ 7, 11 ]
101
+ },
102
+
103
+
104
+ imgRequire : {},
105
+ imgLoaded : {},
106
+
107
+
108
+ requireImage : function(filename) {
109
+ jscolor.imgRequire[filename] = true;
110
+ },
111
+
112
+
113
+ loadImage : function(filename) {
114
+ if(!jscolor.imgLoaded[filename]) {
115
+ jscolor.imgLoaded[filename] = new Image();
116
+ jscolor.imgLoaded[filename].src = jscolor.getDir()+filename;
117
+ }
118
+ },
119
+
120
+
121
+ fetchElement : function(mixed) {
122
+ return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
123
+ },
124
+
125
+
126
+ addEvent : function(el, evnt, func) {
127
+ if(el.addEventListener) {
128
+ el.addEventListener(evnt, func, false);
129
+ } else if(el.attachEvent) {
130
+ el.attachEvent('on'+evnt, func);
131
+ }
132
+ },
133
+
134
+
135
+ fireEvent : function(el, evnt) {
136
+ if(!el) {
137
+ return;
138
+ }
139
+ if(document.createEvent) {
140
+ var ev = document.createEvent('HTMLEvents');
141
+ ev.initEvent(evnt, true, true);
142
+ el.dispatchEvent(ev);
143
+ } else if(document.createEventObject) {
144
+ var ev = document.createEventObject();
145
+ el.fireEvent('on'+evnt, ev);
146
+ } else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
147
+ el['on'+evnt]();
148
+ }
149
+ },
150
+
151
+
152
+ getElementPos : function(e) {
153
+ var e1=e, e2=e;
154
+ var x=0, y=0;
155
+ if(e1.offsetParent) {
156
+ do {
157
+ x += e1.offsetLeft;
158
+ y += e1.offsetTop;
159
+ } while(e1 = e1.offsetParent);
160
+ }
161
+ while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
162
+ x -= e2.scrollLeft;
163
+ y -= e2.scrollTop;
164
+ }
165
+ return [x, y];
166
+ },
167
+
168
+
169
+ getElementSize : function(e) {
170
+ return [e.offsetWidth, e.offsetHeight];
171
+ },
172
+
173
+
174
+ getRelMousePos : function(e) {
175
+ var x = 0, y = 0;
176
+ if (!e) { e = window.event; }
177
+ if (typeof e.offsetX === 'number') {
178
+ x = e.offsetX;
179
+ y = e.offsetY;
180
+ } else if (typeof e.layerX === 'number') {
181
+ x = e.layerX;
182
+ y = e.layerY;
183
+ }
184
+ return { x: x, y: y };
185
+ },
186
+
187
+
188
+ getViewPos : function() {
189
+ if(typeof window.pageYOffset === 'number') {
190
+ return [window.pageXOffset, window.pageYOffset];
191
+ } else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
192
+ return [document.body.scrollLeft, document.body.scrollTop];
193
+ } else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
194
+ return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
195
+ } else {
196
+ return [0, 0];
197
+ }
198
+ },
199
+
200
+
201
+ getViewSize : function() {
202
+ if(typeof window.innerWidth === 'number') {
203
+ return [window.innerWidth, window.innerHeight];
204
+ } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
205
+ return [document.body.clientWidth, document.body.clientHeight];
206
+ } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
207
+ return [document.documentElement.clientWidth, document.documentElement.clientHeight];
208
+ } else {
209
+ return [0, 0];
210
+ }
211
+ },
212
+
213
+
214
+ URI : function(uri) { // See RFC3986
215
+
216
+ this.scheme = null;
217
+ this.authority = null;
218
+ this.path = '';
219
+ this.query = null;
220
+ this.fragment = null;
221
+
222
+ this.parse = function(uri) {
223
+ var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
224
+ this.scheme = m[3] ? m[2] : null;
225
+ this.authority = m[5] ? m[6] : null;
226
+ this.path = m[7];
227
+ this.query = m[9] ? m[10] : null;
228
+ this.fragment = m[12] ? m[13] : null;
229
+ return this;
230
+ };
231
+
232
+ this.toString = function() {
233
+ var result = '';
234
+ if(this.scheme !== null) { result = result + this.scheme + ':'; }
235
+ if(this.authority !== null) { result = result + '//' + this.authority; }
236
+ if(this.path !== null) { result = result + this.path; }
237
+ if(this.query !== null) { result = result + '?' + this.query; }
238
+ if(this.fragment !== null) { result = result + '#' + this.fragment; }
239
+ return result;
240
+ };
241
+
242
+ this.toAbsolute = function(base) {
243
+ var base = new jscolor.URI(base);
244
+ var r = this;
245
+ var t = new jscolor.URI;
246
+
247
+ if(base.scheme === null) { return false; }
248
+
249
+ if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
250
+ r.scheme = null;
251
+ }
252
+
253
+ if(r.scheme !== null) {
254
+ t.scheme = r.scheme;
255
+ t.authority = r.authority;
256
+ t.path = removeDotSegments(r.path);
257
+ t.query = r.query;
258
+ } else {
259
+ if(r.authority !== null) {
260
+ t.authority = r.authority;
261
+ t.path = removeDotSegments(r.path);
262
+ t.query = r.query;
263
+ } else {
264
+ if(r.path === '') {
265
+ t.path = base.path;
266
+ if(r.query !== null) {
267
+ t.query = r.query;
268
+ } else {
269
+ t.query = base.query;
270
+ }
271
+ } else {
272
+ if(r.path.substr(0,1) === '/') {
273
+ t.path = removeDotSegments(r.path);
274
+ } else {
275
+ if(base.authority !== null && base.path === '') {
276
+ t.path = '/'+r.path;
277
+ } else {
278
+ t.path = base.path.replace(/[^\/]+$/,'')+r.path;
279
+ }
280
+ t.path = removeDotSegments(t.path);
281
+ }
282
+ t.query = r.query;
283
+ }
284
+ t.authority = base.authority;
285
+ }
286
+ t.scheme = base.scheme;
287
+ }
288
+ t.fragment = r.fragment;
289
+
290
+ return t;
291
+ };
292
+
293
+ function removeDotSegments(path) {
294
+ var out = '';
295
+ while(path) {
296
+ if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
297
+ path = path.replace(/^\.+/,'').substr(1);
298
+ } else if(path.substr(0,3)==='/./' || path==='/.') {
299
+ path = '/'+path.substr(3);
300
+ } else if(path.substr(0,4)==='/../' || path==='/..') {
301
+ path = '/'+path.substr(4);
302
+ out = out.replace(/\/?[^\/]*$/, '');
303
+ } else if(path==='.' || path==='..') {
304
+ path = '';
305
+ } else {
306
+ var rm = path.match(/^\/?[^\/]*/)[0];
307
+ path = path.substr(rm.length);
308
+ out = out + rm;
309
+ }
310
+ }
311
+ return out;
312
+ }
313
+
314
+ if(uri) {
315
+ this.parse(uri);
316
+ }
317
+
318
+ },
319
+
320
+
321
+ //
322
+ // Usage example:
323
+ // var myColor = new jscolor.color(myInputElement)
324
+ //
325
+
326
+ color : function(target, prop) {
327
+
328
+
329
+ this.required = true; // refuse empty values?
330
+ this.adjust = true; // adjust value to uniform notation?
331
+ this.hash = false; // prefix color with # symbol?
332
+ this.caps = true; // uppercase?
333
+ this.slider = true; // show the value/saturation slider?
334
+ this.valueElement = target; // value holder
335
+ this.styleElement = target; // where to reflect current color
336
+ this.onImmediateChange = null; // onchange callback (can be either string or function)
337
+ this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
338
+ this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
339
+ this.minH = 0; // read-only 0-6
340
+ this.maxH = 6; // read-only 0-6
341
+ this.minS = 0; // read-only 0-1
342
+ this.maxS = 1; // read-only 0-1
343
+ this.minV = 0; // read-only 0-1
344
+ this.maxV = 1; // read-only 0-1
345
+
346
+ this.pickerOnfocus = true; // display picker on focus?
347
+ this.pickerMode = 'HSV'; // HSV | HVS
348
+ this.pickerPosition = 'bottom'; // left | right | top | bottom
349
+ this.pickerSmartPosition = true; // automatically adjust picker position when necessary
350
+ this.pickerButtonHeight = 20; // px
351
+ this.pickerClosable = false;
352
+ this.pickerCloseText = 'Close';
353
+ this.pickerButtonColor = 'ButtonText'; // px
354
+ this.pickerFace = 10; // px
355
+ this.pickerFaceColor = 'ThreeDFace'; // CSS color
356
+ this.pickerBorder = 1; // px
357
+ this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
358
+ this.pickerInset = 1; // px
359
+ this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
360
+ this.pickerZIndex = 10000;
361
+
362
+
363
+ for(var p in prop) {
364
+ if(prop.hasOwnProperty(p)) {
365
+ this[p] = prop[p];
366
+ }
367
+ }
368
+
369
+
370
+ this.hidePicker = function() {
371
+ if(isPickerOwner()) {
372
+ removePicker();
373
+ }
374
+ };
375
+
376
+
377
+ this.showPicker = function() {
378
+ if(!isPickerOwner()) {
379
+ var tp = jscolor.getElementPos(target); // target pos
380
+ var ts = jscolor.getElementSize(target); // target size
381
+ var vp = jscolor.getViewPos(); // view pos
382
+ var vs = jscolor.getViewSize(); // view size
383
+ var ps = getPickerDims(this); // picker size
384
+ var a, b, c;
385
+ switch(this.pickerPosition.toLowerCase()) {
386
+ case 'left': a=1; b=0; c=-1; break;
387
+ case 'right':a=1; b=0; c=1; break;
388
+ case 'top': a=0; b=1; c=-1; break;
389
+ default: a=0; b=1; c=1; break;
390
+ }
391
+ var l = (ts[b]+ps[b])/2;
392
+
393
+ // picker pos
394
+ if (!this.pickerSmartPosition) {
395
+ var pp = [
396
+ tp[a],
397
+ tp[b]+ts[b]-l+l*c
398
+ ];
399
+ } else {
400
+ var pp = [
401
+ -vp[a]+tp[a]+ps[a] > vs[a] ?
402
+ (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
403
+ tp[a],
404
+ -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
405
+ (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
406
+ (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
407
+ ];
408
+ }
409
+ drawPicker(pp[a], pp[b]);
410
+ }
411
+ };
412
+
413
+
414
+ this.importColor = function() {
415
+ if(!valueElement) {
416
+ this.exportColor();
417
+ } else {
418
+ if(!this.adjust) {
419
+ if(!this.fromString(valueElement.value, leaveValue)) {
420
+ styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
421
+ styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
422
+ styleElement.style.color = styleElement.jscStyle.color;
423
+ this.exportColor(leaveValue | leaveStyle);
424
+ }
425
+ } else if(!this.required && /^\s*$/.test(valueElement.value)) {
426
+ valueElement.value = '';
427
+ styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
428
+ styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
429
+ styleElement.style.color = styleElement.jscStyle.color;
430
+ this.exportColor(leaveValue | leaveStyle);
431
+
432
+ } else if(this.fromString(valueElement.value)) {
433
+ // OK
434
+ } else {
435
+ this.exportColor();
436
+ }
437
+ }
438
+ };
439
+
440
+
441
+ this.exportColor = function(flags) {
442
+ if(!(flags & leaveValue) && valueElement) {
443
+ var value = this.toString();
444
+ if(this.caps) { value = value.toUpperCase(); }
445
+ if(this.hash) { value = '#'+value; }
446
+ valueElement.value = value;
447
+ }
448
+ if(!(flags & leaveStyle) && styleElement) {
449
+ styleElement.style.backgroundImage = "none";
450
+ styleElement.style.backgroundColor =
451
+ '#'+this.toString();
452
+ styleElement.style.color =
453
+ 0.213 * this.rgb[0] +
454
+ 0.715 * this.rgb[1] +
455
+ 0.072 * this.rgb[2]
456
+ < 0.5 ? '#FFF' : '#000';
457
+ }
458
+ if(!(flags & leavePad) && isPickerOwner()) {
459
+ redrawPad();
460
+ }
461
+ if(!(flags & leaveSld) && isPickerOwner()) {
462
+ redrawSld();
463
+ }
464
+ };
465
+
466
+
467
+ this.fromHSV = function(h, s, v, flags) { // null = don't change
468
+ if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); }
469
+ if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); }
470
+ if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); }
471
+
472
+ this.rgb = HSV_RGB(
473
+ h===null ? this.hsv[0] : (this.hsv[0]=h),
474
+ s===null ? this.hsv[1] : (this.hsv[1]=s),
475
+ v===null ? this.hsv[2] : (this.hsv[2]=v)
476
+ );
477
+
478
+ this.exportColor(flags);
479
+ };
480
+
481
+
482
+ this.fromRGB = function(r, g, b, flags) { // null = don't change
483
+ if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); }
484
+ if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); }
485
+ if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); }
486
+
487
+ var hsv = RGB_HSV(
488
+ r===null ? this.rgb[0] : r,
489
+ g===null ? this.rgb[1] : g,
490
+ b===null ? this.rgb[2] : b
491
+ );
492
+ if(hsv[0] !== null) {
493
+ this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0]));
494
+ }
495
+ if(hsv[2] !== 0) {
496
+ this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1]));
497
+ }
498
+ this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2]));
499
+
500
+ // update RGB according to final HSV, as some values might be trimmed
501
+ var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]);
502
+ this.rgb[0] = rgb[0];
503
+ this.rgb[1] = rgb[1];
504
+ this.rgb[2] = rgb[2];
505
+
506
+ this.exportColor(flags);
507
+ };
508
+
509
+
510
+ this.fromString = function(hex, flags) {
511
+ var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
512
+ if(!m) {
513
+ return false;
514
+ } else {
515
+ if(m[1].length === 6) { // 6-char notation
516
+ this.fromRGB(
517
+ parseInt(m[1].substr(0,2),16) / 255,
518
+ parseInt(m[1].substr(2,2),16) / 255,
519
+ parseInt(m[1].substr(4,2),16) / 255,
520
+ flags
521
+ );
522
+ } else { // 3-char notation
523
+ this.fromRGB(
524
+ parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
525
+ parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
526
+ parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
527
+ flags
528
+ );
529
+ }
530
+ return true;
531
+ }
532
+ };
533
+
534
+
535
+ this.toString = function() {
536
+ return (
537
+ (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
538
+ (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
539
+ (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
540
+ );
541
+ };
542
+
543
+
544
+ function RGB_HSV(r, g, b) {
545
+ var n = Math.min(Math.min(r,g),b);
546
+ var v = Math.max(Math.max(r,g),b);
547
+ var m = v - n;
548
+ if(m === 0) { return [ null, 0, v ]; }
549
+ var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
550
+ return [ h===6?0:h, m/v, v ];
551
+ }
552
+
553
+
554
+ function HSV_RGB(h, s, v) {
555
+ if(h === null) { return [ v, v, v ]; }
556
+ var i = Math.floor(h);
557
+ var f = i%2 ? h-i : 1-(h-i);
558
+ var m = v * (1 - s);
559
+ var n = v * (1 - s*f);
560
+ switch(i) {
561
+ case 6:
562
+ case 0: return [v,n,m];
563
+ case 1: return [n,v,m];
564
+ case 2: return [m,v,n];
565
+ case 3: return [m,n,v];
566
+ case 4: return [n,m,v];
567
+ case 5: return [v,m,n];
568
+ }
569
+ }
570
+
571
+
572
+ function removePicker() {
573
+ delete jscolor.picker.owner;
574
+ document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
575
+ }
576
+
577
+
578
+ function drawPicker(x, y) {
579
+ if(!jscolor.picker) {
580
+ jscolor.picker = {
581
+ box : document.createElement('div'),
582
+ boxB : document.createElement('div'),
583
+ pad : document.createElement('div'),
584
+ padB : document.createElement('div'),
585
+ padM : document.createElement('div'),
586
+ sld : document.createElement('div'),
587
+ sldB : document.createElement('div'),
588
+ sldM : document.createElement('div'),
589
+ btn : document.createElement('div'),
590
+ btnS : document.createElement('span'),
591
+ btnT : document.createTextNode(THIS.pickerCloseText)
592
+ };
593
+ for(var i=0,segSize=4; i<jscolor.images.sld[1]; i+=segSize) {
594
+ var seg = document.createElement('div');
595
+ seg.style.height = segSize+'px';
596
+ seg.style.fontSize = '1px';
597
+ seg.style.lineHeight = '0';
598
+ jscolor.picker.sld.appendChild(seg);
599
+ }
600
+ jscolor.picker.sldB.appendChild(jscolor.picker.sld);
601
+ jscolor.picker.box.appendChild(jscolor.picker.sldB);
602
+ jscolor.picker.box.appendChild(jscolor.picker.sldM);
603
+ jscolor.picker.padB.appendChild(jscolor.picker.pad);
604
+ jscolor.picker.box.appendChild(jscolor.picker.padB);
605
+ jscolor.picker.box.appendChild(jscolor.picker.padM);
606
+ jscolor.picker.btnS.appendChild(jscolor.picker.btnT);
607
+ jscolor.picker.btn.appendChild(jscolor.picker.btnS);
608
+ jscolor.picker.box.appendChild(jscolor.picker.btn);
609
+ jscolor.picker.boxB.appendChild(jscolor.picker.box);
610
+ }
611
+
612
+ var p = jscolor.picker;
613
+
614
+ // controls interaction
615
+ p.box.onmouseup =
616
+ p.box.onmouseout = function() { target.focus(); };
617
+ p.box.onmousedown = function() { abortBlur=true; };
618
+ p.box.onmousemove = function(e) {
619
+ if (holdPad || holdSld) {
620
+ holdPad && setPad(e);
621
+ holdSld && setSld(e);
622
+ if (document.selection) {
623
+ document.selection.empty();
624
+ } else if (window.getSelection) {
625
+ window.getSelection().removeAllRanges();
626
+ }
627
+ dispatchImmediateChange();
628
+ }
629
+ };
630
+ if('ontouchstart' in window) { // if touch device
631
+ var handle_touchmove = function(e) {
632
+ var event={
633
+ 'offsetX': e.touches[0].pageX-touchOffset.X,
634
+ 'offsetY': e.touches[0].pageY-touchOffset.Y
635
+ };
636
+ if (holdPad || holdSld) {
637
+ holdPad && setPad(event);
638
+ holdSld && setSld(event);
639
+ dispatchImmediateChange();
640
+ }
641
+ e.stopPropagation(); // prevent move "view" on broswer
642
+ e.preventDefault(); // prevent Default - Android Fix (else android generated only 1-2 touchmove events)
643
+ };
644
+ p.box.removeEventListener('touchmove', handle_touchmove, false)
645
+ p.box.addEventListener('touchmove', handle_touchmove, false)
646
+ }
647
+ p.padM.onmouseup =
648
+ p.padM.onmouseout = function() { if(holdPad) { holdPad=false; jscolor.fireEvent(valueElement,'change'); } };
649
+ p.padM.onmousedown = function(e) {
650
+ // if the slider is at the bottom, move it up
651
+ switch(modeID) {
652
+ case 0: if (THIS.hsv[2] === 0) { THIS.fromHSV(null, null, 1.0); }; break;
653
+ case 1: if (THIS.hsv[1] === 0) { THIS.fromHSV(null, 1.0, null); }; break;
654
+ }
655
+ holdSld=false;
656
+ holdPad=true;
657
+ setPad(e);
658
+ dispatchImmediateChange();
659
+ };
660
+ if('ontouchstart' in window) {
661
+ p.padM.addEventListener('touchstart', function(e) {
662
+ touchOffset={
663
+ 'X': e.target.offsetParent.offsetLeft,
664
+ 'Y': e.target.offsetParent.offsetTop
665
+ };
666
+ this.onmousedown({
667
+ 'offsetX':e.touches[0].pageX-touchOffset.X,
668
+ 'offsetY':e.touches[0].pageY-touchOffset.Y
669
+ });
670
+ });
671
+ }
672
+ p.sldM.onmouseup =
673
+ p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; jscolor.fireEvent(valueElement,'change'); } };
674
+ p.sldM.onmousedown = function(e) {
675
+ holdPad=false;
676
+ holdSld=true;
677
+ setSld(e);
678
+ dispatchImmediateChange();
679
+ };
680
+ if('ontouchstart' in window) {
681
+ p.sldM.addEventListener('touchstart', function(e) {
682
+ touchOffset={
683
+ 'X': e.target.offsetParent.offsetLeft,
684
+ 'Y': e.target.offsetParent.offsetTop
685
+ };
686
+ this.onmousedown({
687
+ 'offsetX':e.touches[0].pageX-touchOffset.X,
688
+ 'offsetY':e.touches[0].pageY-touchOffset.Y
689
+ });
690
+ });
691
+ }
692
+
693
+ // picker
694
+ var dims = getPickerDims(THIS);
695
+ p.box.style.width = dims[0] + 'px';
696
+ p.box.style.height = dims[1] + 'px';
697
+
698
+ // picker border
699
+ p.boxB.style.position = 'absolute';
700
+ p.boxB.style.clear = 'both';
701
+ p.boxB.style.left = x+'px';
702
+ p.boxB.style.top = y+'px';
703
+ p.boxB.style.zIndex = THIS.pickerZIndex;
704
+ p.boxB.style.border = THIS.pickerBorder+'px solid';
705
+ p.boxB.style.borderColor = THIS.pickerBorderColor;
706
+ p.boxB.style.background = THIS.pickerFaceColor;
707
+
708
+ // pad image
709
+ p.pad.style.width = jscolor.images.pad[0]+'px';
710
+ p.pad.style.height = jscolor.images.pad[1]+'px';
711
+
712
+ // pad border
713
+ p.padB.style.position = 'absolute';
714
+ p.padB.style.left = THIS.pickerFace+'px';
715
+ p.padB.style.top = THIS.pickerFace+'px';
716
+ p.padB.style.border = THIS.pickerInset+'px solid';
717
+ p.padB.style.borderColor = THIS.pickerInsetColor;
718
+
719
+ // pad mouse area
720
+ p.padM.style.position = 'absolute';
721
+ p.padM.style.left = '0';
722
+ p.padM.style.top = '0';
723
+ p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + 'px';
724
+ p.padM.style.height = p.box.style.height;
725
+ p.padM.style.cursor = 'crosshair';
726
+
727
+ // slider image
728
+ p.sld.style.overflow = 'hidden';
729
+ p.sld.style.width = jscolor.images.sld[0]+'px';
730
+ p.sld.style.height = jscolor.images.sld[1]+'px';
731
+
732
+ // slider border
733
+ p.sldB.style.display = THIS.slider ? 'block' : 'none';
734
+ p.sldB.style.position = 'absolute';
735
+ p.sldB.style.right = THIS.pickerFace+'px';
736
+ p.sldB.style.top = THIS.pickerFace+'px';
737
+ p.sldB.style.border = THIS.pickerInset+'px solid';
738
+ p.sldB.style.borderColor = THIS.pickerInsetColor;
739
+
740
+ // slider mouse area
741
+ p.sldM.style.display = THIS.slider ? 'block' : 'none';
742
+ p.sldM.style.position = 'absolute';
743
+ p.sldM.style.right = '0';
744
+ p.sldM.style.top = '0';
745
+ p.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
746
+ p.sldM.style.height = p.box.style.height;
747
+ try {
748
+ p.sldM.style.cursor = 'pointer';
749
+ } catch(eOldIE) {
750
+ p.sldM.style.cursor = 'hand';
751
+ }
752
+
753
+ // "close" button
754
+ function setBtnBorder() {
755
+ var insetColors = THIS.pickerInsetColor.split(/\s+/);
756
+ var pickerOutsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1];
757
+ p.btn.style.borderColor = pickerOutsetColor;
758
+ }
759
+ p.btn.style.display = THIS.pickerClosable ? 'block' : 'none';
760
+ p.btn.style.position = 'absolute';
761
+ p.btn.style.left = THIS.pickerFace + 'px';
762
+ p.btn.style.bottom = THIS.pickerFace + 'px';
763
+ p.btn.style.padding = '0 15px';
764
+ p.btn.style.height = '18px';
765
+ p.btn.style.border = THIS.pickerInset + 'px solid';
766
+ setBtnBorder();
767
+ p.btn.style.color = THIS.pickerButtonColor;
768
+ p.btn.style.font = '12px sans-serif';
769
+ p.btn.style.textAlign = 'center';
770
+ try {
771
+ p.btn.style.cursor = 'pointer';
772
+ } catch(eOldIE) {
773
+ p.btn.style.cursor = 'hand';
774
+ }
775
+ p.btn.onmousedown = function () {
776
+ THIS.hidePicker();
777
+ };
778
+ p.btnS.style.lineHeight = p.btn.style.height;
779
+
780
+ // load images in optimal order
781
+ switch(modeID) {
782
+ case 0: var padImg = 'hs.png'; break;
783
+ case 1: var padImg = 'hv.png'; break;
784
+ }
785
+ p.padM.style.backgroundImage = "url('"+jscolor.getDir()+"cross.gif')";
786
+ p.padM.style.backgroundRepeat = "no-repeat";
787
+ p.sldM.style.backgroundImage = "url('"+jscolor.getDir()+"arrow.gif')";
788
+ p.sldM.style.backgroundRepeat = "no-repeat";
789
+ p.pad.style.backgroundImage = "url('"+jscolor.getDir()+padImg+"')";
790
+ p.pad.style.backgroundRepeat = "no-repeat";
791
+ p.pad.style.backgroundPosition = "0 0";
792
+
793
+ // place pointers
794
+ redrawPad();
795
+ redrawSld();
796
+
797
+ jscolor.picker.owner = THIS;
798
+ document.getElementsByTagName('body')[0].appendChild(p.boxB);
799
+ }
800
+
801
+
802
+ function getPickerDims(o) {
803
+ var dims = [
804
+ 2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[0] +
805
+ (o.slider ? 2*o.pickerInset + 2*jscolor.images.arrow[0] + jscolor.images.sld[0] : 0),
806
+ o.pickerClosable ?
807
+ 4*o.pickerInset + 3*o.pickerFace + jscolor.images.pad[1] + o.pickerButtonHeight :
808
+ 2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[1]
809
+ ];
810
+ return dims;
811
+ }
812
+
813
+
814
+ function redrawPad() {
815
+ // redraw the pad pointer
816
+ switch(modeID) {
817
+ case 0: var yComponent = 1; break;
818
+ case 1: var yComponent = 2; break;
819
+ }
820
+ var x = Math.round((THIS.hsv[0]/6) * (jscolor.images.pad[0]-1));
821
+ var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.pad[1]-1));
822
+ jscolor.picker.padM.style.backgroundPosition =
823
+ (THIS.pickerFace+THIS.pickerInset+x - Math.floor(jscolor.images.cross[0]/2)) + 'px ' +
824
+ (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.cross[1]/2)) + 'px';
825
+
826
+ // redraw the slider image
827
+ var seg = jscolor.picker.sld.childNodes;
828
+
829
+ switch(modeID) {
830
+ case 0:
831
+ var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
832
+ for(var i=0; i<seg.length; i+=1) {
833
+ seg[i].style.backgroundColor = 'rgb('+
834
+ (rgb[0]*(1-i/seg.length)*100)+'%,'+
835
+ (rgb[1]*(1-i/seg.length)*100)+'%,'+
836
+ (rgb[2]*(1-i/seg.length)*100)+'%)';
837
+ }
838
+ break;
839
+ case 1:
840
+ var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
841
+ var i = Math.floor(THIS.hsv[0]);
842
+ var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
843
+ switch(i) {
844
+ case 6:
845
+ case 0: rgb=[0,1,2]; break;
846
+ case 1: rgb=[1,0,2]; break;
847
+ case 2: rgb=[2,0,1]; break;
848
+ case 3: rgb=[2,1,0]; break;
849
+ case 4: rgb=[1,2,0]; break;
850
+ case 5: rgb=[0,2,1]; break;
851
+ }
852
+ for(var i=0; i<seg.length; i+=1) {
853
+ s = 1 - 1/(seg.length-1)*i;
854
+ c[1] = c[0] * (1 - s*f);
855
+ c[2] = c[0] * (1 - s);
856
+ seg[i].style.backgroundColor = 'rgb('+
857
+ (c[rgb[0]]*100)+'%,'+
858
+ (c[rgb[1]]*100)+'%,'+
859
+ (c[rgb[2]]*100)+'%)';
860
+ }
861
+ break;
862
+ }
863
+ }
864
+
865
+
866
+ function redrawSld() {
867
+ // redraw the slider pointer
868
+ switch(modeID) {
869
+ case 0: var yComponent = 2; break;
870
+ case 1: var yComponent = 1; break;
871
+ }
872
+ var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.sld[1]-1));
873
+ jscolor.picker.sldM.style.backgroundPosition =
874
+ '0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.arrow[1]/2)) + 'px';
875
+ }
876
+
877
+
878
+ function isPickerOwner() {
879
+ return jscolor.picker && jscolor.picker.owner === THIS;
880
+ }
881
+
882
+
883
+ function blurTarget() {
884
+ if(valueElement === target) {
885
+ THIS.importColor();
886
+ }
887
+ if(THIS.pickerOnfocus) {
888
+ THIS.hidePicker();
889
+ }
890
+ }
891
+
892
+
893
+ function blurValue() {
894
+ if(valueElement !== target) {
895
+ THIS.importColor();
896
+ }
897
+ }
898
+
899
+
900
+ function setPad(e) {
901
+ var mpos = jscolor.getRelMousePos(e);
902
+ var x = mpos.x - THIS.pickerFace - THIS.pickerInset;
903
+ var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
904
+ switch(modeID) {
905
+ case 0: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), 1 - y/(jscolor.images.pad[1]-1), null, leaveSld); break;
906
+ case 1: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), null, 1 - y/(jscolor.images.pad[1]-1), leaveSld); break;
907
+ }
908
+ }
909
+
910
+
911
+ function setSld(e) {
912
+ var mpos = jscolor.getRelMousePos(e);
913
+ var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
914
+ switch(modeID) {
915
+ case 0: THIS.fromHSV(null, null, 1 - y/(jscolor.images.sld[1]-1), leavePad); break;
916
+ case 1: THIS.fromHSV(null, 1 - y/(jscolor.images.sld[1]-1), null, leavePad); break;
917
+ }
918
+ }
919
+
920
+
921
+ function dispatchImmediateChange() {
922
+ if (THIS.onImmediateChange) {
923
+ var callback;
924
+ if (typeof THIS.onImmediateChange === 'string') {
925
+ callback = new Function (THIS.onImmediateChange);
926
+ } else {
927
+ callback = THIS.onImmediateChange;
928
+ }
929
+ callback.call(THIS);
930
+ }
931
+ }
932
+
933
+
934
+ var THIS = this;
935
+ var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
936
+ var abortBlur = false;
937
+ var
938
+ valueElement = jscolor.fetchElement(this.valueElement),
939
+ styleElement = jscolor.fetchElement(this.styleElement);
940
+ var
941
+ holdPad = false,
942
+ holdSld = false,
943
+ touchOffset = {};
944
+ var
945
+ leaveValue = 1<<0,
946
+ leaveStyle = 1<<1,
947
+ leavePad = 1<<2,
948
+ leaveSld = 1<<3;
949
+
950
+ // target
951
+ jscolor.addEvent(target, 'focus', function() {
952
+ if(THIS.pickerOnfocus) { THIS.showPicker(); }
953
+ });
954
+ jscolor.addEvent(target, 'blur', function() {
955
+ if(!abortBlur) {
956
+ window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
957
+ } else {
958
+ abortBlur = false;
959
+ }
960
+ });
961
+
962
+ // valueElement
963
+ if(valueElement) {
964
+ var updateField = function() {
965
+ THIS.fromString(valueElement.value, leaveValue);
966
+ dispatchImmediateChange();
967
+ };
968
+ jscolor.addEvent(valueElement, 'keyup', updateField);
969
+ jscolor.addEvent(valueElement, 'input', updateField);
970
+ jscolor.addEvent(valueElement, 'blur', blurValue);
971
+ valueElement.setAttribute('autocomplete', 'off');
972
+ }
973
+
974
+ // styleElement
975
+ if(styleElement) {
976
+ styleElement.jscStyle = {
977
+ backgroundImage : styleElement.style.backgroundImage,
978
+ backgroundColor : styleElement.style.backgroundColor,
979
+ color : styleElement.style.color
980
+ };
981
+ }
982
+
983
+ // require images
984
+ switch(modeID) {
985
+ case 0: jscolor.requireImage('hs.png'); break;
986
+ case 1: jscolor.requireImage('hv.png'); break;
987
+ }
988
+ jscolor.requireImage('cross.gif');
989
+ jscolor.requireImage('arrow.gif');
990
+
991
+ this.importColor();
992
+ }
993
+
994
+ };
995
+
996
+
997
+ jscolor.install();
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Phxsolution_Formbuilder</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Custom form builder</summary>
10
+ <description>Custom form builder</description>
11
+ <notes>Fixed some minor bugs.</notes>
12
+ <authors><author><name>Murad Ali</name><user>phxsolution</user><email>contact@phxsolution.com</email></author></authors>
13
+ <date>2015-01-30</date>
14
+ <time>14:13:31</time>
15
+ <contents><target name="mageetc"><dir name="."><file name="Phxsolution_Formbuilder.xml" hash=""/></dir></target><target name="magecommunity"><dir name="Phxsolution"><dir name="Formbuilder"><dir name="Block"><dir name="Adminhtml"><dir name="Formbuilder"><dir name="Edit"><dir name="Elements"><file name="Jscolorblock.php" hash="1a990d2bf3de66e0a57dfbee0392a24c"/></dir><file name="Form.php" hash="e20273437fb55a13d45d7f614b49e5ed"/><dir name="Tab"><file name="Fieldsgrid.php" hash="935506a56a3e021d90b39469381c1f95"/><file name="Form.php" hash="0f101907777b961c6a8276ec1ee6b553"/><dir name="Options"><file name="Option.php" hash="b90344afd1f05bfc8fd93fd8d6ad6e98"/><dir name="Type"><file name="Date.php" hash="c0565edcd7fe65e834c781d42a6d19c2"/><file name="File.php" hash="0bc4ad5bedd67075aeb36255a90934f5"/><file name="Select.php" hash="6f8fc022bec1946ca819d01426132013"/><file name="Text.php" hash="f0aaf04e77ed8877a91e8335d164a7a3"/></dir></dir><file name="Options.php" hash="a5eb61c23da76f98a58adfbc72ca3746"/><file name="Recordsgrid.php" hash="c7b64bb9e72ea272dc498f41862b9d24"/></dir><file name="Tabs.php" hash="594b46d1fb37f35da23435e5a29ad81e"/></dir><file name="Edit.php" hash="14988d6334ce10c41c5e1c4dcd77bfc4"/><file name="Grid.php" hash="f340245d0ba0c753076da26443de5bf9"/><dir name="Renderer"><file name="Fieldtitle.php" hash="77de7c80130e9c65f9a480c76fef1595"/><file name="Formtitle.php" hash="4f9ace648d90453f65163d9cf71f25af"/><file name="Getoptions.php" hash="4f4bbab55ae3b846c3e82f08d724e93c"/><file name="Image.php" hash="5f8a73638c4f56f31f98cfb66e955e61"/><file name="Numberoffields.php" hash="d6ce87f925d62b87b05e9267e79ae186"/><file name="Recordvalue.php" hash="139e84376a1c38d5b7e123db4dbbb8a8"/></dir></dir><file name="Formbuilder.php" hash="f9f257c3730efb61a02c648e24613d5e"/></dir><dir name="Frontend"><file name="Date.php" hash="0797ca67913af04e5a174db2b53419eb"/><file name="File.php" hash="73b64e65cb622ea93ed127ac690103ae"/><file name="Form.php" hash="d5f5bc44ec2d929e91d22772275121de"/><file name="Formbuilder.php" hash="99d21ff63f09c50bb1c02f231201a7a1"/><file name="Select.php" hash="d97b7f7fa96c4327fb722b14a2995140"/><file name="Text.php" hash="e0dea9657f1ce1b7630f630e3bf133d4"/></dir></dir><dir name="Helper"><file name="Data.php" hash="9325a45f92283e264746a28c5dc2861e"/></dir><dir name="Model"><file name="Fields.php" hash="e03fcfc2bcfda3a0159d32fb134278d6"/><file name="Forms.php" hash="b911a987069ab83971cd8679696f1141"/><dir name="Mysql4"><dir name="Fields"><file name="Collection.php" hash="c7226e1388d223abd4869e2c960fd1c9"/></dir><file name="Fields.php" hash="53a3270bcc205ad77827e501b99d8258"/><dir name="Forms"><file name="Collection.php" hash="ed05e64031c62842df14721614687b33"/></dir><file name="Forms.php" hash="ec9f6f339eb39f32f3b5de7f8d2532ad"/><dir name="Options"><file name="Collection.php" hash="cc0d0272478f6d4f8b72d27bd96d55da"/></dir><file name="Options.php" hash="93bbe8f013286c7b2b4e2afb5d7da780"/><dir name="Records"><file name="Collection.php" hash="70e6959cf7b609f39aebed7058d5b34e"/></dir><file name="Records.php" hash="3209f8474955cff494c419b00fa729f5"/></dir><file name="Observer.php" hash="83deea98e8df7e61962cfb0af69a7682"/><file name="Options.php" hash="90fccc8c4be7b66d269fa9f88c069716"/><file name="Records.php" hash="76f39afcb412cfbae3211df2332ff407"/><file name="Status.php" hash="46137d1b2f0f3a2bc96729db3e0c6e99"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormbuilderController.php" hash="44cbde7be22fd873e330aa1fa9df082f"/></dir><file name="IndexController.php" hash="9dbe6bb107ec88528d979a99a23fb93f"/></dir><dir name="etc"><file name="config.xml" hash="bc7b573b1a59a7e014d684d0186373ee"/><file name="system.xml" hash="f907c9ecd89a531ae3e6da816d397d74"/></dir><dir name="sql"><dir name="formbuilder_setup"><file name="mysql4-install-0.1.0.php" hash="16a10b71a46e014f24c4c9f3e6c059e5"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="formbuilder.xml" hash="bc26c0630ebd5156020612429f7222ce"/></dir><dir name="template"><dir name="formbuilder"><file name="date.phtml" hash="f9cf6dbae29f6078b1891d304c2546de"/><file name="file.phtml" hash="f9eb1f8c2cd771721073680d88980d85"/><file name="form.phtml" hash="28d0723b899618875fbfbe1bad88c2d0"/><file name="formbuilder.phtml" hash="28ea24b9237feec17e8475d0540e06a2"/><file name="select.phtml" hash="3d95fa9af63afcf5eccff1250d48f7dc"/><file name="text.phtml" hash="38503786b985bf3fcd48af6009a4bb10"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="formbuilder.xml" hash="8f01fe47ae07d651a44cd514e680696c"/></dir><dir name="template"><dir name="formbuilder"><dir name="catalog"><dir name="product"><dir name="edit"><dir name="options"><file name="option.phtml" hash="c24802beaec38ea569082a0dc0268ad1"/><dir name="type"><file name="date.phtml" hash="e939ad56a38df54ef2e02050b8c196d4"/><file name="file.phtml" hash="6195acc29483fc3743f4f3761c2050c4"/><file name="select.phtml" hash="bad580b6b244b717a1de0a266edd255a"/><file name="text.phtml" hash="72d6ef6a4a46b7b342fd90be449e3731"/></dir></dir><file name="options.phtml" hash="8b4febcfd81ce0ef726393fbabfdd024"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="formbuilder"><file name="custom.css" hash="497bfb41e94a4659d36bffdaa0714a7b"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="formbuilder"><dir name="jscolor"><file name="arrow.gif" hash="5034704a76cd55c1cbcbc58ea6bf523f"/><file name="cross.gif" hash="ba9a274b9323753cd95bc3b1eb2f4e5f"/><file name="hs.png" hash="fefa1a03d92ebad25c88dca94a0b63db"/><file name="hv.png" hash="990d71cada17da100653636cf8490884"/><file name="jscolor.js" hash="d85e03380b38c0937ee2c2594c599720"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/formbuilder/custom.css ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ /**
3
+ * Phxsolution Formbuilder
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 you can be sent a copy immediately.
14
+ *
15
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
16
+ *
17
+ * @category module css
18
+ * @package Phxsolution_Formbuilder
19
+ * @author Murad Ali
20
+ * @contact contact@phxsolution.com
21
+ * @site www.phxsolution.com
22
+ * @copyright Copyright (c) 2014 Phxsolution Formbuilder
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
25
+ .form-list .input-box {width:450px}
26
+ .product-options {border: 1px solid #333;}
27
+ .formbuilder ul {list-style: none !important; list-style-type: none !important;}