Exemplo n.º 1
0
 /**
  * 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);
 }