PageRenderTime 61ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/header.inc.php

https://gitlab.com/x33n/ampache
PHP | 430 lines | 384 code | 22 blank | 24 comment | 57 complexity | b8eec213de6c74d7c4d92493570280d3 MD5 | raw file
  1. <?php
  2. /* vim:set softtabstop=4 shiftwidth=4 expandtab: */
  3. /**
  4. *
  5. * LICENSE: GNU General Public License, version 2 (GPLv2)
  6. * Copyright 2001 - 2015 Ampache.org
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License v2
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. *
  21. */
  22. if (INIT_LOADED != '1') { exit; }
  23. $web_path = AmpConfig::get('web_path');
  24. $htmllang = str_replace("_", "-", AmpConfig::get('lang'));
  25. $location = get_location();
  26. $_SESSION['login'] = false;
  27. ?>
  28. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  29. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>" dir="<?php echo is_rtl(AmpConfig::get('lang')) ? 'rtl' : 'ltr';?>">
  30. <head>
  31. <link rel="shortcut icon" href="<?php echo $web_path; ?>/favicon.ico" />
  32. <link rel="search" type="application/opensearchdescription+xml" title="<?php echo scrub_out(AmpConfig::get('site_title')); ?>" href="<?php echo $web_path; ?>/search.php?action=descriptor" />
  33. <?php if (AmpConfig::get('use_rss')) { ?>
  34. <link rel="alternate" type="application/rss+xml" title="<?php echo T_('Now Playing'); ?>" href="<?php echo $web_path; ?>/rss.php" />
  35. <link rel="alternate" type="application/rss+xml" title="<?php echo T_('Recently Played'); ?>" href="<?php echo $web_path; ?>/rss.php?type=recently_played" />
  36. <link rel="alternate" type="application/rss+xml" title="<?php echo T_('Newest Albums'); ?>" href="<?php echo $web_path; ?>/rss.php?type=latest_album" />
  37. <?php } ?>
  38. <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=<?php echo AmpConfig::get('site_charset'); ?>" />
  39. <title><?php echo AmpConfig::get('site_title'); ?> - <?php echo $location['title']; ?></title>
  40. <?php require_once AmpConfig::get('prefix') . '/templates/stylesheets.inc.php'; ?>
  41. <link rel="stylesheet" href="<?php echo $web_path; ?>/templates/jquery-editdialog.css" type="text/css" media="screen" />
  42. <link rel="stylesheet" href="<?php echo $web_path; ?>/modules/jquery-ui-ampache/jquery-ui.min.css" type="text/css" media="screen" />
  43. <link rel="stylesheet" href="<?php echo $web_path; ?>/templates/jquery-file-upload.css" type="text/css" media="screen" />
  44. <link rel="stylesheet" href="<?php echo $web_path; ?>/modules/jstree/themes/default/style.min.css" type="text/css" media="screen" />
  45. <link rel="stylesheet" href="<?php echo $web_path; ?>/modules/tag-it/jquery.tagit.css" type="text/css" media="screen" />
  46. <link rel="stylesheet" href="<?php echo $web_path; ?>/modules/rhinoslider/css/rhinoslider-1.05.css" type="text/css" media="screen" />
  47. <link rel="stylesheet" href="<?php echo $web_path; ?>/modules/jquery-mediaTable/jquery.mediaTable.css" type="text/css" media="screen" />
  48. <link rel="stylesheet" href="<?php echo $web_path; ?>/modules/jquery-datetimepicker/jquery.datetimepicker.css" type="text/css" media="screen" />
  49. <script src="<?php echo $web_path; ?>/modules/jquery/jquery.min.js" language="javascript" type="text/javascript"></script>
  50. <script src="<?php echo $web_path; ?>/modules/jquery-ui/jquery-ui.min.js" language="javascript" type="text/javascript"></script>
  51. <script src="<?php echo $web_path; ?>/modules/prettyPhoto/js/jquery.prettyPhoto.js" language="javascript" type="text/javascript"></script>
  52. <script src="<?php echo $web_path; ?>/modules/tag-it/tag-it.min.js" language="javascript" type="text/javascript"></script>
  53. <script src="<?php echo $web_path; ?>/modules/noty/packaged/jquery.noty.packaged.min.js" language="javascript" type="text/javascript"></script>
  54. <script src="<?php echo $web_path; ?>/modules/jquery-cookie/jquery.cookie.js" language="javascript" type="text/javascript"></script>
  55. <script src="<?php echo $web_path; ?>/modules/jscroll/jquery.jscroll.min.js" language="javascript" type="text/javascript"></script>
  56. <script src="<?php echo $web_path; ?>/modules/jquery-qrcode/jquery.qrcode.min.js" language="javascript" type="text/javascript"></script>
  57. <script src="<?php echo $web_path; ?>/modules/rhinoslider/js/rhinoslider-1.05.min.js" language="javascript" type="text/javascript"></script>
  58. <script src="<?php echo $web_path; ?>/modules/responsive-elements/responsive-elements.js" language="javascript" type="text/javascript"></script>
  59. <script src="<?php echo $web_path; ?>/modules/jquery-mediaTable/jquery.mediaTable.js" language="javascript" type="text/javascript"></script>
  60. <script src="<?php echo $web_path; ?>/modules/jquery-datetimepicker/jquery.datetimepicker.js" language="javascript" type="text/javascript"></script>
  61. <script src="<?php echo $web_path; ?>/modules/jquery-knob/jquery.knob.js" language="javascript" type="text/javascript"></script>
  62. <script src="<?php echo $web_path; ?>/modules/jquery-file-upload/jquery.iframe-transport.js" language="javascript" type="text/javascript"></script>
  63. <script src="<?php echo $web_path; ?>/modules/jquery-file-upload/jquery.fileupload.js" language="javascript" type="text/javascript"></script>
  64. <script src="<?php echo $web_path; ?>/lib/javascript/base.js" language="javascript" type="text/javascript"></script>
  65. <script src="<?php echo $web_path; ?>/lib/javascript/ajax.js" language="javascript" type="text/javascript"></script>
  66. <script src="<?php echo $web_path; ?>/lib/javascript/tools.js" language="javascript" type="text/javascript"></script>
  67. <script type="text/javascript" charset="utf-8">
  68. $(document).ready(function(){
  69. $("a[rel^='prettyPhoto']").prettyPhoto({social_tools:false});
  70. <?php if (AmpConfig::get('geolocation')) { ?>
  71. geolocate_user();
  72. <?php } ?>
  73. });
  74. // Using the following workaround to set global variable available from any javascript script.
  75. var jsAjaxUrl = "<?php echo AmpConfig::get('ajax_url') ?>";
  76. var jsWebPath = "<?php echo $web_path; ?>";
  77. var jsAjaxServer = "<?php echo AmpConfig::get('ajax_server') ?>";
  78. var jsSaveTitle = "<?php echo T_('Save') ?>";
  79. var jsCancelTitle = "<?php echo T_('Cancel') ?>";
  80. </script>
  81. <?php
  82. if (AmpConfig::get('ajax_load')) {
  83. $iframed = true;
  84. ?>
  85. <script src="<?php echo $web_path; ?>/lib/javascript/dynamicpage.js" language="javascript" type="text/javascript"></script>
  86. <?php
  87. require_once AmpConfig::get('prefix') . '/templates/show_html5_player_headers.inc.php';
  88. ?>
  89. <script type="text/javascript">
  90. function NavigateTo(url)
  91. {
  92. window.location.hash = url.substring(jsWebPath.length + 1);
  93. }
  94. function getCurrentPage()
  95. {
  96. if (window.location.hash.length > 0) {
  97. var wpage = window.location.hash.substring(1);
  98. if (wpage !== 'prettyPhoto') {
  99. return btoa(wpage);
  100. } else {
  101. return "";
  102. }
  103. }
  104. return btoa(window.location.href.substring(jsWebPath.length + 1));
  105. }
  106. </script>
  107. <?php
  108. } else {
  109. ?>
  110. <script type="text/javascript">
  111. function NavigateTo(url)
  112. {
  113. window.location.href = url;
  114. }
  115. function getCurrentPage()
  116. {
  117. return btoa(window.location.href);
  118. }
  119. </script>
  120. <?php } ?>
  121. <script type="text/javascript">
  122. $.widget( "custom.catcomplete", $.ui.autocomplete, {
  123. _renderItem: function( ul, item ) {
  124. var itemhtml = "<a href='" + item.link + "'>";
  125. if (item.image != '') {
  126. itemhtml += "<img src='" + item.image + "' class='searchart' />";
  127. }
  128. itemhtml += "<span class='searchitemtxt'>" + item.label + ((item.rels == '') ? "" : " - " + item.rels) + "</span></a>"
  129. return $( "<li class='ui-menu-item'>" )
  130. .data("ui-autocomplete-item", item)
  131. .append( itemhtml )
  132. .appendTo( ul );
  133. },
  134. _renderMenu: function( ul, items ) {
  135. var that = this, currentType = "";
  136. $.each( items, function( index, item ) {
  137. if (item.type != currentType) {
  138. ul.append( "<li class='ui-autocomplete-category'>" + item.type + "</li>" );
  139. currentType = item.type;
  140. }
  141. that._renderItem( ul, item );
  142. });
  143. }
  144. });
  145. $(function() {
  146. $( "#searchString" )
  147. // don't navigate away from the field on tab when selecting an item
  148. .bind( "keydown", function( event ) {
  149. if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "ui-autocomplete" ).menu.active ) {
  150. event.preventDefault();
  151. }
  152. })
  153. .catcomplete({
  154. source: function( request, response ) {
  155. $.getJSON( jsAjaxUrl, {
  156. page: 'search',
  157. action: 'search',
  158. target: $('#searchStringRule').val(),
  159. search: request.term,
  160. xoutput: 'json'
  161. }, response );
  162. },
  163. search: function() {
  164. // custom minLength
  165. if (this.value.length < 2) {
  166. return false;
  167. }
  168. },
  169. focus: function() {
  170. // prevent value inserted on focus
  171. return false;
  172. },
  173. select: function( event, ui ) {
  174. if (ui.item != null) {
  175. $(this).val(ui.item.value);
  176. }
  177. return false;
  178. }
  179. });
  180. });
  181. </script>
  182. <script type="text/javascript">
  183. var lastaction = new Date().getTime();
  184. var refresh_slideshow_interval=<?php echo AmpConfig::get('slideshow_time'); ?>;
  185. var iSlideshow = null;
  186. var tSlideshow = null;
  187. function init_slideshow_check()
  188. {
  189. if (refresh_slideshow_interval > 0) {
  190. if (tSlideshow != null) {
  191. clearTimeout(tSlideshow);
  192. }
  193. tSlideshow = window.setTimeout(function(){init_slideshow_refresh();}, refresh_slideshow_interval * 1000);
  194. }
  195. }
  196. function swap_slideshow()
  197. {
  198. if (iSlideshow == null) {
  199. init_slideshow_refresh();
  200. } else {
  201. stop_slideshow();
  202. }
  203. }
  204. function init_slideshow_refresh()
  205. {
  206. if ($("#webplayer").is(":visible")) {
  207. clearTimeout(tSlideshow);
  208. tSlideshow = null;
  209. $("#aslideshow").height($(document).height())
  210. .css({'display': 'inline'});
  211. iSlideshow = true;
  212. refresh_slideshow();
  213. }
  214. }
  215. function refresh_slideshow()
  216. {
  217. if (iSlideshow != null) {
  218. <?php echo Ajax::action('?page=index&action=slideshow', ''); ?>;
  219. } else {
  220. init_slideshow_check();
  221. }
  222. }
  223. function stop_slideshow()
  224. {
  225. if (iSlideshow != null) {
  226. iSlideshow = null;
  227. $("#aslideshow").css({'display': 'none'});
  228. }
  229. }
  230. function update_action()
  231. {
  232. lastaction = new Date().getTime();
  233. stop_slideshow();
  234. init_slideshow_check();
  235. }
  236. $(document).mousemove(function(e) {
  237. if (iSlideshow == null) {
  238. update_action();
  239. }
  240. });
  241. $(document).ready(function() {
  242. init_slideshow_check();
  243. });
  244. </script>
  245. </head>
  246. <body>
  247. <?php if (AmpConfig::get('sociable') && AmpConfig::get('notify')) { ?>
  248. <script type="text/javascript" language="javascript">
  249. var lastrefresh = new Date().getTime();
  250. var refresh_sociable_interval=<?php echo AmpConfig::get('refresh_limit') ?>;
  251. function refresh_sociable()
  252. {
  253. <?php echo Ajax::action('?page=index&action=shoutbox&since=\' + lastrefresh + \'', ''); ?>;
  254. lastrefresh = new Date().getTime();
  255. }
  256. $(document).ready(function() {
  257. window.setInterval(function(){refresh_sociable();}, refresh_sociable_interval * 1000);
  258. });
  259. </script>
  260. <div id="live_shoutbox"></div>
  261. <?php } ?>
  262. <div id="aslideshow">
  263. <div id="aslideshow_container">
  264. <div id="fslider"></div>
  265. <div id="fslider_script"></div>
  266. </div>
  267. </div>
  268. <script type="text/javascript" language="javascript">
  269. $("#aslideshow").click(function(e) {
  270. if (!$(e.target).hasClass('rhino-btn')) {
  271. update_action();
  272. }
  273. });
  274. </script>
  275. <?php if (AmpConfig::get('cookie_disclaimer') && !isset($_COOKIE['cookie_disclaimer'])) { ?>
  276. <script type="text/javascript" language="javascript">
  277. noty({text: '<?php echo T_("We have placed cookies on your computer to help make this website better. You can change your") . " <a href=\"" . AmpConfig::get('web_path') . "/cookie_disclaimer.php\">" . T_("cookie settings") . "</a> " . T_("at any time. Otherwise, we\'ll assume you\'re OK to continue.<br /><br />Click on this message do not display it again."); ?>',
  278. type: 'warning',
  279. layout: 'bottom',
  280. timeout: false,
  281. callback: {
  282. afterClose: function() {
  283. $.cookie('cookie_disclaimer', '1', { expires: 365 });
  284. }
  285. },
  286. });
  287. </script>
  288. <?php } ?>
  289. <!-- rfc3514 implementation -->
  290. <div id="rfc3514" style="display:none;">0x0</div>
  291. <div id="notification" class="notification-out"><img src="<?php echo $web_path; ?>/images/icon_info.png" /><span id="notification-content"></span></div>
  292. <div id="maincontainer">
  293. <div id="header" class="header-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>"><!-- This is the header -->
  294. <h1 id="headerlogo">
  295. <a href="<?php echo $web_path; ?>/index.php">
  296. <img src="<?php echo UI::get_logo_url(); ?>" title="<?php echo AmpConfig::get('site_title'); ?>" alt="<?php echo AmpConfig::get('site_title'); ?>" />
  297. </a>
  298. </h1>
  299. <div id="headerbox">
  300. <?php UI::show_box_top('','box box_headerbox'); ?>
  301. <?php require_once AmpConfig::get('prefix') . '/templates/show_search_bar.inc.php'; ?>
  302. <?php if (User::is_registered()) { ?>
  303. <?php require_once AmpConfig::get('prefix') . '/templates/show_playtype_switch.inc.php'; ?>
  304. <span id="loginInfo"><a href="<?php echo $web_path; ?>/preferences.php?tab=account"><?php echo $GLOBALS['user']->fullname; ?></a> <a rel="nohtml" href="<?php echo $web_path; ?>/logout.php">[<?php echo T_('Log out'); ?>]</a></span>
  305. <?php } else { ?>
  306. <span id="loginInfo">
  307. <a href="<?php echo $web_path; ?>/login.php" rel="nohtml"><?php echo T_('Login'); ?></a>
  308. <?php if (AmpConfig::get('allow_public_registration')) { ?>
  309. / <a href="<?php echo $web_path; ?>/register.php" rel="nohtml"><?php echo T_('Register'); ?></a>
  310. <?php } ?>
  311. </span>
  312. <?php } ?>
  313. <span id="updateInfo">
  314. <?php
  315. if (AmpConfig::get('autoupdate') && Access::check('interface','100')) {
  316. if (AutoUpdate::is_update_available()) {
  317. AutoUpdate::show_new_version();
  318. }
  319. }
  320. $count_temp_playlist = count($GLOBALS['user']->playlist->get_items());
  321. ?>
  322. </span>
  323. <?php UI::show_box_bottom(); ?>
  324. </div> <!-- End headerbox -->
  325. </div><!-- End header -->
  326. <?php if (AmpConfig::get('topmenu')) { ?>
  327. <div id="topmenu_container" class="topmenu_container-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>">
  328. <div id="topmenu_item">
  329. <a href="<?php echo $web_path; ?>/index.php">
  330. <img src="<?php echo $web_path; ?>/images/topmenu-home.png" />
  331. <span><?php echo T_('Home'); ?></span>
  332. </a>
  333. </div>
  334. <div id="topmenu_item">
  335. <a href="<?php echo $web_path; ?>/browse.php?action=artist">
  336. <img src="<?php echo $web_path; ?>/images/topmenu-music.png" />
  337. <span><?php echo T_('Artists'); ?></span>
  338. </a>
  339. </div>
  340. <div id="topmenu_item">
  341. <a href="<?php echo $web_path; ?>/browse.php?action=playlist">
  342. <img src="<?php echo $web_path; ?>/images/topmenu-playlist.png" />
  343. <span><?php echo T_('Playlists'); ?></span>
  344. </a>
  345. </div>
  346. <div id="topmenu_item">
  347. <a href="<?php echo $web_path; ?>/stats.php?action=userflag">
  348. <img src="<?php echo $web_path; ?>/images/topmenu-favorite.png" />
  349. <span><?php echo T_('Favorites'); ?></span>
  350. </a>
  351. </div>
  352. </div>
  353. <?php } ?>
  354. <?php $isCollapsed = $_COOKIE['sidebar_state'] == "collapsed"; ?>
  355. <div id="sidebar" class="sidebar-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>">
  356. <div id="sidebar-header" class="<?php echo $isCollapsed ? 'sidebar-header-collapsed' : ''; ?>" ><span id="sidebar-header-content"><?php echo $isCollapsed ? '>>>' : '<<<'; ?></span></div>
  357. <div id="sidebar-content" class="<?php echo $isCollapsed ? 'sidebar-content-collapsed' : ''; ?>" >
  358. <?php require_once AmpConfig::get('prefix') . '/templates/sidebar.inc.php'; ?>
  359. </div>
  360. <div id="sidebar-content-light" class="<?php echo $isCollapsed ? 'sidebar-content-light-collapsed' : ''; ?>" >
  361. <?php require_once AmpConfig::get('prefix') . '/templates/sidebar.light.inc.php'; ?>
  362. </div>
  363. </div>
  364. <!-- Handle collapsed visibility -->
  365. <script type="text/javascript">
  366. $('#sidebar-header').click(function(){
  367. var newstate = "collapsed";
  368. if ($('#sidebar-header').hasClass("sidebar-header-collapsed")) {
  369. newstate = "expanded";
  370. }
  371. if (newstate != "expanded") {
  372. $("#content").addClass("content-left-wild", 600);
  373. } else {
  374. $("#content").removeClass("content-left-wild", 1000);
  375. }
  376. $('#sidebar').hide(500, function() {
  377. if (newstate == "expanded") {
  378. $('#sidebar-content-light').removeClass("sidebar-content-light-collapsed");
  379. $('#sidebar-content').removeClass("sidebar-content-collapsed");
  380. $('#sidebar-header').removeClass("sidebar-header-collapsed");
  381. $('#sidebar-header-content').text('<<<');
  382. } else {
  383. $('#sidebar-content').addClass("sidebar-content-collapsed");
  384. $('#sidebar-header').addClass("sidebar-header-collapsed");
  385. $('#sidebar-content-light').addClass("sidebar-content-light-collapsed");
  386. $('#sidebar-header-content').text('>>>');
  387. }
  388. $('#sidebar').show(500);
  389. });
  390. $.cookie('sidebar_state', newstate, { expires: 30, path: '/'});
  391. });
  392. </script>
  393. <div id="rightbar" class="rightbar-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?> <?php echo $count_temp_playlist ? '' : 'hidden' ?>">
  394. <?php require_once AmpConfig::get('prefix') . '/templates/rightbar.inc.php'; ?>
  395. </div>
  396. <!-- Tiny little div, used to cheat the system -->
  397. <div id="ajax-loading">Loading . . .</div>
  398. <div id="util_div" style="display:none;"></div>
  399. <iframe name="util_iframe" id="util_iframe" style="display:none;" src="<?php echo $web_path; ?>/util.php"></iframe>
  400. <div id="content" class="content-<?php echo AmpConfig::get('ui_fixed') ? (AmpConfig::get('topmenu') ? 'fixed-topmenu' : 'fixed') : 'float'; ?> <?php echo (($count_temp_playlist || AmpConfig::get('play_type') == 'localplay') ? '' : 'content-right-wild'); echo $isCollapsed ? ' content-left-wild' : ''; ?>">
  401. <?php if (AmpConfig::get('int_config_version') != AmpConfig::get('config_version') AND $GLOBALS['user']->has_access(100)) { ?>
  402. <div class="fatalerror">
  403. <?php echo T_('Error Config File Out of Date'); ?>
  404. <a rel="nohtml" href="<?php echo $web_path; ?>/admin/system.php?action=generate_config"><?php echo T_('Generate New Config'); ?></a> |
  405. <a rel="nohtml" href="<?php echo $web_path; ?>/admin/system.php?action=write_config"><?php echo T_('Write New Config'); ?></a>
  406. </div>
  407. <?php } ?>
  408. <div id="guts">