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


PHP Mobile_Detect類代碼示例

本文整理匯總了PHP中Mobile_Detect的典型用法代碼示例。如果您正苦於以下問題:PHP Mobile_Detect類的具體用法?PHP Mobile_Detect怎麽用?PHP Mobile_Detect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: is_mobile_lib_mobile_detect

 /**
  * @return bool
  */
 private function is_mobile_lib_mobile_detect()
 {
     if (!class_exists('Mobile_Detect')) {
         require_once dirname(__FILE__) . '/Mobile/lib/Mobile-Detect-2.8.13/Mobile_Detect.php';
     }
     $detector = new Mobile_Detect();
     return $detector->isMobile();
 }
開發者ID:firatkarakusoglu,項目名稱:feedback-cat,代碼行數:11,代碼來源:Mobile.php

示例2: initLayoutType

function initLayoutType()
{
    // Safety check.
    if (!class_exists('Mobile_Detect')) {
        return 'classic';
    }
    $detect = new Mobile_Detect();
    $isMobile = $detect->isMobile();
    $isTablet = $detect->isTablet();
    $layoutTypes = layoutTypes();
    // Set the layout type.
    if (isset($_GET['layoutType'])) {
        $layoutType = $_GET['layoutType'];
    } else {
        if (empty($_SESSION['layoutType'])) {
            $layoutType = $isMobile ? $isTablet ? 'tablet' : 'mobile' : 'classic';
        } else {
            $layoutType = $_SESSION['layoutType'];
        }
    }
    // Fallback. If everything fails choose classic layout.
    if (!in_array($layoutType, $layoutTypes)) {
        $layoutType = 'classic';
    }
    // Store the layout type for future use.
    $_SESSION['layoutType'] = $layoutType;
    return $layoutType;
}
開發者ID:burak-tekin,項目名稱:Mobile-Detect,代碼行數:28,代碼來源:session_example.php

示例3: ts_theme_setup

function ts_theme_setup()
{
    /* Add editor-style.css file*/
    add_editor_style();
    /* Add Theme Support */
    add_theme_support('post-formats', array('audio', 'gallery', 'quote', 'video'));
    add_theme_support('post-thumbnails');
    add_theme_support('automatic-feed-links');
    add_theme_support('title-tag');
    $defaults = array('default-color' => '', 'default-image' => '');
    add_theme_support('custom-background', $defaults);
    add_theme_support('woocommerce');
    if (!isset($content_width)) {
        $content_width = 1200;
    }
    /* Translation */
    load_theme_textdomain('gon', get_template_directory() . '/languages');
    $locale = get_locale();
    $locale_file = get_template_directory() . "/languages/{$locale}.php";
    if (is_readable($locale_file)) {
        require_once $locale_file;
    }
    /* Register Menu Location */
    register_nav_menus(array('primary' => esc_html__('Primary Navigation', 'gon')));
    register_nav_menus(array('vertical' => esc_html__('Vertical Navigation', 'gon')));
    register_nav_menus(array('mobile' => esc_html__('Mobile Navigation', 'gon')));
    /* Mobile Detect */
    if (class_exists('Mobile_Detect')) {
        $detect = new Mobile_Detect();
        $_is_tablet = $detect->isTablet();
        $_is_mobile = $detect->isMobile() && !$_is_tablet;
        define('TS_IS_MOBILE', $_is_mobile);
        define('TS_IS_TABLET', $_is_tablet);
    }
}
開發者ID:ericsoncardosoweb,項目名稱:dallia,代碼行數:35,代碼來源:theme_functions.php

示例4: getMobileOs

 public static function getMobileOs()
 {
     $deviceOs = "";
     if (isset($_SERVER['AMF_DEVICE_OS'])) {
         // APACHE MOBILE FILTER IS INSTALLED
         $deviceOs = $_SERVER['AMF_DEVICE_OS'];
         if (stripos($deviceOs, "iphone") !== false) {
             $deviceOs = "IOS";
         } else {
             if (stripos($deviceOs, "android") !== false) {
                 $deviceOs = "ANDROIDOS";
             }
         }
     } else {
         $detect = new Mobile_Detect();
         if ($detect->isiOS()) {
             $deviceOs = "IOS";
         } else {
             if ($detect->isAndroidOS()) {
                 $deviceOs = "ANDROIDOS";
             }
         }
     }
     return $deviceOs;
 }
開發者ID:giangnh264,項目名稱:mobileplus,代碼行數:25,代碼來源:MobileDevice.php

示例5: pow_off

function pow_off()
{
    if (false == POW_OFF) {
        pow_actions();
        return;
    }
    if (!class_exists('Mobile_Detect')) {
        include dirname(__FILE__) . '/lib/Mobile_Detect.php';
    }
    $detect = new Mobile_Detect();
    switch (POW_OFF) {
        case "phone":
            if ($detect->isMobile() && !$detect->isTablet()) {
                return;
            }
            break;
        case "tablet":
            if ($detect->isTablet()) {
                return;
            }
            break;
        case "mobile":
            if ($detect->isMobile()) {
                return;
            }
            break;
    }
    pow_actions();
}
開發者ID:puppy09,項目名稱:madC,代碼行數:29,代碼來源:pullouts.php

示例6: executeIndex

 public function executeIndex(HTTPRequest $request)
 {
     $detect = new \Mobile_Detect();
     $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
     $ua = $detect->getUserAgents();
     $this->page->addVar('deviceType', $deviceType);
 }
開發者ID:eneel87,項目名稱:formation,代碼行數:7,代碼來源:DeviceController.php

示例7: isSmartphone

 /**
  * スマートフォンかどうかを判別する。
  * $_SESSION['pc_disp'] = true の場合はPC表示。
  *
  * @return boolean
  */
 public function isSmartphone()
 {
     $detect = new \Mobile_Detect();
     // SPでかつPC表示OFFの場合
     // TabletはPC扱い
     return $detect->isMobile() && !$detect->isTablet() && !static::getSmartphonePcFlag();
 }
開發者ID:ChigusaYasoda,項目名稱:ec-cube,代碼行數:13,代碼來源:SmartphoneUserAgent.php

示例8: parse_carousel

function parse_carousel($atts, $content, $id)
{
    wp_enqueue_style('ui-custom-theme');
    wp_enqueue_script('jquery-ui-accordion');
    $id = rand();
    $output = '';
    if (class_exists('Mobile_Detect')) {
        $detect = new Mobile_Detect();
        $_device_ = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'mobile' : 'pc';
        if (isset($atts['animation'])) {
            $animation_class = $atts['animation'] && $_device_ == 'pc' ? 'wpb_' . $atts['animation'] . ' wpb_animate_when_almost_visible' : '';
        }
    } else {
        if (isset($atts['animation'])) {
            $animation_class = $atts['animation'] ? 'wpb_' . $atts['animation'] . ' wpb_animate_when_almost_visible' : '';
        }
    }
    str_replace("[Carousel_item", "", $content, $i);
    $output .= "\n\t" . '<div class="is-carousel simple-carousel testimonial car-style" id="post-gallery' . $id . '">';
    $output .= "\n\t\t" . '<div class="simple-carousel-content carousel-content">';
    $output .= do_shortcode(str_replace('<br class="nc" />', '', $content));
    $output .= "\n\t\t" . '</div>';
    $output .= "\n\t\t" . '<div class="carousel-pagination"></div>';
    $output .= "\n\t" . '</div>';
    return $output;
}
開發者ID:aljeicks,項目名稱:streamtube,代碼行數:26,代碼來源:carousel.php

示例9: enableNativeMobile

 public function enableNativeMobile()
 {
     $md = new \Mobile_Detect();
     if ($md->isMobile()) {
         $this->addHeaderItem('<meta name="viewport" content="width=device-width,initial-scale=1"/>');
     }
 }
開發者ID:meixelsberger,項目名稱:concrete5-5.7.0,代碼行數:7,代碼來源:DashboardPageController.php

示例10: isSmartphone

 /**
  * スマートフォンかどうかを判別する。
  * $_SESSION['pc_disp'] = true の場合はPC表示。
  *
  * @return boolean
  */
 public function isSmartphone()
 {
     $detect = new Mobile_Detect();
     // SPでかつPC表示OFFの場合
     // TabletはPC扱い
     return $detect->isMobile() && !$detect->isTablet() && !SC_SmartphoneUserAgent_Ex::getSmartphonePcFlag();
 }
開發者ID:ryoogata,項目名稱:eccube-SQLAzureSupport-plugin,代碼行數:13,代碼來源:SC_SmartphoneUserAgent.php

示例11: presscore_sc_cachedata_filter

/**
 * Replace main.js with platform dependent scripts. God! Please, make it work!
 *
 */
function presscore_sc_cachedata_filter(&$cachedata)
{
    if (!class_exists('Mobile_Detect')) {
        include get_template_directory() . '/inc/extensions/mobile-detect.php';
    }
    $detect = new Mobile_Detect();
    $device_type = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
    $stylesheet = get_template_directory_uri();
    $dynamic_scripts = array('desktop-tablet' => '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/desktop-tablet.js\'></script>', 'phone' => '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/phone.js\'></script>', 'desktop' => '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/desktop.js\'></script>');
    $main = '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/main.js\'></script>';
    $output = '';
    // enqueue device specific scripts
    switch ($device_type) {
        case 'tablet':
            $output .= $dynamic_scripts['desktop-tablet'];
            break;
        case 'phone':
            $output .= $dynamic_scripts['phone'];
            break;
        default:
            $output .= $dynamic_scripts['desktop-tablet'];
            $output .= $dynamic_scripts['desktop'];
    }
    $output .= $main;
    // remove cached scripts
    $cachedata = str_replace(array_values($dynamic_scripts), '', $cachedata);
    return str_replace($main, $output, $cachedata);
}
開發者ID:RDePoppe,項目名稱:luminaterealestate,代碼行數:32,代碼來源:mod-supercache.php

示例12: lfGetRanking

 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 public function lfGetRanking()
 {
     $arrRecommends = parent::lfGetRanking();
     $detect = new Mobile_Detect();
     $cur_category_id = 0;
     if ($detect->is("AndroidOS")) {
         $cur_category_id = 1;
     } elseif ($detect->is("iOS")) {
         $cur_category_id = 2;
     } else {
         return array();
     }
     $response = array();
     if (count($arrRecommends) > 0) {
         $objProduct = new SC_Product_Ex();
         foreach ($arrRecommends as $value) {
             $product_id = $value['product_id'];
             $category_id = $objProduct->getCategoryIds($product_id);
             if (in_array($cur_category_id, $category_id)) {
                 // nop
                 $response[] = $value;
             }
         }
     }
     return $response;
 }
開發者ID:alice-asahina,項目名稱:kisekae_touch,代碼行數:31,代碼來源:LC_Page_FrontParts_Bloc_Recommend_Ex.php

示例13: beforeExecuteRoute

 public function beforeExecuteRoute($event)
 {
     $dispatcher = $event->getSource();
     $config = $dispatcher->getDI()->getConfig();
     if (!$config->wscn->mobileRedirect) {
         return true;
     }
     $cookie = $dispatcher->getDI()->getCookies();
     //Disabled redirect from cookie
     if ($cookie->has($config->wscn->mobileRedirectCookieName)) {
         return true;
     }
     $detect = new \Mobile_Detect();
     if ($detect->isMobile()) {
         $controller = $dispatcher->getActiveController();
         $controllerClass = get_class($controller);
         $mobileControllerClass = str_replace('Wscn', 'WscnMobile', $controllerClass);
         $path = $dispatcher->getDI()->getRequest()->getURI();
         if (!class_exists($mobileControllerClass)) {
             $path = '/';
         }
         $mobileDomain = $config->wscn->mobileDomain;
         $redirectTo = "http://{$mobileDomain}{$path}";
         return $dispatcher->getDI()->getResponse()->redirect($redirectTo);
     }
 }
開發者ID:skybird,項目名稱:phalcon,代碼行數:26,代碼來源:DispatchListener.php

示例14: createStore

 public function createStore()
 {
     $this->load->dbforge();
     $this->load->helper('file_helper');
     $this->load->helper('Mobile_Detect_helper');
     $this->load->helper('create_db_helper');
     $detect = new Mobile_Detect();
     $deviceName = "";
     if ($detect->isMobile()) {
         $deviceName = "mobile";
     } else {
         if ($detect->isTablet()) {
             $deviceName = "tablet";
         } else {
             $deviceName = "pc";
         }
     }
     $post = $this->input->post();
     $clientInfo = $post["clientInfo"];
     $userId = $this->session->userdata("userid");
     $databaseObj = $this->template->getTemplateName($post["key"]);
     $resultObj = $databaseObj->result()[0];
     $projectName = $resultObj->TemplateProjectName;
     $projectImage = $resultObj->TemplateImage;
     recursive_copy("assets/template/" . $projectName, "../" . $post["domainName"]);
     copy("assets/images/screen-shot/" . $projectImage, "assets/images/screen-shot/" . $post["domainName"] . ".jpg");
     $databaseObj->next_result();
     $databaseObj = $this->template->createStore($post["storeName"], $post["domainName"], $userId, $post["key"], $clientInfo["appCodeName"], $clientInfo["appVersion"], $this->input->ip_address(), $deviceName, $clientInfo["platform"]);
     $newStore = $databaseObj->result()[0];
     $databaseObj->next_result();
     execSql($newStore->TemplateType, $post["domainName"], get_instance());
 }
開發者ID:silvranz,項目名稱:ovs,代碼行數:32,代碼來源:Template.php

示例15: actu

 function actu($id_actu)
 {
     $this->load->helper('url');
     $detect = new Mobile_Detect();
     $this->load->model('Menus');
     $this->load->model('Actualites');
     $data['menu'] = $this->Menus->pages_menu();
     $data['content'] = $this->Actualites->affiche_actu($id_actu);
     $data['cat'] = $this->Actualites->get_cat($data['content'][0]->id_cat);
     $data['cat'] = $data['cat'][0]->categorie;
     $data['path_img'] = 'actus';
     $data['footer'] = $this->Menus->menu_footer();
     // Liens du pied de page
     $data['dlfooter'] = $this->Menus->dl_footer();
     // Liens de téléchargement du pied de page
     $this->load->view('header', $data);
     //        $this->load->view('breadcrumb');
     if ($detect->isMobile()) {
         $this->load->view('m_actualite', $data);
     } else {
         $this->load->view('actualite', $data);
         $this->load->view('social');
     }
     $this->load->view('footer', $data);
 }
開發者ID:fsingler,項目名稱:pdc,代碼行數:25,代碼來源:actus.php


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