.

AjaxView Class Reference
[Ajax]

Renders page as Ajax result. More...

Inheritance diagram for AjaxView:
PageViewBase ViewBase IView ICache IRenderer

List of all members.

Public Member Functions

  __construct ($page_data)
  Contructor takes the page data.

Protected Member Functions

  after_render (&$rendered_content, $policy)
  Called after content is rendered, but not if content is taken from cache.
  assign_default_vars ($policy)
  Assign variables.
  render_content (&$rendered_content, $policy)
  Sets content.
  render_postprocess (&$rendered_content, $policy)
  Called after content is rendered, always.
  should_cache ()
  Returns true, if cache should be used.

Detailed Description

Renders page as Ajax result.

In case of an error, the 'error' member gets set in return data. Else member 'result' is set to PageData::ajax_data

Author:
Gerd Riesselmann

Definition at line 11 of file ajaxview.cls.php.


Constructor & Destructor Documentation

AjaxView::__construct ( page_data  ) 

Contructor takes the page data.

Definition at line 15 of file ajaxview.cls.php.

00015                                                 {
00016                 parent::__construct($page_data, '');
00017         } 

Member Function Documentation

AjaxView::after_render ( &$  rendered_content,
policy  
) [protected]

Called after content is rendered, but not if content is taken from cache.

Parameters:
string  $rendered_content The content rendered
int  $policy If set to IView::DISPLAY, content is printed, if false it is returned only
Returns:
void

Reimplemented from ViewBase.

Definition at line 54 of file ajaxview.cls.php.

00054                                                                      {
00055                 // Do nothing here
00056         }
AjaxView::assign_default_vars ( policy  )  [protected]

Assign variables.

Parameters:
int  $policy If set to IView::DISPLAY, content is printed, if false it is returned only

Reimplemented from PageViewBase.

Definition at line 63 of file ajaxview.cls.php.

00063                                                         {
00064                 // Do nothing here      
00065         }
AjaxView::render_content ( &$  rendered_content,
policy  
) [protected]

Sets content.

Parameters:
mixed  $rendered_content The content rendered
int  $policy If set to IView::DISPLAY, content is printed, if false it is returned only
Returns:
void

Reimplemented from PageViewBase.

Definition at line 26 of file ajaxview.cls.php.

00026                                                                        {
00027                 $data = array();
00028                 $is_error = true;
00029                 switch ($this->page_data->status_code) {
00030                         case ControllerBase::ACCESS_DENIED:
00031                                 $data['error'] = tr('Access denied', 'core');
00032                                 break;
00033                         case ControllerBase::NOT_FOUND:
00034                                 $data['error'] = tr('Page not found', 'core');
00035                                 break;
00036                         case ControllerBase::INTERNAL_ERROR:
00037                                 $data['error'] = tr('Server error', 'core');
00038                                 break;
00039                         default:
00040                                 if ($this->page_data->status instanceof Status && $this->page_data->status->is_error()) {
00041                                         $is_error = true;
00042                                         $data['error'] = $this->page_data->status->to_string(Status::OUTPUT_PLAIN);
00043                                 }       
00044                                 else {
00045                                         $is_error = false;
00046                                         $data['result'] = $this->page_data->ajax_data;
00047                                 }
00048                                 break;
00049                 } 
00050                 $data['is_error'] = $is_error;
00051                 $rendered_content = ConverterFactory::encode($data, CONVERTER_JSON);
00052         }
AjaxView::render_postprocess ( &$  rendered_content,
policy  
) [protected]

Called after content is rendered, always.

Parameters:
mixed  $rendered_content The content rendered $policy If set to IView::DISPLAY, content is printed, if false it is returned only
Returns:
void

Reimplemented from PageViewBase.

Definition at line 83 of file ajaxview.cls.php.

00083                                                                            {
00084                 $this->send_status();
00085                 
00086                 if (!Common::flag_is_set($policy, self::CONTENT_ONLY)) {
00087                         header('Cache-Control: maxage=3600'); //Fix for IE in SSL 
00088                         header('Pragma: public');
00089                         //header('Content-Length: ') . strlen($rendered_content);                       
00090                         header('Content-Type: application/json');
00091                 }
00092         }       
AjaxView::should_cache (  )  [protected]

Returns true, if cache should be used.

Returns:
bool

Reimplemented from PageViewBase.

Definition at line 72 of file ajaxview.cls.php.

00072                                           {
00073                 return false;
00074         }       

The documentation for this class was generated from the following file: