Qual: Make some refactoring to prepare speed enhancement in menu loading.

This commit is contained in:
Laurent Destailleur 2011-02-18 09:35:34 +00:00
parent 79696609ce
commit 58df0bc0d8
8 changed files with 7 additions and 107 deletions

View File

@ -1,89 +0,0 @@
<?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
* \ingroup core
* \brief Fichier de la classe de gestion des smartphones
* \version $Id$
*/
/**
* \class Smartphone
* \brief Class to manage Smartphones
*/
class Smartphone {
var $db;
var $phone;
var $theme;
var $title;
var $template_dir;
/**
* Constructor for class
* @param DB Handler acces base de donnees
*/
function Smartphone($DB,$phone)
{
$this->db = $DB;
$dirt='others'; // default
if (preg_match('/android|blackberry|iphone|maemo/i',$phone)) // iWebKit template
{
$this->theme = 'default';
$dirt='smartphone';
}
elseif (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$phone)) // Special template
{
$this->theme = 'default';
$dirt=$phone;
}
$this->phone=$phone;
$this->template_dir=DOL_DOCUMENT_ROOT.'/theme/phones/'.$dirt.'/tpl/';
}
/**
* Show menu
*/
function smartmenu()
{
global $conf, $langs;
if (! $conf->smart_menu) $conf->smart_menu ='smartphone_backoffice.php';
$smart_menu=$conf->smart_menu;
if (GETPOST('top_menu')) $smart_menu=GETPOST('top_menu');
// Load the smartphone menu manager
$result=@include_once(DOL_DOCUMENT_ROOT ."/includes/menus/smartphone/".$smart_menu);
if (! $result) // If failed to include, we try with standard
{
$conf->smart_menu='smartphone_backoffice.php';
include_once(DOL_DOCUMENT_ROOT ."/includes/menus/smartphone/".$smart_menu);
}
$menusmart = new MenuSmart($this->db);
$menusmart->atarget=$target;
include_once($this->template_dir.'menu.tpl.php');
}
}

View File

@ -59,11 +59,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
// Select templates
if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
{
// Template directory
include_once(DOL_DOCUMENT_ROOT.'/core/class/smartphone.class.php');
$smartphone = new Smartphone($db,$conf->browser->phone); // This class is only to know template dir according to phone type
$smartphone->title = $title;
$template_dir = $smartphone->template_dir;
$template_dir = DOL_DOCUMENT_ROOT.'/theme/phones/smartphone/tpl/';
}
else
{

View File

@ -478,8 +478,7 @@ img.login, img.printer, img.entity {
/* Menu gauche */
/* ============================================================================== */
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')
|| (! empty($conf->browser->phone) && class_exists('Smartphone') && empty($conf->global->MAIN_SEARCHFORM_WITH_SMARTHPONE) && empty($conf->global->BOOKMARKS_SHOW_WITH_SMARTHPONE))) { ?>
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')) { ?>
.vmenu {
display: none;
}

View File

@ -530,8 +530,7 @@ img.entity {
/* Menu gauche */
/* ============================================================================== */
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')
|| (! empty($conf->browser->phone) && class_exists('Smartphone') && empty($conf->global->MAIN_SEARCHFORM_WITH_SMARTHPONE) && empty($conf->global->BOOKMARKS_SHOW_WITH_SMARTHPONE))) { ?>
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')) { ?>
.vmenu {
display: none;
}

View File

@ -499,7 +499,7 @@ img.login, img.printer, img.entity {
/* ============================================================================== */
<?php if ((GETPOST("optioncss") == 'print')
|| (! empty($conf->browser->phone) && class_exists('Smartphone') && empty($conf->global->MAIN_SEARCHFORM_WITH_SMARTHPONE) && empty($conf->global->BOOKMARKS_SHOW_WITH_SMARTHPONE))) { ?>
|| (! empty($conf->browser->phone) && empty($conf->global->MAIN_SEARCHFORM_WITH_SMARTHPONE) && empty($conf->global->BOOKMARKS_SHOW_WITH_SMARTHPONE))) { ?>
.vmenu {
display: none;
}

View File

@ -405,8 +405,7 @@ img.printer
/* Menu gauche */
/* ============================================================================== */
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')
|| (! empty($conf->browser->phone) && class_exists('Smartphone') && empty($conf->global->MAIN_SEARCHFORM_WITH_SMARTHPONE) && empty($conf->global->BOOKMARKS_SHOW_WITH_SMARTHPONE))) { ?>
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')) { ?>
.vmenu {
display: none;
}

View File

@ -386,8 +386,7 @@ img.printer
/* Menu gauche */
/* ============================================================================== */
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')
|| (! empty($conf->browser->phone) && class_exists('Smartphone') && empty($conf->global->MAIN_SEARCHFORM_WITH_SMARTHPONE) && empty($conf->global->BOOKMARKS_SHOW_WITH_SMARTHPONE))) { ?>
<?php if ((! empty($_GET["optioncss"]) && $_GET["optioncss"] == 'print')) { ?>
.vmenu {
display: none;
}

View File

@ -153,10 +153,7 @@ if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_A
// Select templates
if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/smartphone.class.php');
$smartphone = new Smartphone($db,$conf->browser->phone); // This class is only to know template dir according to phone type
$smartphone->title = $title;
$template_dir = $smartphone->template_dir;
$template_dir = DOL_DOCUMENT_ROOT.'/theme/phones/smartphone/tpl/';
}
else
{