webpage.class.inc.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <?php
  2. // Copyright (C) 2010-2012 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. /**
  19. * Class WebPage
  20. *
  21. * @copyright Copyright (C) 2010-2012 Combodo SARL
  22. * @license http://opensource.org/licenses/AGPL-3.0
  23. */
  24. /**
  25. * Generic interface common to CLI and Web pages
  26. */
  27. Interface Page
  28. {
  29. public function output();
  30. public function add($sText);
  31. public function p($sText);
  32. public function pre($sText);
  33. public function add_comment($sText);
  34. public function table($aConfig, $aData, $aParams = array());
  35. }
  36. /**
  37. * Simple helper class to ease the production of HTML pages
  38. *
  39. * This class provide methods to add content, scripts, includes... to a web page
  40. * and renders the full web page by putting the elements in the proper place & order
  41. * when the output() method is called.
  42. * Usage:
  43. * $oPage = new WebPage("Title of my page");
  44. * $oPage->p("Hello World !");
  45. * $oPage->output();
  46. */
  47. class WebPage implements Page
  48. {
  49. protected $s_title;
  50. protected $s_content;
  51. protected $s_deferred_content;
  52. protected $a_scripts;
  53. protected $a_dict_entries;
  54. protected $a_styles;
  55. protected $a_include_scripts;
  56. protected $a_include_stylesheets;
  57. protected $a_headers;
  58. protected $a_base;
  59. protected $iNextId;
  60. protected $iTransactionId;
  61. protected $sContentType;
  62. protected $sContentDisposition;
  63. protected $sContentFileName;
  64. protected $s_sOutputFormat;
  65. protected $a_OutputOptions;
  66. public function __construct($s_title)
  67. {
  68. $this->s_title = $s_title;
  69. $this->s_content = "";
  70. $this->s_deferred_content = '';
  71. $this->a_scripts = array();
  72. $this->a_dict_entries = array();
  73. $this->a_styles = array();
  74. $this->a_linked_scripts = array();
  75. $this->a_linked_stylesheets = array();
  76. $this->a_headers = array();
  77. $this->a_base = array( 'href' => '', 'target' => '');
  78. $this->iNextId = 0;
  79. $this->iTransactionId = 0;
  80. $this->sContentType = '';
  81. $this->sContentDisposition = '';
  82. $this->sContentFileName = '';
  83. $this->s_OutputFormat = utils::ReadParam('output_format', 'html');
  84. $this->a_OutputOptions = array();
  85. ob_start(); // Start capturing the output
  86. }
  87. /**
  88. * Change the title of the page after its creation
  89. */
  90. public function set_title($s_title)
  91. {
  92. $this->s_title = $s_title;
  93. }
  94. /**
  95. * Specify a default URL and a default target for all links on a page
  96. */
  97. public function set_base($s_href = '', $s_target = '')
  98. {
  99. $this->a_base['href'] = $s_href;
  100. $this->a_base['target'] = $s_target;
  101. }
  102. /**
  103. * Add any text or HTML fragment to the body of the page
  104. */
  105. public function add($s_html)
  106. {
  107. $this->s_content .= $s_html;
  108. }
  109. /**
  110. * Add any text or HTML fragment (identified by an ID) at the end of the body of the page
  111. * This is useful to add hidden content, DIVs or FORMs that should not
  112. * be embedded into each other.
  113. */
  114. public function add_at_the_end($s_html, $sId = '')
  115. {
  116. $this->s_deferred_content .= $s_html;
  117. }
  118. /**
  119. * Add a paragraph to the body of the page
  120. */
  121. public function p($s_html)
  122. {
  123. $this->add($this->GetP($s_html));
  124. }
  125. /**
  126. * Add a pre-formatted text to the body of the page
  127. */
  128. public function pre($s_html)
  129. {
  130. $this->add('<pre>'.$s_html.'</pre>');
  131. }
  132. /**
  133. * Add a comment
  134. */
  135. public function add_comment($sText)
  136. {
  137. $this->add('<!--'.$sText.'-->');
  138. }
  139. /**
  140. * Add a paragraph to the body of the page
  141. */
  142. public function GetP($s_html)
  143. {
  144. return "<p>$s_html</p>\n";
  145. }
  146. /**
  147. * Adds a tabular content to the web page
  148. * @param Hash $aConfig Configuration of the table: hash array of 'column_id' => 'Column Label'
  149. * @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
  150. * @param Hash $aParams Hash array. Extra parameters for the table.
  151. * @return void
  152. */
  153. public function table($aConfig, $aData, $aParams = array())
  154. {
  155. $this->add($this->GetTable($aConfig, $aData, $aParams));
  156. }
  157. public function GetTable($aConfig, $aData, $aParams = array())
  158. {
  159. $oAppContext = new ApplicationContext();
  160. static $iNbTables = 0;
  161. $iNbTables++;
  162. $sHtml = "";
  163. $sHtml .= "<table class=\"listResults\">\n";
  164. $sHtml .= "<thead>\n";
  165. $sHtml .= "<tr>\n";
  166. foreach($aConfig as $sName=>$aDef)
  167. {
  168. $sHtml .= "<th title=\"".$aDef['description']."\">".$aDef['label']."</th>\n";
  169. }
  170. $sHtml .= "</tr>\n";
  171. $sHtml .= "</thead>\n";
  172. $sHtml .= "<tbody>\n";
  173. foreach($aData as $aRow)
  174. {
  175. $sHtml .= $this->GetTableRow($aRow, $aConfig);
  176. }
  177. $sHtml .= "</tbody>\n";
  178. $sHtml .= "</table>\n";
  179. return $sHtml;
  180. }
  181. public function GetTableRow($aRow, $aConfig)
  182. {
  183. $sHtml = '';
  184. if (isset($aRow['@class'])) // Row specific class, for hilighting certain rows
  185. {
  186. $sHtml .= "<tr class=\"{$aRow['@class']}\">";
  187. }
  188. else
  189. {
  190. $sHtml .= "<tr>";
  191. }
  192. foreach($aConfig as $sName=>$aAttribs)
  193. {
  194. $sClass = isset($aAttribs['class']) ? 'class="'.$aAttribs['class'].'"' : '';
  195. $sValue = ($aRow[$sName] === '') ? '&nbsp;' : $aRow[$sName];
  196. $sHtml .= "<td $sClass>$sValue</td>";
  197. }
  198. $sHtml .= "</tr>";
  199. return $sHtml;
  200. }
  201. /**
  202. * Add some Javascript to the header of the page
  203. */
  204. public function add_script($s_script)
  205. {
  206. $this->a_scripts[] = $s_script;
  207. }
  208. /**
  209. * Add some Javascript to the header of the page
  210. */
  211. public function add_ready_script($s_script)
  212. {
  213. // Do nothing silently... this is not supported by this type of page...
  214. }
  215. /**
  216. * Add a dictionary entry for the Javascript side
  217. */
  218. public function add_dict_entry($s_entryId)
  219. {
  220. $this->a_dict_entries[$s_entryId] = Dict::S($s_entryId);
  221. }
  222. /**
  223. * Add some CSS definitions to the header of the page
  224. */
  225. public function add_style($s_style)
  226. {
  227. $this->a_styles[] = $s_style;
  228. }
  229. /**
  230. * Add a script (as an include, i.e. link) to the header of the page
  231. */
  232. public function add_linked_script($s_linked_script)
  233. {
  234. $this->a_linked_scripts[$s_linked_script] = $s_linked_script;
  235. }
  236. /**
  237. * Add a CSS stylesheet (as an include, i.e. link) to the header of the page
  238. */
  239. public function add_linked_stylesheet($s_linked_stylesheet, $s_condition = "")
  240. {
  241. $this->a_linked_stylesheets[] = array( 'link' => $s_linked_stylesheet, 'condition' => $s_condition);
  242. }
  243. /**
  244. * Add some custom header to the page
  245. */
  246. public function add_header($s_header)
  247. {
  248. $this->a_headers[] = $s_header;
  249. }
  250. /**
  251. * Add needed headers to the page so that it will no be cached
  252. */
  253. public function no_cache()
  254. {
  255. $this->add_header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  256. $this->add_header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past
  257. }
  258. /**
  259. * Build a special kind of TABLE useful for displaying the details of an object from a hash array of data
  260. */
  261. public function details($aFields)
  262. {
  263. $this->add($this->GetDetails($aFields));
  264. }
  265. /**
  266. * Records the current state of the 'html' part of the page output
  267. * @return mixed The current state of the 'html' output
  268. */
  269. public function start_capture()
  270. {
  271. return strlen($this->s_content);
  272. }
  273. /**
  274. * Returns the part of the html output that occurred since the call to start_capture
  275. * and removes this part from the current html output
  276. * @param $offset mixed The value returned by start_capture
  277. * @return string The part of the html output that was added since the call to start_capture
  278. */
  279. public function end_capture($offset)
  280. {
  281. $sCaptured = substr($this->s_content, $offset);
  282. $this->s_content = substr($this->s_content, 0, $offset);
  283. return $sCaptured;
  284. }
  285. /**
  286. * Build a special kind of TABLE useful for displaying the details of an object from a hash array of data
  287. */
  288. public function GetDetails($aFields)
  289. {
  290. $sHtml = "<table class=\"details\">\n";
  291. $sHtml .= "<tbody>\n";
  292. foreach($aFields as $aAttrib)
  293. {
  294. $sHtml .= "<tr>\n";
  295. // By Rom, for csv import, proposed to show several values for column selection
  296. if (is_array($aAttrib['value']))
  297. {
  298. $sHtml .= "<td class=\"label\">".$aAttrib['label']."</td><td>".implode("</td><td>", $aAttrib['value'])."</td>\n";
  299. }
  300. else
  301. {
  302. $sHtml .= "<td class=\"label\">".$aAttrib['label']."</td><td>".$aAttrib['value']."</td>\n";
  303. }
  304. $sComment = (isset($aAttrib['comments'])) ? $aAttrib['comments'] : '&nbsp;';
  305. $sInfo = (isset($aAttrib['infos'])) ? $aAttrib['infos'] : '&nbsp;';
  306. $sHtml .= "<td>$sComment</td><td>$sInfo</td>\n";
  307. $sHtml .= "</tr>\n";
  308. }
  309. $sHtml .= "</tbody>\n";
  310. $sHtml .= "</table>\n";
  311. return $sHtml;
  312. }
  313. /**
  314. * Build a set of radio buttons suitable for editing a field/attribute of an object (including its validation)
  315. * @param $aAllowedValues hash Array of value => display_value
  316. * @param $value mixed Current value for the field/attribute
  317. * @param $iId mixed Unique Id for the input control in the page
  318. * @param $sFieldName string The name of the field, attr_<$sFieldName> will hold the value for the field
  319. * @param $bMandatory bool Whether or not the field is mandatory
  320. * @param $bVertical bool Disposition of the radio buttons vertical or horizontal
  321. * @param $sValidationField string HTML fragment holding the validation field (exclamation icon...)
  322. * @return string The HTML fragment corresponding to the radio buttons
  323. */
  324. public function GetRadioButtons($aAllowedValues, $value, $iId, $sFieldName, $bMandatory, $bVertical, $sValidationField)
  325. {
  326. $idx = 0;
  327. $sHTMLValue = '';
  328. foreach($aAllowedValues as $key => $display_value)
  329. {
  330. if ((count($aAllowedValues) == 1) && ($bMandatory == 'true') )
  331. {
  332. // When there is only once choice, select it by default
  333. $sSelected = ' checked';
  334. }
  335. else
  336. {
  337. $sSelected = ($value == $key) ? ' checked' : '';
  338. }
  339. $sHTMLValue .= "<input type=\"radio\" id=\"{$iId}_{$key}\" name=\"radio_$sFieldName\" onChange=\"$('#{$iId}').val(this.value).trigger('change');\" value=\"$key\"$sSelected><label class=\"radio\" for=\"{$iId}_{$key}\">&nbsp;$display_value</label>&nbsp;";
  340. if ($bVertical)
  341. {
  342. if ($idx == 0)
  343. {
  344. // Validation icon at the end of the first line
  345. $sHTMLValue .= "&nbsp;{$sValidationField}\n";
  346. }
  347. $sHTMLValue .= "<br>\n";
  348. }
  349. $idx++;
  350. }
  351. $sHTMLValue .= "<input type=\"hidden\" id=\"$iId\" name=\"$sFieldName\" value=\"$value\"/>";
  352. if (!$bVertical)
  353. {
  354. // Validation icon at the end of the line
  355. $sHTMLValue .= "&nbsp;{$sValidationField}\n";
  356. }
  357. return $sHTMLValue;
  358. }
  359. /**
  360. * Discard unexpected output data
  361. * This is a MUST when the Page output is DATA (download of a document, download CSV export, download ...)
  362. */
  363. public function TrashUnexpectedOutput()
  364. {
  365. // This protection is redundant with a protection implemented in MetaModel::IncludeModule
  366. // which detects such issues while loading module files
  367. // Here, the purpose is to detect and discard characters produced by the code execution (echo)
  368. $sPreviousContent = ob_get_clean();
  369. if (trim($sPreviousContent) != '')
  370. {
  371. if (Utils::GetConfig() && Utils::GetConfig()->Get('debug_report_spurious_chars'))
  372. {
  373. IssueLog::Error("Output already started before downloading file:\nContent was:'$sPreviousContent'\n");
  374. }
  375. }
  376. }
  377. /**
  378. * Outputs (via some echo) the complete HTML page by assembling all its elements
  379. */
  380. public function output()
  381. {
  382. foreach($this->a_headers as $s_header)
  383. {
  384. header($s_header);
  385. }
  386. $s_captured_output = ob_get_contents();
  387. ob_end_clean();
  388. echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
  389. echo "<html>\n";
  390. echo "<head>\n";
  391. echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
  392. echo "<title>".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."</title>\n";
  393. echo $this->get_base_tag();
  394. foreach($this->a_linked_scripts as $s_script)
  395. {
  396. // Make sure that the URL to the script contains the application's version number
  397. // so that the new script do NOT get reloaded from the cache when the application is upgraded
  398. if (strpos($s_script, '?') === false)
  399. {
  400. $s_script .= "?itopversion=".ITOP_VERSION;
  401. }
  402. else
  403. {
  404. $s_script .= "&itopversion=".ITOP_VERSION;
  405. }
  406. echo "<script type=\"text/javascript\" src=\"$s_script\"></script>\n";
  407. }
  408. if (count($this->a_scripts)>0)
  409. {
  410. echo "<script type=\"text/javascript\">\n";
  411. foreach($this->a_scripts as $s_script)
  412. {
  413. echo "$s_script\n";
  414. }
  415. echo "</script>\n";
  416. }
  417. $this->output_dict_entries();
  418. foreach($this->a_linked_stylesheets as $a_stylesheet)
  419. {
  420. if ($a_stylesheet['condition'] != "")
  421. {
  422. echo "<!--[if {$a_stylesheet['condition']}]>\n";
  423. }
  424. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$a_stylesheet['link']}\" />\n";
  425. if ($a_stylesheet['condition'] != "")
  426. {
  427. echo "<![endif]-->\n";
  428. }
  429. }
  430. if (count($this->a_styles)>0)
  431. {
  432. echo "<style>\n";
  433. foreach($this->a_styles as $s_style)
  434. {
  435. echo "$s_style\n";
  436. }
  437. echo "</style>\n";
  438. }
  439. if (class_exists('MetaModel') && MetaModel::GetConfig())
  440. {
  441. echo "<link rel=\"shortcut icon\" href=\"".utils::GetAbsoluteUrlAppRoot()."images/favicon.ico\" />\n";
  442. }
  443. echo "</head>\n";
  444. echo "<body>\n";
  445. echo self::FilterXSS($this->s_content);
  446. if (trim($s_captured_output) != "")
  447. {
  448. echo "<div class=\"raw_output\">".self::FilterXSS($s_captured_output)."</div>\n";
  449. }
  450. echo '<div id="at_the_end">'.self::FilterXSS($this->s_deferred_content).'</div>';
  451. echo "</body>\n";
  452. echo "</html>\n";
  453. if (class_exists('MetaModel'))
  454. {
  455. MetaModel::RecordQueryTrace();
  456. }
  457. }
  458. /**
  459. * Build a series of hidden field[s] from an array
  460. */
  461. // By Rom - je verrais bien une serie d'outils pour gerer des parametres que l'on retransmet entre pages d'un wizard...
  462. // ptet deriver webpage en webwizard
  463. public function add_input_hidden($sLabel, $aData)
  464. {
  465. foreach($aData as $sKey=>$sValue)
  466. {
  467. $this->add("<input type=\"hidden\" name=\"".$sLabel."[$sKey]\" value=\"$sValue\">");
  468. }
  469. }
  470. protected function get_base_tag()
  471. {
  472. $sTag = '';
  473. if (($this->a_base['href'] != '') || ($this->a_base['target'] != ''))
  474. {
  475. $sTag = '<base ';
  476. if (($this->a_base['href'] != ''))
  477. {
  478. $sTag .= "href =\"{$this->a_base['href']}\" ";
  479. }
  480. if (($this->a_base['target'] != ''))
  481. {
  482. $sTag .= "target =\"{$this->a_base['target']}\" ";
  483. }
  484. $sTag .= " />\n";
  485. }
  486. return $sTag;
  487. }
  488. /**
  489. * Get an ID (for any kind of HTML tag) that is guaranteed unique in this page
  490. * @return int The unique ID (in this page)
  491. */
  492. public function GetUniqueId()
  493. {
  494. return $this->iNextId++;
  495. }
  496. /**
  497. * Set the content-type (mime type) for the page's content
  498. * @param $sContentType string
  499. * @return void
  500. */
  501. public function SetContentType($sContentType)
  502. {
  503. $this->sContentType = $sContentType;
  504. }
  505. /**
  506. * Set the content-disposition (mime type) for the page's content
  507. * @param $sDisposition string The disposition: 'inline' or 'attachment'
  508. * @param $sFileName string The original name of the file
  509. * @return void
  510. */
  511. public function SetContentDisposition($sDisposition, $sFileName)
  512. {
  513. $this->sContentDisposition = $sDisposition;
  514. $this->sContentFileName = $sFileName;
  515. }
  516. /**
  517. * Set the transactionId of the current form
  518. * @param $iTransactionId integer
  519. * @return void
  520. */
  521. public function SetTransactionId($iTransactionId)
  522. {
  523. $this->iTransactionId = $iTransactionId;
  524. }
  525. /**
  526. * Returns the transactionId of the current form
  527. * @return integer The current transactionID
  528. */
  529. public function GetTransactionId()
  530. {
  531. return $this->iTransactionId;
  532. }
  533. public static function FilterXSS($sHTML)
  534. {
  535. return str_ireplace('<script', '&lt;script', $sHTML);
  536. }
  537. /**
  538. * What is the currently selected output format
  539. * @return string The selected output format: html, pdf...
  540. */
  541. public function GetOutputFormat()
  542. {
  543. return $this->s_OutputFormat;
  544. }
  545. /**
  546. * Check whether the desired output format is possible or not
  547. * @param string $sOutputFormat The desired output format: html, pdf...
  548. * @return bool True if the format is Ok, false otherwise
  549. */
  550. function IsOutputFormatAvailable($sOutputFormat)
  551. {
  552. $bResult = false;
  553. switch($sOutputFormat)
  554. {
  555. case 'html':
  556. $bResult = true; // Always supported
  557. break;
  558. case 'pdf':
  559. $bResult = @is_readable(APPROOT.'lib/MPDF/mpdf.php');
  560. break;
  561. }
  562. return $bResult;
  563. }
  564. /**
  565. * Retrieves the value of a named output option for the given format
  566. * @param string $sFormat The format: html or pdf
  567. * @param string $sOptionName The name of the option
  568. * @return mixed false if the option was never set or the options's value
  569. */
  570. public function GetOutputOption($sFormat, $sOptionName)
  571. {
  572. if (isset($this->a_OutputOptions[$sFormat][$sOptionName]))
  573. {
  574. return $this->a_OutputOptions[$sFormat][$sOptionName];
  575. }
  576. return false;
  577. }
  578. /**
  579. * Sets a named output option for the given format
  580. * @param string $sFormat The format for which to set the option: html or pdf
  581. * @param string $sOptionName the name of the option
  582. * @param mixed $sValue The value of the option
  583. */
  584. public function SetOutputOption($sFormat, $sOptionName, $sValue)
  585. {
  586. if (!isset($this->a_OutputOptions[$sFormat]))
  587. {
  588. $this->a_OutputOptions[$sFormat] = array($sOptionName => $sValue);
  589. }
  590. else
  591. {
  592. $this->a_OutputOptions[$sFormat][$sOptionName] = $sValue;
  593. }
  594. }
  595. public function RenderPopupMenuItems($aActions, $aFavoriteActions = array())
  596. {
  597. $sPrevUrl = '';
  598. $sHtml = '';
  599. foreach ($aActions as $aAction)
  600. {
  601. $sClass = isset($aAction['class']) ? " class=\"{$aAction['class']}\"" : "";
  602. $sOnClick = isset($aAction['onclick']) ? " onclick=\"{$aAction['onclick']}\"" : "";
  603. if (empty($aAction['url']))
  604. {
  605. if ($sPrevUrl != '') // Don't output consecutively two separators...
  606. {
  607. $sHtml .= "<li>{$aAction['label']}</li>";
  608. }
  609. $sPrevUrl = '';
  610. }
  611. else
  612. {
  613. $sHtml .= "<li><a href=\"{$aAction['url']}\"$sClass $sOnClick>{$aAction['label']}</a></li>";
  614. $sPrevUrl = $aAction['url'];
  615. }
  616. }
  617. $sHtml .= "</ul></li></ul></div>";
  618. foreach(array_reverse($aFavoriteActions) as $aAction)
  619. {
  620. $sHtml .= "<div class=\"actions_button\"><a href='{$aAction['url']}'>{$aAction['label']}</a></div>";
  621. }
  622. return $sHtml;
  623. }
  624. protected function output_dict_entries()
  625. {
  626. if (count($this->a_dict_entries)>0)
  627. {
  628. echo "<script type=\"text/javascript\">\n";
  629. echo "var Dict = {};\n";
  630. echo "Dict._entries = {};\n";
  631. echo "Dict.S = function(sEntry) {\n";
  632. echo " if (sEntry in Dict._entries)\n";
  633. echo " {\n";
  634. echo " return Dict._entries[sEntry];\n";
  635. echo " }\n";
  636. echo " else\n";
  637. echo " {\n";
  638. echo " return sEntry;\n";
  639. echo " }\n";
  640. echo "};\n";
  641. foreach($this->a_dict_entries as $s_entry => $s_value)
  642. {
  643. echo "Dict._entries['$s_entry'] = '".addslashes($s_value)."';\n";
  644. }
  645. echo "</script>\n";
  646. }
  647. }
  648. }
  649. ?>