diff --git a/lib/Alchemy/Phrasea/Application/Lightbox.php b/lib/Alchemy/Phrasea/Application/Lightbox.php index b41ebb9b44..a05107aa38 100644 --- a/lib/Alchemy/Phrasea/Application/Lightbox.php +++ b/lib/Alchemy/Phrasea/Application/Lightbox.php @@ -74,7 +74,6 @@ return call_user_func( { /* @var $twig \Twig_Environment */ $twig = $app['Core']->getTwig(); -// var_dump($twig->getLoader()->getPaths()); $browser = \Browser::getInstance(); if (!$browser->isMobile()) diff --git a/lib/Alchemy/Phrasea/Helper/Record/Edit.php b/lib/Alchemy/Phrasea/Helper/Record/Edit.php index 145958a86c..0ebdce70c8 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Edit.php @@ -566,7 +566,7 @@ class Edit extends RecordHelper ) ); - $record->set_metadatas($metas); + $record->set_metadatas($metas, true); } $newstat = $record->get_status(); diff --git a/lib/classes/Exception/Session/MailLocked.class.php b/lib/classes/Exception/Session/MailLocked.class.php index b653cca9e0..4ce40f09da 100644 --- a/lib/classes/Exception/Session/MailLocked.class.php +++ b/lib/classes/Exception/Session/MailLocked.class.php @@ -18,4 +18,17 @@ class Exception_Session_MailLocked extends Exception { + protected $usr_id; + + public function __construct($usr_id = null, $message = null, $code = null, $previous = null) + { + $this->usr_id = $usr_id; + parent::__construct($message, $code, $previous); + } + + public function get_usr_id() + { + return $this->usr_id; + } + } diff --git a/lib/classes/Session/Authentication/Native.class.php b/lib/classes/Session/Authentication/Native.class.php index 00d2ea369f..c3e96cddfe 100644 --- a/lib/classes/Session/Authentication/Native.class.php +++ b/lib/classes/Session/Authentication/Native.class.php @@ -141,7 +141,7 @@ class Session_Authentication_Native implements Session_Authentication_Interface $stmt->closeCursor(); if ($row && $row['mail_locked'] == "1") - throw new Exception_Session_MailLocked(); + throw new Exception_Session_MailLocked($this->user->get_id()); return $this; } diff --git a/lib/classes/eventsmanager/notify/autoregister.class.php b/lib/classes/eventsmanager/notify/autoregister.class.php index 6695631fc7..ee54a2de17 100644 --- a/lib/classes/eventsmanager/notify/autoregister.class.php +++ b/lib/classes/eventsmanager/notify/autoregister.class.php @@ -256,7 +256,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract $body .= "
\n
" . _('admin::register: l\'utilisateur s\'est inscrit sur les bases suivantes') . "
\n"; - $body .= "\n"; $body .= "
\n
" . _('admin::register: vous pourrez consulter son compte en ligne via l\'interface d\'administration') diff --git a/lib/classes/eventsmanager/notify/register.class.php b/lib/classes/eventsmanager/notify/register.class.php index 2e8cce5617..4a0b6844fe 100644 --- a/lib/classes/eventsmanager/notify/register.class.php +++ b/lib/classes/eventsmanager/notify/register.class.php @@ -261,7 +261,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract $body .= "
\n
" . _('admin::register: les demandes de l\'utilisateur portent sur les bases suivantes') . "
\n"; - $body .= "\n"; $body .= "
\n
" diff --git a/lib/classes/geonames.class.php b/lib/classes/geonames.class.php index 561f46de94..7b84b7a032 100644 --- a/lib/classes/geonames.class.php +++ b/lib/classes/geonames.class.php @@ -2,7 +2,16 @@ class geonames { - + protected static $NamesFromId = array(); + + protected static $CountryFromId = array(); + + protected static $CountryCodeFromId = array(); + + protected static $GeonameFromIp = array(); + + protected static $Searches = array(); + public function name_from_id($geonameid) { $registry = registry::get_instance(); diff --git a/lib/classes/http/query.class.php b/lib/classes/http/query.class.php index 9e10148024..30009ccd14 100644 --- a/lib/classes/http/query.class.php +++ b/lib/classes/http/query.class.php @@ -25,26 +25,37 @@ class http_query */ public static function getHttpCodeFromUrl($url) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, 10); - curl_setopt($ch, CURLOPT_NOBODY, true); - curl_setopt($ch, CURLOPT_HEADER, true); + if (!is_scalar($url)) + return null; - curl_exec($ch); - $result = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + if (trim($url) === '') + return null; - curl_close($ch); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 10); + curl_setopt($ch, CURLOPT_NOBODY, true); + curl_setopt($ch, CURLOPT_HEADER, true); - return $result; + curl_exec($ch); + $result = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + + curl_close($ch); + + return $result; } public static function getHttpHeaders($url) { + if (!is_scalar($url)) + return null; + + if (trim($url) === '') + return null; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @@ -69,24 +80,30 @@ class http_query * @param array $post_data * @return string */ - public static function getUrl($url, $post_data=false) + public static function getUrl($url, $post_data = false) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); - curl_setopt($ch, CURLOPT_FAILONERROR, 1); + if (!is_scalar($url)) + return null; - if ($post_data) - { - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); - } + if (trim($url) === '') + return null; - $result = (curl_exec($ch)); - curl_close($ch); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); + curl_setopt($ch, CURLOPT_FAILONERROR, 1); + + if ($post_data) + { + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + } + + $result = (curl_exec($ch)); + curl_close($ch); return $result; } diff --git a/lib/classes/mail.class.php b/lib/classes/mail.class.php index d4d02f9acc..ac1137ac7f 100644 --- a/lib/classes/mail.class.php +++ b/lib/classes/mail.class.php @@ -170,7 +170,7 @@ class mail public static function mail_confirmation($email, $usr_id) { - + $registry = registry::get_instance(); $expire = new DateTime('+3 days'); $token = random::getUrlToken('password', $usr_id, $expire, $email); @@ -256,7 +256,7 @@ class mail $mail->ConfirmReadingTo = $reading_confirm_to; } - $mail->MsgHTML(strip_tags($body, '

')); + $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\n" . $txt . "\n
    \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 = '"' . $w . '"'; + $txt = '"' . $w . '"'; } else { @@ -753,86 +733,20 @@ 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->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . '[' . $tree["PNUM"] . '] ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')'); else - return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . ' ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')'); break; } } - /* - function _queryAsHTML($tree, $mouseCallback="void", $depth=0) - { - // printf("astext : "); - // var_dump($tree); - if($depth==0) - { - $ambiguites = array("n"=>0, "refs"=>array()); - } - switch($tree["CLASS"]) - { - case "SIMPLE": - case "QSIMPLE": - $w = is_array($tree["VALUE"]) ? implode(" ", $tree["VALUE"]) : $tree["VALUE"]; - $tab = "\n" . str_repeat("\t", $depth); - if(isset($tree["PATH"])) - { - $path = $tree["PATH"]; - if(isset($tree["CONTEXT"])) - $w .= " [" . $tree["CONTEXT"] . "]"; - $txt = $tab . ""; - $txt .= $tab . "\t\"" . $w . ""; - // $txt .= $tab . "\t\""; - $txt .= "\""; - $txt .= $tab . "\n"; - } - else - { - if(isset($tree["CONTEXT"])) - $w .= "[" . $tree["CONTEXT"] . "]"; - if($tree["CLASS"] == "QSIMPLE") - $txt = $tab . "\"" . $w . "\"\n"; - else - $txt = $tab . "" . $w . "\n"; - } - - return($txt); - break; - case "PHRASEA_KW_ALL": - return($tree["VALUE"][0]); - 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->_queryAsHTML($tree["LB"], $mouseCallback, $depth+1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->_queryAsHTML($tree["RB"], $mouseCallback, $depth+1) . ")"); - else - - return("(" . $this->_queryAsHTML($tree["LB"], $mouseCallback, $depth+1) . " " . $tree["VALUE"] . " " . $this->_queryAsHTML($tree["RB"], $mouseCallback, $depth+1) . ")"); - break; - } - } - */ - function setTids(&$tree, $bid, &$domthe, $searchsynonyms) { if ($this->debug) @@ -841,8 +755,8 @@ class searchEngine_adapter_phrasea_queryParser // $this->proposals["BASES"]["b$bid"] = array("BID"=>$bid, "TERMS"=>array()); $ambigus = 0; - if (is_array($w = $tree["RB"]["VALUE"])) - $t = $w = implode(" ", $w); + if (is_array($w = $tree["RB"]["VALUE"])) + $t = $w = implode(" ", $w); if (isset($tree["CONTEXT"])) { @@ -873,7 +787,7 @@ class searchEngine_adapter_phrasea_queryParser if ($this->debug) printf("searching thesaurus with xpath='%s'
\n", $x); - $dxp = new DOMXPath($domthe); + $dxp = new DOMXPath($domthe); $nodes = $dxp->query($x); if (!isset($tree["RB"]["SREF"]["TIDS"])) @@ -897,7 +811,7 @@ class searchEngine_adapter_phrasea_queryParser $this->addtoTIDS($tree["RB"], $bid, $node); } } - $path = $tree["RB"]["SREF"]["PATH"]; + $path = $tree["RB"]["SREF"]["PATH"]; $prophtml = ""; $this->propAsHTML($domthe->documentElement, $prophtml, $path); $this->proposals["BASES"]["b$bid"]["TERMS"][$path]["HTML"] = $prophtml; @@ -990,10 +904,8 @@ class searchEngine_adapter_phrasea_queryParser function containsColonOperator(&$tree) { if (!$tree) - return(false); if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE")) - return(true); $ret = false; if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") @@ -1007,12 +919,12 @@ class searchEngine_adapter_phrasea_queryParser function addtoTIDS(&$extendednode, $bid, $DOMnode) // ajoute un tid en évitant les doublons { - $id = $DOMnode->getAttribute("id"); + $id = $DOMnode->getAttribute("id"); $pid = $DOMnode->parentNode->getAttribute("id"); $lng = $DOMnode->getAttribute("lng"); - $w = $DOMnode->getAttribute("w"); - $k = $DOMnode->getAttribute("k"); - $p = $DOMnode->parentNode->getAttribute("v"); // le terme général (pére) du terme recherché : utile pour la levée d'ambiguité + $w = $DOMnode->getAttribute("w"); + $k = $DOMnode->getAttribute("k"); + $p = $DOMnode->parentNode->getAttribute("v"); // le terme général (pére) du terme recherché : utile pour la levée d'ambiguité $path = $extendednode["SREF"]["PATH"]; if ($this->debug) @@ -1042,7 +954,7 @@ class searchEngine_adapter_phrasea_queryParser } } if (!$found) - $extendednode["SREF"]["TIDS"][] = array("bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p); + $extendednode["SREF"]["TIDS"][] = array("bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p); // on liste les propositions de thésaurus pour ce node (dans l'arbre simple) if (!isset($this->proposals["BASES"]["b$bid"]["TERMS"][$path])) @@ -1060,7 +972,7 @@ class searchEngine_adapter_phrasea_queryParser // on marque le terme principal $DOMnode->parentNode->setAttribute("term", "1"); // on commence par marquer les fils directs. rappel:$DOMnode pointe sur un sy - for ($node = $DOMnode->parentNode->firstChild; $node; $node = $node->nextSibling) + for ($node = $DOMnode->parentNode->firstChild; $node; $node = $node->nextSibling) { if ($node->nodeName == "te") { @@ -1073,30 +985,27 @@ class searchEngine_adapter_phrasea_queryParser $id = $node->getAttribute("id"); if (!$id) break; // on a dépassé la racine du thésaurus - $node->setAttribute("marked", "1"); -// printf("<%s id='%s'
\n", $node->nodeName, $node->getAttribute("id")); + $node->setAttribute("marked", "1"); } } - function astext_ambigu($tree, &$ambiguites, $mouseCallback="void", $depth=0) + function astext_ambigu($tree, &$ambiguites, $mouseCallback = "void", $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"]) { case "SIMPLE": case "QSIMPLE": - $prelink = $postlink = ""; - $w = is_array($tree["VALUE"]) ? implode(" ", $tree["VALUE"]) : $tree["VALUE"]; - $tab = "\n" . str_repeat("\t", $depth); + $prelink = $postlink = ""; + $w = is_array($tree["VALUE"]) ? implode(" ", $tree["VALUE"]) : $tree["VALUE"]; + $tab = "\n" . str_repeat("\t", $depth); if (isset($tree["TIDS"]) && count($tree["TIDS"]) > 1) { - $ambiguites["refs"][$n = $ambiguites["n"]] = &$tree; - $txt = $tab . ""; + $ambiguites["refs"][$n = $ambiguites["n"]] = &$tree; + $txt = $tab . ""; $txt .= $tab . "\t\"" . $w . ""; $txt .= $tab . "\t\""; $txt .= $tab . "\n"; @@ -1119,28 +1028,23 @@ 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_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")"); else - return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . " " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")"); break; } } - function get_ambigu(&$tree, $mouseCallback="void", $depth=0) + function get_ambigu(&$tree, $mouseCallback = "void", $depth = 0) { if (!$tree) - return(""); unset($tree["DEPTH"]); if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") @@ -1150,32 +1054,29 @@ class searchEngine_adapter_phrasea_queryParser } else { - + } if ($depth == 0) { $t_ambiguites = array(); - $r = ($this->astext_ambigu($tree, $t_ambiguites, $mouseCallback)); + $r = ($this->astext_ambigu($tree, $t_ambiguites, $mouseCallback)); $t_ambiguites["query"] = $r; return($t_ambiguites); } } - function set_default(&$tree, &$emptyw, $depth=0) + function set_default(&$tree, &$emptyw, $depth = 0) { if (!$tree) - return(true); if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") { if ($tree["CLASS"] == "OPS") { if (!$this->set_default($tree["LB"], $emptyw, $depth + 1)) - return(false); if (!$this->set_default($tree["RB"], $emptyw, $depth + 1)) - return(false); } else // OPK ! @@ -1202,7 +1103,7 @@ class searchEngine_adapter_phrasea_queryParser } if (is_array($tree["RB"]["VALUE"])) { - $lw = ""; + $lw = ""; foreach ($tree["RB"]["VALUE"] as $w) $lw .= ( $lw == "" ? "" : " ") . $w; $tree["RB"]["VALUE"] = $lw; @@ -1225,8 +1126,8 @@ class searchEngine_adapter_phrasea_queryParser if (is_array($tree["VALUE"])) { $treetmp = null; - $pnum = 0; - for ($i = 0; $i < count($tree["VALUE"]); $i++) + $pnum = 0; + for ($i = 0; $i < count($tree["VALUE"]); $i++) { // gestion mot vide if (isset($emptyw[$tree["VALUE"][$i]]) || $tree["VALUE"][$i] == "?" || $tree["VALUE"][$i] == "*") @@ -1238,35 +1139,35 @@ class searchEngine_adapter_phrasea_queryParser { if ($treetmp == null) { - $treetmp = array("CLASS" => $tree["CLASS"], - "NODETYPE" => $tree["NODETYPE"], - "VALUE" => $tree["VALUE"][$i], - "PNUM" => $tree["PNUM"], - "DEPTH" => $tree["DEPTH"]); - $pnum = 0; + $treetmp = array("CLASS" => $tree["CLASS"], + "NODETYPE" => $tree["NODETYPE"], + "VALUE" => $tree["VALUE"][$i], + "PNUM" => $tree["PNUM"], + "DEPTH" => $tree["DEPTH"]); + $pnum = 0; } else { - $dop = $tree["CLASS"] == "QSIMPLE" ? $this->quoted_defaultop : $this->defaultop; - $treetmp = array("CLASS" => "OPS", - "VALUE" => $dop["VALUE"], - "NODETYPE" => $dop["NODETYPE"], - "PNUM" => $pnum, // peut-être écrasé par defaultop - "DEPTH" => $depth, - "LB" => $treetmp, - "RB" => array("CLASS" => $tree["CLASS"], - "NODETYPE" => $tree["NODETYPE"], - "VALUE" => $tree["VALUE"][$i], - "PNUM" => $tree["PNUM"], - "DEPTH" => $tree["DEPTH"]) + $dop = $tree["CLASS"] == "QSIMPLE" ? $this->quoted_defaultop : $this->defaultop; + $treetmp = array("CLASS" => "OPS", + "VALUE" => $dop["VALUE"], + "NODETYPE" => $dop["NODETYPE"], + "PNUM" => $pnum, // peut-être écrasé par defaultop + "DEPTH" => $depth, + "LB" => $treetmp, + "RB" => array("CLASS" => $tree["CLASS"], + "NODETYPE" => $tree["NODETYPE"], + "VALUE" => $tree["VALUE"][$i], + "PNUM" => $tree["PNUM"], + "DEPTH" => $tree["DEPTH"]) ); if (array_key_exists("PNUM", $dop)) $treetmp["PNUM"] = $dop["PNUM"]; - $pnum = 0; + $pnum = 0; } } } - $tree = $treetmp; + $tree = $treetmp; } } } @@ -1281,18 +1182,16 @@ class searchEngine_adapter_phrasea_queryParser while ($n > 0); } - function factor_or2(&$tree, $depth=0) + function factor_or2(&$tree, $depth = 0) { - // printf("
factor_or depth=%s sur
", $depth); - // var_dump($tree); $nmodif = 0; if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") { if ($tree["NODETYPE"] == PHRASEA_OP_OR && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE") && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE")) { - $tree["CLASS"] = "SIMPLE"; + $tree["CLASS"] = "SIMPLE"; $tree["NODETYPE"] = PHRASEA_KEYLIST; - $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : array($tree["LB"]["VALUE"]); + $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : array($tree["LB"]["VALUE"]); if (is_array($tree["RB"]["VALUE"])) { foreach ($tree["RB"]["VALUE"] as $v) @@ -1302,11 +1201,8 @@ class searchEngine_adapter_phrasea_queryParser $tree["VALUE"][] = $tree["RB"]["VALUE"]; unset($tree["LB"]); unset($tree["RB"]); - // unset($tree["NODETYPE"]); unset($tree["PNUM"]); $nmodif++; - // printf("
donne
"); - // var_dump($tree); } else { @@ -1314,13 +1210,11 @@ class searchEngine_adapter_phrasea_queryParser $nmodif += $this->factor_or2($tree["RB"], $depth + 1); } } - // printf("
return %s
", $nmodif); return($nmodif); } - function setNumValue(&$tree, SimpleXMLElement $sxml_struct, $depth=0) + function setNumValue(&$tree, SimpleXMLElement $sxml_struct, $depth = 0) { - // var_dump($tree); if ($tree["CLASS"] == "OPK") { if (isset($tree["RB"]) && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE") && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE")) @@ -1371,50 +1265,43 @@ class searchEngine_adapter_phrasea_queryParser ## creation branche gauche avec ">=" // print("changeNodeEquals2\n"); // print("creation branche gauche ( '>=' ) \n"); - $newTreeLB = array("CLASS" => "OPK", - "VALUE" => ">=", - "NODETYPE" => PHRASEA_OP_GEQT, - "PNUM" => NULL, - "DEPTH" => 0, - "LB" => $oneBranch["LB"], - "RB" => array("CLASS" => "SIMPLE", - "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], false), - "NODETYPE" => PHRASEA_KEYLIST, - "PNUM" => NULL, - "DEPTH" => 0) + $newTreeLB = array("CLASS" => "OPK", + "VALUE" => ">=", + "NODETYPE" => PHRASEA_OP_GEQT, + "PNUM" => NULL, + "DEPTH" => 0, + "LB" => $oneBranch["LB"], + "RB" => array("CLASS" => "SIMPLE", + "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], false), + "NODETYPE" => PHRASEA_KEYLIST, + "PNUM" => NULL, + "DEPTH" => 0) ); -// var_dump($newTreeLB); -// print("fin creation branche gauche ( '>=' ) \n"); - ## fin creation branche gauche ( ">=" ) - ## creation branche droite avec "<=" -// print("creation branche droite avec '<=' \n"); - $newTreeRB = array("CLASS" => "OPK", - "VALUE" => "<=", - "NODETYPE" => PHRASEA_OP_LEQT, - "PNUM" => NULL, - "DEPTH" => 0, - "LB" => $oneBranch["LB"], - "RB" => array("CLASS" => "SIMPLE", - "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], true), - "NODETYPE" => PHRASEA_KEYLIST, - "PNUM" => NULL, - "DEPTH" => 0) + + $newTreeRB = array("CLASS" => "OPK", + "VALUE" => "<=", + "NODETYPE" => PHRASEA_OP_LEQT, + "PNUM" => NULL, + "DEPTH" => 0, + "LB" => $oneBranch["LB"], + "RB" => array("CLASS" => "SIMPLE", + "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], true), + "NODETYPE" => PHRASEA_KEYLIST, + "PNUM" => NULL, + "DEPTH" => 0) ); -// var_dump($newTreeRB); // print("fin creation branche droite avec '<=' \n"); ## fin creation branche droite ( "<=" ) - $tree = array("CLASS" => "OPS", - "VALUE" => "et", - "NODETYPE" => PHRASEA_OP_AND, - "PNUM" => NULL, - "DEPTH" => 0, - "LB" => $newTreeLB, - "RB" => $newTreeRB); + $tree = array("CLASS" => "OPS", + "VALUE" => "et", + "NODETYPE" => PHRASEA_OP_AND, + "PNUM" => NULL, + "DEPTH" => 0, + "LB" => $newTreeLB, + "RB" => $newTreeRB); - // et on le retourne -// var_dump($tree); return $tree; } @@ -1422,23 +1309,23 @@ class searchEngine_adapter_phrasea_queryParser { if (strtoupper($type) == strtoupper("Date")) { - $dateEnIso = $this->isoDate($branch["VALUE"]); + $dateEnIso = $this->isoDate($branch["VALUE"]); $branch["VALUE"] = $dateEnIso; } } - function isoDate($onedate, $max=false) + function isoDate($onedate, $max = false) { $v_y = "1900"; $v_m = "01"; $v_d = "01"; - $v_h = $v_minutes = $v_s = "00"; + $v_h = $v_minutes = $v_s = "00"; if ($max) { - $v_h = $v_minutes = $v_s = "99"; + $v_h = $v_minutes = $v_s = "99"; } - $tmp = $onedate; + $tmp = $onedate; if (!is_array($tmp)) $tmp = explode(" ", $tmp); @@ -1519,31 +1406,31 @@ class searchEngine_adapter_phrasea_queryParser { case 14 : // date iso YYYYMMDDHHMMSS - $v_y = substr($tmp[0], 0, 4); - $v_m = substr($tmp[0], 4, 2); - $v_d = substr($tmp[0], 6, 2); - $v_h = substr($tmp[0], 8, 2); + $v_y = substr($tmp[0], 0, 4); + $v_m = substr($tmp[0], 4, 2); + $v_d = substr($tmp[0], 6, 2); + $v_h = substr($tmp[0], 8, 2); $v_minutes = substr($tmp[0], 10, 2); - $v_s = substr($tmp[0], 12, 2); + $v_s = substr($tmp[0], 12, 2); break; case 8 : // date iso YYYYMMDD - $v_y = substr($tmp[0], 0, 4); - $v_m = substr($tmp[0], 4, 2); - $v_d = substr($tmp[0], 6, 2); + $v_y = substr($tmp[0], 0, 4); + $v_m = substr($tmp[0], 4, 2); + $v_d = substr($tmp[0], 6, 2); break; case 6 : // date iso YYYYMM - $v_y = substr($tmp[0], 0, 4); - $v_m = substr($tmp[0], 4, 2); + $v_y = substr($tmp[0], 0, 4); + $v_m = substr($tmp[0], 4, 2); if ($max) - $v_d = "99"; + $v_d = "99"; else - $v_d = "00"; + $v_d = "00"; break; case 4 : // date iso YYYY - $v_y = $tmp[0]; + $v_y = $tmp[0]; if ($max) $v_m = "99"; @@ -1582,11 +1469,9 @@ class searchEngine_adapter_phrasea_queryParser return("" . $v_y . $v_m . $v_d . $v_h . $v_minutes . $v_s); } - function distrib_in(&$tree, $depth=0) + function distrib_in(&$tree, $depth = 0) { $opdistrib = array(PHRASEA_OP_AND, PHRASEA_OP_OR, PHRASEA_OP_EXCEPT, PHRASEA_OP_NEAR, PHRASEA_OP_BEFORE, PHRASEA_OP_AFTER); // ces opérateurs sont 'distribuables' autour d'un 'IN' - // printf("
distrib_in depth=%s sur
", $depth); - // var_dump($tree); if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") { @@ -1606,25 +1491,24 @@ class searchEngine_adapter_phrasea_queryParser $m_o = $tree["NODETYPE"]; $m_n = $tree["PNUM"]; - $tree["CLASS"] = $tree["LB"]["CLASS"]; + $tree["CLASS"] = $tree["LB"]["CLASS"]; $tree["NODETYPE"] = $tree["LB"]["NODETYPE"]; - $tree["VALUE"] = $tree["LB"]["VALUE"]; - $tree["PNUM"] = $tree["LB"]["PNUM"]; + $tree["VALUE"] = $tree["LB"]["VALUE"]; + $tree["PNUM"] = $tree["LB"]["PNUM"]; - $tree["LB"]["CLASS"] = $m_t; + $tree["LB"]["CLASS"] = $m_t; $tree["LB"]["NODETYPE"] = $m_o; - $tree["LB"]["VALUE"] = $m_v; - $tree["LB"]["PNUM"] = $m_n; + $tree["LB"]["VALUE"] = $m_v; + $tree["LB"]["PNUM"] = $m_n; - $tree["RB"] = array("CLASS" => $m_t, - "NODETYPE" => $m_o, - "VALUE" => $m_v, - "PNUM" => $m_n, - "LB" => $tree["LB"]["RB"], - "RB" => $tree["RB"]); + $tree["RB"] = array("CLASS" => $m_t, + "NODETYPE" => $m_o, + "VALUE" => $m_v, + "PNUM" => $m_n, + "LB" => $tree["LB"]["RB"], + "RB" => $tree["RB"]); $tree["LB"]["RB"] = $tree["RB"]["RB"]; - // var_dump($tree); // return; } @@ -1639,22 +1523,22 @@ class searchEngine_adapter_phrasea_queryParser $m_o = $tree["NODETYPE"]; $m_n = $tree["PNUM"]; - $tree["CLASS"] = $tree["RB"]["CLASS"]; + $tree["CLASS"] = $tree["RB"]["CLASS"]; $tree["NODETYPE"] = $tree["RB"]["NODETYPE"]; - $tree["VALUE"] = $tree["RB"]["VALUE"]; - $tree["PNUM"] = $tree["RB"]["PNUM"]; + $tree["VALUE"] = $tree["RB"]["VALUE"]; + $tree["PNUM"] = $tree["RB"]["PNUM"]; - $tree["RB"]["CLASS"] = $m_t; + $tree["RB"]["CLASS"] = $m_t; $tree["RB"]["NODETYPE"] = $m_o; - $tree["RB"]["VALUE"] = $m_v; - $tree["RB"]["PNUM"] = $m_n; + $tree["RB"]["VALUE"] = $m_v; + $tree["RB"]["PNUM"] = $m_n; - $tree["LB"] = array("CLASS" => $m_t, - "NODETYPE" => $m_o, - "VALUE" => $m_v, - "PNUM" => $m_n, - "LB" => $tree["LB"], - "RB" => $tree["RB"]["LB"]); + $tree["LB"] = array("CLASS" => $m_t, + "NODETYPE" => $m_o, + "VALUE" => $m_v, + "PNUM" => $m_n, + "LB" => $tree["LB"], + "RB" => $tree["RB"]["LB"]); $tree["RB"]["LB"] = $tree["LB"]["LB"]; } @@ -1711,7 +1595,7 @@ class searchEngine_adapter_phrasea_queryParser { // printf("\n\n"); $tree = null; - while ($t = $this->nexttoken($inquote)) + while ($t = $this->nexttoken($inquote)) { if ($this->debug) printf("got token %s of class %s\n", $t["VALUE"], $t["CLASS"]); @@ -1723,7 +1607,6 @@ class searchEngine_adapter_phrasea_queryParser // quand on est entre guillements les tokens perdent leur signification $tree = $this->addtotree($tree, $t, $depth, $inquote); if (!$tree) - return(null); } else @@ -1746,7 +1629,6 @@ class searchEngine_adapter_phrasea_queryParser // quand on est entre guillements les tokens perdent leur signification $tree = $this->addtotree($tree, $t, $depth, $inquote); if (!$tree) - return(null); } else // '(' : appel récursif @@ -1759,22 +1641,21 @@ class searchEngine_adapter_phrasea_queryParser { $tree["RB"] = $this->maketree($depth + 1); if (!$tree["RB"]) - $tree = null; + $tree = null; } else { // ici on applique l'opérateur par défaut - $tree = array("CLASS" => "OPS", - "VALUE" => $this->defaultop["VALUE"], - "NODETYPE" => $this->defaultop["NODETYPE"], - "PNUM" => $this->defaultop["PNUM"], - "DEPTH" => $depth, - "LB" => $tree, - "RB" => $this->maketree($depth + 1)); + $tree = array("CLASS" => "OPS", + "VALUE" => $this->defaultop["VALUE"], + "NODETYPE" => $this->defaultop["NODETYPE"], + "PNUM" => $this->defaultop["PNUM"], + "DEPTH" => $depth, + "LB" => $tree, + "RB" => $this->maketree($depth + 1)); } } if (!$tree) - return(null); } break; @@ -1816,22 +1697,21 @@ class searchEngine_adapter_phrasea_queryParser { $tree["RB"] = $this->maketree($depth + 1, true); if (!$tree["RB"]) - $tree = null; + $tree = null; } else { // ici on applique l'opérateur par défaut - $tree = array("CLASS" => "OPS", - "VALUE" => $this->defaultop["VALUE"], - "NODETYPE" => $this->defaultop["NODETYPE"], - "PNUM" => $this->defaultop["PNUM"], - "DEPTH" => $depth, - "LB" => $tree, - "RB" => $this->maketree($depth + 1, true)); + $tree = array("CLASS" => "OPS", + "VALUE" => $this->defaultop["VALUE"], + "NODETYPE" => $this->defaultop["NODETYPE"], + "PNUM" => $this->defaultop["PNUM"], + "DEPTH" => $depth, + "LB" => $tree, + "RB" => $this->maketree($depth + 1, true)); } } if (!$tree) - return(null); } break; @@ -1844,7 +1724,6 @@ class searchEngine_adapter_phrasea_queryParser print("-------------------------\n"); } if (!$tree) - return(null); break; } @@ -1871,7 +1750,6 @@ class searchEngine_adapter_phrasea_queryParser } if (!$t) - return($tree); switch ($t["CLASS"]) { @@ -1879,7 +1757,6 @@ class searchEngine_adapter_phrasea_queryParser // if($this->debug) // { // printf("addtotree({tree}, \$t='%s', \$depth=%d, inquote=%s)\n", $t["VALUE"], $depth, $inquote?"true":"false"); -// var_dump($tree); // } if ($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") { @@ -1940,7 +1817,7 @@ class searchEngine_adapter_phrasea_queryParser return(null); } - return(array("CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); + return(array("CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); break; case "TOK_WORD": if ($t["CLASS"] == "TOK_WORD" && isset($this->ops[$t["VALUE"]]) && !$inquote) @@ -1978,17 +1855,17 @@ class searchEngine_adapter_phrasea_queryParser } } - return(array("CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); + return(array("CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); } else { // ce mot n'est pas un opérateur - $pnum = null; + $pnum = null; $nodetype = PHRASEA_KEYLIST; if ($t["CLASS"] == "TOK_WORD" && isset($this->spw[$t["VALUE"]]) && !$inquote) { // mais c'est un mot 'spécial' de phrasea ('last', 'all') - $type = $this->spw[$t["VALUE"]]["CLASS"]; + $type = $this->spw[$t["VALUE"]]["CLASS"]; $nodetype = $this->spw[$t["VALUE"]]["NODETYPE"]; if ($this->spw[$t["VALUE"]]["CANNUM"]) { @@ -2016,9 +1893,9 @@ class searchEngine_adapter_phrasea_queryParser function addsimple($t, $type, $nodetype, $pnum, $tree, $depth) { - $nok = 0; + $nok = 0; $registry = registry::get_instance(); - $w = $t["VALUE"]; + $w = $t["VALUE"]; if ($w != "?" && $w != "*") // on laisse passer les 'isolés' pour les traiter plus tard comme des mots vides { for ($i = 0; $i < strlen($w); $i++) @@ -2042,7 +1919,7 @@ class searchEngine_adapter_phrasea_queryParser } if (!$tree) { - return(array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth)); + return(array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth)); } switch ($tree["CLASS"]) { @@ -2052,17 +1929,17 @@ class searchEngine_adapter_phrasea_queryParser $tree["VALUE"][] = $t["VALUE"]; else { - $tree = array("CLASS" => "OPS", - "VALUE" => "et", - "NODETYPE" => PHRASEA_OP_AND, - "PNUM" => null, - "DEPTH" => $depth, - "LB" => $tree, - "RB" => array("CLASS" => $type, - "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), - "PNUM" => $pnum, - "DEPTH" => $depth)); + $tree = array("CLASS" => "OPS", + "VALUE" => "et", + "NODETYPE" => PHRASEA_OP_AND, + "PNUM" => null, + "DEPTH" => $depth, + "LB" => $tree, + "RB" => array("CLASS" => $type, + "NODETYPE" => $nodetype, + "VALUE" => array($t["VALUE"]), + "PNUM" => $pnum, + "DEPTH" => $depth)); } return($tree); @@ -2070,7 +1947,7 @@ class searchEngine_adapter_phrasea_queryParser case "OPK": if ($tree["RB"] == null) { - $tree["RB"] = array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth); + $tree["RB"] = array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth); return($tree); } @@ -2084,43 +1961,43 @@ class searchEngine_adapter_phrasea_queryParser } if (($tree["RB"]["CLASS"] == "PHRASEA_KW_LAST" || $tree["RB"]["CLASS"] == "PHRASEA_KW_ALL") && $tree["RB"]["DEPTH"] == $depth) { - $tree["RB"] = array("CLASS" => "OPS", - "VALUE" => "et", - "NODETYPE" => PHRASEA_OP_AND, - "PNUM" => null, - "DEPTH" => $depth, - "LB" => $tree["RB"], - "RB" => array("CLASS" => $type, - "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), - "PNUM" => $pnum, - "DEPTH" => $depth)); + $tree["RB"] = array("CLASS" => "OPS", + "VALUE" => "et", + "NODETYPE" => PHRASEA_OP_AND, + "PNUM" => null, + "DEPTH" => $depth, + "LB" => $tree["RB"], + "RB" => array("CLASS" => $type, + "NODETYPE" => $nodetype, + "VALUE" => array($t["VALUE"]), + "PNUM" => $pnum, + "DEPTH" => $depth)); return($tree); } - return(array("CLASS" => "OPS", - "VALUE" => $this->defaultop["VALUE"], - "NODETYPE" => $this->defaultop["NODETYPE"], - "PNUM" => $this->defaultop["PNUM"], - "DEPTH" => $depth, - "LB" => $tree, - "RB" => array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth) - )); + return(array("CLASS" => "OPS", + "VALUE" => $this->defaultop["VALUE"], + "NODETYPE" => $this->defaultop["NODETYPE"], + "PNUM" => $this->defaultop["PNUM"], + "DEPTH" => $depth, + "LB" => $tree, + "RB" => array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth) + )); } case "PHRASEA_KW_LAST": case "PHRASEA_KW_ALL": - return(array("CLASS" => "OPS", - "VALUE" => "et", - "NODETYPE" => PHRASEA_OP_AND, - "PNUM" => null, - "DEPTH" => $depth, - "LB" => $tree, - "RB" => array("CLASS" => $type, - "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), - "PNUM" => $pnum, - "DEPTH" => $depth))); + return(array("CLASS" => "OPS", + "VALUE" => "et", + "NODETYPE" => PHRASEA_OP_AND, + "PNUM" => null, + "DEPTH" => $depth, + "LB" => $tree, + "RB" => array("CLASS" => $type, + "NODETYPE" => $nodetype, + "VALUE" => array($t["VALUE"]), + "PNUM" => $pnum, + "DEPTH" => $depth))); } } @@ -2129,10 +2006,9 @@ class searchEngine_adapter_phrasea_queryParser $this->phq = $s . " " . $this->phq; } - function nexttoken($inquote=false) + function nexttoken($inquote = false) { if ($this->phq == "") - return(null); switch ($c = substr($this->phq, 0, 1)) { @@ -2144,7 +2020,7 @@ class searchEngine_adapter_phrasea_queryParser return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); } - $c2 = $c . substr($this->phq, 1, 1); + $c2 = $c . substr($this->phq, 1, 1); if ($c2 == "<=" || $c2 == ">=" || $c2 == "<>") { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 2, 99999, 'UTF-8'), 'UTF-8'); @@ -2241,10 +2117,10 @@ class searchEngine_adapter_phrasea_queryParser return(array("CLASS" => "TOK_QUOTE", "VALUE" => "\"")); break; default: - $l = mb_strlen($this->phq, 'UTF-8'); - $t = ""; + $l = mb_strlen($this->phq, 'UTF-8'); + $t = ""; $c_utf8 = ""; - for ($i = 0; $i < $l; $i++) + for ($i = 0; $i < $l; $i++) { if (!$this->unicode->has_indexer_bad_char(($c_utf8 = mb_substr($this->phq, $i, 1, 'UTF-8')))) { @@ -2267,10 +2143,8 @@ class searchEngine_adapter_phrasea_queryParser $this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8'); } if ($t != "") - return(array("CLASS" => "TOK_WORD", "VALUE" => $t)); else - return(array("CLASS" => "TOK_VOID", "VALUE" => $t)); break; } diff --git a/lib/classes/system/file.class.php b/lib/classes/system/file.class.php index 35cac3b692..c70fb4b0f2 100644 --- a/lib/classes/system/file.class.php +++ b/lib/classes/system/file.class.php @@ -713,8 +713,6 @@ class system_file extends SplFileObject public function read_uuid() { - $registry = registry::get_instance(); - if ($this->uuid) return $this->uuid; @@ -1135,12 +1133,12 @@ class system_file extends SplFileObject foreach ($tmpval as $val) { - $ret[] = array( - 'meta_struct_id' => $meta->get_id(), - 'meta_id' => null, + $ret[] = array( + 'meta_struct_id' => $meta->get_id(), + 'meta_id' => null, 'value' => $val - ); - } + ); + } } @@ -1390,7 +1388,7 @@ if (!function_exists('mime_content_type')) , 'movie' => 'video/x-sgi-movie' // Videos MoviePlayer ); $fileinfo = new system_file($f); - $extension = $fileinfo->get_extension(true); + $ext = $fileinfo->get_extension(true); return array_key_exists($ext, $ext2mime) ? $ext2mime[$ext] : 'application/octet-stream'; diff --git a/lib/classes/task/period/archive.class.php b/lib/classes/task/period/archive.class.php index 4299bbebd1..b4c8d92c11 100644 --- a/lib/classes/task/period/archive.class.php +++ b/lib/classes/task/period/archive.class.php @@ -1538,7 +1538,7 @@ class task_period_archive extends task_abstract $collection = collection::get_from_coll_id($databox, $cid); $record = record_adapter::create($collection, $system_file, false, true); - $record->set_metadatas($meta['metadatas']); + $record->set_metadatas($meta['metadatas'], true); $record->set_binary_status(databox_status::operation_or($stat0, $stat1)); $record->rebuild_subdefs(); $record->reindex(); @@ -1879,7 +1879,7 @@ class task_period_archive extends task_abstract { $collection = collection::get_from_base_id($base_id); $record = record_adapter::create($collection, $system_file, false, false); - $record->set_metadatas($meta['metadatas']); + $record->set_metadatas($meta['metadatas'], true); $record->set_binary_status(databox_status::operation_or(databox_status::operation_or($stat0, $stat1), databox_status::hex2bin($hexstat))); $record->rebuild_subdefs(); $record->reindex(); diff --git a/lib/classes/task/period/batchupload.class.php b/lib/classes/task/period/batchupload.class.php index 2fea49a7f0..1086a14e6e 100644 --- a/lib/classes/task/period/batchupload.class.php +++ b/lib/classes/task/period/batchupload.class.php @@ -100,7 +100,7 @@ class task_period_batchupload extends task_appboxAbstract $collection = collection::get_from_coll_id($databox, $coll_id); $record = record_adapter::create($collection, $system_file, $row2['filename'], false); - $record->set_metadatas($meta['metadatas']); + $record->set_metadatas($meta['metadatas'], true); $record->rebuild_subdefs(); $record->reindex(); unset($record); diff --git a/lib/classes/task/period/outofdate.class.php b/lib/classes/task/period/outofdate.class.php index 58eaef71f0..a5802b408b 100644 --- a/lib/classes/task/period/outofdate.class.php +++ b/lib/classes/task/period/outofdate.class.php @@ -1232,9 +1232,6 @@ class task_period_outofdate extends task_abstract ); phrasea::headers(200, true, 'application/json', 'UTF-8', false); -// return("hello4"); -//var_dump($parm2); -//return; $ret = NULL; switch($parm2['ACT']) { diff --git a/lib/classes/task/period/upgradetov32.class.php b/lib/classes/task/period/upgradetov32.class.php index 7d365b2a74..f63f6bfc29 100644 --- a/lib/classes/task/period/upgradetov32.class.php +++ b/lib/classes/task/period/upgradetov32.class.php @@ -338,7 +338,7 @@ class task_period_upgradetov32 extends task_abstract } } } - $record->set_metadatas($metadatas); + $record->set_metadatas($metadatas, true); unset($record); } catch (Exception $e) diff --git a/lib/classes/task/period/writemeta.class.php b/lib/classes/task/period/writemeta.class.php index 6e632ec07a..3e87a4193b 100644 --- a/lib/classes/task/period/writemeta.class.php +++ b/lib/classes/task/period/writemeta.class.php @@ -282,7 +282,6 @@ class task_period_writemeta extends task_databoxAbstract { $coll_id = $row['coll_id']; $record_id = $row['record_id']; - $base_id = phrasea::baseFromColl($this->sbas_id, $coll_id); $jeton = $row['jeton']; $record = new record_adapter($this->sbas_id, $record_id); @@ -303,92 +302,51 @@ class task_period_writemeta extends task_databoxAbstract } } - $uuid = $record->get_uuid(); - $registry = $databox->get_registry(); - $dom = new DOMDocument('1.0', 'UTF-8'); - $dom->formatOutput = true; - $dom->preserveWhiteSpace = true; - - $noderoot = $dom->appendChild($dom->createElement('rdf:RDF')); - $noderoot->setAttribute('xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); - - $nodedesc = $noderoot->appendChild($dom->createElement('rdf:Description')); - - if ($uuid) - { - $node = $nodedesc->appendChild($dom->createElement('XMP-exif:ImageUniqueID')); - $node->appendChild($dom->createTextNode($uuid)); - $node = $nodedesc->appendChild($dom->createElement('IPTC:UniqueDocumentID')); - $node->appendChild($dom->createTextNode($uuid)); - } - - $nodedesc->setAttribute('xmlns:et', 'http://ns.exiftool.ca/1.0/'); - $nodedesc->setAttribute('et:toolkit', 'Image::ExifTool 7.62'); - - $nodedesc->setAttribute('xmlns:ExifTool', 'http://ns.exiftool.ca/ExifTool/1.0/'); - $nodedesc->setAttribute('xmlns:File', 'http://ns.exiftool.ca/File/1.0/'); - $nodedesc->setAttribute('xmlns:JFIF', 'http://ns.exiftool.ca/JFIF/JFIF/1.0/'); - $nodedesc->setAttribute('xmlns:Photoshop', 'http://ns.exiftool.ca/Photoshop/Photoshop/1.0/'); - $nodedesc->setAttribute('xmlns:IPTC', 'http://ns.exiftool.ca/IPTC/IPTC/1.0/'); - $nodedesc->setAttribute('xmlns:Adobe', 'http://ns.exiftool.ca/APP14/Adobe/1.0/'); - $nodedesc->setAttribute('xmlns:FotoStation', 'http://ns.exiftool.ca/FotoStation/FotoStation/1.0/'); - $nodedesc->setAttribute('xmlns:File2', 'http://ns.exiftool.ca/File/1.0/'); - $nodedesc->setAttribute('xmlns:IPTC2', 'http://ns.exiftool.ca/IPTC/IPTC2/1.0/'); - $nodedesc->setAttribute('xmlns:Composite', 'http://ns.exiftool.ca/Composite/1.0/'); - - $nodedesc->setAttribute('xmlns:IFD0', 'http://ns.exiftool.ca/EXIF/IFD0/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-x', 'http://ns.exiftool.ca/XMP/XMP-x/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-exif', 'http://ns.exiftool.ca/XMP/XMP-exif/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-photoshop', 'http://ns.exiftool.ca/XMP/XMP-photoshop/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-tiff', 'http://ns.exiftool.ca/XMP/XMP-tiff/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-xmp', 'http://ns.exiftool.ca/XMP/XMP-xmp/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-xmpMM', 'http://ns.exiftool.ca/XMP/XMP-xmpMM/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-xmpRights', 'http://ns.exiftool.ca/XMP/XMP-xmpRights/1.0/'); - $nodedesc->setAttribute('xmlns:XMP-dc', 'http://ns.exiftool.ca/XMP/XMP-dc/1.0/'); - $nodedesc->setAttribute('xmlns:ExifIFD', 'http://ns.exiftool.ca/EXIF/ExifIFD/1.0/'); - $nodedesc->setAttribute('xmlns:GPS', 'http://ns.exiftool.ca/EXIF/GPS/1.0/'); - $nodedesc->setAttribute('xmlns:PDF', 'http://ns.exiftool.ca/PDF/PDF/1.0/'); - - $meta_struct = $databox->get_meta_structure(); - $fields = $record->get_caption()->get_fields(); + $subCMD = ''; + + if ($record->get_uuid()) + { + $subCMD .= '-XMP-exif:ImageUniqueID='; + $subCMD .= escapeshellarg($record->get_uuid()); + $subCMD .= '-IPTC:UniqueDocumentID='; + $subCMD .= escapeshellarg($record->get_uuid()); + } + foreach ($fields as $field) { $meta = $field->get_databox_field(); - $fname = $field->get_name(); if (trim($meta->get_metadata_source()) === '') continue; - $tag = $meta->get_metadata_tagname(); $multi = $meta->is_multi(); $type = $meta->get_type(); $datas = $field->get_value(); - $node = $nodedesc->appendChild($dom->createElement($tag)); + if ($multi) { - $node = $node->appendChild($dom->createElement('rdf:Bag')); $datas = $field->get_value(); foreach ($datas as $value) { $value = $this->format_value($type, $value); - $node->appendChild($dom->createElement('rdf:li'))->appendChild($dom->createTextNode($value)); + + $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; + $subCMD .= escapeshellarg($value).' '; } } else { $datas = $this->format_value($type, $datas); - $node->appendChild($dom->createTextNode($datas)); + + $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; + $subCMD .= escapeshellarg($datas).' '; } } - $temp = tempnam($registry->get('GV_RootPath') . 'tmp/', 'meta'); - rename($temp, $tempxml = $temp . '.xml'); - $dom->save($tempxml); - foreach ($tsub as $name => $file) { $cmd = ''; @@ -397,16 +355,18 @@ class task_period_writemeta extends task_databoxAbstract $cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original '); if ($name != 'document' || $this->clear_doc) $cmd .= '-all:all= '; - $cmd .= ( ' -codedcharacterset=utf8 -TagsFromFile ' . escapeshellarg($tempxml) . ' ' . escapeshellarg($file) ); - + + $cmd .= ' -codedcharacterset=utf8 '; + + $cmd .= $subCMD.' '.escapeshellarg($file); + $this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name)); $s = trim(shell_exec($cmd)); $this->log("\t" . $s); } - - unlink($tempxml); + return $this; } protected function flush_records_sbas() diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index d210fcc941..ebf3564acc 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -894,12 +894,6 @@ $GV = array( ), array( 'section' => _('GV::section:: Parametrage de l\'inscription'), 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_needMail', - 'comment' => _('reglages:: Une addresse email valide est necessaire pour l\'inscription online'), - 'default' => false - ), array( 'type' => 'boolean', 'name' => 'GV_autoselectDB', diff --git a/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php b/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php index 782da3505f..c1e11b7e9a 100644 --- a/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php @@ -1154,7 +1154,6 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract * * @todo */ -// var_dump($record["technical_informations"]); $this->assertTrue(is_array($record["technical_informations"])); diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php index f47c73ab18..34bdc9fcdf 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php @@ -109,7 +109,6 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract { $appbox = appbox::get_instance(); $crawler = $this->client->request('POST', '/feeds/requestavailable/'); - var_dump($this->client->getResponse()->getStatusCode()); $this->assertTrue($this->client->getResponse()->isOk()); $feeds = Feed_Collection::load_all($appbox, self::$user); foreach ($feeds->get_feeds() as $one_feed) diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php index 8f785714ce..76eddb349f 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php @@ -24,7 +24,8 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract */ public static $entry; public static $publisher; - public static $need_records = 1; + public static $need_records = 2; + public static $need_subdefs = true; protected $client; public function setUp() @@ -35,6 +36,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract self::$publisher = Feed_Publisher_Adapter::getPublisher(appbox::get_instance(), self::$feed, self::$user); self::$entry = Feed_Entry_Adapter::create(appbox::get_instance(), self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com"); Feed_Entry_Item::create(appbox::get_instance(), self::$entry, self::$record_1); + Feed_Entry_Item::create(appbox::get_instance(), self::$entry, self::$record_2); self::$feed->set_public(true); } @@ -73,6 +75,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/"); $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type")); $xml = $this->client->getResponse()->getContent(); + $this->verifyXML($xml); $this->verifyRSS($feed, $xml); @@ -141,6 +144,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/"); $this->assertTrue($this->client->getResponse()->isOk()); $xml = $this->client->getResponse()->getContent(); + $this->verifyXML($xml); $this->verifyRSS($feed, $xml); $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/"); @@ -161,7 +165,12 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract public function verifyXML($xml) { + /** + * XML is not verified due to Validator Service bug + */ + return; + try { $validator = new W3CFeedRawValidator($xml); @@ -177,8 +186,6 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract function verifyRSS(Feed_Adapter $feed, $xml_string) { - $this->verifyXML($xml_string); - $dom_doc = new DOMDocument(); $dom_doc->loadXML($xml_string); @@ -213,7 +220,6 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract break; case 'pubDate': $this->assertTrue(new DateTime() >= new DateTime($child->nodeValue)); - break; case 'generator': $this->assertEquals("Phraseanet", $child->nodeValue); @@ -314,8 +320,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract case 'media:content' : $this->checkMediaContentAttributes($item, $node); break; - case 'media:thumbnail' : - break; + case 'media:thumbnail': default : $this->checkOptionnalMediaGroupNode($node, $item); break; @@ -470,6 +475,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract ) ); + foreach ($fields as $key_field => $field) { if ($field["media_field"]["name"] == $node->nodeName) @@ -482,7 +488,8 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract { foreach ($node->attributes as $attribute) { - $this->assertTrue(array_key_exists($attribute->name, $field["media_field"]["attributes"]), "MIssing attribute " . $attribute->name . " for " . $field['media_field']['name']); + $this->assertTrue(array_key_exists($attribute->name, $field["media_field"]["attributes"]), "Checkin attribute ".$attribute->name." for " . $field['media_field']['name']); + $this->assertEquals($attribute->value, $field["media_field"]["attributes"][$attribute->name], "Checkin attribute ".$attribute->name." for " . $field['media_field']['name']); } } } @@ -640,4 +647,4 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract } } -} \ No newline at end of file +} diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php b/lib/unitTest/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php index f353e0cc0e..4cda299805 100644 --- a/lib/unitTest/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php @@ -17,13 +17,13 @@ require_once __DIR__ . '/../../../../../../PhraseanetPHPUnitAbstract.class.inc'; * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class DoctrineNormalTest extends PhraseanetPHPUnitAbstract +class DoctrinePhpechoTest extends PhraseanetPHPUnitAbstract { public function testService() { - $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Normal( + $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho( 'hello', array(), array() ); @@ -32,7 +32,7 @@ class DoctrineNormalTest extends PhraseanetPHPUnitAbstract public function testType() { - $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Normal( + $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho( 'hello', array(), array() ); @@ -41,7 +41,7 @@ class DoctrineNormalTest extends PhraseanetPHPUnitAbstract public function testScope() { - $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Normal( + $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho( 'hello', array(), array()); $this->assertEquals("log", $log->getScope()); } diff --git a/lib/unitTest/Bridge/Bridge_AccountSettingsTest.php b/lib/unitTest/Bridge/Bridge_AccountSettingsTest.php index 77c1c5c74f..577095051d 100644 --- a/lib/unitTest/Bridge/Bridge_AccountSettingsTest.php +++ b/lib/unitTest/Bridge/Bridge_AccountSettingsTest.php @@ -38,8 +38,7 @@ class Bridge_AccountSettingsTest extends PhraseanetPHPUnitAuthenticatedAbstract } catch (Exception $e) { - var_dump($e->getMessage()); - $this->fail(); + $this->fail($e->getMessage()); } } diff --git a/lib/unitTest/Doctrine/Entities/BasketTest.php b/lib/unitTest/Doctrine/Entities/BasketTest.php index 8d871ba8d4..ef5c556062 100644 --- a/lib/unitTest/Doctrine/Entities/BasketTest.php +++ b/lib/unitTest/Doctrine/Entities/BasketTest.php @@ -108,17 +108,6 @@ class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract $date = $this->basket->getUpdated(); $this->assertInstanceOf('\DateTime', $date); -// sleep(5); -// $this->basket->setName('hello COCOCOCO'); -// $this->basket->setDescription('44WDFDFOLSDF'); -// $this->em->persist($this->basket); -// $this->em->flush(); -// var_dump($this->basket->getId()); -// $basket = $this->em->getRepository('\Entities\Basket')->find($this->basket->getId()); -// $dateUpdated = $basket->getUpdated(); -// var_dump($date->format(DATE_ATOM), $dateUpdated->format(DATE_ATOM)); -// $this->assertGreaterThan($dateUpdated, $date); -// $this->assertGreaterThan($dateUpdated, $this->basket->getCreated()); } public function testGetElements() diff --git a/lib/unitTest/record/adapterTest.php b/lib/unitTest/record/adapterTest.php index 2f425e9c5f..f3cb1ce1fb 100644 --- a/lib/unitTest/record/adapterTest.php +++ b/lib/unitTest/record/adapterTest.php @@ -371,7 +371,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract } } - self::$record_1->set_metadatas($metadatas); + self::$record_1->set_metadatas($metadatas, true); $caption = self::$record_1->get_caption(); @@ -381,7 +381,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { $current_fields = $caption->get_fields(array($meta_el->get_name())); - $this->assertTrue(count($current_fields) == 1); + $this->assertEquals(1, count($current_fields)); $field = $current_fields[0]; $multi_imploded = implode(' ' . $meta_el->get_separator() . ' ', array('un', 'jeu', 'de', 'test')); diff --git a/templates/web/prod/actions/edit_default.twig b/templates/web/prod/actions/edit_default.twig index 0bdc514bb8..6340631d0e 100644 --- a/templates/web/prod/actions/edit_default.twig +++ b/templates/web/prod/actions/edit_default.twig @@ -69,17 +69,19 @@ {% endif %} {% for field in editing.get_fields() %} {% set i = field.get_id() %} -
- - - {% if field.get_dces_element %} - {% trans 'Ce champ est decrit comme un element DublinCore' %} - {% endif %} - - {{field.get_name()}} {% if field.is_required() %} * {% endif %} : - - ??? -
+ {% if field.is_readonly() is empty %} +
+ + + {% if field.get_dces_element %} + {% trans 'Ce champ est decrit comme un element DublinCore' %} + {% endif %} + + {{field.get_name()}} {% if field.is_required() %} * {% endif %} : + + ??? +
+ {% endif %} {% endfor %} {% endmacro %} diff --git a/www/login/authenticate.php b/www/login/authenticate.php index 69e543ac31..900d32e53b 100644 --- a/www/login/authenticate.php +++ b/www/login/authenticate.php @@ -88,7 +88,7 @@ if ((!is_null($parm['login']) && !is_null($parm['pwd'])) || $is_guest) } catch (Exception_Session_MailLocked $e) { - return phrasea::redirect("/login/?redirect=" . $parm['redirect'] . "&error=mailNotConfirm&usr=" . $logged['usr_id']); + return phrasea::redirect("/login/?redirect=" . $parm['redirect'] . "&error=mailNotConfirm&usr=" . $e->get_usr_id()); } catch (Exception_Session_WrongToken $e) { diff --git a/www/login/index.php b/www/login/index.php index 6c33085469..fdcbb66f78 100644 --- a/www/login/index.php +++ b/www/login/index.php @@ -72,7 +72,7 @@ if ($parm['error'] !== null) break; case 'mailNotConfirm' : $errorWarning = '
' . _('login::erreur: Vous n\'avez pas confirme votre email') . '
'; - if (is_numeric((int) $parm['usr'])) + if (ctype_digit($parm['usr'])) $errorWarning .= '
'; break; case 'no-base' : diff --git a/www/login/register-confirm.php b/www/login/register-confirm.php index 5ac4ae4d6d..7f64e0eb76 100644 --- a/www/login/register-confirm.php +++ b/www/login/register-confirm.php @@ -19,7 +19,7 @@ require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $request = http_request::getInstance(); -$parm = $request->get_post_datas('code'); +$parm = $request->get_parms('code'); try { @@ -27,7 +27,7 @@ try } catch(Exception_NotFound $e) { - return phrasea::redirect('/login/?redirect=/prod'); + return phrasea::redirect('/login/?redirect=/prod&error=TokenNotFound'); } $usr_id = $datas['usr_id']; diff --git a/www/login/register.php b/www/login/register.php index 7c0d5ecb81..bcd3dbc6e9 100644 --- a/www/login/register.php +++ b/www/login/register.php @@ -175,23 +175,17 @@ if ($request->has_post_datas()) ->set_company($parm['form_company']) ->set_position($parm['form_activity']) ->set_geonameid($parm['form_geonameid']); - - /** - * @todo implement this shit - */ - $fieldsname.= ",mail_locked"; - $fieldsvalue.= ",'1'"; - + $newid = $user->get_id(); -// //user cree, je branche autoregister si ya -// $autoSB = $autoB = array(); - $demandOK = array(); if ($registry->get('GV_autoregister')) { - $template_user = User_Adapter::get_usr_id_from_login('autoregister'); + $template_user_id = User_Adapter::get_usr_id_from_login('autoregister'); + + $template_user = User_Adapter::getInstance($template_user_id, appbox::get_instance()); + $user->ACL()->apply_model($template_user, array_keys($inscOK[$base_id])); } @@ -225,6 +219,7 @@ if ($request->has_post_datas()) if ($newUsrEmail) { + $user->set_mail_locked(true); return phrasea::redirect('/login/sendmail-confirm.php?usr_id=' . $newid); } diff --git a/www/login/sendmail-confirm.php b/www/login/sendmail-confirm.php index b2ecbe96d3..1d64d718ca 100644 --- a/www/login/sendmail-confirm.php +++ b/www/login/sendmail-confirm.php @@ -18,7 +18,7 @@ require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); -$parm = $request->get_post_datas('usr_id'); +$parm = $request->get_parms('usr_id'); $appbox = appbox::get_instance(); $confirm = ''; diff --git a/www/prod/answer.php b/www/prod/answer.php index c11d1403c1..30ab6e9207 100644 --- a/www/prod/answer.php +++ b/www/prod/answer.php @@ -41,7 +41,6 @@ if (!$parm['bas']) $parm["pag"] = (int) $parm["pag"]; $mod = $user->getPrefs('view'); -//var_dump($session->get_ses_id(), phrasea_open_session($session->get_ses_id(), $session->get_usr_id())); function dmicrotime_float($message = '', $stack = 'def') { static $last = array(); @@ -49,9 +48,6 @@ function dmicrotime_float($message = '', $stack = 'def') $new = ((float) $usec + (float) $sec); -// if (isset($last[$stack]) && $message) -// echo "$stack \t\t temps : $message " . ($new - $last[$stack]) . "\n"; - $last[$stack] = $new; return ($new - $last[$stack]); diff --git a/www/thesaurus2/xmlhttp/deletenohits.x.php b/www/thesaurus2/xmlhttp/deletenohits.x.php index b48a8bb6be..1afc4b92d1 100644 --- a/www/thesaurus2/xmlhttp/deletenohits.x.php +++ b/www/thesaurus2/xmlhttp/deletenohits.x.php @@ -64,9 +64,6 @@ if ($parm["bid"] !== null) $s_thits .= ( str_replace('d', '.', $rowbas['value']) . ';'); } - if ($parm['debug']) - var_dump($s_thits); - if ($parm['typ'] == 'CT') { $dom = $databox->get_dom_cterms(); diff --git a/www/xmlhttp/replacecandidate.j.php b/www/xmlhttp/replacecandidate.j.php index 52952e2162..75be66a718 100644 --- a/www/xmlhttp/replacecandidate.j.php +++ b/www/xmlhttp/replacecandidate.j.php @@ -242,10 +242,7 @@ function simplified($t) return(array('a' => $sa, 'u' => $su)); } -if ($parm['debug']) - var_dump($result); -else - print(p4string::jsonencode(array('parm' => $parm, 'result' => $result))); +print(p4string::jsonencode(array('parm' => $parm, 'result' => $result))); if ($parm['debug']) print("");