itopwebpage.class.inc.php 26 KB

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