From 1a659cc4d0ffdbf9e149afbf5c7cf8387f782594 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 7 Mar 2012 16:40:22 +0000 Subject: [PATCH] Experimental support of PDF output for iTop pages, provided that mPDF is installed in lib/MPDF SVN:1.2[1876] --- application/itopwebpage.class.inc.php | 696 +++++++++++++------------- application/webpage.class.inc.php | 66 +++ 2 files changed, 423 insertions(+), 339 deletions(-) diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index 3939e4c9d..e4abb883c 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -32,13 +32,13 @@ require_once(APPROOT."/application/user.preferences.class.inc.php"); class iTopWebPage extends NiceWebPage { private $m_sMenu; -// private $m_currentOrganization; + // private $m_currentOrganization; private $m_aTabs; private $m_sCurrentTabContainer; private $m_sCurrentTab; private $m_sMessage; private $m_sInitScript; - + public function __construct($sTitle) { parent::__construct($sTitle); @@ -159,7 +159,7 @@ class iTopWebPage extends NiceWebPage alert(err); } EOF -; + ; $this->add_ready_script( <<< EOF //add new widget called TruncatedList to properly display truncated lists when they are sorted @@ -354,7 +354,7 @@ EOF $('.caselog_header').click( function () { $(this).toggleClass('open').next('.caselog_entry').toggle(); }); EOF -); + ); $sUserPrefs = appUserPreferences::GetAsJSON(); $this->add_script( <<m_sMenu .= $sHtml; @@ -475,7 +475,7 @@ EOF $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); $oSet = new CMDBObjectSet($oSearchFilter); $iCount = $oSet->Count(); // total number of existing Orgs - + // Now get the list of Orgs to be displayed in the menu $oSearchFilter = DBObjectSearch::FromOQL(ApplicationMenu::GetFavoriteSiloQuery()); $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); @@ -488,76 +488,76 @@ EOF switch($iCount) { case 0: - // No such dimension/silo => nothing to select - $sHtml = '
'; - break; - + // No such dimension/silo => nothing to select + $sHtml = '
'; + break; + case 1: - // Only one possible choice... no selection, but display the value - $oOrg = $oSet->Fetch(); - $sHtml = '
'.$oOrg->GetName().'
'; - $sHtml .= ''; - break; - + // Only one possible choice... no selection, but display the value + $oOrg = $oSet->Fetch(); + $sHtml = '
'.$oOrg->GetName().'
'; + $sHtml .= ''; + break; + default: - $sHtml = ''; - $oAppContext = new ApplicationContext(); - $iCurrentOrganization = $oAppContext->GetCurrentValue('org_id'); - $sHtml = '
'; - $sHtml .= '
'; //'; + /* + $sSelected = ($iCurrentOrganization == '') ? ' selected' : ''; + $sHtml .= ''; + while($oOrg = $oSet->Fetch()) + { + if ($iCurrentOrganization == $oOrg->GetKey()) + { + // $oCurrentOrganization = $oOrg; $sSelected = " selected"; - - } - else - { + + } + else + { $sSelected = ""; - } - $sHtml .= ''; - } - $sHtml .= ''; -*/ - $sFavoriteOrgs = ''; - $oWidget = new UIExtKeyWidget('Organization', 'org_id', '', true /* search mode */); - $sHtml .= $oWidget->Display($this, 50, false, '', $oSet, $iCurrentOrganization, 'org_id', false, 'c[org_id]', '', array('iFieldSize' => 20, 'iMinChars' => MetaModel::GetConfig()->Get('min_autocomplete_chars'), 'sDefaultValue' => Dict::S('UI:AllOrganizations'))); - $this->add_ready_script('$("#org_id").bind("extkeychange", function() { $("#SiloSelection form").submit(); } )'); - $this->add_ready_script("$('#label_org_id').click( function() { $(this).val(''); $('#org_id').val(''); return true; } );\n"); - // Add other dimensions/context information to this form - $oAppContext->Reset('org_id'); // org_id is handled above and we want to be able to change it here ! - $oAppContext->Reset('menu'); // don't pass the menu, since a menu may expect more parameters - $sHtml .= $oAppContext->GetForForm(); // Pass what remains, if anything... - $sHtml .= '
'; - $sHtml .= '
'; + } + $sHtml .= ''; + } + $sHtml .= ''; + */ + $sFavoriteOrgs = ''; + $oWidget = new UIExtKeyWidget('Organization', 'org_id', '', true /* search mode */); + $sHtml .= $oWidget->Display($this, 50, false, '', $oSet, $iCurrentOrganization, 'org_id', false, 'c[org_id]', '', array('iFieldSize' => 20, 'iMinChars' => MetaModel::GetConfig()->Get('min_autocomplete_chars'), 'sDefaultValue' => Dict::S('UI:AllOrganizations'))); + $this->add_ready_script('$("#org_id").bind("extkeychange", function() { $("#SiloSelection form").submit(); } )'); + $this->add_ready_script("$('#label_org_id').click( function() { $(this).val(''); $('#org_id').val(''); return true; } );\n"); + // Add other dimensions/context information to this form + $oAppContext->Reset('org_id'); // org_id is handled above and we want to be able to change it here ! + $oAppContext->Reset('menu'); // don't pass the menu, since a menu may expect more parameters + $sHtml .= $oAppContext->GetForForm(); // Pass what remains, if anything... + $sHtml .= ''; + $sHtml .= ''; } - return $sHtml; + return $sHtml; } - - public function DisplayMenu() - { + + public function DisplayMenu() + { // Display the menu $oAppContext = new ApplicationContext(); $iAccordionIndex = 0; ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash()); - } + } /** * Outputs (via some echo) the complete HTML page by assembling all its elements */ - public function output() - { + public function output() + { $sForm = $this->GetSiloSelectionForm(); $this->DisplayMenu(); // Compute the menu // Put here the 'ready scripts' that must be executed after all others - $this->add_ready_script( + $this->add_ready_script( <<a_headers as $s_header) - { - header($s_header); - } - $s_captured_output = ob_get_contents(); - ob_end_clean(); - echo "\n"; - echo "\n"; - echo "\n"; - // Make sure that Internet Explorer renders the page using its latest/highest/greatest standards ! - echo "\n"; - echo "\n"; - echo "".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."\n"; - echo $this->get_base_tag(); - // Stylesheets MUST be loaded before any scripts otherwise - // jQuery scripts may face some spurious problems (like failing on a 'reload') - foreach($this->a_linked_stylesheets as $a_stylesheet) - { - if ($a_stylesheet['condition'] != "") + ); + if ($this->GetOutputFormat() == 'html') + { + foreach($this->a_headers as $s_header) { - echo "\n"; - } - } - foreach($this->a_linked_scripts as $s_script) - { - // Make sure that the URL to the script contains the application's version number - // so that the new script do NOT get reloaded from the cache when the application is upgraded - if (strpos($s_script, '?') === false) - { - $s_script .= "?itopversion=".ITOP_VERSION; - } - else - { - $s_script .= "&itopversion=".ITOP_VERSION; - } - echo "\n"; - } - $this->add_script("\$(document).ready(function() {\n{$this->m_sInitScript};\nwindow.setTimeout('onDelayedReady()',10)\n});"); - if (count($this->m_aReadyScripts)>0) - { - $this->add_script("\nonDelayedReady = function() {\n".implode("\n", $this->m_aReadyScripts)."\n}\n"); } - if (count($this->a_scripts)>0) - { - echo "\n"; - } - - if (count($this->a_styles)>0) - { - echo "\n"; - } - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; + $s_captured_output = ob_get_contents(); + ob_end_clean(); + $sHtml = "\n"; + $sHtml .= "\n"; + $sHtml .= "\n"; + // Make sure that Internet Explorer renders the page using its latest/highest/greatest standards ! + $sHtml .= "\n"; + $sHtml .= "\n"; + $sHtml .= "".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."\n"; + $sHtml .= $this->get_base_tag(); + // Stylesheets MUST be loaded before any scripts otherwise + // jQuery scripts may face some spurious problems (like failing on a 'reload') + foreach($this->a_linked_stylesheets as $a_stylesheet) + { + if ($a_stylesheet['condition'] != "") + { + $sHtml .= "\n"; + } + } + // special stylesheet for printing, hides the navigation gadgets + $sHtml .= "\n"; + + if ($this->GetOutputFormat() == 'html') + { + foreach($this->a_linked_scripts as $s_script) + { + // Make sure that the URL to the script contains the application's version number + // so that the new script do NOT get reloaded from the cache when the application is upgraded + if (strpos($s_script, '?') === false) + { + $s_script .= "?itopversion=".ITOP_VERSION; + } + else + { + $s_script .= "&itopversion=".ITOP_VERSION; + } + $sHtml .= "\n"; + } + $this->add_script("\$(document).ready(function() {\n{$this->m_sInitScript};\nwindow.setTimeout('onDelayedReady()',10)\n});"); + if (count($this->m_aReadyScripts)>0) + { + $this->add_script("\nonDelayedReady = function() {\n".implode("\n", $this->m_aReadyScripts)."\n}\n"); + } + if (count($this->a_scripts)>0) + { + $sHtml .= "\n"; + } + } + + if (count($this->a_styles)>0) + { + $sHtml .= "\n"; + } + $sHtml .= "\n"; + $sHtml .= "\n"; + + $sHtml .= "\n"; + $sHtml .= "\n"; @@ -668,7 +677,7 @@ EOF // 2) clicking on it will erase it $sText = Dict::S("UI:YourSearch"); $sOnClick = " onclick=\"this.value='';this.onclick=null;\""; - } + } // Render the tabs in the page (if any) foreach($this->m_aTabs as $sTabContainerName => $m_aTabs) { @@ -676,149 +685,180 @@ EOF $container_index = 0; if (count($m_aTabs) > 0) { - $sTabs = "\n
\n"; - $sTabs .= "\n"; - // Now add the content of the tabs themselves - $i = 0; - foreach($m_aTabs as $sTabName => $sTabContent) - { - $sTabs .= "
".$sTabContent."
\n"; - $i++; - } - $sTabs .= "
\n\n"; - } + $sTabs = "\n
\n"; + $sTabs .= "\n"; + // Now add the content of the tabs themselves + $i = 0; + foreach($m_aTabs as $sTabName => $sTabContent) + { + $sTabs .= "
".$sTabContent."
\n"; + $i++; + } + $sTabs .= "
\n\n"; + } $this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content); $container_index++; } - $sUserName = UserRights::GetUser(); - $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : ''; - if (UserRights::IsAdministrator()) - { - $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName); - } - else - { - $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName); - } - $sLogOffMenu = "\n"; - $sRestrictions = ''; - if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) + if ($this->GetOutputFormat() == 'html') { + $sUserName = UserRights::GetUser(); + $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : ''; + if (UserRights::IsAdministrator()) + { + $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName); + } + else + { + $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName); + } + $sLogOffMenu = "\n"; + + $sRestrictions = ''; if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) { - $sRestrictions = Dict::S('UI:AccessRO-All'); + if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) + { + $sRestrictions = Dict::S('UI:AccessRO-All'); + } } - } - elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE)) - { - $sRestrictions = Dict::S('UI:AccessRO-Users'); - } - - if (strlen($sRestrictions) > 0) - { - $sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message')); - $sApplicationBanner = '
'; - $sApplicationBanner .= ''; - $sApplicationBanner .= ' '.$sRestrictions.''; - if (strlen($sAdminMessage) > 0) + elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE)) { - $sApplicationBanner .= ' '.$sAdminMessage.''; + $sRestrictions = Dict::S('UI:AccessRO-Users'); } - $sApplicationBanner .= '
'; - } - else if(strlen($this->m_sMessage)) - { - $sApplicationBanner = '
'.$this->m_sMessage.'
'; + + if (strlen($sRestrictions) > 0) + { + $sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message')); + $sApplicationBanner = '
'; + $sApplicationBanner .= ''; + $sApplicationBanner .= ' '.$sRestrictions.''; + if (strlen($sAdminMessage) > 0) + { + $sApplicationBanner .= ' '.$sAdminMessage.''; + } + $sApplicationBanner .= '
'; + } + else if(strlen($this->m_sMessage)) + { + $sApplicationBanner = '
'.$this->m_sMessage.'
'; + } + else + { + $sApplicationBanner = ''; + } + + $sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help'); + //$sLogOffMenu = ""; + + $sHtml .= '
'; + $sHtml .= ''; + $sHtml .= ' '; + $sHtml .= '
'; + $sHtml .= '
pin
'; + $sHtml .= '
'.self::FilterXSS($sForm).'
'; + $sHtml .= '
'; + $sHtml .= ' '; + $sHtml .= ' '; + $sHtml .= ''; + $sHtml .= '
'; + + $sHtml .= '
'; + $sHtml .= '
'; + $sHtml .= self::FilterXSS($sApplicationBanner); + $sHtml .= ' '; + //echo '        
'; + $sHtml .= '
'; + $sHtml .= '
'; + $sHtml .= ' '; + $sHtml .= self::FilterXSS($this->s_content); + $sHtml .= ' '; + $sHtml .= '
'; + $sHtml .= ''; + + // Add the captured output + if (trim($s_captured_output) != "") + { + $sHtml .= "
".self::FilterXSS($s_captured_output)."
\n"; + } + $sHtml .= "
".self::FilterXSS($this->s_deferred_content)."
"; + // echo $this->s_deferred_content; + $sHtml .= "
Please wait...
\n"; // jqModal Window + $sHtml .= "
"; + $sHtml .= "
"; } else { - $sApplicationBanner = ''; + $sHtml .= self::FilterXSS($this->s_content); } - $sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help'); - //$sLogOffMenu = ""; + $sHtml .= "\n"; + $sHtml .= "\n"; - echo '
'; - echo ''; - echo ' '; - echo '
'; - echo '
pin
'; - echo '
'.self::FilterXSS($sForm).'
'; - echo '
'; - echo ' '; - echo ' '; - echo ''; - echo '
'; + if ($this->GetOutputFormat() == 'html') + { + echo $sHtml; + } + else if ($this->GetOutputFormat() == 'pdf' && $this->IsOutputFormatAvailable('pdf') ) + { + require_once(APPROOT.'lib/MPDF/mpdf.php'); + $oMPDF = new mPDF('c'); + $oMPDF->mirroMargins = false; + if ($this->a_base['href'] != '') + { + $oMPDF->setBasePath($this->a_base['href']); // Seems that the tag is not recognized by mPDF... + } + $oMPDF->showWatermarkText = true; + if ($this->GetOutputOption('pdf', 'template_path')) + { + $oMPDF->setImportUse(); // Allow templates + $oMPDF->SetDocTemplate ($this->GetOutputOption('pdf', 'template_path'), 1); + } + $oMPDF->WriteHTML($sHtml); + $oMPDF->Output(); + } + } - echo '
'; - echo '
'; - echo self::FilterXSS($sApplicationBanner); - echo ' '; - //echo '        
'; - echo '
'; - echo '
'; - echo ' '; - echo self::FilterXSS($this->s_content); - echo ' '; - echo '
'; - echo ''; - - // Add the captured output - if (trim($s_captured_output) != "") - { - echo "
".self::FilterXSS($s_captured_output)."
\n"; - } - echo "
".self::FilterXSS($this->s_deferred_content)."
"; -// echo $this->s_deferred_content; - echo "
Please wait...
\n"; // jqModal Window - echo "
"; - echo "
"; - - echo "\n"; - echo "\n"; - } - public function AddTabContainer($sTabContainer) { $this->m_aTabs[$sTabContainer] = array(); $this->add("\$Tabs:$sTabContainer\$"); } - + public function AddToTab($sTabContainer, $sTabLabel, $sHtml) { if (!isset($this->m_aTabs[$sTabContainer][$sTabLabel])) @@ -846,12 +886,12 @@ EOF $this->m_sCurrentTab = $sTabLabel; return $sPreviousTab; } - + public function GetCurrentTab() { return $this->m_sCurrentTab; } - + public function RemoveTab($sTabLabel, $sTabContainer = null) { if ($sTabContainer == null) @@ -862,7 +902,7 @@ EOF { // Delete the content of the tab unset($this->m_aTabs[$sTabContainer][$sTabLabel]); - + // If we just removed the active tab, let's reset the active tab if (($this->m_sCurrentTabContainer == $sTabContainer) && ($this->m_sCurrentTab == $sTabLabel)) { @@ -892,7 +932,7 @@ EOF } return $result; } - + /** * Make the given tab the active one, as if it were clicked * DOES NOT WORK: apparently in the *old* version of jquery @@ -914,7 +954,7 @@ EOF break; } $tab_index++; - } + } break; } $container_index++; @@ -922,7 +962,7 @@ EOF $sSelector = '#tabbedContent_'.$container_index.' > ul'; $this->add_ready_script("$('$sSelector').tabs('select', $tab_index);"); } - + public function StartCollapsibleSection($sSectionLabel, $bOpen = false) { $this->add($this->GetStartCollapsibleSection($sSectionLabel, $bOpen)); @@ -952,91 +992,69 @@ EOF return ""; } - public function add($sHtml) - { - if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab)) - { - $this->AddToTab($this->m_sCurrentTabContainer, $this->m_sCurrentTab, $sHtml); - } - else - { - parent::add($sHtml); - } - } - + public function add($sHtml) + { + if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab)) + { + $this->AddToTab($this->m_sCurrentTabContainer, $this->m_sCurrentTab, $sHtml); + } + else + { + parent::add($sHtml); + } + } + /** * Records the current state of the 'html' part of the page output * @return mixed The current state of the 'html' output - */ - public function start_capture() - { - if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab)) - { - $iOffset = isset($this->m_aTabs[$this->m_sCurrentTabContainer][$this->m_sCurrentTab]) ? strlen($this->m_aTabs[$this->m_sCurrentTabContainer][$this->m_sCurrentTab]): 0; - return array('tc' => $this->m_sCurrentTabContainer, 'tab' => $this->m_sCurrentTab, 'offset' => $iOffset); - } - else - { - return parent::start_capture(); - } - } - - /** - * Returns the part of the html output that occurred since the call to start_capture - * and removes this part from the current html output - * @param $offset mixed The value returned by start_capture - * @return string The part of the html output that was added since the call to start_capture - */ - public function end_capture($offset) - { - if (is_array($offset)) - { - if (isset($this->m_aTabs[$offset['tc']][$offset['tab']])) - { - $sCaptured = substr($this->m_aTabs[$offset['tc']][$offset['tab']], $offset['offset']); - $this->m_aTabs[$offset['tc']][$offset['tab']] = substr($this->m_aTabs[$offset['tc']][$offset['tab']], 0, $offset['offset']); - } - else - { - $sCaptured = ''; - } - } - else - { - $sCaptured = parent::end_capture($offset); - } - return $sCaptured; - } - - /** - * Set the message to be displayed in the 'admin-banner' section at the top of the page - */ - public function SetMessage($sMessage) - { - $this->m_sMessage = $sMessage; - } - - /* - public function AddSearchForm($sClassName, $bOpen = false) - { - $iSearchSectionId = 0; - - $sStyle = $bOpen ? 'SearchDrawer' : 'SearchDrawer DrawerClosed'; - $this->add("
\n"); - $this->add("

Search form for ".Metamodel::GetName($sClassName)."

\n"); - $this->add_ready_script("\$(\"#LnkSearch_$iSearchSectionId\").click(function() {\$(\"#Search_$iSearchSectionId\").slideToggle('normal'); $(\"#LnkSearch_$iSearchSectionId\").toggleClass('open');});"); - $oFilter = new DBObjectSearch($sClassName); - $sFilter = $oFilter->serialize(); - $oSet = new CMDBObjectSet($oFilter); - cmdbAbstractObject::DisplaySearchForm($this, $oSet, array('operation' => 'search', 'filter' => $sFilter, 'search_form' => true)); - $this->add("
\n"); - $this->add("
\n"); - $this->add("
Search
\n"); - - - $iSearchSectionId++; + */ + public function start_capture() + { + if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab)) + { + $iOffset = isset($this->m_aTabs[$this->m_sCurrentTabContainer][$this->m_sCurrentTab]) ? strlen($this->m_aTabs[$this->m_sCurrentTabContainer][$this->m_sCurrentTab]): 0; + return array('tc' => $this->m_sCurrentTabContainer, 'tab' => $this->m_sCurrentTab, 'offset' => $iOffset); + } + else + { + return parent::start_capture(); + } + } + + /** + * Returns the part of the html output that occurred since the call to start_capture + * and removes this part from the current html output + * @param $offset mixed The value returned by start_capture + * @return string The part of the html output that was added since the call to start_capture + */ + public function end_capture($offset) + { + if (is_array($offset)) + { + if (isset($this->m_aTabs[$offset['tc']][$offset['tab']])) + { + $sCaptured = substr($this->m_aTabs[$offset['tc']][$offset['tab']], $offset['offset']); + $this->m_aTabs[$offset['tc']][$offset['tab']] = substr($this->m_aTabs[$offset['tc']][$offset['tab']], 0, $offset['offset']); + } + else + { + $sCaptured = ''; + } + } + else + { + $sCaptured = parent::end_capture($offset); + } + return $sCaptured; + } + + /** + * Set the message to be displayed in the 'admin-banner' section at the top of the page + */ + public function SetMessage($sMessage) + { + $this->m_sMessage = $sMessage; } - */ } ?> diff --git a/application/webpage.class.inc.php b/application/webpage.class.inc.php index 5246653b3..65431aa83 100644 --- a/application/webpage.class.inc.php +++ b/application/webpage.class.inc.php @@ -50,6 +50,8 @@ class WebPage protected $sContentType; protected $sContentDisposition; protected $sContentFileName; + protected $s_sOutputFormat; + protected $a_OutputOptions; public function __construct($s_title) { @@ -67,6 +69,8 @@ class WebPage $this->sContentType = ''; $this->sContentDisposition = ''; $this->sContentFileName = ''; + $this->s_OutputFormat = utils::ReadParam('output_format', 'html'); + $this->a_OutputOptions = array(); ob_start(); // Start capturing the output } @@ -515,5 +519,67 @@ class WebPage { return str_ireplace('s_OutputFormat; + } + + /** + * Check whether the desired output format is possible or not + * @param string $sOutputFormat The desired output format: html, pdf... + * @return bool True if the format is Ok, false otherwise + */ + function IsOutputFormatAvailable($sOutputFormat) + { + $bResult = false; + switch($sOutputFormat) + { + case 'html': + $bResult = true; // Always supported + break; + + case 'pdf': + $bResult = @is_readable(APPROOT.'lib/MPDF/mpdf.php'); + break; + } + return $bResult; + } + + /** + * Retrieves the value of a named output option for the given format + * @param string $sFormat The format: html or pdf + * @param string $sOptionName The name of the option + * @return mixed false if the option was never set or the options's value + */ + public function GetOutputOption($sFormat, $sOptionName) + { + if (isset($this->a_OutputOptions[$sFormat][$sOptionName])) + { + return $this->a_OutputOptions[$sFormat][$sOptionName]; + } + return false; + } + /** + * Sets a named output option for the given format + * @param string $sFormat The format for which to set the option: html or pdf + * @param string $sOptionName the name of the option + * @param mixed $sValue The value of the option + */ + public function SetOutputOption($sFormat, $sOptionName, $sValue) + { + if (!isset($this->a_OutputOptions[$sFormat])) + { + $this->a_OutputOptions[$sFormat] = array($sOptionName => $sValue); + } + else + { + $this->a_OutputOptions[$sFormat][$sOptionName] = $sValue; + } + } } ?> \ No newline at end of file