voraussetzung ist, dasss zuvor folgender query auf der db abgesetzt wird:
Code: Alles auswählen
ALTER TABLE `con_art_lang` ADD `serializeddata` TEXT;
Code: Alles auswählen
<?php
cInclude("includes", "functions.upl.php");
if (!class_exists('downloadList')) {
class downloadList {
function downloadList($index) {
global $edit, $client, $cfg, $idart, $lang;
// Member aufnehmen
$this->edit = $edit;
$this->index = 'var_'.$index;
$this->idart = $idart;
$this->lang = $lang;
// Initialisierung des Datenbankzugriffs
$this->db = new DB_Contenido;
// CMS_VALUE als Member aufnehmen
$this->serialization();
// Dateien aus dem Dateisystem lesen
$this->db->query("SELECT * FROM ".$cfg['tab']['upl']." WHERE idclient='$client' ORDER BY dirname ASC, filename ASC");
while ($this->db->next_record()) {
$this->medien[$this->db->f('idupl')] = array ('idupl' => $this->db->f('idupl'), 'filename' => $this->db->f('dirname').$this->db->f('filename'));
}
}
function serialization() {
global $cfg;
if (!empty ($_POST[$this->index]) && $this->edit) {
for ($i = 0; $i <= count($_POST[$this->index]); $i += 3) {
if ($_POST[$this->index][$i] != 0) {
$this->cmsValue[] = $_POST[$this->index][$i];
$this->cmsValue[] = $_POST[$this->index][$i +1];
$this->cmsValue[] = $_POST[$this->index][$i +2];
}
}
$serializedData = mysql_real_escape_string(wddx_serialize_value($this->cmsValue));
$this->db->query("UPDATE ".$cfg['tab']['art_lang']." SET serializeddata = '".$serializedData."' WHERE idart = ".$this->idart." and idlang = ".$this->lang);
} else {
$this->db->query("SELECT serializeddata FROM ".$cfg['tab']['art_lang']." WHERE idart = ".$this->idart." and idlang = ".$this->lang);
while ($this->db->next_record()) {
$this->cmsValue = wddx_deserialize($this->db->f('serializeddata'));
}
}
if (!empty ($_GET['moveUp']) && $this->edit) {
for ($i = 0; $i < count($this->cmsValue); $i += 3) {
if ($i == $_GET['moveUp'] - 3) {
$newCmsValue[] = $this->cmsValue[$i +3];
$newCmsValue[] = $this->cmsValue[$i +4];
$newCmsValue[] = $this->cmsValue[$i +5];
} else
if ($i == $_GET['moveUp']) {
$newCmsValue[] = $this->cmsValue[$i -3];
$newCmsValue[] = $this->cmsValue[$i -2];
$newCmsValue[] = $this->cmsValue[$i -1];
} else {
$newCmsValue[] = $this->cmsValue[$i];
$newCmsValue[] = $this->cmsValue[$i +1];
$newCmsValue[] = $this->cmsValue[$i +2];
}
}
$this->cmsValue = $newCmsValue;
$serializedData = mysql_real_escape_string(wddx_serialize_value($this->cmsValue));
$this->db->query("UPDATE ".$cfg['tab']['art_lang']." SET serializeddata = '".$serializedData."' WHERE idart = ".$this->idart." and idlang = ".$this->lang);
}
}
function getRequestUri() {
$returnValue = $_SERVER['PHP_SELF'];
$start = true;
if (!empty ($_GET)) {
foreach ($_GET as $key => $value) {
if ($key != 'moveUp') {
if ($start) {
$start = false;
$returnValue .= '?'.$key.'='.$value;
} else {
$returnValue .= '&'.$key.'='.$value;
}
}
}
}
return $returnValue;
}
function show() {
if ($this->edit) {
return $this->edit();
} else {
return $this->showOutput();
}
}
function edit() {
global $cfg;
// Dateien aus dem Dateisystem lesen
$this->db->query("SELECT * FROM ".$cfg['tab']['upl']." WHERE idclient='$client' ORDER BY dirname ASC, filename ASC");
while ($this->db->next_record()) {
$this->medien[$this->db->f('idupl')] = array ('idupl' => $this->db->f('idupl'), 'filename' => $this->db->f('dirname').$this->db->f('filename'));
}
$returnValue = '<div><form action="'.$this->getRequestUri().'" method="POST"><table border="0" cellspacing="0" cellpadding="0" width="100%">';
for ($i = 0; $i <= count($this->cmsValue); $i += 3) {
$returnValue .= '<tr><td>Datei:</td><td><select name="'.$this->index.'['.$i.']">';
$returnValue .= "<option value='0'>-- kein --</option>\n";
foreach ($this->medien as $medium) {
($this->cmsValue[$i] == $medium['idupl']) ? $sel = ' selected="selected" ' : $sel = '';
$returnValue .= '<option value="'.$medium['idupl'].'" '.$sel.'>'.$medium['filename'].'</option>'."\n";
}
$returnValue .= '</select></td></tr>';
$returnValue .= '<tr><td>Bezeichnung:</td><td><input type="text" size="35" value="'.$this->cmsValue[($i +1)].'" name="'.$this->index.'['. ($i +1).']" /></td></tr>';
$returnValue .= '<tr><td>Beschreibung:</td><td><textarea rows="3" cols="40" name="'.$this->index.'['. ($i +2).']">'.$this->cmsValue[($i +2)].'</textarea></td></tr>';
if ($i > 0 && $i < count($this->cmsValue)) {
$returnValue .= '<tr><td> </td><td><a href="'.$this->getRequestUri().'&moveUp='.$i.'">^^^ nach oben verschieben ^^^</a></td></tr>';
}
$returnValue .= '<tr><td colspan="2"><hr/></td></tr>';
}
return $returnValue.'</table><input type="submit" value="speichern" /></form></div>';
}
function setMask($mask) {
$this->mask = $mask;
}
function showOutput() {
global $client, $cfgClient;
$returnValue = '';
for ($i = 0; $i < count($this->cmsValue); $i += 3) {
$name = $this->cmsValue[$i + 1];
$description = $this->cmsValue[$i + 2];
$filename = $this->medien[$this->cmsValue[$i]]['filename'];
$localFilename = $cfgClient[$client]["upl"]["path"].$filename;
$link = $cfgClient[$client]["upl"]["htmlpath"].$filename;
$size = human_readable_size(filesize($localFilename));
$icon = "<img src=".uplGetFileIcon($localFilename)." alt=". getFileExtension($localFilename)." />";
$mask = str_replace('{name}', $name, $this->mask);
$mask = str_replace('{description}', $description, $mask);
$mask = str_replace('{size}', $size, $mask);
$mask = str_replace('{icon}', $icon, $mask);
$mask = str_replace('{link}', $link, $mask);
$returnValue .= $mask;
}
return $returnValue;
}
}
}
$downloadList = new downloadList("liste1");
$downloadList->setMask('<div style="margin-bottom:10px;">{icon}<a href="{link}">{name} ({size})</a><div>{description}</div></div>');
echo $downloadList->show();
?>
andreas