/** * returns a short description of current document in best possible lang */ public function executeGetdescription() { $id = $this->getRequestParameter('id'); if (!$id) { return $this->ajax_feedback('Missing id parameter'); } $user = $this->getUser(); // if session is time-over if (!$user->getId()) { return $this->ajax_feedback('Your session is over. Please login again.'); } $user_prefered_langs = $user->getCulturesForDocuments(); $desc = DocumentI18n::findBestDescription($id, $user_prefered_langs, $this->model_class); if (!$desc) { return $this->ajax_feedback('not available'); } $max = sfConfig::get('app_shortdescription_max_length'); $output = substr($desc, 0, $max); $output .= strlen($desc) > $max ? '...' : ''; return $this->renderText($output); }