本文整理汇总了PHP中Book::getAssociatedBooksData方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getAssociatedBooksData方法的具体用法?PHP Book::getAssociatedBooksData怎么用?PHP Book::getAssociatedBooksData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::getAssociatedBooksData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setEditFormInformation
public function setEditFormInformation()
{
parent::setEditFormInformation();
if (!$this->new_document) {
$this->title_prefix = $this->getHighestSummitName();
$this->setPageTitle($this->__('Edition of "%1%"', array('%1%' => $this->title_prefix . $this->__(' :') . ' ' . $this->document->getName())));
// retrieve associated books for displaying them near bibliography field
$prefered_cultures = $this->getUser()->getCulturesForDocuments();
$id = $this->getRequestParameter('id');
$this->associated_books = Book::getAssociatedBooksData(Association::findAllWithBestName($id, $prefered_cultures, 'br'));
}
}
示例2: executeView
//.........这里部分代码省略.........
}
}
$over_summit_name_2 = false;
$over_summit_name_3 = false;
foreach ($sub_summit_names as $sub_summit_name) {
if (!$over_summit_name_3 && strpos($sub_summit_name, $summit_name) === 0) {
$over_summit_name_2 = true;
} else {
if (!empty($over_summit_name) && strpos($sub_summit_name, $over_summit_name) !== false) {
$over_summit_name_3 = true;
}
}
}
if ($over_summit_name_2) {
$over_summit_name = $summit_name;
}
}
} else {
$associated_summits = $main_associated_summits;
}
$this->associated_summits = $associated_summits;
array_unshift($sub_summit_ids, $current_doc_id);
$this->ids = implode('-', $sub_summit_ids);
// second param will not display the summit name before the route when the summit is the one of the document
$associated_routes = Route::getAssociatedRoutesData($this->associated_docs, $this->__(' :') . ' ', $this->document->get('id'), $over_summit_name);
$this->associated_routes = $associated_routes;
$associated_books = c2cTools::sortArrayByName(array_filter($this->associated_docs, array('c2cTools', 'is_book')));
$doc_ids = array();
$associated_huts = array();
$associated_parkings = array();
$associated_routes_books = array();
if (count($associated_routes) || count($associated_sites)) {
foreach ($associated_routes as $route) {
if ($route['duration'] instanceof Doctrine_Null || $route['duration'] <= 4) {
$doc_ids[] = $route['id'];
}
}
foreach ($associated_sites as $site) {
$doc_ids[] = $site['id'];
}
if (count($doc_ids)) {
$book_ids = array();
foreach ($associated_books as $book) {
$book_ids[] = $book['id'];
}
$associated_route_docs = Association::findLinkedDocsWithBestName($doc_ids, $prefered_cultures, array('hr', 'ht', 'pr', 'pt', 'br'), false, false, $book_ids);
if (count($associated_route_docs)) {
$associated_route_docs = c2cTools::sortArray($associated_route_docs, 'elevation');
$associated_huts = array_filter($associated_route_docs, array('c2cTools', 'is_hut'));
$associated_parkings = Parking::getAssociatedParkingsData(array_filter($associated_route_docs, array('c2cTools', 'is_parking')));
$associated_routes_books = c2cTools::sortArray(array_filter($associated_route_docs, array('c2cTools', 'is_book')), 'name');
foreach ($associated_routes_books as $key => $book) {
$associated_routes_books[$key]['parent_id'] = true;
}
}
}
}
$this->associated_huts = $associated_huts;
$this->associated_parkings = $associated_parkings;
$associated_books = array_merge($associated_books, $associated_routes_books);
if (count($associated_books)) {
$associated_books = Book::getAssociatedBooksData($associated_books);
}
$this->associated_books = $associated_books;
// get associated outings
$latest_outings = array();
$nb_outings = 0;
if (count($associated_routes)) {
$outing_params = array('summits' => $this->ids);
$nb_outings = sfConfig::get('app_nb_linked_outings_docs');
$latest_outings = Outing::listLatest($nb_outings + 1, array(), array(), array(), $outing_params, false);
$latest_outings = Language::getTheBest($latest_outings, 'Outing');
}
$this->latest_outings = $latest_outings;
$this->nb_outings = $nb_outings;
$this->associated_images = Document::fetchAdditionalFieldsFor(array_filter($this->associated_docs, array('c2cTools', 'is_image')), 'Image', array('filename', 'image_type', 'date_time', 'width', 'height'));
$cab = count($associated_books);
$this->section_list = array('books' => $cab != 0, 'map' => (bool) $this->document->get('geom_wkt'));
$related_portals = array();
Portal::getRelatedPortals($related_portals, $this->associated_areas, $associated_routes);
$summit_type_index = $this->document->get('summit_type');
if ($summit_type_index == 5 && !in_array('raid', $related_portals)) {
$related_portals[] = 'raid';
}
$this->related_portals = $related_portals;
$summit_type_list = sfConfig::get('app_summits_summit_types');
$summit_type_list[1] = 'summit';
$summit_type = $this->__($summit_type_list[$summit_type_index]);
$doc_name = $summit_name;
$title = $doc_name;
if ($this->document->isArchive()) {
$version = $this->getRequestParameter('version');
$title .= ' :: ' . $this->__('revision') . ' ' . $version;
}
$title .= ' :: ' . $summit_type;
$this->setPageTitle($title);
$description = array($summit_type . ' :: ' . $doc_name, $this->document->get('elevation') . $this->__('meters'), $this->getAreasList());
$this->getResponse()->addMeta('description', implode(' - ', $description));
}
}
示例3: executeView
//.........这里部分代码省略.........
$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;
}
}
}
}
$associated_books = array_merge($associated_books, $associated_routes_books);
if (count($associated_books)) {
$associated_books = Book::getAssociatedBooksData($associated_books);
}
$this->associated_books = $associated_books;
// get associated outings
$latest_outings = array();
$nb_outings = 0;
if (!$is_gite_camping && count($associated_routes) || $is_gite_camping && count($parking_ids)) {
if (!$is_gite_camping) {
$outing_params = array('huts' => $current_doc_id);
} else {
$outing_params = array('parkings' => $this->ids);
}
$nb_outings = sfConfig::get('app_nb_linked_outings_docs');
$latest_outings = Outing::listLatest($nb_outings + 1, array(), array(), array(), $outing_params, false);
$latest_outings = Language::getTheBest($latest_outings, 'Outing');
}
$this->latest_outings = $latest_outings;
$this->nb_outings = $nb_outings;
// possibly related portals
$related_portals = array();
Portal::getRelatedPortals($related_portals, $this->associated_areas, $associated_routes);
$this->related_portals = $related_portals;
$cab = count($associated_books);
$this->section_list = array('books' => $cab != 0, 'map' => (bool) $this->document->get('geom_wkt'));
$hut_type_list = sfConfig::get('mod_huts_shelter_types_list');
$hut_type_index = $this->document->get('shelter_type');
$hut_type = $this->__($hut_type_list[$hut_type_index]);
$doc_name = $this->document->get('name');
$title = $doc_name;
if ($this->document->isArchive()) {
$version = $this->getRequestParameter('version');
$title .= ' :: ' . $this->__('revision') . ' ' . $version;
}
$title .= ' :: ' . $hut_type;
$this->setPageTitle($title);
$description = array($hut_type . ' :: ' . $doc_name, $this->getActivitiesList(), $this->getAreasList());
$this->getResponse()->addMeta('description', implode(' - ', $description));
}
}
示例4: setEditFormInformation
public function setEditFormInformation()
{
parent::setEditFormInformation();
if (!$this->new_document) {
// retrieve associated books for displaying them near bibliography field
$prefered_cultures = $this->getUser()->getCulturesForDocuments();
$id = $this->getRequestParameter('id');
$this->associated_books = Book::getAssociatedBooksData(Association::findAllWithBestName($id, $prefered_cultures, 'bt'));
}
}
示例5: 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');
$main_associated_parkings = c2cTools::sortArray(array_filter($this->associated_docs, array('c2cTools', 'is_parking')), 'elevation');
// Idea here is to retrieve not only the routes linked directly to the parking, but also the ones
// associated to the sub(-sub)-parkings
// We also do this for products and huts
$parking_ids = array();
if (count($main_associated_parkings)) {
$associated_parkings = Association::createHierarchyWithBestName($main_associated_parkings, $prefered_cultures, array('type' => 'pp', 'current_doc_id' => $current_doc_id, 'keep_current_doc' => true));
$associated_parkings = Parking::getAssociatedParkingsData($associated_parkings);
// simply go through the list and get the next items that have a bigger level
$i = reset($associated_parkings);
while (!isset($i['is_doc'])) {
$i = next($associated_parkings);
}
$doc_level = $i['level'];
$i = next($associated_parkings);
while ($i !== false && $i['level'] > $doc_level) {
$parking_ids[] = $i['id'];
$i = next($associated_parkings);
}
if (count($parking_ids)) {
$this->associated_docs = array_merge($this->associated_docs, Association::findLinkedDocsWithBestName($parking_ids, $prefered_cultures, array('pr', 'ph', 'pf')));
}
} else {
$associated_parkings = $main_associated_parkings;
}
$this->associated_parkings = $associated_parkings;
array_unshift($parking_ids, $current_doc_id);
$this->ids = implode('-', $parking_ids);
$associated_routes = Route::getAssociatedRoutesData($this->associated_docs, $this->__(' :') . ' ');
$this->associated_routes = $associated_routes;
// related books (associated to the above mentioned routes)
$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)) {
$associated_route_docs = Association::findLinkedDocsWithBestName($route_ids, $prefered_cultures, array('br'), false, false);
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;
}
}
}
}
$cab = 0;
if (count($associated_routes_books)) {
$associated_books = Book::getAssociatedBooksData($associated_routes_books);
$this->associated_books = $associated_books;
$cab = count($associated_books);
}
// get associated outings (to the above mentionned routes)
$latest_outings = array();
$nb_outings = 0;
if (count($associated_routes)) {
$outing_params = array('parkings' => $this->ids);
$nb_outings = sfConfig::get('app_nb_linked_outings_docs');
$latest_outings = Outing::listLatest($nb_outings + 1, array(), array(), array(), $outing_params, false);
$latest_outings = Language::getTheBest($latest_outings, 'Outing');
}
$this->latest_outings = $latest_outings;
$this->nb_outings = $nb_outings;
// associated huts
$this->associated_huts = c2cTools::sortArray(array_filter($this->associated_docs, array('c2cTools', 'is_hut')), 'elevation');
// asscoiated products
$this->associated_products = c2cTools::sortArray(array_filter($this->associated_docs, array('c2cTools', 'is_product')), 'name');
// related portals
$related_portals = array();
$public_transportation_rating = $this->document->get('public_transportation_rating');
if (in_array($public_transportation_rating, array(1, 2, 4, 5))) {
$related_portals[] = 'cda';
}
Portal::getRelatedPortals($related_portals, $this->associated_areas, $associated_routes);
$this->related_portals = $related_portals;
$this->section_list = array('books' => $cab != 0, 'map' => (bool) $this->document->get('geom_wkt'));
$description = array($this->__('parking') . ' :: ' . $this->document->get('name'), $this->getAreasList());
$this->getResponse()->addMeta('description', implode(' - ', $description));
}
}