当前位置: 首页>>代码示例>>PHP>>正文


PHP FileField::addValidator方法代码示例

本文整理汇总了PHP中FileField::addValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP FileField::addValidator方法的具体用法?PHP FileField::addValidator怎么用?PHP FileField::addValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileField的用法示例。


在下文中一共展示了FileField::addValidator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: defaultImage

 public function defaultImage()
 {
     $this->contentMenu->getElement('socialsharing_default_image')->setActive(true);
     $settings = new Form('default_image');
     $settings->setEnctype("multipart/form-data");
     $file = new FileField('image');
     $validator = new SocialSharingImageValidator(true);
     $file->addValidator($validator);
     $settings->addElement($file);
     $submit = new Submit('upload');
     $submit->setValue(OW::getLanguage()->text('socialsharing', 'upload'));
     $settings->addElement($submit);
     //printVar($config->getValue('socialsharing', 'facebook'));
     if (OW::getRequest()->isPost()) {
         if ($settings->isValid($_POST)) {
             SOCIALSHARING_BOL_Service::getInstance()->uploadImage($_FILES['image']['tmp_name']);
             OW::getFeedback()->info(OW::getLanguage()->text('socialsharing', 'upload_complite'));
             //Setting succsessfully saved
         } else {
             $message = OW::getLanguage()->text('base', 'upload_file_fail');
             switch ($_FILES['image']['error']) {
                 case UPLOAD_ERR_INI_SIZE:
                     $message = $language->text('base', 'upload_file_max_upload_filesize_error');
                     break;
                 case UPLOAD_ERR_PARTIAL:
                     $message = $language->text('base', 'upload_file_file_partially_uploaded_error');
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     $message = $language->text('base', 'upload_file_no_file_error');
                     break;
                 case UPLOAD_ERR_NO_TMP_DIR:
                     $message = $language->text('base', 'upload_file_no_tmp_dir_error');
                     break;
                 case UPLOAD_ERR_CANT_WRITE:
                     $message = $language->text('base', 'upload_file_cant_write_file_error');
                     break;
                 case UPLOAD_ERR_EXTENSION:
                     $message = $language->text('base', 'upload_file_invalid_extention_error');
                     break;
             }
             OW::getFeedback()->error($message);
         }
         $this->redirect();
     }
     $this->addForm($settings);
     $this->assign('imageUrl', SOCIALSHARING_BOL_Service::getInstance()->getDefaultImageUrl());
 }
开发者ID:vazahat,项目名称:dudex,代码行数:47,代码来源:admin.php

示例2: addLastStepQuestions

 private function addLastStepQuestions($controller)
 {
     $displayPhoto = false;
     $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload');
     $photoValidator = new photoValidator(false);
     switch ($displayPhotoUpload) {
         case BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD:
             $photoValidator = new photoValidator(true);
         case BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD:
             $userPhoto = new FileField('userPhoto');
             $userPhoto->setLabel(OW::getLanguage()->text('base', 'questions_question_user_photo_label'));
             $userPhoto->addValidator($photoValidator);
             $this->addElement($userPhoto);
             $displayPhoto = true;
     }
     $displayTermsOfUse = false;
     if (OW::getConfig()->getValue('base', 'join_display_terms_of_use')) {
         $termOfUse = new CheckboxField('termOfUse');
         $termOfUse->setLabel(OW::getLanguage()->text('base', 'questions_question_user_terms_of_use_label'));
         $termOfUse->setRequired();
         $this->addElement($termOfUse);
         $displayTermsOfUse = true;
     }
     $this->setEnctype('multipart/form-data');
     $event = new OW_Event('join.get_captcha_field');
     OW::getEventManager()->trigger($event);
     $captchaField = $event->getData();
     $displayCaptcha = false;
     if (!empty($captchaField) && $captchaField instanceof FormElement) {
         $captchaField->setName('captchaField');
         $this->addElement($captchaField);
         $displayCaptcha = true;
     }
     //$captchaField = new CaptchaField('captchaField');
     //$this->addElement($captchaField);
     $controller->assign('display_captcha', $displayCaptcha);
     $controller->assign('display_photo', $displayPhoto);
     $controller->assign('display_terms_of_use', $displayTermsOfUse);
     if (OW::getRequest()->isPost()) {
         if (!empty($captchaField) && $captchaField instanceof FormElement) {
             $captchaField->setValue(null);
         }
         if (isset($userPhoto) && isset($_FILES[$userPhoto->getName()]['name'])) {
             $_POST[$userPhoto->getName()] = $_FILES[$userPhoto->getName()]['name'];
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:47,代码来源:join.php

示例3: index

 /**
  * Default action
  */
 public function index()
 {
     //$this->contentMenu->getElement('socialsharing_index')->setActive(true);
     $config = OW::getConfig();
     $order = $config->getValue('socialsharing', 'order');
     $defautOrder = SOCIALSHARING_CLASS_Settings::getEntityList();
     if (!empty($order)) {
         $order = json_decode($order, true);
         if (!is_array($order)) {
             $order = $defautOrder;
         }
         $result = array();
         foreach ($order as $key => $item) {
             if (in_array($key, $defautOrder)) {
                 $result[$key] = $key;
             }
         }
         if (!empty($order)) {
             $order = $result;
         } else {
             $order = $defautOrder;
         }
     } else {
         $order = $defautOrder;
     }
     $this->assign('order', $order);
     $settings = new Form('settings');
     //printVar($order);
     foreach ($order as $item) {
         $element = new CheckboxField($item);
         $element->setValue($config->getValue('socialsharing', $item));
         $settings->addElement($element);
     }
     $settings->setEnctype("multipart/form-data");
     $file = new FileField('image');
     $validator = new SocialSharingImageValidator(true);
     $file->addValidator($validator);
     $settings->addElement($file);
     $submit = new Submit('save_settings');
     $settings->addElement($submit);
     //printVar($config->getValue('socialsharing', 'facebook'));
     $apiKeyForm = new Form('api_key_form');
     $key = new TextField('api_key');
     $key->setLabel(OW::getLanguage()->text('socialsharing', 'api_key_label'));
     $key->setRequired();
     $apiKey = OW::getConfig()->getValue('socialsharing', 'api_key');
     $key->setValue($apiKey);
     $apiKeyForm->addElement($key);
     $apiKeySubmit = new Submit('save_api_key');
     $apiKeyForm->addElement($apiKeySubmit);
     $this->addForm($apiKeyForm);
     if (OW::getRequest()->isPost()) {
         if (isset($_POST['save_settings'])) {
             if ($settings->isValid($_POST)) {
                 $data = $settings->getValues();
                 $config->saveConfig('socialsharing', 'facebook', (bool) $data['facebook']);
                 $config->saveConfig('socialsharing', 'twitter', (bool) $data['twitter']);
                 $config->saveConfig('socialsharing', 'googlePlus', (bool) $data['googlePlus']);
                 $config->saveConfig('socialsharing', 'pinterest', (bool) $data['pinterest']);
                 SOCIALSHARING_BOL_Service::getInstance()->uploadImage($_FILES['image']['tmp_name']);
                 OW::getFeedback()->info(OW::getLanguage()->text('socialsharing', 'settings_saved'));
                 //Setting succsessfully saved
                 $this->redirect();
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('socialsharing', 'settings_saved_error'));
                 //
             }
         } else {
             if (isset($_POST['save_api_key'])) {
                 if ($apiKeyForm->isValid($_POST)) {
                     $data = $apiKeyForm->getValues();
                     $config->saveConfig('socialsharing', 'api_key', $data['api_key']);
                     OW::getFeedback()->info(OW::getLanguage()->text('socialsharing', 'api_key_saved'));
                     //Setting succsessfully saved
                     $this->redirect();
                 } else {
                     OW::getFeedback()->error(OW::getLanguage()->text('socialsharing', 'settings_saved_error'));
                 }
             }
         }
     }
     $this->addForm($settings);
     $this->assign('imageUrl', SOCIALSHARING_BOL_Service::getInstance()->getDefaultImageUrl() . '?pid=' . md5(rand(0, 9999999999)));
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . "jquery-ui.min.js");
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('socialsharing')->getStaticJsUrl() . "admin.js");
     OW::getDocument()->addOnloadScript(" window.sharing = new socialSharingAdmin(" . json_encode(array("ajaxResponderUrl" => OW::getRouter()->urlFor('SOCIALSHARING_CTRL_Admin', 'ajaxResponder'))) . ") ");
 }
开发者ID:jorgemunoz8807,项目名称:havanabook,代码行数:90,代码来源:admin.php


注:本文中的FileField::addValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。