Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         media
6
 * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: setparameter.php 2098 2014-02-11 01:37:03Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/media/setparameter.php $
14
 * @lastmodified    $Date: 2014-02-11 02:37:03 +0100 (Tue, 11 Feb 2014) $
15
 *
16
 */
17

    
18
if(!defined('WB_URL'))
19
{
20
    $config_file = realpath('../../config.php');
21
    if(file_exists($config_file) && !defined('WB_URL'))
22
    {
23
    	require($config_file);
24
    }
25
}
26
//if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
27
$oTrans = Translate::getInstance();
28
$oTrans->enableAddon('admin\\access');
29

    
30
$admin = new admin('Media', 'media', false);
31
// Include the WB functions file
32
if(!function_exists('directory_list')) { require(WB_PATH.'/framework/functions.php'); }
33

    
34
//// check if theme language file exists for the language set by the user (e.g. DE, EN)
35
//if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
36
//	// no theme language file exists for the language set by the user, include default theme language file EN.php
37
//	require_once(THEME_PATH .'/languages/EN.php');
38
//} else {
39
//	// a theme language file exists for the language defined by the user, load it
40
//	require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
41
//}
42
// Get the current homedir
43
$currentHome = WB_PATH.MEDIA_DIRECTORY.$admin->get_home_folder();
44
$currentHome = str_replace(WB_PATH, '', $currentHome);
45
$currentHome = str_replace(array('/',' '),'_',$currentHome);
46

    
47
//Save post vars to the parameters file
48
if ( !is_null($admin->get_post_escaped("save"))) {
49
/*
50
	if (!$admin->checkFTAN())
51
	{
52
		$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'],'browse.php',false);
53
	}
54
*/
55

    
56
	$pathsettings = array();
57
	if(DEFAULT_THEME != '') {
58
		//Check for existing settings entry, if not existing, create a record first!
59
		if (!$database->query ( "SELECT * FROM ".TABLE_PREFIX."settings where `name`='mediasettings'" )) {
60
			$database->query ( "INSERT INTO ".TABLE_PREFIX."settings (`name`,`value`) VALUES ('mediasettings','')" );
61
		}
62
	} else {
63
		$pathsettings = array();
64
	}
65

    
66
	$pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!='' ? 'checked="checked"' : '');
67
	$pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!='' ? 'checked="checked"' : '');
68

    
69
	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
70

    
71
	$dirs[] = WB_PATH.MEDIA_DIRECTORY;
72
	foreach($dirs AS $name) {
73
		$r = str_replace(WB_PATH, '', $name);
74
		$r = str_replace(array('/',' '),'_',$r);
75
		$w = (int)$admin->get_post_escaped($r.'-w');
76
		$h = (int)$admin->get_post_escaped($r.'-h');
77
		$pathsettings[$r]['width']=$w;
78
		$pathsettings[$r]['height']=$h;
79
	}
80
//	$pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!='' ? 'checked="checked"' : '');
81
//	$pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!='' ? 'checked="checked"' : '');
82
	$fieldSerialized = serialize($pathsettings);
83
	$database->query ( "UPDATE ".TABLE_PREFIX."settings SET `value` = '$fieldSerialized' WHERE `name`='mediasettings'" );
84
	header ("Location: browse.php");
85
}
86

    
87
include ('parameters.php');
88
if ($_SESSION['GROUP_ID'] != 1 && (isset($pathsettings['global']['admin_only']) && $pathsettings['global']['admin_only']) ) {
89
	echo "Sorry, settings not available";
90
	exit();
91
}
92

    
93
// Read data to display
94
$caller = "setparameter";
95

    
96
// Setup template object, parse vars to it, then parse it
97
// Create new template object
98
$template = new Template(dirname($admin->correct_theme_source('setparameter.htt')));
99
$template->set_file('page', 'setparameter.htt');
100
$template->set_block('page', 'main_block', 'main');
101
$template->set_var($oTrans->getLangArray());
102
if ($_SESSION['GROUP_ID'] != 1) {
103
	$template->set_var('DISPLAY_ADMIN', 'hide');
104
}
105
$template->set_var(array(
106
        'TEXT_HEADER' => $oTrans->TEXT_TEXT_HEADER,
107
        'SAVE_TEXT' => $oTrans->TEXT_SAVE,
108
        'BACK' => $oTrans->TEXT_BACK,
109
    )
110
);
111

    
112
$template->set_block('main_block', 'list_block', 'list');
113
$row_bg_color = '';
114
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
115

    
116
$dirs[] = WB_PATH.MEDIA_DIRECTORY;
117

    
118
$array_lowercase = array_map('strtolower', $dirs);
119
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
120

    
121
foreach($dirs AS $name) {
122
	$relative = str_replace(WB_PATH, '', $name);
123
	$safepath = str_replace(array('/',' '),'_',$relative);
124
	$cur_width = $cur_height = '';
125
	if (isset($pathsettings[$safepath]['width'])){ $cur_width = $pathsettings[$safepath]['width'];}
126
	if (isset($pathsettings[$safepath]['height'])){ $cur_height = $pathsettings[$safepath]['height'];}
127
	$cur_width = ($cur_width ? (int)$cur_width : '');
128
	$cur_height = ($cur_height ? (int)$cur_height : '');
129
// check for user homefolder
130
    $bPathCanEdit = (preg_match('/'.$currentHome.'/i', $safepath)) ? true : false;
131

    
132
//	if($row_bg_color == 'DEDEDE') $row_bg_color = 'EEEEEE';
133
//	else $row_bg_color = 'DEDEDE';
134
    $row_bg_color = ($row_bg_color == '#dedede') ? '#fff' : '#dedede';
135

    
136
	$template->set_var(array(
137
            'ADMIN_URL' => ADMIN_URL,
138
            'THEME_URL' => THEME_URL,
139
            'PATH_NAME' => $relative,
140
            'WIDTH' => $oTrans->TEXT_WIDTH,
141
            'HEIGHT' => $oTrans->TEXT_HEIGHT,
142
            'FIELD_NAME_W' => $safepath.'-w',
143
            'FIELD_NAME_H' => $safepath.'-h',
144
            'CAN_EDIT_CLASS' => ($bPathCanEdit==false) ? '' : 'bold',
145
            'SHOW_EDIT_CLASS' => ($bPathCanEdit==false) ? 'hide' : '',
146
            'READ_ONLY_DIR' => ($bPathCanEdit==false) ? ' readonly="readonly"' : '',
147
            'CUR_HEIGHT' => $cur_height,
148
            'CUR_WIDTH' => $cur_width,
149
            'SETTINGS' => $oTrans->TEXT_SETTINGS,
150
            'ADMIN_ONLY' => $oTrans->TEXT_ADMIN_ONLY,
151
            'ADMIN_ONLY_SELECTED' => isset($pathsettings['global']['admin_only']) ? $pathsettings['global']['admin_only']:'',
152
            'NO_SHOW_THUMBS' => $oTrans->TEXT_NO_SHOW_THUMBS,
153
            'NO_SHOW_THUMBS_SELECTED' => isset($pathsettings['global']['show_thumbs']) ? $pathsettings['global']['show_thumbs']:'',
154
            'ROW_BG_COLOR' => $row_bg_color,
155
            'FTAN' => $admin->getFTAN()
156
        )
157
    );
158
	$template->parse('list', 'list_block', true);
159
}
160

    
161
$template->parse('main', 'main_block', false);
162
$template->pparse('output', 'page');
(12-12/14)