Documentation is available at Boutique.class.php
- <?php
- class Boutique {
- /**
- * @access private
- * @var string
- */
- private $lID;
- /**
- * @access private
- * @var string
- */
- private $lName;
- /**
- * @access private
- * @var string
- */
- private $lIPNummer;
- /**
- * @access private
- * @var string
- */
- private $lType;
- /**
- * @access private
- * @var array
- */
- private $lChannels;
- /**
- * @access private
- * @var int
- */
- private $lChannelCount;
- /**
- * @access private
- * @var int
- */
- private $lChannelQueueCounter;
- /**
- * @access private
- * @var array
- */
- private $lAuthentication;
- /**
- * Constructor. This creates a Boutique object.
- * @param int $pID
- * @param string $pIP
- * @param string $pType
- * @param string $pName
- * @return Channel
- */
- function __construct($pID,$pIP,$pType, $pAuthentication = array(), $pName = null) {
- $this->lID = trim($pID);
- $this->lIPNummer = trim($pIP);
- $this->lType = trim($pType);
- $this->lName = trim($pName);
- $this->lChannelCount = 0;
- $this->lAuthentication = array();
- $this->lAuthentication[0] = trim($pAuthentication[0]);
- $this->lAuthentication[1] = trim($pAuthentication[1]);
- $this->resetChannelCounter();
- }
- /**
- * Get the Channel url. This is used for getting channels from a boutique.
- * @return string
- */
- private function getChannelUrl() {
- $lExtraUrl = "";
- if ($this->lAuthentication[0] != "" || $this->lAuthentication[1] != "") {
- $lExtraUrl = $this->lAuthentication[0] . ":" . $this->lAuthentication[1] . "@";
- }
- switch ($this->lType) {
- case "enigma1":
- return "http://" . $lExtraUrl . $this->lIPNummer . "/body?mode=zap&zapmode=0&zapsubmode=4";
- break;
- case "enigma2";
- return "http://" . $lExtraUrl . $this->lIPNummer . "/web/getservices?sRef=1:7:1:0:0:0:0:0:0:0:FROM%20BOUQUET%20%22" . $this->lID . "%22%20ORDER%20BY%20bouquet";
- break;
- default:
- return false;
- break;
- }
- }
- /**
- * Get the boutique ID.
- * @return string
- */
- public function getID() {
- return $this->lID;
- }
- /**
- * Get the boutique name.
- * @return string
- */
- public function getName() {
- return $this->lName;
- }
- /**
- * Load all channels in the boutique.
- * Set $pReNew to 1 to force a reload of the boutique data.
- * @param int $pReNew
- * @return boolean
- */
- function loadChannels($pReNew = 0) {
- if ($this->getChannelCount() == 0 || $pReNew == 1) {
- switch ($this->lType) {
- case "enigma1":
- $lData = file_get_contents($this->getBoutiqueUrl());
- //$lData = file_get_contents("enigma1.txt"); // Test
- $lStartPos = stripos($lData,"var bouquets = new Array(");
- $lStartPos = stripos($lData,"\n",$lStartPos);
- $lStopPos = stripos($lData,"\n",$lStartPos+1);
- $lDataNames = explode(",",str_ireplace("\"","",trim(substr($lData,$lStartPos,$lStopPos-$lStartPos))));
- $lStartPos = stripos($lData,"var bouquetRefs = new Array(");
- $lStartPos = stripos($lData,"\n",$lStartPos);
- $lStopPos = stripos($lData,"\n",$lStartPos+1);
- $lDataIDs = explode(",",str_ireplace("\"","",trim(substr($lData,$lStartPos,$lStopPos-$lStartPos))));
- for ($i = 0; $i < sizeof($lDataIDs); $i++) {
- if (trim($this->lID) == trim($lDataIDs[$i])) { // This is me....
- $lStartPos = stripos($lData,"channels[$i] = new Array(");
- if ($lStartPos !== false) {
- $lStartPos += strlen("channels[$i] = new Array(");
- $lStopPos = stripos($lData,");",$lStartPos);
- $lDataNames2 = explode(",",str_ireplace("\"","",trim(substr($lData,$lStartPos,$lStopPos-$lStartPos))));
- $lStartPos = stripos($lData,"channelRefs[$i] = new Array(");
- if ($lStartPos !== false) {
- $lStartPos += strlen("channelRefs[$i] = new Array(");
- $lStopPos = stripos($lData,");",$lStartPos);
- $lDataIDs2 = explode(",",str_ireplace("\"","",trim(substr($lData,$lStartPos,$lStopPos-$lStartPos))));
- for ($j = 0; $j < sizeof($lDataIDs2); $j++) {
- $this->addChannel(new Channel($lDataIDs2[$j],$this->lIPNummer,$this->lType,$lDataNames2[$j]));
- }
- }
- }
- break; // Stop looping, because current Boutique is found and the channels are loaded
- }
- }
- break;
- case "enigma2";
- $lData = Utils::xml2array(file_get_contents($this->getChannelUrl()));
- if (is_array($lData) && is_array($lData["e2servicelist"])) {
- foreach ($lData["e2servicelist"][0]["e2service"] as $lChannel) {
- $this->addChannel(new Channel($lChannel["e2servicereference"],$this->lIPNummer,$this->lType,$lChannel["e2servicename"]));
- }
- }
- break;
- default:
- return false;
- break;
- }
- $this->lChannelCount = sizeof($this->lChannels);
- }
- }
- /**
- * Add a channel to the boutique.
- * @param Channel $pChannel
- */
- public function addChannel(Channel $pChannel) {
- $this->lChannels[] = $pChannel;
- }
- /**
- * Get the channel object based in channel id.
- * @param string $pChannelID
- * @return Channel
- */
- public function getChannel($pChannelID) {
- if ( ($pChannelID = trim($pChannelID)) == "") return false;
- foreach ($this->lChannels as $lChannel) {
- if ($lChannel->getID() == $pChannelID) {
- return $lChannel;
- }
- }
- }
- /**
- * Get the total channels inside a boutique.
- * @return int
- */
- public function getChannelCount() {
- return $this->lChannelCount;
- }
- /**
- * Reset the internal channel counter.
- */
- public function resetChannelCounter() {
- $this->lChannelQueueCounter = -1;
- }
- /**
- * Get the next channel from the boutique.
- * @return Channel
- */
- public function getNextChannel() {
- $this->lChannelQueueCounter++;
- if (isset($this->lChannels[$this->lChannelQueueCounter])) {
- return $this->lChannels[$this->lChannelQueueCounter];
- }
- return null;
- }
- }
- ?>
Documentation generated on Sat, 19 Jan 2008 12:56:13 +0100 by phpDocumentor 1.3.0RC3