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'));
*
* smarty funciton : {url param1=... param2=...}
*/
- public function makeUrl(array $params, &$smarty = null)
+ public function makeUrl(array $params, $smarty = null)
{
if (function_exists('hook_makeLink')
&& $res = hook_makeLink($params)) {
*
* Smarty function : {link param1=... param2=...}
*/
- public function makeLink(array $params, &$smarty = null)
+ public function makeLink(array $params, $smarty = null)
{
$catch = array('text', 'popup', 'class', 'accesskey', 'style');
foreach ($catch as $key) {
*
* Smarty function: {img img=... alt=... [height=...] [width=...]}
*/
- public function makeImg(array $params, &$smarty = null)
+ public function makeImg(array $params, $smarty = null)
{
$catch = array('img', 'alt', 'height', 'width');
foreach ($catch as $key) {
*
* Smarty function : {imglink img=... alt=... [param1=...]}
*/
- public function makeImgLink(array $params, &$smarty = null)
+ public function makeImgLink(array $params, $smarty = null)
{
if (!isset($params['popup'])) {
$params['popup'] = @$params['alt'];
// {{{ function banana_trimwhitespace
-function banana_trimwhitespace($source, &$smarty)
+function banana_trimwhitespace($source, $smarty)
{
$tags = array('script', 'pre', 'textarea');