示例#1
0
 /**
  * Рисуем кнопку
  *
  * @param string $id Id HTML-элемента
  * @param string $value Значение элемента
  * @param array $params Массив параметров, передаваемых в JS-скрипт инициализации UI-компоненты
  * @param array $attribs Массив атрибутов HTML-элемента
  * @return string
  */
 public function datetimePicker($id, $value = null, array $params = array(), array $attribs = array())
 {
     $attribs = $this->_prepareAttributes($id, $value, $attribs);
     $attribs['data-widget'] = 'datetimepicker';
     if (!isset($params['dateFormat']) && Zend_Registry::isRegistered('Zend_Locale')) {
         $params['dateFormat'] = ZendX_JQuery_View_Helper_DatePicker::resolveZendLocaleToDatePickerFormat();
     }
     $params['addSliderAccess'] = true;
     $params['sliderAccessArgs'] = array('touchonly' => false);
     if (count($params) > 0) {
         $params = ZendX_JQuery::encodeJson($params);
     } else {
         $params = "{}";
     }
     $js = sprintf('%s("form").on("mousemove",function(){%s("[data-widget=datetimepicker]").datetimepicker(%s)});', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $params);
     $this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/js/jquery.ui.timepicker.addon.js');
     $this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/js/jquery.ui.sliderAccess.js');
     $this->jquery->addOnLoad($js);
     if ($value != null) {
         $value = Phorm_Format_Date::datetime($value);
     }
     return $this->view->formText($id, $value, $attribs);
 }
示例#2
0
 public static function convertDateFormatToJquery($format = null)
 {
     if (!$format) {
         $format = self::getLocaleDateFormat();
     }
     $newFormat = ZendX_JQuery_View_Helper_DatePicker::resolveZendLocaleToDatePickerFormat($format);
     return $newFormat;
 }
 /**
  * @group ZF-5615
  */
 public function testDatePickerLocalization()
 {
     $dpFormat = ZendX_JQuery_View_Helper_DatePicker::resolveZendLocaleToDatePickerFormat("MMM d, yyyy");
     $this->assertEquals("M d, yy", $dpFormat, "'MMM d, yyyy' has to be converted to 'M d, yy'.");
 }
 /**
  * Checks and updates the on and off strings when one of the effecteds is a date, time or datetime field
  * 
  * @param string $valueOn
  * @param string $valueOff
  */
 protected function checkPicker(&$valueOn, &$valueOff)
 {
     $effecteds = array_keys($this->getEffecteds());
     foreach ($effecteds as $field) {
         if ($this->model instanceof \MUtil_Model_ModelAbstract && $this->model->has($field)) {
             $modelItemType = $this->model->get($field, 'type');
             $dateFormat = $this->model->get($field, 'dateFormat');
             $timeFormat = $this->model->get($field, 'timeFormat');
             switch ($modelItemType) {
                 case \MUtil_Model::TYPE_DATE:
                 case \MUtil_Model::TYPE_TIME:
                 case \MUtil_Model::TYPE_DATETIME:
                     $picker = 'datepicker';
                     break;
                 default:
                     $picker = '';
                     break;
             }
             if (!empty($picker)) {
                 // If none set, get the locale default dateformat
                 if (!$dateFormat && !$timeFormat && \Zend_Registry::isRegistered('Zend_Locale')) {
                     $dateFormat = \ZendX_JQuery_View_Helper_DatePicker::resolveZendLocaleToDatePickerFormat();
                 }
                 if ($dateFormat) {
                     if ($timeFormat) {
                         $picker = 'datetimepicker';
                     }
                 } elseif ($timeFormat) {
                     $picker = 'timepicker';
                 }
                 $valueOn .= "\$('#{$field}').{$picker}('enable');";
                 $valueOff .= "\$('#{$field}').{$picker}('disable');";
             }
         }
     }
 }