Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 2 | Revision 20 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
    /**
3
     * @package shop
4
     * @author Lars Tiefland <ltiefland@gmail.com>
5
     * @copyright 2012
6
     * @version $Id$
7
     */
8
 
9
    /**
10
     * @package shop
11
     * @author Lars Tiefland <ltiefland@gmail.com>
12
     * @copyright 2012
13
     * @version $Id$
14
     */
15
    namespace Weban;
16
    class directory
17
    {
18
        private $id;
19
        public $name;
20
        private $description;
21
        public $link;
18 lars 22
        public $artikelstamm;
2 lars 23
 
24
        public function __construct( $id = null )
25
        {
26
            $sql = "SELECT
27
                    id,
28
                    name,
29
                    beschreibung AS description,
30
		    artikelstamm
31
                FROM
32
                    directory
33
                WHERE
34
                    id = $id
35
                AND
36
                    language='" . $GLOBALS["INI"]["language"] . "'
37
            ";
38
            $res = $GLOBALS["db"]->query( $sql );
39
            $row = $res->fetchRow();
40
            $this->id = $row["id"];
41
            $this->name = $row["name"];
42
            $this->description = $row["description"];
43
            $this->link = "/index.php?navigation=" . $this->id;
18 lars 44
            $this->bilder = directory_bild::Liste( $this->id );
45
            $this->artikelstamm = $row["artikelstamm"];
2 lars 46
        }
47
 
48
        public function __set( $name, $value )
49
        {
50
            $allowed = array(
51
                "name" => "setName",
52
                "status" => "setStatus",
53
                "description" => "setDesc",
54
                );
55
            if ( isset( $allowed[$name] ) )
56
            {
57
                trigger_error( "Please use " . $allowed[$name] . "() instead!",
58
                    E_USER_DEPRECATED );
59
                $this->{$allowed[$name]}( $value );
60
            }
61
            else
62
            {
63
                trigger_error( 'Undefined property: ' . get_class( $this ) .
64
                    '::$' . $name, E_USER_NOTICE );
65
            }
66
        }
67
 
68
        public function __get( $name )
69
        {
70
            $allowed = array(
71
                "id" => "getId",
72
                "name" => "getName",
73
                "status" => "getStatus",
74
                "description" => "getDesc",
75
                );
76
            if ( isset( $allowed[$name] ) )
77
            {
78
                $this->{$allowed[$name]}();
79
            }
80
            else
81
            {
82
                trigger_error( 'Undefined property: ' . get_class( $this ) .
83
                    '::$' . $name, E_USER_NOTICE );
84
            }
85
        }
86
 
87
        public function getId()
88
        {
89
            return $this->id;
90
        }
91
        public function getName()
92
        {
93
            return $this->name;
94
        }
95
        public function getDest()
96
        {
97
            return $this->description;
98
        }
99
        public function setDesc( $value )
100
        {
101
            $this->description = $value;
102
        }
103
        public function setName( $value )
104
        {
105
            $this->name = $value;
106
        }
107
        public static function Liste( $father )
108
        {
109
            $items = array();
110
            $sql = "SELECT
111
                    id
112
                FROM
113
                    directory
114
                WHERE
115
                    father = $father
116
                AND
117
                    status = 0
118
                AND
119
                    language='" . $GLOBALS["INI"]["language"] . "'
120
            ";
121
            $res = $GLOBALS["db"]->query( $sql );
122
            while ( $row = $res->fetchRow() )
123
            {
124
                $items[] = new directory( $row["id"] );
125
            }
126
            return $items;
127
        }
128
    }
129
?>