Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 8 | Revision 46 | 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
 
16
    namespace Weban;
17
    require_once "classes/preise.class.php";
18
    class artikel
19
    {
20
        public $id;
21
        public $name;
22
        public $beschreibung;
23
        public $link;
24
        public $hersteller;
25
        public $bilder;
26
        public $kennung;
27
        public $ean;
28
        public function __construct( $id )
29
        {
30
            $sql = "SELECT
31
                    id,
32
                    kurzbezeichnung AS name,
33
                    beschreibung,
34
                    father,
35
                    hersteller,
36
                    kennung,
37
                    ean
38
                FROM
39
                    artikel
40
                WHERE
41
                    id = $id
42
                AND
43
                    language='" . $GLOBALS["INI"]["language"] . "'
44
            ";
45
            $res = $GLOBALS["db"]->query( $sql );
46
            $row = $res->fetchRow();
47
            $this->id = $row["id"];
48
            $this->name = $row["name"];
49
            $this->beschreibung = $row["beschreibung"];
50
            $this->father = $row["father"];
51
            $this->kennung = $row["kennung"];
52
            $this->ean = $row["ean"];
22 lars 53
            if ( $GLOBALS["INI"]["alias"] == 0 )
54
            {
55
                $this->link = "/index.php?item=" . $this->id;
56
            }
57
            else
58
            {
59
                $path = getPath( $this->father );
60
                foreach ( $path as $dir )
61
                {
62
                    $link[] = $dir->id . "-" . str2url( $dir->name );
63
                }
64
                $link[] = $this->id . "-" . str2url( $this->name ) . ".html";
65
                $link = "/" . implode( "/", $link );
66
                $this->link = $link;
67
            }
2 lars 68
            $fd = new directory( $this->father );
69
            $this->artikelstamm = $fd->artikelstamm;
70
            $this->hersteller = new hersteller( $row["hersteller"] );
71
            $this->bilder = artikel_bild::Liste( $this->id );
72
            $staffeln = preise::Liste( $this->id );
73
            foreach ( $staffeln as $p_index => $staffel )
74
            {
75
                $preis = $staffel["preis"][0];
76
                unset( $staffel["preis"][0] );
77
                unset( $staffel["menge"][0] );
78
                $this->preis[$p_index]["preis"] = $preis;
79
                $this->preis[$p_index]["staffel"] = $staffel;
80
            }
7 lars 81
            if ( count( $this->bilder ) > 1 )
82
            {
83
                $thumbs = "";
84
                foreach ( $this->bilder as $bild )
85
                {
86
                    if ( $bild["typ"] == "Bild" )
87
                    {
88
                        $thumbs .= "
89
                            <li>
8 lars 90
                                <a href=\"javascript:void(0);\" rel=\"{gallery: 'gal1', smallimage: '/images/Bild_" .
7 lars 91
                            $bild["bild_index"] . "/kl/" . $bild["url"] .
8 lars 92
                            "', largeimage: '/images/Bild_" . $bild["bild_index"] .
93
                            "/" . $bild["url"] . "'}\">
7 lars 94
                                <img src=\"/images/Bild_" . $bild["bild_index"] .
95
                            "/mini/" . $bild["url"] . "\" />
96
                                </a>
97
                            </li>
98
                        ";
99
                    }
100
                }
101
                $this->thumbs = $thumbs;
102
            }
2 lars 103
            $this->instantConfirm = "/index.php?basket=true&item=$this->id&menge=1";
104
        }
105
 
106
        public static function Liste( $father )
107
        {
108
            $items = array();
109
            $sql = "SELECT
110
                    id
111
                FROM
112
                    artikel
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 artikel( $row["id"] );
124
            }
125
            return $items;
126
        }
127
 
128
    }
129
?>