itopwebpage.class.inc.php 25 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]").tabs(); // tabs
  132. $("table.listResults").tableHover(); // hover tables
  133. $(".listResults").tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra', 'truncatedList']} ); // sortable and zebra tables
  134. $(".date-pick").datepicker({
  135. showOn: 'button',
  136. buttonImage: '../images/calendar.png',
  137. buttonImageOnly: true,
  138. dateFormat: 'yy-mm-dd',
  139. constrainInput: false,
  140. changeMonth: true,
  141. changeYear: true
  142. });
  143. $('.resizable').resizable(); // Make resizable everything that claims to be resizable !
  144. docWidth = $(document).width();
  145. $('#ModalDlg').dialog({ autoOpen: false, modal: true, width: 0.8*docWidth }); // JQuery UI dialogs
  146. ShowDebug();
  147. $('#logOffBtn>ul').popupmenu();
  148. }
  149. catch(err)
  150. {
  151. // Do something with the error !
  152. alert(err);
  153. }
  154. //$('.display_block').draggable(); // make the blocks draggable
  155. EOF
  156. );
  157. $sUserPrefs = appUserPreferences::GetAsJSON();
  158. $this->add_script("
  159. // For automplete
  160. function findValue(li) {
  161. if( li == null ) return alert(\"No match!\");
  162. // if coming from an AJAX call, let's use the CityId as the value
  163. if( !!li.extra ) var sValue = li.extra[0];
  164. // otherwise, let's just display the value in the text box
  165. else var sValue = li.selectValue;
  166. //alert(\"The value you selected was: \" + sValue);
  167. }
  168. function selectItem(li) {
  169. findValue(li);
  170. }
  171. function formatItem(row) {
  172. return row[0];
  173. }
  174. function goBack()
  175. {
  176. window.history.back();
  177. }
  178. function BackToDetails(sClass, id)
  179. {
  180. window.location.href = './UI.php?operation=details&class='+sClass+'&id='+id;
  181. }
  182. function ShowDebug()
  183. {
  184. if ($('#rawOutput > div').html() != '')
  185. {
  186. $('#rawOutput').dialog( {autoOpen: true, modal:false});
  187. }
  188. }
  189. var oUserPreferences = $sUserPrefs;
  190. ");
  191. // Add the standard menus
  192. /*
  193. * +--------------------+
  194. * | Welcome |
  195. * +--------------------+
  196. * Welcome To iTop
  197. * +--------------------+
  198. * | Tools |
  199. * +--------------------+
  200. * CSV Import
  201. * +--------------------+
  202. * | Admin Tools | << Only present if the user is an admin
  203. * +--------------------+
  204. * User Accounts
  205. * Profiles
  206. * Notifications
  207. * Run Queries
  208. * Export
  209. * Data Model
  210. * Universal Search
  211. */
  212. $oWelcomeMenu = new MenuGroup('WelcomeMenu', 0 /* fRank */);
  213. new TemplateMenuNode('WelcomeMenuPage', '../business/templates/welcome_menu.html', $oWelcomeMenu->GetIndex() /* oParent */, 1 /* fRank */);
  214. $oToolsMenu = new MenuGroup('DataAdministration', 2 /* fRank */);
  215. new WebPageMenuNode('CSVImportMenu', '../pages/csvimport.php', $oToolsMenu->GetIndex(), 1 /* fRank */);
  216. // Add the admin menus
  217. $oAdminMenu = new MenuGroup('AdminTools', 999 /* fRank */);
  218. new OQLMenuNode('UserAccountsMenu', 'SELECT URP_Users', $oAdminMenu->GetIndex(), 1 /* fRank */);
  219. new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2 /* fRank */);
  220. new TemplateMenuNode('NotificationsMenu', '../business/templates/notifications_menu.html', $oAdminMenu->GetIndex(), 3 /* fRank */);
  221. new WebPageMenuNode('RunQueriesMenu', '../pages/run_query.php', $oAdminMenu->GetIndex(), 8 /* fRank */);
  222. new WebPageMenuNode('ExportMenu', '../webservices/export.php', $oAdminMenu->GetIndex(), 9 /* fRank */);
  223. new WebPageMenuNode('DataModelMenu', '../pages/schema.php', $oAdminMenu->GetIndex(), 10 /* fRank */);
  224. new WebPageMenuNode('UniversalSearchMenu', '../pages/UniversalSearch.php', $oAdminMenu->GetIndex(), 11 /* fRank */);
  225. }
  226. public function AddToMenu($sHtml)
  227. {
  228. $this->m_sMenu .= $sHtml;
  229. }
  230. public function GetSiloSelectionForm()
  231. {
  232. // List of visible Organizations
  233. $iCount = 0;
  234. $oContext = new UserContext();
  235. if (MetaModel::IsValidClass('Organization'))
  236. {
  237. $oSearchFilter = $oContext->NewFilter('Organization');
  238. $oSet = new CMDBObjectSet($oSearchFilter);
  239. $iCount = $oSet->Count();
  240. }
  241. switch($iCount)
  242. {
  243. case 0:
  244. // No such dimension/silo => nothing to select
  245. $sHtml = '<div id="SiloSelection"><!-- nothing to select --></div>';
  246. break;
  247. case 1:
  248. // Only one possible choice... no selection, but display the value
  249. $oOrg = $oSet->Fetch();
  250. $sHtml = '<div id="SiloSelection">'.$oOrg->GetName().'</div>';
  251. $sHtml .= '';
  252. break;
  253. default:
  254. $sHtml = '<div id="SiloSelection">';
  255. $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();">';
  256. $sSelected = ($this->m_currentOrganization == '') ? ' selected' : '';
  257. $sHtml .= '<option value=""'.$sSelected.'>'.Dict::S('UI:AllOrganizations').'</option>';
  258. while($oOrg = $oSet->Fetch())
  259. {
  260. if ($this->m_currentOrganization == $oOrg->GetKey())
  261. {
  262. $oCurrentOrganization = $oOrg;
  263. $sSelected = " selected";
  264. }
  265. else
  266. {
  267. $sSelected = "";
  268. }
  269. $sHtml .= '<option value="'.$oOrg->GetKey().'"'.$sSelected.'>'.$oOrg->GetName().'</option>';
  270. }
  271. $sHtml .= '</select>';
  272. // Add other dimensions/context information to this form
  273. $oAppContext = new ApplicationContext();
  274. $oAppContext->Reset('org_id'); // Org id is handled above and we want to be able to change it here !
  275. $sHtml .= $oAppContext->GetForForm();
  276. $sHtml .= '</form>';
  277. $sHtml .= '</div>';
  278. }
  279. return $sHtml;
  280. }
  281. public function DisplayMenu()
  282. {
  283. $oContext = new UserContext();
  284. // Display the menu
  285. $oAppContext = new ApplicationContext();
  286. $iActiveNodeId = ApplicationMenu::GetActiveNodeId();
  287. $iAccordionIndex = 0;
  288. ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash(), $iActiveNodeId);
  289. }
  290. /**
  291. * Outputs (via some echo) the complete HTML page by assembling all its elements
  292. */
  293. public function output()
  294. {
  295. $this->DisplayMenu(); // Compute the menu
  296. foreach($this->a_headers as $s_header)
  297. {
  298. header($s_header);
  299. }
  300. $s_captured_output = ob_get_contents();
  301. ob_end_clean();
  302. echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
  303. echo "<html>\n";
  304. echo "<head>\n";
  305. echo "<title>{$this->s_title}</title>\n";
  306. echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
  307. echo $this->get_base_tag();
  308. // Stylesheets MUST be loaded before any scripts otherwise
  309. // jQuery scripts may face some spurious problems (like failing on a 'reload')
  310. foreach($this->a_linked_stylesheets as $a_stylesheet)
  311. {
  312. if ($a_stylesheet['condition'] != "")
  313. {
  314. echo "<!--[if {$a_stylesheet['condition']}]>\n";
  315. }
  316. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$a_stylesheet['link']}\" />\n";
  317. if ($a_stylesheet['condition'] != "")
  318. {
  319. echo "<![endif]-->\n";
  320. }
  321. }
  322. foreach($this->a_linked_scripts as $s_script)
  323. {
  324. echo "<script type=\"text/javascript\" src=\"$s_script\"></script>\n";
  325. }
  326. if (count($this->m_aReadyScripts)>0)
  327. {
  328. $this->add_script("\$(document).ready(function() {\n".implode("\n", $this->m_aReadyScripts)."\n});");
  329. }
  330. if (count($this->a_scripts)>0)
  331. {
  332. echo "<script type=\"text/javascript\">\n";
  333. foreach($this->a_scripts as $s_script)
  334. {
  335. echo "$s_script\n";
  336. }
  337. echo "</script>\n";
  338. }
  339. if (count($this->a_styles)>0)
  340. {
  341. echo "<style>\n";
  342. foreach($this->a_styles as $s_style)
  343. {
  344. echo "$s_style\n";
  345. }
  346. echo "</style>\n";
  347. }
  348. echo "<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"iTop\" href=\"./opensearch.xml.php\" />\n";
  349. echo "</head>\n";
  350. echo "<body>\n";
  351. // Render the revision number
  352. if (ITOP_REVISION == '$WCREV$')
  353. {
  354. // This is NOT a version built using the buil system, just display the main version
  355. $sVersionString = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
  356. }
  357. else
  358. {
  359. // This is a build made from SVN, let display the full information
  360. $sVersionString = Dict::Format('UI:iTopVersion:Long', ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
  361. }
  362. // Render the text of the global search form
  363. $sText = Utils::ReadParam('text', '');
  364. $sOnClick = "";
  365. if (empty($sText))
  366. {
  367. // if no search text is supplied then
  368. // 1) the search text is filled with "your search"
  369. // 2) clicking on it will erase it
  370. $sText = Dict::S("UI:YourSearch");
  371. $sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
  372. }
  373. $sForm = $this->GetSiloSelectionForm();
  374. // Render the tabs in the page (if any)
  375. foreach($this->m_aTabs as $sTabContainerName => $m_aTabs)
  376. {
  377. $sTabs = '';
  378. $container_index = 0;
  379. if (count($m_aTabs) > 0)
  380. {
  381. $sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$container_index}\" class=\"light\">\n";
  382. $sTabs .= "<ul>\n";
  383. // Display the unordered list that will be rendered as the tabs
  384. $i = 0;
  385. foreach($m_aTabs as $sTabName => $sTabContent)
  386. {
  387. $sTabs .= "<li><a href=\"#fragment_$i\" class=\"tab\"><span>".htmlentities($sTabName, ENT_QUOTES, 'UTF-8')."</span></a></li>\n";
  388. $i++;
  389. }
  390. $sTabs .= "</ul>\n";
  391. // Now add the content of the tabs themselves
  392. $i = 0;
  393. foreach($m_aTabs as $sTabName => $sTabContent)
  394. {
  395. $sTabs .= "<div id=\"fragment_$i\">".$sTabContent."</div>\n";
  396. $i++;
  397. }
  398. $sTabs .= "</div>\n<!-- end of tabs-->\n";
  399. }
  400. $this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content);
  401. $container_index++;
  402. }
  403. $sUserName = UserRights::GetUser();
  404. $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
  405. if (UserRights::IsAdministrator())
  406. {
  407. $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
  408. }
  409. else
  410. {
  411. $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
  412. }
  413. $sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
  414. $sLogOffMenu .= "<li><span>$sLogonMessage</span></li>\n";
  415. $sLogOffMenu .= "<li><a href=\"../pages/UI.php?loginop=logoff\">".Dict::S('UI:LogOffMenu')."</a></li>\n";
  416. if (UserRights::CanChangePassword())
  417. {
  418. $sLogOffMenu .= "<li><a href=\"../pages/UI.php?loginop=change_pwd\">".Dict::S('UI:ChangePwdMenu')."</a></li>\n";
  419. }
  420. $sLogOffMenu .= "</ul>\n</li>\n</ul></span>\n";
  421. //$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
  422. echo '<div id="left-pane" class="ui-layout-west">';
  423. echo '<!-- Beginning of the left pane -->';
  424. echo ' <div id="header-logo">';
  425. 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>';
  426. echo ' </div>';
  427. echo ' <div class="header-menu">';
  428. echo ' <div class="icon ui-state-default ui-corner-all"><span id="tPinMenu" class="ui-icon ui-icon-pin-w">pin</span></div>';
  429. echo ' <div style="width:100%; text-align:center;">'.$sForm.'</div>';
  430. echo ' </div>';
  431. echo ' <div id="menu" class="ui-layout-content">';
  432. echo ' <div id="inner_menu">';
  433. echo ' <div id="accordion">';
  434. echo $this->m_sMenu;
  435. echo ' <!-- Beginning of the accordion menu -->';
  436. echo ' <!-- End of the accordion menu-->';
  437. echo ' </div>';
  438. echo ' </div> <!-- /inner menu -->';
  439. echo ' </div> <!-- /menu -->';
  440. echo ' <div class="footer"><a href="http://www.combodo.com" title="www.combodo.com" target="_blank"><img src="../images/logo-combodo.png"/></a></div>';
  441. echo '<!-- End of the left pane -->';
  442. echo '</div>';
  443. echo '<div class="ui-layout-center">';
  444. echo ' <div id="top-bar" style="width:100%">';
  445. echo ' <div id="global-search"><form><table><tr><td id="g-search-input"><input type="text" name="text" value="'.$sText.'"'.$sOnClick.'/></td>';
  446. echo '<td><input type="image" src="../images/searchBtn.png"/></a></td>';
  447. 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>';
  448. 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>';
  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. ?>