Seite 1 von 1

Standardbildmodul CMS_IMG (file: include.CMS_IMG.php)

Verfasst: Sa 14. Mai 2005, 13:35
von Arno Simon
Mahlzeit zusammen,

nachdem ich mein - ursprünglich in diesem Thread - gepostetes Coding nun auch auf dem WebSpace - und nicht nur auf dem Localhost - einsetzen wollte, sind mir dort noch ein paar Fehler, insbesondere was die Wahl der Pfadvariablen angeht, aufgefallen.

Da ich diese natürlich im Zuge dessen korrigiert habe, möchte ich Euch diese auch nicht vorenthalten:

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  :   14.05.2005 Arno Simon
*
* © 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"));
}

if (!isset($cfgClient["set"]))
{
 rereadClients ();
}

?>
<html>
 <head>
  <title>contenido</title>
  <link rel="stylesheet" type="text/css" href="<?php print $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["styles"] ?>contenido.css">
 </HEAD>
 <body>
  <script type="text/javascript">
    <!--
    function rewrite() {
     var picture = new Array();
<?php
$sql = "SELECT * FROM ".$cfg["tab"]["upl"].
       " WHERE idclient='".$client."' AND filetype IN ('jpg', 'gif', 'png') ORDER BY idupl";
$db->query($sql);
while ( $db->next_record() )
{
 echo '     picture['.$db->f("idupl").']="'.$cfgClient[$client]["path"]["htmlpath"].$cfgClient[$client]["upload"].$db->f("dirname").$db->f("filename").'";
';
}
?>     var selectedbutton = document.forms['user'].CMS_IMG
     if (selectedbutton.options[selectedbutton.selectedIndex].value=="0")
     {
     var selectedbuttonvalue = "<?php echo $cfg["path"]["contenido_fullhtml"]; ?>images/spacer.gif";
     } else {
     var selectedbuttonvalue = picture[selectedbutton.options[selectedbutton.selectedIndex].value];
     }
     document.images.vorschau.src = "" + selectedbuttonvalue;
    }
    -->
  </script>
  <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);
       //### next line name=...
?>
     <FORM name="user" method="post" action="<?php echo $cfg["path"]["contenido_fullhtml"].$cfg["path"]["includes"]; ?>include.backendedit.php">
<?php
       $sess->hidden_session();
?>
      <INPUT type="hidden" name="lang"       value="<?php echo $lang; ?>">
<!--      <INPUT type="hidden" name="submit"     value="editcontent"> -->
      <INPUT type="hidden" name="typenr"     value="<?php echo $typenr; ?>">
      <INPUT type="hidden" name="idart"      value="<?php echo $idart; ?>">
      <INPUT type="hidden" name="idcat"      value="<?php echo $idcat; ?>">
      <INPUT type="hidden" name="idartlang"  value="<?php echo $idartlang; ?>">
      <INPUT type="hidden" name="doedit"     value="1">
      <INPUT type="hidden" name="action"     value="10">
      <INPUT type="hidden" name="type"       value="<?php echo $type; ?>">
      <INPUT type="hidden" name="changeview" value="edit">
      <TABLE cellpadding=$cellpadding cellspacing=$cellpadding border=0>
       <TR>
        <TD valign=\"top\" class=text_medium nowrap>
         &nbsp;<?php echo $typenr.".&nbsp;".$a_description["CMS_IMG"][$typenr]; ?>:&nbsp;
        </TD>
        <TD class=content>
         <SELECT name="CMS_IMG" SIZE="1" ONCHANGE="rewrite()">
<?php   if ($a_content["CMS_IMG"][$typenr] != "0")
        { ?>
          <option value=0><?php echo '-- '.i18n("None").' --'; ?></option>
<?php   } else { ?>
          <option value="0" selected><?php echo '-- '.i18n("None").' --'; ?></option>
<?php   }
        $sql = "SELECT * FROM ".$cfg["tab"]["upl"]." WHERE idclient='".$client."' AND filetype IN ('jpg', 'gif', 'png') ORDER BY dirname, filename";
        $db->query($sql);
        $default_image = $cfg["path"]["contenido_fullhtml"]."images/spacer.gif";
        while ( $db->next_record() )
        {
         $descr = $db->f("description");
         if ( strlen($descr) > 24 )
         {
          $descr = substr($descr, 0, 24);
          $descr .= "..";
         }
         if ($db->f("idupl") != $a_content["CMS_IMG"][$typenr])
         {
          echo '          '.
               '<option value="'.
               $db->f("idupl").'">'.
               $db->f("dirname").
               $db->f("filename").
               ' ['.$descr.']'.
               '</option>';
         } else {
          echo '          '.
               '<option value="'.$db->f("idupl").
               '" selected>'.$db->f("dirname").
               $db->f("filename").
               ' ['.$descr.']'.
               '</option>';
          $default_image = $cfgClient[$client]["path"]["htmlpath"].
                           $cfgClient[$client]["upload"].
                           $db->f("dirname").$db->f("filename");
         }
        } ?>
         </SELECT>
        </TD>
        <td rowspan ="2" width="15">
        &nbsp;
        </td>
        <TD rowspan ="2" width="300" valign="center" halign="center">
         <img src="<?php echo $default_image; ?>" name="vorschau" border="0">
        </TD>
       </TR>
       <TR>
        <TD valign=top class=text_medium nowrap>
         &nbsp;<?php echo $a_description["CMS_IMGDESCR"][$typenr]; ?>:&nbsp;
        </TD>
        <TD class="content">
         <TEXTAREA class="text_medium" name="CMS_IMGDESCR" ROWS="3" COLS="30"><?php echo $a_content["CMS_IMGDESCR"][$typenr]; ?></TEXTAREA>
        </TD>
       </TR>
<?php
        $tmp_area = "con_editcontent";
?>
       <TR valign="top">
        <TD colspan="2">
         <br>
         <a href="<?php echo $sess->url($cfgClient[$client]["path"]["htmlpath"].
         'front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&idartlang=$idartlang'); ?>>
         <img src="<?php echo $cfg['path']['contenido_fullhtml'].$cfg['path']['images'].'but_cancel.gif'; ?> border="0"></a>
         <INPUT type="image" name="submit" value="editcontent" src="<?php echo $cfg['path']['contenido_fullhtml'].$cfg['path']['images'].'but_ok.gif'; ?>" border="0">
        </TD>
       </TR>
      </TABLE>
     </FORM>
    </td>
   </tr>
  </table>
 </body>
</HTML>
Das Coding in die Datei /contenido/includes/include.CMS_IMG.php pasten.

vG

Arno

PS ich darf mich, insbesondere beim Initiator des Ursprungsthreads, für das mangelnde Feedback bedanken!

Verfasst: Sa 14. Mai 2005, 17:14
von HerrB
Man könnte noch ergänzen (wie auch im Urspungsthema erwähnt), dass diese Überarbeitung eine Bildvorschau bei CMS_IMG-Modulen/Elementen erlaubt.

Gruß
HerrB

Verfasst: So 15. Mai 2005, 10:37
von Arno Simon
Pardon, habe ich vergessen.....

vG

Arno

Verfasst: Mo 16. Mai 2005, 18:55
von Arno Simon
Ups... Da kann man mal sehen, was die Forumssuche (auf der Suche nach etwas ganz anderem...) so alles hervorbringt:

Ende 2003 gab es bereits einen Thread der sich mit einer Preview-Funktion im CMS_IMG beschäftigt hat und ich muß sagen, das was dabei herausgekommen ist, ist zwar wesentlich Umfangreicher (warum hat es eigentlich keinen Eingang in die Auslieferung gefunden?!), dafür IMHO aber auch besser als das was ich da oben gepostet habe...

vG

Arno

Verfasst: Mi 6. Jul 2005, 19:33
von trixta
habe es jetzt mal um ne upload möglichkeit erweitert:

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  :   14.05.2005 Arno Simon
* Modified  :   06.07.2005 Arno Simon
*
* © four for business AG
******************************************/

if ($doedit == "1") {
	global $cfgClient;
	global $client;
	global $upldir;
	global $uplfile;
	global $HTTP_POST_FILES;

	cInclude("includes","functions.upl.php");


if (is_array($_FILES)) {
		$userfile = Array($_FILES['uplfile']['tmp_name']);
		$userfile_name = Array($_FILES['uplfile']['name']);
		$userfile_size = Array($_FILES['uplfile']['size']);
		
		$errno = uplupload($upldir,$userfile,$userfile_name,$userfile_size);
		
		if (!$errno) {
    		if ($_FILES['uplfile']['name'][0] != "") {
			$sql = "SELECT idupl 
FROM 
	   ".$cfg["tab"]["upl"]." 
	    WHERE 
		filename ='".$_FILES['uplfile']['name']."' AND 
		dirname ='".$upldir."'
		ORDER BY idupl";
$db->query($sql);
while ( $db->next_record() )
{
$CMS_IMG = $db->f("idupl");
}

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

if (!isset($cfgClient["set"]))
{
 rereadClients ();
}

?>
<html>
 <head>
  <title>contenido</title>
  <link rel="stylesheet" type="text/css" href="<?php print $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["styles"] ?>contenido.css">
 </HEAD>
 <body>
  <script type="text/javascript">
    <!--
    function rewrite() {
	var selectedbutton1 = document.forms['user'].vorschau
     if (selectedbutton1.options[selectedbutton1.selectedIndex].value=="1") {
     var picture = new Array();
	 
<?php
$sql = "SELECT * FROM ".$cfg["tab"]["upl"].
       " WHERE idclient='".$client."' AND filetype IN ('jpg', 'gif', 'png') ORDER BY idupl";
$db->query($sql);
while ( $db->next_record() )
{
 echo '     picture['.$db->f("idupl").']="'.$cfgClient[$client]["path"]["htmlpath"].$cfgClient[$client]["upload"].$db->f("dirname").$db->f("filename").'";
';
}

?>     var selectedbutton = document.forms['user'].CMS_IMG
     if (selectedbutton.options[selectedbutton.selectedIndex].value=="0")
     {
     var selectedbuttonvalue = "<?php echo $cfg["path"]["contenido_fullhtml"]; ?>images/spacer.gif";
     } else {
     var selectedbuttonvalue = picture[selectedbutton.options[selectedbutton.selectedIndex].value];
     }
     document.images.vorschau.src = "" + selectedbuttonvalue;
    }
	}
    -->
  </script>
  <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);
       //### next line name=...
?>
     <FORM enctype="multipart/form-data" name="user" method="post" action="<?php echo $cfg["path"]["contenido_fullhtml"].$cfg["path"]["includes"]; ?>include.backendedit.php">
<?php
       $sess->hidden_session();
?>
      <INPUT type="hidden" name="lang"       value="<?php echo $lang; ?>">
<!--      <INPUT type="hidden" name="submit"     value="editcontent"> -->
      <INPUT type="hidden" name="typenr"     value="<?php echo $typenr; ?>">
      <INPUT type="hidden" name="idart"      value="<?php echo $idart; ?>">
      <INPUT type="hidden" name="idcat"      value="<?php echo $idcat; ?>">
      <INPUT type="hidden" name="idartlang"  value="<?php echo $idartlang; ?>">
      <INPUT type="hidden" name="doedit"     value="1">
      <INPUT type="hidden" name="action"     value="10">
      <INPUT type="hidden" name="type"       value="<?php echo $type; ?>">
      <INPUT type="hidden" name="changeview" value="edit">
      <TABLE cellpadding=$cellpadding cellspacing=$cellpadding border=0>
       <TR>
        <TD valign="top" class=text_medium nowrap>
         &nbsp;<?php echo $typenr.".&nbsp;".$a_description["CMS_IMG"][$typenr]; ?>:&nbsp;
        </TD>
        <TD class=content>

<select name="vorschau" size="1">
<option value="1">Vorschau An</option>
<option value="0">Vorschau Aus</option>
</select>
         <SELECT name="CMS_IMG" SIZE="1" ONCHANGE="rewrite()">
<?php   if ($a_content["CMS_IMG"][$typenr] != "0")
        { ?>
          <option value=0><?php echo '-- '.i18n("None").' --'; ?></option>
<?php   } else { ?>
          <option value="0" selected><?php echo '-- '.i18n("None").' --'; ?></option>
<?php   }
        $sql = "SELECT * FROM ".$cfg["tab"]["upl"]." WHERE idclient='".$client."' AND filetype IN ('jpg', 'gif', 'png') ORDER BY dirname, filename";
        $db->query($sql);
        $default_image = $cfg["path"]["contenido_fullhtml"]."images/spacer.gif";
        while ( $db->next_record() )
        {
         $descr = $db->f("description");
         if ( strlen($descr) > 24 )
         {
          $descr = substr($descr, 0, 24);
          $descr .= "..";
         }
          if ($db->f("idupl") != $a_content["CMS_IMG"][$typenr]) {
          echo '          '.
               '<option value="'.
               $db->f("idupl").'">'.
               $db->f("dirname").
               $db->f("filename").
               ' ['.$descr.']'.
               '</option>';
		 }
		 else {
          echo '          '.
               '<option value="'.$db->f("idupl").
               '" selected>'.$db->f("dirname").
               $db->f("filename").
               ' ['.$descr.']'.
               '</option>';
          $default_image = $cfgClient[$client]["path"]["htmlpath"].
                           $cfgClient[$client]["upload"].
                           $db->f("dirname").$db->f("filename");
         }
        } 
		 ?>
         </SELECT>
        </TD>
        <td rowspan ="4" width="15">
        &nbsp;
        </td>
        <TD rowspan ="4" width="300" align="center">
         <img src="<?php echo $default_image; ?>" name="vorschau" border="0">
        </TD>
       </TR>
       <TR valign=top>
        <TD class=text_medium nowrap>
         &nbsp;<?php echo $a_description["CMS_IMGDESCR"][$typenr]; ?>:&nbsp;
        </TD>
        <TD class="content">
         <TEXTAREA class="text_medium" name="CMS_IMGDESCR" ROWS="3" COLS="30"><?php echo $a_content["CMS_IMGDESCR"][$typenr]; ?></TEXTAREA>
        </TD>
       </TR>
	          <TR valign=top>
        <TD class=text_medium nowrap>
         &nbsp;Datei hochladen:&nbsp;
        </TD>
        <TD class="content">
         <?php cInclude("includes","functions.upl.php");

        // Laden der Verzeichnisse und Dateien in separate Arrays
		$olddir = getcwd();
        chdir($cfgClient[$client]['upl']['path'].rawurldecode($path));
        
        $dirlist = uplDirectoryListRecursive($cfgClient[$client]['upl']['path'].rawurldecode($path));


		chdir($olddir);

		$upldirs = '<select name="upldir">';
        $upldirs .= '<option value=""><upload>/</option>';

        foreach ($dirlist as $key => $value)
        {
                $upldirs .= '<option value="'.$value["pathstring"].'">'."<upload>/".$value["pathstring"].'</option>';
        }
        
        $upldirs .= "</select>"; 
		echo $upldirs; ?><input name="uplfile" type="file">
        </TD>
       </TR>
<?php
        $tmp_area = "con_editcontent";
?>
       <TR valign="top">
        <TD colspan="2">
         <br>
         <a href="<?php echo $sess->url($cfgClient[$client]["path"]["htmlpath"].
         'front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&idartlang=$idartlang'); ?>>
         <img src="<?php echo $cfg['path']['contenido_fullhtml'].$cfg['path']['images'].'but_cancel.gif'; ?> border="0"></a>
         <INPUT type="image" name="submit" value="editcontent" src="<?php echo $cfg['path']['contenido_fullhtml'].$cfg['path']['images'].'but_ok.gif'; ?>" border="0">
        </TD>
       </TR>
	          <TR><TD colspan="2" height="100%"><br><br><br><br><br><br><br><br><br><br><br></TD></TR>
      </TABLE>
     </FORM>
    </td>
   </tr>
  </table>
 </body>
</HTML>

Verfasst: Mi 6. Jul 2005, 19:42
von emergence
Arno Simon hat geschrieben:Ende 2003 gab es bereits einen Thread der sich mit einer Preview-Funktion im CMS_IMG beschäftigt hat und ich muß sagen, das was dabei herausgekommen ist, ist zwar wesentlich Umfangreicher (warum hat es eigentlich keinen Eingang in die Auslieferung gefunden?!), dafür IMHO aber auch besser als das was ich da oben gepostet habe...
ähm soweit ich weiss ist der code sehr wohl enthalten -> ab contenido 4.5.x