當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateField::getMaxYear方法代碼示例

本文整理匯總了PHP中DateField::getMaxYear方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateField::getMaxYear方法的具體用法?PHP DateField::getMaxYear怎麽用?PHP DateField::getMaxYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateField的用法示例。


在下文中一共展示了DateField::getMaxYear方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPresentationClass

 /**
  * Returns all available presentations
  *
  * @return array<string>
  */
 public function getPresentationClass($presentation, $fieldName, $configs = null)
 {
     $event = new OW_Event('base.questions_field_get_label', array('presentation' => $presentation, 'fieldName' => $fieldName, 'configs' => $configs, 'type' => 'edit'));
     OW::getEventManager()->trigger($event);
     $label = $event->getData();
     $class = null;
     $event = new OW_Event('base.questions_field_init', array('type' => 'main', 'presentation' => $presentation, 'fieldName' => $fieldName, 'configs' => $configs));
     OW::getEventManager()->trigger($event);
     $class = $event->getData();
     if (empty($class)) {
         switch ($presentation) {
             case self::QUESTION_PRESENTATION_TEXT:
                 $class = new TextField($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_SELECT:
                 $class = new Selectbox($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_TEXTAREA:
                 $class = new Textarea($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_CHECKBOX:
                 $class = new CheckboxField($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_RADIO:
                 $class = new RadioField($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_MULTICHECKBOX:
                 $class = new CheckboxGroup($fieldName);
                 break;
             case self::QUESTION_PRESENTATION_BIRTHDATE:
             case self::QUESTION_PRESENTATION_AGE:
             case self::QUESTION_PRESENTATION_DATE:
                 $class = new DateField($fieldName);
                 if (!empty($configs) && mb_strlen(trim($configs)) > 0) {
                     $configsList = json_decode($configs, true);
                     foreach ($configsList as $name => $value) {
                         if ($name = 'year_range' && isset($value['from']) && isset($value['to'])) {
                             $class->setMinYear($value['from']);
                             $class->setMaxYear($value['to']);
                         }
                     }
                 }
                 $class->addValidator(new DateValidator($class->getMinYear(), $class->getMaxYear()));
                 break;
             case self::QUESTION_PRESENTATION_RANGE:
                 $class = new Range($fieldName);
                 if (!empty($configs) && mb_strlen(trim($configs)) > 0) {
                     $configsList = json_decode($configs, true);
                     foreach ($configsList as $name => $value) {
                         $minMax = explode("-", $value);
                         if ($name = 'range' && isset($minMax[0]) && isset($minMax[1])) {
                             $class->setMinValue($minMax[0]);
                             $class->setMaxValue($minMax[1]);
                         }
                     }
                 }
                 $class->addValidator(new RangeValidator());
                 break;
             case self::QUESTION_PRESENTATION_URL:
                 $class = new TextField($fieldName);
                 $class->addValidator(new UrlValidator());
                 break;
             case self::QUESTION_PRESENTATION_PASSWORD:
                 $class = new PasswordField($fieldName);
                 break;
         }
     }
     if (!empty($label)) {
         $class->setLabel($label);
     }
     return $class;
 }
開發者ID:hardikamutech,項目名稱:hammu,代碼行數:77,代碼來源:question_service(19-5-2015).php


注:本文中的DateField::getMaxYear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。