Commit 6df5ce9b authored by Nico Schallehn's avatar Nico Schallehn

Neue Filter implementiert

parent 23afd297
......@@ -4,7 +4,6 @@
*/
class MediaDBViewerAPI{
private $API_KEY;
private $DB_Server;
private $DB_Username;
......@@ -25,7 +24,6 @@ class MediaDBViewerAPI{
$this->DB_Passwort = $entry['Passwort'];
$this->DB_Database = $entry['Database'];
$this->API_KEY = $entry['Schuessel'];
$this->DB_Objekt = new mysqli($this->DB_Server, $this->DB_Username,$this->DB_Passwort, $this->DB_Database);
if($DB_Objekt->error != null){
$ret = false;
......@@ -41,18 +39,14 @@ class MediaDBViewerAPI{
return $this->error(1004,"Erwarteter Parameter: Tabelle");
}
else{
// Array für istgleich vergleiche
$IstgleichArr = array("imdbID" => "imdbID", "acodecger" => "acodecger", "acodeceng" => "acodeceng", "vcodec" => "vcodec",
"resolution" => "resolution", "channelsger" => "channelsger", "channelseng" => "channelseng", "hdd" => "hdd", "checked" => "checked"
);
// Array für größer Kleiner Vergleich
$GrossKleinerArr = array("Jahr" => "year", "Groesse" => "size");
$GrossKleinerArr = array("Jahr" => "year", "Groesse" => "size", "Laufzeit" => "duration", "Hinzugefuegt" => "added", "Gesehen" => "lastView");
$Array = array_merge(array_intersect_key($GET_arr, $GrossKleinerArr),array_intersect_key($GET_arr, $IstgleichArr));
//count($Array)>0;
// Wenn irgenein filter gesetzt ist Filterung nur für Tablle Filme!!
if( (isset($GET_arr['GenreID']) OR isset($GET_arr['Genre']) OR isset($GET_arr['SchauspielerID']) OR isset($GET_arr['Schauspieler']) OR
......@@ -69,7 +63,6 @@ class MediaDBViewerAPI{
$first = false;
}
}
if(isset($GET_arr['3d']) ){
$Where .= ($first?"":" AND ").'3d '.($GET_arr['3d']?"!=":"=").'""';
$first = false;
......@@ -82,35 +75,6 @@ class MediaDBViewerAPI{
$Where .= ($first?"":" AND ").'acodecger'.($GET_arr['Deutsch']?" IS NOT ":" IS ").'null';
$first = false;
}
/* diesen CODE-Block kürzer schreiben!!
if(isset($GET_arr['acodecger']) ){
$Where .= ($first?"":" AND ").'acodecger = "'.$GET_arr['acodecger'].'"';
$first = false;
}
if(isset($GET_arr['acodeceng']) ){
$Where .= ($first?"":" AND ").'acodeceng = "'.$GET_arr['acodeceng'].'"';
$first = false;
}
if(isset($GET_arr['vcodec']) ){
$Where .= ($first?"":" AND ").'vcodec = "'.$GET_arr['vcodec'].'"';
$first = false;
}
if(isset($GET_arr['resolution']) ){
$Where .= ($first?"":" AND ").'resolution = "'.$GET_arr['resolution'].'"';
$first = false;
}
if(isset($GET_arr['channelsger']) ){
$Where .= ($first?"":" AND ").'channelsger = "'.$GET_arr['channelsger'].'"';
$first = false;
}
if(isset($GET_arr['channelseng']) ){
$Where .= ($first?"":" AND ").'channelseng = "'.$GET_arr['channelseng'].'"';
$first = false;
}
if(isset($GET_arr['hdd']) ){
$Where .= ($first?"":" AND ").'hdd = "'.$GET_arr['hdd'].'"';
$first = false;
} */
if(isset($GET_arr['checked']) ){
if($GET_arr['checked'] == "NULL"){
$Where .= ($first?"":" AND ").'checked IS NULL';
......@@ -127,7 +91,6 @@ class MediaDBViewerAPI{
$first = false;
}
// größergleich oder kleinergleich Filter:
foreach ($GrossKleinerArr as $key => $value) {
if(isset($GET_arr[$key])){
if ((substr($GET_arr[$key],0,1) == "<") OR (substr($GET_arr[$key],0,1) == ">") OR !strpos($GET_arr[$key], ",")) {
......@@ -143,29 +106,8 @@ class MediaDBViewerAPI{
$first = false;
$Where .= ($first?"":" AND ").$value.' <="'.$NumberArr[1].'"';
}
}
}
/*
if(isset($GET_arr['Jahr'])){
if ((substr($GET_arr['Jahr'],0,1) == "<") OR (substr($GET_arr['Jahr'],0,1) == ">") OR !strpos($GET_arr['Jahr'], ",")) {
// Kleiner oder Größer und kein Komma!
$Jahr = str_replace(">", "", $GET_arr['Jahr']);
$Jahr = str_replace("<", "", $Jahr);
$Where .= ($first?"":" AND ").'year '.((substr($GET_arr['Jahr'],0,1) == ">")?">":"").((substr($GET_arr['Jahr'],0,1) == "<")?"<":"").'="'.$Jahr.'"';
$first = false;
}else if(strpos($GET_arr['Jahr'], ",")>0){
$jahrArr = explode(",", $GET_arr['Jahr']);
var_dump($jahrArr);
$Where .= ($first?"":" AND ").'year >="'.$jahrArr[0].'"';
$first = false;
$Where .= ($first?"":" AND ").'year <="'.$jahrArr[1].'"';
}
}
*/
// In Filter:
// Attribute von Filmen die nur über eine M:N Verbindung vorhanden sind:
if(isset($GET_arr['GenreID']) OR isset($GET_arr['Genre']) OR isset($GET_arr['SchauspielerID']) OR isset($GET_arr['Schauspieler']) OR isset($GET_arr['SchauspielerSuche'])){
......@@ -220,10 +162,7 @@ class MediaDBViewerAPI{
AND (($GET_arr['Tabelle'] == "Staffeln") OR (($GET_arr['Tabelle'] == "Episoden"))) ){ // Filterung nur für Tablle Episoden!!
$first = true;
//$imdbArrToCompar = 0;
$Where = "WHERE ";
$Where = "WHERE ";
if(isset($GET_arr['series_nr']) ){
$Where .= ($first?"":" AND ").'series_nr = "'.$GET_arr['series_nr'].'"';
$first = false;
......@@ -236,17 +175,7 @@ class MediaDBViewerAPI{
$Where .= ($first?"":" AND ").'episodenumber = "'.$GET_arr['episodenumber'].'"';
$first = false;
}
}/*
// Wenn irgendein filter gesetzt ist Filterung nur für Tablle Episoden!!
if( (isset($GET_arr['season_nr']) OR isset($GET_arr['dummerPlatzhalter']) )
AND ( (($GET_arr['Tabelle'] == "Episoden"))) ){ // Filterung nur für Tablle Episoden!!
$first = true;
//$imdbArrToCompar = 0;
$Where = "WHERE ";
}*/
}
// Überprüfen ob Schauspieler oder Genre gefordert wird
$SpaltenArr = explode(",", $GET_arr['Spalten']);
$ListGenre = (in_array("Genre", $SpaltenArr)?true:false);
......@@ -295,9 +224,7 @@ class MediaDBViewerAPI{
.$this->iset($GET_arr['Sortierung'], " ", " ORDER BY ", " ")
.$this->iset($GET_arr['Anzahl'],"", " Limit "," ")
.";";
//$this->DebugOut($Query." >>Zeile:".__LINE__); //TODO Debugausgabe entfernen
//$entrys = $this->DB_Objekt->query($Query);
$entrys = $this->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$TitelArray = array();
......@@ -317,7 +244,6 @@ class MediaDBViewerAPI{
// Genre oder Schauspielerblock hinzufügen wenn es gewünscht ist
if($ListGenre){
$Query = 'SELECT group_concat(g.gername ORDER BY g.gername) AS Genre FROM FilmGenre AS fg JOIN Genre AS g ON fg.genreID = g.genreID WHERE fg.imdbID="'.$entry["imdbID"].'"';
//$Genre = $this->DB_Objekt->query($Query);
$Genre = $this->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$GenreArr = $Genre->fetch_array();
......@@ -326,8 +252,6 @@ class MediaDBViewerAPI{
if($ListSchauspieler){
$Query = 'SELECT group_concat(s.name ORDER BY s.name) AS Schauspieler '.
'FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE fs.imdbID="'.$entry["imdbID"].'"';
//$this->DebugOut($Query);
//$Schauspieler = $this->DB_Objekt->query($Query);
$Schauspieler = $this->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$SchauspielerArr = $Schauspieler->fetch_array();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment