From a50589c3c9e72e6423366108f07f41698ab7552f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Nov 2017 15:10:46 +0100 Subject: [PATCH] NEW Better behaviour when using a text browser --- htdocs/core/class/html.formother.class.php | 6 +++++- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/search_page.php | 11 +++++------ htdocs/main.inc.php | 16 ++++++++++++---- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 432a7bb37de..565cd4310b4 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1023,7 +1023,11 @@ class FormOther $selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); if (empty($conf->use_javascript_ajax)) $selectboxlist.=' '; $selectboxlist.=''; - $selectboxlist.=ajax_combobox("boxcombo"); + if (! empty($conf->use_javascript_ajax)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $selectboxlist.=ajax_combobox("boxcombo"); + } } // Javascript code for dynamic actions diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index ebd64b36a3c..90089488389 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -298,7 +298,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM print ''."\n"; } - if (is_array($moredata) && ! empty($moredata['searchform'])) + if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page { print "\n"; print "\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 9e88767f473..1f8529257d2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -484,7 +484,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''."\n"; } - if (is_array($moredata) && ! empty($moredata['searchform']) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page { print "\n"; print "\n"; diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index eb873d0e8f9..83ef016d3a9 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2017 Laurent Destailleur * * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. @@ -20,7 +20,7 @@ /** * \file htdocs/core/search_page.php - * \brief File to return search box + * \brief File to return a page with search boxes */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -78,7 +78,8 @@ if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile else { $usedbyinclude = 1; // Used into next include - include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; + $showtitlebefore = GETPOST('showtitlebefore','int'); + include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; $accesskeyalreadyassigned=array(); foreach($arrayresult as $key => $val) @@ -94,7 +95,7 @@ else $accesskey=$val['label'][0]; $accesskeyalreadyassigned[$accesskey]=$accesskey; } - $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1)); + $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1), $showtitlebefore); } } @@ -112,11 +113,9 @@ print "\n"; print "\n"; print '
'; print ''; -//print '
'; print '
'."\n"; print $searchform; print '
'."\n"; -//print '
'; print '
'; print "\n\n"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1d049e670c9..a4654713208 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1589,9 +1589,9 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra print "\n".''."\n".'
'."\n"; - print "\n"; + if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? - if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1; // Select into select2 is awfull on smartphone + print "\n"; if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { if (! is_object($form)) $form=new Form($db); @@ -1621,7 +1621,13 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra } else $searchform=$hookmanager->resPrint; - if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) + // Force special value for $searchform + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $urltosearch=DOL_URL_ROOT.'/core/search_page.php?showtitlebefore=1'; + $searchform='
'; + } + elseif ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { $searchform='
'; $searchform.='