Remove binary adapters

This commit is contained in:
Romain Neutron
2012-04-25 13:33:15 +02:00
parent 0896b2073a
commit 97b635e6b4

View File

@@ -91,15 +91,12 @@ class databox extends base
protected static $_instances = array(); protected static $_instances = array();
const BASE_TYPE = self::DATA_BOX; const BASE_TYPE = self::DATA_BOX;
const CACHE_META_STRUCT = 'meta_struct'; const CACHE_META_STRUCT = 'meta_struct';
const CACHE_THESAURUS = 'thesaurus'; const CACHE_THESAURUS = 'thesaurus';
const CACHE_COLLECTIONS = 'collections'; const CACHE_COLLECTIONS = 'collections';
const CACHE_STRUCTURE = 'structure'; const CACHE_STRUCTURE = 'structure';
const PIC_PDF = 'logopdf'; const PIC_PDF = 'logopdf';
protected $cache; protected $cache;
protected $connection; protected $connection;
protected $registry; protected $registry;
@@ -118,7 +115,7 @@ class databox extends base
$connection_params = phrasea::sbas_params(); $connection_params = phrasea::sbas_params();
if (!isset($connection_params[$sbas_id])) if ( ! isset($connection_params[$sbas_id]))
throw new Exception_DataboxNotFound (); throw new Exception_DataboxNotFound ();
$this->host = $connection_params[$sbas_id]['host']; $this->host = $connection_params[$sbas_id]['host'];
@@ -207,7 +204,7 @@ class databox extends base
{ {
assert(is_int($sbas_id)); assert(is_int($sbas_id));
assert($sbas_id > 0); assert($sbas_id > 0);
if (!array_key_exists($sbas_id, self::$_instances)) if ( ! array_key_exists($sbas_id, self::$_instances))
{ {
self::$_instances[$sbas_id] = new self($sbas_id); self::$_instances[$sbas_id] = new self($sbas_id);
} }
@@ -302,7 +299,7 @@ class databox extends base
foreach ($rs as $rowbas) foreach ($rs as $rowbas)
{ {
if (!isset($trows[$rowbas[$sortk1]])) if ( ! isset($trows[$rowbas[$sortk1]]))
$trows[$rowbas[$sortk1]] = array(); $trows[$rowbas[$sortk1]] = array();
$trows[$rowbas[$sortk1]][$rowbas[$sortk2]] = array( $trows[$rowbas[$sortk1]][$rowbas[$sortk2]] = array(
"coll_id" => $rowbas["coll_id"], "coll_id" => $rowbas["coll_id"],
@@ -451,7 +448,6 @@ class databox extends base
$stmt->closeCursor(); $stmt->closeCursor();
if ($row) if ($row)
return self::get_instance((int) $row['sbas_id']); return self::get_instance((int) $row['sbas_id']);
try try
@@ -576,8 +572,9 @@ class databox extends base
public function get_meta_structure() public function get_meta_structure()
{ {
if ($this->meta_struct) if ($this->meta_struct)
{
return $this->meta_struct; return $this->meta_struct;
}
try try
{ {
@@ -625,8 +622,10 @@ class databox extends base
*/ */
public function get_subdef_structure() public function get_subdef_structure()
{ {
if (!$this->subdef_struct) if ( ! $this->subdef_struct)
{
$this->subdef_struct = new databox_subdefsStructure($this); $this->subdef_struct = new databox_subdefsStructure($this);
}
return $this->subdef_struct; return $this->subdef_struct;
} }
@@ -637,9 +636,9 @@ class databox extends base
* @param <type> $date * @param <type> $date
* @return <type> * @return <type>
*/ */
public static function dispatch($repository_path, $date=false) public static function dispatch($repository_path, $date = false)
{ {
if (!$date) if ( ! $date)
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
$repository_path = p4string::addEndSlash($repository_path); $repository_path = p4string::addEndSlash($repository_path);
@@ -649,7 +648,7 @@ class databox extends base
$day = date('d', strtotime($date)); $day = date('d', strtotime($date));
$n = 0; $n = 0;
$comp = $year . '/' . $month . '/' . $day . '/'; $comp = $year . DIRECTORY_SEPARATOR . $month . DIRECTORY_SEPARATOR . $day . DIRECTORY_SEPARATOR;
$condition = true; $condition = true;
@@ -657,10 +656,13 @@ class databox extends base
while (($pathout = $repository_path . $comp . self::addZeros($n)) && is_dir($pathout) && self::more_than_limit_in_dir($pathout)) while (($pathout = $repository_path . $comp . self::addZeros($n)) && is_dir($pathout) && self::more_than_limit_in_dir($pathout))
{ {
$n++; $n ++;
} }
if (!is_dir($pathout))
if ( ! is_dir($pathout))
{
system_file::mkdir($pathout); system_file::mkdir($pathout);
}
return p4string::addEndSlash($pathout); return p4string::addEndSlash($pathout);
@@ -693,13 +695,12 @@ class databox extends base
{ {
if ($file != '.' && $file != '..') if ($file != '.' && $file != '..')
{ {
$n++; $n ++;
} }
} }
} }
} }
if ($n > $limit) if ($n > $limit)
return true; return true;
return false; return false;
@@ -949,7 +950,7 @@ class databox extends base
$src = trim(isset($field['src']) ? $field['src'] : ''); $src = trim(isset($field['src']) ? $field['src'] : '');
$meta_id = isset($field['meta_id']) ? $field['meta_id'] : null; $meta_id = isset($field['meta_id']) ? $field['meta_id'] : null;
if (!is_null($meta_id)) if ( ! is_null($meta_id))
continue; continue;
@@ -1035,7 +1036,7 @@ class databox extends base
$stmt->execute(array(':coll_id' => $row['coll_id'], ':sbas_id' => $this->get_sbas_id())); $stmt->execute(array(':coll_id' => $row['coll_id'], ':sbas_id' => $this->get_sbas_id()));
$base_ids[] = $base_id = $conn->lastInsertId(); $base_ids[] = $base_id = $conn->lastInsertId();
if (!empty($row['logo'])) if ( ! empty($row['logo']))
{ {
file_put_contents($registry->get('GV_RootPath') . 'config/minilogos/' . $base_id, $row['logo']); file_put_contents($registry->get('GV_RootPath') . 'config/minilogos/' . $base_id, $row['logo']);
} }
@@ -1216,7 +1217,6 @@ class databox extends base
public function get_structure() public function get_structure()
{ {
if ($this->structure) if ($this->structure)
return $this->structure; return $this->structure;
$this->structure = $this->retrieve_structure(); $this->structure = $this->retrieve_structure();
@@ -1257,7 +1257,6 @@ class databox extends base
public function get_cterms() public function get_cterms()
{ {
if ($this->cterms) if ($this->cterms)
return $this->cterms; return $this->cterms;
$sql = "SELECT value FROM pref WHERE prop='cterms'"; $sql = "SELECT value FROM pref WHERE prop='cterms'";
@@ -1395,7 +1394,7 @@ class databox extends base
continue; continue;
} }
if (!isset($AvSubdefs[$subdefgroup_name])) if ( ! isset($AvSubdefs[$subdefgroup_name]))
$AvSubdefs[$subdefgroup_name] = array(); $AvSubdefs[$subdefgroup_name] = array();
foreach ($subdefs as $sd) foreach ($subdefs as $sd)
@@ -1407,7 +1406,7 @@ class databox extends base
$errors[] = _('ERREUR : Les name de subdef sont uniques par groupe de subdefs et necessaire'); $errors[] = _('ERREUR : Les name de subdef sont uniques par groupe de subdefs et necessaire');
continue; continue;
} }
if (!in_array($sd_class, array('thumbnail', 'preview', 'document'))) if ( ! in_array($sd_class, array('thumbnail', 'preview', 'document')))
{ {
$errors[] = _('ERREUR : La classe de subdef est necessaire et egal a "thumbnail","preview" ou "document"'); $errors[] = _('ERREUR : La classe de subdef est necessaire et egal a "thumbnail","preview" ou "document"');
continue; continue;
@@ -1424,7 +1423,6 @@ class databox extends base
public function get_cgus() public function get_cgus()
{ {
if ($this->cgus) if ($this->cgus)
return $this->cgus; return $this->cgus;
$this->load_cgus(); $this->load_cgus();
@@ -1461,7 +1459,7 @@ class databox extends base
$avLanguages = User_Adapter::avLanguages(); $avLanguages = User_Adapter::avLanguages();
foreach ($avLanguages as $lang) foreach ($avLanguages as $lang)
foreach ($lang as $k => $v) foreach ($lang as $k => $v)
if (!isset($TOU[$k])) if ( ! isset($TOU[$k]))
$missing_locale[] = $k; $missing_locale[] = $k;
$date_obj = new DateTime(); $date_obj = new DateTime();