이모티콘 경로 문제 수정

짧은 주소 사용시 https://~/mid/modules/path가 되지 않도록 수정
이모티콘 추가시 '추가되었다'는 메세지 띄움
This commit is contained in:
conory 2020-03-03 21:49:37 +09:00
parent 64e1258f0c
commit a721429f8b
5 changed files with 45 additions and 31 deletions

View file

@ -267,6 +267,7 @@ $lang->success_sended = 'Sent successfully.';
$lang->success_reset = 'Reset successfully.';
$lang->success_leaved = 'Your account has been closed successfully.';
$lang->success_saved = 'Saved successfully.';
$lang->success_added = 'Added successfully.';
$lang->fail_to_registed = 'Failed to register.';
$lang->fail_to_update = 'Fail to update.';
$lang->fail_to_delete = 'Failed to delete.';

View file

@ -269,6 +269,7 @@ $lang->success_sended = '발송했습니다.';
$lang->success_reset = '초기화했습니다.';
$lang->success_leaved = '탈퇴했습니다.';
$lang->success_saved = '저장했습니다.';
$lang->success_added = '추가했습니다.';
$lang->fail_to_registed = '등록하지 못했습니다.';
$lang->fail_to_update = '수정하지 못했습니다.';
$lang->fail_to_delete = '삭제 실패했습니다.';

View file

@ -19,7 +19,7 @@ class emoticon extends EditorHandler
{
$this->editor_sequence = $editor_sequence;
$this->component_path = $component_path;
$this->emoticon_path = sprintf('%s%s/images',preg_replace('/^\.\//i','',$this->component_path),'tpl','images');
$this->emoticon_path = $this->component_path . 'tpl/images';
}
/**
@ -28,39 +28,47 @@ class emoticon extends EditorHandler
function getEmoticonList()
{
$emoticon = Context::get('emoticon');
if(!$emoticon || !preg_match("/^([a-z0-9\_]+)$/i",$emoticon)) return new BaseObject(-1,'msg_invalid_request');
$list = $this->getEmoticons($emoticon);
$this->add('emoticons', $list);
if(!$emoticon || !preg_match('/^[a-z0-9\_]+$/i', $emoticon))
{
return new BaseObject(-1, 'msg_invalid_request');
}
$this->add('emoticons', $this->getEmoticons($emoticon));
}
/**
* @brief Likely to be recursively emoticons will search all the files to a subdirectory. 8000 gaekkajineun ran tests whether the stack and raise beef pro-overs and Unsure. (06/09/2007, Benny)
*/
function getEmoticons($path)
function getEmoticons($emoticon)
{
$emoticon_path = sprintf("%s/%s", $this->emoticon_path, $path);
$output = array();
$oDir = dir($emoticon_path);
while($file = $oDir->read())
$emoticon_path = sprintf('%s/%s', $this->emoticon_path, $emoticon);
$emoticon_url = RX_BASEURL . preg_replace('@^\./@', '', $emoticon_path) . '/';
if(!$emoticon_files = Rhymix\Framework\Storage::readDirectory($emoticon_path))
{
if(substr($file,0,1)=='.') continue;
if(preg_match('/\.(jpg|jpeg|gif|png)$/i',$file)) {
$svg = null;
$filename = sprintf("%s/%s", $path, str_replace($this->emoticon_path,'',$file));
list($width, $height, $type, $attr) = getimagesize($emoticon_path . '/'. $file);
if(file_exists (($emoticon_path . '/svg/'. substr($file, 0, -4) . '.svg'))) {
$svg = sprintf("%s/svg/%s", $path, str_replace($this->emoticon_path,'',substr($file, 0, -4) . '.svg'));
}
$output[] = array('filename' => $filename, 'width' => $width, 'height' => $height, 'svg' => $svg, 'alt' => substr($file, 0, -4));
}
return array();
}
$oDir->close();
if(count($output)) asort($output);
$output = array();
foreach($emoticon_files as $file)
{
if(!preg_match('/\.(jpg|jpeg|gif|png)$/i', $file))
{
continue;
}
$file_name = basename($file);
list($file_width, $file_height) = getimagesize($file);
$svg_name = preg_replace('@\.[^.]+$@', '', $file_name) . '.svg';
$output[] = array(
'url' => $emoticon_url . $file_name,
'width' => $file_width,
'height' => file_height,
'svg' => file_exists(sprintf('%s/svg/%s', $emoticon_path, $svg_name)) ? ($emoticon_url . 'svg/' . $svg_name) : '',
'alt' => $file_name,
);
}
asort($output);
return $output;
}

View file

@ -1,6 +1,9 @@
<load target="popup.js" />
<load target="popup.less" />
{@Context::addMetaTag('viewport', 'width=device-width', FALSE);}
<script>
var lang_success_added = '{$lang->success_added}';
</script>
<div class="x_modal-header">
<h1>{$component_info->title}</h1>
</div>

View file

@ -23,17 +23,17 @@ function completeGetEmoticons(ret_obj) {
.width( parseInt(emoticons[i].width, 10))
.height(parseInt(emoticons[i].height, 10))
.attr({
'src': './modules/editor/components/emoticon/tpl/images/'+emoticons[i].filename,
'data-src': './modules/editor/components/emoticon/tpl/images/'+emoticons[i].filename,
'src': emoticons[i].url,
'data-src': emoticons[i].url,
'alt': emoticons[i].alt
});
if( emoticons[i].svg ) {
$img.attr({
'data-svg': './modules/editor/components/emoticon/tpl/images/'+emoticons[i].svg
'data-svg': emoticons[i].svg
});
if( typeof SVGRect !== "undefined" ) {
$img.attr({
'src': './modules/editor/components/emoticon/tpl/images/'+emoticons[i].svg
'src': emoticons[i].svg
});
}
}
@ -67,7 +67,8 @@ function insertEmoticon(obj) {
win.editorRelKeys[win.editorPrevSrl].pasteHTML(html);
if (is_popup) window.focus();
rhymix_alert(lang_success_added);
return false;
}