Subversion-Projekte lars-tiefland.shop_ns

Revision

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
    {
20 lars 18
        public $id;
2 lars 19
        public $name;
20 lars 20
        public $description;
2 lars 21
        public $link;
18 lars 22
        public $artikelstamm;
20 lars 23
        public $bilder;
22 lars 24
        public $father;
2 lars 25
 
26
        public function __construct( $id = null )
27
        {
28
            $sql = "SELECT
29
                    id,
30
                    name,
22 lars 31
                    father,
2 lars 32
                    beschreibung AS description,
22 lars 33
                    artikelstamm
2 lars 34
                FROM
35
                    directory
36
                WHERE
37
                    id = $id
38
                AND
39
                    language='" . $GLOBALS["INI"]["language"] . "'
40
            ";
41
            $res = $GLOBALS["db"]->query( $sql );
42
            $row = $res->fetchRow();
43
            $this->id = $row["id"];
44
            $this->name = $row["name"];
45
            $this->description = $row["description"];
22 lars 46
            $this->father = $row["father"];
47
            if ( $GLOBALS["INI"]["alias"] == 0 )
48
            {
49
                $this->link = "/index.php?navigation=" . $this->id;
50
            }
51
            else
52
            {
53
                $path = getPath( $this->father );
54
                foreach ( $path as $dir )
55
                {
56
                    $link[] = $dir->id . "-" . str2url( $dir->name );
57
                }
58
                $link[] = $this->id . "-" . Str2url( $this->name );
59
                $link = "/" . implode( "/", $link ) . "/";
60
                $this->link = $link;
61
            }
18 lars 62
            $this->bilder = directory_bild::Liste( $this->id );
63
            $this->artikelstamm = $row["artikelstamm"];
2 lars 64
        }
65
 
22 lars 66
        public static function Liste( $father, $order = "kennung" )
2 lars 67
        {
68
            $items = array();
69
            $sql = "SELECT
70
                    id
71
                FROM
72
                    directory
73
                WHERE
74
                    father = $father
75
                AND
76
                    status = 0
77
                AND
20 lars 78
                    artikelstamm=0
79
                AND
2 lars 80
                    language='" . $GLOBALS["INI"]["language"] . "'
20 lars 81
                ORDER BY
82
                    $order
2 lars 83
            ";
84
            $res = $GLOBALS["db"]->query( $sql );
85
            while ( $row = $res->fetchRow() )
86
            {
87
                $items[] = new directory( $row["id"] );
88
            }
89
            return $items;
90
        }
91
    }
92
?>