if ($pageclass == 'BananaPage') {
Banana::load('page');
}
- Banana::$page = new $pageclass;
+ Banana::$page = new $pageclass(@$this->params['output']);
$types = array('multipart/report' => _b_('Rapport d\'erreur'),
'multipart/mixed' => _b_('Composition'),
'text/html' => _b_('Texte formaté'),
protected $killed = array();
protected $actions = array();
+ protected $mode;
+ protected $json_params = array();
+
public $css = '';
- public function __construct()
+ public function __construct($mode)
{
parent::Smarty();
+ $this->mode = strtolower($mode);
$this->compile_check = Banana::$debug_smarty;
$this->template_dir = dirname(__FILE__) . '/templates/';
$this->compile_dir = Banana::$spool_root . '/templates_c/';
return true;
}
+ /** Assign a variable in the page.
+ */
+ public function assign($var, $value)
+ {
+ if ($this->mode === 'json') {
+ $this->json_params[$var] = $value;
+ } else {
+ parent::assign($var, $value);
+ }
+ }
+
/** Register an action to show on banana page
* @param action_code HTML code of the action
* @param pages ARRAY pages where to show the action (null == every pages)
*/
public function run()
{
+ if ($this->mode === 'json') {
+ return json_encode($this->json_params);
+ }
$tpl = $this->prepare();
if (!isset($this->pages[$this->page])) {
$this->trig(_b_('La page demandée n\'existe pas'));