示例#1
0
 public static function hook_view_name($view_name)
 {
     //TODO Check for a Theme here
     //Check for a Mobile version of the View
     $mobile = false;
     if (Component::isActive('Wurfl')) {
         $device = Wurfl::getDevice();
         if ($device && $device->getCapability('mobile_browser') != '' || array_key_exists('mobile', $_REQUEST)) {
             $mobile = true;
         }
     }
     if ($mobile && Component::isActive('Mobile' . $view_name)) {
         $view_name = 'Mobile' . $view_name;
     }
     return $view_name;
 }
示例#2
0
 public static function getDevice()
 {
     if (!is_null(self::$device)) {
         return self::$device;
     }
     if (RESOURCES_DIR && class_exists('WURFL_WURFLManagerProvider')) {
         $wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
         try {
             $wurflManager = WURFL_WURFLManagerProvider::getWURFLManager($wurflConfigFile);
             self::$device = $wurflManager->getDeviceForHttpRequest($_SERVER);
         } catch (Exception $e) {
             if (Controller::$debug) {
                 Backend::addError('Wurfl Error: ' . $e->getMessage());
             }
             return false;
         }
         return self::$device ? self::$device : false;
     } else {
         Backend::addError('Could not find WURFL resources');
         return false;
     }
 }