Changeset 26972
- Timestamp:
- Jan 26, 2014, 1:38:37 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/history.php
r26649 r26972 340 340 name, url_name 341 341 FROM '.TAGS_TABLE; 342 343 global $name_of_tag; // used for preg_replace 342 344 $name_of_tag = array(); 343 345 $result = pwg_query($query); … … 400 402 if (isset($line['tag_ids'])) 401 403 { 402 $tags_string = preg_replace (403 '/(\d+)/ e',404 'isset($name_of_tag["$1"]) ? $name_of_tag["$1"] : "$1"',404 $tags_string = preg_replace_callback( 405 '/(\d+)/', 406 create_function('$m', 'return isset($name_of_tag[$m[1]]) ? $name_of_tag[$m[1]] : $m[1];'), 405 407 str_replace( 406 408 ',', … … 542 544 ) 543 545 ); 546 547 unset($name_of_tag); 544 548 } 545 549 -
trunk/admin/include/functions.php
r26928 r26972 583 583 ORDER BY id_uppercat,rank,name'; 584 584 585 global $cat_map; // used in preg_replace callback 585 586 $cat_map = array(); 586 587 … … 609 610 $datas = array(); 610 611 612 $cat_map_callback = create_function('$m', 'global $cat_map; return $cat_map[$m[1]]["rank"];'); 613 611 614 foreach( $cat_map as $id=>$cat ) 612 615 { 613 $new_global_rank = preg_replace( 614 '/(\d+)/e', 615 "\$cat_map['$1']['rank']", 616 str_replace(',', '.', $cat['uppercats'] ) 617 ); 616 $new_global_rank = preg_replace_callback( 617 '/(\d+)/', 618 $cat_map_callback, 619 str_replace(',', '.', $cat['uppercats'] ) 620 ); 621 618 622 if ( $cat['rank_changed'] 619 623 or $new_global_rank!=$cat['global_rank'] … … 627 631 } 628 632 } 633 634 unset($cat_map); 629 635 630 636 mass_updates( -
trunk/include/emogrifier.class.php
r25344 r26972 36 36 2012-05-01 Made removal of invisible nodes operate in a case-insensitive manner... Thanks Juha P.! 37 37 2013-10-10 Add preserveStyleTag option 38 2014-01-26 PHP 5.5 compatibility (/e modifier is deprecated in preg_replace) 38 39 */ 39 40 … … 125 126 $nodes = @$xpath->query('//*[@style]'); 126 127 foreach ($nodes as $node) { 127 $normalizedOrigStyle = preg_replace ('/[A-z\-]+(?=\:)/Se',"strtolower('\\0')",$node->getAttribute('style'));128 $normalizedOrigStyle = preg_replace_callback('/[A-z\-]+(?=\:)/S',create_function('$m', 'return strtolower($m[0]);'),$node->getAttribute('style')); 128 129 129 130 // in order to not overwrite existing style attributes in the HTML, we have to save the original HTML styles … … 300 301 '/(\w)\[(\w+)\]/', // Matches element with attribute 301 302 '/(\w)\[(\w+)\=[\'"]?(\w+)[\'"]?\]/', // Matches element with EXACT attribute 302 '/(\w+)?\#([\w\-]+)/e', // Matches id attributes303 '/(\w+|[\*\]])?((\.[\w\-]+)+)/e', // Matches class attributes304 305 303 ); 306 304 $replace = array( … … 312 310 '\\1[@\\2]', 313 311 '\\1[@\\2="\\3"]', 314 "(strlen('\\1') ? '\\1' : '*').'[@id=\"\\2\"]'",315 "(strlen('\\1') ? '\\1' : '*').'[contains(concat(\" \",@class,\" \"),concat(\" \",\"'.implode('\",\" \"))][contains(concat(\" \",@class,\" \"),concat(\" \",\"',explode('.',substr('\\2',1))).'\",\" \"))]'",316 312 ); 317 313 318 314 $css_selector = '//'.preg_replace($search, $replace, $css_selector); 315 316 // matches ids and classes 317 $css_selector = preg_replace_callback('/(\w+)?\#([\w\-]+)/', array($this, 'matchIdAttributes'), $css_selector); 318 $css_selector = preg_replace_callback('/(\w+|[\*\]])?((\.[\w\-]+)+)/', array($this, 'matchClassAttributes'), $css_selector); 319 319 320 320 // advanced selectors are going to require a bit more advanced emogrification … … 326 326 } 327 327 return $this->caches[CACHE_SELECTOR][$xpathkey]; 328 } 329 330 private function matchIdAttributes($m) { 331 return (strlen($m[1]) ? $m[1] : '*').'[@id="'.$m[2].'"]'; 332 } 333 334 private function matchClassAttributes($m) { 335 return (strlen($m[1]) ? $m[1] : '*').'[contains(concat(" ",@class," "),concat(" ","'.implode('"," "))][contains(concat(" ",@class," "),concat(" ","',explode('.',substr($m[2],1))).'"," "))]'; 328 336 } 329 337
Note: See TracChangeset
for help on using the changeset viewer.