ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

work_space.inc.php
Go to the documentation of this file.
1 <?php
2 
3 
4 
6 // Function:
7 // _submit ($window_name, $javascript)
8 //
9 // Description:
10 // Builds a new "work space" window, and sends the javascript passed in
11 // back to the browser to execute after the window is built.
13 function ws_work_space_submit($window_name, $javascript='') {
14  global $conf, $self, $color, $style, $images;
15 
16  /**** UPDATE THIS WINDOW'S "HISTORY" ****/
17  if (!is_array($_SESSION['ona'][$window_name]['history'])) {
18  $_SESSION['ona'][$window_name]['history'] = array();
19  }
20 
21  // Get the "URL" and it's "Title"
22  $title = '';
23  if (preg_match("/xajax_window_submit\('([^']+)'/", $javascript, $matches)) { $title = $matches[1]; }
24 
25  // Remove old history items that are duplicates of the current "URL"
26  $new_history = array();
27  foreach ($_SESSION['ona'][$window_name]['history'] as $history) {
28  if ($history['url'] != $javascript) {
29  array_push($new_history, $history);
30  }
31  }
32  $_SESSION['ona'][$window_name]['history'] = $new_history;
33 
34  // Add the current "URL"
35  array_push($_SESSION['ona'][$window_name]['history'], array('title' => $title, 'type' => $title, 'url' => $javascript));
36 
37 
38  // If there are to many url's in the history, trim some.
39  while (count($_SESSION['ona'][$window_name]['history']) > 7)
40  array_shift($_SESSION['ona'][$window_name]['history']);
41 
42  // We're building the window in $window and will use window_open() to create the window
43  $window = array(
44  'title' => "Search Results",
45  'html' => "",
46  'js' => "",
47  );
48 
49 
50  // Set the window title:
51  $window['title'] = "Work Space";
52 
53 
54 // Define javascript to run after the window is created
55 $window['js'] .= <<<EOL
56 
57  /* Hide the 'Search Results' box if it's visible */
58  var _el = el('search_results');
59  if (_el && (_el.style.visibility == 'visible' || _el.style.display == 'block')) {
60  _el.style.visibility = "hidden";
61  _el.style.display = "none";
62  }
63 
64  var _el = el('{$window_name}');
65 
66  /* Get the size of the box we live 'in' */
67  var content_top = calcOffset(el('content_table'), 'offsetTop');
68  var content_left = calcOffset(el('content_table'), 'offsetLeft');
69  var content_width = el('content_table').offsetWidth;
70  var content_height = el('content_table').offsetHeight;
71 
72  /* Now calculate where we will sit .. the -4 and -2 are for borders */
73  var my_top = content_top;
74  var my_left = content_left;
75  var my_width = '100%';
76  var my_height = document.body.clientHeight - el('bar_top').clientHeight - el('trace_history').clientHeight;
77  if (browser.isIE) {
78  my_height += 2;
79  }
80 
81  /* Finally reposition/resize the window, hide any overflow, and bring it up behind other windows. */
82  _el.style.top = my_top + 'px';
83  _el.style.left = my_left + 'px';
84  _el.style.width = my_width ;
85  _el.style.height = my_height + 'px';
86  _el.style.zIndex = 1;
87  _el.style.overflow = 'hidden';
88 
89  /* Now disable the drag library from moving this 'window' */
90  el('{$window_name}').onclick = function() { return true; };
91  el('{$window_name}_title').onmousedown = function() { return true; };
92  el('{$window_name}_title').style.cursor = 'default';
93 
94  /* Make sure the title bar goes all the way across */
95  el('{$window_name}_title_table').style.width = my_width ;
96 
97  /* Gray the title bar */
98  el('{$window_name}_title_table').className = '';
99  el('{$window_name}_title_table').style.backgroundColor = '#A6A6A6';
100  el('{$window_name}_title_table').style.borderBottom = 'none';
101  el('{$window_name}_title').style.color = '#F0F0F0';
102 
103  /* Make the content peice scroll */
104  _el = el('{$window_name}_content');
105  _el.style.width = my_width ;
106  _el.style.height = (my_height - el('{$window_name}_title').offsetHeight - 4 ) + 'px';
107  _el.style.overflow = 'auto';
108 
109  {$javascript}
110 
111  el('{$window_name}').style.border='0px';
112 
113  el('work_space').setAttribute('wsname', '{$title}');
114 
115 EOL;
116 
117 
118  // Define the window's inner html -
119  $window['html'] .= <<<EOL
120 
121  </div>
122 
123  <div id="{$window_name}_content">
124  <br><br><br><br><center><img src="{$images}/loading.gif" /></center>
125  </div>
126 
127 EOL;
128 
129 
130 
131  // Lets build a window and display the results
132  return(window_open($window_name, $window));
133 
134 }
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
146 // Function:
147 // rewrite_history ($window_name, $null, $return_html)
148 //
149 // Description:
150 // Rewrites the hitory div in the work_space window.
151 // If $return_html == 1 the raw html is returned rather than returning
152 // and XML response to update it.
153 // This also updates the work space window's title.
155 function ws_rewrite_history($window_name, $null='', $return_html=0) {
156  global $conf, $self, $color, $style, $images;
157 
158  $html = $js = '';
159 
160  // clear the trace history if they have cliked the word "trace"
161  if ($null == 'clear') {
162  $_SESSION['ona']['work_space']['history'] = '';
163  }
164 
165  $html .= "<span title=\"Click to clear history\" onclick=\"xajax_window_submit('work_space', 'clear', 'rewrite_history');\">&nbsp;Trace: </span>";
166  $and = '';
167  foreach((array)$_SESSION['ona'][$window_name]['history'] as $history) {
168  $history['title'] = htmlentities($history['title'], ENT_QUOTES, $conf['php_charset']);
169  $history['type'] = htmlentities($history['type'], ENT_QUOTES, $conf['php_charset']);
170  $history['url'] = str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']);
171  $history['url'] = htmlentities($history['url'], ENT_QUOTES, $conf['php_charset']);
172  $html .= <<<EOL
173 {$and}<a title="{$history['type']}: {$history['title']}" onClick="xajax_window_submit('work_space', '{$history['url']}');">{$history['title']}</a>&nbsp;
174 EOL;
175  $and = '&nbsp;&gt;&gt;&nbsp;';
176  }
177 
178  if ($return_html) return($html);
179 
180  // Update the work_space window's title
181  if($_SESSION['ona'][$window_name]['history']) { $history = end($_SESSION['ona'][$window_name]['history']); }
182  $new_title = "Work Space: {$history['type']}: {$history['title']}";
183  $new_buttons = <<<EOL
184  <span style="font-size: xx-small;vertical-align: middle;">&copy; {$year} <a style="color: white;" href="http://opennetadmin.com">OpenNetAdmin</a> - {$conf['version']}</span>
185  <a style="cursor: pointer;" title="Open online help for: {$history['type']}" onClick="document.location = '{$_ENV['help_url']}{$history['type']}';"><img src="{$images}/silk/help.png" border="0" /></a>
186 
187  <a onclick="removeElement('work_space');" style="cursor: pointer;" title="Home"><img border="0" src="{$images}/silk/application_home.png"/></a>
188 EOL;
189 
190  // Insert the new html into the window
191  // Instantiate the xajaxResponse object
192  $response = new xajaxResponse();
193  $response->addAssign("trace_history", "innerHTML", $html);
194  $response->addAssign("work_space_title_r", "innerHTML", $new_buttons);
195  $response->addAssign("work_space_title", "innerHTML", $new_title);
196  return($response->getXML());
197 }
198 
199 
200 
201 
202 ?>
onclick
_button onclick
Definition: app_advanced_search.inc.php:50
$window
$window['title']
Definition: install.php:26
window_open
window_open($window_name, $window=array())
Definition: webwin.inc.php:59
$year
$year
Definition: html_desktop.inc.php:6
$images
$images
Definition: config.inc.php:26
EOL
< a style="text-decoration: none;" href="/">< input class='edit' type="button" value="I don't like free stuff?" onclick=""/></a ></center ></div > EOL
Definition: install.php:40
ws_rewrite_history
ws_rewrite_history($window_name, $null='', $return_html=0)
Definition: work_space.inc.php:155
$_SESSION
$_SESSION['ona']['auth']
Definition: login.php:14
$conf
global $conf
Definition: 2-to-3.php:15
xajaxResponse
Definition: xajaxResponse.inc.php:68
$style
$style['font-family']
Definition: config.inc.php:158
nbsp
& nbsp
Definition: install.php:36
ws_work_space_submit
ws_work_space_submit($window_name, $javascript='')
Definition: work_space.inc.php:13
$self
global $self
Definition: 2-to-3.php:15
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119