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 %} +
    +
    +
    + + + + + + {% if nts == 0 %} + {% trans 'thesaurus:: Accepter le terme comme' %} +

    {{ fullpath_src | raw }}



    +
    + {% trans 'thesaurus:: comme terme specifique' %} +

    + + {% set fullpath_tgt_raw = fullpath_tgt | raw %} + {% trans %} + thesaurus:: comme synonyme de {{ fullpath_tgt_raw }} + {% endtrans %} +
    + {% else %} +

    {{ fullpath_src | raw }}



    + {% trans 'thesaurus:: Accepter la branche comme' %} +  {% trans 'thesaurus:: comme terme specifique' %} +

    {{ fullpath_tgt | raw }}



    + + {% endif %} +
    +
    + +        + +
    +
    + {% 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' %} + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + +
    {% trans 'thesaurus:: options d\'export : ' %}{% trans 'thesaurus:: example' %}
    +
    + + {% trans 'thesaurus:: export au format texte' %} +
    +
    +
    + + {% trans 'thesaurus:: exporter avec les synonymes sur la meme ligne' %} +
    +
    + + {% trans 'thesaurus:: exporter avec une ligne par synonyme' %} +
    +
    + + {% trans 'thesaurus:: export : numeroter les lignes ' %} +
    +
    + + {% trans 'thesaurus:: export : inclure la langue' %} +
    +
    + + {% trans 'thesaurus:: export : inclure les hits' %} +
    +
    +
    + +
    +
    +
    + +     + +
    +
    + + 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"; -} -?> - + + - <?php echo p4string::MakeString(_('thesaurus:: export en topics')) ?> - - + {% trans 'thesaurus:: export en topics' %} + @@ -103,87 +59,85 @@ if ($parm["dlg"]) {
    - " > - " > - " > - " > - " > - " > + + + + + +
    - + {% trans 'thesaurus:: exporter' %}
    - + {% trans 'thesaurus:: exporter vers topics pour toutes les langues' %}
    -
    - + {% trans %} + thesaurus:: exporter a l'ecran pour la langue {{ piv }} + {% endtrans %}

    - + {% trans 'phraseanet:: tri' %}
    - + {% trans 'phraseanet:: tri par date' %}

    - + {% trans 'thesaurus:: recherche' %}
    - + {% trans 'thesaurus:: recherche thesaurus *:"query"' %}
    - + {% trans 'thesaurus:: recherche fulltext' %}
    - + {% trans 'thesaurus:: question complete (avec operateurs)' %}

    - + {% trans 'thesaurus:: presentation' %}
    - + {% trans 'thesaurus:: presentation : branches refermables' %}
    - + {% trans 'thesaurus:: presentation : branche ouvertes' %}
    - + {% trans 'thesaurus:: tout deployer - refermable' %}
    - + {% trans 'thesaurus:: tout deployer - statique' %}
    - + {% trans 'thesaurus:: tout fermer' %}
    - +     - +
    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' %} + + + + +
    +
    + + + + +
    +
    {% trans 'thesaurus:: langue par default' %} {{ piv }}
    +
    +
    + {% trans 'Fichier ASCII tabule' %} + (max 16Mo) +
    + +
    + + + + + + + +
    {% trans 'thesaurus:: supprimer les liens des champs tbranch' %}
    {% trans 'thesaurus:: reindexer la base apres l\'import' %}
    +
    + +     + +
    +
    + + + 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 %} + +
    + {% trans 'thesaurus:: Editer le thesaurus' %} + +
    +
    + + + + + {% for code, language in languages %} + + {% endfor %} + +
    {% trans 'thesaurus:: langue pivot' %} + + ( {{ language }} ) +
    +
    +
    +
    +
    + {% 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' %} + + + + + + +
    +
    + + + + + {% set branch = "
    " ~ fullBranch ~ "
    " %} + {% trans %} + thesaurus:: Lier la branche de thesaurus au champ {{ branch }} + {% endtrans %} + +
    + {% for fieldname, checked in fieldnames %} + {{ fieldname }}
    + {% endfor %} +
    +
    + +     + +
    +
    + + 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' %} + + + + + + +
    +
    + + + +
    +
    +
    +
    + {% for fieldname, branches in oldlinks %} + {% if branches['old_branch'] %} + {% set old_branch = branches['old_branch'] %} + {{ fieldname }} + {% trans %} + thesaurus:: Ce champ a ete modifie ; ancienne branche : {{ old_branch }} + {% endtrans %} +
    + {% endif %} + {% trans 'thesaurus:: nouvelle branche' %} : {{ branches['new_branch'] }} +
    + + {% if branches['old_branch'] is not none and '' == branches['new_branch'] %} + {{ fieldname }}{% trans 'thesaurus:: ce champ n\'est plus lie au thesaurus, les termes indexes et candidats seront supprimes' %} +
    + + {% endif %} + {% if '' != branches['new_branch'] %} + {% if '' == branches['old_branch'] %} + {{ fieldname }}{% trans 'thesaurus:: ce champ doit etre lie au thesaurus. La reindexation de la base est necessaire' %} + {% else %} + {{ fieldname }}{% trans 'thesaurus:: le lien au thesaurus doit etre modifie, la reindexation de la base est necessaire' %} + {% endif %} +
    + + {% endif %} + {% endfor %} +
    + + {% if need_reindex %} + +
    {% trans 'thesaurus:: reindexation necessaire' %}
    + {% else %} +
    {% trans 'thesaurus:: pas de reindexation' %}
    + {% endif %} +
    + +     + +
    +
    + + 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' %} + + + +
    +
    +
    +
    +
    +
    + {% for field in field2del %} + {% trans %} + thesaurus:: suppression du lien du champ {{ field }} + {% endtrans %} +
    + {% endfor %} + {% for candidate in candidates2del %} + {% set field = candidate2del["field"] %} + {% trans %} + thesaurus:: suppression de la branche de mot candidats pour le champ {{ field }} + {% endtrans %} +
    + {% endfor %} + {% for field in branch2del %} + {% trans %} + thesaurus:: suppression de la branche de mot candidats pour le champ {{ field }} + {% endtrans %} +
    + {% endfor %} + + {% if ctchanged %} + {% trans 'thesaurus:: enregistrement de la liste modifiee des mots candidats.' %} +
    + {% endif %} + + {% for field in field2del %} + {% trans %} + thesaurus:: suppression des indexes vers le thesaurus pour le champ {{ field }} + {% endtrans %} +
    + {% endfor %} + + {% if reindexed %} + {% trans 'thesaurus:: reindexer tous les enregistrements' %} +
    + {% endif %} +
    +
    + +
    +
    + + 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 }} + + + + + + + +
    +
    + + + + + + + + + + + + + + + + +
    {{ label }} : 
    {% trans 'thesaurus:: contexte' %} : (  )
    {% trans 'phraseanet:: language' %} :  + {% for code, language in languages %} + + + + +    + {% endfor %} +
    +
    +
    + +    + +
    +
    +
    +
    + + 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 }} +
    +
    +
    + + +
    + {% for candidate in candidates %} + {{ candidate['field'] }}
    + {% endfor %} +
    + {% if nb_candidates_ok > 1 %} + {{ 'thesaurus:: selectionner la provenance a accepter' | trans }} + {% endif %} +
    + +     + +
    +
    + {% 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' %}
    +
    +
    +
    + + + + + + + + + {% for data in synonyms %} + + + {% if data['lng'] %} + + {% else %} + + {% endif %} + + + + + {% endfor %} + +
    + {% if loop.index > 0 %} + + {% endif %} + {% if not loop.last %} + + {% endif %} + {{ data['t'] }}{{ data['hits'] }}{{ data['id'] }}
    +
    +
    +
    +
    +
    + +
    +
    + + + 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); - -
    - " /> - " /> + + +
    -
    + @@ -265,20 +182,18 @@ $jsFlags = '{ ' . $jsFlags . ' }';
    - - X + {% trans 'phraseanet:: thesaurus' %} + X
    -
    -   - X +
    {% trans 'thesaurus:: onglet stock' %} X
    - + {% trans 'thesaurus:: afficher les termes refuses' %}
    @@ -288,13 +203,10 @@ $jsFlags = '{ ' . $jsFlags . ' }';
    -
    -
    +
    {% trans 'thesaurus:: onglet thesaurus' %}   - X + X
    @@ -311,8 +223,8 @@ $jsFlags = '{ ' . $jsFlags . ' }';
     
    - - + + - - - - -\n"); - $dom = xmlhttp($url); - - if ((int) ($dom->documentElement->getAttribute('found')) == 0) { - ?> -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - - 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; - } - // { - // if( ($cfield_tbranch = $cfield->getAttribute("tbranch")) ) - // { - // } - // } -// print("cfield='$cfield'
    \n"); -// print($fullpath); - - $url = "thesaurus2/xmlhttp/getterm.x.php"; - $url .= "?bid=" . urlencode($parm["bid"]); - $url .= "&piv=" . urlencode($parm["piv"]); - $url .= "&sortsy=0"; - $url .= "&id=" . urlencode($parm["tgt"]); - $url .= "&typ=TH"; - if ($cfield) - $url .= "&acf=" . urlencode($cfield); - $url .= "¬s=1"; - - // print("URL='$url'
    \n"); - // print($url. "
    \n"); - $dom = xmlhttp($url); - - if ((int) ($dom->documentElement->getAttribute('found')) == 0) { - // on n'a pas trouve le node de destination (il a ete deplace par qqun d'autre) - ?> -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - - saveXML()); - - $fullpath_tgt = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue; - - $acceptable = 0 + $dom->getElementsByTagName("cfield")->item(0)->getAttribute("acceptable"); - - // print("acceptable=$acceptable
    \n"); - if ($acceptable) { - ?> -
    -
    - - - "> - "> - "> - "> - "> -

    ' . $fullpath_src . '



    '); - print("
      " . p4string::MakeString(_('thesaurus:: comme terme specifique'))); - print("   "); - print(""); - // print("

    \n"); - printf(p4string::MakeString(_('thesaurus:: comme synonyme de %s'), "html"), "

    \n

    " . $fullpath_tgt . "


    \n"); - } else { - printf("

    " . $fullpath_src . "



    \n"); - print(p4string::MakeString(_('thesaurus:: Accepter la branche comme'), "html") . '
    '); - print(" " . p4string::MakeString(_('thesaurus:: comme terme specifique'))); - printf("

    \n

    " . $fullpath_tgt . "



    \n"); - print("\n"); - } - // print($fullpath); - ?> -
    -
    - -        - - -
    - -
    -
    -
    -
    -
    " . $cfield . "

    ") ?> -
    -
    -
    -
    -
    -
    -
    - - - - diff --git a/www/thesaurus2/export_text.php b/www/thesaurus2/export_text.php deleted file mode 100644 index 35b5bceae0..0000000000 --- a/www/thesaurus2/export_text.php +++ /dev/null @@ -1,261 +0,0 @@ -get_parms( - "bid" - , "piv" - , "id" - , "typ" - , "dlg" - , "osl" - , "iln" - , "ilg" - , "hit" - , "smp" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - - <?php echo p4string::MakeString(_('thesaurus:: export au format texte')) ?> - - - - - - -get_databox((int) $parm['bid']); - $connbas = connection::getPDOConnection($app, $parm['bid']); - - if ($parm["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); - printf("
    \n", $parm["smp"] ? 9 : 12);
    -            if ($parm["id"] == "T")
    -                $q = "/thesaurus";
    -            elseif ($parm["id"] == "C")
    -                $q = "/cterms";
    -            else
    -                $q = "//te[@id='" . $parm["id"] . "']";
    -            export0($xpathth->query($q)->item(0));
    -            print("
    \n"); - } - } catch (Exception $e) { - - } -} - - - -$tnodes = NULL; - -function printTNodes() -{ - global $tnodes; - global $thits; - global $parm; - - $numlig = ($parm["iln"] == "1"); - $hits = ($parm["hit"] == "1"); - $ilg = ($parm["ilg"] == "1"); - $oneline = ($parm["osl"] == "1"); - - $ilig = 1; - - foreach ($tnodes as $node) { - $tabs = str_repeat("\t", $node["depth"]); - switch ($node["type"]) { - case "ROOT": - if ($numlig) - print($ilig ++ . "\t"); - if ($hits && ! $oneline) - print("\t"); - print($tabs . $node["name"] . "\n"); - break; - case "TRASH": - if ($numlig) - print($ilig ++ . "\t"); - if ($hits && ! $oneline) - print("\t"); - print($tabs . "{TRASH}\n"); - break; - case "FIELD": - if ($numlig) - print($ilig ++ . "\t"); - if ($hits && ! $oneline) - print("\t"); - print($tabs . $node["name"] . "\n"); - break; - case "TERM": - $isyn = 0; - if ($oneline) { - if ($numlig) - print($ilig ++ . "\t"); - print($tabs); - $isyn = 0; - foreach ($node["syns"] as $syn) { - if ($isyn > 0) - print(" ; "); - print($syn["v"]); - if ($ilg) - print(" [" . $syn["lng"] . "]"); - if ($hits) - print(" [" . $syn["hits"] . "]"); - $isyn ++; - } - print("\n"); - } - else { - $isyn = 0; - foreach ($node["syns"] as $syn) { - if ($numlig) - print($ilig ++ . "\t"); - if ($hits) - print( $syn["hits"] . "\t"); - print($tabs); - if ($isyn > 0) - print("; "); - print($syn["v"]); - if ($ilg) - print(" [" . $syn["lng"] . "]"); - print("\n"); - $isyn ++; - } - } - break; - } - if ( ! $oneline) { - if ($numlig) - print($ilig ++ . "\t"); - print("\n"); - } - } -} - -function exportNode(&$node, $depth) -{ - global $thits; - global $tnodes; - 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); - } - } -} - -function export0($znode) -{ - global $tnodes; - $tnodes = array(); - - $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) { - // print( exportNode($node, $depth) ); - exportNode($node, $depth); - } - - export($znode, count($nodes)); - - - printTNodes(); -} - -function export($node, $depth = 0) -{ - global $tnodes; - if ($node->nodeType == XML_ELEMENT_NODE) { - // print( exportNode($node, $depth) ); - exportNode($node, $depth); - } - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { - if ($n->nodeName == "te") - export($n, $depth + 1); - } -} -?> - - diff --git a/www/thesaurus2/export_text_dlg.php b/www/thesaurus2/export_text_dlg.php deleted file mode 100644 index 4b5e5271f6..0000000000 --- a/www/thesaurus2/export_text_dlg.php +++ /dev/null @@ -1,191 +0,0 @@ -get_parms( - "bid" - , "piv" - , "id" - , "typ" - , "dlg" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - <?php echo p4string::MakeString(_('thesaurus:: export au format texte')) ?> - - - - - -
    -
    -
    - " > - " > - " > - " > - " > - - - - - - - - - - - - - -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - -
    - -
    -
    -
    - -     - -
    -
    - - diff --git a/www/thesaurus2/export_topics.php b/www/thesaurus2/export_topics.php deleted file mode 100644 index fee55c6f7a..0000000000 --- a/www/thesaurus2/export_topics.php +++ /dev/null @@ -1,274 +0,0 @@ -get_parms( - "bid" - , "piv" - , "id" - , "typ" - , "dlg" - , 'obr' // liste des branches ouvertes - , 'ofm' // 'toscreen' ; 'tofiles' - , 'srt' // trie - , 'sth' // recherche 'thesaurus' - , 'sand' // full query, with 'and's - , 'obrf' // opened br format -); -if ($parm['ofm'] == 'toscreen') { - //header('Content-type: text/xml'); - //header('Content-Disposition: attachment; filename="topics.xml"'); -} - -$lng = $app['locale']; - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} - -$obr = explode(';', $parm['obr']); - -$t_lng = array(); - -if ($parm['ofm'] == 'tofiles') { - foreach (Application::getAvailableLanguages() as $lng_code => $lng) { - $lng_code = explode('_', $lng_code); - $lng_code = $lng_code[0]; - $t_lng[] = $lng_code; - } -} else { - $t_lng[] = $parm['piv']; -} - -switch ($parm['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'); -?> - - - <?php echo p4string::MakeString(_('thesaurus:: export en topics')) ?> - - - - - - - - -
    -get_databox((int) $parm['bid']); - if ($parm["typ"] == "TH") { - $domth = $databox->get_dom_thesaurus(); - } else { - $domth = $databox->get_dom_cterms(); - } - - if ($domth) { - $xpathth = new DOMXPath($domth); - if ($parm["id"] == "T") - $q = "/thesaurus"; - elseif ($parm["id"] == "C") - $q = "/cterms"; - else - $q = "//te[@id='" . $parm["id"] . "']"; - - if ($parm['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));
    -
    -                export0($xpathth->query($q)->item(0), $dom, $root, $lng);
    -
    -                if ($parm['ofm'] == 'toscreen') {
    -                    print(str_replace(array('&', '<', '>'), array('&', '<', '>'), $dom->saveXML()));
    -                } elseif ($parm['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))
    -                        echo p4string::MakeString(sprintf(_('thesaurus:: fichier genere : %s'), $fname));
    -                    else
    -                        echo p4string::MakeString(_('thesaurus:: erreur lors de l\'enregsitrement du fichier'));
    -                    print("

    \n"); - } - } - if ($parm['ofm'] == 'toscreen') - print("
    \n"); - } - } catch (Exception $e) { - - } -} - -if ($parm['ofm'] == 'tofiles') { - ?> -
    -
    -
    -
    - -
    - -
    - - - - appendChild($dom->createElement('topics')); - export($znode, $dom, $topics, '', $lng, 0); - } - - function export($node, &$dom, &$topics, $prevQuery, $lng, $depth = 0) - { - global $parm; - global $tnodes; - global $obr; - global $opened_display; - $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 ($parm['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 ($parm['sth']) { - $query = '*:' . $query; - if ($parm['sand']) - $query = '(' . $query . ')'; - } - - if ($parm['sand'] && $prevQuery != '') - $query = $prevQuery . ' ' . _('phraseanet::technique:: et') . ' ' . $query . ''; - - $topic->appendChild($dom->createElement('query'))->appendChild($dom->createTextNode('' . $query . '')); - - $topics2 = $dom->createElement('topics'); - - if (export($t_node[$i]['node'], $dom, $topics2, $query, $lng, $depth + 1) > 0) - $topic->appendChild($topics2); - } - } - - return($ntopics); - } diff --git a/www/thesaurus2/import.php b/www/thesaurus2/import.php deleted file mode 100644 index 3aefec3f05..0000000000 --- a/www/thesaurus2/import.php +++ /dev/null @@ -1,373 +0,0 @@ -get_parms( - "bid" - , 'piv' - , "id" - , 't' - , 'dlg' -); - -set_time_limit(300); - -$imported = false; -$err = ''; - -if ($parm["bid"] !== null) { - $loaded = false; - try { - $databox = $app['phraseanet.appbox']->get_databox((int) $parm['bid']); - $connbas = connection::getPDOConnection($app, $parm['bid']); - - $dom = $databox->get_dom_thesaurus(); - - if ($dom) { - $err = ''; - if ($parm['id'] == '') { - // on importe un theaurus entier - $node = $dom->documentElement; - while ($node->firstChild) - $node->removeChild($node->firstChild); - - $err = importFile($dom, $node); - } 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) { - - } -} - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - ");'> - - - - -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 ( ! 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 = $parm['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', $unicode->remove_indexer_chars($syn)); - if ($kon) - $sy->setAttribute('k', $unicode->remove_indexer_chars($kon)); - - $sy->setAttribute('lng', $lng); - - $nsy ++; - } - - $te->setAttribute('nextid', (string) $nsy); - } - - fclose($fp); - } - - return($err); -} - -function no_dof($dom, $node) -{ - global $parm; - $unicode = new unicode(); - - $t = $parm['t']; - - - $t = preg_replace('/\\r|\\n/', '£', $t); - $t = preg_replace('/££*/', '£', $t); - $t = preg_replace('/£\\s*;/', ' ;', $t); - $tlig = explode('£', $t); - - $mindepth = 999999; - foreach ($tlig as $lig) { -// echo('.'); -// flush(); - - if (trim($lig) == '') - continue; - for ($depth = 0; $lig != '' && $lig[$depth] == "\t"; $depth ++ ) - ; - if ($depth < $mindepth) - $mindepth = $depth; - } - - $curdepth = -1; - $tid = array(-1 => -1, 0 => -1); - foreach ($tlig as $lig) { -// echo('-'); -// flush(); - - $lig = substr($lig, $mindepth); - if (trim($lig) == '') - continue; - for ($depth = 0; $lig != '' && $lig[0] == "\t"; $depth ++ ) - $lig = substr($lig, 1); - -// printf("curdepth=%s, depth=%s : %s\n", $curdepth, $depth, $lig); - - if ($depth > $curdepth + 1) { - // error -// print('error over-indent at \'' . $lig . "'\n"); - continue; - } - - while ($curdepth >= $depth) { - $curdepth --; - $node = $node->parentNode; - } - $curdepth = $depth; - - $nid = (int) ($node->getAttribute('nextid')); - $id = $node->getAttribute('id') . '.' . $nid; - $pid = $node->getAttribute('id'); - -// print("pid=".$pid); - - $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(';', $lig); - $nsy = 0; - foreach ($tsy as $syn) { - $lng = $parm['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); - - // for($id='T',$i=0; $i<=$curdepth; $i++) - // $id .= '.' . $tid[$i]; -// $id = '?'; -// printf("depth=%s (%s) ; sy='%s', kon='%s', lng='%s', hit='%s' \n", $depth, $id, $syn, $kon, $lng, $hit); - - /* - $nid = (int)($node->getAttribute('nextid')); - $pid = $node->getAttribute('id'); - - $id = ($pid ? ($pid.'.'):'T') . $nid ; - $node->setAttribute('nextid', (string)($nid+1)); - - */ - $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', $unicode->remove_indexer_chars($syn)); - if ($kon) - $sy->setAttribute('k', $unicode->remove_indexer_chars($kon)); - - $sy->setAttribute('lng', $lng); - - $nsy ++; - } - - $te->setAttribute('nextid', (string) $nsy); - } -} diff --git a/www/thesaurus2/import_dlg.php b/www/thesaurus2/import_dlg.php deleted file mode 100644 index eec5bfcdc4..0000000000 --- a/www/thesaurus2/import_dlg.php +++ /dev/null @@ -1,122 +0,0 @@ -get_parms( - "bid" - , "piv" - , "id" - , "dlg" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - - <?php echo p4string::MakeString(_('thesaurus:: Importer')) ?> - - - - - -
    -
    - " > - " > - " > - " > -
    - -
    " . ' ' . $parm['piv']; ?>
    -
    -
    - - - - -  (max 16Mo) -
    - -
    - - - - - - - - -
    -
    - -     - -
    -
    - - - diff --git a/www/thesaurus2/index.php b/www/thesaurus2/index.php deleted file mode 100644 index 2a2aa69908..0000000000 --- a/www/thesaurus2/index.php +++ /dev/null @@ -1,159 +0,0 @@ -get_parms( - "bas", "res" -); - -$conn = $app['phraseanet.appbox']->get_connection(); - -phrasea::headers(); - -// on liste les bases dont on peut éditer le thésaurus -// todo : ajouter 'bas_edit_thesaurus' dans sbasusr. pour l'instant on simule avec bas_edit_thesaurus=bas_bas_modify_struct -$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"; -?> - - - - <?php echo $app['phraseanet.registry']->get('GV_homeTitle'); ?> - <?php echo p4string::MakeString(_('phraseanet:: thesaurus')) ?> - - - - - - - - -
    -
    -
    -
    -get_id(); - -$stmt = $conn->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; - } - $name = phrasea::sbas_names($row['sbas_id'], $app); - $select_bases .= "\n"; - $last_base = array("sbid" => $row["sbas_id"], "name" => $name); - $nbases ++; -} - -if ($nbases > 0) { - ?> - -
    - " /> - - - %s
    \n", $last_base["sbid"], $last_base["name"]); - ?> - - - - -
    - - -
    - - $lng) { - $lng_code = explode('_', $lng_code); - $lng_code = $lng_code[0]; - printf("", $nf == 0 ? p4string::MakeString(_('thesaurus:: langue pivot')) /* Langue pivot : */ : ""); - print("\n"); - $nf ++; - } - ?> -
    %s (" . $lng_code . ")
    -
    -
    -
    -
    - - - - -
    - - diff --git a/www/thesaurus2/linkfield.php b/www/thesaurus2/linkfield.php deleted file mode 100644 index eaf962a3c6..0000000000 --- a/www/thesaurus2/linkfield.php +++ /dev/null @@ -1,145 +0,0 @@ -get_parms( - "bid" - , "piv" - , "tid" -); -?> - - - <?php echo p4string::MakeString(_('thesaurus:: Lier la branche de thesaurus au champ')) ?> - - - - - - - get_databox((int) $parm['bid']); - $domstruct = $databox->get_dom_structure(); - $domth = $databox->get_dom_thesaurus(); - - if ($domstruct && $domth) { - $xpathth = new DOMXPath($domth); - $xpathstruct = new DOMXPath($domstruct); - - if ($parm["tid"] !== "") - $q = "//te[@id='" . $parm["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; - } - } - ?> -
    -
    - "> - "> - "> - " . $fullBranch . "
    "; - printf(_('thesaurus:: Lier la branche de thesaurus au champ %s'), $fbhtml); - ?> -
    - query("/record/description/*"); - for ($i = 0; $i < $nodes->length; $i ++ ) { - $fieldname = $nodes->item($i)->nodeName; - $tbranch = $nodes->item($i)->getAttribute("tbranch"); - $ck = ""; - 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") == $parm["tid"]) { - $ck = "checked"; - } - } - } - printf("\t\t%s
    \n" - , $fieldname, $ck, $ck ? "1" : "0", $fieldname); - } - ?> -
    -
    - -     - -
    -
    - - - diff --git a/www/thesaurus2/linkfield2.php b/www/thesaurus2/linkfield2.php deleted file mode 100644 index 50a9d97dc0..0000000000 --- a/www/thesaurus2/linkfield2.php +++ /dev/null @@ -1,175 +0,0 @@ -get_parms( - "bid" - , "piv" - , "tid" - , "field" -); -?> - - - <?php echo p4string::MakeString(_('thesaurus:: Lier la branche de thesaurus')) ?> - - - - - - -
    - get_databox((int) $parm['bid']); - $domstruct = $databox->get_dom_structure(); - $domth = $databox->get_dom_thesaurus(); - - if ($domstruct && $domth) { - $xpathth = new DOMXPath($domth); - $xpathstruct = new DOMXPath($domstruct); - ?> -
    - "> - "> - "> -
    -
    -
    -
    - query("/record/description/*"); - for ($i = 0; $i < $nodes->length; $i ++ ) { - $fieldname = $nodes->item($i)->nodeName; - $tbranch = $nodes->item($i)->getAttribute("tbranch"); - $ck = false; - $tids = array(); // les ids de branches liees e ce champ - if ($tbranch) { - // ce champ a deje un tbranch, on balaye les branches auxquelles il est lie - $thnodes = $xpathth->query($tbranch); - for ($j = 0; $j < $thnodes->length; $j ++ ) { - if ($thnodes->item($j)->getAttribute("id") == $parm["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); - } - } - } - // printf("'%s' avant:%s apres:%s
    \n", $fieldname, $ck, array_key_exists($fieldname, $parm["field"])); - if (array_key_exists($fieldname, $parm["field"]) != $ck) { - print("\t\t
    "); - echo "" . $fieldname . "" . p4string::MakeString(sprintf(_('thesaurus:: Ce champ a ete modifie ; ancienne branche : %s '), $tbranch)); - print("
    \n"); - if ($ck) { - // print("il etait lie a la branche, il ne l'est plus
    \n"); - unset($tids[$parm["tid"]]); - } else { - // print("il n'etait pas lie a la branche, il l'est maintenant
    \n"); - $tids[$parm["tid"]] = $xpathth->query("/thesaurus//te[@id='" . thesaurus::xquery_escape($parm["tid"]) . "']")->item(0); - } - $newtbranch = ""; - foreach ($tids as $kitd => $node) { - if ($kitd === "") - $newtbranch .= ( $newtbranch ? " | " : "") . "/thesaurus"; - else { - // $newtbranch .= ($newtbranch?" | ":"") . "/thesaurus//te[@id='" . $kitd . "']"; - $neb = ""; - while ($node && $node->nodeName == "te") { - $neb = "/te[@id='" . $node->getAttribute("id") . "']" . $neb; - $node = $node->parentNode; - } - $newtbranch .= ( $newtbranch ? " | " : "") . "/thesaurus" . $neb; - } - } - echo p4string::MakeString(_('thesaurus:: nouvelle branche')) . $newtbranch; - print("
    \n"); - - if ($tbranch != "" && $newtbranch == "") { - echo "" . $fieldname . "" . p4string::MakeString(_('thesaurus:: ce champ n\'est plus lie au thesaurus, les termes indexes et candidats seront supprimes')); - print("
    \n"); - printf("\t\t\n", $fieldname); - } - if ($newtbranch != "") { - if ($tbranch == "") { - echo "" . $fieldname . "" . p4string::MakeString(_('thesaurus:: ce champ doit etre lie au thesaurus. La reindexation de la base est necessaire')); - } else { - echo "" . $fieldname . "" . p4string::MakeString(_('thesaurus:: le lien au thesaurus doit etre modifie, la reindexation de la base est necessaire')); - } - print("
    \n"); - - $needreindex = true; - printf("\t\t\n", $fieldname . "<" . $newtbranch); - } - } - } - ?> -
    - \n"); - print("
    " . p4string::MakeString(_('thesaurus:: reindexation necessaire')) /* Reindexation necessaire ! */ . "
    "); - } else { - print("
    " . p4string::MakeString(_('thesaurus:: pas de reindexation')) /* Pas de reindexation necessaire ! */ . "
    "); - } - ?> -
    - -     - -
    - -
    - - diff --git a/www/thesaurus2/linkfield3.php b/www/thesaurus2/linkfield3.php deleted file mode 100644 index 3e43e03c04..0000000000 --- a/www/thesaurus2/linkfield3.php +++ /dev/null @@ -1,138 +0,0 @@ -get_parms( - "bid" - , "piv" - , "f2unlk" - , "fbranch" - , "reindex" -); -?> - - - <?php echo p4string::MakeString(_('thesaurus:: Lier la branche de thesaurus')) ?> - - - - - -
    -
    -
    -
    -
    -
    - get_databox((int) $parm['bid']); - $connbas = connection::getPDOConnection($app, $parm['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 ($parm["f2unlk"] 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)); - } - - echo p4string::MakeString(sprintf(_('thesaurus:: suppression du lien du champ %s'), $f2unlk)); - print("
    \n"); - $field = $meta_struct->get_element_by_name($f2unlk); - if ($field) - $field->set_tbranch('')->save(); - } - foreach ($candidates2del as $candidate2del) { - echo p4string::MakeString(sprintf(_('thesaurus:: suppression de la branche de mot candidats pour le champ %s'), $candidate2del["field"])); - print("
    \n"); - $candidate2del["node"]->parentNode->removeChild($candidate2del["node"]); - $ctchanged = true; - } - - foreach ($parm["fbranch"] 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(); - echo p4string::MakeString(sprintf(_('thesaurus:: suppression de la branche de mot candidats pour le champ %s'), $fieldname)); - print("
    \n"); - } - } - - if ($ctchanged) { - if ($ctchanged) { - $databox->saveCterms($domct); - print(p4string::MakeString(_('thesaurus:: enregistrement de la liste modifiee des mots candidats.'))); - print("
    \n"); - } - } - } - - - $sql = "DELETE FROM thit WHERE name = :name"; - $stmt = $connbas->prepare($sql); - foreach ($parm["f2unlk"] as $f2unlk) { - $stmt->execute(array(':name' => $f2unlk)); - echo p4string::MakeString(_('thesaurus:: suppression des indexes vers le thesaurus pour le champ') . " " . $f2unlk . ""); - print("
    \n"); - } - $stmt->closeCursor(); - - if ($parm["reindex"]) { - $sql = "UPDATE record SET status=status & ~2"; - $stmt = $connbas->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - echo p4string::MakeString(_('thesaurus:: reindexer tous les enregistrements')); - print("
    \n"); - } - } catch (Exception $e) { - - } - } - ?> -
    -
    - -
    -
    - - diff --git a/www/thesaurus2/loadth.php b/www/thesaurus2/loadth.php deleted file mode 100644 index 2270619e78..0000000000 --- a/www/thesaurus2/loadth.php +++ /dev/null @@ -1,206 +0,0 @@ -get_parms( - "bid", "piv", "repair" -); - -function fixW(&$node, $depth = 0) -{ - if ($node && $node->nodeType == XML_ELEMENT_NODE) { - if (($v = $node->getAttribute("v")) != "") { - $unicode = new unicode(); - $node->setAttribute("w", $unicode->remove_indexer_chars($v)); - } - for ($c = $node->firstChild; $c; $c = $c->nextSibling) - fixW($c, $depth + 1); - } -} -if ($hdir = opendir($app['phraseanet.registry']->get('GV_RootPath') . "www/thesaurus2/patch")) { - while (false !== ($file = readdir($hdir))) { - if (substr($file, 0, 1) == ".") - continue; - if (is_file($f = $app['phraseanet.registry']->get('GV_RootPath') . "www/thesaurus2/patch/" . $file)) { - require_once($f); - print("\n"); - } - } - closedir($hdir); -} - -function fixThesaurus(&$domct, &$domth, &$connbas) -{ - $oldversion = $version = $domth->documentElement->getAttribute("version"); -// $cls = "patch_th_".str_replace(".","_",$version); -//printf("---- %s %s %s \n", $version, $cls, class_exists($cls) ); -//printf("---- %s %s \n", $version, $cls ); - while (class_exists($cls = "patch_th_" . str_replace(".", "_", $version), false)) { - print("// ============== patching from version='$version'\n"); - - $last_version = $version; - $zcls = new $cls; - print("// ----------- calling class '$cls'\n"); - $version = $zcls->patch($version, $domct, $domth, $connbas); - print("// ----------- method 'patch' -> returned '$version'\n"); - - if ($version == $last_version) - break; - } - - return($version); -} -?> - diff --git a/www/thesaurus2/newsy_dlg.php b/www/thesaurus2/newsy_dlg.php deleted file mode 100644 index 0b930784dd..0000000000 --- a/www/thesaurus2/newsy_dlg.php +++ /dev/null @@ -1,126 +0,0 @@ -get_parms( - "piv" - , "typ" // type de dlg : "TS"=nouvo terme specifique ; "SY"=nouvo synonyme -); - - -$lng = $app['locale']; - -switch ($parm["typ"]) { - case "TS": - $tstr = array(p4string::MakeString(_('thesaurus:: Nouveau terme')), p4string::MakeString(_('thesaurus:: terme'))); - break; - case "SY": - $tstr = array(p4string::MakeString(_('thesaurus:: Nouveau synonyme')), p4string::MakeString(_('thesaurus:: synonyme'))); - break; - default: - $tstr = array("", ""); - break; -} -?> - - - <?php echo $tstr[0] ?> - - - - - - - -
    -
    - - - - - - - - - - - - - - - - -
    (  )
    - $lng) { - $lng_code = explode('_', $lng_code); - $lng_code = $lng_code[0]; - $ck = $lng_code == $parm["piv"] ? " checked" : ""; - ?> - - name="lng" value="" id="lng_"> - - -    - -
    -
    -
    - -    - -
    -
    -
    -
    - - diff --git a/www/thesaurus2/newterm.php b/www/thesaurus2/newterm.php deleted file mode 100644 index 639f5573d6..0000000000 --- a/www/thesaurus2/newterm.php +++ /dev/null @@ -1,327 +0,0 @@ -get('GV_RootPath') . "www/thesaurus2/xmlhttp.php"); - -$request = http_request::getInstance(); -$parm = $request->get_parms( - "bid" - , "piv" // pivot - , "pid" - , "t" - , "sylng" // lng nouvo sy - , "typ" // "TS" ou "SY" - , "dlg" -); -?> - - - <?php echo $parm["typ"] == "TS" ? p4string::MakeString(_('thesaurus:: Nouveau terme specifique')) : p4string::MakeString(_('thesaurus:: Nouveau synonyme')) ?> - - - - - - - - " . $term . " ")); - if ($context != "") - $zterm .= p4string::MakeString(sprintf(_('thesaurus:: avec contexte %s'), "" . $context . "")); - else - $zterm .= p4string::MakeString(_('thesaurus:: sans contexte')); - -// print($dom->saveXML()); - - $xpath = new DOMXPath($dom); - - $candidates = $xpath->query("/result/candidates_list/ct"); - -// on verifie si au moins un champ candidat est acceptable - $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 ++; - } - } - if ($nb_candidates_ok > 0) { - // au moins un champ est acceptable : on presente des radio - if ($nb_candidates_ok == 1) - $t = p4string::MakeString(_('thesaurus:: est deja candidat en provenance du champ acceptable : ')); - else - $t = p4string::MakeString(_('thesaurus:: est deja candidat en provenance des champs acceptables : ')); - ?> -
    -
    - -
    -
    - -
    -
    -
    - "> - "> - \n"); -// if($nb_candidates_bad) -// printf("\t\t\t\t%s
    \n", $flist_bad); -// if($nb_candidates_ok) -// printf("\t\t\t\t%s
    \n", $flist_ok); - // $ck = "checked"; - for ($i = 0; $i < $candidates->length; $i ++ ) { - if ($candidates->item($i)->getAttribute("sourceok") == "1") { -// printf("\t\t\t\n", $candidates->item($i)->getAttribute("id") ); - printf("\t\t%s
    \n" - , $candidates->item($i)->getAttribute("id") - , $candidates->item($i)->getAttribute("field")); - // $ck = ""; - } else { -// printf("\t\t%s
    \n" -// , $candidates->item($i)->getAttribute("id") -// , $candidates->item($i)->getAttribute("field") ); - } - } - print("\t\t\t
    \n"); - - if ($nb_candidates_ok > 1) - print(p4string::MakeString(_('thesaurus:: selectionner la provenance a accepter')) . "
    \n"); - ?> -
    - -     - - -
    - 0) { - // present dans les candidats, mais aucun champ acceptable : on informe - if ($nb_candidates_bad == 1) - $t = p4string::MakeString(_('thesaurus:: est candidat en provenance des champs mais ne peut etre accepte a cet emplacement du thesaurus')); - else - $t = p4string::MakeString(_('thesaurus:: est candidat en provenance des champs mais ne peut etre accepte a cet emplacement du thesaurus')); - } - else { - // pas present dans les candidats - $t = p4string::MakeString(_('thesaurus:: n\'est pas present dans les candidats')) . "\n"; - } - ?> -
    -

    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -     - -
    - - - - - - diff --git a/www/thesaurus2/properties.php b/www/thesaurus2/properties.php deleted file mode 100644 index c37f297734..0000000000 --- a/www/thesaurus2/properties.php +++ /dev/null @@ -1,527 +0,0 @@ -get('GV_RootPath') . "www/thesaurus2/xmlhttp.php"); - -$request = http_request::getInstance(); -$parm = $request->get_parms( - "bid" - , "piv" - , "id" - , "typ" - , "dlg" -); - - -$lng = $app['locale']; - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - <?php echo p4string::MakeString(_('thesaurus:: Proprietes')) ?> - - - - - - - - - - - - - - -\n"); - $dom = xmlhttp($url); - printf("
    id: %s
    \n", $parm["id"]); - $fullpath = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue; - print("

    " . $fullpath . "


    \n"); - if ($parm["typ"] == "CT") { -// printf("present dans %s fiche(s).
    \n", $dom->getElementsByTagName("hits")->item(0)->firstChild->nodeValue ); - print("
    \n"); - } elseif ($parm["typ"] == "TH") { - echo p4string::MakeString(sprintf(_('thesaurus:: %s reponses retournees'), $dom->getElementsByTagName("allhits")->item(0)->firstChild->nodeValue)); - print("
    \n"); - print("
    \n"); - } - ?> -
    -
    - - - - - - - - - - - - - - - - - - - - - - -
       
    -
    -
    -
    - - - - - - - - - getElementsByTagName("sy_list")->item(0); - $nsy = 0; - for ($n = $sy_list->firstChild; $n; $n = $n->nextSibling) { - printf("\t\t\t\t\t\t\n", $id = $n->getAttribute("id"), $n->getAttribute("hits")); - printf("\t\t\t\t\t\t\t\n"); - printf("\t\t\t\t\t\t\t\n"); - if (($lng = $n->getAttribute("lng"))) - printf("\t\t\t\t\t\t\t\n", $n->getAttribute("id"), $lng); - else - printf("\t\t\t\t\t\t\t\n", $n->getAttribute("id")); - printf("\t\t\t\t\t\t\t\n", $n->getAttribute("t")); - printf("\t\t\t\t\t\t\t\n", $n->getAttribute("hits")); - printf("\t\t\t\t\t\t\t\n", $id); -// printf("\n"); - print("\t\t\t\t\t\t\n"); - $nsy ++; - } -// if($parm["typ"]=="TH") -// { -// print("\n"); -// } - ?> - -
    \n"); - if ($nsy > 0) - printf("\t\t\t\t\t\t\t\t\n"); - if ($nsy > 0 && $n->nextSibling) - print(" "); - if ($n->nextSibling) - printf("\t\t\t\t\t\t\t\t%s%s%s
    nouveau synonyme...
    -
    -
    -
    -
    -
    - -
    -
    - %s
  • \n", htmlentities($dom->saveXML())); -} -?> - - - diff --git a/www/thesaurus2/replace.php b/www/thesaurus2/replace.php deleted file mode 100644 index b7c9c2ef21..0000000000 --- a/www/thesaurus2/replace.php +++ /dev/null @@ -1,201 +0,0 @@ -get('GV_RootPath') . "www/thesaurus2/xmlhttp.php"); - -$request = http_request::getInstance(); -$parm = $request->get_parms( - "bid" - , "piv" - , "pid" // id du pere (te) - , "id" // id du synonyme (sy) - , "typ" - , "dlg" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} - -$url = "thesaurus2/xmlhttp/getsy.x.php"; -$url .= "?bid=" . urlencode($parm["bid"]); -$url .= "&piv=" . urlencode($parm["piv"]); -$url .= "&sortsy=0"; -$url .= "&id=" . urlencode($parm["id"]); -$url .= "&typ=" . urlencode($parm["typ"]); - -$dom = xmlhttp($url); -$fullpath = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue; -$zterm = $dom->getElementsByTagName("sy")->item(0)->getAttribute("t"); -$hits = $dom->getElementsByTagName("hits")->item(0)->firstChild->nodeValue; -?> - - - - Corriger... - - - - - - - - -
    id: 
    -



    -\n", $dom->getElementsByTagName("hits")->item(0)->firstChild->nodeValue ); - -if ($parm["typ"] == "TH") { - $loaded = false; - try { - $databox = $app['phraseanet.appbox']->get_databox((int) $parm['bid']); - $domstruct = $databox->get_dom_structure(); - $domth = $databox->get_dom_thesaurus(); - - if ($domstruct && $domth) { - $xpathth = new DOMXPath($domth); - $xpathstruct = new DOMXPath($domstruct); - ?> -
    -
    - "> - "> - "> - "> - "> - - "> - "> -
    -
    - - -
    -
    -
    - query("/record/description/*"); - for ($i = 0; $i < $fields->length; $i ++ ) { - $fieldname = $fields->item($i)->nodeName; - $tbranch = $fields->item($i)->getAttribute("tbranch"); - $ck = ""; - if ($tbranch) { - // ce champ a un tbranch, est-ce qu'il permet d'atteindre le terme selectionne ? - $branches = $xpathth->query($tbranch); - for ($j = 0; $j < $branches->length; $j ++ ) { - $q = ".//sy[@id='" . $parm["id"] . "']"; - // printf("searching %s against id=%s
    \n", $q, $branches->item($j)->getAttribute("id")); - if ($xpathth->query($q, $branches->item($j))->length > 0) { - // oui - $ck = true; - } - } - } - if ($ck) { - printf("\t\t%s
    \n" - , $fieldname, $fieldname); - } else { - printf("\t\t%s
    \n" - , $fieldname, $fieldname); - } - } - ?> -
    -
    - -     - -
    -
    - - - diff --git a/www/thesaurus2/replace2.php b/www/thesaurus2/replace2.php deleted file mode 100644 index 7292ce9b87..0000000000 --- a/www/thesaurus2/replace2.php +++ /dev/null @@ -1,275 +0,0 @@ -get('GV_RootPath') . "www/thesaurus2/xmlhttp.php"); - -$request = http_request::getInstance(); -$parm = $request->get_parms( - "bid" - , "piv" - , "pid" // id du pere (te) - , "id" // id du synonyme (sy) - , "src" - , "rpl" - , "rplrec" - , "field" - , "dlg" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} - -$url3 = "./replace3.php"; -$url3 .= "?bid=" . urlencode($parm["bid"]); -$url3 .= "&piv=" . urlencode($parm["piv"]); -$url3 .= "&id=" . urlencode($parm["id"]); -$url3 .= "&src=" . urlencode($parm["src"]); -$url3 .= "&rplrec=" . urlencode($parm["rplrec"]); -$url3 .= "&rpl=" . urlencode($parm["rpl"]); -$lstfld = ""; -if ($parm["rplrec"] && is_array($parm["field"])) { - foreach ($parm["field"] as $f) { - $url3 .= "&field[]=" . urlencode($f); - $lstfld .= ( $lstfld ? ", " : "") . "" . $f . ""; - } -} -$url3 .= "&dlg=" . urlencode($parm["dlg"] ? 1 : 0); -?> - - - Corriger... - - - - - - - -\n"); - // print($dom->saveXML()); - - $xpath = new DOMXPath($dom); - - $candidates = $xpath->query("/result/candidates_list/ct"); - if ($candidates->length > 0) { - // le terme saisi existait dans les candidats, on peut choisir qui accepter - ?> -
    - "> - "> -
    - le terme " . $term . ""; - if ($context != "") - $t .= " (avec contexte " . $context . ")"; - $t .= utf8_encode(" est deje candidat en provenance"); - $t .= ( $candidates->length == 1) ? " du champ :" : " des champs suivants :"; - $t .= "

    \n"; - - print($t); - - $candidates_ok = 0; - for ($i = 0; $i < $candidates->length; $i ++ ) { - if ($candidates->item($i)->getAttribute("sourceok") == "1") - $candidates_ok ++; - } - - print("
    \n"); - for ($i = 0; $i < $candidates->length; $i ++ ) { - if ($candidates->item($i)->getAttribute("sourceok") == "1") { - printf("\t\t%s
    \n" - , $candidates->item($i)->getAttribute("id") - , $candidates->item($i)->getAttribute("field")); - } else { - printf("\t\t%s
    \n" - , $candidates->item($i)->getAttribute("id") - , $candidates->item($i)->getAttribute("field")); - } - } - print("

    \n"); - if ($candidates_ok > 1) - print(utf8_encode("selectionnez la provenance e accepter.
    \n")); - } - - $nrec = 0; - if ($parm["rplrec"]) { // remplacer egalement dans les record - // table temporaire - $sql = "CREATE TEMPORARY TABLE IF NOT EXISTS `tmprecord` (`xml` TEXT COLLATE utf8_general_ci) SELECT record_id, xml FROM record"; - $stmt = $connbas->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - - $unicode = new unicode(); - $src_noacc = $unicode->remove_indexer_chars($parm["src"]); - $src_noacc_len = mb_strlen($src_noacc, "UTF-8"); - $src_noacc_tchar = array(); - for ($i = 0; $i < $src_noacc_len; $i ++ ) - $src_noacc_tchar[$i] = mb_substr($src_noacc, $i, 1, "UTF-8"); - - $sql = ""; - $params = array(); - $n = 0; - foreach ($parm["field"] as $field) { - $params[':like' . $n] = "%<$field>%" . $src_noacc . "%%"; - $sql .= ( $sql == "" ? "" : " OR ") . "(xml LIKE :like" . $n . ")"; - $n ++; - } - - $sql = "SELECT record_id, BINARY xml AS xml FROM tmprecord WHERE $sql"; - $stmt = $connbas->prepare($sql); - $stmt->execute($params); - $nrec = $stmt->rowCount(); - $stmt->closeCursor(); - - $out .= "remplacement de " . $parm["src"] . " par " . $parm["rpl"] . " dans le champ " . $lstfld . "
    \n"; - $out .= "
    \n"; - - $out .= "
    \n"; - $out .= "
    0%
    \n"; - $out .= "
    0%
    \n"; - $out .= "
    \n"; - $out .= "
     
    \n"; - $out .= "
    \n"; - - if ($nrec >= 0) { - $out .= "
    " . utf8_encode(" $nrec documents concernes !") . "
    \n"; - $out .= "
    \n
    \n"; - $out .= " \n"; - $out .= "    \n"; - $out .= " \n"; - $onload = "loaded();"; - } else { - $out .= "
    " . utf8_encode(" $nrec records concernes !") . "
    \n"; - $out .= "
    \n
    \n"; - $out .= " \n"; - $onload = "loaded();doContinue();"; - } - } else { - $onload = "loaded();"; - } - ?> - -
    -
    - - - -
    - -
    - - - diff --git a/www/thesaurus2/replace3.php b/www/thesaurus2/replace3.php deleted file mode 100644 index 5855ad3d36..0000000000 --- a/www/thesaurus2/replace3.php +++ /dev/null @@ -1,171 +0,0 @@ -get_parms( - "bid" - , "piv" - , "id" - , "src" - , "rpl" - , "field" - , "dlg" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - -prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - - $unicode = new unicode(); - $src_noacc = $unicode->remove_indexer_chars($parm["src"]); - $src_noacc_len = mb_strlen($src_noacc, "UTF-8"); - $src_noacc_tchar = array(); - for ($i = 0; $i < $src_noacc_len; $i ++ ) - $src_noacc_tchar[$i] = mb_substr($src_noacc, $i, 1, "UTF-8"); - - $sql = ""; - $params = array(); - $n = 0; - foreach ($parm["field"] as $field) { - $params[':like' . $n] = "%<$field>%" . $src_noacc . "%%"; - $sql .= ( $sql == "" ? "" : " OR ") . "(xml LIKE :like" . $n . ")"; - } - $sql = "SELECT record_id, BINARY xml AS xml FROM tmprecord WHERE $sql"; - $stmt = $connbas->prepare($sql); - $stmt->execute($params); - $rsbas2 = $stmt->fetchAll(PDO::FETCH_ASSOC); - $nrectot = $stmt->rowCount(); - $stmt->closeCursor(); - - $nrecdone = $nrecchanged = $nspot = 0; - foreach ($rsbas2 as $rowbas2) { - $nrecdone ++; - printf("\n"); - flush(); - - set_time_limit(30); - - $xml = $rowbas2["xml"]; - $spots = array(); - foreach ($parm["field"] as $field) { - $ibyte_min = $ichar_min = 0; - while (true) { - if (($ibyte_min = strpos($xml, "<$field>", $ibyte_min)) === false) - break; - $ibyte_min += strlen("<$field>"); - if (($ibyte_max = strpos($xml, "", $ibyte_min)) === false) - break; - - $ichar_min = mb_strpos($xml, "<$field>", $ichar_min, "UTF-8") + mb_strlen("<$field>"); - $ichar_max = mb_strpos($xml, "", $ichar_min, "UTF-8"); // + mb_strlen(""); - - $txml = substr($xml, $ibyte_min, $ibyte_max - $ibyte_min); - - $xml_noacc_tchar = array(); // buffer circulaire taille+2 (car prec. et car suiv. pour trouver uniquement les mots entiers) - $xml_noacc_tchar[0] = array(">", ">", 1); // car precedent - for ($i = 0; $i < $src_noacc_len + 1; $i ++ ) { - $c = mb_substr($txml, 0, 1, "UTF-8"); - $xml_noacc_tchar[$i + 1] = array($c, $unicode->remove_indexer_chars($c), $l = strlen($c)); - $txml = substr($txml, $l); - } - - for ($ib = $ibyte_min, $ic = $ichar_min; $ic <= $ichar_max - $src_noacc_len; $ic ++ ) { - - if (isdelim($xml_noacc_tchar[0][0]) && isdelim($xml_noacc_tchar[$src_noacc_len + 1][0])) { - for ($i = 0; $i < $src_noacc_len; $i ++ ) { - if ($xml_noacc_tchar[$i + 1][1] !== $src_noacc_tchar[$i]) - break; - } - - if ($i == $src_noacc_len) { - for ($l = 0, $i = 1; $i < $src_noacc_len + 1; $i ++ ) - $l += $xml_noacc_tchar[$i][2]; - - if (count($spots) == 0) { - $nrecchanged ++; - } - $nspot ++; - - $spots[$ib] = array("p" => $ib, "l" => $l); - } - } - $lost = array_shift($xml_noacc_tchar); - $c = mb_substr($txml, 0, 1, "UTF-8"); - $xml_noacc_tchar[] = array($c, $unicode->remove_indexer_chars($c), $l = strlen($c)); - // $txml = mb_substr($txml, 1, 9999, "UTF-8"); - $txml = substr($txml, $l); - $ib += $lost[2]; - - $ibyte_min = $ibyte_max + strlen(""); - $ichar_min = $ichar_max + mb_strlen(""); - } - } - } - if (count($spots) > 0) { - ksort($spots); - $dp = 0; - $ddp = (strlen($parm["rpl"]) - strlen($parm["src"])); - - foreach ($spots as $spot) { - $xml = substr($xml, 0, $dp + $spot["p"]) . $parm["rpl"] . substr($xml, $dp + $spot["p"] + $spot["l"]); - $dp += $ddp; // strlen(""); - } - print($xml); - print("
    \n"); - - $sql = "UPDATE tmprecord SET xml = :xml"; - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':xml' => $xml)); - $stmt->closeCursor(); - } - } - printf("found %d times in %d records
    \n", $nspot, $nrecdone); - printf("\n"); - } catch (Exception $e) { - - } -} - -function isdelim($utf8char) -{ - $unicode = new unicode(); - - return in_array($utf8char, $unicode->get_indexer_bad_chars()); -} -?> - - diff --git a/www/thesaurus2/rescan.php b/www/thesaurus2/rescan.php deleted file mode 100644 index 8601489801..0000000000 --- a/www/thesaurus2/rescan.php +++ /dev/null @@ -1,122 +0,0 @@ -get_parms( - "bid" - , "piv" - , "dlg" - , "dct" // delete candidates terms - , "drt" // delete rejected terms -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - Relire les candidats - - - - - -get_databox((int) $parm['bid']); - $connbas = connection::getPDOConnection($app, $parm['bid']); - - $domct = $databox->get_dom_cterms(); - - if ($domct) { - $nodestodel = array(); - removeCandidates($domct->documentElement, $nodestodel); - - foreach ($nodestodel as $nodetodel) { - $nodetodel->parentNode->removeChild($nodetodel); - } - if ($parm["dct"]) { - $sql = "DELETE FROM thit WHERE value LIKE 'C%'"; - $stmt = $connbas->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - } - if ($parm["drt"]) { - $sql = "DELETE FROM thit WHERE value LIKE 'R%'"; - $stmt = $connbas->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - } - - $databox->saveCterms($domct); - - $sql = "UPDATE record SET status=status & ~2"; - $stmt = $connbas->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - ?> -
    -
    - -
    -
    - " onclick="refreshCterms();self.close();"> -
    -
    - nodeType == XML_ELEMENT_NODE && $node->nodeName == "te" && $node->getAttribute("field") == "") { - $id0 = substr($node->getAttribute("id"), 0, 1); - if (($parm["dct"] && $id0 == "C") || ($parm["drt"] && $id0 == "R")) - $nodestodel[] = $node; - } - else { - for ($n = $node->firstChild; $n; $n = $n->nextSibling) - removeCandidates($n, $nodestodel); - } - } - ?> - - - diff --git a/www/thesaurus2/rescan_dlg.php b/www/thesaurus2/rescan_dlg.php deleted file mode 100644 index f236e8e10a..0000000000 --- a/www/thesaurus2/rescan_dlg.php +++ /dev/null @@ -1,145 +0,0 @@ -get_parms( - "bid" - , "piv" - , "dlg" -); - -if ($parm["dlg"]) { - $opener = "window.dialogArguments.win"; -} else { - $opener = "opener"; -} -?> - - - Relire les candidats - - - - - - -
    -
    - -get_databox((int) $parm['bid']); - $connbas = connection::getPDOConnection($app, $parm['bid']); - - $nrec = 0; - $sql = "SELECT COUNT(*) AS nrec FROM record"; - $stmt = $connbas->prepare($sql); - $stmt->execute(); - $rowbas = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($rowbas) - $nrec = $rowbas["nrec"]; - - $domct = $databox->get_dom_cterms(); - - if ($domct) { - $r = countCandidates($domct->documentElement); - - printf(utf8_encode("%s termes candidats, %s termes refuses

    \n"), $r["nc"], $r["nr"]); - ?> - "> - "> - "> -
    -
    -
    - \n"); ?> -
    -
    -
    - -    - -
    -
    -
    -
    - 0, "nr" => 0); - if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName == "sy" && strlen($id = $node->getAttribute("id")) > 1) { - if (substr($id, 0, 1) == "C") - $ret["nc"] ++; - elseif (substr($id, 0, 1) == "R") - $ret["nr"] ++; - } - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { - $r = countCandidates($n); - $ret["nc"] += $r["nc"]; - $ret["nr"] += $r["nr"]; - } - - return($ret); -} -?> - - - diff --git a/www/thesaurus2/xmlhttp.php b/www/thesaurus2/xmlhttp.php deleted file mode 100644 index f330b464f7..0000000000 --- a/www/thesaurus2/xmlhttp.php +++ /dev/null @@ -1,60 +0,0 @@ -get('GV_ServerName') . $url; - $xml = http_query::getUrl($fullurl); - $ret = new DOMDocument(); - $ret->loadXML($xml); - - return($ret); -} - -function indentXML(&$dom) -{ - indentXML2($dom, $dom->documentElement, 0, 0); -} - -function indentXML2(&$dom, $node, $depth, $ichild) -{ - $tab = str_repeat("\t", $depth); - $fc = null; - if ($node->nodeType == XML_ELEMENT_NODE) { - if ($ichild == 0) - $node->parentNode->insertBefore($dom->createTextNode($tab), $node); - else - $node->parentNode->insertBefore($dom->createTextNode("\n" . $tab), $node); - $fc = $node->firstChild; - if ($fc) { - if ($fc->nodeType == XML_TEXT_NODE && ! $fc->nextSibling) { - - } else { - $node->insertBefore($dom->createTextNode("\n"), $fc); - for ($i = 0, $n = $fc; $n; $n = $n->nextSibling, $i ++ ) { - indentXML2($dom, $n, $depth + 1, $i); - } - $node->appendChild($dom->createTextNode("\n" . $tab)); - } - } - } elseif ($node->nodeType == XML_TEXT_NODE) { - $node->parentNode->insertBefore($dom->createTextNode($tab), $node); - } -} -?>