This commit is contained in:
Romain Neutron
2012-01-25 18:45:28 +01:00
parent 4a65e2af8a
commit fc1a0abb19
9 changed files with 375 additions and 488 deletions

View File

@@ -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())

View File

@@ -2,6 +2,15 @@
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)
{

View File

@@ -25,6 +25,12 @@ class http_query
*/
public static function getHttpCodeFromUrl($url)
{
if (!is_scalar($url))
return null;
if (trim($url) === '')
return null;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
@@ -45,6 +51,11 @@ class http_query
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,8 +80,14 @@ 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)
{
if (!is_scalar($url))
return null;
if (trim($url) === '')
return null;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);

View File

@@ -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();

View File

@@ -68,11 +68,13 @@ class searchEngine_adapter_phrasea_queryParser
var $defaultlast = 12;
var $phq;
var $errmsg = "";
/**
*
* @var boolean
*/
var $debug = false;
/**
* un tableau qui contiendra des propositions de thesaurus
* pour les termes de l'arbre simple
@@ -80,12 +82,12 @@ class searchEngine_adapter_phrasea_queryParser
* @var array
*/
var $proposals = Array("QRY" => "", "BASES" => array());
/**
* Current language for thesaurus
* @var <type>
*/
var $lng = null;
protected $unicode;
function __construct($lng = "???")
@@ -120,7 +122,6 @@ class searchEngine_adapter_phrasea_queryParser
$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 = "<table border=\"1\">\n<tr>\n" . $txt . "</tr>\n</table>\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"])
{
@@ -246,7 +236,7 @@ class searchEngine_adapter_phrasea_queryParser
print("</div>\n");
}
function dumpDiv2(&$tree, $depth=0)
function dumpDiv2(&$tree, $depth = 0)
{
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)
return;
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);
}
function distrib_opk(&$tree, $depth=0)
function distrib_opk(&$tree, $depth = 0)
{
if (!$tree)
return;
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS"))
{
@@ -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"] = "<span id=\"thprop_q\">" . $this->_queryAsHTML($tree) . "</span>";
return($copy);
@@ -472,7 +458,6 @@ class searchEngine_adapter_phrasea_queryParser
if ($depth == 0)
$ret = $tree;
if (!$useThesaurus)
return; // full-text only : inchangé
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
{
@@ -598,7 +583,7 @@ 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");
@@ -607,7 +592,6 @@ class searchEngine_adapter_phrasea_queryParser
$this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
if (!$tree)
return(0);
$ambigus = 0;
@@ -625,7 +609,7 @@ 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)
@@ -705,8 +689,6 @@ class searchEngine_adapter_phrasea_queryParser
}
ksort($tsort);
// var_dump($tsort);
foreach ($tsort as $n)
{
$this->propAsHTML($n, $html, $path, $depth + 1);
@@ -716,10 +698,8 @@ class searchEngine_adapter_phrasea_queryParser
$html .= $tab . "</div>\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());
@@ -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 . "<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) . "&nbsp;" . $tree["VALUE"] . "[" . $tree["PNUM"] . "]&nbsp;" . $this->_queryAsHTML($tree["RB"], $mouseCallback, $depth+1) . ")");
else
return("(" . $this->_queryAsHTML($tree["LB"], $mouseCallback, $depth+1) . "&nbsp;" . $tree["VALUE"] . "&nbsp;" . $this->_queryAsHTML($tree["RB"], $mouseCallback, $depth+1) . ")");
break;
}
}
*/
function setTids(&$tree, $bid, &$domthe, $searchsynonyms)
{
if ($this->debug)
@@ -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")
@@ -1074,14 +986,11 @@ class searchEngine_adapter_phrasea_queryParser
if (!$id)
break; // on a dépassé la racine du thésaurus
$node->setAttribute("marked", "1");
// printf("&lt;%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)
{
$ambiguites = array("n" => 0, "refs" => array());
@@ -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")
@@ -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)
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 !
@@ -1281,10 +1182,8 @@ class searchEngine_adapter_phrasea_queryParser
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;
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
{
@@ -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("<hr><b>donne</b><br>");
// var_dump($tree);
}
else
{
@@ -1314,13 +1210,11 @@ class searchEngine_adapter_phrasea_queryParser
$nmodif += $this->factor_or2($tree["RB"], $depth + 1);
}
}
// printf("<br>return %s<br>", $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"))
@@ -1383,11 +1277,7 @@ class searchEngine_adapter_phrasea_queryParser
"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,
@@ -1400,7 +1290,6 @@ class searchEngine_adapter_phrasea_queryParser
"PNUM" => NULL,
"DEPTH" => 0)
);
// var_dump($newTreeRB);
// print("fin creation branche droite avec '<=' \n");
## fin creation branche droite ( "<=" )
@@ -1413,8 +1302,6 @@ class searchEngine_adapter_phrasea_queryParser
"RB" => $newTreeRB);
// et on le retourne
// var_dump($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_m = "01";
@@ -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("<hr><b>distrib_in depth=%s sur</b><br>", $depth);
// var_dump($tree);
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
{
@@ -1624,7 +1509,6 @@ class searchEngine_adapter_phrasea_queryParser
"RB" => $tree["RB"]);
$tree["LB"]["RB"] = $tree["RB"]["RB"];
// var_dump($tree);
// return;
}
@@ -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
@@ -1774,7 +1656,6 @@ class searchEngine_adapter_phrasea_queryParser
}
}
if (!$tree)
return(null);
}
break;
@@ -1831,7 +1712,6 @@ class searchEngine_adapter_phrasea_queryParser
}
}
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")
{
@@ -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))
{
@@ -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;
}

View File

@@ -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;

View File

@@ -1154,7 +1154,6 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
*
* @todo
*/
// var_dump($record["technical_informations"]);
$this->assertTrue(is_array($record["technical_informations"]));

View File

@@ -38,8 +38,7 @@ class Bridge_AccountSettingsTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
catch (Exception $e)
{
var_dump($e->getMessage());
$this->fail();
$this->fail($e->getMessage());
}
}

View File

@@ -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()