diff --git a/config/nginx.rewrite.rules b/config/nginx.rewrite.rules
index a1a8af46d8..eb8b3c54cd 100644
--- a/config/nginx.rewrite.rules
+++ b/config/nginx.rewrite.rules
@@ -10,7 +10,7 @@ rewrite ^/login/.*$ /index.php last;
rewrite ^/developers/.*$ /index.php last;
rewrite ^/permalink/.*$ /index.php last;
rewrite ^/datafiles/.*$ /index.php last;
-rewrite ^/thesaurus2/xmlhttp/.*$ /index.php last;
+rewrite ^/thesaurus/$ /index.php last;
rewrite ^/xmlhttp/.*$ /index.php last;
rewrite ^/prod/records/.*$ /index.php last;
rewrite ^/prod/records/edit/.*$ /index.php last;
diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php
index 949dc09300..eed0d2e9c8 100644
--- a/lib/Alchemy/Phrasea/Application.php
+++ b/lib/Alchemy/Phrasea/Application.php
@@ -661,7 +661,7 @@ class Application extends SilexApplication
$this->mount('/report/informations', new ReportInformations());
$this->mount('/report/export', new ReportExport());
- $this->mount('/thesaurus2', new Thesaurus());
+ $this->mount('/thesaurus', new Thesaurus());
$this->mount('/xmlhttp', new ThesaurusXMLHttp());
}
diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php
index 4ca88b78e0..77e641f6c6 100644
--- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php
+++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php
@@ -11,17 +11,43 @@
namespace Alchemy\Phrasea\Controller\Thesaurus;
+use Alchemy\Phrasea\Application as PhraseaApplication;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+// check ***::***
+
class Thesaurus implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
+ $controllers->before(function() use ($app) {
+ $app['firewall']->requireAuthentication();
+ $app['firewall']->requireAccessToModule('thesaurus');
+ });
+
+ $controllers->match('/', $this->call('indexThesaurus'));
+ $controllers->match('accept.php', $this->call('accept'));
+ $controllers->match('export_text.php', $this->call('exportText'));
+ $controllers->match('export_text_dlg.php', $this->call('exportTextDialog'));
+ $controllers->match('export_topics.php', $this->call('exportTopics'));
+ $controllers->match('export_topics_dlg.php', $this->call('exportTopicsDialog'));
+ $controllers->match('import.php', $this->call('import'));
+ $controllers->match('import_dlg.php', $this->call('importDialog'));
+ $controllers->match('linkfield.php', $this->call('linkFieldStep1'));
+ $controllers->match('linkfield2.php', $this->call('linkFieldStep2'));
+ $controllers->match('linkfield3.php', $this->call('linkFieldStep3'));
+ $controllers->match('loadth.php', $this->call('loadThesaurus'));
+ $controllers->match('newsy_dlg.php', $this->call('newSynonymDialog'));
+ $controllers->match('newterm.php', $this->call('newTerm'));
+ $controllers->match('properties.php', $this->call('properties'));
+ $controllers->match('search.php', $this->call('search'));
+ $controllers->match('thesaurus.php', $this->call('thesaurus'));
+
$controllers->match('xmlhttp/accept.x.php', $this->call('acceptXml'));
$controllers->match('xmlhttp/acceptcandidates.x.php', $this->call('acceptCandidatesXml'));
$controllers->match('xmlhttp/changesylng.x.php', $this->call('changeSynonymLanguageXml'));
@@ -43,6 +69,1184 @@ class Thesaurus implements ControllerProviderInterface
return $controllers;
}
+ public function accept(Application $app, Request $request)
+ {
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ $dom = $this->getXMLTerm($app, $bid, $request->get('src'), 'CT', $request->get('piv'), '0', null, '1', null);
+
+ $cterm_found = (int) $dom->documentElement->getAttribute('found');
+
+ $fullpath_src = $fullpath_tgt = $nts = $cfield = $term_found = $acceptable = null;
+
+ if ($cterm_found) {
+ $fullpath_src = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue;
+ $nts = $dom->getElementsByTagName("ts_list")->item(0)->getAttribute("nts");
+
+ if (($cfield = $dom->getElementsByTagName("cfield")->item(0))) {
+ if ($cfield->getAttribute("delbranch")) {
+ $cfield = '*';
+ } else {
+ $cfield = $cfield->getAttribute("field");
+ }
+ } else {
+ $cfield = null;
+ }
+
+ $dom = $this->getXMLTerm($app, $bid, $request->get('tgt'), 'TH', $request->get('piv'), '0', null, '1', $cfield);
+
+ $term_found = (int) $dom->documentElement->getAttribute('found');
+
+ if ($term_found) {
+ $fullpath_tgt = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue;
+ $acceptable = (int) $dom->getElementsByTagName("cfield")->item(0)->getAttribute("acceptable");
+ }
+ }
+
+ return $app['twig']->render('thesaurus/accept.html.twig', array(
+ 'dlg' => $request->get('dlg'),
+ 'bid' => $request->get('bid'),
+ 'piv' => $request->get('piv'),
+ 'src' => $request->get('src'),
+ 'tgt' => $request->get('tgt'),
+ 'cterm_found' => $cterm_found,
+ 'term_found' => $term_found,
+ 'cfield' => $cfield,
+ 'nts' => $nts,
+ 'fullpath_tgt' => $fullpath_tgt,
+ 'fullpath_src' => $fullpath_src,
+ 'acceptable' => $acceptable,
+ ));
+ }
+
+ public function exportText(Application $app, Request $request)
+ {
+ $thits = $tnodes = array();
+ $output = '';
+
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ if ($request->get("typ") == "TH" || $request->get("typ") == "CT") {
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $bid);
+ $connbas = \connection::getPDOConnection($app, $bid);
+
+ if ($request->get("typ") == "TH") {
+ $domth = $databox->get_dom_thesaurus();
+ } else {
+ $domth = $databox->get_dom_cterms();
+ }
+
+ if ($domth) {
+ $sql = "SELECT value, SUM(1) as hits FROM thit GROUP BY value";
+
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute();
+ $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ foreach ($rs as $rowbas2) {
+ $thits[str_replace('d', '.', $rowbas2["value"])] = $rowbas2["hits"];
+ }
+
+ $xpathth = new \DOMXPath($domth);
+ if ($request->get("id") == "T") {
+ $q = "/thesaurus";
+ } elseif ($request->get("id") == "C") {
+ $q = "/cterms";
+ } else {
+ $q = "//te[@id='" . $request->get("id") . "']";
+ }
+ $this->export0($xpathth->query($q)->item(0), $tnodes, $thits, $output, $request->get('iln'), $request->get('hit'), $request->get('ilg'), $request->get('osl'));
+ }
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ return $app['twig']->render('thesaurus/export-text.html.twig', array(
+ 'output' => $output,
+ 'smp' => $request->get('smp'),
+ ));
+ }
+
+ private function printTNodes(&$output, &$tnodes, $iln, $hit, $ilg, $osl)
+ {
+ $numlig = $iln == "1";
+ $hits = $hit == "1";
+ $ilg = $ilg == "1";
+ $oneline = $osl == "1";
+
+ $ilig = 1;
+ foreach ($tnodes as $node) {
+ $tabs = str_repeat("\t", $node["depth"]);
+ switch ($node["type"]) {
+ case "ROOT":
+ if ($numlig) {
+ $output .= $ilig ++ . "\t";
+ }
+ if ($hits && ! $oneline) {
+ $output .= "\t";
+ }
+ $output .= $tabs . $node["name"] . "\n";
+ break;
+ case "TRASH":
+ if ($numlig) {
+ $output .= $ilig ++ . "\t";
+ }
+ if ($hits && ! $oneline) {
+ $output .= "\t";
+ }
+ $output .= $tabs . "{TRASH}\n";
+ break;
+ case "FIELD":
+ if ($numlig) {
+ $output .= $ilig ++ . "\t";
+ }
+ if ($hits && ! $oneline) {
+ $output .= "\t";
+ }
+ $output .= $tabs . $node["name"] . "\n";
+ break;
+ case "TERM":
+ $isyn = 0;
+ if ($oneline) {
+ if ($numlig) {
+ $output .= $ilig ++ . "\t";
+ }
+ $output .= $tabs;
+ $isyn = 0;
+ foreach ($node["syns"] as $syn) {
+ if ($isyn > 0) {
+ $output .= " ; ";
+ }
+ $output .= $syn["v"];
+ if ($ilg) {
+ $output .= " [" . $syn["lng"] . "]";
+ }
+ if ($hits) {
+ $output .= " [" . $syn["hits"] . "]";
+ }
+ $isyn ++;
+ }
+ $output .= "\n";
+ } else {
+ $isyn = 0;
+ foreach ($node["syns"] as $syn) {
+ if ($numlig) {
+ $output .= $ilig ++ . "\t";
+ }
+ if ($hits) {
+ $output .= $syn["hits"] . "\t";
+ }
+ $output .= $tabs;
+
+ if ($isyn > 0) {
+ $output .= "; ";
+ }
+
+ $output .= $syn["v"];
+
+ if ($ilg) {
+ $output .= " [" . $syn["lng"] . "]";
+ }
+ $output .= "\n";
+ $isyn ++;
+ }
+ }
+ break;
+ }
+ if (! $oneline) {
+ if ($numlig) {
+ $output .= $ilig ++ . "\t";
+ }
+ $output .= "\n";
+ }
+ }
+ }
+
+ private function exportNode(&$node, &$tnodes, &$thits, $depth)
+ {
+ if ($node->nodeType == XML_ELEMENT_NODE) {
+ if (($nname = $node->nodeName) == "thesaurus" || $nname == "cterms") {
+ $tnodes[] = array(
+ "type" => "ROOT",
+ "depth" => $depth,
+ "name" => $nname,
+ "cdate" => $node->getAttribute("creation_date"),
+ "mdate" => $node->getAttribute("modification_date")
+ );
+ } elseif (($fld = $node->getAttribute("field"))) {
+ if ($node->getAttribute("delbranch")) {
+ $tnodes[] = array(
+ "type" => "TRASH",
+ "depth" => $depth,
+ "name" => $fld
+ );
+ } else {
+ $tnodes[] = array(
+ "type" => "FIELD",
+ "depth" => $depth,
+ "name" => $fld
+ );
+ }
+ } else {
+ $tsy = array();
+ for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
+ if ($n->nodeName == "sy") {
+ $id = $n->getAttribute("id");
+ if (array_key_exists($id . '.', $thits)) {
+ $hits = 0 + $thits[$id . '.'];
+ } else {
+ $hits = 0;
+ }
+
+ $tsy[] = array(
+ "v" => $n->getAttribute("v"),
+ "lng" => $n->getAttribute("lng"),
+ "hits" => $hits
+ );
+ }
+ }
+ $tnodes[] = array("type" => "TERM", "depth" => $depth, "syns" => $tsy);
+ }
+ }
+ }
+
+ private function export0($znode, &$tnodes, &$thits, &$output, $iln, $hit, $ilg, $osl)
+ {
+ $nodes = array();
+ $depth = 0;
+
+ for ($node = $znode->parentNode; $node; $node = $node->parentNode) {
+ if ($node->nodeType == XML_ELEMENT_NODE)
+ $nodes[] = $node;
+ }
+ $nodes = array_reverse($nodes);
+
+ foreach ($nodes as $depth => $node) {
+ $this->exportNode($node, $tnodes, $thits, $depth);
+ }
+
+ $this->export($znode, $tnodes, $thits, count($nodes));
+ $this->printTNodes($output, $tnodes, $iln, $hit, $ilg, $osl);
+ }
+
+ private function export($node, &$tnodes, &$thits, $depth = 0)
+ {
+ if ($node->nodeType == XML_ELEMENT_NODE) {
+ $this->exportNode($node, $tnodes, $thits, $depth);
+ }
+ for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
+ if ($n->nodeName == "te") {
+ $this->export($n, $tnodes, $thits, $depth + 1);
+ }
+ }
+ }
+
+ public function exportTextDialog(Application $app, Request $request)
+ {
+ return $app['twig']->render('thesaurus/export-text-dialog.html.twig', array(
+ 'dlg' => $request->get('dlg'),
+ 'bid' => $request->get('bid'),
+ 'typ' => $request->get('typ'),
+ 'piv' => $request->get('piv'),
+ 'id' => $request->get('id'),
+ ));
+ }
+
+ public function exportTopics(Application $app, Request $request)
+ {
+ $lng = $app['locale'];
+ $obr = explode(';', $request->get('obr'));
+
+ $t_lng = array();
+
+ if ($request->get('ofm') == 'tofiles') {
+ $t_lng = array_map(function ($code) {
+ $lng_code = explode('_', $code);
+
+ return $lng_code[0];
+ }, array_keys(PhraseaApplication::getAvailableLanguages()));
+ } else {
+ $t_lng[] = $request->get('piv');
+ }
+
+ switch ($request->get('obrf')) {
+ case 'from_itf_closable':
+ $default_display = 'closed';
+ $opened_display = 'opened';
+ break;
+ case 'from_itf_static':
+ $default_display = 'closed';
+ $opened_display = 'static';
+ break;
+ case 'all_opened_closable':
+ $default_display = 'opened';
+ $opened_display = '';
+ break;
+ case 'all_opened_static':
+ $default_display = 'static';
+ $opened_display = '';
+ break;
+ case 'all_closed':
+ $default_display = 'closed';
+ $opened_display = '';
+ break;
+ }
+
+ $now = date('YmdHis');
+ $lngs = array();
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $request->get("bid"));
+ if ($request->get("typ") == "TH") {
+ $domth = $databox->get_dom_thesaurus();
+ } else {
+ $domth = $databox->get_dom_cterms();
+ }
+
+ if ($domth) {
+ $xpathth = new \DOMXPath($domth);
+ if ($request->get("id") == "T") {
+ $q = "/thesaurus";
+ } elseif ($request->get("id") == "C") {
+ $q = "/cterms";
+ } else {
+ $q = "//te[@id='" . $request->get("id") . "']";
+ }
+
+ if ($request->get('ofm') == 'toscreen') {
+ printf("
\n");
+ }
+
+ foreach ($t_lng as $lng) {
+ $dom = new \DOMDocument("1.0", "UTF-8");
+ $dom->standalone = true;
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $root = $dom->appendChild($dom->createElementNS('www.phraseanet.com', 'phraseanet:topics'));
+
+ $root->appendChild($dom->createComment(sprintf(_('thesaurus:: fichier genere le %s'), $now)));
+
+ $root->appendChild($dom->createElement('display'))
+ ->appendChild($dom->createElement('defaultview'))
+ ->appendChild($dom->createTextNode($default_display));
+
+ $this->export0Topics($xpathth->query($q)->item(0), $dom, $root, $lng, $request->get("srt"), $request->get("sth"), $request->get("sand"), $opened_display, $obr);
+
+ if ($request->get("ofm") == 'toscreen') {
+ $lngs[$lng] = str_replace(array('&', '<', '>'), array('&', '<', '>'), $dom->saveXML());
+ } elseif ($request->get("ofm") == 'tofiles') {
+ $fname = 'topics_' . $lng . '.xml';
+
+ @rename($app['phraseanet.registry']->get('GV_RootPath') . 'config/topics/' . $fname, $app['phraseanet.registry']->get('GV_RootPath') . 'config/topics/topics_' . $lng . '_BKP_' . $now . '.xml');
+
+ if ($dom->save($app['phraseanet.registry']->get('GV_RootPath') . 'config/topics/' . $fname)) {
+ $lngs[$lng] = \p4string::MakeString(sprintf(_('thesaurus:: fichier genere : %s'), $fname));
+ } else {
+ $lngs[$lng] = \p4string::MakeString(_('thesaurus:: erreur lors de l\'enregsitrement du fichier'));
+ }
+ }
+ }
+ }
+ } catch (\Exception $e) {
+
+ }
+
+ return $app['twig']->render('thesaurus/export-topics.html.twig', array(
+ 'lngs' => $lngs,
+ 'ofm' => $request->get('ofm'),
+ ));
+ }
+
+ private function export0Topics($znode, &$dom, &$root, $lng, $srt, $sth, $sand, $opened_display, $obr)
+ {
+ $topics = $root->appendChild($dom->createElement('topics'));
+ $this->doExportTopics($znode, $dom, $topics, '', $lng, $srt, $sth, $sand, $opened_display, $obr, 0);
+ }
+
+ private function doExportTopics($node, &$dom, &$topics, $prevQuery, $lng, $srt, $sth, $sand, $opened_display, $obr, $depth = 0)
+ {
+ $ntopics = 0;
+ if ($node->nodeType == XML_ELEMENT_NODE) {
+ $t_node = array();
+ $t_sort = array();
+ $i = 0;
+ for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
+ if ($n->nodeName == "te") {
+ $ntopics ++;
+ $label0 = $label = "";
+ $query0 = $query = "";
+ for ($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling) {
+ if ($n2->nodeName == "sy") {
+ if (! $query0) {
+ $query0 = $n2->getAttribute("w");
+ if ($n2->getAttribute("k")) {
+ $query0 .= ( ' (' . $n2->getAttribute("k") . ')');
+ }
+ $label0 = $n2->getAttribute("v");
+ }
+ if ($n2->getAttribute("lng") == $lng) {
+ $query = $n2->getAttribute("w");
+ if ($n2->getAttribute("k"))
+ $query .= ( ' (' . $n2->getAttribute("k") . ')');
+ $label = $n2->getAttribute("v");
+ break;
+ }
+ }
+ }
+ if ( ! $query) {
+ $query = $query0;
+ }
+ if ( ! $label) {
+ $label = $label0;
+ }
+
+ $t_sort[$i] = $query; // tri sur w
+ $t_node[$i] = array('label' => $label, 'node' => $n);
+
+ $i ++;
+ }
+ }
+
+ if ($srt)
+ natcasesort($t_sort);
+
+ foreach ($t_sort as $i => $query) {
+ $topic = $topics->appendChild($dom->createElement('topic'));
+ // $topic->setAttribute('id', $n->getAttribute('id'));
+ if ($opened_display != '' && in_array($t_node[$i]['node']->getAttribute('id'), $obr)) {
+ $topic->setAttribute('view', $opened_display);
+ }
+ $topic->appendChild($dom->createElement('label'))->appendChild($dom->createTextNode($t_node[$i]['label']));
+
+ $query = '"' . $query . '"';
+ if ($sth) {
+ $query = '*:' . $query;
+ if ($sand) {
+ $query = '(' . $query . ')';
+ }
+ }
+
+ if ($sand && $prevQuery != '') {
+ $query = $prevQuery . ' ' . _('phraseanet::technique:: et') . ' ' . $query . '';
+ }
+
+ $topic->appendChild($dom->createElement('query'))->appendChild($dom->createTextNode('' . $query . ''));
+
+ $topics2 = $dom->createElement('topics');
+
+ if ($this->doExportTopics($t_node[$i]['node'], $dom, $topics2, $query, $lng, $srt, $sth, $sand, $opened_display, $obr, $depth + 1) > 0) {
+ $topic->appendChild($topics2);
+ }
+ }
+ }
+
+ return $ntopics;
+ }
+
+ public function exportTopicsDialog(Application $app, Request $request)
+ {
+ return $app['twig']->render('thesaurus/export-topics-dialog.html.twig', array(
+ 'bid' => $request->get('bid'),
+ 'piv' => $request->get('piv'),
+ 'typ' => $request->get('typ'),
+ 'dlg' => $request->get('dlg'),
+ 'id' => $request->get('id'),
+ 'obr' => $request->get('obr'),
+ ));
+ }
+
+ public function import(Application $app, Request $request)
+ {
+ set_time_limit(300);
+
+ $imported = false;
+ $err = '';
+
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $bid);
+ $connbas = \connection::getPDOConnection($app, $bid);
+
+ $dom = $databox->get_dom_thesaurus();
+
+ if ($dom) {
+ if ($request->get('id') == '') {
+ // on importe un theaurus entier
+ $node = $dom->documentElement;
+ while ($node->firstChild) {
+ $node->removeChild($node->firstChild);
+ }
+
+ $cbad = array();
+ $cok = array();
+ for ($i = 0; $i < 32; $i ++) {
+ $cbad[] = chr($i);
+ $cok[] = '_';
+ }
+
+ $file = $request->files->get('fil')->getPathname();
+
+ if (($fp = fopen($file, 'rb'))) {
+ $iline = 0;
+ $curdepth = -1;
+ $tid = array(-1 => -1, 0 => -1);
+ while ( ! $err && ! feof($fp) && ($line = fgets($fp)) !== FALSE) {
+ $iline ++;
+ if (trim($line) == '') {
+ continue;
+ }
+ for ($depth = 0; $line != '' && $line[0] == "\t"; $depth ++) {
+ $line = substr($line, 1);
+ }
+ if ($depth > $curdepth + 1) {
+ $err = sprintf(_("over-indent at line %s"), $iline);
+ continue;
+ }
+
+ $line = trim($line);
+
+ if ( ! $this->checkEncoding($line, 'UTF-8')) {
+ $err = sprintf(_("bad encoding at line %s"), $iline);
+ continue;
+ }
+
+ $line = str_replace($cbad, $cok, ($oldline = $line));
+ if ($line != $oldline) {
+ $err = sprintf(_("bad character at line %s"), $iline);
+ continue;
+ }
+
+ while ($curdepth >= $depth) {
+ $curdepth --;
+ $node = $node->parentNode;
+ }
+ $curdepth = $depth;
+
+ $nid = (int) ($node->getAttribute('nextid'));
+ $id = $node->getAttribute('id') . '.' . $nid;
+ $pid = $node->getAttribute('id');
+
+ $te_id = ($pid ? ($pid . '.') : 'T') . $nid;
+
+ $node->setAttribute('nextid', (string) ($nid + 1));
+
+ $te = $node->appendChild($dom->createElement('te'));
+ $te->setAttribute('id', $te_id);
+
+ $node = $te;
+
+ $tsy = explode(';', $line);
+ $nsy = 0;
+ foreach ($tsy as $syn) {
+ $lng = $request->get('piv');
+ $hit = '';
+ $kon = '';
+
+ if (($ob = strpos($syn, '[')) !== false) {
+ if (($cb = strpos($syn, ']', $ob)) !== false) {
+ $lng = trim(substr($syn, $ob + 1, $cb - $ob - 1));
+ $syn = substr($syn, 0, $ob) . substr($syn, $cb + 1);
+ } else {
+ $lng = trim(substr($syn, $ob + 1));
+ $syn = substr($syn, 0, $ob);
+ }
+
+ if (($ob = strpos($syn, '[')) !== false) {
+ if (($cb = strpos($syn, ']', $ob)) !== false) {
+ $hit = trim(substr($syn, $ob + 1, $cb - $ob - 1));
+ $syn = substr($syn, 0, $ob) . substr($syn, $cb + 1);
+ } else {
+ $hit = trim(substr($syn, $ob + 1));
+ $syn = substr($syn, 0, $ob);
+ }
+ }
+ }
+ if (($ob = strpos($syn, '(')) !== false) {
+ if (($cb = strpos($syn, ')', $ob)) !== false) {
+ $kon = trim(substr($syn, $ob + 1, $cb - $ob - 1));
+ $syn = substr($syn, 0, $ob) . substr($syn, $cb + 1);
+ } else {
+ $kon = trim(substr($syn, $ob + 1));
+ $syn = substr($syn, 0, $ob);
+ }
+ }
+
+ $syn = trim($syn);
+
+ $sy = $node->appendChild($dom->createElement('sy'));
+ $sy->setAttribute('id', $te_id . '.' . $nsy);
+ $v = $syn;
+ if ($kon) {
+ $v .= ' (' . $kon . ')';
+ }
+ $sy->setAttribute('v', $v);
+ $sy->setAttribute('w', $app['unicode']->remove_indexer_chars($syn));
+ if ($kon) {
+ $sy->setAttribute('k', $app['unicode']->remove_indexer_chars($kon));
+ }
+ $sy->setAttribute('lng', $lng);
+
+ $nsy ++;
+ }
+
+ $te->setAttribute('nextid', (string) $nsy);
+ }
+
+ fclose($fp);
+ }
+
+ } else {
+ // on importe dans une branche
+ $err = 'not implemented';
+ }
+
+ if (! $err) {
+ $imported = true;
+ $databox->saveThesaurus($dom);
+ }
+ }
+
+ if (! $err) {
+ $meta_struct = $databox->get_meta_structure();
+
+ foreach ($meta_struct->get_elements() as $meta_field) {
+ $meta_field->set_tbranch('')->save();
+ }
+
+ $dom = $databox->get_dom_cterms();
+ if ($dom) {
+ $node = $dom->documentElement;
+ while ($node->firstChild) {
+ $node->removeChild($node->firstChild);
+ }
+ $databox->saveCterms($dom);
+ }
+
+ $sql = 'UPDATE RECORD SET status=status & ~3';
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+ }
+ } catch (\Exception $e) {
+
+ }
+
+ return $app['twig']->render('thesaurus/import.html.twig', array('err' => $err));
+ }
+
+ private function checkEncoding($string, $string_encoding)
+ {
+ $fs = $string_encoding == 'UTF-8' ? 'UTF-32' : $string_encoding;
+ $ts = $string_encoding == 'UTF-32' ? 'UTF-8' : $string_encoding;
+
+ return $string === mb_convert_encoding(mb_convert_encoding($string, $fs, $ts), $ts, $fs);
+ }
+
+ public function importDialog(Application $app, Request $request)
+ {
+ return $app['twig']->render('thesaurus/import-dialog.html.twig', array(
+ 'dlg' => $request->get('dlg'),
+ 'bid' => $request->get('bid'),
+ 'id' => $request->get('id'),
+ 'piv' => $request->get('piv'),
+ ));
+ }
+
+ public function indexThesaurus(Application $app, Request $request)
+ {
+ $sql = "SELECT
+ sbas.sbas_id,
+ sbasusr.bas_manage AS bas_manage,
+ sbasusr.bas_modify_struct AS bas_modify_struct,
+ sbasusr.bas_modif_th AS bas_edit_thesaurus
+ FROM
+ (usr INNER JOIN sbasusr
+ ON usr.usr_id = :usr_id
+ AND usr.usr_id = sbasusr.usr_id
+ AND model_of = 0)
+ INNER JOIN
+ sbas ON sbas.sbas_id = sbasusr.sbas_id
+ HAVING bas_edit_thesaurus > 0
+ ORDER BY sbas.ord";
+
+ $bases = $languages = array();
+
+ $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
+ $stmt->execute(array(':usr_id' => $app['phraseanet.user']->get_id()));
+ $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ foreach ($rs as $row) {
+ try {
+ $connbas = \connection::getPDOConnection($app, $row['sbas_id']);
+ } catch (\Exception $e) {
+ continue;
+ }
+ $bases[$row['sbas_id']] = \phrasea::sbas_names($row['sbas_id'], $app);
+ }
+
+ foreach (PhraseaApplication::getAvailableLanguages() as $lng_code => $lng) {
+ $lng_code = explode('_', $lng_code);
+ $languages[$lng_code[0]] = $lng;
+ }
+
+ return $app['twig']->render('thesaurus/index.html.twig', array(
+ 'languages' => $languages,
+ 'bases' => $bases,
+ ));
+ }
+
+ public function linkFieldStep1(Application $app, Request $request)
+ {
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $bid);
+ $domstruct = $databox->get_dom_structure();
+ $domth = $databox->get_dom_thesaurus();
+
+ if ($domstruct && $domth) {
+ $xpathth = new \DOMXPath($domth);
+ $xpathstruct = new \DOMXPath($domstruct);
+
+ if ($request->get('tid') !== "") {
+ $q = "//te[@id='" . $request->get('tid') . "']";
+ } else {
+ $q = "//te[not(@id)]";
+ }
+
+ $nodes = $xpathth->query($q);
+ $fullBranch = "";
+ if ($nodes->length == 1) {
+ for ($n = $nodes->item(0); $n && $n->nodeType == XML_ELEMENT_NODE && $n->getAttribute("id") !== ""; $n = $n->parentNode) {
+ $sy = $xpathth->query("sy", $n)->item(0);
+ $sy = $sy ? $sy->getAttribute("v") : "";
+ if (! $sy) {
+ $sy = $sy = "...";
+ }
+ $fullBranch = " / " . $sy . $fullBranch;
+ }
+ }
+ $fieldnames = array();
+ $nodes = $xpathstruct->query("/record/description/*");
+ for ($i = 0; $i < $nodes->length; $i ++) {
+ $fieldname = $nodes->item($i)->nodeName;
+ $tbranch = $nodes->item($i)->getAttribute("tbranch");
+ $ck = false;
+ if ($tbranch) {
+ // ce champ a deje un tbranch, est-ce qu'il pointe sur la branche selectionnee ?
+ $thnodes = $xpathth->query($tbranch);
+ for ($j = 0; $j < $thnodes->length; $j ++) {
+ if ($thnodes->item($j)->getAttribute("id") == $request->get('tid')) {
+ $ck = true;
+ }
+ }
+ }
+ $fieldnames[$fieldname] = $ck;
+ }
+ }
+ } catch (\Exception $e) {
+
+ }
+
+ return $app['twig']->render('thesaurus/link-field-step1.html.twig', array(
+ 'piv' => $request->get('piv'),
+ 'bid' => $request->get('bid'),
+ 'tid' => $request->get('tid'),
+ 'fullBranch' => $fullBranch,
+ 'fieldnames' => $fieldnames
+ ));
+ }
+
+ public function linkFieldStep2(Application $app, Request $request)
+ {
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ $oldlinks = array();
+ $needreindex = false;
+
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $bid);
+ $domstruct = $databox->get_dom_structure();
+ $domth = $databox->get_dom_thesaurus();
+
+ if ($domstruct && $domth) {
+ $xpathth = new \DOMXPath($domth);
+ $xpathstruct = new \DOMXPath($domstruct);
+ $nodes = $xpathstruct->query("/record/description/*");
+
+ for ($i = 0; $i < $nodes->length; $i ++) {
+ $fieldname = $nodes->item($i)->nodeName;
+ $oldbranch = $nodes->item($i)->getAttribute("tbranch");
+ $ck = false;
+ $tids = array(); // les ids de branches liees e ce champ
+ if ($oldbranch) {
+ // ce champ a deje un tbranch, on balaye les branches auxquelles il est lie
+ $thnodes = $xpathth->query($oldbranch);
+ for ($j = 0; $j < $thnodes->length; $j ++) {
+ if ($thnodes->item($j)->getAttribute("id") == $request->get('tid')) {
+ // il etait deje lie e la branche selectionnee
+ $tids[$thnodes->item($j)->getAttribute("id")] = $thnodes->item($j);
+ $ck = true;
+ } else {
+ // il etait lie e une autre branche
+ $tids[$thnodes->item($j)->getAttribute("id")] = $thnodes->item($j);
+ }
+ }
+ }
+
+ if (in_array($fieldname, $request->get('field', array())) != $ck) {
+ if ($ck) {
+ // print("il etait lie a la branche, il ne l'est plus
\n");
+ unset($tids[$request->get('tid')]);
+ } else {
+ // print("il n'etait pas lie a la branche, il l'est maintenant
\n");
+ $tids[$request->get('tid')] = $xpathth->query("/thesaurus//te[@id='" . \thesaurus::xquery_escape($request->get('tid')) . "']")->item(0);
+ }
+ $newtbranch = "";
+ foreach ($tids as $kitd => $node) {
+ if ($kitd === "") {
+ $newtbranch .= ( $newtbranch ? " | " : "") . "/thesaurus";
+ } else {
+ $neb = "";
+ while ($node && $node->nodeName == "te") {
+ $neb = "/te[@id='" . $node->getAttribute("id") . "']" . $neb;
+ $node = $node->parentNode;
+ }
+ $newtbranch .= ( $newtbranch ? " | " : "") . "/thesaurus" . $neb;
+ }
+ }
+
+ $oldlinks[$fieldname] = array(
+ 'old_branch' => $oldbranch,
+ 'new_branch' => $newtbranch
+ );
+
+ if ($newtbranch != "") {
+ $needreindex = true;
+ }
+ }
+ }
+ }
+ } catch (\Exception $e) {
+
+ }
+
+ return $app['twig']->render('thesaurus/link-field-step2.html.twig', array(
+ 'piv' => $request->get('piv'),
+ 'bid' => $request->get('bid'),
+ 'tid' => $request->get('tid'),
+ 'oldlinks' => $oldlinks,
+ 'need_reindex' => $needreindex,
+ ));
+ }
+
+ public function linkFieldStep3(Application $app, Request $request)
+ {
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $bid);
+ $connbas = \connection::getPDOConnection($app, $bid);
+ $meta_struct = $databox->get_meta_structure();
+ $domct = $databox->get_dom_cterms();
+ $domst = $databox->get_dom_structure();
+
+ if ($domct && $domst) {
+ $xpathct = new \DOMXPath($domct);
+ $xpathst = new \DOMXPath($domst);
+ $ctchanged = false;
+
+ $candidates2del = array();
+ foreach ($request->get("f2unlk", array()) as $f2unlk) {
+ $q = "/cterms/te[@field='" . \thesaurus::xquery_escape($f2unlk) . "']";
+ $nodes = $xpathct->query($q);
+ for ($i = 0; $i < $nodes->length; $i ++) {
+ $candidates2del[] = array(
+ "field" => $f2unlk,
+ "node" => $nodes->item($i)
+ );
+ }
+
+ $field = $meta_struct->get_element_by_name($f2unlk);
+ if ($field) {
+ $field->set_tbranch('')->save();
+ }
+ }
+ foreach ($candidates2del as $candidate2del) {
+ $candidate2del["node"]->parentNode->removeChild($candidate2del["node"]);
+ $ctchanged = true;
+ }
+
+ foreach ($request->get("fbranch", array()) as $fbranch) {
+ $p = strpos($fbranch, "<");
+ if ($p > 1) {
+ $fieldname = substr($fbranch, 0, $p);
+ $tbranch = substr($fbranch, $p + 1);
+ $field = $meta_struct->get_element_by_name($fieldname);
+ if ($field) {
+ $field->set_tbranch($tbranch)->save();
+ }
+ }
+ }
+
+ if ($ctchanged) {
+ $databox->saveCterms($domct);
+ }
+ }
+
+ $sql = "DELETE FROM thit WHERE name = :name";
+ $stmt = $connbas->prepare($sql);
+ foreach ($request->get("f2unlk", array()) as $f2unlk) {
+ $stmt->execute(array(':name' => $f2unlk));
+ }
+ $stmt->closeCursor();
+
+ if ($request->get("reindex")) {
+ $sql = "UPDATE record SET status=status & ~2";
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+ }
+ } catch (\Exception $e) {
+
+ }
+
+ return $app['twig']->render('thesaurus/link-field-step3.html.twig', array(
+ 'field2del' => $request->get('f2unlk', array()),
+ 'candidates2del' => $candidates2del,
+ 'branch2del' => $request->get('fbranch', array()),
+ 'ctchanged' => $ctchanged,
+ 'reindexed' => $request->get('reindex'),
+ ));
+ }
+
+ private function fixThesaurus($app, &$domct, &$domth, &$connbas)
+ {
+ $oldversion = $version = $domth->documentElement->getAttribute("version");
+
+ if ('' === trim($version)) {
+ $version = '1.0.0';
+ }
+
+ while (class_exists($cls = "patchthesaurus_" . str_replace(".", "", $version))) {
+
+ $last_version = $version;
+ $zcls = new $cls;
+ $version = $zcls->patch($version, $domct, $domth, $connbas);
+
+ if ($version == $last_version) {
+ break;
+ }
+ }
+
+ return $version;
+ }
+
+ public function loadThesaurus(Application $app, Request $request)
+ {
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ $updated = false;
+ $validThesaurus = true;
+ $ctlist = array();
+ $name = \phrasea::sbas_names($request->get('bid'), $app);
+
+ try {
+ $databox = $app['phraseanet.appbox']->get_databox((int) $request->get('bid'));
+ $connbas = \connection::getPDOConnection($app, $request->get('bid'));
+
+ $domct = $databox->get_dom_cterms();
+ $domth = $databox->get_dom_thesaurus();
+ $now = date("YmdHis");
+
+ if ( ! $domct && $request->get('repair') == 'on') {
+ $domct = new \DOMDocument();
+ $domct->load(__DIR__ . "/../../../../conf.d/blank_cterms.xml");
+ $domct->documentElement->setAttribute("creation_date", $now);
+ $databox->saveCterms($domct);
+ }
+ if ( ! $domth && $request->get('repair') == 'on') {
+ $domth = new \DOMDocument();
+ $domth->load(__DIR__ . "/../../../../conf.d/blank_thesaurus.xml");
+ $domth->documentElement->setAttribute("creation_date", $now);
+ $databox->saveThesaurus($domth);
+ }
+
+ if ($domct && $domth) {
+
+ $oldversion = $domth->documentElement->getAttribute("version");
+ if (($version = $this->fixThesaurus($app, $domct, $domth, $connbas)) != $oldversion) {
+ $updated = true;
+ $databox->saveCterms($domct);
+ $databox->saveThesaurus($domth);
+ }
+
+ for ($ct = $domct->documentElement->firstChild; $ct; $ct = $ct->nextSibling) {
+ if ($ct->nodeName == "te") {
+ $ctlist[] = array(
+ 'id' => $ct->getAttribute("id"),
+ 'field' => $ct->getAttribute("field")
+ );
+ }
+ }
+ } else {
+ $validThesaurus = false;
+ }
+ } catch (\Exception $e) {
+
+ }
+
+ return $app['twig']->render('thesaurus/load-thesaurus.html.twig', array(
+ 'bid' => $request->get('bid'),
+ 'name' => $name,
+ 'cterms' => $ctlist,
+ 'valid_thesaurus' => $validThesaurus,
+ 'updated' => $updated
+ ));
+ }
+
+ public function newSynonymDialog(Application $app, Request $request)
+ {
+ $languages = array();
+
+ foreach (PhraseaApplication::getAvailableLanguages() as $lng_code => $lng) {
+ $lng_code = explode('_', $lng_code);
+ $languages[$lng_code[0]] = $lng;
+ }
+
+ return $app['twig']->render('thesaurus/new-synonym-dialog.html.twig', array(
+ 'piv' => $request->get('piv'),
+ 'typ' => $request->get('typ'),
+ 'languages' => $languages,
+ ));
+ }
+
+
+ public function newTerm(Application $app, Request $request)
+ {
+ list($term, $context) = $this->splitTermAndContext($request->get("t"));
+
+ $dom = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $request->get('term'), $request->get('context'), $request->get('piv'));
+
+ $xpath = new \DOMXPath($dom);
+
+ $candidates = $xpath->query("/result/candidates_list/ct");
+
+ $nb_candidates_ok = $nb_candidates_bad = 0;
+ $flist_ok = $flist_bad = "";
+ for ($i = 0; $i < $candidates->length; $i ++) {
+ if ($candidates->item($i)->getAttribute("sourceok") == "1") { // && $candidates->item($i)->getAttribute("cid"))
+ $flist_ok .= ( $flist_ok ? ", " : "") . $candidates->item($i)->getAttribute("field");
+ $nb_candidates_ok ++;
+ } else {
+ $flist_bad .= ( $flist_bad ? ", " : "") . $candidates->item($i)->getAttribute("field");
+ $nb_candidates_bad ++;
+ }
+ }
+ $candidates_list = array();
+ for ($i = 0; $i < $candidates->length; $i ++) {
+ if ($candidates->item($i)->getAttribute("sourceok") == "1") {
+ $candidates_list = array(
+ 'id' => $candidates->item($i)->getAttribute("id"),
+ 'field' => $candidates->item($i)->getAttribute("field"),
+ );
+ }
+ }
+
+ return $app['twig']->render('thesaurus/new-term.html.twig', array(
+ 'typ' => $request->get('typ'),
+ 'bid' => $request->get('bid'),
+ 'piv' => $request->get('piv'),
+ 'pid' => $request->get('pid'),
+ 'sylng' => $request->get('sylng'),
+ 'dlg' => $request->get('dlg'),
+ 'candidates' => $candidates_list,
+ 'term' => $term,
+ 'context' => $context,
+ 'nb_candidates_ok' => $nb_candidates_ok,
+ 'nb_candidates_bad' => $nb_candidates_bad,
+ ));
+ }
+
+ public function properties(Application $app, Request $request)
+ {
+ $dom = $this->getXMLTerm($app, $request->get('bid'), $request->get('id'), $request->get('typ'), $request->get('piv'), '0', null, '1', null);
+ $fullpath = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue;
+ $hits = $dom->getElementsByTagName("allhits")->item(0)->firstChild->nodeValue;
+
+ $languages = $synonyms = array();
+
+ $sy_list = $dom->getElementsByTagName("sy_list")->item(0);
+ for ($n = $sy_list->firstChild; $n; $n = $n->nextSibling) {
+ $synonyms[] = array(
+ 'id' => $n->getAttribute("id"),
+ 'lng' => $n->getAttribute("lng"),
+ 't' => $n->getAttribute("t"),
+ 'hits' => $n->getAttribute("hits"),
+ );
+ }
+
+ foreach (PhraseaApplication::getAvailableLanguages() as $code => $language) {
+ $lng_code = explode('_', $code);
+ $languages[$lng_code[0]] = $language;
+ }
+
+ return $app['twig']->render('thesaurus/properties.html.twig', array(
+ 'typ' => $request->get('typ'),
+ 'bid' => $request->get('bid'),
+ 'piv' => $request->get('piv'),
+ 'id' => $request->get('id'),
+ 'dlg' => $request->get('dlg'),
+ 'languages' => $languages,
+ 'fullpath' => $fullpath,
+ 'hits' => $hits,
+ 'synonyms' => $synonyms,
+ ));
+ }
+
+ public function search(Application $app, Request $request)
+ {
+ return $app['twig']->render('thesaurus/search.html.twig');
+ }
+
+ public function thesaurus(Application $app, Request $request)
+ {
+ $flags = $jsFlags = array();
+
+ foreach (PhraseaApplication::getAvailableLanguages() as $code => $language) {
+ $lng_code = explode('_', $code);
+ $flags[$lng_code[0]] = $language;
+ $jsFlags[$lng_code[0]] = array('w' => 18, 'h' => 13);
+ }
+ $jsFlags = json_encode($jsFlags);
+
+ return $app['twig']->render('thesaurus/thesaurus.html.twig', array(
+ 'piv' => $request->get('piv'),
+ 'bid' => $request->get('bid'),
+ 'flags' => $flags,
+ 'jsFlags' => $jsFlags,
+ ));
+ }
+
+
public function acceptXml(Application $app, Request $request)
{
$ret = new \DOMDocument("1.0", "UTF-8");
@@ -1125,7 +2329,7 @@ class Thesaurus implements ControllerProviderInterface
// le champ "*" est la corbeille, il est toujours accepte
$cfield->setAttribute("acceptable", "1");
} else {
- if (($databox_field = $meta->get_element_by_name($acf)) instanceof databox_field) {
+ if (($databox_field = $meta->get_element_by_name($acf)) instanceof \databox_field) {
$tbranch = $databox_field->get_tbranch();
$q = "(" . $tbranch . ")/descendant-or-self::te[@id='" . $id . "']";
@@ -1259,7 +2463,6 @@ class Thesaurus implements ControllerProviderInterface
$newts->appendChild($ret->createTextNode($ts["allsy"]));
}
-
$fullpath_html = $fullpath = "";
for ($depth = 0, $n = $nodes->item(0); $n; $n = $n->parentNode, $depth -- ) {
if ($n->nodeName == "te") {
@@ -1595,6 +2798,7 @@ class Thesaurus implements ControllerProviderInterface
"reindex" => $request->get('reindex'),
"debug" => $request->get('debug'),
), true)));
+
$refresh_list = $root->appendChild($ret->createElement("refresh_list"));
if (null === $bid = $request->get("bid")) {
@@ -1891,7 +3095,7 @@ class Thesaurus implements ControllerProviderInterface
return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml'));
}
- private function doRejectBranch(connection_pdo $connbas, &$node)
+ private function doRejectBranch(\connection_pdo $connbas, &$node)
{
if (strlen($oldid = $node->getAttribute("id")) > 1) {
$node->setAttribute("id", $newid = ("R" . substr($oldid, 1)));
@@ -1911,6 +3115,17 @@ class Thesaurus implements ControllerProviderInterface
}
public function searchCandidateXml(Application $app, Request $request)
+ {
+ if (null === $bid = $request->get("bid")) {
+ return new Response('Missing bid parameter', 400);
+ }
+
+ $ret = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $request->get('t'), $request->get('k'), $request->get('piv'), $request->get('debug'));
+
+ return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml'));
+ }
+
+ private function doSearchCandidate(Application $app, $bid, $pid, $t, $k, $piv, $debug = false)
{
$ret = new \DOMDocument("1.0", "UTF-8");
$ret->standalone = true;
@@ -1918,20 +3133,16 @@ class Thesaurus implements ControllerProviderInterface
$root = $ret->appendChild($ret->createElement("result"));
$root->appendChild($ret->createCDATASection(var_export(array(
- "bid" => $request->get('bid'),
- "pid" => $request->get('pid'),
- "t" => $request->get('t'),
- "k" => $request->get('k'),
- "piv" => $request->get('piv'),
- "debug" => $request->get('debug'),
+ "bid" => $bid,
+ "pid" => $pid,
+ "t" => $t,
+ "k" => $k,
+ "piv" => $piv,
+ "debug" => $debug,
), true)));
$ctlist = $root->appendChild($ret->createElement("candidates_list"));
- if (null === $bid = $request->get("bid")) {
- return new Response('Missing bid parameter', 400);
- }
-
try {
$databox = $app['phraseanet.appbox']->get_databox((int) $bid);
@@ -1950,8 +3161,8 @@ class Thesaurus implements ControllerProviderInterface
for ($i = 0; $i < $nodes->length; $i ++) {
$fieldname = $nodes->item($i)->nodeName;
$tbranch = $nodes->item($i)->getAttribute("tbranch");
- if ($request->get('pid') != "") {
- $q = "(" . $tbranch . ")/descendant-or-self::te[@id='" . $request->get('pid') . "']";
+ if ($pid != "") {
+ $q = "(" . $tbranch . ")/descendant-or-self::te[@id='" . $pid . "']";
} else {
$q = "(" . $tbranch . ")/descendant-or-self::te[not(@id)]";
}
@@ -1968,7 +3179,7 @@ class Thesaurus implements ControllerProviderInterface
}
$l = $xpathth->query($q)->length;
- if ($request->get('debug')) {
+ if ($debug) {
printf("field '%s' : %s --: %d nodes
\n", $fieldname, $q, $l);
}
@@ -1990,42 +3201,36 @@ class Thesaurus implements ControllerProviderInterface
);
if (count($fields) > 0) {
- // on cherche le terme dans les candidats
- $domct = new \DOMDocument;
- if ($domct->loadXML($rowbas["cterms"])) {
- $xpathct = new \DOMXPath($domct);
-
- $q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($request->get('k'))) . "'";
- if ($request->get('k')) {
- if ($request->get('k') != "*") {
- $q .= " and @k='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($request->get('k'))) . "'";
- }
- } else {
- $q .= " and not(@k)";
+ $q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";
+ if ($k) {
+ if ($k != "*") {
+ $q .= " and @k='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";
}
- $q = "/cterms//te[./sy[$q]]";
+ } else {
+ $q .= " and not(@k)";
+ }
+ $q = "/cterms//te[./sy[$q]]";
- if ($request->get('debug')) {
- printf("xquery : %s
\n", $q);
+ if ($debug) {
+ printf("xquery : %s
\n", $q);
+ }
+
+ // $root->appendChild($ret->createCDATASection( $q ));
+ $nodes = $xpathct->query($q);
+ // le terme peut etre present dans plusieurs candidats
+ for ($i = 0; $i < $nodes->length; $i ++) {
+ // on a trouve le terme dans les candidats, mais en provenance de quel champ ?.. on remonte au champ candidat
+ for ($n = $nodes->item($i)->parentNode; $n && $n->parentNode && $n->parentNode->nodeName != "cterms"; $n = $n->parentNode) {
+ ;
}
-
- // $root->appendChild($ret->createCDATASection( $q ));
- $nodes = $xpathct->query($q);
- // le terme peut etre present dans plusieurs candidats
- for ($i = 0; $i < $nodes->length; $i ++) {
- // on a trouve le terme dans les candidats, mais en provenance de quel champ ?.. on remonte au champ candidat
- for ($n = $nodes->item($i)->parentNode; $n && $n->parentNode && $n->parentNode->nodeName != "cterms"; $n = $n->parentNode) {
- ;
- }
- if ($request->get('debug')) {
- printf("proposed in field %s
\n", $n->getAttribute("field"));
- }
- if ($n && array_key_exists($f = $n->getAttribute("field"), $fields)) {
- $fields[$f]["cid"] = $nodes->item($i)->getAttribute("id");
- }
+ if ($debug) {
+ printf("proposed in field %s
\n", $n->getAttribute("field"));
+ }
+ if ($n && array_key_exists($f = $n->getAttribute("field"), $fields)) {
+ $fields[$f]["cid"] = $nodes->item($i)->getAttribute("id");
}
}
- if ($request->get('debug')) {
+ if ($debug) {
printf("fields:%s
\n", var_export($fields, true));
}
}
@@ -2046,7 +3251,7 @@ class Thesaurus implements ControllerProviderInterface
}
- return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml'));
+ return $ret;
}
public function searchNoHitsXml(Application $app, Request $request)
diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
index 9eb7c634e8..a388ef3cba 100644
--- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
+++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
@@ -24,6 +24,11 @@ class Xmlhttp implements ControllerProviderInterface
{
$controllers = $app['controllers_factory'];
+ $controllers->before(function() use ($app) {
+ $app['firewall']->requireAuthentication();
+ $app['firewall']->requireAccessToModule('thesaurus');
+ });
+
$controllers->match('acceptcandidates.j.php', $this->call('AcceptCandidatesJson'));
$controllers->match('checkcandidatetarget.j.php', $this->call('CheckCandidateTargetJson'));
$controllers->match('editing_presets.j.php', $this->call('EditingPresetsJson'));
diff --git a/lib/classes/gatekeeper.php b/lib/classes/gatekeeper.php
index 5b0c778ff8..43da2f5061 100644
--- a/lib/classes/gatekeeper.php
+++ b/lib/classes/gatekeeper.php
@@ -68,73 +68,6 @@ class gatekeeper
return $this;
}
- /**
- * Check the current sub_directory on the domain name
- * Redirect if access is denied
- *
- * @return Void
- */
- public function check_directory(Request $request)
- {
- if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) {
- $this->_PHP_SELF = $_SERVER['PHP_SELF'];
-
- $php_script = explode('/', $_SERVER['PHP_SELF']);
-
- if (trim($php_script[0]) == 0)
- array_shift($php_script);
-
- if (count($php_script) > 1)
- $this->_directory = $php_script[0];
- else
- $this->_directory = '';
- $this->_script_name = array_pop($php_script);
- }
-
- if (!$this->app->isAuthenticated()) {
- switch ($this->_directory) {
- case 'client':
- $this->give_guest_access();
- if ($request->isXmlHttpRequest()) {
- phrasea::headers(404);
- } else {
- phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
- }
- break;
- case 'thesaurus2':
- if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
- || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
- || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') {
- return;
- }
- phrasea::redirect('/login/?redirect=/thesaurus2');
- break;
- case 'report':
- phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
- break;
- }
- } elseif ($_SERVER['PHP_SELF'] === '/login/logout/') {
- return;
- }
-
- switch ($this->_directory) {
- case 'thesaurus2':
- if (!$this->app['phraseanet.user']->ACL()->has_access_to_module('thesaurus')) {
- phrasea::headers(403);
- }
- break;
- case 'report':
- if (!$this->app['phraseanet.user']->ACL()->has_right('report')) {
- phrasea::headers(403);
- }
- break;
- default:
- break;
- }
-
- return;
- }
-
/**
* Redirect to the correct guest location
*
diff --git a/www/thesaurus2/patch/th_.php b/lib/classes/patchthesaurus/100.php
similarity index 91%
rename from www/thesaurus2/patch/th_.php
rename to lib/classes/patchthesaurus/100.php
index bad0c59909..ef09e266d8 100644
--- a/www/thesaurus2/patch/th_.php
+++ b/lib/classes/patchthesaurus/100.php
@@ -14,10 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_th_
+class patchthesaurus_100
{
- function patch($version, &$domct, &$domth, connection_pdo &$connbas)
+ public function patch($version, &$domct, &$domth, connection_pdo &$connbas)
{
if ($version == "") {
$th = $domth->documentElement;
@@ -32,7 +32,7 @@ class patch_th_
$th->setAttribute("nextid", $te0->getAttribute("nextid"));
$te = $xp->query("te", $te0);
$te1 = array();
- for ($i = 0; $i < $te->length; $i ++ ) {
+ for ($i = 0; $i < $te->length; $i ++) {
$te1[] = $te->item($i);
}
foreach ($te1 as $tei) {
@@ -52,7 +52,7 @@ class patch_th_
return($version);
}
- function fixThesaurus2(&$domth, &$tenode, $depth = 0)
+ public function fixThesaurus2(&$domth, &$tenode, $depth = 0)
{
$unicode = new unicode();
$sy = $tenode->appendChild($domth->createElement("sy"));
@@ -80,5 +80,3 @@ class patch_th_
}
}
}
-
-?>
diff --git a/www/thesaurus2/patch/th_2.0.0.php b/lib/classes/patchthesaurus/200.php
similarity index 88%
rename from www/thesaurus2/patch/th_2.0.0.php
rename to lib/classes/patchthesaurus/200.php
index bd3117db91..e30746de34 100644
--- a/www/thesaurus2/patch/th_2.0.0.php
+++ b/lib/classes/patchthesaurus/200.php
@@ -14,10 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_th_2_0_0
+class patchthesaurus_200
{
- function patch($version, &$domct, &$domth, connection_pdo &$connbas)
+ public function patch($version, &$domct, &$domth, connection_pdo &$connbas)
{
if ($version == "2.0.0") {
$th = $domth->documentElement;
@@ -26,7 +26,7 @@ class patch_th_2_0_0
$xp = new DOMXPath($domth);
$te = $xp->query("/thesaurus//te");
- for ($i = 0; $i < $te->length; $i ++ ) {
+ for ($i = 0; $i < $te->length; $i ++) {
$id = $te->item($i)->getAttribute("id");
if ($id[0] >= "0" && $id[0] <= "9")
$te->item($i)->setAttribute("id", "T" . $id);
diff --git a/www/thesaurus2/patch/th_2.0.1.php b/lib/classes/patchthesaurus/201.php
similarity index 88%
rename from www/thesaurus2/patch/th_2.0.1.php
rename to lib/classes/patchthesaurus/201.php
index 1aa8f866cc..848d482e32 100644
--- a/www/thesaurus2/patch/th_2.0.1.php
+++ b/lib/classes/patchthesaurus/201.php
@@ -14,10 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_th_2_0_1
+class patchthesaurus_201
{
- function patch($version, &$domct, &$domth, connection_pdo &$connbas)
+ public function patch($version, &$domct, &$domth, connection_pdo &$connbas)
{
if ($version == "2.0.1") {
$th = $domth->documentElement;
@@ -25,7 +25,7 @@ class patch_th_2_0_1
$xp = new DOMXPath($domth);
$te = $xp->query("/thesaurus//te");
- for ($i = 0; $i < $te->length; $i ++ ) {
+ for ($i = 0; $i < $te->length; $i ++) {
// $id = "S" . substr($te->item($i)->getAttribute("id"), 1);
$id = $te->item($i)->getAttribute("id");
$nid = (int) ($te->item($i)->getAttribute("nextid"));
@@ -48,7 +48,7 @@ class patch_th_2_0_1
$stmt->closeCursor();
$domct = new DOMDocument();
- $domct->load("../thesaurus2/blank_cterms.xml");
+ $domct->load(__DIR__ . "/../../../lib/conf.d/blank_cterms.xml");
$ct = $domct->documentElement;
$ct->setAttribute("creation_date", $now = date("YmdHis"));
$ct->setAttribute("modification_date", $now);
diff --git a/www/thesaurus2/patch/th_2.0.2.php b/lib/classes/patchthesaurus/202.php
similarity index 92%
rename from www/thesaurus2/patch/th_2.0.2.php
rename to lib/classes/patchthesaurus/202.php
index a930a5a81c..d3e33b5de7 100644
--- a/www/thesaurus2/patch/th_2.0.2.php
+++ b/lib/classes/patchthesaurus/202.php
@@ -14,10 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_th_2_0_2
+class patchthesaurus_202
{
- function patch($version, &$domct, &$domth, connection_pdo &$connbas)
+ public function patch($version, &$domct, &$domth, connection_pdo &$connbas)
{
if ($version == "2.0.2") {
$th = $domth->documentElement;
diff --git a/www/thesaurus2/patch/th_2.0.3.php b/lib/classes/patchthesaurus/203.php
similarity index 94%
rename from www/thesaurus2/patch/th_2.0.3.php
rename to lib/classes/patchthesaurus/203.php
index 167582598a..adb7a8df97 100644
--- a/www/thesaurus2/patch/th_2.0.3.php
+++ b/lib/classes/patchthesaurus/203.php
@@ -14,10 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_th_2_0_3
+class patchthesaurus_203
{
- function patch($version, &$domct, &$domth, connection_pdo &$connbas)
+ public function patch($version, &$domct, &$domth, connection_pdo &$connbas)
{
global $debug;
global $ctchanged, $thchanged, $needreindex;
@@ -26,7 +26,7 @@ class patch_th_2_0_3
if ($version == "2.0.3") {
$xp = new DOMXPath($domth);
$sy = $xp->query("//sy");
- for ($i = 0; $i < $sy->length; $i ++ ) {
+ for ($i = 0; $i < $sy->length; $i ++) {
if (($k = $sy->item($i)->getAttribute("k"))) {
$v = $sy->item($i)->getAttribute("v");
if (strpos($v, "(") === false) {
@@ -78,7 +78,7 @@ class patch_th_2_0_3
}
$sy = $xp->query("//sy");
- for ($i = 0; $i < $sy->length; $i ++ ) {
+ for ($i = 0; $i < $sy->length; $i ++) {
if (($k = $sy->item($i)->getAttribute("k"))) {
if (strpos($v = $sy->item($i)->getAttribute("v"), "(") === false)
$sy->item($i)->setAttribute("v", $v . " (" . $k . ")");
@@ -104,7 +104,7 @@ class patch_th_2_0_3
return($version);
}
- function fixRejected(connection_pdo &$connbas, &$node, $rejected)
+ public function fixRejected(connection_pdo &$connbas, &$node, $rejected)
{
global $debug;
@@ -136,7 +136,7 @@ class patch_th_2_0_3
$this->fixRejected($connbas, $n, $rejected);
}
- function fixIds(connection_pdo &$connbas, &$node)
+ public function fixIds(connection_pdo &$connbas, &$node)
{
global $debug;
diff --git a/www/thesaurus2/patch/th_2.0.4.php b/lib/classes/patchthesaurus/204.php
similarity index 94%
rename from www/thesaurus2/patch/th_2.0.4.php
rename to lib/classes/patchthesaurus/204.php
index 8d0b24ad2f..7511113566 100644
--- a/www/thesaurus2/patch/th_2.0.4.php
+++ b/lib/classes/patchthesaurus/204.php
@@ -14,10 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_th_2_0_4
+class patchthesaurus_204
{
- function patch($version, &$domct, &$domth, connection_pdo &$connbas)
+ public function patch($version, &$domct, &$domth, connection_pdo &$connbas)
{
global $debug;
global $ctchanged, $thchanged, $needreindex;
@@ -27,7 +27,7 @@ class patch_th_2_0_4
if ($version == "2.0.4") {
$xp = new DOMXPath($domth);
$sy = $xp->query("//sy");
- for ($i = 0; $i < $sy->length; $i ++ ) {
+ for ($i = 0; $i < $sy->length; $i ++) {
if (($k = $sy->item($i)->getAttribute("k"))) {
$v = $sy->item($i)->getAttribute("v");
if (strpos($v, "(") === false) {
@@ -80,7 +80,7 @@ class patch_th_2_0_4
}
$sy = $xp->query("//sy");
- for ($i = 0; $i < $sy->length; $i ++ ) {
+ for ($i = 0; $i < $sy->length; $i ++) {
if (($k = $sy->item($i)->getAttribute("k"))) {
if (strpos($v = $sy->item($i)->getAttribute("v"), "(") === false) {
$sy->item($i)->setAttribute("v", $v . " (" . $k . ")");
@@ -107,7 +107,7 @@ class patch_th_2_0_4
return($version);
}
- function fixRejected(connection_pdo &$connbas, &$node, $rejected)
+ public function fixRejected(connection_pdo &$connbas, &$node, $rejected)
{
global $debug;
@@ -139,7 +139,7 @@ class patch_th_2_0_4
$this->fixRejected($connbas, $n, $rejected);
}
- function fixIds(connection_pdo &$connbas, &$node)
+ public function fixIds(connection_pdo &$connbas, &$node)
{
global $debug;
diff --git a/www/thesaurus2/blank_cterms.xml b/lib/conf.d/blank_cterms.xml
similarity index 100%
rename from www/thesaurus2/blank_cterms.xml
rename to lib/conf.d/blank_cterms.xml
diff --git a/www/thesaurus2/blank_thesaurus.xml b/lib/conf.d/blank_thesaurus.xml
similarity index 100%
rename from www/thesaurus2/blank_thesaurus.xml
rename to lib/conf.d/blank_thesaurus.xml
diff --git a/templates/web/common/menubar.html.twig b/templates/web/common/menubar.html.twig
index 993959f275..350ea2824e 100644
--- a/templates/web/common/menubar.html.twig
+++ b/templates/web/common/menubar.html.twig
@@ -35,7 +35,7 @@
{% if app['browser'].isNewGeneration and app['phraseanet.registry'].get('GV_thesaurus') == true and app['phraseanet.user'].ACL.has_access_to_module('thesaurus') %}
-
+
{% trans 'admin::monitor: module thesaurus' %}
diff --git a/templates/web/thesaurus/accept.html.twig b/templates/web/thesaurus/accept.html.twig
new file mode 100644
index 0000000000..8be5b1b5b6
--- /dev/null
+++ b/templates/web/thesaurus/accept.html.twig
@@ -0,0 +1,187 @@
+{% if dlg %}
+ {% set opener = "window.dialogArguments.win" %}
+{% else %}
+ {% set opener = "opener" %}
+{% endif %}
+
+
+
+ {% trans 'thesaurus:: accepter...' %}
+
+
+
+
+
+
+
+ {% if not cterm_found %}
+
+
+
+
+ {% trans 'thesaurus:: removed_src' %}
+
+
+ {% trans 'thesaurus:: refresh' %}
+
+
+
+
+
+
+ {% else %}
+ {% if not term_found %}
+
+
+
+
+ {% trans 'thesaurus:: removed tgt' %}
+
+
+ {% trans 'thesaurus:: refresh' %}
+
+
+
+
+
+
+ {% else %}
+ {% if acceptable %}
+
+
+
+
+ {% else %}
+
+
+
+
+ {% trans %}
+ thesaurus:: A cet emplacement du thesaurus , un candidat du champ {{ cfield }} ne peut etre accepte
+ {% endtrans %}
+
+
+
+
+
+
+
+
+ {% endif %}
+ {% endif %}
+ {% endif %}
+
+
diff --git a/templates/web/thesaurus/export-text-dialog.html.twig b/templates/web/thesaurus/export-text-dialog.html.twig
new file mode 100644
index 0000000000..ad898e4699
--- /dev/null
+++ b/templates/web/thesaurus/export-text-dialog.html.twig
@@ -0,0 +1,119 @@
+
+
+
+ {% trans 'thesaurus:: export au format texte' %}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/web/thesaurus/export-text.html.twig b/templates/web/thesaurus/export-text.html.twig
new file mode 100644
index 0000000000..6218906ef6
--- /dev/null
+++ b/templates/web/thesaurus/export-text.html.twig
@@ -0,0 +1,18 @@
+
+
+
+ {% trans 'thesaurus:: export au format texte' %}
+
+
+
+
+
+{{ output }}
+
+
+
diff --git a/www/thesaurus2/export_topics_dlg.php b/templates/web/thesaurus/export-topics-dialog.html.twig
similarity index 52%
rename from www/thesaurus2/export_topics_dlg.php
rename to templates/web/thesaurus/export-topics-dialog.html.twig
index 3422f278cb..a6691d7dcd 100644
--- a/www/thesaurus2/export_topics_dlg.php
+++ b/templates/web/thesaurus/export-topics-dialog.html.twig
@@ -1,46 +1,8 @@
-get_parms(
- "bid"
- , "piv"
- , "id"
- , "typ"
- , "dlg"
- , 'obr' // liste des branches ouvertes
-);
-
-if ($parm["dlg"]) {
- $opener = "window.dialogArguments.win";
-} else {
- $opener = "opener";
-}
-?>
-
+
+
-
-
-
+ {% trans 'thesaurus:: export en topics' %}
+
@@ -103,87 +59,85 @@ if ($parm["dlg"]) {
diff --git a/templates/web/thesaurus/export-topics.html.twig b/templates/web/thesaurus/export-topics.html.twig
new file mode 100644
index 0000000000..1680a530d6
--- /dev/null
+++ b/templates/web/thesaurus/export-topics.html.twig
@@ -0,0 +1,43 @@
+
+
+
+ {% trans 'thesaurus:: export en topics' %}
+
+
+
+
+
+
+
+
+ {% for lng, export in lngs %}
+
+ {{ export }}
+
+ {% endfor %}
+
+ {% if ofm == 'tofiles' %}
+
+
+
+
+
+
+ {% endif %}
+
+
+
diff --git a/templates/web/thesaurus/import-dialog.html.twig b/templates/web/thesaurus/import-dialog.html.twig
new file mode 100644
index 0000000000..40918867bf
--- /dev/null
+++ b/templates/web/thesaurus/import-dialog.html.twig
@@ -0,0 +1,76 @@
+{% if dlg is not none %}
+ {% set opener = "window.dialogArguments.win" %}
+{% else %}
+ {% set opener = "opener" %}
+{% endif %}
+
+
+
+
+ {% trans 'thesaurus:: Importer' %}
+
+
+
+
+
+
+
+
+
diff --git a/templates/web/thesaurus/import.html.twig b/templates/web/thesaurus/import.html.twig
new file mode 100644
index 0000000000..7bfcd64384
--- /dev/null
+++ b/templates/web/thesaurus/import.html.twig
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/templates/web/thesaurus/index.html.twig b/templates/web/thesaurus/index.html.twig
new file mode 100644
index 0000000000..fe854142a4
--- /dev/null
+++ b/templates/web/thesaurus/index.html.twig
@@ -0,0 +1,58 @@
+
+
+
+
+ {{ app['phraseanet.registry'].get('GV_homeTitle') }} - {% trans 'phraseanet:: thesaurus' %}
+
+
+
+
+
+
+
+
+ {% set count_bases = bases | length %}
+ {% if count_bases > 0 %}
+
+
+ {% else %}
+ {% trans 'thesaurus:: Vous n\'avez acces a aucune base' %}
+ {% endif %}
+
+
+
diff --git a/templates/web/thesaurus/link-field-step1.html.twig b/templates/web/thesaurus/link-field-step1.html.twig
new file mode 100644
index 0000000000..767fdbb666
--- /dev/null
+++ b/templates/web/thesaurus/link-field-step1.html.twig
@@ -0,0 +1,66 @@
+
+
+
+ {% trans 'thesaurus:: Lier la branche de thesaurus au champ' %}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/web/thesaurus/link-field-step2.html.twig b/templates/web/thesaurus/link-field-step2.html.twig
new file mode 100644
index 0000000000..3801611dd6
--- /dev/null
+++ b/templates/web/thesaurus/link-field-step2.html.twig
@@ -0,0 +1,79 @@
+
+
+
+ {% trans 'thesaurus:: Lier la branche de thesaurus' %}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/web/thesaurus/link-field-step3.html.twig b/templates/web/thesaurus/link-field-step3.html.twig
new file mode 100644
index 0000000000..4818cd9a5b
--- /dev/null
+++ b/templates/web/thesaurus/link-field-step3.html.twig
@@ -0,0 +1,56 @@
+
+
+
+ {% trans 'thesaurus:: Lier la branche de thesaurus' %}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/web/thesaurus/load-thesaurus.html.twig b/templates/web/thesaurus/load-thesaurus.html.twig
new file mode 100644
index 0000000000..0c307ce737
--- /dev/null
+++ b/templates/web/thesaurus/load-thesaurus.html.twig
@@ -0,0 +1,43 @@
+
+
\ No newline at end of file
diff --git a/templates/web/thesaurus/new-synonym-dialog.html.twig b/templates/web/thesaurus/new-synonym-dialog.html.twig
new file mode 100644
index 0000000000..aa05e9b566
--- /dev/null
+++ b/templates/web/thesaurus/new-synonym-dialog.html.twig
@@ -0,0 +1,86 @@
+{% if 'TS' == typ %}
+ {% set title = 'thesaurus:: Nouveau terme' | trans %}
+ {% set label = 'thesaurus:: terme' | trans %}
+{% elseif 'SY' == typ %}
+ {% set title = 'thesaurus:: Nouveau synonyme' | trans %}
+ {% set label = 'thesaurus:: synonyme' | trans %}
+{% else %}
+ {% set title = '' %}
+ {% set label = '' %}
+{% endif %}
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/web/thesaurus/new-term.html.twig b/templates/web/thesaurus/new-term.html.twig
new file mode 100644
index 0000000000..d69ae1220d
--- /dev/null
+++ b/templates/web/thesaurus/new-term.html.twig
@@ -0,0 +1,205 @@
+
+
+
+ {% if typ == "TS" %}{% trans 'thesaurus:: Nouveau terme specifique' %}{% else %}{% trans 'thesaurus:: Nouveau synonyme' %}{% endif %}
+
+
+
+
+ {% if dlg is not none %}
+ {% set opener = 'window.dialogArguments.win' %}
+ {% else %}
+ {% set opener = 'opener' %}
+ {% endif %}
+
+ {% if context is not none %}
+ {% set zterm %}
+ {% trans %}
+ thesaurus:: le terme {{ term }} avec contexte {{ context }}
+ {% endtrans %}
+ {% endset %}
+ {% else %}
+ {% set zterm %}
+ {% trans %}
+ thesaurus:: le terme {{ term }} sans contexte
+ {% endtrans %}
+ {% endset %}
+ {% endif %}
+
+ {% if nb_candidates_ok > 0 %}
+ {% if nb_candidates_ok == 1 %}
+ {% set prop_label = 'thesaurus:: est deja candidat en provenance du champ acceptable : ' | trans %}
+ {% else %}
+ {% set prop_label = 'thesaurus:: est deja candidat en provenance des champs acceptables : ' | trans %}
+ {% endif %}
+
+
+ {{ zterm }}
+
+
+ {{ prop_label }}
+
+
+
+
+ {% else %}
+ {% if nb_candidates_bad > 0 %}
+ // present dans les candidats, mais aucun champ acceptable : on informe
+ {% if nb_candidates_bad == 1 %}
+ {% set prop_label = 'thesaurus:: est candidat en provenance des champs mais ne peut etre accepte a cet emplacement du thesaurus' | trans %}
+ {% else %}
+ {% set prop_label = 'thesaurus:: est candidat en provenance des champs mais ne peut etre accepte a cet emplacement du thesaurus' | trans %}
+ {% endif %}
+ {% else %}
+ // pas present dans les candidats
+ {% set prop_label = 'thesaurus:: n\'est pas present dans les candidats' | trans %}
+ {% endif %}
+
+ {% trans 'thesaurus:: attention :' %}
+
+
+ {{ zterm }}
+
+
+ {{ prop_label }}
+
+
+ {% endif %}
+
+
+
+
diff --git a/templates/web/thesaurus/properties.html.twig b/templates/web/thesaurus/properties.html.twig
new file mode 100644
index 0000000000..63350711b8
--- /dev/null
+++ b/templates/web/thesaurus/properties.html.twig
@@ -0,0 +1,427 @@
+{% if dlg is not none %}
+ {% set opener = "window.dialogArguments.win" %}
+{% else %}
+ {% set opener = "opener" %}
+{% endif %}
+
+
+
+ {% trans 'thesaurus:: Proprietes' %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id: {{ id }}
+
+ {{ fullpath | raw }}
+ {% if typ == "CT" %}
+
+ {% elseif typ == "TH" %}
+ {% trans %}
+ thesaurus:: {{ hits }} reponses retournees
+ {% endtrans %}
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+ {% trans 'thesaurus:: synonymes' %} |
+ {% trans 'thesaurus:: hits' %} |
+ {% trans 'thesaurus:: ids' %} |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/www/thesaurus2/search.php b/templates/web/thesaurus/search.html.twig
similarity index 50%
rename from www/thesaurus2/search.php
rename to templates/web/thesaurus/search.html.twig
index 9c09bf1880..2e06ef881a 100644
--- a/www/thesaurus2/search.php
+++ b/templates/web/thesaurus/search.html.twig
@@ -1,42 +1,8 @@
-get_parms(
- "dlg"
- , "piv"
-);
-
-if ($parm["dlg"]) {
- $opener = "window.dialogArguments.win";
-} else {
- $opener = "opener";
-}
-?>
-
+
+
- Chercher
-
-
+ {% trans 'Chercher' %}
+
-
+
@@ -68,14 +33,11 @@ User_Adapter::updateClientInfos($app, 5);
// recharger tout
function reload()
{
- self.location.replace("thesaurus.php?piv=&bid=") ;
+ self.location.replace("thesaurus.php?piv={{ piv }}&bid={{ bid }}") ;
}
function test(div)
{
- // alert(deb);
- // return;
- // alert("div");
t = document.getElementById(div).innerHTML;
t = t.replace(/&/g, "&");
t = t.replace(/";
+ document.getElementById("T0").innerHTML = document.getElementById("T1").innerHTML = "{% trans 'phraseanet::chargement' %}";
f.target = "IFR0";
f.submit();
- // loadForm("?");
}
function chgCkShowRejected()
@@ -134,22 +93,6 @@ User_Adapter::updateClientInfos($app, 5);
function scrollEnd(n)
{
document.getElementById("desktop").scrollTop = 0;
- /*
- if(n==0)
- window.setTimeout("scrollEnd(1);", 500);
- else
- {
- // alert('zerzerzer');
- // o_thbox_bck.style.width = (0)+"px";
- // o_thbox_bck.style.height = (0)+"px";
- // o_thbox_bck.style.visibility = "hidden";
- // o_thbox_bck.style.visibility = "visible";
-
- // window.setTimeout("resizeEnd();", 25);
- // window.setTimeout("o_thbox_bck.style.visibility = \"visible\";", 25);
- evtResize();
- }
- */
}
var xhr_object;
function sessionactive(){
@@ -159,7 +102,7 @@ User_Adapter::updateClientInfos($app, 5);
dataType: 'json',
data: {
module : 5,
- usr : get_id() ?>
+ usr : {{ app['phraseanet.user'].get_id() }}
},
error: function(){
window.setTimeout("sessionactive();", 10000);
@@ -187,72 +130,46 @@ User_Adapter::updateClientInfos($app, 5);
-
-
-