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


PHP Set::sort方法代码示例

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


在下文中一共展示了Set::sort方法的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: index

 function index()
 {
     $this->ProductionManager->recursive = 2;
     $production_managers = $this->ProductionManager->find('all');
     $busiest_dev = array();
     $counter = 0;
     $total_working_projects = 0;
     if (!$this->Session->read('TempProd.total_working_projects_set')) {
         $this->Session->write('TempProd.total_working_projects_set', 1);
         foreach ($production_managers as $prod) {
             foreach ($prod['Project'] as $project) {
                 if ($project['complete'] == 0 || $project['complete'] == '0') {
                     $total_working_projects += 1;
                 }
             }
             //Update the SQL table with final value
             //$this->Developer->read(null, $dev['Developer']['id']);
             $data = array('ProductionManager' => array('id' => $prod['ProductionManager']['id'], 'total_working_projects' => $total_working_projects));
             $this->ProductionManager->save($data);
             $total_working_projects = 0;
             $counter++;
         }
     }
     $production_managers = Set::sort($production_managers, '{n}.ProductionManager.total_working_projects', 'desc');
     if ($production_managers[0]['ProductionManager']['total_working_projects'] == $production_managers[1]['ProductionManager']['total_working_projects']) {
         $busiest_prod[0] = $production_managers[0];
         $busiest_prod[1] = $production_managers[1];
     } else {
         $busiest_prod = $production_managers[0];
     }
     $this->paginate = array('order' => array('ProductionManager.total_working_projects' => 'desc'));
     $this->set('production_managers', $this->paginate());
 }
开发者ID:robsawyer,项目名称:PMT,代码行数:33,代码来源:production_managers_controller.php

示例3: testLookup_by_user_id

 public function testLookup_by_user_id()
 {
     $results = $this->User->find('lookup', array('user_id' => array('8620662', '15982041')));
     $results = Set::sort($results, '/id_str', 'asc');
     $screenNames = Set::extract('/screen_name', $results);
     $ids = Set::extract('/id_str', $results);
     $this->assertEquals(array('cakephp', 'nojimage'), $screenNames);
     $this->assertEquals(array('8620662', '15982041'), $ids);
 }
开发者ID:nojimage,项目名称:cakephp-twim,代码行数:9,代码来源:TwimUserNeedAuthTest.php

示例4: testIndex

 function testIndex()
 {
     $result = $this->testAction('/surveys/index', array('return' => 'vars'));
     $surveys = Set::sort($result['paramsForList']['data']['entries'], '{n}.Survey.id', 'asc');
     $this->assertEqual($surveys[0]['Survey']['name'], 'Team Creation Survey');
     $this->assertEqual($surveys[0]['Survey']['question_count'], 2);
     $this->assertEqual($surveys[1]['Survey']['name'], 'Survey, all Q types');
     $this->assertEqual($surveys[1]['Survey']['question_count'], 4);
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:9,代码来源:surveys_controller.test.php

示例5: findTop10

 function findTop10()
 {
     $top_10 = array(43, 33, 26, 18, 296, 23, 69, 313, 292, 203);
     $records = $this->find('all', array('contain' => false, 'conditions' => array('id' => $top_10)));
     foreach ($records as $key => $val) {
         if (isset($val['Brand']['id']) && in_array($val['Brand']['id'], $top_10)) {
             $val['Brand']['top_10'] = array_search($val['Brand']['id'], $top_10) + 1;
         }
         $records[$key] = $val;
     }
     return Set::sort($records, '{n}.Brand.top_10', 'asc');
 }
开发者ID:ryan953,项目名称:BierFrau,代码行数:12,代码来源:brand.php

示例6: findCommon

 function findCommon()
 {
     $top_10 = array(3, 10, 9, 13, 12, 5, 4, 11, 36, 24);
     $records = $this->find('all', array('contain' => array('Container'), 'conditions' => array('Package.id' => $top_10)));
     foreach ($records as $key => $val) {
         if (isset($val['Package']['id']) && in_array($val['Package']['id'], $top_10)) {
             $val['Package']['top_10'] = array_search($val['Package']['id'], $top_10) + 1;
         }
         $records[$key] = $val;
     }
     return Set::sort($records, '{n}.Package.top_10', 'asc');
 }
开发者ID:ryan953,项目名称:BierFrau,代码行数:12,代码来源:package.php

示例7: getRequests

 /**
  * Returns an array of CakeRequest objects. Performs various transformations on the request passed to the constructor,
  * so that the requests match the format expected by CakePHP.
  *
  * @return array Array with CakeRequest objects.
  */
 public function getRequests()
 {
     $requests = array();
     // If the request comes from $HTTP_RAW_POST_DATA it could be a batch request.
     if (strlen($this->rawPostData)) {
         $data = json_decode($this->rawPostData, true);
         // TODO: improve detection (not perfect, but should it should be correct in most cases.)
         if (isset($data['action']) || isset($data['method']) || isset($data['data'])) {
             $data = array($data);
         }
         $data = Set::sort($data, '{n}.tid', 'asc');
     } else {
         if (!empty($this->postData)) {
             // Form requests only contain one request.
             $data = array($this->postData);
         } else {
             // no data passed
             throw new BanchaException('Missing POST Data: The Bancha Dispatcher expected to get all requests in the Ext.Direct format as POST ' . 'parameter, but there is no data in this request. You can not access this site directly!');
         }
     }
     if (count($data) > 0) {
         for ($i = 0; $i < count($data); $i++) {
             $transformer = new BanchaRequestTransformer($data[$i]);
             // CakePHP should think that every Bancha request is a POST request.
             $_SERVER['REQUEST_METHOD'] = 'POST';
             // Create CakeRequest and fill it with values from the transformer.
             $requests[$i] = new CakeRequest($transformer->getUrl());
             // the CakeRequest uses the envirement variable $_POST in his
             // during the startup called _processPost() (currently line 153).
             // This is unclean and adds false data in our case. So delete this data.
             $requests[$i]->data = array();
             // now set params for the request
             $requests[$i]['controller'] = $transformer->getController();
             $requests[$i]['action'] = $transformer->getAction();
             $requests[$i]['named'] = $transformer->getPaging();
             $requests[$i]['plugin'] = null;
             // bancha-specific
             $requests[$i]['tid'] = $transformer->getTid();
             $requests[$i]['extUpload'] = $transformer->getExtUpload();
             $requests[$i]['client_id'] = $transformer->getClientId();
             $requests[$i]['isFormRequest'] = $transformer->isFormRequest();
             $requests[$i]['pass'] = $transformer->getPassParams();
             // additional property for cleaner controller syntax
             $requests[$i]['isBancha'] = true;
             // Handle all other parameters as POST parameters.
             foreach ($transformer->getCleanedDataArray() as $key => $value) {
                 $requests[$i]->data($key, $value);
             }
         }
     }
     return $requests;
 }
开发者ID:rolandschuetz,项目名称:Bancha,代码行数:58,代码来源:BanchaRequestCollection.php

示例8: testGetCourseEvalEvent

 function testGetCourseEvalEvent()
 {
     $empty = null;
     $this->Event =& ClassRegistry::init('Event');
     //Test a valid course number
     $course = Set::sort($this->Event->GetCourseEvalEvent(1), '{n}.Event.id', 'asc');
     $events = $this->toEventNameArray($course);
     $this->assertEqual($events['0'], 'Term 1 Evaluation');
     $this->assertEqual($events['1'], 'Term Report Evaluation');
     $this->assertEqual($events['2'], 'Project Evaluation');
     //Test an invalid course number
     $course = $this->Event->GetCourseEvalEvent(999);
     $this->assertEqual($course, $empty);
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:14,代码来源:event.test.php

示例9: cleanSearchString

 function cleanSearchString(&$Model, $searchString = null)
 {
     $clean = $this->settings[$Model->alias]['clean'];
     $clean['rules'] = Set::sort($clean['rules'], '{[\\w ]+}.order', 'asc');
     if (!empty($clean['rules'])) {
         foreach ($clean['rules'] as $ruleKey => $rule) {
             $searchString = preg_replace('/' . $rule['pattern'] . '/', $rule['replacement'], $searchString);
         }
         unset($ruleKey);
         unset($rule);
     }
     if (!empty($clean['trim'])) {
         $searchString = trim($searchString);
     }
     return $searchString;
 }
开发者ID:ricog,项目名称:searchable,代码行数:16,代码来源:searchable.php

示例10: paginate

 function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array())
 {
     App::import('Core', 'Folder');
     $Folder = new Folder($this->__path());
     $pages = $Folder->read();
     $pages = $pages[1];
     unset($Folder);
     $returnPages = array();
     foreach ($pages as $page) {
         if (strpos($page, '.ctp') !== false) {
             $returnPage = array('name' => Inflector::humanize(substr($page, 0, strlen($page) - 4)), 'file_name' => $page);
             $returnPages[]['Page'] = $returnPage;
         }
     }
     return Set::sort($returnPages, '{n}.Page.file_name', 'asc');
 }
开发者ID:rchavik,项目名称:infinitas,代码行数:16,代码来源:page.php

示例11: view

 public function view($id = null)
 {
     if (!$id) {
         throw new NotFoundException(__('Invalid query'));
     }
     $query = $this->Query->find('all', array('conditions' => array('id' => $id), 'recursive' => 2));
     $userQuery = $this->Query->query("Select * from users where id = '" . $query[0]["Query"]["user_id"] . "'");
     if (!$query) {
         throw new NotFoundException(__('Invalid query'));
     }
     $this->set('targetQuery', $query[0]);
     $this->set('author', $userQuery[0]["users"]);
     $sql = "SELECT comments.id, sum(comments_users.vote) as votes FROM comments, comments_users WHERE comments.query_id = " . $query[0]["Query"]["id"] . "  AND comments.id = comments_users.comment_id GROUP BY comment_id";
     $commentsWithVotes = $this->Query->query($sql);
     $sql = "SELECT id FROM comments WHERE query_id = " . $query[0]["Query"]["id"];
     $allCommentsQuery = $this->Query->query($sql);
     foreach ($allCommentsQuery as $key => $row) {
         $exist = false;
         foreach ($commentsWithVotes as $key => $value) {
             if ($row['comments']['id'] == $value['comments']['id']) {
                 $exist = true;
                 break;
             }
         }
         if (!$exist) {
             $count = count($commentsWithVotes);
             $commentsWithVotes[$count]['comments']['id'] = $row['comments']['id'];
             $commentsWithVotes[$count][0]['votes'] = 0;
         }
     }
     $sortedComments = Set::sort($commentsWithVotes, '{n}.0.votes', 'desc');
     $this->set('sortedComments', $sortedComments);
     /*$commentsWithVotes[3]['comments']['id']=1;
     		$commentsWithVotes[3][0]['sum(comments_users.vote)']= 0;
     		print_r($commentsWithVotes);die();*/
     /*foreach ($query[0]['Comment'] as $key => $value) {
     			$sql = "SELECT sum(vote) as votes FROM comments_users where comment_id = ".$value['id'];
     			if(empty($this->Query->query($sql)[0][0]['votes']))
     				$aOrdenar[$value['id']]= 0;
     			else
     				$aOrdenar[$value['id']]= $this->Query->query($sql)[0][0]['votes'];
     		}
     		print_r(Set::sort($aOrdenar, '{n}', 'desc'));*/
     $sql = "SELECT sum(vote) from queries_users where query_id = {$id}";
     $numVotos = $this->Query->query($sql);
     $this->set('numVotos', $numVotos[0][0]["sum(vote)"]);
 }
开发者ID:dvillanuevavilar,项目名称:Query,代码行数:47,代码来源:QueriesController.php

示例12: paginate

 public function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array())
 {
     App::import('Core', 'Folder');
     $Folder = new Folder($this->__path());
     $pages = $Folder->read();
     $pages = $pages[1];
     unset($Folder);
     $returnPages = array();
     foreach ($pages as $page) {
         if (strpos($page, '.ctp') !== false) {
             $returnPages[][$this->alias] = $this->__getPageData(basename($page));
         }
     }
     if (empty($returnPages)) {
         return array();
     }
     return Set::sort($returnPages, '{n}.' . $this->alias . '.file_name', 'asc');
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:18,代码来源:GlobalPage.php

示例13: _order

 protected function _order(array $controllers)
 {
     foreach ($controllers as $key => $controller) {
         $controllers[$key]['Controller']['order'] = 0;
         if (empty($controller['Controller'])) {
             continue;
         }
         $importName = $controller['Controller']['importName'];
         extract($controller['Controller']['properties']);
         App::uses($controller, $importName);
         if (class_exists($controller)) {
             $controllers[$key]['Controller']['order'] = isset($controller::$order) ? intval($controller::$order) : 0;
         }
     }
     extract($this->settings);
     $order_by = $order_by == 'name' ? 'key' : $order_by;
     return $this->controllersList = Set::sort($controllers, "{n}.Controller.{$order_by}", $order_sort);
 }
开发者ID:JacopKane,项目名称:Cake-ControllersList,代码行数:18,代码来源:GetListComponent.php

示例14: restauraBackup

 /**
  * Restaura as configurações dos menus
  *
  * @param Array $aSnap -- Configurações a serem restauradas
  * @return Boolean
  */
 public function restauraBackup($aSnap)
 {
     $this->begin();
     $aSnap = Set::sort($aSnap, '{n}.id', 'asc');
     $this->Behaviors->detach('Tree');
     if ($this->deleteAll("1 = 1") && (empty($aSnap) || $this->saveAll($aSnap))) {
         $this->Behaviors->attach('Tree');
         $aRetorno = $this->query("select max(id) as last from cms.menus;");
         $last = $aRetorno[0][0]['last'] + 1;
         $sSql = "alter sequence cms.menus_id_seq restart with {$last};";
         $this->query($sSql);
         $this->commit();
         return true;
     }
     $this->Behaviors->attach('Tree');
     $this->rollback();
     return false;
 }
开发者ID:niltonfelipe,项目名称:e-cidade_transparencia,代码行数:24,代码来源:menu.php

示例15: admin_index

	/**
	 * The administration panel to view all of the flagged items. In this area, you can delete, deactivate, reactivate and remove flags from items.
	 * @param 
	 * @return 
	 * 
	*/
	function admin_index(){
		$flags = $this->paginate('Flag');
		
		//Get the flag count for each item and add that to the item array [Flag]['count']
		$counter = 0;
		foreach($flags as $flag){
			$flags[$counter]['Flag']['count'] = $this->Flag->getItemCount($flag['Flag']['model'],$flag['Flag']['model_id']);
			$counter++; 
		}
		$total_count = $this->Flag->getCount();
		
		//debug($flags);
		//Group like flagged items ex. The same item that has been flagged 
		$flags = Set::sort($flags,'{n}.Flag.model_id','desc');
		$flags = Set::sort($flags,'{n}.Flag.model','desc');
		
		$this->set(compact('total_count','flags'));
		$this->set('string', $this->String);
	}
开发者ID:robksawyer,项目名称:FIND---GET---MAKE,代码行数:25,代码来源:flags_controller.php


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