Merge avec issue #0000082 (parti etablissement)

This commit is contained in:
Michael RICOIS 2010-03-18 16:27:18 +00:00
parent c95fd2ad0b
commit 6cf5419c94
4 changed files with 110 additions and 94 deletions

View File

@ -34,14 +34,14 @@
* 2. Lazy-connecting
* Creating an instance of Doctrine_Connection does not connect
* to database. Connecting to database is only invoked when actually needed
* (for example when query() is being called)
* (for example when query() is being called)
*
* 3. Convenience methods
* Doctrine_Connection provides many convenience methods such as fetchAll(), fetchOne() etc.
*
* 4. Modular structure
* Higher level functionality such as schema importing, exporting, sequence handling etc.
* is divided into modules. For a full list of connection modules see
* is divided into modules. For a full list of connection modules see
* Doctrine_Connection::$_modules
*
* @package Doctrine
@ -78,7 +78,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* The name of this connection driver.
*
* @var string $driverName
* @var string $driverName
*/
protected $driverName;
@ -160,7 +160,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @var array $serverInfo
*/
protected $serverInfo = array();
protected $options = array();
/**
@ -207,8 +207,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this->options['dsn'] = $adapter['dsn'];
$this->options['username'] = $adapter['user'];
$this->options['password'] = $adapter['pass'];
$this->options['other'] = array();
$this->options['other'] = array();
if (isset($adapter['other'])) {
$this->options['other'] = array(Doctrine::ATTR_PERSISTENT => $adapter['persistent']);
}
@ -237,10 +237,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* getOption
*
*
* Retrieves option
*
* @param string $option
* @param string $option
* @return void
*/
public function getOption($option)
@ -252,10 +252,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* setOption
*
*
* Set option value
*
* @param string $option
* @param string $option
* @return void
*/
public function setOption($option, $value)
@ -322,7 +322,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* setAttribute
* sets an attribute
*
* @todo why check for >= 100? has this any special meaning when creating
* @todo why check for >= 100? has this any special meaning when creating
* attributes?
*
* @param integer $attribute
@ -369,7 +369,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* Sets the name of the connection
*
* @param string $name
* @param string $name
* @return void
*/
public function setName($name)
@ -446,7 +446,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
public function getDbh()
{
$this->connect();
return $this->dbh;
}
@ -456,8 +456,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @return boolean
*/
public function connect()
{
public function connect() {
if ($this->isConnected) {
return false;
}
@ -468,28 +467,36 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$e = explode(':', $this->options['dsn']);
$found = false;
if (extension_loaded('pdo')) {
if (in_array($e[0], self::getAvailableDrivers())) {
try {
$this->dbh = new PDO($this->options['dsn'], $this->options['username'],
(!$this->options['password'] ? '':$this->options['password']), $this->options['other']);
$this->dbh = new PDO($this->options['dsn'],
$this->options['username'],
($this->options['password'] ?
$this->options['password'] : ''),
$this->options['other']);
$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->dbh->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
throw new Doctrine_Connection_Exception('PDO Connection Error: ' . $e->getMessage());
throw new Doctrine_Connection_Exception(
'PDO Connection Error: '.$e->getMessage());
}
$found = true;
}
}
if ( ! $found) {
$class = 'Doctrine_Adapter_' . ucwords($e[0]);
if (! $found) {
$class = 'Doctrine_Adapter_'.ucwords($e[0]);
if (class_exists($class)) {
$this->dbh = new $class($this->options['dsn'], $this->options['username'], $this->options['password']);
$this->dbh = new $class($this->options['dsn'],
$this->options['username'],
$this->options['password']);
} else {
throw new Doctrine_Connection_Exception("Couldn't locate driver named " . $e[0]);
throw new Doctrine_Connection_Exception(
"Couldn't locate driver named ".$class);
}
}
@ -507,8 +514,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this->getListener()->postConnect($event);
return true;
}
public function incrementQueryCount()
public function incrementQueryCount()
{
$this->_count++;
}
@ -620,7 +627,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$query = 'DELETE FROM '
. $this->quoteIdentifier($table->getTableName())
. ' WHERE ' . implode(' AND ', $tmp);
return $this->exec($query, array_values($identifier));
}
@ -655,7 +662,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
. ' SET ' . implode(', ', $set)
. ' WHERE ' . implode(' = ? AND ', $this->quoteMultipleIdentifier($table->getIdentifierColumnNames()))
. ' = ?';
return $this->exec($sql, $params);
}
@ -730,13 +737,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
// quick fix for the identifiers that contain a dot
if (strpos($str, '.')) {
$e = explode('.', $str);
return $this->formatter->quoteIdentifier($e[0], $checkOption) . '.'
return $this->formatter->quoteIdentifier($e[0], $checkOption) . '.'
. $this->formatter->quoteIdentifier($e[1], $checkOption);
}
return $this->formatter->quoteIdentifier($str, $checkOption);
}
/**
* quoteMultipleIdentifier
* Quotes multiple identifier strings
@ -802,7 +809,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public function fetchAll($statement, array $params = array())
public function fetchAll($statement, array $params = array())
{
return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC);
}
@ -815,7 +822,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param int $colnum 0-indexed column number to retrieve
* @return mixed
*/
public function fetchOne($statement, array $params = array(), $colnum = 0)
public function fetchOne($statement, array $params = array(), $colnum = 0)
{
return $this->execute($statement, $params)->fetchColumn($colnum);
}
@ -827,7 +834,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public function fetchRow($statement, array $params = array())
public function fetchRow($statement, array $params = array())
{
return $this->execute($statement, $params)->fetch(Doctrine::FETCH_ASSOC);
}
@ -839,7 +846,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public function fetchArray($statement, array $params = array())
public function fetchArray($statement, array $params = array())
{
return $this->execute($statement, $params)->fetch(Doctrine::FETCH_NUM);
}
@ -852,7 +859,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param int $colnum 0-indexed column number to retrieve
* @return array
*/
public function fetchColumn($statement, array $params = array(), $colnum = 0)
public function fetchColumn($statement, array $params = array(), $colnum = 0)
{
return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_COLUMN, $colnum);
}
@ -864,7 +871,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public function fetchAssoc($statement, array $params = array())
public function fetchAssoc($statement, array $params = array())
{
return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC);
}
@ -876,7 +883,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public function fetchBoth($statement, array $params = array())
public function fetchBoth($statement, array $params = array())
{
return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_BOTH);
}
@ -918,17 +925,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
try {
$event = new Doctrine_Event($this, Doctrine_Event::CONN_PREPARE, $statement);
$this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event);
$stmt = false;
if ( ! $event->skipOperation) {
$stmt = $this->dbh->prepare($statement);
}
$this->getAttribute(Doctrine::ATTR_LISTENER)->postPrepare($event);
return new Doctrine_Connection_Statement($this, $stmt);
} catch(Doctrine_Adapter_Exception $e) {
} catch(PDOException $e) { }
@ -955,7 +962,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return Doctrine_Record|false Doctrine_Record object on success,
* boolean false on failure
*/
public function queryOne($query, array $params = array())
public function queryOne($query, array $params = array())
{
$parser = new Doctrine_Query($this);
@ -1078,7 +1085,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$event = new Doctrine_Event($this, Doctrine_Event::CONN_ERROR);
$this->getListener()->preError($event);
$name = 'Doctrine_Connection_' . $this->driverName . '_Exception';
$exc = new $name($e->getMessage(), (int) $e->getCode());
@ -1090,7 +1097,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if ($this->getAttribute(Doctrine::ATTR_THROW_EXCEPTIONS)) {
throw $exc;
}
$this->getListener()->postError($event);
}
@ -1117,7 +1124,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if (isset($this->tables[$name])) {
return $this->tables[$name];
}
$class = $name . 'Table';
if (class_exists($class, $this->getAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES)) &&
@ -1126,7 +1133,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} else {
$table = new Doctrine_Table($name, $this, true);
}
return $table;
}
@ -1197,11 +1204,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
return $this->getTable($name)->create();
}
/**
* Creates a new Doctrine_Query object that operates on this connection.
*
* @return Doctrine_Query
*
* @return Doctrine_Query
*/
public function createQuery()
{
@ -1267,7 +1274,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this->getAttribute(Doctrine::ATTR_LISTENER)->preClose($event);
$this->clear();
unset($this->dbh);
$this->isConnected = false;
@ -1309,7 +1316,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $this->dbh->errorInfo();
}
/**
* getCacheDriver
*
@ -1320,7 +1327,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
return $this->getResultCacheDriver();
}
/**
* getResultCacheDriver
*
@ -1334,7 +1341,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $this->getAttribute(Doctrine::ATTR_RESULT_CACHE);
}
/**
* getQueryCacheDriver
*
@ -1355,7 +1362,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Returns the ID of the last inserted row, or the last value from a sequence object,
* depending on the underlying driver.
*
* Note: This method may not return a meaningful or consistent result across different drivers,
* Note: This method may not return a meaningful or consistent result across different drivers,
* because the underlying database may not even support the notion of auto-increment fields or sequences.
*
* @param string $table name of the table into which a new row was inserted
@ -1383,7 +1390,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
return $this->transaction->beginTransaction($savepoint);
}
public function beginInternalTransaction($savepoint = null)
{
return $this->transaction->beginInternalTransaction($savepoint);
@ -1417,7 +1424,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* this method can be listened with onPreTransactionRollback and onTransactionRollback
* eventlistener methods
*
* @param string $savepoint name of a savepoint to rollback to
* @param string $savepoint name of a savepoint to rollback to
* @throws Doctrine_Transaction_Exception if the rollback operation fails at database level
* @return boolean false if rollback couldn't be performed, true otherwise
*/
@ -1503,13 +1510,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* which is always guaranteed to exist. Mysql: 'mysql', PostgreSQL: 'postgres', etc.
* This value is set in the Doctrine_Export_{DRIVER} classes if required
*
* @param string $info
* @param string $info
* @return void
*/
public function getTmpConnection($info)
{
$pdoDsn = $info['scheme'] . ':';
if ($info['unix_socket']) {
$pdoDsn .= 'unix_socket=' . $info['unix_socket'] . ';';
}
@ -1545,7 +1552,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
return $query;
}
/**
* Creates dbms specific LIMIT/OFFSET SQL for the subqueries that are used in the
* context of the limit-subquery algorithm.
@ -1583,7 +1590,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* Unserialize. Recreate connection from serialized content
*
* @param string $serialized
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
@ -1640,7 +1647,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
$generated = implode('_', $parts);
// If the final length is greater than 64 we need to create an abbreviated fk name
if (strlen(sprintf($format, $generated)) > $maxLength) {
$generated = '';
@ -1661,9 +1668,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if (is_numeric($end)) {
unset($e[count($e) - 1]);
$fkName = implode('_', $e);
$name = $fkName . '_' . ++$end;
} else {
$name .= '_1';
$name = $fkName . '_' . ++$end;
} else {
$name .= '_1';
}
}

View File

@ -130,10 +130,13 @@ class MMap {
$this->adresseValidee=strtoupper(@getTextInHtml($this->body, '<address>', 'adress>', '</address>'));
$strTmp=@getTextInHtml($this->body, '<Point><coordinates>', '<coordinates>', '</coordinates>');
$tabTmp=explode(',', $strTmp);
$this->latitudeDec=$tabTmp[1];
$this->longitudeDec=$tabTmp[0];
$this->latitudeDeg=dec2dms($this->latitudeDec);
$this->longitudeDeg=dec2dms($this->longitudeDec);
if (isset($tabTmp[1]) == false) {
return false;
}
$this->latitudeDec = $tabTmp[1];
$this->longitudeDec = $tabTmp[0];
$this->latitudeDeg = dec2dms($this->latitudeDec);
$this->longitudeDeg = dec2dms($this->longitudeDec);
/*
200 G_GEO_SUCCESS No errors occurred; the address was successfully parsed and its geocode has been returned.

View File

@ -1150,14 +1150,18 @@ public function rechercheDir($nom, $prenom='', $fonction='', $dateNaiss='', $vil
$tab=$tabUpdate;
}
if ($tab['precis']==0) {
$mMap=new MMap($etab['adr_num'].' '.$this->getCodeVoie($etab['adr_typeVoie']).' '.$etab['adr_libVoie'], $etab['adr_cp'], $etab['adr_ville']);
$tabUpdate=array( 'latitude'=>$mMap->latitudeDec,
'longitude'=>$mMap->longitudeDec,
'precis'=>$mMap->precision,
);
$this->iDb->update('infos_entrep', $tabUpdate, "siren=$siren");
$tab=array_merge($tab,$tabUpdate);
if ($tab['precis'] == 0) {
$mMap = new MMap($etab['adr_num'].' '.
$this->getCodeVoie($etab['adr_typeVoie']).
' '.$etab['adr_libVoie'],
$etab['adr_cp'],
$etab['adr_ville']);
$tabUpdate = array('latitude' => $mMap->latitudeDec,
'longitude'=> $mMap->longitudeDec,
'precis' => $mMap->precision, );
$this->iDb->update('infos_entrep', $tabUpdate,
"siren=$siren");
$tab = array_merge($tab,$tabUpdate);
}
if ($siren*1>0) {

View File

@ -13,6 +13,7 @@ if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14) die('Paramètr
$idEntreprise=trim(preg_replace('/[^0-9]/', '', $_REQUEST['idEntreprise']))*1; // Si id=0 alors non communiqué
if (($siret*1)==0 && $idEntreprise==0) die('Paramètres incorrects !');
$siren = substr($siret,0,9);
$raisonSociale = etabSession($siren, $idEntreprise);
$mil = false;
//Générer un nom de fichier pour le cache et l'export des fichiers
@ -55,7 +56,7 @@ $(document).ready(function(){
});
//-->
</script>
<?php
<?php
}*/
?>
<div id="center">
@ -86,9 +87,9 @@ $(document).ready(function(){
else $type='établissement ';
if ($etab['Actif']==1) $type.='actif';
else $type.='inactif';
if($etab['Nic']*1==0 || $etab['Nic']*1>=99990) $type.=' provisoire';
$lien='<a title="Voir la fiche d\'identité" href="/?page=identite&siret='.$siren.$etab['Nic'].'&idEntreprise='.$idEntreprise.'">';
?>
<tr>
@ -113,25 +114,26 @@ $(document).ready(function(){
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" width="506" class="StyleInfoData" id="carte">
<?php
if (count($etabs)==0)
{
echo 'Aucun &eacute;tablissement n\'est pr&eacute;sent dans notre base';
}
elseif (preg_match('/\bCARTES\b/i', $_SESSION['tabInfo']['pref']))
{
echo '<iframe src="/?page=carte&siret='.$siren.'" width=506 height=505 marginheight="1" marginwidth="1" scrolling="No" frameborder=0></iframe>';
}
?>
</td>
<td width="30">&nbsp;</td>
<td colspan="2" width="506" class="StyleInfoData">
<?php
if (count($etabs) == 0) {
print 'Aucun &eacute;tablissement n\'est pr&eacute;sent dans notre base';
} else if (preg_match('/\bCARTES\b/i', $_SESSION['tabInfo']['pref'])) {
print '<iframe src="/?page=carte&siret='.$siren.
'" width=506 height=505 marginheight="1" marginwidth="1"'.
' scrolling="No" frameborder=0></iframe>';
}
?>
</td>
</tr>
</table>
</div>
<?php
<?php
//Exportation des données sous forme de fichier
function htmldecode($value){
$value = is_array($value) ? array_map('htmldecode', $value) : html_entity_decode($value, ENT_QUOTES, 'UTF-8');