build_thumb moved to common utils

git-svn-id: file:///home/shish/svn/shimmie2/trunk@16 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-04-26 22:27:17 +00:00
parent c11a6484b8
commit 6e90eed812
2 changed files with 30 additions and 14 deletions

View File

@ -116,7 +116,7 @@ class Index extends Extension {
for($j=0; $j<$width; $j++) {
$image = isset($images[$i*$width+$j]) ? $images[$i*$width+$j] : null;
if(!is_null($image)) {
$table .= $this->build_thumb($image, $query);
$table .= build_thumb($image, $query);
}
else {
$table .= "\t<td>&nbsp;</td>\n";
@ -128,16 +128,6 @@ class Index extends Extension {
return $table;
}
private function build_thumb($image, $query=null) {
global $config;
$h_view_link = make_link("post/view/{$image->id}", $query);
$h_tip = html_escape($image->get_tooltip());
$h_thumb_link = $image->get_thumb_link();
$tsize = get_thumbnail_size($image->width, $image->height);
return "<td><a href='$h_view_link'><img title='$h_tip' alt='$h_tip'
width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link'></a></td>\n";
}
// }}}
// rss {{{
private function do_rss() {

View File

@ -91,13 +91,25 @@ function get_memory_limit() {
function bbcode2html($text) {
$text = trim($text);
$text = html_escape($text);
# $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
# $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
# $text = preg_replace("/\[u\](.*?)\[\/u\]/s", "<u>\\1</u>", $text);
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "<u>\\1</u>", $text);
$text = preg_replace("/\[\[(.*?)\]\]/s",
"<a href='".make_link("wiki/\\1")."'>\\1</a>", $text);
$text = str_replace("\n", "\n<br>", $text);
return $text;
}
function strip_bbcode($text) {
$text = trim($text);
$text = html_escape($text);
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text);
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text);
$text = preg_replace("/\[\[(.*?)\]\]/s", "\\1", $text);
return $text;
}
function tag_explode($tags) {
if(is_string($tags)) {
$tags = explode(' ', $tags);
@ -124,6 +136,9 @@ function tag_explode($tags) {
return $tag_array;
}
function sql_quote($text) {
return '"'.sql_escape($text).'"';
}
function get_thumbnail_size($orig_width, $orig_height) {
global $config;
@ -142,6 +157,17 @@ function get_thumbnail_size($orig_width, $orig_height) {
// }
}
function build_thumb($image, $query=null) {
global $config;
$h_view_link = make_link("post/view/{$image->id}", $query);
$h_tip = html_escape($image->get_tooltip());
$h_thumb_link = $image->get_thumb_link();
$tsize = get_thumbnail_size($image->width, $image->height);
return "<td><a href='$h_view_link'><img title='$h_tip' alt='$h_tip'
width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link'></a></td>\n";
}
# $db is the connection object
function CountExecs($db, $sql, $inputarray) {