| 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 |
2098
|
darkviper
|
$oTrans = Translate::getInstance();
|
| 21 |
|
|
$oTrans->enableAddon('admin\\addons');
|
| 22 |
1392
|
Luisehahne
|
require_once(WB_PATH .'/framework/functions.php');
|
| 23 |
1457
|
Luisehahne
|
// suppress to print the header, so no new FTAN will be set
|
| 24 |
|
|
$admin = new admin('Addons', 'templates_view', false);
|
| 25 |
1392
|
Luisehahne
|
if( !$admin->checkFTAN() )
|
| 26 |
|
|
{
|
| 27 |
1467
|
Luisehahne
|
$admin->print_header();
|
| 28 |
2098
|
darkviper
|
$admin->print_error($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS);
|
| 29 |
1392
|
Luisehahne
|
}
|
| 30 |
|
|
|
| 31 |
1712
|
Luisehahne
|
// After check print the header
|
| 32 |
|
|
$admin->print_header();
|
| 33 |
1392
|
Luisehahne
|
// Get template name
|
| 34 |
|
|
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
| 35 |
2098
|
darkviper
|
$admin->print_error($oTrans->MESSAGE_GENERIC_FORGOT_OPTIONS);
|
| 36 |
1712
|
Luisehahne
|
} 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 |
2098
|
darkviper
|
$admin->print_error($oTrans->MESSAGE_GENERIC_NOT_INSTALLED);
|
| 43 |
1712
|
Luisehahne
|
}
|
| 44 |
|
|
|
| 45 |
|
|
// Check if the template exists
|
| 46 |
|
|
if(!is_readable(WB_PATH.'/templates/'.$file)) {
|
| 47 |
2098
|
darkviper
|
$admin->print_error($oTrans->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES);
|
| 48 |
1712
|
Luisehahne
|
}
|
| 49 |
1392
|
Luisehahne
|
// Print admin header
|
| 50 |
1712
|
Luisehahne
|
//$admin = new admin('Addons', 'templates_view');
|
| 51 |
1392
|
Luisehahne
|
|
| 52 |
1529
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
| 53 |
|
|
// Create new template object
|
| 54 |
1625
|
Luisehahne
|
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
|
| 55 |
1529
|
Luisehahne
|
// $template->debug = true;
|
| 56 |
1392
|
Luisehahne
|
$template->set_file('page', 'templates_details.htt');
|
| 57 |
|
|
$template->set_block('page', 'main_block', 'main');
|
| 58 |
2098
|
darkviper
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
| 59 |
|
|
$template->set_var($oTrans->getLangArray());
|
| 60 |
1392
|
Luisehahne
|
$template->set_var('FTAN', $admin->getFTAN());
|
| 61 |
|
|
|
| 62 |
|
|
// Insert values
|
| 63 |
2098
|
darkviper
|
$sql = 'SELECT * FROM `'.WbDatabase::getInstance()->TablePrefix.'addons` '
|
| 64 |
|
|
. 'WHERE `type` = \'template\' AND directory = \''.$file.'\'';
|
| 65 |
|
|
$result = WbDatabase::getInstance()->doQuery($sql);
|
| 66 |
1392
|
Luisehahne
|
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 |
1712
|
Luisehahne
|
}
|
| 88 |
1392
|
Luisehahne
|
|
| 89 |
|
|
$template->set_var(array(
|
| 90 |
1750
|
Luisehahne
|
'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 |
1712
|
Luisehahne
|
|
| 99 |
2098
|
darkviper
|
$template->set_var('TEXT_FUNCTION', ($row['function'] == 'theme' ? $oTrans->TEXT_THEME : $oTrans->TEXT_TEMPLATE));
|
| 100 |
1392
|
Luisehahne
|
// Parse template object
|
| 101 |
|
|
$template->parse('main', 'main_block', false);
|
| 102 |
|
|
$template->pparse('output', 'page');
|
| 103 |
|
|
// Print admin footer
|
| 104 |
|
|
$admin->print_footer();
|