diff --git a/application/webpage.class.inc.php b/application/webpage.class.inc.php index bc47c52ea..8a7cd06e7 100644 --- a/application/webpage.class.inc.php +++ b/application/webpage.class.inc.php @@ -31,41 +31,48 @@ Interface Page { public function output(); + public function add($sText); + public function p($sText); + public function pre($sText); + public function add_comment($sText); + public function table($aConfig, $aData, $aParams = array()); } - /** - * Simple helper class to ease the production of HTML pages + *
Simple helper class to ease the production of HTML pages * - * This class provide methods to add content, scripts, includes... to a web page + *
This class provide methods to add content, scripts, includes... to a web page * and renders the full web page by putting the elements in the proper place & order * when the output() method is called. - * Usage: - * $oPage = new WebPage("Title of my page"); - * $oPage->p("Hello World !"); - * $oPage->output(); + * + *
Usage: + * ```php + * $oPage = new WebPage("Title of my page"); + * $oPage->p("Hello World !"); + * $oPage->output(); + * ``` */ class WebPage implements Page { - protected $s_title; - protected $s_content; - protected $s_deferred_content; - protected $a_scripts; - protected $a_dict_entries; - protected $a_dict_entries_prefixes; - protected $a_styles; - protected $a_linked_scripts; - protected $a_linked_stylesheets; - protected $a_headers; - protected $a_base; - protected $iNextId; - protected $iTransactionId; + protected $s_title; + protected $s_content; + protected $s_deferred_content; + protected $a_scripts; + protected $a_dict_entries; + protected $a_dict_entries_prefixes; + protected $a_styles; + protected $a_linked_scripts; + protected $a_linked_stylesheets; + protected $a_headers; + protected $a_base; + protected $iNextId; + protected $iTransactionId; protected $sContentType; protected $sContentDisposition; protected $sContentFileName; @@ -73,241 +80,256 @@ class WebPage implements Page protected $s_sOutputFormat; protected $a_OutputOptions; protected $bPrintable; - - public function __construct($s_title, $bPrintable = false) - { - $this->s_title = $s_title; - $this->s_content = ""; - $this->s_deferred_content = ''; - $this->a_scripts = array(); - $this->a_dict_entries = array(); - $this->a_dict_entries_prefixes = array(); - $this->a_styles = array(); - $this->a_linked_scripts = array(); - $this->a_linked_stylesheets = array(); - $this->a_headers = array(); - $this->a_base = array( 'href' => '', 'target' => ''); - $this->iNextId = 0; - $this->iTransactionId = 0; - $this->sContentType = ''; - $this->sContentDisposition = ''; - $this->sContentFileName = ''; + + public function __construct($s_title, $bPrintable = false) + { + $this->s_title = $s_title; + $this->s_content = ""; + $this->s_deferred_content = ''; + $this->a_scripts = array(); + $this->a_dict_entries = array(); + $this->a_dict_entries_prefixes = array(); + $this->a_styles = array(); + $this->a_linked_scripts = array(); + $this->a_linked_stylesheets = array(); + $this->a_headers = array(); + $this->a_base = array('href' => '', 'target' => ''); + $this->iNextId = 0; + $this->iTransactionId = 0; + $this->sContentType = ''; + $this->sContentDisposition = ''; + $this->sContentFileName = ''; $this->bTrashUnexpectedOutput = false; $this->s_OutputFormat = utils::ReadParam('output_format', 'html'); $this->a_OutputOptions = array(); $this->bPrintable = $bPrintable; - ob_start(); // Start capturing the output - } - + ob_start(); // Start capturing the output + } + /** * Change the title of the page after its creation */ - public function set_title($s_title) - { - $this->s_title = $s_title; - } - + public function set_title($s_title) + { + $this->s_title = $s_title; + } + /** * Specify a default URL and a default target for all links on a page */ - public function set_base($s_href = '', $s_target = '') - { - $this->a_base['href'] = $s_href; - $this->a_base['target'] = $s_target; - } - + public function set_base($s_href = '', $s_target = '') + { + $this->a_base['href'] = $s_href; + $this->a_base['target'] = $s_target; + } + /** * Add any text or HTML fragment to the body of the page */ - public function add($s_html) - { - $this->s_content .= $s_html; - } - + public function add($s_html) + { + $this->s_content .= $s_html; + } + /** * Add any text or HTML fragment (identified by an ID) at the end of the body of the page * This is useful to add hidden content, DIVs or FORMs that should not - * be embedded into each other. + * be embedded into each other. */ - public function add_at_the_end($s_html, $sId = '') - { - $this->s_deferred_content .= $s_html; - } - + public function add_at_the_end($s_html, $sId = '') + { + $this->s_deferred_content .= $s_html; + } + /** * Add a paragraph to the body of the page */ - public function p($s_html) - { - $this->add($this->GetP($s_html)); - } - + public function p($s_html) + { + $this->add($this->GetP($s_html)); + } + /** * Add a pre-formatted text to the body of the page */ - public function pre($s_html) - { - $this->add('
'.$s_html.''); - } - + public function pre($s_html) + { + $this->add('
'.$s_html.''); + } + /** * Add a comment */ - public function add_comment($sText) - { - $this->add(''); - } + public function add_comment($sText) + { + $this->add(''); + } + /** * Add a paragraph to the body of the page */ - public function GetP($s_html) - { - return "
$s_html
\n"; - } - + public function GetP($s_html) + { + return "$s_html
\n"; + } + /** - * Adds a tabular content to the web page + * Adds a tabular content to the web page * * @param string[] $aConfig Configuration of the table: hash array of 'column_id' => 'Column Label' - * @param string[] $aData Hash array. Data to display in the table: each row is made of 'column_id' => Data. A column 'pkey' is expected for each row + * @param string[] $aData Hash array. Data to display in the table: each row is made of 'column_id' => Data. A + * column 'pkey' is expected for each row * @param array $aParams Hash array. Extra parameters for the table. * - * @return void - */ + * @return void + */ public function table($aConfig, $aData, $aParams = array()) { $this->add($this->GetTable($aConfig, $aData, $aParams)); } - + public function GetTable($aConfig, $aData, $aParams = array()) { $oAppContext = new ApplicationContext(); - + static $iNbTables = 0; $iNbTables++; $sHtml = ""; $sHtml .= "| ".$aDef['label']." | \n"; } $sHtml .= "
|---|