diff --git a/build/exe/doliwamp/php.ini.install b/build/exe/doliwamp/php.ini.install index dc7b8dd3428..b208c9af287 100644 --- a/build/exe/doliwamp/php.ini.install +++ b/build/exe/doliwamp/php.ini.install @@ -688,7 +688,7 @@ extension=php_pdo_mysql.dll ;extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_pspell.dll -;extension=php_shmop.dll +extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll extension=php_sockets.dll diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index e55f82869ec..66576f8cef9 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -28,6 +28,7 @@ */ require_once("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/agenda.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); @@ -128,23 +129,8 @@ if ($objectid > 0) $contact->fetch($act->contact->id); $act->contact=$contact; - $h=0; - - $head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objectid; - $head[$h][1] = $langs->trans("CardAction"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$objectid; - $head[$h][1] = $langs->trans('Documents'); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$objectid; - $head[$h][1] = $langs->trans('Info'); - $h++; - - dol_fiche_head($head, $hselected, $langs->trans("Action"),0,'task'); + $head=actions_prepare_head(); + dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'task'); // Affichage fiche action en mode visu print '
| ';
diff --git a/htdocs/lib/agenda.lib.php b/htdocs/lib/agenda.lib.php
index a5470fc7210..5b85d1cf4c0 100644
--- a/htdocs/lib/agenda.lib.php
+++ b/htdocs/lib/agenda.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2008-2009 Laurent Destailleur \n"; + if (! function_exists("shmop_open")) return 0; + $handle=@shmop_open($shmkey,'a',0,0); + if ($handle) + { + $data=unserialize(shmop_read($handle,0,$size)); + shmop_close($handle); + } + return $data; +} + +/** \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_setshmop($memoryid,$data,$size=0) +{ + $shmkey = ftok($memoryid, 'D'); + $newdata=serialize($data); + if (! $size) $size=strlen($newdata); + print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".strlen($newdata)."bytes size=".$size." \n"; + if (! function_exists("shmop_write")) return 0; + $handle=shmop_open($shmkey,'c',0644,$size); + if ($handle) + { + $shm_bytes_written=shmop_write($handle,$newdata,0); + if ($shm_bytes_written != strlen($newdata)) + { + print "Couldn't write the entire length of data\n"; + } + shmop_close($handle); + return $shm_bytes_written; + } + else + { + print 'Error in shmop_open'; + return -1; + } +} + + +/** + * Declare function ftok + */ +if( !function_exists('ftok') ) +{ + function ftok($filename = "", $proj = "") + { + $filename = $filename . $proj; + for ($key = array(); sizeof($key) < strlen($filename); $key[] = ord(substr($filename, sizeof($key), 1))); + return dechex(array_sum($key)); + } +} + +?> diff --git a/htdocs/translate.class.php b/htdocs/translate.class.php index 6b7967f82b3..3c4ee29279a 100644 --- a/htdocs/translate.class.php +++ b/htdocs/translate.class.php @@ -38,8 +38,8 @@ class Translate { var $defaultlang; // Langue courante en vigueur de l'utilisateur var $direction = 'ltr'; // Left to right or Right to left - var $tab_loaded=array(); // Tableau pour signaler les fichiers deja charges 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 @@ -215,31 +215,37 @@ class Translate { // Directory of translation files $scandir = $searchdir."/".$langofdir; $file_lang = $scandir . "/".$newdomain.".lang"; - $filelangexists=is_file($file_lang); + $file_lang_osencoded=dol_osencode($file_lang); + $filelangexists=is_file($file_lang_osencoded); //dol_syslog('Translate::Load Try to read for alt='.$alt.' langofdir='.$langofdir.' file_lang='.$file_lang." => ".$filelangexists); if ($filelangexists) { - // Enable cache of lang file in session (faster but need more memory) + $found=false; + + // Enable cache of lang file in memory (faster but need more memory) // Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) - $enablelangcacheinsession=false; - - if ($enablelangcacheinsession && isset($_SESSION['lang_'.$newdomain])) + $enablelangcacheinmemory=false; + if ($enablelangcacheinmemory) { - foreach($_SESSION['lang_'.$newdomain] as $key => $value) + require_once(DOL_DOCUMENT_ROOT ."/lib/memory.lib.php"); + $tmparray=dol_getshmop('DOL_LANG_'.DOL_VERSION.'_'.$newdomain,65536); + if (is_array($tmparray) && sizeof($tmparray)) { - $this->tab_translate[$key]=$value; - $this->tab_loaded[$newdomain]=3; // Set this file as loaded from cache in session + $this->tab_translate=$tmparray; + $this->tab_loaded[$newdomain]=3; // Set this file as loaded from cache in session + $found=true; } } - else + + if (! $found) { if ($fp = @fopen($file_lang,"rt")) { - if ($enablelangcacheinsession) $tabtranslatedomain=array(); // To save lang in session - $finded = 0; - while (($ligne = fgets($fp,4096)) && ($finded == 0)) + if ($enablelangcacheinmemory) $tabtranslatedomain=array(); // To save lang in session + + while ($ligne = fgets($fp,4096)) // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents { if ($ligne[0] != "\n" && $ligne[0] != " " && $ligne[0] != "#") { @@ -272,17 +278,21 @@ class Translate { //print 'XX'.$key; $this->tab_translate[$key]=$value; - if ($enablelangcacheinsession) $tabtranslatedomain[$key]=$value; // To save lang in session + if ($enablelangcacheinmemory) $tabtranslatedomain[$key]=$value; // To save lang in session } } } } - $fileread=1; fclose($fp); - + $fileread=1; + // To save lang in session - if ($enablelangcacheinsession && sizeof($tabtranslatedomain)) $_SESSION['lang_'.$newdomain]=$tabtranslatedomain; - + if ($enablelangcacheinmemory && sizeof($tabtranslatedomain)) + { + require_once(DOL_DOCUMENT_ROOT ."/lib/memory.lib.php"); + $size=dol_setshmop('DOL_LANG_'.DOL_VERSION.'_'.$newdomain,$tabtranslatedomain,65536); + } +//exit; break; // Break loop on each root dir } } |