BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
MobileContext Class Reference
Inheritance diagram for MobileContext:
Collaboration diagram for MobileContext:

Public Member Functions

 getMFConfig ()
 
 getDevice ()
 
 isLazyLoadReferencesEnabled ()
 
 isLazyLoadImagesEnabled ()
 
 imagesDisabled ()
 
 isMobileDevice ()
 
 getAMF ()
 
 setForceMobileView ($value)
 
 getForceMobileView ()
 
 setContentTransformations ($value)
 
 getContentTransformations ()
 
 setMobileMode ($mode)
 
 isBetaGroupMember ()
 
 shouldDisplayMobileView ()
 
 isBlacklistedPage ()
 
 getMobileAction ()
 
 getUseFormat ()
 
 setUseFormat ($useFormat)
 
 setStopMobileRedirectCookie ($expiry=null)
 
 unsetStopMobileRedirectCookie ()
 
 getStopMobileRedirectCookie ()
 
 getUseFormatCookie ()
 
 setDisableImagesCookie ($shouldDisableImages)
 
 getBaseDomain ()
 
 getStopMobileRedirectCookieDomain ()
 
 setUseFormatCookie ($cookieFormat= 'true', $expiry=null)
 
 unsetUseFormatCookie ()
 
 getUseFormatCookieDuration ()
 
 getMobileHostToken ($mobileUrlHostTemplate)
 
 getMobileUrlTemplate ()
 
 getMobileUrl ($url, $forceHttps=false)
 
 usingMobileDomain ()
 
 getDesktopUrl ($url)
 
 parseMobileUrlTemplate ($part=null)
 
 toggleView ($view)
 
 doToggling ()
 
 checkToggleView ()
 
 isLocalUrl ($url)
 
 addAnalyticsLogItem ($key, $val)
 
 getAnalyticsLogItems ()
 
 getXAnalyticsHeader ()
 
 addAnalyticsLogItemFromXAnalytics ($xanalytics_item)
 
 logMobileMode ()
 
- Public Member Functions inherited from ContextSource
 getContext ()
 
 setContext (IContextSource $context)
 
 getConfig ()
 
 getRequest ()
 
 getTitle ()
 
 canUseWikiPage ()
 
 getWikiPage ()
 
 getOutput ()
 
 getUser ()
 
 getLanguage ()
 
 getSkin ()
 
 getTiming ()
 
 getStats ()
 
 msg ()
 
 exportSession ()
 

Static Public Member Functions

static singleton ()
 
static setInstance ($instance)
 

Public Attributes

const USEFORMAT_COOKIE_NAME = 'mf_useformat'
 
const USER_MODE_PREFERENCE_NAME = 'mfMode'
 
const LAZY_LOAD_IMAGES_COOKIE_NAME = 'mfLazyLoadImages'
 
const LAZY_LOAD_IMAGES_COOKIE_VALUE = 'A'
 
const LAZY_LOAD_REFERENCES_COOKIE_NAME = 'mfLazyLoadReferences'
 
const LAZY_LOAD_REFERENCES_COOKIE_VALUE = 'A'
 

Static Public Attributes

static $mfStopRedirectCookieHost = null
 

Protected Member Functions

 __construct (IContextSource $context)
 
 isFauxMobileDevice ()
 
 getUseFormatCookieExpiry ($startTime=null, $cookieDuration=null)
 
 updateMobileUrlHost (&$parsedUrl)
 
 updateDesktopUrlHost (&$parsedUrl)
 
 updateDesktopUrlQuery (&$parsedUrl)
 
 updateMobileUrlPath (&$parsedUrl)
 

Protected Attributes

 $mobileMode
 
 $disableImages
 
 $lazyLoadImages
 
 $lazyLoadReferences
 
 $useFormat
 
 $blacklistedPage
 
 $analyticsLogItems = array()
 
 $action
 
 $mobileAction
 

Detailed Description

MobileContext.php Provide various request-dependant methods to use in mobile context

Constructor & Destructor Documentation

MobileContext::__construct ( IContextSource  $context)
protected

Set the IontextSource Object

Parameters
IContextSource$contextThe IContextSource Object has to set

Member Function Documentation

MobileContext::addAnalyticsLogItem (   $key,
  $val 
)

Add key/value pairs for analytics purposes to $this->analyticsLogItems

Parameters
string$key
string$val
MobileContext::addAnalyticsLogItemFromXAnalytics (   $xanalytics_item)

Take a key/val pair in string format and add it to $this->analyticsLogItems

Parameters
string$xanalytics_itemIn the format key=value
MobileContext::checkToggleView ( )

Determine whether or not we need to toggle the view, and toggle it

MobileContext::doToggling ( )

Performs view change as requested vy toggleView()

MobileContext::getAMF ( )

Check for mobile device when using Apache Mobile Filter (AMF)

IF AMF is enabled, make sure we use it to detect mobile devices. Tablets are currently served desktop site.

AMF docs: http://wiki.apachemobilefilter.org/

Returns
bool
MobileContext::getAnalyticsLogItems ( )

Read key/value pairs for analytics purposes from $this->analyticsLogItems

Returns
array
MobileContext::getBaseDomain ( )

Return the basic second level domain or just IP adress

Returns
string
MobileContext::getContentTransformations ( )

Whether content should be transformed to better suit mobile devices

Returns
bool
MobileContext::getDesktopUrl (   $url)

Take a URL and return a copy that removes any mobile tokens

Parameters
string$url
Returns
string
MobileContext::getDevice ( )

Gets the current device description

Returns
IDeviceProperties
MobileContext::getForceMobileView ( )

Whether mobile view should always be enforced

Returns
bool
MobileContext::getMFConfig ( )

Get MobileFrontend's config object.

Returns
Config
MobileContext::getMobileAction ( )

Get requested mobile action

Returns
string
MobileContext::getMobileHostToken (   $mobileUrlHostTemplate)

Take a URL Host Template and return the mobile token portion

Eg if a desktop domain is en.wikipedia.org, but the mobile variant is en.m.wikipedia.org, the mobile token is 'm.'

Parameters
$mobileUrlHostTemplatestring
Returns
string
MobileContext::getMobileUrl (   $url,
  $forceHttps = false 
)

Take a URL and return a copy that conforms to the mobile URL template

Parameters
string$url
bool$forceHttps
Returns
string|bool
MobileContext::getMobileUrlTemplate ( )

Get the template for mobile URLs.

See Also
$wgMobileUrlTemplate
MobileContext::getStopMobileRedirectCookie ( )

Read cookie for stop automatic mobile redirect

Returns
string
MobileContext::getStopMobileRedirectCookieDomain ( )

Determine the correct domain to use for the stopMobileRedirect cookie

Will use $wgMFStopRedirectCookieHost if it's set, otherwise will use result of getBaseDomain()

Returns
string
MobileContext::getUseFormat ( )

Get useformat from request for e.g. for isFauxMobileDevice()

Returns
string
MobileContext::getUseFormatCookie ( )

Get the useformat cookie

This cookie can determine whether or not a user should see the mobile version of a page.

Returns
string|null
MobileContext::getUseFormatCookieDuration ( )

Determine the duration the cookie should last.

If $wgMobileFrontendFormatcookieExpiry has a non-0 value, use that for the duration. Otherwise, fall back to $wgCookieExpiration.

Returns
int The number of seconds for which the cookie should last.
MobileContext::getUseFormatCookieExpiry (   $startTime = null,
  $cookieDuration = null 
)
protected

Get the expiration time for the mf_useformat cookie

Parameters
int$startTimeThe base time (in seconds since Epoch) from which to calculate cookie expiration. If null, time() is used.
int$cookieDurationThe time (in seconds) the cookie should last
Returns
int The time (in seconds since Epoch) that the cookie should expire
MobileContext::getXAnalyticsHeader ( )

Get HTTP header string for X-Analytics

This is made up of key/vaule pairs and is used for analytics purposes.

Returns
string|bool
MobileContext::imagesDisabled ( )

Checks whether images are disabled for the current user

Returns
bool
MobileContext::isBetaGroupMember ( )

Wether user is Beta group member

Returns
boolean
MobileContext::isBlacklistedPage ( )

Checks whether current page is blacklisted from displaying mobile view

Returns
bool
MobileContext::isFauxMobileDevice ( )
protected

Wether useformat is mobile

Returns
bool
MobileContext::isLazyLoadImagesEnabled ( )

Checks whether images should be lazy loaded for the current user

Returns
bool
MobileContext::isLazyLoadReferencesEnabled ( )

Checks whether references should be lazy loaded for the current user

Returns
bool
MobileContext::isLocalUrl (   $url)

Determine whether or not a given URL is local

Parameters
string$urlURL to check against
Returns
bool
MobileContext::isMobileDevice ( )

Check whether the device is a mobile device

Returns
bool
MobileContext::logMobileMode ( )

Adds analytics log items if the user is in beta mode

Invoked from MobileFrontendHooks::onRequestContextCreateSkin()

MobileContext::parseMobileUrlTemplate (   $part = null)

Parse mobile URL template into its host and path components.

Optionally specify which portion of the template you want returned.

Parameters
string$part
Returns
mixed

This if/else block exists because of an annoying aspect of substr() Even if you pass 'null' or 'false' into the 'length' param, it will return an empty string. http://www.stopgeek.com/wp-content/uploads/2007/07/sense.jpg

MobileContext::setContentTransformations (   $value)

Whether content should be transformed to better suit mobile devices

Parameters
bool$value
MobileContext::setDisableImagesCookie (   $shouldDisableImages)

Set or unset cookie to disable images on pages

Parameters
bool$shouldDisableImages
MobileContext::setForceMobileView (   $value)

Save whether mobile view should always be enforced

Parameters
bool$value
static MobileContext::setInstance (   $instance)
static

Set $this->instance to the given instance of MobileContext or null

Parameters
MobileContext | null$instanceMobileContext instance or null to set
Returns
MobileContext|null
MobileContext::setMobileMode (   $mode)

Sets testing group membership, both cookie and this class variables

Parameters
string$modeMode to set
MobileContext::setStopMobileRedirectCookie (   $expiry = null)

Set Cookie to stop automatically redirect to mobile page

Parameters
integer$expiryExpire time of cookie
MobileContext::setUseFormat (   $useFormat)

Set useformat as var

Parameters
string$useFormatThe useformat value to set
MobileContext::setUseFormatCookie (   $cookieFormat = 'true',
  $expiry = null 
)

Set the mf_useformat cookie

This cookie can determine whether or not a user should see the mobile version of pages.

Parameters
string$cookieFormat
null$expiry
MobileContext::shouldDisplayMobileView ( )

Determine whether or not we should display the mobile view

Step through the hierarchy of what should or should not trigger the mobile view.

Primacy is given to the page action - we will never show mobile view for page edits or page history. 'userformat' request param is then honored, followed by cookie settings, then actual device detection, finally falling back on false.

Returns
bool
static MobileContext::singleton ( )
static

Returns the actual MobileContext Instance or create a new if no exists

Returns
MobileContext
MobileContext::toggleView (   $view)

Toggles view to one specified by the user

If a user has requested a particular view (eg clicked 'Desktop' from a mobile page), set the requested view for this particular request and set a cookie to keep them on that view for subsequent requests.

Parameters
string$viewUser requested particular view
MobileContext::unsetStopMobileRedirectCookie ( )

Remove cookie and continue automatic redirect to mobile page

Returns
string
MobileContext::unsetUseFormatCookie ( )

Remove cookie based saved useformat value

MobileContext::updateDesktopUrlHost ( $parsedUrl)
protected

Update the host of a given URL to strip out any mobile tokens

Parameters
array$parsedUrlResult of parseUrl() or wfParseUrl()
MobileContext::updateDesktopUrlQuery ( $parsedUrl)
protected

Update the query portion of a given URL to remove any 'useformat' params

Parameters
array$parsedUrlResult of parseUrl() or wfParseUrl()
MobileContext::updateMobileUrlHost ( $parsedUrl)
protected

Update host of given URL to conform to mobile URL template.

Parameters
array$parsedUrlResult of parseUrl() or wfParseUrl()
MobileContext::updateMobileUrlPath ( $parsedUrl)
protected

Update path of given URL to conform to mobile URL template.

NB: this is not actually being used anywhere at the moment. It will take some magic to get MW to properly handle path modifications like this is intended to provide. This will hopefully be implemented someday in the not to distant future.

Parameters
array$parsedUrlResult of parseUrl() or wfParseUrl()
MobileContext::usingMobileDomain ( )

If a mobile-domain is specified by the $wgMobileUrlTemplate and there's a mobile header, then we assume the user is accessing the site from the mobile-specific domain (because why would the desktop site set the header?).

Returns
bool

Member Data Documentation

boolean MobileContext::$blacklistedPage
protected

Save whether current page is blacklisted from displaying in mobile view

boolean MobileContext::$disableImages
protected

Save whether images are disabled for the current user

boolean MobileContext::$lazyLoadImages
protected

Save whether images will be lazy loaded for current user

boolean MobileContext::$lazyLoadReferences
protected

Save whether references will be lazy loaded for current user

string MobileContext::$mobileAction
protected

Saves requested Mobile action

string MobileContext::$mobileMode
protected

Saves the testing mode user has opted in: 'beta' or 'stable'

string MobileContext::$useFormat
protected

Save explicitly requested format


The documentation for this class was generated from the following file: