Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 18 | Zur aktuellen Revision | Details | 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;
22
	public $artikelstamm;
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;
44
	    $this->artikelstamm=$row["artikelstamm"];
45
        }
46
 
47
        public function __set( $name, $value )
48
        {
49
            $allowed = array(
50
                "name" => "setName",
51
                "status" => "setStatus",
52
                "description" => "setDesc",
53
                );
54
            if ( isset( $allowed[$name] ) )
55
            {
56
                trigger_error( "Please use " . $allowed[$name] . "() instead!",
57
                    E_USER_DEPRECATED );
58
                $this->{$allowed[$name]}( $value );
59
            }
60
            else
61
            {
62
                trigger_error( 'Undefined property: ' . get_class( $this ) .
63
                    '::$' . $name, E_USER_NOTICE );
64
            }
65
        }
66
 
67
        public function __get( $name )
68
        {
69
            $allowed = array(
70
                "id" => "getId",
71
                "name" => "getName",
72
                "status" => "getStatus",
73
                "description" => "getDesc",
74
                );
75
            if ( isset( $allowed[$name] ) )
76
            {
77
                $this->{$allowed[$name]}();
78
            }
79
            else
80
            {
81
                trigger_error( 'Undefined property: ' . get_class( $this ) .
82
                    '::$' . $name, E_USER_NOTICE );
83
            }
84
        }
85
 
86
        public function getId()
87
        {
88
            return $this->id;
89
        }
90
        public function getName()
91
        {
92
            return $this->name;
93
        }
94
        public function getDest()
95
        {
96
            return $this->description;
97
        }
98
        public function setDesc( $value )
99
        {
100
            $this->description = $value;
101
        }
102
        public function setName( $value )
103
        {
104
            $this->name = $value;
105
        }
106
        public static function Liste( $father )
107
        {
108
            $items = array();
109
            $sql = "SELECT
110
                    id
111
                FROM
112
                    directory
113
                WHERE
114
                    father = $father
115
                AND
116
                    status = 0
117
                AND
118
                    language='" . $GLOBALS["INI"]["language"] . "'
119
            ";
120
            $res = $GLOBALS["db"]->query( $sql );
121
            while ( $row = $res->fetchRow() )
122
            {
123
                $items[] = new directory( $row["id"] );
124
            }
125
            return $items;
126
        }
127
    }
128
?>