Neue und benutzerfreundlichere include.CMS_IMG.php
Verfasst: Fr 21. Nov 2003, 14:49
Hallo,
Derzeit ist es so, dass wenn man das Modul Bild verwendet und auf >> Image klickt lediglich ein DropDown mit allen Bildnamen (+Kommentar) erscheint. Ab einer bestimmten Anzahl an Bildern wird dieses DropDown etwas mühsam...
Lange Rede kurzer Sinn: Hab mich dem Thema angenommen und es ist eine neue include.CMS_IMG.php entstanden.
Änderungen:
- Bildauswahl erfolgt durch 2 Schritte (Auswahl Verzeichnis -> Auswahl Bild)
- Preview Fenster (Für alle, wie mich die mit dem Namen nichts anfagen können.)
Anmerkung:
Wurde nur minimal getestet. Also: Keine Verantwortung. Code wird später nocheinmal schöner geschrieben.
Installation
Obigen Code in die Datei include.CMS_IMG.php einfügen (ist unter /contenido/includes zu finden.)
@timo
Änderungswünsche bitte kundtun, damit diese Änderung vielleicht (hope so) in eine offiziele Version eingebaut wird.
Viel Spass noch und schönes WE....
chris
Derzeit ist es so, dass wenn man das Modul Bild verwendet und auf >> Image klickt lediglich ein DropDown mit allen Bildnamen (+Kommentar) erscheint. Ab einer bestimmten Anzahl an Bildern wird dieses DropDown etwas mühsam...
Lange Rede kurzer Sinn: Hab mich dem Thema angenommen und es ist eine neue include.CMS_IMG.php entstanden.
Änderungen:
- Bildauswahl erfolgt durch 2 Schritte (Auswahl Verzeichnis -> Auswahl Bild)
- Preview Fenster (Für alle, wie mich die mit dem Namen nichts anfagen können.)
Anmerkung:
Wurde nur minimal getestet. Also: Keine Verantwortung. Code wird später nocheinmal schöner geschrieben.
Code: Alles auswählen
<?php
/******************************************
* File : include.CMS_IMG.php
* Project : Contenido
* Descr : Include file for editiing
* content of type CMS_IMG
*
* Author : Jan Lengowski
* Created : 07.05.2003
* Modified : 07.05.2003
21.11.2003 (Ing. Christian Schuller - www.maurer-it.com)
*
* © four for business AG
******************************************/
if ($doedit == "1") {
consaveContentEntry($idartlang, "CMS_IMG", $typenr, $CMS_IMG);
consaveContentEntry($idartlang, "CMS_IMGDESCR", $typenr, $CMS_IMGDESCR);
conGenerateCodeForArtInAllCategories($idart);
header("location:".$sess->url($cfgClient[$client]["path"]["htmlpath"]."front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&changeview=edit"));
}
?>
<html>
<head>
<title>contenido</title>
<link rel="stylesheet" type="text/css" href="<?php print $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["styles"] ?>contenido.css">
</HEAD>
<script>
function disp_preview(id)
{
preview.document.open();
preview.document.writeln('<html><body style="padding:0px; margin:0px;"><table border=0 width=100% height=100%><tr><td align="middle"><img src="'+imglnk[id]+'"></td></tr></table></body></html>');
preview.document.close();
}
//disp_preview('http://www.maurer-it.com/cms/upload/bilder/Team/christian.jpg');
</script>
<body>
<table width="100%" border=0 cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td width="10" rowspan="4"><img src="<?php print $cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"] ?>spacer.gif" width="10" height="10"></td>
<td width="100%"><img src="<?php print $cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"] ?>spacer.gif" width="10" height="10"></td>
<td width="10" rowspan="4"><img src="<?php print $cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"] ?>spacer.gif" width="10" height="10"></td>
</tr>
<tr>
<td>
<?php
getAvailableContentTypes($idartlang);
echo " <FORM method=\"post\" action=\"".$cfg["path"]["contenido_fullhtml"].$cfg["path"]["includes"]."include.backendedit.php\">";
$sess->hidden_session();
// COLLECT DATA
if (!isset($img_dir))
{
$sql = "SELECT * FROM ".$cfg["tab"]["upl"]." WHERE idclient='".$client."' AND idupl = ".$a_content["CMS_IMG"][$typenr];
$db->query($sql);
$db->next_record();
$img_dir = $db->f("dirname");
}
$sql = "SELECT * FROM ".$cfg["tab"]["upl"]." WHERE idclient='".$client."' AND filetype IN ('jpg', 'gif', 'png') ORDER BY dirname, filename";
$db->query($sql);
while ( $db->next_record() ) {
$descr = $db->f("description");
if ( strlen($descr) > 24 ) {
$descr = substr($descr, 0, 24);
$descr .= "..";
}
// collect data for dir selection
$tmp = split("/",$db->f("dirname"));
if (!in_array($tmp[count($tmp)-2],$ds_name))
{
$ds_lvl[] = count($tmp)-1;
$ds_name[] = $tmp[count($tmp)-2];
$ds_fullpath[] = $db->f("dirname");
}
if (strcmp($img_dir,$db->f("dirname"))==0)
{
$img_list[] = $db->f("filename");
$img_id[] = $db->f("idupl");
$img_descr[] = $descr;
}
/*$img_dir
$fullpath=$db->f("dirname").$db->f("filename");
$imgpath = $cfgClient[$client]["path"]["htmlpath"]."/upload/".$fullpath;
$t = "".$fullpath." [".$descr."]";
if ($db->f("idupl") != $a_content["CMS_IMG"][$typenr]) {
echo "<option style=\"background-color:#C0C0C0;\" value=\"".$db->f("idupl")."\">".$t."</option><br>";
} else {
echo "<option value=\"".$db->f("idupl")."\" selected>".$t."</option><br>";
}*/
}
echo " <INPUT type=hidden name=lang value=\"$lang\">";
// echo " <INPUT type=hidden name=submit value=\"editcontent\">";
echo " <INPUT type=hidden name=typenr value=\"$typenr\">";
echo " <INPUT type=hidden name=idart value=\"$idart\">";
echo " <INPUT type=hidden name=idcat value=\"$idcat\">";
echo " <INPUT type=hidden name=idartlang value=\"$idartlang\">";
echo "<INPUT type=hidden name=doedit value=1>";
echo " <INPUT type=hidden name=action value=\"10\">";
echo " <INPUT type=hidden name=type value=\"$type\">";
echo "<INPUT type=hidden name=changeview value=\"edit\">";
echo " <TABLE cellpadding=$cellpadding cellspacing=$cellpadding border=0>";
echo " <TR><TD valign=\"top\" class=text_medium nowrap> ".i18n("Directory").": </TD><TD class=content>";
echo "<SELECT name=img_dir SIZE=1 onchange='doedit.value=0; submit();' style='width:300px;'>";
for($i=0;$i<count($ds_lvl);$i++)
{
$t = str_repeat("-",$ds_lvl[$i]*2)."> ".$ds_name[$i];
switch ($ds_lvl[$i])
{
case 0:
case 1: $style="background-color:#C0C0C0;"; break;
case 2: $style="background-color:#D0D0D0;"; break;
case 3: $style="background-color:#E0E0E0;"; break;
default: $style="background-color:#F0F0F0;"; break;
}
if (strcmp($img_dir,$ds_fullpath[$i])==0)
{
echo "<option style='".$style." font-weight:bold;' value='".$ds_fullpath[$i]."' selected>".$t."</option>";
}
else
{
echo "<option style='".$style.";' value='".$ds_fullpath[$i]."' >".$t."</option>";
}
}
echo "</SELECT>";
echo " </TD></TR>";
echo " <TR><TD valign=\"top\" class=text_medium nowrap> ".$typenr.". ".$a_description["CMS_IMG"][$typenr].": </TD><TD class=content>";
// Generate JavaScript Data Array
echo "<script>";
echo "imglnk = new Array();";
for($i=0;$i<count($img_list);$i++)
{
echo 'imglnk["'.$img_id[$i].'"] = "'.$cfgClient[$client]["path"]["htmlpath"]."upload/".$img_dir."/".$img_list[$i].'";';
}
echo "</script>";
echo "<SELECT name=CMS_IMG SIZE=1 onChange='disp_preview(this.value);' style='width:300px;'>";
if ($a_content["CMS_IMG"][$typenr] != "0") {
echo "<option value=0>-- ".i18n("None")." --</option>";
} else {
echo "<option value=0 selected>-- ".i18n("None")." --</option>";
}
for($i=0;$i<count($img_list);$i++)
{
$t = $img_list[$i]." (".$img_descr[$i].")";
//$onclick = "disp_preview('".$cfgClient[$client]["path"]["htmlpath"]."upload/".$img_dir."/".$img_list[$i]."');";
$onclick = "alert('hi');";
switch ($i % 2)
{
case 0: $style="background-color:#D0D0D0;"; break;
case 1: $style="background-color:#E0E0E0;"; break;
}
if ($a_content["CMS_IMG"][$typenr]==$img_id[$i])
{
echo "<option style='".$style." font-weight:bold;' value='".$img_id[$i]."' selected >".$t."</option>";
}
else
{
echo "<option style='".$style."' value='".$img_id[$i]."' >".$t."</option>";
}
}
echo "</SELECT>";
echo " </TD></TR>";
// Preview
echo " <TR><TD valign=\"top\" class=text_medium nowrap> ".i18n("Preview").": </TD><TD class=content>";
echo '<iframe src="about:blank" name="preview" style="border: 0px; width:300px; height:200px;">';
echo '</iframe>';
echo " </TD></TR>";
?>
<?
echo " <TR><TD valign=top class=text_medium nowrap> ".$a_description["CMS_IMGDESCR"][$typenr].": </TD><TD class=content>";
echo " <TEXTAREA class=text_medium name=CMS_IMGDESCR ROWS=3 COLS=30 style='width:300px;'>".$a_content["CMS_IMGDESCR"][$typenr]."</TEXTAREA>";
echo " </TD></TR>";
$tmp_area = "con_editcontent";
echo " <TR valign=top><TD colspan=2><br>
<a href=".$sess->url($cfgClient[$client]["path"]["htmlpath"]."front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&idartlang=$idartlang")."><img src=\"".$cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"]."but_cancel.gif\" border=0></a>
<INPUT type=image name=submit value=editcontent src=\"".$cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"]."but_ok.gif\" border=0 >
</TD></TR>";
echo " </TABLE>
</FORM>";
?>
</td></tr></table>
</body>
</HTML>
Obigen Code in die Datei include.CMS_IMG.php einfügen (ist unter /contenido/includes zu finden.)
@timo
Änderungswünsche bitte kundtun, damit diese Änderung vielleicht (hope so) in eine offiziele Version eingebaut wird.
Viel Spass noch und schönes WE....
chris