本文整理汇总了PHP中IsMobile函数的典型用法代码示例。如果您正苦于以下问题:PHP IsMobile函数的具体用法?PHP IsMobile怎么用?PHP IsMobile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsMobile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Gdn_Dispatcher_AfterAnalyzeRequest_Handler
public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender)
{
// Remove plugins so they don't mess up layout or functionality.
if (in_array($Sender->Application(), array('vanilla', 'conversations')) && IsMobile() || $Sender->Application() == 'dashboard' && in_array($Sender->Controller(), array('Activity', 'Profile', 'Search'))) {
Gdn::PluginManager()->RemoveMobileUnfriendlyPlugins();
}
SaveToConfig('Garden.Format.EmbedSize', '240x135', FALSE);
}
示例2: AttachModule
/**
* Main function that
* 1. adds CSS file to controller
* 2. adds new categories module
*/
private function AttachModule($Sender)
{
if (IsMobile()) {
return;
} else {
include_once PATH_PLUGINS . DS . 'CategoriesModulePlus' . DS . 'modules' . DS . 'class.categoriesmoduleplusmodule.php';
// ApplicationFolder is needed for rendering the view
$ApplicationFolder = 'plugins/CategoriesModulePlus';
$Sender->AddCssFile('categoriesmoduleplus.css', $ApplicationFolder);
$CategoriesModulePlusModule = new CategoriesModulePlusModule($Sender, $ApplicationFolder);
// add module to the panel
$Sender->AddModule($CategoriesModulePlusModule);
}
}
示例3: Index
/**
* Loads default page view.
*
* @param string $PageUrlCode ; Unique page URL stub identifier.
*/
public function Index($PageUrlCode = '')
{
$this->Page = $this->PageModel->GetByUrlCode($PageUrlCode);
// Require the custom view permission if it exists.
// Otherwise, the page is public by default.
$ViewPermissionName = 'BasicPages.' . $PageUrlCode . '.View';
if (array_key_exists($ViewPermissionName, Gdn::PermissionModel()->PermissionColumns())) {
$this->Permission($ViewPermissionName);
}
// If page doesn't exist.
if ($this->Page == null) {
throw new Exception(sprintf(T('%s Not Found'), T('Page')), 404);
return null;
}
$this->SetData('Page', $this->Page, false);
// Add body CSS class.
$this->CssClass = 'Page-' . $this->Page->UrlCode;
if (IsMobile()) {
$this->CssClass .= ' PageMobile';
}
// Set the canonical URL to have the proper page link.
$this->CanonicalUrl(PageModel::PageUrl($this->Page));
// Add modules
$this->AddModule('GuestModule');
$this->AddModule('SignedInModule');
// Add CSS files
$this->AddCssFile('page.css');
$this->AddModule('NewDiscussionModule');
$this->AddModule('DiscussionFilterModule');
$this->AddModule('BookmarkedModule');
$this->AddModule('DiscussionsModule');
$this->AddModule('RecentActivityModule');
// Setup head.
if (!$this->Data('Title')) {
$Title = C('Garden.HomepageTitle');
$DefaultControllerDestination = Gdn::Router()->GetDestination('DefaultController');
if ($Title != '' && strpos($DefaultControllerDestination, 'page/' . $this->Page->UrlCode) !== false) {
// If the page is set as DefaultController.
$this->Title($Title, '');
// Add description meta tag.
$this->Description(C('Garden.Description', null));
} else {
// If the page is NOT the DefaultController.
$this->Title($this->Page->Name);
// Add description meta tag.
$this->Description(SliceParagraph(Gdn_Format::PlainText($this->Page->Body, $this->Page->Format), 160));
}
}
$this->Render();
}
示例4: Base_Render_Before
/**
* Add mobile meta info. Add script to hide iphone browser bar on pageload.
*/
public function Base_Render_Before($Sender)
{
if (IsMobile() && is_object($Sender->Head)) {
$Sender->Head->AddTag('meta', array('name' => 'viewport', 'content' => "width=device-width,minimum-scale=1.0,maximum-scale=1.0"));
$Sender->Head->AddString('<script type="text/javascript">
// If not looking for a specific comment, hide the address bar in iphone
var hash = window.location.href.split("#")[1];
if (typeof(hash) == "undefined") {
setTimeout(function () {
window.scrollTo(0, 1);
}, 1000);
}
</script>');
}
}
示例5: connectButton
public static function connectButton($Provider, $Options = array())
{
if (!is_array($Provider)) {
$Provider = self::getProvider($Provider);
}
$Url = htmlspecialchars(self::connectUrl($Provider));
$Data = $Provider;
$Target = Gdn::Request()->Get('Target');
if (!$Target) {
$Target = '/' . ltrim(Gdn::Request()->Path());
}
if (StringBeginsWith($Target, '/entry/signin')) {
$Target = '/';
}
$ConnectQuery = array('client_id' => $Provider['AuthenticationKey'], 'Target' => $Target);
$Data['Target'] = urlencode(Url('entry/jsconnect', TRUE) . '?' . http_build_query($ConnectQuery));
$Data['Redirect'] = $Data['target'] = $Data['redirect'] = $Data['Target'];
$SignInUrl = FormatString(GetValue('SignInUrl', $Provider, ''), $Data);
$RegisterUrl = FormatString(GetValue('RegisterUrl', $Provider, ''), $Data);
if ($RegisterUrl && !GetValue('NoRegister', $Options)) {
$RegisterLink = ' ' . Anchor(sprintf(T('Register with %s', 'Register'), $Provider['Name']), $RegisterUrl, 'Button RegisterLink');
} else {
$RegisterLink = '';
}
if (IsMobile()) {
$PopupWindow = '';
} else {
$PopupWindow = 'PopupWindow';
}
if (GetValue('NoConnectLabel', $Options)) {
$ConnectLabel = '';
} else {
$ConnectLabel = '<span class="Username"></span><div class="ConnectLabel TextColor">' . sprintf(T('Sign In with %s'), $Provider['Name']) . '</div>';
}
if (!C('Plugins.JsConnect.NoGuestCheck')) {
$Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="' . $Url . '">';
if (!GetValue('IsDefault', $Provider)) {
$Result .= '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
}
$Result .= '<div class="JsConnect-Connect"><a class="ConnectLink">' . Img('https://cd8ba0b44a15c10065fd-24461f391e20b7336331d5789078af53.ssl.cf1.rackcdn.com/images/usericon_50.png', array('class' => 'ProfilePhotoSmall UserPhoto')) . $ConnectLabel . '</a></div>';
$Result .= '</div>';
} else {
if (!GetValue('IsDefault', $Provider)) {
$Result = '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
}
}
return $Result;
}
示例6: Base_Render_Before
public function Base_Render_Before($Sender)
{
$InDashboard = !($Sender->MasterView == 'default' || $Sender->MasterView == '');
$Sender->AddJsFile('plugins/embedvanilla/local.js');
// Record the remote source using the embed feature.
$RemoteUrl = C('Plugins.EmbedVanilla.RemoteUrl');
if (!$RemoteUrl) {
$RemoteUrl = GetIncomingValue('remote');
if ($RemoteUrl) {
SaveToConfig('Plugins.EmbedVanilla.RemoteUrl', $RemoteUrl);
}
}
// Report the remote url to redirect to if not currently embedded.
$Sender->AddDefinition('RemoteUrl', $RemoteUrl);
if (!IsSearchEngine() && !$InDashboard && !IsMobile() && C('Plugins.EmbedVanilla.ForceRemoteUrl')) {
$Sender->AddDefinition('ForceRemoteUrl', TRUE);
}
$Sender->AddDefinition('Path', Gdn::Request()->Path());
if ($InDashboard) {
$Sender->AddDefinition('InDashboard', C('Plugins.EmbedVanilla.EmbedDashboard'));
}
}
示例7: Rack
public function Rack()
{
header('Content-Type: application/json; charset=utf-8');
date_default_timezone_set('America/Montreal');
$keys = array('REQUEST_METHOD', 'SCRIPT_NAME', 'PATH_INFO', 'SERVER_NAME', 'SERVER_PORT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_ACCEPT_CHARSET', 'HTTP_USER_AGENT', 'HTTP_REMOTE_ADDR');
$rack = array_intersect_key($_SERVER, array_fill_keys($keys, true));
ksort($rack);
// Extract the headers from $_SERVER.
$headers = array();
foreach ($_SERVER as $key => $value) {
$key = strtoupper($key);
if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$specialHeaders)) {
if ($key === 'HTTP_CONTENT_TYPE' || $key === 'HTTP_CONTENT_LENGTH') {
continue;
}
$headers[$key] = $value;
}
}
ksort($headers);
$result = array('rack' => $rack, 'headers' => $headers, 'get' => $_GET, 'cookie' => $_COOKIE, 'mobile' => array('userAgentType' => userAgentType(), 'isMobile' => IsMobile()));
echo json_encode($result);
}
示例8: currentTheme
/**
*
*
* @return mixed
*/
public function currentTheme()
{
if (IsMobile()) {
if ($this->hasMobilePreview()) {
return $this->getMobilePreview();
}
return c('Garden.MobileTheme', 'default');
} else {
if ($this->hasPreview()) {
return $this->getPreview();
}
return c('Garden.Theme', 'default');
}
}
示例9: DefaultFormat
/**
* Return the default input formatter.
*
* @param bool|null $is_mobile Whether or not you want the format for mobile browsers.
* @return string
*/
public static function DefaultFormat($is_mobile = NULL)
{
if ($is_mobile === true || $is_mobile === null && IsMobile()) {
return C('Garden.MobileInputFormatter', C('Garden.InputFormatter', 'Html'));
} else {
return C('Garden.InputFormatter', 'Html');
}
}
示例10: check_format
/**
*
* 检测数据输入是否正确
*/
private function check_format($type, $val)
{
if ($type == 'phone') {
$is_error = true;
if (is_string($val) || is_numeric($val)) {
if (IsTel($val) || IsMobile($val)) {
$is_error = false;
} elseif (empty($val)) {
$is_error = false;
}
}
if ($is_error) {
$this->errorOutput('您输入的电话号码或者手机号码格式错误');
}
}
}
示例11: session_save_path
require_once PHPMYWIND_INC . '/mysql.class.php';
}
//引入语言包
//Session保存路径
$sess_savepath = PHPMYWIND_DATA . '/sessions/';
if (is_writable($sess_savepath) && is_readable($sess_savepath)) {
session_save_path($sess_savepath);
}
//上传文件保存路径
$cfg_image_dir = PHPMYWIND_UPLOAD . '/image';
$cfg_soft_dir = PHPMYWIND_UPLOAD . '/soft';
$cfg_media_dir = PHPMYWIND_UPLOAD . '/media';
//系统版本号
$cfg_vernum = '5.3 Beta';
$cfg_vertime = '20150913221909';
//设置默认时区
if (PHP_VERSION > '5.1') {
$time51 = $cfg_timezone * -1;
@date_default_timezone_set('Etc/GMT' . $time51);
}
//判断是否开启错误提示
if ($cfg_diserror == 'Y') {
error_reporting(E_ALL);
} else {
error_reporting(0);
}
//判断访问设备
//如果手动更改后台目录,请将/admin目录更改成新后台目录
if (IsMobile() && !strstr(GetCurUrl(), '4g.php') && $cfg_mobile == 'Y' && !strstr(GetCurUrl(), '/admin')) {
header('location:4g.php');
}
示例12: CanRender
/** Whether or not this pocket should be processed based on its state.
*
* @Param array $Data Data specific to the request.
* @return bool
*/
public function CanRender($Data)
{
if (!$this->ShowInDashboard && InSection('Dashboard')) {
return FALSE;
}
$IsMobile = IsMobile();
if ($this->MobileOnly && !$IsMobile || $this->MobileNever && $IsMobile) {
return FALSE;
}
if ($this->IsAd() && Gdn::Session()->CheckPermission('Garden.NoAds.Allow')) {
return FALSE;
}
if ($this->EmbeddedNever && strcasecmp(Gdn::Controller()->RequestMethod, 'embed') == 0) {
return FALSE;
}
// Check to see if the pocket is enabled.
switch ($this->Disabled) {
case Pocket::DISABLED:
return FALSE;
case Pocket::TESTING:
if (!Gdn::Session()->CheckPermission('Plugins.Pockets.Manage')) {
return FALSE;
}
break;
}
// Check to see if the page matches.
if ($this->Page && strcasecmp($this->Page, GetValue('PageName', $Data)) != 0) {
return FALSE;
}
// Check to see if this is repeating.
$Count = GetValue('Count', $Data);
if ($Count) {
switch ($this->RepeatType) {
case Pocket::REPEAT_AFTER:
if (strcasecmp($Count, Pocket::REPEAT_AFTER) != 0) {
return FALSE;
}
break;
case Pocket::REPEAT_BEFORE:
if (strcasecmp($Count, Pocket::REPEAT_BEFORE) != 0) {
return FALSE;
}
break;
case Pocket::REPEAT_ONCE:
if ($Count != 1) {
return FALSE;
}
break;
case Pocket::REPEAT_EVERY:
$Frequency = (array) $this->RepeatFrequency;
$Every = GetValue(0, $Frequency, 1);
if ($Every < 1) {
$Every = 1;
}
$Begin = GetValue(1, $Frequency, 1);
if ($Count % $Every != $Begin % $Every) {
return FALSE;
}
break;
case Pocket::REPEAT_INDEX:
if (!in_array($Count, (array) $this->RepeatFrequency)) {
return FALSE;
}
break;
}
}
// If we've passed all of the tests then the pocket can be processed.
return TRUE;
}
示例13: unset
// Include the application's bootstrap.
$Gdn_Path = PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'bootstrap.php';
if (file_exists($Gdn_Path)) {
include_once $Gdn_Path;
}
// Include the application's hooks.
$Hooks_Path = PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'class.hooks.php';
if (file_exists($Hooks_Path)) {
include_once $Hooks_Path;
}
}
unset($Gdn_EnabledApplications);
unset($Gdn_Path);
unset($Hooks_Path);
// If there is a hooks file in the theme folder, include it.
$ThemeName = C(!IsMobile() ? 'Garden.Theme' : 'Garden.MobileTheme', 'default');
$ThemeHooks = PATH_THEMES . DS . $ThemeName . DS . 'class.' . strtolower($ThemeName) . 'themehooks.php';
if (file_exists($ThemeHooks)) {
include_once $ThemeHooks;
}
// Set up the plugin manager (doing this early so it has fewer classes to
// examine to determine if they are plugins).
Gdn::FactoryInstall(Gdn::AliasPluginManager, 'Gdn_PluginManager', PATH_LIBRARY . DS . 'core' . DS . 'class.pluginmanager.php', Gdn::FactorySingleton);
Gdn::PluginManager()->IncludePlugins();
Gdn::PluginManager()->RegisterPlugins();
Gdn::FactoryOverwrite($FactoryOverwriteBak);
unset($FactoryOverwriteBak);
Gdn::Authenticator()->StartAuthenticator();
/// Include a user-defined bootstrap.
if (file_exists(PATH_ROOT . DS . 'conf' . DS . 'bootstrap.after.php')) {
require_once PATH_ROOT . DS . 'conf' . DS . 'bootstrap.after.php';
示例14: Theme
function Theme()
{
return C(!IsMobile() ? 'Garden.Theme' : 'Garden.MobileTheme', 'default');
}
示例15: Resources
private function Resources($Sender)
{
if (!$this->Enabled()) {
return;
}
$Sender->AddDefinition('InfiniteScroll.HideHead', C('InfiniteScroll.HideHead', true));
$Sender->AddDefinition('InfiniteScroll.Treshold', (int) C('InfiniteScroll.Treshold', 200));
$Sender->AddDefinition('InfiniteScroll.Hotkey', C('InfiniteScroll.Hotkey', 'j'));
$Sender->AddDefinition('InfiniteScroll.NavStyle', (int) C('InfiniteScroll.NavStyle', 0));
$Sender->AddDefinition('InfiniteScroll.ProgressBg', C('InfiniteScroll.ProgressColor', '#38abe3'));
$Sender->AddDefinition('InfiniteScroll.Mobile', IsMobile());
//$Sender->AddJsFile('nanobar.min.js', 'plugins/InfiniteScroll');
//$Sender->AddJsFile('infinitescroll.js', 'plugins/InfiniteScroll');
$Sender->AddJsFile('infinitescroll.min.js', 'plugins/InfiniteScroll');
$Sender->AddCssFile('infinitescroll.css', 'plugins/InfiniteScroll', array('Sort' => 1));
}