Project

General

Profile

1 1035 Ruebenwurz
<?php
2
3
// $Id$
4
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
24
*/
25
26
require('../../config.php');
27
require_once(WB_PATH.'/framework/class.admin.php');
28
$admin = new admin('Media', 'media', false);
29
// Include the WB functions file
30
require_once(WB_PATH.'/framework/functions.php');
31
32 1082 Ruebenwurz
// check if theme language file exists for the language set by the user (e.g. DE, EN)
33
if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
34
	// no theme language file exists for the language set by the user, include default theme language file EN.php
35
	require_once(THEME_PATH .'/languages/EN.php');
36
} else {
37
	// a theme language file exists for the language defined by the user, load it
38
	require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
39
}
40
41 1035 Ruebenwurz
//Save post vars to the parameters file
42
if ( !is_null($admin->get_post_escaped("save"))) {
43
	//Check for existing settings entry, if not existing, create a record first!
44
	if (!$database->query ( "SELECT * FROM ".TABLE_PREFIX."settings where `name`='mediasettings'" )) {
45
		$database->query ( "INSERT INTO ".TABLE_PREFIX."settings (`name`,`value`) VALUES ('mediasettings','')" );
46
	}
47
	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
48
	$dirs[] = WB_PATH.MEDIA_DIRECTORY;
49
	foreach($dirs AS $name) {
50
		$r = str_replace(WB_PATH, '', $name);
51
		$r = str_replace('/','_',$r);
52
		$w = (int)$admin->get_post_escaped($r.'-w');
53
		$h = (int)$admin->get_post_escaped($r.'-h');
54
		$pathsettings[$r]['width']=$w;
55
		$pathsettings[$r]['height']=$h;
56
	}
57
	$pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!=''?'checked':'');
58
	$pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!=''?'checked':'');
59
	$fieldSerialized = serialize($pathsettings);
60
	$database->query ( "UPDATE ".TABLE_PREFIX."settings SET `value` = '$fieldSerialized' WHERE `name`='mediasettings'" );
61
	header ("Location: browse.php");
62
}
63
64
include ('parameters.php');
65
if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) {
66
	echo "Sorry, settings not available";
67
	exit();
68
}
69
70
// Read data to display
71
$caller = "setparameter";
72
73
$template = new Template(THEME_PATH.'/templates');
74
$template->set_file('page', 'setparameter.htt');
75
$template->set_block('page', 'main_block', 'main');
76
if ($_SESSION['GROUP_ID'] != 1) {
77
	$template->set_var('DISPLAY_ADMIN', 'hide');
78
}
79
$template->set_var(array(
80 1082 Ruebenwurz
					'TEXT_HEADER' => $TEXT['TEXT_HEADER'],
81 1035 Ruebenwurz
					'SAVE_TEXT' => $TEXT['SAVE'],
82
					'BACK' => $TEXT['BACK']
83
				)
84
			);
85
86
87
$template->set_block('main_block', 'list_block', 'list');
88
$row_bg_color = '';
89
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
90
$dirs[] = WB_PATH.MEDIA_DIRECTORY;
91
92
$array_lowercase = array_map('strtolower', $dirs);
93
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
94
95
foreach($dirs AS $name) {
96
	$relative = str_replace(WB_PATH, '', $name);
97
	$safepath = str_replace('/','_',$relative);
98
	$cur_width = $cur_height = '';
99
	if (isset($pathsettings[$safepath]['width'])) $cur_width = $pathsettings[$safepath]['width'];
100
	if (isset($pathsettings[$safepath]['height'])) $cur_height = $pathsettings[$safepath]['height'];
101
	$cur_width = ($cur_width ? (int)$cur_width : '-');
102
	$cur_height = ($cur_height ? (int)$cur_height : '-');
103
104
	if($row_bg_color == 'DEDEDE') $row_bg_color = 'EEEEEE';
105
	else $row_bg_color = 'DEDEDE';
106
107
	$template->set_var(array(
108
								'ADMIN_URL' => ADMIN_URL,
109
								'PATH_NAME' => $relative,
110
								'WIDTH' => $TEXT['WIDTH'],
111
								'HEIGHT' => $TEXT['HEIGHT'],
112
								'FIELD_NAME_W' => $safepath.'-w',
113
								'FIELD_NAME_H' => $safepath.'-h',
114
								'CUR_WIDTH' => $cur_width,
115
								'CUR_HEIGHT' => $cur_height,
116
								'SETTINGS' => $TEXT['SETTINGS'],
117 1082 Ruebenwurz
								'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'],
118 1035 Ruebenwurz
								'ADMIN_ONLY_SELECTED' => $pathsettings['global']['admin_only'],
119 1082 Ruebenwurz
								'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'],
120 1035 Ruebenwurz
								'NO_SHOW_THUMBS_SELECTED' => $pathsettings['global']['show_thumbs'],
121
								'ROW_BG_COLOR' => $row_bg_color
122
							)
123
					);
124
	$template->parse('list', 'list_block', true);
125
}
126
127
$template->parse('main', 'main_block', false);
128
$template->pparse('output', 'page');
129
130
131
?>