Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 170 | Revision 178 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 170 Revision 176
Zeile 20... Zeile 20...
20
            ->saveSlugsTo('slug')
20
            ->saveSlugsTo('slug')
21
            ->usingLanguage('de')
21
            ->usingLanguage('de')
22
            ->doNotGenerateSlugsOnUpdate()
22
            ->doNotGenerateSlugsOnUpdate()
23
            ->skipGenerateWhen(fn () => $this->id < 0);
23
            ->skipGenerateWhen(fn () => $this->id < 0);
24
    }
24
    }
-
 
25
    public function navigation( $root, $override = false, $rootInfo = false, $cnt = 0 )
-
 
26
    {
-
 
27
        if ( !isset( $GLOBALS["count"][ __function__ . "_" . $root ] ) )
-
 
28
        {
-
 
29
            $GLOBALS["count"][ __function__ . "_" . $root ] = 0;
-
 
30
            $GLOBALS["zeit"][ __function__ . "_" . $root ] = 0;
-
 
31
        }
-
 
32
        $GLOBALS["count"][ __function__ . "_" . $root ]++;
-
 
33
        $time = microtime( true );
-
 
34
        $showArtikelstamm = false;
-
 
35
 
-
 
36
        if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) )
-
 
37
        {
-
 
38
            $showArtikelstamm = true;
-
 
39
        }
-
 
40
 
-
 
41
        $treebuffer = $this->where("directory_id","=",$root)->get();
-
 
42
 
-
 
43
 
-
 
44
        if ( is_array( $treebuffer ) && is_array( $linkDirs ) )
-
 
45
        {
-
 
46
            $treebuffer = array_merge( $treebuffer, $linkDirs );
-
 
47
        }
-
 
48
 
-
 
49
        $treebufferCount = 0;
-
 
50
        if ( is_countable( $treebuffer ) )
-
 
51
        {
-
 
52
            $treebufferCount = count( $treebuffer ) - 1;
-
 
53
        }
-
 
54
 
-
 
55
        $i = 0;
-
 
56
        if ( is_array( $treebuffer ) )
-
 
57
        {
-
 
58
            foreach ( $treebuffer as $counter => $zeile )
-
 
59
            {
-
 
60
                $k = $i % 2;
-
 
61
                $i++;
-
 
62
 
-
 
63
                /* ######################################################################## */ /* Link entsprechend der Alias-Definition generieren.                        */
-
 
64
                /* ######################################################################## */
-
 
65
                if ( $GLOBALS["INI"]['alias'] == 0 )
-
 
66
                {
-
 
67
                    // dirLink
-
 
68
                    //$zeile['dirLink']=$GLOBALS["INI"]["absoluteURL"]."/?navigation=".$zeile['ID'];
-
 
69
                    $zeile['dirLink'] = "/?navigation=" . $zeile['ID'];
-
 
70
                }
-
 
71
                else
-
 
72
                {
-
 
73
 
-
 
74
                    // Pfad ermitteln
-
 
75
                    $buffer = array();
-
 
76
 
-
 
77
                    $path = getPath_New( $zeile['ID'] );
-
 
78
 
-
 
79
                    foreach ( $path as $elem )
-
 
80
                    {
-
 
81
                        //Muss hier gemacht werden, weil durch die UTF8 Kodierung die Umlaute für die str2url funktion nicht richtig übergeben werden
-
 
82
                        //Wenn man hier die Dateikodierung ändert funktioniert es auch nicht weil der Shop UTF8 ist
-
 
83
 
-
 
84
                        $name = $elem['Name'];
-
 
85
                        $umlaute = array(
-
 
86
                            "Ä",
-
 
87
                            "ä",
-
 
88
                            "Ö",
-
 
89
                            "ö",
-
 
90
                            "Ü",
-
 
91
                            "ü",
-
 
92
                        );
-
 
93
                        $umlauteErsetzen = array(
-
 
94
                            "Ae",
-
 
95
                            "ae",
-
 
96
                            "Oe",
-
 
97
                            "oe",
-
 
98
                            "Üe",
-
 
99
                            "ue",
-
 
100
                        );
-
 
101
                        $name = str_replace( $umlaute, $umlauteErsetzen, $name );
-
 
102
 
-
 
103
                        //$buffer[]=preg_replace("/[\W]+/", "", $elem['ID']."_".$elem['Name']);
-
 
104
                        $buffer[] = $elem['ID'] . "-" . str2url( $name );
-
 
105
 
-
 
106
                    }
-
 
107
 
-
 
108
                    // dirLink
-
 
109
                    //$zeile['dirLink']=$GLOBALS["INI"]["absoluteURL"]."/".implode("/",$buffer)."/";
-
 
110
                    $zeile['dirLink'] = "/" . implode( "/", $buffer ) . "/";
-
 
111
 
-
 
112
                }
-
 
113
 
-
 
114
                /* ######################################################################## */ /* Ausgabe der Unterverzeichnisse                                            */ /* ######################################################################## */
-
 
115
                // Container-Kopf
-
 
116
                $_SESSION['navigation']['nav-zebra'] = $k;
-
 
117
 
-
 
118
                $subdirs = $this->where("direcotry_id","=",$zeile["ID"])->get();
-
 
119
                $nav["sub"][] = array(
-
 
120
                    "id"   => $zeile["ID"],
-
 
121
                    "link" => $zeile['dirLink'],
-
 
122
                    "name" => $zeile["Name"],
-
 
123
                    "sub2" => $subdirs,
-
 
124
 
-
 
125
                );
-
 
126
 
-
 
127
            }
-
 
128
        }
-
 
129
        $anzahl_spalten = 3;
-
 
130
 
-
 
131
        if ( is_numeric( $GLOBALS["INI"]["navigation"]["anzahl_spalten"] ) )
-
 
132
        {
-
 
133
            $anzahl_spalten = $GLOBALS["INI"]["navigation"]["anzahl_spalten"];
-
 
134
        }
-
 
135
 
-
 
136
        if ( is_array( $nav["sub"] ) )
-
 
137
        {
-
 
138
            $nav["sub"]['elemsPerRow'] = floor( count( $nav["sub"] ) / $anzahl_spalten );
-
 
139
            $nav["sub"]['elemsPerRowRest'] = count( $treebuffer ) - ( $nav["sub"]['elemsPerRow'] * $anzahl_spalten );
-
 
140
        }
-
 
141
 
-
 
142
        $time2 = microtime( true );
-
 
143
        $diff = $time2 - $time;
-
 
144
        $GLOBALS["zeit"][ __function__ . "_" . $root ] += $diff;
-
 
145
        return $nav;
-
 
146
    }
-
 
147
 
-
 
148
    /**
-
 
149
     * Wenn in der Config der Wert 'showNavigation' in der Kategorie 'Navigation' gleich "1" ist,
-
 
150
     * dann zeige die Navigation an.
-
 
151
     */
-
 
152
 
-
 
153
    public function nav_menu( $father = -1 )
-
 
154
    {
-
 
155
        $navigation = null;
-
 
156
        if ( !isset( $GLOBALS["count"][ __function__ . "_" . $father ] ) )
-
 
157
        {
-
 
158
            $GLOBALS["count"][ __function__ . "_" . $father ] = 0;
-
 
159
            $GLOBALS["zeit"][ __function__ . "_" . $father ] = 0;
-
 
160
        }
-
 
161
        $GLOBALS["count"][ __function__ . "_" . $father ]++;
-
 
162
        $time = microtime( true );
-
 
163
        if ( $GLOBALS['INI']['navigation']['cache_type'] == "2" )
-
 
164
        {
-
 
165
            $fName = $_SERVER["DOCUMENT_ROOT"] . "/menu_serialized.txt";
-
 
166
            if ( isset( $GLOBALS["INI"]["treeRootMainNav"] ) && $father == $GLOBALS["INI"]["treeRootMainNav"] )
-
 
167
            {
-
 
168
                $fName = $_SERVER["DOCUMENT_ROOT"] . "/mainnav_serialized.txt";
-
 
169
            }
-
 
170
            if ( isset( $GLOBALS["INI"]["treeRooSecondNav"] ) && $father == $GLOBALS["INI"]["treeRootSecondNav"] )
-
 
171
            {
-
 
172
                $fName = $_SERVER["DOCUMENT_ROOT"] . "/secondnav_serialized.txt";
-
 
173
            }
-
 
174
 
-
 
175
            if ( file_exists( $fName ) )
-
 
176
            {
-
 
177
                $content = file_get_contents( $fName );
-
 
178
                $navigation = unserialize( $content );
-
 
179
            }
-
 
180
        }
-
 
181
        elseif ( $GLOBALS["INI"]["navigation"]["cache_type"] == "1" )
-
 
182
        {
-
 
183
            $fName = $_SERVER["DOCUMENT_ROOT"] . "/menu.xml";
-
 
184
 
-
 
185
            if ( file_exists( $fName ) )
-
 
186
            {
-
 
187
                $confArr = array(
-
 
188
                    "root"     => "menu",
-
 
189
                    "encoding" => "UTF-8",
-
 
190
                );
-
 
191
                $nav = new Config();
-
 
192
                $nav = $nav->parseConfig( $fName, "XML", $confArr );
-
 
193
                $nav = $nav->toArray();
-
 
194
                $navigation = $nav["root"];
-
 
195
            }
-
 
196
        }
-
 
197
 
-
 
198
        if ( !$navigation )
-
 
199
        {
-
 
200
            $navigation = $this->getMenuFromDB( $father );
-
 
201
        }
-
 
202
 
-
 
203
        $time2 = microtime( true );
-
 
204
        $diff = $time2 - $time;
-
 
205
        $GLOBALS["zeit"][ __function__ . "_" . $father ] += $diff;
-
 
206
        return $navigation;
-
 
207
    }
-
 
208
 
-
 
209
    private function getMenuFromDB( $father )
-
 
210
    {
-
 
211
        if ( !isset( $GLOBALS["count"][ __function__ . "_" . $father ] ) )
-
 
212
        {
-
 
213
            $GLOBALS["count"][ __function__ . "_" . $father ] = 0;
-
 
214
            $GLOBALS["zeit"][ __function__ . "_" . $father ] = 0;
-
 
215
        }
-
 
216
        $GLOBALS["count"][ __function__ . "_" . $father ]++;
-
 
217
        $navigation = array();
-
 
218
        $time = microtime( true );
-
 
219
        $order_by = "Kennung, Name";
-
 
220
        $sql_erw = "AND Artikelstamm = 0";
-
 
221
        if ( isset( $GLOBALS['INI']['navigation']['order_by'] ) )
-
 
222
        {
-
 
223
            $order_by = $GLOBALS['INI']['navigation']['order_by'];
-
 
224
        }
-
 
225
 
-
 
226
        //Sollen Artikelstämme in der Navigation rauskommen, dann hole auch Artikelstämme
-
 
227
        if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) )
-
 
228
        {
-
 
229
            $sql_erw = "";
-
 
230
        }
-
 
231
        if ( isset( $GLOBALS["INI"]["navigation"]["sqlErweiterung"] ) )
-
 
232
        {
-
 
233
            $sql_erw .= " " . $GLOBALS["INI"]["navigation"]["sqlErweiterung"];
-
 
234
        }
-
 
235
 
-
 
236
        $sel = "";
-
 
237
 
-
 
238
        //if ( !$_SESSION['mainNavigation'] )
-
 
239
        {
-
 
240
            $sql = 'SELECT
-
 
241
                    ID AS id,
-
 
242
                    name,
-
 
243
                    status,
-
 
244
                    url,
-
 
245
                    Beschreibung,
-
 
246
                    short_line_1
-
 
247
                    ' . $sel . '
-
 
248
                FROM
-
 
249
                    directory
-
 
250
                WHERE
-
 
251
                    Father = ' . $father . '
-
 
252
                    ' . $sql_erw . '
-
 
253
 
-
 
254
                ORDER BY
-
 
255
                    ' . $order_by . '
-
 
256
            ';
-
 
257
 
-
 
258
            if ( $result = $GLOBALS["shopDB"]->query( $sql ) )
-
 
259
            {
-
 
260
                while ( $row = $result->fetch_assoc() )
-
 
261
                {
-
 
262
                    $row["medien"] = directory_medien::liste( $row["id"] );
-
 
263
 
-
 
264
                    if ( $row["status"] == 99 )
-
 
265
                    {
-
 
266
                        $row["dirLink"] = $row["url"];
-
 
267
                    }
-
 
268
                    else
-
 
269
                    {
-
 
270
                        $row["dirLink"] = "/" . $row['id'] . "-" . str2url( $row['name'] ) . "/";
-
 
271
                    }
-
 
272
                    $topLvl_arr[] = $row;
-
 
273
                    $topLvl = $row["id"];
-
 
274
                    //$specialItems['specialItems'][$row['id']] = getItems( $row['id'] );
-
 
275
 
-
 
276
                }
-
 
277
                if ( is_array( $specialItems ) )
-
 
278
                {
-
 
279
                    $GLOBALS["ui"]->assign( "specialItems", $specialItems );
-
 
280
                }
-
 
281
            }
-
 
282
            else
-
 
283
            {
-
 
284
                admin_debug( $GLOBALS["shopDB"]->error . "<br>" . $sql );
-
 
285
            }
-
 
286
 
-
 
287
            $_SESSION['Fathers'] = @implode( ",", $topLvl );
-
 
288
 
-
 
289
            $cnt = 0;
-
 
290
 
-
 
291
            if ( is_array( $topLvl_arr ) )
-
 
292
            {
-
 
293
                foreach ( $topLvl_arr as $elem )
-
 
294
                {
-
 
295
                    $navigation[ $cnt ]["top"][] = array(
-
 
296
                        "id"           => $elem["id"],
-
 
297
                        "name"         => $elem["name"],
-
 
298
                        "dirLink"      => $elem["dirLink"],
-
 
299
                        "beschreibung" => $elem["Beschreibung"],
-
 
300
                        "medien"       => $elem["medien"],
-
 
301
                        "specialItem"  => $elem["specialItem"],
-
 
302
                        "short_line_1" => $elem["short_line_1"],
-
 
303
                    );
-
 
304
                    if ( $elem['Alternativer_Titel'] )
-
 
305
                    {
-
 
306
                        $navigation[ $cnt ]["top"][0]["Alternativer_Titel"] = $elem['Alternativer_Titel'];
-
 
307
                    }
-
 
308
                    if ( !( $_REQUEST["buy"] == true || $_REQUEST["basket"] == true ) )
-
 
309
                    {
-
 
310
                        $nav = $this->navigation( $elem["id"], false, true, $cnt );
-
 
311
                        $navigation[ $cnt ]["sub"] = $nav["sub"];
-
 
312
                    }
-
 
313
                    $cnt++;
-
 
314
                }
-
 
315
            }
-
 
316
        }
-
 
317
        $time2 = microtime( true );
-
 
318
        $diff = $time2 - $time;
-
 
319
        $GLOBALS["zeit"][ __function__ . "_" . $father ] += $diff;
-
 
320
        return $navigation;
-
 
321
    }
25
}
322
}