nicewebpage.class.inc.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Class NiceWebPage
  18. *
  19. * @author Erwan Taloc <erwan.taloc@combodo.com>
  20. * @author Romain Quetiez <romain.quetiez@combodo.com>
  21. * @author Denis Flaven <denis.flaven@combodo.com>
  22. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  23. */
  24. require_once(APPROOT."/application/webpage.class.inc.php");
  25. /**
  26. * Web page with some associated CSS and scripts (jquery) for a fancier display
  27. */
  28. class NiceWebPage extends WebPage
  29. {
  30. var $m_aReadyScripts;
  31. public function __construct($s_title)
  32. {
  33. parent::__construct($s_title);
  34. $this->m_aReadyScripts = array();
  35. $this->add_linked_script("../js/jquery-1.4.2.min.js");
  36. //$this->add_linked_script("../js/jquery.history_remote.pack.js");
  37. $this->add_linked_stylesheet('../css/ui-lightness/jquery-ui-1.8.2.custom.css');
  38. $this->add_linked_script('../js/jquery-ui-1.8.2.custom.min.js');
  39. //$this->add_linked_script("../js/ui.resizable.js");
  40. // $this->add_linked_script("../js/ui.tabs.js");
  41. $this->add_linked_script("../js/hovertip.js");
  42. // $this->add_linked_script("../js/jqModal.js");
  43. $this->add_linked_stylesheet("../css/light-grey.css");
  44. // $this->add_linked_stylesheet("../js/themes/light/light.tabs.css");
  45. //$this->add_linked_stylesheet("../css/jquery.tabs-ie.css", "lte IE 7");
  46. // $this->add_linked_stylesheet("../css/jqModal.css");
  47. $this->add_ready_script(' window.setTimeout(hovertipInit, 1);');
  48. }
  49. public function small_p($sText)
  50. {
  51. $this->add("<p style=\"font-size:smaller\">$sText</p>\n");
  52. }
  53. // By Rom, used by CSVImport and Advanced search
  54. public function MakeClassesSelect($sName, $sDefaultValue, $iWidthPx, $iActionCode = null)
  55. {
  56. // $aTopLevelClasses = array('bizService', 'bizContact', 'logInfra', 'bizDocument');
  57. // These are classes wich root class is cmdbAbstractObject !
  58. $this->add("<select id=\"select_$sName\" name=\"$sName\">");
  59. $aValidClasses = array();
  60. foreach(MetaModel::GetClasses('bizmodel') as $sClassName)
  61. {
  62. if (is_null($iActionCode) || UserRights::IsActionAllowed($sClassName, $iActionCode))
  63. {
  64. $sSelected = ($sClassName == $sDefaultValue) ? " SELECTED" : "";
  65. $sDescription = MetaModel::GetClassDescription($sClassName);
  66. $sDisplayName = MetaModel::GetName($sClassName);
  67. $aValidClasses[$sDisplayName] = "<option style=\"width: ".$iWidthPx." px;\" title=\"$sDescription\" value=\"$sClassName\"$sSelected>$sDisplayName</option>";
  68. }
  69. }
  70. ksort($aValidClasses);
  71. $this->add(implode("\n", $aValidClasses));
  72. $this->add("</select>");
  73. }
  74. // By Rom, used by Advanced search
  75. public function add_select($aChoices, $sName, $sDefaultValue, $iWidthPx)
  76. {
  77. $this->add("<select id=\"select_$sName\" name=\"$sName\">");
  78. foreach($aChoices as $sKey => $sValue)
  79. {
  80. $sSelected = ($sKey == $sDefaultValue) ? " SELECTED" : "";
  81. $this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"".htmlspecialchars($sKey)."\"$sSelected>".htmlentities($sValue, ENT_QUOTES, 'UTF-8')."</option>");
  82. }
  83. $this->add("</select>");
  84. }
  85. public function add_ready_script($sScript)
  86. {
  87. $this->m_aReadyScripts[] = $sScript;
  88. }
  89. /**
  90. * Outputs (via some echo) the complete HTML page by assembling all its elements
  91. */
  92. public function output()
  93. {
  94. if (count($this->m_aReadyScripts)>0)
  95. {
  96. $this->add_script("\$(document).ready(function() {\n".implode("\n", $this->m_aReadyScripts)."\n});");
  97. }
  98. parent::output();
  99. }
  100. }
  101. ?>