Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/themes_helper.php
Context not available. | |||||
} | } | ||||
$this->themeFiles = Array (); | $this->themeFiles = Array (); | ||||
$theme_path = $this->themesFolder . '/' . $theme_name; | |||||
if ($theme_id) { | if ($theme_id) { | ||||
if (!$theme_enabled) { | if (!$theme_enabled) { | ||||
// don't process existing theme files, that are disabled | // don't process existing theme files, that are disabled | ||||
Context not available. | |||||
} | } | ||||
else { | else { | ||||
// theme was not found in db, but found on hdd -> create new | // theme was not found in db, but found on hdd -> create new | ||||
$config = $this->getConfiguration($theme_path); | |||||
$theme_info = Array ( | $theme_info = Array ( | ||||
'Name' => $theme_name, | 'Name' => $theme_name, | ||||
'Enabled' => 0, | 'Enabled' => 0, | ||||
Context not available. | |||||
'PrimaryTheme' => 0, | 'PrimaryTheme' => 0, | ||||
'CacheTimeout' => 3600, // not in use right now | 'CacheTimeout' => 3600, // not in use right now | ||||
'StylesheetId' => 0, // not in use right now | 'StylesheetId' => 0, // not in use right now | ||||
'LanguagePackInstalled' => 0 | 'LanguagePackInstalled' => 0, | ||||
'StylesheetFile' => isset($config['stylesheet_file']) ? $config['stylesheet_file'] : '', | |||||
); | ); | ||||
$this->Conn->doInsert($theme_info, $table_name); | $this->Conn->doInsert($theme_info, $table_name); | ||||
Context not available. | |||||
} | } | ||||
$this->_themeNames[$theme_id] = $theme_name; | $this->_themeNames[$theme_id] = $theme_name; | ||||
$theme_path = $this->themesFolder.'/'.$theme_name; | |||||
$this->FindThemeFiles('', $theme_path, $theme_id); // search from base theme directory | $this->FindThemeFiles('', $theme_path, $theme_id); // search from base theme directory | ||||
// delete file records from db, that were not found on hdd | // delete file records from db, that were not found on hdd | ||||
Context not available. | |||||
} | } | ||||
return $template_aliases; | return $template_aliases; | ||||
} | |||||
/** | |||||
* Returns theme configuration. | |||||
* | |||||
* @param string $theme_path Absolute path to theme. | |||||
* | |||||
* @return array | |||||
*/ | |||||
protected function getConfiguration($theme_path) | |||||
{ | |||||
$xml_file = $theme_path . '/_install/theme.xml'; | |||||
if ( !file_exists($xml_file) ) { | |||||
return array(); | |||||
} | |||||
$theme = simplexml_load_file($xml_file); | |||||
if ( $theme === false ) { | |||||
// broken xml OR no aliases defined | |||||
return array(); | |||||
} | |||||
$ret = array(); | |||||
foreach ( $theme->attributes() as $name => $value ) { | |||||
$ret[(string)$name] = (string)$value; | |||||
} | |||||
return $ret; | |||||
} | } | ||||
/** | /** | ||||
Context not available. | |||||
return $this->Conn->GetOne($sql); | return $this->Conn->GetOne($sql); | ||||
} | } | ||||
} | } | ||||
No newline at end of file | |||||
Context not available. |