Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
bureau2crea committed Aug 17, 2011
1 parent 62497d1 commit 051386b
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 292 deletions.
43 changes: 21 additions & 22 deletions htdocs/core/class/translate.class.php
Expand Up @@ -23,7 +23,7 @@
* \brief File for Tanslate class
* \author Eric Seigne
* \author Laurent Destailleur
* \version $Id: translate.class.php,v 1.52 2011/08/17 21:51:20 eldy Exp $
* \version $Id: translate.class.php,v 1.50 2011/08/15 23:17:14 eldy Exp $
*/


Expand All @@ -35,16 +35,16 @@ class Translate {

var $dir; // Directories that contains /langs subdirectory

var $defaultlang; // Current language for current user
var $defaultlang; // Langue courante en vigueur de l'utilisateur
var $direction = 'ltr'; // Left to right or Right to left
var $charset_inputfile=array(); // To store charset encoding used for language
var $charset_output='UTF-8'; // Codage used by "trans" method outputs

var $tab_translate=array(); // Array of all translations key=>value
var $tab_translate=array(); // Tableau des traductions
var $tab_loaded=array(); // Array to store result after loading each language file

var $cache_labels=array(); // Cache for labels return by trans method
var $cache_labels=array(); // Cache for labels

var $charset_inputfile=array(); // To store charset encoding used for language
var $charset_output='UTF-8'; // Codage used by "trans" method outputs


/**
Expand All @@ -62,6 +62,7 @@ function Translate($dir = "",$conf)
}



/**
* Set accessor for this->defaultlang
*
Expand Down Expand Up @@ -219,7 +220,7 @@ function Load($domain,$alt=0,$stopafterdirection=0,$forcelangdir='')
// Using a memcached server
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
{
$usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
$usecachekey=$newdomain.'_'.$langofdir.'_'.$file_lang;
}
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
Expand Down Expand Up @@ -260,27 +261,29 @@ function Load($domain,$alt=0,$stopafterdirection=0,$forcelangdir='')
{
$value=trim(preg_replace('/\\n/',"\n",$tab[1]));

//if ($key == 'CHARSET') // This is to declare in which charset files are encoded
//{
// $this->charset_inputfile[$newdomain]=strtoupper($value);
if ($key == 'CHARSET') // This is to declare in which charset files are encoded
{
$this->charset_inputfile[$newdomain]=strtoupper($value);
//print 'File '.$file_lang.' is declared to have format '.$this->charset_inputfile[$newdomain].'<br>';
//}
//else
if ($key == 'DIRECTION') // This is to declare direction of language
}
elseif ($key == 'DIRECTION') // This is to declare direction of language
{
if ($alt < 2 || empty($this->tab_translate[$key])) // We load direction only for primary files or if not yet loaded
if ($alt < 2 || empty($this->tab_translate[$key])) // We load direction only for primary files or if not yer load
{
$this->tab_translate[$key]=$value;

if ($stopafterdirection) break; // We do not save tab if we stop after DIRECTION
else if ($usecachekey) $tabtranslatedomain[$key]=$value;
}
}
else
{
// On stocke toujours dans le tableau Tab en UTF-8
//if (! empty($this->charset_inputfile[$newdomain]) && $this->charset_inputfile[$newdomain] == 'ISO-8859-1') $value=utf8_encode($value);
if (empty($this->charset_inputfile[$newdomain]) || $this->charset_inputfile[$newdomain] == 'ISO-8859-1') $value=utf8_encode($value);

//print 'XX'.$key;
$this->tab_translate[$key]=$value;

if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache
}
}
Expand All @@ -292,16 +295,12 @@ function Load($domain,$alt=0,$stopafterdirection=0,$forcelangdir='')
// To save lang content for usecachekey into cache
if ($usecachekey && sizeof($tabtranslatedomain))
{
$ressetcache=dol_setcache($usecachekey,$tabtranslatedomain);
if ($ressetcache < 0)
{
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
dol_syslog($error, LOG_ERR);
}
require_once(DOL_DOCUMENT_ROOT ."/lib/memory.lib.php");
$size=dol_setcache($usecachekey,$tabtranslatedomain);
}
//exit;

if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced, we do not stop loop.
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions htdocs/index.php
Expand Up @@ -20,7 +20,7 @@
/**
* \file htdocs/index.php
* \brief Dolibarr home page
* \version $Id: index.php,v 1.203 2011/08/17 22:13:26 eldy Exp $
* \version $Id: index.php,v 1.202 2011/08/15 17:43:43 eldy Exp $
*/

define('NOCSRFCHECK',1); // This is login page. We must be able to go on it from another web site.
Expand Down Expand Up @@ -90,7 +90,8 @@
}


print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_TRY_DIV)) print '<div class="fichecenter"><div class="fichethirdleft">';
else print '<table width="100%" class="notopnoleftnoright"><tr><td valign="top" class="notopnoleft">';


/*
Expand Down Expand Up @@ -254,7 +255,8 @@
}


print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
if (! empty($conf->global->MAIN_TRY_DIV)) print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
else print '</td><td width="65%" valign="top" class="notopnoleftnoright">';


/*
Expand Down Expand Up @@ -514,7 +516,8 @@
print '</table>'; // End table array


print '</div></div></div><div class="fichecenter"><br>';
if (! empty($conf->global->MAIN_TRY_DIV)) print '</div></div></div><div class="fichecenter"><br>';
else print '</td></tr></table>'; // End table left area



Expand All @@ -525,7 +528,7 @@
printBoxesArea($user,"0");


print '</div>';
if (! empty($conf->global->MAIN_TRY_DIV)) print '</div>';

/*
* Show security warnings
Expand Down Expand Up @@ -565,7 +568,7 @@

$db->close();

llxFooter('$Date: 2011/08/17 22:13:26 $ - $Revision: 1.203 $');
llxFooter('$Date: 2011/08/15 17:43:43 $ - $Revision: 1.202 $');


/**
Expand Down
14 changes: 6 additions & 8 deletions htdocs/lib/company.lib.php
Expand Up @@ -23,7 +23,7 @@
* \file htdocs/lib/company.lib.php
* \brief Ensemble de fonctions de base pour le module societe
* \ingroup societe
* \version $Id: company.lib.php,v 1.124 2011/08/17 19:43:18 hregis Exp $
* \version $Id: company.lib.php,v 1.123 2011/07/31 23:25:41 eldy Exp $
*/

/**
Expand Down Expand Up @@ -190,18 +190,16 @@ function societe_admin_prepare_head($object)
$head[$h][2] = 'general';
$h++;

$head[$h][0] = DOL_URL_ROOT.'/admin/societe_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin');

$head[$h][0] = DOL_URL_ROOT.'/admin/societe_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;

complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin','remove');

return $head;
}
Expand Down
16 changes: 7 additions & 9 deletions htdocs/lib/member.lib.php
Expand Up @@ -19,7 +19,7 @@
/**
* \file htdocs/lib/member.lib.php
* \brief Ensemble de fonctions de base pour les adherents
* \version $Id: member.lib.php,v 1.26 2011/08/17 19:43:18 hregis Exp $
* \version $Id: member.lib.php,v 1.25 2011/07/31 23:26:02 eldy Exp $
*
* Ensemble de fonctions de base de dolibarr sous forme d'include
*/
Expand Down Expand Up @@ -110,12 +110,6 @@ function member_admin_prepare_head($object)
$head[$h][2] = 'general';
$h++;

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'member_admin');

$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
Expand All @@ -125,8 +119,12 @@ function member_admin_prepare_head($object)
$head[$h][1] = $langs->trans("BlankSubscriptionForm");
$head[$h][2] = 'public';
$h++;

complete_head_from_modules($conf,$langs,$object,$head,$h,'member_admin','remove');

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'member_admin');

return $head;
}
Expand Down
28 changes: 12 additions & 16 deletions htdocs/lib/memory.lib.php
Expand Up @@ -19,7 +19,7 @@
/**
* \file htdocs/lib/memory.lib.php
* \brief Set of function for memory/cache management
* \version $Id: memory.lib.php,v 1.12 2011/08/17 21:39:08 eldy Exp $
* \version $Id: memory.lib.php,v 1.11 2011/07/31 23:25:11 eldy Exp $
*/

global $shmkeys,$shmoffset;
Expand All @@ -34,11 +34,10 @@


/**
* Save data into a memory area shared by all users, all sessions on server
*
* @param $memoryid Memory id of shared area
* @param $data Data to save
* @return int <0 if KO, Nb of bytes written if OK
* \brief Save data into a memory area shared by all users, all sessions on server
* \param $memoryid Memory id of shared area
* \param $data Data to save
* \return int <0 if KO, Nb of bytes written if OK
*/
function dol_setcache($memoryid,$data)
{
Expand All @@ -53,8 +52,7 @@ function dol_setcache($memoryid,$data)
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
//$m->setOption(Memcached::OPT_COMPRESSION, false);
//print "Add memoryid=".$memoryid;
$m->add($memoryid,$data); // This fails if key already exists
$m->add($memoryid,$data);
$rescode=$m->getResultCode();
if ($rescode == 0)
{
Expand All @@ -72,7 +70,7 @@ function dol_setcache($memoryid,$data)
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
//$m->setOption(Memcached::OPT_COMPRESSION, false);
$result=$m->add($memoryid,$data); // This fails if key already exists
$result=$m->add($memoryid,$data);
if ($result)
{
return sizeof($data);
Expand All @@ -92,10 +90,9 @@ function dol_setcache($memoryid,$data)
}

/**
* Read a memory area shared by all users, all sessions on server
*
* @param $memoryid Memory id of shared area
* @return int <0 if KO, data if OK
* \brief Read a memory area shared by all users, all sessions on server
* \param $memoryid Memory id of shared area
* \return int <0 if KO, data if OK
*/
function dol_getcache($memoryid)
{
Expand All @@ -109,10 +106,9 @@ function dol_getcache($memoryid)
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
//$m->setOption(Memcached::OPT_COMPRESSION, false);
//print "Get memoryid=".$memoryid;
$data=$m->get($memoryid);
$rescode=$m->getResultCode();
//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".sizeof($data)."\n<br>";
//print "memoryid=".$memoryid." - rescode=".$rescode." - date=".sizeof($data)."\n<br>";
//var_dump($data);
if ($rescode == 0)
{
Expand All @@ -131,7 +127,7 @@ function dol_getcache($memoryid)
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
//$m->setOption(Memcached::OPT_COMPRESSION, false);
$data=$m->get($memoryid);
//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".sizeof($data)."\n<br>";
//print "memoryid=".$memoryid." - rescode=".$rescode." - date=".sizeof($data)."\n<br>";
//var_dump($data);
if ($data)
{
Expand Down
35 changes: 28 additions & 7 deletions htdocs/main.inc.php
Expand Up @@ -25,7 +25,7 @@
* \file htdocs/main.inc.php
* \ingroup core
* \brief File that defines environment for Dolibarr pages only (variables not required by scripts)
* \version $Id: main.inc.php,v 1.763 2011/08/17 19:26:48 eldy Exp $
* \version $Id: main.inc.php,v 1.762 2011/08/17 09:51:39 cdelambert Exp $
*/

@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
Expand Down Expand Up @@ -137,6 +137,31 @@ function analyse_sql_and_script(&$var,$get)
// This include will set: $conf, $db, $langs, $user, $mysoc objects
require_once("master.inc.php");

// Activate error interceptions
/*
function processError($code, $message, $file, $line, $context)
{
$errmess='ERROR '.$file.' - '.$line.' - '.error_reporting()." - ".$code."<br>\n";
//print $errmess;
if (error_reporting() & $code) {
print $errmess;
throw new Exception($message, $code);
}
}
set_error_handler('processError');
*/

// GET and POST converter
/*
foreach($_REQUEST as $key => $value)
{
// For prevent conflict
$var = '__'.$key;
// Create variable with tested value
$$var = GETPOST($key);
}
*/

// Activate end of page function
register_shutdown_function('dol_shutdown');

Expand Down Expand Up @@ -1202,13 +1227,9 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
if (! empty($conf->browser->phone)) $loginhtmltext.='<br><b>'.$langs->trans("Phone").'</b>: '.$conf->browser->phone;
if (! empty($_SESSION["disablemodules"])) $loginhtmltext.='<br><b>'.$langs->trans("DisabledModules").'</b>: <br>'.join(', ',explode(',',$_SESSION["disablemodules"]));

$appli='Dolibarr';
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;

// Link info
$logouttext='';
$logouthtmltext=$appli.' '.DOL_VERSION.'<br>';
$logouthtmltext.=$langs->trans("Logout").'<br>';
$logouthtmltext=''; $logouttext='';
$logouthtmltext=$langs->trans("Logout").'<br>';
//$logouthtmltext.="<br>";
if ($_SESSION["dol_authmode"] != 'forceuser'
&& $_SESSION["dol_authmode"] != 'http')
Expand Down

0 comments on commit 051386b

Please sign in to comment.