diff --git a/src/mibew/client.php b/src/mibew/client.php index 26f3f222..f0ebc8f1 100644 --- a/src/mibew/client.php +++ b/src/mibew/client.php @@ -24,6 +24,9 @@ require_once(dirname(__FILE__).'/libs/captcha.php'); require_once(dirname(__FILE__).'/libs/invitation.php'); require_once(dirname(__FILE__).'/libs/track.php'); require_once(dirname(__FILE__).'/libs/classes/thread.php'); +require_once(dirname(__FILE__).'/libs/interfaces/style.php'); +require_once(dirname(__FILE__).'/libs/classes/style.php'); +require_once(dirname(__FILE__).'/libs/classes/chat_style.php'); if(Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") { if(!is_secure_request()) { @@ -37,6 +40,8 @@ if(Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") { } } +// Initialize chat style which is currently used in system +$chat_style = new ChatStyle(ChatStyle::currentStyle()); // Do not support old browsers at all if (get_remote_level($_SERVER['HTTP_USER_AGENT']) == 'old') { @@ -44,7 +49,7 @@ if (get_remote_level($_SERVER['HTTP_USER_AGENT']) == 'old') { $page = array_merge_recursive( setup_logo() ); - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "nochat.tpl"); + $chat_style->render('nochat'); exit; } @@ -63,7 +68,7 @@ if (verifyparam("act", "/^(invitation)$/", "default") == 'invitation' // Build js application options $page['invitationOptions'] = json_encode($page['invitation']); // Expand page - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "chat.tpl"); + $chat_style->render('chat'); exit; } } @@ -129,7 +134,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { ) ); $page['leaveMessageOptions'] = json_encode($page['leaveMessage']); - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "chat.tpl"); + $chat_style->render('chat'); exit; } @@ -158,7 +163,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { setup_survey($visitor['name'], $email, $groupid, $info, $referrer) ); $page['surveyOptions'] = json_encode($page['survey']); - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "chat.tpl"); + $chat_style->render('chat'); exit; } @@ -184,12 +189,12 @@ $page = setup_chatview_for_user($thread); $pparam = verifyparam( "act", "/^(mailthread)$/", "default"); if( $pparam == "mailthread" ) { - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "mail.tpl"); + $chat_style->render('mail'); } else { // Build js application options $page['chatOptions'] = json_encode($page['chat']); // Expand page - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "chat.tpl"); + $chat_style->render('chat'); } ?> \ No newline at end of file diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index ad9e7981..2c17b741 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -24,6 +24,9 @@ require_once(dirname(__FILE__).'/classes/mibew_api_execution_context.php'); require_once(dirname(__FILE__).'/classes/request_processor.php'); require_once(dirname(__FILE__).'/classes/client_side_processor.php'); require_once(dirname(__FILE__).'/classes/thread_processor.php'); +require_once(dirname(__FILE__).'/interfaces/style.php'); +require_once(dirname(__FILE__).'/classes/style.php'); +require_once(dirname(__FILE__).'/classes/chat_style.php'); /** @@ -418,7 +421,8 @@ function setup_chatview(Thread $thread) { $data['neediframesrc'] = needsFramesrc(); // Load dialogs style options - $style_config = get_dialogs_style_config(getchatstyle()); + $chat_style = new ChatStyle(ChatStyle::currentStyle()); + $style_config = $chat_style->configurations(); $data['chat']['windowsParams']['mail'] = $style_config['mail']['window_params']; diff --git a/src/mibew/libs/classes/chat_style.php b/src/mibew/libs/classes/chat_style.php new file mode 100644 index 00000000..e6ea06dd --- /dev/null +++ b/src/mibew/libs/classes/chat_style.php @@ -0,0 +1,129 @@ +name(); + } + + /** + * Renders template file to HTML and send it to the output + * + * @param string $template_name Name of the template file without path and + * extension + */ + public function render($template_name) { + $templates_root = dirname(dirname(dirname(__FILE__))) . + '/' . $this->filesPath() . '/templates/'; + $full_template_name = $template_name . '.tpl'; + + expand($this, $templates_root, $full_template_name); + } + + /** + * Returns name of the style which is currently used in the system + * + * @return string Name of a style + */ + public static function currentStyle() { + // Ceck if request contains chat style + $style_name = verifyparam("style", "/^\w+$/", ""); + if (!$style_name) { + // Load value from system settings + $style_name = Settings::get('chat_style'); + } + + // Get all style list and make sure that in has at least one style. + $available_styles = self::availableStyles(); + if (empty($available_styles)) { + throw new RuntimeException('There are no dialog styles in the system'); + } + + // Check if selected style exists. If it does not exist try to fall back + // to "default". Finally, if there is no appropriate style in the system + // throw an exception. + if (in_array($style_name, $available_styles)) { + return $style_name; + } elseif (in_array('default', $available_styles)) { + return 'default'; + } else { + throw new RuntimeException('There is no appropriate dialog style in the system'); + } + } + + /** + * Sets style which is currently used in the system + * + * @param string $style_name Name of a style + */ + public static function setCurrentStyle($style_name) { + Settings::set('chat_style', $style_name); + Settings::update(); + } + + /** + * Returns an array which contains names of available styles. + * + * @param array List of styles names + */ + public static function availableStyles() { + $styles_root = dirname(dirname(dirname(__FILE__))) . + '/styles/dialogs'; + + return self::getStyleList($styles_root); + } + + /** + * Returns array of default configurations for concrete style object. This + * method uses "Template method" design pattern. + * + * @return array Default configurations of the style + */ + protected function defaultConfigurations() { + return array( + 'history' => array( + 'window_params' => '' + ), + 'users' => array( + 'thread_tag' => 'div', + 'visitor_tag' => 'div' + ), + 'tracked' => array( + 'user_window_params' => '', + 'visitor_window_params' => '' + ), + 'invitation' => array( + 'window_params' => '' + ), + 'ban' => array( + 'window_params' => '' + ), + 'screenshots' => array() + ); + } +} + +?> \ No newline at end of file diff --git a/src/mibew/libs/classes/settings.php b/src/mibew/libs/classes/settings.php index c4a759db..4f34f1ff 100644 --- a/src/mibew/libs/classes/settings.php +++ b/src/mibew/libs/classes/settings.php @@ -65,7 +65,7 @@ Class Settings { 'hosturl' => 'http://mibew.org', 'logo' => '', 'usernamepattern' => '{name}', - 'chatstyle' => 'default', + 'chat_style' => 'default', 'invitationstyle' => 'default', 'operator_pages_style' => 'default', 'chattitle' => 'Live Support', diff --git a/src/mibew/libs/classes/style.php b/src/mibew/libs/classes/style.php new file mode 100644 index 00000000..3fd5c254 --- /dev/null +++ b/src/mibew/libs/classes/style.php @@ -0,0 +1,135 @@ +styleName = $style_name; + } + + /** + * Returns name of the style related with the object + * + * @return string Name of the style + */ + public function name() { + return $this->styleName; + } + + /** + * Loads configurations of the style. The results is cached in the class + * instance. + * + * @return array Style configurations + * @throws RuntimeException + */ + public function configurations() { + $config_file = dirname(dirname(dirname(__FILE__))) + . '/' . $this->filesPath() . '/config.ini'; + + // Check if configurations already loaded. Do not do the job twice. + if (is_null($this->cachedConfigurations)) { + // Set empty value for configuration array + $this->cachedConfigurations = array(); + + // Try to read configuration file + if (!is_readable($config_file)) { + throw new RuntimeException('Cannot read configuration file'); + } + + // Load configurations from file, merge it with default configs and + // cache the result. + $loaded_config = parse_ini_file($config_file, true); + $default_config = $this->defaultConfigurations(); + $this->cachedConfigurations = $loaded_config + $default_config; + } + + return $this->cachedConfigurations; + } + + /** + * Gets names of styles which are located in the $root_dir. + * + * @param string $root_dir Root styles directory + * @return array List of styles' names + */ + protected static function getStyleList($root_dir) { + // Check if styles list is already stored in the cache + if (!isset(self::$cachedStyleLists[$root_dir])) { + // Build list of styles for the specified root directory. + $style_list = array(); + if ($handle = opendir($root_dir)) { + while (false !== ($file = readdir($handle))) { + if (preg_match("/^\w+$/", $file) && is_dir("$root_dir/$file")) { + $style_list[$file] = $file; + } + } + closedir($handle); + } + + // Cache the list + self::$cachedStyleLists[$root_dir] = $style_list; + } + + return self::$cachedStyleLists[$root_dir]; + } + + /** + * Builds base path for style files. This path is relative Mibew root and + * does not contain neither leading nor trailing slash. + * + * @return string Base path for style files + */ + public abstract function filesPath(); + + /** + * Returns array of default configurations for concrete style object. This + * method uses "Template method" design pattern. + * + * @return array Default configurations of the style + */ + protected abstract function defaultConfigurations(); +} + +?> \ No newline at end of file diff --git a/src/mibew/libs/common/configurations.php b/src/mibew/libs/common/configurations.php index 829b95ea..36c7268d 100644 --- a/src/mibew/libs/common/configurations.php +++ b/src/mibew/libs/common/configurations.php @@ -67,32 +67,4 @@ function get_core_style_config($style) { return $config; } -/** - * Load configuration array for dialogs style - * - * @param string $style Style name - * @return array Configuration array - */ -function get_dialogs_style_config($style) { - // Get root dir of mibew messanger - $base_path = realpath(dirname(dirname(dirname(__FILE__)))); - - // Load config - $config = read_config_file($base_path.'/styles/dialogs/'.$style.'/config.ini'); - - // Set default values - $config = ($config === false) ? array() : $config; - $config += array( - 'chat' => array( - 'window_params' => '' - ), - 'mail' => array( - 'window_params' => '' - ), - 'screenshots' => array() - ); - - return $config; -} - ?> \ No newline at end of file diff --git a/src/mibew/libs/common/request.php b/src/mibew/libs/common/request.php index 8012850f..a2075ff2 100644 --- a/src/mibew/libs/common/request.php +++ b/src/mibew/libs/common/request.php @@ -76,15 +76,6 @@ function is_secure_request() || isset($_SERVER["HTTP_HTTPS"]) && $_SERVER["HTTP_HTTPS"] == "on"; } -function getchatstyle() -{ - $chatstyle = verifyparam("style", "/^\w+$/", ""); - if ($chatstyle) { - return $chatstyle; - } - return Settings::get('chatstyle'); -} - /** * Returns name of the current operator pages style * diff --git a/src/mibew/libs/expand.php b/src/mibew/libs/expand.php index 6332811b..2363717d 100644 --- a/src/mibew/libs/expand.php +++ b/src/mibew/libs/expand.php @@ -17,7 +17,7 @@ $ifregexp = "/\\\${(if|ifnot):([\w\.]+)}(.*?)(\\\${else:\\2}.*?)?\\\${endif:\\2}/s"; $expand_include_path = ""; -$current_style = ""; +$current_style = NULL; $flatten_page = array(); @@ -52,9 +52,9 @@ function expand_var($matches) if ($var == 'mibewroot') { return $mibewroot; } else if ($var == 'tplroot') { - return "$mibewroot/styles/dialogs/$current_style"; + return "$mibewroot/" . $current_style->filesPath(); } else if ($var == 'styleid') { - return $current_style; + return $current_style->name(); } else if ($var == 'pagination') { return generate_pagination($page['pagination']); } else if ($var == 'errors' || $var == 'harderrors') { @@ -110,24 +110,16 @@ function expandtext($text) return preg_replace_callback("/\\\${(\w+:)?([\w\.,]+)}/", "expand_var", $text); } -function expand($basedir, $style, $filename) +function expand(StyleInterface $style, $templates_root, $filename) { global $page, $expand_include_path, $current_style, $flatten_page; $flatten_page = array_flatten_recursive($page); start_html_output(); - if (!is_dir("$basedir/$style")) { - $style = "default"; - } - $expand_include_path = "$basedir/$style/templates/"; + $expand_include_path = $templates_root; $current_style = $style; $contents = @file_get_contents($expand_include_path . $filename); - if ($contents === false) { - $expand_include_path = "$basedir/default/templates/"; - $current_style = "default"; - $contents = @file_get_contents($expand_include_path . $filename) or die("cannot load template"); - } echo expandtext($contents); } diff --git a/src/mibew/libs/interfaces/style.php b/src/mibew/libs/interfaces/style.php new file mode 100644 index 00000000..cd0a5074 --- /dev/null +++ b/src/mibew/libs/interfaces/style.php @@ -0,0 +1,74 @@ + \ No newline at end of file diff --git a/src/mibew/mail.php b/src/mibew/mail.php index 79203992..5b8b68cd 100644 --- a/src/mibew/mail.php +++ b/src/mibew/mail.php @@ -21,6 +21,9 @@ require_once(dirname(__FILE__).'/libs/expand.php'); require_once(dirname(__FILE__).'/libs/groups.php'); require_once(dirname(__FILE__).'/libs/notify.php'); require_once(dirname(__FILE__).'/libs/classes/thread.php'); +require_once(dirname(__FILE__).'/libs/interfaces/style.php'); +require_once(dirname(__FILE__).'/libs/classes/style.php'); +require_once(dirname(__FILE__).'/libs/classes/chat_style.php'); $errors = array(); $page = array(); @@ -33,6 +36,9 @@ if (! $thread) { die("wrong thread"); } +// Initialize chat style which is currently used in system +$chat_style = new ChatStyle(ChatStyle::currentStyle()); + $email = getparam('email'); $page['email'] = $email; $group = is_null($thread->groupId)?NULL:group_by_id($thread->groupId); @@ -51,7 +57,7 @@ if( count($errors) > 0 ) { $page, setup_logo($group) ); - expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "mail.tpl"); + $chat_style->render('mail'); exit; } @@ -74,6 +80,6 @@ $page = array_merge_recursive( $page, setup_logo($group) ); -expand(dirname(__FILE__).'/styles/dialogs', getchatstyle(), "mailsent.tpl"); +$chat_style->render('mailsent'); exit; ?> \ No newline at end of file diff --git a/src/mibew/operator/agent.php b/src/mibew/operator/agent.php index 2c4b1d9c..36ac34eb 100644 --- a/src/mibew/operator/agent.php +++ b/src/mibew/operator/agent.php @@ -24,6 +24,9 @@ require_once(dirname(dirname(__FILE__)).'/libs/pagination.php'); require_once(dirname(dirname(__FILE__)).'/libs/expand.php'); require_once(dirname(dirname(__FILE__)).'/libs/classes/thread.php'); require_once(dirname(dirname(__FILE__)).'/libs/view.php'); +require_once(dirname(dirname(__FILE__)).'/libs/interfaces/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php'); $operator = check_login(); @@ -42,21 +45,22 @@ if (Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") { $threadid = verifyparam("thread", "/^\d{1,8}$/"); $page = array(); +// Initialize chat style which is currently used in system +$chat_style = new ChatStyle(ChatStyle::currentStyle()); + if (!isset($_GET['token'])) { $remote_level = get_remote_level($_SERVER['HTTP_USER_AGENT']); if ($remote_level != "ajaxed") { $errors = array(getlocal("thread.error.old_browser")); - start_html_output(); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); exit; } $thread = Thread::load($threadid); if (!$thread || !isset($thread->lastToken)) { $errors = array(getlocal("thread.error.wrong_thread")); - start_html_output(); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); exit; } @@ -67,8 +71,7 @@ if (!isset($_GET['token'])) { if (!is_capable(CAN_TAKEOVER, $operator)) { $errors = array(getlocal("thread.error.cannot_take_over")); - start_html_output(); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); exit; } @@ -86,14 +89,12 @@ if (!isset($_GET['token'])) { if (!$viewonly) { if(! $thread->take($operator)){ $errors = array(getlocal("thread.error.cannot_take")); - start_html_output(); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); exit; } } else if (!is_capable(CAN_VIEWTHREADS, $operator)) { $errors = array(getlocal("thread.error.cannot_view")); - start_html_output(); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); exit; } @@ -111,8 +112,7 @@ if (!$thread) { if ($thread->agentId != $operator['operatorid'] && !is_capable(CAN_VIEWTHREADS, $operator)) { $errors = array("Cannot view threads"); - start_html_output(); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); exit; } @@ -126,12 +126,12 @@ start_html_output(); $pparam = verifyparam("act", "/^(redirect)$/", "default"); if ($pparam == "redirect") { setup_redirect_links($threadid, $operator, $token); - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "redirect.tpl"); + $chat_style->render('redirect'); } else { // Build js application options $page['chatOptions'] = json_encode($page['chat']); // Expand page - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "chat.tpl"); + $chat_style->render('chat'); } ?> \ No newline at end of file diff --git a/src/mibew/operator/getcode.php b/src/mibew/operator/getcode.php index 3a99d81c..8235d405 100644 --- a/src/mibew/operator/getcode.php +++ b/src/mibew/operator/getcode.php @@ -21,6 +21,9 @@ require_once(dirname(dirname(__FILE__)).'/libs/groups.php'); require_once(dirname(dirname(__FILE__)).'/libs/getcode.php'); require_once(dirname(dirname(__FILE__)).'/libs/styles.php'); require_once(dirname(dirname(__FILE__)).'/libs/view.php'); +require_once(dirname(dirname(__FILE__)).'/libs/interfaces/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php'); $operator = check_login(); force_password($operator); @@ -34,7 +37,7 @@ if (!isset($imageLocales[$image])) { } $image_locales = $imageLocales[$image]; -$stylelist = get_style_list(dirname(dirname(__FILE__)).'/styles/dialogs'); +$stylelist = ChatStyle::availableStyles(); $stylelist[""] = getlocal("page.preview.style_default"); $style = verifyparam("style", "/^\w*$/", ""); if ($style && !in_array($style, $stylelist)) { diff --git a/src/mibew/operator/redirect.php b/src/mibew/operator/redirect.php index fe6c43e5..181a984f 100644 --- a/src/mibew/operator/redirect.php +++ b/src/mibew/operator/redirect.php @@ -21,6 +21,9 @@ require_once(dirname(dirname(__FILE__)).'/libs/chat.php'); require_once(dirname(dirname(__FILE__)).'/libs/expand.php'); require_once(dirname(dirname(__FILE__)).'/libs/groups.php'); require_once(dirname(dirname(__FILE__)).'/libs/classes/thread.php'); +require_once(dirname(dirname(__FILE__)).'/libs/interfaces/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php'); $operator = check_login(); @@ -35,6 +38,9 @@ if (! $thread) { $page = array(); $errors = array(); +// Initialize chat style which is currently used in system +$chat_style = new ChatStyle(ChatStyle::currentStyle()); + if (isset($_GET['nextGroup'])) { $nextid = verifyparam("nextGroup", "/^\d{1,8}$/"); $nextGroup = group_by_id($nextid); @@ -110,10 +116,11 @@ $page = array_merge_recursive( $page, setup_logo() ); + if (count($errors) > 0) { - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "error.tpl"); + $chat_style->render('error'); } else { - expand(dirname(dirname(__FILE__)).'/styles/dialogs', getchatstyle(), "redirected.tpl"); + $chat_style->render('redirected'); } ?> \ No newline at end of file diff --git a/src/mibew/operator/settings.php b/src/mibew/operator/settings.php index 84036c1e..ce0d31c6 100644 --- a/src/mibew/operator/settings.php +++ b/src/mibew/operator/settings.php @@ -21,6 +21,9 @@ require_once(dirname(dirname(__FILE__)).'/libs/settings.php'); require_once(dirname(dirname(__FILE__)).'/libs/styles.php'); require_once(dirname(dirname(__FILE__)).'/libs/cron.php'); require_once(dirname(dirname(__FILE__)).'/libs/view.php'); +require_once(dirname(dirname(__FILE__)).'/libs/interfaces/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php'); $operator = check_login(); force_password($operator); @@ -29,7 +32,7 @@ csrfchecktoken(); $page = array('agentId' => ''); $errors = array(); -$stylelist = get_style_list(dirname(dirname(__FILE__)).'/styles/dialogs'); +$stylelist = ChatStyle::availableStyles(); $operator_pages_style_list = get_style_list(dirname(dirname(__FILE__)).'/styles/operator_pages'); $options = array( @@ -39,7 +42,7 @@ $options = array( 'hosturl', 'usernamepattern', 'operator_pages_style', - 'chatstyle', + 'chat_style', 'chattitle', 'geolink', 'geolinkparams', @@ -69,9 +72,9 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { $params['sendmessagekey'] = verifyparam('sendmessagekey', "/^c?enter$/"); $params['cron_key'] = getparam('cronkey'); - $params['chatstyle'] = verifyparam("chatstyle", "/^\w+$/", $params['chatstyle']); - if (!in_array($params['chatstyle'], $stylelist)) { - $params['chatstyle'] = $stylelist[0]; + $params['chat_style'] = verifyparam("chat_style", "/^\w+$/", $params['chat_style']); + if (!in_array($params['chat_style'], $stylelist)) { + $params['chat_style'] = $stylelist[0]; } $params['operator_pages_style'] = verifyparam("operator_pages_style", "/^\w+$/", $params['operator_pages_style']); @@ -121,7 +124,7 @@ $page['formgeolinkparams'] = topage($params['geolinkparams']); $page['formusernamepattern'] = topage($params['usernamepattern']); $page['formoperatorpagesstyle'] = $params['operator_pages_style']; $page['availableOperatorPagesStyles'] = $operator_pages_style_list; -$page['formchatstyle'] = $params['chatstyle']; +$page['formchatstyle'] = $params['chat_style']; $page['formchattitle'] = topage($params['chattitle']); $page['formsendmessagekey'] = $params['sendmessagekey']; $page['availableChatStyles'] = $stylelist; diff --git a/src/mibew/operator/themes.php b/src/mibew/operator/themes.php index 48048d6e..20211536 100644 --- a/src/mibew/operator/themes.php +++ b/src/mibew/operator/themes.php @@ -22,12 +22,14 @@ require_once(dirname(dirname(__FILE__)).'/libs/operator.php'); require_once(dirname(dirname(__FILE__)).'/libs/groups.php'); require_once(dirname(dirname(__FILE__)).'/libs/expand.php'); require_once(dirname(dirname(__FILE__)).'/libs/settings.php'); -require_once(dirname(dirname(__FILE__)).'/libs/styles.php'); require_once(dirname(dirname(__FILE__)).'/libs/view.php'); +require_once(dirname(dirname(__FILE__)).'/libs/interfaces/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php'); $operator = check_login(); -$stylelist = get_style_list(dirname(dirname(__FILE__)).'/styles/dialogs'); +$stylelist = ChatStyle::availableStyles(); $preview = verifyparam("preview", "/^\w+$/", "default"); if (!in_array($preview, $stylelist)) { @@ -35,13 +37,15 @@ if (!in_array($preview, $stylelist)) { $preview = $stylelist[$style_names[0]]; } -$style_config = get_dialogs_style_config($preview); +$chat_style = new ChatStyle($preview); + +$style_config = $chat_style->configurations(); $screenshots = array(); foreach($style_config['screenshots'] as $name => $desc) { $screenshots[] = array( 'name' => $name, - 'file' => $mibewroot . '/styles/dialogs/' . $preview + 'file' => $mibewroot . '/' . $chat_style->filesPath() . '/screenshots/' . $name . '.png', 'description' => $desc ); diff --git a/src/mibew/operator/users.php b/src/mibew/operator/users.php index 7413958f..af4023a6 100644 --- a/src/mibew/operator/users.php +++ b/src/mibew/operator/users.php @@ -19,6 +19,9 @@ require_once(dirname(dirname(__FILE__)).'/libs/init.php'); require_once(dirname(dirname(__FILE__)).'/libs/operator.php'); require_once(dirname(dirname(__FILE__)).'/libs/groups.php'); require_once(dirname(dirname(__FILE__)).'/libs/view.php'); +require_once(dirname(dirname(__FILE__)).'/libs/interfaces/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php'); +require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php'); $operator = check_login(); force_password($operator); @@ -41,7 +44,8 @@ $page['geoLink'] = Settings::get('geolink'); $page['geoWindowParams'] = Settings::get('geolinkparams'); // Load dialogs style options -$style_config = get_dialogs_style_config(getchatstyle()); +$chat_style = new ChatStyle(ChatStyle::currentStyle()); +$style_config = $chat_style->configurations(); $page['chatStyles.chatWindowParams'] = $style_config['chat']['window_params']; // Load core style options diff --git a/src/mibew/styles/operator_pages/default/views/settings.php b/src/mibew/styles/operator_pages/default/views/settings.php index 6c5c1e93..a49a22cf 100644 --- a/src/mibew/styles/operator_pages/default/views/settings.php +++ b/src/mibew/styles/operator_pages/default/views/settings.php @@ -125,18 +125,18 @@ require_once(dirname(__FILE__).'/inc_errors.php');
- +

- +
- +
- +