當前位置: 首頁>>代碼示例>>PHP>>正文


PHP c2cTools::mobileRegexp方法代碼示例

本文整理匯總了PHP中c2cTools::mobileRegexp方法的典型用法代碼示例。如果您正苦於以下問題:PHP c2cTools::mobileRegexp方法的具體用法?PHP c2cTools::mobileRegexp怎麽用?PHP c2cTools::mobileRegexp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在c2cTools的用法示例。


在下文中一共展示了c2cTools::mobileRegexp方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public function execute($filterChain)
 {
     $context = $this->getContext();
     $user = $context->getUser();
     if ($this->isFirstCall() && !$user->hasAttribute('form_factor')) {
         // if you make changes here, be sure also to check web/forums/include/common.php
         // and check varnish vcl file
         $cookie = $context->getRequest()->getCookie('form_factor');
         if ($cookie === 'mobile' || $cookie === null && c2cTools::mobileRegexp()) {
             $user->setAttribute('form_factor', 'mobile');
         } else {
             $user->setAttribute('form_factor', 'desktop');
         }
     }
     if ($user->getAttribute('form_factor', 'desktop') === 'mobile') {
         // change layout for mobile_layout
         $context->getResponse()->setParameter($context->getModuleName() . '_' . $context->getActionName() . '_layout', 'mobile_layout', 'symfony/action/view');
         $context->getResponse()->addStylesheet('/static/css/mobile.css', 'last');
     } else {
         $context->getResponse()->addStylesheet('/static/css/default.css');
         $context->getResponse()->addStylesheet('/static/css/menu.css');
         $context->getResponse()->addStylesheet('/static/css/print.css', 'print');
     }
     // execute next filter
     $filterChain->execute();
 }
開發者ID:snouhaud,項目名稱:camptocamp.org,代碼行數:26,代碼來源:FormFactorFilter.class.php

示例2: executeSwitchformfactor

 public function executeSwitchformfactor()
 {
     $user = $this->getUser();
     if ($user->getAttribute('form_factor', 'desktop') === 'mobile') {
         $user->setAttribute('form_factor', 'desktop');
         if (!c2cTools::mobileRegexp()) {
             // delete form_factor cookie (not needed)
             $this->getResponse()->setCookie('form_factor', null, -1);
         } else {
             // set cookie so that we are sure to prevent redirection on next sessions
             $this->getResponse()->setCookie('form_factor', 'desktop', time() + 60 * 60 * 24 * 30);
         }
     } else {
         $user->setAttribute('form_factor', 'mobile');
         if (c2cTools::mobileRegexp()) {
             // delete form_factor cookie (not needed)
             $this->getResponse()->setCookie('form_factor', null, -1);
         } else {
             // set cookie so that we are sure to set form factor correctly on next sessions
             $this->getResponse()->setCookie('form_factor', 'mobile', time() + 60 * 60 * 24 * 30);
         }
     }
     // redirect to referer
     return $this->redirect($this->getRequest()->getReferer());
 }
開發者ID:snouhaud,項目名稱:camptocamp.org,代碼行數:25,代碼來源:actions.class.php

示例3:

<?php

// this is the same process that occurs in FormFactorFilter for symfony
// adapted for the forums
if (!$sf_user->hasAttribute('form_factor')) {
    // if you make changes here, be sure also to check varnish and FormFactorFilter
    $cookie = $request->getCookie('form_factor');
    if ($cookie === 'mobile' || $cookie === null && c2cTools::mobileRegexp()) {
        $sf_user->setAttribute('form_factor', 'mobile');
    } else {
        $sf_user->setAttribute('form_factor', 'desktop');
    }
}
$mobile_version = c2cTools::mobileVersion();
開發者ID:snouhaud,項目名稱:camptocamp.org,代碼行數:14,代碼來源:symfony_formfactor.php


注:本文中的c2cTools::mobileRegexp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。