1: <?php
2: /*****************************************************************************************
3: * X2Engine Open Source Edition is a customer relationship management program developed by
4: * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
5: *
6: * This program is free software; you can redistribute it and/or modify it under
7: * the terms of the GNU Affero General Public License version 3 as published by the
8: * Free Software Foundation with the addition of the following permission added
9: * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10: * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
11: * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12: *
13: * This program is distributed in the hope that it will be useful, but WITHOUT
14: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15: * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16: * details.
17: *
18: * You should have received a copy of the GNU Affero General Public License along with
19: * this program; if not, see http://www.gnu.org/licenses or write to the Free
20: * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21: * 02110-1301 USA.
22: *
23: * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
24: * California 95067, USA. or at email address contact@x2engine.com.
25: *
26: * The interactive user interfaces in modified source and object code versions
27: * of this program must display Appropriate Legal Notices, as required under
28: * Section 5 of the GNU Affero General Public License version 3.
29: *
30: * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31: * these Appropriate Legal Notices must retain the display of the "Powered by
32: * X2Engine" logo. If the display of the logo is not reasonably feasible for
33: * technical reasons, the Appropriate Legal Notices must display the words
34: * "Powered by X2Engine".
35: *****************************************************************************************/
36:
37: Yii::import('application.components.WebFormDesigner.views.*');
38:
39: /**
40: * Parent Widget class to handle the 3 different Webforms
41: */
42: class WebFormDesigner extends X2Widget {
43:
44: /**
45: * Name of web form
46: * 'list', 'service', 'weblead'
47: * @var string
48: */
49: public $type;
50:
51:
52:
53: /**
54: * @var string
55: */
56: public $url;
57:
58: /**
59: * @var string
60: */
61: public $saveUrl;
62:
63: /**
64: * Name of the JS Class
65: * @var [type]
66: */
67: public $protoName;
68:
69: public $forms;
70:
71: public $formAttrs = array();
72:
73: public $id;
74:
75: public $viewFile = 'application.components.WebFormDesigner.views._createWebForm2';
76:
77: /**
78: * List of Default Fields
79: * @var array
80: */
81: public $defaultList = array();
82:
83:
84:
85: public $modelName;
86:
87: public function init () {
88: $this->JSClass = $this->protoName;
89:
90:
91:
92: foreach ($this->forms as $form) {
93: $this->formAttrs[] = $form->attributes;
94: }
95:
96: }
97:
98: public function run () {
99: $this->registerPackages ();
100: $this->instantiateJSClass ();
101: $this->render($this->viewFile);
102: }
103:
104: public function getPackages () {
105: // Default Packages
106: $this->_packages = array_merge ( parent::getPackages(), array(
107:
108: 'WebFormDesignerJS' => array (
109: 'baseUrl' => Yii::app()->baseUrl,
110: 'js' => array('js/WebFormDesigner/WebFormDesigner.js'),
111: 'depends' => array('auxlib')
112: ),
113: 'WebFormDesignerCSS' => array (
114: 'baseUrl' => Yii::app()->theme->baseUrl,
115: 'css' => array ('css/createWebForm.css'),
116: ),
117: )
118: );
119:
120: return $this->_packages;
121: }
122:
123: public function getJSObjectName () {
124: return 'x2.webFormDesigner';
125: }
126:
127: public function getJSClassParams () {
128: $this->_JSClassParams = array_merge (parent::getJSClassParams(), array(
129: 'iframeSrc' => Yii::app()->createExternalUrl($this->url),
130: 'externalAbsoluteBaseUrl' => Yii::app()->getExternalAbsoluteBaseUrl (),
131: 'saveUrl' => Yii::app()->createAbsoluteUrl ($this->saveUrl),
132: 'savedForms' => $this->formAttrs,
133: 'deleteFormUrl' => Yii::app()->createAbsoluteUrl (
134: '/marketing/marketing/deleteWebForm'),
135: 'fields' => array('fg','bgc','font','bs','bc'),
136: 'colorfields' => array('fg','bgc','bc'),
137: ));
138:
139: return $this->_JSClassParams;
140: }
141:
142: /**
143: * Builds the dropdown for saved webforms
144: * @return html constructed HTML
145: */
146: public function getDropDown () {
147: array_unshift($this->formAttrs, array('id'=>'0', 'name'=>'------------'));
148:
149: $html = CHtml::dropDownList(
150: 'saved-forms', '',
151: CHtml::encodeArray(CHtml::listData($this->formAttrs, 'id', 'name')),
152: array (
153: 'class' => 'left'
154: ));
155:
156: return $html;
157: }
158:
159: /**
160: * @see X2Widget::getTranslations
161: */
162: public function getTranslations () {
163: return array (
164: 'formSavedMsg' => Yii::t('marketing', 'Form Saved'),
165: 'nameRequiredMsg' => Yii::t('marketing', 'Name cannot be blank.'),
166: 'Label:' => Yii::t('marketing', 'Label:'),
167: 'Value:' => Yii::t('marketing', 'Value:'),
168: );
169: }
170:
171: /**
172: * Each web form has a unique view file that is rendered based on its type
173: */
174: public function renderSpecific() {
175: $this->render('application.components.WebFormDesigner.views.'.$this->type);
176: }
177:
178: public function getDescription() {
179: return '';
180: }
181:
182:
183:
184:
185: }
186:
187: ?>
188: