Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / navigation / NavigationHeader.class.php
blobb1513d2c03183421fa0b55da7055c59787d430bf
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Header for the navigation panel
6 * @package PhpMyAdmin-Navigation
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * This class renders the logo, links, server selection and recent tables,
14 * which are then displayed at the top of the naviagtion panel
16 * @package PhpMyAdmin-Navigation
18 class PMA_NavigationHeader
20 /**
21 * Renders the navigation
23 * @return void
25 public function getDisplay()
27 if (empty($GLOBALS['url_query'])) {
28 $GLOBALS['url_query'] = PMA_generate_common_url();
30 $link_url = PMA_generate_common_url(
31 array(
32 'ajax_request' => true
35 $class = ' class="list_container';
36 if ($GLOBALS['cfg']['NavigationTreePointerEnable']) {
37 $class .= ' highlight';
39 $class .= '"';
40 $buffer = '<div id="pma_navigation">';
41 $buffer .= '<div id="pma_navigation_resizer"></div>';
42 $buffer .= '<div id="pma_navigation_collapser"></div>';
43 $buffer .= '<div id="pma_navigation_content">';
44 $buffer .= sprintf(
45 '<a class="hide navigation_url" href="navigation.php%s"></a>',
46 $link_url
48 $buffer .= $this->_logo();
49 $buffer .= $this->_links();
50 $buffer .= $this->_serverChoice();
51 $buffer .= $this->_recent();
52 $buffer .= PMA_Util::getImage(
53 'ajax_clock_small.gif',
54 __('Loading'),
55 array('style' => 'visibility: hidden;', 'class' => 'throbber')
57 $buffer .= '<div id="pma_navigation_tree"' . $class . '>';
58 return $buffer;
61 /**
62 * Create the code for displaying the phpMyAdmin
63 * logo based on configuration settings
65 * @return string HTML code for the logo
67 private function _logo()
69 $retval = '<!-- LOGO START -->';
70 // display Logo, depending on $GLOBALS['cfg']['NavigationDisplayLogo']
71 if ($GLOBALS['cfg']['NavigationDisplayLogo']) {
72 $logo = 'phpMyAdmin';
73 if (@file_exists($GLOBALS['pmaThemeImage'] . 'logo_left.png')) {
74 $logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'logo_left.png" '
75 . 'alt="' . $logo . '" id="imgpmalogo" />';
76 } elseif (@file_exists($GLOBALS['pmaThemeImage'] . 'pma_logo2.png')) {
77 $logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png" '
78 . 'alt="' . $logo . '" id="imgpmalogo" />';
80 $retval .= '<div id="pmalogo">';
81 if ($GLOBALS['cfg']['NavigationLogoLink']) {
82 $retval .= ' <a href="' . htmlspecialchars(
83 $GLOBALS['cfg']['NavigationLogoLink']
85 switch ($GLOBALS['cfg']['NavigationLogoLinkWindow']) {
86 case 'new':
87 $retval .= '" target="_blank"';
88 break;
89 case 'main':
90 // do not add our parameters for an external link
91 if (substr(strtolower($GLOBALS['cfg']['NavigationLogoLink']), 0, 4) !== '://') {
92 $retval .= '?' . $GLOBALS['url_query'] . '"';
93 } else {
94 $retval .= '" target="_blank"';
97 $retval .= '>';
98 $retval .= $logo;
99 $retval .= '</a>';
100 } else {
101 $retval .= $logo;
103 $retval .= '</div>';
105 $retval .= '<!-- LOGO END -->';
106 return $retval;
110 * Renders a single link for the top of the navigation panel
112 * @param string $link The url for the link
113 * @param bool $showText Whether to show the text or to
114 * only use it for title attributes
115 * @param string $text The text to display and use for title attributes
116 * @param bool $showIcon Whether to show the icon
117 * @param string $icon The filename of the icon to show
118 * @param string $linkId Value to use for the ID attribute
119 * @param string $disableAjax Whether to disable ajax page loading for this link
120 * @param string $linkTarget The name of the target frame for the link
122 * @return string HTML code for one link
124 private function _getLink(
125 $link,
126 $showText,
127 $text,
128 $showIcon,
129 $icon,
130 $linkId = '',
131 $disableAjax = false,
132 $linkTarget = ''
134 $retval = '<a href="' . $link . '"';
135 if (! empty($linkId)) {
136 $retval .= ' id="' . $linkId . '"';
138 if (! empty($linkTarget)) {
139 $retval .= ' target="' . $linkTarget . '"';
141 if ($disableAjax) {
142 $retval .= ' class="disableAjax"';
144 $retval .= ' title="' . $text . '">';
145 if ($showIcon) {
146 $retval .= PMA_Util::getImage(
147 $icon,
148 $text
151 if ($showText) {
152 $retval .= $text;
154 $retval .= '</a>';
155 if ($showText) {
156 $retval .= '<br />';
158 return $retval;
162 * Creates the code for displaying the links
163 * at the top of the navigation frame
165 * @return string HTML code for the links
167 private function _links()
169 $iconicNav = $GLOBALS['cfg']['NavigationBarIconic'];
170 $showIcon = $iconicNav === true || $iconicNav === 'both';
171 $showText = $iconicNav === false || $iconicNav === 'both';
173 $retval = '<!-- LINKS START -->';
174 $retval .= '<div id="leftframelinks">';
175 $retval .= $this->_getLink(
176 'index.php?' . PMA_generate_common_url(),
177 $showText,
178 __('Home'),
179 $showIcon,
180 'b_home.png'
182 // if we have chosen server
183 if ($GLOBALS['server'] != 0) {
184 // Logout for advanced authentication
185 if ($GLOBALS['cfg']['Server']['auth_type'] != 'config') {
186 $link = 'index.php?' . $GLOBALS['url_query'];
187 $link .= '&amp;old_usr=' . urlencode($GLOBALS['PHP_AUTH_USER']);
188 $retval .= $this->_getLink(
189 $link,
190 $showText,
191 __('Log out'),
192 $showIcon,
193 's_loggoff.png',
195 true
198 $link = 'querywindow.php?';
199 $link .= PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']);
200 $link .= '&amp;no_js=true';
201 $retval .= $this->_getLink(
202 $link,
203 $showText,
204 __('Query window'),
205 $showIcon,
206 'b_selboard.png',
207 'pma_open_querywindow',
208 true
211 $retval .= $this->_getLink(
212 PMA_Util::getDocuLink('index'),
213 $showText,
214 __('phpMyAdmin documentation'),
215 $showIcon,
216 'b_docs.png',
218 false,
219 'documentation'
221 if ($showIcon) {
222 $retval .= PMA_Util::showMySQLDocu('', '', true);
224 if ($showText) {
225 // PMA_showMySQLDocu always spits out an icon,
226 // we just replace it with some perl regexp.
227 $link = preg_replace(
228 '/<img[^>]+>/i',
229 __('Documentation'),
230 PMA_Util::showMySQLDocu('', '', true)
232 $retval .= $link;
233 $retval .= '<br />';
235 $retval .= $this->_getLink(
236 '#',
237 $showText,
238 __('Reload navigation frame'),
239 $showIcon,
240 's_reload.png',
241 'pma_navigation_reload'
243 $retval .= '</div>';
244 $retval .= '<!-- LINKS ENDS -->';
245 return $retval;
249 * Displays the MySQL servers choice form
251 * @return string HTML code for the MySQL servers choice
253 private function _serverChoice()
255 $retval = '';
256 if ($GLOBALS['cfg']['NavigationDisplayServers']
257 && count($GLOBALS['cfg']['Servers']) > 1
259 include_once './libraries/select_server.lib.php';
260 $retval .= '<!-- SERVER CHOICE START -->';
261 $retval .= '<div id="serverChoice">';
262 $retval .= PMA_selectServer(true, true);
263 $retval .= '</div>';
264 $retval .= '<!-- SERVER CHOICE END -->';
266 return $retval;
270 * Displays a drop-down choice of most recently used tables
272 * @return string HTML code for the Recent tables
274 private function _recent()
276 $retval = '';
277 // display recently used tables
278 if ($GLOBALS['cfg']['NumRecentTables'] > 0) {
279 $retval .= '<!-- RECENT START -->';
280 $retval .= '<div id="recentTableList">';
281 $retval .= '<form method="post" ';
282 $retval .= 'action="' . $GLOBALS['cfg']['DefaultTabTable'] . '">';
283 $retval .= PMA_generate_common_hidden_inputs(
284 array(
285 'db' => '',
286 'table' => '',
287 'server' => $GLOBALS['server']
290 $retval .= PMA_RecentTable::getInstance()->getHtmlSelect();
291 $retval .= '</form>';
292 $retval .= '</div>';
293 $retval .= '<!-- RECENT END -->';
295 return $retval;