nicewebpage.class.inc.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. require_once("../application/webpage.class.inc.php");
  3. /**
  4. * Web page with some associated CSS and scripts (jquery) for a fancier display
  5. */
  6. class nice_web_page extends web_page
  7. {
  8. var $m_aReadyScripts;
  9. public function __construct($s_title)
  10. {
  11. parent::__construct($s_title);
  12. $this->m_aReadyScripts = array();
  13. $this->add_linked_script("../js/jquery.latest.js");
  14. $this->add_linked_script("../js/jquery.history_remote.pack.js");
  15. //$this->add_linked_script("../js/ui.resizable.js");
  16. $this->add_linked_script("../js/ui.tabs.js");
  17. $this->add_linked_script("../js/hovertip.js");
  18. $this->add_linked_script("../js/jqModal.js");
  19. $this->add_linked_stylesheet("../css/light-grey.css");
  20. $this->add_linked_stylesheet("../js/themes/light/light.tabs.css");
  21. //$this->add_linked_stylesheet("../css/jquery.tabs-ie.css", "lte IE 7");
  22. $this->add_linked_stylesheet("../css/jqModal.css");
  23. $this->add_ready_script(' window.setTimeout(hovertipInit, 1);');
  24. }
  25. public function small_p($sText)
  26. {
  27. $this->add("<p style=\"font-size:smaller\">$sText</p>\n");
  28. }
  29. // By Rom, used by CSVImport and Advanced search
  30. public function MakeClassesSelect($sName, $sDefaultValue, $iWidthPx)
  31. {
  32. // $aTopLevelClasses = array('bizService', 'bizContact', 'logInfra', 'bizDocument');
  33. // These are classes wich root class is cmdbAbstractObject !
  34. $this->add("<select id=\"select_$sName\" name=\"$sName\">");
  35. foreach(MetaModel::GetClasses('bizmodel') as $sClassName)
  36. {
  37. $sSelected = ($sClassName == $sDefaultValue) ? " SELECTED" : "";
  38. $this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"$sClassName\"$sSelected>$sClassName - ".MetaModel::GetClassDescription($sClassName)."</option>");
  39. }
  40. $this->add("</select>");
  41. }
  42. // By Rom, used by Advanced search
  43. public function add_select($aChoices, $sName, $sDefaultValue, $iWidthPx)
  44. {
  45. $this->add("<select id=\"select_$sName\" name=\"$sName\">");
  46. foreach($aChoices as $sKey => $sValue)
  47. {
  48. $sSelected = ($sKey == $sDefaultValue) ? " SELECTED" : "";
  49. $this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"$sKey\"$sSelected>$sValue</option>");
  50. }
  51. $this->add("</select>");
  52. }
  53. public function add_ready_script($sScript)
  54. {
  55. $this->m_aReadyScripts[] = $sScript;
  56. }
  57. /**
  58. * Outputs (via some echo) the complete HTML page by assembling all its elements
  59. */
  60. public function output()
  61. {
  62. if (count($this->m_aReadyScripts)>0)
  63. {
  64. $this->add_script("\$(document).ready(function() {\n".implode("\n", $this->m_aReadyScripts)."\n});");
  65. }
  66. parent::output();
  67. }
  68. }
  69. ?>