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


PHP Hash::numeric方法代码示例

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


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

示例1: setup

 public function setup(Model $Model, $config = array())
 {
     $config = (array) $config;
     if (Hash::numeric($config) && isset($config[0])) {
         $config = array('on' => $config[0]);
     }
     $this->settings[$Model->alias] = array_merge($this->_defaults, $config);
 }
开发者ID:gourmet,项目名称:security,代码行数:8,代码来源:ReviewableBehavior.php

示例2: getTranslationFields

 /**
  * Get field names for Translation
  *
  * @param object $model
  * @return array
  * @access public
  */
 public function getTranslationFields(Model $model)
 {
     if (Hash::numeric(array_keys($this->translationFields[$model->alias]))) {
         return $this->translationFields[$model->alias];
     } else {
         return array_keys($this->translationFields[$model->alias]);
     }
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:15,代码来源:KonstruktorTranslateBehavior.php

示例3: setup

 /**
  * {@inheritdoc}
  */
 public function setup(Model $Model, $config = array())
 {
     if (!empty($config) && (!array_key_exists('fields', (array) $config) && Hash::numeric((array) array_keys($config)))) {
         $config = array('fields' => Hash::normalize($config));
     }
     $this->settings[$Model->alias] = array_merge($this->_defaults, $config);
     $this->bindSecurityToken($Model);
 }
开发者ID:gourmet,项目名称:security,代码行数:11,代码来源:TokenizableBehavior.php

示例4: _prepareMeta

 /**
  * Protected method for MetaBehavior::prepareData()
  *
  * @param Model $model
  * @param array $data
  * @return array
  */
 protected function _prepareMeta($data)
 {
     if (isset($data['Meta']) && is_array($data['Meta']) && count($data['Meta']) > 0 && !Hash::numeric(array_keys($data['Meta']))) {
         $meta = $data['Meta'];
         $data['Meta'] = array();
         $i = 0;
         foreach ($meta as $metaArray) {
             $data['Meta'][$i] = $metaArray;
             $i++;
         }
     }
     return $data;
 }
开发者ID:saydulk,项目名称:croogo,代码行数:20,代码来源:MetaBehavior.php

示例5: getDenormalizedFields

 /**
  * Get Denormalized Fields
  *
  * @author	Everton Yoshitani <everton@wizehive.com>
  * @since	1.0
  * @param	Model $Model
  * @param	$data Request data to search foreign keys
  * @return	array
  */
 public function getDenormalizedFields(Model $Model, $data = array())
 {
     if (empty($Model->_denormalized_fields)) {
         return false;
     }
     $denormalized_fields = array();
     foreach ($Model->_denormalized_fields as $denormalized_field => $settings) {
         if (is_callable($settings) && is_object($settings) && $settings instanceof Closure) {
             $settings = $settings($data);
         }
         if (empty($settings)) {
             continue;
         }
         if (!Hash::numeric(array_keys($settings))) {
             $settings = array($settings);
         }
         $values = array();
         $last = count($settings) - 1;
         foreach ($settings as $index => $set) {
             if (empty($set['field']) || empty($set['conditions']) || !is_array($set['conditions'])) {
                 continue;
             }
             if (strpos($set['field'], '.')) {
                 list(, $field_name) = explode('.', $set['field']);
             } else {
                 $field_name = $set['field'];
             }
             $field_conditions = array();
             foreach ($set['conditions'] as $field => $value) {
                 if (!is_string($field)) {
                     continue;
                 }
                 $field_model = $Model->alias;
                 if (strpos($field, '.') !== false) {
                     list($field_model, $field) = explode('.', $field);
                 }
                 if ($field_model === $Model->alias) {
                     $modelObject = $Model;
                 } elseif (isset($Model->{$field_model})) {
                     $modelObject = $Model->{$field_model};
                 } else {
                     $modelObject = ClassRegistry::init($field_model);
                 }
                 $value_model = $Model->alias;
                 if (strpos($value, '.') !== false) {
                     list($value_model, $value) = explode('.', $value);
                 }
                 if ($value_model === $Model->alias && !empty($data[$value])) {
                     $value = $data[$value];
                 } elseif ($value_model !== $Model->alias && !empty($values[$value_model . '.' . $value])) {
                     $value = $values[$value_model . '.' . $value];
                 }
                 $field_conditions[] = array($field_model . '.' . $field => $value);
             }
             $field_value = $modelObject->field($field_name, $field_conditions);
             if ($index !== $last && empty($field_value)) {
                 continue 3;
             } elseif ($index === $last) {
                 $denormalized_fields[$denormalized_field] = $field_value;
             } else {
                 $values[$set['field']] = $field_value;
             }
         }
     }
     return $denormalized_fields;
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:75,代码来源:ApiBehavior.php

示例6: afterFind

 /**
  * afterFind Callback
  *
  * @param array $results
  * @param boolean $primary
  * @return array Modified results
  * @access public
  */
 public function afterFind(Model $model, $results, $primary)
 {
     $locale = $this->_getLocale($model);
     if (empty($locale) || empty($results)) {
         return $results;
     }
     $fields = $this->getTranslationFields($model);
     $RuntimeModel = $this->translateModel($model);
     if ($primary && isset($results[0][$model->alias])) {
         $i = 0;
         foreach ($results as $result) {
             if (!isset($result[$model->alias][$model->primaryKey])) {
                 continue;
             }
             $translations = $RuntimeModel->find('all', array('conditions' => array($RuntimeModel->alias . '.model' => $model->alias, $RuntimeModel->alias . '.foreign_key' => $result[$model->alias][$model->primaryKey], $RuntimeModel->alias . '.field' => $fields)));
             foreach ($translations as $translation) {
                 $field = $translation[$RuntimeModel->alias]['field'];
                 // Original row
                 /*if (isset($results[$i][$model->alias][$field])) {
                 			$results[$i][$field.'Original'] = $results[$i][$model->alias][$field];
                 		}*/
                 // Translated row
                 if ($translation[$RuntimeModel->alias]['locale'] == $locale && isset($results[$i][$model->alias][$field])) {
                     $results[$i][$model->alias][$field] = $translation[$RuntimeModel->alias]['content'];
                 }
                 // Other translations
                 if (!Hash::numeric(array_keys($this->translationFields[$model->alias])) && isset($results[$i][$model->alias][$field])) {
                     if (!isset($results[$i][$field . 'Translation'])) {
                         $results[$i][$field . 'Translation'] = array();
                     }
                     $results[$i][$field . 'Translation'][] = $translation[$RuntimeModel->alias];
                 }
             }
             $i++;
         }
     }
     return $results;
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:46,代码来源:CroogoTranslateBehavior.php

示例7: numeric

 /**
  * Checks to see if all the values in the array are numeric
  *
  * @param array $array The array to check.  If null, the value of the current Set object
  * @return boolean true if values are numeric, false otherwise
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::numeric
  */
 public static function numeric($array = null)
 {
     return Hash::numeric($array);
 }
开发者ID:aichelman,项目名称:StudyUp,代码行数:11,代码来源:Set.php

示例8: testNumeric

 /**
  * testNumericArrayCheck method
  *
  * @return void
  */
 public function testNumeric()
 {
     $data = array('one');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array(1 => 'one');
     $this->assertFalse(Hash::numeric($data));
     $data = array('one');
     $this->assertFalse(Hash::numeric($data));
     $data = array('one' => 'two');
     $this->assertFalse(Hash::numeric($data));
     $data = array('one' => 1);
     $this->assertTrue(Hash::numeric($data));
     $data = array(0);
     $this->assertTrue(Hash::numeric($data));
     $data = array('one', 'two', 'three', 'four', 'five');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array('1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five');
     $this->assertTrue(Hash::numeric(array_keys($data)));
     $data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five');
     $this->assertFalse(Hash::numeric(array_keys($data)));
     $data = array(2.4, 1, 0, -1, -2);
     $this->assertTrue(Hash::numeric($data));
 }
开发者ID:yuuicchan0912,项目名称:sample1,代码行数:30,代码来源:HashTest.php

示例9: _filterCustomConditions

 protected function _filterCustomConditions(Model $model, $results, $conditions)
 {
     // Every result has to be checked against the conditions.
     // If it does not meet all conditions it will be removed
     // from the results array.
     if (is_array($results)) {
         // if we have a results list with multiple results we need to check each
         if (TRUE === Hash::numeric(array_keys($results))) {
             foreach ($results as $key => $result) {
                 if (!$this->_meetsConditions($model, $result, $conditions)) {
                     unset($results[$key]);
                 }
             }
         } else {
             if (!$this->_meetsConditions($model, $results, $conditions)) {
                 $results = array();
             }
         }
         return $results;
     }
     return array();
 }
开发者ID:stefanheinen,项目名称:cake-custom-conditions-behavior,代码行数:22,代码来源:CustomConditionsBehavior.php

示例10: afterFind

 /**
  * {@inheritdoc}
  */
 public function afterFind($results, $primary = false)
 {
     if (empty($this->belongsToForeignModels)) {
         return $results;
     }
     // Apply filter to result like:
     // array('model' => 'ForeignModel', 'ForeignModel' => array(..), 'AnotherForeignModel' => array(..))
     if (!empty($results['foreign_model'])) {
         return $this->_filterForeignModels($results, $results['foreign_model']);
     }
     // Skip if result not like array(0 => array(..), 1 => array(..), ...)
     if (!Hash::numeric(array_keys($results))) {
         return $results;
     }
     foreach ($results as $k => $result) {
         // Apply filter to result like:
         // array('Affiliate' => array('model' => 'ForeignModel', 'ForeignModel' => array(..), 'AnotherForeignModel' => array(..)))
         if (!empty($result[$this->alias]) && !empty($result[$this->alias]['foreign_model'])) {
             $results[$k] = $this->_filterForeignModels($result, $result[$this->alias]['foreign_model']);
         }
     }
     return $results;
 }
开发者ID:gourmet,项目名称:common,代码行数:26,代码来源:CommonAppModel.php

示例11: checkPrev

 /**
  * Check previous session data.
  *
  * @param mixed $prev Previous action for check
  * @param array $options
  * @param string $prevAction Previous action to Redirect.
  * @return boolean Success
  */
 public function checkPrev($prev, $options = array(), $prevAction = null)
 {
     // mostly compatible
     if (is_string($options)) {
         $options = array('message' => $options);
     } elseif ($options !== array() && empty($options)) {
         $options = array();
     }
     $options += $this->_filter(compact('prevAction'));
     $defaults = array('message' => $this->messages['prev']);
     extract($options = array_merge($defaults, $options));
     if (is_array($prev) && Hash::numeric(array_keys($prev))) {
         foreach ($prev as $p) {
             if (!$this->checkPrev($p, $options)) {
                 return false;
             }
         }
         return true;
     }
     $check = true;
     if (!is_array($prev)) {
         $prev = array('action' => $prev);
     }
     if ($prevAction === null) {
         $prevAction = $prev;
     }
     if (!$this->Session->check($this->sessionKey($prev))) {
         if ($message !== false) {
             $this->Session->setFlash($message, $this->flashParams['element'], $this->flashParams['params'], $this->flashParams['key']);
         }
         if ($this->autoRedirect) {
             $this->Controller->redirect($prevAction);
         }
         return false;
     }
     return true;
 }
开发者ID:42milez,项目名称:cakephp2-blog-tutorial,代码行数:45,代码来源:TransitionComponent.php

示例12: batchUpdate

 /**
  * Batch Update Resource Data, Filtering by Query String
  * 
  * @author	Wes DeMoney <wes@wizehive.com>
  * @since	1.0
  * @param	array	$this->_data	Array of Resource Indexed Data
  * @param	string	$this->_model	Primary Resource Name
  * @return	boolean 
  */
 public function batchUpdate()
 {
     $data = $this->_data;
     $this->withData();
     $parent_model = $this->_model;
     $this->forModel();
     $passed_conditions = $this->_passed_conditions;
     $this->withPassedConditions();
     $field_exceptions = $this->_field_exceptions;
     $this->withFieldExceptions();
     // Cannot Update Multiple Models
     if (count(array_keys($data)) > 1) {
         $this->setResponseCode(4015);
         return false;
     }
     // Data Should Not Be Indexed
     if (Hash::numeric(array_keys($data[$parent_model]))) {
         $this->setResponseCode(4008);
         return false;
     }
     // Cannot Pass ID
     if (!empty($data[$parent_model]['id'])) {
         $this->setResponseCode(4001);
         return false;
     }
     // Field Map Based Off Read for Querying
     $field_map = $this->withParentModel()->forModel($parent_model)->returnsFieldMap('read');
     $modelObject = $this->Controller->{$parent_model};
     $fields = array();
     if (!empty($field_map)) {
         $fields = $this->forModel($parent_model)->withFieldMap($field_map)->withDataFields($data[$parent_model])->withFieldExceptions($field_exceptions)->returnsFilteredDataFields();
     }
     $field_names = $modelObject->getFieldNames($field_map);
     if (empty($passed_conditions)) {
         $passed_conditions = $this->Query->withFieldMap($field_map)->rendersConditions();
     }
     if (empty($passed_conditions)) {
         $this->setResponseCode(4017);
         return false;
     }
     $conditions = $this->withParentModel()->forModel($parent_model)->withFields($field_names)->withPassedConditions($passed_conditions)->on('update')->rendersConditions();
     if (empty($conditions)) {
         $this->setResponseCode(4017);
         return false;
     }
     // Find IDs of Records to Update
     $ids = $modelObject->find('list', array('conditions' => $conditions, 'fields' => array($parent_model . '.id'), 'contain' => false));
     if (empty($ids)) {
         return true;
     }
     // ID `0` Could Come from Special Cases like FormRecordFolder `Uncategorized`
     if (false !== ($key = array_search(0, $ids))) {
         unset($ids[$key]);
     }
     if (empty($ids)) {
         return true;
     }
     $modelObject->begin();
     foreach ($ids as $id) {
         $modelObject->create(false);
         $modelObject->id = $id;
         $modelObject->set(array($parent_model => $fields));
         // Validation
         if (!$modelObject->validates() || !is_null($this->getIndexValidationErrors())) {
             $validationErrors = $modelObject->validationErrors;
             $modelObject->rollback();
             $this->setResponseCode(4012);
             if (!empty($validationErrors)) {
                 $this->forModel($parent_model)->withFieldMap($field_map)->setValidationErrors($validationErrors);
             }
             return false;
         }
         // Can Update
         if (!$this->Permissions->forModel($parent_model)->canUpdate($id, $fields)) {
             $this->setResponseCode(4013);
             return false;
         }
         $fieldList = array_keys($field_map);
         if (!empty($field_exceptions)) {
             $fieldList = array_merge($fieldList, $field_exceptions);
         }
         // Save Data
         if (!$modelObject->save(array($data), array('fieldList' => $fieldList, 'validate' => false))) {
             $modelObject->rollback();
             $this->setResponseCode(5001);
             return false;
         }
     }
     $modelObject->commit();
     $this->Controller->request->params['paging'][$parent_model]['count'] = count($ids);
     return true;
//.........这里部分代码省略.........
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:101,代码来源:ApiResourceComponent.php

示例13: setup

 /**
  * setup method
  *
  * @param	Model	$Model
  * @param	array	$config
  * @return	void
  */
 public function setup(Model $Model, $config = array())
 {
     $this->settings[$Model->alias] = array_merge(array('consolidated' => true, 'field' => 'bits', 'bits' => array('ALL' => 1), 'disabled' => false, 'mask' => null, 'default' => 1), (array) $config);
     if (empty($this->settings[$Model->alias]['bits'])) {
         $this->disableBitmasked($Model);
     } else {
         if (Hash::numeric(array_keys($this->settings[$Model->alias]['bits']))) {
             $last = 1;
             $bits = array('ALL' => 1);
             foreach ($this->settings[$Model->alias]['bits'] as $flag) {
                 $bits[$flag] = $last = $last * 2;
             }
             $this->settings[$Model->alias]['bits'] = $bits;
         }
     }
 }
开发者ID:jmcneese,项目名称:bitmasked,代码行数:23,代码来源:BitmaskedBehavior.php

示例14: validateHabtmRelation

 /**
  * Validation rule for HABTM relations
  * 
  * @author	Anthony Putignano <anthony@wizehive.com>
  * @since	1.0
  * @param	Model		$Model
  * @param	mixed		$check
  * @return	boolean
  */
 public function validateHabtmRelation(Model $Model, $check = array())
 {
     foreach ($this->__settings[$Model->alias]['fields'] as $field => $settings) {
         if (array_key_exists($field, $check)) {
             $ids = array_shift($check);
             $ids = $this->getHabtmAssociationIdArray($Model, $ids);
             if (!Hash::numeric($ids)) {
                 return false;
             }
             extract($settings);
             if (!isset($Model->{$foreignModel})) {
                 $Model->{$foreignModel} = ClassRegistry::init($foreignModel);
             }
             $relations = array();
             foreach ($ids as $id) {
                 if (array_key_exists($id, $relations)) {
                     return false;
                 }
                 $relations[$id] = true;
                 if (!$Model->{$foreignModel}->exists($id)) {
                     return false;
                 }
             }
             return true;
         }
     }
     return false;
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:37,代码来源:VirtualHabtmBehavior.php

示例15: _serialize

 /**
  * Serialize view vars.
  *
  * @param string|array $serialize The viewVars that need to be serialized.
  * @return string The serialized data
  * @throws RuntimeException When the prefix is not specified
  */
 protected function _serialize($serialize)
 {
     $rootNode = isset($this->viewVars['_rootNode']) ? $this->viewVars['_rootNode'] : 'channel';
     if (is_array($serialize)) {
         $data = array($rootNode => array());
         foreach ($serialize as $alias => $key) {
             if (is_numeric($alias)) {
                 $alias = $key;
             }
             $data[$rootNode][$alias] = $this->viewVars[$key];
         }
     } else {
         $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
         if (is_array($data) && Hash::numeric(array_keys($data))) {
             $data = array($rootNode => array($serialize => $data));
         }
     }
     $defaults = array('document' => array(), 'channel' => array(), 'items' => array());
     $data += $defaults;
     if (!empty($data['document']['namespace'])) {
         foreach ($data['document']['namespace'] as $prefix => $url) {
             $this->setNamespace($prefix, $url);
         }
     }
     $channel = $this->channel($data['channel']);
     if (!empty($channel['image']) && empty($channel['image']['title'])) {
         $channel['image']['title'] = $channel['title'];
     }
     foreach ($data['items'] as $item) {
         $channel['item'][] = $this->_prepareOutput($item);
     }
     $array = array('rss' => array('@version' => $this->version, 'channel' => $channel));
     $namespaces = array();
     foreach ($this->_usedNamespaces as $usedNamespacePrefix) {
         if (!isset($this->_namespaces[$usedNamespacePrefix])) {
             throw new RuntimeException(__('The prefix %s is not specified.', $usedNamespacePrefix));
         }
         $namespaces['xmlns:' . $usedNamespacePrefix] = $this->_namespaces[$usedNamespacePrefix];
     }
     $array['rss'] += $namespaces;
     $options = array();
     if (Configure::read('debug')) {
         $options['pretty'] = true;
     }
     $output = Xml::fromArray($array, $options)->asXML();
     $output = $this->_replaceCdata($output);
     return $output;
 }
开发者ID:Jony01,项目名称:LLD,代码行数:55,代码来源:RssView.php


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