itopwebpage.class.inc.php 25 KB

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