Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         media
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id: setparameter.php 1476 2011-07-13 15:46:19Z Luisehahne $
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
16
 *
17
 */
18

    
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
21
$admin = new admin('Media', 'media', false);
22
// Include the WB functions file
23
require_once(WB_PATH.'/framework/functions.php');
24

    
25
// check if theme language file exists for the language set by the user (e.g. DE, EN)
26
if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
27
	// no theme language file exists for the language set by the user, include default theme language file EN.php
28
	require_once(THEME_PATH .'/languages/EN.php');
29
} else {
30
	// a theme language file exists for the language defined by the user, load it
31
	require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
32
}
33

    
34
//Save post vars to the parameters file
35
if ( !is_null($admin->get_post_escaped("save"))) {
36
/*
37
	if (!$admin->checkFTAN())
38
	{
39
		$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'],'browse.php',false);
40
	}
41
*/
42

    
43
	if(DEFAULT_THEME != ' wb_theme') {
44
		//Check for existing settings entry, if not existing, create a record first!
45
		if (!$database->query ( "SELECT * FROM ".TABLE_PREFIX."settings where `name`='mediasettings'" )) {
46
			$database->query ( "INSERT INTO ".TABLE_PREFIX."settings (`name`,`value`) VALUES ('mediasettings','')" );
47
		}
48
	} else {
49
		$pathsettings = array();
50
	}
51

    
52
	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
53
	$dirs[] = WB_PATH.MEDIA_DIRECTORY;
54
	foreach($dirs AS $name) {
55
		$r = str_replace(WB_PATH, '', $name);
56
		$r = str_replace(array('/',' '),'_',$r);
57
		$w = (int)$admin->get_post_escaped($r.'-w');
58
		$h = (int)$admin->get_post_escaped($r.'-h');
59
		$pathsettings[$r]['width']=$w; 
60
		$pathsettings[$r]['height']=$h;
61
	}
62
	$pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!=''?'checked':'');
63
	$pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!=''?'checked':'');
64
	$fieldSerialized = serialize($pathsettings);
65
	$database->query ( "UPDATE ".TABLE_PREFIX."settings SET `value` = '$fieldSerialized' WHERE `name`='mediasettings'" );
66
	header ("Location: browse.php");
67
}
68

    
69
include ('parameters.php');
70
if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) {
71
	echo "Sorry, settings not available";
72
	exit();
73
}
74

    
75
// Read data to display
76
$caller = "setparameter";
77

    
78
$template = new Template(THEME_PATH.'/templates');
79
$template->set_file('page', 'setparameter.htt');
80
$template->set_block('page', 'main_block', 'main');
81
if ($_SESSION['GROUP_ID'] != 1) {
82
	$template->set_var('DISPLAY_ADMIN', 'hide');
83
}
84
$template->set_var(array( 
85
				'TEXT_HEADER' => $TEXT['TEXT_HEADER'],
86
				'SAVE_TEXT' => $TEXT['SAVE'],
87
				'BACK' => $TEXT['BACK'],
88
			)
89
		);
90

    
91
$template->set_block('main_block', 'list_block', 'list');
92
$row_bg_color = '';
93
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
94
$dirs[] = WB_PATH.MEDIA_DIRECTORY;
95

    
96
$array_lowercase = array_map('strtolower', $dirs);
97
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
98

    
99
foreach($dirs AS $name) {
100
	$relative = str_replace(WB_PATH, '', $name);
101
	$safepath = str_replace(array('/',' '),'_',$relative);
102
	$cur_width = $cur_height = '';
103
	if (isset($pathsettings[$safepath]['width'])) $cur_width = $pathsettings[$safepath]['width'];
104
	if (isset($pathsettings[$safepath]['height'])) $cur_height = $pathsettings[$safepath]['height'];
105
	$cur_width = ($cur_width ? (int)$cur_width : '-');
106
	$cur_height = ($cur_height ? (int)$cur_height : '-');
107

    
108
	if($row_bg_color == 'DEDEDE') $row_bg_color = 'EEEEEE';
109
	else $row_bg_color = 'DEDEDE';
110

    
111
	$template->set_var(array( 
112
					'ADMIN_URL' => ADMIN_URL,
113
					'PATH_NAME' => $relative,
114
					'WIDTH' => $TEXT['WIDTH'],
115
					'HEIGHT' => $TEXT['HEIGHT'],
116
					'FIELD_NAME_W' => $safepath.'-w',
117
					'FIELD_NAME_H' => $safepath.'-h',
118
					'CUR_WIDTH' => $cur_width,
119
					'CUR_HEIGHT' => $cur_height,
120
					'SETTINGS' => $TEXT['SETTINGS'],
121
					'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'],
122
					'ADMIN_ONLY_SELECTED' => $pathsettings['global']['admin_only'],
123
					'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'],
124
					'NO_SHOW_THUMBS_SELECTED' => $pathsettings['global']['show_thumbs'],
125
					'ROW_BG_COLOR' => $row_bg_color,
126
					'FTAN' => $admin->getFTAN()
127
				)
128
		);
129
	$template->parse('list', 'list_block', true);
130
}
131

    
132
$template->parse('main', 'main_block', false);
133
$template->pparse('output', 'page');
(14-14/16)