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


PHP Set::diff方法代码示例

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


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

示例1: isUpToDate

 /**
  * Verifica se os menus do banco estão atualizados com os do arquivo
  * @param $aDados- array de menus do banco
  * @return boolean
  */
 public function isUpToDate($aDados)
 {
     $aDados = Set::combine($aDados, "/Menu/id", "/Menu");
     App::import("Xml");
     App::import("Folder");
     App::import("File");
     $sCaminhosArquivos = Configure::read("Cms.CheckPoint.menus");
     $oFolder = new Folder($sCaminhosArquivos);
     $aConteudo = $oFolder->read();
     $aArquivos = Set::sort($aConteudo[1], "{n}", "desc");
     if (empty($aArquivos)) {
         return false;
     }
     $oFile = new File($sCaminhosArquivos . $aArquivos[0]);
     $oXml = new Xml($oFile->read());
     $aAntigo = $oXml->toArray();
     foreach ($aDados as &$aMenu) {
         $aMenu['Menu']['content'] = str_replace("\r\n", " ", $aMenu['Menu']['content']);
     }
     if (isset($aAntigo["menus"])) {
         $aAntigo["Menus"] = $aAntigo["menus"];
         unset($aAntigo["menus"]);
     }
     if (isset($aAntigo["Menus"])) {
         $aAntigo = Set::combine($aAntigo["Menus"], "/Menu/id", "/Menu");
         $aRetorno = Set::diff($aDados, $aAntigo);
     }
     return empty($aRetorno);
 }
开发者ID:niltonfelipe,项目名称:e-cidade_transparencia,代码行数:34,代码来源:check_point.php

示例2: getThemes

 /**
  * Find all themes in the webroot themed directory
  *
  * @return array
  * 
  */
 function getThemes()
 {
     $themed_dir = WWW_ROOT . 'themed' . DS;
     $filter = array('.', '..');
     $themes = scandir($themed_dir);
     $themes = Set::diff($filter, $themes);
     $themes = array_combine($themes, $themes);
     return $themes;
 }
开发者ID:sambernard,项目名称:wildflower,代码行数:15,代码来源:setting.php

示例3: admin_mysql

 public function admin_mysql()
 {
     $User = ClassRegistry::init('Users.User');
     $globalVars = $User->query('show global variables');
     $globalVars = array_combine(Set::extract('/VARIABLES/Variable_name', $globalVars), Set::extract('/VARIABLES/Value', $globalVars));
     $localVars = $User->query('show variables');
     $localVars = array_combine(Set::extract('/VARIABLES/Variable_name', $localVars), Set::extract('/VARIABLES/Value', $localVars));
     $localVars = Set::diff($localVars, $globalVars);
     $this->set(compact('globalVars', 'localVars'));
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:10,代码来源:DatabasesController.php

示例4: getThemes

 /**
  * Find all themes in the webroot themed directory
  *
  * @return array
  * 
  */
 function getThemes()
 {
     $themed_dir = APP . 'views' . DS . 'themed' . DS;
     $filter = array('.', '..');
     $themes = @scandir($themed_dir);
     if (!$themes) {
         return false;
     }
     $themes = Set::diff($filter, $themes);
     $themes = array_combine($themes, $themes);
     return $themes;
 }
开发者ID:uuking,项目名称:wildflower,代码行数:18,代码来源:setting.php

示例5: paginate

 /**
  * Handles automatic pagination of model records.
  *
  * @param mixed $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel')
  * @param mixed $scope Additional find conditions to use while paginating
  * @param array $whitelist List of allowed fields for ordering.  This allows you to prevent ordering 
  *   on non-indexed, or undesirable columns.
  * @return array Model query results
  */
 public function paginate($object = null, $scope = array(), $whitelist = array())
 {
     if (is_array($object)) {
         $whitelist = $scope;
         $scope = $object;
         $object = null;
     }
     $object = $this->_getObject($object);
     if (!is_object($object)) {
         throw new MissingModelException($object);
     }
     $class = get_class($object);
     $options = $this->mergeOptions($class);
     $options = $this->validateSort($object, $options, $whitelist);
     $options = $this->checkLimit($options);
     $conditions = $fields = $order = $limit = $page = null;
     if (!isset($options['conditions'])) {
         $options['conditions'] = array();
     }
     $type = 'all';
     if (isset($options[0])) {
         $type = $options[0];
         unset($options[0]);
     }
     extract($options);
     if (is_array($scope) && !empty($scope)) {
         $conditions = array_merge($conditions, $scope);
     } elseif (is_string($scope)) {
         $conditions = array($conditions, $scope);
     }
     $extra = array_intersect_key($options, compact('conditions', 'fields', 'order', 'limit', 'page'));
     if (intval($page) < 1) {
         $page = 1;
     }
     $page = $options['page'] = (int) $page;
     $parameters = compact('conditions', 'fields', 'order', 'limit', 'page');
     $results = $class::find($type, array_merge($parameters, $extra));
     $defaults = $this->getDefaults(get_class($object));
     unset($defaults[0]);
     $count = $results->count(false);
     $pageCount = intval(ceil($count / $limit));
     $paging = array('page' => $page, 'current' => count($results), 'count' => $count, 'prevPage' => $page > 1, 'nextPage' => $count > $page * $limit, 'pageCount' => $pageCount, 'order' => $order, 'limit' => $limit, 'options' => Set::diff($options, $defaults), 'paramType' => $options['paramType']);
     if (!isset($this->Controller->request['paging'])) {
         $this->Controller->request['paging'] = array();
     }
     $this->Controller->request['paging'] = array_merge((array) $this->Controller->request['paging'], array($class => $paging));
     if (!in_array('Paginator', $this->Controller->helpers) && !array_key_exists('Paginator', $this->Controller->helpers)) {
         $this->Controller->helpers[] = 'Paginator';
     }
     return $results;
 }
开发者ID:beyondkeysystem,项目名称:MongoCake,代码行数:60,代码来源:DocumentPaginatorComponent.php

示例6: afterSave

 public function afterSave(Model $Model, $created)
 {
     $User = ClassRegistry::init('User');
     $currentUser = null;
     if ($User->hasMethod('getCurrentUser')) {
         $currentUser = $User->getCurrentUser();
     }
     $data = $Model->find('first', array('conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id), 'recursive' => -1));
     $derivative[$Model->alias] = !empty($data) ? $data[$Model->alias] : array();
     $log = array('Log' => array('action' => $created ? 'created' : 'modified', 'diff' => json_encode(array($Model->alias => Set::diff($this->_original[$Model->alias], $derivative[$Model->alias]))), 'model' => $Model->alias, 'model_id' => $Model->id, 'user_id' => $currentUser ? $currentUser[$User->primaryKey] : ''));
     $Log = ClassRegistry::init('History.Log');
     $Log->create();
     $Log->save($log);
 }
开发者ID:tsmsogn,项目名称:History,代码行数:14,代码来源:LogBehavior.php

示例7: _reset

 function _reset($sets = null, $unsets = null)
 {
     unset($this->Controller);
     $this->Controller = new AliasComponentTestController();
     if ($unsets !== null) {
         if ($unsets === true) {
             $this->Controller->components = array();
         } else {
             $components = Set::normalize($this->Controller->components);
             $this->Controller->components = Set::diff($components, array_flip((array) $unsets));
         }
     }
     if ($sets !== null) {
         $this->Controller->components = Set::merge($this->Controller->components, $sets);
     }
     $this->Controller->constructClasses();
     $this->Controller->Component->initialize($this->Controller);
     $this->Controller->beforeFilter();
 }
开发者ID:hiromi2424,项目名称:hack_plugin,代码行数:19,代码来源:alias.test.php

示例8: mapRouteElements

 /**
  * Maps a URL array onto a route and returns the string result, or false if no match
  *
  * @param array $route Route Route
  * @param array $url URL URL to map
  * @return mixed Result (as string) or false if no match
  * @access public
  * @static
  */
 function mapRouteElements($route, $url)
 {
     $_this =& Router::getInstance();
     if (isset($route[3]['prefix'])) {
         $prefix = $route[3]['prefix'];
         unset($route[3]['prefix']);
     }
     $pass = array();
     $defaults = $route[3];
     $routeParams = $route[2];
     $params = Set::diff($url, $defaults);
     foreach ($params as $key => $value) {
         if (is_int($key)) {
             $pass[] = $value;
             unset($params[$key]);
         }
     }
     list($named, $params) = $_this->getNamedElements($params);
     if (!strpos($route[0], '*') && (!empty($pass) || !empty($named))) {
         return false;
     }
     $urlKeys = array_keys($url);
     $paramsKeys = array_keys($params);
     $defaultsKeys = array_keys($defaults);
     if (!empty($params)) {
         if (array_diff($paramsKeys, $routeParams) != array()) {
             return false;
         }
         $required = array_diff($defaultsKeys, $urlKeys);
     }
     $isFilled = true;
     if (!empty($routeParams)) {
         $filled = array_intersect_key($url, array_combine($routeParams, array_keys($routeParams)));
         $isFilled = array_diff($routeParams, array_keys($filled)) == array();
         if (!$isFilled && empty($params)) {
             return false;
         }
     }
     if (empty($params)) {
         return Router::__mapRoute($route, am($url, compact('pass', 'named', 'prefix')));
     } elseif (!empty($routeParams) && !empty($route[3])) {
         if (!empty($required)) {
             return false;
         }
         foreach ($params as $key => $val) {
             if (!isset($url[$key]) || $url[$key] != $val || (!isset($defaults[$key]) || $defaults[$key] != $val) && !in_array($key, $routeParams)) {
                 return false;
             }
         }
     } else {
         if (empty($required) && $defaults['plugin'] == $url['plugin'] && $defaults['controller'] == $url['controller'] && $defaults['action'] == $url['action']) {
             return Router::__mapRoute($route, am($url, compact('pass', 'named', 'prefix')));
         }
         return false;
     }
     if (!empty($route[4])) {
         foreach ($route[4] as $key => $reg) {
             if (array_key_exists($key, $url) && !preg_match('/' . $reg . '/', $url[$key])) {
                 return false;
             }
         }
     }
     return Router::__mapRoute($route, am($filled, compact('pass', 'named', 'prefix')));
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:73,代码来源:router.php

示例9: controller_hash_file_is_out_of_sync

 public function controller_hash_file_is_out_of_sync()
 {
     if ($this->check_controller_hash_tmp_file()) {
         $stored_controller_hashes = $this->get_stored_controllers_hashes();
         $current_controller_hashes = $this->get_current_controllers_hashes();
         /*
          * Check what controllers have changed
          */
         $updated_controllers = array_keys(Set::diff($current_controller_hashes, $stored_controller_hashes));
         return !empty($updated_controllers);
     }
 }
开发者ID:magooemp,项目名称:eramba,代码行数:12,代码来源:AclManagerComponent.php

示例10: _diff_dotpaths

 function _diff_dotpaths($key_dotpath, $lock_dotpath)
 {
     $DiffSet = array();
     $KeySet = explode('.', $key_dotpath);
     $LockSet = explode('.', $lock_dotpath);
     $depth_delta = count($KeySet) - count($LockSet);
     if ($depth_delta > 0) {
         foreach (range(1, $depth_delta) as $n) {
             $LockSet[] = $LockSet[count($LockSet) - 1] == '*' ? '*' : '!';
         }
     }
     $SetDiff = Set::diff($KeySet, $LockSet);
     if ($SetDiff) {
         foreach ($KeySet as $n => $x) {
             if (isset($SetDiff[$n]) && $LockSet[$n] != '*') {
                 $DiffSet[$n] = $x;
             }
         }
     }
     return $DiffSet;
 }
开发者ID:areisv,项目名称:cakewell,代码行数:21,代码来源:auth.php

示例11: indexOf

 function indexOf($condition, $start = 0)
 {
     if (!is_array($condition)) {
         $condition = array('id' => $condition);
     }
     if (!empty($condition)) {
         $i = $start;
         foreach ($this->data['products'] as $index => $product) {
             $product = array_intersect_key($product, $condition);
             if (!count(Set::diff($condition, $product))) {
                 return $index;
             }
             $i++;
         }
     }
     return -1;
 }
开发者ID:kevthunder,项目名称:cake-shop,代码行数:17,代码来源:cart_maker.php

示例12: mapRouteElements

 /**
  * Maps a URL array onto a route and returns the string result, or false if no match
  *
  * @param array $route Route Route
  * @param array $url URL URL to map
  * @return mixed Result (as string) or false if no match
  * @access public
  * @static
  */
 function mapRouteElements($route, $url)
 {
     if (isset($route[3]['prefix'])) {
         $prefix = $route[3]['prefix'];
         unset($route[3]['prefix']);
     }
     $pass = array();
     $defaults = $route[3];
     $routeParams = $route[2];
     $params = Set::diff($url, $defaults);
     $urlInv = array_combine(array_values($url), array_keys($url));
     $i = 0;
     while (isset($defaults[$i])) {
         if (isset($urlInv[$defaults[$i]])) {
             if (!in_array($defaults[$i], $url) && is_int($urlInv[$defaults[$i]])) {
                 return false;
             }
             unset($urlInv[$defaults[$i]], $defaults[$i]);
         } else {
             return false;
         }
         $i++;
     }
     foreach ($params as $key => $value) {
         if (is_int($key)) {
             $pass[] = $value;
             unset($params[$key]);
         }
     }
     list($named, $params) = Router::getNamedElements($params);
     if (!strpos($route[0], '*') && (!empty($pass) || !empty($named))) {
         return false;
     }
     $urlKeys = array_keys($url);
     $paramsKeys = array_keys($params);
     $defaultsKeys = array_keys($defaults);
     if (!empty($params)) {
         if (array_diff($paramsKeys, $routeParams) != array()) {
             return false;
         }
         $required = array_values(array_diff($routeParams, $urlKeys));
         $reqCount = count($required);
         for ($i = 0; $i < $reqCount; $i++) {
             if (array_key_exists($required[$i], $defaults) && $defaults[$required[$i]] === null) {
                 unset($required[$i]);
             }
         }
     }
     $isFilled = true;
     if (!empty($routeParams)) {
         $filled = array_intersect_key($url, array_combine($routeParams, array_keys($routeParams)));
         $isFilled = array_diff($routeParams, array_keys($filled)) === array();
         if (!$isFilled && empty($params)) {
             return false;
         }
     }
     if (empty($params)) {
         return Router::__mapRoute($route, array_merge($url, compact('pass', 'named', 'prefix')));
     } elseif (!empty($routeParams) && !empty($route[3])) {
         if (!empty($required)) {
             return false;
         }
         foreach ($params as $key => $val) {
             if (!isset($url[$key]) || $url[$key] != $val || (!isset($defaults[$key]) || $defaults[$key] != $val) && !in_array($key, $routeParams)) {
                 if (!isset($defaults[$key])) {
                     continue;
                 }
                 return false;
             }
         }
     } else {
         if (empty($required) && $defaults['plugin'] === $url['plugin'] && $defaults['controller'] === $url['controller'] && $defaults['action'] === $url['action']) {
             return Router::__mapRoute($route, array_merge($url, compact('pass', 'named', 'prefix')));
         }
         return false;
     }
     if (!empty($route[4])) {
         foreach ($route[4] as $key => $reg) {
             if (array_key_exists($key, $url) && !preg_match('#' . $reg . '#', $url[$key])) {
                 return false;
             }
         }
     }
     return Router::__mapRoute($route, array_merge($filled, compact('pass', 'named', 'prefix')));
 }
开发者ID:codegooglecom,项目名称:ypanel,代码行数:94,代码来源:router.php

示例13: queryAssociation


//.........这里部分代码省略.........
             }
             if (!empty($fetch) && is_array($fetch)) {
                 if ($recursive > 0) {
                     foreach ($linkModel->__associations as $type1) {
                         foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
                             $deepModel =& $linkModel->{$assoc1};
                             $tmpStack = $stack;
                             $tmpStack[] = $assoc1;
                             if ($linkModel->useDbConfig === $deepModel->useDbConfig) {
                                 $db =& $this;
                             } else {
                                 $db =& ConnectionManager::getDataSource($deepModel->useDbConfig);
                             }
                             $db->queryAssociation($linkModel, $deepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack);
                         }
                     }
                 }
             }
             return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel, $recursive);
         } elseif ($type === 'hasAndBelongsToMany') {
             $ins = $fetch = array();
             for ($i = 0; $i < $count; $i++) {
                 if ($in = $this->insertQueryData('{$__cakeID__$}', $resultSet[$i], $association, $assocData, $model, $linkModel, $stack)) {
                     $ins[] = $in;
                 }
             }
             $foreignKey = $model->hasAndBelongsToMany[$association]['foreignKey'];
             $joinKeys = array($foreignKey, $model->hasAndBelongsToMany[$association]['associationForeignKey']);
             list($with, $habtmFields) = $model->joinModel($model->hasAndBelongsToMany[$association]['with'], $joinKeys);
             $habtmFieldsCount = count($habtmFields);
             if (!empty($ins)) {
                 $fetch = array();
                 $ins = array_chunk($ins, 1000);
                 foreach ($ins as $i) {
                     $q = str_replace('{$__cakeID__$}', '(' . join(', ', $i) . ')', $query);
                     $q = str_replace('= (', 'IN (', $q);
                     $q = str_replace('  WHERE 1 = 1', '', $q);
                     $q = $this->insertQueryData($q, null, $association, $assocData, $model, $linkModel, $stack);
                     if ($q != false) {
                         $res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
                         $fetch = array_merge($fetch, $res);
                     }
                 }
             }
         }
         for ($i = 0; $i < $count; $i++) {
             $row =& $resultSet[$i];
             if ($type !== 'hasAndBelongsToMany') {
                 $q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack);
                 if ($q != false) {
                     $fetch = $this->fetchAll($q, $model->cacheQueries, $model->alias);
                 } else {
                     $fetch = null;
                 }
             }
             if (!empty($fetch) && is_array($fetch)) {
                 if ($recursive > 0) {
                     foreach ($linkModel->__associations as $type1) {
                         foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
                             $deepModel =& $linkModel->{$assoc1};
                             if ($type1 === 'belongsTo' || $deepModel->alias === $model->alias && $type === 'belongsTo' || $deepModel->alias != $model->alias) {
                                 $tmpStack = $stack;
                                 $tmpStack[] = $assoc1;
                                 if ($linkModel->useDbConfig == $deepModel->useDbConfig) {
                                     $db =& $this;
                                 } else {
                                     $db =& ConnectionManager::getDataSource($deepModel->useDbConfig);
                                 }
                                 $db->queryAssociation($linkModel, $deepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack);
                             }
                         }
                     }
                 }
                 if ($type == 'hasAndBelongsToMany') {
                     $merge = array();
                     foreach ($fetch as $j => $data) {
                         if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) {
                             if ($habtmFieldsCount > 2) {
                                 $merge[] = $data;
                             } else {
                                 $merge[] = Set::diff($data, array($with => $data[$with]));
                             }
                         }
                     }
                     if (empty($merge) && !isset($row[$association])) {
                         $row[$association] = $merge;
                     } else {
                         $this->__mergeAssociation($resultSet[$i], $merge, $association, $type);
                     }
                 } else {
                     $this->__mergeAssociation($resultSet[$i], $fetch, $association, $type);
                 }
                 $resultSet[$i][$association] = $linkModel->afterfind($resultSet[$i][$association]);
             } else {
                 $tempArray[0][$association] = false;
                 $this->__mergeAssociation($resultSet[$i], $tempArray, $association, $type);
             }
         }
     }
 }
开发者ID:jerzzz777,项目名称:cake-cart,代码行数:101,代码来源:dbo_oracle.php

示例14: get_missing_acos

 /**
  * Get a list of plugins, controllers and actions that don't have any corresponding ACO.
  * To run faster, the method only checks controllers that have not already been checked or that have been modified.
  *
  * Depending on the $update_hash_file, the method may return the missing ACOs only once
  * (in order to show the alert message only once in the view)
  *
  * @param boolean $update_hash_file If true, the method update the controller hash file, making the method returning missing ACOs only once
  * @return array Array of missing ACO nodes by comparing with each existing plugin, controller and action
  */
 public function get_missing_acos($update_hash_file = true)
 {
     if ($this->check_controller_hash_tmp_file()) {
         $missing_aco_nodes = array();
         $stored_controller_hashes = $this->get_stored_controllers_hashes();
         $current_controller_hashes = $this->get_current_controllers_hashes();
         /*
          * Store current controllers hashes on disk
          */
         if ($update_hash_file) {
             $file = new File($this->controllers_hash_file);
             $file->write(serialize($current_controller_hashes));
         }
         /*
          * Check what controllers have changed
          */
         $updated_controllers = array_keys(Set::diff($current_controller_hashes, $stored_controller_hashes));
         if (!empty($updated_controllers)) {
             $aco =& $this->Acl->Aco;
             foreach ($updated_controllers as $controller_name) {
                 $controller_classname = $this->AclReflector->get_controller_classname($controller_name);
                 $methods = $this->AclReflector->get_controller_actions($controller_classname);
                 $aco =& $this->Acl->Aco;
                 foreach ($methods as $method) {
                     $methodNode = $aco->node('controllers/' . $controller_name . '/' . $method);
                     if (empty($methodNode)) {
                         $missing_aco_nodes[] = $controller_name . '/' . $method;
                     }
                 }
             }
         }
         return $missing_aco_nodes;
     }
 }
开发者ID:ambagasdowa,项目名称:kml,代码行数:44,代码来源:acl_manager.php

示例15: diffRecords

 /**
  * Computa as alterações no registro e retorna um array formatado
  * com os valores antigos e novos
  *
  * 'campo' => array('old' => valor antigo, 'new' => valor novo)
  *
  * @param array $old
  * @param array $new
  *
  * @return array $formatted
  */
 private function diffRecords($old, $new)
 {
     $diff = Set::diff($old, $new);
     $formatted = array();
     foreach ($diff as $key => $value) {
         if (!isset($old[$key]) || !isset($new[$key])) {
             continue;
         }
         $formatted[$key] = array('old' => $old[$key], 'new' => $new[$key]);
     }
     return $formatted;
 }
开发者ID:radig,项目名称:auditable,代码行数:23,代码来源:AuditableBehavior.php


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