@@ -21,7 +21,7 @@ |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($this->configs[$config])) { |
24 | - throw new InvalidConfigurationException('Typograph\'s config "'. $config .'" doesn\'t exist'); |
|
24 | + throw new InvalidConfigurationException('Typograph\'s config "'.$config.'" doesn\'t exist'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | return EMTypograph::fast_apply($string, $this->configs[$config]); |
@@ -112,7 +112,7 @@ |
||
112 | 112 | |
113 | 113 | foreach ($triad as $value) { |
114 | 114 | $value = (int) $value; |
115 | - if ($value > 255) { |
|
115 | + if ($value>255) { |
|
116 | 116 | $addTag = false; |
117 | 117 | break; |
118 | 118 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | 'math_chars' => array( |
54 | 54 | 'description' => 'Математические знаки больше/меньше/плюс минус/неравно', |
55 | 55 | 'pattern' => array('/!=/', '/\<=/', '/([^=]|^)\>=/', '/~=/', '/\+-/'), |
56 | - 'replacement' => array('≠', '≤', '\1≥', '≅', '±' ) |
|
56 | + 'replacement' => array('≠', '≤', '\1≥', '≅', '±') |
|
57 | 57 | ), |
58 | 58 | /* |
59 | 59 | 'split_number_to_triads' => array( |
@@ -83,7 +83,7 @@ |
||
83 | 83 | 'arrows_symbols' => array( |
84 | 84 | 'description' => 'Замена стрелок вправо-влево на html коды', |
85 | 85 | 'pattern' => array('/(\s|\>|\ \;|^)\-\>($|\s|\ \;|\<)/', '/(\s|\>|\ \;|^|;)\<\-(\s|\ \;|$)/', '/→/u', '/←/u'), |
86 | - 'replacement' => array('\1→\2', '\1←\2', '→', '←' ) |
|
86 | + 'replacement' => array('\1→\2', '\1←\2', '→', '←') |
|
87 | 87 | ), |
88 | 88 | ); |
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -76,7 +76,7 @@ |
||
76 | 76 | protected function oaquote_extra() |
77 | 77 | { |
78 | 78 | $this->_text = $this->preg_replace_e( |
79 | - '/(<' .self::BASE64_PARAGRAPH_TAG . '>)([\040\t]+)?(\«\;)/e', |
|
79 | + '/(<'.self::BASE64_PARAGRAPH_TAG.'>)([\040\t]+)?(\«\;)/e', |
|
80 | 80 | '$m[1] . $this->tag($m[3], "span", array("class"=>"oa_oquote_nl"))', |
81 | 81 | $this->_text); |
82 | 82 | } |
@@ -70,14 +70,14 @@ |
||
70 | 70 | $match = '/(^|[^a-zа-яё])([a-zа-яё]+)\ \;('.$b.')/iu'; |
71 | 71 | do { |
72 | 72 | $this->_text = preg_replace($match, '\1\3\2 ', $this->_text); |
73 | - } while(preg_match($match, $this->_text)); |
|
73 | + } while (preg_match($match, $this->_text)); |
|
74 | 74 | |
75 | 75 | $match = '/('.$e.')\ \;([a-zа-яё]+)($|[^a-zа-яё])/iu'; |
76 | 76 | do { |
77 | 77 | $this->_text = preg_replace($match, ' \2\1\3', $this->_text); |
78 | - } while(preg_match($match, $this->_text)); |
|
78 | + } while (preg_match($match, $this->_text)); |
|
79 | 79 | |
80 | - $this->_text = $this->preg_replace_e('/'.$b.'.*?'.$e.'/iue', 'str_replace(" "," ",$m[0]);' , $this->_text ); |
|
80 | + $this->_text = $this->preg_replace_e('/'.$b.'.*?'.$e.'/iue', 'str_replace(" "," ",$m[0]);', $this->_text); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | ); |
28 | 28 | |
29 | 29 | |
30 | - protected $group_list = array( |
|
30 | + protected $group_list = array( |
|
31 | 31 | 'Quote' => true, |
32 | 32 | 'Dash' => true, |
33 | 33 | 'Nobr' => true, |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | ); |
44 | 44 | protected $all_options = array( |
45 | 45 | |
46 | - 'Quote.quotes' => array( 'description' => 'Расстановка «кавычек-елочек» первого уровня', 'selector' => "Quote.*quote" ), |
|
47 | - 'Quote.quotation' => array( 'description' => 'Внутренние кавычки-лапки', 'selector' => "Quote", 'setting' => 'no_bdquotes', 'reversed' => true ), |
|
46 | + 'Quote.quotes' => array('description' => 'Расстановка «кавычек-елочек» первого уровня', 'selector' => "Quote.*quote"), |
|
47 | + 'Quote.quotation' => array('description' => 'Внутренние кавычки-лапки', 'selector' => "Quote", 'setting' => 'no_bdquotes', 'reversed' => true), |
|
48 | 48 | |
49 | 49 | 'Dash.to_libo_nibud' => 'direct', |
50 | 50 | 'Dash.iz_za_pod' => 'direct', |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'Nobr.nbsp_celcius' => 'direct', |
59 | 59 | 'Nobr.hyphen_nowrap_in_small_words' => 'direct', |
60 | 60 | 'Nobr.hyphen_nowrap' => 'direct', |
61 | - 'Nobr.nowrap' => array('description' => 'Nobr (по умолчанию) & nowrap', 'disabled' => true, 'selector' => '*', 'setting' => 'nowrap' ), |
|
61 | + 'Nobr.nowrap' => array('description' => 'Nobr (по умолчанию) & nowrap', 'disabled' => true, 'selector' => '*', 'setting' => 'nowrap'), |
|
62 | 62 | |
63 | 63 | 'Symbol.tm_replace' => 'direct', |
64 | 64 | 'Symbol.r_sign_replace' => 'direct', |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'Symbol.apostrophe' => 'direct', |
67 | 67 | 'Symbol.degree_f' => 'direct', |
68 | 68 | 'Symbol.arrows_symbols' => 'direct', |
69 | - 'Symbol.no_inches' => array( 'description' => 'Расстановка дюйма после числа', 'selector' => "Quote", 'setting' => 'no_inches', 'reversed' => true ), |
|
69 | + 'Symbol.no_inches' => array('description' => 'Расстановка дюйма после числа', 'selector' => "Quote", 'setting' => 'no_inches', 'reversed' => true), |
|
70 | 70 | |
71 | 71 | 'Punctmark.auto_comma' => 'direct', |
72 | 72 | 'Punctmark.hellip' => 'direct', |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | |
92 | 92 | 'Space.many_spaces_to_one' => 'direct', |
93 | 93 | 'Space.clear_percent' => 'direct', |
94 | - 'Space.clear_before_after_punct' => array( 'description' => 'Удаление пробелов перед и после знаков препинания в предложении', 'selector' => 'Space.remove_space_before_punctuationmarks'), |
|
95 | - 'Space.autospace_after' => array( 'description' => 'Расстановка пробелов после знаков препинания', 'selector' => 'Space.autospace_after_*'), |
|
96 | - 'Space.bracket_fix' => array( 'description' => 'Удаление пробелов внутри скобок, а также расстановка пробела перед скобками', |
|
94 | + 'Space.clear_before_after_punct' => array('description' => 'Удаление пробелов перед и после знаков препинания в предложении', 'selector' => 'Space.remove_space_before_punctuationmarks'), |
|
95 | + 'Space.autospace_after' => array('description' => 'Расстановка пробелов после знаков препинания', 'selector' => 'Space.autospace_after_*'), |
|
96 | + 'Space.bracket_fix' => array('description' => 'Удаление пробелов внутри скобок, а также расстановка пробела перед скобками', |
|
97 | 97 | 'selector' => array('Space.nbsp_before_open_quote', 'Punctmark.fix_brackets')), |
98 | 98 | |
99 | 99 | 'Abbr.nbsp_money_abbr' => 'direct', |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | 'Abbr.nobr_before_unit_volt' => 'direct', |
109 | 109 | 'Abbr.nbsp_before_unit' => 'direct', |
110 | 110 | |
111 | - 'OptAlign.all' => array( 'description' => 'Все настройки оптического выравнивания', 'hide' => true, 'selector' => 'OptAlign.*'), |
|
111 | + 'OptAlign.all' => array('description' => 'Все настройки оптического выравнивания', 'hide' => true, 'selector' => 'OptAlign.*'), |
|
112 | 112 | 'OptAlign.oa_oquote' => 'direct', |
113 | 113 | 'OptAlign.oa_obracket_coma' => 'direct', |
114 | 114 | 'OptAlign.oa_oquote_extra' => 'direct', |
115 | - 'OptAlign.layout' => array( 'description' => 'Inline стили или CSS' ), |
|
115 | + 'OptAlign.layout' => array('description' => 'Inline стили или CSS'), |
|
116 | 116 | |
117 | 117 | 'Text.paragraphs' => 'direct', |
118 | 118 | 'Text.auto_links' => 'direct', |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | |
124 | 124 | //'Etc.no_nbsp_in_nobr' => 'direct', |
125 | - 'Etc.unicode_convert' => array('description' => 'Преобразовывать html-сущности в юникод', 'selector' => '*', 'setting' => 'dounicode' , 'disabled' => true), |
|
125 | + 'Etc.unicode_convert' => array('description' => 'Преобразовывать html-сущности в юникод', 'selector' => '*', 'setting' => 'dounicode', 'disabled' => true), |
|
126 | 126 | |
127 | 127 | ); |
128 | 128 | |
@@ -137,25 +137,25 @@ discard block |
||
137 | 137 | { |
138 | 138 | $arr['all'] = array(); |
139 | 139 | $bygroup = array(); |
140 | - foreach($this->all_options as $opt => $op) |
|
140 | + foreach ($this->all_options as $opt => $op) |
|
141 | 141 | { |
142 | 142 | $arr['all'][$opt] = $this->get_option_info($opt); |
143 | - $x = explode(".",$opt); |
|
143 | + $x = explode(".", $opt); |
|
144 | 144 | $bygroup[$x[0]][] = $opt; |
145 | 145 | } |
146 | 146 | $arr['group'] = array(); |
147 | - foreach($this->group_list as $group => $ginfo) |
|
147 | + foreach ($this->group_list as $group => $ginfo) |
|
148 | 148 | { |
149 | - if($ginfo === true) |
|
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) $info['title'] = $tret->title; else $info['title'] = "Не определено"; |
|
153 | 153 | } else { |
154 | 154 | $info = $ginfo; |
155 | 155 | } |
156 | 156 | $info['name'] = $group; |
157 | 157 | $info['options'] = array(); |
158 | - if(is_array($bygroup[$group])) foreach($bygroup[$group] as $opt) $info['options'][] = $opt; |
|
158 | + if (is_array($bygroup[$group])) foreach ($bygroup[$group] as $opt) $info['options'][] = $opt; |
|
159 | 159 | $arr['group'][] = $info; |
160 | 160 | } |
161 | 161 | return $arr; |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function get_option_info($key) |
172 | 172 | { |
173 | - if(!isset($this->all_options[$key])) return false; |
|
174 | - if(is_array($this->all_options[$key])) return $this->all_options[$key]; |
|
173 | + if (!isset($this->all_options[$key])) return false; |
|
174 | + if (is_array($this->all_options[$key])) return $this->all_options[$key]; |
|
175 | 175 | |
176 | - if(($this->all_options[$key] == "direct") || ($this->all_options[$key] == "reverse")) |
|
176 | + if (($this->all_options[$key] == "direct") || ($this->all_options[$key] == "reverse")) |
|
177 | 177 | { |
178 | 178 | $pa = explode(".", $key); |
179 | 179 | $tret_pattern = $pa[0]; |
180 | 180 | $tret = $this->get_tret($tret_pattern); |
181 | - if(!$tret) return false; |
|
182 | - if(!isset($tret->rules[$pa[1]])) return false; |
|
181 | + if (!$tret) return false; |
|
182 | + if (!isset($tret->rules[$pa[1]])) return false; |
|
183 | 183 | $array = $tret->rules[$pa[1]]; |
184 | 184 | $array['way'] = $this->all_options[$key]; |
185 | 185 | return $array; |
@@ -196,28 +196,28 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function do_setup($name, $value) |
198 | 198 | { |
199 | - if(!isset($this->all_options[$name])) return; |
|
199 | + if (!isset($this->all_options[$name])) return; |
|
200 | 200 | |
201 | 201 | // эта настрока связана с правилом ядра |
202 | - if(is_string($this->all_options[$name])) |
|
202 | + if (is_string($this->all_options[$name])) |
|
203 | 203 | { |
204 | - $this->set($name, "active", $value ); |
|
205 | - return ; |
|
204 | + $this->set($name, "active", $value); |
|
205 | + return; |
|
206 | 206 | } |
207 | - if(is_array($this->all_options[$name])) |
|
207 | + if (is_array($this->all_options[$name])) |
|
208 | 208 | { |
209 | - if(isset($this->all_options[$name]['selector'])) |
|
209 | + if (isset($this->all_options[$name]['selector'])) |
|
210 | 210 | { |
211 | 211 | $settingname = "active"; |
212 | - if(isset($this->all_options[$name]['setting'])) $settingname = $this->all_options[$name]['setting']; |
|
212 | + if (isset($this->all_options[$name]['setting'])) $settingname = $this->all_options[$name]['setting']; |
|
213 | 213 | $this->set($this->all_options[$name]['selector'], $settingname, $value); |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if($name == "OptAlign.layout") |
|
217 | + if ($name == "OptAlign.layout") |
|
218 | 218 | { |
219 | - if($value == "style") $this->set_tag_layout(EMTLib::LAYOUT_STYLE); |
|
220 | - if($value == "class") $this->set_tag_layout(EMTLib::LAYOUT_CLASS); |
|
219 | + if ($value == "style") $this->set_tag_layout(EMTLib::LAYOUT_STYLE); |
|
220 | + if ($value == "class") $this->set_tag_layout(EMTLib::LAYOUT_CLASS); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public static function fast_apply($text, $options = null) |
233 | 233 | { |
234 | 234 | $obj = new self(); |
235 | - if(is_array($options)) $obj->setup($options); |
|
235 | + if (is_array($options)) $obj->setup($options); |
|
236 | 236 | $obj->set_text($text); |
237 | 237 | return $obj->apply(); |
238 | 238 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | { |
18 | 18 | public $title = "Расстановка и удаление пробелов"; |
19 | 19 | |
20 | - public $domain_zones = array('ru','ру','ком','орг', 'уа', 'ua', 'uk', 'co', 'fr', |
|
20 | + public $domain_zones = array('ru', 'ру', 'ком', 'орг', 'уа', 'ua', 'uk', 'co', 'fr', |
|
21 | 21 | 'com', 'net', 'edu', 'gov', 'org', 'mil', 'int', 'info', 'biz', 'info', 'name', 'pro'); |
22 | 22 | |
23 | 23 | public $classes = array( |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | * @return void |
66 | 66 | */ |
67 | 67 | protected function do_paragraphs($text) { |
68 | - $text = str_replace("\r\n","\n",$text); |
|
69 | - $text = str_replace("\r","\n",$text); |
|
70 | - $text = '<' . self::BASE64_PARAGRAPH_TAG . '>' . trim($text) . '</' . self::BASE64_PARAGRAPH_TAG . '>'; |
|
68 | + $text = str_replace("\r\n", "\n", $text); |
|
69 | + $text = str_replace("\r", "\n", $text); |
|
70 | + $text = '<'.self::BASE64_PARAGRAPH_TAG.'>'.trim($text).'</'.self::BASE64_PARAGRAPH_TAG.'>'; |
|
71 | 71 | //$text = $this->preg_replace_e('/([\040\t]+)?(\n|\r){2,}/e', '"</" . self::BASE64_PARAGRAPH_TAG . "><" .self::BASE64_PARAGRAPH_TAG . ">"', $text); |
72 | 72 | //$text = $this->preg_replace_e('/([\040\t]+)?(\n){2,}/e', '"</" . self::BASE64_PARAGRAPH_TAG . "><" .self::BASE64_PARAGRAPH_TAG . ">"', $text); |
73 | 73 | $text = $this->preg_replace_e('/([\040\t]+)?(\n)+([\040\t]*)(\n)+/e', '$m[1]."</" . self::BASE64_PARAGRAPH_TAG . ">".\Fenrizbes\TypographBundle\EMT\EMTLib::iblock($m[2].$m[3])."<" .self::BASE64_PARAGRAPH_TAG . ">"', $text); |
74 | 74 | //$text = $this->preg_replace_e('/([\040\t]+)?(\n)+([\040\t]*)(\n)+/e', '"</" . self::BASE64_PARAGRAPH_TAG . ">"."<" .self::BASE64_PARAGRAPH_TAG . ">"', $text); |
75 | 75 | //может от открвающего до закрывающего ?! |
76 | - $text = preg_replace('/\<' . self::BASE64_PARAGRAPH_TAG . '\>('.EMTLib::INTERNAL_BLOCK_OPEN.'[a-zA-Z0-9\/=]+?'.EMTLib::INTERNAL_BLOCK_CLOSE.')?\<\/' . self::BASE64_PARAGRAPH_TAG . '\>/s', "", $text); |
|
76 | + $text = preg_replace('/\<'.self::BASE64_PARAGRAPH_TAG.'\>('.EMTLib::INTERNAL_BLOCK_OPEN.'[a-zA-Z0-9\/=]+?'.EMTLib::INTERNAL_BLOCK_CLOSE.')?\<\/'.self::BASE64_PARAGRAPH_TAG.'\>/s', "", $text); |
|
77 | 77 | return $text; |
78 | 78 | } |
79 | 79 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function build_paragraphs() |
86 | 86 | { |
87 | - $r = mb_strpos($this->_text, '<' . self::BASE64_PARAGRAPH_TAG . '>' ); |
|
88 | - $p = EMTLib::rstrpos($this->_text, '</' . self::BASE64_PARAGRAPH_TAG . '>' ) ; |
|
89 | - if(($r!== false) && ($p !== false)) { |
|
87 | + $r = mb_strpos($this->_text, '<'.self::BASE64_PARAGRAPH_TAG.'>'); |
|
88 | + $p = EMTLib::rstrpos($this->_text, '</'.self::BASE64_PARAGRAPH_TAG.'>'); |
|
89 | + if (($r !== false) && ($p !== false)) { |
|
90 | 90 | |
91 | - $beg = mb_substr($this->_text,0,$r); |
|
92 | - $end = mb_substr($this->_text,$p+mb_strlen('</' . self::BASE64_PARAGRAPH_TAG . '>')); |
|
91 | + $beg = mb_substr($this->_text, 0, $r); |
|
92 | + $end = mb_substr($this->_text, $p+mb_strlen('</'.self::BASE64_PARAGRAPH_TAG.'>')); |
|
93 | 93 | $this->_text = |
94 | - (trim($beg) ? $this->do_paragraphs($beg). "\n":"") .'<' . self::BASE64_PARAGRAPH_TAG . '>'. |
|
95 | - mb_substr($this->_text,$r + mb_strlen('<' . self::BASE64_PARAGRAPH_TAG . '>'),$p -($r + mb_strlen('<' . self::BASE64_PARAGRAPH_TAG . '>')) ).'</' . self::BASE64_PARAGRAPH_TAG . '>'. |
|
96 | - (trim($end) ? "\n".$this->do_paragraphs($end) :"") ; |
|
94 | + (trim($beg) ? $this->do_paragraphs($beg)."\n" : "").'<'.self::BASE64_PARAGRAPH_TAG.'>'. |
|
95 | + mb_substr($this->_text, $r+mb_strlen('<'.self::BASE64_PARAGRAPH_TAG.'>'), $p-($r+mb_strlen('<'.self::BASE64_PARAGRAPH_TAG.'>'))).'</'.self::BASE64_PARAGRAPH_TAG.'>'. |
|
96 | + (trim($end) ? "\n".$this->do_paragraphs($end) : ""); |
|
97 | 97 | } else { |
98 | 98 | $this->_text = $this->do_paragraphs($this->_text); |
99 | 99 | } |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function build_brs() |
108 | 108 | { |
109 | - $this->_text = $this->preg_replace_e('/(\<\/' . self::BASE64_PARAGRAPH_TAG . '\>)([\r\n \t]+)(\<' . self::BASE64_PARAGRAPH_TAG . '\>)/mse', '$m[1].\Fenrizbes\TypographBundle\EMT\EMTLib::iblock($m[2]).$m[3]', $this->_text); |
|
109 | + $this->_text = $this->preg_replace_e('/(\<\/'.self::BASE64_PARAGRAPH_TAG.'\>)([\r\n \t]+)(\<'.self::BASE64_PARAGRAPH_TAG.'\>)/mse', '$m[1].\Fenrizbes\TypographBundle\EMT\EMTLib::iblock($m[2]).$m[3]', $this->_text); |
|
110 | 110 | |
111 | - if (!preg_match('/\<' . self::BASE64_BREAKLINE_TAG . '\>/', $this->_text)) { |
|
112 | - $this->_text = str_replace("\r\n","\n",$this->_text); |
|
113 | - $this->_text = str_replace("\r","\n",$this->_text); |
|
111 | + if (!preg_match('/\<'.self::BASE64_BREAKLINE_TAG.'\>/', $this->_text)) { |
|
112 | + $this->_text = str_replace("\r\n", "\n", $this->_text); |
|
113 | + $this->_text = str_replace("\r", "\n", $this->_text); |
|
114 | 114 | //$this->_text = $this->preg_replace_e('/(\n|\r)/e', '"<" . self::BASE64_BREAKLINE_TAG . ">"', $this->_text); |
115 | 115 | $this->_text = $this->preg_replace_e('/(\n)/e', '"<" . self::BASE64_BREAKLINE_TAG . ">\n"', $this->_text); |
116 | 116 | } |