move move common code into base classes

This commit is contained in:
Shish 2012-03-12 05:08:40 +00:00
parent 15777b3bb5
commit 3eb1f1c2ab
6 changed files with 47 additions and 108 deletions

View file

@ -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 '<a href="'.$h_view_link.'" class="thumb">'.
'<img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" src="'.$h_thumb_link.'">'.

View file

@ -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;
}
}
/**

View file

@ -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 "<a href='$h_view_link'><img title='$h_tip' alt='$h_tip' ".
"width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link' /></a>";

View file

@ -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 "<a class='thumb' href='$h_view_link'><img title='$h_tip' alt='$h_tip' ".
"width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link' /></a>";

View file

@ -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 "
<center><div class='thumbblock'>

View file

@ -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 "
<div class='thumbblock'>