From 4a37906ee40d81cb56da9ec125cf89fbf157ff92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Jan 2008 20:22:40 +0000 Subject: [PATCH] Perf: Quelques optimisations du code. --- htdocs/admin/ihm.php | 4 +- htdocs/lib/datepicker.php | 69 +++++++++++++++++++++++--- htdocs/lib/functions.inc.php | 36 -------------- htdocs/main.inc.php | 56 +++++++-------------- htdocs/product/photos.php | 8 +-- htdocs/theme/common/window/alert.css | 8 +-- htdocs/theme/common/window/default.css | 10 ++-- 7 files changed, 93 insertions(+), 98 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index cb7a26b124f..3ea7fa62778 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -15,14 +15,12 @@ * 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$ */ /** \file htdocs/admin/ihm.php \brief Page de configuration de l'interface homme machine - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); diff --git a/htdocs/lib/datepicker.php b/htdocs/lib/datepicker.php index f6a8c504807..2c9a454e23b 100644 --- a/htdocs/lib/datepicker.php +++ b/htdocs/lib/datepicker.php @@ -37,24 +37,40 @@ set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); require_once("../master.inc.php"); +$langs->load("main"); + // URL http://mydolibarr/lib/datepicker.php?mode=test&m=10&y=2038 can be used for tests +print ''."\n"; +print ''; if (isset($_GET["mode"]) && $_GET["mode"] == 'test') { - print ''."\n"; - print ''; print ''."\n"; - print ''."\n"; } else { - print ''."\n"; - print 'Calendar'."\n"; + print 'Calendar'; } +// Define tradMonths javascript array +$tradTemp=array($langs->trans("January"), + $langs->trans("February"), + $langs->trans("March"), + $langs->trans("April"), + $langs->trans("May"), + $langs->trans("June"), + $langs->trans("July"), + $langs->trans("August"), + $langs->trans("September"), + $langs->trans("October"), + $langs->trans("November"), + $langs->trans("December") + ); +print ''."\n"; +print ''."\n"; -$langs->load("main"); - $qualified=true; if (! isset($_GET["sd"])) $_GET["sd"]="00000000"; @@ -216,4 +232,43 @@ function displayBox($selectedDate,$month,$year){ \ No newline at end of file diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 9e10b81be85..adf3d9be65d 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -2807,42 +2807,6 @@ function make_substitutions($chaine,$substitutionarray) return $chaine; } -/* - * \brief Convertit une variable php en variable javascript - * \param var variable php - * \return result variable javascript - */ - function php2js($var) - { - if (is_array($var)) - { - $array = array(); - foreach ($var as $a_var) - { - $array[] = php2js($a_var); - } - $result = "[" . join(",", $array) . "]"; - return $result; - } - else if (is_bool($var)) - { - $result = $var ? "true" : "false"; - return $result; - } - else if (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) - { - $result = $var; - return $result; - } - else if (is_string($var)) - { - $result = "\"" . addslashes(stripslashes($var)) . "\""; - return $result; - } - // autres cas: objets, on ne les gére pas - $result = FALSE; - return $result; -} /* * \brief Formate l'affichage de date de début et de fin diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c6568b184c8..de742411264 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -667,14 +667,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0) print ''."\n"; print ''."\n"; - // Style sheets pour la class Window - if (! $disablejs && $conf->use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - // Definition en alternate style sheet des feuilles de styles les plus maintenues // Les navigateurs qui supportent sont rares. Plus aucun connu. /* @@ -694,38 +686,24 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0) if (! $disablejs && $conf->use_javascript_ajax) { require_once DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php'; - - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - // TODO As-ton besoin des ces 2 js ? - print ''."\n"; - print ''."\n"; - - } - // TODO Voir si on peut pas virer ca - if (! $disablejs && $conf->use_javascript_ajax) - { - // Define tradMonths javascript array - $tradTemp=Array($langs->trans("January"), - $langs->trans("February"), - $langs->trans("March"), - $langs->trans("April"), - $langs->trans("May"), - $langs->trans("June"), - $langs->trans("July"), - $langs->trans("August"), - $langs->trans("September"), - $langs->trans("October"), - $langs->trans("November"), - $langs->trans("December") - ); - print ''."\n"; - } + // This one is required for all Ajax features + print ''."\n"; + // This one is required fox boxes + print ''."\n"; + + // Those ones are required only with option "confirm by ajax popup" + if ($conf->global->MAIN_CONFIRM_AJAX) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + //print ''."\n"; + } + } print "\n"; } diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index cef2c1b6869..ee6d83b8378 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -236,13 +236,13 @@ if ($_GET["id"] || $_GET["ref"]) if ($conf->use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) { $url = $_SERVER["PHP_SELF"].'?id='.$product->id.'&file='.urlencode($pdir.$viewfilename).'&action=confirm_delete&confirm=yes'; - print 'trans("No").'\',\'delete\')"'; + print 'trans("No").'\',\'delete\')">'; } else { - print ''; - } - print img_delete().''; + print ''; + } + print img_delete().''; } if ($nbbyrow) print ''; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print ''; diff --git a/htdocs/theme/common/window/alert.css b/htdocs/theme/common/window/alert.css index 353e862f88d..22b21f0c60a 100644 --- a/htdocs/theme/common/window/alert.css +++ b/htdocs/theme/common/window/alert.css @@ -1,8 +1,8 @@ .overlay_alert { - background-color: #ACBCBB; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; + background-color: #DDDDDD; + filter: alpha(opacity=50); /*Does not respect CSS standard */ + -moz-opacity: 0.5; + opacity: 0.5; } .alert_nw { diff --git a/htdocs/theme/common/window/default.css b/htdocs/theme/common/window/default.css index 7b129b60142..1c2b2c7b283 100644 --- a/htdocs/theme/common/window/default.css +++ b/htdocs/theme/common/window/default.css @@ -1,13 +1,13 @@ .overlay_dialog { background-color: #666666; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; + filter: alpha(opacity=50); /* Does not respect CSS standard */ + -moz-opacity: 0.5; + opacity: 0.5; } .overlay___invisible__ { - background-color: #666666; - filter:alpha(opacity=0); + background-color: #666666; + filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0; }