1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-21 02:08:17 +03:00

Поддержка тега <ls user="login"> для вставки пользователя в текст

This commit is contained in:
Mzhelskiy Maxim 2011-08-25 08:10:20 +00:00
parent 7e1c121780
commit 692c068554
24 changed files with 82 additions and 13 deletions

View file

@ -6,13 +6,13 @@ return array(
'cfgAllowTags' => array(
// вызов метода с параметрами
array(
array('cut','a', 'img', 'i', 'b', 'u', 's', 'video', 'em', 'strong', 'nobr', 'li', 'ol', 'ul', 'sup', 'abbr', 'sub', 'acronym', 'h4', 'h5', 'h6', 'br', 'hr', 'pre', 'code', 'object', 'param', 'embed', 'blockquote', 'iframe'),
array('ls','cut','a', 'img', 'i', 'b', 'u', 's', 'video', 'em', 'strong', 'nobr', 'li', 'ol', 'ul', 'sup', 'abbr', 'sub', 'acronym', 'h4', 'h5', 'h6', 'br', 'hr', 'pre', 'code', 'object', 'param', 'embed', 'blockquote', 'iframe'),
),
),
// Коротие теги типа
'cfgSetTagShort' => array(
array(
array('br','img', 'hr', 'cut')
array('br','img', 'hr', 'cut','ls')
),
),
// Преформатированные теги
@ -58,10 +58,14 @@ return array(
'abbr',
array('title')
),
array(
array(
'iframe',
array('width' => '#int', 'height' => '#int', 'src' => array('#domain'=>array('youtube.com','rutube.ru','vimeo.com')))
),
array(
'ls',
array('user'=>'#text')
),
),
// Параметры тегов являющиеся обязательными
'cfgSetTagParamsRequired' => array(
@ -148,7 +152,12 @@ return array(
array('h4','h5','h6','ol','ul','blockquote','pre')
)
),
'cfgSetTagCallbackFull' => array(
array(
'ls',
array('_this_','CallbackTagLs'),
),
),
),
// настройки для обработки текста в результатах поиска

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -22,4 +22,5 @@
.markItUp .editor-clean a { background-image:url(images/clean.png); }
.markItUp .editor-preview a { background-image:url(images/preview.png); }
.markItUp .editor-cut a { background-image:url(images/cut.png); }
.markItUp .editor-video a { background-image:url(images/video.png); }
.markItUp .editor-video a { background-image:url(images/video.png); }
.markItUp .editor-user a { background-image:url(images/user.png); }

View file

@ -64,6 +64,11 @@ class ModuleText extends Module {
if (is_array($aConfig)) {
foreach ($aConfig as $sMethod => $aExec) {
foreach ($aExec as $aParams) {
if (in_array(strtolower($sMethod),array_map("strtolower",array('cfgSetTagCallbackFull','cfgSetTagCallback')))) {
if (isset($aParams[1][0]) and $aParams[1][0]=='_this_') {
$aParams[1][0]=$this;
}
}
call_user_func_array(array($this->oJevix,$sMethod), $aParams);
}
}
@ -209,5 +214,22 @@ class ModuleText extends Module {
return array($sTextShort,$sTextNew,$sTextCut ? htmlspecialchars($sTextCut) : null);
}
/**
* Обработка тега <ls> в тексте
*
* @param unknown_type $sTag
* @param unknown_type $aParams
* @return unknown
*/
public function CallbackTagLs($sTag,$aParams) {
$sText='';
if (isset($aParams['user'])) {
if ($oUser=$this->User_getUserByLogin($aParams['user'])) {
$sText.="<a href=\"{$oUser->getUserWebPath()}\" class=\"ls-user\">{$oUser->getLogin()}</a> ";
}
}
return $sText;
}
}
?>

View file

@ -654,6 +654,8 @@ return array(
'panel_title_h5' => 'H5',
'panel_title_h6' => 'H6',
'panel_clear_tags' => 'очистить от тегов',
'panel_user' => 'вставить пользователя',
'panel_user_promt' => 'Введите логин пользователя',
/**
* Блоки

View file

@ -43,7 +43,7 @@ tinyMCE.init({
{include file='window_load_img.tpl' sToLoad='topic_text'}
<script type="text/javascript">
jQuery(document).ready(function($){
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt"});
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt,panel_user,panel_user_promt"});
// Подключаем редактор
$('#topic_text').markItUp(getMarkitupSettings());
});

View file

@ -42,7 +42,7 @@ tinyMCE.init({
{include file='window_load_img.tpl' sToLoad='topic_text'}
<script type="text/javascript">
jQuery(document).ready(function($){
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt"});
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt,panel_user,panel_user_promt"});
// Подключаем редактор
$('#topic_text').markItUp(getMarkitupSettings());
});

View file

@ -63,7 +63,7 @@
/* Misc */
.user { padding-left: 12px; background: url(../images/user.png) no-repeat 0 2px; color: #555; }
.user, .ls-user { padding-left: 12px; background: url(../images/user.png) no-repeat 0 2px; color: #555; }
.user.inactive { color: #888; }
.center { width: 300px; margin: 0 auto; }

View file

@ -35,6 +35,7 @@ function getMarkitupSettings() {
{name: ls.lang.get('panel_image'), className:'editor-image', replaceWith:'<img src="[!['+ls.lang.get('panel_image_promt')+':!:http://]!]" />' },
{name: ls.lang.get('panel_video'), className:'editor-video', replaceWith:'<video>[!['+ls.lang.get('panel_video_promt')+':!:http://]!]</video>' },
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
{separator:'---------------' },
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
{name: ls.lang.get('panel_cut'), className:'editor-cut', replaceWith: function(markitup) { if (markitup.selection) return '<cut name="'+markitup.selection+'">'; else return '<cut>' }}

View file

@ -116,7 +116,7 @@ tinyMCE.init({
<p>
<label for="topic_text">{$aLang.topic_create_text}{if !$oConfig->GetValue('view.tinymce')} ({$aLang.topic_create_text_notice}){/if}:</label>
{if !$oConfig->GetValue('view.tinymce')}
<div class="panel_form">
<div class="panel-form">
{hook run='form_add_topic_panel_begin'}
<select onchange="lsPanel.putTagAround('topic_text',this.value); this.selectedIndex=0; return false;">
<option value="">{$aLang.panel_title}</option>
@ -135,6 +135,7 @@ tinyMCE.init({
<a href="#" onclick="lsPanel.putTagAround('topic_text','s'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/strikethrough.png" title="{$aLang.panel_s}"></a>
&nbsp;
<a href="#" onclick="lsPanel.putTagUrl('topic_text','{$aLang.panel_url_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/link.png" title="{$aLang.panel_url}"></a>
<a href="#" onclick="lsPanel.putTagUser('topic_text','{$aLang.panel_user_promt}'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/user.png" title="{$aLang.panel_user}" /></a>
<a href="#" onclick="lsPanel.putQuote('topic_text'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/quote.png" title="{$aLang.panel_quote}"></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','code'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/code.png" title="{$aLang.panel_code}"></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','video'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/video.png" title="{$aLang.panel_video}"></a>

View file

@ -112,6 +112,7 @@ tinyMCE.init({
<a href="#" onclick="lsPanel.putTagAround('topic_text','s'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/strikethrough.png" title="{$aLang.panel_s}" /></a>
&nbsp;
<a href="#" onclick="lsPanel.putTagUrl('topic_text','{$aLang.panel_url_promt}'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/link.png" title="{$aLang.panel_url}" /></a>
<a href="#" onclick="lsPanel.putTagUser('topic_text','{$aLang.panel_user_promt}'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/user.png" title="{$aLang.panel_user}" /></a>
<a href="#" onclick="lsPanel.putQuote('topic_text'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/quote.png" title="{$aLang.panel_quote}" /></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','code'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/code.png" title="{$aLang.panel_code}" /></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','video'); return false;"><img src="{cfg name='path.static.skin'}/images/panel/video.png" title="{$aLang.panel_video}" /></a>

View file

@ -136,7 +136,7 @@ p { margin-bottom: 18px; }
/* Misc */
.user { padding-left: 12px; background: url(../images/user.png) no-repeat 0 2px; color: #555; }
.user, .ls-user { padding-left: 12px; background: url(../images/user.png) no-repeat 0 2px; color: #555; }
.user.inactive { color: #888; }
.center { width: 300px; margin: 0 auto; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -56,6 +56,18 @@ var lsPanelClass = new Class({
}
},
putTagUser: function(obj,sPromt) {
obj=$(obj);
var sel=obj.getSelectedText();
if (sel) {
this.putText(obj,'<ls user="'+sel+'"/>');
} else {
if (text=prompt(sPromt,'')) {
this.putText(obj,'<ls user="'+text+'"/>');
}
}
},
putQuote: function(obj) {
obj=$(obj);
selText=this.getSelectedText();

View file

@ -42,7 +42,7 @@ tinyMCE.init({
{include file='window_load_img.tpl' sToLoad='topic_text'}
<script type="text/javascript">
jQuery(document).ready(function($){
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt"});
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt,panel_user,panel_user_promt"});
// Подключаем редактор
$('#topic_text').markItUp(getMarkitupSettings());
});

View file

@ -42,7 +42,7 @@
{include file='window_load_img.tpl' sToLoad='topic_text'}
<script type="text/javascript">
jQuery(document).ready(function($){
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt"});
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt,panel_user,panel_user_promt"});
// Подключаем редактор
$('#topic_text').markItUp(getMarkitupSettings());
});

View file

@ -67,6 +67,7 @@
/* Misc */
.user { padding-left: 12px; background: url(../images/icons.gif) no-repeat 0 -107px; color: #555; text-decoration: none;}
.ls-user { padding-left: 12px; background: url(../images/icons.gif) no-repeat 0 -105px; color: #999999; text-decoration: none; font-size: 14px; font-weight: bold;}
.user.inactive { color: #888; }
.padding { padding: 10px 20px; }

View file

@ -33,6 +33,7 @@ function getMarkitupSettings() {
{name: ls.lang.get('panel_image'), className:'editor-image', replaceWith:'<img src="[!['+ls.lang.get('panel_image_promt')+':!:http://]!]" />' },
{name: ls.lang.get('panel_video'), className:'editor-video', replaceWith:'<video>[!['+ls.lang.get('panel_video_promt')+':!:http://]!]</video>' },
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
{separator:'---------------' },
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
{name: ls.lang.get('panel_cut'), className:'editor-cut', replaceWith: function(markitup) { if (markitup.selection) return '<cut name="'+markitup.selection+'">'; else return '<cut>' }}
@ -55,6 +56,7 @@ function getMarkitupCommentSettings() {
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { $('#form_upload_img').jqmShow(); } },
{name: ls.lang.get('panel_image'), className:'editor-image', replaceWith:'<img src="[!['+ls.lang.get('panel_image_promt')+':!:http://]!]" />' },
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
{separator:'---------------' },
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }
]

View file

@ -134,6 +134,7 @@ tinyMCE.init({
<a href="#" onclick="lsPanel.putTagAround('topic_text','s'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/strikethrough.png" title="{$aLang.panel_s}"></a>
&nbsp;
<a href="#" onclick="lsPanel.putTagUrl('topic_text','{$aLang.panel_url_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/link.png" title="{$aLang.panel_url}"></a>
<a href="#" onclick="lsPanel.putTagUser('topic_text','{$aLang.panel_user_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/user.png" title="{$aLang.panel_user}" /></a>
<a href="#" onclick="lsPanel.putQuote('topic_text'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/quote.png" title="{$aLang.panel_quote}"></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','code'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/code.png" title="{$aLang.panel_code}"></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','video'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/video.png" title="{$aLang.panel_video}"></a>

View file

@ -111,6 +111,7 @@ tinyMCE.init({
<a href="#" onclick="lsPanel.putTagAround('topic_text','s'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/strikethrough.png" title="{$aLang.panel_s}"></a>
&nbsp;
<a href="#" onclick="lsPanel.putTagUrl('topic_text','{$aLang.panel_url_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/link.png" title="{$aLang.panel_url}"></a>
<a href="#" onclick="lsPanel.putTagUser('topic_text','{$aLang.panel_user_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/user.png" title="{$aLang.panel_user}" /></a>
<a href="#" onclick="lsPanel.putQuote('topic_text'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/quote.png" title="{$aLang.panel_quote}"></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','code'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/code.png" title="{$aLang.panel_code}"></a>
<a href="#" onclick="lsPanel.putTagAround('topic_text','video'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/video.png" title="{$aLang.panel_video}"></a>

View file

@ -85,6 +85,7 @@
<a href="#" onclick="lsPanel.putTagAround('form_comment_text','s'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/strikethrough.png" title="{$aLang.panel_s}"></a>
&nbsp;
<a href="#" onclick="lsPanel.putTagUrl('form_comment_text','{$aLang.panel_url_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/link.png" title="{$aLang.panel_url}"></a>
<a href="#" onclick="lsPanel.putTagUser('form_comment_text','{$aLang.panel_user_promt}'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/user.png" title="{$aLang.panel_user}" /></a>
<a href="#" onclick="lsPanel.putQuote('form_comment_text'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/quote.png" title="{$aLang.panel_quote}"></a>
<a href="#" onclick="lsPanel.putTagAround('form_comment_text','code'); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/code.png" title="{$aLang.panel_code}"></a>
{hook run='form_add_comment_panel_end'}

View file

@ -942,4 +942,6 @@ table.admin_page td { /* IE: */ border-left: expression(previousSibling == nul
box-shadow: 0 0 10px #ddd;
}
#photoset-upload-form p { margin-bottom: 10px; }
#photoset-upload-form .input-text { width: 262px; border: 1px solid #ccc; margin: 0; padding: 3px; font-family: Arial, sans-serif; font-size: 12px; }
#photoset-upload-form .input-text { width: 262px; border: 1px solid #ccc; margin: 0; padding: 3px; font-family: Arial, sans-serif; font-size: 12px; }
.ls-user { padding-right: 3px; color: #999; font-weight: bold; text-decoration: none; background: url(../images/icons.gif) no-repeat scroll 0 -105px; padding-left: 13px; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -56,6 +56,18 @@ var lsPanelClass = new Class({
}
},
putTagUser: function(obj,sPromt) {
obj=$(obj);
var sel=obj.getSelectedText();
if (sel) {
this.putText(obj,'<ls user="'+sel+'"/>');
} else {
if (text=prompt(sPromt,'')) {
this.putText(obj,'<ls user="'+text+'"/>');
}
}
},
putQuote: function(obj) {
obj=$(obj);
selText=this.getSelectedText();