Add Smartphone class
This commit is contained in:
parent
6eca5c277d
commit
38d2583e8d
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
class CommonObject
|
class CommonObject
|
||||||
{
|
{
|
||||||
|
var $db;
|
||||||
|
|
||||||
// Instantiate hook classe of thirdparty module
|
// Instantiate hook classe of thirdparty module
|
||||||
var $hooks=array();
|
var $hooks=array();
|
||||||
|
|
||||||
|
|||||||
72
htdocs/core/class/smartphone.class.php
Normal file
72
htdocs/core/class/smartphone.class.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/class/smartphone.class.php
|
||||||
|
* \brief Fichier de la classe de gestion des smartphones
|
||||||
|
* \version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class Smartphone
|
||||||
|
* \brief Classe de gestion des smartphones
|
||||||
|
*/
|
||||||
|
class Smartphone {
|
||||||
|
|
||||||
|
var $db;
|
||||||
|
|
||||||
|
var $phone;
|
||||||
|
var $theme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for class
|
||||||
|
* @param DB Handler acces base de donnees
|
||||||
|
*/
|
||||||
|
function Smartphone($DB)
|
||||||
|
{
|
||||||
|
$this->db = $DB;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get template directory
|
||||||
|
*/
|
||||||
|
function getTemplateDir()
|
||||||
|
{
|
||||||
|
// iWebKit template
|
||||||
|
if (preg_match('/android|blackberry|iphone/i',$this->phone))
|
||||||
|
{
|
||||||
|
$this->theme = 'default';
|
||||||
|
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/smartphone/tpl/";
|
||||||
|
}
|
||||||
|
// Special template
|
||||||
|
elseif (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$this->phone))
|
||||||
|
{
|
||||||
|
$this->theme = 'default';
|
||||||
|
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$this->phone."/tpl/";
|
||||||
|
}
|
||||||
|
// Default template
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -34,6 +34,7 @@
|
|||||||
function dol_loginfunction($langs,$conf,$mysoc)
|
function dol_loginfunction($langs,$conf,$mysoc)
|
||||||
{
|
{
|
||||||
global $dolibarr_main_demo,$db;
|
global $dolibarr_main_demo,$db;
|
||||||
|
global $smartphone;
|
||||||
|
|
||||||
$langcode=(empty($_GET["lang"])?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):$_GET["lang"]);
|
$langcode=(empty($_GET["lang"])?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):$_GET["lang"]);
|
||||||
$langs->setDefaultLang($langcode);
|
$langs->setDefaultLang($langcode);
|
||||||
@ -52,25 +53,9 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
|||||||
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
|
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
|
||||||
|
|
||||||
// Select templates
|
// Select templates
|
||||||
if ($conf->browser->phone)
|
if (class_exists('Smartphone'))
|
||||||
{
|
{
|
||||||
// iWebKit template
|
$template_dir = $smartphone->getTemplateDir();
|
||||||
if (preg_match('/android|blackberry|iphone/i',$conf->browser->phone))
|
|
||||||
{
|
|
||||||
$theme = 'default';
|
|
||||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/smartphone/tpl/";
|
|
||||||
}
|
|
||||||
// Special template
|
|
||||||
elseif (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone))
|
|
||||||
{
|
|
||||||
$theme = 'default';
|
|
||||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/tpl/";
|
|
||||||
}
|
|
||||||
// Default template
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -267,6 +267,15 @@ if (sizeof($conf->need_smarty) > 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init Smartphone
|
||||||
|
if (isset($conf->browser->phone))
|
||||||
|
{
|
||||||
|
include_once(DOL_DOCUMENT_ROOT."/core/class/smartphone.class.php");
|
||||||
|
|
||||||
|
$smartphone = new Smartphone($db);
|
||||||
|
$smartphone->phone = $conf->browser->phone;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phase authentication / login
|
* Phase authentication / login
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -32,9 +32,9 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<title><?php echo $title; ?></title>
|
<title><?php echo $title; ?></title>
|
||||||
<meta name="robots" content="noindex,nofollow" />
|
<meta name="robots" content="noindex,nofollow" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<link rel="apple-touch-icon" href="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/thumbs/homescreen.png'; ?>" />
|
<link rel="apple-touch-icon" href="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/thumbs/homescreen.png'; ?>" />
|
||||||
<meta name="viewport"content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" />
|
<meta name="viewport"content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" />
|
||||||
<link type="text/css" rel="stylesheet" href="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/'.$theme.'.css.php'; ?>" />
|
<link type="text/css" rel="stylesheet" href="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/'.$smartphone->theme.'.css.php'; ?>" />
|
||||||
<script type="text/javascript" src="<?php echo $dol_url_root.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
<script type="text/javascript" src="<?php echo $dol_url_root.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<input type="hidden" name="loginfunction" value="loginfunction" />
|
<input type="hidden" name="loginfunction" value="loginfunction" />
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<img src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/thumbs/dolibarr.png'; ?>">
|
<img src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/thumbs/dolibarr.png'; ?>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -102,7 +102,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<?php if ($forgetpasslink) { ?>
|
<?php if ($forgetpasslink) { ?>
|
||||||
<li class="menu">
|
<li class="menu">
|
||||||
<a href="<?php echo $dol_url_root.'/user/passwordforgotten.php'; ?>">
|
<a href="<?php echo $dol_url_root.'/user/passwordforgotten.php'; ?>">
|
||||||
<img alt="tools" src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/thumbs/tools.png'; ?>" />
|
<img alt="tools" src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/thumbs/tools.png'; ?>" />
|
||||||
<span class="name"><?php echo $langs->trans('PasswordForgotten'); ?></span>
|
<span class="name"><?php echo $langs->trans('PasswordForgotten'); ?></span>
|
||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</a>
|
</a>
|
||||||
@ -112,7 +112,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<?php if ($helpcenterlink) { ?>
|
<?php if ($helpcenterlink) { ?>
|
||||||
<li class="menu">
|
<li class="menu">
|
||||||
<a href="<?php echo $dol_url_root.'/support/index.php'; ?>">
|
<a href="<?php echo $dol_url_root.'/support/index.php'; ?>">
|
||||||
<img alt="support" src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/thumbs/support.png'; ?>" />
|
<img alt="support" src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/thumbs/support.png'; ?>" />
|
||||||
<span class="name"><?php echo $langs->trans('NeedHelpCenter'); ?></span>
|
<span class="name"><?php echo $langs->trans('NeedHelpCenter'); ?></span>
|
||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@ -33,7 +33,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<meta name="robots" content="noindex,nofollow" />
|
<meta name="robots" content="noindex,nofollow" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="viewport"content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" />
|
<meta name="viewport"content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" />
|
||||||
<link type="text/css" rel="stylesheet" href="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/'.$theme.'.css.php'; ?>" />
|
<link type="text/css" rel="stylesheet" href="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/'.$smartphone->theme.'.css.php'; ?>" />
|
||||||
<script type="text/javascript" src="<?php echo $dol_url_root.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
<script type="text/javascript" src="<?php echo $dol_url_root.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<div id="title"><?php echo $langs->trans('Password'); ?></div>
|
<div id="title"><?php echo $langs->trans('Password'); ?></div>
|
||||||
<div id="leftnav">
|
<div id="leftnav">
|
||||||
<a href="<?php echo $dol_url_root; ?>/">
|
<a href="<?php echo $dol_url_root; ?>/">
|
||||||
<img alt="home" src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/img/home.png'; ?>"/>
|
<img alt="home" src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/img/home.png'; ?>"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -54,7 +54,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
<input type="hidden" name="action" value="buildnewpassword">
|
<input type="hidden" name="action" value="buildnewpassword">
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<img src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$theme.'/thumbs/dolibarr.png'; ?>">
|
<img src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/thumbs/dolibarr.png'; ?>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@ -144,29 +144,13 @@ $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
|
|||||||
$dol_url_root = DOL_URL_ROOT;
|
$dol_url_root = DOL_URL_ROOT;
|
||||||
|
|
||||||
// Select templates
|
// Select templates
|
||||||
if ($conf->browser->phone)
|
if (class_exists('Smartphone'))
|
||||||
{
|
{
|
||||||
// iWebKit template
|
$template_dir = $smartphone->getTemplateDir();
|
||||||
if (preg_match('/android|blackberry|iphone/i',$conf->browser->phone))
|
|
||||||
{
|
|
||||||
$theme = 'default';
|
|
||||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/smartphone/tpl/";
|
|
||||||
}
|
|
||||||
// Special phones templates
|
|
||||||
elseif (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone))
|
|
||||||
{
|
|
||||||
$theme = 'default';
|
|
||||||
$template_dir = DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/tpl/";
|
|
||||||
}
|
|
||||||
// Default phones template
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$template_dir = DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl"))
|
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl.php"))
|
||||||
{
|
{
|
||||||
$template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/";
|
$template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user