Функция hak_txpimage

09 Июнь 2010

Вернуться к статье.

//--- Functions for the image browser ----
function hak_txpimage() {
global $img_dir,$path_to_site,$txpcfg;
$category = gps("c");
$category = (!empty($category)) ? "AND category='".$category."'" : "" ;

$limit_image = gps("limimg");
$limit_img_count = gps("limcount");

if ( (empty($limit_img_count)) || (!intval($limit_img_count)) ){
$limit_img_count = 0;
}
else { $limit_img_count = intval($limit_img_count) - 1; }

if (empty($limit_image)) { $limit_image = " LIMIT 10"; }
else {
if ($limit_image == "All") { $limit_image = ""; }
elseif (!intval($limit_image)) { $limit_image = " LIMIT 10"; }
else { $limit_image = " LIMIT ".$limit_img_count*$limit_image.",".$limit_image; };
}

$rs = safe_rows_start("*", "txp_image","1=1 ".$category." ORDER BY id DESC,category,name".$limit_image);
$src = gps("src");

if ($rs) {
$out = array();
while ($a = nextRow($rs)) {
extract($a);
$thumbclick ='';
$image["path"] = hu.$img_dir.'/'.$id.$ext;
$image["width"] = $w;
$image["height"] = $h;
$image["alt"] = (empty($alt)) ? "" : rawurlencode($alt);
$image["caption"] = (empty($caption)) ? "" : rawurlencode($caption);
$onclick = 'onclick=\'TxpImageDialog.insertImage(this,'.hak_tinymce::map_attribs($image).');return'.n.'false;\'';

$preview = $image;
$thumb = $image;

if($thumbnail) {
$thumb["path"] = hu.$img_dir.'/'.$id.'t'.$ext;
$thumb["width"] = $thumb_w;
$thumb["height"] = $thumb_h;
$thumb["alt"] = $image["alt"];
$thumb["caption"] = $image["caption"];
$preview = $thumb;
$thumbclick = 'onclick=\'TxpImageDialog.insertImage(this,'.hak_tinymce::map_attribs($thumb).');return'.n.'false;\'';
$thumbclick = '<a href="#" '.$thumbclick.'><img src="img/pictures.png" width="18" height="18" title="'.hak_tinymce::mce_gTxt('insert_thumb').'" alt="'.hak_tinymce::mce_gTxt('insert_thumb').'" /></a>';
}

//$desiredheight = $preview["height"];
if ($preview["width"] > $preview["height"]) {
$new["width"] = 100;
if (!empty($preview["width"])) {
$new["height"] = (100 / $preview["width"]) * $preview["height"];
} else {
$new["height"] = "";
}
$margin = (100 - $new["height"]) / 2;
$margin = intval($margin)."px 0";
} else {
$new["height"] = 100;
if (!empty($preview["height"])) {
$new["width"] = (100 / $preview["height"] ) * $preview["width"];
} else {
$new["width"] = "";
}
$margin = (100 - $new["width"]) / 2;
$margin = "0 ".intval($margin)."px";
}
$selected = ($src == $image["path"] || $src == $thumb["path"]) ? "active" : "";
$out[] = '<div class="image '.$selected.'"><div style="padding:'.$margin.'"><img src="'.$preview["path"].'" height="'.$new["height"].'" width="'.$new["width"].'" onclick="window.open(\''.$image["path"].'\',\'mypopup\', \'menubar=0,status=0,height='.$image["height"].',width='.$image["width"].'\')"/></div>'.
'<a href="#" '.$onclick.'><img src="img/picture.png" width="18" height="18" alt="'.hak_tinymce::mce_gTxt('insert_image').'" title="'.hak_tinymce::mce_gTxt('insert_image').'" /></a>'.
$thumbclick.
'</div>';
}
echo implode($out,"\n");
exit(0);
}
}

Вернуться к статье.

Андрей Лебедев

,

Комментарий

Нет комментарий.

Комментировать: