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


PHP Set::pushDiff方法代码示例

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


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

示例1: pushDiff

 /**
  * Pushes the differences in $array2 onto the end of $array
  *
  * @param array $array Original array
  * @param array $array2 Differences to push
  * @return array Combined array
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::pushDiff
  */
 public static function pushDiff($array, $array2)
 {
     if (empty($array) && !empty($array2)) {
         return $array2;
     }
     if (!empty($array) && !empty($array2)) {
         foreach ($array2 as $key => $value) {
             if (!array_key_exists($key, $array)) {
                 $array[$key] = $value;
             } else {
                 if (is_array($value)) {
                     $array[$key] = Set::pushDiff($array[$key], $array2[$key]);
                 }
             }
         }
     }
     return $array;
 }
开发者ID:aichelman,项目名称:StudyUp,代码行数:26,代码来源:Set.php

示例2: __mergeHasMany

 /**
  * mergeHasMany - Merge the results of hasMany relations.
  *
  *
  * @param array $resultSet Data to merge into
  * @param array $merge Data to merge
  * @param string $association Name of Model being Merged
  * @param object $model Model being merged onto
  * @param object $linkModel Model being merged
  * @return void
  */
 function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel)
 {
     foreach ($resultSet as $i => $value) {
         $count = 0;
         $merged[$association] = array();
         foreach ($merge as $j => $data) {
             if (isset($value[$model->alias]) && $value[$model->alias][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
                 if (count($data) > 1) {
                     $data = array_merge($data[$association], $data);
                     unset($data[$association]);
                     foreach ($data as $key => $name) {
                         if (is_numeric($key)) {
                             $data[$association][] = $name;
                             unset($data[$key]);
                         }
                     }
                     $merged[$association][] = $data;
                 } else {
                     $merged[$association][] = $data[$association];
                 }
             }
             $count++;
         }
         if (isset($value[$model->alias])) {
             $resultSet[$i] = Set::pushDiff($resultSet[$i], $merged);
             unset($merged);
         }
     }
 }
开发者ID:sathishkumarb,项目名称:HVMS,代码行数:40,代码来源:dbo_source.php

示例3: reverse

 /**
  * Converts an object into an array
  *
  * @param object $object
  * @return array
  */
 function reverse($object)
 {
     if (is_object($object)) {
         $merge = array();
         if (is_a($object, 'xmlnode') || is_a($object, 'XMLNode')) {
             if ($object->name != Inflector::underscore($this->name)) {
                 if (is_object($object->child(Inflector::underscore($this->name)))) {
                     $object = $object->child(Inflector::underscore($this->name));
                     $object = $object->attributes;
                 } else {
                     return null;
                 }
             }
         } elseif (is_a($object, 'stdclass') || is_a($object, 'stdClass')) {
             $object = get_object_vars($object);
             $keys = array_keys($object);
             $count = count($keys);
             for ($i = 0; $i < $count; $i++) {
                 if ($keys[$i] == '__identity__') {
                     $key = $object[$keys[$i]];
                     unset($object[$keys[$i]]);
                     $object[$key] = $object;
                 } elseif (is_array($object[$keys[$i]])) {
                     $keys1 = array_keys($object[$keys[$i]]);
                     $count1 = count($keys1);
                     for ($ii = 0; $ii < $count1; $ii++) {
                         if (is_object($object[$keys[$i]][$keys1[$ii]])) {
                             $merge[$keys[$i]][$keys1[$ii]] = Set::reverse($object[$keys[$i]][$keys1[$ii]]);
                         } else {
                             $merge[$keys[$i]][$keys1[$ii]] = $object[$keys[$i]][$keys1[$ii]];
                         }
                     }
                     unset($object[$keys[$i]]);
                 } elseif (is_object($object[$keys[$i]])) {
                     $merge[$keys[$i]] = Set::reverse($object[$keys[$i]]);
                     unset($object[$keys[$i]]);
                 }
             }
         }
         $return = $object;
         if (!empty($merge)) {
             $mergeKeys = array_keys($merge);
             $objectKeys = array_keys($object);
             $count = count($mergeKeys);
             $change = $object;
             $count1 = count($objectKeys);
             for ($i = 0; $i < $count; $i++) {
                 $loop = $count1;
                 for ($ii = 0; $ii < $loop; $ii++) {
                     if (is_array($object[$objectKeys[$ii]])) {
                         if (array_key_exists($objectKeys[$ii], $object[$objectKeys[$ii]])) {
                             unset($change[$objectKeys[$ii]][$objectKeys[$ii]]);
                         }
                     } else {
                         unset($change[$objectKeys[$ii]]);
                     }
                 }
                 foreach ($objectKeys as $key => $value) {
                     if (is_array($object[$value])) {
                         if (array_key_exists($mergeKeys[$i], $object[$value])) {
                             unset($change[$value][$mergeKeys[$i]]);
                         }
                     } else {
                         unset($change[$value]);
                     }
                 }
             }
             $object = Set::pushDiff($change, $merge);
         }
         return $object;
     }
 }
开发者ID:sukhjeet81,项目名称:capuchn,代码行数:78,代码来源:set.php

示例4: pushDiff

 /**
  * Pushes the differences in $array2 onto the end of $array
  *
  * @param mixed $array Original array
  * @param mixed $array2 Differences to push
  * @return array Combined array
  * @access public
  */
 function pushDiff($array = null, $array2 = null)
 {
     if ($array2 !== null && is_array($array2)) {
         foreach ($array2 as $key => $value) {
             if (!array_key_exists($key, $array)) {
                 $array[$key] = $value;
             } else {
                 if (is_array($value)) {
                     $array[$key] = Set::pushDiff($array[$key], $array2[$key]);
                 }
             }
         }
         return $array;
     }
     if (!isset($this->value)) {
         $this->value = array();
     }
     $this->value = Set::pushDiff($this->value, Set::__array($array));
     return $this->value;
 }
开发者ID:venka10,项目名称:RUS,代码行数:28,代码来源:set.php

示例5: __validatePost

 /**
  * Validate submitted form
  *
  * @param object $controller Instantiating controller
  * @return bool true if submitted form is valid
  * @access private
  */
 function __validatePost(&$controller)
 {
     if (!empty($controller->data)) {
         if (!isset($controller->data['__Token'])) {
             if (!$this->blackHole($controller, 'auth')) {
                 return null;
             }
         }
         $token = $controller->data['__Token']['key'];
         if ($this->Session->check('_Token')) {
             $tData = unserialize($this->Session->read('_Token'));
             if ($tData['expires'] < time() || $tData['key'] !== $token) {
                 if (!$this->blackHole($controller, 'auth')) {
                     return null;
                 }
             }
         }
         if (!isset($controller->data['__Token']['fields'])) {
             if (!$this->blackHole($controller, 'auth')) {
                 return null;
             }
         }
         $form = $controller->data['__Token']['fields'];
         $check = $controller->data;
         unset($check['__Token']['fields']);
         if (!empty($this->disabledFields)) {
             foreach ($check as $model => $fields) {
                 foreach ($fields as $field => $value) {
                     $key[] = $model . '.' . $field;
                 }
                 unset($field);
             }
             foreach ($this->disabledFields as $value) {
                 $parts = preg_split('/\\/|\\./', $value);
                 if (count($parts) == 1) {
                     $key1[] = $controller->modelClass . '.' . $parts['0'];
                 } elseif (count($parts) == 2) {
                     $key1[] = $parts['0'] . '.' . $parts['1'];
                 }
             }
             foreach ($key1 as $value) {
                 if (in_array($value, $key)) {
                     $remove = explode('.', $value);
                     unset($check[$remove['0']][$remove['1']]);
                     if (empty($check[$remove['0']])) {
                         unset($check[$remove['0']]);
                     }
                 } elseif (in_array('_' . $value, $key)) {
                     $remove = explode('.', $value);
                     $controller->data[$remove['0']][$remove['1']] = $controller->data['_' . $remove['0']][$remove['1']];
                     unset($check['_' . $remove['0']][$remove['1']]);
                     if (empty($check['_' . $remove['0']])) {
                         unset($check['_' . $remove['0']]);
                     }
                 }
             }
         }
         ksort($check);
         foreach ($check as $key => $value) {
             $merge = array();
             if ($key === '__Token') {
                 $field[$key] = $value;
                 continue;
             }
             $string = substr($key, 0, 1);
             if ($string === '_') {
                 $newKey = substr($key, 1);
                 if (!isset($controller->data[$newKey])) {
                     $controller->data[$newKey] = array();
                     if (array_keys($controller->data[$key]) === array($newKey)) {
                         $field[$newKey] = array($newKey);
                     }
                 }
                 if (is_array($value)) {
                     $values = array_values($value);
                     $k = array_keys($value);
                     $count = count($k);
                     if (is_numeric($k[0])) {
                         for ($i = 0; $count > $i; $i++) {
                             foreach ($values[$i] as $key2 => $value1) {
                                 if ($value1 === '0') {
                                     $field[$newKey][$i] = array_merge($field[$newKey][$i], array($key2));
                                 }
                             }
                         }
                         $controller->data[$newKey] = Set::pushDiff($controller->data[$key], $controller->data[$newKey]);
                     }
                     for ($i = 0; $count > $i; $i++) {
                         $field[$key][$k[$i]] = $values[$i];
                     }
                     foreach ($k as $lookup) {
                         if (isset($controller->data[$newKey][$lookup])) {
                             unset($controller->data[$key][$lookup]);
//.........这里部分代码省略.........
开发者ID:subh,项目名称:raleigh-workshop-08,代码行数:101,代码来源:security.php

示例6: _bindTextDomain

 /**
  * Binds the given domain to a file in the specified directory.
  *
  * @param string $domain Domain to bind
  * @return string Domain binded
  */
 protected function _bindTextDomain($domain)
 {
     $this->_noLocale = true;
     $core = true;
     $merge = array();
     $searchPaths = App::path('locales');
     $plugins = CakePlugin::loaded();
     if (!empty($plugins)) {
         foreach ($plugins as $plugin) {
             $pluginDomain = Inflector::underscore($plugin);
             if ($pluginDomain === $domain) {
                 $searchPaths[] = CakePlugin::path($plugin) . 'Locale' . DS;
                 $searchPaths = array_reverse($searchPaths);
                 break;
             }
         }
     }
     foreach ($searchPaths as $directory) {
         foreach ($this->l10n->languagePath as $lang) {
             $localeDef = $directory . $lang . DS . $this->category;
             if (is_file($localeDef)) {
                 $definitions = self::loadLocaleDefinition($localeDef);
                 if ($definitions !== false) {
                     $this->_domains[$domain][$this->_lang][$this->category] = self::loadLocaleDefinition($localeDef);
                     $this->_noLocale = false;
                     return $domain;
                 }
             }
             if ($core) {
                 $app = $directory . $lang . DS . $this->category . DS . 'core';
                 $translations = false;
                 if (is_file($app . '.mo')) {
                     $translations = self::loadMo($app . '.mo');
                 }
                 if ($translations === false && is_file($app . '.po')) {
                     $translations = self::loadPo($app . '.po');
                 }
                 if ($translations !== false) {
                     $this->_domains[$domain][$this->_lang][$this->category] = $translations;
                     $merge[$domain][$this->_lang][$this->category] = $this->_domains[$domain][$this->_lang][$this->category];
                     $this->_noLocale = false;
                     $core = null;
                 }
             }
             $file = $directory . $lang . DS . $this->category . DS . $domain;
             $translations = false;
             if (is_file($file . '.mo')) {
                 $translations = self::loadMo($file . '.mo');
             }
             if ($translations === false && is_file($file . '.po')) {
                 $translations = self::loadPo($file . '.po');
             }
             if ($translations !== false) {
                 $this->_domains[$domain][$this->_lang][$this->category] = $translations;
                 $this->_noLocale = false;
                 break 2;
             }
         }
     }
     if (empty($this->_domains[$domain][$this->_lang][$this->category])) {
         $this->_domains[$domain][$this->_lang][$this->category] = array();
         return $domain;
     }
     if (isset($this->_domains[$domain][$this->_lang][$this->category][""])) {
         $head = $this->_domains[$domain][$this->_lang][$this->category][""];
         foreach (explode("\n", $head) as $line) {
             $header = strtok($line, ":");
             $line = trim(strtok("\n"));
             $this->_domains[$domain][$this->_lang][$this->category]["%po-header"][strtolower($header)] = $line;
         }
         if (isset($this->_domains[$domain][$this->_lang][$this->category]["%po-header"]["plural-forms"])) {
             $switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->_domains[$domain][$this->_lang][$this->category]["%po-header"]["plural-forms"]);
             $this->_domains[$domain][$this->_lang][$this->category]["%plural-c"] = $switch;
             unset($this->_domains[$domain][$this->_lang][$this->category]["%po-header"]);
         }
         $this->_domains = Set::pushDiff($this->_domains, $merge);
         if (isset($this->_domains[$domain][$this->_lang][$this->category][null])) {
             unset($this->_domains[$domain][$this->_lang][$this->category][null]);
         }
     }
     return $domain;
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:88,代码来源:I18n.php

示例7: add

 /**
  * add
  *
  * @param mixed $course_id
  *
  * @access public
  * @return void
  */
 function add($course_id)
 {
     $course = $this->Course->getAccessibleCourseById($course_id, User::get('id'), User::getCourseFilterPermission());
     if (!$course) {
         $this->Session->setFlash(__('Error: Course does not exist or you do not have permission to view this course.', true));
         $this->redirect('/courses');
         return;
     }
     if (!empty($this->data)) {
         $this->data['Group']['group_name'] = trim($this->data['Group']['group_name']);
         if ($this->Group->save($this->data)) {
             $this->Session->setFlash(__('The group was added successfully.', true), 'good');
             $this->redirect('index/' . $course_id);
             return;
         }
     }
     $user_data1 = $this->User->getEnrolledStudentsForList($course_id);
     $user_data2 = $this->User->getCourseTutorsForList($course_id);
     $user_data = Set::pushDiff($user_data1, $user_data2);
     //Check if student is already assigned in a group
     $groups = $this->Group->getGroupsByCourseId($course_id);
     $assigned_users = $this->GroupsMembers->getUserListInGroups(array_keys($groups));
     foreach ($assigned_users as $assigned_user) {
         $user_data[$assigned_user] = $user_data[$assigned_user] . ' *';
     }
     $this->set('breadcrumb', $this->breadcrumb->push(array('course' => $course['Course']))->push(__('Add Group', true)));
     $this->data['Group']['course_id'] = $course_id;
     // gets all the students in db for the unfiltered students list
     $this->set('user_data', $user_data);
     $this->set('course_id', $course_id);
     $this->set('group_num', $this->Group->getFirstAvailGroupNum($course_id));
     $this->render('edit');
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:41,代码来源:groups_controller.php

示例8: _mergeHasMany

/**
 * mergeHasMany - Merge the results of hasMany relations.
 *
 *
 * @param array $resultSet Data to merge into
 * @param array $merge Data to merge
 * @param string $association Name of Model being Merged
 * @param Model $model Model being merged onto
 * @param Model $linkModel Model being merged
 * @return void
 */
	protected function _mergeHasMany(&$resultSet, $merge, $association, $model, $linkModel) {
		$modelAlias = $model->alias;
		$modelPK = $model->primaryKey;
		$modelFK = $model->hasMany[$association]['foreignKey'];
		foreach ($resultSet as &$result) {
			if (!isset($result[$modelAlias])) {
				continue;
			}
			$merged = array();
			foreach ($merge as $data) {
				if ($result[$modelAlias][$modelPK] === $data[$association][$modelFK]) {
					if (count($data) > 1) {
						$data = array_merge($data[$association], $data);
						unset($data[$association]);
						foreach ($data as $key => $name) {
							if (is_numeric($key)) {
								$data[$association][] = $name;
								unset($data[$key]);
							}
						}
						$merged[] = $data;
					} else {
						$merged[] = $data[$association];
					}
				}
			}
			$result = Set::pushDiff($result, array($association => $merged));
		}
	}
开发者ID:sherix88,项目名称:sigedu,代码行数:40,代码来源:DboSource.php

示例9: __initSingularRules

 /**
  * Initializes singular inflection rules
  *
  * @return void
  * @access protected
  */
 function __initSingularRules()
 {
     $coreSingularRules = array('/(s)tatuses$/i' => '\\1\\2tatus', '/^(.*)(menu)s$/i' => '\\1\\2', '/(quiz)zes$/i' => '\\1', '/(matr)ices$/i' => '\\1ix', '/(vert|ind)ices$/i' => '\\1ex', '/^(ox)en/i' => '\\1', '/(alias)(es)*$/i' => '\\1', '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\\1us', '/(cris|ax|test)es$/i' => '\\1is', '/(shoe)s$/i' => '\\1', '/(o)es$/i' => '\\1', '/ouses$/' => 'ouse', '/uses$/' => 'us', '/([m|l])ice$/i' => '\\1ouse', '/(x|ch|ss|sh)es$/i' => '\\1', '/(m)ovies$/i' => '\\1\\2ovie', '/(s)eries$/i' => '\\1\\2eries', '/([^aeiouy]|qu)ies$/i' => '\\1y', '/([lr])ves$/i' => '\\1f', '/(tive)s$/i' => '\\1', '/(hive)s$/i' => '\\1', '/(drive)s$/i' => '\\1', '/([^fo])ves$/i' => '\\1fe', '/(^analy)ses$/i' => '\\1sis', '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\\1\\2sis', '/([ti])a$/i' => '\\1um', '/(p)eople$/i' => '\\1\\2erson', '/(m)en$/i' => '\\1an', '/(c)hildren$/i' => '\\1\\2hild', '/(n)ews$/i' => '\\1\\2ews', '/^(.*us)$/' => '\\1', '/s$/i' => '');
     $coreUninflectedSingular = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*ss', 'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus', 'carp', 'chassis', 'clippers', 'cod', 'coitus', 'Congoese', 'contretemps', 'corps', 'debris', 'diabetes', 'djinn', 'eland', 'elk', 'equipment', 'Faroese', 'flounder', 'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti', 'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings', 'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', 'media', 'mews', 'moose', 'mumps', 'Nankingese', 'news', 'nexus', 'Niasese', 'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese', 'proceedings', 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors', 'sea[- ]bass', 'series', 'Shavese', 'shears', 'siemens', 'species', 'swine', 'testes', 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese', 'whiting', 'wildebeest', 'Yengeese');
     $coreIrregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother', 'children' => 'child', 'corpuses' => 'corpus', 'cows' => 'cow', 'ganglions' => 'ganglion', 'genies' => 'genie', 'genera' => 'genus', 'graffiti' => 'graffito', 'hoofs' => 'hoof', 'loaves' => 'loaf', 'men' => 'man', 'monies' => 'money', 'mongooses' => 'mongoose', 'moves' => 'move', 'mythoi' => 'mythos', 'numina' => 'numen', 'occiputs' => 'occiput', 'octopuses' => 'octopus', 'opuses' => 'opus', 'oxen' => 'ox', 'penises' => 'penis', 'people' => 'person', 'sexes' => 'sex', 'soliloquies' => 'soliloquy', 'testes' => 'testis', 'trilbys' => 'trilby', 'turfs' => 'turf');
     $singularRules = Set::pushDiff($this->__singularRules, $coreSingularRules);
     $uninflected = Set::pushDiff($this->__uninflectedSingular, $coreUninflectedSingular);
     $irregular = Set::pushDiff($this->__irregularSingular, $coreIrregularSingular);
     $this->singularRules = array('singularRules' => $singularRules, 'uninflected' => $uninflected, 'irregular' => $irregular);
     $this->singularized = array();
 }
开发者ID:javierm,项目名称:wildflower,代码行数:17,代码来源:inflector.php

示例10: __mergeHasMany

 function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel)
 {
     foreach ($resultSet as $key => $value) {
         $merged[$association] = array();
         $count = 0;
         foreach ($merge as $assoc => $data) {
             if (isset($value[$model->name]) && $value[$model->name][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
                 if (count($data) > 1) {
                     $temp[] = Set::pushDiff($data[$association], $data);
                     unset($temp[$count][$association]);
                     $merged[$association] = $temp;
                 } else {
                     $merged[$association][] = $data[$association];
                 }
             }
             $count++;
         }
         if (isset($value[$model->name])) {
             $resultSet[$key] = Set::pushDiff($resultSet[$key], $merged);
             unset($merged);
             unset($temp);
         }
     }
 }
开发者ID:uwitec,项目名称:eduoa,代码行数:24,代码来源:dbo_source.php

示例11: testPushDiff

 /**
  * testPushDiff method
  *
  * @access public
  * @return void
  */
 function testPushDiff()
 {
     $array1 = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2'));
     $array2 = array('ModelTwo' => array('id' => 1002, 'field_one' => 'a2.m2.f1', 'field_two' => 'a2.m2.f2'));
     $result = Set::pushDiff($array1, $array2);
     $this->assertIdentical($result, $array1 + $array2);
     $array3 = array('ModelOne' => array('id' => 1003, 'field_one' => 'a3.m1.f1', 'field_two' => 'a3.m1.f2', 'field_three' => 'a3.m1.f3'));
     $result = Set::pushDiff($array1, $array3);
     $expected = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3'));
     $this->assertIdentical($result, $expected);
     $array1 = array(0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2')), 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2')));
     $array2 = array(0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2')), 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2')));
     $result = Set::pushDiff($array1, $array2);
     $this->assertIdentical($result, $array1);
     $array3 = array(0 => array('ModelThree' => array('id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2')));
     $result = Set::pushDiff($array1, $array3);
     $expected = array(0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2'), 'ModelThree' => array('id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2')), 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2')));
     $this->assertIdentical($result, $expected);
     $result = Set::pushDiff($array1, null);
     $this->assertIdentical($result, $array1);
     $result = Set::pushDiff($array1, $array2);
     $this->assertIdentical($result, $array1 + $array2);
 }
开发者ID:subh,项目名称:raleigh-workshop-08,代码行数:29,代码来源:set.test.php

示例12: _findEvents

 /**
  * undocumented function
  *
  * @param string $state
  * @param string $query
  * @param string $results
  * @return void
  */
 function _findEvents($state, $query, $results = array())
 {
     if ($state == 'before') {
         $defaults = array('order' => array('Timeline.created' => 'DESC', 'Timeline.id' => 'DESC'));
         $query = Set::pushDiff($defaults, $query);
         return $query;
     }
     $data = array();
     foreach ((array) $results as $key => $timeline) {
         $type = $timeline['Timeline']['model'];
         if (!isset($this->{$type})) {
             continue;
         }
         $this->{$type}->recursive = 0;
         $related = $this->{$type}->findById($timeline['Timeline']['foreign_key']);
         if (!empty($related)) {
             $data[] = array_merge($timeline, (array) $related);
         }
     }
     return $data;
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:29,代码来源:timeline.php

示例13: getStudentsNotInGroup

 /**
  * Get students and tutors not in a group
  *
  * @param int    $group_id group id
  * @param string $type     type of user
  *
  * @return array students and tutors not in the group
  */
 function getStudentsNotInGroup($group_id, $type = 'list')
 {
     // $people includes id of both students and tutors/TAs in group
     $people = $this->getMembersByGroupId($group_id, 'all');
     $people = Set::extract('/Member/id', $people);
     $peopleInGroups = array();
     $course = $this->Course->getCourseByGroupId($group_id);
     if (empty($course)) {
         return array();
     }
     $peopleListinGroups = $this->Member->find($type, array('conditions' => array('NOT' => array('Member.id' => $people), 'Group.course_id' => $course['Course']['id']), 'recursive' => 1, 'fields' => array('Member.student_no_with_full_name'), 'contain' => array('Group'), 'order' => 'Member.student_no'));
     foreach ($peopleListinGroups as $key => $student) {
         $peopleListinGroups[$key] = $student . ' *';
         $peopleInGroups[] = $key;
     }
     $excludedPeople = array_merge($people, $peopleInGroups);
     $studentsListNotinGroups = $this->Member->find($type, array('conditions' => array('NOT' => array('Member.id' => $excludedPeople), 'Enrolment.id' => $course['Course']['id']), 'recursive' => 1, 'fields' => array('Member.student_no_with_full_name'), 'order' => 'Member.student_no'));
     $tutorsListNotinGroups = $this->Member->find($type, array('conditions' => array('NOT' => array('Member.id' => $excludedPeople), 'Tutor.id' => $course['Course']['id'], 'Role.id' => 4), 'recursive' => 1, 'fields' => array('Member.full_name'), 'order' => 'Member.last_name'));
     $peopleList = Set::pushDiff($studentsListNotinGroups, $peopleListinGroups);
     $sorted_list = Set::pushDiff($tutorsListNotinGroups, $peopleList);
     return $sorted_list;
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:30,代码来源:group.php

示例14: __bindTextDomain

 /**
  * Binds the given domain to a file in the specified directory.
  *
  * @param string $domain Domain to bind
  * @return string Domain binded
  * @access private
  */
 function __bindTextDomain($domain)
 {
     $this->__noLocale = true;
     $core = true;
     $merge = array();
     $searchPaths[] = S2Paths::get($this->app, 'S2_APP_OVERRIDES') . 'locale';
     $searchPaths[] = S2Paths::get($this->app, 'S2_APP') . 'locale';
     //		$plugins = Configure::listObjects('plugin');
     if (!empty($plugins)) {
         $pluginPaths = Configure::read('pluginPaths');
         foreach ($plugins as $plugin) {
             $plugin = Inflector::underscore($plugin);
             if ($plugin === $domain) {
                 foreach ($pluginPaths as $pluginPath) {
                     $searchPaths[] = $pluginPath . DS . $plugin . DS . 'locale';
                 }
                 $searchPaths = array_reverse($searchPaths);
                 break;
             }
         }
     }
     foreach ($searchPaths as $directory) {
         foreach ($this->l10n->languagePath as $lang) {
             $file = $directory . DS . $lang . DS . $this->category . DS . $domain;
             if ($core) {
                 $app = $directory . DS . $lang . DS . $this->category . DS . 'core';
                 if (file_exists($fn = "{$app}.mo")) {
                     $this->__loadMo($fn, $domain);
                     $this->__noLocale = false;
                     $merge[$this->category][$this->__lang][$domain] = $this->__domains[$this->category][$this->__lang][$domain];
                     $core = null;
                 } elseif (file_exists($fn = "{$app}.po") && ($f = fopen($fn, "r"))) {
                     $this->__loadPo($f, $domain);
                     $this->__noLocale = false;
                     $merge[$this->category][$this->__lang][$domain] = $this->__domains[$this->category][$this->__lang][$domain];
                     $core = null;
                 }
             }
             if (file_exists($fn = "{$file}.mo")) {
                 $this->__loadMo($fn, $domain);
                 $this->__noLocale = false;
                 break 2;
             } elseif (file_exists($fn = "{$file}.po") && ($f = fopen($fn, "r"))) {
                 $this->__loadPo($f, $domain);
                 $this->__noLocale = false;
                 break 2;
             }
         }
     }
     if (empty($this->__domains[$this->category][$this->__lang][$domain])) {
         $this->__domains[$this->category][$this->__lang][$domain] = array();
         return $domain;
     }
     if ($head = $this->__domains[$this->category][$this->__lang][$domain][""]) {
         foreach (explode("\n", $head) as $line) {
             $header = strtok($line, ":");
             $line = trim(strtok("\n"));
             $this->__domains[$this->category][$this->__lang][$domain]["%po-header"][strtolower($header)] = $line;
         }
         if (isset($this->__domains[$this->category][$this->__lang][$domain]["%po-header"]["plural-forms"])) {
             $switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->__domains[$this->category][$this->__lang][$domain]["%po-header"]["plural-forms"]);
             $this->__domains[$this->category][$this->__lang][$domain]["%plural-c"] = $switch;
             unset($this->__domains[$this->category][$this->__lang][$domain]["%po-header"]);
         }
         $this->__domains = Set::pushDiff($this->__domains, $merge);
         if (isset($this->__domains[$this->category][$this->__lang][$domain][null])) {
             unset($this->__domains[$this->category][$this->__lang][$domain][null]);
         }
     }
     return $domain;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:78,代码来源:I18n.php

示例15: testPushDiff

 /**
  * testPushDiff method
  *
  * @return void
  */
 public function testPushDiff()
 {
     $array1 = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2'));
     $array2 = array('ModelTwo' => array('id' => 1002, 'field_one' => 'a2.m2.f1', 'field_two' => 'a2.m2.f2'));
     $result = Set::pushDiff($array1, $array2);
     $this->assertEquals($array1 + $array2, $result);
     $array3 = array('ModelOne' => array('id' => 1003, 'field_one' => 'a3.m1.f1', 'field_two' => 'a3.m1.f2', 'field_three' => 'a3.m1.f3'));
     $result = Set::pushDiff($array1, $array3);
     $expected = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3'));
     $this->assertEquals($expected, $result);
     $array1 = array(0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2')), 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2')));
     $array2 = array(0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2')), 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2')));
     $result = Set::pushDiff($array1, $array2);
     $this->assertEquals($array1, $result);
     $array3 = array(0 => array('ModelThree' => array('id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2')));
     $result = Set::pushDiff($array1, $array3);
     $expected = array(0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2'), 'ModelThree' => array('id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2')), 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2')));
     $this->assertEquals($expected, $result);
     $result = Set::pushDiff($array1, NULL);
     $this->assertEquals($array1, $result);
     $result = Set::pushDiff($array1, $array2);
     $this->assertEquals($array1 + $array2, $result);
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:28,代码来源:SetTest.php


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