Ignore:
Timestamp:
2012/07/09 08:53:25 (12 years ago)
Author:
pineray
Message:

機種端末IDをスタティック変数に保持する.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/SC_Display.php

    r21925 r21962  
    130130 
    131131    /** 
    132      * 機種を判別する。 
     132     * Detect the viewing device. 
    133133     * 
    134      * SC_Display::MOBILE = ガラケー = 1 
    135      * SC_Display::SMARTPHONE = スマホ = 2 
     134     * SC_Display::MOBILE = k-tai = 1 
     135     * SC_Display::SMARTPHONE = smart phone = 2 
    136136     * SC_Display::PC = PC = 10 
    137137     * 
    138138     * @static 
    139      * @return integer 端末種別ID 
     139     * @param   $reset  boolean 
     140     * @return  integer Device Type ID 
    140141     */ 
    141     function detectDevice() { 
    142         $nu = new Net_UserAgent_Mobile(); 
    143         $su = new SC_SmartphoneUserAgent_Ex(); 
    144         if ($nu->isMobile()) { 
    145             return DEVICE_TYPE_MOBILE; 
    146         } elseif ($su->isSmartphone()) { 
    147             return DEVICE_TYPE_SMARTPHONE; 
    148         } else { 
    149             return DEVICE_TYPE_PC; 
     142    public static function detectDevice($reset = FALSE) { 
     143        if (empty(SC_Display_Ex::$device) || $reset) { 
     144            $nu = new Net_UserAgent_Mobile(); 
     145            $su = new SC_SmartphoneUserAgent_Ex(); 
     146            if ($nu->isMobile()) { 
     147                SC_Display_Ex::$device = DEVICE_TYPE_MOBILE; 
     148            } elseif ($su->isSmartphone()) { 
     149                SC_Display_Ex::$device = DEVICE_TYPE_SMARTPHONE; 
     150            } else { 
     151                SC_Display_Ex::$device = DEVICE_TYPE_PC; 
     152            } 
    150153        } 
     154        return SC_Display_Ex::$device; 
    151155    } 
    152156 
Note: See TracChangeset for help on using the changeset viewer.