diff --git a/htdocs/includes/boxes/box_bookmarks.php b/htdocs/includes/boxes/box_bookmarks.php index 0ebec730f27c3240a0d77cd001238093d58a1438..6b86c442ce205001c98315e29cba7afa717d59e5 100644 --- a/htdocs/includes/boxes/box_bookmarks.php +++ b/htdocs/includes/boxes/box_bookmarks.php @@ -105,7 +105,12 @@ class box_bookmarks extends ModeleBoxes { $i++; } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$langs->trans("NoRecordedBookmarks")); + if ($num==0) + { + $mytxt=$langs->trans("NoRecordedBookmarks"); + if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickHereToAdd"); + $this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$mytxt); + } } else { diff --git a/htdocs/includes/menus/standard/auguria.lib.php b/htdocs/includes/menus/standard/auguria.lib.php index de745205516c68d0a982f3f14800642f5072ed40..ed4786021539e359e4349fbb8a921c022796acf6 100644 --- a/htdocs/includes/menus/standard/auguria.lib.php +++ b/htdocs/includes/menus/standard/auguria.lib.php @@ -63,7 +63,7 @@ function print_auguria_menu($db,$atarget,$type_user) } else { - dol_file_exists($tabMenu[$i]['url'],1); + $url=dol_file_exists($tabMenu[$i]['url'],1); if (! preg_match('/\?/',$url)) $url.='?'; else $url.='&'; if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) @@ -275,7 +275,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after) } // Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser. - dol_files_exists($menu_array[$i]['url'],1); + $url=dol_file_exists($menu_array[$i]['url'],1); if (! preg_match('/mainmenu=/i',$menu_array[$i]['url'])) { diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index de996d84739e4d5817350538146f45606b651262..d212162b723c3f8f971a921d16aa2bbfe496f103 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -44,7 +44,8 @@ BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier's invoices BoxMyLastBookmarks=My last %s bookmarks FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s LastRefreshDate=Last refresh date -NoRecordedBookmarks=No bookmarks defined. Click <a href="%s">here</a> to add bookmarks. +NoRecordedBookmarks=No bookmarks defined. +ClickToAdd=Click here to add. NoRecordedCustomers=No recorded customers BoxTitleLastActionsToDo=Last %s actions to do BoxTitleLastContracts=Last %s contracts diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 3b98d5d66f7468f9460aff20c0c4426fc644d35b..909bc24558f210c48f9516b65e111c5c0837f92c 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -44,7 +44,8 @@ BoxTitleTotalUnpaidSuppliersBills=Impayés fournisseurs BoxMyLastBookmarks=Mes %s derniers marque-pages FailedToRefreshDataInfoNotUpToDate=Échec du rafraichissement du flux RSS. Date du dernier rafraichissement: %s LastRefreshDate=Date dernier rafraichissement -NoRecordedBookmarks=Pas de bookmarks personnels. Cliquer ici pour en ajouter. +NoRecordedBookmarks=Pas de bookmarks personnels. +ClickToAdd=Cliquer ici pour ajouter. NoRecordedCustomers=Pas de client enregistré BoxTitleLastActionsToDo=Les %s dernières actions à faire BoxTitleLastContracts=Les %s derniers contrats diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index acce17baf878cfc6e16ff6cb85eaa60cf6fb29ee..455a8640c553c4a81c94c62638dd2120c7929bdd 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -87,30 +87,41 @@ function dol_require_once($relpath) // Forced to use file_exists otherwise there is a blank page //$res=@require_once(DOL_DOCUMENT_ROOT.$relpath); //if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath); - $res=@require_once(dol_file_exists($relpath)); - + $res=require_once(dol_file_exists($relpath)); + return $res; } /** - * Make an file_exists using default root and alternate root if it fails. + * Return path of url or filesystem. Return default_root or alternate root if file_exist fails. + * TODO Rename function into dol_buildpath * @param path Relative or absolute path to file (Ie: mydir/myfile, ../myfile, ...) - * @return int Result + * @param mode 0=Used for a Filesystem path, 1=Used for an URL path + * @return string Full filsystem path (if mode=0), Relative url path (if mode=1) */ -function dol_file_exists($path,$absolute=0) +function dol_file_exists($path,$mode=0) { - $res=false; - - if ($absolute) + if (empty($mode)) // For a filesystem path { - preg_match('/^([^<]+\.php)/i',$path,$regs); - $res=DOL_URL_ROOT.$path; - if (defined('DOL_URL_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res=DOL_URL_ROOT_ALT.$path; + $res = DOL_DOCUMENT_ROOT.$path; // Standard value + if (defined('DOL_DOCUMENT_ROOT_ALT') && DOL_DOCUMENT_ROOT_ALT) // We check only if alternate feature is used + { + if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path; + } } - else + else // For an url path { - $res = DOL_DOCUMENT_ROOT.$path; - if (defined('DOL_DOCUMENT_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path; + $res = DOL_URL_ROOT.$path; // Standard value + if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used + { + // We try to get local path of file on filesystem from url + // FIXME Trying to know if a file on disk exist by forging path on disk from url + // works only for some web server and some setup. This is bugged when + // using proxy, rewriting, virtual path, etc... + preg_match('/^([^<]+\.php)$/i',$path,$regs); // Why a "<" char ? + if (! empty($regs[1])) $path = $regs[1]; + if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_URL_ROOT_ALT.$path; + } } return $res; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 652a704a11a2aeabd3bc80ea6c20c31b4c0e4935..bb5f4d0613e659025c8116dd787e818ebe7ec618 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -32,6 +32,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require("../../main.inc.php"); $langs->load("main"); +$langs->load("install"); $langs->load("other"); // Security check @@ -228,16 +229,21 @@ foreach ($demoprofiles as $profilarray) { $url=$_SERVER["PHP_SELF"].'?action=gotodemo&urlfrom='.urlencode($_SERVER["PHP_SELF"]); $urlwithmod=$url.'&demochoice='.$profilarray['key']; + // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' + //print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'<br>'; + $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]); + //print $urlfrom; + //if ($i % $NBOFCOLS == 0) print '<tr>'; print '<tr>'; print '<td>'."\n"; - print '<form method="POST" name="form'.$profilarray['key'].'" action="'.$_SERVER["PHP_SELF"].'">'; - print '<input type="hidden" name="action" value="gotodemo">'; - print '<input type="hidden" name="urlfrom" value="'.urlencode($_SERVER["PHP_SELF"]).'">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="username" value="demo">'; - print '<table summary="Dolibarr online demonstration for profile '.$profilarray['label'].'" style="font-size:14px;" width="100%" class="CTableRow'.($i%2==0?'1':'2').'">'."\n"; + print '<form method="POST" name="form'.$profilarray['key'].'" action="'.$_SERVER["PHP_SELF"].'">'."\n"; + print '<input type="hidden" name="action" value="gotodemo">'."\n"; + print '<input type="hidden" name="urlfrom" value="'.urlencode($urlfrom).'">'."\n"; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n"; + print '<input type="hidden" name="username" value="demo">'."\n"; + print '<table summary="Dolibarr online demonstration for profile '.$profilarray['label'].'" style="font-size:14px;" width="100%" class="CTableRow'.($i%2==0?'1':'1').'">'."\n"; print '<tr>'; print '<td width="50"><a href="'.$urlwithmod.'" id="a1'.$profilarray['key'].'" class="modulelineshow"><img src="'.$profilarray['icon'].'" width="48" border="0" alt="Demo '.$profilarray['label'].'"></a></td>'; //print '<td><input type="radio" name="demochoice"'; @@ -346,9 +352,9 @@ function llxHeaderVierge($title, $head = "") print "<title>".$title."</title>\n"; print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php?lang='.$langs->defaultlang.'">'."\n"; print '<!-- Includes for JQuery -->'."\n"; - print '<script type="text/javascript" src="/includes/jquery/js/jquery-latest.min.js"></script>'."\n"; - print '<script type="text/javascript" src="/includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n"; - print '<script type="text/javascript" src="/includes/jquery/plugins/tablednd/jquery.tablednd_0_5.js"></script>'."\n"; + print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-latest.min.js"></script>'."\n"; + print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n"; + print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd_0_5.js"></script>'."\n"; if ($head) print $head."\n"; print '<style type="text/css">'; print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';