Ejemplo n.º 1
0
 /**
  * This function overrides the run method from CJuiDatePicker and fixes the jQuery issue for the Datepicker showing
  * wrong language in the portlet views popup.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if (!isset($this->options['currentText'])) {
         $this->options['currentText'] = ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Now'));
     }
     if (!isset($this->options['closeText'])) {
         $this->options['closeText'] = ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Done'));
     }
     if ($this->flat === false) {
         if ($this->hasModel()) {
             echo ZurmoHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo ZurmoHtml::textField($name, $this->value, $this->htmlOptions);
         }
     } else {
         if ($this->hasModel()) {
             echo ZurmoHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
             $attribute = $this->attribute;
             $this->options['defaultDate'] = $this->model->{$attribute};
         } else {
             echo ZurmoHtml::hiddenField($name, $this->value, $this->htmlOptions);
             $this->options['defaultDate'] = $this->value;
         }
         if (!isset($this->options['onSelect'])) {
             $this->options['onSelect'] = "js:function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}";
             // Not Coding Standard
         }
         $id = $this->htmlOptions['id'] = $this->htmlOptions['id'] . '_container';
         $this->htmlOptions['name'] = $this->htmlOptions['name'] . '_container';
         echo ZurmoHtml::tag('div', $this->htmlOptions, '');
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if ($this->language != '' && $this->language != 'en') {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery(function(){jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));})";
     }
     $cs = Yii::app()->getClientScript();
     if (isset($this->defaultOptions)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $cs->registerScript(__CLASS__, $this->defaultOptions !== null ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     }
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
 protected function renderMashableInboxFormLayout($form)
 {
     assert('$form instanceof ZurmoActiveForm');
     $content = null;
     $model = $this->mashableInboxForm;
     $content = $this->renderSearchView($model, $form);
     $element = new MashableInboxOptionsByModelRadioElement($model, 'optionForModel', $form, array(), $this->getArrayForByModelRadioElement());
     $element->editableTemplate = '<div id="MashableInboxForm_optionForModel_area">{content}</div>';
     $content .= '<div class="filters-bar">';
     $content .= $element->render();
     $element = new MashableInboxStatusRadioElement($model, 'filteredBy', $form);
     $element->editableTemplate = '<div id="MashableInboxForm_filteredBy_area">{content}</div>';
     $content .= $element->render();
     $content .= '</div>';
     $content .= ZurmoHtml::activeHiddenField($model, 'selectedIds');
     $content .= ZurmoHtml::activeHiddenField($model, 'massAction');
     return $content;
 }