Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 22 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php
    /**
     * @package shop
     * @author Lars Tiefland <ltiefland@gmail.com>
     * @copyright 2012
     * @version $Id$
     */

    /**
     * @package shop
     * @author Lars Tiefland <ltiefland@gmail.com>
     * @copyright 2012
     * @version $Id$
     */
    namespace Weban;
    class directory
    {
        public $id;
        public $name;
        public $description;
        public $link;
        public $artikelstamm;
        public $bilder;
        public $father;

        public function __construct( $id = null )
        {
            $sql = "SELECT
                    id,
                    name,
                    father,
                    beschreibung AS description,
                    artikelstamm
                FROM
                    directory
                WHERE
                    id = $id                    
                AND
                    language='" . $GLOBALS["INI"]["language"] . "'
            ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            if ( $row["id"] )
            {
                $this->id = $row["id"];
                $this->name = $row["name"];
                $this->description = $row["description"];
                $this->father = $row["father"];
                if ( $GLOBALS["INI"]["alias"] == 0 )
                {
                    $this->link = "/index.php?navigation=" . $this->id;
                }
                else
                {
                    $path = getPath( $this->father );
                    foreach ( $path as $dir )
                    {
                        $link[] = $dir->id . "-" . str2url( $dir->name );
                    }
                    $link[] = $this->id . "-" . Str2url( $this->name );
                    $link = "/" . implode( "/", $link ) . "/";
                    $this->link = $link;
                }
                $this->bilder = directory_bild::Liste( $this->id );
                $this->artikelstamm = $row["artikelstamm"];
            }
        }

        public static function Liste( $father, $order = "kennung" )
        {
            $items = array();
            $sql = "SELECT
                    id
                FROM
                    directory
                WHERE
                    father = $father
                AND
                    status = 0
                AND
                    artikelstamm=0
                AND
                    language='" . $GLOBALS["INI"]["language"] . "'
                ORDER BY
                    $order
            ";
            $res = $GLOBALS["db"]->query( $sql );
            while ( $row = $res->fetchRow() )
            {
                $items[] = new directory( $row["id"] );
            }
            return $items;
        }
    }
?>