If banana get output=json in its parameters, it will produce a json
output that can be used in order to update the page in javascript.
This works well with the box list, I didn't even test it on other pages.
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
if ($pageclass == 'BananaPage') {
Banana::load('page');
}
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é'),
$types = array('multipart/report' => _b_('Rapport d\'erreur'),
'multipart/mixed' => _b_('Composition'),
'text/html' => _b_('Texte formaté'),
protected $killed = array();
protected $actions = array();
protected $killed = array();
protected $actions = array();
+ protected $mode;
+ protected $json_params = array();
+
- public function __construct()
+ public function __construct($mode)
+ $this->mode = strtolower($mode);
$this->compile_check = Banana::$debug_smarty;
$this->template_dir = dirname(__FILE__) . '/templates/';
$this->compile_dir = Banana::$spool_root . '/templates_c/';
$this->compile_check = Banana::$debug_smarty;
$this->template_dir = dirname(__FILE__) . '/templates/';
$this->compile_dir = Banana::$spool_root . '/templates_c/';
+ /** 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)
/** 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()
{
*/
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'));
$tpl = $this->prepare();
if (!isset($this->pages[$this->page])) {
$this->trig(_b_('La page demandée n\'existe pas'));
<input type="submit" name="validsubs" value="{"Valider"|b}" />
</p>
{/if}
<input type="submit" name="validsubs" value="{"Valider"|b}" />
</p>
{/if}
+<table class="bicol banana_box_list">
<tr>
{if $withsubs}
<th></th>
<tr>
{if $withsubs}
<th></th>
$bt = $banana->backtrace(); // Get protocole execution backtrace
session_write_close();
$bt = $banana->backtrace(); // Get protocole execution backtrace
session_write_close();
+if (@strtolower($_GET['output']) === 'json') {
+ header('Content-Type: text/javascript');
+ echo $res;
+ exit;
+}
// Genererate the page
?>
// Genererate the page
?>