@@ -149,13 +149,19 @@ discard block |
||
149 | 149 | if($ginfo === true) |
150 | 150 | { |
151 | 151 | $tret = $this->get_tret($group); |
152 | - if($tret) $info['title'] = $tret->title; else $info['title'] = "Не определено"; |
|
152 | + if($tret) { |
|
153 | + $info['title'] = $tret->title; |
|
154 | + } else { |
|
155 | + $info['title'] = "Не определено"; |
|
156 | + } |
|
153 | 157 | } else { |
154 | 158 | $info = $ginfo; |
155 | 159 | } |
156 | 160 | $info['name'] = $group; |
157 | 161 | $info['options'] = array(); |
158 | - if(is_array($bygroup[$group])) foreach($bygroup[$group] as $opt) $info['options'][] = $opt; |
|
162 | + if(is_array($bygroup[$group])) { |
|
163 | + foreach($bygroup[$group] as $opt) $info['options'][] = $opt; |
|
164 | + } |
|
159 | 165 | $arr['group'][] = $info; |
160 | 166 | } |
161 | 167 | return $arr; |
@@ -170,16 +176,24 @@ discard block |
||
170 | 176 | */ |
171 | 177 | protected function get_option_info($key) |
172 | 178 | { |
173 | - if(!isset($this->all_options[$key])) return false; |
|
174 | - if(is_array($this->all_options[$key])) return $this->all_options[$key]; |
|
179 | + if(!isset($this->all_options[$key])) { |
|
180 | + return false; |
|
181 | + } |
|
182 | + if(is_array($this->all_options[$key])) { |
|
183 | + return $this->all_options[$key]; |
|
184 | + } |
|
175 | 185 | |
176 | 186 | if(($this->all_options[$key] == "direct") || ($this->all_options[$key] == "reverse")) |
177 | 187 | { |
178 | 188 | $pa = explode(".", $key); |
179 | 189 | $tret_pattern = $pa[0]; |
180 | 190 | $tret = $this->get_tret($tret_pattern); |
181 | - if(!$tret) return false; |
|
182 | - if(!isset($tret->rules[$pa[1]])) return false; |
|
191 | + if(!$tret) { |
|
192 | + return false; |
|
193 | + } |
|
194 | + if(!isset($tret->rules[$pa[1]])) { |
|
195 | + return false; |
|
196 | + } |
|
183 | 197 | $array = $tret->rules[$pa[1]]; |
184 | 198 | $array['way'] = $this->all_options[$key]; |
185 | 199 | return $array; |
@@ -196,7 +210,9 @@ discard block |
||
196 | 210 | */ |
197 | 211 | public function do_setup($name, $value) |
198 | 212 | { |
199 | - if(!isset($this->all_options[$name])) return; |
|
213 | + if(!isset($this->all_options[$name])) { |
|
214 | + return; |
|
215 | + } |
|
200 | 216 | |
201 | 217 | // эта настрока связана с правилом ядра |
202 | 218 | if(is_string($this->all_options[$name])) |
@@ -209,15 +225,21 @@ discard block |
||
209 | 225 | if(isset($this->all_options[$name]['selector'])) |
210 | 226 | { |
211 | 227 | $settingname = "active"; |
212 | - if(isset($this->all_options[$name]['setting'])) $settingname = $this->all_options[$name]['setting']; |
|
228 | + if(isset($this->all_options[$name]['setting'])) { |
|
229 | + $settingname = $this->all_options[$name]['setting']; |
|
230 | + } |
|
213 | 231 | $this->set($this->all_options[$name]['selector'], $settingname, $value); |
214 | 232 | } |
215 | 233 | } |
216 | 234 | |
217 | 235 | if($name == "OptAlign.layout") |
218 | 236 | { |
219 | - if($value == "style") $this->set_tag_layout(EMTLib::LAYOUT_STYLE); |
|
220 | - if($value == "class") $this->set_tag_layout(EMTLib::LAYOUT_CLASS); |
|
237 | + if($value == "style") { |
|
238 | + $this->set_tag_layout(EMTLib::LAYOUT_STYLE); |
|
239 | + } |
|
240 | + if($value == "class") { |
|
241 | + $this->set_tag_layout(EMTLib::LAYOUT_CLASS); |
|
242 | + } |
|
221 | 243 | } |
222 | 244 | |
223 | 245 | } |
@@ -232,7 +254,9 @@ discard block |
||
232 | 254 | public static function fast_apply($text, $options = null) |
233 | 255 | { |
234 | 256 | $obj = new self(); |
235 | - if(is_array($options)) $obj->setup($options); |
|
257 | + if(is_array($options)) { |
|
258 | + $obj->setup($options); |
|
259 | + } |
|
236 | 260 | $obj->set_text($text); |
237 | 261 | return $obj->apply(); |
238 | 262 | } |
@@ -85,7 +85,9 @@ discard block |
||
85 | 85 | |
86 | 86 | protected function inject_in($pos, $text, &$thetext) |
87 | 87 | { |
88 | - for($i=0;$i<strlen($text);$i++) $thetext[$pos+$i] = $text[$i]; |
|
88 | + for($i=0;$i<strlen($text);$i++) { |
|
89 | + $thetext[$pos+$i] = $text[$i]; |
|
90 | + } |
|
89 | 91 | } |
90 | 92 | |
91 | 93 | protected function build_sub_quotations() |
@@ -106,28 +108,36 @@ discard block |
||
106 | 108 | while(true) |
107 | 109 | { |
108 | 110 | $p = EMTLib::strpos_ex($textx, array("«", "»"), $off); |
109 | - if($p===false) break; |
|
111 | + if($p===false) { |
|
112 | + break; |
|
113 | + } |
|
110 | 114 | if($p['str'] == "«") |
111 | 115 | { |
112 | - if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx); |
|
116 | + if($level>0) { |
|
117 | + if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx); |
|
118 | + } |
|
113 | 119 | $level++; |
114 | 120 | } |
115 | 121 | if($p['str'] == "»") |
116 | 122 | { |
117 | 123 | $level--; |
118 | - if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx); |
|
124 | + if($level>0) { |
|
125 | + if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx); |
|
126 | + } |
|
119 | 127 | } |
120 | 128 | $off = $p['pos']+strlen($p['str']); |
121 | 129 | if($level == 0) |
122 | 130 | { |
123 | 131 | $okpos = $off; |
124 | 132 | array_push($okposstack, $okpos); |
125 | - } elseif($level<0) // уровень стал меньше нуля |
|
133 | + } elseif($level<0) { |
|
134 | + // уровень стал меньше нуля |
|
126 | 135 | { |
127 | 136 | if(!$this->is_on('no_inches')) |
128 | 137 | { |
129 | 138 | do{ |
130 | 139 | $lokpos = array_pop($okposstack); |
140 | + } |
|
131 | 141 | $k = substr($textx, $lokpos, $off-$lokpos); |
132 | 142 | $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
133 | 143 | $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k); |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | protected function log($str, $data = null) |
47 | 47 | { |
48 | - if(!$this->logging) return; |
|
48 | + if(!$this->logging) { |
|
49 | + return; |
|
50 | + } |
|
49 | 51 | $this->logs[] = array('class' => '', 'info' => $str, 'data' => $data); |
50 | 52 | } |
51 | 53 | |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | |
68 | 70 | protected function debug($class, $place, &$after_text, $after_text_raw = "") |
69 | 71 | { |
70 | - if(!$this->debug_enabled) return; |
|
72 | + if(!$this->debug_enabled) { |
|
73 | + return; |
|
74 | + } |
|
71 | 75 | $this->debug_info[] = array( |
72 | 76 | 'tret' => $class == $this ? false: true, |
73 | 77 | 'class' => is_object($class)? get_class($class) : $class, |
@@ -145,7 +149,9 @@ discard block |
||
145 | 149 | public function remove_safe_block($id) |
146 | 150 | { |
147 | 151 | foreach($this->_safe_blocks as $k => $block) { |
148 | - if($block['id']==$id) unset($this->_safe_blocks[$k]); |
|
152 | + if($block['id']==$id) { |
|
153 | + unset($this->_safe_blocks[$k]); |
|
154 | + } |
|
149 | 155 | } |
150 | 156 | } |
151 | 157 | |
@@ -270,9 +276,13 @@ discard block |
||
270 | 276 | { |
271 | 277 | foreach($this->trets as $tret) |
272 | 278 | { |
273 | - if(isset($this->tret_objects[$tret])) continue; |
|
279 | + if(isset($this->tret_objects[$tret])) { |
|
280 | + continue; |
|
281 | + } |
|
274 | 282 | $obj = $this->create_object($tret); |
275 | - if($obj == null) continue; |
|
283 | + if($obj == null) { |
|
284 | + continue; |
|
285 | + } |
|
276 | 286 | $this->tret_objects[$tret] = $obj; |
277 | 287 | } |
278 | 288 | |
@@ -328,8 +338,9 @@ discard block |
||
328 | 338 | if(is_string($class)) |
329 | 339 | { |
330 | 340 | $obj = $this->create_object($class); |
331 | - if($obj === null) |
|
332 | - return false; |
|
341 | + if($obj === null) { |
|
342 | + return false; |
|
343 | + } |
|
333 | 344 | $this->tret_objects[($altname ? $altname : $class)] = $obj; |
334 | 345 | $this->trets[] = ($altname ? $altname : $class); |
335 | 346 | return true; |
@@ -345,7 +356,9 @@ discard block |
||
345 | 356 | */ |
346 | 357 | public function get_tret($name) |
347 | 358 | { |
348 | - if(isset($this->tret_objects[$name])) return $this->tret_objects[$name]; |
|
359 | + if(isset($this->tret_objects[$name])) { |
|
360 | + return $this->tret_objects[$name]; |
|
361 | + } |
|
349 | 362 | foreach($this->trets as $tret) |
350 | 363 | { |
351 | 364 | if($tret == $name) |
@@ -387,8 +400,11 @@ discard block |
||
387 | 400 | $this->_init(); |
388 | 401 | |
389 | 402 | $atrets = $this->trets; |
390 | - if(is_string($trets)) $atrets = array($trets); |
|
391 | - elseif(is_array($trets)) $atrets = $trets; |
|
403 | + if(is_string($trets)) { |
|
404 | + $atrets = array($trets); |
|
405 | + } elseif(is_array($trets)) { |
|
406 | + $atrets = $trets; |
|
407 | + } |
|
392 | 408 | |
393 | 409 | $this->debug($this, 'init', $this->_text); |
394 | 410 | |
@@ -404,15 +420,21 @@ discard block |
||
404 | 420 | foreach ($atrets as $tret) |
405 | 421 | { |
406 | 422 | // если установлен режим разметки тэгов то выставим его |
407 | - if($this->use_layout_set) |
|
408 | - $this->tret_objects[$tret]->set_tag_layout_ifnotset($this->use_layout); |
|
423 | + if($this->use_layout_set) { |
|
424 | + $this->tret_objects[$tret]->set_tag_layout_ifnotset($this->use_layout); |
|
425 | + } |
|
409 | 426 | |
410 | - if($this->class_layout_prefix) |
|
411 | - $this->tret_objects[$tret]->set_class_layout_prefix($this->class_layout_prefix); |
|
427 | + if($this->class_layout_prefix) { |
|
428 | + $this->tret_objects[$tret]->set_class_layout_prefix($this->class_layout_prefix); |
|
429 | + } |
|
412 | 430 | |
413 | 431 | // влючаем, если нужно |
414 | - if($this->debug_enabled) $this->tret_objects[$tret]->debug_on(); |
|
415 | - if($this->logging) $this->tret_objects[$tret]->logging = true; |
|
432 | + if($this->debug_enabled) { |
|
433 | + $this->tret_objects[$tret]->debug_on(); |
|
434 | + } |
|
435 | + if($this->logging) { |
|
436 | + $this->tret_objects[$tret]->logging = true; |
|
437 | + } |
|
416 | 438 | |
417 | 439 | // применяем трэт |
418 | 440 | //$this->tret_objects[$tret]->set_text(&$this->_text); |
@@ -420,21 +442,24 @@ discard block |
||
420 | 442 | $this->tret_objects[$tret]->apply(); |
421 | 443 | |
422 | 444 | // соберём ошибки если таковые есть |
423 | - if(count($this->tret_objects[$tret]->errors)>0) |
|
424 | - foreach($this->tret_objects[$tret]->errors as $err ) |
|
445 | + if(count($this->tret_objects[$tret]->errors)>0) { |
|
446 | + foreach($this->tret_objects[$tret]->errors as $err ) |
|
425 | 447 | $this->tret_error($tret, $err['info'], $err['data']); |
448 | + } |
|
426 | 449 | |
427 | 450 | // логгирование |
428 | - if($this->logging) |
|
429 | - if(count($this->tret_objects[$tret]->logs)>0) |
|
451 | + if($this->logging) { |
|
452 | + if(count($this->tret_objects[$tret]->logs)>0) |
|
430 | 453 | foreach($this->tret_objects[$tret]->logs as $log ) |
431 | - $this->tret_log($tret, $log['info'], $log['data']); |
|
454 | + $this->tret_log($tret, $log['info'], $log['data']); |
|
455 | + } |
|
432 | 456 | |
433 | 457 | // отладка |
434 | - if($this->debug_enabled) |
|
435 | - foreach($this->tret_objects[$tret]->debug_info as $di) |
|
458 | + if($this->debug_enabled) { |
|
459 | + foreach($this->tret_objects[$tret]->debug_info as $di) |
|
436 | 460 | { |
437 | 461 | $unsafetext = $di['text']; |
462 | + } |
|
438 | 463 | $unsafetext = EMTLib::safe_tag_chars($unsafetext, false); |
439 | 464 | $unsafetext = $this->safe_blocks($unsafetext, false); |
440 | 465 | $this->debug($tret, $di['place'], $unsafetext, $di['text']); |
@@ -461,7 +486,9 @@ discard block |
||
461 | 486 | if(!$this->disable_notg_replace) |
462 | 487 | { |
463 | 488 | $repl = array('<span class="_notg_start"></span>', '<span class="_notg_end"></span>'); |
464 | - if($this->remove_notg) $repl = ""; |
|
489 | + if($this->remove_notg) { |
|
490 | + $repl = ""; |
|
491 | + } |
|
465 | 492 | $this->_text = str_replace( array('<notg>','</notg>'), $repl , $this->_text); |
466 | 493 | } |
467 | 494 | $this->_text = trim($this->_text); |
@@ -484,15 +511,21 @@ discard block |
||
484 | 511 | foreach ($this->trets as $tret) |
485 | 512 | { |
486 | 513 | $arr =$this->tret_objects[$tret]->classes; |
487 | - if(!is_array($arr)) continue; |
|
514 | + if(!is_array($arr)) { |
|
515 | + continue; |
|
516 | + } |
|
488 | 517 | foreach($arr as $classname => $str) |
489 | 518 | { |
490 | - if(($compact) && (!$str)) continue; |
|
519 | + if(($compact) && (!$str)) { |
|
520 | + continue; |
|
521 | + } |
|
491 | 522 | $clsname = ($this->class_layout_prefix ? $this->class_layout_prefix : "" ).(isset($this->tret_objects[$tret]->class_names[$classname]) ? $this->tret_objects[$tret]->class_names[$classname] :$classname); |
492 | 523 | $res[$clsname] = $str; |
493 | 524 | } |
494 | 525 | } |
495 | - if($list) return $res; |
|
526 | + if($list) { |
|
527 | + return $res; |
|
528 | + } |
|
496 | 529 | $str = ""; |
497 | 530 | foreach($res as $k => $v) |
498 | 531 | { |
@@ -542,7 +575,9 @@ discard block |
||
542 | 575 | */ |
543 | 576 | public function set_enable_map($map, $disable = false, $strict = true) |
544 | 577 | { |
545 | - if(!is_array($map)) return; |
|
578 | + if(!is_array($map)) { |
|
579 | + return; |
|
580 | + } |
|
546 | 581 | $trets = array(); |
547 | 582 | foreach($map as $tret => $list) |
548 | 583 | { |
@@ -554,9 +589,11 @@ discard block |
||
554 | 589 | } |
555 | 590 | $trets[] = $tretx; |
556 | 591 | |
557 | - if($list === true) // все |
|
592 | + if($list === true) { |
|
593 | + // все |
|
558 | 594 | { |
559 | 595 | $tretx->activate(array(), !$disable , true); |
596 | + } |
|
560 | 597 | } elseif(is_string($list)) { |
561 | 598 | $tretx->activate(array($list), $disable , $strict); |
562 | 599 | } elseif(is_array($list)) { |
@@ -567,7 +604,9 @@ discard block |
||
567 | 604 | { |
568 | 605 | foreach($this->trets as $tret) |
569 | 606 | { |
570 | - if(in_array($this->tret_objects[$tret], $trets)) continue; |
|
607 | + if(in_array($this->tret_objects[$tret], $trets)) { |
|
608 | + continue; |
|
609 | + } |
|
571 | 610 | $this->tret_objects[$tret]->activate(array(), $disable , true); |
572 | 611 | } |
573 | 612 | } |
@@ -582,7 +621,9 @@ discard block |
||
582 | 621 | */ |
583 | 622 | public function is_on($key) |
584 | 623 | { |
585 | - if(!isset($this->settings[$key])) return false; |
|
624 | + if(!isset($this->settings[$key])) { |
|
625 | + return false; |
|
626 | + } |
|
586 | 627 | $kk = $this->settings[$key]; |
587 | 628 | return ((strtolower($kk)=="on") || ($kk === "1") || ($kk === true) || ($kk === 1)); |
588 | 629 | } |
@@ -614,20 +655,30 @@ discard block |
||
614 | 655 | } |
615 | 656 | EMTLib::_process_selector_pattern($tret_pattern); |
616 | 657 | EMTLib::_process_selector_pattern($rule_pattern); |
617 | - if($selector == "*") $this->settings[$key] = $value; |
|
658 | + if($selector == "*") { |
|
659 | + $this->settings[$key] = $value; |
|
660 | + } |
|
618 | 661 | |
619 | 662 | foreach ($this->trets as $tret) |
620 | 663 | { |
621 | 664 | $t1 = $this->get_short_tret($tret); |
622 | - if(!EMTLib::_test_pattern($tret_pattern, $t1)) if(!EMTLib::_test_pattern($tret_pattern, $tret)) continue; |
|
665 | + if(!EMTLib::_test_pattern($tret_pattern, $t1)) { |
|
666 | + if(!EMTLib::_test_pattern($tret_pattern, $tret)) continue; |
|
667 | + } |
|
623 | 668 | $tret_obj = $this->get_tret($tret); |
624 | 669 | if($key == "active") |
625 | 670 | { |
626 | 671 | foreach($tret_obj->rules as $rulename => $v) |
627 | 672 | { |
628 | - if(!EMTLib::_test_pattern($rule_pattern, $rulename)) continue; |
|
629 | - if((strtolower($value) === "on") || ($value===1) || ($value === true) || ($value=="1")) $tret_obj->enable_rule($rulename); |
|
630 | - if((strtolower($value) === "off") || ($value===0) || ($value === false) || ($value=="0")) $tret_obj->disable_rule($rulename); |
|
673 | + if(!EMTLib::_test_pattern($rule_pattern, $rulename)) { |
|
674 | + continue; |
|
675 | + } |
|
676 | + if((strtolower($value) === "on") || ($value===1) || ($value === true) || ($value=="1")) { |
|
677 | + $tret_obj->enable_rule($rulename); |
|
678 | + } |
|
679 | + if((strtolower($value) === "off") || ($value===0) || ($value === false) || ($value=="0")) { |
|
680 | + $tret_obj->disable_rule($rulename); |
|
681 | + } |
|
631 | 682 | } |
632 | 683 | } else { |
633 | 684 | if($rule_pattern===false) |
@@ -636,7 +687,9 @@ discard block |
||
636 | 687 | } else { |
637 | 688 | foreach($tret_obj->rules as $rulename => $v) |
638 | 689 | { |
639 | - if(!EMTLib::_test_pattern($rule_pattern, $rulename)) continue; |
|
690 | + if(!EMTLib::_test_pattern($rule_pattern, $rulename)) { |
|
691 | + continue; |
|
692 | + } |
|
640 | 693 | $tret_obj->set_rule($rulename, $key, $value); |
641 | 694 | } |
642 | 695 | } |
@@ -662,7 +715,9 @@ discard block |
||
662 | 715 | { |
663 | 716 | if(is_array($selector)) |
664 | 717 | { |
665 | - foreach($selector as $val) $this->set($val, $key, $value); |
|
718 | + foreach($selector as $val) { |
|
719 | + $this->set($val, $key, $value); |
|
720 | + } |
|
666 | 721 | return; |
667 | 722 | } |
668 | 723 | if(is_array($key)) |
@@ -712,7 +767,9 @@ discard block |
||
712 | 767 | */ |
713 | 768 | public function setup($setupmap) |
714 | 769 | { |
715 | - if(!is_array($setupmap)) return; |
|
770 | + if(!is_array($setupmap)) { |
|
771 | + return; |
|
772 | + } |
|
716 | 773 | |
717 | 774 | if(isset($setupmap['map']) || isset($setupmap['maps'])) |
718 | 775 | { |
@@ -741,7 +798,9 @@ discard block |
||
741 | 798 | } |
742 | 799 | |
743 | 800 | |
744 | - foreach($setupmap as $k => $v) $this->do_setup($k , $v); |
|
801 | + foreach($setupmap as $k => $v) { |
|
802 | + $this->do_setup($k , $v); |
|
803 | + } |
|
745 | 804 | } |
746 | 805 | |
747 | 806 |
@@ -122,12 +122,22 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public static function clear_special_chars($text, $mode = null) |
124 | 124 | { |
125 | - if(is_string($mode)) $mode = array($mode); |
|
126 | - if(is_null($mode)) $mode = array('utf8', 'html'); |
|
127 | - if(!is_array($mode)) return false; |
|
125 | + if(is_string($mode)) { |
|
126 | + $mode = array($mode); |
|
127 | + } |
|
128 | + if(is_null($mode)) { |
|
129 | + $mode = array('utf8', 'html'); |
|
130 | + } |
|
131 | + if(!is_array($mode)) { |
|
132 | + return false; |
|
133 | + } |
|
128 | 134 | $moder = array(); |
129 | - foreach($mode as $mod) if(in_array($mod, array('utf8','html'))) $moder[] = $mod; |
|
130 | - if(count($moder)==0) return false; |
|
135 | + foreach($mode as $mod) { |
|
136 | + if(in_array($mod, array('utf8','html'))) $moder[] = $mod; |
|
137 | + } |
|
138 | + if(count($moder)==0) { |
|
139 | + return false; |
|
140 | + } |
|
131 | 141 | |
132 | 142 | foreach (self::$_charsTable as $char => $vals) |
133 | 143 | { |
@@ -181,8 +191,12 @@ discard block |
||
181 | 191 | $tags = array(); |
182 | 192 | foreach ($allowableTag as $tag) |
183 | 193 | { |
184 | - if ('<' !== substr($tag, 0, 1) || '>' !== substr($tag, -1, 1)) continue; |
|
185 | - if ('/' === substr($tag, 1, 1)) continue; |
|
194 | + if ('<' !== substr($tag, 0, 1) || '>' !== substr($tag, -1, 1)) { |
|
195 | + continue; |
|
196 | + } |
|
197 | + if ('/' === substr($tag, 1, 1)) { |
|
198 | + continue; |
|
199 | + } |
|
186 | 200 | $tags [] = $tag; |
187 | 201 | } |
188 | 202 | $ignore = implode('', $tags); |
@@ -205,10 +219,11 @@ discard block |
||
205 | 219 | */ |
206 | 220 | public static function safe_tag_chars($text, $way) |
207 | 221 | { |
208 | - if ($way) |
|
209 | - $text = preg_replace_callback('/(\<\/?)(.+?)(\>)/s', create_function('$m','return $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . \Fenrizbes\TypographBundle\EMT\EMTLib::encrypt_tag(trim($m[2])) . $m[3];'), $text); |
|
210 | - else |
|
211 | - $text = preg_replace_callback('/(\<\/?)(.+?)(\>)/s', create_function('$m','return $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag(substr(trim($m[2]), 4)) : \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag(trim($m[2])) ) . $m[3];'), $text); |
|
222 | + if ($way) { |
|
223 | + $text = preg_replace_callback('/(\<\/?)(.+?)(\>)/s', create_function('$m','return $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . \Fenrizbes\TypographBundle\EMT\EMTLib::encrypt_tag(trim($m[2])) . $m[3];'), $text); |
|
224 | + } else { |
|
225 | + $text = preg_replace_callback('/(\<\/?)(.+?)(\>)/s', create_function('$m','return $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag(substr(trim($m[2]), 4)) : \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag(trim($m[2])) ) . $m[3];'), $text); |
|
226 | + } |
|
212 | 227 | return $text; |
213 | 228 | } |
214 | 229 | |
@@ -268,7 +283,9 @@ discard block |
||
268 | 283 | if(isset($attribute['style']) && $attribute['style']) |
269 | 284 | { |
270 | 285 | $st = trim($attribute['style']); |
271 | - if(mb_substr($st, -1) != ";") $st .= ";"; |
|
286 | + if(mb_substr($st, -1) != ";") { |
|
287 | + $st .= ";"; |
|
288 | + } |
|
272 | 289 | $st .= $attribute['__style']; |
273 | 290 | $attribute['style'] = $st; |
274 | 291 | } else { |
@@ -280,7 +297,9 @@ discard block |
||
280 | 297 | } |
281 | 298 | foreach ($attribute as $attr => $value) |
282 | 299 | { |
283 | - if($attr == "__style") continue; |
|
300 | + if($attr == "__style") { |
|
301 | + continue; |
|
302 | + } |
|
284 | 303 | if($attr == "class") { |
285 | 304 | $classname = "$value"; |
286 | 305 | continue; |
@@ -331,7 +350,9 @@ discard block |
||
331 | 350 | foreach($needle as $n) |
332 | 351 | { |
333 | 352 | $p = strpos($haystack, $n , $offset); |
334 | - if($p===false) continue; |
|
353 | + if($p===false) { |
|
354 | + continue; |
|
355 | + } |
|
335 | 356 | if($m === false) |
336 | 357 | { |
337 | 358 | $m = $p; |
@@ -344,7 +365,9 @@ discard block |
||
344 | 365 | $w = $n; |
345 | 366 | } |
346 | 367 | } |
347 | - if($m === false) return false; |
|
368 | + if($m === false) { |
|
369 | + return false; |
|
370 | + } |
|
348 | 371 | return array('pos' => $m, 'str' => $w); |
349 | 372 | } |
350 | 373 | return strpos($haystack, $needle, $offset); |
@@ -352,14 +375,18 @@ discard block |
||
352 | 375 | |
353 | 376 | public static function _process_selector_pattern(&$pattern) |
354 | 377 | { |
355 | - if($pattern===false) return; |
|
378 | + if($pattern===false) { |
|
379 | + return; |
|
380 | + } |
|
356 | 381 | $pattern = preg_quote($pattern , '/'); |
357 | 382 | $pattern = str_replace("\\*", "[a-z0-9_\-]*", $pattern); |
358 | 383 | $pattern = "/".$pattern."/i"; |
359 | 384 | } |
360 | 385 | public static function _test_pattern($pattern, $text) |
361 | 386 | { |
362 | - if($pattern === false) return true; |
|
387 | + if($pattern === false) { |
|
388 | + return true; |
|
389 | + } |
|
363 | 390 | return preg_match($pattern, $text); |
364 | 391 | } |
365 | 392 | |
@@ -646,7 +673,9 @@ discard block |
||
646 | 673 | */ |
647 | 674 | public static function html_char_entity_to_unicode($entity) |
648 | 675 | { |
649 | - if(isset(self::$html4_char_ents[$entity])) return self::_getUnicodeChar(self::$html4_char_ents[$entity]); |
|
676 | + if(isset(self::$html4_char_ents[$entity])) { |
|
677 | + return self::_getUnicodeChar(self::$html4_char_ents[$entity]); |
|
678 | + } |
|
650 | 679 | return false; |
651 | 680 | } |
652 | 681 | |
@@ -682,13 +711,11 @@ discard block |
||
682 | 711 | if($found) |
683 | 712 | { |
684 | 713 | return $last_pos - 1; |
685 | - } |
|
686 | - else |
|
714 | + } else |
|
687 | 715 | { |
688 | 716 | return false; |
689 | 717 | } |
690 | - } |
|
691 | - else |
|
718 | + } else |
|
692 | 719 | { |
693 | 720 | return false; |
694 | 721 | } |
@@ -66,7 +66,9 @@ discard block |
||
66 | 66 | |
67 | 67 | private function log($str, $data = null) |
68 | 68 | { |
69 | - if(!$this->logging) return; |
|
69 | + if(!$this->logging) { |
|
70 | + return; |
|
71 | + } |
|
70 | 72 | $this->logs[] = array('info' => $str, 'data' => $data); |
71 | 73 | } |
72 | 74 | |
@@ -78,7 +80,9 @@ discard block |
||
78 | 80 | |
79 | 81 | public function debug($place, &$after_text) |
80 | 82 | { |
81 | - if(!$this->debug_enabled) return; |
|
83 | + if(!$this->debug_enabled) { |
|
84 | + return; |
|
85 | + } |
|
82 | 86 | $this->debug_info[] = array( |
83 | 87 | 'place' => $place, |
84 | 88 | 'text' => $after_text, |
@@ -95,7 +99,9 @@ discard block |
||
95 | 99 | */ |
96 | 100 | public function set_tag_layout_ifnotset($layout) |
97 | 101 | { |
98 | - if($this->use_layout_set) return; |
|
102 | + if($this->use_layout_set) { |
|
103 | + return; |
|
104 | + } |
|
99 | 105 | $this->use_layout = $layout; |
100 | 106 | } |
101 | 107 | |
@@ -132,8 +138,12 @@ discard block |
||
132 | 138 | |
133 | 139 | private function getmethod($name) |
134 | 140 | { |
135 | - if(!$name) return false; |
|
136 | - if(!method_exists($this, $name)) return false; |
|
141 | + if(!$name) { |
|
142 | + return false; |
|
143 | + } |
|
144 | + if(!method_exists($this, $name)) { |
|
145 | + return false; |
|
146 | + } |
|
137 | 147 | return array($this, $name); |
138 | 148 | } |
139 | 149 | |
@@ -142,9 +152,13 @@ discard block |
||
142 | 152 | $this->pre_parse(); |
143 | 153 | foreach($this->rules as $rule) |
144 | 154 | { |
145 | - if(!isset($rule['init'])) continue; |
|
155 | + if(!isset($rule['init'])) { |
|
156 | + continue; |
|
157 | + } |
|
146 | 158 | $m = $this->getmethod($rule['init']); |
147 | - if(!$m) continue; |
|
159 | + if(!$m) { |
|
160 | + continue; |
|
161 | + } |
|
148 | 162 | call_user_func($m); |
149 | 163 | } |
150 | 164 | } |
@@ -152,9 +166,13 @@ discard block |
||
152 | 166 | { |
153 | 167 | foreach($this->rules as $rule) |
154 | 168 | { |
155 | - if(!isset($rule['deinit'])) continue; |
|
169 | + if(!isset($rule['deinit'])) { |
|
170 | + continue; |
|
171 | + } |
|
156 | 172 | $m = $this->getmethod($rule['deinit']); |
157 | - if(!$m) continue; |
|
173 | + if(!$m) { |
|
174 | + continue; |
|
175 | + } |
|
158 | 176 | call_user_func($m); |
159 | 177 | } |
160 | 178 | $this->post_parse(); |
@@ -162,8 +180,12 @@ discard block |
||
162 | 180 | |
163 | 181 | private function rule_order_sort($a, $b) |
164 | 182 | { |
165 | - if($a['order'] == $b['order']) return 0; |
|
166 | - if($a['order'] < $b['order']) return -1; |
|
183 | + if($a['order'] == $b['order']) { |
|
184 | + return 0; |
|
185 | + } |
|
186 | + if($a['order'] < $b['order']) { |
|
187 | + return -1; |
|
188 | + } |
|
167 | 189 | return 1; |
168 | 190 | } |
169 | 191 | |
@@ -239,7 +261,9 @@ discard block |
||
239 | 261 | } |
240 | 262 | |
241 | 263 | $pattern = $rule['pattern']; |
242 | - if(is_string($pattern)) $pattern = array($pattern); |
|
264 | + if(is_string($pattern)) { |
|
265 | + $pattern = array($pattern); |
|
266 | + } |
|
243 | 267 | $eval = false; |
244 | 268 | foreach($pattern as $patt) |
245 | 269 | { |
@@ -257,7 +281,9 @@ discard block |
||
257 | 281 | |
258 | 282 | do { |
259 | 283 | $this->_text = preg_replace($rule['pattern'], $rule['replacement'], $this->_text); |
260 | - if(!(isset($rule['cycled']) && $rule['cycled'])) break; |
|
284 | + if(!(isset($rule['cycled']) && $rule['cycled'])) { |
|
285 | + break; |
|
286 | + } |
|
261 | 287 | } while(preg_match($rule['pattern'], $this->_text)); |
262 | 288 | |
263 | 289 | return; |
@@ -271,20 +297,26 @@ discard block |
||
271 | 297 | |
272 | 298 | $chr = substr($patt,0,1); |
273 | 299 | $preg_arr = explode($chr, $patt); |
274 | - if(strpos($preg_arr[count($preg_arr)-1], "e")!==false) // eval система |
|
300 | + if(strpos($preg_arr[count($preg_arr)-1], "e")!==false) { |
|
301 | + // eval система |
|
275 | 302 | { |
276 | 303 | $preg_arr[count($preg_arr)-1] = str_replace("e","",$preg_arr[count($preg_arr)-1]); |
304 | + } |
|
277 | 305 | $patt = implode($chr, $preg_arr); |
278 | 306 | $this->thereplacement = $repl; |
279 | 307 | do { |
280 | 308 | $this->_text = preg_replace_callback($patt, array($this, "thereplcallback"), $this->_text); |
281 | - if(!(isset($rule['cycled']) && $rule['cycled'])) break; |
|
309 | + if(!(isset($rule['cycled']) && $rule['cycled'])) { |
|
310 | + break; |
|
311 | + } |
|
282 | 312 | } while(preg_match($patt, $this->_text)); |
283 | 313 | |
284 | 314 | } else { |
285 | 315 | do { |
286 | 316 | $this->_text = preg_replace($patt, $repl, $this->_text); |
287 | - if(!(isset($rule['cycled']) && $rule['cycled'])) break; |
|
317 | + if(!(isset($rule['cycled']) && $rule['cycled'])) { |
|
318 | + break; |
|
319 | + } |
|
288 | 320 | } while(preg_match($patt, $this->_text)); |
289 | 321 | } |
290 | 322 | $k++; |
@@ -296,7 +328,9 @@ discard block |
||
296 | 328 | { |
297 | 329 | $chr = substr($pattern,0,1); |
298 | 330 | $preg_arr = explode($chr, $pattern); |
299 | - if(strpos($preg_arr[count($preg_arr)-1], "e")===false) return preg_replace($pattern, $replacement, $text); |
|
331 | + if(strpos($preg_arr[count($preg_arr)-1], "e")===false) { |
|
332 | + return preg_replace($pattern, $replacement, $text); |
|
333 | + } |
|
300 | 334 | $preg_arr[count($preg_arr)-1] = str_replace("e","",$preg_arr[count($preg_arr)-1]); |
301 | 335 | $patt = implode($chr, $preg_arr); |
302 | 336 | $this->thereplacement = $replacement; |
@@ -364,7 +398,9 @@ discard block |
||
364 | 398 | if(isset($this->classes[$classname])) |
365 | 399 | { |
366 | 400 | $style_inline = $this->classes[$classname]; |
367 | - if($style_inline) $attribute['__style'] = $style_inline; |
|
401 | + if($style_inline) { |
|
402 | + $attribute['__style'] = $style_inline; |
|
403 | + } |
|
368 | 404 | } |
369 | 405 | $classname = (isset($this->class_names[$classname]) ? $this->class_names[$classname] :$classname); |
370 | 406 | $classname = ($this->class_layout_prefix ? $this->class_layout_prefix : "" ).$classname; |
@@ -428,7 +464,9 @@ discard block |
||
428 | 464 | */ |
429 | 465 | public function is_on($key) |
430 | 466 | { |
431 | - if(!isset($this->settings[$key])) return false; |
|
467 | + if(!isset($this->settings[$key])) { |
|
468 | + return false; |
|
469 | + } |
|
432 | 470 | $kk = $this->settings[$key]; |
433 | 471 | return ((strtolower($kk)=="on") || ($kk === "1") || ($kk === true) || ($kk === 1)); |
434 | 472 | } |
@@ -441,7 +479,9 @@ discard block |
||
441 | 479 | */ |
442 | 480 | public function ss($key) |
443 | 481 | { |
444 | - if(!isset($this->settings[$key])) return ""; |
|
482 | + if(!isset($this->settings[$key])) { |
|
483 | + return ""; |
|
484 | + } |
|
445 | 485 | return strval($this->settings[$key]); |
446 | 486 | } |
447 | 487 | |
@@ -466,19 +506,31 @@ discard block |
||
466 | 506 | */ |
467 | 507 | public function activate($list,$disable =false, $strict = true) |
468 | 508 | { |
469 | - if(!is_array($list)) return ; |
|
509 | + if(!is_array($list)) { |
|
510 | + return ; |
|
511 | + } |
|
470 | 512 | |
471 | 513 | foreach($list as $rulename) |
472 | 514 | { |
473 | - if($disable) $this->disable_rule($rulename); else $this->enable_rule($rulename); |
|
515 | + if($disable) { |
|
516 | + $this->disable_rule($rulename); |
|
517 | + } else { |
|
518 | + $this->enable_rule($rulename); |
|
519 | + } |
|
474 | 520 | } |
475 | 521 | |
476 | 522 | if($strict) |
477 | 523 | { |
478 | 524 | foreach($this->rules as $rulename => $v) |
479 | 525 | { |
480 | - if(in_array($rulename, $list)) continue; |
|
481 | - if(!$disable) $this->disable_rule($rulename); else $this->enable_rule($rulename); |
|
526 | + if(in_array($rulename, $list)) { |
|
527 | + continue; |
|
528 | + } |
|
529 | + if(!$disable) { |
|
530 | + $this->disable_rule($rulename); |
|
531 | + } else { |
|
532 | + $this->enable_rule($rulename); |
|
533 | + } |
|
482 | 534 | } |
483 | 535 | } |
484 | 536 | } |
@@ -500,9 +552,13 @@ discard block |
||
500 | 552 | */ |
501 | 553 | public function apply($list = null) |
502 | 554 | { |
503 | - if(is_string($list)) $rlist = array($list); |
|
504 | - elseif(is_array($list)) $rlist = $list; |
|
505 | - else $rlist = array_keys($this->rules); |
|
555 | + if(is_string($list)) { |
|
556 | + $rlist = array($list); |
|
557 | + } elseif(is_array($list)) { |
|
558 | + $rlist = $list; |
|
559 | + } else { |
|
560 | + $rlist = array_keys($this->rules); |
|
561 | + } |
|
506 | 562 | $this->_apply($rlist); |
507 | 563 | return $this->_text; |
508 | 564 | } |