mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-01 05:44:41 +03:00
Move all function related with invitation styles to InvitationStyle class
This commit is contained in:
parent
3627e79fe0
commit
3fc3544f23
94
src/mibew/libs/classes/invitation_style.php
Normal file
94
src/mibew/libs/classes/invitation_style.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a style for invitations
|
||||
*/
|
||||
class InvitationStyle extends Style implements StyleInterface {
|
||||
/**
|
||||
* 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 function filesPath() {
|
||||
return 'styles/invitations/' . $this->name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads configurations of the style.
|
||||
*
|
||||
* @return array Style configurations
|
||||
*/
|
||||
public function configurations() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub for StyleInterface::render method.
|
||||
*
|
||||
* The method does not contain actual code because inviation styles are not
|
||||
* renderable now.
|
||||
*/
|
||||
public function render($template_name) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns name of the style which is currently used in the system
|
||||
*
|
||||
* @return string Name of a style
|
||||
*/
|
||||
public static function currentStyle() {
|
||||
// Load value from system settings
|
||||
return Settings::get('invitationstyle');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('invitationstyle', $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/invitations';
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity, $operator_code)
|
||||
function generate_button($title, $locale, $style, $invitation_style_name, $group, $inner, $showhost, $forcesecure, $modsecurity, $operator_code)
|
||||
{
|
||||
$app_location = get_app_location($showhost, $forcesecure);
|
||||
$link = $app_location . "/client.php";
|
||||
@ -48,12 +48,16 @@ function generate_button($title, $locale, $style, $invitationstyle, $group, $inn
|
||||
if (Settings::get('enabletracking')) {
|
||||
$widget_data = array();
|
||||
|
||||
// Get actual invitation style instance
|
||||
if (!$invitation_style_name) {
|
||||
$invitation_style_name = InvitationStyle::currentStyle();
|
||||
}
|
||||
$invitation_style = new InvitationStyle($invitation_style_name);
|
||||
|
||||
// URL of file with additional CSS rules for invitation popup
|
||||
$widget_data['inviteStyle'] = $app_location . '/styles/invitations/' .
|
||||
($invitationstyle
|
||||
? $invitationstyle
|
||||
: (Settings::get('invitationstyle'))
|
||||
) . '/invite.css';
|
||||
$widget_data['inviteStyle'] = $app_location . '/' .
|
||||
$invitation_style->filesPath() .
|
||||
'/invite.css';
|
||||
|
||||
// Time between requests to the server in milliseconds
|
||||
$widget_data['requestTimeout'] = Settings::get('updatefrequency_tracking')
|
||||
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function get_style_list($stylesfolder)
|
||||
{
|
||||
$stylelist = array();
|
||||
if ($handle = opendir($stylesfolder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
|
||||
$stylelist[$file] = $file;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $stylelist;
|
||||
}
|
||||
|
||||
?>
|
@ -19,11 +19,11 @@ 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/getcode.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/styles.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');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/page_style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/invitation_style.php');
|
||||
|
||||
$operator = check_login();
|
||||
force_password($operator);
|
||||
@ -44,7 +44,7 @@ if ($style && !in_array($style, $stylelist)) {
|
||||
$style = "";
|
||||
}
|
||||
|
||||
$invitationstylelist = get_style_list(dirname(dirname(__FILE__)).'/styles/invitations');
|
||||
$invitationstylelist = InvitationStyle::availableStyles();
|
||||
$invitationstylelist[""] = getlocal("page.preview.style_default");
|
||||
$invitationstyle = verifyparam("invitationstyle", "/^\w*$/", "");
|
||||
if ($invitationstyle && !in_array($invitationstyle, $invitationstylelist)) {
|
||||
|
@ -21,14 +21,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/interfaces/style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/page_style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/invitation_style.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
$stylelist = get_style_list(dirname(dirname(__FILE__)).'/styles/invitations');
|
||||
$stylelist = InvitationStyle::availableStyles();
|
||||
|
||||
$preview = verifyparam("preview", "/^\w+$/", "default");
|
||||
if (!in_array($preview, $stylelist)) {
|
||||
|
@ -18,7 +18,6 @@
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/init.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/operator.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/settings.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/styles.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/page_style.php');
|
||||
|
@ -18,12 +18,12 @@
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/init.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/operator.php');
|
||||
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/interfaces/style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/chat_style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/page_style.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/libs/classes/invitation_style.php');
|
||||
|
||||
$operator = check_login();
|
||||
force_password($operator);
|
||||
@ -52,7 +52,7 @@ $options = array(
|
||||
|
||||
if (Settings::get('enabletracking')) {
|
||||
$options[] = 'invitationstyle';
|
||||
$invitationstylelist = get_style_list(dirname(dirname(__FILE__)).'/styles/invitations');
|
||||
$invitationstylelist = InvitationStyle::availableStyles();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
|
Loading…
Reference in New Issue
Block a user