'));
+ $mail->MsgHTML(strip_tags($body, '
- '));
foreach ($files as $f)
{
diff --git a/lib/classes/module/report.class.php b/lib/classes/module/report.class.php
index 5cd459a819..4d4eb62210 100644
--- a/lib/classes/module/report.class.php
+++ b/lib/classes/module/report.class.php
@@ -23,171 +23,205 @@ class module_report
* @var string - timestamp
*/
protected $dmin;
+
/**
* End date of the report
* @var string - timestamp
*/
protected $dmax;
+
/**
* Id of the base we want to connect
* @var int
*/
protected $sbas_id;
+
/**
* Id of the current app's box user
* @var int
*/
protected $user_id;
+
/**
* The result of the report
* @var array
*/
public $report = array();
+
/**
* The title of the report
* @var string
*/
protected $title = '';
+
/**
* default displayed value in the formated tab
* @var array
*/
protected $display = array();
+
/**
* ?
* @var
*/
protected $default_display = array();
+
/**
* Contain all the field from the sql request
* @var array
*/
protected $champ = array();
+
/**
* result of the report
* @var array
*/
protected $result = array();
+
/**
* The id of all collections from a databox
* @var string
*/
protected $list_coll_id = '';
+
/**
* The number of record displayed by page if enable limit is false
* @var int
*/
protected $nb_record = 30;
+
/**
* The current number of the page where are displaying the results
* @var int
*/
protected $nb_page = 1;
+
/**
* check if there is a previous page
* @var
*/
protected $previous_page = false;
+
/**
* check if there is a next page
* @var
*/
protected $next_page = false;
+
/**
*
* @var int total of result
*/
protected $total = 0;
+
/**
* the request executed
*/
protected $req = '';
+
/**
* the request executed
*/
protected $params = array();
+
/**
* do we display next and previous button
* @var bool
*/
protected $display_nav = false;
+
/**
* do we display the configuration button
* @var
*/
protected $config = true;
+
/**
* gettext tags for days
* @var
*/
protected $jour;
+
/**
* gettext tags for month
* @var
*/
protected $month;
+
/**
* The name of the database
* @var string
*/
protected $dbname;
+
/**
* The periode displayed in a string of the report
* @var string
*/
protected $periode;
+
/**
* filter executed on report choose by the user
* @var array;
*/
protected $tab_filter = array();
+
/**
* column displayed in the report choose by the user
* @var
*/
protected $active_column = array();
+
/**
* array that contains the string displayed
* foreach filters
* @var
*/
protected $posting_filter = array();
+
/**
* The ORDER BY filters of the query
* by default is empty
* @var array
*/
protected $tab_order = array();
+
/**
* define columns that are boundable
* @var
*/
protected $bound = array();
+
/**
* do we display print button
* @var
*/
protected $print = true;
+
/**
* do we display csv button
* @var
*/
protected $csv = true;
+
/**
* do we enable limit filter for the report
* @var bool
*/
protected $enable_limit = true;
+
/**
* gettext correspondance for all available columns in report
* @var array
*/
protected $cor = array();
+
/**
* group result of a report this is the name ogf the grouped column
* @var string
*/
protected $groupby;
+
/**
* disbale or enable pretty string useful for export in csv
* @var boolean
@@ -197,9 +231,8 @@ class module_report
/**
*
*/
- protected $cor_query = array();/* ~*~*~*~*~*~*~*~*~*~*~*~ */
- /* METHODS, VARIABLES */
- /* ~*~*~*~*~*~*~*~*~*~*~*~ */
+ protected $cor_query = array();
+ protected $isInformative;
/**
* Constructor
@@ -212,7 +245,7 @@ class module_report
*/
public function __construct($d1, $d2, $sbas_id, $collist)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance();
$session = $appbox->get_session();
$this->dmin = $d1;
$this->dmax = $d2;
@@ -220,13 +253,23 @@ class module_report
$this->list_coll_id = $collist;
$this->user_id = $session->get_usr_id();
$this->periode = phraseadate::getPrettyString(new DateTime($d1))
- . ' - ' . phraseadate::getPrettyString(new DateTime($d2));
+ . ' - ' . phraseadate::getPrettyString(new DateTime($d2));
$this->dbname = phrasea::sbas_names($sbas_id);
$this->cor = $this->setCor();
$this->jour = $this->setDay();
$this->month = $this->setMonth();
}
+ public function IsInformative()
+ {
+ return $this->isInformative;
+ }
+
+ public function setIsInformative($isInformative)
+ {
+ $this->isInformative = $isInformative;
+ }
+
public function getUser_id()
{
return $this->user_id;
@@ -242,7 +285,6 @@ class module_report
$this->user_id = $user_id;
}
-
public function getSbas_id()
{
return $this->sbas_id;
@@ -253,7 +295,7 @@ class module_report
$this->sbas_id = $sbas_id;
}
- public function setPrettyString($bool)
+ public function setPrettyString($bool)
{
$this->pretty_string = $bool;
}
@@ -301,8 +343,6 @@ class module_report
$this->req = $sql;
}
-
-
public function getPeriode()
{
return $this->periode;
@@ -342,9 +382,9 @@ class module_report
public function setActiveColumn(array $active_column)
{
- $this->active_column = $active_column;
+ $this->active_column = $active_column;
- return $this;
+ return $this;
}
public function getActiveColumn()
@@ -460,7 +500,6 @@ class module_report
public function getOrder($k = false)
{
if ($k === false)
-
return $this->tab_order;
return $this->tab_order[$k];
}
@@ -509,6 +548,7 @@ class module_report
{
$this->total = $total;
}
+
public function getDefault_display()
{
return $this->default_display;
@@ -524,7 +564,6 @@ class module_report
return $this->champ;
}
-
/**
* Retourne un objet qui genere la requete selon le type de report
* @param string $domain
@@ -619,28 +658,28 @@ class module_report
private function setCor()
{
return array(
- 'user' => _('report:: utilisateur'),
- 'coll_id' => _('report:: collections'),
- 'connexion' => _('report:: Connexion'),
- 'comment' => _('report:: commentaire'),
- 'search' => _('report:: question'),
- 'date' => _('report:: date'),
- 'ddate' => _('report:: date'),
- 'fonction' => _('report:: fonction'),
- 'activite' => _('report:: activite'),
- 'pays' => _('report:: pays'),
- 'societe' => _('report:: societe'),
- 'nb' => _('report:: nombre'),
- 'pourcent' => _('report:: pourcentage'),
- 'telechargement' => _('report:: telechargement'),
- 'record_id' => _('report:: record id'),
- 'final' => _('report:: type d\'action'),
- 'xml' => _('report:: sujet'),
- 'file' => _('report:: fichier'),
- 'mime' => _('report:: type'),
- 'size' => _('report:: taille'),
- 'copyright' => _('report:: copyright'),
- 'final' => _('phraseanet:: sous definition')
+ 'user' => _('report:: utilisateur'),
+ 'coll_id' => _('report:: collections'),
+ 'connexion' => _('report:: Connexion'),
+ 'comment' => _('report:: commentaire'),
+ 'search' => _('report:: question'),
+ 'date' => _('report:: date'),
+ 'ddate' => _('report:: date'),
+ 'fonction' => _('report:: fonction'),
+ 'activite' => _('report:: activite'),
+ 'pays' => _('report:: pays'),
+ 'societe' => _('report:: societe'),
+ 'nb' => _('report:: nombre'),
+ 'pourcent' => _('report:: pourcentage'),
+ 'telechargement' => _('report:: telechargement'),
+ 'record_id' => _('report:: record id'),
+ 'final' => _('report:: type d\'action'),
+ 'xml' => _('report:: sujet'),
+ 'file' => _('report:: fichier'),
+ 'mime' => _('report:: type'),
+ 'size' => _('report:: taille'),
+ 'copyright' => _('report:: copyright'),
+ 'final' => _('phraseanet:: sous definition')
);
return;
@@ -653,13 +692,13 @@ class module_report
private function setDay()
{
return Array(
- 1 => _('phraseanet::jours:: lundi'),
- 2 => _('phraseanet::jours:: mardi'),
- 3 => _('phraseanet::jours:: mercredi'),
- 4 => _('phraseanet::jours:: jeudi'),
- 5 => _('phraseanet::jours:: vendredi'),
- 6 => _('phraseanet::jours:: samedi'),
- 7 => _('phraseanet::jours:: dimanche'));
+ 1 => _('phraseanet::jours:: lundi'),
+ 2 => _('phraseanet::jours:: mardi'),
+ 3 => _('phraseanet::jours:: mercredi'),
+ 4 => _('phraseanet::jours:: jeudi'),
+ 5 => _('phraseanet::jours:: vendredi'),
+ 6 => _('phraseanet::jours:: samedi'),
+ 7 => _('phraseanet::jours:: dimanche'));
}
/**
@@ -669,18 +708,18 @@ class module_report
private function setMonth()
{
return array(
- _('janvier'),
- _('fevrier'),
- _('mars'),
- _('avril'),
- _('mai'),
- _('juin'),
- _('juillet'),
- _('aout'),
- _('septembre'),
- _('octobre'),
- _('novembre'),
- _('decembre')
+ _('janvier'),
+ _('fevrier'),
+ _('mars'),
+ _('avril'),
+ _('mai'),
+ _('juin'),
+ _('juillet'),
+ _('aout'),
+ _('septembre'),
+ _('octobre'),
+ _('novembre'),
+ _('decembre')
);
}
@@ -748,21 +787,21 @@ class module_report
if (array_key_exists($column, $this->cor))
{
$title_text = $this->cor[$column];
- $def = true;
+ $def = true;
}
- empty($row[0]) ? $title = $column : $title = $row[0];
+ empty($row[0]) ? $title = $column : $title = $row[0];
- $sort = $row[1];
+ $sort = $row[1];
array_key_exists($column, $this->bound) ?
- $bound = $this->bound[$column] : $bound = $row[2];
- $filter = (isset($row[3]) ? $row[3] : 0);
+ $bound = $this->bound[$column] : $bound = $row[2];
+ $filter = (isset($row[3]) ? $row[3] : 0);
$groupby = $row[4];
- $config = array(
- 'title' => $title,
- 'sort' => $sort,
- 'bound' => $bound,
- 'filter' => $filter,
- 'groupby' => $groupby
+ $config = array(
+ 'title' => $title,
+ 'sort' => $sort,
+ 'bound' => $bound,
+ 'filter' => $filter,
+ 'groupby' => $groupby
);
$def ? $config['title'] = $title_text : "";
@@ -780,7 +819,6 @@ class module_report
public function buildReport($tab = false, $groupby = false, $on = false)
{
if (sizeof($this->report) > 0)
-
return $this->report;
$conn = connection::getPDOConnection($this->sbas_id);
@@ -792,10 +830,10 @@ class module_report
{
$stmt = $conn->prepare($this->req);
$stmt->execute($this->params);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
}
- catch(PDOException $e)
+ catch (PDOException $e)
{
echo $e->getMessage();
@@ -837,13 +875,13 @@ class module_report
{
if ($attribut)
{
- foreach ($sxe->$champ->attributes() as $a => $b)
+ foreach ($sxe->$champ->attributes() as $a => $b)
+ {
+ if ($a == $attribut)
{
- if ($a == $attribut)
- {
- $ret.= $b;
- }
+ $ret.= $b;
}
+ }
}
else
{
@@ -871,7 +909,7 @@ class module_report
$tab["struct"] = "";
$tab['champs'] = array();
- $databox = databox::get_instance((int) $sbasid);
+ $databox = databox::get_instance((int) $sbasid);
$tab['struct'] = $databox->get_structure();
$sxe = $databox->get_sxml_structure();
@@ -897,7 +935,7 @@ class module_report
public static function getHost($url)
{
$parse_url = parse_url(trim($url));
- $result = isset($parse_url['host']) ? $parse_url['host'] : array_shift(explode('/', $parse_url['path'], 2));
+ $result = isset($parse_url['host']) ? $parse_url['host'] : array_shift(explode('/', $parse_url['path'], 2));
return trim($result);
}
diff --git a/lib/classes/module/report/download.class.php b/lib/classes/module/report/download.class.php
index 7e6f69ff12..da9475b17b 100644
--- a/lib/classes/module/report/download.class.php
+++ b/lib/classes/module/report/download.class.php
@@ -38,8 +38,7 @@ class module_report_download extends module_report
'mime' => 'subdef.mime',
'file' => 'subdef.file'
);
-
- protected $isInformative;
+
/**
* constructor
*
@@ -278,16 +277,6 @@ class module_report_download extends module_report
return $array;
}
- public function IsInformative()
- {
- return $this->isInformative;
- }
-
- public function setIsInformative($isInformative)
- {
- $this->isInformative = $isInformative;
- }
-
}
diff --git a/lib/classes/module/report/sqldownload.class.php b/lib/classes/module/report/sqldownload.class.php
index bc54ddccf4..ad65a5f641 100644
--- a/lib/classes/module/report/sqldownload.class.php
+++ b/lib/classes/module/report/sqldownload.class.php
@@ -70,7 +70,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
$this->sql .= $this->filter->getOrderFilter() ? : '';
-// var_dump(str_replace(array_keys($this->params), array_values($this->params), $this->sql), $this->sql, $this->params);
$stmt = $this->connbas->prepare($this->sql);
$stmt->execute($this->params);
$this->total_row = $stmt->rowCount();
diff --git a/lib/classes/p4file.class.php b/lib/classes/p4file.class.php
index 756372b668..ec485570ed 100644
--- a/lib/classes/p4file.class.php
+++ b/lib/classes/p4file.class.php
@@ -113,7 +113,7 @@ class p4file
{
$record = record_adapter::create($collection, $system_file, $name);
$record_id = $record->get_record_id();
- $record->set_metadatas($metadatas['metadatas']);
+ $record->set_metadatas($metadatas['metadatas'], true);
}
catch (Exception $e)
{
diff --git a/lib/classes/record/Interface.class.php b/lib/classes/record/Interface.class.php
index a97c859d17..5583384643 100644
--- a/lib/classes/record/Interface.class.php
+++ b/lib/classes/record/Interface.class.php
@@ -85,7 +85,7 @@ interface record_Interface
public function substitute_subdef($name, system_file $pathfile);
- public function set_metadatas(Array $metadatas);
+ public function set_metadatas(Array $metadatas, $force_readonly = false);
public function reindex();
diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php
index 04d67b86f0..5e5c34c56f 100644
--- a/lib/classes/record/adapter.class.php
+++ b/lib/classes/record/adapter.class.php
@@ -862,6 +862,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
, 'meta_id' => $value->getId()
, 'value' => $original_name
)
+ , true
);
}
}
@@ -1211,8 +1212,20 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor();
+
+ try
+ {
+ $subdef = $this->get_subdef($name);
+ $subdef->delete_data_from_cache();
+ }
+ catch (Exception $e)
+ {
+
+ }
+
$this->delete_data_from_cache(self::CACHE_SUBDEFS);
+
if ($meta_writable)
{
$this->write_metas();
@@ -1337,13 +1350,20 @@ class record_adapter implements record_Interface, cache_cacheableInterface
* @param array $metadatas
* @return record_adapter
*/
- public function set_metadatas(Array $metadatas)
+ public function set_metadatas(Array $metadatas, $force_readonly = false)
{
foreach ($metadatas as $param)
{
if (!is_array($param))
throw new Exception_InvalidArgument();
+ $db_field = \databox_field::get_instance($this->get_databox(), $param['meta_struct_id']);
+
+ if ($db_field->is_readonly() === false && !$force_readonly)
+ {
+ continue;
+ }
+
$this->set_metadata($param, $this->databox);
}
diff --git a/lib/classes/recordutils/arial.ttf b/lib/classes/recordutils/arial.ttf
new file mode 100644
index 0000000000..ff0815cd8c
Binary files /dev/null and b/lib/classes/recordutils/arial.ttf differ
diff --git a/lib/classes/recordutils/image.class.php b/lib/classes/recordutils/image.class.php
index 723f4ee742..dd526b3c15 100644
--- a/lib/classes/recordutils/image.class.php
+++ b/lib/classes/recordutils/image.class.php
@@ -292,7 +292,7 @@ class recordutils_image extends recordutils
$txtlines = recordutils_image::wrap(
$fontsize,
0,
- $registry->get('GV_RootPath') . 'lib/stamper/arial.ttf',
+ __DIR__ . '/arial.ttf',
$txtline,
$text_width
);
@@ -352,7 +352,7 @@ class recordutils_image extends recordutils
{
imagettftext($im, $block['s'], 0, $block['x'],
$txt_ypos - $block['dy'], $black,
- $registry->get('GV_RootPath') . 'lib/stamper/arial.ttf', $block['t']);
+ __DIR__ . '/arial.ttf', $block['t']);
$txt_ypos += $block['h'];
}
imagecolordeallocate($im, $black);
diff --git a/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php b/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php
index 09351847ac..fcbff91988 100644
--- a/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php
+++ b/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php
@@ -19,73 +19,75 @@ class searchEngine_adapter_phrasea_queryParser
{
var $ops = array(
- "et" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
- "and" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
- "ou" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
- "or" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
- "sauf" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
- "except" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
- "pres" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
- "near" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
- "avant" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
- "before" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
- "apres" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
- "after" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
- "dans" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false),
- "in" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false)
+ "et" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
+ "and" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
+ "ou" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
+ "or" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
+ "sauf" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
+ "except" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
+ "pres" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
+ "near" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
+ "avant" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
+ "before" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
+ "apres" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
+ "after" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
+ "dans" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false),
+ "in" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false)
);
- var $opk = array(
- "<" => array("NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false),
- ">" => array("NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false),
- "<=" => array("NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false),
- ">=" => array("NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false),
- "<>" => array("NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false),
- "=" => array("NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false),
- ":" => array("NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false)
+ var $opk = array(
+ "<" => array("NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false),
+ ">" => array("NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false),
+ "<=" => array("NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false),
+ ">=" => array("NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false),
+ "<>" => array("NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false),
+ "=" => array("NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false),
+ ":" => array("NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false)
);
- var $spw = array(
- "all" => array(
- "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
- ),
- "last" => array(
- "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
- ),
- // "first" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
- // "premiers" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
- "tout" => array(
- "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
- ),
- "derniers" => array(
- "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
- )
+ var $spw = array(
+ "all" => array(
+ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
+ ),
+ "last" => array(
+ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
+ ),
+ // "first" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
+ // "premiers" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
+ "tout" => array(
+ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
+ ),
+ "derniers" => array(
+ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
+ )
);
var $quoted_defaultop = array(
- "VALUE" => "default_avant", "NODETYPE" => PHRASEA_OP_BEFORE, "PNUM" => 0
+ "VALUE" => "default_avant", "NODETYPE" => PHRASEA_OP_BEFORE, "PNUM" => 0
);
var $defaultop = array(
- "VALUE" => "and", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL
+ "VALUE" => "and", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL
);
var $defaultlast = 12;
var $phq;
- var $errmsg = "";
+ var $errmsg = "";
+
/**
*
* @var boolean
*/
- var $debug = false;
+ var $debug = false;
+
/**
* un tableau qui contiendra des propositions de thesaurus
* pour les termes de l'arbre simple
*
* @var array
*/
- var $proposals = Array("QRY" => "", "BASES" => array());
+ var $proposals = Array("QRY" => "", "BASES" => array());
+
/**
* Current language for thesaurus
* @var
*/
var $lng = null;
-
protected $unicode;
function __construct($lng = "???")
@@ -117,10 +119,9 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- $this->proposals = Array("QRY" => "", "BASES" => array());
+ $this->proposals = Array("QRY" => "", "BASES" => array());
$this->phq = $this->mb_trim($phq, 'UTF-8');
if ($this->phq != "")
-
return($this->maketree(0));
else
{
@@ -138,18 +139,14 @@ class searchEngine_adapter_phrasea_queryParser
{
case "SIMPLE":
if (is_array($tree["VALUE"]))
-
return(implode(" ", $tree["VALUE"]));
else
-
return($tree["VALUE"]);
break;
case "QSIMPLE":
if (is_array($tree["VALUE"]))
-
return("\"" . implode(" ", $tree["VALUE"]) . "\"");
else
-
return("\"" . $tree["VALUE"] . "\"");
break;
case "PHRASEA_KW_ALL":
@@ -157,19 +154,15 @@ class searchEngine_adapter_phrasea_queryParser
break;
case "PHRASEA_KW_LAST":
if ($tree["PNUM"] !== null)
-
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
else
-
return($tree["VALUE"][0]);
break;
case "OPS":
case "OPK":
if (isset($tree["PNUM"]))
-
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext($tree["RB"]) . ")");
else
-
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . " " . $this->astext($tree["RB"]) . ")");
break;
}
@@ -178,7 +171,6 @@ class searchEngine_adapter_phrasea_queryParser
function astable(&$tree)
{
$this->calc_complexity($tree);
- // var_dump($tree);
$txt = "";
$this->astable2($txt, $tree);
$txt = "\n";
@@ -191,15 +183,13 @@ class searchEngine_adapter_phrasea_queryParser
if ($tree)
{
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
-
return($tree["COMPLEXITY"] = $this->calc_complexity($tree["LB"]) + $this->calc_complexity($tree["RB"]));
else
-
return($tree["COMPLEXITY"] = 1);
}
}
- function astable2(&$out, &$tree, $depth=0)
+ function astable2(&$out, &$tree, $depth = 0)
{
switch ($tree["CLASS"])
{
@@ -228,7 +218,7 @@ class searchEngine_adapter_phrasea_queryParser
break;
case "OPS":
case "OPK":
- $op = $tree["VALUE"];
+ $op = $tree["VALUE"];
if (isset($tree["PNUM"]))
$op .= "[" . $tree["PNUM"] . "]";
$out .= "\t
$op | \n";
@@ -246,7 +236,7 @@ class searchEngine_adapter_phrasea_queryParser
print("
\n");
}
- function dumpDiv2(&$tree, $depth=0)
+ function dumpDiv2(&$tree, $depth = 0)
{
switch ($tree["CLASS"])
{
@@ -355,18 +345,17 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- function priority_opk(&$tree, $depth=0)
+ function priority_opk(&$tree, $depth = 0)
{
if (!$tree)
-
return;
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK"))
{
// on a un truc du genre ((a ou b) < 5), on le transforme en (a ou (b < 5))
- $t = $tree["LB"];
+ $t = $tree["LB"];
$tree["LB"] = $t["RB"];
- $t["RB"] = $tree;
- $tree = $t;
+ $t["RB"] = $tree;
+ $tree = $t;
}
if (isset($tree["LB"]))
$this->priority_opk($tree["LB"], $depth + 1);
@@ -374,26 +363,25 @@ class searchEngine_adapter_phrasea_queryParser
$this->priority_opk($tree["RB"], $depth + 1);
}
- function distrib_opk(&$tree, $depth=0)
+ function distrib_opk(&$tree, $depth = 0)
{
if (!$tree)
-
return;
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS"))
{
// on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6))
- $tmp = array("CLASS" => $tree["CLASS"],
- "NODETYPE" => $tree["NODETYPE"],
- "VALUE" => $tree["VALUE"],
- "PNUM" => $tree["PNUM"],
- "LB" => $tree["LB"],
- "RB" => $tree["RB"]["RB"],
- "DEPTH" => $tree["LB"]["DEPTH"]);
- $t = $tree["RB"];
+ $tmp = array("CLASS" => $tree["CLASS"],
+ "NODETYPE" => $tree["NODETYPE"],
+ "VALUE" => $tree["VALUE"],
+ "PNUM" => $tree["PNUM"],
+ "LB" => $tree["LB"],
+ "RB" => $tree["RB"]["RB"],
+ "DEPTH" => $tree["LB"]["DEPTH"]);
+ $t = $tree["RB"];
$tree["RB"] = $t["LB"];
- $t["LB"] = $tree;
- $t["RB"] = $tmp;
- $tree = $t;
+ $t["LB"] = $tree;
+ $t["RB"] = $tmp;
+ $tree = $t;
}
if (isset($tree["LB"]))
$this->distrib_opk($tree["LB"], $depth + 1);
@@ -404,7 +392,6 @@ class searchEngine_adapter_phrasea_queryParser
function thesaurus2_apply(&$tree, $bid)
{
if (!$tree)
-
return;
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"]))
{
@@ -461,7 +448,6 @@ class searchEngine_adapter_phrasea_queryParser
$copy = $tree;
$this->_extendThesaurusOnTerms($tree, $copy, $useFullText, $useThesaurus, $keepfuzzy, 0, "");
- // var_dump($tree);
$this->proposals["QRY"] = "
" . $this->_queryAsHTML($tree) . "";
return($copy);
@@ -472,9 +458,8 @@ class searchEngine_adapter_phrasea_queryParser
if ($depth == 0)
$ret = $tree;
if (!$useThesaurus)
-
return; // full-text only : inchangé
- if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
+ if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
{
if (isset($tree["CONTEXT"]))
$copy = $this->_extendToThesaurus_Simple($tree, false, $keepfuzzy, $path);
@@ -488,10 +473,10 @@ class searchEngine_adapter_phrasea_queryParser
// on a 'field:value' , on traite 'value'
$tree["RB"]["PATH"] = $copy["RB"]["PATH"] = $path . "R";
if (isset($tree["RB"]["CONTEXT"]))
- $copy["CONTEXT"] = $tree["CONTEXT"] = $tree["RB"]["CONTEXT"];
+ $copy["CONTEXT"] = $tree["CONTEXT"] = $tree["RB"]["CONTEXT"];
else
if (!$keepfuzzy)
- $copy["CONTEXT"] = $tree["CONTEXT"] = "*";
+ $copy["CONTEXT"] = $tree["CONTEXT"] = "*";
$copy["RB"]["SREF"] = &$tree["RB"];
}
@@ -522,7 +507,7 @@ class searchEngine_adapter_phrasea_queryParser
function _extendToThesaurus_Simple(&$simple, $keepFullText, $keepfuzzy, $path)
{
$simple["PATH"] = $path;
- $context = null;
+ $context = null;
if (isset($simple["CONTEXT"]))
{
$context = $simple["CONTEXT"];
@@ -531,34 +516,34 @@ class searchEngine_adapter_phrasea_queryParser
if ($keepFullText)
{
// on fait un OU entre la recherche ft et une recherche th
- $tmp = array("CLASS" => "OPS",
- "NODETYPE" => PHRASEA_OP_OR,
- "VALUE" => "OR",
- "PNUM" => null,
- "DEPTH" => $simple["DEPTH"],
- "LB" => $simple,
- "RB" => array("CLASS" => "OPK",
- "NODETYPE" => PHRASEA_OP_COLON,
- "VALUE" => ":",
- // "CONTEXT"=>$context,
- "PNUM" => null,
- "DEPTH" => $simple["DEPTH"] + 1,
- "LB" => array("CLASS" => "SIMPLE",
- "NODETYPE" => PHRASEA_KEYLIST,
- "VALUE" => array("*"),
- "DEPTH" => $simple["DEPTH"] + 2
- ),
- "RB" => $simple
- )
+ $tmp = array("CLASS" => "OPS",
+ "NODETYPE" => PHRASEA_OP_OR,
+ "VALUE" => "OR",
+ "PNUM" => null,
+ "DEPTH" => $simple["DEPTH"],
+ "LB" => $simple,
+ "RB" => array("CLASS" => "OPK",
+ "NODETYPE" => PHRASEA_OP_COLON,
+ "VALUE" => ":",
+ // "CONTEXT"=>$context,
+ "PNUM" => null,
+ "DEPTH" => $simple["DEPTH"] + 1,
+ "LB" => array("CLASS" => "SIMPLE",
+ "NODETYPE" => PHRASEA_KEYLIST,
+ "VALUE" => array("*"),
+ "DEPTH" => $simple["DEPTH"] + 2
+ ),
+ "RB" => $simple
+ )
);
// on vire le contexte du coté fulltext
unset($tmp["LB"]["CONTEXT"]);
// ajoute le contexte si nécéssaire
if ($context !== null)
- $tmp["RB"]["CONTEXT"] = $context;
+ $tmp["RB"]["CONTEXT"] = $context;
else
if (!$keepfuzzy)
- $tmp["RB"]["CONTEXT"] = "*";
+ $tmp["RB"]["CONTEXT"] = "*";
// corrige les profondeurs des 2 copies du 'simple' d'origine
$tmp["LB"]["DEPTH"] += 1;
$tmp["RB"]["RB"]["DEPTH"] += 2;
@@ -569,25 +554,25 @@ class searchEngine_adapter_phrasea_queryParser
else
{
// on remplace le ft par du th
- $tmp = array("CLASS" => "OPK",
- "NODETYPE" => PHRASEA_OP_COLON,
- "VALUE" => ":",
- // "CONTEXT"=>$context,
- "PNUM" => null,
- "DEPTH" => $simple["DEPTH"] + 1,
- "LB" => array("CLASS" => "SIMPLE",
- "NODETYPE" => PHRASEA_KEYLIST,
- "VALUE" => array("*"),
- "DEPTH" => $simple["DEPTH"] + 1
- ),
- "RB" => $simple
+ $tmp = array("CLASS" => "OPK",
+ "NODETYPE" => PHRASEA_OP_COLON,
+ "VALUE" => ":",
+ // "CONTEXT"=>$context,
+ "PNUM" => null,
+ "DEPTH" => $simple["DEPTH"] + 1,
+ "LB" => array("CLASS" => "SIMPLE",
+ "NODETYPE" => PHRASEA_KEYLIST,
+ "VALUE" => array("*"),
+ "DEPTH" => $simple["DEPTH"] + 1
+ ),
+ "RB" => $simple
);
// ajoute le contexte si nécéssaire
if ($context !== null)
- $tmp["CONTEXT"] = $context;
+ $tmp["CONTEXT"] = $context;
else
if (!$keepfuzzy)
- $tmp["CONTEXT"] = "*";
+ $tmp["CONTEXT"] = "*";
// corrige la profondeur de la copie du 'simple' d'origine
$tmp["RB"]["DEPTH"] += 1;
// note une référence vers le terme d'origine
@@ -598,16 +583,15 @@ class searchEngine_adapter_phrasea_queryParser
return($tmp);
}
- function thesaurus2(&$tree, $bid, $name, &$domthe, $searchsynonyms=true, $depth=0)
+ function thesaurus2(&$tree, $bid, $name, &$domthe, $searchsynonyms = true, $depth = 0)
{
if ($this->debug)
print("thesaurus2:\n\$tree=" . var_export($tree, true) . "\n");
if ($depth == 0)
- $this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
+ $this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
if (!$tree)
-
return(0);
$ambigus = 0;
@@ -625,18 +609,18 @@ class searchEngine_adapter_phrasea_queryParser
return($ambigus);
}
- function propAsHTML(&$node, &$html, $path, $depth=0)
+ function propAsHTML(&$node, &$html, $path, $depth = 0)
{
global $parm;
if ($depth > 0)
{
$tsy = array();
$lngfound = "?";
- for ($n = $node->firstChild; $n; $n = $n->nextSibling)
+ for ($n = $node->firstChild; $n; $n = $n->nextSibling)
{
if ($n->nodeName == "sy")
{
- $lng = $n->getAttribute("lng");
+ $lng = $n->getAttribute("lng");
if (!array_key_exists($lng, $tsy))
$tsy[$lng] = array();
$zsy = array("v" => $n->getAttribute("v"), "w" => $n->getAttribute("w"), "k" => $n->getAttribute("k"));
@@ -644,16 +628,16 @@ class searchEngine_adapter_phrasea_queryParser
if ($lngfound == "?" || ($lng == $this->lng && $lngfound != $lng))
{
$lngfound = $lng;
- $syfound = $zsy;
+ $syfound = $zsy;
}
else
{
-
+
}
$tsy[$lng][] = $zsy;
}
}
- $alt = "";
+ $alt = "";
foreach ($tsy as $lng => $tsy2)
{
foreach ($tsy2 as $sy)
@@ -664,8 +648,8 @@ class searchEngine_adapter_phrasea_queryParser
}
$thtml = $syfound["v"];
- $kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null";
- $wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'";
+ $kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null";
+ $wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'";
if ($node->getAttribute("term"))
{
@@ -684,29 +668,27 @@ class searchEngine_adapter_phrasea_queryParser
if ($n->nodeType == XML_ELEMENT_NODE && $n->getAttribute("marked")) // only 'te' marked
{
$lngfound = '?';
- $syfound = '?';
- for ($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling)
+ $syfound = '?';
+ for ($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling)
{
if ($n2->nodeName == 'sy')
{
$lng = $n2->getAttribute('lng');
if ($lngfound == "?" || ($lng == $this->lng && $lngfound != $lng))
{
- $lngfound = $lng;
- $syfound = $n2->getAttribute('w');
+ $lngfound = $lng;
+ $syfound = $n2->getAttribute('w');
}
}
}
$n->removeAttribute("marked");
- for ($i = 0; array_key_exists($syfound . $i, $tsort) && $i < 9999; $i++)
+ for ($i = 0; array_key_exists($syfound . $i, $tsort) && $i < 9999; $i++)
;
$tsort[$syfound . $i] = $n;
}
}
ksort($tsort);
-// var_dump($tsort);
-
foreach ($tsort as $n)
{
$this->propAsHTML($n, $html, $path, $depth + 1);
@@ -716,13 +698,11 @@ class searchEngine_adapter_phrasea_queryParser
$html .= $tab . "
\n";
}
- function _queryAsHTML($tree, $depth=0)
+ function _queryAsHTML($tree, $depth = 0)
{
- // printf("astext : ");
- // var_dump($tree);
if ($depth == 0)
{
- $ambiguites = array("n" => 0, "refs" => array());
+ $ambiguites = array("n" => 0, "refs" => array());
}
switch ($tree["CLASS"])
{
@@ -734,7 +714,7 @@ class searchEngine_adapter_phrasea_queryParser
$path = $tree["PATH"];
if (isset($tree["CONTEXT"]))
$w .= ' [' . $tree["CONTEXT"] . ']';
- $txt = '