Revision 1643
Added by darkviper over 13 years ago
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
=============================================================================== |
| 13 | 13 |
|
| 14 |
|
|
| 14 |
22 Mar-2012 Build 1643 Werner v.d.Decken(DarkViper) |
|
| 15 |
+ added backend functions to copy themes and import htt-template files |
|
| 16 |
according to the the new theme fallback functionality |
|
| 15 | 17 |
22 Mar-2012 Build 1642 Dietmar Woellbrink (Luisehahne) |
| 16 | 18 |
! update header info.php wb_themes |
| 17 | 19 |
22 Mar-2012 Build 1641 Dietmar Woellbrink (Luisehahne) |
| branches/2.8.x/wb/admin/templates/details.php | ||
|---|---|---|
| 82 | 82 |
'AUTHOR' => $row['author'], |
| 83 | 83 |
'DESCRIPTION' => $row['description'], |
| 84 | 84 |
'VERSION' => $row['version'], |
| 85 |
'DESIGNED_FOR' => $row['platform'] |
|
| 85 |
'DESIGNED_FOR' => $row['platform'], |
|
| 86 |
'LICENSE' => $row['license'], |
|
| 86 | 87 |
) |
| 87 | 88 |
); |
| 88 | 89 |
|
| ... | ... | |
| 98 | 99 |
'TEXT_VERSION' => $TEXT['VERSION'], |
| 99 | 100 |
'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'], |
| 100 | 101 |
'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'], |
| 101 |
'TEXT_BACK' => $TEXT['BACK'] |
|
| 102 |
'TEXT_BACK' => $TEXT['BACK'], |
|
| 103 |
'TEXT_LICENSE' => '', |
|
| 102 | 104 |
) |
| 103 | 105 |
); |
| 104 |
|
|
| 106 |
$template->set_var('TEXT_FUNCTION', ($row['function'] == 'theme' ? $TEXT['THEME'] : $TEXT['TEMPLATE']));
|
|
| 105 | 107 |
// Parse template object |
| 106 | 108 |
$template->parse('main', 'main_block', false);
|
| 107 | 109 |
$template->pparse('output', 'page');
|
| branches/2.8.x/wb/admin/templates/index.php | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
// Insert values into template list |
| 32 | 32 |
$template->set_block('main_block', 'template_list_block', 'template_list');
|
| 33 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' order by name");
|
|
| 34 |
if($result->numRows() > 0) {
|
|
| 35 |
while($addon = $result->fetchRow()) {
|
|
| 33 |
$sql = 'SELECT `directory`, `name`, `function` FROM `'.TABLE_PREFIX.'addons` ' |
|
| 34 |
. 'WHERE `type`=\'template\' ORDER BY `name`'; |
|
| 35 |
if(($result = $database->query($sql))) {
|
|
| 36 |
while($addon = $result->fetchRow(MYSQL_ASSOC)) {
|
|
| 36 | 37 |
$template->set_var('VALUE', $addon['directory']);
|
| 37 |
$template->set_var('NAME', $addon['name']);
|
|
| 38 |
$template->set_var('NAME', (($addon['function'] == 'theme' ? '[Theme] ' : '').$addon['name']));
|
|
| 38 | 39 |
$template->parse('template_list', 'template_list_block', true);
|
| 39 | 40 |
} |
| 40 | 41 |
} |
| branches/2.8.x/wb/admin/skel/themes/htt/templates_details.htt | ||
|---|---|---|
| 1 | 1 |
<!-- BEGIN main_block --> |
| 2 | 2 |
|
| 3 |
<h2>{HEADING_TEMPLATE_DETAILS}</h2>
|
|
| 3 |
<h2>{HEADING_TEMPLATE_DETAILS} ({TEXT_FUNCTION})</h2>
|
|
| 4 | 4 |
|
| 5 | 5 |
<table summary="" cellpadding="5" cellspacing="0" border="0"> |
| 6 | 6 |
<tr> |
| ... | ... | |
| 23 | 23 |
<td valign="top">{TEXT_DESCRIPTION}:</td>
|
| 24 | 24 |
<td style="text-align: justify;">{DESCRIPTION}</td>
|
| 25 | 25 |
</tr> |
| 26 |
<tr> |
|
| 27 |
<td>{TEXT_LICENSE}:</td>
|
|
| 28 |
<td>{LICENSE}</td>
|
|
| 29 |
</tr> |
|
| 26 | 30 |
</table> |
| 27 | 31 |
|
| 28 | 32 |
<br /> |
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 51 | 51 |
|
| 52 | 52 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 53 | 53 |
if(!defined('VERSION')) define('VERSION', '2.8.3');
|
| 54 |
if(!defined('REVISION')) define('REVISION', '1642');
|
|
| 54 |
if(!defined('REVISION')) define('REVISION', '1643');
|
|
| 55 | 55 |
if(!defined('SP')) define('SP', '');
|
| branches/2.8.x/wb/admin/addons/CopyTheme.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category WBCore |
|
| 5 |
* @package WBCore_addons |
|
| 6 |
* @author Werner v.d.Decken |
|
| 7 |
* @copyright Website Baker Org. e.V. |
|
| 8 |
* @link http://www.websitebaker2.org/ |
|
| 9 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 10 |
* @revision $Revision$ |
|
| 11 |
* @filesource $HeadURL$ |
|
| 12 |
* @lastmodified $Date$ |
|
| 13 |
*/ |
|
| 14 |
|
|
| 15 |
class CopyTheme{
|
|
| 16 |
|
|
| 17 |
// global vars |
|
| 18 |
private $_oDb = null; |
|
| 19 |
private $_aLang = array(); |
|
| 20 |
private $_aGlobals = array(); |
|
| 21 |
// class properties |
|
| 22 |
private $_sThemesBasePath = ''; // (/var/www/httpdocs/wb/templates) |
|
| 23 |
private $_sSourceDir = ''; // (default_theme) |
|
| 24 |
private $_sNewThemeDir = ''; // (MyNewBackendTheme) |
|
| 25 |
private $_sNewThemeName = ''; // ('my new Backend Theme')
|
|
| 26 |
|
|
| 27 |
private $_aErrors = array(); |
|
| 28 |
|
|
| 29 |
/** |
|
| 30 |
* |
|
| 31 |
* @param string $sSourceThemePath (THEME_PATH.'/templates/'.DEFAULT_THEME) |
|
| 32 |
* @param string $sNewThemeName (NewName) |
|
| 33 |
*/ |
|
| 34 |
public function __construct() |
|
| 35 |
{
|
|
| 36 |
// import global vars |
|
| 37 |
$this->_oDb = $GLOBALS['database']; |
|
| 38 |
$this->_aLang = $GLOBALS['MESSAGE']; |
|
| 39 |
// import global Consts |
|
| 40 |
$this->_aGlobals['TablePrefix'] = TABLE_PREFIX; |
|
| 41 |
$this->_aGlobals['Debug'] = (defined('DEBUG') && DEBUG === true);
|
|
| 42 |
$this->_aGlobals['IsLinux'] = ((substr(__FILE__, 0, 1)) == '/'); |
|
| 43 |
$this->_aGlobals['StringDirMode'] = STRING_DIR_MODE; |
|
| 44 |
$this->_aGlobals['StringFileMode'] = STRING_FILE_MODE; |
|
| 45 |
} |
|
| 46 |
/** |
|
| 47 |
* start copy current theme into a new theme |
|
| 48 |
* @param string $sSourceThemePath (/var/www/httpdocs/wb/templates/destination_theme) |
|
| 49 |
* @param string $sNewThemeName (NewName) |
|
| 50 |
* @return bool |
|
| 51 |
*/ |
|
| 52 |
public function execute($sSourceThemePath, $sNewThemeName) |
|
| 53 |
{
|
|
| 54 |
$bRetval = false; |
|
| 55 |
$this->clearError(); |
|
| 56 |
$this->_init($sSourceThemePath, $sNewThemeName); |
|
| 57 |
if(!is_writeable($this->_sThemesBasePath)) {
|
|
| 58 |
$this->_setError( $this->_aLang['THEME_DESTINATION_READONLY'].' >> ' |
|
| 59 |
.$this->_sThemesBasePath ); |
|
| 60 |
return false; |
|
| 61 |
} |
|
| 62 |
if($this->_copyTree()) {
|
|
| 63 |
if($this->_modifyInfoFile()) {
|
|
| 64 |
if($this->_registerNewTheme()) {
|
|
| 65 |
return true; |
|
| 66 |
} |
|
| 67 |
} |
|
| 68 |
} |
|
| 69 |
$dir = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir; |
|
| 70 |
$this->_doRollback($dir); |
|
| 71 |
return false; |
|
| 72 |
} |
|
| 73 |
/** |
|
| 74 |
* initialize the class |
|
| 75 |
* @param string $sSourceThemePath (/var/www/httpdocs/wb/templates/destination_theme) |
|
| 76 |
* @param string $sNewThemeName (NewName) |
|
| 77 |
* @return boolean |
|
| 78 |
*/ |
|
| 79 |
private function _init($sSourceThemePath, $sNewThemeName) |
|
| 80 |
{
|
|
| 81 |
// sanitize arguments and calculate local vars |
|
| 82 |
$this->_sThemesBasePath = str_replace('\\','/', dirname($sSourceThemePath));
|
|
| 83 |
$this->_sSourceDir = basename($sSourceThemePath); |
|
| 84 |
$this->_sNewThemeDir = $this->_SanitizeNewDirName($sNewThemeName); |
|
| 85 |
$this->_sNewThemeName = $this->_SanitizeNewName($sNewThemeName); |
|
| 86 |
} |
|
| 87 |
/** |
|
| 88 |
* sanitize the new name and make it unique |
|
| 89 |
* @param string $sName |
|
| 90 |
* @return string |
|
| 91 |
*/ |
|
| 92 |
private function _SanitizeNewName($sName) |
|
| 93 |
{
|
|
| 94 |
$sName = mysql_real_escape_string($sName); |
|
| 95 |
$iCount = ''; |
|
| 96 |
do {
|
|
| 97 |
$sSearch = $sName.($iCount ? ' '.$iCount : ''); |
|
| 98 |
$sql = 'SELECT COUNT(*) FROM `'.$this->_aGlobals['TablePrefix'].'addons` ' |
|
| 99 |
. 'WHERE LOWER(`name`)=\''.strtolower($sSearch).'\' AND `function`=\'theme\''; |
|
| 100 |
$exists = $this->_oDb->get_one($sql); |
|
| 101 |
$iCount = (int)$iCount + 1; |
|
| 102 |
}while($exists); |
|
| 103 |
return ($sName != $sSearch ? $sSearch : $sName); |
|
| 104 |
} |
|
| 105 |
/** |
|
| 106 |
* generate a unique valid dirname from template name |
|
| 107 |
* @param string $sName |
|
| 108 |
* @return string |
|
| 109 |
*/ |
|
| 110 |
private function _SanitizeNewDirName($sName) |
|
| 111 |
{
|
|
| 112 |
// remove all of the ASCII controllcodes |
|
| 113 |
$sName = preg_replace('/[^0-9a-zA-Z \-_]/', '', strtolower($sName));
|
|
| 114 |
$sName = str_replace(array('-', '_'), array('- ', ' '), $sName);
|
|
| 115 |
$sName = str_replace(' ', '', ucwords($sName));
|
|
| 116 |
$sName = ($sName == '' ? 'MyNewTheme' : $sName); |
|
| 117 |
$iCount = ''; |
|
| 118 |
do {
|
|
| 119 |
$sSearch = $sName.($iCount ? '_'.$iCount : ''); |
|
| 120 |
$sql = 'SELECT COUNT(*) FROM `'.$this->_aGlobals['TablePrefix'].'addons` ' |
|
| 121 |
. 'WHERE `directory`=\''.$sSearch.'\' AND `function`=\'theme\''; |
|
| 122 |
$exists = $this->_oDb->get_one($sql); |
|
| 123 |
$iCount = (int)$iCount + 1; |
|
| 124 |
}while($exists); |
|
| 125 |
return ($sName != $sSearch ? $sSearch : $sName); |
|
| 126 |
} |
|
| 127 |
/** |
|
| 128 |
* copy the complete theme - directory tree with all included files |
|
| 129 |
* @return boolean true if ok |
|
| 130 |
*/ |
|
| 131 |
private function _copyTree() |
|
| 132 |
{
|
|
| 133 |
$bRetval = true; |
|
| 134 |
$sSourceDir = $this->_sThemesBasePath.'/'.$this->_sSourceDir; |
|
| 135 |
// build file list to copy into destination theme |
|
| 136 |
$aFileList = array(); |
|
| 137 |
try {
|
|
| 138 |
$oIterator = new RecursiveDirectoryIterator($sSourceDir); |
|
| 139 |
foreach (new RecursiveIteratorIterator($oIterator) as $cur) {
|
|
| 140 |
if($cur->isDir() || strpos($cur, '.svn') !== false) { continue; }
|
|
| 141 |
$sPattern = '/^'.preg_quote($sSourceDir, '/').'/'; |
|
| 142 |
$sFilename = preg_replace($sPattern, '', $cur->getPathname()); |
|
| 143 |
$sFilePath = preg_replace($sPattern, '', $cur->getPath()); |
|
| 144 |
$aFileList[$sFilename] = $sFilePath; |
|
| 145 |
} |
|
| 146 |
natsort($aFileList); |
|
| 147 |
}catch(Exeption $e) {
|
|
| 148 |
$msg = 'CopyTheme::_copyTree => '.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
| 149 |
$msg .= '<br />'.$e->getMessage(); |
|
| 150 |
$this->_setError($msg); |
|
| 151 |
$bRetval = false; |
|
| 152 |
} |
|
| 153 |
if($bRetval) {
|
|
| 154 |
// create all needed directories |
|
| 155 |
$aDirectories = array_unique(array_values($aFileList)); |
|
| 156 |
$bRetval = $this->_createDirs($aDirectories); |
|
| 157 |
} |
|
| 158 |
if($bRetval) {
|
|
| 159 |
// copy all needed files |
|
| 160 |
$aFiles = array_keys($aFileList); |
|
| 161 |
$bRetval = $this->_copyFiles($aFiles); |
|
| 162 |
} |
|
| 163 |
return $bRetval; |
|
| 164 |
} |
|
| 165 |
/** |
|
| 166 |
* create all the directories from $aNewDirs-list under $sBaseDir |
|
| 167 |
* @param array $aNewDirList ( array('', '/images', '/images/files')
|
|
| 168 |
*/ |
|
| 169 |
private function _createDirs($aNewDirList) |
|
| 170 |
{
|
|
| 171 |
$bRetval = true; |
|
| 172 |
foreach($aNewDirList as $sDir) {
|
|
| 173 |
$sNewDir = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir.$sDir; |
|
| 174 |
if(!file_exists($sNewDir) && mkdir($sNewDir, 0777, true)) {
|
|
| 175 |
if($this->_aGlobals['IsLinux']) {
|
|
| 176 |
if(!chmod($sNewDir, $this->_aGlobals['StringDirMode'])) {
|
|
| 177 |
$sMsg = 'CopyTheme::createDirs::chmod('.$sNewDir.') >> '
|
|
| 178 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
| 179 |
$this->_setError($sMsg); |
|
| 180 |
$bRetval = false; |
|
| 181 |
break; |
|
| 182 |
} |
|
| 183 |
} |
|
| 184 |
}else {
|
|
| 185 |
$sMsg = 'CopyTheme::createDirs::mkdir('.$sNewDir.') >> '
|
|
| 186 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
| 187 |
$this->_setError($sMsg); |
|
| 188 |
$bRetval = false; |
|
| 189 |
break; |
|
| 190 |
} |
|
| 191 |
} |
|
| 192 |
return $bRetval; |
|
| 193 |
} |
|
| 194 |
/** |
|
| 195 |
* copies a list of files from source directory to destination directory |
|
| 196 |
* @param array $aFileList (array('/index.php', '/images/index.php', '/images/files/index.php')
|
|
| 197 |
*/ |
|
| 198 |
private function _copyFiles($aFileList) |
|
| 199 |
{
|
|
| 200 |
$bRetval = true; |
|
| 201 |
$sSourceDir = $this->_sThemesBasePath.'/'.$this->_sSourceDir; |
|
| 202 |
$sDestinationDir = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir; |
|
| 203 |
foreach($aFileList as $sFile) {
|
|
| 204 |
if(copy($sSourceDir.$sFile, $sDestinationDir.$sFile)) {
|
|
| 205 |
if($this->_aGlobals['IsLinux']) {
|
|
| 206 |
if(!chmod($sDestinationDir.$sFile, $this->_aGlobals['StringFileMode'])) {
|
|
| 207 |
$sMsg = 'CopyTheme::copyFiles::chmod('.$sDestinationDir.$sFile.') >> '
|
|
| 208 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
| 209 |
$this->_setError($sMsg); |
|
| 210 |
$bRetval = false; |
|
| 211 |
break; |
|
| 212 |
} |
|
| 213 |
} |
|
| 214 |
}else {
|
|
| 215 |
$sMsg = 'CopyTheme::copyFiles::copy('.$sDestinationDir.$sFile.') >> '
|
|
| 216 |
.$this->_aLang['GENERIC_FAILED_COMPARE']; |
|
| 217 |
$this->_setError($sMsg); |
|
| 218 |
$bRetval = false; |
|
| 219 |
break; |
|
| 220 |
} |
|
| 221 |
} |
|
| 222 |
return $bRetval; |
|
| 223 |
} |
|
| 224 |
/** |
|
| 225 |
* register a available theme in the database (gets values from info.php) |
|
| 226 |
* @return bool TRUE if ok |
|
| 227 |
*/ |
|
| 228 |
private function _registerNewTheme() |
|
| 229 |
{
|
|
| 230 |
$bRetval = true; |
|
| 231 |
$sThemeInfoFile = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir.'/info.php'; |
|
| 232 |
$aVariables = $this->_getThemeInfo($sThemeInfoFile); |
|
| 233 |
$sql = 'INSERT INTO `'.$this->_aGlobals['TablePrefix'].'addons` ' |
|
| 234 |
. 'SET `type`=\'template\', ' |
|
| 235 |
. '`function`=\'theme\', ' |
|
| 236 |
. '`directory`=\''.$aVariables['directory'].'\', ' |
|
| 237 |
. '`name`=\''.$aVariables['name'].'\', ' |
|
| 238 |
. '`description`=\''.mysql_real_escape_string($aVariables['description']).'\', ' |
|
| 239 |
. '`version`=\''.$aVariables['version'].'\', ' |
|
| 240 |
. '`platform`=\''.$aVariables['platform'].'\', ' |
|
| 241 |
. '`author`=\''.mysql_real_escape_string($aVariables['author']).'\', ' |
|
| 242 |
. '`license`=\''.mysql_real_escape_string($aVariables['license']).'\''; |
|
| 243 |
if(!$this->_oDb->query($sql)) {
|
|
| 244 |
$sMsg = 'CopyTheme::registerNewTheme('.$this->_sNewThemeName.') >> '
|
|
| 245 |
.$this->_aLang['GENERIC_NOT_UPGRADED']; |
|
| 246 |
$sMsg .= (($this->_aGlobals['Debug']) ? '<br />'.$this->_oDb->get_error() : ''); |
|
| 247 |
$this->_setError($sMsg); |
|
| 248 |
$bRetval = false; |
|
| 249 |
} |
|
| 250 |
return $bRetval; |
|
| 251 |
} |
|
| 252 |
/** |
|
| 253 |
* modify info-file of copied theme |
|
| 254 |
* @return bool TRUE if ok |
|
| 255 |
*/ |
|
| 256 |
private function _modifyInfoFile() |
|
| 257 |
{
|
|
| 258 |
$bRetval = false; |
|
| 259 |
$sThemeInfoFile = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir.'/info.php'; |
|
| 260 |
$aVariables = $this->_getThemeInfo($sThemeInfoFile); |
|
| 261 |
$aVariables['directory'] = $this->_sNewThemeDir; |
|
| 262 |
$aVariables['name'] = $this->_sNewThemeName; |
|
| 263 |
$aVariables['version'] = '0.0.1'; |
|
| 264 |
$aVariables['description'] = '(copy): '.$aVariables['description']; |
|
| 265 |
if(file_exists($sThemeInfoFile)) {
|
|
| 266 |
$sInfoContent = file_get_contents($sThemeInfoFile); |
|
| 267 |
foreach($aVariables as $key=>$val) {
|
|
| 268 |
$sSearch = '/(\$template_'.$key.'\s*=\s*(["\'])).*?(\2)\s*;/s'; |
|
| 269 |
$sReplace = ($val != '' && is_numeric($val[0])) ? '${1}' : '$1';
|
|
| 270 |
$sReplace .= $val.'$2;'; |
|
| 271 |
$sInfoContent = preg_replace($sSearch, $sReplace, $sInfoContent); |
|
| 272 |
} |
|
| 273 |
// remove trailing "\?\>" to sanitize the php file |
|
| 274 |
$sInfoContent = preg_replace('/\s*?\?>\s*$/', '', $sInfoContent)."\n";
|
|
| 275 |
if(file_put_contents($sThemeInfoFile, $sInfoContent) !== false) {
|
|
| 276 |
return true; |
|
| 277 |
} |
|
| 278 |
} |
|
| 279 |
$this->_setError('CopyTheme::modifyInfoFile('.$this->_sNewThemeDir.'/info.php) >> '
|
|
| 280 |
.$this->_aLang['GENERIC_NOT_UPGRADED']); |
|
| 281 |
return $bRetval; |
|
| 282 |
} |
|
| 283 |
/** |
|
| 284 |
* read old values from old info-file |
|
| 285 |
* @param string $sThemeInfoFile |
|
| 286 |
* @return array |
|
| 287 |
*/ |
|
| 288 |
private function _getThemeInfo($sThemeInfoFile) |
|
| 289 |
{
|
|
| 290 |
if(file_exists($sThemeInfoFile)) {
|
|
| 291 |
include $sThemeInfoFile; |
|
| 292 |
return array( |
|
| 293 |
'directory' => $template_directory?$template_directory:null, |
|
| 294 |
'name' => $template_name?$template_name:null, |
|
| 295 |
'version' => $template_version?$template_version:null, |
|
| 296 |
'description' => $template_description?$template_description:null, |
|
| 297 |
'platform' => $template_platform?$template_platform:null, |
|
| 298 |
'author' => $template_author?$template_author:null, |
|
| 299 |
'license' => $template_license?$template_license:null, |
|
| 300 |
); |
|
| 301 |
} else {
|
|
| 302 |
return array( |
|
| 303 |
'directory' => null, |
|
| 304 |
'name' => null, |
|
| 305 |
'version' => null, |
|
| 306 |
'description' => null, |
|
| 307 |
'platform' => null, |
|
| 308 |
'author' => null, |
|
| 309 |
'license' => null, |
|
| 310 |
); |
|
| 311 |
} |
|
| 312 |
} |
|
| 313 |
/** |
|
| 314 |
* on Error undo all already done copy/create actions |
|
| 315 |
* @param string $dir |
|
| 316 |
*/ |
|
| 317 |
private function _doRollback($dir) |
|
| 318 |
{
|
|
| 319 |
$iFileErrors = 0; |
|
| 320 |
$iDirErrors = 0; |
|
| 321 |
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), |
|
| 322 |
RecursiveIteratorIterator::CHILD_FIRST); |
|
| 323 |
foreach ($iterator as $path) {
|
|
| 324 |
if ($path->isDir()) {
|
|
| 325 |
rmdir($path->__toString()); |
|
| 326 |
} else {
|
|
| 327 |
unlink($path->__toString()); |
|
| 328 |
} |
|
| 329 |
} |
|
| 330 |
unset($path); |
|
| 331 |
unset($iterator); |
|
| 332 |
if(file_exists($dir)) { rmdir($dir); }
|
|
| 333 |
} |
|
| 334 |
/** |
|
| 335 |
* add a new error message to the queue |
|
| 336 |
* @param string $sErrMsg |
|
| 337 |
*/ |
|
| 338 |
private function _setError($sErrMsg) |
|
| 339 |
{
|
|
| 340 |
$this->_aErrors[] = $sErrMsg; |
|
| 341 |
} |
|
| 342 |
/** |
|
| 343 |
* clear the errors queue |
|
| 344 |
*/ |
|
| 345 |
public function clearError() |
|
| 346 |
{
|
|
| 347 |
$this->_aErrors = array(); |
|
| 348 |
} |
|
| 349 |
/** |
|
| 350 |
* true if there is an error otherwise false |
|
| 351 |
* @return bool |
|
| 352 |
*/ |
|
| 353 |
public function isError() |
|
| 354 |
{
|
|
| 355 |
return (sizeof($this->_aErrors) > 0); |
|
| 356 |
} |
|
| 357 |
/** |
|
| 358 |
* gets all error messages as multiline string |
|
| 359 |
* @param bool $nl2br true seperates lines by "<br />" else by "\n" |
|
| 360 |
* @return string |
|
| 361 |
*/ |
|
| 362 |
public function getError($nl2br = true) |
|
| 363 |
{
|
|
| 364 |
$sClue = ($nl2br ? '<br />' : "\n"); |
|
| 365 |
$sErrorMsg = implode($sClue, $this->_aErrors); |
|
| 366 |
return $sErrorMsg; |
|
| 367 |
} |
|
| 368 |
|
|
| 369 |
|
|
| 370 |
} // end class |
|
| 0 | 371 | |
| branches/2.8.x/wb/admin/addons/CopyThemeHtt.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category WBCore |
|
| 5 |
* @package WBCore_addons |
|
| 6 |
* @author Werner v.d.Decken |
|
| 7 |
* @copyright Website Baker Org. e.V. |
|
| 8 |
* @link http://www.websitebaker2.org/ |
|
| 9 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 10 |
* @revision $Revision$ |
|
| 11 |
* @filesource $HeadURL$ |
|
| 12 |
* @lastmodified $Date$ |
|
| 13 |
*/ |
|
| 14 |
|
|
| 15 |
class CopyThemeHtt {
|
|
| 16 |
|
|
| 17 |
private static $_sSkelPath = ''; |
|
| 18 |
private static $_sThemePath = ''; |
|
| 19 |
private static $_sOs = ''; |
|
| 20 |
private static $_sFileMode = ''; |
|
| 21 |
private static $_aLang = ''; |
|
| 22 |
/** |
|
| 23 |
* import all needed global constants and variables |
|
| 24 |
*/ |
|
| 25 |
private static function init() |
|
| 26 |
{
|
|
| 27 |
// self::$_sSkelPath = ADMIN_PATH.'/themes/templates/'; |
|
| 28 |
self::$_sSkelPath = ADMIN_PATH.'/skel/themes/htt/'; |
|
| 29 |
self::$_sThemePath = THEME_PATH.'/templates/'; |
|
| 30 |
self::$_sOs = OPERATING_SYSTEM; |
|
| 31 |
self::$_sFileMode = STRING_FILE_MODE; |
|
| 32 |
self::$_aLang = $GLOBALS['MESSAGE']; |
|
| 33 |
} |
|
| 34 |
/** |
|
| 35 |
* returns the difference between default and current theme |
|
| 36 |
* @param string $sSourceDir |
|
| 37 |
* @param string $sDestinationDir |
|
| 38 |
* @param string $sExtension |
|
| 39 |
* @return array |
|
| 40 |
*/ |
|
| 41 |
public static function getDivList($sSourceDir, $sDestinationDir, $sExtension) |
|
| 42 |
{
|
|
| 43 |
$aDestinationTemplates = self::getFiles($sDestinationDir, $sExtension); |
|
| 44 |
$aDefaultTemplates = self::getFiles($sSourceDir, $sExtension); |
|
| 45 |
$aRetval = array_diff($aDefaultTemplates, $aDestinationTemplates); |
|
| 46 |
return $aRetval; |
|
| 47 |
} |
|
| 48 |
/** |
|
| 49 |
* copy template files from default theme dir into the current theme dir |
|
| 50 |
* @param array $aFileList |
|
| 51 |
* @return array|null |
|
| 52 |
*/ |
|
| 53 |
public static function doImport($aFileList) |
|
| 54 |
{
|
|
| 55 |
self::init(); |
|
| 56 |
$aErrors = array(); |
|
| 57 |
if(is_array($aFileList)) {
|
|
| 58 |
if(isset($aFileList['none'])) { unset($aFileList['none']); }
|
|
| 59 |
if(sizeof($aFileList) > 0 ) {
|
|
| 60 |
foreach($aFileList as $sFile) {
|
|
| 61 |
$sFile = basename($sFile); |
|
| 62 |
if(copy(self::$_sSkelPath.$sFile, self::$_sThemePath.$sFile)) {
|
|
| 63 |
if(self::$_sOs == 'linux') {
|
|
| 64 |
chmod(self::$_sThemePath.$sFile, self::$_sFileMode); |
|
| 65 |
} |
|
| 66 |
}else {
|
|
| 67 |
$aErrors[] = self::$_aLang['UPLOAD_ERR_CANT_WRITE'].' ['.$sFile.']'; |
|
| 68 |
} |
|
| 69 |
} |
|
| 70 |
} |
|
| 71 |
} |
|
| 72 |
if(sizeof($aErrors) > 0) {
|
|
| 73 |
return $aErrors; |
|
| 74 |
}else {
|
|
| 75 |
return null; |
|
| 76 |
} |
|
| 77 |
} |
|
| 78 |
/** |
|
| 79 |
* generate a filelist containing all files with $sExtension from dir $sDirectory |
|
| 80 |
* @param string $sDirectory |
|
| 81 |
* @param string $sExtension |
|
| 82 |
* @return array |
|
| 83 |
*/ |
|
| 84 |
private static function getFiles($sDirectory, $sExtension) |
|
| 85 |
{
|
|
| 86 |
$aRetval = array(); |
|
| 87 |
try {
|
|
| 88 |
$oIterator = new DirectoryIterator($sDirectory); |
|
| 89 |
foreach ($oIterator as $oFileinfo) {
|
|
| 90 |
if ($oFileinfo->isFile() && |
|
| 91 |
(pathinfo($oFileinfo->getFilename(), PATHINFO_EXTENSION) == $sExtension)) |
|
| 92 |
{
|
|
| 93 |
$aRetval[$oFileinfo->getBasename('.'.$sExtension)] = $oFileinfo->getBasename();
|
|
| 94 |
} |
|
| 95 |
} |
|
| 96 |
} catch (Exception $e) {
|
|
| 97 |
return array(); |
|
| 98 |
} |
|
| 99 |
ksort($aRetval); |
|
| 100 |
return $aRetval; |
|
| 101 |
} |
|
| 102 |
} |
|
| 0 | 103 | |
| branches/2.8.x/wb/admin/addons/reload.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 | 2 |
/** |
| 3 | 3 |
* |
| 4 |
* @category admin |
|
| 5 |
* @package addons |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 4 |
* @category WBCore |
|
| 5 |
* @package WBCore_addons |
|
| 6 |
* @author Werner v.d.Decken |
|
| 7 |
* @copyright Website Baker Org. e.V. |
|
| 9 | 8 |
* @link http://www.websitebaker2.org/ |
| 10 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
| 11 |
* @platform WebsiteBaker 2.8.x |
|
| 12 |
* @requirements PHP 5.2.2 and higher |
|
| 13 |
* @version $Id$ |
|
| 10 |
* @revision $Revision$ |
|
| 14 | 11 |
* @filesource $HeadURL$ |
| 15 | 12 |
* @lastmodified $Date$ |
| 16 |
* |
|
| 17 | 13 |
*/ |
| 18 | 14 |
|
| 19 | 15 |
/** |
| 20 |
* check if there is anything to do |
|
| 16 |
* loop through all resource directories of one type and reload the resources |
|
| 17 |
* @param string $sType type of resource ( module / template / language ) |
|
| 18 |
* @return bool |
|
| 21 | 19 |
*/ |
| 22 |
$post_check = array('reload_modules', 'reload_templates', 'reload_languages');
|
|
| 23 |
foreach ($post_check as $index => $key) {
|
|
| 24 |
if (!isset($_POST[$key])) unset($post_check[$index]); |
|
| 25 |
} |
|
| 26 |
if (count($post_check) == 0) die(header('Location: index.php?advanced'));
|
|
| 27 |
|
|
| 20 |
function ReloadAddonLoop($sType) |
|
| 21 |
{
|
|
| 22 |
global $database; |
|
| 23 |
$database->query('DELETE FROM `'.TABLE_PREFIX.'addons` WHERE `type`=\''.$sType.'\'');
|
|
| 24 |
try{
|
|
| 25 |
$oIterator = new DirectoryIterator(WB_PATH.'/'.$sType.'s'); |
|
| 26 |
$_Function = 'load_'.$sType; |
|
| 27 |
foreach ($oIterator as $oFileinfo) {
|
|
| 28 |
if( ( $oFileinfo->isFile() && |
|
| 29 |
$sType == 'language' && |
|
| 30 |
preg_match('/^([A-Z]{2}.php)/', $oFileinfo->getBasename())
|
|
| 31 |
) || |
|
| 32 |
($oFileinfo->isDir() && $sType != 'language') |
|
| 33 |
) |
|
| 34 |
{
|
|
| 35 |
if(substr($oFileinfo->getBasename(), 0,1) != '.') {
|
|
| 36 |
$_Function($oFileinfo->getPathname()); |
|
| 37 |
} |
|
| 38 |
} |
|
| 39 |
} |
|
| 40 |
}catch(Exception $e) {
|
|
| 41 |
return false; |
|
| 42 |
} |
|
| 43 |
return true; |
|
| 44 |
} |
|
| 28 | 45 |
/** |
| 29 | 46 |
* check if user has permissions to access this file |
| 30 | 47 |
*/ |
| 31 |
// include WB configuration file and WB admin class |
|
| 32 |
require_once('../../config.php');
|
|
| 33 |
require_once('../../framework/class.admin.php');
|
|
| 34 |
|
|
| 48 |
// include all needed core files and check permission |
|
| 49 |
require_once('../../config.php');
|
|
| 50 |
require_once('../../framework/class.admin.php');
|
|
| 51 |
$aMsg = array(); |
|
| 52 |
$aErrors = array(); |
|
| 35 | 53 |
// check user permissions for admintools (redirect users with wrong permissions) |
| 36 |
$admin = new admin('Admintools', 'admintools', false, false);
|
|
| 37 |
|
|
| 38 |
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
|
|
| 39 |
|
|
| 40 |
// check if the referer URL if available |
|
| 41 |
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : |
|
| 42 |
(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : ''); |
|
| 43 |
$referer = ''; |
|
| 44 |
// if referer is set, check if script was invoked from "admin/modules/index.php" |
|
| 45 |
$required_url = ADMIN_URL . '/addons/index.php'; |
|
| 46 |
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) |
|
| 47 |
die(header('Location: ../../index.php'));
|
|
| 48 |
|
|
| 49 |
// include WB functions file |
|
| 50 |
require_once(WB_PATH . '/framework/functions.php'); |
|
| 51 |
|
|
| 52 |
// load WB language file |
|
| 53 |
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php'); |
|
| 54 |
|
|
| 55 |
// create Admin object with admin header |
|
| 56 |
$admin = new admin('Addons', '', false, false);
|
|
| 57 |
$js_back = ADMIN_URL . '/addons/index.php?advanced'; |
|
| 58 |
|
|
| 59 |
if (!$admin->checkFTAN()) |
|
| 60 |
{
|
|
| 61 |
$admin->print_header(); |
|
| 62 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back); |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
/** |
|
| 66 |
* Reload all specified Addons |
|
| 67 |
*/ |
|
| 68 |
$msg = array(); |
|
| 69 |
$table = TABLE_PREFIX . 'addons'; |
|
| 70 |
|
|
| 71 |
foreach ($post_check as $key) {
|
|
| 72 |
switch ($key) {
|
|
| 73 |
case 'reload_modules': |
|
| 74 |
if ($handle = opendir(WB_PATH . '/modules')) {
|
|
| 75 |
// delete modules from database |
|
| 76 |
$sql = "DELETE FROM `$table` WHERE `type` = 'module'"; |
|
| 77 |
$database->query($sql); |
|
| 78 |
|
|
| 79 |
// loop over all modules |
|
| 80 |
while(false !== ($file = readdir($handle))) {
|
|
| 81 |
if ($file != '' && substr($file, 0, 1) != '.' && $file != 'admin.php' && $file != 'index.php') {
|
|
| 82 |
load_module(WB_PATH . '/modules/' . $file); |
|
| 83 |
} |
|
| 54 |
$admin = new admin('Admintools', 'admintools', false, false);
|
|
| 55 |
if ($admin->get_permission('admintools'))
|
|
| 56 |
{
|
|
| 57 |
require_once(WB_PATH . '/framework/functions.php'); |
|
| 58 |
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php'); |
|
| 59 |
// recreate Admin object without admin header |
|
| 60 |
$admin = new admin('Addons', '', false, false);
|
|
| 61 |
$js_back = ADMIN_URL . '/addons/index.php?advanced'; |
|
| 62 |
// check transaction |
|
| 63 |
if ($admin->checkFTAN()) |
|
| 64 |
{
|
|
| 65 |
// start the selected action |
|
| 66 |
if(isset($_POST['cmdCopyTheme'])) |
|
| 67 |
{
|
|
| 68 |
$sNewTheme = (isset($_POST['ThNewTheme']) ? $_POST['ThNewTheme'] : ''); |
|
| 69 |
require(dirname(__FILE__).'/CopyTheme.php'); |
|
| 70 |
$ct = new CopyTheme(); |
|
| 71 |
$ct->execute(THEME_PATH, $sNewTheme); |
|
| 72 |
if($ct->isError()) {
|
|
| 73 |
$aErrors[] = $ct->getError(); |
|
| 74 |
}else {
|
|
| 75 |
$aMsg[] = $TEXT['THEME_COPY_CURRENT'].' :: '.$MESSAGE['GENERIC_COMPARE']; |
|
| 84 | 76 |
} |
| 85 |
closedir($handle); |
|
| 86 |
// add success message |
|
| 87 |
$msg[] = $MESSAGE['ADDON']['MODULES_RELOADED']; |
|
| 88 |
|
|
| 89 |
} else {
|
|
| 90 |
// provide error message and stop |
|
| 91 |
$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back); |
|
| 92 |
} |
|
| 93 |
break; |
|
| 94 |
|
|
| 95 |
case 'reload_templates': |
|
| 96 |
if ($handle = opendir(WB_PATH . '/templates')) {
|
|
| 97 |
// delete templates from database |
|
| 98 |
$sql = "DELETE FROM `$table` WHERE `type` = 'template'"; |
|
| 99 |
$database->query($sql); |
|
| 100 |
|
|
| 101 |
// loop over all templates |
|
| 102 |
while(false !== ($file = readdir($handle))) {
|
|
| 103 |
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
|
|
| 104 |
load_template(WB_PATH . '/templates/' . $file); |
|
| 105 |
} |
|
| 77 |
unset($ct); |
|
| 78 |
// --------------------------- |
|
| 79 |
}elseif(isset($_POST['cmdCopyTemplate'])) |
|
| 80 |
{
|
|
| 81 |
$aFileList = (isset($_POST['ThTemplate']) ? $_POST['ThTemplate'] : array()); |
|
| 82 |
require(dirname(__FILE__).'/CopyThemeHtt.php'); |
|
| 83 |
$x = CopyThemeHtt::doImport($aFileList); |
|
| 84 |
if(is_null($x)) {
|
|
| 85 |
$aMsg[] = $TEXT['THEME_IMPORT_HTT'].' :: '.$MESSAGE['GENERIC_COMPARE']; |
|
| 86 |
}else {
|
|
| 87 |
$aErrors = array_merge($aErrors, $x); |
|
| 106 | 88 |
} |
| 107 |
closedir($handle); |
|
| 108 |
// add success message |
|
| 109 |
$msg[] = $MESSAGE['ADDON']['TEMPLATES_RELOADED']; |
|
| 110 |
|
|
| 111 |
} else {
|
|
| 112 |
// provide error message and stop |
|
| 113 |
$admin->print_header(); |
|
| 114 |
$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back); |
|
| 115 |
} |
|
| 116 |
break; |
|
| 117 |
|
|
| 118 |
case 'reload_languages': |
|
| 119 |
if ($handle = opendir(WB_PATH . '/languages/')) {
|
|
| 120 |
// delete languages from database |
|
| 121 |
$sql = "DELETE FROM `$table` WHERE `type` = 'language'"; |
|
| 122 |
$database->query($sql); |
|
| 123 |
|
|
| 124 |
// loop over all languages |
|
| 125 |
while(false !== ($file = readdir($handle))) {
|
|
| 126 |
if ($file != '' && substr($file, 0, 1) != '.' && $file != 'index.php') {
|
|
| 127 |
load_language(WB_PATH . '/languages/' . $file); |
|
| 89 |
// --------------------------- |
|
| 90 |
}elseif(isset($_POST['cmdReload'])) |
|
| 91 |
{
|
|
| 92 |
$aReloadType = (isset($_POST['reload']) && is_array($_POST['reload'])) ? $_POST['reload'] : array(); |
|
| 93 |
foreach($aReloadType as $sType) {
|
|
| 94 |
switch($sType) {
|
|
| 95 |
case 'modules': |
|
| 96 |
// reload all modules |
|
| 97 |
if(ReloadAddonLoop('module')) {
|
|
| 98 |
$aMsg[] = $MESSAGE['ADDON_MODULES_RELOADED']; |
|
| 99 |
}else {
|
|
| 100 |
$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD']; |
|
| 101 |
} |
|
| 102 |
break; |
|
| 103 |
case 'templates': |
|
| 104 |
// reload all templates |
|
| 105 |
if(ReloadAddonLoop('template')) {
|
|
| 106 |
$aMsg[] = $MESSAGE['ADDON_TEMPLATES_RELOADED']; |
|
| 107 |
}else {
|
|
| 108 |
$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD']; |
|
| 109 |
} |
|
| 110 |
break; |
|
| 111 |
case 'languages': |
|
| 112 |
// reload all languages |
|
| 113 |
if(ReloadAddonLoop('language')) {
|
|
| 114 |
$aMsg[] = $MESSAGE['ADDON_LANGUAGES_RELOADED']; |
|
| 115 |
}else {
|
|
| 116 |
$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD']; |
|
| 117 |
} |
|
| 118 |
break; |
|
| 119 |
default: |
|
| 120 |
$aErrors[] = $MESSAGE['GENERIC_NOT_COMPARE'].' ['.$sType.']'; |
|
| 121 |
break; |
|
| 128 | 122 |
} |
| 129 | 123 |
} |
| 130 |
closedir($handle); |
|
| 131 |
// add success message |
|
| 132 |
$msg[] = $MESSAGE['ADDON']['LANGUAGES_RELOADED']; |
|
| 133 |
|
|
| 134 |
} else {
|
|
| 135 |
// provide error message and stop |
|
| 136 |
$admin->print_header(); |
|
| 137 |
$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back); |
|
| 124 |
}else {
|
|
| 125 |
// --------------------------- |
|
| 126 |
$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD']; |
|
| 138 | 127 |
} |
| 139 |
break; |
|
| 128 |
}else { // invalid FTAN
|
|
| 129 |
$aErrors[] = $MESSAGE['GENERIC_SECURITY_ACCESS']; |
|
| 130 |
} |
|
| 131 |
}else { // no permission
|
|
| 132 |
$aErrors[] = $MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']; |
|
| 140 | 133 |
} |
| 141 |
} |
|
| 142 |
|
|
| 134 |
if(sizeof($aErrors) > 0) {
|
|
| 135 |
// output error message |
|
| 136 |
$admin->print_header(); |
|
| 137 |
$admin->print_error(implode('<br />', $aErrors), $js_back);
|
|
| 138 |
}else {
|
|
| 143 | 139 |
// output success message |
| 144 |
$admin->print_header(); |
|
| 145 |
$admin->print_success(implode($msg, '<br />'), $js_back); |
|
| 146 |
$admin->print_footer(); |
|
| 140 |
$admin->print_header(); |
|
| 141 |
$admin->print_success(implode('<br />', $aMsg), $js_back);
|
|
| 142 |
$admin->print_footer(); |
|
| 143 |
} |
|
| branches/2.8.x/wb/admin/addons/index.php | ||
|---|---|---|
| 46 | 46 |
* Obsolete as we are using blocks ... see "parsing the blocks" section |
| 47 | 47 |
*/ |
| 48 | 48 |
$display_none = "style=\"display: none;\""; |
| 49 |
if($admin->get_permission('modules') != true) $template->set_var('DISPLAY_MODULES', $display_none);
|
|
| 50 |
if($admin->get_permission('templates') != true) $template->set_var('DISPLAY_TEMPLATES', $display_none);
|
|
| 51 |
if($admin->get_permission('languages') != true) $template->set_var('DISPLAY_LANGUAGES', $display_none);
|
|
| 52 |
if($admin->get_permission('admintools') != true) $template->set_var('DISPLAY_ADVANCED', $display_none);
|
|
| 49 |
if($admin->get_permission('modules') != true) { $template->set_var('DISPLAY_MODULES', $display_none); }
|
|
| 50 |
if($admin->get_permission('templates') != true) { $template->set_var('DISPLAY_TEMPLATES', $display_none); }
|
|
| 51 |
if($admin->get_permission('languages') != true) { $template->set_var('DISPLAY_LANGUAGES', $display_none); }
|
|
| 52 |
if($admin->get_permission('admintools') != true) { $template->set_var('DISPLAY_ADVANCED', $display_none); }
|
|
| 53 | 53 |
|
| 54 |
if(!isset($_GET['advanced']) || $admin->get_permission('admintools') != true)
|
|
| 54 |
if(!isset($_GET['advanced']) || $admin->get_permission('admintools') != true) {
|
|
| 55 | 55 |
$template->set_var('DISPLAY_RELOAD', $display_none);
|
| 56 |
|
|
| 56 |
} |
|
| 57 | 57 |
/** |
| 58 | 58 |
* Insert section names and descriptions |
| 59 | 59 |
*/ |
| ... | ... | |
| 80 | 80 |
/** |
| 81 | 81 |
* Parsing the blocks ... |
| 82 | 82 |
*/ |
| 83 |
if ( $admin->get_permission('modules') == true) $template->parse('main_block', "modules_block", true);
|
|
| 84 |
if ( $admin->get_permission('templates') == true) $template->parse('main_block', "templates_block", true);
|
|
| 85 |
if ( $admin->get_permission('languages') == true) $template->parse('main_block', "languages_block", true);
|
|
| 86 |
if ( isset($_GET['advanced']) AND $admin->get_permission('admintools') == true) $template->parse('main_block', "reload_block", true);
|
|
| 83 |
if ( $admin->get_permission('modules') == true) { $template->parse('main_block', "modules_block", true); }
|
|
| 84 |
if ( $admin->get_permission('templates') == true) { $template->parse('main_block', "templates_block", true); }
|
|
| 85 |
if ( $admin->get_permission('languages') == true) { $template->parse('main_block', "languages_block", true); }
|
|
| 86 |
// start advanced block |
|
| 87 |
if ( isset($_GET['advanced']) AND $admin->get_permission('admintools') == true) {
|
|
| 88 |
$template->set_var(array( |
|
| 89 |
'TXT_THEME_COPY_CURRENT' => $TEXT['THEME_COPY_CURRENT'], |
|
| 90 |
'TXT_THEME_NEW_NAME' => $TEXT['THEME_NEW_NAME'], |
|
| 91 |
'TXT_THEME_CURRENT' => $TEXT['THEME_CURRENT'], |
|
| 92 |
'TXT_THEME_START_COPY' => $TEXT['THEME_START_COPY'], |
|
| 93 |
'TXT_THEME_IMPORT_HTT' => $TEXT['THEME_IMPORT_HTT'], |
|
| 94 |
'TXT_THEME_SELECT_HTT' => $TEXT['THEME_SELECT_HTT'], |
|
| 95 |
'TXT_THEME_NOMORE_HTT' => $TEXT['THEME_NOMORE_HTT'], |
|
| 96 |
'TXT_THEME_START_IMPORT' => $TEXT['THEME_START_IMPORT'], |
|
| 97 |
'MESSAGE_THEME_COPY_CURRENT' => $MESSAGE['THEME_COPY_CURRENT'], |
|
| 98 |
'MESSAGE_THEME_ALREADY_EXISTS' => $MESSAGE['THEME_ALREADY_EXISTS'], |
|
| 99 |
'MESSAGE_THEME_INVALID_SOURCE_DESTINATION' => $MESSAGE['THEME_INVALID_SOURCE_DESTINATION'], |
|
| 100 |
'MESSAGE_THEME_DESTINATION_READONLY' => $MESSAGE['THEME_DESTINATION_READONLY'], |
|
| 101 |
'MESSAGE_THEME_IMPORT_HTT' => $MESSAGE['THEME_IMPORT_HTT'], |
|
| 102 |
) |
|
| 103 |
); |
|
| 104 |
// start copy current theme |
|
| 105 |
$sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ' |
|
| 106 |
. 'WHERE `directory`=\''.DEFAULT_THEME.'\' AND `function`=\'theme\''; |
|
| 107 |
$tmp = $database->get_one($sql); |
|
| 108 |
$template->set_var('THEME_DEFAULT_NAME', $tmp);
|
|
| 109 |
// end copy current theme |
|
| 110 |
// start template import |
|
| 111 |
include(dirname(__FILE__).'/CopyThemeHtt.php'); |
|
| 112 |
$aTplList = CopyThemeHtt::getDivList(ADMIN_PATH.'/themes/templates', |
|
| 113 |
THEME_PATH.'/templates', 'htt'); |
|
| 114 |
$sOptionList = ''; |
|
| 115 |
if(sizeof($aTplList)) {
|
|
| 116 |
foreach($aTplList as $key=>$val) {
|
|
| 117 |
$sOptionList .= '<option value="'.$val.'">'.$key.'</option>'."\n"; |
|
| 118 |
} |
|
| 119 |
}else {
|
|
| 120 |
$sOptionList = '<option value="none">'.$TEXT['THEME_NOMORE_HTT'].'</option>'."\n"; |
|
| 121 |
} |
|
| 122 |
$template->set_var('THEME_TEMPLATE_LIST', $sOptionList);
|
|
| 123 |
// end template import |
|
| 124 |
$template->parse('main_block', "reload_block", true);
|
|
| 125 |
} |
|
| 126 |
// end advanced block |
|
| 87 | 127 |
|
| 88 | 128 |
/** |
| 89 | 129 |
* Parse template object |
| ... | ... | |
| 95 | 135 |
* Print admin footer |
| 96 | 136 |
*/ |
| 97 | 137 |
$admin->print_footer(); |
| 98 |
|
|
| 99 |
?> |
|
| branches/2.8.x/wb/templates/allcss/index.php | ||
|---|---|---|
| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
| 1 | 2 |
<?php |
| 2 | 3 |
/** |
| 3 | 4 |
* $Id$ |
| ... | ... | |
| 32 | 33 |
|
| 33 | 34 |
// TEMPLATE CODE STARTS BELOW |
| 34 | 35 |
?> |
| 35 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
|
| 36 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
| 37 | 36 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 38 | 37 |
<head> |
| 39 | 38 |
<meta http-equiv="Content-Type" content="text/html; charset=<?php |
| ... | ... | |
| 45 | 44 |
<link rel="stylesheet" type="text/css" href="<?php |
| 46 | 45 |
echo TEMPLATE_DIR; ?>/print.css" media="print" /> |
| 47 | 46 |
<title><?php page_title('', '[WEBSITE_TITLE]'); ?></title>
|
| 48 |
<?php
|
|
| 47 |
<?php |
|
| 49 | 48 |
// automatically include optional WB module files (frontend.css, frontend.js) |
| 50 |
if (function_exists('register_frontend_modfiles')) {
|
|
| 51 |
register_frontend_modfiles('css');
|
|
| 52 |
// register_frontend_modfiles('jquery');
|
|
| 53 |
register_frontend_modfiles('js');
|
|
| 54 |
} ?> |
|
| 49 |
register_frontend_modfiles('css');
|
|
| 50 |
// register_frontend_modfiles('javascript');
|
|
| 51 |
register_frontend_modfiles('js');
|
|
| 52 |
?> |
|
| 55 | 53 |
</head> |
| 56 | 54 |
|
| 57 | 55 |
<body> |
| ... | ... | |
| 142 | 140 |
</div> |
| 143 | 141 |
<?php |
| 144 | 142 |
// automatically include optional WB module file frontend_body.js) |
| 145 |
if (function_exists('register_frontend_modfiles_body')) { register_frontend_modfiles_body(); }
|
|
| 143 |
register_frontend_modfiles_body();
|
|
| 146 | 144 |
?> |
| 147 | 145 |
</body> |
| 148 | 146 |
</html> |
| branches/2.8.x/wb/templates/round/index.php | ||
|---|---|---|
| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
| 1 | 2 |
<?php |
| 2 | 3 |
/** |
| 3 | 4 |
* $Id$ |
| ... | ... | |
| 32 | 33 |
|
| 33 | 34 |
// TEMPLATE CODE STARTS BELOW |
| 34 | 35 |
?> |
| 35 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
|
| 36 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
| 37 | 36 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 38 | 37 |
<head> |
| 39 | 38 |
<meta http-equiv="Content-Type" content="text/html; charset=<?php |
| ... | ... | |
| 45 | 44 |
<link rel="stylesheet" type="text/css" href="<?php |
| 46 | 45 |
echo TEMPLATE_DIR; ?>/print.css" media="print" /> |
| 47 | 46 |
<title><?php page_title('', '[WEBSITE_TITLE]'); ?></title>
|
| 48 |
<?php
|
|
| 47 |
<?php |
|
| 49 | 48 |
// automatically include optional WB module files (frontend.css, frontend.js) |
| 50 |
if (function_exists('register_frontend_modfiles')) {
|
|
| 51 |
register_frontend_modfiles('css');
|
|
| 52 |
// register_frontend_modfiles('jquery');
|
|
| 53 |
register_frontend_modfiles('js');
|
|
| 54 |
} ?> |
|
| 49 |
register_frontend_modfiles('css');
|
|
| 50 |
// register_frontend_modfiles('javascript');
|
|
| 51 |
register_frontend_modfiles('js');
|
|
| 52 |
?> |
|
| 55 | 53 |
</head> |
| 56 | 54 |
|
| 57 | 55 |
<body> |
| ... | ... | |
| 249 | 247 |
</table> |
| 250 | 248 |
<?php |
| 251 | 249 |
// automatically include optional WB module file frontend_body.js) |
| 252 |
if (function_exists('register_frontend_modfiles_body')) { register_frontend_modfiles_body(); }
|
|
| 250 |
register_frontend_modfiles_body();
|
|
| 253 | 251 |
?> |
| 254 | 252 |
</body> |
| 255 | 253 |
</html> |
| branches/2.8.x/wb/templates/simple/index.php | ||
|---|---|---|
| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
| 1 | 2 |
<?php |
| 2 | 3 |
/** |
| 3 | 4 |
* $Id$ |
| ... | ... | |
| 32 | 33 |
|
| 33 | 34 |
// TEMPLATE CODE STARTS BELOW |
| 34 | 35 |
?> |
| 35 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
|
| 36 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
| 37 | 36 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 38 | 37 |
<head> |
| 39 | 38 |
<meta http-equiv="Content-Type" content="text/html; charset=<?php |
| 40 | 39 |
echo defined('DEFAULT_CHARSET') ? DEFAULT_CHARSET : 'utf-8'; ?>" />
|
| 41 | 40 |
<meta name="description" content="<?php page_description(); ?>" /> |
| 42 | 41 |
<meta name="keywords" content="<?php page_keywords(); ?>" /> |
| 43 |
<?php
|
|
| 42 |
<?php |
|
| 44 | 43 |
// automatically include optional WB module files (frontend.css, frontend.js) |
| 45 |
if (function_exists('register_frontend_modfiles')) {
|
|
| 46 |
register_frontend_modfiles('css');
|
|
| 47 |
register_frontend_modfiles('js');
|
|
| 48 |
} ?> |
|
| 44 |
register_frontend_modfiles('css');
|
|
| 45 |
register_frontend_modfiles('js');
|
|
| 46 |
?> |
|
| 49 | 47 |
<link rel="stylesheet" type="text/css" href="<?php |
| 50 | 48 |
echo TEMPLATE_DIR; ?>/template.css" media="screen,projection" /> |
| 51 | 49 |
<link rel="stylesheet" type="text/css" href="<?php |
| ... | ... | |
| 102 | 100 |
</table> |
| 103 | 101 |
<?php |
| 104 | 102 |
// automatically include optional WB module file frontend_body.js) |
| 105 |
if (function_exists('register_frontend_modfiles_body')) { register_frontend_modfiles_body(); }
|
|
| 103 |
register_frontend_modfiles_body();
|
|
| 106 | 104 |
?> |
| 107 | 105 |
</body> |
| 108 | 106 |
</html> |
| branches/2.8.x/wb/templates/wb_theme/info.php | ||
|---|---|---|
| 34 | 34 |
$template_license_terms = '-'; |
| 35 | 35 |
$template_description = 'Default backend theme for Website Baker 2.8.'; |
| 36 | 36 |
|
| 37 |
?> |
|
| 37 |
?> |
|
| 38 |
|
|
Also available in: Unified diff
added backend functions to copy themes and import htt-template files according to the the new theme fallback functionality