Skip to content

Commit bd09237

Browse files
committed
фиксы для TinyMce + разные мелочи
close instantsoft#900
1 parent 8abb3e8 commit bd09237

File tree

26 files changed

+478
-104
lines changed

26 files changed

+478
-104
lines changed

install/steps/paths.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ function step($is_submit){
1111
$sp = session_save_path();
1212

1313
if (!$sp) {
14-
$sp = rtrim(sys_get_temp_dir(), '/');
14+
$sp = sys_get_temp_dir();
1515
}
1616

17+
$sp = rtrim($sp, '/');
18+
1719
$uniq = uniqid();
1820

1921
if(mkdir($sp.DS.$uniq, 0755, true) && is_writable($sp.DS.$uniq)){

static/smiles/ups.gif

2.76 KB
Loading

system/controllers/activity/hooks/content_after_update_approve.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ public function run($data){
77
$ctype_name = $data['ctype_name'];
88
$item = $data['item'];
99

10+
if(empty($item['slug'])){
11+
return $data;
12+
}
13+
1014
// обновляем запись в ленте активности
1115
$this->updateEntry('content', "add.{$ctype_name}", $item['id'], array(
1216
'subject_title' => $item['title'],
1317
'subject_id' => $item['id'],
1418
'subject_url' => href_to_rel($ctype_name, $item['slug'] . '.html'),
1519
'is_private' => isset($item['is_private']) ? $item['is_private'] : 0,
16-
'is_pub' => $item['is_pub']
20+
'is_pub' => (isset($item['is_pub']) ? $item['is_pub'] : 1)
1721
));
1822

1923
return $data;

system/controllers/auth/actions/login.php

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public function run(){
2323

2424
if ($is_submit){
2525

26+
if (!$password || !$email || $this->validate_email($email) !== true){
27+
28+
cmsUser::addSessionMessage(LANG_LOGIN_ERROR, 'error');
29+
$this->redirectBack();
30+
31+
}
32+
2633
$is_captcha_valid = true;
2734

2835
if (cmsUser::sessionGet('is_auth_captcha') && $this->options['auth_captcha']){

system/controllers/wysiwygs/backend/actions/presets_add.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public function run($id = null){
3030

3131
}
3232

33+
$errors = [];
34+
3335
if ($this->request->has('submit')){
3436

3537
$wysiwyg_name = $this->request->get('wysiwyg_name', '');
@@ -83,7 +85,7 @@ public function run($id = null){
8385
'do' => $do,
8486
'preset' => $preset,
8587
'form' => $form,
86-
'errors' => isset($errors) ? $errors : false
88+
'errors' => $errors
8789
));
8890

8991
}

system/core/template.php

+4
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,10 @@ public function getRenderedAsset($tpl_file, $data = array()) {
21852185
* @return string
21862186
*/
21872187
public function renderFormField($field_type, $data = array()) {
2188+
$input_js_file = $this->getJavascriptFileName('fields/'.$field_type.'_input');
2189+
if($input_js_file){
2190+
$this->addJSFromContext($input_js_file);
2191+
}
21882192
return $this->getRenderedAsset('fields/'.$field_type, $data);
21892193
}
21902194

system/core/user.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public static function autoLogin($auth_token){
271271
*/
272272
public static function login($email, $password, $remember = false) {
273273

274-
if (!$email || filter_var($email, FILTER_VALIDATE_EMAIL) !== $email){
274+
if (!$email || !$password){
275275
return 0;
276276
}
277277

system/fields/string.php

+12
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ public function getInput($value){
109109
$this->data['autocomplete'] = $this->getProperty('autocomplete');
110110
$this->data['attributes'] = $this->getProperty('attributes')?:array('autocomplete' => 'off');
111111

112+
if($this->data['autocomplete']){
113+
if(empty($this->data['autocomplete']['data'])){
114+
$this->data['autocomplete']['data'] = false;
115+
}
116+
if(empty($this->data['autocomplete']['url'])){
117+
$this->data['autocomplete']['url'] = false;
118+
}
119+
if(empty($this->data['autocomplete']['multiple_separator'])){
120+
$this->data['autocomplete']['multiple_separator'] = ', ';
121+
}
122+
}
123+
112124
$this->data['attributes']['id'] = $this->id;
113125
$this->data['attributes']['required'] = (array_search(array('required'), $this->getRules()) !== false);
114126

system/languages/en/controllers/tinymce/tinymce.php

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
define('LANG_TINYMCE_MIN_HEIGHT', 'Minimum editor height');
2222
define('LANG_TINYMCE_MAX_HEIGHT', 'Maximum editor height');
2323
define('LANG_TINYMCE_ALLOW_MIME_TYPES', 'Allowed file types for "%s" group');
24+
define('LANG_TINYMCE_PASTE_AS_TEXT', 'Paste text, clearing formatting (paste plugin)');
25+
define('LANG_TINYMCE_BLOCK_FORMATS', 'Available formats');
26+
define('LANG_TINYMCE_P', 'Paragraph');
27+
define('LANG_TINYMCE_SP', 'Spoiler');

system/languages/ru/controllers/tinymce/tinymce.php

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
define('LANG_TINYMCE_MIN_HEIGHT', 'Минимальная высота редактора');
2222
define('LANG_TINYMCE_MAX_HEIGHT', 'Максимальная высота редактора');
2323
define('LANG_TINYMCE_ALLOW_MIME_TYPES', 'Разрешенные типы файлов для группы "%s"');
24+
define('LANG_TINYMCE_PASTE_AS_TEXT', 'Вставлять текст, очищая форматирование (плагин paste)');
25+
define('LANG_TINYMCE_BLOCK_FORMATS', 'Доступные форматы');
26+
define('LANG_TINYMCE_P', 'Параграф');
27+
define('LANG_TINYMCE_SP', 'Спойлер');
+10-69
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php if ($field->title) { ?><label for="<?php echo $field->id; ?>"><?php echo $field->title; ?></label><?php } ?>
2-
32
<?php
43
$in_filter_as = $field->getOption('in_filter_as');
54
if($field->context === 'filter' && $in_filter_as && $in_filter_as !== 'input'){ ?>
@@ -20,78 +19,20 @@
2019
<?php if(isset($field->suffix)) { ?><span class="suffix"><?php echo $field->suffix; ?></span><?php } ?>
2120
</div>
2221
<?php } ?>
23-
<?php if($field->getOption('show_symbol_count')){ ?>
22+
<?php if($field->getOption('show_symbol_count')){ ob_start(); ?>
2423
<script type="text/javascript">
2524
$(function(){
26-
icms.forms.initSymbolCount('<?php echo $field->id; ?>', <?php echo intval($field->getOption('max_length')) ?: 0; ?>, <?php echo intval($field->getOption('min_length')) ?: 0; ?>);
25+
icms.forms.initSymbolCount('<?php echo $field->id; ?>', <?php echo intval($field->getOption('max_length', 0)); ?>, <?php echo intval($field->getOption('min_length', 0)); ?>);
2726
});
2827
</script>
29-
<?php } ?>
28+
<?php $this->addBottom(ob_get_clean()); } ?>
3029
<?php if($field->data['autocomplete']){ ?>
31-
<?php $this->addJSFromContext('templates/default/js/jquery-ui.js'); ?>
32-
<?php $this->addCSSFromContext('templates/default/css/jquery-ui.css'); ?>
33-
34-
<script type="text/javascript">
35-
var cache = {};
36-
<?php if(!empty($field->data['autocomplete']['multiple'])) { ?>
37-
$( "#<?php echo $field->id; ?>" ).bind('keydown', function( event ) {
38-
if ( event.keyCode === $.ui.keyCode.TAB &&
39-
$( this ).data('ui-autocomplete').menu.active ) {
40-
event.preventDefault();
41-
}
42-
}).autocomplete({
43-
minLength: 2,
44-
source: function( request, response ) {
45-
var full_term = request.term;
46-
var term = full_term.split( /,\s*/ ).pop();
47-
if (term.length < 2) {
48-
return false;
49-
}
50-
if (term in cache) {
51-
response(cache[term]);
52-
return;
53-
}
54-
$.getJSON( '<?php echo $field->data['autocomplete']['url']; ?>', {
55-
term: term
56-
}, function(data, status, xhr) {
57-
cache[term] = data;
58-
response(data);
59-
});
60-
},
61-
focus: function() {
62-
return false;
63-
},
64-
select: function( event, ui ) {
65-
var terms = this.value.split( /,\s*/ );
66-
terms.pop();
67-
terms.push( ui.item.value );
68-
terms.push('');
69-
this.value = terms.join(', ');
70-
icms.events.run('autocomplete_select', this);
71-
return false;
72-
}
73-
});
74-
<?php } else { ?>
75-
$( "#<?php echo $field->id; ?>" ).autocomplete({
76-
minLength: 2,
77-
delay: 500,
78-
source: function( request, response ) {
79-
var term = request.term;
80-
if ( term in cache ) {
81-
response( cache[ term ] );
82-
return;
83-
}
84-
$.getJSON('<?php echo $field->data['autocomplete']['url']; ?>', request, function( data, status, xhr ) {
85-
cache[ term ] = data;
86-
response( data );
87-
});
88-
},
89-
select: function( event, ui ) {
90-
icms.events.run('autocomplete_select', this);
91-
}
92-
});
93-
<?php } ?>
94-
</script>
30+
<?php $this->addJSFromContext($this->getJavascriptFileName('jquery-ui')); ?>
31+
<?php $this->addCSSFromContext($this->getTemplateStylesFileName('jquery-ui')); ?>
32+
<?php ob_start(); ?>
33+
<script type="text/javascript">
34+
initAutocomplete('<?php echo $field->id; ?>', <?php echo (!empty($field->data['autocomplete']['multiple']) ? 'true' : 'false') ?>, '<?php echo $field->data['autocomplete']['url']; ?>', <?php echo (!empty($field->data['autocomplete']['data']) ? json_encode($field->data['autocomplete']['data']) : 'false') ?>, '<?php echo $field->data['autocomplete']['multiple_separator'] ?>');
35+
</script>
36+
<?php $this->addBottom(ob_get_clean()); ?>
9537
<?php }
9638
}
97-

templates/default/controllers/admin/styles.css

+1
Original file line numberDiff line numberDiff line change
@@ -2836,6 +2836,7 @@ input[type=radio]:checked ~ label{
28362836
border-radius: 4px;
28372837
background-color: #a7b6bd;
28382838
color: #FFF;
2839+
margin: 0 0 2px 0;
28392840
}
28402841
.pattern_fields > a:hover {
28412842
background-color: #64889b;

templates/default/controllers/wysiwygs/backend/preset.tpl.php

+27
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,35 @@
5353

5454
$('#tab-basic').after(data.html);
5555

56+
$('.form-tabs').find('.field.ft_string > input, .field.ft_text > textarea').each(function(indx, element){
57+
$(this).trigger('input');
58+
});
59+
5660
icms.events.run('loadwwoptions', data);
5761
}, 'json');
5862
}).triggerHandler('change');
63+
64+
$('.form-tabs').on('input', '.field.ft_string > input, .field.ft_text > textarea', function (){
65+
if($(this).val().length === 0){ return; }
66+
var btns = $(this).val().split(' ');
67+
var panel = $(this).closest('.field').find('.pattern_fields');
68+
$('a', panel).show().css('background-color', '');
69+
for(var idx in btns){
70+
var btn = btns[idx].trim();
71+
if(btn.length < 2){
72+
continue;
73+
}
74+
$('a:contains("'+btn+'")', panel).filter(function() {
75+
var result = $(this).text().trim() === btn;
76+
if(!result){
77+
var matcher = new RegExp('^'+ btn);
78+
if(matcher.test($(this).text())){
79+
$(this).css('background-color', '#728994');
80+
}
81+
}
82+
return result;
83+
}).hide();
84+
}
85+
});
5986
});
6087
</script>

templates/default/css/theme-layout.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ nav .menu ul {
187187
}
188188

189189
nav .menu {
190-
position: relative; z-index: 5; float: left;
190+
z-index: 5; float: left;
191191
height: 50px;
192192
line-height: 50px;
193193
}

templates/default/js/core.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ function addTextToPosition(field_id, text){
647647
var field = $(field_id);
648648
var value = $(field).val();
649649
var pos = getCaretPosition(field);
650-
$(field).val(value.substring(0, pos) + text + value.substring(pos, value.length));
650+
$(field).val(value.substring(0, pos) + text + value.substring(pos, value.length)).trigger('input');
651651
setCaretPosition(field, pos+text.length);
652652
return false;
653653
}

templates/default/js/fields/string.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ function fieldStringLoadDefault(url){
2222
}, 'json');
2323
}
2424
return false;
25-
}
25+
}

0 commit comments

Comments
 (0)