Skip to content

Commit

Permalink
поддержка смайлов + разные мелочи
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzegit committed Mar 22, 2017
1 parent 614e55d commit ca2bd13
Show file tree
Hide file tree
Showing 59 changed files with 221 additions and 41 deletions.
9 changes: 4 additions & 5 deletions index.php
Expand Up @@ -7,13 +7,12 @@
// LICENSED BY GNU/GPL v2 //
// //
/******************************************************************************/
session_start();
session_start();

define('VALID_RUN', true);
define('VALID_RUN', true);

// Устанавливаем кодировку
header('Content-type:text/html; charset=utf-8');
header('X-Powered-By: InstantCMS 2');
// Устанавливаем кодировку
header('Content-type:text/html; charset=utf-8');

require_once 'bootstrap.php';

Expand Down
Binary file added static/smiles/angel.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/blush.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/bomb.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/bravo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/crazy.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/dance.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/devil.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/drink.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/eyes.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/glass.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/inlove.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/jokingly.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/kiss.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/kissed.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/kissing.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/laugh.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/macho.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/music.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/no.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/ok.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/pardon.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/pitchup.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/quiet.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/rofl.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/rose.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/smiles/sad.gif
Binary file added static/smiles/sick.gif
Binary file added static/smiles/smile.gif
Binary file added static/smiles/sorry.gif
Binary file added static/smiles/sos.gif
Binary file added static/smiles/stop.gif
Binary file added static/smiles/strong.gif
Binary file added static/smiles/think.gif
Binary file added static/smiles/thumbsup.gif
Binary file added static/smiles/tired.gif
Binary file added static/smiles/tongue.gif
Binary file added static/smiles/unknown.gif
Binary file added static/smiles/wassup.gif
Binary file added static/smiles/wink.gif
Binary file added static/smiles/wonder.gif
Binary file added static/smiles/yahoo.gif
4 changes: 2 additions & 2 deletions system/config/version.ini
@@ -1,5 +1,5 @@
[version]
major = 2
minor = 7
build = 1
date = 20170213
build = 2
date = 20170327
81 changes: 80 additions & 1 deletion system/controllers/typograph/frontend.php
Expand Up @@ -2,4 +2,83 @@

class typograph extends cmsFrontend {

}
private static $smiles;
private $smiles_dir = 'static/smiles/';

public function actionGetSmiles() {

return $this->cms_template->renderJSON(array(
'smiles' => $this->loadSmiles()->getSmiles()
));

}

public function replaceEmotionToSmile($text) {

$smiles_emotion = array(
' :) ' => 'smile',
' =) ' => 'smile',
':-)' => 'smile',
' :( ' => 'sad',
':-(' => 'sad',
';-)' => 'wink',
' ;) ' => 'wink',
' :D ' => 'laugh',
':-D' => 'laugh',
'=-0' => 'wonder',
':-0' => 'wonder',
':-P' => 'tongue'
);

foreach($smiles_emotion as $find => $tag){
$text = str_replace($find, ':'.$tag.':', $text);
}

$smiles = $this->loadSmiles()->getSmiles();

if($smiles){
foreach($smiles as $tag => $smile_path){
$text = str_replace(':'.$tag.':', ' <img src="'.$smile_path.'" alt="'.$tag.'" /> ', $text);
}
}

return $text;

}

private function loadSmiles() {

if(self::$smiles !== null){
return $this;
}

$cache = cmsCache::getInstance();
$cache_key = 'smiles';

if (false !== (self::$smiles = $cache->get($cache_key))){
return $this;
}

$pattern = $this->cms_config->root_path . $this->smiles_dir . '*.gif';

$files = glob($pattern);

if ($files) {
foreach ($files as $file) {
self::$smiles[pathinfo($file, PATHINFO_FILENAME)] = $this->cms_config->root. $this->smiles_dir . basename($file);
}
} else {
self::$smiles = array();
}

$cache->set($cache_key, self::$smiles, 86400);

return $this;

}

private function getSmiles() {
return self::$smiles;
}

}
12 changes: 11 additions & 1 deletion system/controllers/typograph/hooks/html_filter.php
Expand Up @@ -7,18 +7,28 @@ public function run($data){
$errors = null;
$is_auto_br = true;
$build_redirect_link = true;
$build_smiles = true;

if (is_array($data)){
$text = $data['text'];
$is_auto_br = $data['is_auto_br'];
if(isset($data['build_redirect_link'])){
$build_redirect_link = $data['build_redirect_link'];
}
if(isset($data['build_smiles'])){
$build_smiles = $data['build_smiles'];
}
} else {
$text = $data;
}

return $this->getJevix($is_auto_br, $build_redirect_link)->parse($text, $errors);
$text = $this->getJevix($is_auto_br, $build_redirect_link)->parse($text, $errors);

if($build_smiles){
$text = $this->replaceEmotionToSmile($text);
}

return $text;

}

Expand Down
4 changes: 4 additions & 0 deletions system/controllers/users/backend.php
Expand Up @@ -33,6 +33,10 @@ public function getBackendMenu(){
array(
'title' => LANG_USERS_CFG_MIGRATION,
'url' => href_to($this->root_url, 'migrations')
),
array(
'title' => LANG_USERS,
'url' => href_to('admin', 'users')
)
);
}
Expand Down
1 change: 1 addition & 0 deletions system/fields/html.php
Expand Up @@ -50,6 +50,7 @@ public function parse($value){
$value = cmsEventsManager::hook('html_filter', array(
'text' => $value,
'is_auto_br' => false,
'build_smiles' => $this->getOption('editor') == 'markitup', // пока что только так
'build_redirect_link' => (bool)$this->getOption('build_redirect_link')
));
}
Expand Down
12 changes: 10 additions & 2 deletions templates/default/controllers/admin/styles.css
Expand Up @@ -2241,7 +2241,7 @@ form .field .input_checkbox_list#countries_view label, form .field .input_checkb
padding-left: 10px;
}
}
@media screen and (max-width: 800px) {
@media screen and (max-width: 815px) {
table.layout td.sidebar,
table.layout-no-fit td.sidebar {
display: none;
Expand Down Expand Up @@ -2270,7 +2270,7 @@ form .field .input_checkbox_list#countries_view label, form .field .input_checkb
left: 10px;
}
#cp_header {
padding: 0;
padding: 0 5px;
}
}
@media screen and (max-width: 640px) {
Expand All @@ -2289,3 +2289,11 @@ form .field .input_checkbox_list#countries_view label, form .field .input_checkb
font-size: 0.95em;
}
}
@media screen and (max-width: 495px) {
#dashboard #chart select {
width: 185px;
}
#dashboard #chart .toolbar .pills-menu {
margin-left: 5px;
}
}
6 changes: 6 additions & 0 deletions templates/default/controllers/admin/users.tpl.php
Expand Up @@ -22,6 +22,12 @@
'onclick' => "return contentCancelFilter()"
));

$this->addToolButton(array(
'class' => 'settings',
'title' => LANG_CONFIG,
'href' => $this->href_to('controllers', array('edit', 'users'))
));

$this->addToolButton(array(
'class' => 'add',
'title' => LANG_CP_USER_ADD,
Expand Down
2 changes: 1 addition & 1 deletion templates/default/controllers/admin/users_filter.tpl.php
Expand Up @@ -6,7 +6,7 @@

<legend><?php echo LANG_FILTER; ?></legend>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<table cellpadding="2" cellspacing="0" border="0" width="100%">

<?php $index = 0; ?>
<?php foreach($fields as $field) { ?>
Expand Down
4 changes: 3 additions & 1 deletion templates/default/controllers/markitup/widget.tpl.php
@@ -1,5 +1,6 @@
<?php
$this->addJSFromContext('wysiwyg/markitup/sets/'.$options['set'].'/image_upload.js');
$this->addJSFromContext('wysiwyg/markitup/insert_smiles.js');
$this->addJSFromContext('wysiwyg/markitup/jquery.markitup.js');
$this->addJSFromContext('wysiwyg/markitup/sets/'.$options['set'].'/'.(isset($options['set_name']) ? $options['set_name'] : 'set').'.js');
$this->addCSSFromContext('wysiwyg/markitup/sets/'.$options['set'].'/style.css');
Expand All @@ -9,6 +10,7 @@
<textarea id="<?php echo $options['id']; ?>"
class="textarea"
name="<?php echo $field_id;?>"
data-smiles-url="<?php echo href_to('typograph', 'get_smiles'); ?>"
data-upload-url="<?php echo href_to('markitup', 'upload'); ?>"><?php echo $content; ?></textarea>

<script type="text/javascript">
Expand All @@ -17,4 +19,4 @@ class="textarea"
$("#<?php echo $options['id']; ?>").markItUp(mySettings);
}
});
</script>
</script>
10 changes: 10 additions & 0 deletions templates/default/css/theme-gui.css
Expand Up @@ -1958,6 +1958,16 @@ form .ft_parent a.add {
width: 100%;
box-sizing: border-box;
}
#pm_contact .smilepanel {
position: absolute;
bottom: 137px;
background: #FFF;
box-sizing: border-box;
width: 80%;
right: 0;
border-top: 1px solid #DDD;
border-left: 1px solid #DDD;
}
/* City Selection Window ================================================= */

#geo_window {
Expand Down
45 changes: 45 additions & 0 deletions wysiwyg/markitup/insert_smiles.js
@@ -0,0 +1,45 @@
var insertSmiles = {
smiles: [],
smiles_url: '',
instance: {},
displayPanel: function (markItUp) {
this.instance = markItUp;
this.smiles_url = $(this.instance.textarea).data('smiles-url');
this.load();
},
load: function () {
if(this.smiles.length > 0){
return this.display();
}
$.post(this.smiles_url, {}, function(result){
if(!result.smiles){ return; }
for(var s in result.smiles){
insertSmiles.smiles.push('<img title=":'+s+':" data-smile=":'+s+':" src="'+result.smiles[s]+'" />');
}
insertSmiles.bindCancel().create().display();
}, 'json');
},
create: function (){
$(this.instance.textarea).parent().find('.markItUpHeader').
append('<div class="smilepanel">'+insertSmiles.smiles.join('')+'</div>').
on('click', '.smilepanel > img', function (){
$.markItUp({ replaceWith: ' '+$(this).data('smile')+' ' });
insertSmiles.hide();
});
return this;
},
hide: function(){
$(this.instance.textarea).parent().find('.smilepanel').hide();
},
display: function(){
$(this.instance.textarea).parent().find('.smilepanel').toggle('fast');
},
bindCancel: function (){
$(document).on('click', 'html', function(event) {
if ($(event.target).closest($('.smilepanel, .btnSmiles, textarea')).length) { return; }
insertSmiles.hide();
event.stopPropagation();
});
return this;
}
};
Binary file added wysiwyg/markitup/sets/default-en/images/smiles.png
16 changes: 3 additions & 13 deletions wysiwyg/markitup/sets/default-en/set.js
@@ -1,14 +1,3 @@
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2011 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
// ----------------------------------------------------------------------------
var mySettings = {
resizeHandle: false,
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
Expand All @@ -27,6 +16,7 @@ var mySettings = {
{name:'Upload Image', className: 'btnImgUpload', beforeInsert: function(markItUp) { InlineUpload.display(markItUp) }},
{name:'YouTube Video', openWith:'<youtube>[![YouTube Video URL]!]', closeWith:'</youtube>', className: 'btnVideoYoutube'},
{name:'Facebook Video', openWith:'<facebook>[![Facebook Video URL]!]', closeWith:'</facebook>', className: 'btnVideoFacebook'},
{name:'Code', openWith:'<code>', closeWith:'</code>', className: 'btnCode'}
{name:'Code', openWith:'<code>', closeWith:'</code>', className: 'btnCode'},
{name:'Smiles', className: 'btnSmiles', key: 'Z', beforeInsert: function(markItUp) { insertSmiles.displayPanel(markItUp); }}
]
}
};
20 changes: 19 additions & 1 deletion wysiwyg/markitup/sets/default-en/style.css
Expand Up @@ -41,7 +41,25 @@
.markItUp .btnCode a {
background-image:url(images/code.png);
}

.markItUp .btnSmiles a {
background-image:url(images/smiles.png);
}
.smilepanel {
display: none;
padding: 0 5px 10px 5px !important;
box-sizing: border-box;
}
.smilepanel > img {
cursor: pointer;
padding: 3px !important;
display: inline-block;
vertical-align: middle;
border-radius: 2px;
}
.smilepanel > img:hover {
background-color: #FFF;
box-shadow: 0px 0px 9px 3px #FFF;
}
.markItUpInlineUpload
{
position: absolute;
Expand Down
Binary file added wysiwyg/markitup/sets/default-ru/images/smiles.png
16 changes: 3 additions & 13 deletions wysiwyg/markitup/sets/default-ru/set.js
@@ -1,14 +1,3 @@
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2011 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
// ----------------------------------------------------------------------------
var mySettings = {
resizeHandle: false,
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
Expand All @@ -27,6 +16,7 @@ var mySettings = {
{name:'Фото с компьютера', className: 'btnImgUpload', beforeInsert: function(markItUp) { InlineUpload.display(markItUp) }},
{name:'Видео YouTube', openWith:'<youtube>[![Ссылка на ролик YouTube]!]', closeWith:'</youtube>', className: 'btnVideoYoutube'},
{name:'Видео Facebook', openWith:'<facebook>[![Ссылка на ролик Facebook]!]', closeWith:'</facebook>', className: 'btnVideoFacebook'},
{name:'Код', openWith:'<code>', closeWith:'</code>', className: 'btnCode'}
{name:'Код', openWith:'<code>', closeWith:'</code>', className: 'btnCode'},
{name:'Смайлы', className: 'btnSmiles', key: 'Z', beforeInsert: function(markItUp) { insertSmiles.displayPanel(markItUp); }}
]
}
};

0 comments on commit ca2bd13

Please sign in to comment.