From 3eb1f1c2abb394bfaf0916aa449908ac48b585e4 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 12 Mar 2012 05:08:40 +0000 Subject: [PATCH] move move common code into base classes --- core/basethemelet.class.php | 26 +++++--------------------- core/imageboard.pack.php | 21 ++++++++++++++++++++- themes/danbooru/themelet.class.php | 26 +++++--------------------- themes/futaba/themelet.class.php | 28 ++++++---------------------- themes/lite/themelet.class.php | 28 ++++++---------------------- themes/warm/themelet.class.php | 26 +++++--------------------- 6 files changed, 47 insertions(+), 108 deletions(-) diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 655492c9..e1ca4b13 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -33,31 +33,15 @@ class BaseThemelet { $i_id = (int) $image->id; $h_view_link = make_link('post/view/'.$i_id, $query); $h_thumb_link = $image->get_thumb_link(); - - - // Removes the size tag if the file is an mp3 - if($image->ext === 'mp3'){ - $iitip = $image->get_tooltip(); - $mp3tip = array("0x0"); - $h_tip = str_replace($mp3tip, " ", $iitip); + $h_tip = html_escape($image->get_tooltip()); - // Makes it work with a variation of the default tooltips (I.E $tags // $filesize // $size) - $justincase = array(" //", "// ", " //", "// ", " "); - if(strstr($h_tip, " ")){ - $h_tip = html_escape(str_replace($justincase, "", $h_tip)); - }else{ - $h_tip = html_escape($h_tip); - } - }else{ - $h_tip = html_escape($image->get_tooltip()); - } - - // If file is flash or svg then sets thumbnail to max size. if($image->ext === 'swf' || $image->ext === 'svg'){ - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } + $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); + } else{ - $tsize = get_thumbnail_size($image->width, $image->height); } + $tsize = get_thumbnail_size($image->width, $image->height); + } return ''. ''.$h_tip.''. diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index bf1c7662..de64291a 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -334,7 +334,26 @@ class Image { */ public function get_tooltip() { global $config; - return $this->parse_link_template($config->get_string('image_tip'), "no_escape"); + $tt = $this->parse_link_template($config->get_string('image_tip'), "no_escape"); + + // Removes the size tag if the file is an mp3 + if($this->ext === 'mp3'){ + $iitip = $tt; + $mp3tip = array("0x0"); + $h_tip = str_replace($mp3tip, " ", $iitip); + + // Makes it work with a variation of the default tooltips (I.E $tags // $filesize // $size) + $justincase = array(" //", "// ", " //", "// ", " "); + if(strstr($h_tip, " ")) { + $h_tip = html_escape(str_replace($justincase, "", $h_tip)); + }else{ + $h_tip = html_escape($h_tip); + } + return $h_tip; + } + else { + return $tt; + } } /** diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index 1c3f2932..7880429f 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -4,31 +4,15 @@ class Themelet extends BaseThemelet { global $config; $h_view_link = make_link("post/view/{$image->id}", $query); $h_thumb_link = $image->get_thumb_link(); - - - // Removes the size tag if the file is an mp3 - if($image->ext == 'mp3'){ - $iitip = $image->get_tooltip(); - $mp3tip = array("0x0"); - $h_tip = str_replace($mp3tip, " ", $iitip); - - // Makes it work with a variation of the default tooltips (I.E $tags // $filesize // $size) - $justincase = array(" //", "// ", " //", "// ", " "); - if(strstr($h_tip, " ")){ - $h_tip = html_escape(str_replace($justincase, "", $h_tip)); - }else{ - $h_tip = html_escape($h_tip); - } - }else{ $h_tip = html_escape($image->get_tooltip()); - } - // If file is flash or svg then sets thumbnail to max size. - if($image->ext == 'swf' || $image->ext == 'svg'){ - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } + if($image->ext == 'swf' || $image->ext == 'svg') { + $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); + } else{ - $tsize = get_thumbnail_size($image->width, $image->height); } + $tsize = get_thumbnail_size($image->width, $image->height); + } return "$h_tip"; diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 2941fef4..7d4955e6 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -8,31 +8,15 @@ class Themelet extends BaseThemelet { global $config; $h_view_link = make_link("post/view/{$image->id}", $query); $h_thumb_link = $image->get_thumb_link(); - - - // Removes the size tag if the file is an mp3 - if($image->ext == 'mp3'){ - $iitip = $image->get_tooltip(); - $mp3tip = array("0x0"); - $h_tip = str_replace($mp3tip, " ", $iitip); - - // Makes it work with a variation of the default tooltips (I.E $tags // $filesize // $size) - $justincase = array(" //", "// ", " //", "// ", " "); - if(strstr($h_tip, " ")){ - $h_tip = html_escape(str_replace($justincase, "", $h_tip)); - }else{ - $h_tip = html_escape($h_tip); - } - }else{ $h_tip = html_escape($image->get_tooltip()); - } - // If file is flash or svg then sets thumbnail to max size. - if($image->ext == 'swf' || $image->ext == 'svg'){ - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } - else{ - $tsize = get_thumbnail_size($image->width, $image->height); } + if($image->ext == 'swf' || $image->ext == 'svg') { + $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); + } + else { + $tsize = get_thumbnail_size($image->width, $image->height); + } return "$h_tip"; diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 639f13bb..8afa7754 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -9,31 +9,15 @@ class Themelet extends BaseThemelet { $i_id = int_escape($image->id); $h_view_link = make_link("post/view/$i_id", $query); $h_thumb_link = $image->get_thumb_link(); - - - // Removes the size tag if the file is an mp3 - if($image->ext == 'mp3'){ - $iitip = $image->get_tooltip(); - $mp3tip = array("0x0"); - $h_tip = str_replace($mp3tip, " ", $iitip); - - // Makes it work with a variation of the default tooltips (I.E $tags // $filesize // $size) - $justincase = array(" //", "// ", " //", "// ", " "); - if(strstr($h_tip, " ")){ - $h_tip = html_escape(str_replace($justincase, "", $h_tip)); - }else{ - $h_tip = html_escape($h_tip); - } - }else{ $h_tip = html_escape($image->get_tooltip()); - } - // If file is flash or svg then sets thumbnail to max size. - if($image->ext == 'swf' || $image->ext == 'svg'){ - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } - else{ - $tsize = get_thumbnail_size($image->width, $image->height); } + if($image->ext == 'swf' || $image->ext == 'svg') { + $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); + } + else { + $tsize = get_thumbnail_size($image->width, $image->height); + } return "
diff --git a/themes/warm/themelet.class.php b/themes/warm/themelet.class.php index 0cf3cbb2..fe585cba 100644 --- a/themes/warm/themelet.class.php +++ b/themes/warm/themelet.class.php @@ -13,31 +13,15 @@ class Themelet extends BaseThemelet { $h_view_link = make_link("post/view/$i_id", $query); $h_image_link = $image->get_image_link(); $h_thumb_link = $image->get_thumb_link(); - - - // Removes the size tag if the file is an mp3 - if($image->ext == 'mp3'){ - $iitip = $image->get_tooltip(); - $mp3tip = array("0x0"); - $h_tip = str_replace($mp3tip, " ", $iitip); - - // Makes it work with a variation of the default tooltips (I.E $tags // $filesize // $size) - $justincase = array(" //", "// ", " //", "// ", " "); - if(strstr($h_tip, " ")){ - $h_tip = html_escape(str_replace($justincase, "", $h_tip)); - }else{ - $h_tip = html_escape($h_tip); - } - }else{ $h_tip = html_escape($image->get_tooltip()); - } - // If file is flash or svg then sets thumbnail to max size. - if($image->ext == 'swf' || $image->ext == 'svg'){ - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } + if($image->ext == 'swf' || $image->ext == 'svg') { + $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); + } else{ - $tsize = get_thumbnail_size($image->width, $image->height); } + $tsize = get_thumbnail_size($image->width, $image->height); + } return "