コード例 #1
0
ファイル: html.class.php プロジェクト: salomalo/php-oxygen
 /**
  * Get <html> tag css classes with browser name and version
  * @return string 
  */
 private function _getHtmlClass()
 {
     $userAgent = UserAgent::getInstance();
     $browser = strtolower($userAgent->getBrowser());
     preg_match('#^([0-9]*)[\\.]?#', $userAgent->getBrowserVersion(), $matches);
     return $browser . ' ' . $browser . $matches[1];
 }
コード例 #2
0
ファイル: Request.php プロジェクト: jhouie/melyssaframework
 public function __construct()
 {
     self::$instance =& $this;
     // Classe de user agent:
     $this->userAgentParser =& UserAgent::getInstance();
     // Definindo o tipo de requisição:
     $this->setRequestMethod();
     // Definindo a página anterior do site:
     $this->setReferrer();
     // Definindo a uri (tudo que existe depois do domínio da aplicação)
     $this->setUri();
     // Setando os parâmetros dentro do array de segmentos, aí ainda temos a uri normal guardada !
     $this->explodeSegments();
     // Setando os parâmetros da url (diferente dos segmentos, retiramos o controller e a action, saca?) xD;
     $this->setUrlParams($this->segments);
 }
コード例 #3
0
 public function get_ua_strategy()
 {
     $arrRes = array('type' => '', 'tpl' => '', 'name' => '', 'rollback_name' => '');
     if (empty($this->_ua_string)) {
         return $arrRes;
     }
     // 全部UA适配策略配置
     $adaptions = Bd_Conf::getConf('tpl_uaadaptation/TEMPLATE_UA_ADAPTATION');
     if (empty($adaptions)) {
         return $arrRes;
     }
     $obj = UserAgent::getInstance(VUI_CONF_PATH . '/' . 'ualist_exact');
     // 获取下全部的UA字段,包括厂商、机型、操作系统、系统版本号、浏览器、浏览器版本号等等
     $arrFields = $obj->getFieldsFromUA($this->_ua_string);
     // 未查到相关字段,不做任何处理
     if (empty($arrFields) || !is_array($arrFields)) {
         return $arrRes;
     }
     // 遍历适配规则,应用命中的策略
     foreach ($adaptions as $perAdapt) {
         if (empty($perAdapt['rule']) || !is_array($perAdapt['rule'])) {
             continue;
         }
         $bHint = true;
         // rule中的字段均是UA所要强制匹配上的
         foreach ($perAdapt['rule'] as $key => $pattern) {
             if (!preg_match('/' . $pattern . '/', $arrFields[$key])) {
                 $bHint = false;
             }
         }
         if (!$bHint) {
             continue;
         }
         // 适配策略的应用目前包括模板类型(baidu/baiduhd)、模板名(page.2.0.tpl)、退化模板名(page.tpl)
         $arrRes['type'] = isset($perAdapt['strategy']['type']) ? trim($perAdapt['strategy']['type']) : '';
         $arrRes['tpl'] = isset($perAdapt['strategy']['tpl']) ? trim($perAdapt['strategy']['tpl']) : '';
         $arrRes['none_tpl'] = isset($perAdapt['strategy']['none_tpl']) ? trim($perAdapt['strategy']['none_tpl']) : '';
         $arrRes['rollback_name'] = isset($perAdapt['strategy']['rollback_name']) ? trim($perAdapt['strategy']['rollback_name']) : '';
         $arrRes['rollback_none_name'] = isset($perAdapt['strategy']['rollback_none_name']) ? trim($perAdapt['strategy']['rollback_none_name']) : '';
         $arrRes['name'] = isset($perAdapt['strategy']['name']) ? trim($perAdapt['strategy']['name']) : '';
         break;
     }
     return $arrRes;
 }
コード例 #4
0
 /**
  * Criação do elemento de paginação completo:
  *
  * @access private
  */
 private function createLinks()
 {
     $pages = '';
     //Pegando o total de páginas:
     if ($this->totalPages > 1) {
         $pages .= $this->openContainer;
         // Criando link para a primeira página:
         $pages .= $this->makeFirstLink();
         // Criando link para a página anterior:
         $pages .= $this->makePrevLink();
         // Criando paginação estilo google:
         // Setando o máximo de páginas conforme o tipo de dispositivo:
         $user =& UserAgent::getInstance();
         if ($user->isMobile()) {
             $totalToShow = 6;
         } else {
             $totalToShow = 8;
         }
         for ($i = $this->actualPage - 4, $limLinks = $i + $totalToShow; $i <= $limLinks; $i++) {
             if ($i < 1) {
                 $i = 1;
                 $limLinks = 9;
             }
             if ($limLinks > $this->totalPages) {
                 $limLinks = $this->totalPages;
                 $i = $limLinks - $totalToShow;
             }
             if ($i < 1) {
                 $i = 1;
                 $limLinks = $this->totalPages;
             }
             if ($i == $this->actualPage) {
                 $pages .= $this->makeActualPage();
             } else {
                 $pages .= $this->makeLink($i);
             }
         }
         // Criando link para a próxima página:
         $pages .= $this->makeNextLink();
         // Criando link para a última página:
         $pages .= $this->makeLastLink();
         $pages .= $this->closeContainer;
     }
     return $pages;
 }