Exemple #1
0
 /**
  * Controller for mChat
  *
  * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
  */
 public function handle()
 {
     $ret = $this->render_helper->render_data_for_page();
     // If this was an ajax request, we just create an json_response and return that. It's not ours to handle here.
     if ($this->request->is_ajax() && is_array($ret) && isset($ret['json']) && $ret['json'] === true) {
         return new \Symfony\Component\HttpFoundation\JsonResponse($ret);
     }
     // If error occured, render it
     if (isset($ret['error']) && $ret['error'] == true) {
         return $this->helper->error($ret['error_text'], $ret['error_type']);
     }
     return $this->helper->render($ret['filename'], $ret['lang_title']);
 }
Exemple #2
0
 /**
  * Gets suggestions for tags based on a ajax request, route: /tags/suggest
  *
  * @param php://input raw post data must contain a json-encoded object of this structure: {"query":"...", "exclude":["...", "...", ...]}
  */
 public function suggest_tags()
 {
     if (false && $this->request->is_ajax()) {
         $data = json_decode(file_get_contents('php://input'), true);
         $query = $data['query'];
         $exclude = $data['exclude'];
         $tags = $this->tags_manager->get_tag_suggestions($query, $exclude, 5);
         $json_response = new json_response();
         $json_response->send($tags);
     }
     // fake a 404
     return $this->helper->error($this->user->lang('RH_TOPICTAGS_TAG_SUGGEST_TAG_ROUTE_ERROR', $this->helper->get_current_url()), 404);
 }
Exemple #3
0
 public function finish($message, $status_code, $redirect_time = 5, $route = 'slider_controller')
 {
     $this->meta_refresh($redirect_time, $route);
     return $this->helper->error($this->user->lang($message), $status_code);
 }
Exemple #4
0
 /**
  * {@inheritDoc}
  */
 public function error($message, $code = 500)
 {
     return parent::error($this->user->lang($message), $code);
 }