Initial commit: Backup der Webseiten
- zoesch.de - blitzkiste.net - gruene-hassberge (norbert.zoesch.de) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
169
zoesch.de/galerie/themes/bootstrapdefault/include/config.php
Normal file
169
zoesch.de/galerie/themes/bootstrapdefault/include/config.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
namespace BootstrapDefault;
|
||||
|
||||
class Config {
|
||||
|
||||
const CONF_PARAM = 'bootstrapdefault';
|
||||
const CONF_VERSION = 5;
|
||||
|
||||
const TYPE_BOOL = 'bool';
|
||||
const TYPE_STRING = 'string';
|
||||
const TYPE_FILE = 'file';
|
||||
|
||||
const KEY_VERSION = 'conf_version';
|
||||
|
||||
const KEY_BOOTSTRAP_THEME = 'bootstrap_theme';
|
||||
|
||||
const KEY_PICTURE_PAGE = 'picture_page';
|
||||
|
||||
const KEY_SOCIAL_ENABLED = 'social_enabled';
|
||||
const KEY_SOCIAL_TWITTER = 'social_twitter';
|
||||
const KEY_SOCIAL_FACEBOOK = 'social_facebook';
|
||||
const KEY_SOCIAL_GOOGLE_PLUS = 'social_google_plus';
|
||||
|
||||
const KEY_COMMENTS_TYPE = 'comments_type';
|
||||
const KEY_COMMENTS_DISQUS_SHORTNAME = 'comments_disqus_shortname';
|
||||
|
||||
const KEY_TAG_CLOUD_TYPE = 'tag_cloud_type';
|
||||
|
||||
const KEY_CUSTOM_CSS = 'custom_css';
|
||||
|
||||
private $defaults = array(
|
||||
self::KEY_BOOTSTRAP_THEME => 'default',
|
||||
self::KEY_PICTURE_PAGE => 'normal',
|
||||
self::KEY_SOCIAL_ENABLED => true,
|
||||
self::KEY_SOCIAL_TWITTER => true,
|
||||
self::KEY_SOCIAL_FACEBOOK => true,
|
||||
self::KEY_SOCIAL_GOOGLE_PLUS => true,
|
||||
self::KEY_COMMENTS_TYPE => 'piwigo',
|
||||
self::KEY_COMMENTS_DISQUS_SHORTNAME => null,
|
||||
self::KEY_TAG_CLOUD_TYPE => 'basic',
|
||||
self::KEY_CUSTOM_CSS => null,
|
||||
);
|
||||
|
||||
private $types = array(
|
||||
self::KEY_BOOTSTRAP_THEME => self::TYPE_STRING,
|
||||
self::KEY_PICTURE_PAGE => self::TYPE_STRING,
|
||||
self::KEY_SOCIAL_ENABLED => self::TYPE_BOOL,
|
||||
self::KEY_SOCIAL_TWITTER => self::TYPE_BOOL,
|
||||
self::KEY_SOCIAL_FACEBOOK => self::TYPE_BOOL,
|
||||
self::KEY_SOCIAL_GOOGLE_PLUS => self::TYPE_BOOL,
|
||||
self::KEY_COMMENTS_TYPE => self::TYPE_STRING,
|
||||
self::KEY_COMMENTS_DISQUS_SHORTNAME => self::TYPE_STRING,
|
||||
self::KEY_TAG_CLOUD_TYPE => self::TYPE_STRING,
|
||||
self::KEY_CUSTOM_CSS => self::TYPE_FILE,
|
||||
);
|
||||
|
||||
private $files = array();
|
||||
|
||||
private $config = array();
|
||||
|
||||
public function __construct() {
|
||||
global $conf;
|
||||
|
||||
// Initialise the files array
|
||||
$this->initFiles();
|
||||
|
||||
// Create initial config if necessary
|
||||
if (!isset($conf[self::CONF_PARAM])) {
|
||||
$this->createDefaultConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
// Load and JSON decode the config
|
||||
$loaded = json_decode($conf[self::CONF_PARAM], true);
|
||||
|
||||
// Check for current version
|
||||
if (isset($loaded[self::KEY_VERSION]) && $loaded[self::KEY_VERSION] == self::CONF_VERSION) {
|
||||
$this->config = $loaded;
|
||||
return;
|
||||
}
|
||||
|
||||
// Invalid or old config, recreate
|
||||
$this->createDefaultConfig();
|
||||
if (is_array($loaded)) {
|
||||
$this->populateConfig($loaded);
|
||||
}
|
||||
$this->save();
|
||||
}
|
||||
|
||||
private function initFiles() {
|
||||
$this->files[self::KEY_CUSTOM_CSS] = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'bootstrapdefault/custom.css';
|
||||
}
|
||||
|
||||
public function __set($key, $value) {
|
||||
if (array_key_exists($key, $this->defaults)) {
|
||||
switch ($this->types[$key]) {
|
||||
case self::TYPE_STRING:
|
||||
$this->config[$key] = !empty($value) ? $value : null;
|
||||
break;
|
||||
case self::TYPE_BOOL:
|
||||
$this->config[$key] = $value ? true : false;
|
||||
break;
|
||||
case self::TYPE_FILE:
|
||||
$this->saveFile($key, $value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($key) {
|
||||
if (array_key_exists($key, $this->defaults)) {
|
||||
switch ($this->types[$key]) {
|
||||
case self::TYPE_STRING:
|
||||
case self::TYPE_BOOL:
|
||||
return $this->config[$key];
|
||||
case self::TYPE_FILE:
|
||||
return $this->loadFile($key);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function fromPost(array $post) {
|
||||
foreach (array_keys($this->defaults) as $key) {
|
||||
$this->__set($key, isset($post[$key]) ? stripslashes($post[$key]) : null);
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
conf_update_param(self::CONF_PARAM, json_encode($this->config));
|
||||
}
|
||||
|
||||
private function createDefaultConfig() {
|
||||
$this->config = $this->defaults;
|
||||
$this->config[self::KEY_VERSION] = self::CONF_VERSION;
|
||||
}
|
||||
|
||||
private function populateConfig(array $config) {
|
||||
foreach (array_keys($this->defaults) as $key) {
|
||||
if (isset($config[$key])) {
|
||||
$this->config[$key] = $config[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function saveFile($key, $content) {
|
||||
$file = $this->files[$key];
|
||||
$dir = dirname($file);
|
||||
if (!file_exists($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
if (empty($content) && file_exists($file)) {
|
||||
unlink($file);
|
||||
} else {
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadFile($key) {
|
||||
$file = $this->files[$key];
|
||||
if (file_exists($file)) {
|
||||
return file_get_contents($file);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$url = '../';
|
||||
header( 'Request-URI: '.$url );
|
||||
header( 'Content-Location: '.$url );
|
||||
header( 'Location: '.$url );
|
||||
exit();
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace BootstrapDefault;
|
||||
|
||||
class ThemeController {
|
||||
|
||||
private $config;
|
||||
|
||||
public function __construct() {
|
||||
$this->config = new Config();
|
||||
}
|
||||
|
||||
public function init() {
|
||||
$this->setPluginWarnings();
|
||||
|
||||
add_event_handler('loc_begin_page_header', array($this, 'assignConfig'));
|
||||
$shortname = $this->config->comments_disqus_shortname;
|
||||
if ($this->config->comments_type == 'disqus' && !empty($shortname)) {
|
||||
add_event_handler('blockmanager_apply', array($this, 'hideMenus'));
|
||||
}
|
||||
}
|
||||
|
||||
private function setPluginWarnings() {
|
||||
global $pwg_loaded_plugins, $page;
|
||||
if (isset($pwg_loaded_plugins['language_switch'])) {
|
||||
$page['errors'][] = l10n('Language Switch plugin is enabled but is not compatible with the Bootstrap Default theme. Please disable it and download the <a href="http://piwigo.org/ext/extension_view.php?eid=797" target="_new">Bootstrap Default Language Switch</a> instead.');
|
||||
}
|
||||
}
|
||||
|
||||
public function assignConfig() {
|
||||
global $template;
|
||||
$template->assign('theme_config', $this->config);
|
||||
}
|
||||
|
||||
public function hideMenus($menus) {
|
||||
$menu = &$menus[0];
|
||||
|
||||
$mbMenu = $menu->get_block('mbMenu');
|
||||
unset($mbMenu->data['comments']);
|
||||
|
||||
$mbSpecials = $menu->get_block('mbSpecials');
|
||||
if (!is_null($mbSpecials)) {
|
||||
unset($mbSpecials->data['calendar']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user