mirror of
https://github.com/Mibew/i18n.git
synced 2025-02-02 09:34:41 +03:00
generate Text button started
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@803 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
parent
f069d8d9b6
commit
a0d3403cb5
113
src/messenger/webim/libs/getcode.php
Normal file
113
src/messenger/webim/libs/getcode.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Mibew Messenger project.
|
||||
*
|
||||
* Copyright (c) 2005-2010 Mibew Messenger Community
|
||||
* All rights reserved. The contents of this file are subject to the terms of
|
||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||
* to allow use of your version of this file only under the terms of the GPL, and
|
||||
* not to allow others to use your version of this file under the terms of the
|
||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||
* with the notice and other provisions required by the GPL.
|
||||
*
|
||||
* Contributors:
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function setup_getcode_tabs($active) {
|
||||
global $page, $webimroot;
|
||||
$page['tabselected'] = $active;
|
||||
$page['tabs'] = array(
|
||||
array('title'=> getlocal("page_getcode.tab.image"), 'link' => "$webimroot/operator/getcode.php"),
|
||||
array('title'=> getlocal("page_getcode.tab.text"), 'link' => "$webimroot/operator/gettextcode.php"),
|
||||
);
|
||||
}
|
||||
|
||||
function generate_button($title,$locale,$style,$group,$inner,$showhost,$forcesecure,$modsecurity) {
|
||||
$link = get_app_location($showhost,$forcesecure)."/client.php";
|
||||
if($locale)
|
||||
$link = append_query($link, "locale=$locale");
|
||||
if($style)
|
||||
$link = append_query($link, "style=$style");
|
||||
if($group)
|
||||
$link = append_query($link, "group=$group");
|
||||
|
||||
$modsecfix = $modsecurity ? ".replace('http://','').replace('https://','')" : "";
|
||||
$jslink = append_query("'".$link,"url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)");
|
||||
$temp = get_popup($link, "$jslink",
|
||||
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1" );
|
||||
return "<!-- mibew button -->".$temp."<!-- / mibew button -->";
|
||||
}
|
||||
|
||||
function get_style_list($stylesfolder) {
|
||||
$stylelist = array("" => getlocal("page.preview.style_default"));
|
||||
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;
|
||||
}
|
||||
|
||||
function verifyparam_groupid($paramid) {
|
||||
global $settings, $errors;
|
||||
$groupid = "";
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$groupid = verifyparam($paramid, "/^\d{0,8}$/", "");
|
||||
if($groupid) {
|
||||
$group = group_by_id($groupid);
|
||||
if(!$group) {
|
||||
$errors[] = getlocal("page.group.no_such");
|
||||
$groupid = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $groupid;
|
||||
}
|
||||
|
||||
function get_groups_list() {
|
||||
global $settings;
|
||||
$result = array();
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$link = connect();
|
||||
$allgroups = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$result[] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
||||
foreach($allgroups as $g) {
|
||||
$result[] = $g;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_image_locales_map($localesdir) {
|
||||
$imageLocales = array();
|
||||
$allLocales = get_available_locales();
|
||||
foreach($allLocales as $curr) {
|
||||
$imagesDir = "$localesdir/$curr/button";
|
||||
if($handle = @opendir($imagesDir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^(\w+)_on.gif$/", $file, $matches)
|
||||
&& is_file("$imagesDir/".$matches[1]."_off.gif")) {
|
||||
$image = $matches[1];
|
||||
if( !isset($imageLocales[$image]) ) {
|
||||
$imageLocales[$image] = array();
|
||||
}
|
||||
$imageLocales[$image][] = $curr;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
return $imageLocales;
|
||||
}
|
||||
|
||||
?>
|
@ -279,6 +279,8 @@ page.gen_button.modsecurity=Compatibility with mod_security (modsecurity.org), t
|
||||
page.gen_button.sample=Example
|
||||
page.gen_button.secure_links=Use secure links (https)
|
||||
page.gen_button.title=Button HTML code generation
|
||||
page_getcode.tab.image=Image
|
||||
page_getcode.tab.text=Text
|
||||
page.group.create_new=Here you can create new group.
|
||||
page.group.duplicate_name=Please choose another name, because group with entered name already exists.
|
||||
page.group.intro=On this page you can edit group details.
|
||||
|
@ -22,76 +22,27 @@
|
||||
require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/groups.php');
|
||||
|
||||
function generate_button($title,$locale,$style,$group,$inner,$showhost,$forcesecure,$modsecurity) {
|
||||
$link = get_app_location($showhost,$forcesecure)."/client.php";
|
||||
if($locale)
|
||||
$link = append_query($link, "locale=$locale");
|
||||
if($style)
|
||||
$link = append_query($link, "style=$style");
|
||||
if($group)
|
||||
$link = append_query($link, "group=$group");
|
||||
|
||||
$modsecfix = $modsecurity ? ".replace('http://','').replace('https://','')" : "";
|
||||
$jslink = append_query("'".$link,"url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)");
|
||||
$temp = get_popup($link, "$jslink",
|
||||
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1" );
|
||||
return "<!-- mibew button -->".$temp."<!-- / mibew button -->";
|
||||
}
|
||||
require_once('../libs/getcode.php');
|
||||
|
||||
$operator = check_login();
|
||||
loadsettings();
|
||||
|
||||
$imageLocales = array();
|
||||
$allLocales = get_available_locales();
|
||||
foreach($allLocales as $curr) {
|
||||
$imagesDir = "../locales/$curr/button";
|
||||
if($handle = @opendir($imagesDir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^(\w+)_on.gif$/", $file, $matches)
|
||||
&& is_file("$imagesDir/".$matches[1]."_off.gif")) {
|
||||
$image = $matches[1];
|
||||
if( !isset($imageLocales[$image]) ) {
|
||||
$imageLocales[$image] = array();
|
||||
}
|
||||
$imageLocales[$image][] = $curr;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
|
||||
$imageLocales = get_image_locales_map("../locales");
|
||||
$image = verifyparam(isset($_GET['image']) ? "image" : "i", "/^\w+$/", "webim");
|
||||
if(!isset($imageLocales[$image])) {
|
||||
$errors[] = "Unknown image: $image";
|
||||
$avail = array_keys($imageLocales);
|
||||
$image = $avail[0];
|
||||
}
|
||||
$image_locales = $imageLocales[$image];
|
||||
|
||||
$stylelist = array("" => getlocal("page.preview.style_default"));
|
||||
$stylesfolder = "../styles";
|
||||
if($handle = opendir($stylesfolder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
|
||||
$stylelist[$file] = $file;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
$stylelist = get_style_list("../styles");
|
||||
$style = verifyparam("style","/^\w*$/", "");
|
||||
if($style && !in_array($style, $stylelist)) {
|
||||
$style = "";
|
||||
}
|
||||
|
||||
$groupid = "";
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$groupid = verifyparam( "group", "/^\d{0,8}$/", "");
|
||||
if($groupid) {
|
||||
$group = group_by_id($groupid);
|
||||
if(!$group) {
|
||||
$errors[] = getlocal("page.group.no_such");
|
||||
$groupid = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$groupid = verifyparam_groupid("group");
|
||||
$showhost = verifyparam("hostname","/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure","/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity","/^on$/", "") == "on";
|
||||
@ -114,17 +65,7 @@ $page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhos
|
||||
$page['availableImages'] = array_keys($imageLocales);
|
||||
$page['availableLocales'] = $image_locales;
|
||||
$page['availableStyles'] = $stylelist;
|
||||
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$link = connect();
|
||||
$allgroups = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$page['groups'] = array();
|
||||
$page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
||||
foreach($allgroups as $g) {
|
||||
$page['groups'][] = $g;
|
||||
}
|
||||
}
|
||||
$page['groups'] = get_groups_list();
|
||||
|
||||
$page['formgroup'] = $groupid;
|
||||
$page['formstyle'] = $style;
|
||||
@ -135,6 +76,7 @@ $page['formsecure'] = $forcesecure;
|
||||
$page['formmodsecurity'] = $modsecurity;
|
||||
|
||||
prepare_menu($operator);
|
||||
setup_getcode_tabs(0);
|
||||
start_html_output();
|
||||
require('../view/getcode_image.php');
|
||||
?>
|
66
src/messenger/webim/operator/gettextcode.php
Normal file
66
src/messenger/webim/operator/gettextcode.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Mibew Messenger project.
|
||||
*
|
||||
* Copyright (c) 2005-2010 Mibew Messenger Community
|
||||
* All rights reserved. The contents of this file are subject to the terms of
|
||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||
* to allow use of your version of this file only under the terms of the GPL, and
|
||||
* not to allow others to use your version of this file under the terms of the
|
||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||
* with the notice and other provisions required by the GPL.
|
||||
*
|
||||
* Contributors:
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/groups.php');
|
||||
require_once('../libs/getcode.php');
|
||||
|
||||
$operator = check_login();
|
||||
loadsettings();
|
||||
|
||||
$stylelist = get_style_list("../styles");
|
||||
$style = verifyparam("style","/^\w*$/", "");
|
||||
if($style && !in_array($style, $stylelist)) {
|
||||
$style = "";
|
||||
}
|
||||
|
||||
$groupid = verifyparam_groupid("group");
|
||||
$showhost = verifyparam("hostname","/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure","/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity","/^on$/", "") == "on";
|
||||
|
||||
$allLocales = get_available_locales();
|
||||
|
||||
$lang = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
if( !$lang || !in_array($lang,$allLocales) )
|
||||
$lang = in_array($current_locale,$allLocales) ? $current_locale : $allLocales[0];
|
||||
|
||||
$message = "Click to chat"; // TODO
|
||||
|
||||
$page = array();
|
||||
$page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhost,$forcesecure,$modsecurity);
|
||||
$page['availableLocales'] = $allLocales;
|
||||
$page['availableStyles'] = $stylelist;
|
||||
$page['groups'] = get_groups_list();
|
||||
|
||||
$page['formgroup'] = $groupid;
|
||||
$page['formstyle'] = $style;
|
||||
$page['formlang'] = $lang;
|
||||
$page['formhostname'] = $showhost;
|
||||
$page['formsecure'] = $forcesecure;
|
||||
$page['formmodsecurity'] = $modsecurity;
|
||||
|
||||
prepare_menu($operator);
|
||||
setup_getcode_tabs(1);
|
||||
start_html_output();
|
||||
require('../view/getcode_text.php');
|
||||
?>
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
require_once("inc_menu.php");
|
||||
require_once("inc_tabbar.php");
|
||||
$page['title'] = getlocal("page.gen_button.title");
|
||||
$page['menuid'] = "getcode";
|
||||
|
||||
@ -34,6 +35,8 @@ require_once('inc_errors.php');
|
||||
?>
|
||||
|
||||
<form name="buttonCodeForm" method="get" action="<?php echo $webimroot ?>/operator/getcode.php">
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
||||
<div class="fieldForm">
|
||||
@ -45,14 +48,6 @@ require_once('inc_errors.php');
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_image") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="i" onchange="this.form.submit();"><?php foreach($page['availableImages'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("image") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all"/>
|
||||
|
||||
<?php if($page['showgroups']) { ?>
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_group") ?></div>
|
||||
@ -61,6 +56,14 @@ require_once('inc_errors.php');
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br clear="all"/>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_image") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="i" onchange="this.form.submit();"><?php foreach($page['availableImages'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("image") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_style") ?></div>
|
||||
@ -113,6 +116,7 @@ require_once('inc_errors.php');
|
||||
</div>
|
||||
|
||||
</div><div class="formbottom"><div class="formbottomi"></div></div></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
119
src/messenger/webim/view/getcode_text.php
Normal file
119
src/messenger/webim/view/getcode_text.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Mibew Messenger project.
|
||||
*
|
||||
* Copyright (c) 2005-2010 Mibew Messenger Community
|
||||
* All rights reserved. The contents of this file are subject to the terms of
|
||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||
* to allow use of your version of this file only under the terms of the GPL, and
|
||||
* not to allow others to use your version of this file under the terms of the
|
||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||
* with the notice and other provisions required by the GPL.
|
||||
*
|
||||
* Contributors:
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
require_once("inc_menu.php");
|
||||
require_once("inc_tabbar.php");
|
||||
$page['title'] = getlocal("page.gen_button.title");
|
||||
$page['menuid'] = "getcode";
|
||||
|
||||
function tpl_content() { global $page, $webimroot, $errors;
|
||||
?>
|
||||
|
||||
<?php echo getlocal("page.gen_button.intro") ?>
|
||||
<br />
|
||||
<br />
|
||||
<?php
|
||||
require_once('inc_errors.php');
|
||||
?>
|
||||
|
||||
<form name="buttonCodeForm" method="get" action="<?php echo $webimroot ?>/operator/gettextcode.php">
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
||||
<div class="fieldForm">
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_locale") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="lang" onchange="this.form.submit();"><?php foreach($page['availableLocales'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("lang") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($page['showgroups']) { ?>
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_group") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="group" onchange="this.form.submit();"><?php foreach($page['groups'] as $k) { echo "<option value=\"".$k['groupid']."\"".($k['groupid'] == form_value("group") ? " selected=\"selected\"" : "").">".$k['vclocalname']."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br clear="all"/>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_style") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="style" onchange="this.form.submit();"><?php foreach($page['availableStyles'] as $k => $v) { echo "<option value=\"".$k."\"".($k == form_value("style") ? " selected=\"selected\"" : "").">".$v."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all"/>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.include_site_name") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<input type="checkbox" name="hostname" value="on"<?php echo form_value_cb('hostname') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if( $page['formhostname'] ) { ?>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.secure_links") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<input type="checkbox" name="secure" value="on"<?php echo form_value_cb('secure') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br clear="all"/>
|
||||
|
||||
<div class="field">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.modsecurity") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<input type="checkbox" name="modsecurity" value="on"<?php echo form_value_cb('modsecurity') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.code") ?></div>
|
||||
<div class="fvaluewithta" dir="ltr">
|
||||
<textarea cols="44" rows="15"><?php echo htmlspecialchars($page['buttonCode']) ?></textarea>
|
||||
</div>
|
||||
<div class="fdescr"><?php echo getlocal("page.gen_button.code.description") ?></div>
|
||||
<br clear="all"/>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.sample") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<?php echo $page['buttonCode'] ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><div class="formbottom"><div class="formbottomi"></div></div></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
} /* content */
|
||||
|
||||
require_once('inc_main.php');
|
||||
?>
|
Loading…
Reference in New Issue
Block a user