Subversion-Projekte lars-tiefland.shop_ns

Revision

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