Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1659 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1659 Revision 1693
Zeile 25... Zeile 25...
25
                ->usingLanguage( 'de' )
25
                ->usingLanguage( 'de' )
26
                ->doNotGenerateSlugsOnUpdate()
26
                ->doNotGenerateSlugsOnUpdate()
27
                ->skipGenerateWhen( fn() => $this->id < 0 );
27
                ->skipGenerateWhen( fn() => $this->id < 0 );
28
        }
28
        }
Zeile 29... Zeile -...
29
 
-
 
30
        public function navigation( $root, $override = false, $rootInfo = false, $cnt = 0 ): array
-
 
31
        {
-
 
32
            if ( !isset( $GLOBALS["count"][__function__ . "_" . $root] ) )
-
 
33
            {
-
 
34
                $GLOBALS["count"][__function__ . "_" . $root] = 0;
-
 
35
                $GLOBALS["zeit"][__function__ . "_" . $root] = 0;
-
 
36
            }
-
 
37
            $nav = array();
-
 
38
            $GLOBALS["count"][__function__ . "_" . $root]++;
-
 
39
            $time = microtime( true );
-
 
40
            $showArtikelstamm = false;
-
 
41
 
-
 
42
            if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) )
-
 
43
            {
-
 
44
                $showArtikelstamm = true;
-
 
45
            }
-
 
46
 
-
 
47
            $treebuffer = $this->with( 'directory' )->orderBy( "kennung" )->orderBy( "name" )->whereIn( "status", [ 0, 99 ] )->where( "directory_id", "=", $root )->where( 'articlemaster', '=', 0 )->get();
-
 
48
 
-
 
49
 
-
 
50
            /*if (is_array($treebuffer) && is_array($linkDirs)) {
-
 
51
                $treebuffer = array_merge($treebuffer, $linkDirs);
-
 
52
            }*/
-
 
53
 
-
 
54
            $treebufferCount = 0;
-
 
55
            if ( is_countable( $treebuffer ) )
-
 
56
            {
-
 
57
                $treebufferCount = count( $treebuffer ) - 1;
-
 
58
            }
-
 
59
 
-
 
60
            $i = 0;
-
 
61
            if ( is_countable( $treebuffer ) )
-
 
62
            {
-
 
63
                foreach ( $treebuffer as $counter => $zeile )
-
 
64
                {
-
 
65
                    $k = $i % 2;
-
 
66
                    $i++;
-
 
67
 
-
 
68
                    /* ######################################################################## */ /* Link entsprechend der Alias-Definition generieren.                        */
-
 
69
                    /* ######################################################################## */
-
 
70
                    // Pfad ermitteln
-
 
71
                    $buffer = array();
-
 
72
 
-
 
73
                    $dirLink = "/directory/" . $zeile['id'] . "-" . $zeile["slug"] . "/";
-
 
74
 
-
 
75
 
-
 
76
                    // dirLink
-
 
77
                    //$zeile['dirLink']=$GLOBALS["INI"]["absoluteURL"]."/".implode("/",$buffer)."/";
-
 
78
                    $zeile['dirLink'] = $dirLink;
-
 
79
 
-
 
80
                    /* ######################################################################## */ /* Ausgabe der Unterverzeichnisse                                            */ /* ######################################################################## */
-
 
81
                    // Container-Kopf
-
 
82
                    $_SESSION['navigation']['nav-zebra'] = $k;
-
 
83
 
-
 
84
                    $subdirC = $this->with( 'directory' )->orderBy( "kennung" )->orderBy( "name" )->whereIn( "status", [ 0, 99 ] )->where( "directory_id", "=", $zeile["id"] )->where( 'articlemaster', '=', 0 )->get();
-
 
85
                    $subdirs = array();
-
 
86
                    foreach ( $subdirC as $subdir )
-
 
87
                    {
-
 
88
                        $subdirs[] = array(
-
 
89
                            "id"   => $subdir["id"],
-
 
90
                            "link" => "/directory/" . $subdir["id"] . "-" . $subdir['slug'] . "/",
-
 
91
                            "name" => $subdir["name"],
-
 
92
                        );
-
 
93
                    }
-
 
94
                    $nav["sub"][] = array(
-
 
95
                        "id"   => $zeile["id"],
-
 
96
                        "link" => $zeile['dirLink'],
-
 
97
                        "name" => $zeile["name"],
-
 
98
                        "sub2" => $subdirs,
-
 
99
 
-
 
100
                    );
-
 
101
 
-
 
102
                }
-
 
103
            }
-
 
104
            $anzahl_spalten = 3;
-
 
105
 
-
 
106
            if ( isset( $GLOBALS["INI"]["navigation"]["anzahl_spalten"] ) && is_numeric( $GLOBALS["INI"]["navigation"]["anzahl_spalten"] ) )
-
 
107
            {
-
 
108
                $anzahl_spalten = $GLOBALS["INI"]["navigation"]["anzahl_spalten"];
-
 
109
            }
-
 
110
 
-
 
111
            if ( isset( $nav["sub"] ) && is_array( $nav["sub"] ) )
-
 
112
            {
-
 
113
                $nav["sub"]['elemsPerRow'] = floor( count( $nav["sub"] ) / $anzahl_spalten );
-
 
114
                $nav["sub"]['elemsPerRowRest'] = count( $treebuffer ) - ( $nav["sub"]['elemsPerRow'] * $anzahl_spalten );
-
 
115
            }
-
 
116
 
-
 
117
            $time2 = microtime( true );
-
 
118
            $diff = $time2 - $time;
-
 
119
            $GLOBALS["zeit"][__function__ . "_" . $root] += $diff;
-
 
120
            return $nav;
-
 
121
        }
-
 
122
 
-
 
123
        /**
-
 
124
         * Wenn in der Config der Wert 'showNavigation' in der Kategorie 'Navigation' gleich "1" ist,
-
 
125
         * dann zeige die Navigation an.
-
 
126
         */
-
 
127
 
-
 
128
        public function nav_menu( $father = -1 )
-
 
129
        {
-
 
130
            $navigation = null;
-
 
131
            if ( !isset( $GLOBALS["count"][__function__ . "_" . $father] ) )
-
 
132
            {
-
 
133
                $GLOBALS["count"][__function__ . "_" . $father] = 0;
-
 
134
                $GLOBALS["zeit"][__function__ . "_" . $father] = 0;
-
 
135
            }
-
 
136
            $GLOBALS["count"][__function__ . "_" . $father]++;
-
 
137
            $time = microtime( true );
-
 
138
            if ( $GLOBALS['INI']['navigation']['cache_type'] == "2" )
-
 
139
            {
-
 
140
                $fName = $_SERVER["DOCUMENT_ROOT"] . "/menu_serialized.txt";
-
 
141
                if ( isset( $GLOBALS["INI"]["treeRootMainNav"] ) && $father == $GLOBALS["INI"]["treeRootMainNav"] )
-
 
142
                {
-
 
143
                    $fName = $_SERVER["DOCUMENT_ROOT"] . "/mainnav_serialized.txt";
-
 
144
                }
-
 
145
                if ( isset( $GLOBALS["INI"]["treeRooSecondNav"] ) && $father == $GLOBALS["INI"]["treeRootSecondNav"] )
-
 
146
                {
-
 
147
                    $fName = $_SERVER["DOCUMENT_ROOT"] . "/secondnav_serialized.txt";
-
 
148
                }
-
 
149
 
-
 
150
                if ( file_exists( $fName ) )
-
 
151
                {
-
 
152
                    $content = file_get_contents( $fName );
-
 
153
                    $navigation = unserialize( $content );
-
 
154
                }
-
 
155
            }
-
 
156
            elseif ( $GLOBALS["INI"]["navigation"]["cache_type"] == "1" )
-
 
157
            {
-
 
158
                $fName = $_SERVER["DOCUMENT_ROOT"] . "/menu.xml";
-
 
159
 
-
 
160
                if ( file_exists( $fName ) )
-
 
161
                {
-
 
162
                    $confArr = array(
-
 
163
                        "root"     => "menu",
-
 
164
                        "encoding" => "UTF-8",
-
 
165
                    );
-
 
166
                    $nav = new Config();
-
 
167
                    $nav = $nav->parseConfig( $fName, "XML", $confArr );
-
 
168
                    $nav = $nav->toArray();
-
 
169
                    $navigation = $nav["root"];
-
 
170
                }
-
 
171
            }
-
 
172
 
-
 
173
            if ( !$navigation )
-
 
174
            {
-
 
175
                $navigation = $this->getMenuFromDB( $father );
-
 
176
            }
-
 
177
 
-
 
178
            $time2 = microtime( true );
-
 
179
            $diff = $time2 - $time;
-
 
180
            $GLOBALS["zeit"][__function__ . "_" . $father] += $diff;
-
 
181
            return $navigation;
-
 
182
        }
-
 
183
 
-
 
184
        private function getMenuFromDB( $father ): array
-
 
185
        {
-
 
186
            if ( !isset( $GLOBALS["count"][__function__ . "_" . $father] ) )
-
 
187
            {
-
 
188
                $GLOBALS["count"][__function__ . "_" . $father] = 0;
-
 
189
                $GLOBALS["zeit"][__function__ . "_" . $father] = 0;
-
 
190
            }
-
 
191
            $GLOBALS["count"][__function__ . "_" . $father]++;
-
 
192
            $navigation = array();
-
 
193
            $time = microtime( true );
-
 
194
            $order_by = array( "kennung", "name" );
-
 
195
            $sql_erw = "AND artikelstamm = 0";
-
 
196
            if ( isset( $GLOBALS['INI']['navigation']['order_by'] ) )
-
 
197
            {
-
 
198
                $order_by = $GLOBALS['INI']['navigation']['order_by'];
-
 
199
            }
-
 
200
 
-
 
201
            //Sollen Artikelstämme in der Navigation rauskommen, dann hole auch Artikelstämme
-
 
202
            if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) )
-
 
203
            {
-
 
204
                $sql_erw = "";
-
 
205
            }
-
 
206
            if ( isset( $GLOBALS["INI"]["navigation"]["sqlErweiterung"] ) )
-
 
207
            {
-
 
208
                $sql_erw .= " " . $GLOBALS["INI"]["navigation"]["sqlErweiterung"];
-
 
209
            }
-
 
210
 
-
 
211
            $dirs = self::with( 'directory' )->orderBy( "kennung" )->orderBy( "name" )->whereIn( "status", [ 0, 99 ] )->where( "directory_id", "=", $father )->where( 'articlemaster', '=', 0 )->get();
-
 
212
            foreach ( $dirs as $cnt => $dir )
-
 
213
            {
-
 
214
                $dirLink = "/directory/" . $dir["id"] . "-" . $dir["slug"] . "/";
-
 
215
                if ( $dir["url"] )
-
 
216
                {
-
 
217
                    $dirLink = $dir["url"];
-
 
218
                }
-
 
219
                $navigation[$cnt]["top"][] = array( "id" => $dir["id"], "name" => $dir["name"], "dirLink" => $dirLink, "beschreibung" => $dir["description"], );
-
 
220
                $nav = $this->navigation( $dir["id"], false, true, $cnt );
-
 
221
                if ( isset( $nav["sub"] ) )
-
 
222
                {
-
 
223
                    $navigation[$cnt]["sub"] = $nav["sub"];
-
 
224
                }
-
 
225
            }
-
 
226
            $time2 = microtime( true );
-
 
227
            $diff = $time2 - $time;
-
 
228
            $GLOBALS["zeit"][__function__ . "_" . $father] += $diff;
-
 
229
            return $navigation;
-
 
230
        }
-
 
231
 
29
 
232
        public function directory(): BelongsTo
30
        public function directory(): BelongsTo
233
        {
31
        {
234
            return $this->belongsTo( Directory::class );
32
            return $this->belongsTo( Directory::class );
Zeile 246... Zeile 44...
246
 
44
 
247
        public function manufacturer(): BelongsTo
45
        public function manufacturer(): BelongsTo
248
        {
46
        {
249
            return $this->belongsTo( Manufacturer::class );
47
            return $this->belongsTo( Manufacturer::class );
250
        }
-
 
251
 
-
 
252
        public function shopPosition(): Collection
-
 
253
        {
-
 
254
            $pos = collect(); //$pos = "Sie sind hier: <a href=\"/\">Startseite</a> <span class='breadcrumb-trenner'> &raquo; </span>";
-
 
255
            $path = getPath( $_SESSION['navigation']['position'] )->reverse();
-
 
256
            foreach ( $path as $dir )
-
 
257
            {
-
 
258
                $pos[] = $dir;
-
 
259
            }
-
 
260
 
-
 
261
            return $pos;
-
 
262
        }
-
 
263
 
48
        }