mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch '3.8'
Conflicts: composer.lock lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
"symfony/symfony" : "2.4.x-dev",
|
||||
"alchemy-fr/tcpdf-clone" : "~6.0",
|
||||
"themattharris/tmhoauth" : "~0.7",
|
||||
"twig/twig" : "~1.13.0",
|
||||
"twig/twig" : "~1.14, >=1.14.2",
|
||||
"twig/extensions" : "~1.0",
|
||||
"zend/gdata" : "~1.12.1"
|
||||
},
|
||||
|
||||
22
composer.lock
generated
22
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "4f95339f95a308e3ad5bef8f973bffa9",
|
||||
"hash": "090224c87151fc64fac81c3e8d258481",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alchemy-fr/tcpdf-clone",
|
||||
@@ -2821,12 +2821,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/symfony.git",
|
||||
"reference": "f7692beec7ad44e4b48c92d9936501ac235925b6"
|
||||
"reference": "7fecfbce3e7ce87d3a04d8276fd835cd73979309"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/symfony/zipball/f7692beec7ad44e4b48c92d9936501ac235925b6",
|
||||
"reference": "f7692beec7ad44e4b48c92d9936501ac235925b6",
|
||||
"url": "https://api.github.com/repos/symfony/symfony/zipball/7fecfbce3e7ce87d3a04d8276fd835cd73979309",
|
||||
"reference": "7fecfbce3e7ce87d3a04d8276fd835cd73979309",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2926,7 +2926,7 @@
|
||||
"keywords": [
|
||||
"framework"
|
||||
],
|
||||
"time": "2013-10-31 11:15:14"
|
||||
"time": "2013-10-31 14:00:33"
|
||||
},
|
||||
{
|
||||
"name": "themattharris/tmhoauth",
|
||||
@@ -3019,16 +3019,16 @@
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.13.2",
|
||||
"version": "v1.14.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fabpot/Twig.git",
|
||||
"reference": "6d6a1009427d1f398c9d40904147bf9f723d5755"
|
||||
"reference": "ca445842fcea4f844d68203ffa2d00f5e3cdea64"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/6d6a1009427d1f398c9d40904147bf9f723d5755",
|
||||
"reference": "6d6a1009427d1f398c9d40904147bf9f723d5755",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/ca445842fcea4f844d68203ffa2d00f5e3cdea64",
|
||||
"reference": "ca445842fcea4f844d68203ffa2d00f5e3cdea64",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3037,7 +3037,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.13-dev"
|
||||
"dev-master": "1.14-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -3064,7 +3064,7 @@
|
||||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"time": "2013-08-03 15:35:31"
|
||||
"time": "2013-10-30 08:20:53"
|
||||
},
|
||||
{
|
||||
"name": "zend/gdata",
|
||||
|
||||
@@ -76,7 +76,7 @@ class Step35 implements DatasUpgraderInterface
|
||||
$stmt->execute(array(':record_id' => $row['record_id']));
|
||||
|
||||
try {
|
||||
$record = new \record_adapter($app, $databox->get_sbas_id(), $row['record_id']);
|
||||
$record = new \record_adapter($this->app, $databox->get_sbas_id(), $row['record_id']);
|
||||
} catch (\Exception $e) {
|
||||
$this->app['monolog']->addError(sprintf("Unable to load record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $record->get_sbas_id(), $e->getMessage()));
|
||||
continue;
|
||||
|
||||
@@ -28,11 +28,16 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
|
||||
$controllers->before(function () use ($app) {
|
||||
$app['firewall']->requireAuthentication();
|
||||
$app['firewall']->requireAccessToModule('thesaurus');
|
||||
});
|
||||
|
||||
$controllers->match('acceptcandidates.j.php', 'controller.thesaurus.xmlhttp:AcceptCandidatesJson');
|
||||
$controllers->match('checkcandidatetarget.j.php', 'controller.thesaurus.xmlhttp:CheckCandidateTargetJson');
|
||||
$controllers->match('acceptcandidates.j.php', 'controller.thesaurus.xmlhttp:AcceptCandidatesJson')
|
||||
->before(function () use ($app) {
|
||||
$app['firewall']->requireAccessToModule('thesaurus');
|
||||
});
|
||||
$controllers->match('checkcandidatetarget.j.php', 'controller.thesaurus.xmlhttp:CheckCandidateTargetJson')
|
||||
->before(function () use ($app) {
|
||||
$app['firewall']->requireAccessToModule('thesaurus');
|
||||
});
|
||||
$controllers->match('editing_presets.j.php', 'controller.thesaurus.xmlhttp:EditingPresetsJson');
|
||||
$controllers->match('getsy_prod.x.php', 'controller.thesaurus.xmlhttp:GetSynonymsXml');
|
||||
$controllers->match('getterm_prod.h.php', 'controller.thesaurus.xmlhttp:GetTermHtml');
|
||||
@@ -40,7 +45,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$controllers->match('openbranch_prod.j.php', 'controller.thesaurus.xmlhttp:OpenBranchJson');
|
||||
$controllers->match('openbranches_prod.h.php', 'controller.thesaurus.xmlhttp:OpenBranchesHtml');
|
||||
$controllers->match('openbranches_prod.x.php', 'controller.thesaurus.xmlhttp:OpenBranchesXml');
|
||||
$controllers->match('replacecandidate.j.php', 'controller.thesaurus.xmlhttp:ReplaceCandidateJson');
|
||||
$controllers->match('replacecandidate.j.php', 'controller.thesaurus.xmlhttp:ReplaceCandidateJson')
|
||||
->before(function () use ($app) {
|
||||
$app['firewall']->requireAccessToModule('thesaurus');
|
||||
});
|
||||
$controllers->match('search_th_term_prod.j.php', 'controller.thesaurus.xmlhttp:SearchTermJson');
|
||||
|
||||
return $controllers;
|
||||
@@ -75,6 +83,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$q = "/thesaurus//te[@id='" . $request->get("tid") . "']";
|
||||
}
|
||||
|
||||
if ($request->get("debug")) {
|
||||
printf("qth: %s<br/>\n", $q);
|
||||
}
|
||||
|
||||
$parentnode = $xpathth->query($q)->item(0);
|
||||
if (!$parentnode) {
|
||||
throw new \Exception('Unable to find branch');
|
||||
@@ -85,6 +97,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
|
||||
foreach ($request->get("cid") as $cid) {
|
||||
$q = "//te[@id='" . $cid . "']";
|
||||
if ($request->get("debug")) {
|
||||
printf("qct: %s<br/>\n", $q);
|
||||
}
|
||||
$ct = $xpathct->query($q)->item(0);
|
||||
if (!$ct) {
|
||||
continue;
|
||||
@@ -106,6 +121,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$this->renumerate($request->get('piv'), $te, $pid, $chgids);
|
||||
$te = $parentnode->appendChild($te);
|
||||
|
||||
if ($request->get("debug")) {
|
||||
printf("newid=%s<br/>\n", $te->getAttribute("id"));
|
||||
}
|
||||
|
||||
$soldid = str_replace(".", "d", $oldid) . "d";
|
||||
$snewid = str_replace(".", "d", $pid) . "d";
|
||||
$l = strlen($soldid) + 1;
|
||||
@@ -114,9 +133,13 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
SET value=CONCAT('$snewid', SUBSTRING(value FROM $l))
|
||||
WHERE value LIKE :like";
|
||||
|
||||
if ($request->get("debug")) {
|
||||
printf("soldid=%s ; snewid=%s<br/>\nsql=%s<br/>\n", $soldid, $snewid, $sql);
|
||||
} else {
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute(array(':like' => $soldid . '%'));
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
$refreshid = $parentnode->getAttribute('id');
|
||||
$refresh['T' . $refreshid] = array(
|
||||
@@ -142,6 +165,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
if ($ct2->nodeType != XML_ELEMENT_NODE || $ct2->nodeName != 'sy') {
|
||||
continue;
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
printf("ct2:%s \n", var_export($ct2, true));
|
||||
}
|
||||
$nid = $parentnode->getAttribute("nextid");
|
||||
$parentnode->setAttribute("nextid", (int) $nid + 1);
|
||||
|
||||
@@ -158,6 +184,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$this->renumerate($request->get('piv'), $te, $pid, $chgids);
|
||||
$te = $parentnode->appendChild($te);
|
||||
|
||||
if ($request->get("debug")) {
|
||||
printf("newid=%s<br/>\n", $te->getAttribute("id"));
|
||||
}
|
||||
|
||||
$soldid = str_replace(".", "d", $oldid) . "d";
|
||||
$snewid = str_replace(".", "d", $pid) . "d";
|
||||
$l = strlen($soldid) + 1;
|
||||
@@ -166,9 +196,13 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
SET value = CONCAT('$snewid', SUBSTRING(value FROM $l))
|
||||
WHERE value LIKE :like";
|
||||
|
||||
if ($request->get("debug")) {
|
||||
printf("soldid=%s ; snewid=%s<br/>\nsql=%s<br/>\n", $soldid, $snewid, $sql);
|
||||
} else {
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute(array(':like' => $soldid . '%'));
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
$thchanged = true;
|
||||
}
|
||||
@@ -254,6 +288,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$tbranch = $databox_field->get_tbranch();
|
||||
$q = "(" . $tbranch . ")/descendant-or-self::te[@id='" . $request->get("id") . "']";
|
||||
|
||||
if ($request->get("debug")) {
|
||||
printf("tbranch-q = \" $q \" <br/>\n");
|
||||
}
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
|
||||
$json['acceptable'] = ($nodes->length > 0);
|
||||
@@ -267,6 +305,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$q = "/thesaurus//te[@id='" . $request->get("id") . "']";
|
||||
}
|
||||
|
||||
if ($request->get("debug")) {
|
||||
print("q:" . $q . "<br/>\n");
|
||||
}
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
$json['found'] = $nodes->length;
|
||||
|
||||
@@ -274,14 +316,23 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$fullpath_html = $fullpath = "";
|
||||
for ($depth = 0, $n = $nodes->item(0); $n; $n = $n->parentNode, $depth--) {
|
||||
if ($n->nodeName == "te") {
|
||||
if ($request->get("debug")) {
|
||||
printf("parent:%s<br/>\n", $n->nodeName);
|
||||
}
|
||||
$firstsy = $goodsy = null;
|
||||
for ($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling) {
|
||||
if ($n2->nodeName == "sy") {
|
||||
$sy = $n2->getAttribute("v");
|
||||
if (!$firstsy) {
|
||||
$firstsy = $sy;
|
||||
if ($request->get("debug")) {
|
||||
printf("fullpath : firstsy='%s' in %s<br/>\n", $firstsy, $n2->getAttribute("lng"));
|
||||
}
|
||||
}
|
||||
if ($n2->getAttribute("lng") == $request->get("piv")) {
|
||||
if ($request->get("debug")) {
|
||||
printf("fullpath : found '%s' in %s<br/>\n", $sy, $n2->getAttribute("lng"));
|
||||
}
|
||||
$goodsy = $sy;
|
||||
break;
|
||||
}
|
||||
@@ -324,6 +375,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
'presetid' => $request->get('presetid'),
|
||||
'title' => $request->get('title'),
|
||||
'f' => $request->get('f'),
|
||||
'debug' => $request->get('debug'),
|
||||
));
|
||||
|
||||
switch ($request->get('act')) {
|
||||
@@ -474,6 +526,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$xpath = $databox->get_xpath_thesaurus();
|
||||
$q = "/thesaurus//sy[@id='" . $request->get('id') . "']";
|
||||
|
||||
if ($request->get('debug')) {
|
||||
print("q:" . $q . "<br/>\n");
|
||||
}
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
if ($nodes->length > 0) {
|
||||
$n2 = $nodes->item(0);
|
||||
@@ -508,6 +564,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$q = "/thesaurus//te[@id='" . $request->get("id") . "']";
|
||||
}
|
||||
|
||||
if ($request->get("debug")) {
|
||||
print("q:" . $q . "<br/>\n");
|
||||
}
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
if ($nodes->length > 0) {
|
||||
$nts = 0;
|
||||
@@ -582,6 +642,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
if ($request->get("sortsy") && $request->get("lng")) {
|
||||
ksort($tts, SORT_STRING);
|
||||
}
|
||||
if ($request->get("debug")) {
|
||||
printf("tts : <pre>%s</pre><br/>\n", var_export($tts, true));
|
||||
}
|
||||
|
||||
$bid = $request->get("bid");
|
||||
foreach ($tts as $ts) {
|
||||
@@ -623,6 +686,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
"bid" => $request->get('bid'),
|
||||
"id" => $request->get('id'),
|
||||
"sortsy" => $request->get('sortsy'),
|
||||
"debug" => $request->get('debug'),
|
||||
), true)));
|
||||
|
||||
$html = $root->appendChild($ret->createElement("html"));
|
||||
@@ -645,6 +709,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$q = "/thesaurus//te[@id='" . $request->get("id") . "']";
|
||||
}
|
||||
|
||||
if ($request->get("debug")) {
|
||||
print("q:" . $q . "<br/>\n");
|
||||
}
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
if ($nodes->length > 0) {
|
||||
$nts = 0;
|
||||
@@ -720,6 +788,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
if ($request->get("sortsy") && $app['locale']) {
|
||||
ksort($tts, SORT_STRING);
|
||||
}
|
||||
if ($request->get("debug")) {
|
||||
printf("tts : <pre>%s</pre><br/>\n", var_export($tts, true));
|
||||
}
|
||||
|
||||
$zhtml = "";
|
||||
$bid = $request->get("bid");
|
||||
@@ -788,6 +859,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
|
||||
}
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid] = $rowbas;
|
||||
}
|
||||
@@ -804,6 +879,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
|
||||
}
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid . $rowbas['k']] = $rowbas;
|
||||
}
|
||||
@@ -821,6 +900,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
|
||||
}
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid] = $rowbas;
|
||||
}
|
||||
@@ -837,11 +920,19 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
|
||||
}
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid . '.' . $rowbas['k']] = $rowbas;
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("/* %s */\n", var_export($t_nrec, true));
|
||||
}
|
||||
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbid);
|
||||
if ($request->get('type') == 'T') {
|
||||
$xqroot = 'thesaurus';
|
||||
@@ -852,12 +943,19 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
if ($dom) {
|
||||
$term0 = '';
|
||||
$firstTerm0 = '';
|
||||
|
||||
$xpath = new \DOMXPath($dom);
|
||||
if ($thid == 'T' || $thid == 'C') {
|
||||
$q = '/' . $xqroot;
|
||||
$term0 = $dbname;
|
||||
} else {
|
||||
$q = '/' . $xqroot . '//te[@id=\'' . $thid . '\']';
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
print("q:" . $q . "<br/>\n");
|
||||
}
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
if ($nodes->length > 0) {
|
||||
@@ -911,6 +1009,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("tts(%s) : <pre>%s</pre><br/>\n", $nts, var_export($tts, true));
|
||||
}
|
||||
|
||||
if ($nts > 0) {
|
||||
$field0 = $node0->getAttribute('field');
|
||||
if ($field0) {
|
||||
@@ -924,6 +1026,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
} elseif ($request->get('type') == 'C') {
|
||||
$tts = array_reverse($tts);
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
printf("%s: type=%s : <pre>%s</pre><br/>\n", __LINE__, $request->get('type'), var_export($tts, true));
|
||||
}
|
||||
|
||||
foreach ($tts as $ts) {
|
||||
$class = '';
|
||||
@@ -973,6 +1078,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
'id' => $request->get('id'),
|
||||
'lng' => $request->get('lng'),
|
||||
'sortsy' => $request->get('sortsy'),
|
||||
'debug' => $request->get('debug'),
|
||||
'root' => $request->get('root'),
|
||||
'last' => $request->get('last'),
|
||||
), 'html' => $html));
|
||||
@@ -1049,6 +1155,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$xpath = $databox->get_xpath_thesaurus();
|
||||
$q = '/thesaurus';
|
||||
|
||||
if ($request->get('debug')) {
|
||||
print('q:' . $q . '<br/>\n');
|
||||
}
|
||||
if (($znode = $xpath->query($q)->item(0))) {
|
||||
$q2 = '//sy';
|
||||
if ($request->get('t')) {
|
||||
@@ -1085,6 +1194,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$html .= '</p>';
|
||||
}
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
printf('zhtml=%s<br/>\n', $html);
|
||||
}
|
||||
}
|
||||
|
||||
return new Response($html);
|
||||
@@ -1173,6 +1285,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
'bid' => $request->get('bid'),
|
||||
't' => $request->get('t'),
|
||||
'mod' => $request->get('mod'),
|
||||
'debug' => $request->get('debug'),
|
||||
), true)));
|
||||
|
||||
$html = $root->appendChild($ret->createElement('html'));
|
||||
@@ -1191,6 +1304,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$xpath = $databox->get_xpath_thesaurus();
|
||||
$q = '/thesaurus';
|
||||
|
||||
if ($request->get('debug')) {
|
||||
print('q:' . $q . '<br/>\n');
|
||||
}
|
||||
|
||||
if (($znode = $xpath->query($q)->item(0))) {
|
||||
$q2 = '//sy';
|
||||
if ($request->get('t')) {
|
||||
@@ -1200,12 +1317,18 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
|
||||
$q2 = '//sy[' . $q2 . ']';
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
print('q2:' . $q2 . '<br/>\n');
|
||||
}
|
||||
$nodes = $xpath->query($q2, $znode);
|
||||
if ($mod == 'TREE') {
|
||||
for ($i = 0; $i < $nodes->length; $i++) {
|
||||
$nodes->item($i)->setAttribute('bold', '1');
|
||||
for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
|
||||
$n->setAttribute('open', '1');
|
||||
if ($request->get('debug')) {
|
||||
printf('opening node te id=%s<br/>\n', $n->getAttribute('id'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,6 +1346,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$zhtml .= '</p>';
|
||||
}
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
printf('zhtml=%s<br/>\n', $zhtml);
|
||||
}
|
||||
$html->appendChild($ret->createTextNode($zhtml));
|
||||
}
|
||||
|
||||
@@ -1308,6 +1434,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$tsbas['b' . $sbas_id]['tids'][] = implode('.', $id);
|
||||
}
|
||||
|
||||
if ($request->get('debug')) {
|
||||
var_dump($tsbas);
|
||||
}
|
||||
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
|
||||
// first, count the number of records to update
|
||||
@@ -1334,7 +1464,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$xp = '//te[@id="' . $tid . '"]/sy';
|
||||
$nodes = $xpathct->query($xp);
|
||||
if ($nodes->length == 1) {
|
||||
$sy = $nodes->item(0);
|
||||
$sy = $term = $nodes->item(0);
|
||||
$syid = str_replace('.', 'd', $sy->getAttribute('id')) . 'd';
|
||||
$lid .= ( $lid ? ',' : '') . "'" . $syid . "'";
|
||||
$field = $sy->parentNode->parentNode->getAttribute('field');
|
||||
@@ -1359,12 +1489,22 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) sql: \n", __LINE__);
|
||||
var_dump($sql);
|
||||
}
|
||||
|
||||
$tsbas[$ksbas]['trids'] = $stmt->fetchAll(\PDO::FETCH_COLUMN, 0);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$ret['nRecsToUpdate'] += count($tsbas[$ksbas]['trids']);
|
||||
}
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) nRecsToUpdate = %d \ntsbas: \n", __LINE__, $ret['nRecsToUpdate']);
|
||||
print_r($tsbas);
|
||||
}
|
||||
|
||||
if ($ret['nRecsToUpdate'] <= self::SEARCH_REPLACE_MAXREC) {
|
||||
foreach ($tsbas as $sbas) {
|
||||
|
||||
@@ -1378,6 +1518,10 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
|
||||
// fix caption of records
|
||||
foreach ($sbas['trids'] as $rid) {
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) ======== working on record_id = %d ======= \n", __LINE__, $rid);
|
||||
}
|
||||
try {
|
||||
$record = $databox->get_record($rid);
|
||||
|
||||
@@ -1387,11 +1531,17 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
/* @var $field caption_field */
|
||||
foreach ($record->get_caption()->get_fields(null, true) as $field) {
|
||||
$meta_struct_id = $field->get_meta_struct_id();
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) field '%s' meta_struct_id=%s \n", __LINE__, $field->get_name(), $meta_struct_id);
|
||||
}
|
||||
|
||||
/* @var $v caption_Field_Value */
|
||||
$fname = $field->get_name();
|
||||
if (!array_key_exists($fname, $sbas['tvals'])) {
|
||||
foreach ($field->get_values() as $v) {
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) ...v = '%s' (meta_id=%s) keep \n", __LINE__, $v->getValue(), $v->getId());
|
||||
}
|
||||
$metadatask[] = array(
|
||||
'meta_struct_id' => $meta_struct_id,
|
||||
'meta_id' => $v->getId(),
|
||||
@@ -1408,6 +1558,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) ...v = '%s' (meta_id=%s) %s \n", __LINE__, $v->getValue(), $v->getId(), ($keep ? '' : '!!! drop !!!'));
|
||||
}
|
||||
if ($keep) {
|
||||
$metadatask[] = array(
|
||||
'meta_struct_id' => $meta_struct_id,
|
||||
@@ -1425,15 +1578,28 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->get('debug')) {
|
||||
printf("(%d) metadatask: \n", __LINE__);
|
||||
var_dump($metadatask);
|
||||
printf("(%d) metadatasd: \n", __LINE__);
|
||||
var_dump($metadatasd);
|
||||
}
|
||||
|
||||
if (count($metadatasd) > 0) {
|
||||
if (!$request->get('debug')) {
|
||||
$record->set_metadatas($metadatasd, true);
|
||||
$ret['nRecsUpdated']++;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// delete the branch from the cterms
|
||||
if ($request->get('debug')) {
|
||||
printf("cterms before :\n%s \n", $sbas['domct']->saveXML());
|
||||
}
|
||||
foreach ($sbas['tvals'] as $tval) {
|
||||
foreach ($tval as $sy) {
|
||||
// remove candidate from cterms
|
||||
@@ -1442,8 +1608,13 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$ret['ctermsDeleted'][] = $sbas['sbas_id'] . '.' . $te->getAttribute('id');
|
||||
}
|
||||
}
|
||||
if ($request->get('debug')) {
|
||||
printf("cterms after :\n%s \n", $sbas['domct']->saveXML());
|
||||
}
|
||||
if (!$request->get('debug')) {
|
||||
$databox->saveCterms($sbas['domct']);
|
||||
}
|
||||
}
|
||||
$ret['msg'] = sprintf(_('prod::thesaurusTab:dlg:%d record(s) updated'), $ret['nRecsUpdated']);
|
||||
} else {
|
||||
// too many records to update
|
||||
@@ -1464,6 +1635,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
|
||||
$html = '';
|
||||
$sbid = (int) $request->get('sbid');
|
||||
$dbname = '';
|
||||
|
||||
try {
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbid);
|
||||
@@ -1497,13 +1669,21 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
if (($q !== null) && $domth) {
|
||||
$xpath = new \DOMXPath($domth);
|
||||
|
||||
if ($request->get('debug'))
|
||||
print('q:' . $q . "\n");
|
||||
|
||||
$t = $this->splitTermAndContext($request->get('t'));
|
||||
$q2 = 'starts-with(@w, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[0])) . '\')';
|
||||
if ($t[1])
|
||||
$q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
|
||||
$q2 = '//sy[' . $q2 . ' and @lng=\'' . $lng . '\']';
|
||||
|
||||
if ($request->get('debug'))
|
||||
print('q2:' . $q2 . "\n");
|
||||
|
||||
$q .= $q2;
|
||||
if ($request->get('debug'))
|
||||
print('q:' . $q . "\n");
|
||||
|
||||
$nodes = $xpath->query($q);
|
||||
|
||||
@@ -1511,6 +1691,8 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$nodes->item($i)->setAttribute('bold', '1');
|
||||
for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
|
||||
$n->setAttribute('open', '1');
|
||||
if ($request->get('debug'))
|
||||
printf("opening node te id=%s \n", $n->getAttribute('id'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1530,10 +1712,11 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
't' => $request->get('t'),
|
||||
'field' => $request->get('field'),
|
||||
'lng' => $request->get('lng'),
|
||||
'debug' => $request->get('debug'),
|
||||
), 'html' => $html));
|
||||
}
|
||||
|
||||
private function buildTermLabel($language, \DOMNode $n, &$key0, &$nts0)
|
||||
private function buildTermLabel($language, $n, &$key0, &$nts0)
|
||||
{
|
||||
$lngfound = false; // true when wet met a first synonym in the current language
|
||||
$key0 = null; // key of the sy in the current language (or key of the first sy if we can't find good lng)
|
||||
@@ -1639,4 +1822,9 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function call($method)
|
||||
{
|
||||
return sprintf('%s::%s', __CLASS__, $method);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user