HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbInputVertical.php
Go to the documentation of this file.
1 <?php
11 Yii::import('booster.widgets.input.TbInput');
12 
21 class TbInputVertical extends TbInput
22 {
27  protected function checkBox()
28  {
29  $attribute = $this->attribute;
30  list($hidden, $checkbox) = $this->getSeparatedSelectableInput();
31 
32  echo ($hidden) ? $hidden . PHP_EOL : '';
33  echo '<label class="checkbox" for="' . $this->getAttributeId($attribute) . '">';
34  echo $checkbox . PHP_EOL;
35  echo $this->model->getAttributeLabel($attribute);
36  echo $this->getError() . $this->getHint();
37  echo '</label>';
38  }
39 
44  protected function toggleButton()
45  {
46  // widget configuration is set on htmlOptions['options']
47  $options = array(
48  'model' => $this->model,
49  'attribute' => $this->attribute
50  );
51  if (isset($this->htmlOptions['options'])) {
52  $options = CMap::mergeArray($options, $this->htmlOptions['options']);
53  unset($this->htmlOptions['options']);
54  }
55  $options['htmlOptions'] = $this->htmlOptions;
56 
57  echo $this->getLabel();
58  $this->widget('booster.widgets.TbToggleButton', $options);
59  echo $this->getError() . $this->getHint();
60  }
61 
66  protected function checkBoxList()
67  {
68  echo $this->getLabel();
69  echo $this->form->checkBoxList($this->model, $this->attribute, $this->data, $this->htmlOptions);
70  echo $this->getError() . $this->getHint();
71  }
72 
77  protected function checkBoxListInline()
78  {
79  $this->htmlOptions['inline'] = true;
80  $this->checkBoxList();
81  }
82 
87  protected function checkBoxGroupsList()
88  {
89  if (isset($this->htmlOptions['for']) && !empty($this->htmlOptions['for'])) {
90  $label_for = $this->htmlOptions['for'];
91  unset($this->htmlOptions['for']);
92  } else if (isset($this->data) && !empty($this->data)) {
93  $label_for = CHtml::getIdByName(
94  get_class($this->model) . '[' . $this->attribute . '][' . key($this->data) . ']'
95  );
96  }
97 
98  if (isset($label_for)) {
99  $this->labelOptions = array('for' => $label_for);
100  }
101 
102  echo $this->getLabel();
103  echo $this->form->checkBoxGroupsList($this->model, $this->attribute, $this->data, $this->htmlOptions);
104  echo $this->getError() . $this->getHint();
105  }
106 
111  protected function dropDownList()
112  {
113  echo $this->getLabel();
114  echo $this->form->dropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
115  echo $this->getError() . $this->getHint();
116  }
117 
122  protected function fileField()
123  {
124  echo $this->getLabel();
125  echo $this->form->fileField($this->model, $this->attribute, $this->htmlOptions);
126  echo $this->getError() . $this->getHint();
127  }
128 
133  protected function passwordField()
134  {
135  echo $this->getLabel();
136  echo $this->getPrepend();
137  echo $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions);
138  echo $this->getAppend();
139  echo $this->getError() . $this->getHint();
140  }
141 
147  protected function passfieldField()
148  {
149  if (isset($this->htmlOptions['options'])) {
150  $options = $this->htmlOptions['options'];
151  unset($this->htmlOptions['options']);
152  }
153 
154  if (isset($this->htmlOptions['events'])) {
155  $events = $this->htmlOptions['events'];
156  unset($this->htmlOptions['events']);
157  }
158 
159  echo $this->getLabel();
160  echo $this->getPrepend();
161  $this->widget(
162  'booster.widgets.TbPassfield',
163  array(
164  'model' => $this->model,
165  'attribute' => $this->attribute,
166  'options' => isset($options) ? $options : array(),
167  'events' => isset($events) ? $events : array(),
168  'htmlOptions' => $this->htmlOptions,
169  )
170  );
171  echo $this->getAppend();
172  echo $this->getError() . $this->getHint();
173  }
174 
179  protected function radioButton()
180  {
181  $attribute = $this->attribute;
182  list($hidden, $radioButton) = $this->getSeparatedSelectableInput();
183 
184  echo ($hidden) ? $hidden . PHP_EOL : '';
185  echo '<label class="radio" for="' . $this->getAttributeId($attribute) . '">';
186  echo $radioButton . PHP_EOL;
187  //echo $this->form->radioButton($this->model, $this->attribute, $this->htmlOptions) . PHP_EOL;
188  echo $this->model->getAttributeLabel($attribute);
189  echo $this->getError() . $this->getHint();
190  echo '</label>';
191  }
192 
197  protected function radioButtonList()
198  {
199  echo $this->getLabel();
200  echo '<span id="' . $this->getAttributeId($this->attribute) . '">';
201  echo $this->form->radioButtonList($this->model, $this->attribute, $this->data, $this->htmlOptions);
202  echo $this->getError() . $this->getHint();
203  echo '</span>';
204  }
205 
210  protected function radioButtonListInline()
211  {
212  $this->htmlOptions['inline'] = true;
213  $this->radioButtonList();
214  }
215 
220  protected function radioButtonGroupsList()
221  {
222  if (isset($this->htmlOptions['for']) && !empty($this->htmlOptions['for'])) {
223  $label_for = $this->htmlOptions['for'];
224  unset($this->htmlOptions['for']);
225  } else if (isset($this->data) && !empty($this->data)) {
226  $label_for = CHtml::getIdByName(
227  get_class($this->model) . '[' . $this->attribute . '][' . key($this->data) . ']'
228  );
229  }
230 
231  if (isset($label_for)) {
232  $this->labelOptions = array('for' => $label_for);
233  }
234 
235  echo $this->getLabel();
236  echo $this->form->radioButtonGroupsList($this->model, $this->attribute, $this->data, $this->htmlOptions);
237  echo $this->getError() . $this->getHint();
238  }
239 
244  protected function textArea()
245  {
246  echo $this->getLabel();
247  echo $this->form->textArea($this->model, $this->attribute, $this->htmlOptions);
248  echo $this->getError() . $this->getHint();
249  }
250 
255  protected function textField()
256  {
257  echo $this->getLabel();
258  echo $this->getPrepend();
259  echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
260  echo $this->getAppend();
261  echo $this->getError() . $this->getHint();
262  }
263 
268  protected function maskedTextField()
269  {
270  echo $this->getLabel();
271  echo $this->getPrepend();
272  echo $this->form->maskedTextField($this->model, $this->attribute, $this->data, $this->htmlOptions);
273  echo $this->getAppend();
274  echo $this->getError() . $this->getHint();
275  }
276 
281  protected function captcha()
282  {
283  echo $this->getLabel() . '<div class="captcha">';
284  echo '<div class="widget">' . $this->widget('CCaptcha', $this->captchaOptions, true) . '</div>';
285  echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
286  echo $this->getError() . $this->getHint();
287  echo '</div>';
288  }
289 
294  protected function uneditableField()
295  {
296  echo $this->getLabel();
297  echo CHtml::tag('span', $this->htmlOptions, $this->model->{$this->attribute});
298  echo $this->getError() . $this->getHint();
299  }
300 
306  protected function datepickerField()
307  {
308  if (isset($this->htmlOptions['options'])) {
309  $options = $this->htmlOptions['options'];
310  unset($this->htmlOptions['options']);
311  }
312 
313  if (isset($this->htmlOptions['events'])) {
314  $events = $this->htmlOptions['events'];
315  unset($this->htmlOptions['events']);
316  }
317 
318  echo $this->getLabel();
319  echo $this->getPrepend();
320  $this->widget(
321  'booster.widgets.TbDatePicker',
322  array(
323  'model' => $this->model,
324  'attribute' => $this->attribute,
325  'options' => isset($options) ? $options : array(),
326  'events' => isset($events) ? $events : array(),
327  'htmlOptions' => $this->htmlOptions,
328  )
329  );
330  echo $this->getAppend();
331  echo $this->getError() . $this->getHint();
332  }
333 
339  protected function datetimepickerField()
340  {
341  if (isset($this->htmlOptions['options'])) {
342  $options = $this->htmlOptions['options'];
343  unset($this->htmlOptions['options']);
344  }
345 
346  if (isset($this->htmlOptions['events'])) {
347  $events = $this->htmlOptions['events'];
348  unset($this->htmlOptions['events']);
349  }
350 
351  echo $this->getLabel();
352  echo $this->getPrepend();
353  $this->widget(
354  'booster.widgets.TbDateTimePicker',
355  array(
356  'model' => $this->model,
357  'attribute' => $this->attribute,
358  'options' => isset($options) ? $options : array(),
359  'events' => isset($events) ? $events : array(),
360  'htmlOptions' => $this->htmlOptions,
361  )
362  );
363  echo $this->getAppend();
364  echo $this->getError() . $this->getHint();
365  }
366 
372  protected function colorpickerField()
373  {
374  $format = 'hex';
375  if (isset($this->htmlOptions['format'])) {
376  $format = $this->htmlOptions['format'];
377  unset($this->htmlOptions['format']);
378  }
379 
380  if (isset($this->htmlOptions['events'])) {
381  $events = $this->htmlOptions['events'];
382  unset($this->htmlOptions['events']);
383  }
384 
385  echo $this->getLabel();
386  echo $this->getPrepend();
387  $this->widget(
388  'booster.widgets.TbColorPicker',
389  array(
390  'model' => $this->model,
391  'attribute' => $this->attribute,
392  'format' => $format,
393  'events' => isset($events) ? $events : array(),
394  'htmlOptions' => $this->htmlOptions,
395  )
396  );
397  echo $this->getAppend();
398  echo $this->getError() . $this->getHint();
399  }
400 
405  protected function redactorJs()
406  {
407  if (isset($this->htmlOptions['options'])) {
408  $options = $this->htmlOptions['options'];
409  unset($this->htmlOptions['options']);
410  }
411  if (isset($this->htmlOptions['width'])) {
412  $width = $this->htmlOptions['width'];
413  unset($this->htmlOptions['width']);
414  }
415  if (isset($this->htmlOptions['height'])) {
416  $height = $this->htmlOptions['height'];
417  unset($this->htmlOptions['height']);
418  }
419  echo $this->getLabel();
420  $this->widget(
421  'booster.widgets.TbRedactorJs',
422  array(
423  'model' => $this->model,
424  'attribute' => $this->attribute,
425  'editorOptions' => isset($options) ? $options : array(),
426  'width' => isset($width) ? $width : '100%',
427  'height' => isset($height) ? $height : '400px',
428  'htmlOptions' => $this->htmlOptions
429  )
430  );
431  echo $this->getError() . $this->getHint();
432  }
433 
438  protected function markdownEditorJs()
439  {
440 
441  if (isset($this->htmlOptions['width'])) {
442  $width = $this->htmlOptions['width'];
443  unset($this->htmlOptions['width']);
444  }
445  if (isset($this->htmlOptions['height'])) {
446  $height = $this->htmlOptions['height'];
447  unset($this->htmlOptions['height']);
448  }
449  echo $this->getLabel();
450  echo '<div class="wmd-panel">';
451  echo '<div id="wmd-button-bar" class="btn-toolbar"></div>';
452  $this->widget(
453  'booster.widgets.TbMarkdownEditorJs',
454  array(
455  'model' => $this->model,
456  'attribute' => $this->attribute,
457  'width' => isset($width) ? $width : '100%',
458  'height' => isset($height) ? $height : '400px',
459  'htmlOptions' => $this->htmlOptions
460  )
461  );
462  echo $this->getError() . $this->getHint();
463  echo '<div id="wmd-preview" class="wmd-panel wmd-preview" style="width:' . (isset($width) ? $width
464  : '100%') . '"></div>';
465  echo '</div>'; // wmd-panel
466  }
467 
472  protected function ckEditor()
473  {
474  if (isset($this->htmlOptions['options'])) {
475  $options = $this->htmlOptions['options'];
476  unset($this->htmlOptions['options']);
477  }
478 
479  echo $this->getLabel();
480  $this->widget(
481  'booster.widgets.TbCKEditor',
482  array(
483  'model' => $this->model,
484  'attribute' => $this->attribute,
485  'editorOptions' => isset($options) ? $options : array(),
486  'htmlOptions' => $this->htmlOptions
487  )
488  );
489  echo $this->getError() . $this->getHint();
490  }
491 
496  protected function html5Editor()
497  {
498  if (isset($this->htmlOptions['options'])) {
499  $options = $this->htmlOptions['options'];
500  unset($this->htmlOptions['options']);
501  }
502  if (isset($this->htmlOptions['width'])) {
503  $width = $this->htmlOptions['width'];
504  unset($this->htmlOptions['width']);
505  }
506  if (isset($this->htmlOptions['height'])) {
507  $height = $this->htmlOptions['height'];
508  unset($this->htmlOptions['height']);
509  }
510  echo $this->getLabel();
511  $this->widget(
512  'booster.widgets.TbHtml5Editor',
513  array(
514  'model' => $this->model,
515  'attribute' => $this->attribute,
516  'editorOptions' => isset($options) ? $options : array(),
517  'width' => isset($width) ? $width : '100%',
518  'height' => isset($height) ? $height : '400px',
519  'htmlOptions' => $this->htmlOptions
520  )
521  );
522  echo $this->getError() . $this->getHint();
523  }
524 
530  protected function dateRangeField()
531  {
532  if (isset($this->htmlOptions['options'])) {
533  $options = $this->htmlOptions['options'];
534  unset($this->htmlOptions['options']);
535  }
536 
537  if (isset($options['callback'])) {
538  $callback = $options['callback'];
539  unset($options['callback']);
540  }
541 
542  echo $this->getLabel();
543  echo $this->getPrepend();
544  $this->widget(
545  'booster.widgets.TbDateRangePicker',
546  array(
547  'model' => $this->model,
548  'attribute' => $this->attribute,
549  'options' => isset($options) ? $options : array(),
550  'callback' => isset($callback) ? $callback : '',
551  'htmlOptions' => $this->htmlOptions,
552  )
553  );
554  echo $this->getAppend();
555  echo $this->getError() . $this->getHint();
556  }
557 
563  protected function timepickerField()
564  {
565  if (isset($this->htmlOptions['options'])) {
566  $options = $this->htmlOptions['options'];
567  unset($this->htmlOptions['options']);
568  }
569 
570  if (isset($this->htmlOptions['events'])) {
571  $events = $this->htmlOptions['events'];
572  unset($this->htmlOptions['events']);
573  }
574 
575  echo $this->getLabel();
576  echo $this->getPrepend();
577  $this->widget(
578  'booster.widgets.TbTimePicker',
579  array(
580  'model' => $this->model,
581  'attribute' => $this->attribute,
582  'options' => isset($options) ? $options : array(),
583  'events' => isset($events) ? $events : array(),
584  'htmlOptions' => $this->htmlOptions,
585  'form' => $this->form
586  )
587  );
588  echo $this->getAppend();
589  echo $this->getError() . $this->getHint();
590  }
591 
596  protected function select2Field()
597  {
598  if (isset($this->htmlOptions['options'])) {
599  $options = $this->htmlOptions['options'];
600  unset($this->htmlOptions['options']);
601  }
602 
603  if (isset($this->htmlOptions['events'])) {
604  $events = $this->htmlOptions['events'];
605  unset($this->htmlOptions['events']);
606  }
607 
608  if (isset($this->htmlOptions['data'])) {
609  $data = $this->htmlOptions['data'];
610  unset($this->htmlOptions['data']);
611  }
612 
613  if (isset($this->htmlOptions['asDropDownList'])) {
614  $asDropDownList = $this->htmlOptions['asDropDownList'];
615  unset($this->htmlOptions['asDropDownList']);
616  }
617 
618  if (isset($this->htmlOptions['val']))
619  {
620  $val = $this->htmlOptions['val'];
621  unset($this->htmlOptions['val']);
622  }
623 
624  echo $this->getLabel();
625  echo $this->getPrepend();
626  $this->widget(
627  'booster.widgets.TbSelect2',
628  array(
629  'model' => $this->model,
630  'attribute' => $this->attribute,
631  'options' => isset($options) ? $options : array(),
632  'events' => isset($events) ? $events : array(),
633  'data' => isset($data) ? $data : array(),
634  'asDropDownList' => isset($asDropDownList) ? $asDropDownList : true,
635  'val' => isset($val) ? $val : null,
636  'htmlOptions' => $this->htmlOptions,
637  'form' => $this->form
638  )
639  );
640  echo $this->getAppend();
641  echo $this->getError() . $this->getHint();
642  }
643 
648  protected function typeAheadField()
649  {
650  echo $this->getLabel();
651  echo $this->getPrepend();
652  echo $this->form->typeAheadField($this->model, $this->attribute, $this->data, $this->htmlOptions);
653  echo $this->getAppend();
654  echo $this->getError() . $this->getHint();
655  }
656 
661  protected function numberField()
662  {
663  echo $this->getLabel();
664  echo $this->getPrepend();
665  echo $this->form->numberField($this->model, $this->attribute, $this->htmlOptions);
666  echo $this->getAppend();
667  echo $this->getError() . $this->getHint();
668  }
669 
674  protected function customField()
675  {
676  echo $this->getLabel();
677  echo $this->getPrepend();
678  echo $this->htmlOptions['input'];
679  echo $this->getAppend();
680  echo $this->getError() . $this->getHint();
681  }
682 }