Add Smartphone class
Fix: mutualized code
This commit is contained in:
parent
97ca7bdfab
commit
298c4c6fc7
@ -33,6 +33,8 @@ class Smartphone {
|
||||
|
||||
var $phone;
|
||||
var $theme;
|
||||
var $title;
|
||||
var $template_dir;
|
||||
|
||||
/**
|
||||
* Constructor for class
|
||||
@ -52,21 +54,38 @@ class Smartphone {
|
||||
if (preg_match('/android|blackberry|iphone/i',$this->phone))
|
||||
{
|
||||
$this->theme = 'default';
|
||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/smartphone/tpl/";
|
||||
$this->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/";
|
||||
$this->template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$this->phone."/tpl/";
|
||||
}
|
||||
// Default template
|
||||
else
|
||||
{
|
||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/";
|
||||
$this->template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/";
|
||||
}
|
||||
|
||||
return $template_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show HTML header
|
||||
* @param title Web page title
|
||||
*/
|
||||
function smartheader()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
include_once($this->template_dir.'header.tpl.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show HTML footer
|
||||
*/
|
||||
function smartfooter()
|
||||
{
|
||||
include_once($this->template_dir.'footer.tpl.php');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -51,11 +51,18 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
|
||||
$php_self = $_SERVER['PHP_SELF'];
|
||||
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
|
||||
|
||||
// Title
|
||||
$title='Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
|
||||
|
||||
// Select templates
|
||||
if (class_exists('Smartphone'))
|
||||
{
|
||||
$template_dir = $smartphone->getTemplateDir();
|
||||
// Template directory
|
||||
$smartphone->getTemplateDir();
|
||||
$smartphone->title = $title;
|
||||
$template_dir = $smartphone->template_dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -88,10 +95,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
$login_background=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png';
|
||||
}
|
||||
|
||||
// Title
|
||||
$title='Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
|
||||
|
||||
$demologin='';
|
||||
$demopassword='';
|
||||
if (! empty($dolibarr_main_demo))
|
||||
|
||||
27
htdocs/theme/phones/smartphone/tpl/footer.tpl.php
Normal file
27
htdocs/theme/phones/smartphone/tpl/footer.tpl.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- BEGIN FOOTER SMARTPHONE TEMPLATE -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- END FOOTER SMARTPHONE TEMPLATE -->
|
||||
43
htdocs/theme/phones/smartphone/tpl/header.tpl.php
Normal file
43
htdocs/theme/phones/smartphone/tpl/header.tpl.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
header('Cache-Control: Public, must-revalidate');
|
||||
header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<!-- BEGIN HEADER SMARTPHONE TEMPLATE -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<title><?php echo $this->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/'.$this->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/'.$this->theme.'/'.$this->theme.'.css.php'; ?>" />
|
||||
<script type="text/javascript" src="<?php echo DOL_URL_ROOT.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- END HEADER SMARTPHONE TEMPLATE -->
|
||||
@ -17,28 +17,10 @@
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
header('Cache-Control: Public, must-revalidate');
|
||||
header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
$smartphone->smartheader($title);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<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/'.$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/'.$smartphone->theme.'/'.$smartphone->theme.'.css.php'; ?>" />
|
||||
<script type="text/javascript" src="<?php echo $dol_url_root.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- START LOGIN SMARTPHONE TEMPLATE -->
|
||||
|
||||
<div id="topbar">
|
||||
<div id="title"><?php echo $title; ?></div>
|
||||
@ -127,7 +109,6 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php $smartphone->smartfooter(); ?>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
<!-- END LOGIN SMARTPHONE TEMPLATE -->
|
||||
@ -17,27 +17,10 @@
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
header('Cache-Control: Public, must-revalidate');
|
||||
header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
$smartphone->smartheader($title);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<title><?php echo $langs->trans('Password'); ?></title>
|
||||
<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/'.$smartphone->theme.'/'.$smartphone->theme.'.css.php'; ?>" />
|
||||
<script type="text/javascript" src="<?php echo $dol_url_root.'/includes/iwebkit/Framework/javascript/functions.js'; ?>"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- BEGIN SMARTPHONE TEMPLATE -->
|
||||
|
||||
<div id="topbar">
|
||||
<div id="title"><?php echo $langs->trans('Password'); ?></div>
|
||||
@ -112,7 +95,6 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php $smartphone->smartfooter(); ?>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
<!-- END SMARTPHONE TEMPLATE -->
|
||||
@ -143,11 +143,16 @@ $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
|
||||
|
||||
$dol_url_root = DOL_URL_ROOT;
|
||||
|
||||
// Title
|
||||
$title='Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
|
||||
|
||||
// Select templates
|
||||
if (class_exists('Smartphone'))
|
||||
{
|
||||
// Template directory
|
||||
$smartphone->getTemplateDir();
|
||||
$smartphone->title = $title;
|
||||
$template_dir = $smartphone->template_dir;
|
||||
}
|
||||
else
|
||||
@ -177,10 +182,6 @@ else
|
||||
if (! $_REQUEST["username"]) $focus_element = 'username';
|
||||
else $focus_element = 'password';
|
||||
|
||||
// Title
|
||||
$title='Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
|
||||
|
||||
// Send password button enabled ?
|
||||
$disabled='disabled';
|
||||
if ($mode == 'dolibarr') $disabled='';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user