We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

templating.php 3.09 KB
Newer Older
mattl's avatar
mattl committed
1 2
<?php

mattl's avatar
mattl committed
3 4
/* Libre.fm -- a free network service for sharing your music listening habits

5
   Copyright (C) 2009 Free Software Foundation, Inc
mattl's avatar
mattl committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

22 23 24
require_once('config.php');
require_once('auth.php');
require_once('smarty/Smarty.class.php');
elleo's avatar
elleo committed
25

26
if($_GET['lang']) {
elleo's avatar
elleo committed
27 28
	$languages = array($_GET['lang'] . '.UTF-8');
	setcookie('lang', $_GET['lang'] . '.UTF-8', time() + 31536000);
29 30
} elseif (isset($_COOKIE['lang'])) {
	$languages = array($_COOKIE['lang']);
31
} else {
32
	// Attempt to mangle browser language strings in to valid gettext locales (needs a big lookup table to be 100% accurate)
elleo's avatar
elleo committed
33
	$languages = preg_split('/,/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
34 35 36 37 38 39 40 41
	for($i = 0; $i < count($languages); $i++) {
		$languages[$i] = preg_replace('/;q=\d\.\d/', '', $languages[$i]);
		if(strlen($languages[$i]) == 2) {
			$languages[$i] = $languages[$i] . '_' . strtoupper($languages[$i]);
		} elseif (stristr($languages[$i], '-')) {
			$lcomponents = preg_split('/-/', $languages[$i]);
			$languages[$i] = $lcomponents[0]  . '_' . strtoupper($lcomponents[1]);
		}
clint's avatar
clint committed
42

elleo's avatar
elleo committed
43
		$languages[$i] = $languages[$i] . '.UTF-8';
44
	}
45
}
46
$current_lang = setlocale(LC_ALL, $languages);
elleo's avatar
elleo committed
47 48
bindtextdomain('nixtape', $install_path . '/themes/' . $default_theme . '/locale/');
textdomain('nixtape');
49

elleo's avatar
elleo committed
50
$smarty = new Smarty();
mattl's avatar
mattl committed
51

52 53
$smarty->template_dir = $install_path . '/themes/'. $default_theme . '/templates/';
$smarty->compile_dir = $install_path. '/themes/' . $default_theme . '/templates_c/';
clint's avatar
clint committed
54
$smarty->cache_dir = $install_path. '/cache/';
tobyink's avatar
tobyink committed
55

56
$current_lang = preg_replace('/.UTF-8/', '', $current_lang);
57
$smarty->assign('current_lang', $current_lang);
58
$smarty->assign('lang_selector_array', array(($current_lang) => 1));
59
$smarty->assign('base_url', $base_url);
tobyink's avatar
tobyink committed
60
$smarty->assign('this_page', $_SERVER['REQUEST_URI']);
tobyink's avatar
tobyink committed
61
$smarty->assign('this_page_absolute',
clint's avatar
clint committed
62
	 (empty($_SERVER['HTTPS']) ? 'http://' : 'http://')
tobyink's avatar
tobyink committed
63 64 65
	.(empty($_SERVER['HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HOST'])
	.(($_SERVER['SERVER_PORT']==80) ? '' : (':'.$_SERVER['SERVER_PORT']))
	. $_SERVER['REQUEST_URI']);
tobyink's avatar
tobyink committed
66

67 68
if(isset($logged_in)) {
	$smarty->assign('logged_in', true);
69 70
	// Pre-fix this user's details with 'this_' to avoid confusion with other users
	$smarty->assign('this_user', $this_user);
elleo's avatar
elleo committed
71 72
}

mattl's avatar
mattl committed
73
/* $random_group = Group::random();
tobyink's avatar
tobyink committed
74 75
if ($random_group!==false && !PEAR::isError($random_group))
{
mattl's avatar
mattl committed
76 77
	$smarty-assign('random_group', $random_group);
	} */
tobyink's avatar
tobyink committed
78

elleo's avatar
elleo committed
79
header('Content-Type: text/html; charset=utf-8');
80

81 82 83 84
function insert_getMenu($lidsid, $smrt) {
	$smrt->display('menu.tpl');
}

elleo's avatar
elleo committed
85
?>