Revision 178 | Revision 181 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?phpnamespace App\Models;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;use Spatie\Sluggable\HasSlug;use Spatie\Sluggable\SlugOptions;class Directory extends Model{use HasFactory, HasSlug;/*** Get the options for generating the slug.*/public function getSlugOptions(): SlugOptions{return SlugOptions::create()->generateSlugsFrom('name')->saveSlugsTo('slug')->usingLanguage('de')->doNotGenerateSlugsOnUpdate()->skipGenerateWhen(fn () => $this->id < 0);}public function navigation( $root, $override = false, $rootInfo = false, $cnt = 0 ){if ( !isset( $GLOBALS["count"][ __function__ . "_" . $root ] ) ){$GLOBALS["count"][ __function__ . "_" . $root ] = 0;$GLOBALS["zeit"][ __function__ . "_" . $root ] = 0;}$GLOBALS["count"][ __function__ . "_" . $root ]++;$time = microtime( true );$showArtikelstamm = false;if ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) ){$showArtikelstamm = true;}$treebuffer = $this->where("directory_id","=",$root)->get();if ( is_array( $treebuffer ) && is_array( $linkDirs ) ){$treebuffer = array_merge( $treebuffer, $linkDirs );}$treebufferCount = 0;if ( is_countable( $treebuffer ) ){$treebufferCount = count( $treebuffer ) - 1;}$i = 0;if ( is_array( $treebuffer ) ){foreach ( $treebuffer as $counter => $zeile ){$k = $i % 2;$i++;/* ######################################################################## */ /* Link entsprechend der Alias-Definition generieren. *//* ######################################################################## */if ( $GLOBALS["INI"]['alias'] == 0 ){// dirLink//$zeile['dirLink']=$GLOBALS["INI"]["absoluteURL"]."/?navigation=".$zeile['ID'];$zeile['dirLink'] = "/?navigation=" . $zeile['ID'];}else{// Pfad ermitteln$buffer = array();$path = getPath_New( $zeile['ID'] );foreach ( $path as $elem ){//Muss hier gemacht werden, weil durch die UTF8 Kodierung die Umlaute für die str2url funktion nicht richtig übergeben werden//Wenn man hier die Dateikodierung ändert funktioniert es auch nicht weil der Shop UTF8 ist$name = $elem['Name'];$umlaute = array("Ä","ä","Ö","ö","Ü","ü",);$umlauteErsetzen = array("Ae","ae","Oe","oe","Üe","ue",);$name = str_replace( $umlaute, $umlauteErsetzen, $name );//$buffer[]=preg_replace("/[\W]+/", "", $elem['ID']."_".$elem['Name']);$buffer[] = $elem['ID'] . "-" . str2url( $name );}// dirLink//$zeile['dirLink']=$GLOBALS["INI"]["absoluteURL"]."/".implode("/",$buffer)."/";$zeile['dirLink'] = "/" . implode( "/", $buffer ) . "/";}/* ######################################################################## */ /* Ausgabe der Unterverzeichnisse */ /* ######################################################################## */// Container-Kopf$_SESSION['navigation']['nav-zebra'] = $k;$subdirs = $this->where("direcotry_id","=",$zeile["ID"])->get();$nav["sub"][] = array("id" => $zeile["ID"],"link" => $zeile['dirLink'],"name" => $zeile["Name"],"sub2" => $subdirs,);}}$anzahl_spalten = 3;if ( is_numeric( $GLOBALS["INI"]["navigation"]["anzahl_spalten"] ) ){$anzahl_spalten = $GLOBALS["INI"]["navigation"]["anzahl_spalten"];}if ( is_array( $nav["sub"] ) ){$nav["sub"]['elemsPerRow'] = floor( count( $nav["sub"] ) / $anzahl_spalten );$nav["sub"]['elemsPerRowRest'] = count( $treebuffer ) - ( $nav["sub"]['elemsPerRow'] * $anzahl_spalten );}$time2 = microtime( true );$diff = $time2 - $time;$GLOBALS["zeit"][ __function__ . "_" . $root ] += $diff;return $nav;}/*** Wenn in der Config der Wert 'showNavigation' in der Kategorie 'Navigation' gleich "1" ist,* dann zeige die Navigation an.*/public function nav_menu( $father = -1 ){$navigation = null;if ( !isset( $GLOBALS["count"][ __function__ . "_" . $father ] ) ){$GLOBALS["count"][ __function__ . "_" . $father ] = 0;$GLOBALS["zeit"][ __function__ . "_" . $father ] = 0;}$GLOBALS["count"][ __function__ . "_" . $father ]++;$time = microtime( true );if ( $GLOBALS['INI']['navigation']['cache_type'] == "2" ){$fName = $_SERVER["DOCUMENT_ROOT"] . "/menu_serialized.txt";if ( isset( $GLOBALS["INI"]["treeRootMainNav"] ) && $father == $GLOBALS["INI"]["treeRootMainNav"] ){$fName = $_SERVER["DOCUMENT_ROOT"] . "/mainnav_serialized.txt";}if ( isset( $GLOBALS["INI"]["treeRooSecondNav"] ) && $father == $GLOBALS["INI"]["treeRootSecondNav"] ){$fName = $_SERVER["DOCUMENT_ROOT"] . "/secondnav_serialized.txt";}if ( file_exists( $fName ) ){$content = file_get_contents( $fName );$navigation = unserialize( $content );}}elseif ( $GLOBALS["INI"]["navigation"]["cache_type"] == "1" ){$fName = $_SERVER["DOCUMENT_ROOT"] . "/menu.xml";if ( file_exists( $fName ) ){$confArr = array("root" => "menu","encoding" => "UTF-8",);$nav = new Config();$nav = $nav->parseConfig( $fName, "XML", $confArr );$nav = $nav->toArray();$navigation = $nav["root"];}}if ( !$navigation ){$navigation = $this->getMenuFromDB( $father );}$time2 = microtime( true );$diff = $time2 - $time;$GLOBALS["zeit"][ __function__ . "_" . $father ] += $diff;return $navigation;}private function getMenuFromDB( $father ){if ( !isset( $GLOBALS["count"][ __function__ . "_" . $father ] ) ){$GLOBALS["count"][ __function__ . "_" . $father ] = 0;$GLOBALS["zeit"][ __function__ . "_" . $father ] = 0;}$GLOBALS["count"][ __function__ . "_" . $father ]++;$navigation = array();$time = microtime( true );$order_by = "kennung, name";$sql_erw = "AND artikelstamm = 0";if ( isset( $GLOBALS['INI']['navigation']['order_by'] ) ){$order_by = $GLOBALS['INI']['navigation']['order_by'];}//Sollen Artikelstämme in der Navigation rauskommen, dann hole auch Artikelstämmeif ( isset( $GLOBALS["INI"]["Navigation"]["showArtikelstamm"] ) ){$sql_erw = "";}if ( isset( $GLOBALS["INI"]["navigation"]["sqlErweiterung"] ) ){$sql_erw .= " " . $GLOBALS["INI"]["navigation"]["sqlErweiterung"];}$sel = "";//if ( !$_SESSION['mainNavigation'] ){/*$sql = 'SELECTid,name,status,slug,url,description,short_line_1' . $sel . 'FROMdirectoryWHEREdirectory_id = ' . $father . '' . $sql_erw . 'ORDER BY' . $order_by . '';if ( $result = $GLOBALS["shopDB"]->query( $sql ) ){while ( $row = $result->fetch_assoc() ){$row["medien"] = directory_medien::liste( $row["id"] );if ( $row["status"] == 99 ){$row["dirLink"] = $row["url"];}else{$row["dirLink"] = "/" . $row['id'] . "-" . $row['slug'] . "/";}$topLvl_arr[] = $row;$topLvl = $row["id"];//$specialItems['specialItems'][$row['id']] = getItems( $row['id'] );}if ( is_array( $specialItems ) ){$GLOBALS["ui"]->assign( "specialItems", $specialItems );}}else{admin_debug( $GLOBALS["shopDB"]->error . "<br>" . $sql );}$_SESSION['Fathers'] = @implode( ",", $topLvl );$cnt = 0;if ( is_array( $topLvl_arr ) ){foreach ( $topLvl_arr as $elem ){$navigation[ $cnt ]["top"][] = array("id" => $elem["id"],"name" => $elem["name"],"dirLink" => $elem["dirLink"],"beschreibung" => $elem["Beschreibung"],"medien" => $elem["medien"],"specialItem" => $elem["specialItem"],"short_line_1" => $elem["short_line_1"],);if ( $elem['Alternativer_Titel'] ){$navigation[ $cnt ]["top"][0]["Alternativer_Titel"] = $elem['Alternativer_Titel'];}if ( !( $_REQUEST["buy"] == true || $_REQUEST["basket"] == true ) ){$nav = $this->navigation( $elem["id"], false, true, $cnt );$navigation[ $cnt ]["sub"] = $nav["sub"];}$cnt++;}}*/}$dirs = self::with('directory')->whereIn("status",[0,2,99])->where("directory_id","=",$father)->get();$time2 = microtime( true );$diff = $time2 - $time;$GLOBALS["zeit"][ __function__ . "_" . $father ] += $diff;return $navigation;}public function directory(){return $this->belongsTo(Directory::class);}}