}\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
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
\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
$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
$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
$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
*/
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'),
if (!is_null($pages)) {
$infos = $pages[$l['page']];
$value = $infos[$id];
- }else{
- $value='';
+ } else {
+ $value = '';
}
} else {
$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);
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;