Mit dieser Modifikation sind mehr Textteile als Headline und Text auswählbar, Code etwas schlanker. Im Output kann man außerdem einstellen, ob nach X Teasern etwas anderes erscheinen soll.
Code: Alles auswählen
# Initialization
$bDebug = false;
unset ($aSettings);
$aSettings = array();
$aSettings["ArticleCount"] = "CMS_VALUE[1]";
$aSettings["TeaserLength"] = "CMS_VALUE[2]";
$aSettings["SampleCat"] = "CMS_VALUE[3]";
$aSettings["SampleArt"] = "CMS_VALUE[4]";
$aSettings["HeadlineIdentifier"] = "CMS_VALUE[5]";
$aSettings["TextIdentifier"] = "CMS_VALUE[6]";
$aSettings["Text2Identifier"] = "CMS_VALUE[15]";
$aSettings["Text3Identifier"] = "CMS_VALUE[16]";
$aSettings["ImageIdentifier"] = "CMS_VALUE[7]";
$aSettings["ImageWidth"] = "CMS_VALUE[8]";
$aSettings["ImageHeight"] = "CMS_VALUE[9]";
$aSettings["ImageFromContent"] = "CMS_VALUE[10]";
# Functions
function fncBuildCategorySelect($sName, $sValue, $sLevel = 0, $sOnChange = '') {
global $cfg, $client, $lang, $idcat;
$db = new DB_Contenido;
$db2 = new DB_Contenido;
$html = '';
$html .= '<select name="'.$sName.'" onchange="'.$sOnChange.'">';
$html .= ' <option value="">'.i18n("Please choose").'</option>';
if ($sLevel > 0) {
$addString = "AND c.level<$sLevel";
}
$sql = "SELECT
a.idcat AS idcat,
b.name AS name,
c.level
FROM
".$cfg["tab"]["cat"]." AS a,
".$cfg["tab"]["cat_lang"]." AS b,
".$cfg["tab"]["cat_tree"]." AS c
WHERE
a.idclient = '".$client."' AND
b.idlang = '".$lang."' AND
b.idcat = a.idcat AND
c.idcat = a.idcat $addString
ORDER BY
c.idtree";
$db->query($sql);
$categories = array ();
while ($db->next_record()) {
$categories[$db->f("idcat")]["name"] = $db->f("name");
$sql = "SELECT level FROM ".$cfg["tab"]["cat_tree"]." WHERE idcat = '".$db->f("idcat")."'";
$db2->query($sql);
if ($db2->next_record()) {
$categories[$db->f("idcat")]["level"] = $db2->f("level");
}
$sql2 = "SELECT
a.title AS title,
b.idcatart AS idcatart
FROM
".$cfg["tab"]["art_lang"]." AS a,
".$cfg["tab"]["cat_art"]." AS b
WHERE
b.idcat = '".$db->f("idcat")."' AND
a.idart = b.idart AND
a.idlang = '".$lang."'";
$db2->query($sql);
while ($db2->next_record()) {
$categories[$db->f("idcat")]["articles"][$db2->f("idcatart")] = $db2->f("title");
}
}
foreach ($categories as $tmpidcat => $props) {
$spaces = " ";
for ($i = 0; $i < $props["level"]; $i ++) {
$spaces .= " ";
}
$tmp_val = $tmpidcat;
if ($sValue != $tmp_val) {
$html .= '<option value="'.$tmp_val.'" style="background-color:#EFEFEF">'.$spaces.">".$props["name"].'</option>';
} else {
$html .= '<option value="'.$tmp_val.'" style="background-color:#EFEFEF" selected="selected">'.$spaces.">".$props["name"].'</option>';
}
}
$html .= '</select>';
unset ($db2);
unset ($sql);
unset ($categories);
unset ($tmp_val);
unset ($tmpidcat);
unset ($spaces);
return $html;
}
function fncBuildArticleSelect($sName, $sIDCat, $sValue, $sOnChange = '') {
global $cfg, $lang;
$db2 = new DB_Contenido;
$html = '';
$html .= '<select name="'.$sName.'" onchange="'.$sOnChange.'">'.chr(10);
$html .= ' <option value="" selected>'.i18n("Please choose").'</option>'.chr(10);
if (is_numeric($sIDCat) && $sIDCat > 0) {
$sql = "SELECT
a.title AS title,
b.idcatart AS idcatart
FROM
".$cfg["tab"]["art_lang"]." AS a,
".$cfg["tab"]["cat_art"]." AS b
WHERE
a.online = '1' AND
b.idcat = '".$sIDCat."' AND
a.idart = b.idart AND
a.idlang = '".$lang."'";
$db2->query($sql);
while ($db2->next_record()) {
$lIDCatArt = $db2->f('idcatart');
$sTitle = $db2->f('title');
if ($sValue != $lIDCatArt) {
$html .= '<option value="'.$lIDCatArt.'"> '.$sTitle.'</option>'.chr(10);
} else {
$html .= '<option selected="selected" value="'.$lIDCatArt.'"> '.$sTitle.'</option>'.chr(10);
}
}
}
$html .= '</select>'.chr(10);
unset ($db2);
unset ($lIDCatArt);
unset ($sTitle);
return $html;
}
function fncBuildTypeSelect($sName, $lIDCatArt, $sValue, $sTypeRange = '', $sOnChange = '') {
global $cfg, $lang;
$db2 = new DB_Contenido;
$html = '';
$html .= '<select name="'.$sName.'" onchange="'.$sOnChange.'">'.chr(10);
$html .= ' <option value="" selected>'.i18n("Please choose").'</option>'.chr(10);
if (is_numeric($lIDCatArt) && $lIDCatArt > 0) {
$sql = "SELECT
a.typeid AS typeid,
a.value AS value,
a.idtype AS idtype,
d.type AS type,
d.description AS description
FROM
".$cfg["tab"]["content"]." AS a,
".$cfg["tab"]["art_lang"]." AS b,
".$cfg["tab"]["cat_art"]." AS c,
".$cfg["tab"]["type"]." AS d
WHERE
a.idtype = d.idtype AND
a.idartlang = b.idartlang AND
b.idart = c.idart AND
b.idlang = '".$lang."' AND ";
if ($sTypeRange != "") {
$sql .= "a.idtype IN (".$sTypeRange.") AND ";
}
$sql .= " c.idcatart = '".$lIDCatArt."' ORDER BY a.idtype, a.typeid";
$db2->query($sql);
while ($db2->next_record()) {
$sTypeIdentifier = "tblData.idtype = '".$db2->f('idtype')."' AND tblData.typeid = '".$db2->f('typeid')."'";
$sContent = $db2->f('type')."[".$db2->f('typeid')."]: ".substr(strip_tags(urldecode($db2->f("value"))), 0, 50);
$sDescription = i18n($db2->f("description"));
if ($sValue != $sTypeIdentifier) {
$html .= '<option value="'.$sTypeIdentifier.'"> '.$sContent.'</option>'.chr(10);
} else {
$html .= '<option selected="selected" value="'.$sTypeIdentifier.'"> '.$sContent.'</option>'.chr(10);
}
}
}
$html .= '</select>'.chr(10);
unset ($db2);
unset ($sTypeIdentifier);
unset ($sContent);
unset ($sDescription);
return $html;
}
# Checking values
if (!is_numeric($aSettings["ArticleCount"]) || $aSettings["ArticleCount"] <= 0) {
$aSettings["ArticleCount"] = 1;
}
if (!is_numeric($aSettings["TeaserLength"]) || $aSettings["TeaserLength"] <= 0) {
$aSettings["TeaserLength"] = 50;
}
if (!is_numeric($aSettings["SampleCat"]) || $aSettings["SampleCat"] < 0) {
$aSettings["SampleCat"] = 0;
}
if (!is_numeric($aSettings["SampleArt"]) || $aSettings["SampleArt"] < 0) {
$aSettings["SampleArt"] = 0;
}
if (strlen($aSettings["HeadlineIdentifier"]) > 50) {
$aSettings["HeadlineIdentifier"] = "";
}
if (strlen($aSettings["TextIdentifier"]) > 50) {
$aSettings["TextIdentifier"] = "";
}
if (strlen($aSettings["Text2Identifier"]) > 50) {
$aSettings["Text2Identifier"] = "";
}
if (strlen($aSettings["Text3Identifier"]) > 50) {
$aSettings["Text3Identifier"] = "";
}
if (strlen($aSettings["ImageIdentifier"]) > 50) {
$aSettings["ImageIdentifier"] = "";
}
if (!is_numeric($aSettings["ImageWidth"]) || $aSettings["ImageWidth"] <= 0) {
$aSettings["ImageWidth"] = 0;
$aSettings["ImageHeight"] = 0;
}
if (!is_numeric($aSettings["ImageHeight"]) || $aSettings["ImageHeight"] <= 0) {
$aSettings["ImageWidth"] = 0;
$aSettings["ImageHeight"] = 0;
}
echo ' <table cellspacing="0" cellpadding="2" border="0" width="100%">', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td>'.mi18n("Count:").'</td>', chr(10);
echo ' <td><input type="text" name="CMS_VAR[1]" value="'.$aSettings["ArticleCount"].'" size="5"> <input type="image" src="images/submit.gif"></td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td>'.mi18n("Teaser length (max.):").'</td>', chr(10);
echo ' <td><input type="text" name="CMS_VAR[2]" value="'.$aSettings["TeaserLength"].'" size="5"></td>', chr(10);
echo ' </tr>', chr(10);
echo ' </table>', chr(10);
echo ' <table cellspacing="0" cellpadding="2" border="0" width="100%">', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td colspan="2" class="textw_medium" style="background-color: #a9aec2; border: 1px solid #747488;">'.mi18n("Identify elements:").'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td colspan="2" class="text" style="border-left: 1px solid #747488; border-right: 1px solid #747488;">'.mi18n("Sample category:").'<br />'.fncBuildCategorySelect("CMS_VAR[3]", $aSettings["SampleCat"], 0, "if (document.forms[0].elements['CMS_VAR[3]'].value != 'CMS_VALUE[3]') { document.forms[0].elements['CMS_VAR[4]'].disabled = true; document.forms[0].elements['CMS_VAR[5]'].disabled = true; document.forms[0].elements['CMS_VAR[6]'].disabled = true; document.forms[0].elements['CMS_VAR[15]'].disabled = true; document.forms[0].elements['CMS_VAR[16]'].disabled = true; document.forms[0].elements['CMS_VAR[7]'].disabled = true; } else { document.forms[0].elements['CMS_VAR[4]'].disabled = false; document.forms[0].elements['CMS_VAR[5]'].disabled = false; document.forms[0].elements['CMS_VAR[6]'].disabled = false; document.forms[0].elements['CMS_VAR[15]'].disabled = false; document.forms[0].elements['CMS_VAR[16]'].disabled = false; document.forms[0].elements['CMS_VAR[7]'].disabled = false;}").' <input type="image" src="images/submit.gif"></td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td colspan="2" class="text" style="border-left: 1px solid #747488; border-right: 1px solid #747488;">'.mi18n("Sample Article:").'<br />'.fncBuildArticleSelect("CMS_VAR[4]", $aSettings["SampleCat"], $aSettings["SampleArt"], "if (document.forms[0].elements['CMS_VAR[4]'].value != 'CMS_VALUE[4]') { document.forms[0].elements['CMS_VAR[5]'].disabled = true; document.forms[0].elements['CMS_VAR[6]'].disabled = true; document.forms[0].elements['CMS_VAR[15]'].disabled = true; document.forms[0].elements['CMS_VAR[16]'].disabled = true; document.forms[0].elements['CMS_VAR[7]'].disabled = true; } else { document.forms[0].elements['CMS_VAR[5]'].disabled = false; document.forms[0].elements['CMS_VAR[6]'].disabled = false; document.forms[0].elements['CMS_VAR[15]'].disabled = false; document.forms[0].elements['CMS_VAR[16]'].disabled = false; document.forms[0].elements['CMS_VAR[7]'].disabled = false;}").' <input type="image" src="images/submit.gif"></td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Headline Element:").'</td>', chr(10);
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildTypeSelect("CMS_VAR[5]", $aSettings["SampleArt"], $aSettings["HeadlineIdentifier"], "'1','2','3','9','17'").'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Text Element:").'</td>', chr(10);
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildTypeSelect("CMS_VAR[6]", $aSettings["SampleArt"], $aSettings["TextIdentifier"], "'1','2','3','9','17'").'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Text Element 2:").'</td>', chr(10);
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildTypeSelect("CMS_VAR[15]", $aSettings["SampleArt"], $aSettings["Text2Identifier"], "'1','2','3','9','17'").'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Text Element 3:").'</td>', chr(10);
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildTypeSelect("CMS_VAR[16]", $aSettings["SampleArt"], $aSettings["Text3Identifier"], "'1','2','3','9','17'").'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488; border-bottom: 1px solid #747488;">'.mi18n("Image Element:").'</td>', chr(10);
echo ' <td class="text" style="border-right: 1px solid #747488; border-bottom: 1px solid #747488;">',chr(10);
if ($aSettings["ImageFromContent"] != "") {
echo ' <input type="checkbox" name="CMS_VAR[10]" value="enabled" checked onclick="document.forms[0].elements[\'CMS_VAR[7]\'].disabled = true;" />'.mi18n("From text").' <input type="image" src="images/submit.gif"> ',chr(10);
echo ' '.fncBuildTypeSelect("CMS_VAR[7]", $aSettings["SampleArt"], $aSettings["ImageIdentifier"], "'1','2','3','9','17'").' ', chr(10);
} else {
echo ' <input type="checkbox" name="CMS_VAR[10]" value="enabled" onclick="document.forms[0].elements[\'CMS_VAR[7]\'].disabled = true;" />'.mi18n("From text").' <input type="image" src="images/submit.gif"> ',chr(10);
echo ' '.fncBuildTypeSelect("CMS_VAR[7]", $aSettings["SampleArt"], $aSettings["ImageIdentifier"], "'4'").' ', chr(10);
}
echo ' '.mi18n("Width:").' <input type="text" name="CMS_VAR[8]" value="'.$aSettings["ImageWidth"].'" size="5" title="'.mi18n("Set to 0 to disable resize").'"> ', chr(10);
echo ' '.mi18n("Height:").' <input type="text" name="CMS_VAR[9]" value="'.$aSettings["ImageHeight"].'" size="5" title="'.mi18n("Set to 0 to disable resize").'"></td>', chr(10);
echo ' </tr>', chr(10);
echo ' </table>', chr(10);
for ($i = 0; $i < $aSettings["ArticleCount"]; $i++) {
$lCatIdentifier = 20 + ($i * 2);
$lArtIdentifier = 21 + ($i * 2);
echo ' <br />', chr(10);
echo ' <table cellspacing="0" cellpadding="2" border="0" width="100%>', chr(10);
echo ' <tr valign="top">', chr(10);
echo ' <td class="textw_medium" style="background-color: #a9aec2; border: 1px solid #747488;">'.sprintf(mi18n("Article %d:"), $i + 1).'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488; border-right: 1px solid #747488;">'.mi18n("Select Category:")."</td>", chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
if ($bDebug) {
echo "<td><pre>Count: ".$aSettings["ArticleCount"].", Cat: CMS_VALUE[$lCatIdentifier], CatArt: CMS_VALUE[$lArtIdentifier], Client: ".$client.", Lang: ".$lang."<br />Webpath: ".$cfgClient[$client]['path']['htmlpath']."</pre></td>", chr(10);
}
echo ' <td class="text" style="border-left: 1px solid #747488; border-right: 1px solid #747488;">'.fncBuildCategorySelect("CMS_VAR[$lCatIdentifier]", "CMS_VALUE[$lCatIdentifier]", 0, "if (document.forms[0].elements['CMS_VAR[$lCatIdentifier]'].value != 'CMS_VALUE[$lCatIdentifier]') { document.forms[0].elements['CMS_VAR[$lArtIdentifier]'].disabled = true; } else { document.forms[0].elements['CMS_VAR[$lArtIdentifier]'].disabled = false; }").' <input type="image" src="images/submit.gif"></td>', chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488; border-right: 1px solid #747488;">'.mi18n("Select Article:")."</td>", chr(10);
echo ' </tr>', chr(10);
echo ' <tr valign="top">',chr(10);
echo ' <td class="text" style="border-left: 1px solid #747488; border-right: 1px solid #747488; border-bottom: 1px solid #747488;">'.fncBuildArticleSelect("CMS_VAR[$lArtIdentifier]", "CMS_VALUE[$lCatIdentifier]", "CMS_VALUE[$lArtIdentifier]").'</td>', chr(10);
echo ' </tr>', chr(10);
echo ' </table>', chr(10);
}
Code: Alles auswählen
<?php
# Initialization
$bDebug = false;
unset ($aSettings);
unset ($aData);
$aSettings = array();
$aData = array();
$aSettings["ArticleCount"] = "CMS_VALUE[1]";
$aSettings["TeaserLength"] = "CMS_VALUE[2]";
$aSettings["HeadlineIdentifier"] = "CMS_VALUE[5]";
$aSettings["TextIdentifier"] = "CMS_VALUE[6]";
$aSettings["Text2Identifier"] = "CMS_VALUE[15]";
$aSettings["Text3Identifier"] = "CMS_VALUE[16]";
$aSettings["ImageIdentifier"] = "CMS_VALUE[7]";
$aSettings["ImageWidth"] = "CMS_VALUE[8]";
$aSettings["ImageHeight"] = "CMS_VALUE[9]";
$aSettings["ImageFromContent"] = "CMS_VALUE[10]";
# Checking values
if (!is_numeric($aSettings["ArticleCount"]) || $aSettings["ArticleCount"] <= 0) {
$aSettings["ArticleCount"] = 0;
}
if (!is_numeric($aSettings["TeaserLength"]) || $aSettings["TeaserLength"] <= 0) {
$aSettings["TeaserLength"] = 50;
}
if (!is_numeric($aSettings["ImageWidth"]) || $aSettings["ImageWidth"] <=0) {
$aSettings["ImageWidth"] = 0;
$aSettings["ImageHeight"] = 0;
}
if (!is_numeric($aSettings["ImageHeight"]) || $aSettings["ImageHeight"] <=0) {
$aSettings["ImageWidth"] = 0;
$aSettings["ImageHeight"] = 0;
}
if (!is_object($db2)) {
$db2 = new DB_Contenido;
}
if (!is_object($db3)) {
$db3 = new DB_Contenido;
}
if ($aSettings["ArticleCount"] > 0 && ($aSettings["HeadlineIdentifier"]!="" || $aSettings["TextIdentifier"]!="" || $aSettings["Text2Identifier"]!="" || $aSettings["Text3Identifier"]!="" || $aSettings["ImageIdentifier"]!="")) {
for ($i = 0; $i < $aSettings["ArticleCount"]; $i++) {
$lArtIdentifier = 21 + ($i * 2);
$aData["Item".($i + 1)] = array();
$aData["Item".($i + 1)]["IDCatArt"] = "CMS_VALUE[$lArtIdentifier]";
$aData["Item".($i + 1)]["Headline"] = " ";
$aData["Item".($i + 1)]["Text"] = " ";
$aData["Item".($i + 1)]["Text2"] = " ";
$aData["Item".($i + 1)]["Text3"] = " ";
$aData["Item".($i + 1)]["Image"] = array();
$aData["Item".($i + 1)]["Image"]["ServerPath"] = "";
$aData["Item".($i + 1)]["Image"]["WebPath"] = "";
if ($aData["Item".($i + 1)]["IDCatArt"] != "") {
$sql = "SELECT tblData.value AS value, tblData.idtype AS idtype, tblData.typeid AS typeid FROM ";
$sql .= $cfg["tab"]["cat_art"]." AS tblCatArt, ";
$sql .= $cfg["tab"]["art_lang"]." AS tblArtLang, ";
$sql .= $cfg["tab"]["content"]." AS tblData ";
$sql .= "WHERE tblData.idartlang = tblArtLang.idartlang AND ";
$sql .= "tblArtLang.idlang = '".$lang."' AND ";
$sql .= "tblArtLang.idart = tblCatArt.idart AND ";
$sql .= "tblCatArt.idcatart = '".$aData["Item".($i + 1)]["IDCatArt"]."' AND (";
$sql_items = "";
if ($aSettings["HeadlineIdentifier"] != "") {
$sql_items = "(".$aSettings["HeadlineIdentifier"].")";
}
if ($aSettings["TextIdentifier"] != "") {
if ($sql_items != "") {
$sql_items .= " OR (".$aSettings["TextIdentifier"].")";
} else {
$sql_items = "(".$aSettings["TextIdentifier"].")";
}
}
if ($aSettings["Text2Identifier"] != "") {
if ($sql_items != "") {
$sql_items .= " OR (".$aSettings["Text2Identifier"].")";
} else {
$sql_items = "(".$aSettings["Text2Identifier"].")";
}
}
if ($aSettings["Text3Identifier"] != "") {
if ($sql_items != "") {
$sql_items .= " OR (".$aSettings["Text3Identifier"].")";
} else {
$sql_items = "(".$aSettings["Text3Identifier"].")";
}
}
if ($aSettings["ImageIdentifier"] != "") {
if ($sql_items != "") {
$sql_items .= " OR (".$aSettings["ImageIdentifier"].")";
} else {
$sql_items = "(".$aSettings["ImageIdentifier"].")";
}
}
$sql .= $sql_items.")";
if ($bDebug) {
echo "<pre>".$sql."</pre>", chr(10);
}
// execute query
$db2->query($sql);
while ($db2->next_record()) {
$sTypeIdentifier = "tblData.idtype = '".$db2->f('idtype')."' AND tblData.typeid = '".$db2->f('typeid')."'";
# Note: The TypeIdentifier for one item may be the same as for another item.
# Therefore, we are storing the content everywhere as needed
if ($sTypeIdentifier == $aSettings["HeadlineIdentifier"]) {
$aData["Item".($i + 1)]["Headline"] = strip_tags(urldecode($db2->f('value')));
}
if ($sTypeIdentifier == $aSettings["TextIdentifier"]) {
$sTmpValue = strip_tags(urldecode($db2->f('value')));
if (strlen($sTmpValue) > $aSettings["TeaserLength"]) {
$sTmpValue = substr($sTmpValue, 0, $aSettings["TeaserLength"])."...";
}
$aData["Item".($i + 1)]["Text"] = $sTmpValue;
}
if ($sTypeIdentifier == $aSettings["Text2Identifier"]) {
$sTmpValue = strip_tags(urldecode($db2->f('value')));
if (strlen($sTmpValue) > $aSettings["TeaserLength"]) {
$sTmpValue = substr($sTmpValue, 0, $aSettings["TeaserLength"])."...";
}
$aData["Item".($i + 1)]["Text2"] = $sTmpValue;
}
if ($sTypeIdentifier == $aSettings["Text3Identifier"]) {
$sTmpValue = strip_tags(urldecode($db2->f('value')));
if (strlen($sTmpValue) > $aSettings["TeaserLength"]) {
$sTmpValue = substr($sTmpValue, 0, $aSettings["TeaserLength"])."...";
}
$aData["Item".($i + 1)]["Text3"] = $sTmpValue;
}
if ($sTypeIdentifier == $aSettings["ImageIdentifier"]) {
$sql = "";
if ($aSettings["ImageFromContent"] != "") {
$sTmpValue = urldecode($db2->f('value'));
$regEx = "/<img[^>]*?>.*?/i";
$match = array ();
preg_match($regEx, $sTmpValue, $match);
$regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
$img = array ();
preg_match($regEx, $match[0], $img);
$img_src = preg_split("/\//", $img[0]);
$img_name = $img_src[count($img_src) - 1];
$img_name = preg_replace("/\"/", "", $img_name);
#$img_split = preg_split("/\./", $img_name);
#$img_type = $img_split[count($img_split) - 1];
#$img_split2 = preg_split("/_/", $img_split[0]);
$name = $img_name;
#if (count($img_split2) > 1) {
# $img_x = $img_split2[count($img_split2) - 1];
# $img_y = $img_split2[count($img_split2) - 2];
# if (is_numeric($img_x) AND is_numeric($img_y)) {
# $suffix = "_".$img_x."_".$img_y.".".$img_type;
# $name = preg_replace("/$suffix/", "", $img_name);
# $name = $name.".[a-zA-Z]{3}";
# }
#}
if (strlen($name) > 0) {
$sql = "SELECT dirname, filename FROM ".$cfg["tab"]["upl"]." ";
$sql .= "WHERE filename REGEXP '$name'";
}
} else {
$sql = "SELECT dirname, filename FROM ".$cfg["tab"]["upl"]." ";
$sql .= "WHERE idupl = '".$db2->f('value')."'";
}
if ($bDebug) {
echo "<pre>".$sql."</pre>";
}
if ($sql != "") {
// execute query
$db3->query($sql);
if ($db3->next_record()) {
$aData["Item".($i + 1)]["Image"]["ServerPath"] = $cfgClient[$client]["upl"]["path"].$db3->f('dirname').$db3->f('filename');
$aData["Item".($i + 1)]["Image"]["WebPath"] = $cfgClient[$client]["upl"]["htmlpath"].$db3->f('dirname').$db3->f('filename');
}
}
}
}
}
}
unset ($db2);
unset ($sql);
unset ($sql_items);
unset ($sIDCatArt);
unset ($sTmpValue);
for ($i = 0; $i < $aSettings["ArticleCount"]; $i++) {
if ($aData["Item".($i + 1)]["IDCatArt"] != "") {
$href = $sess->url("front_content.php?idcatart=".$aData["Item".($i + 1)]["IDCatArt"]);
echo '<div id="area'.($i + 1).'">', chr(10);
if ($aSettings["ImageWidth"] == 0 || $aSettings["ImageHeight"] == 0) {
$image = $aData["Item".($i + 1)]["Image"]["WebPath"];
} else {
if ($aData["Item".($i + 1)]["Image"]["ServerPath"] != "" && file_exists($aData["Item".($i + 1)]["Image"]["ServerPath"])) {
#Scale image
$image = capiImgScale($aData["Item".($i + 1)]["Image"]["ServerPath"], $aSettings["ImageWidth"], $aSettings["ImageHeight"], false, false, 10, false);
} else {
$image = $aData["Item".($i + 1)]["Image"]["WebPath"];
}
}
#Get dimensions of the image
list ($width, $height, $type, $attr) = getimagesize($image);
echo ' <div id="image"><img src="'.$image.'" width="'.$width.'" height="'.$height.'" /></div>', chr(10);
echo ' <div id="headline">'.$aData["Item".($i + 1)]["Headline"].'</div>', chr(10);
echo ' <div id="text">'.$aData["Item".($i + 1)]["Text"].'<br /><a href="'.$href.'">'.mi18n("More...").'</a></div>', chr(10);
echo ' <div id="text2">'.$aData["Item".($i + 1)]["Text2"].'<br /><a href="'.$href.'">'.mi18n("More...").'</a></div>', chr(10);
echo ' <div id="text3">'.$aData["Item".($i + 1)]["Text3"].'<br /><a href="'.$href.'">'.mi18n("More...").'</a></div>', chr(10);
echo '</div>', chr(10);
}
}
}
?>