1 |
1392
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package templates
|
6 |
1529
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
1712
|
Luisehahne
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1392
|
Luisehahne
|
* @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 |
2091
|
darkviper
|
$mLang = Translate::getInstance();
|
21 |
1923
|
darkviper
|
$mLang->enableAddon('admin\addons');
|
22 |
1392
|
Luisehahne
|
require_once(WB_PATH .'/framework/functions.php');
|
23 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
24 |
1457
|
Luisehahne
|
// suppress to print the header, so no new FTAN will be set
|
25 |
|
|
$admin = new admin('Addons', 'templates_view', false);
|
26 |
1392
|
Luisehahne
|
if( !$admin->checkFTAN() )
|
27 |
|
|
{
|
28 |
1467
|
Luisehahne
|
$admin->print_header();
|
29 |
1923
|
darkviper
|
$admin->print_error($mLang->MESSAGE_GENERIC_SECURITY_ACCESS);
|
30 |
1392
|
Luisehahne
|
}
|
31 |
|
|
|
32 |
1712
|
Luisehahne
|
// After check print the header
|
33 |
|
|
$admin->print_header();
|
34 |
1392
|
Luisehahne
|
// Get template name
|
35 |
|
|
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
36 |
1923
|
darkviper
|
$admin->print_error($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS);
|
37 |
1712
|
Luisehahne
|
} 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 |
1923
|
darkviper
|
$admin->print_error($mLang->MESSAGE_GENERIC_NOT_INSTALLED);
|
44 |
1712
|
Luisehahne
|
}
|
45 |
|
|
|
46 |
|
|
// Check if the template exists
|
47 |
|
|
if(!is_readable(WB_PATH.'/templates/'.$file)) {
|
48 |
1923
|
darkviper
|
$admin->print_error($mLang->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES);
|
49 |
1712
|
Luisehahne
|
}
|
50 |
1392
|
Luisehahne
|
// Print admin header
|
51 |
1712
|
Luisehahne
|
//$admin = new admin('Addons', 'templates_view');
|
52 |
1392
|
Luisehahne
|
|
53 |
1529
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
54 |
|
|
// Create new template object
|
55 |
1625
|
Luisehahne
|
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
|
56 |
1529
|
Luisehahne
|
// $template->debug = true;
|
57 |
1392
|
Luisehahne
|
$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 |
1712
|
Luisehahne
|
}
|
85 |
1392
|
Luisehahne
|
|
86 |
|
|
$template->set_var(array(
|
87 |
1750
|
Luisehahne
|
'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 |
1712
|
Luisehahne
|
/*-- 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 |
1392
|
Luisehahne
|
// Parse template object
|
100 |
|
|
$template->parse('main', 'main_block', false);
|
101 |
|
|
$template->pparse('output', 'page');
|
102 |
|
|
// Print admin footer
|
103 |
|
|
$admin->print_footer();
|