예제 #1
0
 /**
  * Get device features
  * 
  * @return Application_Model_Device
  */
 public function getDevice()
 {
     if ($this->device == null) {
         $this->device = false;
         $devices = Application_Model_DevicesMapper::i()->fetchAll();
         /* @var Application_Model_Device $device */
         foreach ($devices as $device) {
             // if exact do an == comparison
             if ($device->isExact() && $device->getPattern() == $_SERVER['HTTP_USER_AGENT'] || !$device->isExact() && preg_match($device->getPattern(), $_SERVER['HTTP_USER_AGENT']) > 0) {
                 // valid $device found;
                 $this->device = $device;
                 break;
             }
         }
         if ($this->device == false) {
             // load things from default
             $this->device = new Application_Model_Device();
             if (X_VlcShares_Plugins::broker()->isRegistered('wiimc')) {
                 $this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WiimcPlxRenderer'));
             } else {
                 $this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WebkitRenderer'));
             }
             $this->device->setIdProfile($this->options->get('profile', 1))->setLabel("Unknown device");
         }
     }
     return $this->device;
 }
 /**
  * Singleton
  * @return Application_Model_DevicesMapper
  */
 public static function i()
 {
     if (self::$_instance == null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #3
0
 /**
  * Load the device features inside the $this->device
  */
 private function loadDevice()
 {
     if ($this->device === null) {
         $this->device = false;
         $devices = Application_Model_DevicesMapper::i()->fetchAll();
         /* @var Application_Model_Device $device */
         foreach ($devices as $device) {
             // if exact do an == comparison
             if ($device->isExact() && $device->getPattern() == $_SERVER['HTTP_USER_AGENT'] || !$device->isExact() && preg_match($device->getPattern(), $_SERVER['HTTP_USER_AGENT']) > 0) {
                 // valid $device found;
                 $this->device = $device;
             }
             // false + 0 matches
         }
     }
 }
 public function testAction()
 {
     $useragent = $this->getRequest()->getParam('user-agent', '');
     $devices = Application_Model_DevicesMapper::i()->fetchAll();
     $deviceFound = false;
     /* @var Application_Model_Device $device */
     foreach ($devices as $device) {
         // if exact do an == comparison
         if ($device->isExact() && $device->getPattern() == $useragent || !$device->isExact() && preg_match($device->getPattern(), $useragent) > 0) {
             // valid $device found;
             $deviceFound = $device;
             break;
         }
         // false + 0 matches
     }
     if ($deviceFound) {
         $return = array('deviceId' => $deviceFound->getId(), 'success' => true);
     } else {
         $return = array('success' => false);
     }
     $this->_helper->json($return);
 }