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/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/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/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 2af7486eed..c70fb4b0f2 100644 --- a/lib/classes/system/file.class.php +++ b/lib/classes/system/file.class.php @@ -1056,7 +1056,6 @@ class system_file extends SplFileObject { $value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue; $utf8value = trim($this->guessCharset($value)); - var_dump($utf8value); $tfields[$src][] = $utf8value; } } @@ -1132,12 +1131,15 @@ class system_file extends SplFileObject $tmpval[] = $val; } + foreach ($tmpval as $val) + { $ret[] = array( 'meta_struct_id' => $meta->get_id(), 'meta_id' => null, - 'value' => $tmpval + 'value' => $val ); } + } $statBit = null; 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/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()