mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Cleanup
This commit is contained in:
@@ -74,7 +74,6 @@ return call_user_func(
|
|||||||
{
|
{
|
||||||
/* @var $twig \Twig_Environment */
|
/* @var $twig \Twig_Environment */
|
||||||
$twig = $app['Core']->getTwig();
|
$twig = $app['Core']->getTwig();
|
||||||
// var_dump($twig->getLoader()->getPaths());
|
|
||||||
$browser = \Browser::getInstance();
|
$browser = \Browser::getInstance();
|
||||||
|
|
||||||
if (!$browser->isMobile())
|
if (!$browser->isMobile())
|
||||||
|
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
class geonames
|
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)
|
public function name_from_id($geonameid)
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,12 @@ class http_query
|
|||||||
*/
|
*/
|
||||||
public static function getHttpCodeFromUrl($url)
|
public static function getHttpCodeFromUrl($url)
|
||||||
{
|
{
|
||||||
|
if (!is_scalar($url))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (trim($url) === '')
|
||||||
|
return null;
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||||
@@ -45,6 +51,11 @@ class http_query
|
|||||||
|
|
||||||
public static function getHttpHeaders($url)
|
public static function getHttpHeaders($url)
|
||||||
{
|
{
|
||||||
|
if (!is_scalar($url))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (trim($url) === '')
|
||||||
|
return null;
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@@ -69,8 +80,14 @@ class http_query
|
|||||||
* @param array $post_data
|
* @param array $post_data
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getUrl($url, $post_data=false)
|
public static function getUrl($url, $post_data = false)
|
||||||
{
|
{
|
||||||
|
if (!is_scalar($url))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (trim($url) === '')
|
||||||
|
return null;
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||||
|
@@ -70,7 +70,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
|||||||
|
|
||||||
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
$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 = $this->connbas->prepare($this->sql);
|
||||||
$stmt->execute($this->params);
|
$stmt->execute($this->params);
|
||||||
$this->total_row = $stmt->rowCount();
|
$this->total_row = $stmt->rowCount();
|
||||||
|
@@ -68,11 +68,13 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
var $defaultlast = 12;
|
var $defaultlast = 12;
|
||||||
var $phq;
|
var $phq;
|
||||||
var $errmsg = "";
|
var $errmsg = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $debug = false;
|
var $debug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* un tableau qui contiendra des propositions de thesaurus
|
* un tableau qui contiendra des propositions de thesaurus
|
||||||
* pour les termes de l'arbre simple
|
* pour les termes de l'arbre simple
|
||||||
@@ -80,12 +82,12 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $proposals = Array("QRY" => "", "BASES" => array());
|
var $proposals = Array("QRY" => "", "BASES" => array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current language for thesaurus
|
* Current language for thesaurus
|
||||||
* @var <type>
|
* @var <type>
|
||||||
*/
|
*/
|
||||||
var $lng = null;
|
var $lng = null;
|
||||||
|
|
||||||
protected $unicode;
|
protected $unicode;
|
||||||
|
|
||||||
function __construct($lng = "???")
|
function __construct($lng = "???")
|
||||||
@@ -120,7 +122,6 @@ 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');
|
$this->phq = $this->mb_trim($phq, 'UTF-8');
|
||||||
if ($this->phq != "")
|
if ($this->phq != "")
|
||||||
|
|
||||||
return($this->maketree(0));
|
return($this->maketree(0));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -138,18 +139,14 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
{
|
{
|
||||||
case "SIMPLE":
|
case "SIMPLE":
|
||||||
if (is_array($tree["VALUE"]))
|
if (is_array($tree["VALUE"]))
|
||||||
|
|
||||||
return(implode(" ", $tree["VALUE"]));
|
return(implode(" ", $tree["VALUE"]));
|
||||||
else
|
else
|
||||||
|
|
||||||
return($tree["VALUE"]);
|
return($tree["VALUE"]);
|
||||||
break;
|
break;
|
||||||
case "QSIMPLE":
|
case "QSIMPLE":
|
||||||
if (is_array($tree["VALUE"]))
|
if (is_array($tree["VALUE"]))
|
||||||
|
|
||||||
return("\"" . implode(" ", $tree["VALUE"]) . "\"");
|
return("\"" . implode(" ", $tree["VALUE"]) . "\"");
|
||||||
else
|
else
|
||||||
|
|
||||||
return("\"" . $tree["VALUE"] . "\"");
|
return("\"" . $tree["VALUE"] . "\"");
|
||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_ALL":
|
case "PHRASEA_KW_ALL":
|
||||||
@@ -157,19 +154,15 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_LAST":
|
case "PHRASEA_KW_LAST":
|
||||||
if ($tree["PNUM"] !== null)
|
if ($tree["PNUM"] !== null)
|
||||||
|
|
||||||
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
||||||
else
|
else
|
||||||
|
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
break;
|
break;
|
||||||
case "OPS":
|
case "OPS":
|
||||||
case "OPK":
|
case "OPK":
|
||||||
if (isset($tree["PNUM"]))
|
if (isset($tree["PNUM"]))
|
||||||
|
|
||||||
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext($tree["RB"]) . ")");
|
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext($tree["RB"]) . ")");
|
||||||
else
|
else
|
||||||
|
|
||||||
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . " " . $this->astext($tree["RB"]) . ")");
|
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . " " . $this->astext($tree["RB"]) . ")");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -178,7 +171,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
function astable(&$tree)
|
function astable(&$tree)
|
||||||
{
|
{
|
||||||
$this->calc_complexity($tree);
|
$this->calc_complexity($tree);
|
||||||
// var_dump($tree);
|
|
||||||
$txt = "";
|
$txt = "";
|
||||||
$this->astable2($txt, $tree);
|
$this->astable2($txt, $tree);
|
||||||
$txt = "<table border=\"1\">\n<tr>\n" . $txt . "</tr>\n</table>\n";
|
$txt = "<table border=\"1\">\n<tr>\n" . $txt . "</tr>\n</table>\n";
|
||||||
@@ -191,15 +183,13 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
if ($tree)
|
if ($tree)
|
||||||
{
|
{
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
||||||
|
|
||||||
return($tree["COMPLEXITY"] = $this->calc_complexity($tree["LB"]) + $this->calc_complexity($tree["RB"]));
|
return($tree["COMPLEXITY"] = $this->calc_complexity($tree["LB"]) + $this->calc_complexity($tree["RB"]));
|
||||||
else
|
else
|
||||||
|
|
||||||
return($tree["COMPLEXITY"] = 1);
|
return($tree["COMPLEXITY"] = 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function astable2(&$out, &$tree, $depth=0)
|
function astable2(&$out, &$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
switch ($tree["CLASS"])
|
switch ($tree["CLASS"])
|
||||||
{
|
{
|
||||||
@@ -246,7 +236,7 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
print("</div>\n");
|
print("</div>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpDiv2(&$tree, $depth=0)
|
function dumpDiv2(&$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
switch ($tree["CLASS"])
|
switch ($tree["CLASS"])
|
||||||
{
|
{
|
||||||
@@ -355,10 +345,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function priority_opk(&$tree, $depth=0)
|
function priority_opk(&$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK"))
|
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK"))
|
||||||
{
|
{
|
||||||
@@ -374,10 +363,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$this->priority_opk($tree["RB"], $depth + 1);
|
$this->priority_opk($tree["RB"], $depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function distrib_opk(&$tree, $depth=0)
|
function distrib_opk(&$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS"))
|
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS"))
|
||||||
{
|
{
|
||||||
@@ -404,7 +392,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
function thesaurus2_apply(&$tree, $bid)
|
function thesaurus2_apply(&$tree, $bid)
|
||||||
{
|
{
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"]))
|
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;
|
$copy = $tree;
|
||||||
$this->_extendThesaurusOnTerms($tree, $copy, $useFullText, $useThesaurus, $keepfuzzy, 0, "");
|
$this->_extendThesaurusOnTerms($tree, $copy, $useFullText, $useThesaurus, $keepfuzzy, 0, "");
|
||||||
|
|
||||||
// var_dump($tree);
|
|
||||||
$this->proposals["QRY"] = "<span id=\"thprop_q\">" . $this->_queryAsHTML($tree) . "</span>";
|
$this->proposals["QRY"] = "<span id=\"thprop_q\">" . $this->_queryAsHTML($tree) . "</span>";
|
||||||
|
|
||||||
return($copy);
|
return($copy);
|
||||||
@@ -472,7 +458,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
$ret = $tree;
|
$ret = $tree;
|
||||||
if (!$useThesaurus)
|
if (!$useThesaurus)
|
||||||
|
|
||||||
return; // full-text only : inchangé
|
return; // full-text only : inchangé
|
||||||
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
|
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
|
||||||
{
|
{
|
||||||
@@ -598,7 +583,7 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
return($tmp);
|
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)
|
if ($this->debug)
|
||||||
print("thesaurus2:\n\$tree=" . var_export($tree, true) . "\n");
|
print("thesaurus2:\n\$tree=" . var_export($tree, true) . "\n");
|
||||||
@@ -607,7 +592,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$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)
|
if (!$tree)
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
$ambigus = 0;
|
$ambigus = 0;
|
||||||
@@ -625,7 +609,7 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
return($ambigus);
|
return($ambigus);
|
||||||
}
|
}
|
||||||
|
|
||||||
function propAsHTML(&$node, &$html, $path, $depth=0)
|
function propAsHTML(&$node, &$html, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
global $parm;
|
global $parm;
|
||||||
if ($depth > 0)
|
if ($depth > 0)
|
||||||
@@ -705,8 +689,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
ksort($tsort);
|
ksort($tsort);
|
||||||
|
|
||||||
// var_dump($tsort);
|
|
||||||
|
|
||||||
foreach ($tsort as $n)
|
foreach ($tsort as $n)
|
||||||
{
|
{
|
||||||
$this->propAsHTML($n, $html, $path, $depth + 1);
|
$this->propAsHTML($n, $html, $path, $depth + 1);
|
||||||
@@ -716,10 +698,8 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$html .= $tab . "</div>\n";
|
$html .= $tab . "</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function _queryAsHTML($tree, $depth=0)
|
function _queryAsHTML($tree, $depth = 0)
|
||||||
{
|
{
|
||||||
// printf("astext : ");
|
|
||||||
// var_dump($tree);
|
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
{
|
{
|
||||||
$ambiguites = array("n" => 0, "refs" => array());
|
$ambiguites = array("n" => 0, "refs" => array());
|
||||||
@@ -753,86 +733,20 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_LAST":
|
case "PHRASEA_KW_LAST":
|
||||||
if ($tree["PNUM"] !== null)
|
if ($tree["PNUM"] !== null)
|
||||||
|
|
||||||
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
||||||
else
|
else
|
||||||
|
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
break;
|
break;
|
||||||
case "OPS":
|
case "OPS":
|
||||||
case "OPK":
|
case "OPK":
|
||||||
if (isset($tree["PNUM"]))
|
if (isset($tree["PNUM"]))
|
||||||
|
|
||||||
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . '[' . $tree["PNUM"] . '] ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . '[' . $tree["PNUM"] . '] ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
||||||
else
|
else
|
||||||
|
|
||||||
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . ' ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . ' ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
|
||||||
break;
|
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 . "<b><span onmouseover=\"return(".$mouseCallback."(event, '$path'));\" onmouseout=\"return(".$mouseCallback."(event, '$path'));\" id=\"thprop_a_".$path."\">";
|
|
||||||
$txt .= $tab . "\t\"" . $w . "";
|
|
||||||
// $txt .= $tab . "\t<span id='thprop_w_".$path."'></span>\"";
|
|
||||||
$txt .= "\"";
|
|
||||||
$txt .= $tab . "</span></b>\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)
|
function setTids(&$tree, $bid, &$domthe, $searchsynonyms)
|
||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
@@ -990,10 +904,8 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
function containsColonOperator(&$tree)
|
function containsColonOperator(&$tree)
|
||||||
{
|
{
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE"))
|
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE"))
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
||||||
@@ -1074,14 +986,11 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
if (!$id)
|
if (!$id)
|
||||||
break; // on a dépassé la racine du thésaurus
|
break; // on a dépassé la racine du thésaurus
|
||||||
$node->setAttribute("marked", "1");
|
$node->setAttribute("marked", "1");
|
||||||
// printf("<%s id='%s'<br/>\n", $node->nodeName, $node->getAttribute("id"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if ($depth == 0)
|
||||||
{
|
{
|
||||||
$ambiguites = array("n" => 0, "refs" => array());
|
$ambiguites = array("n" => 0, "refs" => array());
|
||||||
@@ -1119,28 +1028,23 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
break;
|
break;
|
||||||
case "PHRASEA_KW_LAST":
|
case "PHRASEA_KW_LAST":
|
||||||
if ($tree["PNUM"] !== null)
|
if ($tree["PNUM"] !== null)
|
||||||
|
|
||||||
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
|
||||||
else
|
else
|
||||||
|
|
||||||
return($tree["VALUE"][0]);
|
return($tree["VALUE"][0]);
|
||||||
break;
|
break;
|
||||||
case "OPS":
|
case "OPS":
|
||||||
case "OPK":
|
case "OPK":
|
||||||
if (isset($tree["PNUM"]))
|
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) . ")");
|
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
||||||
else
|
else
|
||||||
|
|
||||||
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . " " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . " " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_ambigu(&$tree, $mouseCallback="void", $depth=0)
|
function get_ambigu(&$tree, $mouseCallback = "void", $depth = 0)
|
||||||
{
|
{
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return("");
|
return("");
|
||||||
unset($tree["DEPTH"]);
|
unset($tree["DEPTH"]);
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
||||||
@@ -1162,20 +1066,17 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_default(&$tree, &$emptyw, $depth=0)
|
function set_default(&$tree, &$emptyw, $depth = 0)
|
||||||
{
|
{
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
||||||
{
|
{
|
||||||
if ($tree["CLASS"] == "OPS")
|
if ($tree["CLASS"] == "OPS")
|
||||||
{
|
{
|
||||||
if (!$this->set_default($tree["LB"], $emptyw, $depth + 1))
|
if (!$this->set_default($tree["LB"], $emptyw, $depth + 1))
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
if (!$this->set_default($tree["RB"], $emptyw, $depth + 1))
|
if (!$this->set_default($tree["RB"], $emptyw, $depth + 1))
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
else // OPK !
|
else // OPK !
|
||||||
@@ -1281,10 +1182,8 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
while ($n > 0);
|
while ($n > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function factor_or2(&$tree, $depth=0)
|
function factor_or2(&$tree, $depth = 0)
|
||||||
{
|
{
|
||||||
// printf("<hr><b>factor_or depth=%s sur</b><br>", $depth);
|
|
||||||
// var_dump($tree);
|
|
||||||
$nmodif = 0;
|
$nmodif = 0;
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
||||||
{
|
{
|
||||||
@@ -1302,11 +1201,8 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$tree["VALUE"][] = $tree["RB"]["VALUE"];
|
$tree["VALUE"][] = $tree["RB"]["VALUE"];
|
||||||
unset($tree["LB"]);
|
unset($tree["LB"]);
|
||||||
unset($tree["RB"]);
|
unset($tree["RB"]);
|
||||||
// unset($tree["NODETYPE"]);
|
|
||||||
unset($tree["PNUM"]);
|
unset($tree["PNUM"]);
|
||||||
$nmodif++;
|
$nmodif++;
|
||||||
// printf("<hr><b>donne</b><br>");
|
|
||||||
// var_dump($tree);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1314,13 +1210,11 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$nmodif += $this->factor_or2($tree["RB"], $depth + 1);
|
$nmodif += $this->factor_or2($tree["RB"], $depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("<br>return %s<br>", $nmodif);
|
|
||||||
return($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 ($tree["CLASS"] == "OPK")
|
||||||
{
|
{
|
||||||
if (isset($tree["RB"]) && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE") && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE"))
|
if (isset($tree["RB"]) && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE") && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE"))
|
||||||
@@ -1383,11 +1277,7 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
"PNUM" => NULL,
|
"PNUM" => NULL,
|
||||||
"DEPTH" => 0)
|
"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",
|
$newTreeRB = array("CLASS" => "OPK",
|
||||||
"VALUE" => "<=",
|
"VALUE" => "<=",
|
||||||
"NODETYPE" => PHRASEA_OP_LEQT,
|
"NODETYPE" => PHRASEA_OP_LEQT,
|
||||||
@@ -1400,7 +1290,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
"PNUM" => NULL,
|
"PNUM" => NULL,
|
||||||
"DEPTH" => 0)
|
"DEPTH" => 0)
|
||||||
);
|
);
|
||||||
// var_dump($newTreeRB);
|
|
||||||
// print("fin creation branche droite avec '<=' \n");
|
// print("fin creation branche droite avec '<=' \n");
|
||||||
## fin creation branche droite ( "<=" )
|
## fin creation branche droite ( "<=" )
|
||||||
|
|
||||||
@@ -1413,8 +1302,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
"RB" => $newTreeRB);
|
"RB" => $newTreeRB);
|
||||||
|
|
||||||
|
|
||||||
// et on le retourne
|
|
||||||
// var_dump($tree);
|
|
||||||
return $tree;
|
return $tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1427,7 +1314,7 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isoDate($onedate, $max=false)
|
function isoDate($onedate, $max = false)
|
||||||
{
|
{
|
||||||
$v_y = "1900";
|
$v_y = "1900";
|
||||||
$v_m = "01";
|
$v_m = "01";
|
||||||
@@ -1582,11 +1469,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
return("" . $v_y . $v_m . $v_d . $v_h . $v_minutes . $v_s);
|
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'
|
$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("<hr><b>distrib_in depth=%s sur</b><br>", $depth);
|
|
||||||
// var_dump($tree);
|
|
||||||
|
|
||||||
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
|
||||||
{
|
{
|
||||||
@@ -1624,7 +1509,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
"RB" => $tree["RB"]);
|
"RB" => $tree["RB"]);
|
||||||
|
|
||||||
$tree["LB"]["RB"] = $tree["RB"]["RB"];
|
$tree["LB"]["RB"] = $tree["RB"]["RB"];
|
||||||
// var_dump($tree);
|
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1723,7 +1607,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
// quand on est entre guillements les tokens perdent leur signification
|
// quand on est entre guillements les tokens perdent leur signification
|
||||||
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1746,7 +1629,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
// quand on est entre guillements les tokens perdent leur signification
|
// quand on est entre guillements les tokens perdent leur signification
|
||||||
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
$tree = $this->addtotree($tree, $t, $depth, $inquote);
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
else // '(' : appel récursif
|
else // '(' : appel récursif
|
||||||
@@ -1774,7 +1656,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1831,7 +1712,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1844,7 +1724,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
print("-------------------------\n");
|
print("-------------------------\n");
|
||||||
}
|
}
|
||||||
if (!$tree)
|
if (!$tree)
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1871,7 +1750,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$t)
|
if (!$t)
|
||||||
|
|
||||||
return($tree);
|
return($tree);
|
||||||
switch ($t["CLASS"])
|
switch ($t["CLASS"])
|
||||||
{
|
{
|
||||||
@@ -1879,7 +1757,6 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
// if($this->debug)
|
// if($this->debug)
|
||||||
// {
|
// {
|
||||||
// printf("addtotree({tree}, \$t='%s', \$depth=%d, inquote=%s)\n", $t["VALUE"], $depth, $inquote?"true":"false");
|
// 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")
|
if ($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE")
|
||||||
{
|
{
|
||||||
@@ -2129,10 +2006,9 @@ class searchEngine_adapter_phrasea_queryParser
|
|||||||
$this->phq = $s . " " . $this->phq;
|
$this->phq = $s . " " . $this->phq;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nexttoken($inquote=false)
|
function nexttoken($inquote = false)
|
||||||
{
|
{
|
||||||
if ($this->phq == "")
|
if ($this->phq == "")
|
||||||
|
|
||||||
return(null);
|
return(null);
|
||||||
switch ($c = substr($this->phq, 0, 1))
|
switch ($c = substr($this->phq, 0, 1))
|
||||||
{
|
{
|
||||||
@@ -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');
|
$this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8');
|
||||||
}
|
}
|
||||||
if ($t != "")
|
if ($t != "")
|
||||||
|
|
||||||
return(array("CLASS" => "TOK_WORD", "VALUE" => $t));
|
return(array("CLASS" => "TOK_WORD", "VALUE" => $t));
|
||||||
else
|
else
|
||||||
|
|
||||||
return(array("CLASS" => "TOK_VOID", "VALUE" => $t));
|
return(array("CLASS" => "TOK_VOID", "VALUE" => $t));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1056,7 +1056,6 @@ class system_file extends SplFileObject
|
|||||||
{
|
{
|
||||||
$value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue;
|
$value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue;
|
||||||
$utf8value = trim($this->guessCharset($value));
|
$utf8value = trim($this->guessCharset($value));
|
||||||
var_dump($utf8value);
|
|
||||||
$tfields[$src][] = $utf8value;
|
$tfields[$src][] = $utf8value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1132,12 +1131,15 @@ class system_file extends SplFileObject
|
|||||||
$tmpval[] = $val;
|
$tmpval[] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($tmpval as $val)
|
||||||
|
{
|
||||||
$ret[] = array(
|
$ret[] = array(
|
||||||
'meta_struct_id' => $meta->get_id(),
|
'meta_struct_id' => $meta->get_id(),
|
||||||
'meta_id' => null,
|
'meta_id' => null,
|
||||||
'value' => $tmpval
|
'value' => $val
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$statBit = null;
|
$statBit = null;
|
||||||
|
@@ -1154,7 +1154,6 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
*
|
*
|
||||||
* @todo
|
* @todo
|
||||||
*/
|
*/
|
||||||
// var_dump($record["technical_informations"]);
|
|
||||||
|
|
||||||
$this->assertTrue(is_array($record["technical_informations"]));
|
$this->assertTrue(is_array($record["technical_informations"]));
|
||||||
|
|
||||||
|
@@ -38,8 +38,7 @@ class Bridge_AccountSettingsTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
var_dump($e->getMessage());
|
$this->fail($e->getMessage());
|
||||||
$this->fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,17 +108,6 @@ class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$date = $this->basket->getUpdated();
|
$date = $this->basket->getUpdated();
|
||||||
$this->assertInstanceOf('\DateTime', $date);
|
$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()
|
public function testGetElements()
|
||||||
|
Reference in New Issue
Block a user