function scaleImages(&$dom, &$serendipity)
 {
     if ($this->get_config('wurfl')) {
         $this->debugItems[] = 'Trying to scale images with WURFL';
         // already did a wurfl check for this device in our session?
         if ($_SESSION['mobile_plugin']['ua'] == $_SERVER['HTTP_USER_AGENT'] && $_SESSION['mobile_plugin']['wurfl']['width']) {
             // got the wurfl result stored in session
             $imageWidth = $_SESSION['mobile_plugin']['wurfl']['width'];
             $this->debugItems[] = 'We don\'t need to query WURFL again as the result was stored in our session';
         } else {
             // load wurfl php
             require_once dirname(__FILE__) . '/wurfl/wurfl_config.php';
             require_once WURFL_CLASS_FILE;
             // create wurfl object
             $W = new wurfl_class();
             $this->debugItems[] = 'WURFL object created';
             // query wurfl
             $W->GetDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT']);
             // get maximum image width from wurfl
             $imageWidth = (int) $W->getDeviceCapability('max_image_width') - 20;
         }
         if ($imageWidth < 0) {
             // fallback
             $dom = $this->m->scaleImages($dom, $serendipity, $this->get_config('scale_image_width'), S9Y_PEAR_PATH, $this->debugItems);
             $this->debugItems[] = 'Device not found in WURFL or screen to small. Using maximum image width as fallback';
         } else {
             // found a device
             $_SESSION['mobile_plugin']['wurfl']['width'] = $imageWidth;
             $dom = $this->m->scaleImages($dom, $serendipity, $imageWidth, S9Y_PEAR_PATH, $this->debugItems);
             $this->debugItems[] = 'Device found in WURFL, images were scaled';
         }
     } else {
         if (serendipity_db_bool($this->get_config('wurfl')) && $this->m->isIPhone === true) {
             // fix image width for iphone if not found in wurfl
             $this->debugItems[] = 'Scaling images for iPhone device';
             $dom = $this->m->scaleImages($dom, $serendipity, 300, S9Y_PEAR_PATH, $this->debugItems);
             $this->debugItems[] = 'Scaled all images';
         } else {
             // don't use wurfl
             $dom = $this->m->scaleImages($dom, $serendipity, $this->get_config('scale_image_width'), S9Y_PEAR_PATH, $this->debugItems);
             $this->debugItems[] = 'Scaled all images';
         }
     }
     // store useragent in session to check if it has changed since the last request
     $_SESSION['mobile_plugin']['ua'] = $_SERVER['HTTP_USER_AGENT'];
 }
Ejemplo n.º 2
0
}
if (isset($_GET['devHeight'])) {
    $device['height'] = $_GET['devHeight'];
}
if (isset($device)) {
    $_SESSION['device'] = $device;
}
$wurflFile = "wurfl/wurfl_class.php";
if (file_exists($wurflFile)) {
    require_once $wurflFile;
    $wurfl = new wurfl_class($wurfl, $wurfl_agents);
    // Set the user agent
    $wurfl->GetDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT']);
    //print_r( $wurfl->wurfl_agent );
    if ($wurfl->wurfl_agent) {
        if ($wurfl->getDeviceCapability('html_wi_oma_xhtmlmp_1_0')) {
            $device['width'] = $wurfl->getDeviceCapability('resolution_width');
            $device['height'] = $wurfl->getDeviceCapability('resolution_height');
        }
    }
} else {
    // This is an example of using fixed device strings to just match your phone etc
    $devices = array(array('name' => "Motorola V600", 'ua_match' => "MOT-V600", 'skin' => "mobile", 'cookies' => false, 'width' => 176, 'height' => 220));
    foreach ($devices as $tempDevice) {
        if (preg_match('/' . $tempDevice['ua_match'] . '/', $_SERVER['HTTP_USER_AGENT'])) {
            $skin = $tempDevice['skin'];
            $cookies = $tempDevice['cookies'];
            break;
        }
    }
}