Exemple #1
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (Configure::read('unloadDebugKit') == true) {
         $this->Components->unload('DebugKit.Toolbar');
     }
     // language initialization
     $language_list = Configure::read('Config.languageList');
     $this->language = $language_list[Configure::read('Config.language')]['code'];
     if (isset($this->params['language'])) {
         foreach ($language_list as $locale => $language) {
             if ($language['active'] && $language['code'] == $this->params['language']) {
                 $this->language = $this->params['language'];
                 Configure::write('Config.language', $locale);
                 break;
             }
         }
     }
     // set language
     $this->set('language', $this->language);
     $this->set('language_list', $language_list);
     $this->Session->write('Config.language', $this->language);
     // Detect device
     $Mobile_Detect = new Mobile_Detect();
     $this->device_info = 'Desktop';
     $this->device_browser = '';
     $this->device_info_type = '';
     if ($Mobile_Detect->isTablet()) {
         $this->device_info = 'Tablet';
         if ($Mobile_Detect->isiPad()) {
             $this->device_info_type = 'Ipad';
         } else {
             if ($Mobile_Detect->isAndroidOS()) {
                 $this->device_info_type = 'Android';
             } else {
                 $this->device_info_type = 'others';
             }
         }
     } else {
         if ($Mobile_Detect->isMobile()) {
             $this->device_info = 'Mobile';
             if ($Mobile_Detect->isiPhone()) {
                 $this->device_info_type = 'Iphone';
             } else {
                 if ($Mobile_Detect->isAndroidOS()) {
                     $this->device_info_type = 'Android';
                 } else {
                     $this->device_info_type = 'others';
                 }
             }
         }
     }
     if ($Mobile_Detect->isChrome() && $Mobile_Detect->isSafari()) {
         $this->device_browser = 'AndroidDefault';
     } else {
         if ($Mobile_Detect->isChrome()) {
             $this->device_browser = 'Chrome';
         } else {
             if ($Mobile_Detect->isSafari()) {
                 $this->device_browser = 'Safari';
             } else {
                 if ($Mobile_Detect->isIE()) {
                     $this->device_browser = 'IE';
                 } else {
                     if ($Mobile_Detect->isFirefox()) {
                         $this->device_browser = 'Firefox';
                     } else {
                         if ($Mobile_Detect->isOpera()) {
                             $this->device_browser = 'Opera';
                         } else {
                             $this->device_browser = 'others';
                         }
                     }
                 }
             }
         }
     }
     $this->set('device_info', $this->device_info);
     $this->set('device_info_type', $this->device_info_type);
     $this->set('device_browser', $this->device_browser);
     //GA account
     $ga_account = Configure::read('ga_account');
     $this->set('ga_account', !empty($ga_account[$this->language]) ? $ga_account[$this->language] : '');
     //FB_appID
     $FB_appID = Configure::read('FB_appID');
     $this->set('FB_appID', $FB_appID);
 }
	/**
	 * Loads cookie and sets up theme filters.
	 */
	static function setup_theme() {
		global $wpdb;
		$tablemobility = $wpdb->prefix.'ult25_mobile';
		$browser = new Mobile_Detect;
		if($browser->isMobile()){
			if(isset($_REQUEST['theme'])): // click desktop
				self::set_theme_onclick();
			endif;
			self::load_cookie();
			if ( ! empty( self::$theme ) ) :
			add_filter( 'pre_option_template', array( self::$theme, 'get_template' ) );
			add_filter( 'pre_option_stylesheet', array( self::$theme, 'get_stylesheet' ) );
			add_filter( 'pre_option_stylesheet_root', array( self::$theme, 'get_theme_root' ) );
			
			$parent = self::$theme->parent();
			
			if( empty( $parent ) )
				add_filter( 'pre_option_template_root', array( self::$theme, 'get_theme_root' ) );
			else
				add_filter( 'pre_option_template_root', array( $parent, 'get_theme_root' ) );
			
			add_filter( 'pre_option_current_theme', '__return_false' );
			else:
			/*
			 * isAndroidOS()	bool(false)
			 * isBlackBerryOS()	bool(false)
			 * isPalmOS()	bool(false)
			 * isSymbianOS()	bool(false)
			 * isWindowsMobileOS()	bool(false)
			 * isWindowsPhoneOS()	bool(false)
			 * isiOS()	bool(false)
			 */
			$browsing = false;
			if($browser->isiPad()){
				$browsing = 'iPad';
			} elseif ($browser->isiPhone()){
				$browsing= 'iPhone';
			} elseif ($browser->isAndroidOS()){
				if($browser->isTablet()){
				$browsing = 'AndroidTablet';
				} else {
				$browsing = 'Android';
				}
			} elseif ($browser->isWindowsMobileOS() || $browser->isWindowsPhoneOS()){
				if($browser->isTablet()){
					$browsing = 'WindowsTablet';
				} else {
					$browsing = 'Windows';
				}
			} elseif ($browser->isBlackBerryOS()){
				$browsing = 'BlackBerry';
			}
			if($browsing){
			$mobilethemeq = "SELECT * FROM `".$tablemobility."` WHERE `device`='$browsing'";
			$mfetch=$wpdb->get_row($mobilethemeq);
			if($mfetch){
				$theme = wp_get_theme(  $mfetch->theme );
				
				if (
				$theme->exists()
				&& $theme->get( 'Name' ) != get_option( 'current_theme' )
				&& self::is_allowed( $theme )
				) {
					self::$theme = $theme;
					add_filter( 'pre_option_template', array( self::$theme, 'get_template' ) );
					add_filter( 'pre_option_stylesheet', array( self::$theme, 'get_stylesheet' ) );
					add_filter( 'pre_option_stylesheet_root', array( self::$theme, 'get_theme_root' ) );
					
					$parent = self::$theme->parent();
					
					if( empty( $parent ) )
						add_filter( 'pre_option_template_root', array( self::$theme, 'get_theme_root' ) );
					else
					add_filter( 'pre_option_template_root', array( $parent, 'get_theme_root' ) );
					add_filter( 'pre_option_current_theme', '__return_false' );
					add_action('ultimatum_meta', 'ultimatum_add_noscale_meta');
					add_action('ultimatum_meta', 'ultimatum_web_app_meta');
					if($mfetch->mpush==1){
						//add_action('ultimatum_meta', 'ultimatum_web_app_bubble');
						//add_action('ultimatum_before_body_close','ultimatum_web_app_link_hider');
					}
				}
				
			}
			}
			endif;
		}
		if ( self::can_switch_themes() ) {
			self::load_cookie();

			if ( ! empty( self::$theme ) ) {

				add_filter( 'pre_option_template', array( self::$theme, 'get_template' ) );
				add_filter( 'pre_option_stylesheet', array( self::$theme, 'get_stylesheet' ) );
				add_filter( 'pre_option_stylesheet_root', array( self::$theme, 'get_theme_root' ) );

				$parent = self::$theme->parent();

				if( empty( $parent ) )
					add_filter( 'pre_option_template_root', array( self::$theme, 'get_theme_root' ) );
				else
					add_filter( 'pre_option_template_root', array( $parent, 'get_theme_root' ) );

				add_filter( 'pre_option_current_theme', '__return_false' );
			}
		}
	}
        global $more;
        $more = 0;
        the_content('<div style="padding-top: 15px;"><button class="btn btn-info" style="float: right;" type="button">Read More</button></div>');
        ?>
</div>

				<?php 
    }
    ?>
	
				</div>
		</div>
	</div>
</div>
<?php 
    if ($detect->isMobile() || $detect->isTablet() || $detect->isiPhone() || $detect->isiOS()) {
        if (!get_previous_posts_link() || !get_next_posts_link()) {
            ?>
			
<div id="row-widget-header" class="navigation">
	<div id="sub-container">
		<div class="row" id="widgetrow" style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;">
			
			<?php 
            add_filter('next_posts_link_attributes', 'posts_link_next_class');
            function posts_link_next_class()
            {
                return 'class="btn btn-default custom btn-outline-inverse pull-right"';
            }
            add_filter('previous_posts_link_attributes', 'posts_link_prev_class');
            function posts_link_prev_class()
function get_device_name($userAgent)
{
    $detect = new Mobile_Detect();
    $detect->setUserAgent($userAgent);
    $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'cell' : 'computer';
    if ($deviceType == 'computer') {
        return $deviceType;
    }
    $name = 'unknow';
    do {
        if ($detect->isiPhone()) {
            $name = 'iPhone';
            break;
        }
        if ($detect->isBlackBerry()) {
            $name = 'BlackBerry';
            break;
        }
        if ($detect->isHTC()) {
            $name = 'HTC';
            break;
        }
        if ($detect->isNexus()) {
            $name = 'Nexus';
            break;
        }
        if ($detect->isDell()) {
            $name = 'Dell';
            break;
        }
        if ($detect->isMotorola()) {
            $name = 'Motorola';
            break;
        }
        if ($detect->isSamsung()) {
            $name = 'Samsung';
            break;
        }
        if ($detect->isLG()) {
            $name = 'LG';
            break;
        }
        if ($detect->isSony()) {
            $name = 'Sony';
            break;
        }
        if ($detect->isAsus()) {
            $name = 'Asus';
            break;
        }
        if ($detect->isPalm()) {
            $name = 'Palm';
            break;
        }
        if ($detect->isVertu()) {
            $name = 'Vertu';
            break;
        }
        if ($detect->isPantech()) {
            $name = 'Pantech';
            break;
        }
        if ($detect->isFly()) {
            $name = 'Fly';
            break;
        }
        if ($detect->isSimValley()) {
            $name = 'SimValley';
            break;
        }
        if ($detect->isGenericPhone()) {
            $name = 'Generic';
            break;
        }
        if ($detect->isiPad()) {
            $name = 'iPad';
            break;
        }
        if ($detect->isNexusTablet()) {
            $name = 'Nexus';
            break;
        }
        if ($detect->isSamsungTablet()) {
            $name = 'Samsung';
            break;
        }
        if ($detect->isKindle()) {
            $name = 'Kindle';
            break;
        }
        if ($detect->isSurfaceTablet()) {
            $name = 'Surface';
            break;
        }
        if ($detect->isAsusTablet()) {
            $name = 'Asus';
            break;
        }
        if ($detect->isBlackBerryTablet()) {
            $name = 'BlackBerry';
            break;
        }
        if ($detect->isHTCtablet()) {
            $name = 'HTC';
            break;
        }
        if ($detect->isMotorolaTablet()) {
            $name = 'Motorola';
            break;
        }
        if ($detect->isNookTablet()) {
            $name = 'Nook';
            break;
        }
        if ($detect->isAcerTablet()) {
            $name = 'Acer';
            break;
        }
        if ($detect->isToshibaTablet()) {
            $name = 'Toshiba';
            break;
        }
        if ($detect->isLGTablet()) {
            $name = 'LG';
            break;
        }
        if ($detect->isYarvikTablet()) {
            $name = 'Yarvik';
            break;
        }
        if ($detect->isMedionTablet()) {
            $name = 'Medion';
            break;
        }
        if ($detect->isArnovaTablet()) {
            $name = 'Arnova';
            break;
        }
        if ($detect->isArchosTablet()) {
            $name = 'Archos';
            break;
        }
        if ($detect->isAinolTablet()) {
            $name = 'Ainol';
            break;
        }
        if ($detect->isSonyTablet()) {
            $name = 'Sony';
            break;
        }
        if ($detect->isCubeTablet()) {
            $name = 'Cube';
            break;
        }
        if ($detect->isCobyTablet()) {
            $name = 'Coby';
            break;
        }
        if ($detect->isSMiTTablet()) {
            $name = 'SMiT';
            break;
        }
        if ($detect->isRockChipTablet()) {
            $name = 'RockChip';
            break;
        }
        if ($detect->isTelstraTablet()) {
            $name = 'Telstra';
            break;
        }
        if ($detect->isFlyTablet()) {
            $name = 'Fly';
            break;
        }
        if ($detect->isbqTablet()) {
            $name = 'bq';
            break;
        }
        if ($detect->isHuaweiTablet()) {
            $name = 'Huawei';
            break;
        }
        if ($detect->isNecTablet()) {
            $name = 'Nec';
            break;
        }
        if ($detect->isPantechTablet()) {
            $name = 'Pantech';
            break;
        }
        if ($detect->isBronchoTablet()) {
            $name = 'Broncho';
            break;
        }
        if ($detect->isVersusTablet()) {
            $name = 'Versus';
            break;
        }
        if ($detect->isZyncTablet()) {
            $name = 'Zync';
            break;
        }
        if ($detect->isPositivoTablet()) {
            $name = 'Positivo';
            break;
        }
        if ($detect->isNabiTablet()) {
            $name = 'Nabi';
            break;
        }
        if ($detect->isPlaystationTablet()) {
            $name = 'Playstation';
            break;
        }
        if ($detect->isGenericTablet()) {
            $name = 'Generic';
            break;
        }
        if ($detect->isAndroidOS()) {
            $name = 'Android';
            break;
        }
        if ($detect->isBlackBerryOS()) {
            $name = 'BlackBerry';
            break;
        }
        if ($detect->isPalmOS()) {
            $name = 'Plam';
            break;
        }
        if ($detect->isSymbianOS()) {
            $name = 'Symbian';
            break;
        }
        if ($detect->isWindowsMobileOS()) {
            $name = 'WindowsMobile';
            break;
        }
        if ($detect->isWindowsPhoneOS()) {
            $name = 'WindowsPhone';
            break;
        }
        if ($detect->isiOS()) {
            $name = 'iOS';
            break;
        }
        if ($detect->isMeeGoOS()) {
            $name = 'MeeGo';
            break;
        }
        if ($detect->isMaemoOS()) {
            $name = 'Maemo';
            break;
        }
        if ($detect->isJavaOS()) {
            $name = 'JavaOS';
            break;
        }
        if ($detect->iswebOS()) {
            $name = 'WebOS';
            break;
        }
        if ($detect->isbadaOS()) {
            $name = 'badaOS';
            break;
        }
        if ($detect->isBREWOS()) {
            $name = 'BREWOS';
            break;
        }
    } while (false);
    return $name . ' ' . $deviceType;
}