* @author Denis Flaven * @license http://www.opensource.org/licenses/lgpl-license.php LGPL */ class ajax_page extends web_page { /** * Jquery style ready script * @var Hash */ protected $m_sReadyScript; /** * constructor for the web page * @param string $s_title Not used */ function __construct($s_title) { parent::__construct($s_title); $this->m_sReadyScript = ""; } /** * Echoes the content of the whole page * @return void */ public function output() { foreach($this->a_headers as $s_header) { header($s_header); } $s_captured_output = ob_get_contents(); ob_end_clean(); echo trim($this->s_content); if (!empty($this->m_sReadyScript)) { echo "\n"; } if (trim($s_captured_output) != "") { echo $s_captured_output; } } /** * Adds a paragraph with a smaller font into the page * NOT implemented (i.e does nothing) * @param string $sText Content of the (small) paragraph * @return void */ public function small_p($sText) { } /** * Adds a tabular content to the web page * @param Hash $aConfig Configuration of the table: hash array of 'column_id' => 'Column Label' * @param Hash $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 Hash $aParams Hash array. Extra parameters for the table. Entry 'class' holds the class of the objects listed in the table * @return void */ public function table($aConfig, $aData, $aParams = array()) { // WARNING WARNING WARNING // This whole function is actually a copy paste from iTopWebPage::table $oAppContext = new ApplicationContext(); static $iNbTables = 0; $iNbTables++; $sHtml = ""; $sHtml .= "\n"; $sHtml .= "\n"; $sHtml .= "\n"; foreach($aConfig as $sName=>$aDef) { $sHtml .= "\n"; } $sHtml .= "\n"; $sHtml .= "\n"; $sHtml .= "\n"; foreach($aData as $aRow) { if (false) //(isset($aParams['preview']) && $aParams['preview']) { $sHtml .= "\n"; } else if (isset($aRow['key'])) { $sHtml .= "\n"; } else { $sHtml .= "\n"; } foreach($aConfig as $sName=>$aVoid) { if ($sName != 'key') { $sValue = empty($aRow[$sName]) ? ' ' : $aRow[$sName]; $sHtml .= "\n"; } else { $sUIPage = cmdbAbstractObject::ComputeUIPage($aParams['class']); $sHtml .= "\n"; } } $sHtml .= "\n"; } $sHtml .= "\n"; $sHtml .= "
".$aDef['label']."
$sValueGetForLink()."\">
\n"; if (isset($aParams['preview']) && $aParams['preview']) { $sHtml .= "
Preview Pane
"; } $this->add($sHtml); } /** * Adds a script to be executed when the DOM is ready (typical JQuery use) * NOT implemented in this version of the class. * @return void */ public function add_ready_script($sScript) { // Does nothing in ajax rendered content.. for now... // Maybe we should add this as a simple