-
Notifications
You must be signed in to change notification settings - Fork 0
/
fast-insert-xfields.xml
312 lines (242 loc) · 10.2 KB
/
fast-insert-xfields.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?xml version="1.0" encoding="utf-8"?>
<dleplugin>
<name>Fast insert xfields</name>
<description>Сохраняет выбранные дополнительные поля с типом перекрёстные ссылки, а так же теги для последующей их вставки в будущем на страницах добавления и редактирования новостей в административной части.</description>
<icon></icon>
<version></version>
<dleversion>15.1</dleversion>
<versioncompare>greater</versioncompare>
<upgradeurl></upgradeurl>
<filedelete>0</filedelete>
<needplugin></needplugin>
<mnotice>1</mnotice>
<mysqlinstall><![CDATA[]]></mysqlinstall>
<mysqlupgrade><![CDATA[]]></mysqlupgrade>
<mysqlenable><![CDATA[]]></mysqlenable>
<mysqldisable><![CDATA[]]></mysqldisable>
<mysqldelete><![CDATA[]]></mysqldelete>
<phpinstall><![CDATA[]]></phpinstall>
<phpupgrade><![CDATA[]]></phpupgrade>
<phpenable><![CDATA[]]></phpenable>
<phpdisable><![CDATA[]]></phpdisable>
<phpdelete><![CDATA[]]></phpdelete>
<notice><![CDATA[<p>@<a href="https://t.me/TeraMoune" target="_blank">TeraMoune</a></p>
<details><summary style="color:green;font-weight:500" role="button">[b]Для благодарности[/b]</summary><ul style="margin-bottom: 0;"><li>[b]<span style="color:rgb(127,43,253);">Ю</span>Money[/b]: 4100115063692304</li><li>[b]<span style="color:#FF8C00;">Qiwi</span> nickname[/b]: TERAMOUNE</li></ul></details>
<p>Другие плагины на <a href="https://github.com/TeraMoune" target="_blank">[b]GitHub[/b]</a></p>]]></notice>
<file name="engine/inc/addnews.php">
<operation action="before">
<searchcode><![CDATA[$(function(){]]></searchcode>
<replacecode><![CDATA[function Check(request, patt) {
var pattern = new RegExp(patt, 'i');
return pattern.test(request);
}
function sortFn( prop ) {
return function(a, b) {
return b[prop] - a[prop];
}
}
function storage_tag_menu() {
var string_first2 = new Array();
$('.tags-menu').remove();
$('input[type=\"text\"][name^=\"xfield\"], input#tags').map(function(i, item) {
let xf = $(item).attr('id');
let arr_t_first2 = new Array();
let arr_tt2 = new Array();
let storage_item = localStorage.getItem('dle-tag-'+xf);
if( !storage_item ) return false;
let tmp_arr2 = storage_item.split('|');
tmp_arr2.forEach(function(item, i, arr) {
itemt = item.split('*');
arr_tt2[i] = {name: itemt[0], count: itemt[1]};
});
//У arr_tt2 есть два ключа name и count
let newArray2 = arr_tt2.sort(sortFn('count')); //Сортировка по ключу count
newArray2 = newArray2.slice(0, 10); //Срез массива до 10 первых значений
newArray2.forEach(function(item, i, arr) {
var name = item['name'].replace(/'/g, '#39;'); //Замена ' на #39;
arr_t_first2[i] = '<li><a href=\"#\" onclick=\"insert(\''+name+'\',\''+xf+'\', true); return false;\" style=\"border-radius: 5px;padding: 3px;margin:2px 2px;border: 1px solid #00000052;font-size:12px;\">'+item['name']+'</a></li>';
});
if( xf == 'tags' )
$(item).parents('.col-sm-9').append('<div class=\"tags-menu\" style=\"margin-top: 10px;\"><ul style=\"line-height: 24px;display: inline-flex;list-style-type: none;padding: 0;\">'+arr_t_first2.join('')+'</ul> <strong onclick=\"clearTag(\''+xf+'\')\" style=\"cursor:pointer\">[Clear]</strong></div>');
else
$(item).parents('.col-sm-10').append('<div class=\"tags-menu\" style=\"margin-top: 10px;\"><ul style=\"line-height: 24px;display: inline-flex;list-style-type: none;padding: 0;\">'+arr_t_first2.join('')+'</ul> <strong onclick=\"clearTag(\''+xf+'\')\" style=\"cursor:pointer\">[Clear]</strong></div>');
});
}
function storage_tag(id, i) {
if( !i ) i = 'other';
var we = '';
var input_tag = id;
storage_item = localStorage.getItem('dle-tag-'+i);
var arr_t = new Array(),
arr_t2 = new Array(),
itemt = new Array();
if(storage_item != '' && storage_item != null) {
var tmp_arr = storage_item.split('|');
if( tmp_arr.length > 0 ) {
tmp_arr.forEach(function(item, i, arr) {
itemt = item.split('*');
if( id == itemt[0] ) {
we = itemt[0]+'*'+itemt[1];
itemt[1]++;
}
arr_t[i] = itemt[0]+'*'+itemt[1];
arr_t2[itemt[0]] = itemt[1];
});
}
}
if( !arr_t2[id] ){
arr_t.push(id+'*1');
we = id+'*1';
}
string = arr_t.join('|');
localStorage.setItem('dle-tag-'+i, string);
storage_tag_menu();
}
function clearTag(t){
localStorage.setItem('dle-tag-'+t, '');
setTimeout(function() {
storage_tag_menu();
}, 50);
}
function insert(i, t, g) {
i = i.replace(/#39;/g, '\''); // Обратная замена #39; на '
if( g ) {
$('#'+t).tokenfield('createToken', i);
}
setTimeout(function() {
storage_tag(i, t);
}, 50);
return false;
}]]></replacecode>
<enabled>1</enabled>
</operation>
<operation action="after">
<searchcode><![CDATA[$(function(){]]></searchcode>
<replacecode><![CDATA[storage_tag_menu();]]></replacecode>
<enabled>1</enabled>
</operation>
<operation action="replace">
<searchcode><![CDATA[ minLength: 3,
delay: 500
},]]></searchcode>
<replacecode><![CDATA[ minLength: 2,
delay: 500,
select: function( event, ui ) {
let xf = event.target.id.split('-tokenfield');
insert(ui.item.value, xf[0]);
}
},]]></replacecode>
<searchcount>2</searchcount>
<replacecount>1</replacecount>
<enabled>1</enabled>
</operation>
</file>
<file name="engine/inc/editnews.php">
<operation action="before">
<searchcode><![CDATA[$(function(){]]></searchcode>
<replacecode><![CDATA[function Check(request, patt) {
var pattern = new RegExp(patt, 'i');
return pattern.test(request);
}
function sortFn( prop ) {
return function(a, b) {
return b[prop] - a[prop];
}
}
function storage_tag_menu() {
var string_first2 = new Array();
$('.tags-menu').remove();
$('input[type=\"text\"][name^=\"xfield\"], input#tags').map(function(i, item) {
let xf = $(item).attr('id');
let arr_t_first2 = new Array();
let arr_tt2 = new Array();
let storage_item = localStorage.getItem('dle-tag-'+xf);
if( !storage_item ) return false;
let tmp_arr2 = storage_item.split('|');
tmp_arr2.forEach(function(item, i, arr) {
itemt = item.split('*');
arr_tt2[i] = {name: itemt[0], count: itemt[1]};
});
//У arr_tt2 есть два ключа name и count
let newArray2 = arr_tt2.sort(sortFn('count')); //Сортировка по ключу count
newArray2 = newArray2.slice(0, 10); //Срез массива до 10 первых значений
newArray2.forEach(function(item, i, arr) {
var name = item['name'].replace(/'/g, '#39;'); //Замена ' на #39;
arr_t_first2[i] = '<li><a href=\"#\" onclick=\"insert(\''+name+'\',\''+xf+'\', true); return false;\" style=\"border-radius: 5px;padding: 3px;margin:2px 2px;border: 1px solid #00000052;font-size:12px;\">'+item['name']+'</a></li>';
});
if( xf == 'tags' )
$(item).parents('.col-sm-9').append('<div class=\"tags-menu\" style=\"margin-top: 10px;\"><ul style=\"line-height: 24px;display: inline-flex;list-style-type: none;padding: 0;\">'+arr_t_first2.join('')+'</ul> <strong onclick=\"clearTag(\''+xf+'\')\" style=\"cursor:pointer\">[Clear]</strong></div>');
else
$(item).parents('.col-sm-10').append('<div class=\"tags-menu\" style=\"margin-top: 10px;\"><ul style=\"line-height: 24px;display: inline-flex;list-style-type: none;padding: 0;\">'+arr_t_first2.join('')+'</ul> <strong onclick=\"clearTag(\''+xf+'\')\" style=\"cursor:pointer\">[Clear]</strong></div>');
});
}
function clearTag(t){
localStorage.setItem('dle-tag-'+t, '');
setTimeout(function() {
storage_tag_menu();
}, 50);
}
function storage_tag(id, i) {
if( !i ) i = 'other';
var we = '';
var input_tag = id;
storage_item = localStorage.getItem('dle-tag-'+i);
var arr_t = new Array(),
arr_t2 = new Array(),
itemt = new Array();
if(storage_item != '' && storage_item != null) {
var tmp_arr = storage_item.split('|');
if( tmp_arr.length > 0 ) {
tmp_arr.forEach(function(item, i, arr) {
itemt = item.split('*');
if( id == itemt[0] ) {
we = itemt[0]+'*'+itemt[1];
itemt[1]++;
}
arr_t[i] = itemt[0]+'*'+itemt[1];
arr_t2[itemt[0]] = itemt[1];
});
}
}
if( !arr_t2[id] ){
arr_t.push(id+'*1');
we = id+'*1';
}
string = arr_t.join('|');
localStorage.setItem('dle-tag-'+i, string);
storage_tag_menu();
}
function insert(i, t, g) {
i = i.replace(/#39;/g, '\''); // Обратная замена #39; на '
if( g ) {
$('#'+t).tokenfield('createToken', i);
}
setTimeout(function() {
storage_tag(i, t);
}, 50);
return false;
}]]></replacecode>
<enabled>1</enabled>
</operation>
<operation action="after">
<searchcode><![CDATA[$(function(){]]></searchcode>
<replacecode><![CDATA[storage_tag_menu();]]></replacecode>
<enabled>1</enabled>
</operation>
<operation action="replace">
<searchcode><![CDATA[ minLength: 3,
delay: 500
},]]></searchcode>
<replacecode><![CDATA[ minLength: 2,
delay: 500,
select: function( event, ui ) {
let xf = event.target.id.split('-tokenfield');
insert(ui.item.value, xf[0]);
}
},]]></replacecode>
<searchcount>2</searchcount>
<replacecount>1</replacecount>
<enabled>1</enabled>
</operation>
</file>
</dleplugin>