bludit/kernel/admin/controllers/themes.php

58 lines
1.8 KiB
PHP
Raw Normal View History

2015-08-02 04:47:45 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard');
}
2015-08-03 02:49:12 +02:00
// ============================================================================
// Main after POST
// ============================================================================
2015-08-02 04:47:45 +02:00
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
2015-08-03 02:49:12 +02:00
// Main after POST
2015-08-02 04:47:45 +02:00
// ============================================================================
2015-08-02 06:40:24 +02:00
2015-08-03 00:05:20 +02:00
$themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
2015-08-02 06:40:24 +02:00
2015-08-03 00:05:20 +02:00
foreach($themesPaths as $themePath)
{
2016-01-14 05:42:18 +01:00
// Check if the theme is translated.
$languageFilename = $themePath.DS.'languages'.DS.$Site->locale().'.json';
if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = $themePath.DS.'languages'.DS.'en_US.json';
}
2015-08-03 00:05:20 +02:00
2016-01-14 05:42:18 +01:00
if( Sanitize::pathFile($languageFilename) )
2015-08-03 00:05:20 +02:00
{
2016-01-14 05:42:18 +01:00
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
$database = $database['theme-data'];
$database['dirname'] = basename($themePath);
2015-10-07 02:37:32 +02:00
2016-01-14 05:42:18 +01:00
// --- Metadata ---
$filenameMetadata = $themePath.DS.'metadata.json';
2015-08-03 00:05:20 +02:00
2016-01-14 05:42:18 +01:00
if( Sanitize::pathFile($filenameMetadata) )
{
$metadataString = file_get_contents($filenameMetadata);
$metadata = json_decode($metadataString, true);
$database = $database + $metadata;
// Theme data
array_push($themes, $database);
}
2015-08-03 00:05:20 +02:00
}
}