diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4c76ddd337a..bc114930e7a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -33,6 +33,8 @@ class CommonObject { + var $db; + // Instantiate hook classe of thirdparty module var $hooks=array(); diff --git a/htdocs/core/class/smartphone.class.php b/htdocs/core/class/smartphone.class.php new file mode 100644 index 00000000000..2100b290e62 --- /dev/null +++ b/htdocs/core/class/smartphone.class.php @@ -0,0 +1,72 @@ + + * + * 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; + } + +} diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index 02eb19d76ca..9f00bfd63c7 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -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 { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b4f74722706..4b6cc69257e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -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 */ diff --git a/htdocs/theme/phones/smartphone/tpl/login.tpl.php b/htdocs/theme/phones/smartphone/tpl/login.tpl.php index 2a3ff72d288..84caeb5f5a9 100644 --- a/htdocs/theme/phones/smartphone/tpl/login.tpl.php +++ b/htdocs/theme/phones/smartphone/tpl/login.tpl.php @@ -32,9 +32,9 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client); <?php echo $title; ?> - + - + @@ -50,7 +50,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
- +

@@ -102,7 +102,7 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);