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


PHP c2cTools::sortArrayByName方法代码示例

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


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

示例1: getAssociatedMapsData

 public static function getAssociatedMapsData($maps)
 {
     if (!count($maps)) {
         return array();
     }
     $editor_list = sfConfig::get('app_maps_editors');
     foreach ($maps as $key => $map) {
         $name = $editor_list[$map['editor']] . ' ' . $map['code'] . ' ' . $map['name'];
         $maps[$key]['name'] = $name;
     }
     return c2cTools::sortArrayByName($maps);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:12,代码来源:Map.class.php

示例2: executeView

 /**
  * Executes view action.
  */
 public function executeView()
 {
     $timer = new sfTimer('executeView');
     $this->timer = $timer;
     sfLoader::loadHelpers(array('General', 'MetaLink'));
     $id = $this->getRequestParameter('id');
     $lang = $this->getRequestParameter('lang');
     $version = $this->getRequestParameter('version');
     $slug = $this->getRequestParameter('slug');
     // and if not, redirect to true module...
     if ($this->model_class == 'Document') {
         $doc = Document::find('Document', $id, array('module'));
         $module = $doc->get('module');
     }
     $user = $this->getUser();
     $prefered_cultures = $user->getCulturesForDocuments();
     $module = isset($module) ? $module : $this->getModuleName();
     // we check here if document id requested corresponds to $module model
     if (empty($lang)) {
         // if lang isn't set, we use the prefered language session and redirect to the good URL
         // (for caching reasons, this cannot be silent)
         if (!($lang = DocumentI18n::findBestCulture($id, $prefered_cultures, $this->model_class))) {
             c2cActions::statsdTiming('document.executeView.redirect', $timer->getElapsedTime('executeView'));
             $this->setNotFoundAndRedirect();
         } else {
             $document = $this->getDocument($id, $lang, $version);
             c2cActions::statsdTiming('document.executeView.redirect', $timer->getElapsedTime('executeView'));
             $this->redirectIfSlugMissing($document, $id, $lang, $module);
         }
     }
     $document = $this->getDocument($id, $lang, $version);
     // no need to test whether document has been found :
     // already done in getDocument method.
     if (empty($version) && $module != 'users' && (empty($slug) || $module != 'routes' && $slug != get_slug($document))) {
         c2cActions::statsdTiming('document.executeView.redirect', $timer->getElapsedTime('executeView'));
         $this->redirectIfSlugMissing($document, $id, $lang, $module);
     }
     // case where module = documents, and lang, version or slug already given
     if ($this->model_class == 'Document') {
         $this->redirect("@document_by_id_lang_slug?module={$module}&id={$id}&lang={$lang}&slug={$slug}", 301);
     }
     if ($to_id = $document->get('redirects_to')) {
         $this->setWarning('Current document has been merged into document %1%', array('%1%' => $to_id), false);
     }
     $title = $document->get('name');
     if ($document->isArchive()) {
         $this->getResponse()->addMeta('robots', 'noindex, nofollow');
         $this->metadata = $document->getMetadatas();
         $this->created_at = $this->metadata->get('written_at');
         $this->current_version = $version;
         $title .= ' :: ' . $this->__('revision') . ' ' . $version;
         $this->associated_docs = array();
         // we need associated images for displaying them
         $prefered_cultures = $this->getUser()->getCulturesForDocuments();
         $association_type = c2cTools::Module2Letter($module) . 'i';
         $this->associated_images = Document::fetchAdditionalFieldsFor(Association::findAllWithBestName($id, $prefered_cultures, $association_type), 'Image', array('filename', 'image_type', 'date_time'));
     } else {
         if (isset($to_id)) {
             $this->getResponse()->addMeta('robots', 'noindex, follow');
         } else {
             $this->getResponse()->addMeta('robots', 'index, follow');
         }
         $this->metadata = NULL;
         if ($module != 'portals') {
             $version_infos = Document::getCurrentVersionInfosFromIdAndCulture($id, $lang);
             $this->current_version = $version_infos['version'];
             $this->created_at = $version_infos['created_at'];
         }
         // retrieve associated docs
         // some additional docs can be retrieved in module/executeView, like two hops summits
         // contains all documents directly linked
         $association_type = $module == 'users' ? array('ui') : null;
         $associated_docs = Association::findAllWithBestName($id, $prefered_cultures, $association_type);
         // mark them (useful information)
         foreach ($associated_docs as &$doc) {
             $doc['directly_linked'] = true;
         }
         $this->associated_docs = $associated_docs;
         // all the linked articles
         $this->associated_articles = array_filter($this->associated_docs, array('c2cTools', 'is_article'));
         // linked sites
         $this->associated_sites = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_site')));
         // linked books. For summits and huts, the displayed books are the one linked to the linked routes
         if (!in_array($module, array('summits', 'huts'))) {
             $this->associated_books = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_book')));
         }
         // linked images
         // For sites and summits, we will dislay images linked to the summit/site AND its subsummits/subsites
         if (!in_array($module, array('summits', 'sites'))) {
             $this->associated_images = Document::fetchAdditionalFieldsFor(array_filter($this->associated_docs, array('c2cTools', 'is_image')), 'Image', array('filename', 'image_type', 'date_time', 'width', 'height'));
         }
         // Geo associated docs
         if (!in_array($module, array('articles', 'books'))) {
             $associated_areas = GeoAssociation::findAreasWithBestName($id, $prefered_cultures);
             $this->associated_areas = $associated_areas;
         }
         if (!in_array($module, array('outings', 'articles', 'books', 'portals'))) {
//.........这里部分代码省略.........
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:101,代码来源:actions.class.php

示例3: getAssociatedSitesData

 public static function getAssociatedSitesData($associated_docs)
 {
     $sites = Document::fetchAdditionalFieldsFor(array_filter($associated_docs, array('c2cTools', 'is_site')), 'Site', array('site_types'));
     return c2cTools::sortArrayByName($sites);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:5,代码来源:Site.class.php

示例4: executeView


//.........这里部分代码省略.........
                         $parent_ids[] = $route['id'];
                     } else {
                         $other_routes[$route['id']] = $route['duration'];
                     }
                 } else {
                     $default_ids[] = $route['id'];
                 }
             }
             // s'il n'y a pas d'itin?raire de 1 ou 2 jours, on utilise les itin?raires qui ont la plus petite dur?e
             // s'il n'y en a pas non plus, on utilise les itin?raire dont la dur?e est non renseign?e
             if (!count($parent_ids)) {
                 if (count($other_routes) > 1) {
                     asort($other_routes);
                     $min_duration = $other_routes . reset();
                     foreach ($other_routes as $id => $duration) {
                         if ($duration == $min_duration) {
                             $other_ids[] = $id;
                         }
                     }
                 } elseif (count($other_routes)) {
                     $other_ids[] = key($other_routes);
                 } else {
                     $other_ids = $default_ids;
                 }
                 $parent_ids = $other_ids;
             }
         }
         if (count($this->associated_sites)) {
             $associated_sites = $this->associated_sites;
             foreach ($associated_sites as $site) {
                 $parent_ids[] = $site['id'];
             }
         }
         // now retrieve the associated docs (summits, huts, parkings)
         if (count($parent_ids)) {
             $associated_route_docs = Association::findLinkedDocsWithBestName($parent_ids, $prefered_cultures, array('sr', 'hr', 'pr', 'pt'), false, false);
             if (count($associated_route_docs)) {
                 $associated_route_docs = c2cTools::sortArray($associated_route_docs, 'elevation');
                 $associated_summits = array_filter($associated_route_docs, array('c2cTools', 'is_summit'));
                 $associated_huts = array_filter($associated_route_docs, array('c2cTools', 'is_hut'));
                 $associated_parkings = Parking::getAssociatedParkingsData(array_filter($associated_route_docs, array('c2cTools', 'is_parking')));
                 if (count($associated_summits) && count($associated_huts)) {
                     $summit_ids = $summit_hut_tmp = $summit_hut_ids = array();
                     foreach ($associated_summits as $summit) {
                         $summit_ids[] = $summit['id'];
                     }
                     $summit_hut_tmp = Association::countAllLinked($summit_ids, 'sh');
                     if (count($summit_hut_tmp)) {
                         foreach ($summit_hut_tmp as $hut) {
                             $summit_hut_ids[] = $hut['main_id'];
                         }
                         foreach ($associated_summits as $key => $summit) {
                             if (in_array($summit['id'], $summit_hut_ids)) {
                                 unset($associated_summits[$key]);
                             }
                         }
                     }
                 }
             }
         }
         $this->associated_summits = $associated_summits;
         $this->associated_huts = $associated_huts;
         $this->associated_parkings = $associated_parkings;
         $this->associated_routes = $associated_routes;
         // associated users
         $associated_users = array_filter($this->associated_docs, array('c2cTools', 'is_user'));
         if (count($associated_users) >= 2) {
             // Set outing creator at first in the users list, and sort other users by name
             $creator_id = $this->document->getCreatorId();
             $creator = array();
             $associated_users_2 = array();
             foreach ($associated_users as $key => $user) {
                 if ($user['id'] == $creator_id) {
                     $creator[$key] = $user;
                 } else {
                     $associated_users_2[$key] = $user;
                 }
             }
             if (count($associated_users_2) >= 2) {
                 $associated_users_2 = c2cTools::sortArrayByName($associated_users_2);
             }
             $associated_users = array_merge($creator, $associated_users_2);
         }
         $this->associated_users = $associated_users;
         // related portals
         $related_portals = array();
         $activities = $this->document->get('activities');
         $outing_with_public_transportation = $this->document->get('outing_with_public_transportation');
         if (!$outing_with_public_transportation instanceof Doctrine_Null && $outing_with_public_transportation) {
             $related_portals[] = 'cda';
         }
         Portal::getRelatedPortals($related_portals, $this->associated_areas, $associated_routes, $activities);
         $this->related_portals = $related_portals;
         $description = array($title, $this->getActivitiesList(), $this->getAreasList());
         $this->getResponse()->addMeta('description', implode(' - ', $description));
     } else {
         // only moderators and associated users should see archive versions of outings
         $this->filterAuthorizedPeople($this->getRequestParameter('id'));
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:101,代码来源:actions.class.php

示例5: getAssociatedAreasData

 public static function getAssociatedAreasData($associated_areas)
 {
     $areas = Document::fetchAdditionalFieldsFor($associated_areas, 'Area', array('area_type'));
     return c2cTools::sortArrayByName($areas);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:5,代码来源:Area.class.php

示例6: executeGetroutes

 /**
  * returns a list of associated routes
  */
 public function executeGetroutes()
 {
     $id = $this->getRequestParameter('summit_id');
     $div_name = $this->getRequestParameter('div_name');
     $div_prefix = $this->getRequestParameter('div_prefix', '');
     $div_id = $div_prefix . $div_name;
     $user = $this->getUser();
     $user_id = $user->getId();
     // if id = 0 or no provided
     if (!$id) {
         return $this->ajax_feedback('Missing id parameter');
     }
     // if session is time-over
     if (!$user_id) {
         return $this->ajax_feedback('Your session is over. Please login again.');
     }
     $summit = Document::find('Summit', $id, array('id', 'elevation'));
     if (!$summit) {
         return $this->ajax_feedback('Summit not found');
     }
     $sub_summits = Summit::getSubSummits($id);
     $ids = array($id);
     foreach ($sub_summits as $sub) {
         $ids[] = $sub['id'];
     }
     $routes = Association::findLinkedDocsWithBestName($ids, $this->getUser()->getCulturesForDocuments(), 'sr');
     $routes = Route::addBestSummitName($routes, $this->__(' :') . ' ');
     $routes = c2cTools::sortArrayByName($routes);
     if (count($routes) == 0) {
         return $this->ajax_feedback($this->__('No associated route found'));
     }
     if (!$div_id) {
         return $this->ajax_feedback('Please chose a "select" container ID in "remote_function"');
     }
     $output = $this->__('Route:') . ' <select id="' . $div_id . '" name="' . $div_name . '" onchange="C2C.getWizardRouteRatings(\'' . $div_id . '\');">';
     foreach ($routes as $route) {
         $output .= '<option value="' . $route['id'] . '">' . $route['name'] . '</option>';
     }
     $output .= '</select>';
     $output .= '<p id="wizard_' . $div_id . '_descr" class="short_descr" style="display: none">' . '<span id="' . $div_id . '_descr">' . $this->__('Short description: ') . $this->__('not available') . '</span></p>';
     return $this->renderText($output);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:45,代码来源:actions.class.php

示例7: findMapsWithBestName

 public static function findMapsWithBestName($id, $user_prefered_langs)
 {
     $query = 'SELECT mi.id, mi.culture, mi.name, m.code, m.editor ' . 'FROM maps_i18n mi LEFT JOIN maps m ON mi.id = m.id ' . 'WHERE mi.id IN ' . '(SELECT a.linked_id FROM app_geo_associations a WHERE a.main_id = ? AND type = ?) ' . 'ORDER BY mi.id ASC';
     $results = sfDoctrine::connection()->standaloneQuery($query, array($id, 'dm'))->fetchAll();
     $out = self::setBestName($results, $user_prefered_langs);
     $out = c2cTools::sortArrayByName($out);
     return $out;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:8,代码来源:GeoAssociation.class.php

示例8: executeView

 /**
  * Executes view action.
  */
 public function executeView()
 {
     parent::executeView();
     if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) {
         $user = $this->getUser();
         $prefered_cultures = $user->getCulturesForDocuments();
         $current_doc_id = $this->getRequestParameter('id');
         $is_gite_camping = $this->document->get('shelter_type') == 5 || $this->document->get('shelter_type') == 6;
         // retrieve 2-hops parkings
         $associated_parkings = c2cTools::sortArray(array_filter($this->associated_docs, array('c2cTools', 'is_parking')), 'elevation');
         if (count($associated_parkings)) {
             $associated_parkings = Association::createHierarchyWithBestName($associated_parkings, $prefered_cultures, array('type' => 'pp'));
             $associated_parkings = Parking::getAssociatedParkingsData($associated_parkings);
         }
         $this->associated_parkings = $associated_parkings;
         $associated_routes = array_filter($this->associated_docs, array('c2cTools', 'is_route'));
         // associated summits
         $associated_summits = c2cTools::sortArray(array_filter($this->associated_docs, array('c2cTools', 'is_summit')), 'name');
         $this->associated_summits = $associated_summits;
         $summit_ids = $summit_routes_tmp = $summit_routes_ids = array();
         if (count($associated_summits)) {
             foreach ($associated_summits as $summit) {
                 $summit_ids[] = $summit['id'];
             }
             $summit_routes_tmp = Association::countAllLinked($summit_ids, 'sr');
             foreach ($summit_routes_tmp as $route) {
                 $summit_routes_ids[] = $route['linked_id'];
             }
         }
         // for a gite, routes  and sites are not directly linked. We retrieve the routes linked to the linked parkings
         if ($is_gite_camping) {
             $parking_ids = array();
             foreach ($associated_parkings as $parking) {
                 $parking_ids[] = $parking['id'];
             }
             $associated_parking_docs = Association::findLinkedDocsWithBestName($parking_ids, $prefered_cultures, array('pr', 'pt'), false, true);
             $associated_routes = array_filter($associated_parking_docs, array('c2cTools', 'is_route'));
             $associated_parking_sites = c2cTools::sortArrayByName(array_filter($associated_parking_docs, array('c2cTools', 'is_site')));
             $this->associated_sites = array_merge($this->associated_sites, $associated_parking_sites);
             // associated sites should be empty!! Else it violates moderation rules
             $this->ids = implode('-', $parking_ids);
         } else {
             $associated_routes = array_filter($this->associated_docs, array('c2cTools', 'is_route'));
             $this->associated_sites = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_site')));
             $this->ids = $current_doc_id;
         }
         // get additional data for routes
         $associated_routes = Route::getAssociatedRoutesData($associated_routes, $this->__(' :') . ' ', reset($summit_ids));
         // these are the routes where the hut act as a summit
         // they are displayed in a specific section
         $summit_ids = $summit_routes_tmp = $summit_routes_ids = $associated_summit_routes = array();
         if (count($associated_summits)) {
             foreach ($associated_summits as $summit) {
                 $summit_ids[] = $summit['id'];
             }
             $summit_routes_tmp = Association::countAllLinked($summit_ids, 'sr');
             foreach ($summit_routes_tmp as $route) {
                 $summit_routes_ids[] = $route['linked_id'];
             }
         }
         if (count($summit_routes_ids)) {
             foreach ($associated_routes as $key => $route) {
                 if (in_array($route['id'], $summit_routes_ids)) {
                     $associated_summit_routes[$key] = $route;
                     unset($associated_routes[$key]);
                 }
             }
         }
         $this->associated_routes = $associated_routes;
         $this->associated_summit_routes = $associated_summit_routes;
         // We retrieve both the books directly linked
         $associated_books = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_book')));
         // AND the books linked to linked routes
         // FIXME we should probably also do this with linked sites
         $route_ids = array();
         $associated_routes_books = array();
         if (count($associated_routes)) {
             foreach ($associated_routes as $route) {
                 if ($route['duration'] instanceof Doctrine_Null || $route['duration'] <= 4) {
                     $route_ids[] = $route['id'];
                 }
             }
             if (count($route_ids)) {
                 $book_ids = array();
                 foreach ($associated_books as $book) {
                     $book_ids[] = $book['id'];
                 }
                 $associated_route_docs = Association::findLinkedDocsWithBestName($route_ids, $prefered_cultures, array('br'), false, false, $book_ids);
                 if (count($associated_route_docs)) {
                     $associated_route_docs = c2cTools::sortArray($associated_route_docs, 'name');
                     $associated_routes_books = array_filter($associated_route_docs, array('c2cTools', 'is_book'));
                     foreach ($associated_routes_books as $key => $book) {
                         $associated_routes_books[$key]['parent_id'] = true;
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:101,代码来源:actions.class.php

示例9: getAssociatedHutsData

 public static function getAssociatedHutsData($associated_docs)
 {
     $huts = Document::fetchAdditionalFieldsFor(array_filter($associated_docs, array('c2cTools', 'is_hut')), 'Hut', array('elevation'));
     return c2cTools::sortArrayByName($huts);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:5,代码来源:Hut.class.php


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