Time to do an update.
This commit is contained in:
parent
70c8a87e15
commit
0b0697bb42
22 changed files with 4352 additions and 268 deletions
218
classes/HeaderMeta.php
Normal file
218
classes/HeaderMeta.php
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
|
||||
namespace DJMixHosting;
|
||||
|
||||
use DJMixHosting\Genre;
|
||||
|
||||
class HeaderMeta
|
||||
{
|
||||
|
||||
private $config;
|
||||
private $title = "";
|
||||
private $description = "";
|
||||
private $url = "";
|
||||
private $image = "";
|
||||
private $type = "";
|
||||
private $duration_seconds = "";
|
||||
private $musician = "";
|
||||
private $audio = "";
|
||||
private $keywords = "";
|
||||
private $canonical = "";
|
||||
private $robot = "";
|
||||
private $noindex = "";
|
||||
|
||||
public function __construct($object, $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
// detect if it is DJMixHosting\Mix, DJMixHosting\Genre, DJMixHosting\Mixshow, or DJMixHosting\DJ in $object
|
||||
if ($object instanceof Mix) {
|
||||
$djs = $object->get_djs();
|
||||
$djList = "";
|
||||
foreach ($djs as $dj) {
|
||||
$djList .= $dj->getName() . ", ";
|
||||
}
|
||||
$djList = rtrim($djList, ", ");
|
||||
|
||||
$genres = $object->get_genres();
|
||||
$genreNames = "";
|
||||
|
||||
$genreList = rtrim($genreNames, ", ");
|
||||
|
||||
|
||||
$this->set_ogTitle($object->get_name());
|
||||
$this->set_ogDescription($object->get_description());
|
||||
$this->set_ogUrl($object->get_page_url());
|
||||
$this->set_ogImage($object->get_cover());
|
||||
$this->set_ogType("music.song");
|
||||
$this->set_ogDurationSeconds($object->get_seconds());
|
||||
$this->set_ogMusician($djList);
|
||||
$this->set_ogAudio($object->get_download_url());
|
||||
$this->set_ogKeywords($genreList);
|
||||
$this->set_ogCanonical($object->get_page_url());
|
||||
$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 "<meta property=\"$property\" content=\"$content\"/>".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 "<meta name=\"$name\" content=\"$content\"/>" . 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue