Project

General

Profile

1 1392 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         templates
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1392 Luisehahne
 * @copyright       2009-2011, Website Baker 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$
13 1457 Luisehahne
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15 1392 Luisehahne
 *
16
 */
17
18
// Include the config file
19
require('../../config.php');
20
require_once(WB_PATH .'/framework/functions.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22 1457 Luisehahne
// suppress to print the header, so no new FTAN will be set
23
$admin = new admin('Addons', 'templates_view', false);
24 1392 Luisehahne
if( !$admin->checkFTAN() )
25
{
26 1467 Luisehahne
	$admin->print_header();
27 1425 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
28 1392 Luisehahne
}
29
30
// Get template name
31
if(!isset($_POST['file']) OR $_POST['file'] == "") {
32
	header("Location: index.php");
33
	exit(0);
34
} else {
35 1494 Luisehahne
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-2
36 1392 Luisehahne
}
37
38
// Check if the template exists
39
if(!file_exists(WB_PATH.'/templates/'.$file)) {
40
	header("Location: index.php");
41
	exit(0);
42
}
43
44
// Print admin header
45
$admin = new admin('Addons', 'templates_view');
46
47 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
48
// Create new template object
49 1625 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
50 1529 Luisehahne
// $template->debug = true;
51 1392 Luisehahne
$template->set_file('page', 'templates_details.htt');
52
$template->set_block('page', 'main_block', 'main');
53
$template->set_var('FTAN', $admin->getFTAN());
54
55
// Insert values
56
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' AND directory = '$file'");
57
if($result->numRows() > 0) {
58
	$row = $result->fetchRow();
59
}
60
61
// check if a template description exists for the displayed backend language
62
$tool_description = false;
63
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/templates/'.$file.'/languages/'.LANGUAGE .'.php')) {
64
	// read contents of the template language file into string
65
	$data = @file_get_contents(WB_PATH .'/templates/' .$file .'/languages/' .LANGUAGE .'.php');
66
	// use regular expressions to fetch the content of the variable from the string
67
	$tool_description = get_variable_content('template_description', $data, false, false);
68
	// replace optional placeholder {WB_URL} with value stored in config.php
69
	if($tool_description !== false && strlen(trim($tool_description)) != 0) {
70
		$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
71
	} else {
72
		$tool_description = false;
73
	}
74
}
75
if($tool_description !== false) {
76
	// Override the template-description with correct desription in users language
77
	$row['description'] = $tool_description;
78
}
79
80
$template->set_var(array(
81
								'NAME' => $row['name'],
82
								'AUTHOR' => $row['author'],
83
								'DESCRIPTION' => $row['description'],
84
								'VERSION' => $row['version'],
85
								'DESIGNED_FOR' => $row['platform']
86
								)
87
						);
88
89
// Insert language headings
90
$template->set_var(array(
91
								'HEADING_TEMPLATE_DETAILS' => $HEADING['TEMPLATE_DETAILS']
92
								)
93
						);
94
// Insert language text and messages
95
$template->set_var(array(
96
								'TEXT_NAME' => $TEXT['NAME'],
97
								'TEXT_AUTHOR' => $TEXT['AUTHOR'],
98
								'TEXT_VERSION' => $TEXT['VERSION'],
99
								'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'],
100
								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
101
								'TEXT_BACK' => $TEXT['BACK']
102
								)
103
						);
104
105
// Parse template object
106
$template->parse('main', 'main_block', false);
107
$template->pparse('output', 'page');
108
109
// Print admin footer
110
$admin->print_footer();
111
112 4 ryan
?>