Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 20 | Zur aktuellen Revision | 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
    {
        private $id;
        public $name;
        private $description;
        public $link;
        public $artikelstamm;

        public function __construct( $id = null )
        {
            $sql = "SELECT
                    id,
                    name,
                    beschreibung AS description,
                    artikelstamm
                FROM
                    directory
                WHERE
                    id = $id                    
                AND
                    language='" . $GLOBALS["INI"]["language"] . "'
            ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            $this->id = $row["id"];
            $this->name = $row["name"];
            $this->description = $row["description"];
            $this->link = "/index.php?navigation=" . $this->id;
            $this->artikelstamm=$row["artikelstamm"];
        }

        public function __set( $name, $value )
        {
            $allowed = array(
                "name" => "setName",
                "status" => "setStatus",
                "description" => "setDesc",
                );
            if ( isset( $allowed[$name] ) )
            {
                trigger_error( "Please use " . $allowed[$name] . "() instead!",
                    E_USER_DEPRECATED );
                $this->{$allowed[$name]}( $value );
            }
            else
            {
                trigger_error( 'Undefined property: ' . get_class( $this ) .
                    '::$' . $name, E_USER_NOTICE );
            }
        }

        public function __get( $name )
        {
            $allowed = array(
                "id" => "getId",
                "name" => "getName",
                "status" => "getStatus",
                "description" => "getDesc",
                );
            if ( isset( $allowed[$name] ) )
            {
                $this->{$allowed[$name]}();
            }
            else
            {
                trigger_error( 'Undefined property: ' . get_class( $this ) .
                    '::$' . $name, E_USER_NOTICE );
            }
        }

        public function getId()
        {
            return $this->id;
        }
        public function getName()
        {
            return $this->name;
        }
        public function getDest()
        {
            return $this->description;
        }
        public function setDesc( $value )
        {
            $this->description = $value;
        }
        public function setName( $value )
        {
            $this->name = $value;
        }
        public static function Liste( $father )
        {
            $items = array();
            $sql = "SELECT
                    id
                FROM
                    directory
                WHERE
                    father = $father
                AND
                    status = 0
                AND
                    language='" . $GLOBALS["INI"]["language"] . "'
            ";
            $res = $GLOBALS["db"]->query( $sql );
            while ( $row = $res->fetchRow() )
            {
                $items[] = new directory( $row["id"] );
            }
            return $items;
        }
    }
?>