Neue und benutzerfreundlichere include.CMS_IMG.php

freeclimber
Beiträge: 21
Registriert: Fr 31. Okt 2003, 14:16
Kontaktdaten:

Neue und benutzerfreundlichere include.CMS_IMG.php

Beitrag von freeclimber » 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.

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>&nbsp;".i18n("Directory").":&nbsp;</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>&nbsp;".$typenr.".&nbsp;".$a_description["CMS_IMG"][$typenr].":&nbsp;</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>&nbsp;".i18n("Preview").":&nbsp;</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>&nbsp;".$a_description["CMS_IMGDESCR"][$typenr].":&nbsp;</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>
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

chriscross
Beiträge: 38
Registriert: Fr 31. Okt 2003, 15:25
Kontaktdaten:

good job

Beitrag von chriscross » Mo 24. Nov 2003, 10:09

danke freecliber für die überarbeitung des Bild-Moduls! Wollte mich dem, notgedrungen, schon selbst annehmen doch zum Glück bist du mir zuvorgekommen :D

gruss
chriscross

mtealc
Beiträge: 22
Registriert: Sa 29. Nov 2003, 03:22
Kontaktdaten:

Beitrag von mtealc » Di 2. Dez 2003, 18:06

Hi, nicht schlecht leider hat sich ein Bug eingeschlichen!
Wenn kein unterordner vohanden ist werden die bilder im DIR-> "Bilder" nicht angezeigt


mfg


micha

timo
Beiträge: 6284
Registriert: Do 15. Mai 2003, 18:32
Wohnort: Da findet ihr mich nie!
Kontaktdaten:

Beitrag von timo » Mi 3. Dez 2003, 10:29

Hab es in meinen Terminkalender eingetragen - werde aber kurzfristig nicht dazu kommen, die Sachen zu testen (da in der 4.4.x sowieso nur Bugfixes gemacht werden, finde ich es nicht weiter tragisch :))

christian@maurer-it.com
Beiträge: 27
Registriert: Fr 14. Nov 2003, 11:46
Wohnort: Wien
Kontaktdaten:

Beitrag von christian@maurer-it.com » Mi 3. Dez 2003, 11:38

Hallo, Danke für den Hinweis, werde den Bug so schnell wie möglcih suchen und korrigieren.... (diese woche noch.. hoffe ich.)

mfg chris

christian@maurer-it.com
Beiträge: 27
Registriert: Fr 14. Nov 2003, 11:46
Wohnort: Wien
Kontaktdaten:

Beitrag von christian@maurer-it.com » Mi 3. Dez 2003, 12:19

@mtealc

Sorry, aber konnte den Fehler nicht reproduzieren. Kannst Du mir bitte genau sagen wie dein upload verzeichnis strukturier ist, wo welche bilder liegen und wann diese in der 2ten dropdown nicht zur Auswahl stehen.

Danke! chris

micha28
Beiträge: 8
Registriert: Mi 23. Jul 2003, 13:10
Kontaktdaten:

Beitrag von micha28 » Mi 3. Dez 2003, 14:28

ok ich versuchs mal ;-)

mein verzeichniss Bilder hat im moment keine unterverzeichnisse!

-> im select tag steht nur ein wert "->Bilder"

durch einfügen eines Null wertes denke ich wäre das problem erledigt


gruss micha

christian@maurer-it.com
Beiträge: 27
Registriert: Fr 14. Nov 2003, 11:46
Wohnort: Wien
Kontaktdaten:

Beitrag von christian@maurer-it.com » Mi 3. Dez 2003, 14:30

Thx!

jetzt hab ichs. Der Fehler liegt in der ersten SelectBox. Denn nur bei einem onchange wird die 2. SelectBox mit Daten gefüllt. Wenn jedoch in der 1. nur ein Wert steht geht das nicht.

Werd das mal schnell ändern....

thx a lot !
mfg
Christian

micha28
Beiträge: 8
Registriert: Mi 23. Jul 2003, 13:10
Kontaktdaten:

ups

Beitrag von micha28 » Mi 3. Dez 2003, 14:32

genau das wars ;-)


gruss micha


ups ich hab ja zwei nick's hier

christian@maurer-it.com
Beiträge: 27
Registriert: Fr 14. Nov 2003, 11:46
Wohnort: Wien
Kontaktdaten:

Beitrag von christian@maurer-it.com » Mi 3. Dez 2003, 14:42

Hallo hier nun die neue Version!

Änderungen:
+ Bug behoben (thx for testing to micha28)
+ Farbanpassungen (Statt Grau nun die Contenido Backend Tabellenfarben.)

Code:

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)
*		03.12.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=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>&nbsp;".i18n("Directory").":&nbsp;</TD><TD class=content>";
        echo "<SELECT name=img_dir SIZE=1 onchange='doedit.value=0; submit();' style='width:300px; border: solid 1px ".$cfg['color']['table_border'].";'>";
        echo "<option style=\"background-color:".$cfg['color']['table_header'].";\" value='0' >".i18n("Please choose your Directory")."</option>";	
        	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:".$cfg['color']['table_header'].";"; break;
        	    case 2: $style="background-color:".$cfg['color']['table_light'].";"; break;
        	    case 3: $style="background-color:".$cfg['color']['table_dark'].";"; break;
        	    default: $style="background-color:".$cfg['color']['table_dark'].";"; 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>&nbsp;".i18n("Image").":&nbsp;</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; border: solid 1px ".$cfg['color']['table_border'].";'>";
                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:".$cfg['color']['table_light'].";"; break;
        	    case 1: $style="background-color:".$cfg['color']['table_dark'].";"; 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>&nbsp;".i18n("Preview").":&nbsp;</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>&nbsp;".$a_description["CMS_IMGDESCR"][$typenr].":&nbsp;</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>
mfG
Christian

micha28
Beiträge: 8
Registriert: Mi 23. Jul 2003, 13:10
Kontaktdaten:

Beitrag von micha28 » Mi 3. Dez 2003, 14:52

Ging aber schnell!
Respekt!
:D
gruss micha

timo
Beiträge: 6284
Registriert: Do 15. Mai 2003, 18:32
Wohnort: Da findet ihr mich nie!
Kontaktdaten:

Beitrag von timo » Mi 10. Dez 2003, 14:53

und hier die überarbeitete Version von uns :)

Notes:
- Die Werte für Breite, Höhe usw werden im CVS direkt aus dem Customizing gezogen
- Defaultwerte für Breite und Höhe des Previews auf 600x400
- Description-Box ist direkt unter dem Directory/Image Wähler
- Directory und Image werden in einer konfigurierbaren Liste angezeigt (wer ein Dropdown lieber mag, kann einfach den Default-Wert für die Höhe auf 1 setzen)
- Schattierung machen wir eventuell raus (was haltet ihr davon? Ich finde, Schattierung sollte nur sein, wenn mehr als 1 Spalte in einer Liste vorhanden ist -> sieht ohne besser aus)

Großes Lob für die Idee mit dem iframe als Preview (ja, das Ding funktioniert auch mit Mozilla/Firebird und ist HTML 4.0-konform :))

Viel Spaß!

Code: Alles auswählen

<?php

/*****************************************
* File      :   $RCSfile: include.CMS_IMG.php,v $
* Descr     :   CMS_IMG editor 
*
* Author    :   $Author: timo.hummel $
*               
* Created   :   10.12.2003
* Modified  :   $Date: 2003/12/10 13:50:47 $
*
* © four for business AG, www.4fb.de
*
* Contributions by:
* 21.11.2003 (Ing. Christian Schuller - www.maurer-it.com)
*
* $Id: include.CMS_IMG.php,v 1.20 2003/12/10 13:50:47 timo.hummel Exp $
******************************************/
      


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();
        }

</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

	cInclude("classes","class.ui.php");
	cInclude("classes","class.htmlelements.php");
	cInclude("classes","class.template.php");
	cInclude("includes","functions.forms.php");
	
    getAvailableContentTypes($idartlang);
    
    $dirheight = 5;
    $dirwidth = 300;
    $filewidth = 300;
    $fileheight = 5;
    $descrwidth = 70;
    $descrheight = 5;
    $previewwidth = 600;
    $previewheight = 400;
    
   
    // 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);
    
    $ds_name = Array();
    
    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;
        }
     
    }
    
    $form = new UI_Table_Form("editcontent", $cfg["path"]["contenido_fullhtml"].$cfg["path"]["includes"]."include.backendedit.php");
    $form->setVar("lang",$lang);
    $form->setVar("typenr",$typenr);
    $form->setVar("idart",$idart);
    $form->setVar("idcat",$idcat);
    $form->setVar("idartlang",$idartlang);
    $form->setVar("contenido",$sess->id);
    $form->setVar("action",10);
    $form->setVar("doedit",1);
    $form->setVar("type",$type);
    $form->setVar("changeview","edit");
    $form->setVar("CMS_LINK", $a_content["CMS_LINK"][$typenr]);       

	$header = sprintf(i18n("Edit image for container %s"),$typenr);
	$form->addHeader($header);
	
	$dirselect = new cHTMLSelectElement("img_dir");
	$dirselect->setEvent("change", "doedit.value=0; submit();");
	$dirselect->setSize($dirheight);
	$dirselect->setStyle("width: {$dirwidth}px;");
	
	foreach ($ds_lvl as $key => $value)
	{
		$text = str_repeat("-",$value*2)."> ".$ds_name[$key];

		$option = new cHTMLOptionElement($text, $ds_fullpath[$key]);
		
        switch ($value)
        {
            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[$key])==0)
        {
        	$option->setSelected("selected");	
        }
        
        $dirselect->addOptionElement($key, $option);
		
	}
	
	$script =  '<script language="JavaScript">';
	$script .= "imglnk = new Array();";
    
	foreach($img_list as $key => $value)
	{
    	$script .= 'imglnk["'.$img_id[$key].'"] = "'.$cfgClient[$client]["path"]["htmlpath"]."upload/".$img_dir."/".$img_list[$key].'";';
	}   
    $script .= "</script>";

	$fileselect = new cHTMLSelectElement("CMS_IMG");
	$fileselect->setEvent("change", "disp_preview(this.value);");
	$fileselect->setSize($fileheight);
	$fileselect->setStyle("width: {$filewidth}px;");

	$option = new cHTMLOptionElement("-- ".i18n("None")." --", "0");
	
	if ($a_content["CMS_IMG"][$typenr] == 0)
	{
		$option->setSelected("selected");
	}

	$fileselect->addOptionElement(0,$option);
	
    foreach ($img_list as $key => $value)
    {
    	$description = $img_descr[$key];
    	
    	if ($description != "")
    	{
    		$text = $value . " (". $description .")";	
    	} else {
    		$text = $value;
    	}

        switch ($key % 2)
        {
            case 0: $style="background-color:#D0D0D0;"; break;
            case 1: $style="background-color:#E0E0E0;"; break;
        }
        
        $option = new cHTMLOptionElement($text, $img_id[$key]);
        
        if ($a_content["CMS_IMG"][$typenr]==$img_id[$key])
		{
			$option->setSelected("selected");
		}
		
		$option->setStyle($style);
		$fileselect->addOptionElement($key, $option);
    }	
	
	$form->add(i18n("Directory / File"), $dirselect->render().$script.$fileselect->render());
	
	$textarea = new cHTMLTextarea("CMS_IMGDESCR", $a_content["CMS_IMGDESCR"][$typenr], $descrwidth, $descrheight);
	$form->add("Description", $textarea->render()); 
	
    $preview = '<iframe src="about:blank" name="preview" style="border: 0px; width:'.$previewwidth.'px; height:'.$previewheight.'px;">';
    $preview .= '</iframe>';

	$form->add("Preview", $preview);
	
	

	
	
	$form->render(false);

               

       
         

         


?>
</td></tr></table>
</body>
</HTML>

christian@maurer-it.com
Beiträge: 27
Registriert: Fr 14. Nov 2003, 11:46
Wohnort: Wien
Kontaktdaten:

Beitrag von christian@maurer-it.com » Mi 10. Dez 2003, 15:02

Super Arbeit!
Schaut wesentlich besser aus als meine Version :cry:

mfg
chris

p.s.: wenn ich mehr zeit hätte, würde ich mehr module u.ä. erstellen 8)

timo
Beiträge: 6284
Registriert: Do 15. Mai 2003, 18:32
Wohnort: Da findet ihr mich nie!
Kontaktdaten:

Beitrag von timo » Mi 10. Dez 2003, 15:08

Kein Problem, über jede Idee bzw tat sind wir dankbar (oder auch die Community)

emergence
Beiträge: 10644
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence » Mi 10. Dez 2003, 15:12

schön nur ein kleiner fehler timo...

die zeile um das entsprechende javascript mit link zu erzeugen sollte so aussehen

Code: Alles auswählen

$script .= 'imglnk["'.$img_id[$key].'"] = "'.$cfgClient[$client]["path"]["htmlpath"]."upload/".$img_dir.$img_list[$key].'";';
begründung: der wert der in $img_dir gespeichert ist enthält schon ein /

bei mir hats im unterverzeichniss zb die jpg bilder nicht mehr angezeigt...

Gesperrt