Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS
SVN: [114886] branches/wmf/1.19wmf1/extensions/MobileFrontend/ DeviceDetection.php
 

Index | Next | Previous | View Flat


awjrichards at svn

Apr 13, 2012, 12:29 PM


Views: 67
Permalink
SVN: [114886] branches/wmf/1.19wmf1/extensions/MobileFrontend/ DeviceDetection.php

https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114886

Revision: 114886
Author: awjrichards
Date: 2012-04-13 19:29:52 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
Picking up missing changes from previous merge

Modified Paths:
--------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php 2012-04-13 19:21:51 UTC (rev 114885)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php 2012-04-13 19:29:52 UTC (rev 114886)
@@ -17,7 +17,7 @@
/**
* @return array
*/
- public function availableFormats() {
+ public function getAvailableFormats() {
$formats = array (
'html' => array (
'view_format' => 'html',
@@ -247,11 +247,21 @@
}

/**
+ * @param $userAgent
+ * @param string $acceptHeader
+ * @return array
+ */
+ public function detectDevice( $userAgent, $acceptHeader = '' ) {
+ $formatName = $this->detectFormatName( $userAgent, $acceptHeader );
+ return $this->getDevice( $formatName );
+ }
+
+ /**
* @param $formatName
* @return array
*/
- public function format( $formatName ) {
- $format = $this->availableFormats();
+ public function getDevice( $formatName ) {
+ $format = $this->getAvailableFormats();
return ( isset( $format[$formatName] ) ) ? $format[$formatName] : array();
}

@@ -260,7 +270,7 @@
* @param $acceptHeader string
* @return string
*/
- public function formatName( $userAgent, $acceptHeader = '' ) {
+ public function detectFormatName( $userAgent, $acceptHeader = '' ) {
$formatName = '';

if ( preg_match( '/Android/', $userAgent ) ) {
@@ -334,4 +344,18 @@
}
return $formatName;
}
+
+ /**
+ * @return array: List of all device-specific stylesheets
+ */
+ public function getCssFiles() {
+ $devices = $this->getAvailableFormats();
+ $files = array();
+ foreach ( $devices as $dev ) {
+ if ( isset( $dev['css_file_name'] ) ) {
+ $files[] = $dev['css_file_name'];
+ }
+ }
+ return array_unique( $files );
+ }
}


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS [at] lists
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Subject User Time
SVN: [114886] branches/wmf/1.19wmf1/extensions/MobileFrontend/ DeviceDetection.php awjrichards at svn Apr 13, 2012, 12:29 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.