Skip to content

Commit f6d1ece

Browse files
committed
Improvement in Jevix plugin
1 parent 89a7c6d commit f6d1ece

File tree

3 files changed

+189
-124
lines changed

3 files changed

+189
-124
lines changed

plugins/jevix/inc/jevix.class.php

+162-118
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,169 @@
11
<?php
22

3-
function jevix($text, $xhtml = false, $use_admin = true) {
4-
5-
global $location;
3+
function sed_jevix($text, $filter = 'medium', $xhtml = false, $use_admin = true)
4+
{
5+
if ($use_admin == false) return $text; //Disable Jevix for Admin
66

7-
if ($use_admin == false) return $text;
8-
9-
$jevix = new Jevix();
10-
11-
// For User profile text
12-
if ($location == "Users")
13-
{
14-
$jevix->cfgAllowTags(array('p','a','i','b','u','s','em','strong','br','strike'));
15-
$jevix->cfgSetTagShort(array('br'));
16-
$jevix->cfgAllowTagParams('a', array('title', 'href' => '#link', 'rel' => '#text', 'name' => '#text', 'target' => array('_blank')));
17-
$jevix->cfgSetTagParamsRequired('a', 'href');
18-
$jevix->cfgSetTagIsEmpty(array('a'));
19-
}
20-
// For Pages, Forums, Comments, Pm's
21-
else
22-
{
23-
$jevix->cfgAllowTags(array(
24-
'p','a','img','i','b','u','s','em','strong','strike',
25-
'nobr','li','ol','ul','sup','abbr','sub','acronym','h1', 'h2',
26-
'h3', 'h4', 'h5', 'h6','br','hr','pre','code','object','param','embed','adabracut',
27-
'blockquote','iframe','span','div','table', 'tr', 'td', 'th'
28-
));
29-
//2. Establish short tags. (Not having closing tag)
30-
$jevix->cfgSetTagShort(array('br','img', 'hr'));
31-
//3. Establish preformatted tags. (In all of them will be will be replaced on HTML essence)
32-
$jevix->cfgSetTagPreformatted(array('pre','code'));
33-
//4. Establish tags which are necessary for cutting out from the text together with a content.
34-
//$jevix->cfgSetTagCutWithContent(array('script', 'object', 'iframe', 'style'));
35-
$jevix->cfgSetTagCutWithContent(array('script', 'style'));
36-
//5. Establish the resolved parametres tags. Also it is possible to establish admissible values of these parametres.
37-
$jevix->cfgAllowTagParams('p', array('style'));
38-
$jevix->cfgAllowTagParams('span', array('style'));
39-
$jevix->cfgAllowTagParams('a', array('title', 'href' => '#link', 'rel' => '#text', 'name' => '#text', 'target' => array('_blank')));
40-
$jevix->cfgAllowTagParams('img', array('src' => '#image', 'style' => '#text', 'alt' => '#text', 'title', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int'));
41-
$jevix->cfgAllowTagParams('object', array('width' => '#int', 'height' => '#int', 'data' => array('#domain'=>array('youtube.com','rutube.ru','vimeo.com','player.vimeo.com')), 'type' => '#text', 'class' => '#text', 'frameborder' => '#int', 'title' => '#text'));
42-
$jevix->cfgAllowTagParams('param', array('name' => '#text', 'value' => '#text'));
43-
$jevix->cfgAllowTagParams('embed', array('src' => '#image', 'type' => '#text','allowscriptaccess' => '#text', 'allowfullscreen' => '#text','width' => '#int', 'height' => '#int', 'flashvars'=> '#text', 'wmode'=> '#text'));
44-
$jevix->cfgAllowTagParams('iframe', array('width' => '#int', 'height' => '#int', 'src' => array('#domain'=>array('youtube.com','rutube.ru','vimeo.com','player.vimeo.com')), 'type' => '#text', 'class' => '#text', 'frameborder' => '#int', 'title' => '#text'));
45-
$jevix->cfgAllowTagParams('pre', array('class'));
46-
$jevix->cfgAllowTagParams('acronym', array('title'));
47-
$jevix->cfgAllowTagParams('abbr', array('title'));
48-
$jevix->cfgAllowTagParams('hr', array('id' => '#text', 'class'));
49-
$jevix->cfgAllowTagParams('div', array('class', 'id', 'style'));
50-
$jevix->cfgAllowTagParams('h1', array('style'));
51-
$jevix->cfgAllowTagParams('h2', array('style'));
52-
$jevix->cfgAllowTagParams('h3', array('style'));
53-
$jevix->cfgAllowTagParams('h4', array('style'));
54-
$jevix->cfgAllowTagParams('h5', array('style'));
55-
$jevix->cfgAllowTagParams('h6', array('style'));
56-
$jevix->cfgAllowTagParams('span', array('class', 'id', 'style'));
57-
$jevix->cfgAllowTagParams('table', array('border', 'class', 'width', 'align', 'valign', 'style'));
58-
$jevix->cfgAllowTagParams('tr', array('height', 'class'));
59-
$jevix->cfgAllowTagParams('td', array('colspan', 'rowspan', 'class', 'width', 'height', 'align', 'valign'));
60-
$jevix->cfgAllowTagParams('th', array('colspan', 'rowspan', 'class', 'width', 'height', 'align', 'valign'));
61-
62-
// 20. Establish the resolved parametres css styles for tags
63-
$jevix->cfgSetTagStyleParams(array('span'),
64-
array(
65-
'text-decoration' => array('none', 'line-through', 'underline'),
66-
'font-style' => array('normal', 'italic'),
67-
'font-family',
68-
'font-weight' => array('normal', 'bold'),
69-
'font-size' => '#regexp:%^(8|10|12|14|16|18|20)px$%i',
70-
'color' => '#regexp:%^(#([a-f0-9]{6}|[a-f0-9]{3}))|(rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\))$%i',
71-
'background-color' => '#regexp:%^(#([a-f0-9]{6}|[a-f0-9]{3}))|(rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\))$%i'
72-
)
73-
);
74-
75-
$jevix->cfgSetTagStyleParams(array('p'),
76-
array(
77-
'padding-left' => '#regexp:%^(10|20|30|40|50|60|70|80|90|100|120|140|150|160|180)px$%i',
78-
'margin-left' => '#regexp:%^(10|20|30|40|50|60|70|80|90|100|120|140|150|160|180)px$%i',
79-
'text-align' => array('left', 'center', 'right', 'justify'),
80-
)
81-
);
82-
83-
//6. Establish parametres tags being the obligatory. Without them cuts out tag leaving contents.
84-
$jevix->cfgSetTagParamsRequired('img', 'src');
85-
$jevix->cfgSetTagParamsRequired('a', 'href');
86-
87-
// 7. Establish tags which can contain tag the container
88-
$jevix->cfgSetTagChilds('ul', array('li'), false, true);
89-
$jevix->cfgSetTagChilds('ol', array('li'), false, true);
90-
$jevix->cfgSetTagChilds('object', 'param', false, true);
91-
$jevix->cfgSetTagChilds('object', 'embed', false, false);
92-
93-
$jevix->cfgSetTagIsEmpty(array('param','embed','a','iframe'));
94-
95-
// 8. Establish attributes tags which will be automatically added
96-
//$jevix->cfgSetTagParamDefault('a', 'rel', null, true);
97-
$jevix->cfgSetTagParamDefault('embed', 'wmode', 'opaque', true);
98-
99-
// 9. Establish autoreplacement
100-
$jevix->cfgSetAutoReplace(array('+/-', '(c)', '(с)', '(r)', '(C)', '(С)', '(R)'), array('±', '©', '©', '®', '©', '©', '®'));
101-
102-
$jevix->cfgSetTagNoTypography('code','video','object');
103-
}
104-
// 10. Include or switch off mode XHTML. It (is by default included)
105-
$jevix->cfgSetXHTMLMode($xhtml);
106-
107-
// 11. Include or switch off a mode of replacement of carrying over of lines on тег <br/>. It (is by default included)
108-
//$jevix->cfgSetAutoBrMode(true);
109-
$jevix->cfgSetAutoBrMode(false);
110-
111-
// 12. Include or switch off a mode of automatic definition of references. It (is by default included)
112-
//$jevix->cfgSetAutoLinkMode(true);
113-
$jevix->cfgSetAutoLinkMode(false);
114-
115-
// 13. Disconnect typografy in defined tag
116-
//$jevix->cfgSetTagNoTypography('code');
7+
$jevix = new Jevix();
8+
9+
switch($filter)
10+
{
11+
/* -- Full settings -- */
12+
case 'full':
13+
14+
$jevix->cfgAllowTags(array(
15+
'p','a','img','i','b','u','s','em','strong','strike','small',
16+
'nobr','li','ol','ul','sup','abbr','sub','acronym','h1', 'h2',
17+
'h3', 'h4', 'h5', 'h6','br','hr','pre','code','object','param','embed','adabracut',
18+
'blockquote','iframe','span','div','table','tbody','thead','tfoot','tr','td','th'
19+
));
20+
// Establish short tags. (Not having closing tag)
21+
$jevix->cfgSetTagShort(array('br','img', 'hr'));
22+
// Establish preformatted tags. (In all of them will be will be replaced on HTML essence)
23+
$jevix->cfgSetTagPreformatted(array('pre','code'));
24+
// Establish tags which are necessary for cutting out from the text together with a content.
25+
$jevix->cfgSetTagCutWithContent(array('script', 'style', 'meta'));
26+
// Establish the resolved parametres tags. Also it is possible to establish admissible values of these parametres.
27+
$jevix->cfgAllowTagParams('p', array('style'));
28+
$jevix->cfgAllowTagParams('span', array('style'));
29+
$jevix->cfgAllowTagParams('a', array('title', 'href' => '#link', 'rel' => '#text', 'name' => '#text', 'target' => array('_blank')));
30+
$jevix->cfgAllowTagParams('img', array('src' => '#image', 'style' => '#text', 'alt' => '#text', 'title', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int'));
31+
$jevix->cfgAllowTagParams('object', array('width' => '#int', 'height' => '#int', 'data' => array('#domain'=>array('youtube.com','rutube.ru','vimeo.com','player.vimeo.com')), 'type' => '#text', 'class' => '#text', 'frameborder' => '#int', 'title' => '#text'));
32+
$jevix->cfgAllowTagParams('param', array('name' => '#text', 'value' => '#text'));
33+
$jevix->cfgAllowTagParams('embed', array('src' => '#image', 'type' => '#text','allowscriptaccess' => '#text', 'allowfullscreen' => '#text','width' => '#int', 'height' => '#int', 'flashvars'=> '#text', 'wmode'=> '#text'));
34+
$jevix->cfgAllowTagParams('iframe', array('width' => '#int', 'height' => '#int', 'src' => array('#domain'=>array('youtube.com','rutube.ru','vimeo.com','player.vimeo.com')), 'type' => '#text', 'class' => '#text', 'frameborder' => '#int', 'title' => '#text'));
35+
$jevix->cfgAllowTagParams('pre', array('class'));
36+
$jevix->cfgAllowTagParams('acronym', array('title'));
37+
$jevix->cfgAllowTagParams('abbr', array('title'));
38+
$jevix->cfgAllowTagParams('hr', array('id' => '#text', 'class'));
39+
$jevix->cfgAllowTagParams('div', array('class', 'id', 'style'));
40+
$jevix->cfgAllowTagParams('h1', array('style'));
41+
$jevix->cfgAllowTagParams('h2', array('style'));
42+
$jevix->cfgAllowTagParams('h3', array('style'));
43+
$jevix->cfgAllowTagParams('h4', array('style'));
44+
$jevix->cfgAllowTagParams('h5', array('style'));
45+
$jevix->cfgAllowTagParams('h6', array('style'));
46+
$jevix->cfgAllowTagParams('span', array('class', 'id', 'style'));
47+
$jevix->cfgAllowTagParams('table', array('border', 'class', 'width', 'align', 'valign', 'style'));
48+
$jevix->cfgAllowTagParams('tr', array('height', 'class'));
49+
$jevix->cfgAllowTagParams('td', array('colspan', 'rowspan', 'class', 'width', 'height', 'align', 'valign'));
50+
$jevix->cfgAllowTagParams('th', array('colspan', 'rowspan', 'class', 'width', 'height', 'align', 'valign'));
51+
// Establish the resolved parametres css styles for tags
52+
$jevix->cfgSetTagStyleParams(array('span'),
53+
array(
54+
'text-decoration' => array('none', 'line-through', 'underline'),
55+
'font-style' => array('normal', 'italic'),
56+
'font-family',
57+
'font-weight' => array('normal', 'bold'),
58+
'font-size' => '#regexp:%^(8|10|12|14|16|18|20)px$%i',
59+
'color' => '#regexp:%^(#([a-f0-9]{6}|[a-f0-9]{3}))|(rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\))$%i',
60+
'background-color' => '#regexp:%^(#([a-f0-9]{6}|[a-f0-9]{3}))|(rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\))$%i'
61+
)
62+
);
63+
// Allowed style for tags
64+
$jevix->cfgSetTagStyleParams(array('p'),
65+
array(
66+
'padding-left' => '#regexp:%^(10|20|30|40|50|60|70|80|90|100|120|140|150|160|180)px$%i',
67+
'margin-left' => '#regexp:%^(10|20|30|40|50|60|70|80|90|100|120|140|150|160|180)px$%i',
68+
'text-align' => array('left', 'center', 'right', 'justify')
69+
)
70+
);
71+
// Establish parametres tags being the obligatory. Without them cuts out tag leaving contents.
72+
$jevix->cfgSetTagParamsRequired('img', 'src');
73+
$jevix->cfgSetTagParamsRequired('a', 'href');
74+
// Establish tags which can contain tag the container
75+
$jevix->cfgSetTagChilds('ul', array('li'), false, true);
76+
$jevix->cfgSetTagChilds('ol', array('li'), false, true);
77+
$jevix->cfgSetTagChilds('object', 'param', false, true);
78+
$jevix->cfgSetTagChilds('object', 'embed', false, false);
79+
// Establish tags which can be empty
80+
$jevix->cfgSetTagIsEmpty(array('param','embed','a','iframe'));
81+
// Establish attributes tags which will be automatically added
82+
$jevix->cfgSetTagParamDefault('embed', 'wmode', 'opaque', true);
83+
// Establish autoreplacement
84+
$jevix->cfgSetAutoReplace(array('+/-', '(c)', '(с)', '(r)', '(C)', '(С)', '(R)'), array('±', '©', '©', '®', '©', '©', '®'));
85+
// Disconnect typografy in defined tag
86+
$jevix->cfgSetTagNoTypography('code','video','object');
87+
88+
break;
89+
/* ---- */
90+
91+
/* -- Medium settings -- */
92+
case 'medium':
93+
94+
$jevix->cfgAllowTags(array(
95+
'p','a','img','i','b','u','s','em','strong','strike','small',
96+
'nobr','li','ol','ul','sup','abbr','sub','acronym','h1', 'h2',
97+
'h3', 'h4', 'h5', 'h6','br','hr','pre','code','blockquote','span'
98+
));
99+
$jevix->cfgSetTagShort(array('br','img', 'hr'));
100+
$jevix->cfgSetTagPreformatted(array('pre','code'));
101+
$jevix->cfgSetTagCutWithContent(array('script', 'style', 'meta'));
102+
$jevix->cfgAllowTagParams('p', array('style'));
103+
$jevix->cfgAllowTagParams('span', array('style'));
104+
$jevix->cfgAllowTagParams('a', array('title', 'href' => '#link', 'rel' => '#text', 'name' => '#text', 'target' => array('_blank')));
105+
$jevix->cfgAllowTagParams('img', array('src' => '#image', 'style' => '#text', 'alt' => '#text', 'title', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int'));
106+
$jevix->cfgAllowTagParams('pre', array('class'));
107+
$jevix->cfgAllowTagParams('acronym', array('title'));
108+
$jevix->cfgAllowTagParams('abbr', array('title'));
109+
$jevix->cfgAllowTagParams('hr', array('id' => '#text', 'class'));
110+
$jevix->cfgAllowTagParams('h1', array('style'));
111+
$jevix->cfgAllowTagParams('h2', array('style'));
112+
$jevix->cfgAllowTagParams('h3', array('style'));
113+
$jevix->cfgAllowTagParams('h4', array('style'));
114+
$jevix->cfgAllowTagParams('h5', array('style'));
115+
$jevix->cfgAllowTagParams('h6', array('style'));
116+
$jevix->cfgSetTagStyleParams(array('span'),
117+
array(
118+
'text-decoration' => array('none', 'line-through', 'underline'),
119+
'font-style' => array('normal', 'italic'),
120+
'font-family',
121+
'font-weight' => array('normal', 'bold'),
122+
'font-size' => '#regexp:%^(8|10|12|14|16|18|20)px$%i',
123+
'color' => '#regexp:%^(#([a-f0-9]{6}|[a-f0-9]{3}))|(rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\))$%i',
124+
'background-color' => '#regexp:%^(#([a-f0-9]{6}|[a-f0-9]{3}))|(rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\))$%i'
125+
)
126+
);
127+
$jevix->cfgSetTagStyleParams(array('p'),
128+
array(
129+
'padding-left' => '#regexp:%^(10|20|30|40|50|60|70|80|90|100|120|140|150|160|180)px$%i',
130+
'margin-left' => '#regexp:%^(10|20|30|40|50|60|70|80|90|100|120|140|150|160|180)px$%i',
131+
'text-align' => array('left', 'center', 'right', 'justify')
132+
)
133+
);
134+
$jevix->cfgSetTagParamsRequired('img', 'src');
135+
$jevix->cfgSetTagParamsRequired('a', 'href');
136+
$jevix->cfgSetTagChilds('ul', array('li'), false, true);
137+
$jevix->cfgSetTagChilds('ol', array('li'), false, true);
138+
$jevix->cfgSetAutoReplace(array('+/-', '(c)', '(с)', '(r)', '(C)', '(С)', '(R)'), array('±', '©', '©', '®', '©', '©', '®'));
139+
$jevix->cfgSetTagNoTypography('code');
140+
141+
break;
142+
/* ---- */
117143

118-
// Variable in which will be write errors
119-
$errors = null;
120-
121-
return $jevix->parse($text, $errors);
122-
}
144+
/* -- Micro settings - default -- */
145+
default:
146+
147+
$jevix->cfgAllowTags(array('p','a','i','b','u','s','em','strong','br','strike'));
148+
$jevix->cfgSetTagShort(array('br'));
149+
$jevix->cfgAllowTagParams('a', array('title', 'href' => '#link', 'rel' => '#text', 'name' => '#text', 'target' => array('_blank')));
150+
$jevix->cfgSetTagParamsRequired('a', 'href');
151+
$jevix->cfgSetTagIsEmpty(array('a'));
152+
153+
break;
154+
/* ---- */
155+
}
156+
157+
// Include or switch off mode XHTML. It (is by default included)
158+
$jevix->cfgSetXHTMLMode($xhtml);
159+
// Include or switch off a mode of replacement of carrying over of lines on тег <br/>. It (is by default included)
160+
$jevix->cfgSetAutoBrMode(false);
161+
// Include or switch off a mode of automatic definition of references. It (is by default included)
162+
$jevix->cfgSetAutoLinkMode(false);
163+
// Variable in which will be write errors
164+
$errors = null;
165+
return $jevix->parse($text, $errors);
166+
}
123167

124168
/**
125169
* Jevix — means of automatic application of rules of a set of texts,

plugins/jevix/jevix.import.filter.php

+24-5
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,38 @@
2626

2727
if (!defined('SED_CODE')) { die('Wrong URL.'); }
2828

29-
global $usr, $location;
29+
global $usr, $location, $flocation;
3030

3131
require_once('plugins/jevix/inc/jevix.class.php');
3232

33+
$jevix_filter_settings = array(
34+
'Pages' => 'full',
35+
'Private_Messages' => 'medium',
36+
'Polls' => 'micro',
37+
'Gallery' => 'micro',
38+
'PFS' => 'micro',
39+
'Users' => 'micro',
40+
'Plugins' => 'full',
41+
'Forums' => 'full',
42+
'Comments' => 'medium',
43+
'Administration' => 'full'
44+
);
45+
46+
$flocation = (empty($flocation)) ? $location : $flocation;
47+
48+
if (array_key_exists($flocation, $jevix_filter_settings))
49+
{
50+
$filter = $jevix_filter_settings[$flocation];
51+
}
52+
else { $filter = 'micro'; }
53+
3354
// Use XHTML ?
3455
$use_xhtml = ($cfg['plugin']['jevix']['use_xhtml'] == "yes") ? true : false;
3556

3657
// Use for Administrators ?
3758
$use_admin = (($cfg['plugin']['jevix']['use_for_admin'] == "no") && ($usr['maingrp'] == 5)) ? false : true;
3859

3960
// Use jevix only html mode
40-
if ($cfg['textmode'] != "bbcode") { $v = jevix($v, $use_xhtml, $use_admin); }
41-
42-
61+
if ($cfg['textmode'] != "bbcode") { $v = sed_jevix($v, $filter, $use_xhtml, $use_admin); }
4362

44-
?>
63+
?>

system/functions.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ function sed_build_catpath($cat, $mask)
461461
*/
462462
function sed_build_comments($code, $url, $display, $allow = TRUE)
463463
{
464-
global $db_com, $db_users, $db_pages, $cfg, $usr, $L, $sys, $skin, $ishtml;
464+
global $db_com, $db_users, $db_pages, $cfg, $usr, $L, $sys, $skin, $flocation, $ishtml;
465+
466+
$flocation = 'Comments';
465467

466468
$n = sed_import('n', 'G', 'ALP');
467469
$a = sed_import('a', 'G', 'ALP');

0 commit comments

Comments
 (0)