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


PHP CFormModel::afterValidate方法代码示例

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


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

示例1: afterValidate

 public function afterValidate()
 {
     if (!$this->hasErrors()) {
         $path = Yii::getPathOfAlias('webroot') . '/../uploads/in/images/' . $this->image;
         $pathStore = Yii::getPathOfAlias('webroot') . '/uploads/store/product/' . $this->image;
         if (file_exists($path)) {
             // Файл доступен по пути
             $data = @file_get_contents($path);
             $res = @imagecreatefromstring($data);
             if (is_resource($res)) {
                 // Файл коректно открывается
                 if (copy($path, $pathStore)) {
                     // Файл скопировался
                     $this->image = basename($path);
                     @unlink($path);
                     // удалить файл
                 } else {
                     $this->image = null;
                 }
             }
         } else {
             $this->image = null;
         }
     }
     return parent::afterValidate();
 }
开发者ID:QSODevelopers,项目名称:yupe-storeswap,代码行数:26,代码来源:DProduct.php

示例2: afterValidate

 /**
  * Displays errors whether its present.
  * 
  * @see CModel::afterValidate()
  */
 protected function afterValidate()
 {
     if ($this->hasErrors()) {
         $errors = $this->getErrors();
         $this->displayErrors($errors);
     }
     parent::afterValidate();
 }
开发者ID:hansenmakangiras,项目名称:disperindag,代码行数:13,代码来源:FilterModel.php

示例3: afterValidate

 public function afterValidate()
 {
     $return = parent::afterValidate();
     if (!$this->usuario->isValidToken()) {
         $this->addError('novaSenha', Yii::t('AlterarSenhaForm', 'Esta chave de acesso não é mais válida'));
     }
     return $return;
 }
开发者ID:BrunoCheble,项目名称:novopedido,代码行数:8,代码来源:AlterarSenhaForm.php

示例4: afterValidate

 protected function afterValidate()
 {
     $dbConnection = $this->getDbConnection();
     try {
         $dbConnection->active = true;
     } catch (CDbException $e) {
         $this->addError('dbname', 'Не удалось подключиться к базе данных. Ошибка: "' . $e->getMessage() . '"');
     }
     return parent::afterValidate();
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:10,代码来源:DbSettings.php

示例5: afterValidate

 function afterValidate()
 {
     // If this method was called then
     // the model is already filled
     // with data and data is valid
     // so we can use it safely:
     $this->fullName = $this->firstName . ' ' . $this->lastName;
     // It's important to call parent class method
     // so all other event handlers are called
     return parent::afterValidate();
 }
开发者ID:vrigzalejo,项目名称:YiiOne,代码行数:11,代码来源:UserForm.php

示例6: afterValidate

 protected function afterValidate()
 {
     switch ($this->src_type) {
         case 1:
             $this->text = str_replace("\r", "", $this->text);
             break;
         case 2:
             // Читаем файл
             $file = CUploadedFile::getInstanceByName("TextSource[file]");
             $this->text = file_get_contents($file->tempName, false, null, -1, 500 * 1024);
             if ($this->text === false) {
                 $this->addError("file", "Файл не загрузился. Возможно, он слишком велик.");
                 return false;
             }
             // Кодировка
             if ($this->encoding != "UTF-8") {
                 $this->text = iconv($this->encoding, "UTF-8//IGNORE", $this->text);
             } elseif (!mb_check_encoding($this->text, "utf-8")) {
                 $this->addError("encoding", "Неправильная кодировка текста, выберите правильную.");
             }
             break;
         case 3:
             exit;
             if (!preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $this->url)) {
                 $this->addError("url", "Некорректный URL. Должно быть что-то вроде http://someawesomesite.ru/foo/bar/baz.html");
                 return false;
             }
             echo "<pre>";
             echo "Download text from '{$this->url}'\n";
             $html = Yii::app()->curl->run($this->url);
             file_put_contents("import.html", $html);
             print_r(Yii::app()->curl->info);
             echo "<hr />";
             // Пытаемся узнать кодировку, если её не указали явно
             if (preg_match('#<meta.*http-equiv=[\'"]?content-type[\'"]?.*>#is', $html, $res)) {
                 echo "Got meta http-equiv: " . htmlspecialchars($res[0]) . "\n";
             } elseif (preg_match('#<meta.*charset=\'content-type\'.*>#is', $html, $res)) {
                 echo "Got meta charset: " . htmlspecialchars($res[0]) . "\n";
             } elseif (Yii::app()->curl->info["content_type"] != "" && preg_match('#charset=([^; ]+)#i', Yii::app()->curl->info["content_type"], $res)) {
                 echo "Found content-type header with charset: {$res[0]}\n";
                 $charset = $res[1];
             } else {
                 echo "Can't find encoding information (assume ISO)\n";
                 $charset = "ISO−8859−1";
             }
             $charset = strtoupper($charset);
             $this->encoding = $charset;
             if ($charset != "UTF-8" && $charset != "UTF8") {
                 $html = iconv($charset, "UTF-8", $html);
             } elseif (!mb_check_encoding($html, "utf-8")) {
                 $this->addError("encoding", "Неправильная кодировка текста, выберите правильную.");
             }
             $html = preg_replace('#<head>.+</head>#isU', '', $html);
             $html = preg_replace('#<script[^>]*>.+</script[^>]*>#isU', '', $html);
             //				$html = preg_replace('#<style[^>]*>.+</style[^>]*>#isU', '', $html);
             echo "<b>HTML</b> = '" . htmlspecialchars($html) . "'";
             $p = new CHtmlPurifier();
             // идея в том, чтобы оставить только блочные теги, а потом по ним разбить на фрагменты
             $html = preg_replace('/\\s+/s', " ", $html);
             // привели всё к одной строке
             $html = preg_replace('#</[^>]*>#s', " ", $html);
             // убрали все закрывающие теги
             $html = preg_replace('/<(p|div|li|dd|dt|h\\d|address|blockquote)[^>]*>/s', "\n\n", $html);
             // все открывающие блочные теги - в два переноса строки
             $html = preg_replace('/<br[^>]*>/s', "\n", $html);
             // br - в одинарный перенос строки
             $html = strip_tags($html);
             $html = preg_replace('/[ \\t]+/', " ", $html);
             echo "</pre>";
             $this->text = $html;
             $this->chopper = 2;
             break;
         default:
             $this->addError("src_typ", "Системная ошибка. Обратитесь в техподдержку.");
             return false;
             break;
     }
     $this->text = trim($this->text);
     if ($this->text == "") {
         $this->addError("src_typ", "Текст не обнаружен. Иногда это случается, если выбрать неправильную кодировку.");
         return false;
     }
     if (mb_strlen($this->text) > 500 * 1024) {
         $this->addError("src_typ", "Слишком большой текст. Пожалуйста, разбейте его на несколько глав, не более 500 КБ каждая.");
         return false;
     }
     return parent::afterValidate();
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:88,代码来源:TextSource.php

示例7: afterValidate

 protected function afterValidate()
 {
     $this->ls_id = $this->gs_list[$this->gs_id]['login_id'];
     parent::afterValidate();
 }
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:5,代码来源:LoginForm.php

示例8: afterValidate

 public function afterValidate()
 {
     $this->putToMemory();
     parent::afterValidate();
 }
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:5,代码来源:ConnectionsLogForm.php

示例9: afterValidate

 protected function afterValidate()
 {
     parent::afterValidate();
     $this->password = '';
     $this->password_repeat = '';
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:6,代码来源:RegisterForm.php

示例10: afterValidate

 /**
  * After the standard validation is completed, check the database connections.
  * @see CModel::afterValidate()
  */
 public function afterValidate()
 {
     parent::afterValidate();
     if (count($this->getErrors()) == 0) {
         //check memcache first, since creating the db / user should be last.
         if ($this->memcacheHostname != null) {
             if ($this->memcachePortNumber == null) {
                 $this->addError('memcachePortNumber', Zurmo::t('InstallModule', 'Since you specified a memcache ' . 'hostname, you must specify a port.'));
                 return;
             }
             $memcacheResult = InstallUtil::checkMemcacheConnection($this->memcacheHostname, (int) $this->memcachePortNumber);
             if ($memcacheResult !== true) {
                 $this->addError('memcacheHostname', Zurmo::t('InstallModule', 'Error code:') . " " . $memcacheResult[0] . '<br/>Message(Memcached): ' . $memcacheResult[1]);
                 return;
             }
         }
         if (!$this->hostInfo) {
             $this->addError('hostInfo', Zurmo::t('InstallModule', 'Please enter server IP or URL.'));
             return;
         } else {
             if (strpos($this->hostInfo, 'http://') === false && strpos($this->hostInfo, 'https://') === false) {
                 $this->addError('hostInfo', Zurmo::t('InstallModule', 'Host Info must start with "http://" or "https://".'));
                 return;
             }
         }
         if ($this->databaseAdminUsername != null) {
             if ($this->databaseAdminPassword == null) {
                 $this->addError('databaseAdminPassword', Zurmo::t('InstallModule', 'Since you specified a database ' . 'admin username, you must enter a password'));
                 return;
             }
             $connectionResult = DatabaseCompatibilityUtil::checkDatabaseConnection($this->databaseType, $this->databaseHostname, $this->databaseAdminUsername, $this->databaseAdminPassword, (int) $this->databasePort);
             if ($connectionResult !== true) {
                 $this->addError('databaseAdminUsername', Zurmo::t('InstallModule', 'Error code:') . " " . $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
                 return;
             }
             $userExistsResult = DatabaseCompatibilityUtil::checkDatabaseUserExists($this->databaseType, $this->databaseHostname, $this->databaseAdminUsername, $this->databaseAdminPassword, (int) $this->databasePort, $this->databaseUsername);
             if ($userExistsResult === true) {
                 $this->addError('databaseUsername', Zurmo::t('InstallModule', 'You have specified an existing user. ' . 'If you would like to use this user, then do not specify the database admin username and ' . 'password. Otherwise pick a database username that does not exist.'));
                 return;
             }
             $databaseExistsResult = DatabaseCompatibilityUtil::checkDatabaseExists($this->databaseType, $this->databaseHostname, $this->databaseAdminUsername, $this->databaseAdminPassword, (int) $this->databasePort, $this->databaseName);
             if ($databaseExistsResult === true) {
                 $this->addError('databaseName', Zurmo::t('InstallModule', 'You have specified an existing database. ' . 'If you would like to use this database, then do not specify the database admin username and ' . 'password. Otherwise pick a database name that does not exist.'));
                 return;
             }
             $createDatabaseResult = DatabaseCompatibilityUtil::createDatabase($this->databaseType, $this->databaseHostname, $this->databaseAdminUsername, $this->databaseAdminPassword, (int) $this->databasePort, $this->databaseName);
             if ($createDatabaseResult === false) {
                 $this->addError('databaseName', Zurmo::t('InstallModule', 'There was a problem creating the database ' . 'Error code:') . " " . $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
                 return;
             }
             $createUserResult = DatabaseCompatibilityUtil::createDatabaseUser($this->databaseType, $this->databaseHostname, $this->databaseAdminUsername, $this->databaseAdminPassword, (int) $this->databasePort, $this->databaseName, $this->databaseUsername, $this->databasePassword);
             if ($createUserResult === false) {
                 $this->addError('databaseUsername', Zurmo::t('InstallModule', 'There was a problem creating the user ' . 'Error code:') . " " . $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
                 return;
             }
         } else {
             $connectionResult = DatabaseCompatibilityUtil::checkDatabaseConnection($this->databaseType, $this->databaseHostname, $this->databaseUsername, $this->databasePassword, (int) $this->databasePort);
             if ($connectionResult !== true) {
                 $this->addError('databaseUsername', Zurmo::t('InstallModule', 'Error code:') . " " . $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
                 return;
             }
             $databaseExistsResult = DatabaseCompatibilityUtil::checkDatabaseExists($this->databaseType, $this->databaseHostname, $this->databaseUsername, $this->databasePassword, (int) $this->databasePort, $this->databaseName);
             if ($databaseExistsResult !== true) {
                 $this->addError('databaseName', Zurmo::t('InstallModule', 'The database name specified does not ' . 'exist or the user specified does not have access.') . '<br/>' . Zurmo::t('InstallModule', 'Error code:') . " " . $databaseExistsResult[0] . '<br/>Message: ' . $databaseExistsResult[1]);
                 return;
             } else {
                 if ($this->removeExistingData == false) {
                     $this->addError('removeExistingData', Zurmo::t('InstallModule', 'Since you specified an existing database ' . 'you must check this box in order to proceed. THIS WILL REMOVE ALL EXISTING DATA.'));
                     return;
                 }
             }
         }
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:78,代码来源:InstallSettingsForm.php

示例11: afterValidate

 protected function afterValidate()
 {
     if (($err = $this->testConnect()) !== true) {
         $this->addError('', 'Ошибка подключения к БД: ' . $err);
     }
     return parent::afterValidate();
 }
开发者ID:urichalex,项目名称:CS-Bans,代码行数:7,代码来源:InstallForm.php

示例12: afterValidate

 protected function afterValidate()
 {
     if (($err = $this->testConnect()) !== TRUE) {
         $this->addError('', 'Ошибка подключения к БД: ' . $err);
     }
     if (!$this->license) {
         $this->addError('license', 'Вы не приняли условия лицензионного соглашения');
     }
     return parent::afterValidate();
 }
开发者ID:BroneKot,项目名称:CS-Bans,代码行数:10,代码来源:InstallForm.php

示例13: afterValidate

 public function afterValidate()
 {
     parent::afterValidate();
 }
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:4,代码来源:GenerateMessageForm.php

示例14: afterValidate

 public function afterValidate()
 {
     parent::afterValidate();
     if ($this->hasErrors()) {
         $this->incrementErrorLoginNums();
     } else {
         $this->clearErrorLoginNums();
     }
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:9,代码来源:LoginForm.php

示例15: afterValidate

 public function afterValidate()
 {
     parent::afterValidate();
     if ($this->getErrors()) {
         self::incrementErrorLoginNums();
     } else {
         self::clearErrorLoginNums();
     }
 }
开发者ID:jackycgq,项目名称:24beta,代码行数:9,代码来源:LoginForm.php


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