Exemplo n.º 1
0
 public static function isSmartphone()
 {
     $wurflDir = OW_DIR_LIB . 'wurfl' . DS;
     $resourcesDir = OW_DIR_PLUGINFILES . 'base' . DS . 'wurfl' . DS;
     if (defined('OW_PLUGIN_XP') && OW_PLUGIN_XP) {
         $resourcesDir = OW_DIR_STATIC_PLUGIN . 'base' . DS . 'wurfl' . DS;
     }
     require_once $wurflDir . 'Application.php';
     $persistenceDir = $resourcesDir . 'persistence' . DS;
     $cacheDir = $resourcesDir . 'cache' . DS;
     //        if ( !file_exists($wurflDir) )
     //        {
     //            mkdir($wurflDir);
     //            chmod($wurflDir, 0777);
     //            mkdir($persistenceDir);
     //            chmod($persistenceDir, 0777);
     //            mkdir($cacheDir);
     //            chmod($cacheDir, 0777);
     //        }
     $wurflConfig = new WURFL_Configuration_InMemoryConfig();
     $wurflConfig->wurflFile($wurflDir . 'wurfl.zip');
     $wurflConfig->matchMode('accuracy');
     $wurflConfig->allowReload(true);
     $wurflConfig->capabilityFilter(array("device_os", "device_os_version", "is_tablet", "is_wireless_device", "mobile_browser", "mobile_browser_version", "pointing_method", "preferred_markup", "resolution_height", "resolution_width", "ux_full_desktop", "xhtml_support_level"));
     $wurflConfig->persistence('file', array('dir' => $persistenceDir));
     $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
     $wurflManager = $wurflManagerFactory->create();
     $requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER);
     return filter_var($requestingDevice->getVirtualCapability('is_smartphone'), FILTER_VALIDATE_BOOLEAN);
 }
Exemplo n.º 2
0
 public function __construct()
 {
     require_once WURFL_DIR . 'Application.php';
     /* $persistenceDir = RESOURCES_DIR.'storage/persistence';
     		$cacheDir = RESOURCES_DIR.'storage/cache'; */
     $persistenceDir = Yii::app()->getRuntimePath() . '/WURFL/storage/persistence';
     $cacheDir = Yii::app()->getRuntimePath() . '/WURFL/storage/cache';
     $cacheServer = Yii::app()->cache->getServers();
     $cache_host = $cacheServer[0]->host;
     $cache_port = $cacheServer[0]->port;
     $wurflConfig = new WURFL_Configuration_InMemoryConfig();
     $wurflConfig->wurflFile(RESOURCES_DIR . 'wurfl.zip');
     $wurflConfig->matchMode('performance');
     $wurflConfig->persistence('file', array('dir' => $persistenceDir));
     //$wurflConfig->cache('memcache', array('host' => $cache_host,'port'=>$cache_port, 'namespace'=>'wurfl', 'expiration' => 36000));
     $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
     $this->wurflManager = $wurflManager = $wurflManagerFactory->create();
     if (isset($_REQUEST['userAgent'])) {
         $userAgent = $_REQUEST['userAgent'];
         $this->_device = $wurflManager->getDeviceForUserAgent($userAgent);
     } elseif (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) {
         $userAgent = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
         $this->_device = $wurflManager->getDeviceForUserAgent($userAgent);
     } else {
         $this->_device = $wurflManager->getDeviceForHttpRequest($_SERVER);
     }
     $this->brand = strtolower($this->_device->getCapability('brand_name'));
     $this->model = strtolower($this->_device->getCapability('model_name'));
 }
Exemplo n.º 3
0
 public function __construct()
 {
     /*
      * This is an example of configuring the WURFL PHP API
      */
     // Enable all error logging while in development
     ini_set('display_errors', 'on');
     error_reporting(E_ALL);
     $wurflDir = dirname(__FILE__) . '/wurfl/WURFL';
     $resourcesDir = dirname(__FILE__) . '/wurfl/resources';
     require_once $wurflDir . '/Application.php';
     $persistenceDir = $resourcesDir . '/storage/persistence';
     $cacheDir = $resourcesDir . '/storage/cache';
     // Create WURFL Configuration
     $wurflConfig = new WURFL_Configuration_InMemoryConfig();
     // Set location of the WURFL File
     $wurflConfig->wurflFile($resourcesDir . '/wurfl.zip');
     // Set the match mode for the API ('performance' or 'accuracy')
     $wurflConfig->matchMode('performance');
     // Setup WURFL Persistence
     $wurflConfig->persistence('file', array('dir' => $persistenceDir));
     // Setup Caching
     $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
     // Create a WURFL Manager Factory from the WURFL Configuration
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
     // Create a WURFL Manager
     /* @var $wurflManager WURFL_WURFLManager */
     $this->wurflManager = $wurflManagerFactory->create();
     $this->wurflDevice = $this->wurflManager->getDeviceForHttpRequest($_SERVER);
 }
Exemplo n.º 4
0
 public function reload($wurflConfigurationPath)
 {
     $wurflConfig = $this->fromFile($wurflConfigurationPath);
     touch($wurflConfig->wurflFile);
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
     $wurflManagerFactory->create();
 }
Exemplo n.º 5
0
 private function _load_wrfl()
 {
     if ($this->device == null) {
         $wurflDir = Yii::getPathOfAlias($this->wurflDir);
         $persistenceDir = Yii::getPathOfAlias($this->persistenceDir);
         $cacheDir = Yii::getPathOfAlias($this->cacheDir);
         require_once realpath($wurflDir . '/Application.php');
         Yii::registerAutoloader(array('WURFL_ClassLoader', 'loadClass'));
         // Create WURFL Configuration
         $wurflConfig = new WURFL_Configuration_InMemoryConfig();
         // Set location of the WURFL File
         $wurflConfig->wurflFile(realpath(Yii::getPathOfAlias($this->wurflFileDir) . '/wurfl.zip'));
         // Set the match mode for the API ('performance' or 'accuracy')
         $wurflConfig->matchMode($this->matchMode);
         // Setup WURFL Persistence
         $wurflConfig->persistence('file', array('dir' => $persistenceDir));
         // Setup Caching
         $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => $this->expiration));
         // Create a WURFL Manager Factory from the WURFL Configuration
         $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
         // Create a WURFL Manager
         /* @var $wurflManager WURFL_WURFLManager */
         $wurflManager = $wurflManagerFactory->create();
         $this->device = $wurflManager->getDeviceForHttpRequest($_SERVER);
     }
 }
Exemplo n.º 6
0
/**
 * Initialize WURFL
 *
 */
function wurfl_init($args = array())
{
    if (!isset($args['mode'])) {
        $args['mode'] = 'performance';
    }
    sys::import('modules.wurfl.xarincludes.WURFL.Application');
    $resourcesDir = sys::code() . 'modules/wurfl/xarincludes/resources';
    $persistenceDir = $resourcesDir . '/storage/persistence';
    $cacheDir = $resourcesDir . '/storage/cache';
    // Create WURFL Configuration
    $wurflConfig = new WURFL_Configuration_InMemoryConfig();
    // Set location of the WURFL File
    $wurflConfig->wurflFile($resourcesDir . '/wurfl.xml');
    // Set the match mode for the API ('performance' or 'accuracy')
    $wurflConfig->matchMode($args['mode']);
    // Setup WURFL Persistence
    $wurflConfig->persistence('file', array('dir' => $persistenceDir));
    // Setup Caching
    $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
    // Create a WURFL Manager Factory from the WURFL Configuration
    $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
    // Create a WURFL Manager
    /* @var $wurflManager WURFL_WURFLManager */
    $wurflManager = $wurflManagerFactory->create();
    return $wurflManager;
}
Exemplo n.º 7
0
 public function loadWurfl(WURFL_Configuration_Config $config)
 {
     if ($config instanceof WURFL_Configuration_InMemoryConfig) {
         $config->cache("null");
     }
     $wurfl_factory = new WURFL_WURFLManagerFactory($config);
     $this->wurfl = $wurfl_factory->create();
 }
Exemplo n.º 8
0
 public static function setUpBeforeClass()
 {
     $resourcesDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . self::RESOURCES_DIR;
     $config = new WURFL_Configuration_InMemoryConfig();
     $config->wurflFile($resourcesDir . "/wurfl-2.0.27.zip")->wurflPatch($resourcesDir . "/web_browsers_patch.xml")->wurflPatch($resourcesDir . "/issues/nokia-patch.xml")->wurflPatch($resourcesDir . "/issues/issue-177-patch.xml");
     self::$persistenceProvider = new WURFL_Storage_Memcache();
     self::$persistenceProvider->clear();
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($config, self::$persistenceProvider);
     self::$wurflManager = $wurflManagerFactory->create();
 }
Exemplo n.º 9
0
 public function testCut()
 {
     $config = $this->makeConfig();
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($config);
     $wurfl = $wurflManagerFactory->create();
     $centralTest = new CentralTestManager($wurfl);
     $centralTest->show_success = false;
     ob_start();
     $centralTest->runBatchTest(CentralTestManager::TYPE_ALL);
     ob_end_clean();
     $this->assertEquals(0, $centralTest->num_failure, sprintf('Central Unit Tests failed: %d', $centralTest->num_failure));
 }
Exemplo n.º 10
0
 /**
  * Constructor takes user agent that it will use to determine results of
  * other methods. It also builds a chain of WURLF objects (XMLConfig ->
  * ManagerFactory -> Manager), concluding with a manager that calculates
  * device information for the user agent in question and stores it in
  * $_device.
  *
  * In the event that the $useragent passed is NULL,
  *
  * @param string $useragent
  */
 public function __construct($useragent)
 {
     $this->_user_agent = $useragent;
     if (!$this->_user_agent) {
         $this->_manager = null;
         $this->_device = null;
     } else {
         $config = new WURFL_Configuration_XmlConfig(Config::get('user_agent', 'wurfl_config_path'));
         $factory = new WURFL_WURFLManagerFactory($config);
         $this->_manager = $factory->create();
         $this->_device = $this->_manager->getDeviceForUserAgent($useragent);
     }
 }
Exemplo n.º 11
0
 public function setUp()
 {
     $resourcesDir = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . "../../resources");
     $config = new WURFL_Configuration_InMemoryConfig();
     $config->wurflFile($resourcesDir . "/wurfl_base.xml");
     // Setup WURFL Persistence
     $this->persistenceDir = sys_get_temp_dir() . '/api_test';
     WURFL_FileUtils::mkdir($this->persistenceDir);
     $config->persistence('file', array('dir' => $this->persistenceDir));
     // Setup Caching
     $config->cache('null');
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($config);
     $this->wurflManager = $wurflManagerFactory->create();
 }
Exemplo n.º 12
0
 /**
  * Get features from request
  *
  * @param  array $request $_SERVER variable
  * @return array
  */
 public static function getFromRequest($request, array $config)
 {
     if (!isset($config['xzend_wurflapi'])) {
         require_once 'Zend/Http/UserAgent/Features/Exception.php';
         throw new Zend_Http_UserAgent_Features_Exception('"xzend_wurflapi" configuration is not defined');
     }
     $config = $config['xzend_wurflapi'];
     if (empty($config['wurfl_lib_dir'])) {
         require_once 'Zend/Http/UserAgent/Features/Exception.php';
         throw new Zend_Http_UserAgent_Features_Exception('The "wurfl_lib_dir" parameter is not defined');
     }
     if (empty($config['wurfl_config_file']) && empty($config['wurfl_config_array'])) {
         require_once 'Zend/Http/UserAgent/Features/Exception.php';
         throw new Zend_Http_UserAgent_Features_Exception('The "wurfl_config_file" parameter is not defined');
     }
     if (empty($config['wurfl_api_version'])) {
         $config['wurfl_api_version'] = self::DEFAULT_API_VERSION;
     }
     switch ($config['wurfl_api_version']) {
         case '1.2':
             require_once $config['wurfl_lib_dir'] . 'Application.php';
             if (!empty($config['wurfl_config_file'])) {
                 $wurflConfig = WURFL_Configuration_ConfigFactory::create($config['wurfl_config_file']);
             } elseif (!empty($config['wurfl_config_array'])) {
                 $c = $config['wurfl_config_array'];
                 $wurflConfig = new WURFL_Configuration_InMemoryConfig();
                 $wurflConfig->wurflFile($c['wurfl']['main-file'])->wurflPatch($c['wurfl']['patches']);
                 if ($c['persistence']['provider'] == 'file') {
                     $wurflConfig->persistence("file", array(WURFL_Configuration_Config::DIR => $c['persistence']['dir']));
                 }
                 if ($c['cache']['provider'] == 'file') {
                     $wurflConfig->cache("file", array(WURFL_Configuration_Config::DIR => $c['cache']['dir'], WURFL_Configuration_Config::EXPIRATION => $c['cache']['expiration']));
                 }
             }
             $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
             $wurflManager = $wurflManagerFactory->create();
             break;
         default:
             require_once 'Zend/Http/UserAgent/Features/Exception.php';
             throw new Zend_Http_UserAgent_Features_Exception(sprintf('Unknown API version "%s"', $config['wurfl_api_version']));
     }
     $device = $wurflManager->getDeviceForHttpRequest(array_change_key_case($request, CASE_UPPER));
     $features = $device->getAllCapabilities();
     return $features;
 }
 protected function getWurflDevice()
 {
     $wurflConfigFile = jfPortableDevice::getConfig('wurflConfigFile');
     if (!$wurflConfigFile) {
         return null;
     }
     $wurflDir = dirname(__FILE__) . "/../../../lib/vendor/WURFL_PHP/WURFL/";
     require_once $wurflDir . 'ClassLoader.php';
     // Create WURFL Configuration from an XML config file
     $wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);
     // Create a WURFL Manager Factory from the WURFL Configuration
     $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
     // Create a WURFL Manager ($wurflManager is a WURFL_WURFLManager object)
     $wurflManager = $wurflManagerFactory->create();
     // Get information on the loaded WURFL ($wurflInfo is a WURFL_Xml_Info object)
     //$wurflInfo = $wurflManager->getWURFLInfo();
     return $wurflManager->getDeviceForHttpRequest($_SERVER);
 }
Exemplo n.º 14
0
 public static function getInfo()
 {
     $deviceId = $modelName = "";
     // AMF was installed
     if (isset($_SERVER['AMF_ID'])) {
         $deviceId = isset($_SERVER['AMF_ID']) ? $_SERVER['AMF_ID'] : "";
         $modelName = isset($_SERVER['AMF_MODEL_NAME']) ? $_SERVER['AMF_MODEL_NAME'] : "";
     } else {
         if (!defined("WURFL_DIR")) {
             define("WURFL_DIR", Yii::getPathOfAlias("application.vendors.WURFL_CHACHA") . "/");
             define("RESOURCES_DIR", WURFL_DIR . "Resources/");
         }
         require_once WURFL_DIR . 'Application.php';
         //$wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
         //$wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);
         $persistenceDir = RESOURCES_DIR . 'storage/persistence';
         $cacheServer = Yii::app()->cache->getServers();
         $cache_host = $cacheServer[0]->host;
         $cache_port = $cacheServer[0]->port;
         $wurflConfig = new WURFL_Configuration_InMemoryConfig();
         $wurflConfig->wurflFile(RESOURCES_DIR . 'wurfl.zip');
         $wurflConfig->matchMode('performance');
         $wurflConfig->persistence('file', array('dir' => $persistenceDir));
         $wurflConfig->cache('memcache', array('host' => $cache_host, 'port' => $cache_port, 'namespace' => 'wurfl', 'expiration' => 36000));
         $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
         $wurflManager = $wurflManagerFactory->create();
         $device = $wurflManager->getDeviceForHttpRequest($_SERVER);
         $modelName = $device->getCapability("model_name");
         if (Utils::appleDevice('iPad')) {
             $deviceId = 'apple_ipad_ver1_sub42';
         } else {
             $deviceId = $device->id;
         }
     }
     return array('deviceId' => $deviceId, 'modelName' => $modelName);
 }
Exemplo n.º 15
0
function load_wurfl_manager()
{
    global $wurflManager;
    if (defined('_XMLREADER_INSTALLED') && _XMLREADER_INSTALLED || extension_loaded('xmlreader')) {
        // Init WURFL library for mobile device detection
        $wurflDir = _TRACK_LIB_PATH . '/wurfl/WURFL';
        $resourcesDir = _TRACK_LIB_PATH . '/wurfl/resources';
        require_once $wurflDir . '/Application.php';
        $persistenceDir = _CACHE_COMMON_PATH . '/wurfl-persistence';
        $cacheDir = _CACHE_COMMON_PATH . '/wurfl-cache';
        $wurflConfig = new WURFL_Configuration_InMemoryConfig();
        $wurflConfig->wurflFile(_TRACK_STATIC_PATH . '/wurfl/wurfl_1.5.3.xml');
        $wurflConfig->matchMode('accuracy');
        $wurflConfig->allowReload(true);
        $wurflConfig->persistence('file', array('dir' => $persistenceDir));
        $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
        $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
        $wurflManager = $wurflManagerFactory->create();
    }
}
Exemplo n.º 16
0
 protected function createWurflClass()
 {
     if ($this->arguments->altClass) {
         $class_name = $this->arguments->altClass->value;
         if (class_exists($class_name, false) && is_subclass_of($class_name, 'WURFL_WURFLManager')) {
             $this->wurfl = new $class_name();
         } else {
             throw new WURFL_WURFLCLIInvalidArgumentException("Error: {$class_name} must extend WURFL_WURFLManager.");
         }
     } else {
         $persistenceDir = RESOURCES_DIR . '/storage/persistence';
         $cacheDir = RESOURCES_DIR . '/storage/cache';
         // Create WURFL Configuration
         $wurflConfig = new WURFL_Configuration_InMemoryConfig();
         // Set location of the WURFL File
         $wurflConfig->wurflFile(RESOURCES_DIR . '/wurfl.zip');
         // Set the match mode for the API ('performance' or 'accuracy')
         $wurflConfig->matchMode('performance');
         // Setup WURFL Persistence
         $wurflConfig->persistence('file', array('dir' => $persistenceDir));
         // Setup Caching
         $wurflConfig->cache('null');
         $wurflConfig->allowReload(true);
         // Create a WURFL Manager Factory from the WURFL Configuration
         $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
         // Create a WURFL Manager
         $this->wurfl = $wurflManagerFactory->create();
     }
 }
Exemplo n.º 17
0
 /**
  * @param $out OutputPage
  * @param $text String
  * @return bool
  */
 public function beforePageDisplayHTML(&$out, &$text)
 {
     global $wgContLang, $wgRequest, $wgMemc, $wgUser;
     wfProfileIn(__METHOD__);
     $userAgent = $_SERVER['HTTP_USER_AGENT'];
     $acceptHeader = isset($_SERVER["HTTP_ACCEPT"]) ? $_SERVER["HTTP_ACCEPT"] : '';
     $uAmd5 = md5($userAgent);
     $key = wfMemcKey('mobile', 'ua', $uAmd5);
     $props = null;
     try {
         $props = $wgMemc->get($key);
         if (!$props) {
             $wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
             $wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);
             $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
             $wurflManager = $wurflManagerFactory->create();
             $device = $wurflManager->getDeviceForHttpRequest($_SERVER);
             if ($device->isSpecific() === true) {
                 $props = $device->getAllCapabilities();
                 $wgMemc->set($key, $props, 86400);
             } else {
                 $wgMemc->set($key, 'generic', 86400);
                 $props = 'generic';
             }
         }
     } catch (Exception $e) {
         // echo $e->getMessage();
     }
     // Note: The WebRequest Class calls are made in this block because
     // since PHP 5.1.x, all objects have their destructors called
     // before the output buffer callback function executes.
     // Thus, globalized objects will not be available as expected in the function.
     // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104]
     $xDevice = isset($_SERVER['HTTP_X_DEVICE']) ? $_SERVER['HTTP_X_DEVICE'] : '';
     self::$useFormat = $wgRequest->getText('useformat');
     $mobileAction = $wgRequest->getText('mobileaction');
     $action = $wgRequest->getText('action');
     if (self::$useFormat !== 'mobile' && self::$useFormat !== 'mobile-wap' && !$xDevice) {
         wfProfileOut(__METHOD__);
         return true;
     }
     if ($action === 'edit' || $mobileAction === 'view_normal_site') {
         wfProfileOut(__METHOD__);
         return true;
     }
     self::$title = $out->getTitle();
     if (self::$title->isMainPage()) {
         self::$isMainPage = true;
     }
     if (self::$title->getNamespace() == NS_FILE) {
         self::$isFilePage = true;
     }
     self::$htmlTitle = $out->getHTMLTitle();
     self::$disableImages = $wgRequest->getText('disableImages', 0);
     self::$enableImages = $wgRequest->getText('enableImages', 0);
     self::$displayNoticeId = $wgRequest->getText('noticeid', '');
     if (self::$disableImages == 1) {
         $wgRequest->response()->setcookie('disableImages', 1);
         $location = str_replace('?disableImages=1', '', str_replace('&disableImages=1', '', $wgRequest->getFullRequestURL()));
         $location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location));
         $location = $this->getRelativeURL($location);
         $wgRequest->response()->header('Location: ' . $location . '&mfi=0');
     } elseif (self::$disableImages == 0) {
         $disableImages = $wgRequest->getCookie('disableImages');
         if ($disableImages) {
             self::$disableImages = $disableImages;
         }
     }
     if (self::$enableImages == 1) {
         $disableImages = $wgRequest->getCookie('disableImages');
         if ($disableImages) {
             $wgRequest->response()->setcookie('disableImages', '');
         }
         $location = str_replace('?enableImages=1', '', str_replace('&enableImages=1', '', $wgRequest->getFullRequestURL()));
         $location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location));
         $location = $this->getRelativeURL($location);
         $wgRequest->response()->header('Location: ' . $location . '&mfi=1');
     }
     self::$format = $wgRequest->getText('format');
     self::$callback = $wgRequest->getText('callback');
     self::$requestedSegment = $wgRequest->getText('seg', 0);
     self::$search = $wgRequest->getText('search');
     self::$searchField = $wgRequest->getText('search', '');
     $device = new DeviceDetection();
     if ($xDevice) {
         $formatName = $xDevice;
     } else {
         $formatName = $device->formatName($userAgent, $acceptHeader);
     }
     self::$device = $device->format($formatName);
     if (self::$device['view_format'] === 'wml') {
         $this->contentFormat = 'WML';
     } elseif (self::$device['view_format'] === 'html') {
         $this->contentFormat = 'XHTML';
     }
     if (self::$useFormat === 'mobile-wap') {
         $this->contentFormat = 'WML';
     }
     if ($mobileAction == 'leave_feedback') {
         echo $this->renderLeaveFeedbackXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'leave_feedback_post') {
         $this->getMsg();
         $subject = $wgRequest->getText('subject', '');
         $message = $wgRequest->getText('message', '');
         $token = $wgRequest->getText('edittoken', '');
         $title = Title::newFromText(self::$messages['mobile-frontend-feedback-page']);
         if ($title->userCan('edit') && !$wgUser->isBlockedFrom($title) && $wgUser->matchEditToken($token)) {
             $article = new Article($title, 0);
             $rawtext = $article->getRawText();
             $rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> ";
             $article->doEdit($rawtext, '');
         }
         $location = str_replace('&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '&noticeid=1&useformat=mobile');
         $location = $this->getRelativeURL($location);
         $wgRequest->response()->header('Location: ' . $location);
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML') {
         echo $this->renderDisableMobileSiteXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML') {
         echo $this->renderOptInMobileSiteXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'opt_out_mobile_site' && $this->contentFormat == 'XHTML') {
         echo $this->renderOptOutMobileSiteXHTML();
         wfProfileOut(__METHOD__);
         exit;
     }
     if ($mobileAction == 'opt_in_cookie') {
         wfIncrStats('mobile.opt_in_cookie_set');
         $this->setOptInOutCookie('1');
         $this->disableCaching();
         $location = wfExpandUrl(Title::newMainPage()->getFullURL(), PROTO_CURRENT);
         $wgRequest->response()->header('Location: ' . $location);
     }
     if ($mobileAction == 'opt_out_cookie') {
         $this->setOptInOutCookie('');
     }
     $this->getMsg();
     $this->disableCaching();
     $this->sendXDeviceVaryHeader();
     $this->sendApplicationVersionVaryHeader();
     $this->checkUserStatus();
     $this->checkUserLoggedIn();
     if (self::$title->isSpecial('Userlogin') && self::$isBetaGroupMember) {
         self::$wsLoginToken = $wgRequest->getSessionData('wsLoginToken');
         $q = array('action' => 'submitlogin', 'type' => 'login');
         $returnToVal = $wgRequest->getVal('returnto');
         if ($returnToVal) {
             $q['returnto'] = $returnToVal;
         }
         self::$wsLoginFormAction = self::$title->getLocalURL($q);
     }
     $this->setDefaultLogo();
     ob_start(array($this, 'DOMParse'));
     wfProfileOut(__METHOD__);
     return true;
 }
Exemplo n.º 18
0
<?php

// Enable all error logging while in development
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$wurflDir = dirname(__FILE__) . '/../../WURFL';
$resourcesDir = dirname(__FILE__) . '/../resources';
require_once $wurflDir . '/Application.php';
$persistenceDir = $resourcesDir . '/storage/persistence';
$cacheDir = $resourcesDir . '/storage/cache';
$wurflConfig = new WURFL_Configuration_InMemoryConfig();
$wurflConfig->wurflFile($resourcesDir . '/wurfl.zip');
$wurflConfig->matchMode('performance');
$wurflConfig->persistence('file', array('dir' => $persistenceDir));
$wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
$wurflManager = $wurflManagerFactory->create();
$wurflInfo = $wurflManager->getWURFLInfo();
define("XHTML_ADVANCED", "xhtml_advanced.php");
define("XHTML_SIMPLE", "xhtml_simple.php");
define("WML", "wml.php");
$device = $wurflManager->getDeviceForHttpRequest($_SERVER);
$xhtml_lvl = $device->getCapability('xhtml_support_level');
$contentType = $device->getCapability('xhtmlmp_preferred_mime_type');
$page = getPageFromMarkup($xhtml_lvl);
renderPage($page, $contentType);
function getPageFromMarkup($xhtml_lvl)
{
    /* xhtml_support_level possible values:
     * -1: No XHTML Support
     *  0: Poor XHTML Support