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


PHP Str::nullOrEmpty方法代码示例

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


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

示例1: validateUserInput

 public function validateUserInput()
 {
     parent::validateUserInput();
     if (Str::nullOrEmpty($this->blogId)) {
         $this->addError("generic.error.missingRequiredField", array("field" => "blogId"));
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:7,代码来源:PostBlogUpdate.php

示例2: validateUserInput

 public function validateUserInput()
 {
     if (Str::nullOrEmpty($this->name)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'name'), 'name');
     }
     if (Str::nullOrEmpty($this->contents)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'contents'), 'contents');
     }
     if (Str::nullOrEmpty($this->blogId)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'blogId'));
     }
     // check captcha
     if (!Str::nullOrEmpty($this->captchaChallenge)) {
         $resp = ReCaptcha::recaptcha_check_answer(self::CAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $this->captchaChallenge, $this->captchaResponse);
         if ($resp->is_valid) {
             // DAY is in milliseconds, convert to seconds and multiply by 14 for 2 weeks
             $expireTime = time() + GlobalConstants::DAY / 10 * 14;
             setcookie(self::CAPTCHA_COOKIE_NAME, true, $expireTime, '/');
         } else {
             $this->addError($resp->error);
         }
     } elseif (!isset($_COOKIE[self::CAPTCHA_COOKIE_NAME])) {
         $this->addError("Captcha does not appear to be functioning properly, please contact site administrator.");
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:25,代码来源:PostBlogComment.php

示例3: validateUserInput

 public function validateUserInput()
 {
     if (Str::nullOrEmpty($this->commentId)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'commentId'));
     }
     if (!isAdmin()) {
         $this->addError("generic.error.insufficientPermissions");
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:9,代码来源:DeleteBlogComment.php

示例4: validateUserInput

 protected function validateUserInput()
 {
     if (Str::nullOrEmpty($this->email)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'email'), 'email');
     }
     if (Str::nullOrEmpty($this->password)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'password'), 'password');
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:9,代码来源:ValidateCredentials.php

示例5: validateUserInput

 public function validateUserInput()
 {
     if (Str::nullOrEmpty($this->postTitle)) {
         $this->addError("generic.error.missingRequiredField", array("field" => "postTitle"));
     }
     if (Str::nullOrEmpty($this->contents)) {
         $this->addError("generic.error.missingRequiredField", array("field" => "contents"));
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:9,代码来源:PostBlog.php

示例6: validateUserInput

 public function validateUserInput()
 {
     if (!$this->isLoggedIn()) {
         $this->addError("generic.error.notLoggedIn");
     }
     if (Str::nullOrEmpty($this->email)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'email'), 'email');
     }
     if ($this->password != $this->passwordConfirm) {
         $this->addError("editAccount.error.passwordMismatch");
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:12,代码来源:UpdateAccount.php

示例7: testNullOrEmpty

 function testNullOrEmpty()
 {
     $null = null;
     $empty = "";
     $whiteSpace = "    ";
     $notEmpty = "    a    ";
     $zero = array();
     $result = new Result("");
     $this->assertTrue(Str::nullOrEmpty($null));
     $this->assertTrue(Str::nullOrEmpty($this->notInitialized));
     $this->assertTrue(Str::nullOrEmpty($empty));
     $this->assertTrue(Str::nullOrEmpty($zero));
     $this->assertFalse(Str::nullOrEmpty($whiteSpace, true));
     $this->assertFalse(Str::nullOrEmpty($notEmpty, true));
     $this->assertFalse(Str::nullOrEmpty($result, true));
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:16,代码来源:StrTest.php

示例8: get

 /**
  * Format a message using message formatting rules, the provided
  * arguments and the provided locale.
  *
  * The locale influences numeric formatting, time formatting and monetary
  * formatting. Note that this has been disabled until test servers are at
  * least PHP 5.3.
  *
  * @param string $string String to format.
  * @param array $arguments Arguments used to format or substitute into
  * message.
  * @param class $locale Overriding locale object.
  *
  * @return string Formatted string.
  */
 public static function get($string, array $arguments = array(), $locale = null)
 {
     global $UBAR_GLOB;
     try {
         // array of directives to ignore because no matching argument found
         $ignoreList = array();
         // while you find something that looks like a directive, try to process it
         while (preg_match(self::REPLACE_REGEX, $string, $match)) {
             // get the key which should match an argument
             $key = trim($match[1]);
             // value from arguments matching key
             $value = NULL;
             // directive instructions - math, choice, number formatting, etc
             $instructions = NULL;
             // key not found in arguments
             if (!array_key_exists($key, $arguments)) {
                 // replace unrecognized directive with marker so the while loop doesn't get caught on it again<br />
                 // TODO: determine if better way to handle this
                 // TODO: log if in dev mode
                 self::ignore($match[0], $ignoreList, $string);
                 continue;
             } else {
                 $value = $arguments[$key];
             }
             // get instruction portion of directive - may be empty
             if (isset($match[2])) {
                 $instructions = trim(substr($match[2], 1));
             }
             // if empty, just replace value
             if (Str::nullOrEmpty($instructions)) {
                 $string = str_replace($match[0], $value, $string);
                 // else, process the instructions using the provided value
             } else {
                 $processedValue = self::processValue($value, $instructions, $locale);
                 if (!is_null($processedValue)) {
                     $string = str_replace($match[0], $processedValue, $string);
                     // if the value could not be processed, add to the ignore list
                 } else {
                     self::ignore($match[0], $ignoreList, $string);
                 }
             }
         }
         // if any replace markers for directives with bad keys, put them back now
         foreach ($ignoreList as $key => $value) {
             // NOTE: since expression language creates parse errors in xhtml and may otherwise impact markup, escaping characters in string.
             $string = str_replace($key, htmlspecialchars($value), $string);
         }
         // return string now that all directives with associated arguments are replaced
         // TODO: in dev mode, check that there weren't any missed directives because no argument found to match
     } catch (Exception $e) {
         // TODO: determine what expected errors can be caught and handle appropriately
         // something unknown went wrong, make xthml safe since the expression language format will cause xml parse errors
         if ($UBAR_GLOB['DEV_MODE']) {
             throw $e;
         }
         $string = htmlspecialchars($string);
     }
     return $string;
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:74,代码来源:MessageFormat.php

示例9: __construct

 /**
  * Construct a localized properties instance with the given locale and
  * path. The path is only used as an override and should not be used
  * regularly.
  *
  * @param class $locale Locale to use for properties file lookup and
  * formatting.
  * @param string $path Override to path to properties files.
  */
 public function __construct($locale = NULL, $path = NULL)
 {
     global $UBAR_GLOB;
     // use properties root if exists and no override specified
     if ((!isset($path) || is_null($path)) && isset($UBAR_GLOB['PROPERTIES_PATH'])) {
         $path = $UBAR_GLOB['PROPERTIES_PATH'];
     }
     // verify directory found
     if (!file_exists($path)) {
         throw new Exception("Path \"{$path}\" to properties files does not exist. File: " . __FILE__ . " on line: " . __LINE__);
     }
     // get locale
     if (isset($locale) && !is_null($locale)) {
         // TODO: make it not throw an error if pear package not installed for localization
         // TODO: either use php 5.3 or PEAR i18n
         //$this->locale = Locale::parseLocale($locale);
         $this->locale = $locale;
         //die(print_r($this->locale));
     } else {
         if (isset($UBAR_GLOB['LOCALE'])) {
             // TODO: convert to Locale instance
             $this->locale = $UBAR_GLOB['LOCALE'];
         }
     }
     // TODO: check if valid locale
     // make sure that default properties file exists
     $defaultPath = $path . $UBAR_GLOB['PROPERTIES_ROOT'] . self::PROPERTIES_APPENDER;
     if (!file_exists($defaultPath)) {
         throw new Exception('Default properties file \'' . $defaultPath . '\' does not exist.');
     }
     // if this is the default locale or there was no override, set default as main properties
     if ($this->locale == $UBAR_GLOB['LOCALE_DEFAULT'] || Str::nullOrEmpty($this->locale)) {
         $this->isDefault = true;
         $this->properties = file_get_contents($defaultPath);
         // else, try to get localized properties file
     } else {
         $this->defaultProperties = file_get_contents($defaultPath);
         $localizedPath = $path . $UBAR_GLOB['PROPERTIES_ROOT'] . "_" . $this->locale . self::PROPERTIES_APPENDER;
         // if localized file doesn't exist, set default as primary and log that couldn't find localized property file
         if (!file_exists($localizedPath)) {
             //throw new Exception('Properties file \'' . $propertiesPath . '\' does not exist.');
             // log that couldn't find locale specific properties
             $this->properties = $this->defaultProperties;
             // get localized properties file
         } else {
             $this->properties = file_get_contents($localizedPath);
         }
     }
     // strip comments - this is anything where the first non whitespace is #
     $this->properties = preg_replace(Properties::PROP_COMMENT_REGEX, "", $this->properties);
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:60,代码来源:LocalizedProperties.php

示例10: showResult

 /**
  * Render the result or redirect to the appropriate location.
  *
  * NOTE: This is a public method so that it may be called from tests. It is
  * not recommended that you call it directly elsewhere.
  *
  * NOTE: Currently a type of ERROR without a global result just dumps the
  * errors to screen.
  *
  * @throws Exception If now result defwas found and no default handling
  * could be found.
  *
  * @todo Do error presentation for ERROR type.
  *
  */
 public function showResult()
 {
     global $UBAR_GLOB;
     // no def and not default, look for it in global results
     if ($this->resultDef == null) {
         switch ($this->resultString) {
             case GlobalConstants::JSON:
                 // to render json, action must extend JSONAction
                 echo $this->action->getJSONString();
                 return;
             case GlobalConstants::ERROR:
                 // TODO: build in a default error representation
                 // since no error result found, just dump the errors
                 echo "Unable to find default error representation, overridable by having a global result for ERROR<br />";
                 die(print_r($this->action->getErrors(), true));
                 break;
             default:
                 throw new Exception("No definition found for result string {$resultString} for the action definition {$actionClassName}");
         }
     }
     // guaranteed to have a result def, switch on type
     switch ($this->resultDef->getType()) {
         case GlobalConstants::ACTION_TYPE:
             // make a new request so there is no redeclaration or confusion with request params
             // NOTE: this is less efficient but safer
             // TODO: get possible override for action identifier instead of hardcoding ".action"
             header('Location: ' . $this->resultDef->getTarget() . ".action");
             break;
         case GlobalConstants::PAGE_TYPE:
             // pass in possible overrides for page and template
             $this->renderPage($this->resultDef);
             break;
         case GlobalConstants::FILE_TYPE:
             require_once $UBAR_GLOB['BASE_VIEW_PATH'] . $this->resultDef->getTarget();
             return;
         case GlobalConstants::URL_TYPE:
             if (Str::nullOrEmpty($this->resultDef->getTarget())) {
                 throw new Exception("With a url result type, you must specify a location to redirect to");
             }
             // url types (and possibly others?) may have expressions embedded in target, evaluate
             $target = $this->evaluateResultString($this->resultDef->getTarget());
             header('Location: ' . $target);
             return;
         case GlobalConstants::JSON_TYPE:
             // to render json, action must extend JSONAction
             echo $this->action->getJSONString();
             return;
         default:
             throw new Exception("Unknown result type ," . $this->resultDef->getType());
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:66,代码来源:Dispatcher.php


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