1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Функционал добавления языковых текстовок в шаблон + доработка топика фотосета

This commit is contained in:
Mzhelskiy Maxim 2011-07-24 11:48:08 +00:00
parent b88c76e3f4
commit 254e0ab4c7
23 changed files with 285 additions and 81 deletions

View file

@ -157,6 +157,11 @@ class ActionAdmin extends Action {
$this->Message_AddNotice($this->Lang_Get('user_field_updated'),$this->Lang_Get('attention'));
break;
default:
/**
* Загружаем в шаблон JS текстовки
*/
$this->Lang_AddLangJs(array('user_field_delete_confirm'));
$aUserFields = $this->User_getUserFields();
$this->Viewer_Assign('aUserFields',$aUserFields);
$this->SetTemplateAction('user_fields');

View file

@ -1,5 +1,24 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
/**
* Обработка УРЛа вида /photoset/ - управление своими топиками(тип: фотосет)
*
*/
class ActionPhotoset extends Action {
/**
* Главное меню
@ -38,6 +57,14 @@ class ActionPhotoset extends Action {
$this->oUserCurrent=$this->User_GetUserCurrent();
$this->SetDefaultEvent('add');
$this->Viewer_AddHtmlTitle($this->Lang_Get('topic_photoset_title'));
/**
* Загружаем в шаблон JS текстовки
*/
$this->Lang_AddLangJs(array(
'topic_photoset_photo_delete','topic_photoset_mark_as_preview','topic_photoset_photo_delete_confirm','topic_photoset_mark_as_preview',
'topic_photoset_is_preview'
));
}
/**
* Регистрируем евенты

View file

@ -129,8 +129,9 @@ $config['general']['reg']['activation'] = false; // использовать а
*/
$config['lang']['current'] = 'russian'; // текущий язык текстовок
$config['lang']['default'] = 'russian'; // язык, который будет использовать на сайте по умолчанию
$config['lang']['path'] = '___path.root.server___/templates/language'; // полный путь до языковых файлов
$config['lang']['path'] = '___path.root.server___/templates/language'; // полный путь до языковых файлов
$config['lang']['disable_blocks'] =false; // Использование многоуровневого языкового файла (по примеру конфига)
$config['lang']['load_to_js'] = array(); // Массив текстовок, которые необходимо прогружать на страницу в виде JS хеша, позволяет использовать текстовки внутри js
/**
* Настройки ACL(Access Control List список контроля доступа)
*/
@ -436,7 +437,6 @@ $config['head']['default']['js'] = array(
"___path.root.engine_lib___/external/MooTools_1.2/plugs/vlaCal-v2.1/jslib/vlaCal-v2.1.js",
"___path.root.engine_lib___/external/MooTools_1.2/plugs/iFrameFormRequest/iFrameFormRequest.js",
"___path.root.engine_lib___/external/prettify/prettify.js",
"___path.static.skin___/js/ls.lang.ru.js",
"___path.static.skin___/js/vote.js",
"___path.static.skin___/js/favourites.js",
"___path.static.skin___/js/questions.js",

View file

@ -41,6 +41,12 @@ class ModuleLang extends Module {
* @var array
*/
protected $aLangMsg=array();
/**
* Список текстовок для JS
*
* @var unknown_type
*/
protected $aLangMsgJs=array();
/**
* Инициализация модуля
@ -76,11 +82,44 @@ class ModuleLang extends Module {
if($this->sCurrentLang!=$this->sDefaultLang) $this->LoadLangFiles($this->sCurrentLang);
}
$this->LoadLangJs();
/**
* Загружаем в шаблон
*/
$this->Viewer_Assign('aLang',$this->aLangMsg);
}
/**
* Загружает из конфига текстовки для JS
*
*/
protected function LoadLangJs() {
$aMsg=Config::Get('lang.load_to_js');
if (is_array($aMsg) and count($aMsg)) {
$this->aLangMsgJs=$aMsg;
}
}
/**
* Прогружает в шаблон текстовки в виде JS
*
*/
protected function AssignToJs() {
$aLangMsg=array();
foreach ($this->aLangMsgJs as $sName) {
$aLangMsg[$sName]=$this->Get($sName,array(),false);
}
$this->Viewer_Assign('aLangJs',$aLangMsg);
}
/**
* Добавляет текстовку к JS
*
* @param unknown_type $aKeys
*/
public function AddLangJs($aKeys) {
if (!is_array($aKeys)) {
$aKeys=array($aKeys);
}
$this->aLangMsgJs=array_merge($this->aLangMsgJs,$aKeys);
}
/**
* Загружает текстовки из языковых файлов
*
@ -185,7 +224,7 @@ class ModuleLang extends Module {
* @param array $aReplace
* @return string
*/
public function Get($sName,$aReplace=array()) {
public function Get($sName,$aReplace=array(),$bDelete=true) {
if (!Config::Get('lang.disable_blocks') && strpos($sName, '.')) {
$sLang = &$this->aLangMsg;
$aKeys = explode('.', $sName);
@ -211,7 +250,7 @@ class ModuleLang extends Module {
$sLang=strtr($sLang,$aReplacePairs);
}
if(Config::Get('module.lang.delete_undefined') and is_string($sLang)) {
if(Config::Get('module.lang.delete_undefined') and $bDelete and is_string($sLang)) {
$sLang=preg_replace("/\%\%[\S]+\%\%/U",'',$sLang);
}
return $sLang;
@ -255,6 +294,10 @@ class ModuleLang extends Module {
*
*/
public function Shutdown() {
/**
* Делаем выгрузку необходимых текстовок в шаблон в виде js
*/
$this->AssignToJs();
}
}
?>

View file

@ -0,0 +1,44 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
/**
* Позволяет транслировать данные в json
*
* @param unknown_type $params
* @param unknown_type $smarty
* @return unknown
*/
function smarty_function_json($params, &$smarty)
{
if (!array_key_exists('var', $params)) {
$smarty->trigger_error("json: missing 'var' parameter");
return;
}
$var = $params['var'];
$_contents = json_encode($var);
if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $_contents);
} else {
return $_contents;
}
}
?>

View file

@ -307,6 +307,7 @@ return array(
'topic_photoset_create' => 'Создание фотосета',
'topic_photoset_edit' => 'Редактирование фотосета',
'topic_photoset_upload_title' => 'Загрузка изображений',
'topic_photoset_upload_choose' => 'Загрузить фото',
'topic_photoset_upload_rules' => 'Доступна загрузка изображений в формат JPG, PNG, GIF<br />Размер изображений не должен превышать %%SIZE%% Kб<br />Максимальное число загружаемых изображений: %%COUNT%%',
'topic_photoset_choose_image' => 'Выберите изображение для загрузки',
'topic_photoset_is_preview' => 'Отмечено как превью к топику',
@ -318,13 +319,16 @@ return array(
'topic_photoset_title' => 'Фотосет',
'topic_photoset_photo_deleted' => 'Фото удалено',
'topic_photoset_photo_deleted_error_last' => 'Нельзя удалить последню фотографию',
'topic_photoset_photo_delete' => 'Удалить',
'topic_photoset_photo_delete_confirm' => 'Удалить фото?',
'topic_photoset_photo_added' => 'Фото добавлено',
'topic_photoset_error_too_much_photos' => 'Топик может содержать не более %%MAX%% фото',
'topic_photoset_title_edit' => 'Редактирование фотосета',
'topic_photoset_title_create' => 'Создание фотосета',
'topic_photoset_error_bad_filesize' => 'Размер фото должен быть не более %%MAX%% Кб',
'topic_photoset_photos' => 'фото',
/**
* Комментарии
*/
@ -535,6 +539,7 @@ return array(
'user_field_update' => 'Изменить',
'user_field_updated' => 'Поле успешно изменено',
'user_field_delete' => 'Удалить',
'user_field_delete_confirm' => 'Удалить поле?',
'user_field_deleted' => 'Поле удалено',
'userfield_form_name' => 'Имя',
'userfield_form_title' => 'Заголовок',

View file

@ -158,7 +158,7 @@ tinyMCE.init({
<div class="topic-photo-upload-rules">
{$aLang.topic_photoset_upload_rules|ls_lang:"SIZE%%`$oConfig->get('module.topic.photoset.photo_max_size')`":"COUNT%%`$oConfig->get('module.topic.photoset.count_photos_max')`"}
</div>
<a href="javascript:ls.photoset.showForm()">Загрузить фото</a>
<a href="javascript:ls.photoset.showForm()">{$aLang.topic_photoset_upload_choose}</a>
<input type="hidden" name="topic_main_photo" id="topic_main_photo" value="{$_aRequest.topic_main_photo}" />
<ul id="swfu_images">
{if count($aPhotos)}
@ -169,7 +169,7 @@ tinyMCE.init({
<li id="photo_{$oPhoto->getId()}" {if $bIsMainPhoto}class="marked-as-preview"{/if}>
<img src="{$oPhoto->getWebPath('100crop')}" alt="image" />
<textarea onBlur="ls.photoset.setPreviewDescription({$oPhoto->getId()}, this.value)">{$oPhoto->getDescription()}</textarea><br />
<a href="javascript:ls.photoset.deletePhoto({$oPhoto->getId()})" class="image-delete">Удалить</a>
<a href="javascript:ls.photoset.deletePhoto({$oPhoto->getId()})" class="image-delete">{$aLang.topic_photoset_photo_delete}</a>
<span id="photo_preview_state_{$oPhoto->getId()}" class="photo-preview-state">
{if $bIsMainPhoto}
{$aLang.topic_photoset_is_preview}

View file

@ -20,37 +20,36 @@
{/if}
<script>
var DIR_WEB_ROOT = '{cfg name="path.root.web"}';
var DIR_STATIC_SKIN = '{cfg name="path.static.skin"}';
var LIVESTREET_SECURITY_KEY = '{$LIVESTREET_SECURITY_KEY}';
var BLOG_USE_TINYMCE='{cfg name="view.tinymce"}';
var LANG_JOIN = '{$aLang.blog_join}';
var LANG_LEAVE = '{$aLang.blog_leave}';
var LANG_DELETE = '{$aLang.blog_delete}';
var LANG_POLL_ERROR = '{$aLang.topic_question_create_answers_error_max}';
var DIR_WEB_ROOT = '{cfg name="path.root.web"}';
var DIR_STATIC_SKIN = '{cfg name="path.static.skin"}';
var LIVESTREET_SECURITY_KEY = '{$LIVESTREET_SECURITY_KEY}';
var BLOG_USE_TINYMCE = '{cfg name="view.tinymce"}';
var IMG_PATH_LOADER = DIR_STATIC_SKIN + '/images/loader.gif';
var TINYMCE_LANG='en';
{if $oConfig->GetValue('lang.current')=='russian'}
TINYMCE_LANG='ru';
{/if}
var aRouter = new Array();
{foreach from=$aRouter key=sPage item=sPath}
aRouter['{$sPage}'] = '{$sPath}';
{/foreach}
var LANG_JOIN = '{$aLang.blog_join}';
var LANG_LEAVE = '{$aLang.blog_leave}';
var LANG_DELETE = '{$aLang.blog_delete}';
var LANG_POLL_ERROR = '{$aLang.topic_question_create_answers_error_max}';
var IMG_PATH_LOADER = DIR_STATIC_SKIN + '/images/loader.gif';
var TINYMCE_LANG='en';
{if $oConfig->GetValue('lang.current')=='russian'}
TINYMCE_LANG='ru';
{/if}
var aRouter = new Array();
{foreach from=$aRouter key=sPage item=sPath}
aRouter['{$sPage}'] = '{$sPath}';
{/foreach}
</script>
{$aHtmlHeadFiles.js}
{literal}
<script language="JavaScript" type="text/javascript">
var tinyMCE=false;
var tinyMCE=false;
ls.lang.load({json var=$aLangJs});
</script>
{/literal}
{hook run='html_head_end'}
</head>

View file

@ -1,7 +0,0 @@
var lsLang = new Array();
lsLang['photoset_mark_as_preview'] = 'Отметить как превью';
lsLang['photoset_preview'] = 'Превью';
lsLang['photoset_delete'] = 'Удалить';
lsLang['photoset_confirm_delete'] = 'Удалить фото?';
lsLang['userfield_confirm_delete'] = 'Удалить поле?';

View file

@ -38,6 +38,41 @@ ls.msg = (function ($) {
}).call(ls.msg || {},jQuery);
/**
* Доступ к языковым текстовкам (предварительно должны быть прогружены в шаблон)
*/
ls.lang = (function ($) {
/**
* Набор текстовок
*/
this.msgs = {};
/**
* Загрузка текстовок
*/
this.load = function(msgs){
this.msgs=msgs;
};
/**
* Отображение сообщения об ошибке
*/
this.get = function(name,replace){
if (this.msgs[name]) {
var value=this.msgs[name];
if (replace) {
$.each(replace,function(k,v){
value=value.replace(new RegExp('%%'+k+'%%','g'),v);
});
}
return value;
}
return '';
};
return this;
}).call(ls.lang || {},jQuery);
/**
* Вспомогательные функции

View file

@ -10,8 +10,8 @@ ls.photoset =( function ($) {
if (!response.bStateError) {
template = '<li id="photo_'+response.id+'"><a href="#"><img src="'+response.file+'" alt="image" /></a>'
+'<textarea onBlur="ls.photoset.setPreviewDescription('+response.id+', this.value)"></textarea><br />'
+'<a href="javascript:ls.photoset.deletePhoto('+response.id+')" class="image-delete">'+lsLang['photoset_delete']+'</a>'
+'<span id="photo_preview_state_'+response.id+'" class="photo-preview-state"><a href="javascript:ls.photoset.setPreview('+response.id+')" class="mark-as-preview">'+lsLang['photoset_mark_as_preview']+'</a></span></li>';
+'<a href="javascript:ls.photoset.deletePhoto('+response.id+')" class="image-delete">'+ls.lang.get('topic_photoset_photo_delete')+'</a>'
+'<span id="photo_preview_state_'+response.id+'" class="photo-preview-state"><a href="javascript:ls.photoset.setPreview('+response.id+')" class="mark-as-preview">'+ls.lang.get('topic_photoset_mark_as_preview')+'</a></span></li>';
$('#swfu_images').append(template);
ls.msg.notice(response.sMsgTitle,response.sMsg);
} else {
@ -22,7 +22,7 @@ ls.photoset =( function ($) {
this.deletePhoto = function(id)
{
if (!confirm(lsLang['photoset_confirm_delete'])) {return;}
if (!confirm(ls.lang.get('topic_photoset_photo_delete_confirm'))) {return;}
ls.ajax(aRouter['photoset']+'deleteimage', {'id':id}, function(response){
if (!response.bStateError) {
$('#photo_'+id).remove();
@ -40,10 +40,10 @@ ls.photoset =( function ($) {
$('.marked-as-preview').each(function (index, el) {
$(el).removeClass('marked-as-preview');
tmpId = $(el).attr('id').slice($(el).attr('id').lastIndexOf('_')+1);
$('#photo_preview_state_'+tmpId).html('<a href="javascript:ls.photoset.setDescription('+tmpId+')" class="mark-as-preview">'+lsLang['photoset_mark_as_preview']+'</a>');
$('#photo_preview_state_'+tmpId).html('<a href="javascript:ls.photoset.setDescription('+tmpId+')" class="mark-as-preview">'+ls.lang.get('topic_photoset_mark_as_preview')+'</a>');
});
$('#photo_'+id).addClass('marked-as-preview');
$('#photo_preview_state_'+id).html(lsLang['photoset_preview']);
$('#photo_preview_state_'+id).html(ls.lang.get('topic_photoset_is_preview'));
}
this.setPreviewDescription = function(id, text)

View file

@ -68,7 +68,7 @@ ls.userfield =( function ($) {
}
this.deleteUserfield = function(id) {
if (!confirm(lsLang['userfield_confirm_delete'])) {return;}
if (!confirm(ls.lang.get('user_field_delete_confirm'))) {return;}
ls.ajax(aRouter['admin']+'userfields', {'action':'delete', 'id':id}, function(data) {
if (!data.bStateError) {
$('#field_'+id).remove();

View file

@ -14,7 +14,6 @@ $config['head']['default']['js'] = array(
"___path.static.skin___/js/libs/jquery.jqplugin.1.0.2.min.js",
"___path.static.skin___/js/libs/jquery.cookie.js",
"___path.static.skin___/js/libs/jquery.serializejson.js",
"___path.static.skin___/js/ls.lang.ru.js",
"___path.static.skin___/js/main.js",
"___path.static.skin___/js/favourite.js",
"___path.static.skin___/js/blocks.js",

View file

@ -196,7 +196,7 @@ tinyMCE.init({
<div class="topic-photo-upload-rules">
{$aLang.topic_photoset_upload_rules|ls_lang:"SIZE%%`$oConfig->get('module.topic.photoset.photo_max_size')`":"COUNT%%`$oConfig->get('module.topic.photoset.count_photos_max')`"}
</div>
<a href="javascript:photosetShowUploadForm()">Загрузить фото</a>
<a href="javascript:photosetShowUploadForm()">{$aLang.topic_photoset_upload_choose}</a>
<input type="hidden" name="topic_main_photo" id="topic_main_photo" value="{$_aRequest.topic_main_photo}" />
<ul id="swfu_images">
{if count($aPhotos)}
@ -207,7 +207,7 @@ tinyMCE.init({
<li id="photo_{$oPhoto->getId()}" {if $bIsMainPhoto}class="marked-as-preview"{/if}>
<img src="{$oPhoto->getWebPath('100crop')}" alt="image" />
<textarea onBlur="topicImageSetDescription({$oPhoto->getId()}, this.value)">{$oPhoto->getDescription()}</textarea><br />
<a href="javascript:deleteTopicImage({$oPhoto->getId()})" class="image-delete">Удалить</a>
<a href="javascript:deleteTopicImage({$oPhoto->getId()})" class="image-delete">{$aLang.topic_photoset_photo_delete}</a>
<span class="photo-preview-state">
{if $bIsMainPhoto}
{$aLang.topic_photoset_is_preview}

View file

@ -50,22 +50,21 @@
{$aHtmlHeadFiles.js}
{literal}
<script language="JavaScript" type="text/javascript">
var tinyMCE=false;
lsLang.load({json var=$aLangJs});
var msgErrorBox=new Roar({
position: 'upperRight',
className: 'roar-error',
margin: {x: 30, y: 10}
margin: { x: 30, y: 10 }
});
var msgNoticeBox=new Roar({
position: 'upperRight',
className: 'roar-notice',
margin: {x: 30, y: 10}
margin: { x: 30, y: 10 }
});
</script>
{/literal}
{if $oUserCurrent && $oConfig->GetValue('module.talk.reload')}
{literal}

View file

@ -1,7 +0,0 @@
var lsLang = new Array();
lsLang['photoset_mark_as_preview'] = 'Отметить как превью';
lsLang['photoset_preview'] = 'Превью';
lsLang['photoset_delete'] = 'Удалить';
lsLang['photoset_confirm_delete'] = 'Удалить фото?';
lsLang['userfield_confirm_delete'] = 'Удалить поле?';

View file

@ -1,3 +1,39 @@
var lsLangClass = new Class({
initialize: function(){
this.msgs = {};
},
/**
* Загрузка текстовок
*/
load: function(msgs) {
this.msgs=msgs;
},
/**
* Отображение сообщения об ошибке
*/
get: function(name,replace){
if (this.msgs[name]) {
var value=this.msgs[name];
if (replace) {
(new Hash(replace)).each(function(v,k){
value=value.replace(new RegExp('%%'+k+'%%','g'),v);
});
}
return value;
}
return '';
}
});
var lsLang = new lsLangClass();
function ajaxTextPreview(textId,save,divPreview) {
var text;
if (BLOG_USE_TINYMCE && tinyMCE && (ed=tinyMCE.get(textId))) {
@ -128,8 +164,8 @@ function addTopicImage(response)
if (!response.bStateError) {
template = '<a href="#"><img src="'+response.file+'" alt="image" /></a>'
+'<textarea onBlur="topicImageSetDescription('+response.id+', this.value)"></textarea><br />'
+'<a href="javascript:deleteTopicImage('+response.id+')" class="image-delete">'+lsLang['delete']+'</a>'
+'<span class="photo-preview-state"><a href="javascript:setTopicMainPhoto('+response.id+')" class="mark-as-preview">'+lsLang['mark_as_preview']+'</a></span>';
+'<a href="javascript:deleteTopicImage('+response.id+')" class="image-delete">'+lsLang.get('topic_photoset_photo_delete')+'</a>'
+'<span class="photo-preview-state"><a href="javascript:setTopicMainPhoto('+response.id+')" class="mark-as-preview">'+lsLang.get('topic_photoset_mark_as_preview')+'</a></span>';
liElement= new Element('li', {'id':'photo_'+response.id,'html':template})
liElement.inject('swfu_images');
msgNoticeBox.alert(response.sMsgTitle,response.sMsg);
@ -141,7 +177,7 @@ function addTopicImage(response)
function deleteTopicImage(id)
{
if (!confirm(lsLang['userfield_confirm_delete'])) {return;}
if (!confirm(lsLang.get('topic_photoset_photo_delete_confirm'))) {return;}
new Request.JSON({
url: aRouter['photoset']+'deleteimage',
data: {'id':id, 'security_ls_key': LIVESTREET_SECURITY_KEY },
@ -161,10 +197,10 @@ function setTopicMainPhoto(id)
$('topic_main_photo').set('value', id);
$$('..marked-as-preview').each(function (el) {
el.removeClass('marked-as-preview');
el.getElement('span').set('html','<a href="javascript:setTopicMainPhoto('+el.get('id').slice(el.get('id').lastIndexOf('_')+1)+')" class="mark-as-preview">'+lsLang['mark_as_preview']+'</a>')
el.getElement('span').set('html','<a href="javascript:setTopicMainPhoto('+el.get('id').slice(el.get('id').lastIndexOf('_')+1)+')" class="mark-as-preview">'+lsLang.get('topic_photoset_mark_as_preview')+'</a>')
});
$('photo_'+id).addClass('marked-as-preview');
$('photo_'+id).getElement('span').set('html', lsLang['preview']);
$('photo_'+id).getElement('span').set('html', lsLang.get('topic_photoset_is_preview'));
}
function topicImageSetDescription(id, text)

View file

@ -89,7 +89,7 @@ function updateUserfield() {
}
function deleteUserfield(id) {
if (!confirm(lsLang['userfield_confirm_delete'])) {return;}
if (!confirm(lsLang.get('user_field_delete_confirm'))) {return;}
new Request.JSON({
url: aRouter['admin']+'userfields',
data: {'action':'delete', 'id':id, 'security_ls_key':LIVESTREET_SECURITY_KEY},

View file

@ -9,7 +9,6 @@ $config['head']['default']['js'] = array(
"___path.root.engine_lib___/external/MooTools_1.2/plugs/Autocompleter/Autocompleter.Request.js",
"___path.root.engine_lib___/external/MooTools_1.2/plugs/vlaCal-v2.1/jslib/vlaCal-v2.1.js",
"___path.root.engine_lib___/external/MooTools_1.2/plugs/iFrameFormRequest/iFrameFormRequest.js",
"___path.static.skin___/js/ls.lang.ru.js",
"___path.static.skin___/js/vote.js",
"___path.static.skin___/js/favourites.js",
"___path.static.skin___/js/questions.js",

View file

@ -195,7 +195,7 @@ tinyMCE.init({
<div class="topic-photo-upload-rules">
{$aLang.topic_photoset_upload_rules|ls_lang:"SIZE%%`$oConfig->get('module.topic.photoset.photo_max_size')`":"COUNT%%`$oConfig->get('module.topic.photoset.count_photos_max')`"}
</div>
<a href="javascript:photosetShowUploadForm()">Загрузить фото</a>
<a href="javascript:photosetShowUploadForm()">{$aLang.topic_photoset_upload_choose}</a>
<input type="hidden" name="topic_main_photo" id="topic_main_photo" value="{$_aRequest.topic_main_photo}"/>
<ul id="swfu_images">
{if count($aPhotos)}
@ -206,7 +206,7 @@ tinyMCE.init({
<li id="photo_{$oPhoto->getId()}" {if $bIsMainPhoto}class="marked-as-preview"{/if}>
<img src="{$oPhoto->getWebPath('100crop')}" alt="image" />
<textarea onBlur="topicImageSetDescription({$oPhoto->getId()}, this.value)">{$oPhoto->getDescription()}</textarea><br />
<a href="javascript:deleteTopicImage({$oPhoto->getId()})" class="image-delete">Удалить</a>
<a href="javascript:deleteTopicImage({$oPhoto->getId()})" class="image-delete">{$aLang.topic_photoset_photo_delete}</a>
<span class="photo-preview-state">
{if $bIsMainPhoto}
{$aLang.topic_photoset_is_preview}

View file

@ -1,7 +0,0 @@
var lsLang = new Array();
lsLang['photoset_mark_as_preview'] = 'Отметить как превью';
lsLang['photoset_preview'] = 'Превью';
lsLang['photoset_delete'] = 'Удалить';
lsLang['photoset_confirm_delete'] = 'Удалить фото?';
lsLang['userfield_confirm_delete'] = 'Удалить поле?';

View file

@ -1,3 +1,37 @@
var lsLangClass = new Class({
initialize: function(){
this.msgs = {};
},
/**
* Загрузка текстовок
*/
load: function(msgs) {
this.msgs=msgs;
},
/**
* Отображение сообщения об ошибке
*/
get: function(name,replace){
if (this.msgs[name]) {
var value=this.msgs[name];
if (replace) {
(new Hash(replace)).each(function(v,k){
value=value.replace(new RegExp('%%'+k+'%%','g'),v);
});
}
return value;
}
return '';
}
});
var lsLang = new lsLangClass();
function ajaxTextPreview(textId,save,divPreview) {
var text;
if (BLOG_USE_TINYMCE && tinyMCE && (ed=tinyMCE.get(textId))) {
@ -141,8 +175,8 @@ function addTopicImage(response)
if (!response.bStateError) {
template = '<a href="#"><img src="'+response.file+'" alt="image" /></a>'
+'<textarea onBlur="topicImageSetDescription('+response.id+', this.value)"></textarea><br />'
+'<a href="javascript:deleteTopicImage('+response.id+')" class="image-delete">Удалить</a>'
+'<span class="photo-preview-state"><a href="javascript:setTopicMainPhoto('+response.id+')" class="mark-as-preview">Отметить как превью</a></span>';
+'<a href="javascript:deleteTopicImage('+response.id+')" class="image-delete">'+lsLang.get('topic_photoset_photo_delete')+'</a>'
+'<span class="photo-preview-state"><a href="javascript:setTopicMainPhoto('+response.id+')" class="mark-as-preview">'+lsLang.get('topic_photoset_mark_as_preview')+'</a></span>';
liElement= new Element('li', {'id':'photo_'+response.id,'html':template})
liElement.inject('swfu_images');
msgNoticeBox.alert(response.sMsgTitle,response.sMsg);
@ -154,7 +188,7 @@ function addTopicImage(response)
function deleteTopicImage(id)
{
if (!confirm(lsLang['photoset_confirm_delete'])) {return;}
if (!confirm(lsLang.get('topic_photoset_photo_delete_confirm'))) {return;}
new Request.JSON({
url: aRouter['photoset']+'deleteimage',
data: {'id':id, 'security_ls_key': LIVESTREET_SECURITY_KEY },
@ -174,10 +208,10 @@ function setTopicMainPhoto(id)
$('topic_main_photo').set('value', id);
$$('..marked-as-preview').each(function (el) {
el.removeClass('marked-as-preview');
el.getElement('span').set('html','<a href="javascript:setTopicMainPhoto('+el.get('id').slice(el.get('id').lastIndexOf('_')+1)+')" class="mark-as-preview">Отметить как превью</a>')
el.getElement('span').set('html','<a href="javascript:setTopicMainPhoto('+el.get('id').slice(el.get('id').lastIndexOf('_')+1)+')" class="mark-as-preview">'+lsLang.get('topic_photoset_mark_as_preview')+'</a>')
});
$('photo_'+id).addClass('marked-as-preview');
$('photo_'+id).getElement('span').set('html', 'Превью');
$('photo_'+id).getElement('span').set('html', lsLang.get('topic_photoset_is_preview'));
}
function topicImageSetDescription(id, text)

View file

@ -89,7 +89,7 @@ function updateUserfield() {
}
function deleteUserfield(id) {
if (!confirm(lsLang['userfield_confirm_delete'])) {return;}
if (!confirm(lsLang.get('user_field_delete_confirm'))) {return;}
new Request.JSON({
url: aRouter['admin']+'userfields',
data: {'action':'delete', 'id':id, 'security_ls_key':LIVESTREET_SECURITY_KEY},