Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         templates
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @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: details.php 1529 2011-11-25 05:03:32Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/templates/details.php $
14
 * @lastmodified    $Date: 2011-11-25 06:03:32 +0100 (Fri, 25 Nov 2011) $
15
 *
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
// suppress to print the header, so no new FTAN will be set
23
$admin = new admin('Addons', 'templates_view', false);
24
if( !$admin->checkFTAN() )
25
{
26
	$admin->print_header();
27
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
28
}
29

    
30
// Get template name
31
if(!isset($_POST['file']) OR $_POST['file'] == "") {
32
	header("Location: index.php");
33
	exit(0);
34
} else {
35
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-2
36
}
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
// Setup template object, parse vars to it, then parse it
48
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('templates_details.htt'));
49
// Create new template object
50
$template = new Template($ThemePath);
51
// $template->debug = true;
52
$template->set_file('page', 'templates_details.htt');
53
$template->set_block('page', 'main_block', 'main');
54
$template->set_var('FTAN', $admin->getFTAN());
55

    
56
// Insert values
57
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' AND directory = '$file'");
58
if($result->numRows() > 0) {
59
	$row = $result->fetchRow();
60
}
61

    
62
// check if a template description exists for the displayed backend language
63
$tool_description = false;
64
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/templates/'.$file.'/languages/'.LANGUAGE .'.php')) {
65
	// read contents of the template language file into string
66
	$data = @file_get_contents(WB_PATH .'/templates/' .$file .'/languages/' .LANGUAGE .'.php');
67
	// use regular expressions to fetch the content of the variable from the string
68
	$tool_description = get_variable_content('template_description', $data, false, false);
69
	// replace optional placeholder {WB_URL} with value stored in config.php
70
	if($tool_description !== false && strlen(trim($tool_description)) != 0) {
71
		$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
72
	} else {
73
		$tool_description = false;
74
	}
75
}
76
if($tool_description !== false) {
77
	// Override the template-description with correct desription in users language
78
	$row['description'] = $tool_description;
79
}	
80

    
81
$template->set_var(array(
82
								'NAME' => $row['name'],
83
								'AUTHOR' => $row['author'],
84
								'DESCRIPTION' => $row['description'],
85
								'VERSION' => $row['version'],
86
								'DESIGNED_FOR' => $row['platform']
87
								)
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
								'TEXT_BACK' => $TEXT['BACK']
103
								)
104
						);
105

    
106
// Parse template object
107
$template->parse('main', 'main_block', false);
108
$template->pparse('output', 'page');
109

    
110
// Print admin footer
111
$admin->print_footer();
112

    
113
?>
(1-1/4)