Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 22 | 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();
46 lars 47
            if ( $row["id"] )
22 lars 48
            {
46 lars 49
                $this->id = $row["id"];
50
                $this->name = $row["name"];
51
                $this->beschreibung = $row["beschreibung"];
52
                $this->father = $row["father"];
53
                $this->kennung = $row["kennung"];
54
                $this->ean = $row["ean"];
55
                if ( $GLOBALS["INI"]["alias"] == 0 )
22 lars 56
                {
46 lars 57
                    $this->link = "/index.php?item=" . $this->id;
22 lars 58
                }
46 lars 59
                else
7 lars 60
                {
46 lars 61
                    $path = getPath( $this->father );
62
                    foreach ( $path as $dir )
7 lars 63
                    {
46 lars 64
                        $link[] = $dir->id . "-" . str2url( $dir->name );
65
                    }
66
                    $link[] = $this->id . "-" . str2url( $this->name ) . ".html";
67
                    $link = "/" . implode( "/", $link );
68
                    $this->link = $link;
69
                }
70
                $fd = new directory( $this->father );
71
                $this->artikelstamm = $fd->artikelstamm;
72
                $this->hersteller = new hersteller( $row["hersteller"] );
73
                $this->bilder = artikel_bild::Liste( $this->id );
74
                $staffeln = preise::Liste( $this->id );
75
                foreach ( $staffeln as $p_index => $staffel )
76
                {
77
                    $preis = $staffel["preis"][0];
78
                    unset( $staffel["preis"][0] );
79
                    unset( $staffel["menge"][0] );
80
                    $this->preis[$p_index]["preis"] = $preis;
81
                    $this->preis[$p_index]["staffel"] = $staffel;
82
                }
83
                if ( count( $this->bilder ) > 1 )
84
                {
85
                    $thumbs = "";
86
                    foreach ( $this->bilder as $bild )
87
                    {
88
                        if ( $bild["typ"] == "Bild" )
89
                        {
90
                            $thumbs .= "
7 lars 91
                            <li>
8 lars 92
                                <a href=\"javascript:void(0);\" rel=\"{gallery: 'gal1', smallimage: '/images/Bild_" .
46 lars 93
                                $bild["bild_index"] . "/kl/" . $bild["url"] .
94
                                "', largeimage: '/images/Bild_" . $bild["bild_index"] .
95
                                "/" . $bild["url"] . "'}\">
7 lars 96
                                <img src=\"/images/Bild_" . $bild["bild_index"] .
46 lars 97
                                "/mini/" . $bild["url"] . "\" />
7 lars 98
                                </a>
99
                            </li>
100
                        ";
46 lars 101
                        }
7 lars 102
                    }
46 lars 103
                    $this->thumbs = $thumbs;
7 lars 104
                }
46 lars 105
                $this->instantConfirm = "/index.php?basket=true&item=$this->id&menge=1";
7 lars 106
            }
2 lars 107
        }
108
 
109
        public static function Liste( $father )
110
        {
111
            $items = array();
112
            $sql = "SELECT
113
                    id
114
                FROM
115
                    artikel
116
                WHERE
117
                    father = $father
118
                AND
119
                    status = 0
120
                AND
121
                    language='" . $GLOBALS["INI"]["language"] . "'
122
            ";
123
            $res = $GLOBALS["db"]->query( $sql );
124
            while ( $row = $res->fetchRow() )
125
            {
126
                $items[] = new artikel( $row["id"] );
127
            }
128
            return $items;
129
        }
130
 
131
    }
132
?>