From: vincent@cubedesigners.com Date: Tue, 3 Jan 2012 18:00:15 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e67844f1c520b24e7b98c65e08c1ef2898c65387;p=cubeextranet.git --- diff --git a/fluidbook/tools/fwstk/src/cube/util/StringUtil.java b/fluidbook/tools/fwstk/src/cube/util/StringUtil.java index ebe9528fb..6dfe78a27 100644 --- a/fluidbook/tools/fwstk/src/cube/util/StringUtil.java +++ b/fluidbook/tools/fwstk/src/cube/util/StringUtil.java @@ -11,8 +11,21 @@ public class StringUtil { } public static String removePoints(String in) { + return StringUtil.removePoints(in, ""); + } + + public static String removePoints(String in, String ignore) { + + if (ignore != "") { + String ig = ""; + for (int i = 0; i < ignore.length(); i++) { + ig += "\\" + ignore.substring(i, i + 1); + } + ignore = "&&[^" + ig + "]"; + } + return in.replaceAll( - "[\\x21-\\x2f\\x3a-\\x3f\\x5b-\\x5f\\x7b-\\xa0\\xaa-\\xbf]", + "[\\x21-\\x2f\\x3a-\\x3f\\x5b-\\x5f\\x7b-\\xa0\\xaa-\\xbf’" + ignore + "]", " "); } @@ -47,7 +60,8 @@ public class StringUtil { public static String rtrim(String str, String[] charsToTrim) { int length = str.length() - 1; - rightloop: for (; length >= 0; length--) { + rightloop: + for (; length >= 0; length--) { for (String c : charsToTrim) { if (str.indexOf(c) == length) { continue rightloop; @@ -73,7 +87,8 @@ public class StringUtil { public static String ltrim(String str, String[] charsToTrim) { int startIndex = 0; - leftloop: for (startIndex = 0; startIndex <= str.length(); startIndex++) { + leftloop: + for (startIndex = 0; startIndex <= str.length(); startIndex++) { for (String c : charsToTrim) { if (str.indexOf(c) == startIndex) { continue leftloop; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 009d34e34..da97b6cd2 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -622,8 +622,27 @@ class wsDAOBook extends commonDAO { $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } - public function makeTextsIndexes($book_id, &$index, &$textes) { - $pages = $this->getPagesOfBook($book_id); + public function makeTextsIndexes($book, $pages, &$index, &$textes) { + + if ($book->parametres->ignoreSearchSeparators != "") { + $docs = array(); + foreach ($pages as $p => $i) { + $docs[] = $i['document_id']; + } + $docs = array_unique($docs); + + foreach ($docs as $doc) { + $out = WS_DOCS . '/' . $doc . '/'; + + $fwstk = new cubeCommandLine('fwstk'); + $fwstk->setPath(CONVERTER_PATH); + $fwstk->setArg('--input ' . $out . '/crop.pdf'); + $fwstk->setArg('--extractTexts ' . $out . '%s%d.txt'); + $fwstk->setArg('--ignoreSeparators ' . $book->parametres->ignoreSearchSeparators); + $fwstk->execute(); + } + } + $index = array(); $textes = array(); foreach ($pages as $book_page => $infos) { @@ -810,7 +829,7 @@ class wsDAOBook extends commonDAO { $hash .= round($size[0], 4); $hash = sha1($hash); - $this->makeTextsIndexes($book_id, $index, $textes); + $this->makeTextsIndexes($book, $pages, $index, $textes); $daoDoc->getLinksAndRulers($book_id, $links, $rulers); diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 0bd0cd90d..e17b38fb5 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -81,8 +81,9 @@ class wsBookParametres extends wsParametres { $this->fields['search'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer le moteur de recherche')); $this->fields['ignoreSearch'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Mots à ignorer'), 'hint' => __('Liste des mots à ignorer séparés par des virgules'), 'grade' => 5); + $this->fields['ignoreSearchSeparators'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Caractères à ne pas considérer comme un séparateur de mot')); $this->forms['search'] = array('label' => __('Moteur de recherche'), - 'fieldsnames' => array('search', 'ignoreSearch')); + 'fieldsnames' => array('search', 'ignoreSearch', 'ignoreSearchSeparators')); $this->fields['soundTheme'] = array('type' => 'combo', 'default' => 'classic', 'editable' => true, 'label' => __("Thème sonore"), 'datas' => array(__('Pas de son') => '', diff --git a/inc/ws/Util/class.ws.links.php b/inc/ws/Util/class.ws.links.php index e587f089d..2a3b8f7dd 100644 --- a/inc/ws/Util/class.ws.links.php +++ b/inc/ws/Util/class.ws.links.php @@ -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;