Created
July 8, 2011 18:01
-
-
Save worenga/1072381 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class frontendConfiguration extends sfApplicationConfiguration | |
{ | |
public function configure() | |
{ | |
$this->dispatcher->connect('view.configure_format', array($this, 'configureIPhoneFormat')); | |
} | |
public function configureIPhoneFormat(sfEvent $event) | |
{ | |
$request = sfContext::getInstance()->getRequest(); | |
//Exclude IPad, but deliver mobile version to other mobile browsers | |
if(preg_match('#^(?!.*iPad).*(Mobile|Jasmine|Symbian|NetFront|BlackBerry|Opera Mini|Opera Mobi).*$#i', $request->getHttpHeader('User-Agent'))){ | |
$ext = sfContext::getInstance()->getRequest()->getParameter('sf_format'); | |
if($ext != ""){ | |
$event->getSubject()->setExtension('.mobile.'.$ext.'.php'); | |
}else{ | |
$event->getSubject()->setExtension('.mobile.php'); | |
} | |
//Always disable Web debug toolbar in Mobile versions: | |
sfConfig::set('sf_web_debug', false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment