1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35:
36:
37: 38: 39: 40: 41:
42:
43:
44: mb_internal_encoding('UTF-8');
45: mb_regex_encoding('UTF-8');
46: Yii::app()->params->profile = Profile::model()->findByPk(1);
47: if (empty($type)) $type = 'weblead';
48: if (empty($model)) $model = Contacts::model ();
49:
50:
51:
52: if ($type === 'service') {
53: $modelName = 'Services';
54: } else if ($type === 'weblead') {
55: $modelName = 'Contacts';
56: }
57:
58:
59: $defaultFields;
60: if ($type === 'weblead') {
61: $defaultFields = array (
62: array (
63: 'fieldName' => 'firstName',
64: 'position' => 'top',
65: 'required' => 1
66: ),
67: array (
68: 'fieldName' => 'lastName',
69: 'position' => 'top',
70: 'required' => 1
71: ),
72: array (
73: 'fieldName' => 'email',
74: 'position' => 'top',
75: 'required' => 1
76: ),
77: array (
78: 'fieldName' => 'phone',
79: 'position' => 'top',
80: 'required' => 0
81: ),
82: array (
83: 'fieldName' => 'backgroundInfo',
84: 'position' => 'top',
85: 'required' => 0
86: ),
87: );
88: } else if ($type === 'service') {
89: $defaultFields = array (
90: array (
91: 'fieldName' => 'firstName',
92: 'position' => 'top',
93: 'required' => 1
94: ),
95: array (
96: 'fieldName' => 'lastName',
97: 'position' => 'top',
98: 'required' => 1
99: ),
100: array (
101: 'fieldName' => 'email',
102: 'position' => 'top',
103: 'required' => 1
104: ),
105: array (
106: 'fieldName' => 'phone',
107: 'position' => 'top',
108: 'required' => 0
109: ),
110: array (
111: 'fieldName' => 'description',
112: 'position' => 'top',
113: 'required' => 0
114: ),
115: );
116: }
117:
118: $useDefaults = false;
119:
120:
121: $fieldList = $defaultFields;
122: $useDefaults = true;
123:
124:
125: $fieldTypes = array_map (function ($elem) {
126: if ($elem['required']) return $elem['fieldName']; }, $fieldList);
127:
128: if ($type === 'service') {
129: $contactFields = array('firstName', 'lastName', 'email', 'phone');
130: } else {
131: $contactFields = null;
132: }
133:
134: ?>
135:
136: <!DOCTYPE html>
137: <html xmlns="http://www.w3.org/1999/xhtml"
138: xml:lang="<?php echo Yii::app()->language; ?>" lang="<?php echo Yii::app()->language; ?>">
139: <head>
140: <meta charset="UTF-8" />
141: <meta name="language" content="<?php echo Yii::app()->language; ?>" />
142: <title><?php echo CHtml::encode($this->pageTitle); ?></title>
143: <?php $this->renderGaCode('public'); ?>
144:
145: <script type="text/javascript"
146: src="<?php echo Yii::app()->clientScript->coreScriptUrl . '/jquery.js'; ?>">
147: </script>
148:
149: <?php
150:
151:
152: ?>
153:
154: <style type="text/css">
155: html {
156: <?php
157: 158: 159: 160: 161: 162:
163:
164: if (isset ($iframeHeight)) {
165: $height = $iframeHeight;
166: } else {
167: $height = $type == 'weblist' ? 125 : 325;
168: }
169: if (isset ($bs)) {
170: $border = intval(preg_replace('/[^0-9]/', '', $bs));
171: } else if (isset ($bc)) {
172: $border = 0;
173: } else $border = 0;
174: $padding = 36;
175: $height = $height - $padding - (2 * $border);
176:
177: echo 'border: '. $border .'px solid ';
178: if (isset ($bc)) echo addslashes ($bc);
179: echo ";\n";
180:
181: ?>
182:
183: -moz-border-radius: 3px;
184: -webkit-border-radius: 3px;
185: border-radius: 3px;
186: padding-bottom: <?php echo addslashes ($padding) ."px;\n"?>
187: height: <?php echo addslashes ($height) ."px;\n"?>
188: }
189: body {
190: <?php
191: if (isset ($fg)) {
192: echo 'color: '. addslashes ($fg) .";\n";
193: }
194: if (isset ($bgc)) echo 'background-color: '. addslashes ($bgc) .";\n";
195: if (isset ($font)) {
196: echo 'font-family: '. addslashes (FontPickerInput::getFontCss($font)) .";\n";
197: } else {
198: echo "font-family: Arial, Helvetica, sans-serif;\n";
199: }
200: ?>
201: font-size:12px;
202: }
203:
204: input {
205: border: 1px solid
206: font-family: inherit;
207: }
208: .row {
209: margin-bottom: 10px;
210: }
211: textarea {
212: box-sizing: border-box;
213: width: 100%;
214: height: 100px;
215: border-radius: 2px;
216: font-family: inherit;
217: }
218: input[type="text"] {
219: box-sizing: border-box;
220: padding: 2px;
221: border-radius: 2px;
222: line-height: 1.5em;
223: }
224: input[type="text"] {
225: width: 100%;
226: }
227:
228: color:white;
229: text-align:center;
230: font-size: 16px;
231: }
232:
233: box-sizing:border-box;
234: float: right;
235: margin-top: 7px;
236: margin-bottom: 5px;
237: padding: 7px;
238: border-radius: 2px;
239: width: 100%;
240: font-family: inherit;
241: }
242:
243:
244: }
245: .submit-button-row {
246: height: 30px;
247: }
248: <?php
249:
250: ?>
251: </style>
252:
253: <?php
254:
255: ?>
256: </head>
257: <body>
258:
259: <?php
260: foreach(Yii::app()->user->getFlashes() as $key => $message) {
261: echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
262: }
263:
264: $form = $this->beginWidget('CActiveForm', array(
265: 'id'=>$type,
266: 'enableAjaxValidation'=>false,
267: 'htmlOptions'=>array(
268: ),
269: ));
270:
271: function renderFields ($fieldList, $type, $form, $model, $contactFields=null) {
272: foreach($fieldList as $field) {
273: $fieldName = $field['fieldName'];
274: if(!isset($field['type']) || $field['type']==='normal'){
275: if(isset($field['label']) && $field['label'] != '') {
276: $label = '<label>' . $field['label'] . '</label>';
277: } else {
278: if($type === 'service' && in_array($field['fieldName'], $contactFields)){
279: $contact = clone Contacts::model ();
280: if ($model->hasErrors ($fieldName)) {
281: $contact->addError ($fieldName, $model->getError ($fieldName));
282: }
283: $label = $form->labelEx ($contact, $fieldName);
284: }else{
285: $label = $form->labelEx($model,$field['fieldName']);
286: }
287: }
288:
289:
290: $starred = strpos($label, '*') !== false;
291: ?>
292: <div class="row">
293: <?php
294: echo $label;
295: echo ($field['required'] && !$starred ?
296: '<span class="asterisk"> *</span>' : '');
297: if($field['position'] == 'top') { ?>
298: <br />
299: <?php
300: }
301: echo $form->error($model, $field['fieldName']);
302:
303: if($type === 'service' && in_array($field['fieldName'], $contactFields)){
304: echo CHtml::tag ('input', array (
305: 'type' => 'text',
306: 'name' => 'Services['.$field['fieldName'].']',
307: 'class' => $model->hasErrors ($field['fieldName']) ? 'error' : '',
308: 'value' => isset ($_POST['Services'][$field['fieldName']]) ?
309: $_POST['Services'][$field['fieldName']] : '',
310: ));
311: } else {
312:
313: echo $model->renderInput($field['fieldName']);
314:
315: } ?>
316: </div>
317: <?php
318: }elseif ($field['type'] === 'tags') {
319: ?>
320: <input type="hidden" name="tags" value="<?php echo $field['label']?>" />
321: <?php
322: }elseif ($field['type'] === 'hidden') {
323: $model->{$field['fieldName']}=$field['label'];
324: echo $form->hiddenField($model, $field['fieldName']);
325: }
326: }
327: }
328:
329: renderFields ($fieldList, $type, $form, $model, $contactFields);
330:
331:
332:
333: ?>
334: <div class="submit-button-row row">
335: <?php
336: echo CHtml::submitButton(Yii::t('app','Submit'),array('id'=>'submit'));
337: ?>
338: </div>
339:
340: <?php
341: $this->endWidget();
342: ?>
343:
344: <script>
345: (function () {
346:
347: $('form').submit (function () {
348: $(this).find ('#submit').attr ('disabled', 'disabled');
349: });
350: }) ();
351:
352: <?php
353:
354:
355: ?>
356: </script>
357:
358: </body>
359: </html>
360: