]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 3 Jan 2012 18:00:15 +0000 (18:00 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 3 Jan 2012 18:00:15 +0000 (18:00 +0000)
fluidbook/tools/fwstk/src/cube/util/StringUtil.java
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/class.ws.links.php

index ebe9528fb47fbeba5b85d20c5fcf941ff3240a4d..6dfe78a273074ef1691fe8ec04360db1d93e4edb 100644 (file)
@@ -11,8 +11,21 @@ public class StringUtil {
        }\r
 \r
        public static String removePoints(String in) {\r
+               return StringUtil.removePoints(in, "");\r
+       }\r
+\r
+       public static String removePoints(String in, String ignore) {\r
+\r
+               if (ignore != "") {\r
+                       String ig = "";\r
+                       for (int i = 0; i < ignore.length(); i++) {\r
+                               ig += "\\" + ignore.substring(i, i + 1);\r
+                       }\r
+                       ignore = "&&[^" + ig + "]";\r
+               }\r
+\r
                return in.replaceAll(\r
-                               "[\\x21-\\x2f\\x3a-\\x3f\\x5b-\\x5f\\x7b-\\xa0\\xaa-\\xbf]",\r
+                               "[\\x21-\\x2f\\x3a-\\x3f\\x5b-\\x5f\\x7b-\\xa0\\xaa-\\xbf’" + ignore + "]",\r
                                " ");\r
        }\r
 \r
@@ -47,7 +60,8 @@ public class StringUtil {
        public static String rtrim(String str, String[] charsToTrim) {\r
                int length = str.length() - 1;\r
 \r
-               rightloop: for (; length >= 0; length--) {\r
+               rightloop:\r
+               for (; length >= 0; length--) {\r
                        for (String c : charsToTrim) {\r
                                if (str.indexOf(c) == length) {\r
                                        continue rightloop;\r
@@ -73,7 +87,8 @@ public class StringUtil {
 \r
        public static String ltrim(String str, String[] charsToTrim) {\r
                int startIndex = 0;\r
-               leftloop: for (startIndex = 0; startIndex <= str.length(); startIndex++) {\r
+               leftloop:\r
+               for (startIndex = 0; startIndex <= str.length(); startIndex++) {\r
                        for (String c : charsToTrim) {\r
                                if (str.indexOf(c) == startIndex) {\r
                                        continue leftloop;\r
index 009d34e34abf9c323779a73bb271662d9766da30..da97b6cd2e58abb516b90d747865d90163b2bf5e 100644 (file)
@@ -622,8 +622,27 @@ class wsDAOBook extends commonDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
-       public function makeTextsIndexes($book_id, &$index, &$textes) {\r
-               $pages = $this->getPagesOfBook($book_id);\r
+       public function makeTextsIndexes($book, $pages, &$index, &$textes) {\r
+\r
+               if ($book->parametres->ignoreSearchSeparators != "") {\r
+                       $docs = array();\r
+                       foreach ($pages as $p => $i) {\r
+                               $docs[] = $i['document_id'];\r
+                       }\r
+                       $docs = array_unique($docs);\r
+\r
+                       foreach ($docs as $doc) {\r
+                               $out = WS_DOCS . '/' . $doc . '/';\r
+\r
+                               $fwstk = new cubeCommandLine('fwstk');\r
+                               $fwstk->setPath(CONVERTER_PATH);\r
+                               $fwstk->setArg('--input ' . $out . '/crop.pdf');\r
+                               $fwstk->setArg('--extractTexts ' . $out . '%s%d.txt');\r
+                               $fwstk->setArg('--ignoreSeparators ' . $book->parametres->ignoreSearchSeparators);\r
+                               $fwstk->execute();\r
+                       }\r
+               }\r
+\r
                $index = array();\r
                $textes = array();\r
                foreach ($pages as $book_page => $infos) {\r
@@ -810,7 +829,7 @@ class wsDAOBook extends commonDAO {
                $hash .= round($size[0], 4);\r
                $hash = sha1($hash);\r
 \r
-               $this->makeTextsIndexes($book_id, $index, $textes);\r
+               $this->makeTextsIndexes($book, $pages, $index, $textes);\r
                $daoDoc->getLinksAndRulers($book_id, $links, $rulers);\r
 \r
 \r
index 0bd0cd90df679c8474fa80ae7c2d941491766ca0..e17b38fb5dc81227660901714bbce750f8086fc4 100644 (file)
@@ -81,8 +81,9 @@ class wsBookParametres extends wsParametres {
                $this->fields['search'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer le moteur de recherche'));\r
                $this->fields['ignoreSearch'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Mots à ignorer'),\r
                        'hint' => __('Liste des mots à ignorer séparés par des virgules'), 'grade' => 5);\r
+               $this->fields['ignoreSearchSeparators'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Caractères à ne pas considérer comme un séparateur de mot'));\r
                $this->forms['search'] = array('label' => __('Moteur de recherche'),\r
-                       'fieldsnames' => array('search', 'ignoreSearch'));\r
+                       'fieldsnames' => array('search', 'ignoreSearch', 'ignoreSearchSeparators'));\r
 \r
                $this->fields['soundTheme'] = array('type' => 'combo', 'default' => 'classic', 'editable' => true, 'label' => __("Thème sonore"),\r
                        'datas' => array(__('Pas de son') => '',\r
index e587f089df1f739e01cf7587c8c3de5b6ce8595c..2a3b8f7ddb0f4fc9d76c86a24289d0e3a7ff3679 100644 (file)
@@ -12,7 +12,7 @@
  */
 class wsLinks {
 
-       public static function linksToExcel($links, $rulers, $pages=null) {
+       public static function linksToExcel($links, $rulers, $pages = null) {
                $cols = array('document_id' => __('Document'), 'document_page' => __('Page du document'),
                        'page' => __('Page de la publication'), 'left' => __('x'), 'top' => __('y'), 'width' => __('Largeur'), 'height' => __('Hauteur'),
                        'type' => __('Type'), 'to' => __('Destination'), 'target' => __('Cible'),
@@ -46,8 +46,8 @@ class wsLinks {
                                        if (!is_null($pages)) {
                                                $infos = $pages[$l['page']];
                                                $value = $infos[$id];
-                                       }else{
-                                               $value='';
+                                       } else {
+                                               $value = '';
                                        }
                                } else {
 
@@ -130,7 +130,11 @@ class wsLinks {
                        $c->document_id = $document_id;
                        $c->links = $r->links;
                        $c->rulers = $r->rulers;
-                       $c->insert();
+                       try {
+                               $c->insert();
+                       } catch (Exception $e) {
+                               fb($e);
+                       }
                }
 
                return self::_recordToLinks($r);
@@ -154,7 +158,7 @@ class wsLinks {
                return array('links' => $ll, 'rulers' => $rr);
        }
 
-       public static function getLinksAndRulers($book_id, &$links, &$rulers, $time=null) {
+       public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = null) {
 
                global $core;