mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 16:24:43 +03:00
Use YAML files for style configs
This commit is contained in:
parent
2ba5c0e9b3
commit
67383cf052
@ -17,6 +17,8 @@
|
||||
|
||||
namespace Mibew\Style;
|
||||
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* Base class for styles
|
||||
*/
|
||||
@ -36,6 +38,13 @@ abstract class AbstractStyle
|
||||
*/
|
||||
protected $styleName;
|
||||
|
||||
/**
|
||||
* An instance of a parser for config files.
|
||||
*
|
||||
* @var YamlParser|null
|
||||
*/
|
||||
protected $configParser = null;
|
||||
|
||||
/**
|
||||
* Contains cached results of the \Mibew\Style\StyleInterface::getStyleList
|
||||
* method. The lists are keyed by the $root_dir argument of the method.
|
||||
@ -74,7 +83,7 @@ abstract class AbstractStyle
|
||||
*/
|
||||
public function getConfigurations()
|
||||
{
|
||||
$config_file = MIBEW_FS_ROOT . '/' . $this->getFilesPath() . '/config.ini';
|
||||
$config_file = MIBEW_FS_ROOT . '/' . $this->getFilesPath() . '/config.yml';
|
||||
|
||||
// Check if configurations already loaded. Do not do the job twice.
|
||||
if (is_null($this->cachedConfigurations)) {
|
||||
@ -88,7 +97,7 @@ abstract class AbstractStyle
|
||||
|
||||
// Load configurations from file, merge it with default configs and
|
||||
// cache the result.
|
||||
$loaded_config = parse_ini_file($config_file, true);
|
||||
$loaded_config = $this->getConfigParser()->parse(file_get_contents($config_file));
|
||||
$default_config = $this->getDefaultConfigurations();
|
||||
$this->cachedConfigurations = $loaded_config + $default_config;
|
||||
}
|
||||
@ -96,6 +105,20 @@ abstract class AbstractStyle
|
||||
return $this->cachedConfigurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parser which is sutable for parse config files of the style.
|
||||
*
|
||||
* @return YamlParser
|
||||
*/
|
||||
protected function getConfigParser()
|
||||
{
|
||||
if (is_null($this->configParser)) {
|
||||
$this->configParser = new YamlParser();
|
||||
}
|
||||
|
||||
return $this->configParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds base path for style files. This path is relative to Mibew root and
|
||||
* does not contain neither leading nor trailing slash.
|
||||
|
@ -1,17 +0,0 @@
|
||||
; This file determines some dialog styles options
|
||||
; Comments starts with ';'
|
||||
|
||||
[chat]
|
||||
; window_param use as param string in JavaScript window.open method
|
||||
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
|
||||
[mail]
|
||||
; window_param use as param string in JavaScript window.open method
|
||||
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=603,height=254,resizable=0"
|
||||
|
||||
; Screenshots section describe all screenshots shiped with style
|
||||
; Params names should be equals to file names without extension. Pictures
|
||||
; extension should be '.png'
|
||||
; Params values should be equals to screenshot desription
|
||||
[screenshots]
|
||||
client_chat = "Client chat window"
|
16
src/mibew/styles/dialogs/default/config.yml
Normal file
16
src/mibew/styles/dialogs/default/config.yml
Normal file
@ -0,0 +1,16 @@
|
||||
# This file determines some dialog styles options
|
||||
|
||||
chat:
|
||||
# window_param use as param string in JavaScript window.open method
|
||||
window_params: "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
|
||||
mail:
|
||||
# window_param use as param string in JavaScript window.open method
|
||||
window_params: "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=603,height=254,resizable=0"
|
||||
|
||||
# Screenshots section describe all screenshots shiped with style
|
||||
# Params names should be equals to file names without extension. Pictures
|
||||
# extension should be '.png'
|
||||
# Params values should be equals to screenshot desription
|
||||
screenshots:
|
||||
client_chat: "Client chat window"
|
@ -1,10 +0,0 @@
|
||||
; This file determines some invitation style options
|
||||
; Comments starts with ';'
|
||||
|
||||
; Screenshots section describe all screenshots shiped with style
|
||||
; Params names should be equals to file names without extension. Pictures
|
||||
; extension should be '.png'
|
||||
; Params values should be equals to screenshot desription
|
||||
[screenshots]
|
||||
invitation = "Appearance of the invitation"
|
||||
location = "Location of the invitation on a page"
|
9
src/mibew/styles/invitations/default/config.yml
Normal file
9
src/mibew/styles/invitations/default/config.yml
Normal file
@ -0,0 +1,9 @@
|
||||
# This file determines some invitation style options
|
||||
|
||||
# Screenshots section describe all screenshots shiped with style
|
||||
# Params names should be equals to file names without extension. Pictures
|
||||
# extension should be '.png'
|
||||
# Params values should be equals to screenshot desription
|
||||
screenshots:
|
||||
invitation: "Appearance of the invitation"
|
||||
location: "Location of the invitation on a page"
|
@ -1,32 +0,0 @@
|
||||
; This file determines some core styles options
|
||||
; Comments starts with ';'
|
||||
|
||||
[history]
|
||||
; window_param use as param string in JavaScript window.open method
|
||||
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=720,height=560,resizable=1"
|
||||
|
||||
[users]
|
||||
; Use as wrap tag for the thread element
|
||||
thread_tag = "tr"
|
||||
; Use as wrap tag for the visitor element
|
||||
visitor_tag = "tr"
|
||||
|
||||
[tracked]
|
||||
; window_param use as param string in JavaScript window.open method
|
||||
user_window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
visitor_window_params = "toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
|
||||
[invitation]
|
||||
; window_param use as param string in JavaScript window.open method
|
||||
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
|
||||
[ban]
|
||||
; window_param use as param string in JavaScript window.open method
|
||||
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=720,height=480,resizable=1"
|
||||
|
||||
; Screenshots section describe all screenshots shiped with style
|
||||
; Params names should be equals to file names without extension. Pictures
|
||||
; extension should be '.png'
|
||||
; Params values should be equals to screenshot desription
|
||||
[screenshots]
|
||||
home = "Operator's home page"
|
31
src/mibew/styles/pages/default/config.yml
Normal file
31
src/mibew/styles/pages/default/config.yml
Normal file
@ -0,0 +1,31 @@
|
||||
# This file determines some core styles options
|
||||
|
||||
history:
|
||||
# window_param use as param string in JavaScript window.open method
|
||||
window_params: "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=720,height=560,resizable=1"
|
||||
|
||||
users:
|
||||
# Use as wrap tag for the thread element
|
||||
thread_tag: "tr"
|
||||
# Use as wrap tag for the visitor element
|
||||
visitor_tag: "tr"
|
||||
|
||||
tracked:
|
||||
# window_param use as param string in JavaScript window.open method
|
||||
user_window_params: "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
visitor_window_params: "toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
|
||||
invitation:
|
||||
# window_param use as param string in JavaScript window.open method
|
||||
window_params: "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
|
||||
|
||||
ban:
|
||||
# window_param use as param string in JavaScript window.open method
|
||||
window_params: "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=720,height=480,resizable=1"
|
||||
|
||||
# Screenshots section describe all screenshots shiped with style
|
||||
# Params names should be equals to file names without extension. Pictures
|
||||
# extension should be '.png'
|
||||
# Params values should be equals to screenshot desription
|
||||
screenshots:
|
||||
home: "Operator's home page"
|
Loading…
Reference in New Issue
Block a user