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 2098 2014-02-11 01:37:03Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/templates/details.php $
14
 * @lastmodified    $Date: 2014-02-11 02:37:03 +0100 (Tue, 11 Feb 2014) $
15
 *
16
 */
17

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

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

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

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

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

    
62
// Insert values
63
$sql = 'SELECT * FROM `'.WbDatabase::getInstance()->TablePrefix.'addons` '
64
     . 'WHERE `type` = \'template\' AND directory = \''.$file.'\'';
65
$result = WbDatabase::getInstance()->doQuery($sql);
66
if($result->numRows() > 0) {
67
	$row = $result->fetchRow();
68
}
69

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

    
89
$template->set_var(array(
90
      'NAME' => $row['name'],
91
      'AUTHOR' => $row['author'],
92
      'DESCRIPTION' => $row['description'],
93
      'VERSION' => $row['version'],
94
      'DESIGNED_FOR' => $row['platform'],
95
      'LICENSE' => $row['license'],
96
    )
97
);
98

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