$name; } public function __set($name, $value) { $this->$name = $value; } /** * Constructs a Track object from an iTunes Playlists to Xml XML output file. * * @param object $xml */ function __construct($xml) { $this->Name = (string)$xml->name; $this->Album = (string)$xml->album; $this->Artist = (string)$xml->artist; $this->Time = (string)$xml['time']; $this->Rating = (int)$xml->rating; $this->PlayCount = (int)$xml->playCount; $this->LastPlayed = (string)$xml->lastPlayed; $this->Compilation = (bool)$xml->compilation; $this->TrackNumber = (int)$xml->trackNumber; $this->TrackCount = (int)$xml->trackCount; $this->DiscNumber = (int)$xml->discNumber; $this->DiscCount = (int)$xml->discCount; $this->Year = (int)$xml->year; $this->Genre = (string)$xml->genre; $this->DateAdded = (string)$xml->dateAdded; } /** * Function for sorting Track objects by PlayCount, ascending. Uses LastPlayed for ties. * * @access public * @param Track $x First object to compare. * @param Track $y Second object to compare. * @return integer Standard sorting returns. */ public function SortPlayCountAsc($x, $y) { if ($x->PlayCount == $y->PlayCount) { if ($x->LastPlayed == $y->LastPlayed) { return 0; } else if ($x->LastPlayed < $y->LastPlayed) { return -1; } else { return 1; } } else if ($x->PlayCount < $y->PlayCount) { return -1; } else { return 1; } } /** * Function for sorting Track objects by PlayCount, descending. Uses LastPlayed for ties. * * @access public * @param Track $x First object to compare. * @param Track $y Second object to compare. * @return integer Standard sorting returns. */ public function SortPlayCountDesc($x, $y) { if ($x->PlayCount == $y->PlayCount) { if ($x->LastPlayed == $y->LastPlayed) { return 0; } else if ($x->LastPlayed > $y->LastPlayed) { return -1; } else { return 1; } } else if ($x->PlayCount < $y->PlayCount) { return 1; } else { return -1; } } } ?>