Skip to content

Instantly share code, notes, and snippets.

@worenga
Created July 8, 2011 18:01
Show Gist options
  • Save worenga/1072381 to your computer and use it in GitHub Desktop.
Save worenga/1072381 to your computer and use it in GitHub Desktop.
<?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