Gut, ich habs, viele Stunden hab ich auf dieser Artikelliste rumgeritten, um verschiedene Artikellisten mit Thumbs in einem Template zu haben.
Hier nun die angepassten zwei Module ARTIKELISTE-III und Artikelliste-II, damir die faulen unter euch gleich damit arbeiten können.
Limit wurde auf 3 gesetzt, habe es aber schon mit 10 Artikeln getestet. Module laufen einwandfrei.
http://www.autohaus-chaos.de/cms
Gruss,Alex
P.S. Lasst sehen was daraus geworden ist!
EDIT: Habe noch einen SQLFehler beseitigt, 04-11-25 || Erorrlog leer!!! || Datumsabfrage kommt jetzt aus der Datenbank (Danke Silvia)
--->INPUT-Artikelliste-III
Code: Alles auswählen
/**
* Artikelliste-III
*
* Liste von Artikeln mit mehreren Daten basierend
* auf 4fb referenz modul
* 1.Gibt die Subheadline eines Artikel mit aus
* 2.Anschnitte nur nach ganzen Wörtern
* 3.Thumnails werden vernünftig berechnet
* 4.Image für Erzeugung von Thumbs kann gewählt werden
* Author : Evert Smit / Dirk Uptmoor / Peter Beauvain
* Copyright : None
* Created : 13-07-03
* Modified : 16-08-02 /20-09-03 upt /02-02-04 Beau/ 24-11-04 AGL
*/
// selected category
$selected3 = "CMS_VALUE[300]";
$seldir3 = "CMS_VALUE[309]";
$selimg3 = "CMS_VALUE[311]";
//funktion für die checkboxen
function d_checked3($which3) {
if ($which3 != "") {
return "checked";
}
} // end function
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked3("CMS_VALUE[314]")." name=\"CMS_VAR[314]\"></td>
<td width=\"120\">Ausgabe mit Startartikel</td>
<td></td>
<td>Kategorie wählen:<br>
<select name=\"CMS_VAR[300]\">";
if($selected3!="0" && $selected3!=""){
echo"<option value=\"0\">--- kein ---</option>";
}else{
echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>";
}
// fetch all categorys
$query = "SELECT D.idcat, D.level, F.name FROM ".$cfg["tab"]["cat_tree"]." AS D, ".
$cfg["tab"]["cat"]." AS E, ".$cfg["tab"]["cat_lang"]." AS F WHERE D.idcat=E.idcat ".
"AND E.idcat=F.idcat AND F.idlang='$lang' AND E.idclient='$client' ".
"AND F.visible=1 ORDER BY D.idtree";
// execute query
$db->query($query);
// loop result and build the options
while ($db->next_record()) {
// indent spacer
$spaces3 = "|";
// how many levels
$levels3 = $db->f("level");
for ($i = 0; $i < $levels3; $i ++) {
// add 2 spaces for every level
$spaces3 = $spaces3 . "--";
} // end for
$spaces3 .= ">";
if ($selected3 == $db->f("idcat")) {
// selected category
echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces3 . $db->f("name") ."</option>";
} else {
// category
echo "<option value=\"". $db->f("idcat") ."\">". $spaces3 . $db->f("name") ."</option>";
} // end if
} // end while
echo "</select>";
echo "</td>
<td></td>
</tr>
<tr valign=\"top\">
<td></td>
<td></td>
<td width=\"120\"></td>
<td></td>
<td>Überschrift: (wenn leer, keine Ausgabe)<br>
<input type=\"text\" name=\"CMS_VAR[302]\" value=\"CMS_VALUE[302]\" size=\"24\"></td>
</tr>
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<td> <input type=\"checkbox\" value=\"on\" ".d_checked3("CMS_VALUE[304]")." name=\"CMS_VAR[304]\"> </td>
<td width=\"120\">Ausgabe der Artikel-Headline</td>
<td></td>
<td>Angezeigte Zeichen Artikel-Headline:<br>
<input type=\"text\" name=\"CMS_VAR[303]\" value=\"CMS_VALUE[303]\" size=\"24\"></td>
</tr>
<tr valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked3("CMS_VALUE[305]")." name=\"CMS_VAR[305]\"></td>
<td width=\"120\">Ausgabe der Artikel-Subheadline:</td>
<td></td>
<td>Angezeigte Zeichen Artikel-Subheadline:<br>
<input type=\"text\" name=\"CMS_VAR[306]\" value=\"CMS_VALUE[306]\" size=\"24\"></td>
</tr>
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked3("CMS_VALUE[307]")." name=\"CMS_VAR[307]\" ></td>
<td width=\"120\">Ausgabe der Thumbnails:</td>
<td></td>
<td>Bildcontainer für Thumbnail Quelle:<br>";
$db = new DB_Contenido;
$query = "SELECT output AS out, name AS beschreibung FROM ".$cfg["tab"]["mod"]." ";
$db->query($query);
echo"<select name=\"CMS_VAR[311]\">";
echo"<option value=\"kein\">-- kein --</option> ";
while ($db->next_record()) {
$frontendpath3 = $db->f("out");
$name3 = $db->f("beschreibung");
$rest3 = substr("$frontendpath3", 3, 30);
$find3 = strpos($rest3,"CMS_IMG");
if ($find3 === false) {
}
else {
$ok3 = substr($rest3, $find3, 10);
$nummer3 = substr($ok3, 8, 1);
?>
<option value="<?php echo $nummer3 ?>"<?php if ($selimg3 == $nummer3) echo " selected" ?>><?php echo $db->f("beschreibung") ?>
<?
}
}
echo" </option> </select> ";
echo"</td>
</tr>
<td></td><td></td>
<td width=\"120\">Thumbnail Ordner</td>
<td></td><td>Bitte wählen:<br><select name=\"CMS_VAR[309]\" size=\"1\">";
echo"<option value=\"kein\">-- kein --</option>";
$db = new DB_Contenido;
$query = "SELECT DISTINCT dirname FROM ".$cfg["tab"]["upl"]." ORDER BY dirname ASC";
$db->query($query);
while ($db->next_record()) {
?>
<option value="<?php echo $db->f("dirname") ?>"<?php if ($seldir == $db->f("dirname")) echo " selected" ?>><?php echo $db->f("dirname") ?></option>
<?php
}
echo "</select></td>
<tr valign=\"top\">
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
"; //Ende
--->OUTPUT-Artikelliste-III
Code: Alles auswählen
<?
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Erweiterte Artikelliste-III
*
* Liste von Artikeln mit mehreren Daten basierend
* auf 4fb referenz modul
* 1.Gibt die Subheadline eines Artikel mit aus
* 2.Anschnitte nur nach ganzen Wörtern
* 3.Thumnails werden vernünftig berechnet
* 4.Image für Erzeugung von Thumbs kann gewählt werden
* Author : Evert Smit / Dirk Uptmoor / Peter Beauvain
* Copyright : None
* Created : 13-07-03
* Modified : 16-08-02 /20-09-03 upt /02-02-04 Beau /24-11-04 AGL
********************************************************/
//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[314]";
if($print_startartikel !=""){
$startarton = "AND";
}
//die Überschrift wird ausgegeben wenn sie nicht leer ist.
$print_mainheadline3 = "CMS_VALUE[302]";
//soll headline ausgegeben werden?
$print_headline3 = "CMS_VALUE[304]";
//soll subheadline ausgegeben werden?
$print_subheadline3 = "CMS_VALUE[305]";
//soll ein thumnail ausgegeben werden?
$print_thumbnail = "CMS_VALUE[307]";
//thumbnail breite
$thumbnail_width = "CMS_VALUE[308]";
//wenn thumbnails = 0
$imagetag = "";
// second db class instance
$db2 = new DB_Contenido;
// selected category
$selcat = "CMS_VALUE[300]";
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 limit 3";
// 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" borderstyle="dashed" cellpadding="1" cellspacing="2" width="100%"
';
/**** Überschrift der Artikelliste wird ausgegeben, wenn nicht leer ********/
if($print_mainheadline3 !=""){
echo '
<tr>
<td bgcolor="#efefef" border="0" colspan="3" class="newsheadline"> CMS_VALUE[302] <br> </td>
</tr>
<tr>
<td height="5" class="text"> </td>
<td align="right" > </td>
</tr> ';
}
if($print_mainheadline3 ==""){
echo '
<tr>
<td colspan="2" class="newsheadline"> <br></td>
<td align="right"> </td>
</tr>
<tr>
<td bgcolor="#ffffff" class="text"> </td>
<td align="right" bgcolor="#ffffff"> </td>
</tr>
';
}
// Loop through articles
if (is_array($articleID)) {
foreach ($articleID as $key => $value) {
// select all CMS variables of the article
if($print_headline3!="0" && $print_headline3!=""){
$sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '1'";
$db->query($sql);
$db->next_record();
$headline3 = urldecode($db->f("value"));
for ($j=CMS_VALUE[303]; $j < CMS_VALUE[303]+20; $j++)
{
$headline3 = substr($headline3 , 0, $j);
$cut = substr($headline3, $j);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$headline3= substr($headline3 , 0, $j);
$headline3 .= ' .....';
}
}
}
$cfgTab_art_lang = $cfg['tab']['art_lang'];
$cfgTab_content = $cfg['tab']['content'];
$sql = "SELECT D.author AS author, E.lastmodified AS lastmod FROM $cfgTab_art_lang AS D, $cfgTab_content AS E WHERE D.idartlang='$value' AND E.idartlang=D.idartlang ORDER BY E.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_subheadline3!="0" && $print_subheadline3!=""){
$sql_subheadline3 = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '2'";
$db->query($sql_subheadline3);
$db->next_record();
$subheadline3 = urldecode($db->f("value"));
for ($i=CMS_VALUE[306]; $i < CMS_VALUE[306]+20; $i++)
{
$subheadline3 = substr($subheadline3 , 0, $i);
$cut = substr($subheadline3, $i);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$subheadline3= substr($subheadline3 , 0, $i);
$subheadline3 .= ' .....';
}
}
}
/******************* 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[311]'";
$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[309]';
$filedir=$frontendpath;
$imagelocation=$filedir.$webdir.$db2->f('dirname').$db2->f('filename');
$thumblocation=$filedir.$webdir.$thumbdir.$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.$thumbdir.'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);
imagecopyresampled($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.$thumbdir.$db2->f('filename');
$imagetag="<img src=\" $image \" border=0>";
} // 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");
/***********************Anfang Tablezeile für Artikelliste**********************/
echo '
<tr>
<td colspan="3" class="trnews1" cellpadding="2" ><div align="center"></div></td>
</tr>
<tr>
<td colspan="3" class="trnews1" cellpadding="2" ><A HREF="'.$link.'">'.$headline3.'</a></td>
</tr>
<tr>
<td width=\"$thumbnail_width\" align="left" bgcolor="#ffffff"><A HREF="'.$link.'">'.$imagetag.'</a></td>
<td colspan="2" valign="top" bgcolor="#ffffff" class="newstext">'.$subheadline3.'</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff"><span class="trnews1"><img src="upload/design/date.gif" border="0" align="middle" valign"bottom"></span></td>
<td align="center" class="trnews2"><A HREF="'.$link.'">'.$modifydate.'</a></td>
<td valign="bottom"><a href="'.$link.'"><img src="upload/design/mehr.gif" border="0" align="right"></a></td>
</tr>
<tr><td bgcolor="#FFFFFF"><IMG SRC="upload/design/fueller.gif" WIDTH="1" HEIGHT="2"
BORDER="0"></td></tr> ';
} // end while
unset($headline3);
unset($headline31);
unset($subheadline3);
unset($subheadline31);
} // end foreach
} // end if (is_array)
echo '</table>';
/***********************ende Table**********************/
?>
------------------------------------------------
--->INPUT Artikelliste-II
Code: Alles auswählen
/**
* Artikelliste-II
*
* Liste von Artikeln mit mehreren Daten basierend
* auf 4fb referenz modul
* 1.Gibt die Subheadline eines Artikel mit aus
* 2.Anschnitte nur nach ganzen Wörtern
* 3.Thumnails werden vernünftig berechnet
* 4.Image für Erzeugung von Thumbs kann gewählt werden
* Author : Evert Smit / Dirk Uptmoor / Peter Beauvain
* Copyright : None
* Created : 13-07-03
* Modified : 16-08-02 /20-09-03 upt /02-02-04 Beau/ 09-11-04 AGL
*/
// selected category
$selected2 = "CMS_VALUE[200]";
$seldir2 = "CMS_VALUE[209]";
$selimg2 = "CMS_VALUE[211]";
//funktion für die checkboxen
function d_checked2($which2) {
if ($which2 != "") {
return "checked";
}
} // end function
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked2("CMS_VALUE[214]")." name=\"CMS_VAR[214]\"></td>
<td width=\"120\">Ausgabe mit Startartikel</td>
<td></td>
<td>Kategorie wählen:<br>
<select name=\"CMS_VAR[200]\">";
if($selected2!="0" && $selected2!=""){
echo"<option value=\"0\">--- kein ---</option>";
}else{
echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>";
}
// fetch all categorys
$query = "SELECT G.idcat, G.level, I.name FROM ".$cfg["tab"]["cat_tree"]." AS G, ".
$cfg["tab"]["cat"]." AS H, ".$cfg["tab"]["cat_lang"]." AS I WHERE G.idcat=H.idcat ".
"AND H.idcat=I.idcat AND I.idlang='$lang' AND H.idclient='$client' ".
"AND I.visible=1 ORDER BY G.idtree";
// execute query
$db->query($query);
// loop result and build the options
while ($db->next_record()) {
// indent spacer
$spaces2 = "|";
// how many levels
$levels2 = $db->f("level");
for ($i = 0; $i < $levels2; $i ++) {
// add 2 spaces for every level
$spaces2 = $spaces2 . "--";
} // end for
$spaces2 .= ">";
if ($selected2 == $db->f("idcat")) {
// selected category
echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces2 . $db->f("name") ."</option>";
} else {
// category
echo "<option value=\"". $db->f("idcat") ."\">". $spaces2 . $db->f("name") ."</option>";
} // end if
} // end while
echo "</select>";
echo "</td>
<td></td>
</tr>
<tr valign=\"top\">
<td></td>
<td></td>
<td width=\"120\"></td>
<td></td>
<td>Überschrift: (wenn leer, keine Ausgabe)<br>
<input type=\"text\" name=\"CMS_VAR[202]\" value=\"CMS_VALUE[202]\" size=\"24\"></td>
</tr>
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<td> <input type=\"checkbox\" value=\"on\" ".d_checked2("CMS_VALUE[204]")." name=\"CMS_VAR[204]\"> </td>
<td width=\"120\">Ausgabe der Artikel-Headline</td>
<td></td>
<td>Angezeigte Zeichen Artikel-Headline:<br>
<input type=\"text\" name=\"CMS_VAR[203]\" value=\"CMS_VALUE[203]\" size=\"24\"></td>
</tr>
<tr valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked2("CMS_VALUE[205]")." name=\"CMS_VAR[205]\"></td>
<td width=\"120\">Ausgabe der Artikel-Subheadline:</td>
<td></td>
<td>Angezeigte Zeichen Artikel-Subheadline:<br>
<input type=\"text\" name=\"CMS_VAR[206]\" value=\"CMS_VALUE[206]\" size=\"24\"></td>
</tr>
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<tr bgcolor=\"#E8E8EE\" valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked2("CMS_VALUE[207]")." name=\"CMS_VAR[207]\" ></td>
<td width=\"120\">Ausgabe der Thumbnails:</td>
<td></td>
<td>Bildcontainer für Thumbnail Quelle:<br>";
$db = new DB_Contenido;
$query = "SELECT output AS out, name AS beschreibung FROM ".$cfg["tab"]["mod"]." ";
$db->query($query);
echo"<select name=\"CMS_VAR[211]\">";
echo"<option value=\"kein\">-- kein --</option> ";
while ($db->next_record()) {
$frontendpath2 = $db->f("out");
$name = $db->f("beschreibung");
$rest2 = substr("$frontendpath2", 3, 30);
$find2 = strpos($rest2,"CMS_IMG");
if ($find2 === false) {
}
else {
$ok2 = substr($rest2, $find2, 10);
$nummer2 = substr($ok2, 8, 1);
?>
<option value="<?php echo $nummer2 ?>"<?php if ($selimg2 == $nummer2) echo " selected" ?>><?php echo $db->f("beschreibung") ?>
<?
}
}
echo" </option> </select> ";
echo"</td>
</tr>
<td></td><td></td>
<td width=\"120\">Thumbnail Ordner</td>
<td></td><td>Bitte wählen:<br><select name=\"CMS_VAR[209]\" size=\"1\">";
echo"<option value=\"kein\">-- kein --</option>";
$db = new DB_Contenido;
$query = "SELECT DISTINCT dirname FROM ".$cfg["tab"]["upl"]." ORDER BY dirname ASC";
$db->query($query);
while ($db->next_record()) {
?>
<option value="<?php echo $db->f("dirname") ?>"<?php if ($seldir2 == $db->f("dirname")) echo " selected" ?>><?php echo $db->f("dirname") ?></option>
<?php
}
echo "</select></td>
<tr valign=\"top\">
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
"; //Ende
--->OUTPUT Artikelliste-II
Code: Alles auswählen
<?
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Erweiterte Artikelliste-II
*
* Liste von Artikeln mit mehreren Daten basierend
* auf 4fb referenz modul
* 1.Gibt die Subheadline eines Artikel mit aus
* 2.Anschnitte nur nach ganzen Wörtern
* 3.Thumnails werden vernünftig berechnet
* 4.Image für Erzeugung von Thumbs kann gewählt werden
* Author : Evert Smit / Dirk Uptmoor / Peter Beauvain
* Copyright : None
* Created : 13-07-03
* Modified : 16-08-02 /20-09-03 upt /02-02-04 Beau
************************************************/
//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[214]";
if($print_startartikel !=""){
$startarton = "AND";
}
//die Überschrift wird ausgegeben wenn sie nicht leer ist.
$print_mainheadline2 = "CMS_VALUE[202]";
//soll headline ausgegeben werden?
$print_headline2 = "CMS_VALUE[204]";
//soll subheadline ausgegeben werden?
$print_subheadline2 = "CMS_VALUE[205]";
//soll ein thumnail ausgegeben werden?
$print_thumbnail = "CMS_VALUE[207]";
//thumbnail breite
$thumbnail_width = "CMS_VALUE[208]";
//wenn thumbnails = 0
$imagetag = "";
// second db class instance
$db2 = new DB_Contenido;
// selected category
$selcat = "CMS_VALUE[200]";
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 limit 3";
// 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" borderstyle="dashed" cellpadding="1" cellspacing="2" width="100%"
';
/**** Überschrift der Artikelliste wird ausgegeben, wenn nicht leer ********/
if($print_mainheadline2 !=""){
echo '
<tr>
<td bgcolor="#efefef" border="0" colspan="3" class="newsheadline"> CMS_VALUE[202] <br> </td>
</tr>
<tr>
<td height="5" class="text"> </td>
<td align="right" > </td>
</tr> ';
}
if($print_mainheadline2 ==""){
echo '
<tr>
<td colspan="2" class="newsheadline"> <br></td>
<td align="right"> </td>
</tr>
<tr>
<td bgcolor="#ffffff" class="text"> </td>
<td align="right" bgcolor="#ffffff"> </td>
</tr>
';
}
// Loop through articles
if (is_array($articleID)) {
foreach ($articleID as $key => $value) {
// select all CMS variables of the article
if($print_headline2!="0" && $print_headline2!=""){
$sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '1'";
$db->query($sql);
$db->next_record();
$headline2 = urldecode($db->f("value"));
for ($j=CMS_VALUE[203]; $j < CMS_VALUE[203]+20; $j++)
{
$headline2 = substr($headline2 , 0, $j);
$cut = substr($headline2, $j);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$headline2= substr($headline2 , 0, $j);
$headline2 .= ' .....';
}
}
}
$cfgTab_art_lang = $cfg['tab']['art_lang'];
$cfgTab_content = $cfg['tab']['content'];
$sql = "SELECT G.author AS author, H.lastmodified AS lastmod FROM $cfgTab_art_lang AS G, $cfgTab_content AS H WHERE G.idartlang='$value' AND H.idartlang=G.idartlang ORDER BY H.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_subheadline2!="0" && $print_subheadline2!=""){
$sql_subheadline2 = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '2'";
$db->query($sql_subheadline2);
$db->next_record();
$subheadline2 = urldecode($db->f("value"));
for ($i=CMS_VALUE[206]; $i < CMS_VALUE[206]+20; $i++)
{
$subheadline2 = substr($subheadline2 , 0, $i);
$cut = substr($subheadline2, $i);
if ((ord ($cut) == 32)||(ord ($cut) == 44)||(ord ($cut) == 45)) {
$subheadline2= substr($subheadline2 , 0, $i);
$subheadline2 .= ' .....';
}
}
}
/******************* 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[211]'";
$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[209]';
$filedir=$frontendpath;
$imagelocation=$filedir.$webdir.$db2->f('dirname').$db2->f('filename');
$thumblocation=$filedir.$webdir.$thumbdir.$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.$thumbdir.'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);
imagecopyresampled($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.$thumbdir.$db2->f('filename');
$imagetag="<img src=\" $image \" border=0>";
} // 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");
/***********************Anfang Tablezeile für Artikelliste**********************/
echo '
<tr>
<td colspan="3" class="trnews1" cellpadding="2" ><div align="center"></div></td>
</tr>
<tr>
<td colspan="3" class="trnews1" cellpadding="2" ><A HREF="'.$link.'">'.$headline2.'</a></td>
</tr>
<tr>
<td width=\"$thumbnail_width\" align="left" bgcolor="#ffffff"><A HREF="'.$link.'">'.$imagetag.'</a></td>
<td colspan="2" valign="top" bgcolor="#ffffff" class="newstext">'.$subheadline2.'</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff"><span class="trnews1"><img src="upload/design/date.gif" border="0" align="middle" valign"bottom"></span></td>
<td align="center" class="trnews2"><A HREF="'.$link.'">'.$modifydate.'</a></td>
<td valign="bottom"><a href="'.$link.'"><img src="upload/design/mehr.gif" border="0" align="right"></a></td>
</tr>
<tr><td bgcolor="#FFFFFF"><IMG SRC="upload/design/fueller.gif" WIDTH="1" HEIGHT="2"
BORDER="0"></td></tr> ';
} // end while
unset($headline2);
unset($headline21);
unset($subheadline2);
unset($subheadline21);
} // end foreach
} // end if (is_array)
echo '</table>';
/***********************ende Table**********************/
?>