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


PHP AuxLib::coerceToArray方法代码示例

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


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

示例1: evalComparison

 /**
  * @param mixed $subject if applicable, the value to compare $subject with (value of model 
  *  attribute)
  * @param string $operator the type of comparison to be used
  * @param mixed $value the value being analyzed (specified in config menu)
  * @return boolean
  */
 public static function evalComparison($subject, $operator, $value = null, Fields $field = null)
 {
     $value = self::parseArray($operator, $value);
     //        if (!in_array ($operator, $expectsArray, true) && is_array ($value)) {
     //            if (count ($value) > 1) {
     //                return false;
     //            } else {
     //                $value = array_pop ($value);
     //            }
     //        }
     switch ($operator) {
         case '=':
             // check for multiselect dropdown
             if ($field && $field->type === 'dropdown') {
                 $dropdown = $field->getDropdown();
                 if ($dropdown && $dropdown->multi) {
                     $subject = StringUtil::jsonDecode($subject, false);
                     AuxLib::coerceToArray($subject);
                     AuxLib::coerceToArray($value);
                     return $subject === $value;
                 }
                 // check for muti-assignment field
             } else {
                 if ($field && $field->type === 'assignment' && $field->linkType === 'multiple') {
                     $subject = explode(Fields::MULTI_ASSIGNMENT_DELIM, $subject);
                     AuxLib::coerceToArray($subject);
                     AuxLib::coerceToArray($value);
                     return $subject === $value;
                 }
             }
             // this case occurs when dropdown or assignment fields are changed from multiple
             // to single selection, and flow conditions are left over from before the change
             // was made
             if (is_array($value)) {
                 AuxLib::coerceToArray($subject);
             }
             return $subject == $value;
         case '>':
             return $subject > $value;
         case '<':
             return $subject < $value;
         case '>=':
             return $subject >= $value;
         case '<=':
             return $subject <= $value;
         case 'between':
             if (count($value) !== 2) {
                 return false;
             }
             return $subject >= min($value) && $subject <= max($value);
         case '<>':
         case '!=':
             return $subject != $value;
         case 'notEmpty':
             return $subject !== null && $subject !== '';
         case 'empty':
             return $subject === null || trim($subject) === '';
         case 'list':
             if (count($value) === 0) {
                 // if the list is empty,
                 return false;
             }
             // A isn't in it
             foreach ($value as &$val) {
                 if ($subject == $val) {
                     return true;
                 }
             }
             return false;
         case 'notList':
             if (count($value) === 0) {
                 // if the list is empty,
                 return true;
             }
             // A isn't *not* in it
             foreach ($value as &$val) {
                 if ($subject == $val) {
                     return false;
                 }
             }
             return true;
         case 'noContains':
             return stripos($subject, $value) === false;
         case 'contains':
         default:
             return stripos($subject, $value) !== false;
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:95,代码来源:X2FlowTrigger.php

示例2: getItems2

 /**
  * Improved version of getItems which enables use of empty search string, pagination, and
  * configurable option values/names.
  * @param string $prefix name prefix of items to retrieve
  * @param int $page page number of results to retrieve
  * @param int $limit max number of results to retrieve
  * @param string|array $valueAttr attribute(s) used to popuplate the option values. If an 
  *  array is passed, value will composed of values of each of the attributes specified, joined
  *  by commas
  * @param string $nameAttr attribute used to popuplate the option names
  * @return array name, value pairs
  */
 public function getItems2($prefix = '', $page = 0, $limit = 20, $valueAttr = 'name', $nameAttr = 'name')
 {
     $modelClass = get_class($this->owner);
     $model = CActiveRecord::model($modelClass);
     $table = $model->tableName();
     $offset = intval($page) * intval($limit);
     AuxLib::coerceToArray($valueAttr);
     $modelClass::checkThrowAttrError(array_merge($valueAttr, array($nameAttr)));
     $params = array();
     if ($prefix !== '') {
         $params[':prefix'] = $prefix . '%';
     }
     $offset = abs((int) $offset);
     $limit = abs((int) $limit);
     $command = Yii::app()->db->createCommand("\n            SELECT " . implode(',', $valueAttr) . ", {$nameAttr} as __name\n            FROM {$table}\n            WHERE " . ($prefix === '' ? '1=1' : $nameAttr . ' LIKE :prefix') . "\n            ORDER BY __name\n            LIMIT {$offset}, {$limit}\n        ");
     $rows = $command->queryAll(true, $params);
     $items = array();
     foreach ($rows as $row) {
         $name = $row['__name'];
         unset($row['__name']);
         $items[] = array($name, $row);
     }
     return $items;
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:36,代码来源:X2LinkableBehavior.php

示例3: parseModelType

 public static function parseModelType($modelType)
 {
     //AuxLib::debugLogR ($modelType);
     if (isset($_GET['workflowAjax']) && $_GET['workflowAjax']) {
         $modelType = CJSON::decode($modelType);
     }
     if (empty($modelType) || is_array($modelType) && sizeof($modelType) === 1 && empty($modelType[0])) {
         return '';
     }
     AuxLib::coerceToArray($modelType);
     return $modelType;
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:12,代码来源:WorkflowController.php


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