Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         templates
6
 * @author          Ryan Djurovich, 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: details.php 1923 2013-06-08 09:58:47Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/templates/details.php $
14
 * @lastmodified    $Date: 2013-06-08 11:58:47 +0200 (Sat, 08 Jun 2013) $
15
 *
16
 */
17

    
18
// Include the config file
19
require('../../config.php');
20
$mLang = Translate::getinstance();
21
$mLang->enableAddon('admin\addons');
22
require_once(WB_PATH .'/framework/functions.php');
23
require_once(WB_PATH.'/framework/class.admin.php');
24
// suppress to print the header, so no new FTAN will be set
25
$admin = new admin('Addons', 'templates_view', false);
26
if( !$admin->checkFTAN() )
27
{
28
	$admin->print_header();
29
	$admin->print_error($mLang->MESSAGE_GENERIC_SECURITY_ACCESS);
30
}
31

    
32
// After check print the header
33
$admin->print_header();
34
// Get template name
35
if(!isset($_POST['file']) OR $_POST['file'] == "") {
36
	$admin->print_error($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS);
37
} else {
38
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-2
39
}
40

    
41
// Check if the template exists
42
if(!is_dir(WB_PATH.'/templates/'.$file)) {
43
	$admin->print_error($mLang->MESSAGE_GENERIC_NOT_INSTALLED);
44
}
45

    
46
// Check if the template exists
47
if(!is_readable(WB_PATH.'/templates/'.$file)) {
48
	$admin->print_error($mLang->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES);
49
}
50
// Print admin header
51
//$admin = new admin('Addons', 'templates_view');
52

    
53
// Setup template object, parse vars to it, then parse it
54
// Create new template object
55
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
56
// $template->debug = true;
57
$template->set_file('page', 'templates_details.htt');
58
$template->set_block('page', 'main_block', 'main');
59
$template->set_var('FTAN', $admin->getFTAN());
60

    
61
// Insert values
62
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' AND directory = '$file'");
63
if($result->numRows() > 0) {
64
	$row = $result->fetchRow();
65
}
66

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

    
86
$template->set_var(array(
87
      'NAME' => $row['name'],
88
      'AUTHOR' => $row['author'],
89
      'DESCRIPTION' => $row['description'],
90
      'VERSION' => $row['version'],
91
      'DESIGNED_FOR' => $row['platform'],
92
      'LICENSE' => $row['license'],
93
    )
94
);
95
/*-- insert all needed vars from language files ----------------------------------------*/
96
$template->set_var($mLang->getLangArray());
97

    
98
$template->set_var('TEXT_FUNCTION', ($row['function'] == 'theme' ? $mLang->TEXT_THEME : $mLang->TEXT_TEMPLATE));
99
// Parse template object
100
$template->parse('main', 'main_block', false);
101
$template->pparse('output', 'page');
102
// Print admin footer
103
$admin->print_footer();
(1-1/4)