Wrong code in macroReplace function

Hi all.

I have been observing that new versions of dolibarr include a deprecated, non-functional, version of function macroReplace so that macro replacement in odt documents may fail. As the creator of the code I have submitted this onto the github time ago but, as I am not very used to that platform, I am not probably doing it well because there are several versions now where this code does not appear and the old one is still being pushed to everyone.

So I use this, I know, un-natural mechanism and place to let know all dolibarr users (and creators too) that this is the right code, the one that is working with no problems right now in my system, and the one that adapts to the directions that Laurent told me to follow to match the new versions functions namespace.

The function is in /htdocs/includes/odtphp/Segment.php just in case you want to have a look at it.

Hope it will be useful to anyone.

    * Miguel Erill 19/09/2017
    *
    * @param	string	$value	String to convert
    */
    public function macroReplace($text)
    {
    	include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
        global $langs;

        $tmp=dol_getdate(dol_now(), true);
        $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
        $tmp3=dol_get_prev_month($tmp['mon'], $tmp['year']);
        $tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
        $tmp5=dol_get_next_month($tmp['mon'], $tmp['year']);

        $substitutionarray=array(
          '__DAY__' => $tmp['mday'],
          '__CURRENTDAY__' => $tmp['mday'],
          '__MONTH__' => $tmp['mon'],
          '__CURRENTMONTH__' => $tmp['mon'],
//          '__MONTHTEXT__' => $tmp['month'],
          '__MONTHTEXT__' => monthArray($langs)[$tmp['mon']],
          '__CURRENTMONTHLONG__' => monthArray($langs)[$tmp['mon']],
          '__YEAR__' => $tmp['year'],
          '__CURRENTYEAR__' => $tmp['year'],
          '__PREVIOUS_DAY__' => $tmp2['day'],
          '__PREVIOUS_MONTH__' => $tmp3['month'],
          '__PREVIOUS_YEAR__' => ($tmp['year'] - 1),
          '__NEXT_DAY__' => $tmp4['day'],
          '__NEXT_MONTH__' => $tmp5['month'],
          '__NEXTMONTH__' => $tmp5['month'],
          '__NEXTMONTHLONG__' => monthArray($langs)[$tmp5['month']],
          '__NEXT_YEAR__' => ($tmp['year'] + 1),
          '__NEXTYEAR__' => ($tmp['year'] + 1),
        );
        complete_substitutions_array($substitutionarray, $langs);
        $text=make_substitutions($text,$substitutionarray);

	return $text;
    }