2015-08-02 04:47:45 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Variables
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
function buildThemes()
|
|
|
|
{
|
|
|
|
global $Site;
|
|
|
|
|
|
|
|
$themes = array();
|
|
|
|
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
|
|
|
|
|
|
|
|
foreach($themesPaths as $themePath)
|
|
|
|
{
|
|
|
|
// 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';
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Sanitize::pathFile($languageFilename) )
|
|
|
|
{
|
|
|
|
$database = file_get_contents($languageFilename);
|
|
|
|
$database = json_decode($database, true);
|
|
|
|
$database = $database['theme-data'];
|
|
|
|
|
|
|
|
$database['dirname'] = basename($themePath);
|
2015-08-02 04:47:45 +02:00
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
// --- Metadata ---
|
|
|
|
$filenameMetadata = $themePath.DS.'metadata.json';
|
2015-08-02 04:47:45 +02:00
|
|
|
|
2016-01-16 15:01:29 +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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $themes;
|
2015-11-29 00:21:04 +01:00
|
|
|
}
|
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
// ============================================================================
|
|
|
|
// Main
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// Load the language file
|
|
|
|
$languageFilename = PATH_THEME.DS.'languages'.DS.$Site->locale().'.json';
|
|
|
|
if( !Sanitize::pathFile($languageFilename) ) {
|
|
|
|
$languageFilename = PATH_THEME.DS.'languages'.DS.'en_US.json';
|
2015-08-02 04:47:45 +02:00
|
|
|
}
|
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
if( Sanitize::pathFile($languageFilename) )
|
2015-08-02 04:47:45 +02:00
|
|
|
{
|
2016-01-16 15:01:29 +01:00
|
|
|
$database = file_get_contents($languageFilename);
|
|
|
|
$database = json_decode($database, true);
|
2015-08-02 04:47:45 +02:00
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
// Remote the name and description.
|
|
|
|
unset($database['theme-data']);
|
2015-08-02 04:47:45 +02:00
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
// Load words from the theme language
|
|
|
|
if(!empty($database)) {
|
|
|
|
$Language->add($database);
|
|
|
|
}
|
2015-11-28 15:47:03 +01:00
|
|
|
}
|