config = $config; // detect if it is DJMixHosting\Mix, DJMixHosting\Genre, DJMixHosting\Mixshow, or DJMixHosting\DJ in $object if ($object instanceof Mix) { $djs = $object->getDJs(); $djList = ""; foreach ($djs as $dj) { $djList .= $dj->getName() . ", "; } $djList = rtrim($djList, ", "); $genres = $object->getGenres(); $genreNames = ""; $genreList = rtrim($genreNames, ", "); $this->set_ogTitle($object->getName()); $this->set_ogDescription($object->getDescription()); $this->set_ogUrl($object->getPageUrl()); $this->set_ogImage($object->getCover()); $this->set_ogType("music.song"); $this->set_ogDurationSeconds($object->getSeconds()); $this->set_ogMusician($djList); $this->set_ogAudio($object->getDownloadUrl()); $this->set_ogKeywords($genreList); $this->set_ogCanonical($object->getPageUrl()); $this->set_ogRobot("index, follow"); $this->set_ogNoindex(""); } } private function set_ogTitle($title) { $this->title = $title; } private function set_ogDescription($description) { $this->description = $description; } private function set_ogUrl($url) { $this->url = $url; } private function set_ogImage($image) { $this->image = $image; } private function set_ogType($type) { $this->type = $type; } private function set_ogDurationSeconds($duration_seconds) { $this->duration_seconds = $duration_seconds; } private function set_ogMusician($musician) { $this->musician = $musician; } private function set_ogAudio($audio) { $this->audio = $audio; } private function set_ogKeywords($keywords) { $this->keywords = $keywords; } private function set_ogCanonical($canonical) { $this->canonical = $canonical; } private function set_ogRobot($robot) { $this->robot = $robot; } private function set_ogNoindex($noindex) { $this->noindex = $noindex; } public function mixMetaOutput() { global $config; $output = $this->buildMeta("og:title", $this->get_ogTitle()); $output .= $this->buildMeta("og:type", $this->get_ogType()); $output .= $this->buildMeta("og:url", $this->get_ogUrl()); $output .= $this->buildMeta("og:image", $this->get_ogImage()); $output .= $this->buildMeta("og:description", $this->get_ogDescription()); $output .= $this->buildMeta("og:locale", "en_US"); $output .= $this->buildMeta("og:site_name", $config['app']['name']); $output .= $this->buildMeta("music:duration", $this->get_ogDurationSeconds()); $output .= $this->buildMeta("music:musician", $this->get_ogMusician()); $output .= $this->buildMetaName("description", $this->get_ogDescription()); $output .= $this->buildMeta("og:audio", $this->get_ogAudio()); $output .= $this->buildMetaName("keywords", $this->get_ogKeywords()); $output .= $this->buildMeta("canonical", $this->get_ogCanonical()); $output .= $this->buildMetaName("robots", $this->get_ogRobot()); $output .= $this->buildMetaName("robots", $this->get_ogNoindex()); return $output; } private function buildMeta($property, $content) { if ($content == "" || $content == null) { return ""; } else { return "".PHP_EOL; } } public function get_ogTitle() { return $this->title; } public function get_ogType() { return $this->type; } public function get_ogUrl() { return $this->url; } public function get_ogImage() { return $this->image; } public function get_ogDescription() { return $this->description; } public function get_ogDurationSeconds() { return $this->duration_seconds; } public function get_ogMusician() { return $this->musician; } private function buildMetaName($name, $content) { if ($content == "" || $content == null) { return ""; } else { return "" . PHP_EOL; } } public function get_ogAudio() { return $this->audio; } public function get_ogKeywords() { return $this->keywords; } public function get_ogCanonical() { return $this->canonical; } public function get_ogRobot() { return $this->robot; } public function get_ogNoindex() { return $this->noindex; } }