当前位置: 首页>>代码示例>>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;未经允许,请勿转载。