Ejemplo n.º 1
0
 /**
  * Create an instance of the Alarm class.
  *
  * @param XmlElement $xml The xml element with the relevant attributes
  * @param Network $network A Network instance this alarm is from
  */
 public function __construct(XmlElement $xml, Network $network)
 {
     $this->id = $xml->getAttribute("ID");
     $this->attributes = $xml->getAttributes();
     $this->network = $network;
 }
Ejemplo n.º 2
0
 /**
  * Update the track properties using an xml element.
  *
  * @param XmlElement $xml The xml element representing the track meta data
  * @param Controller $controller A controller instance to communicate with
  *
  * @return static
  */
 public static function createFromXml(XmlElement $xml, Controller $controller)
 {
     $track = new static($xml->getTag("res"));
     $track->title = (string) $xml->getTag("title");
     if ($stream = (string) $xml->getTag("streamContent")) {
         $bits = explode(" - ", $stream);
         $track->artist = array_shift($bits);
         $track->title = implode(" - ", $bits);
         $track->album = "";
     } else {
         $track->artist = (string) $xml->getTag("creator");
         $track->album = (string) $xml->getTag("album");
     }
     # Cast the node to a string first (we do this instead of calling nodeValue in case the object is null)
     $number = (string) $xml->getTag("originalTrackNumber");
     # Then convert to a number
     $track->number = (int) $number;
     if ($art = (string) $xml->getTag("albumArtURI")) {
         if (substr($art, 0, 4) !== "http") {
             $art = ltrim($art, "/");
             $art = sprintf("http://%s:1400/%s", $controller->ip, $art);
         }
         $track->albumArt = $art;
     }
     if ($xml->hasAttribute("id")) {
         $track->queueId = $xml->getAttribute("id");
     }
     return $track;
 }