HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbInputHorizontal.php
Go to the documentation of this file.
1 <?php
10 Yii::import('booster.widgets.input.TbInput');
11 
21 {
25  public function run()
26  {
27  echo CHtml::openTag('div', array('class' => 'control-group ' . $this->getContainerCssClass()));
28  parent::run();
29  echo CHtml::closeTag('div');
30  }
31 
36  protected function getLabel()
37  {
38  if (isset($this->labelOptions['class'])) {
39  $this->labelOptions['class'] .= ' control-label';
40  } else {
41  $this->labelOptions['class'] = 'control-label';
42  }
43 
44  if (isset($this->htmlOptions['id'])) {
45  $this->labelOptions['for'] = $this->htmlOptions['id'];
46  }
47 
48  return parent::getLabel();
49  }
50 
55  protected function checkBox()
56  {
57  $attribute = $this->attribute;
58  list($hidden, $checkbox) = $this->getSeparatedSelectableInput();
59 
60  echo '<div class="controls">';
61  echo ($hidden) ? $hidden . PHP_EOL : '';
62  echo '<label class="checkbox" for="' . $this->getAttributeId($attribute) . '">';
63  echo $checkbox . PHP_EOL;
64  echo $this->model->getAttributeLabel($attribute);
65  echo $this->getError() . $this->getHint();
66  echo '</label></div>';
67  }
68 
73  protected function toggleButton()
74  {
75  // widget configuration is set on htmlOptions['options']
76  $options = array(
77  'model' => $this->model,
78  'attribute' => $this->attribute
79  );
80  if (isset($this->htmlOptions['options'])) {
81  $options = CMap::mergeArray($options, $this->htmlOptions['options']);
82  unset($this->htmlOptions['options']);
83  }
84  $options['htmlOptions'] = $this->htmlOptions;
85 
86  echo $this->getLabel();
87  echo '<div class="controls">';
88  $this->widget('booster.widgets.TbToggleButton', $options);
89  echo $this->getError() . $this->getHint();
90  echo '</div>';
91  }
92 
97  protected function checkBoxList()
98  {
99  echo $this->getLabel();
100  echo '<div class="controls">';
101  echo $this->form->checkBoxList($this->model, $this->attribute, $this->data, $this->htmlOptions);
102  echo $this->getError() . $this->getHint();
103  echo '</div>';
104  }
105 
110  protected function checkBoxListInline()
111  {
112  $this->htmlOptions['inline'] = true;
113  $this->checkBoxList();
114  }
115 
120  protected function checkBoxGroupsList()
121  {
122  if (isset($this->htmlOptions['for']) && !empty($this->htmlOptions['for'])) {
123  $label_for = $this->htmlOptions['for'];
124  unset($this->htmlOptions['for']);
125  } else if (isset($this->data) && !empty($this->data)) {
126  $label_for = CHtml::getIdByName(
127  get_class($this->model) . '[' . $this->attribute . '][' . key($this->data) . ']'
128  );
129  }
130 
131  if (isset($label_for)) {
132  $this->labelOptions = array('for' => $label_for);
133  }
134 
135  $this->htmlOptions['class'] = 'pull-left';
136 
137  echo $this->getLabel();
138  echo '<div class="controls">';
139  echo $this->form->checkBoxGroupsList($this->model, $this->attribute, $this->data, $this->htmlOptions);
140  echo $this->getError() . $this->getHint();
141  echo '</div>';
142  }
143 
148  protected function dropDownList()
149  {
150  echo $this->getLabel();
151  echo '<div class="controls">';
152  echo $this->form->dropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
153  echo $this->getError() . $this->getHint();
154  echo '</div>';
155  }
156 
161  protected function fileField()
162  {
163  echo $this->getLabel();
164  echo '<div class="controls">';
165  echo $this->form->fileField($this->model, $this->attribute, $this->htmlOptions);
166  echo $this->getError() . $this->getHint();
167  echo '</div>';
168  }
169 
174  protected function passwordField()
175  {
176  echo $this->getLabel();
177  echo '<div class="controls">';
178  echo $this->getPrepend();
179  echo $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions);
180  echo $this->getAppend();
181  echo $this->getError() . $this->getHint();
182  echo '</div>';
183  }
184 
190  protected function passfieldField()
191  {
192  if (isset($this->htmlOptions['options'])) {
193  $options = $this->htmlOptions['options'];
194  unset($this->htmlOptions['options']);
195  }
196 
197  if (isset($this->htmlOptions['events'])) {
198  $events = $this->htmlOptions['events'];
199  unset($this->htmlOptions['events']);
200  }
201 
202  echo $this->getLabel();
203  echo '<div class="controls">';
204  echo $this->getPrepend();
205  $this->widget(
206  'booster.widgets.TbPassfield',
207  array(
208  'model' => $this->model,
209  'attribute' => $this->attribute,
210  'options' => isset($options) ? $options : array(),
211  'events' => isset($events) ? $events : array(),
212  'htmlOptions' => $this->htmlOptions,
213  )
214  );
215  echo $this->getAppend();
216  echo $this->getError() . $this->getHint();
217  echo '</div>';
218  }
219 
224  protected function radioButton()
225  {
226  $attribute = $this->attribute;
227  list($hidden, $radioButton) = $this->getSeparatedSelectableInput();
228 
229  echo '<div class="controls">';
230  echo ($hidden) ? $hidden . PHP_EOL : '';
231  echo '<label class="radio" for="' . $this->getAttributeId($attribute) . '">';
232  echo $radioButton . PHP_EOL;
233  //echo $this->form->radioButton($this->model, $attribute, $this->htmlOptions) . PHP_EOL;
234  echo $this->model->getAttributeLabel($attribute);
235  echo $this->getError() . $this->getHint();
236  echo '</label></div>';
237  }
238 
243  protected function radioButtonList()
244  {
245  echo $this->getLabel();
246  echo '<div class="controls"><span id="' . $this->getAttributeId($this->attribute) . '">';
247  echo $this->form->radioButtonList($this->model, $this->attribute, $this->data, $this->htmlOptions);
248  echo $this->getError() . $this->getHint();
249  echo '</span></div>';
250  }
251 
256  protected function radioButtonListInline()
257  {
258  $this->htmlOptions['inline'] = true;
259  $this->radioButtonList();
260  }
261 
266  protected function radioButtonGroupsList()
267  {
268  if (isset($this->htmlOptions['for']) && !empty($this->htmlOptions['for'])) {
269  $label_for = $this->htmlOptions['for'];
270  unset($this->htmlOptions['for']);
271  } else if (isset($this->data) && !empty($this->data)) {
272  $label_for = CHtml::getIdByName(
273  get_class($this->model) . '[' . $this->attribute . '][' . key($this->data) . ']'
274  );
275  }
276 
277  if (isset($label_for)) {
278  $this->labelOptions = array('for' => $label_for);
279  }
280 
281  $this->htmlOptions['class'] = 'pull-left';
282 
283  echo $this->getLabel();
284  echo '<div class="controls">';
285  echo $this->form->radioButtonGroupsList($this->model, $this->attribute, $this->data, $this->htmlOptions);
286  echo $this->getError() . $this->getHint();
287  echo '</div>';
288  }
289 
294  protected function textArea()
295  {
296  echo $this->getLabel();
297  echo '<div class="controls">';
298  echo $this->form->textArea($this->model, $this->attribute, $this->htmlOptions);
299  echo $this->getError() . $this->getHint();
300  echo '</div>';
301  }
302 
307  protected function textField()
308  {
309  echo $this->getLabel();
310  echo '<div class="controls">';
311  echo $this->getPrepend();
312  echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
313  echo $this->getAppend();
314  echo $this->getError() . $this->getHint();
315  echo '</div>';
316  }
317 
322  protected function maskedTextField()
323  {
324  echo $this->getLabel();
325  echo '<div class="controls">';
326  echo $this->getPrepend();
327  echo $this->form->maskedTextField($this->model, $this->attribute, $this->data, $this->htmlOptions);
328  echo $this->getAppend();
329  echo $this->getError() . $this->getHint();
330  echo '</div>';
331  }
332 
337  protected function captcha()
338  {
339  echo $this->getLabel();
340  echo '<div class="controls"><div class="captcha">';
341  echo '<div class="widget">' . $this->widget('CCaptcha', $this->captchaOptions, true) . '</div>';
342  echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
343  echo $this->getError() . $this->getHint();
344  echo '</div></div>';
345  }
346 
351  protected function uneditableField()
352  {
353  echo $this->getLabel();
354  echo '<div class="controls">';
355  echo CHtml::tag('span', $this->htmlOptions, $this->model->{$this->attribute});
356  echo $this->getError() . $this->getHint();
357  echo '</div>';
358  }
359 
365  protected function datepickerField()
366  {
367  if (isset($this->htmlOptions['options'])) {
368  $options = $this->htmlOptions['options'];
369  unset($this->htmlOptions['options']);
370  }
371 
372  if (isset($this->htmlOptions['events'])) {
373  $events = $this->htmlOptions['events'];
374  unset($this->htmlOptions['events']);
375  }
376 
377  echo $this->getLabel();
378  echo '<div class="controls">';
379  echo $this->getPrepend();
380  $this->widget(
381  'booster.widgets.TbDatePicker',
382  array(
383  'model' => $this->model,
384  'attribute' => $this->attribute,
385  'options' => isset($options) ? $options : array(),
386  'events' => isset($events) ? $events : array(),
387  'htmlOptions' => $this->htmlOptions,
388  )
389  );
390  echo $this->getAppend();
391  echo $this->getError() . $this->getHint();
392  echo '</div>';
393  }
394 
400  protected function datetimepickerField()
401  {
402  if (isset($this->htmlOptions['options'])) {
403  $options = $this->htmlOptions['options'];
404  unset($this->htmlOptions['options']);
405  }
406 
407  if (isset($this->htmlOptions['events'])) {
408  $events = $this->htmlOptions['events'];
409  unset($this->htmlOptions['events']);
410  }
411 
412  echo $this->getLabel();
413  echo '<div class="controls">';
414  echo $this->getPrepend();
415  $this->widget(
416  'booster.widgets.TbDateTimePicker',
417  array(
418  'model' => $this->model,
419  'attribute' => $this->attribute,
420  'options' => isset($options) ? $options : array(),
421  'events' => isset($events) ? $events : array(),
422  'htmlOptions' => $this->htmlOptions,
423  )
424  );
425  echo $this->getAppend();
426  echo $this->getError() . $this->getHint();
427  echo '</div>';
428  }
429 
435  protected function colorpickerField()
436  {
437  $format = 'hex';
438  if (isset($this->htmlOptions['format'])) {
439  $format = $this->htmlOptions['format'];
440  unset($this->htmlOptions['format']);
441  }
442 
443  if (isset($this->htmlOptions['events'])) {
444  $events = $this->htmlOptions['events'];
445  unset($this->htmlOptions['events']);
446  }
447 
448  echo $this->getLabel();
449  echo '<div class="controls">';
450  echo $this->getPrepend();
451  $this->widget(
452  'booster.widgets.TbColorPicker',
453  array(
454  'model' => $this->model,
455  'attribute' => $this->attribute,
456  'format' => $format,
457  'events' => isset($events) ? $events : array(),
458  'htmlOptions' => $this->htmlOptions,
459  )
460  );
461  echo $this->getAppend();
462  echo $this->getError() . $this->getHint();
463  echo '</div>';
464  }
465 
470  protected function redactorJs()
471  {
472  if (isset($this->htmlOptions['options'])) {
473  $options = $this->htmlOptions['options'];
474  unset($this->htmlOptions['options']);
475  }
476  if (isset($this->htmlOptions['width'])) {
477  $width = $this->htmlOptions['width'];
478  unset($this->htmlOptions['width']);
479  }
480  if (isset($this->htmlOptions['height'])) {
481  $height = $this->htmlOptions['height'];
482  unset($this->htmlOptions['height']);
483  }
484  echo $this->getLabel();
485  echo '<div class="controls">';
486  $this->widget(
487  'booster.widgets.TbRedactorJs',
488  array(
489  'model' => $this->model,
490  'attribute' => $this->attribute,
491  'editorOptions' => isset($options) ? $options : array(),
492  'width' => isset($width) ? $width : '100%',
493  'height' => isset($height) ? $height : '400px',
494  'htmlOptions' => $this->htmlOptions
495  )
496  );
497  echo $this->getError() . $this->getHint();
498  echo '</div>';
499  }
500 
505  protected function markdownEditorJs()
506  {
507 
508  if (isset($this->htmlOptions['width'])) {
509  $width = $this->htmlOptions['width'];
510  unset($this->htmlOptions['width']);
511  }
512  if (isset($this->htmlOptions['height'])) {
513  $height = $this->htmlOptions['height'];
514  unset($this->htmlOptions['height']);
515  }
516  echo $this->getLabel();
517  echo '<div class="controls">';
518  echo '<div class="wmd-panel">';
519  echo '<div id="wmd-button-bar" class="btn-toolbar"></div>';
520  $this->widget(
521  'booster.widgets.TbMarkdownEditorJs',
522  array(
523  'model' => $this->model,
524  'attribute' => $this->attribute,
525  'width' => isset($width) ? $width : '100%',
526  'height' => isset($height) ? $height : '400px',
527  'htmlOptions' => $this->htmlOptions
528  )
529  );
530  echo $this->getError() . $this->getHint();
531  echo '<div id="wmd-preview" class="wmd-panel wmd-preview" style="width:' . (isset($width) ? $width
532  : '100%') . '"></div>';
533  echo '</div>'; // wmd-panel
534  echo '</div>'; // controls
535  }
536 
541  protected function html5Editor()
542  {
543  if (isset($this->htmlOptions['options'])) {
544  $options = $this->htmlOptions['options'];
545  unset($this->htmlOptions['options']);
546  }
547  if (isset($this->htmlOptions['width'])) {
548  $width = $this->htmlOptions['width'];
549  unset($this->htmlOptions['width']);
550  }
551  if (isset($this->htmlOptions['height'])) {
552  $height = $this->htmlOptions['height'];
553  unset($this->htmlOptions['height']);
554  }
555  echo $this->getLabel();
556  echo '<div class="controls">';
557  $this->widget(
558  'booster.widgets.TbHtml5Editor',
559  array(
560  'model' => $this->model,
561  'attribute' => $this->attribute,
562  'editorOptions' => isset($options) ? $options : array(),
563  'width' => isset($width) ? $width : '100%',
564  'height' => isset($height) ? $height : '400px',
565  'htmlOptions' => $this->htmlOptions
566  )
567  );
568  echo $this->getError() . $this->getHint();
569  echo '</div>';
570  }
571 
577  protected function ckEditor()
578  {
579  if (isset($this->htmlOptions['options'])) {
580  $options = $this->htmlOptions['options'];
581  unset($this->htmlOptions['options']);
582  }
583 
584  echo $this->getLabel();
585  echo '<div class="controls">';
586  $this->widget(
587  'booster.widgets.TbCKEditor',
588  array(
589  'model' => $this->model,
590  'attribute' => $this->attribute,
591  'editorOptions' => isset($options) ? $options : array(),
592  'htmlOptions' => $this->htmlOptions
593  )
594  );
595  echo $this->getError() . $this->getHint();
596  echo '</div>';
597  }
598 
604  protected function dateRangeField()
605  {
606  if (isset($this->htmlOptions['options'])) {
607  $options = $this->htmlOptions['options'];
608  unset($this->htmlOptions['options']);
609  }
610 
611  if (isset($options['callback'])) {
612  $callback = $options['callback'];
613  unset($options['callback']);
614  }
615 
616  echo $this->getLabel();
617  echo '<div class="controls">';
618  echo $this->getPrepend();
619  $this->widget(
620  'booster.widgets.TbDateRangePicker',
621  array(
622  'model' => $this->model,
623  'attribute' => $this->attribute,
624  'options' => isset($options) ? $options : array(),
625  'callback' => isset($callback) ? $callback : '',
626  'htmlOptions' => $this->htmlOptions,
627  )
628  );
629  echo $this->getAppend();
630  echo $this->getError() . $this->getHint();
631  echo '</div>';
632  }
633 
639  protected function timepickerField()
640  {
641  if (isset($this->htmlOptions['options'])) {
642  $options = $this->htmlOptions['options'];
643  unset($this->htmlOptions['options']);
644  }
645 
646  if (isset($this->htmlOptions['events'])) {
647  $events = $this->htmlOptions['events'];
648  unset($this->htmlOptions['events']);
649  }
650 
651  echo $this->getLabel();
652  echo '<div class="controls">';
653  echo $this->getPrepend();
654  $this->widget(
655  'booster.widgets.TbTimePicker',
656  array(
657  'model' => $this->model,
658  'attribute' => $this->attribute,
659  'options' => isset($options) ? $options : array(),
660  'events' => isset($events) ? $events : array(),
661  'htmlOptions' => $this->htmlOptions,
662  'form' => $this->form
663  )
664  );
665  echo $this->getAppend();
666  echo $this->getError() . $this->getHint();
667  echo '</div>';
668  }
669 
674  protected function select2Field()
675  {
676  if (isset($this->htmlOptions['options'])) {
677  $options = $this->htmlOptions['options'];
678  unset($this->htmlOptions['options']);
679  }
680 
681  if (isset($this->htmlOptions['events'])) {
682  $events = $this->htmlOptions['events'];
683  unset($this->htmlOptions['events']);
684  }
685 
686  if (isset($this->htmlOptions['data'])) {
687  $data = $this->htmlOptions['data'];
688  unset($this->htmlOptions['data']);
689  }
690 
691  if (isset($this->htmlOptions['asDropDownList'])) {
692  $asDropDownList = $this->htmlOptions['asDropDownList'];
693  unset($this->htmlOptions['asDropDownList']);
694  }
695 
696  echo $this->getLabel();
697  echo '<div class="controls">';
698  echo $this->getPrepend();
699  $this->widget(
700  'booster.widgets.TbSelect2',
701  array(
702  'model' => $this->model,
703  'attribute' => $this->attribute,
704  'options' => isset($options) ? $options : array(),
705  'events' => isset($events) ? $events : array(),
706  'data' => isset($data) ? $data : array(),
707  'asDropDownList' => isset($asDropDownList) ? $asDropDownList : true,
708  'htmlOptions' => $this->htmlOptions,
709  'form' => $this->form
710  )
711  );
712  echo $this->getAppend();
713  echo $this->getError() . $this->getHint();
714  echo '</div>';
715  }
716 
721  protected function typeAheadField()
722  {
723  echo $this->getLabel();
724  echo '<div class="controls">';
725  echo $this->getPrepend();
726  echo $this->form->typeAheadField($this->model, $this->attribute, $this->data, $this->htmlOptions);
727  echo $this->getAppend();
728  echo $this->getError() . $this->getHint();
729  echo '</div>';
730  }
731 
736  protected function numberField()
737  {
738  echo $this->getLabel();
739  echo '<div class="controls">';
740  echo $this->getPrepend();
741  echo $this->form->numberField($this->model, $this->attribute, $this->htmlOptions);
742  echo $this->getAppend();
743  echo $this->getError() . $this->getHint();
744  echo '</div>';
745  }
746 
751  protected function customField()
752  {
753  echo $this->getLabel();
754  echo '<div class="controls">';
755  echo $this->getPrepend();
756  echo $this->htmlOptions['input'];
757  echo $this->getAppend();
758  echo $this->getError() . $this->getHint();
759  echo '</div>';
760  }
761 
762 }