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


PHP Set::countDim方法代码示例

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


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

示例1: initialize

 /**
  * Startup
  *
  * @param object $controller
  * @return void
  */
 function initialize(&$controller)
 {
     $controller->isAmf = false;
     if (class_exists('amfdispatcher') && AmfDispatcher::active()) {
         $controller->isAmf = true;
         $controller->disableCache();
         $controller->view = 'Amf.Amf';
         $data = AmfDispatcher::data();
         if (!empty($data)) {
             if (is_object($data)) {
                 $controller->data = Set::reverse($data);
             } elseif (Set::countDim($data) == 1) {
                 $controller->data = array_pop($data);
             } else {
                 $controller->data = $data;
             }
         }
     }
 }
开发者ID:BGCX067,项目名称:fake-as3-svn-to-git,代码行数:25,代码来源:amf.php

示例2: uniques

 public function uniques($check)
 {
     $conditions = array();
     $args = func_get_args();
     foreach ($args as $field) {
         if (is_array($field)) {
             if (Set::countDim($field, true) === 1) {
                 foreach ($field as $k => $v) {
                     $conditions += array($this->escapeField($k) => $v);
                 }
             }
         } else {
             if (!isset($this->data[$this->alias][$field])) {
                 trigger_error($field . ' is not propery set in data on ' . $this->alias);
                 return false;
             }
             $conditions += array($this->escapeField($field) => $this->data[$this->alias][$field]);
         }
     }
     return !$this->hasAny($conditions);
 }
开发者ID:hiromi2424,项目名称:cake_app_base,代码行数:21,代码来源:app_model.php

示例3: order

 /**
  * Returns an ORDER BY clause as a string.
  *
  * @param string $key Field reference, as a key (i.e. Post.title)
  * @param string $direction Direction (ASC or DESC)
  * @return string ORDER BY clause
  */
 function order($keys, $direction = 'ASC')
 {
     if (is_string($keys) && strpos($keys, ',') && !preg_match('/\\(.+\\,.+\\)/', $keys)) {
         $keys = explode(',', $keys);
         array_map('trim', $keys);
     }
     if (is_array($keys)) {
         foreach ($keys as $key => $val) {
             if (is_numeric($key) && empty($val)) {
                 unset($keys[$key]);
             }
         }
     }
     if (empty($keys) || is_array($keys) && count($keys) && isset($keys[0]) && empty($keys[0])) {
         return '';
     }
     if (is_array($keys)) {
         if (Set::countDim($keys) > 1) {
             $new = array();
             foreach ($keys as $val) {
                 $val = $this->order($val);
                 $new[] = $val;
             }
             $keys = $new;
         }
         foreach ($keys as $key => $value) {
             if (is_numeric($key)) {
                 $value = ltrim(r('ORDER BY ', '', $this->order($value)));
                 $key = $value;
                 if (!preg_match('/\\x20ASC|\\x20DESC/i', $key)) {
                     $value = ' ' . $direction;
                 } else {
                     $value = '';
                 }
             } else {
                 $value = ' ' . $value;
             }
             if (!preg_match('/^.+\\(.*\\)/', $key) && !strpos($key, ',')) {
                 $dir = '';
                 $hasDir = preg_match('/\\x20ASC|\\x20DESC/i', $key, $dir);
                 if ($hasDir) {
                     $dir = $dir[0];
                     $key = preg_replace('/\\x20ASC|\\x20DESC/i', '', $key);
                 } else {
                     $dir = '';
                 }
                 $key = trim($this->name(trim($key)) . ' ' . trim($dir));
             }
             $order[] = $this->order($key . $value);
         }
         return ' ORDER BY ' . trim(r('ORDER BY', '', join(',', $order)));
     } else {
         $keys = preg_replace('/ORDER\\x20BY/i', '', $keys);
         if (strpos($keys, '.')) {
             preg_match_all('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', $keys, $result, PREG_PATTERN_ORDER);
             $pregCount = count($result['0']);
             for ($i = 0; $i < $pregCount; $i++) {
                 $keys = preg_replace('/' . $result['0'][$i] . '/', $this->name($result['0'][$i]), $keys);
             }
             if (preg_match('/\\x20ASC|\\x20DESC/i', $keys)) {
                 return ' ORDER BY ' . $keys;
             } else {
                 return ' ORDER BY ' . $keys . ' ' . $direction;
             }
         } elseif (preg_match('/(\\x20ASC|\\x20DESC)/i', $keys, $match)) {
             $direction = $match['1'];
             $keys = preg_replace('/' . $match['1'] . '/', '', $keys);
             return ' ORDER BY ' . $keys . $direction;
         } else {
             $direction = ' ' . $direction;
         }
         return ' ORDER BY ' . $keys . $direction;
     }
 }
开发者ID:uwitec,项目名称:eduoa,代码行数:81,代码来源:dbo_source.php

示例4: _modelizePost

	/**
	 * Prepares REST data for cake interaction
	 *
	 * @param <type> $data
	 * @return <type>
	 */
	protected function _modelizePost (&$data) {
		if (!is_array($data)) {
			return $data;
		}

		// Don't throw errors if data is already modelized
		// f.e. sending a serialized FormHelper form via ajax
		if (isset($data[$this->Controller->modelClass])) {
			$data = $data[$this->Controller->modelClass];
		}

		// Protected against Saving multiple models in one post
		// while still allowing mass-updates in the form of:
		// $this->data[1][field] = value;
		if (Set::countDim($data) === 2) {
			if (!$this->numeric($data)) {
				return $this->error('2 dimensional can only begin with numeric index');
			}
		} else if (Set::countDim($data) !== 1) {
			return $this->error('You may only send 1 dimensional posts');
		}

		// Encapsulate in Controller Model
		$data = array(
			$this->Controller->modelClass => $data,
		);

		return $data;
	}
开发者ID:rjaus,项目名称:cakephp-rest-plugin,代码行数:35,代码来源:rest.php

示例5: save

 /**
  * @param mixed $data
  * @return bool
  */
 public function save($data = '')
 {
     $data = $this->beforeSave($data);
     if (Configure::read('themeSupport.skins') === true) {
         if ($this->id == GUMM_THEME_PREFIX . '_styles') {
             $skin = GummRegistry::get('Model', 'Skin')->getActiveSkin();
             $data = array($skin => $data);
             if (!$this->mergeOnSave) {
                 $existingStylesData = get_option($this->id);
                 if ($existingStylesData && is_array($existingStylesData)) {
                     $data = array_merge($existingStylesData, $data);
                 }
             }
         }
     }
     if ($this->mergeOnSave) {
         $existingData = get_option($this->id);
         $originData = $data;
         $dimensionCount = Set::countDim($existingData, true);
         if ($dimensionCount === 1 && isset($data[0])) {
         } elseif ($existingData && is_array($existingData) && is_array($data)) {
             $data = Set::merge($existingData, $data);
         }
     }
     $success = update_option($this->id, $data);
     $this->afterSave($data);
     return $success;
 }
开发者ID:nikolaskarica,项目名称:bds-alliance,代码行数:32,代码来源:gumm_model.php

示例6: _isRequiredField

 /**
  * Returns if a field is required to be filled based on validation properties from the validating object
  *
  * @return boolean true if field is required to be filled, false otherwise
  */
 protected function _isRequiredField($validateProperties)
 {
     $required = false;
     if (is_array($validateProperties)) {
         $dims = Set::countDim($validateProperties);
         if ($dims == 1 || $dims == 2 && isset($validateProperties['rule'])) {
             $validateProperties = array($validateProperties);
         }
         foreach ($validateProperties as $rule => $validateProp) {
             if (isset($validateProp['allowEmpty']) && $validateProp['allowEmpty'] === true) {
                 return false;
             }
             $rule = isset($validateProp['rule']) ? $validateProp['rule'] : false;
             $required = $rule || empty($validateProp);
             if ($required) {
                 break;
             }
         }
     }
     return $required;
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:26,代码来源:form.php

示例7: countDim

 /**
  * Counts the dimensions of an array. If $all is set to false (which is the default) it will
  * only consider the dimension of the first element in the array.
  *
  * @param array $array Array to count dimensions on
  * @param boolean $all Set to true to count the dimension considering all elements in array
  * @param integer $count Start the dimension count at this number
  * @return integer The number of dimensions in $array
  * @access public
  */
 function countDim($array = null, $all = false, $count = 0)
 {
     if ($array === null) {
         $array = $this->get();
     } elseif (is_object($array) && is_a($array, 'set')) {
         $array = $array->get();
     }
     if ($all) {
         $depth = array($count);
         if (is_array($array) && reset($array) !== false) {
             foreach ($array as $value) {
                 $depth[] = Set::countDim($value, true, $count + 1);
             }
         }
         $return = max($depth);
     } else {
         if (is_array(reset($array))) {
             $return = Set::countDim(reset($array)) + 1;
         } else {
             $return = 1;
         }
     }
     return $return;
 }
开发者ID:venka10,项目名称:RUS,代码行数:34,代码来源:set.php

示例8: countDim

 /**
  * Counts the dimensions of an array. If $all is set to false (which is the default) it will
  * only consider the dimension of the first element in the array.
  *
  * @param array $array Array to count dimensions on
  * @param boolean $all Set to true to count the dimension considering all elements in array
  * @param integer $count Start the dimension count at this number
  * @return integer The number of dimensions in $array
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::countDim
  */
 public static function countDim($array = null, $all = false, $count = 0)
 {
     if ($all) {
         $depth = array($count);
         if (is_array($array) && reset($array) !== false) {
             foreach ($array as $value) {
                 $depth[] = Set::countDim($value, true, $count + 1);
             }
         }
         $return = max($depth);
     } else {
         if (is_array(reset($array))) {
             $return = Set::countDim(reset($array)) + 1;
         } else {
             $return = 1;
         }
     }
     return $return;
 }
开发者ID:aichelman,项目名称:StudyUp,代码行数:29,代码来源:Set.php

示例9: order

 function order($order, $context)
 {
     if (is_string($order) && strpos($order, ',') && !preg_match('/\\(.+\\,.+\\)/', $order)) {
         $order = array_map('trim', explode(',', $order));
     }
     $order = is_array($order) ? array_filter($order) : $order;
     if (empty($order)) {
         return '';
     }
     if (is_array($keys)) {
         $keys = Set::countDim($keys) > 1 ? array_map(array(&$this, 'order'), $keys) : $keys;
         foreach ($keys as $key => $value) {
             if (is_numeric($key)) {
                 $key = $value = ltrim(str_replace('ORDER BY ', '', $this->order($value)));
                 $value = !preg_match('/\\x20ASC|\\x20DESC/i', $key) ? ' ' . $direction : '';
             } else {
                 $value = ' ' . $value;
             }
             if (!preg_match('/^.+\\(.*\\)/', $key) && !strpos($key, ',')) {
                 if (preg_match('/\\x20ASC|\\x20DESC/i', $key, $dir)) {
                     $dir = $dir[0];
                     $key = preg_replace('/\\x20ASC|\\x20DESC/i', '', $key);
                 } else {
                     $dir = '';
                 }
                 $key = trim($key);
                 if (!preg_match('/\\s/', $key)) {
                     $key = $this->name($key);
                 }
                 $key .= ' ' . trim($dir);
             }
             $order[] = $this->order($key . $value);
         }
         return ' ORDER BY ' . trim(str_replace('ORDER BY', '', join(',', $order)));
     }
     $keys = preg_replace('/ORDER\\x20BY/i', '', $keys);
     if (strpos($keys, '.')) {
         preg_match_all('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', $keys, $result, PREG_PATTERN_ORDER);
         $pregCount = count($result[0]);
         for ($i = 0; $i < $pregCount; $i++) {
             if (!is_numeric($result[0][$i])) {
                 $keys = preg_replace('/' . $result[0][$i] . '/', $this->name($result[0][$i]), $keys);
             }
         }
         $result = ' ORDER BY ' . $keys;
         return $result . (!preg_match('/\\x20ASC|\\x20DESC/i', $keys) ? ' ' . $direction : '');
     } elseif (preg_match('/(\\x20ASC|\\x20DESC)/i', $keys, $match)) {
         $direction = $match[1];
         return ' ORDER BY ' . preg_replace('/' . $match[1] . '/', '', $keys) . $direction;
     }
     return ' ORDER BY ' . $keys . ' ' . $direction;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:52,代码来源:Database.php

示例10: setCollectionsMagic

 /**
  * Automatically determine active collections based on the passed $item
  *
  * @param mixed $item
  */
 public static function setCollectionsMagic($item = null)
 {
     $controller = Sl::getInstance()->controller;
     $collections = array();
     if (is_string($item)) {
         $collections[] = $item;
     } else {
         if ($controller) {
             if (isset($item[$controller->modelClass]['id'])) {
                 $collections["{$controller->modelClass}{$item[$controller->modelClass]['id']}"] = 899;
             }
             if (empty($item['nodes']) && !empty($item['path'][0][$controller->modelClass]['id'])) {
                 $ids = Set::extract("{n}.{$controller->modelClass}.id", $data['path']);
                 foreach ($ids as $i => $id) {
                     $collections["{$controller->modelClass}{$id}"] = 800 + $i;
                 }
             }
         }
         if (!empty($item['nodes'])) {
             foreach ($item['nodes'] as $i => $nodeId) {
                 $collections["Node{$nodeId}"] = 600 + $i;
             }
         }
         if (!empty($item['tags'])) {
             foreach ($item['tags'] as $i => $tagId) {
                 $collections["Tag{$tagId}"] = 400 + $i;
             }
         }
         if (empty($collections) && is_array($item) && Set::numeric($item) && Set::countDim($item, true) == 1) {
             $collections = $item;
         }
     }
     return self::setCollections($collections);
 }
开发者ID:sandulungu,项目名称:StarLight,代码行数:39,代码来源:sl_configure.php

示例11: __composeContent

 /**
  * Generates XML content based on the type of variable or object passed
  *
  * @param  mixed  $content The content to be converted to XML
  * @return string XML
  */
 function __composeContent($content)
 {
     if (is_string($content)) {
         return $content;
     } elseif (is_array($content)) {
         $out = '';
         $keys = array_keys($content);
         $count = count($keys);
         for ($i = 0; $i < $count; $i++) {
             if (is_numeric($keys[$i])) {
                 $out .= $this->__composeContent($content[$keys[$i]]);
             } elseif (is_array($content[$keys[$i]])) {
                 $attr = $child = array();
                 if (Set::countDim($content[$keys[$i]]) >= 2) {
                 } else {
                 }
                 //$out .= $this->elem($keys[$i]
             }
         }
         return $out;
     } elseif (is_object($content) && (is_a($content, 'XMLNode') || is_a($content, 'xmlnode'))) {
         return $content->toString();
     } elseif (is_object($content) && method_exists($content, 'toString')) {
         return $content->toString();
     } elseif (is_object($content) && method_exists($content, 'toString')) {
         return $content->toString();
     } else {
         return $content;
     }
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:36,代码来源:xml.php

示例12: _startFixture

 function _startFixture($name, $data)
 {
     $model = $this->{$name};
     if ($model->actsAs && in_array('Tree', $model->actsAs)) {
         $model->Behaviors->detach('Tree');
     }
     foreach ($data as $key => $value) {
         if (preg_match("/^repeat-([0-9]+)\$/", $key, $matches)) {
             for ($i = 1; $i <= $matches[1]; $i++) {
                 $data[] = $value;
             }
             unset($data[$key]);
             continue;
         }
     }
     $id = 0;
     $created = array();
     foreach ($data as $ri => $r) {
         $id++;
         $records = array();
         if (!array_key_exists('id', $r)) {
             $schema = $model->schema('id');
             if ($schema && $schema['type'] == 'string' && $schema['length'] == 36) {
                 $records['id'] = String::uuid();
             } else {
                 $records['id'] = $id;
             }
         }
         foreach ($r as $fi => $f) {
             $class = Inflector::classify($fi);
             if (isset($model->{$class})) {
                 if (is_array($f)) {
                     if (Set::countDim($f) > 1) {
                         foreach ($f as $i => $v) {
                             $f[$i][$model->hasMany[$class]['foreignKey']] = $records['id'];
                         }
                     } else {
                         $f[$model->hasMany[$class]['foreignKey']] = $records['id'];
                         $f = array($f);
                     }
                     foreach ($this->_startFixture($class, $f) as $i => $v) {
                         unset($v['id']);
                         $this->data[$class][] = $v;
                     }
                 } else {
                     $records[$fi] = '.RANDOM';
                 }
             } else {
                 $records[$fi] = $this->_formatColumn($fi, $f);
             }
         }
         if (isset($model->_schema['created']) && !array_key_exists('created', $records)) {
             $records['created'] = date('Y-m-d H:i:s');
         }
         $created[$ri] = $records;
     }
     return $created;
 }
开发者ID:joelmoss,项目名称:cakephp-db-migrations,代码行数:58,代码来源:populate.php

示例13: set

 /**
  * This function does two things: 1) it scans the array $one for the primary key,
  * and if that's found, it sets the current id to the value of $one[id].
  * For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object.
  * 2) Returns an array with all of $one's keys and values.
  * (Alternative indata: two strings, which are mangled to
  * a one-item, two-dimensional array using $one for a key and $two as its value.)
  *
  * @param mixed $one Array or string of data
  * @param string $two Value string for the alternative indata method
  * @return unknown
  */
 function set($one, $two = null)
 {
     if (is_object($one)) {
         $one = Set::reverse($one);
     }
     if (is_array($one)) {
         if (Set::countDim($one) == 1) {
             $data = array($this->name => $one);
         } else {
             $data = $one;
         }
     } else {
         $data = array($this->name => array($one => $two));
     }
     foreach ($data as $n => $v) {
         if (is_array($v)) {
             foreach ($v as $x => $y) {
                 if (empty($this->whitelist) || (in_array($x, $this->whitelist) || $n !== $this->name)) {
                     if (isset($this->validationErrors[$x])) {
                         unset($this->validationErrors[$x]);
                     }
                     if ($n == $this->name || is_array($y)) {
                         if ($x === $this->primaryKey) {
                             $this->id = $y;
                         }
                         $this->data[$n][$x] = $y;
                     }
                 }
             }
         }
     }
     return $data;
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:45,代码来源:model.php

示例14: set

 /**
  * This function does two things: 1) it scans the array $one for the primary key,
  * and if that's found, it sets the current id to the value of $one[id].
  * For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object.
  * 2) Returns an array with all of $one's keys and values.
  * (Alternative indata: two strings, which are mangled to
  * a one-item, two-dimensional array using $one for a key and $two as its value.)
  *
  * @param mixed $one Array or string of data
  * @param string $two Value string for the alternative indata method
  * @return array Data with all of $one's keys and values
  * @access public
  */
 function set($one, $two = null)
 {
     if (!$one) {
         return;
     }
     if (is_object($one)) {
         $one = Set::reverse($one);
     }
     if (is_array($one)) {
         if (Set::countDim($one) == 1) {
             $data = array($this->alias => $one);
         } else {
             $data = $one;
         }
     } else {
         $data = array($this->alias => array($one => $two));
     }
     foreach ($data as $n => $v) {
         if (is_array($v)) {
             foreach ($v as $x => $y) {
                 if (isset($this->validationErrors[$x])) {
                     unset($this->validationErrors[$x]);
                 }
                 if ($n === $this->alias) {
                     if ($x === $this->primaryKey) {
                         $this->id = $y;
                     }
                 }
                 if (is_array($y) || is_object($y)) {
                     $y = $this->deconstruct($x, $y);
                 }
                 $this->data[$n][$x] = $y;
             }
         }
     }
     return $data;
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:50,代码来源:model.php

示例15: _processValidationRules

 /**
  * Process a validation rule for a field and looks for a message to be added
  * to the translation map
  *
  * @param string $field the name of the field that is being processed
  * @param array $rules the set of validation rules for the field
  * @param string $file the file name where this validation rule was found
  * @param string $domain default domain to bind the validations to
  * @return void
  */
 protected function _processValidationRules($field, $rules, $file, $domain)
 {
     if (is_array($rules)) {
         $dims = Set::countDim($rules);
         if ($dims == 1 || $dims == 2 && isset($rules['message'])) {
             $rules = array($rules);
         }
         foreach ($rules as $rule => $validateProp) {
             $message = null;
             if (isset($validateProp['message'])) {
                 if (is_array($validateProp['message'])) {
                     $message = $validateProp['message'][0];
                 } else {
                     $message = $validateProp['message'];
                 }
             } elseif (is_string($rule)) {
                 $message = $rule;
             }
             if ($message) {
                 $this->_strings[$domain][$message][$file][] = 'validation for field ' . $field;
             }
         }
     }
 }
开发者ID:kevguy,项目名称:Auth-Website,代码行数:34,代码来源:ExtractTask.php


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