当前位置: 首页>>代码示例>>PHP>>正文


PHP thesaurus::xquery_escape方法代码示例

本文整理汇总了PHP中thesaurus::xquery_escape方法的典型用法代码示例。如果您正苦于以下问题:PHP thesaurus::xquery_escape方法的具体用法?PHP thesaurus::xquery_escape怎么用?PHP thesaurus::xquery_escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thesaurus的用法示例。


在下文中一共展示了thesaurus::xquery_escape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testXquery_escape

 public function testXquery_escape()
 {
     $string = 'Eléphant ';
     $this->assertEquals($string, thesaurus::xquery_escape($string));
     $string = '&é"\'(-è_ çà)=ù*!:;,?./§%µ+°0987654321';
     $this->assertEquals('&é"'(-è_ çà)=ù*!:;,?./§%µ+°0987654321', thesaurus::xquery_escape($string));
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:thesaurusTest.php

示例2: SearchTermJson

 public function SearchTermJson(Application $app, Request $request)
 {
     if (null === ($lng = $request->get('lng'))) {
         $data = explode('_', $app['locale']);
         if (count($data) > 0) {
             $lng = $data[0];
         }
     }
     $html = '';
     $sbid = (int) $request->get('sbid');
     try {
         $databox = $app['phraseanet.appbox']->get_databox($sbid);
         $html = "" . '<LI id="TX_P.' . $sbid . '.T" class="expandable">' . "\n";
         $html .= "\t" . '<div class="hitarea expandable-hitarea"></div>' . "\n";
         $html .= "\t" . '<span>' . \phrasea::sbas_labels($sbid, $app) . '</span>' . "\n";
         if ($request->get('t')) {
             if ($request->get('field') != '') {
                 $domth = $databox->get_dom_thesaurus();
                 $dom_struct = $databox->get_dom_structure();
             } else {
                 $domth = $databox->get_dom_thesaurus();
             }
             $q = null;
             if ($request->get('field') != '') {
                 // search only in the branch(es) linked to this field
                 if ($dom_struct) {
                     $xpath = new \DOMXPath($dom_struct);
                     if ($znode = $xpath->query('/record/description/' . $request->get('field'))->item(0)) {
                         $q = '(' . $znode->getAttribute('tbranch') . ')';
                     }
                 }
             } else {
                 // search in the whole thesaurus
                 $q = '/thesaurus';
             }
             if ($q !== null && $domth) {
                 $xpath = new \DOMXPath($domth);
                 $t = $this->splitTermAndContext($request->get('t'));
                 $q2 = 'starts-with(@w, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[0])) . '\')';
                 if ($t[1]) {
                     $q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
                 }
                 $q2 = '//sy[' . $q2 . ' and @lng=\'' . $lng . '\']';
                 $q .= $q2;
                 $nodes = $xpath->query($q);
                 for ($i = 0; $i < $nodes->length; $i++) {
                     $nodes->item($i)->setAttribute('bold', '1');
                     for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
                         $n->setAttribute('open', '1');
                     }
                 }
                 $this->getHTMLTerm($sbid, $lng, $domth->documentElement, $html);
             }
         } else {
             $html .= "\t" . '<ul style="display: none;">loading</ul>' . "\n";
         }
         $html .= "" . '</LI>' . "\n";
     } catch (\Exception $e) {
     }
     return $app->json(['parm' => ['sbid' => $request->get('sbid'), 't' => $request->get('t'), 'field' => $request->get('field'), 'lng' => $request->get('lng'), 'debug' => $request->get('debug')], 'html' => $html]);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:61,代码来源:Xmlhttp.php

示例3: doSearchCandidate

 private function doSearchCandidate(Application $app, $bid, $pid, $t, $k, $piv)
 {
     $ret = new \DOMDocument("1.0", "UTF-8");
     $ret->standalone = true;
     $ret->preserveWhiteSpace = false;
     $root = $ret->appendChild($ret->createElement("result"));
     $root->appendChild($ret->createCDATASection(var_export(["bid" => $bid, "pid" => $pid, "t" => $t, "k" => $k, "piv" => $piv], true)));
     $ctlist = $root->appendChild($ret->createElement("candidates_list"));
     try {
         $databox = $app['phraseanet.appbox']->get_databox((int) $bid);
         $domstruct = $databox->get_dom_structure();
         $domth = $databox->get_dom_thesaurus();
         $domct = $databox->get_dom_cterms();
         if ($domstruct && $domth && $domct) {
             $xpathth = new \DOMXPath($domth);
             $xpathct = new \DOMXPath($domct);
             // on cherche les champs d'ou peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme
             $fields = array();
             $xpathstruct = new \DOMXPath($domstruct);
             $nodes = $xpathstruct->query("/record/description/*[@tbranch]");
             for ($i = 0; $i < $nodes->length; $i++) {
                 $fieldname = $nodes->item($i)->nodeName;
                 $tbranch = $nodes->item($i)->getAttribute("tbranch");
                 if ($pid != "") {
                     $q = "(" . $tbranch . ")/descendant-or-self::te[@id='" . $pid . "']";
                 } else {
                     $q = "(" . $tbranch . ")/descendant-or-self::te[not(@id)]";
                 }
                 $fields[$fieldname] = ["name" => $fieldname, "tbranch" => $tbranch, "cid" => null, "sourceok" => false];
                 if (!$tbranch) {
                     continue;
                 }
                 $l = $xpathth->query($q)->length;
                 if ($l > 0) {
                     // le pt d'insertion du nvo terme se trouve dans la tbranch du champ,
                     // donc ce champ peut etre source de candidats
                     $fields[$fieldname]["sourceok"] = true;
                 } else {
                     // le pt d'insertion du nvo terme ne se trouve PAS dans la tbranch du champ,
                     // donc ce champ ne peut pas etre source de candidats
                 }
             }
             // on considere que la source 'deleted' est toujours valide
             $fields["[deleted]"] = ["name" => $app->trans('thesaurus:: corbeille'), "tbranch" => null, "cid" => null, "sourceok" => true];
             if (count($fields) > 0) {
                 $q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t)) . "'";
                 if ($k) {
                     if ($k != "*") {
                         $q .= " and @k='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";
                     }
                 } else {
                     $q .= " and not(@k)";
                 }
                 $q = "/cterms//te[./sy[{$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 ($n && array_key_exists($f = $n->getAttribute("field"), $fields)) {
                         $fields[$f]["cid"] = $nodes->item($i)->getAttribute("id");
                     }
                 }
             }
             foreach ($fields as $kfield => $field) {
                 if ($field["cid"] === null) {
                     continue;
                 }
                 $ct = $ctlist->appendChild($ret->createElement("ct"));
                 $ct->setAttribute("field", $field["name"]);
                 $ct->setAttribute("sourceok", $field["sourceok"] ? "1" : "0");
                 if ($field["cid"] !== null) {
                     $ct->setAttribute("id", $field["cid"]);
                 }
             }
         }
     } catch (\Exception $e) {
     }
     return $ret;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:81,代码来源:Thesaurus.php


注:本文中的thesaurus::xquery_escape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。