# HG changeset patch # User Franck Deroche # Date 1201604354 -3600 # Node ID 13972ea0af0cd76bc775d372bb08547e61f9cfed # Parent d0b737b2b398136b9b2876841b7b690db6cd3ce7# Parent 77b3ed19aab9aca751e621fc9c3e9d3135b95157 Merge diff -r 77b3ed19aab9 -r 13972ea0af0c admin.js --- a/admin.js Wed Nov 21 23:33:48 2007 +0100 +++ b/admin.js Tue Jan 29 11:59:14 2008 +0100 @@ -47,7 +47,8 @@ var editFilter = { acceptNode: function(node) { - if(node.nodeName == 'a' && node.firstChild && node.firstChild.nodeValue == 'Editer') return NodeFilter.FILTER_ACCEPT; + if(node.nodeName == 'a' && node.firstChild && node.firstChild.nodeValue == 'Editer') + return NodeFilter.FILTER_ACCEPT; return NodeFilter.FILTER_SKIP; } } @@ -181,6 +182,7 @@ var data = xmlRequest.get("admin_xml.php?type=" + type + "&id=" + id); el.parentNode.appendChild(editPost); el.editPostIsShown = 1; + el.parentNode.parentNode.className = 'Pinned'; editPost.style.display = 'block'; editPost.Titre.value = data.getElementsByTagName('titre')[0].textContent; editPost.Contenu.value = data.getElementsByTagName('contenu')[0].firstChild.data; @@ -206,8 +208,9 @@ } } else { - hideForms(); - el.editPostIsShown = 0; + hideForms(); + el.parentNode.parentNode.className = ''; + el.editPostIsShown = 0; } } diff -r 77b3ed19aab9 -r 13972ea0af0c admin.php --- a/admin.php Wed Nov 21 23:33:48 2007 +0100 +++ b/admin.php Tue Jan 29 11:59:14 2008 +0100 @@ -138,7 +138,7 @@ $ar_Version[] = $versionAc; $i++; } - $Titre=$Data->utf8_ensure($val['Titre']); + $Titre=TextUtils::EnsureUTF8($val['Titre']); echo(" \t
  • {$Titre}Editer -- Supprimer -- GĂ©rer les commentaires
  • "); } diff -r 77b3ed19aab9 -r 13972ea0af0c includes/class.dataaccess.php --- a/includes/class.dataaccess.php Wed Nov 21 23:33:48 2007 +0100 +++ b/includes/class.dataaccess.php Tue Jan 29 11:59:14 2008 +0100 @@ -4,38 +4,41 @@ var $user; var $pass; var $db; - var $arResult; - var $query; + var $link; var $connOpen; + var $results; + var $queries; var $_nbQueries; - var $infos; // Cache contenant les informations sur le visiteur - - function DataAccess($host=DB_HOST, $user=DB_USER, $pass=DB_PASSWORD) { + function DataAccess($host=DB_HOST, $user=DB_USER, $pass=DB_PASSWORD, $db=DB_NAME) { $this->host=$host; $this->user=$user; $this->pass=$pass; + $this->db = $db; + $this->connOpen = 0; $this->_nbQueries = 0; + $this->queries = array(); + $this->results = array(); $this->Connect(); } - function Connect($db=DB_NAME) { - if($this->connOpen == 1) return; - $this->db=$db; - $this->connOpen=1; - mysql_connect($this->host, $this->user, $this->pass); - mysql_select_db($this->db); + function Connect() { + if($this->connOpen == 0) { + $this->link = mysql_connect($this->host, $this->user, $this->pass); + mysql_select_db($this->db, $this->link); + } + $this->connOpen++; } function Query($query, $id=0) { - $this->query=$query; - if($this->connOpen != 1) $this->Connect(); - $this->arResult[$id]=mysql_query($this->query); - if($this->connOpen != 1) $this->Close(); - if(@$num_rows=mysql_num_rows($this->arResult[$id])) + $this->_nbQueries++; + $this->queries[$id]=$query; + $this->Connect(); + $this->results[$id]=mysql_query($this->queries[$id], $this->link); + $this->Close(); + if(@$num_rows=mysql_num_rows($this->results[$id])) return $num_rows; - else - return 0; + return 0; } function debugQuery($query, $id=0) { @@ -46,24 +49,17 @@ } function GetRow($id=0) { - if(@$row=mysql_fetch_assoc($this->arResult[$id])) { - foreach($row as $key => $value) - $row_utf[$key]=$this->utf8_ensure($value); - return $row_utf; - } - return 0; - } - - function GetRawRow($id=0) { - if(@$row=mysql_fetch_array($this->arResult[$id])) { + if(@$row=mysql_fetch_array($this->results[$id])) { return $row; } return 0; } function Close() { - $this->connOpen=0; - mysql_close(); + $this->connOpen--; + if($this->connOpen == 0) { + mysql_close($this->link); + } } function getNbQueries() { @@ -73,27 +69,5 @@ function formatDate($timestamp, $decallage=2, $pattern='d/m/Y H:i:s') { return gmdate($pattern, $timestamp + $decallage * 3600); } - - function seems_utf8($Str) { - for ($i=0; $iseems_utf8($Str)?$Str:utf8_encode($Str); - } - } ?> diff -r 77b3ed19aab9 -r 13972ea0af0c includes/class.post.php --- a/includes/class.post.php Wed Nov 21 23:33:48 2007 +0100 +++ b/includes/class.post.php Tue Jan 29 11:59:14 2008 +0100 @@ -19,7 +19,7 @@ array('

    ', '

    '), array('

    ', '

    '), $infos['Message']); - $Mess = Factory::getDB()->utf8_ensure($Mess); + $Mess = TextUtils::EnsureUTF8($Mess); $this->mess = $this->tpl->getDocumentFragment(); $this->mess->appendXML($Mess); diff -r 77b3ed19aab9 -r 13972ea0af0c includes/class.textutils.php --- a/includes/class.textutils.php Wed Nov 21 23:33:48 2007 +0100 +++ b/includes/class.textutils.php Tue Jan 29 11:59:14 2008 +0100 @@ -40,5 +40,26 @@ public static function getMonthName($monthNumber) { return ucfirst(strftime('%B', strtotime('2007-' . $monthNumber . '-01'))); } + + public static function EnsureUTF8($string) { + return TextUtils::SeemsUTF8($string) ? $string : utf8_encode($string); + } + + public static function SeemsUTF8($Str) { + for ($i=0; $i