Permalink
Browse files

Added "my-device" action

  • Loading branch information...
1 parent ce53d15 commit d19ce2c7e10fa8c6f0a0ac831265a4b8f1789b81 @weierophinney committed Oct 19, 2010
View
@@ -32,6 +32,7 @@ mobile-app=/home/matthew/git/zf-examples/mobile-app CD=. filter="*.php *.phtml *
details.phtml
image.phtml
index.phtml
+ my-device.phtml
}
}
}
@@ -16,6 +16,7 @@
<actionMethod actionName="index"/>
<actionMethod actionName="details"/>
<actionMethod actionName="image"/>
+ <actionMethod actionName="myDevice"/>
</controllerFile>
</controllersDirectory>
<formsDirectory enabled="false"/>
@@ -39,6 +40,9 @@
<viewControllerScriptsDirectory forControllerName="Mobile">
<viewScriptFile forActionName="image"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Mobile">
+ <viewScriptFile forActionName="myDevice"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
@@ -16,15 +16,22 @@ public function indexAction()
public function detailsAction()
{
$ua = $this->getInvokeArg('bootstrap')->getResource('useragent');
- $this->view->device = $ua->getDevice();
+ $this->view->device = $ua->getDevice();
}
public function imageAction()
{
// action body
}
+ public function myDeviceAction()
+ {
+ // action body
+ }
+
}
+
+
@@ -11,6 +11,11 @@
<?php $this->placeholder('sidebar')->captureStart() ?>
<li><a href="<?php echo $this->url(array(
'controller' => 'mobile',
+ 'action' => 'my-device',
+ ), 'default') ?>">My Device</a></li>
+
+ <li><a href="<?php echo $this->url(array(
+ 'controller' => 'mobile',
'action' => 'details',
), 'default') ?>">List of mobile capabilities</a></li>
@@ -20,6 +20,11 @@
<li><a href="<?php echo $this->url(array(
'controller' => 'mobile',
+ 'action' => 'my-device',
+ ), 'default') ?>">My Device</a></li>
+
+ <li><a href="<?php echo $this->url(array(
+ 'controller' => 'mobile',
'action' => 'image',
), 'default') ?>">Scaled image</a></li>
<?php $this->placeholder('sidebar')->captureEnd() ?>
@@ -4,7 +4,7 @@
<?php
if ($this->userAgent()->getBrowserType() != 'mobile') {
// Display at 75% width on normal pages
- echo $this->tinySrc('/images/seascape.jpg', array('width' => 'x75'))
+ echo $this->tinySrc('/images/seascape.jpg', array('width' => 'x75'));
} else {
// Full supported width on mobile devices
echo $this->tinySrc('/images/seascape.jpg');
@@ -20,6 +20,11 @@
<li><a href="<?php echo $this->url(array(
'controller' => 'mobile',
+ 'action' => 'my-device',
+ ), 'default') ?>">My Device</a></li>
+
+ <li><a href="<?php echo $this->url(array(
+ 'controller' => 'mobile',
'action' => 'details',
), 'default') ?>">List of mobile capabilities</a></li>
<?php $this->placeholder('sidebar')->captureEnd() ?>
@@ -0,0 +1,53 @@
+<?php
+$ua = $this->userAgent()->getDevice();
+$allFeatures = $ua->getAllFeatures();
+?>
+<h2>My Device</h2>
+
+<dl>
+ <dt>Device</dt>
+ <dd><?php echo $this->escape($ua->getFeature('device')) ?></dd>
+
+ <dt>Browser</dt>
+ <dd><?php echo $this->escape($ua->getBrowser()) ?></dd>
+
+ <dt>Version</dt>
+ <dd><?php echo $this->escape($ua->getBrowserVersion()) ?></dd>
+
+ <dt>Java support?</dt>
+ <dd><?php
+ $found = false;
+ foreach (array_keys($features) as $feature) {
+ if (0 === strpos($feature, 'j2me')) {
+ $found = true;
+ }
+ }
+ echo (($found) ? 'Yes' : 'No');
+ ?></dd>
+
+ <dt>Flash support?</dt>
+ <dd><?php echo ($ua->hasFlashSupport() ? 'Yes' : 'No');?></dd>
+
+ <dt>PDF support?</dt>
+ <dd><?php echo ($ua->hasPdfSupport() ? 'Yes' : 'No');?></dd>
+
+ <dt>Max supported resolution</dt>
+ <dd><?php echo $ua->getMaxImageWidth(), '/', $ua->getMaxImageHeight(); ?></dd>
+</dl>
+
+<?php $this->placeholder('sidebar')->captureStart() ?>
+ <li><a href="<?php echo $this->url(array(
+ 'controller' => 'index',
+ 'action' => 'index',
+ ), 'default') ?>">Home</a></li>
+
+ <li><a href="<?php echo $this->url(array(
+ 'controller' => 'mobile',
+ 'action' => 'details',
+ ), 'default') ?>">List of mobile capabilities</a></li>
+
+ <li><a href="<?php echo $this->url(array(
+ 'controller' => 'mobile',
+ 'action' => 'image',
+ ), 'default') ?>">Scaled image</a></li>
+<?php $this->placeholder('sidebar')->captureEnd() ?>

0 comments on commit d19ce2c

Please sign in to comment.