num_section; break; case 'cms_editorial_parametres_perso': $index=$cms_object->get_num_type(); break; case 'cms_editorial_publications_states': $index=0; break; case 'cms_logo': $index=$cms_object->get_type().'_'.$cms_object->get_id(); break; default: $index=$cms_object->get_id(); break; } return $index; } /** * @param object $cms_object an storable cms object * @return bool true if exists in the array, false otherwise */ public static function get_at_cms_cache($cms_object){ if(!isset(self::$cms_cache_arrayObject[get_class($cms_object)][self::get_index($cms_object)])) { self::$cms_cache_arrayObject[get_class($cms_object)][self::get_index($cms_object)] = null; } if(is_null(self::$cms_cache_arrayObject[get_class($cms_object)][self::get_index($cms_object)])){ return false; }else{ return self::$cms_cache_arrayObject[get_class($cms_object)][self::get_index($cms_object)]; } } /** * @param object $cms_object an storable cms object */ public static function set_at_cms_cache($cms_object){ self::$cms_cache_arrayObject[get_class($cms_object)][self::get_index($cms_object)]=$cms_object; } /* * Private contructor */ private function __construct() {} /* * Prevent cloning of instance */ private function __clone() { throw new Exception('Clone is not allowed !'); } /* * Set the instance to null */ private function __destruct() { self::$cms_cache_arrayObject=null; } public static function clean_cache(){ pmb_mysql_query("TRUNCATE TABLE cms_cache_cadres"); } public static function clean_cache_img(){ global $base_path; self::rmdir_files($base_path.'/opac_css/temp/cms_vign'); //Il faut également vider le cache des cadres static::clean_cache(); } private static function rmdir_files($dir) { foreach(glob($dir . '/*') as $file) { if(is_dir($file)) self::rmdir_files($file); else @unlink($file); } @rmdir($dir); } public static function get_cache_formatted_last_date(){ global $msg, $charset; $query = "SELECT cache_cadre_create_date FROM cms_cache_cadres order by cache_cadre_create_date limit 1"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ return htmlentities($msg['cms_cache_date'], ENT_QUOTES, $charset)." : ".formatdate(pmb_mysql_result($result, 0, 'cache_cadre_create_date'), 1); } return ''; } }