X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fpage.inc.php;h=40fd970835ad89ef99950975648185b2bf2f2afa;hb=460165f7b2df7da02a66963151b74526c12df36d;hp=fef01968d2f4cea3fe5c8a19175e456ff6a2cfe8;hpb=a9676fc7d3f11230cc4be6d84eb4afb97f17ea46;p=banana.git diff --git a/banana/page.inc.php b/banana/page.inc.php index fef0196..40fd970 100644 --- a/banana/page.inc.php +++ b/banana/page.inc.php @@ -7,24 +7,24 @@ * Copyright: See COPYING files that comes with this distribution ********************************************************************************/ -if (!include_once('Smarty.class.php')) { +if (@!include_once('Smarty.class.php')) { require_once 'smarty/libs/Smarty.class.php'; } class BananaPage extends Smarty { - private $error = array(); - private $page = null; + protected $error = array(); + protected $page = null; - private $pages = array(); - private $killed = array(); - private $actions = array(); + protected $pages = array(); + protected $killed = array(); + protected $actions = array(); public $css = ''; public function __construct() { - $this->Smarty(); + parent::Smarty(); $this->compile_check = Banana::$debug_smarty; $this->template_dir = dirname(__FILE__) . '/templates/'; @@ -67,7 +67,7 @@ class BananaPage extends Smarty * @param action_code HTML code of the action * @param pages ARRAY pages where to show the action (null == every pages) * @return true if success - */ + */ public function registerAction($action_code, array $pages = null) { $this->actions[] = array('text' => $action_code, 'pages' => $pages); @@ -112,7 +112,17 @@ class BananaPage extends Smarty if (!is_null(Banana::$group)) { $this->registerPage('thread', Banana::$group, null); if (!is_null(Banana::$artid)) { - $this->registerPage('message', _b_('Message'), null); + if (Banana::$spool) { + $subject = Banana::$spool->overview[Banana::$artid]->subject; + } else if (Banana::$message) { + $subject = Banana::$message->getHeaderValue('subject'); + } else { + $subject = _b_('Message'); + } + if (strlen($subject) > 30) { + $subject = substr($subject, 0, 30) . '…'; + } + $this->registerPage('message', $subject, null); if ($this->page == 'cancel') { $this->registerPage('cancel', _b_('Annulation'), null); } elseif ($this->page == 'new') { @@ -133,7 +143,7 @@ class BananaPage extends Smarty return 'banana-base.tpl'; } - + /** Generate XHTML code */ public function run() @@ -182,6 +192,7 @@ class BananaPage extends Smarty $this->assign('withtabs' , Banana::$withtabs); $this->assign('feed_format', Banana::$feed_format); $this->assign('feed_active', Banana::$feed_active); + $this->assign('with_javascript', Banana::$msgshow_javascript); $this->register_function('url', array($this, 'makeUrl')); $this->register_function('link', array($this, 'makeLink')); @@ -214,7 +225,7 @@ class BananaPage extends Smarty * @param params ARRAY location datas * @param smarty OBJECT Smarty instance associated (null if none) * @return URL of the page associated with the given parameters - * + * * Usual parameters are : * - group : the box name * - artid : the current message id (index of message-id) @@ -230,11 +241,11 @@ class BananaPage extends Smarty if (function_exists('hook_makeLink') && $res = hook_makeLink($params)) { return $res; - } + } $proto = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; $host = Banana::$baseurl ? Banana::$baseurl : $_SERVER['SERVER_NAME']; $file = $_SERVER['PHP_SELF']; - + if (count($params) != 0) { $get = '?'; foreach ($params as $key=>$value) { @@ -245,7 +256,7 @@ class BananaPage extends Smarty } } else { $get = ''; - } + } return $proto . $host . $file . $get; } @@ -265,7 +276,7 @@ class BananaPage extends Smarty */ public function makeLink(array $params, &$smarty = null) { - $catch = array('text', 'popup', 'class', 'accesskey'); + $catch = array('text', 'popup', 'class', 'accesskey', 'style'); foreach ($catch as $key) { ${$key} = isset($params[$key]) ? $params[$key] : null; unset($params[$key]); @@ -283,11 +294,14 @@ class BananaPage extends Smarty if (!is_null($class)) { $class = ' class="' . $class . '"'; } + if (!is_null($style)) { + $style = ' style="' . $style . '"'; + } if (!is_null($accesskey)) { $accesskey = ' accesskey="' . $accesskey . '"'; } return '' . $text . ''; } @@ -330,7 +344,7 @@ class BananaPage extends Smarty return '' . _b_($alt) . ''; } - + /** Build a link to one of the banana built-in javascript * @param src STRING javascript name * @return Javascript tag @@ -352,7 +366,7 @@ class BananaPage extends Smarty return ''; } - + /** Build a link with an image as text * @param params ARRAY image and location data * @param smarty OBJECT Smarty instance associated (null if none) @@ -367,7 +381,7 @@ class BananaPage extends Smarty { if (!isset($params['popup'])) { $params['popup'] = @$params['alt']; - } + } $img = $this->makeImg($params, $smarty); if (isset($params['text'])) { $img .= ' ' . $params['text']; @@ -386,6 +400,7 @@ class BananaPage extends Smarty public function redirect(array $params = array()) { header('Location: ' . $this->makeUrl($params)); + exit; } }