Einzelnen Beitrag anzeigen
Alt 31.08.2009, 08:38  
djxflash
Neuer Benutzer
 
Registriert seit: 31.08.2009
Beiträge: 1
PHP-Kenntnisse:
Fortgeschritten
djxflash befindet sich auf einem aufstrebenden Ast
Standard

PHP-Code:
<?php
$tubel
=new ListView;
if(
$tubel->sortieren("+meine Tunte)==-1) echo("selber ein tubel");
$ok=true;
 
 
class ListView {
    var $table;
    var $idArr=array();
    var $ioformArr=array();
    var $indexInt;
    var $write;
    var $deleteOn;
 
    function __construct($ioformArr, $idArr=NULL, $deleteOn=NULL) {
    Error::logFunction(8,"
construct");
        if(!is_array($ioformArr)) $ioformArr=array($ioformArr);
        if(!is_array($idArr)) $idArr=array($idArr);
        $this->ioformArr=$ioformArr;
        $this->idArr=$idArr;
        $this->indexInt=0;
 
        foreach($ioformArr as $ioform) {
            if($ioform->getStatus()) $write=true;
        }
        $this->write=$write;
 
        if($this->write) {
            echo("
<form method='post' action='' enctype='multipart/form-data'>");
            if(!$_POST['sub'.$this->table]) {
                //foreach($ioformArr as $ioform) $ioform->setNoWrite(true);
            }
            if($_POST['del'.$this->table]) {
                foreach($ioformArr as $ioform) $ioform->setDelete(true);
            }
        }
 
        if($idArr[0]) sortieren($idArr);
    }
 
    function sortieren($idArr) {
    Error::logFunction(8,"
sort");
        $this->idArr=$idArr;
        $ioformArr2=array();
        $idArr2=array();
        for($z=0; $z<count($this->ioformArr); $z++) {
            $idArr2[$z]=$this->ioformArr[$z]->getItem(0);
        }
        for($x=0; $x<count($idArr); $x++) {
            for($z=0; $z<count($idArr2) OR $idArr2[$z]==$idArr[$z]; $z++) $ioformArr2[$x]=$this->ioformArr[$z];
        }
        $this->ioformArr=$ioformArr2;
    }
 
    function showNext() {
    Error::logFunction(8,"
showNext");
        if(is_object($this->ioformArr[$this->indexInt])) $this->ioformArr[$this->indexInt]->show();
        $this->indexInt++;
    }
 
    function __destruct() {
    Error::logFunction(8,"
destruct");
        if($this->write) {
            echo("
<input type='submit' name'sub".$this->table."' value='Speichern' />");
            if($this->deleteOn) {
                echo("
<input type='button' name'del".$this->table."' value='Abbrechen' /></form>");
            }
            echo("
</form>");
        }
    }
 
}
 
 
class ListStandard extends ListView {
    var $style;
    var $spalten;
    var $count;
    /*
    function __construct($table, $idArr, $elementDArr, $spalten, $style=NULL, $dBase=NULL, $write=NULL) {
        parent::__construct($table, $idArr, $elementDArr, $style, $write);
        $this->spalten=$spalten;
        $this->style=$style;
        $this->count=count($elementDArr[0]);
    }*/
 
    function __construct($elementYArr, $idArr=NULL, $deleteOn=NULL) {
    Error::logFunction(8,"
ListStandard::construct");
        $this->style=$style;
        $countXs=count($elementYArr);
        $this->spalten=$countXs;
        for($z=0; $z<$countXs; $z++) if($countYs<count($elementYArr[$z])) $countYs=count($elementYArr[$z]);
        $countD=count($elementYArr[0]);
        $zD=0;
 
        for($y=0; $y<$countYs; $y++) {
            for($x=0; $x<$countXs; $x++) {
                $elementDArr[$zD]=$elementYArr[$x][$y];
                $zD++;
            }
        }
 
        parent::__construct($elementDArr, $idArr, $deleteOn);
        $this->count=count($elementDArr);
    }
 
    function show() {
    Error::logFunction(8,"
ListStandard::show");
        echo("
<table cellspacing='1' cellpadding='1' border='0'>");
        for($x=0; $x<$this->count/$this->spalten; $x++) {
            echo("
<tr>");
            for($z=0; $z<$this->spalten; $z++) {
                echo("
<td style='HEIGHT: 23px'>");
                parent::showNext();
                echo("
</td>");
            }
            echo("
</tr>");
        }
        echo("
</table>");
    }
}
 
?>
Edit Chriz: BBCode, bitte nächstes mal selbst einfügen

Geändert von Chriz (31.08.2009 um 12:19 Uhr).
djxflash ist offline   Mit Zitat antworten