| version 1.31, 2007/06/24 23:16:27 |
version 1.32, 2007/09/16 16:27:37 |
|
|
| * http://platon.sk/projects/Metafox/ |
* http://platon.sk/projects/Metafox/ |
| */ |
*/ |
| |
|
| /* $Platon: Metafox/subst.inc.php,v 1.30 2007-05-20 21:58:02 nepto Exp $ */ |
/* $Platon: Metafox/subst.inc.php,v 1.31 2007-06-24 23:16:27 nepto Exp $ */ |
| |
|
| require_once 'cfgldr.inc.php'; |
require_once 'cfgldr.inc.php'; |
| require_once 'error.inc.php'; |
require_once 'error.inc.php'; |
| Line 434 if ($ezin_db_article != '' && ! empty($e |
|
| Line 434 if ($ezin_db_article != '' && ! empty($e |
|
| ezin_article_link_process($ezin_db_article); |
ezin_article_link_process($ezin_db_article); |
| ezin_article_counts_process($ezin_db_article); |
ezin_article_counts_process($ezin_db_article); |
| // This removes width="..." attribute from <image> tag at article_print page |
// This removes width="..." attribute from <image> tag at article_print page |
| if ($ezin_cgi['output'] == 'article_print') { |
// if image is less than 10% smaller or bigger |
| $ezin_db_article['article_bodytext'] = preg_replace( |
if ($ezin_cgi['output'] == 'article_print') { // {{{ |
| '/<image([^<>]*\s+)(width=("[^<>"]+"|[^<>\s]+))(|\s+[^<>]*)>/i', |
preg_match_all('|<image(-link)?\s+([^>\s]+)([^>]*width=([^>\s]+)[^>]*)>|i', |
| '<image\1\4>', $ezin_db_article['article_bodytext']); |
$ezin_db_article['article_bodytext'], $matches, PREG_SET_ORDER); |
| } |
foreach ($matches as $key => $val) { |
| |
$treshold = 10; // percent // TODO: should be configurable |
| |
$scaleskip = false; |
| |
$file = $val[2]; |
| |
$width = $val[4]; |
| |
$width = preg_replace('/["\']/', '', trim($width)); |
| |
$pct = $width[strlen($width) - 1] == '%'; |
| |
$width = intval($width); |
| |
if ($width <= 0) { |
| |
continue; |
| |
} |
| |
if ($pct) { |
| |
if (abs(100 - $width) <= $treshold) { |
| |
$scaleskip = true; |
| |
} |
| |
} else { |
| |
$ori_width = ezin_get_upload_image_width($file); |
| |
if ($width > 0 && $ori_width > 0) { |
| |
$div = $width / $ori_width; |
| |
if (abs(1 - $div) * 100 <= $treshold) { |
| |
$scaleskip = true; |
| |
} |
| |
} |
| |
} |
| |
if ($scaleskip) { |
| |
$ezin_db_article['article_bodytext'] = preg_replace( |
| |
'/<image(-link)?\s+'.$file.'(\s+[^<>]*)(width=("[^<>"]+"|[^<>\s]+))(|\s+[^<>]*)>/i', |
| |
'<image\1 '.$file.'\2\5>', $ezin_db_article['article_bodytext']); |
| |
} |
| |
} |
| |
} // }}} |
| ezin_handle_special_tags($ezin_db_article['article_hometext'], $ezin_db_article['article_hometext_flags']); |
ezin_handle_special_tags($ezin_db_article['article_hometext'], $ezin_db_article['article_hometext_flags']); |
| ezin_handle_special_tags($ezin_db_article['article_bodytext'], $ezin_db_article['article_bodytext_flags']); |
ezin_handle_special_tags($ezin_db_article['article_bodytext'], $ezin_db_article['article_bodytext_flags']); |
| ezin_process_text_flags($ezin_db_article['article_hometext'], 'article_hometext'); |
ezin_process_text_flags($ezin_db_article['article_hometext'], 'article_hometext'); |