function getReweDataByApi($idOrLink, $format) { //$suchbegriff = "milch"; //$suchbegriff = preg_replace ( '/[^a-zA-Z0-9]+/', '', $suchbegriff ); $id = preg_replace('/[^0-9]+/', '', after_last("/PD", $idOrLink)); if ($id == "") { $id = preg_replace('/[^0-9]+/', '', $idOrLink); } $base = "https://shop.rewe.de/PD" . $id; $url = "https://api.import.io/store/connector/d1d51bb1-5caf-4369-aa66-026ef8cfd987/_query?input=webpage/url:" . $base . "&&_apikey=40581aa5770c4331b477ca6b191549da6a6ebe6117061cab22ffe286a3bec687a28dd324679b4b65c0e05e44c47739c45a4e56111fd9762d4e3dc345e60732bfe413ad4f56724681aeb33b4055f1e54a"; $result = json_decode(curlData($url), true); if (empty($result["results"])) { return ""; } //$result = json_decode ( file_get_contents("/Users/raphaelmanke/git/chefkochWrapperToRDF/chefkochWrapperToRDF/library/test.txt"), true ); // print_r($result); foreach ($result["results"] as $resultItem => $resultValue) { $key = str_replace(array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü'), array('ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue'), $resultValue["naehrwerte"]); $key = preg_replace('/[^a-zA-ZäöüÄÖÜ]+/', '_', $key); $value = preg_replace('/[^0-9,.]+/', '', $resultValue["werte"]); $value = str_replace(".", ",", $value); $currencie = preg_replace('/[^a-zA-Zµ]+/', '', $resultValue["werte"]); if (isset($formattetArray[$resultValue["naehrwerte"]])) { $formattetArray[$key . "1"] = array("value" => $value, "currencie" => $currencie); } else { $formattetArray[$key] = array("value" => $value, "currencie" => $currencie); } //$formattetArray [$resultItem] ["identifier"] = "searchResult"; //$formattetArray [$resultItem] ["suchbegriff"] = $suchbegriff; //$formattetArray [$resultItem] ["wrapperLink"] = "http://wrapper:8888/index.php/reweProdukt/".$formattetArray [$resultItem]["headlineitem-link"]; } $link = str_replace('https:/', 'https://', substr($idOrLink, 0, -1)); $link = str_replace('https:///', 'https://', $link); $array = array("link" => $link, "naehrwerte" => $formattetArray); //print_r($result); //print_r($array); switch ($format) { case "array": return $array; break; case "turtle": return toTurtle($array); break; default: return "falsches Format gewaehlt!"; break; } /* $graph = new EasyRdf_Graph (); foreach ( $formattetArray as $key => $value ) { if ($key < 11) { buildTree ( $graph, $idOrLink, $value ); } } echo $graph->serialise ( "turtle" ); */ }
function get_format() { //return jpg, gif or png $ext = after_last('.', $this->info["path"]); switch (strtolower($ext)) { case 'jpg': case 'jpeg': return 'jpeg'; case 'gif': return 'gif'; case 'png': return 'png'; default: return false; } }
function between_last($this, $that, $inthat) { return after_last($this, before_last($that, $inthat)); }
function between_last($needleStart, $needleEnd, $haystack) { return after_last($needleStart, before_last($needleEnd, $haystack)); }
protected function fetchPPTs($dataTag2, $delimiter1, $delimiter2) { $ppts = []; $i = 0; foreach ($this->rawHtml->find($dataTag2) as $element) { $long_name = $this->textCaptions[$i]; $dimensions = between($delimiter1, $delimiter2, $long_name); $this->_name[$i] = trim(between($delimiter1, $delimiter2, $long_name)); $this->type[$i] = strtoupper($this->_name[$i]); $this->length[$i] = $this->replaceString(trim(str_take(5, $dimensions))); $this->width[$i] = $this->replaceString(trim(str_rtake(6, $dimensions))); $this->thickness[$i] = NULL; $this->_description[$i] = $this->_name[$i] . ' (' . $this->length[$i] . 'X' . $this->width[$i] . ')'; dd($this->_name[$i], $this->length[$i], $this->width[$i], $this->thickness[$i]); $this->remoteImgUrl[$i] = $element->{"data-orig-file"}; $ext = after_last(".", $this->remoteImgUrl[$i]); $this->photoName[$i] = sprintf("%s-%s", time(), create_slug(str_replace(":", "-", $this->_name[$i])) . ".{$ext}"); $this->photoPath[$i] = sprintf("%s/%s", self::imgBasePath, $this->photoName[$i]); $this->photoTPath[$i] = sprintf("%s/tn-%s", self::imgBasePath, $this->photoName[$i]); $i++; } }
protected function getProductType($requestUri) { $tempUri = after_last("/", $requestUri); $requestUri = before("?", $tempUri) ?: $tempUri; return $requestUri; }