itopwebpage.class.inc.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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 iTopWebPage
  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("../application/nicewebpage.class.inc.php");
  25. require_once("../application/usercontext.class.inc.php");
  26. require_once("../application/applicationcontext.class.inc.php");
  27. require_once("../application/user.preferences.class.inc.php");
  28. /**
  29. * Web page with some associated CSS and scripts (jquery) for a fancier display
  30. */
  31. class iTopWebPage extends NiceWebPage
  32. {
  33. private $m_sMenu;
  34. private $m_currentOrganization;
  35. private $m_aTabs;
  36. private $m_sCurrentTabContainer;
  37. private $m_sCurrentTab;
  38. public function __construct($sTitle, $currentOrganization)
  39. {
  40. parent::__construct($sTitle);
  41. $this->m_sCurrentTabContainer = '';
  42. $this->m_sCurrentTab = '';
  43. $this->m_aTabs = array();
  44. $this->m_sMenu = "";
  45. $oAppContext = new ApplicationContext();
  46. $sExtraParams = $oAppContext->GetForLink();
  47. $this->m_currentOrganization = $currentOrganization;
  48. $this->add_header("Content-type: text/html; charset=utf-8");
  49. $this->add_header("Cache-control: no-cache");
  50. $this->add_linked_stylesheet("../css/jquery.treeview.css");
  51. $this->add_linked_stylesheet("../css/jquery.autocomplete.css");
  52. // $this->add_linked_stylesheet("../css/date.picker.css");
  53. $this->add_linked_script('../js/jquery.layout.min.js');
  54. // $this->add_linked_script("../js/jquery.dimensions.js");
  55. $this->add_linked_script("../js/jquery.tablehover.js");
  56. $this->add_linked_script("../js/jquery.treeview.js");
  57. $this->add_linked_script("../js/jquery.autocomplete.js");
  58. $this->add_linked_script("../js/jquery.bgiframe.js");
  59. $this->add_linked_script("../js/jquery.positionBy.js");
  60. $this->add_linked_script("../js/jquery.popupmenu.js");
  61. $this->add_linked_script("../js/date.js");
  62. // $this->add_linked_script("../js/jquery.date.picker.js");
  63. $this->add_linked_script("../js/jquery.tablesorter.min.js");
  64. $this->add_linked_script("../js/jquery.blockUI.js");
  65. $this->add_linked_script("../js/utils.js");
  66. $this->add_linked_script("../js/swfobject.js");
  67. $this->add_ready_script(
  68. <<<EOF
  69. //add new widget called TruncatedList to properly display truncated lists when they are sorted
  70. $.tablesorter.addWidget({
  71. // give the widget a id
  72. id: "truncatedList",
  73. // format is called when the on init and when a sorting has finished
  74. format: function(table)
  75. {
  76. // Check if there is a "truncated" line
  77. this.truncatedList = false;
  78. if ($("tr td.truncated",table).length > 0)
  79. {
  80. this.truncatedList = true;
  81. }
  82. if (this.truncatedList)
  83. {
  84. $("tr td",table).removeClass('truncated');
  85. $("tr:last td",table).addClass('truncated');
  86. }
  87. }
  88. });
  89. try
  90. {
  91. var myLayout; // a var is required because this page utilizes: myLayout.allowOverflow() method
  92. $(document).ready(function () {
  93. // Layout
  94. paneSize = GetUserPreference('menu_size', 300)
  95. myLayout = $('body').layout({
  96. west : {
  97. minSize: 200, size: paneSize, spacing_open: 16, spacing_close: 16, slideTrigger_open: "mouseover", hideTogglerOnSlide: true,
  98. onclose_end: function(name, elt, state, options, layout)
  99. {
  100. if (state.isSliding == false)
  101. {
  102. SetUserPreference('menu_pane', 'closed', true);
  103. }
  104. },
  105. onresize_end: function(name, elt, state, options, layout)
  106. {
  107. if (state.isSliding == false)
  108. {
  109. SetUserPreference('menu_size', state.size, true);
  110. }
  111. },
  112. onopen_end: function(name, elt, state, options, layout)
  113. {
  114. if (state.isSliding == false)
  115. {
  116. SetUserPreference('menu_pane', 'open', true);
  117. }
  118. }
  119. }
  120. });
  121. myLayout.addPinBtn( "#tPinMenu", "west" );
  122. //myLayout.open( "west" );
  123. $('.ui-layout-resizer-west').html('<img src="../images/splitter-top-corner.png"/>');
  124. if (GetUserPreference('menu_pane', 'open') == 'closed')
  125. {
  126. myLayout.close('west');
  127. }
  128. // Accordion Menu
  129. $("#accordion").accordion({ header: "h3", navigation: true, autoHeight: false, collapsible: false });
  130. });
  131. //$("div[id^=tabbedContent] > ul").tabs( 1, { fxFade: true, fxSpeed: 'fast' } ); // tabs
  132. $("div[id^=tabbedContent]").tabs(); // tabs
  133. $("table.listResults").tableHover(); // hover tables
  134. $(".listResults").tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra', 'truncatedList']} ); // sortable and zebra tables
  135. $(".date-pick").datepicker({
  136. showOn: 'button',
  137. buttonImage: '../images/calendar.png',
  138. buttonImageOnly: true,
  139. dateFormat: 'yy-mm-dd',
  140. constrainInput: false,
  141. changeMonth: true,
  142. changeYear: true
  143. });
  144. $('.resizable').resizable(); // Make resizable everything that claims to be resizable !
  145. docWidth = $(document).width();
  146. $('#ModalDlg').dialog({ autoOpen: false, modal: true, width: 0.8*docWidth }); // JQuery UI dialogs
  147. ShowDebug();
  148. $('#logOffBtn>ul').popupmenu();
  149. }
  150. catch(err)
  151. {
  152. // Do something with the error !
  153. alert(err);
  154. }
  155. //$('.display_block').draggable(); // make the blocks draggable
  156. EOF
  157. );
  158. $sUserPrefs = appUserPreferences::GetAsJSON();
  159. $this->add_script("
  160. // For automplete
  161. function findValue(li) {
  162. if( li == null ) return alert(\"No match!\");
  163. // if coming from an AJAX call, let's use the CityId as the value
  164. if( !!li.extra ) var sValue = li.extra[0];
  165. // otherwise, let's just display the value in the text box
  166. else var sValue = li.selectValue;
  167. //alert(\"The value you selected was: \" + sValue);
  168. }
  169. function selectItem(li) {
  170. findValue(li);
  171. }
  172. function formatItem(row) {
  173. return row[0];
  174. }
  175. function goBack()
  176. {
  177. window.history.back();
  178. }
  179. function BackToDetails(sClass, id)
  180. {
  181. window.location.href = './UI.php?operation=details&class='+sClass+'&id='+id;
  182. }
  183. function ShowDebug()
  184. {
  185. if ($('#rawOutput > div').html() != '')
  186. {
  187. $('#rawOutput').dialog( {autoOpen: true, modal:false});
  188. }
  189. }
  190. var oUserPreferences = $sUserPrefs;
  191. ");
  192. // Add the standard menus
  193. /*
  194. * +--------------------+
  195. * | Welcome |
  196. * +--------------------+
  197. * Welcome To iTop
  198. * +--------------------+
  199. * | Tools |
  200. * +--------------------+
  201. * CSV Import
  202. * +--------------------+
  203. * | Admin Tools | << Only present if the user is an admin
  204. * +--------------------+
  205. * User Accounts
  206. * Profiles
  207. * Notifications
  208. * Run Queries
  209. * Export
  210. * Data Model
  211. * Universal Search
  212. */
  213. $oWelcomeMenu = new MenuGroup('UI:WelcomeMenu', 0 /* fRank */);
  214. new TemplateMenuNode('UI:WelcomeMenu', '../business/templates/welcome_menu.html', $oWelcomeMenu->GetIndex() /* oParent */, 1 /* fRank */);
  215. $oToolsMenu = new MenuGroup('UI:AdvancedToolsMenu', 2 /* fRank */);
  216. new WebPageMenuNode('UI:CSVImportMenu', '../pages/csvimport.php', $oToolsMenu->GetIndex(), 1 /* fRank */);
  217. if (userRights::IsAdministrator())
  218. {
  219. // Add the admin menus
  220. $oAdminMenu = new MenuGroup('UI:AdminToolsMenu', 999 /* fRank */);
  221. new OQLMenuNode('UI:UserAccountsMenu', 'UI:UserAccountsMenu:Title', 'SELECT URP_Users', $oAdminMenu->GetIndex(), 1 /* fRank */);
  222. new OQLMenuNode('UI:ProfilesMenu', 'UI:ProfilesMenu:Title', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2 /* fRank */);
  223. new TemplateMenuNode('UI:NotificationsMenu', '../business/templates/notifications_menu.html', $oAdminMenu->GetIndex(), 3 /* fRank */);
  224. new WebPageMenuNode('UI:RunQueriesMenu', '../pages/run_query.php', $oAdminMenu->GetIndex(), 8 /* fRank */);
  225. new WebPageMenuNode('UI:ExportMenu', '../webservices/export.php', $oAdminMenu->GetIndex(), 9 /* fRank */);
  226. new WebPageMenuNode('UI:DataModelMenu', '../pages/schema.php', $oAdminMenu->GetIndex(), 10 /* fRank */);
  227. new WebPageMenuNode('UI:UniversalSearchMenu', '../pages/UniversalSearch.php', $oAdminMenu->GetIndex(), 11 /* fRank */);
  228. }
  229. }
  230. public function AddToMenu($sHtml)
  231. {
  232. $this->m_sMenu .= $sHtml;
  233. }
  234. public function GetSiloSelectionForm()
  235. {
  236. // List of visible Organizations
  237. $iCount = 0;
  238. $oContext = new UserContext();
  239. if (MetaModel::IsValidClass('bizOrganization'))
  240. {
  241. $oSearchFilter = $oContext->NewFilter('Organization');
  242. $oSet = new CMDBObjectSet($oSearchFilter);
  243. $iCount = $oSet->Count();
  244. }
  245. switch($iCount)
  246. {
  247. case 0:
  248. // No such dimension/silo => nothing to select
  249. $sHtml = '<div id="SiloSelection"><!-- nothing to select --></div>';
  250. break;
  251. case 1:
  252. // Only one possible choice... no selection, but display the value
  253. $oOrg = $oSet->Fetch();
  254. $sHtml = '<div id="SiloSelection">'.$oOrg->GetName().'</div>';
  255. $sHtml .= '';
  256. break;
  257. default:
  258. $sHtml = '<div id="SiloSelection">';
  259. $sHtml .= '<form style="display:inline" action="'.$_SERVER['PHP_SELF'].'"><select style="width:150px;font-size:x-small" name="org_id" title="Pick an organization" onChange="this.form.submit();">';
  260. $sSelected = ($this->m_currentOrganization == '') ? ' selected' : '';
  261. $sHtml .= '<option value=""'.$sSelected.'>'.Dict::S('UI:AllOrganizations').'</option>';
  262. while($oOrg = $oSet->Fetch())
  263. {
  264. if ($this->m_currentOrganization == $oOrg->GetKey())
  265. {
  266. $oCurrentOrganization = $oOrg;
  267. $sSelected = " selected";
  268. }
  269. else
  270. {
  271. $sSelected = "";
  272. }
  273. $sHtml .= '<option value="'.$oOrg->GetKey().'"'.$sSelected.'>'.$oOrg->GetName().'</option>';
  274. }
  275. $sHtml .= '</select>';
  276. // Add other dimensions/context information to this form
  277. $oAppContext = new ApplicationContext();
  278. $oAppContext->Reset('org_id'); // Org id is handled above and we want to be able to change it here !
  279. $sHtml .= $oAppContext->GetForForm();
  280. $sHtml .= '</form>';
  281. $sHtml .= '</div>';
  282. }
  283. return $sHtml;
  284. }
  285. public function DisplayMenu()
  286. {
  287. $oContext = new UserContext();
  288. // Display the menu
  289. $oAppContext = new ApplicationContext();
  290. $iActiveNodeId = ApplicationMenu::GetActiveNodeId();
  291. $iAccordionIndex = 0;
  292. ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash(), $iActiveNodeId);
  293. }
  294. /**
  295. * Outputs (via some echo) the complete HTML page by assembling all its elements
  296. */
  297. public function output()
  298. {
  299. $this->DisplayMenu(); // Compute the menu
  300. foreach($this->a_headers as $s_header)
  301. {
  302. header($s_header);
  303. }
  304. $s_captured_output = ob_get_contents();
  305. ob_end_clean();
  306. echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
  307. echo "<html>\n";
  308. echo "<head>\n";
  309. echo "<title>{$this->s_title}</title>\n";
  310. echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
  311. echo $this->get_base_tag();
  312. // Stylesheets MUST be loaded before any scripts otherwise
  313. // jQuery scripts may face some spurious problems (like failing on a 'reload')
  314. foreach($this->a_linked_stylesheets as $a_stylesheet)
  315. {
  316. if ($a_stylesheet['condition'] != "")
  317. {
  318. echo "<!--[if {$a_stylesheet['condition']}]>\n";
  319. }
  320. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$a_stylesheet['link']}\" />\n";
  321. if ($a_stylesheet['condition'] != "")
  322. {
  323. echo "<![endif]-->\n";
  324. }
  325. }
  326. foreach($this->a_linked_scripts as $s_script)
  327. {
  328. echo "<script type=\"text/javascript\" src=\"$s_script\"></script>\n";
  329. }
  330. if (count($this->m_aReadyScripts)>0)
  331. {
  332. $this->add_script("\$(document).ready(function() {\n".implode("\n", $this->m_aReadyScripts)."\n});");
  333. }
  334. if (count($this->a_scripts)>0)
  335. {
  336. echo "<script type=\"text/javascript\">\n";
  337. foreach($this->a_scripts as $s_script)
  338. {
  339. echo "$s_script\n";
  340. }
  341. echo "</script>\n";
  342. }
  343. if (count($this->a_styles)>0)
  344. {
  345. echo "<style>\n";
  346. foreach($this->a_styles as $s_style)
  347. {
  348. echo "$s_style\n";
  349. }
  350. echo "</style>\n";
  351. }
  352. echo "<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"iTop\" href=\"./opensearch.xml.php\" />\n";
  353. echo "</head>\n";
  354. echo "<body>\n";
  355. // Render the revision number
  356. if (ITOP_REVISION == '$WCREV$')
  357. {
  358. // This is NOT a version built using the buil system, just display the main version
  359. $sVersionString = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
  360. }
  361. else
  362. {
  363. // This is a build made from SVN, let display the full information
  364. $sVersionString = Dict::Format('UI:iTopVersion:Long', ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
  365. }
  366. // Render the text of the global search form
  367. $sText = Utils::ReadParam('text', '');
  368. $sOnClick = "";
  369. if (empty($sText))
  370. {
  371. // if no search text is supplied then
  372. // 1) the search text is filled with "your search"
  373. // 2) clicking on it will erase it
  374. $sText = Dict::S("UI:YourSearch");
  375. $sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
  376. }
  377. $sForm = $this->GetSiloSelectionForm();
  378. // Render the tabs in the page (if any)
  379. foreach($this->m_aTabs as $sTabContainerName => $m_aTabs)
  380. {
  381. $sTabs = '';
  382. $container_index = 0;
  383. if (count($m_aTabs) > 0)
  384. {
  385. $sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$container_index}\" class=\"light\">\n";
  386. $sTabs .= "<ul>\n";
  387. // Display the unordered list that will be rendered as the tabs
  388. $i = 0;
  389. foreach($m_aTabs as $sTabName => $sTabContent)
  390. {
  391. $sTabs .= "<li><a href=\"#fragment_$i\" class=\"tab\"><span>".htmlentities($sTabName, ENT_QUOTES, 'UTF-8')."</span></a></li>\n";
  392. $i++;
  393. }
  394. $sTabs .= "</ul>\n";
  395. // Now add the content of the tabs themselves
  396. $i = 0;
  397. foreach($m_aTabs as $sTabName => $sTabContent)
  398. {
  399. $sTabs .= "<div id=\"fragment_$i\">".$sTabContent."</div>\n";
  400. $i++;
  401. }
  402. $sTabs .= "</div>\n<!-- end of tabs-->\n";
  403. }
  404. $this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content);
  405. $container_index++;
  406. }
  407. $sUserName = UserRights::GetUser();
  408. $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
  409. if (UserRights::IsAdministrator())
  410. {
  411. $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
  412. }
  413. else
  414. {
  415. $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
  416. }
  417. $sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
  418. $sLogOffMenu .= "<li><span>$sLogonMessage</span></li>\n";
  419. $sLogOffMenu .= "<li><a href=\"#\">Log Off</a></li>\n";
  420. $sLogOffMenu .= "<li><a href=\"#\">Change password...</a></li>\n";
  421. $sLogOffMenu .= "</ul>\n</li>\n</ul></span>\n";
  422. //$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
  423. echo '<div id="left-pane" class="ui-layout-west">';
  424. echo '<!-- Beginning of the left pane -->';
  425. echo ' <div id="header-logo">';
  426. echo ' <div id="top-left"></div><div id="logo"><a href="http://www.combodo.com/itop"><img src="../images/itop-logo.png" title="'.$sVersionString.'" style="border:0; margin-top:16px; margin-right:40px;"/></a></div>';
  427. echo ' </div>';
  428. echo ' <div class="header-menu">';
  429. echo ' <div class="icon ui-state-default ui-corner-all"><span id="tPinMenu" class="ui-icon ui-icon-pin-w">pin</span></div>';
  430. echo ' <div style="width:100%; text-align:center;">'.$sForm.'</div>';
  431. echo ' </div>';
  432. echo ' <div id="menu" class="ui-layout-content">';
  433. echo ' <div id="inner_menu">';
  434. echo ' <div id="accordion">';
  435. echo $this->m_sMenu;
  436. echo ' <!-- Beginning of the accordion menu -->';
  437. echo ' <!-- End of the accordion menu-->';
  438. echo ' </div>';
  439. echo ' </div> <!-- /inner menu -->';
  440. echo ' </div> <!-- /menu -->';
  441. echo ' <div class="footer"><span>iTop by Combodo</span></div>';
  442. echo '<!-- End of the left pane -->';
  443. echo '</div>';
  444. echo '<div class="ui-layout-center">';
  445. echo ' <div id="top-bar" style="width:100%">';
  446. echo ' <div id="global-search"><form><table><tr><td id="g-search-input"><input type="text" name="text" value="'.$sText.'"'.$sOnClick.'/></td>';
  447. echo '<td><input type="image" src="../images/searchBtn.png"/></td>';
  448. echo '<td style="padding-right:20px;padding-left:20px;">'.$sLogOffMenu.'</td><td><input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
  449. //echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
  450. echo ' </div>';
  451. echo ' <div class="ui-layout-content">';
  452. echo ' <!-- Beginning of page content -->';
  453. echo $this->s_content;
  454. echo ' <!-- End of page content -->';
  455. echo ' </div>';
  456. echo '</div>';
  457. /*
  458. echo "<div class=\"iTopLogo\" title=\"$sVersionString\"><span>iTop</span></div>\n";
  459. //echo "<div id=\"GlobalSearch\"><div style=\"border: 1px solid #999; padding:1px; background-color:#fff;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\"></input></div></div>\n";
  460. $sText = Utils::ReadParam('text', '');
  461. $sOnClick = "";
  462. if (empty($sText))
  463. {
  464. // if no search text is supplied then
  465. // 1) the search text is filled with "your search"
  466. // 2) clicking on it will erase it
  467. $sText = Dict::S("UI:YourSearch");
  468. $sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
  469. }
  470. $sUserName = UserRights::GetUser();
  471. $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
  472. if (UserRights::IsAdministrator())
  473. {
  474. $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
  475. }
  476. else
  477. {
  478. $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
  479. }
  480. $sLogOffBtn = Dict::S('UI:Button:Logoff');
  481. $sSearchBtn = Dict::S('UI:Button:GlobalSearch');
  482. echo "<div id=\"Login\" style=\"position:absolute; top:18px; right:16px; width:600px;\">{$sLogonMessage}&nbsp;&nbsp;";
  483. echo "<form action=\"../pages/UI.php\" method=\"post\" style=\"display:inline\">\n";
  484. echo "<input type=\"submit\" value=\"$sLogOffBtn\" />\n";
  485. echo "<input type=\"hidden\" name=\"loginop\" value=\"logoff\" />\n";
  486. echo "</form>\n";
  487. echo "<form action=\"../pages/UI.php\" style=\"display:inline\"><div style=\"padding:1px; background-color:#fff;display:inline;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\" name=\"text\" value=\"$sText\"$sOnClick></input></div><input type=\"submit\" value=\"$sSearchBtn\" />
  488. <input type=\"hidden\" name=\"operation\" value=\"full_text\" /></form>\n";
  489. echo "</div>\n";
  490. echo "</div>\n";
  491. // Display the menu
  492. echo "<div id=\"MySplitter\">\n";
  493. echo " <div id=\"LeftPane\">\n";
  494. echo $this->m_sMenu;
  495. echo " </div> <!-- LeftPane -->\n";
  496. echo "<div id=\"RightPane\">\n";
  497. // Display the page's content
  498. echo $this->s_content;
  499. */
  500. // Add the captured output
  501. if (trim($s_captured_output) != "")
  502. {
  503. echo "<div id=\"rawOutput\" title=\"Debug Output\"><div style=\"height:500px; overflow-y:auto;\">$s_captured_output</div></div>\n";
  504. }
  505. echo $this->s_deferred_content;
  506. echo "<div style=\"display:none\" title=\"ex2\" id=\"ex2\">Please wait...</div>\n"; // jqModal Window
  507. echo "<div style=\"display:none\" title=\"dialog\" id=\"ModalDlg\"></div>";
  508. echo "</body>\n";
  509. echo "</html>\n";
  510. }
  511. public function AddTabContainer($sTabContainer)
  512. {
  513. $this->m_aTabs[$sTabContainer] = array();
  514. $this->add("\$Tabs:$sTabContainer\$");
  515. }
  516. public function AddToTab($sTabContainer, $sTabLabel, $sHtml)
  517. {
  518. if (!isset($this->m_aTabs[$sTabContainer][$sTabLabel]))
  519. {
  520. // Set the content of the tab
  521. $this->m_aTabs[$sTabContainer][$sTabLabel] = $sHtml;
  522. }
  523. else
  524. {
  525. // Append to the content of the tab
  526. $this->m_aTabs[$sTabContainer][$sTabLabel] .= $sHtml;
  527. }
  528. }
  529. public function SetCurrentTabContainer($sTabContainer = '')
  530. {
  531. $sPreviousTabContainer = $this->m_sCurrentTabContainer;
  532. $this->m_sCurrentTabContainer = $sTabContainer;
  533. return $sPreviousTabContainer;
  534. }
  535. public function SetCurrentTab($sTabLabel = '')
  536. {
  537. $sPreviousTab = $this->m_sCurrentTab;
  538. $this->m_sCurrentTab = $sTabLabel;
  539. return $sPreviousTab;
  540. }
  541. /**
  542. * Make the given tab the active one, as if it were clicked
  543. * DOES NOT WORK: apparently in the *old* version of jquery
  544. * that we are using this is not supported... TO DO upgrade
  545. * the whole jquery bundle...
  546. */
  547. public function SelectTab($sTabContainer, $sTabLabel)
  548. {
  549. $container_index = 0;
  550. $tab_index = 0;
  551. foreach($this->m_aTabs as $sCurrentTabContainerName => $aTabs)
  552. {
  553. if ($sTabContainer == $sCurrentTabContainerName)
  554. {
  555. foreach($aTabs as $sCurrentTabLabel => $void)
  556. {
  557. if ($sCurrentTabLabel == $sTabLabel)
  558. {
  559. break;
  560. }
  561. $tab_index++;
  562. }
  563. break;
  564. }
  565. $container_index++;
  566. }
  567. $sSelector = '#tabbedContent_'.$container_index.' > ul';
  568. $this->add_ready_script("$('$sSelector').tabs('select', $tab_index);");
  569. }
  570. public function StartCollapsibleSection($sSectionLabel, $bOpen = false)
  571. {
  572. $this->add($this->GetStartCollapsibleSection($sSectionLabel, $bOpen));
  573. }
  574. public function GetStartCollapsibleSection($sSectionLabel, $bOpen = false)
  575. {
  576. $sHtml = '';
  577. static $iSectionId = 0;
  578. $sImgStyle = $bOpen ? ' open' : '';
  579. $sHtml .= "<a id=\"LnkCollapse_$iSectionId\" class=\"CollapsibleLabel{$sImgStyle}\" href=\"#\">$sSectionLabel</a></br>\n";
  580. $sStyle = $bOpen ? '' : 'style="display:none" ';
  581. $sHtml .= "<div id=\"Collapse_$iSectionId\" $sStyle>";
  582. $this->add_ready_script("\$(\"#LnkCollapse_$iSectionId\").click(function() {\$(\"#Collapse_$iSectionId\").slideToggle('normal'); $(\"#LnkCollapse_$iSectionId\").toggleClass('open');});");
  583. //$this->add_ready_script("$('#LnkCollapse_$iSectionId').hide();");
  584. $iSectionId++;
  585. return $sHtml;
  586. }
  587. public function EndCollapsibleSection()
  588. {
  589. $this->add($this->GetEndCollapsibleSection());
  590. }
  591. public function GetEndCollapsibleSection()
  592. {
  593. return "</div>";
  594. }
  595. public function add($sHtml)
  596. {
  597. if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab))
  598. {
  599. $this->AddToTab($this->m_sCurrentTabContainer, $this->m_sCurrentTab, $sHtml);
  600. }
  601. else
  602. {
  603. parent::add($sHtml);
  604. }
  605. }
  606. /*
  607. public function AddSearchForm($sClassName, $bOpen = false)
  608. {
  609. $iSearchSectionId = 0;
  610. $sStyle = $bOpen ? 'SearchDrawer' : 'SearchDrawer DrawerClosed';
  611. $this->add("<div id=\"Search_$iSearchSectionId\" class=\"$sStyle\">\n");
  612. $this->add("<h1>Search form for ".Metamodel::GetName($sClassName)."</h1>\n");
  613. $this->add_ready_script("\$(\"#LnkSearch_$iSearchSectionId\").click(function() {\$(\"#Search_$iSearchSectionId\").slideToggle('normal'); $(\"#LnkSearch_$iSearchSectionId\").toggleClass('open');});");
  614. $oFilter = new DBObjectSearch($sClassName);
  615. $sFilter = $oFilter->serialize();
  616. $oSet = new CMDBObjectSet($oFilter);
  617. cmdbAbstractObject::DisplaySearchForm($this, $oSet, array('operation' => 'search', 'filter' => $sFilter, 'search_form' => true));
  618. $this->add("</div>\n");
  619. $this->add("<div class=\"HRDrawer\"/></div>\n");
  620. $this->add("<div id=\"LnkSearch_$iSearchSectionId\" class=\"DrawerHandle\">Search</div>\n");
  621. $iSearchSectionId++;
  622. }
  623. */
  624. }
  625. ?>