Ich versuch nun schon seit ner halben Ewigkeit die
zugewiesenen PDF`s unterhalb jedes Artikels in meiner
Artikelliste auszugeben. Es werden immer nur alle
PDF`s die vorhanden sind angezeigt und nicht nur der tatsächlich
dem Artikel zugewiesene! Was mache ich falsch?
Vielen Dank für Eure Hilfe!
Chris
Mein Outputscript sieht bislang so aus:
Code: Alles auswählen
<?
//Frontendpfad ermitteln
$query = "SELECT frontendpath FROM ".$cfg["tab"]["clients"]." WHERE idclient='".$client."'";
$db->query($query);
$db->next_record();
$frontendpath = $db->f("frontendpath");
$startarton = "AND CATART.is_start = '0' AND";
//soll der startartikel mit ausgegeben werden?.
$print_startartikel = "CMS_VALUE[14]";
if($print_startartikel !=""){
$startarton = "AND";
}
//die Überschrift wird ausgegeben wenn sie nicht leer ist.
$print_mainheadline = "CMS_VALUE[2]";
//soll headline ausgegeben werden?
$print_headline = "CMS_VALUE[4]";
//soll subheadline ausgegeben werden?
$print_subheadline = "CMS_VALUE[5]";
//soll text ausgegeben werden?
$print_text = "CMS_VALUE[12]";
//soll ein thumnail ausgegeben werden?
$print_thumbnail = "CMS_VALUE[7]";
//thumbnail breite
$thumbnail_width = "CMS_VALUE[8]";
//wenn thumbnails = 0
$imagetag = "";
// second db class instance
$db2 = new DB_Contenido;
// selected category
$selcat = "CMS_VALUE[0]";
if($selcat!="0" && $selcat!=""){
// select all articles in category widthout start article
$query = "SELECT ARTLANG.idart, ARTLANG.idartlang, ARTLANG.lastmodified FROM ".$cfg["tab"]["cat_art"]." AS CATART, ".
$cfg["tab"]["art_lang"]." AS ARTLANG ".
"WHERE CATART.idcat = '$selcat' AND ARTLANG.idart = CATART.idart AND ARTLANG.idlang = '$lang' "." $startarton " ."ARTLANG.online = '1' ORDER BY ARTLANG.lastmodified DESC";
// execute query
$db->query($query);
unset($articleID);
unset($linkID);
// get id's of sub articles
while ($db->next_record()) {
$articleID[] = $db->f("idartlang");
$linkID[] = $db->f("idart");
} // end while
/****************** start table **************************/
echo '
<table border="0" cellpadding="0" cellspacing="0" width="100%">
';
/**** Überschrift der Artikelliste wird ausgegeben, wenn nicht leer ********/
if($print_mainheadline !=""){
echo '
<tr>
<td height="20"><b class="brown">CMS_VALUE[2]</b></td>
</tr>
';
}
// Loop through articles
if (is_array($articleID)) {
foreach ($articleID as $key => $value) {
// select all CMS variables of the article
if($print_headline!="0" && $print_headline!=""){
$sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '1'";
$db->query($sql);
$db->next_record();
$headline = urldecode($db->f("value"));
for ($j="CMS_VALUE[3]"; $j < "CMS_VALUE[3]"+20; $j++)
{
$headline1 = substr($headline , 0, $j);
$cut = substr($headline, $j);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$headline= substr($headline , 0, $j);
$headline .= ' ...';
}
}
}
$cfgTab_art_lang = $cfg['tab']['art_lang'];
$cfgTab_content = $cfg['tab']['content'];
$sql = "SELECT A.author AS author, B.lastmodified AS lastmod FROM $cfgTab_art_lang AS A, $cfgTab_content AS B WHERE A.idart='$value' AND B.idartlang=A.idartlang ORDER BY B.lastmodified DESC";
$db->query($sql);$db->next_record();
$modifydate= date("d.m.y",strtotime($db->f("lastmod")));
$modifytime= date("H:i",strtotime($db->f("lastmod")));
if($print_subheadline!="0" && $print_subheadline!=""){
$sql_subheadline = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '2'";
$db->query($sql_subheadline);
$db->next_record();
$subheadline = urldecode($db->f("value"));
for ($i="CMS_VALUE[6]"; $i < "CMS_VALUE[6]"+20; $i++)
{
$subheadline1 = substr($subheadline , 0, $i);
$cut = substr($subheadline, $i);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$subheadline= substr($subheadline , 0, $i);
$subheadline .= ' ...';
}
}
}
if($print_text!="0" && $print_text!=""){
$sql_text = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '2' AND typeid = '1'";
$db->query($sql_text);
$db->next_record();
$text = urldecode($db->f("value"));
for ($i="CMS_VALUE[13]"; $i < "CMS_VALUE[13]"+20; $i++)
{
$text1 = substr($text , 0, $i);
$cut = substr($text, $i);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$text= substr($text , 0, $i);
$text .= ' ...';
}
}
}
/******************* begin thumbnails **********************************/
if($print_thumbnail !="0" && $print_thumbnail !=""){
// select and resolve image path
$imagesql="select value from ".$cfg["tab"]["content"]." where idartlang='$value' and idtype='4' and typeid='CMS_VALUE[11]'";
$db2->query($imagesql);
$db2->next_record();
$image_id= $db2->f("value");
// get image name and path
$imagesql="select * from ".$cfg["tab"]["upl"]." where idupl='$image_id'";
$db2->query($imagesql);
$db2->next_record();
$webdir='upload/';
$thumbdir='CMS_VALUE[9]';
$filedir=$frontendpath;
$imagelocation=$filedir.$webdir.$db2->f('dirname').$db2->f('filename');
$thumblocation=$filedir.$webdir.$db2->f('filename');
if (!file_exists($thumblocation)){
// create thunbnail
$fileinformation=getimagesize($imagelocation);
$imagewidth = $fileinformation[0];
$imageheight = $fileinformation[1];
$imagetype=$db2->f('filetype');
$imageattributes = $fileinformation[3];
//$newfile= $last_id."-image.".$imagetype;
$target=$thumblocation;
if ( !(copy($imagelocation,$target)))
{
echo "Could not copy file to destintaion., Command returned Error Message. Please check your log files. ".$imagelocation." ".$target;
die;
}
//create thumbnails 80xrelational height; neu $thumbnail_width x proportionale Höhe
// Determine what filetype and set pointer to source image
$original_image=ImageCreateFromJPEG($target);
if (!$original_image){
echo 'Error getting image from '.$target.'.';
}
$palette_image =$filedir.$webdir.'vorlage.jpg';
$thumbsize = getImageSize($palette_image);
$maxdim = $thumbsize[0];
$draw_from = $imagelocation;
$dim = GetImageSize($draw_from);
if($dim[0]>$dim[1])
{
$to_w = $maxdim;
$to_h = round($dim[1]*($maxdim/$dim[0]));
$to_x = 0;
$to_y = round($maxdim-$to_h)/2;
}
else
{
$to_h = $maxdim;
$to_w = round($dim[0]*($maxdim/$dim[1]));
$to_y = 0;
$to_x = round($maxdim-$to_w)/2;
}
if($dim[2]==1) {$from = ImageCreateFromGIF($draw_from);}
elseif($dim[2]==2) {$from = ImageCreateFromJPEG($draw_from);}
elseif($dim[2]==3) {$from = ImageCreateFromPNG($draw_from);}
$thumb = ImageCreateFromJPEG($palette_image);
// $set_bg_colour = ImageColorAllocate($thumb,255,0,0);
// $fill_bg_colour = ImageFill($thumb,0,0,$set_bg_colour);
imagecopyresized($thumb, $from, $to_x, $to_y, 0,
0, $to_w, $to_h, $dim[0], $dim[1]);
//echo $target;
// set image width and height of thunbnail and put pointer for filesytsem
$thumbfile= $db2->f('filename');
$target_thumb=$thumblocation;
$t_width=$thumbnail_width;
// calculating height to maintain ratio
$t_height=($thumbnail_width/$imagewidth)*$imageheight;
// remove digits to get solid number
list ($t_height,$notimportand)=explode('.',$t_height);
// create blank image
$thumb_image=imagecreatetruecolor($t_width,$t_height);
// $thumb_image=imagecreate($t_width,$t_height);
// $thumb_image=ImageCreateFromJPEG($palette_image);
// resize image based on height and width
imagecopyresampled($thumb_image,$original_image,0,0,0,0,$t_width,$t_height,$imagewidth,$imageheight);
// store image on file system
// requires different functionf for either gif or jpeg
imagejpeg($thumb,$target_thumb);
imagedestroy($thumb);
imagedestroy($original_image);
}
$image=$webdir.$db2->f('filename');
//wenn Artikel kein Bild hat
if (!$db2->f('filename')){
$imagetag= "";
}
else $imagetag="<img src=\" $image \" border=0 align=\"left\">";
} // ende wenn keine thumbs gewünscht
/**************** Ende Thumbnails ***********************/
// link
$link = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$selcat&idart=$linkID[$key]&m=$m&s=$s&md=$modifydate");
/***********************Anfang Tablezeile für Artikelliste**********************/
echo '
<tr><td height="20"><span class="date">'.$modifydate.'</span> - <span class="black">'.$headline.'</span></td></tr>
<tr><td valign="top">'.$subheadline.'</td></tr>
<tr><td valign="top">'.$text.'</td></tr>
<tr><td valign="top">';
$db3 = new DB_Contenido;
$sql = "SELECT a.idupl, a.filename, a.dirname FROM con_upl a, con_content c WHERE a.filetype = 'pdf' AND c.idartlang='$value'";
$db3->query($sql);
while ($db3->next_record()){
$medias[] = array('idupl'=> $db3->f('idupl'), 'filename' =>$db3->f('filename'), 'dirname' =>$db3->f('dirname'));
}
$CMS_VALUE = array_unique($CMS_VALUE);
for ($i=0; $i <= count($CMS_VALUE); $i+=2){
foreach ($medias as $media){
$data_local= $cfgClient[$client]["upl"]["path"]. $media['dirname']. $media['filename'];
$data_http= $cfgClient[$client]["upl"]["htmlpath"]. $media['dirname']. $media['filename'];
echo "<p class='download'>\n";
echo "<img src=".uplGetFileIcon($data_local)." alt=". getFileExtension($data_local)."> ";
echo "<a href='$data_http'>".$CMS_VALUE[($i+1)]." (Dateigröße ". human_readable_size(filesize($data_local)).")</a>";
echo "</p>\n";
}
}
unset($data_local);
unset($data_http);
unset($medias);
echo '</td></tr>
<tr><td height="10"> </td></tr>
<tr><td height="10" class="horiz_border"> </td></tr>';
} // end while
unset($headline);
unset($headline1);
unset($subheadline);
unset($subheadline1);
unset($text);
unset($textl);
} // end foreach
} // end if (is_array)
echo '</table>';
/***********************ende Table**********************/
function getFileExtension($filename)
{
$dotposition = strrpos($filename, ".");
if ($dotposition !== false)
{
return (strtolower(substr($filename, $dotposition + 1)));
} else {
return false;
}
}
function human_readable_size( $number )
{
$base = 1024;
$suffixes = array( " B", " KB", " MB", " GB", " TB", " PB", " EB" );
$usesuf = 0;
$n = (float) $number; //Appears to be necessary to avoid rounding
while( $n >= $base )
{
$n /= (float) $base;
$usesuf++;
}
$places = 2 - floor( log10( $n ) );
$places = max( $places, 0 );
$retval = number_format( $n, $places, ".", "" ) . $suffixes[$usesuf];
return $retval;
}
/**
* Returns the icon for a file type
* Edited for Contenido 4.4.4
* @param $file Filename to retrieve the extension for
*
* @return Icon for the file type
*
*/
function uplGetFileIcon ($file)
{
global $cfg;
switch (getFileExtension($file))
{
case "sxi":
case "sti":
case "pps":
case "pot":
case "kpr":
case "ppt": $icon = "ppt.gif";
break;
case "doc": $icon = "doc.gif";
break;
case "dot":
case "sxw":
case "stw":
case "sdw":
case "kwd": $icon = "upl_text.gif";
break;
case "xls":
case "sxc":
case "stc":
case "xlw":
case "xlt":
case "csv":
case "ksp":
case "sdc": $icon = "excel.gif";
break;
case "txt":
case "rtf": $icon = "txt.gif";
break;
case "gif": $icon = "gif.gif";
break;
case "png": $icon = "png.gif";
break;
case "jpeg":
case "jpg": $icon = "jpg.gif";
break;
case "html":
case "htm": $icon = "html.gif";
break;
case "lha":
case "rar":
case "arj":
case "bz2":
case "bz":
case "gz":
case "tar":
case "tbz2":
case "tbz":
case "tgz":
case "zip": $icon = "zip.gif";
break;
case "pdf": $icon = "pdf.gif";
break;
case "avi":
case "mpeg":
case 'mpg':
case 'asf':
case 'wmv':
$icon = "avi.gif"; break;
case "mov":
case "3gp":
case "mp4":
case 'mpeg4':
$icon = "mov.gif"; break;
case "rm" :
case "ram" : $icon = "real.gif"; break;
default: $icon = "upl_unknown.gif";
}
return $cfg['path']['contenido_fullhtml'] . $cfg["path"]["images"]. $icon;
}
?>