Subversion-Projekte lars-tiefland.webanos.marine-sales.de

Revision

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

Revision 415 Revision 485
Zeile 68... Zeile 68...
68
                ->usingLanguage( 'de' )
68
                ->usingLanguage( 'de' )
69
                ->doNotGenerateSlugsOnUpdate()
69
                ->doNotGenerateSlugsOnUpdate()
70
                ->skipGenerateWhen( fn() => $this->id < 0 );
70
                ->skipGenerateWhen( fn() => $this->id < 0 );
71
        }
71
        }
Zeile 72... Zeile -...
72
 
-
 
73
        public function navigation( $root, $override = false, $rootInfo = false, $cnt = 0 ): array
-
 
74
        {
-
 
75
            if ( !isset( $GLOBALS["count"][__function__ . "_" . $root] ) )
-
 
76
            {
-
 
77
                $GLOBALS["count"][__function__ . "_" . $root] = 0;
-
 
78
                $GLOBALS["zeit"][__function__ . "_" . $root] = 0;
-
 
79
            }
-
 
80
            $nav = array();
-
 
81
            $GLOBALS["count"][__function__ . "_" . $root]++;
-
 
82
            $time = microtime( true );
-
 
83
            $showArtikelstamm = false;
-
 
84
 
-
 
85
            if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) )
-
 
86
            {
-
 
87
                $showArtikelstamm = true;
-
 
88
            }
-
 
89
 
-
 
90
            $treebuffer = $this->with( 'directory' )->orderBy( "kennung" )->orderBy( "name" )->whereIn( "status", [ 0, 99 ] )->where( "directory_id", "=", $root )->where( 'articlemaster', '=', 0 )->get();
-
 
91
 
-
 
92
 
-
 
93
            /*if (is_array($treebuffer) && is_array($linkDirs)) {
-
 
94
                $treebuffer = array_merge($treebuffer, $linkDirs);
-
 
95
            }*/
-
 
96
 
-
 
97
            $treebufferCount = 0;
-
 
98
            if ( is_countable( $treebuffer ) )
-
 
99
            {
-
 
100
                $treebufferCount = count( $treebuffer ) - 1;
-
 
101
            }
-
 
102
 
-
 
103
            $i = 0;
-
 
104
            if ( is_countable( $treebuffer ) )
-
 
105
            {
-
 
106
                foreach ( $treebuffer as $counter => $zeile )
-
 
107
                {
-
 
108
                    $k = $i % 2;
-
 
109
                    $i++;
-
 
110
 
-
 
111
                    /* ######################################################################## */ /* Link entsprechend der Alias-Definition generieren.                        */
-
 
112
                    /* ######################################################################## */
-
 
113
                    // Pfad ermitteln
-
 
114
                    $buffer = array();
-
 
115
 
-
 
116
                    $dirLink = "/directory/" . $zeile['id'] . "-" . $zeile["slug"] . "/";
-
 
117
 
-
 
118
 
-
 
119
                    // dirLink
-
 
120
                    //$zeile['dirLink']=$GLOBALS["INI"]["absoluteURL"]."/".implode("/",$buffer)."/";
-
 
121
                    $zeile['dirLink'] = $dirLink;
-
 
122
 
-
 
123
                    /* ######################################################################## */ /* Ausgabe der Unterverzeichnisse                                            */ /* ######################################################################## */
-
 
124
                    // Container-Kopf
-
 
125
                    $_SESSION['navigation']['nav-zebra'] = $k;
-
 
126
 
-
 
127
                    $subdirC = $this->with( 'directory' )->orderBy( "kennung" )->orderBy( "name" )->whereIn( "status", [ 0, 99 ] )->where( "directory_id", "=", $zeile["id"] )->where( 'articlemaster', '=', 0 )->get();
-
 
128
                    $subdirs = array();
-
 
129
                    foreach ( $subdirC as $subdir )
-
 
130
                    {
-
 
131
                        $subdirs[] = array(
-
 
132
                            "id"   => $subdir["id"],
-
 
133
                            "link" => "/directory/" . $subdir["id"] . "-" . $subdir['slug'] . "/",
-
 
134
                            "name" => $subdir["name"],
-
 
135
                        );
-
 
136
                    }
-
 
137
                    $nav["sub"][] = array(
-
 
138
                        "id"   => $zeile["id"],
-
 
139
                        "link" => $zeile['dirLink'],
-
 
140
                        "name" => $zeile["name"],
-
 
141
                        "sub2" => $subdirs,
-
 
142
 
-
 
143
                    );
-
 
144
 
-
 
145
                }
-
 
146
            }
-
 
147
            $anzahl_spalten = 3;
-
 
148
 
-
 
149
            if ( isset( $GLOBALS["INI"]["navigation"]["anzahl_spalten"] ) && is_numeric( $GLOBALS["INI"]["navigation"]["anzahl_spalten"] ) )
-
 
150
            {
-
 
151
                $anzahl_spalten = $GLOBALS["INI"]["navigation"]["anzahl_spalten"];
-
 
152
            }
-
 
153
 
-
 
154
            if ( isset( $nav["sub"] ) && is_array( $nav["sub"] ) )
-
 
155
            {
-
 
156
                $nav["sub"]['elemsPerRow'] = floor( count( $nav["sub"] ) / $anzahl_spalten );
-
 
157
                $nav["sub"]['elemsPerRowRest'] = count( $treebuffer ) - ( $nav["sub"]['elemsPerRow'] * $anzahl_spalten );
-
 
158
            }
-
 
159
 
-
 
160
            $time2 = microtime( true );
-
 
161
            $diff = $time2 - $time;
-
 
162
            $GLOBALS["zeit"][__function__ . "_" . $root] += $diff;
-
 
163
            return $nav;
-
 
164
        }
-
 
165
 
-
 
166
        /**
-
 
167
         * Wenn in der Config der Wert 'showNavigation' in der Kategorie 'Navigation' gleich "1" ist,
-
 
168
         * dann zeige die Navigation an.
-
 
169
         */
-
 
170
 
-
 
171
        public function nav_menu( $father = -1 )
-
 
172
        {
-
 
173
            $navigation = null;
-
 
174
            if ( !isset( $GLOBALS["count"][__function__ . "_" . $father] ) )
-
 
175
            {
-
 
176
                $GLOBALS["count"][__function__ . "_" . $father] = 0;
-
 
177
                $GLOBALS["zeit"][__function__ . "_" . $father] = 0;
-
 
178
            }
-
 
179
            $GLOBALS["count"][__function__ . "_" . $father]++;
-
 
180
            $time = microtime( true );
-
 
181
            if ( $GLOBALS['INI']['navigation']['cache_type'] == "2" )
-
 
182
            {
-
 
183
                $fName = $_SERVER["DOCUMENT_ROOT"] . "/menu_serialized.txt";
-
 
184
                if ( isset( $GLOBALS["INI"]["treeRootMainNav"] ) && $father == $GLOBALS["INI"]["treeRootMainNav"] )
-
 
185
                {
-
 
186
                    $fName = $_SERVER["DOCUMENT_ROOT"] . "/mainnav_serialized.txt";
-
 
187
                }
-
 
188
                if ( isset( $GLOBALS["INI"]["treeRooSecondNav"] ) && $father == $GLOBALS["INI"]["treeRootSecondNav"] )
-
 
189
                {
-
 
190
                    $fName = $_SERVER["DOCUMENT_ROOT"] . "/secondnav_serialized.txt";
-
 
191
                }
-
 
192
 
-
 
193
                if ( file_exists( $fName ) )
-
 
194
                {
-
 
195
                    $content = file_get_contents( $fName );
-
 
196
                    $navigation = unserialize( $content );
-
 
197
                }
-
 
198
            }
-
 
199
            elseif ( $GLOBALS["INI"]["navigation"]["cache_type"] == "1" )
-
 
200
            {
-
 
201
                $fName = $_SERVER["DOCUMENT_ROOT"] . "/menu.xml";
-
 
202
 
-
 
203
                if ( file_exists( $fName ) )
-
 
204
                {
-
 
205
                    $confArr = array(
-
 
206
                        "root"     => "menu",
-
 
207
                        "encoding" => "UTF-8",
-
 
208
                    );
-
 
209
                    $nav = new Config();
-
 
210
                    $nav = $nav->parseConfig( $fName, "XML", $confArr );
-
 
211
                    $nav = $nav->toArray();
-
 
212
                    $navigation = $nav["root"];
-
 
213
                }
-
 
214
            }
-
 
215
 
-
 
216
            if ( !$navigation )
-
 
217
            {
-
 
218
                $navigation = $this->getMenuFromDB( $father );
-
 
219
            }
-
 
220
 
-
 
221
            $time2 = microtime( true );
-
 
222
            $diff = $time2 - $time;
-
 
223
            $GLOBALS["zeit"][__function__ . "_" . $father] += $diff;
-
 
224
            return $navigation;
-
 
225
        }
-
 
226
 
-
 
227
        private function getMenuFromDB( $father ): array
-
 
228
        {
-
 
229
            if ( !isset( $GLOBALS["count"][__function__ . "_" . $father] ) )
-
 
230
            {
-
 
231
                $GLOBALS["count"][__function__ . "_" . $father] = 0;
-
 
232
                $GLOBALS["zeit"][__function__ . "_" . $father] = 0;
-
 
233
            }
-
 
234
            $GLOBALS["count"][__function__ . "_" . $father]++;
-
 
235
            $navigation = array();
-
 
236
            $time = microtime( true );
-
 
237
            $order_by = array( "kennung", "name" );
-
 
238
            $sql_erw = "AND artikelstamm = 0";
-
 
239
            if ( isset( $GLOBALS['INI']['navigation']['order_by'] ) )
-
 
240
            {
-
 
241
                $order_by = $GLOBALS['INI']['navigation']['order_by'];
-
 
242
            }
-
 
243
 
-
 
244
            //Sollen Artikelstämme in der Navigation rauskommen, dann hole auch Artikelstämme
-
 
245
            if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) )
-
 
246
            {
-
 
247
                $sql_erw = "";
-
 
248
            }
-
 
249
            if ( isset( $GLOBALS["INI"]["navigation"]["sqlErweiterung"] ) )
-
 
250
            {
-
 
251
                $sql_erw .= " " . $GLOBALS["INI"]["navigation"]["sqlErweiterung"];
-
 
252
            }
-
 
253
 
-
 
254
            $dirs = self::with( 'directory' )->orderBy( "kennung" )->orderBy( "name" )->whereIn( "status", [ 0, 99 ] )->where( "directory_id", "=", $father )->where( 'articlemaster', '=', 0 )->get();
-
 
255
            foreach ( $dirs as $cnt => $dir )
-
 
256
            {
-
 
257
                $dirLink = "/directory/" . $dir["id"] . "-" . $dir["slug"] . "/";
-
 
258
                if ( $dir["url"] )
-
 
259
                {
-
 
260
                    $dirLink = $dir["url"];
-
 
261
                }
-
 
262
                $navigation[$cnt]["top"][] = array( "id" => $dir["id"], "name" => $dir["name"], "dirLink" => $dirLink, "beschreibung" => $dir["description"], );
-
 
263
                $nav = $this->navigation( $dir["id"], false, true, $cnt );
-
 
264
                if ( isset( $nav["sub"] ) )
-
 
265
                {
-
 
266
                    $navigation[$cnt]["sub"] = $nav["sub"];
-
 
267
                }
-
 
268
            }
-
 
269
            $time2 = microtime( true );
-
 
270
            $diff = $time2 - $time;
-
 
271
            $GLOBALS["zeit"][__function__ . "_" . $father] += $diff;
-
 
272
            return $navigation;
-
 
273
        }
-
 
274
 
72
 
275
        public function directory(): BelongsTo
73
        public function directory(): BelongsTo
276
        {
74
        {
277
            return $this->belongsTo( Directory::class );
75
            return $this->belongsTo( Directory::class );
Zeile 278... Zeile 76...
278
        }
76
        }
279
 
77
 
280
        function medium(): HasMany
78
        function medium(): HasMany
281
        {
79
        {
Zeile -... Zeile 80...
-
 
80
            return $this->hasMany( DirectoryMedium::class )->orderBy( "rank" );
-
 
81
        }
-
 
82
 
-
 
83
        function items(): HasMany
-
 
84
        {
282
            return $this->hasMany( DirectoryMedium::class )->orderBy( "rank" );
85
            return $this->hasMany( Item::class )->orderBy( "rank" );
283
        }
86
        }
284
 
87
 
285
        function template(): HasMany
88
        function template(): HasMany