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


PHP CPropertyValue::ensureString方法代码示例

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


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

示例1: prepareInput

 private function prepareInput($attributes)
 {
     $preparedAttributes = array();
     foreach ($attributes as $key => $value) {
         if (in_array($key, array('enableClientValidation', 'safe', 'skipOnError', 'setOnEmpty'))) {
             $preparedAttributes[$key] = CPropertyValue::ensureString($value);
         }
         if ($key === 'except' || $key === 'on') {
             if (is_array($value)) {
                 $preparedAttributes[$key] = implode(', ', $value);
             }
         }
         if ($key === 'value') {
             if ($value === true || $value === false) {
                 $preparedAttributes[$key] = CPropertyValue::ensureString($value);
             } else {
                 if (is_null($value)) {
                     $preparedAttributes[$key] = 'null';
                 } else {
                     if (is_array($value)) {
                         $preparedAttributes[$key] = trim(str_replace('array', '', var_export($value, true)));
                     }
                 }
             }
         }
     }
     return $preparedAttributes;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-kamin,代码行数:28,代码来源:CDefaultValueValidatorForm.php

示例2: testEnsureString

 public function testEnsureString()
 {
     $entries = array(array('', ''), array('abc', 'abc'), array(null, ''), array(0, '0'), array(1, '1'), array(-1.1, '-1.1'), array(true, 'true'), array(false, 'false'), array(array(), 'Array'), array(array(0), 'Array'));
     foreach ($entries as $index => $entry) {
         $this->assertTrue(CPropertyValue::ensureString($entry[0]) === $entry[1], "Comparison {$index}: {$entry[0]}=={$entry[1]}");
     }
 }
开发者ID:avtograd,项目名称:yii,代码行数:7,代码来源:CPropertyValueTest.php

示例3: testEnsureString

 public function testEnsureString()
 {
     $entries = array(array('', ''), array('abc', 'abc'), array(null, ''), array(0, '0'), array(1, '1'), array(-1.1, '-1.1'), array(true, 'true'), array(false, 'false'));
     if (version_compare(PHP_VERSION, '5.4.0', '<')) {
         $entries = array_merge($entries, array(array(array(), 'Array'), array(array(0), 'Array')));
     }
     foreach ($entries as $index => $entry) {
         $this->assertTrue(CPropertyValue::ensureString($entry[0]) === $entry[1], "Comparison {$index}: {$this->varToString($entry[0])}=={$this->varToString($entry[1])}");
     }
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:10,代码来源:CPropertyValueTest.php

示例4: prepareInput

 private function prepareInput($attributes)
 {
     $preparedAttributes = array();
     foreach ($attributes as $key => $value) {
         if (in_array($key, array('enableClientValidation', 'safe', 'skipOnError'))) {
             $preparedAttributes[$key] = CPropertyValue::ensureString($value);
         }
         if ($key === 'except' || $key === 'on') {
             if (is_array($value)) {
                 $preparedAttributes[$key] = implode(', ', $value);
             }
         }
     }
     return $preparedAttributes;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-kamin,代码行数:15,代码来源:CFilterValidatorForm.php

示例5: dropDownList

 /**
  * dropDownList Taxonomy
  * 
  * @param string $name
  * @param string $taxonomy
  * @param string $module
  * @param int $objectId
  * @param array $htmlOptions
  */
 public static function dropDownList($name, $taxonomy, $module, $objectId, $htmlOptions = array())
 {
     $properties = array('name' => $name, 'taxonomy' => $taxonomy, 'module' => $module, 'objectId' => $objectId);
     if (isset($htmlOptions['type'])) {
         $properties['type'] = CPropertyValue::ensureString($htmlOptions['type']);
         unset($htmlOptions['type']);
     }
     if (isset($htmlOptions['repeatChar'])) {
         $properties['repeatChar'] = CPropertyValue::ensureString($htmlOptions['repeatChar']);
         unset($htmlOptions['repeatChar']);
     }
     if (isset($htmlOptions['useRepeatChar'])) {
         $properties['useRepeatChar'] = CPropertyValue::ensureBoolean($htmlOptions['useRepeatChar']);
         unset($htmlOptions['useRepeatChar']);
     }
     $properties['htmlOptions'] = $htmlOptions;
     return Yii::app()->controller->widget('ListTaxonomy', $properties, true);
 }
开发者ID:hung5s,项目名称:yap,代码行数:27,代码来源:TaxonomyHelper.php

示例6: actionSearchName

 /**
  * @param string $term
  */
 public function actionSearchName($term)
 {
     // escape $term
     $term = CPropertyValue::ensureString($term);
     // create criteria
     $c = new CDbCriteria();
     $c->distinct = true;
     $c->addSearchCondition('name', $term);
     $c->limit = 5;
     // save results
     $result = array();
     foreach (Entry::model()->findAll($c) as $model) {
         /* @var Entry $model */
         $result[] = $model->name;
     }
     // output result as JSON
     echo CJSON::encode($result);
 }
开发者ID:humantech,项目名称:ppma,代码行数:21,代码来源:EntryController.php

示例7: prepareInput

 private function prepareInput($attributes)
 {
     $preparedAttributes = array();
     foreach ($attributes as $key => $value) {
         if (in_array($key, array('enableClientValidation', 'safe', 'skipOnError', 'allowEmpty', 'caseSensitive'))) {
             $preparedAttributes[$key] = CPropertyValue::ensureString($value);
         }
         if ($key === 'except' || $key === 'on') {
             if (is_array($value)) {
                 $preparedAttributes[$key] = implode(', ', $value);
             }
         }
         if ($key === 'criteria') {
             $criteria = var_export($value, true);
             $criteria = substr_replace($criteria, '', 0, 5);
             $preparedAttributes[$key] = trim($criteria);
         }
     }
     return $preparedAttributes;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-kamin,代码行数:20,代码来源:CUniqueValidatorForm.php

示例8: setId

 public function setId($value)
 {
     $this->id = CPropertyValue::ensureString($value);
 }
开发者ID:alexskull,项目名称:Ushi,代码行数:4,代码来源:QtzPanel.php

示例9: search

 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('username', $this->username, true, 'AND', 'ILIKE');
     $criteria->addSearchCondition('email', $this->email, true, 'AND', 'ILIKE');
     //        $criteria->compare('user_group_id',$this->user_group_id);
     //$criteria->addSearchCondition('last_login',$this->last_login,true,'AND','ILIKE');
     $criteria->compare('status', $this->status);
     //$criteria->addSearchCondition('creation_datetime',$this->creation_datetime,true,'AND','ILIKE');
     //$criteria->addSearchCondition('last_update',$this->last_update,true,'AND','ILIKE');
     $criteria->with = array('auth' => array('joinType' => 'LEFT JOIN'));
     $criteria->together = true;
     if (!empty($this->userRole)) {
         if ($this->userRole == 'no-role') {
             $criteria->addCondition('auth.userid IS NULL');
         } else {
             $criteria->compare('auth.itemname', CPropertyValue::ensureString($this->userRole));
         }
     }
     $dataprovider = new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'sort' => array('defaultOrder' => 't.id DESC'), 'pagination' => array('pageSize' => defined('SETTINGS_BO_PAGE_SIZE') ? SETTINGS_BO_PAGE_SIZE : 50)));
     return $dataprovider;
 }
开发者ID:hung5s,项目名称:yap,代码行数:24,代码来源:AdminUser.php

示例10: getInput

 /**
  * Extract an data from input data
  *
  * @param string $name can be an normal name or 'Class[attribute]' to get input of a model attribute
  *
  * @param mixed $defaultValue it is recommended to specify default value even when you
  * are sure that the input has data you want to extract.
  *
  * @param string $filter 'xss,notag,newline' filters the data is run through before returned
  * do not combine xss with notag as it slow down the performance.
  */
 public function getInput($name, $defaultValue = null, $filter = '')
 {
     if (is_array($parsedName = $this->parseName($name))) {
         $name = $parsedName[0];
         $key = $parsedName[1];
     }
     if (!array_key_exists($name, $this->data)) {
         return $defaultValue;
     } else {
         $value = $this->data[$name];
         if (isset($key) && is_array($value)) {
             $value = $value[$key];
         }
         if (is_null($value)) {
             return $defaultValue;
         }
     }
     //Run filters
     if (is_string($value) || is_array($value)) {
         foreach ($this->filters as $flt) {
             $value = call_user_func(array($this, $flt), $value, $filter);
         }
     }
     if (is_array($value)) {
         return $value;
     }
     $value = trim($value);
     //Convert to expected type
     if (is_null($defaultValue)) {
         return trim($value);
     }
     if (is_string($defaultValue)) {
         return CPropertyValue::ensureString($value);
     }
     if (is_int($defaultValue)) {
         return CPropertyValue::ensureInteger($value);
     }
     if (is_numeric($defaultValue)) {
         return CPropertyValue::ensureFloat($value);
     }
     if (is_array($defaultValue)) {
         if (!is_array($value)) {
             return array($value);
         } else {
             return $value;
         }
     }
     return $value;
 }
开发者ID:hung5s,项目名称:yap,代码行数:60,代码来源:XInputFilter.php


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