@@ -12,19 +12,19 @@ |
||
| 12 | 12 | class EMTypograph extends EMTBase |
| 13 | 13 | {
|
| 14 | 14 | public $trets = array( |
| 15 | - '\Fenrizbes\TypographBundle\EMT\EMTTretQuote', |
|
| 16 | - '\Fenrizbes\TypographBundle\EMT\EMTTretDash', |
|
| 17 | - '\Fenrizbes\TypographBundle\EMT\EMTTretSymbol', |
|
| 18 | - '\Fenrizbes\TypographBundle\EMT\EMTTretPunctmark', |
|
| 19 | - '\Fenrizbes\TypographBundle\EMT\EMTTretNumber', |
|
| 20 | - '\Fenrizbes\TypographBundle\EMT\EMTTretSpace', |
|
| 21 | - '\Fenrizbes\TypographBundle\EMT\EMTTretAbbr', |
|
| 22 | - '\Fenrizbes\TypographBundle\EMT\EMTTretNobr', |
|
| 23 | - '\Fenrizbes\TypographBundle\EMT\EMTTretDate', |
|
| 24 | - '\Fenrizbes\TypographBundle\EMT\EMTTretOptAlign', |
|
| 25 | - '\Fenrizbes\TypographBundle\EMT\EMTTretEtc', |
|
| 26 | - '\Fenrizbes\TypographBundle\EMT\EMTTretText' |
|
| 27 | - ); |
|
| 15 | + '\Fenrizbes\TypographBundle\EMT\EMTTretQuote', |
|
| 16 | + '\Fenrizbes\TypographBundle\EMT\EMTTretDash', |
|
| 17 | + '\Fenrizbes\TypographBundle\EMT\EMTTretSymbol', |
|
| 18 | + '\Fenrizbes\TypographBundle\EMT\EMTTretPunctmark', |
|
| 19 | + '\Fenrizbes\TypographBundle\EMT\EMTTretNumber', |
|
| 20 | + '\Fenrizbes\TypographBundle\EMT\EMTTretSpace', |
|
| 21 | + '\Fenrizbes\TypographBundle\EMT\EMTTretAbbr', |
|
| 22 | + '\Fenrizbes\TypographBundle\EMT\EMTTretNobr', |
|
| 23 | + '\Fenrizbes\TypographBundle\EMT\EMTTretDate', |
|
| 24 | + '\Fenrizbes\TypographBundle\EMT\EMTTretOptAlign', |
|
| 25 | + '\Fenrizbes\TypographBundle\EMT\EMTTretEtc', |
|
| 26 | + '\Fenrizbes\TypographBundle\EMT\EMTTretText' |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | protected $group_list = array( |
@@ -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 | } |
@@ -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 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | public $title = "Расстановка и удаление пробелов"; |
| 19 | 19 | |
| 20 | 20 | public $domain_zones = array('ru','ру','ком','орг', 'уа', 'ua', 'uk', 'co', 'fr',
|
| 21 | - 'com', 'net', 'edu', 'gov', 'org', 'mil', 'int', 'info', 'biz', 'info', 'name', 'pro'); |
|
| 21 | + 'com', 'net', 'edu', 'gov', 'org', 'mil', 'int', 'info', 'biz', 'info', 'name', 'pro'); |
|
| 22 | 22 | |
| 23 | 23 | public $classes = array( |
| 24 | 24 | 'nowrap' => 'word-spacing:nowrap;', |
@@ -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( |
@@ -15,178 +15,178 @@ |
||
| 15 | 15 | |
| 16 | 16 | class EMTTretQuote extends EMTTret |
| 17 | 17 | {
|
| 18 | - /** |
|
| 19 | - * Базовые параметры тофа |
|
| 20 | - * |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - public $title = "Кавычки"; |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - public $rules = array( |
|
| 27 | - 'quotes_outside_a' => array( |
|
| 28 | - 'description' => 'Кавычки вне тэга <a>', |
|
| 29 | - //'pattern' => '/(\<%%\_\_.+?\>)\"(.+?)\"(\<\/%%\_\_.+?\>)/s', |
|
| 30 | - 'pattern' => '/(\<%%\_\_[^\>]+\>)\"(.+?)\"(\<\/%%\_\_[^\>]+\>)/s', |
|
| 31 | - 'replacement' => '"\1\2\3"' |
|
| 32 | - ), |
|
| 33 | - |
|
| 34 | - 'open_quote' => array( |
|
| 35 | - 'description' => 'Открывающая кавычка', |
|
| 36 | - 'pattern' => '/(^|\(|\s|\>|-)((\"|\\\")+)(\S+)/iue', |
|
| 37 | - 'replacement' => '$m[1] . str_repeat(self::QUOTE_FIRS_OPEN, substr_count($m[2],"\"") ) . $m[4]' |
|
| 38 | - ), |
|
| 39 | - 'close_quote' => array( |
|
| 40 | - 'description' => 'Закрывающая кавычка', |
|
| 41 | - 'pattern' => '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)((\"|\\\")+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|\<|$)/uie', |
|
| 42 | - 'replacement' => '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"") ) . $m[4]' |
|
| 43 | - ), |
|
| 44 | - 'close_quote_adv' => array( |
|
| 45 | - 'description' => 'Закрывающая кавычка особые случаи', |
|
| 46 | - //'pattern' => '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:)((\"|\\\"|\«\;)+)(\<.+?\>)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|$)/uie', |
|
| 47 | - 'pattern' => |
|
| 48 | - array( |
|
| 49 | - '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)((\"|\\\"|\«\;)+)(\<[^\>]+\>)(\.|\&hellip\;|\;|\:|\?|\!|\,|\)|\<\/|$| )/uie', |
|
| 50 | - '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)(\s+)((\"|\\\")+)(\s+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\)|\<\/|$| )/uie', |
|
| 51 | - '/\>(\«\;)\.($|\s|\<)/ui', |
|
| 52 | - '/\>(\«\;),($|\s|\<|\S)/ui', |
|
| 53 | - '/\>(\«\;):($|\s|\<|\S)/ui', |
|
| 54 | - '/\>(\«\;);($|\s|\<|\S)/ui', |
|
| 55 | - '/\>(\«\;)\)($|\s|\<|\S)/ui', |
|
| 56 | - '/((\"|\\\")+)$/uie', |
|
| 57 | - ), |
|
| 58 | - 'replacement' => |
|
| 59 | - array( |
|
| 60 | - '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"")+substr_count($m[2],"«") ) . $m[4]. $m[5]', |
|
| 61 | - '$m[1] .$m[2]. str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[3],"\"")+substr_count($m[3],"«") ) . $m[5]. $m[6]', |
|
| 62 | - '>».\2', |
|
| 63 | - '>»,\2', |
|
| 64 | - '>»:\2', |
|
| 65 | - '>»;\2', |
|
| 66 | - '>»)\2', |
|
| 67 | - 'str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[1],"\"") )', |
|
| 68 | - ), |
|
| 69 | - ), |
|
| 70 | - 'open_quote_adv' => array( |
|
| 71 | - 'description' => 'Открывающая кавычка особые случаи', |
|
| 72 | - 'pattern' => '/(^|\(|\s|\>)(\"|\\\")(\s)(\S+)/iue', |
|
| 73 | - 'replacement' => '$m[1] . self::QUOTE_FIRS_OPEN .$m[4]' |
|
| 74 | - ), |
|
| 75 | - 'close_quote_adv_2' => array( |
|
| 76 | - 'description' => 'Закрывающая кавычка последний шанс', |
|
| 77 | - 'pattern' => '/(\S)((\"|\\\")+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|\<|$)/uie', |
|
| 78 | - 'replacement' => '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"") ) . $m[4]' |
|
| 79 | - ), |
|
| 80 | - 'quotation' => array( |
|
| 81 | - 'description' => 'Внутренние кавычки-лапки и дюймы', |
|
| 82 | - 'function' => 'build_sub_quotations' |
|
| 83 | - ), |
|
| 84 | - ); |
|
| 85 | - |
|
| 86 | - protected function inject_in($pos, $text, &$thetext) |
|
| 87 | - {
|
|
| 88 | - for($i=0;$i<strlen($text);$i++) $thetext[$pos+$i] = $text[$i]; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - protected function build_sub_quotations() |
|
| 92 | - {
|
|
| 93 | - global $__ax,$__ay; |
|
| 94 | - |
|
| 95 | - $exp = strpos($this->_text, "</cA===>")!==false ? "</cA===>" : (strpos($this->_text,"\r\n")!==false ? "\r\n\r\n" :"\n\n"); |
|
| 96 | - |
|
| 97 | - $texts_in = explode($exp, $this->_text); |
|
| 98 | - $texts_out = array(); |
|
| 99 | - |
|
| 100 | - foreach($texts_in as $textx) {
|
|
| 101 | - |
|
| 102 | - $okposstack = array('0');
|
|
| 103 | - $okpos = 0; |
|
| 104 | - $level = 0; |
|
| 105 | - $off = 0; |
|
| 106 | - while(true) |
|
| 107 | - {
|
|
| 108 | - $p = EMTLib::strpos_ex($textx, array("«", "»"), $off);
|
|
| 109 | - if($p===false) break; |
|
| 110 | - if($p['str'] == "«") |
|
| 111 | - {
|
|
| 112 | - if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx);
|
|
| 113 | - $level++; |
|
| 114 | - } |
|
| 115 | - if($p['str'] == "»") |
|
| 116 | - {
|
|
| 117 | - $level--; |
|
| 118 | - if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx);
|
|
| 119 | - } |
|
| 120 | - $off = $p['pos']+strlen($p['str']); |
|
| 121 | - if($level == 0) |
|
| 122 | - {
|
|
| 123 | - $okpos = $off; |
|
| 124 | - array_push($okposstack, $okpos); |
|
| 125 | - } elseif($level<0) // уровень стал меньше нуля |
|
| 126 | - {
|
|
| 127 | - if(!$this->is_on('no_inches'))
|
|
| 128 | - {
|
|
| 129 | - do{
|
|
| 130 | - $lokpos = array_pop($okposstack); |
|
| 131 | - $k = substr($textx, $lokpos, $off-$lokpos); |
|
| 132 | - $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
|
| 133 | - $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k); |
|
| 134 | - //$k = preg_replace("/(^|[^0-9])([0-9]+)\»\;/ui", '\1\2″', $k, 1, $amount);
|
|
| 135 | - |
|
| 136 | - $amount = 0; |
|
| 137 | - $__ax = preg_match_all("/(^|[^0-9])([0-9]+)\»\;/ui", $k, $m);
|
|
| 138 | - $__ay = 0; |
|
| 139 | - if($__ax) |
|
| 140 | - {
|
|
| 141 | - $k = preg_replace_callback("/(^|[^0-9])([0-9]+)\»\;/ui",
|
|
| 142 | - create_function('$m','global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."″";} return $m[0];'),
|
|
| 143 | - $k); |
|
| 144 | - $amount = 1; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - } while(($amount==0) && count($okposstack)); |
|
| 150 | - |
|
| 151 | - // успешно сделали замену |
|
| 152 | - if($amount == 1) |
|
| 153 | - {
|
|
| 154 | - // заново просмотрим содержимое |
|
| 155 | - $textx = substr($textx, 0, $lokpos). $k . substr($textx, $off); |
|
| 156 | - $off = $lokpos; |
|
| 157 | - $level = 0; |
|
| 158 | - continue; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // иначе просто заменим последнюю явно на " от отчаяния |
|
| 162 | - if($amount == 0) |
|
| 163 | - {
|
|
| 164 | - // говорим, что всё в порядке |
|
| 165 | - $level = 0; |
|
| 166 | - $textx = substr($textx, 0, $p['pos']). '"' . substr($textx, $off); |
|
| 167 | - $off = $p['pos'] + strlen('"');
|
|
| 168 | - $okposstack = array($off); |
|
| 169 | - continue; |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - } |
|
| 176 | - // не совпало количество, отменяем все подкавычки |
|
| 177 | - if($level != 0 ){
|
|
| 178 | - |
|
| 179 | - // закрывающих меньше, чем надо |
|
| 180 | - if($level>0) |
|
| 181 | - {
|
|
| 182 | - $k = substr($textx, $okpos); |
|
| 183 | - $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
|
| 184 | - $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k); |
|
| 185 | - $textx = substr($textx, 0, $okpos). $k; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - $texts_out[] = $textx; |
|
| 189 | - } |
|
| 190 | - $this->_text = implode($exp, $texts_out); |
|
| 191 | - } |
|
| 18 | + /** |
|
| 19 | + * Базовые параметры тофа |
|
| 20 | + * |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + public $title = "Кавычки"; |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + public $rules = array( |
|
| 27 | + 'quotes_outside_a' => array( |
|
| 28 | + 'description' => 'Кавычки вне тэга <a>', |
|
| 29 | + //'pattern' => '/(\<%%\_\_.+?\>)\"(.+?)\"(\<\/%%\_\_.+?\>)/s', |
|
| 30 | + 'pattern' => '/(\<%%\_\_[^\>]+\>)\"(.+?)\"(\<\/%%\_\_[^\>]+\>)/s', |
|
| 31 | + 'replacement' => '"\1\2\3"' |
|
| 32 | + ), |
|
| 33 | + |
|
| 34 | + 'open_quote' => array( |
|
| 35 | + 'description' => 'Открывающая кавычка', |
|
| 36 | + 'pattern' => '/(^|\(|\s|\>|-)((\"|\\\")+)(\S+)/iue', |
|
| 37 | + 'replacement' => '$m[1] . str_repeat(self::QUOTE_FIRS_OPEN, substr_count($m[2],"\"") ) . $m[4]' |
|
| 38 | + ), |
|
| 39 | + 'close_quote' => array( |
|
| 40 | + 'description' => 'Закрывающая кавычка', |
|
| 41 | + 'pattern' => '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)((\"|\\\")+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|\<|$)/uie', |
|
| 42 | + 'replacement' => '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"") ) . $m[4]' |
|
| 43 | + ), |
|
| 44 | + 'close_quote_adv' => array( |
|
| 45 | + 'description' => 'Закрывающая кавычка особые случаи', |
|
| 46 | + //'pattern' => '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:)((\"|\\\"|\«\;)+)(\<.+?\>)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|$)/uie', |
|
| 47 | + 'pattern' => |
|
| 48 | + array( |
|
| 49 | + '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)((\"|\\\"|\«\;)+)(\<[^\>]+\>)(\.|\&hellip\;|\;|\:|\?|\!|\,|\)|\<\/|$| )/uie', |
|
| 50 | + '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)(\s+)((\"|\\\")+)(\s+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\)|\<\/|$| )/uie', |
|
| 51 | + '/\>(\«\;)\.($|\s|\<)/ui', |
|
| 52 | + '/\>(\«\;),($|\s|\<|\S)/ui', |
|
| 53 | + '/\>(\«\;):($|\s|\<|\S)/ui', |
|
| 54 | + '/\>(\«\;);($|\s|\<|\S)/ui', |
|
| 55 | + '/\>(\«\;)\)($|\s|\<|\S)/ui', |
|
| 56 | + '/((\"|\\\")+)$/uie', |
|
| 57 | + ), |
|
| 58 | + 'replacement' => |
|
| 59 | + array( |
|
| 60 | + '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"")+substr_count($m[2],"«") ) . $m[4]. $m[5]', |
|
| 61 | + '$m[1] .$m[2]. str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[3],"\"")+substr_count($m[3],"«") ) . $m[5]. $m[6]', |
|
| 62 | + '>».\2', |
|
| 63 | + '>»,\2', |
|
| 64 | + '>»:\2', |
|
| 65 | + '>»;\2', |
|
| 66 | + '>»)\2', |
|
| 67 | + 'str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[1],"\"") )', |
|
| 68 | + ), |
|
| 69 | + ), |
|
| 70 | + 'open_quote_adv' => array( |
|
| 71 | + 'description' => 'Открывающая кавычка особые случаи', |
|
| 72 | + 'pattern' => '/(^|\(|\s|\>)(\"|\\\")(\s)(\S+)/iue', |
|
| 73 | + 'replacement' => '$m[1] . self::QUOTE_FIRS_OPEN .$m[4]' |
|
| 74 | + ), |
|
| 75 | + 'close_quote_adv_2' => array( |
|
| 76 | + 'description' => 'Закрывающая кавычка последний шанс', |
|
| 77 | + 'pattern' => '/(\S)((\"|\\\")+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|\<|$)/uie', |
|
| 78 | + 'replacement' => '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"") ) . $m[4]' |
|
| 79 | + ), |
|
| 80 | + 'quotation' => array( |
|
| 81 | + 'description' => 'Внутренние кавычки-лапки и дюймы', |
|
| 82 | + 'function' => 'build_sub_quotations' |
|
| 83 | + ), |
|
| 84 | + ); |
|
| 85 | + |
|
| 86 | + protected function inject_in($pos, $text, &$thetext) |
|
| 87 | + {
|
|
| 88 | + for($i=0;$i<strlen($text);$i++) $thetext[$pos+$i] = $text[$i]; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + protected function build_sub_quotations() |
|
| 92 | + {
|
|
| 93 | + global $__ax,$__ay; |
|
| 94 | + |
|
| 95 | + $exp = strpos($this->_text, "</cA===>")!==false ? "</cA===>" : (strpos($this->_text,"\r\n")!==false ? "\r\n\r\n" :"\n\n"); |
|
| 96 | + |
|
| 97 | + $texts_in = explode($exp, $this->_text); |
|
| 98 | + $texts_out = array(); |
|
| 99 | + |
|
| 100 | + foreach($texts_in as $textx) {
|
|
| 101 | + |
|
| 102 | + $okposstack = array('0');
|
|
| 103 | + $okpos = 0; |
|
| 104 | + $level = 0; |
|
| 105 | + $off = 0; |
|
| 106 | + while(true) |
|
| 107 | + {
|
|
| 108 | + $p = EMTLib::strpos_ex($textx, array("«", "»"), $off);
|
|
| 109 | + if($p===false) break; |
|
| 110 | + if($p['str'] == "«") |
|
| 111 | + {
|
|
| 112 | + if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx);
|
|
| 113 | + $level++; |
|
| 114 | + } |
|
| 115 | + if($p['str'] == "»") |
|
| 116 | + {
|
|
| 117 | + $level--; |
|
| 118 | + if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx);
|
|
| 119 | + } |
|
| 120 | + $off = $p['pos']+strlen($p['str']); |
|
| 121 | + if($level == 0) |
|
| 122 | + {
|
|
| 123 | + $okpos = $off; |
|
| 124 | + array_push($okposstack, $okpos); |
|
| 125 | + } elseif($level<0) // уровень стал меньше нуля |
|
| 126 | + {
|
|
| 127 | + if(!$this->is_on('no_inches'))
|
|
| 128 | + {
|
|
| 129 | + do{
|
|
| 130 | + $lokpos = array_pop($okposstack); |
|
| 131 | + $k = substr($textx, $lokpos, $off-$lokpos); |
|
| 132 | + $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
|
| 133 | + $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k); |
|
| 134 | + //$k = preg_replace("/(^|[^0-9])([0-9]+)\»\;/ui", '\1\2″', $k, 1, $amount);
|
|
| 135 | + |
|
| 136 | + $amount = 0; |
|
| 137 | + $__ax = preg_match_all("/(^|[^0-9])([0-9]+)\»\;/ui", $k, $m);
|
|
| 138 | + $__ay = 0; |
|
| 139 | + if($__ax) |
|
| 140 | + {
|
|
| 141 | + $k = preg_replace_callback("/(^|[^0-9])([0-9]+)\»\;/ui",
|
|
| 142 | + create_function('$m','global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."″";} return $m[0];'),
|
|
| 143 | + $k); |
|
| 144 | + $amount = 1; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + } while(($amount==0) && count($okposstack)); |
|
| 150 | + |
|
| 151 | + // успешно сделали замену |
|
| 152 | + if($amount == 1) |
|
| 153 | + {
|
|
| 154 | + // заново просмотрим содержимое |
|
| 155 | + $textx = substr($textx, 0, $lokpos). $k . substr($textx, $off); |
|
| 156 | + $off = $lokpos; |
|
| 157 | + $level = 0; |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // иначе просто заменим последнюю явно на " от отчаяния |
|
| 162 | + if($amount == 0) |
|
| 163 | + {
|
|
| 164 | + // говорим, что всё в порядке |
|
| 165 | + $level = 0; |
|
| 166 | + $textx = substr($textx, 0, $p['pos']). '"' . substr($textx, $off); |
|
| 167 | + $off = $p['pos'] + strlen('"');
|
|
| 168 | + $okposstack = array($off); |
|
| 169 | + continue; |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + } |
|
| 176 | + // не совпало количество, отменяем все подкавычки |
|
| 177 | + if($level != 0 ){
|
|
| 178 | + |
|
| 179 | + // закрывающих меньше, чем надо |
|
| 180 | + if($level>0) |
|
| 181 | + {
|
|
| 182 | + $k = substr($textx, $okpos); |
|
| 183 | + $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
|
| 184 | + $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k); |
|
| 185 | + $textx = substr($textx, 0, $okpos). $k; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + $texts_out[] = $textx; |
|
| 189 | + } |
|
| 190 | + $this->_text = implode($exp, $texts_out); |
|
| 191 | + } |
|
| 192 | 192 | } |
@@ -85,48 +85,48 @@ 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++) $thetext[$pos+$i] = $text[$i]; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | protected function build_sub_quotations() |
| 92 | 92 | {
|
| 93 | - global $__ax,$__ay; |
|
| 93 | + global $__ax, $__ay; |
|
| 94 | 94 | |
| 95 | - $exp = strpos($this->_text, "</cA===>")!==false ? "</cA===>" : (strpos($this->_text,"\r\n")!==false ? "\r\n\r\n" :"\n\n"); |
|
| 95 | + $exp = strpos($this->_text, "</cA===>") !== false ? "</cA===>" : (strpos($this->_text, "\r\n") !== false ? "\r\n\r\n" : "\n\n"); |
|
| 96 | 96 | |
| 97 | 97 | $texts_in = explode($exp, $this->_text); |
| 98 | 98 | $texts_out = array(); |
| 99 | 99 | |
| 100 | - foreach($texts_in as $textx) {
|
|
| 100 | + foreach ($texts_in as $textx) {
|
|
| 101 | 101 | |
| 102 | 102 | $okposstack = array('0');
|
| 103 | 103 | $okpos = 0; |
| 104 | 104 | $level = 0; |
| 105 | 105 | $off = 0; |
| 106 | - while(true) |
|
| 106 | + while (true) |
|
| 107 | 107 | {
|
| 108 | 108 | $p = EMTLib::strpos_ex($textx, array("«", "»"), $off);
|
| 109 | - if($p===false) break; |
|
| 110 | - if($p['str'] == "«") |
|
| 109 | + if ($p === false) break; |
|
| 110 | + if ($p['str'] == "«") |
|
| 111 | 111 | {
|
| 112 | - if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx);
|
|
| 112 | + if ($level>0) if (!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx);
|
|
| 113 | 113 | $level++; |
| 114 | 114 | } |
| 115 | - if($p['str'] == "»") |
|
| 115 | + if ($p['str'] == "»") |
|
| 116 | 116 | {
|
| 117 | 117 | $level--; |
| 118 | - if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx);
|
|
| 118 | + if ($level>0) if (!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx);
|
|
| 119 | 119 | } |
| 120 | 120 | $off = $p['pos']+strlen($p['str']); |
| 121 | - if($level == 0) |
|
| 121 | + if ($level == 0) |
|
| 122 | 122 | {
|
| 123 | 123 | $okpos = $off; |
| 124 | 124 | array_push($okposstack, $okpos); |
| 125 | - } elseif($level<0) // уровень стал меньше нуля |
|
| 125 | + } elseif ($level<0) // уровень стал меньше нуля |
|
| 126 | 126 | {
|
| 127 | - if(!$this->is_on('no_inches'))
|
|
| 127 | + if (!$this->is_on('no_inches'))
|
|
| 128 | 128 | {
|
| 129 | - do{
|
|
| 129 | + do {
|
|
| 130 | 130 | $lokpos = array_pop($okposstack); |
| 131 | 131 | $k = substr($textx, $lokpos, $off-$lokpos); |
| 132 | 132 | $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
@@ -136,35 +136,35 @@ discard block |
||
| 136 | 136 | $amount = 0; |
| 137 | 137 | $__ax = preg_match_all("/(^|[^0-9])([0-9]+)\»\;/ui", $k, $m);
|
| 138 | 138 | $__ay = 0; |
| 139 | - if($__ax) |
|
| 139 | + if ($__ax) |
|
| 140 | 140 | {
|
| 141 | 141 | $k = preg_replace_callback("/(^|[^0-9])([0-9]+)\»\;/ui",
|
| 142 | - create_function('$m','global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."″";} return $m[0];'),
|
|
| 142 | + create_function('$m', 'global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."″";} return $m[0];'),
|
|
| 143 | 143 | $k); |
| 144 | 144 | $amount = 1; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | |
| 149 | - } while(($amount==0) && count($okposstack)); |
|
| 149 | + } while (($amount == 0) && count($okposstack)); |
|
| 150 | 150 | |
| 151 | 151 | // успешно сделали замену |
| 152 | - if($amount == 1) |
|
| 152 | + if ($amount == 1) |
|
| 153 | 153 | {
|
| 154 | 154 | // заново просмотрим содержимое |
| 155 | - $textx = substr($textx, 0, $lokpos). $k . substr($textx, $off); |
|
| 155 | + $textx = substr($textx, 0, $lokpos).$k.substr($textx, $off); |
|
| 156 | 156 | $off = $lokpos; |
| 157 | 157 | $level = 0; |
| 158 | 158 | continue; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // иначе просто заменим последнюю явно на " от отчаяния |
| 162 | - if($amount == 0) |
|
| 162 | + if ($amount == 0) |
|
| 163 | 163 | {
|
| 164 | 164 | // говорим, что всё в порядке |
| 165 | 165 | $level = 0; |
| 166 | - $textx = substr($textx, 0, $p['pos']). '"' . substr($textx, $off); |
|
| 167 | - $off = $p['pos'] + strlen('"');
|
|
| 166 | + $textx = substr($textx, 0, $p['pos']).'"'.substr($textx, $off); |
|
| 167 | + $off = $p['pos']+strlen('"');
|
|
| 168 | 168 | $okposstack = array($off); |
| 169 | 169 | continue; |
| 170 | 170 | } |
@@ -174,15 +174,15 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | } |
| 176 | 176 | // не совпало количество, отменяем все подкавычки |
| 177 | - if($level != 0 ){
|
|
| 177 | + if ($level != 0) {
|
|
| 178 | 178 | |
| 179 | 179 | // закрывающих меньше, чем надо |
| 180 | - if($level>0) |
|
| 180 | + if ($level>0) |
|
| 181 | 181 | {
|
| 182 | 182 | $k = substr($textx, $okpos); |
| 183 | 183 | $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k); |
| 184 | 184 | $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k); |
| 185 | - $textx = substr($textx, 0, $okpos). $k; |
|
| 185 | + $textx = substr($textx, 0, $okpos).$k; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | $texts_out[] = $textx; |
@@ -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); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | {
|
| 18 | 18 | public $title = "Сокращения"; |
| 19 | 19 | |
| 20 | - public $domain_zones = array('ru','ру','com','ком','org','орг', 'уа', 'ua');
|
|
| 20 | + public $domain_zones = array('ru', 'ру', 'com', 'ком', 'org', 'орг', 'уа', 'ua');
|
|
| 21 | 21 | |
| 22 | 22 | public $classes = array( |
| 23 | 23 | 'nowrap' => 'word-spacing:nowrap;', |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class TypographTwigExtension extends \Twig_Extension |
| 8 | 8 | { |
| 9 | - protected $typograph; |
|
| 9 | + protected $typograph; |
|
| 10 | 10 | |
| 11 | - public function __construct(TypographService $typograph) |
|
| 12 | - { |
|
| 13 | - $this->typograph = $typograph; |
|
| 14 | - } |
|
| 11 | + public function __construct(TypographService $typograph) |
|
| 12 | + { |
|
| 13 | + $this->typograph = $typograph; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function getName() |
|
| 17 | - { |
|
| 18 | - return 'FenrizbesTypograph'; |
|
| 19 | - } |
|
| 16 | + public function getName() |
|
| 17 | + { |
|
| 18 | + return 'FenrizbesTypograph'; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function getFilters() |
|
| 22 | - { |
|
| 23 | - return array( |
|
| 24 | - new \Twig_SimpleFilter('typograph', array($this, 'applyTypograph'), array('is_safe' => array('html'))) |
|
| 25 | - ); |
|
| 26 | - } |
|
| 21 | + public function getFilters() |
|
| 22 | + { |
|
| 23 | + return array( |
|
| 24 | + new \Twig_SimpleFilter('typograph', array($this, 'applyTypograph'), array('is_safe' => array('html'))) |
|
| 25 | + ); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function applyTypograph($string, $config = null) |
|
| 29 | - { |
|
| 30 | - return $this->typograph->apply($string, $config); |
|
| 31 | - } |
|
| 28 | + public function applyTypograph($string, $config = null) |
|
| 29 | + { |
|
| 30 | + return $this->typograph->apply($string, $config); |
|
| 31 | + } |
|
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -9,14 +9,14 @@ |
||
| 9 | 9 | |
| 10 | 10 | class FenrizbesTypographExtension extends Extension |
| 11 | 11 | { |
| 12 | - public function load(array $configs, ContainerBuilder $container) |
|
| 13 | - { |
|
| 14 | - $configuration = new Configuration(); |
|
| 15 | - $config = $this->processConfiguration($configuration, $configs); |
|
| 12 | + public function load(array $configs, ContainerBuilder $container) |
|
| 13 | + { |
|
| 14 | + $configuration = new Configuration(); |
|
| 15 | + $config = $this->processConfiguration($configuration, $configs); |
|
| 16 | 16 | |
| 17 | - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 18 | - $loader->load('services.yml'); |
|
| 17 | + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 18 | + $loader->load('services.yml'); |
|
| 19 | 19 | |
| 20 | - $container->setParameter('fenrizbes_typograph.configs', $config['configs']); |
|
| 21 | - } |
|
| 20 | + $container->setParameter('fenrizbes_typograph.configs', $config['configs']); |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -7,35 +7,35 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Configuration implements ConfigurationInterface |
| 9 | 9 | { |
| 10 | - public function getConfigTreeBuilder() |
|
| 11 | - { |
|
| 12 | - $treeBuilder = new TreeBuilder(); |
|
| 13 | - $rootNode = $treeBuilder->root('fenrizbes_typograph'); |
|
| 10 | + public function getConfigTreeBuilder() |
|
| 11 | + { |
|
| 12 | + $treeBuilder = new TreeBuilder(); |
|
| 13 | + $rootNode = $treeBuilder->root('fenrizbes_typograph'); |
|
| 14 | 14 | |
| 15 | - $rootNode |
|
| 16 | - ->children() |
|
| 17 | - ->arrayNode('configs') |
|
| 18 | - ->useAttributeAsKey('name') |
|
| 15 | + $rootNode |
|
| 16 | + ->children() |
|
| 17 | + ->arrayNode('configs') |
|
| 18 | + ->useAttributeAsKey('name') |
|
| 19 | 19 | |
| 20 | - ->prototype('array') |
|
| 21 | - ->useAttributeAsKey('name') |
|
| 22 | - ->prototype('variable')->end() |
|
| 23 | - ->end() |
|
| 20 | + ->prototype('array') |
|
| 21 | + ->useAttributeAsKey('name') |
|
| 22 | + ->prototype('variable')->end() |
|
| 23 | + ->end() |
|
| 24 | 24 | |
| 25 | - ->defaultValue(array( |
|
| 26 | - 'default' => array( |
|
| 27 | - 'Text.paragraphs' => 'off', |
|
| 28 | - 'Text.breakline' => 'off', |
|
| 29 | - 'Text.auto_links' => 'off', |
|
| 30 | - 'Text.email' => 'off', |
|
| 31 | - 'OptAlign.oa_oquote' => 'off', |
|
| 32 | - 'OptAlign.oa_obracket_coma' => 'off' |
|
| 33 | - ) |
|
| 34 | - )) |
|
| 35 | - ->end() |
|
| 36 | - ->end() |
|
| 37 | - ; |
|
| 25 | + ->defaultValue(array( |
|
| 26 | + 'default' => array( |
|
| 27 | + 'Text.paragraphs' => 'off', |
|
| 28 | + 'Text.breakline' => 'off', |
|
| 29 | + 'Text.auto_links' => 'off', |
|
| 30 | + 'Text.email' => 'off', |
|
| 31 | + 'OptAlign.oa_oquote' => 'off', |
|
| 32 | + 'OptAlign.oa_obracket_coma' => 'off' |
|
| 33 | + ) |
|
| 34 | + )) |
|
| 35 | + ->end() |
|
| 36 | + ->end() |
|
| 37 | + ; |
|
| 38 | 38 | |
| 39 | - return $treeBuilder; |
|
| 40 | - } |
|
| 39 | + return $treeBuilder; |
|
| 40 | + } |
|
| 41 | 41 | } |