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 1643 darkviper
								'DESIGNED_FOR' => $row['platform'],
86
								'LICENSE' => $row['license'],
87 1392 Luisehahne
								)
88
						);
89
90
// Insert language headings
91
$template->set_var(array(
92
								'HEADING_TEMPLATE_DETAILS' => $HEADING['TEMPLATE_DETAILS']
93
								)
94
						);
95
// Insert language text and messages
96
$template->set_var(array(
97
								'TEXT_NAME' => $TEXT['NAME'],
98
								'TEXT_AUTHOR' => $TEXT['AUTHOR'],
99
								'TEXT_VERSION' => $TEXT['VERSION'],
100
								'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'],
101
								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
102 1643 darkviper
								'TEXT_BACK' => $TEXT['BACK'],
103 1645 Luisehahne
								'TEXT_LICENSE' => $TEXT['LICENSE'],
104 1392 Luisehahne
								)
105
						);
106 1643 darkviper
$template->set_var('TEXT_FUNCTION', ($row['function'] == 'theme' ? $TEXT['THEME'] : $TEXT['TEMPLATE']));
107 1392 Luisehahne
// Parse template object
108
$template->parse('main', 'main_block', false);
109
$template->pparse('output', 'page');
110
111
// Print admin footer
112
$admin->print_footer();
113
114 4 ryan
?>