Add Smartphone class

This commit is contained in:
Regis Houssin 2010-09-22 06:30:32 +00:00
parent 6eca5c277d
commit 38d2583e8d
7 changed files with 97 additions and 45 deletions

View File

@ -33,6 +33,8 @@
class CommonObject
{
var $db;
// Instantiate hook classe of thirdparty module
var $hooks=array();

View 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;
}
}

View File

@ -34,6 +34,7 @@
function dol_loginfunction($langs,$conf,$mysoc)
{
global $dolibarr_main_demo,$db;
global $smartphone;
$langcode=(empty($_GET["lang"])?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):$_GET["lang"]);
$langs->setDefaultLang($langcode);
@ -52,25 +53,9 @@ function dol_loginfunction($langs,$conf,$mysoc)
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
// Select templates
if ($conf->browser->phone)
if (class_exists('Smartphone'))
{
// iWebKit template
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/";
}
$template_dir = $smartphone->getTemplateDir();
}
else
{

View File

@ -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
*/

View File

@ -32,9 +32,9 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<title><?php echo $title; ?></title>
<meta name="robots" content="noindex,nofollow" />
<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" />
<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>
</head>
@ -50,7 +50,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<input type="hidden" name="loginfunction" value="loginfunction" />
<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>
<br>
@ -102,7 +102,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<?php if ($forgetpasslink) { ?>
<li class="menu">
<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="arrow"></span>
</a>
@ -112,7 +112,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<?php if ($helpcenterlink) { ?>
<li class="menu">
<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="arrow"></span>
</a>

View File

@ -33,7 +33,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<meta name="robots" content="noindex,nofollow" />
<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" />
<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>
</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="leftnav">
<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>
</div>
</div>
@ -54,7 +54,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<input type="hidden" name="action" value="buildnewpassword">
<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>
<br>

View File

@ -144,29 +144,13 @@ $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
$dol_url_root = DOL_URL_ROOT;
// Select templates
if ($conf->browser->phone)
if (class_exists('Smartphone'))
{
// iWebKit template
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/";
}
$template_dir = $smartphone->getTemplateDir();
}
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/";
}