From 0674d2e9b1aad9cc8099e57a80cbdd5c7fc2bf7e Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 3 Dec 2010 18:35:16 +0000 Subject: [PATCH] --- inc/config.inc.php | 2 +- inc/ws/Controlleur/class.ws.url.php | 2 +- inc/ws/DAO/class.ws.dao.book.php | 46 ++++++++++++++--------------- inc/ws/DAO/class.ws.dao.theme.php | 19 ++++++++---- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/inc/config.inc.php b/inc/config.inc.php index 3e2eb4858..c541467f7 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -15,7 +15,7 @@ if (in_array($_SERVER['HTTP_HOST'], array_merge($localrel, $localabs))) { define('DEV', true); define('WINDOWS', true); define('FONT_PATH', 'C:/Windows/Fonts'); - define('AS3_SOURCES', 'C:\Users\Vincent\Documents\Works\as3;C:\Users\Vincent\Documents\Works\cubeExtranet\swf\_src'); + define('AS3_SOURCES', 'C:\Users\Vincent\Documents\Works\as3;C:\Users\Vincent\Documents\Works\cubeExtranet\swf\_src;C:\Users\Vincent\Documents\Works\as3-10'); if (in_array($_SERVER['HTTP_HOST'], $localrel)) { define('WEBROOT', '/cubeExtranet'); diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index a49da9bd2..6cd4cf50c 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -165,7 +165,7 @@ html{height:100%}' . "\n"; $dao = new wsDAOBook($core->con); header('Content-type: text/plain'); ob_clean(); - echo $dao->compile(2963, 3, false); + echo $dao->compile(2964, 3, false); exit; } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 6c65facc1..23a4276ea 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -410,33 +410,32 @@ class wsDAOBook extends extranetDAO { $index = array(); $textes = array(); foreach($pages as $book_page => $infos) { - $file = ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.txt'; - $text = file_get_contents($file); - $text = mb_strtolower($text); - $words = cubeSearch::getWords($text, false, true, false); + $tfile = ROOT . '/docs/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.txt'; + $ifile = ROOT . '/docs/' . $infos['document_id'] . '/i' . $infos['document_page'] . '.txt'; + $text = file_get_contents($tfile); + $ipage = file_get_contents($ifile); - $this->fillIndexWithWords($index, $book_page, $words); - $textes[$book_page] = cubeText::removeAccents(cubeText::condenseWhite($text)); + $this->fillIndexWithWords($index, $book_page, $ipage); + $textes[$book_page] = $text; } ksort($index); } - protected function fillIndexWithWords(&$index, $page, $words) + protected function fillIndexWithWords(&$index, $page, $ipage) { - foreach($words as $word) { - $woa = cubeText::removeAccents($word); - if (!isset($index[$woa])) { - $index[$woa] = array('total' => 0, 'words' => array()); - } - if (!isset($index[$woa]['words'][$word])) { - $index[$woa]['words'][$word] = array('total' => 0, 'pages' => array()); + $words = explode('|', $ipage); + + foreach($words as $worddatas) { + list($word, $count) = explode(',', $worddatas); + + if (!isset($index[$word])) { + $index[$word] = array('total' => 0, 'pages' => array()); } - if (!isset($index[$woa]['words'][$word]['pages'][$page])) { - $index[$woa]['words'][$word]['pages'][$page] = 0; + if (!isset($index[$word]['pages'][$page])) { + $index[$word]['pages'][$page] = 0; } - $index[$woa]['total']++; - $index[$woa]['words'][$word]['total']++; - $index[$woa]['words'][$word]['pages'][$page]++; + $index[$word]['total'] += $count; + $index[$word]['pages'][$page] += $count; } } @@ -470,10 +469,10 @@ class wsDAOBook extends extranetDAO { $size = $firstDoc->generalInfos['size']; $daoTheme = new wsDAOTheme($this->con); - $theme = $daoTheme->getThemeOfBook($book_id); + $theme = $daoTheme->getThemeOfBook($book_id,true); - $index=''; - $textes=''; + $index = ''; + $textes = ''; $this->makeTextsIndexes($book_id, $index, $textes); @@ -482,6 +481,7 @@ class wsDAOBook extends extranetDAO { $flex->addVariable('links', $book->links); $flexLight->addVariable('datas', $book->parametres->toStandardObject()); $flexLight->addVariable('id', $book_id, false, true, 'uint'); + $flex->addVariable('traductions', wsLang::getTraductionWithId($book->traductions)); $flex->addVariable('chapters', $book->chapters); $flex->addVariable('extras', '' . $book->extras . '', false, true, 'XML'); @@ -534,7 +534,7 @@ class wsDAOBook extends extranetDAO { // Fonts $flex->addFont(FONT_PATH . '/FFFATLAN_0.TTF', 'CreditsFont', 'ASCII'); $flex->addFont(FONT_PATH . '/DIN Medium_0.ttf', 'GeneralFont', 'Latin'); - $flexLight->addFont(FONT_PATH . '/DIN Medium_0.ttf', 'GeneralFont', 'Numerals'); + $flexLight->addFont(FONT_PATH . '/DIN Medium_0.ttf', 'GeneralFontLight', 'Numerals'); $res .= $flex->compile() . "\n\n-------------------\n\n"; $flexLight->addVariable('datasSize', filesize(ROOT . '/books/datasCompiler/' . $book_id . '/FluidbookDatas.swf')); $res .= $flexLight->compile(); diff --git a/inc/ws/DAO/class.ws.dao.theme.php b/inc/ws/DAO/class.ws.dao.theme.php index 1dc1067e6..f45c51b65 100644 --- a/inc/ws/DAO/class.ws.dao.theme.php +++ b/inc/ws/DAO/class.ws.dao.theme.php @@ -7,8 +7,10 @@ class wsDAOTheme extends extranetDAO { $theme->nom = $r->nom; $theme->date = $r->date; $theme->proprietaire = $r->proprietaire; - $theme->books = explode(',', $r->books); - $theme->nbBooks = $r->nb_books; + if ($r->exists('books')) { + $theme->books = explode(',', $r->books); + $theme->nbBooks = $r->nb_books; + } $theme->signature = $r->signature; $theme->icones = $r->icones; $p = unserialize($r->parametres); @@ -28,9 +30,14 @@ class wsDAOTheme extends extranetDAO { return $this->singleton($r); } - public function getThemeOfBook($book_id) + public function getThemeOfBook($book_id, $basic = false) { - $r = $this->con->select('SELECT * FROM themes_vue WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1'); + if ($basic) { + $table = 'themes'; + } else { + $table = 'theme_vue'; + } + $r = $this->con->select('SELECT * FROM '.$table.' WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1'); return $this->singleton($r); } @@ -56,11 +63,11 @@ class wsDAOTheme extends extranetDAO { $p = new wsThemeParametres($parent); foreach($data as $k => $v) { try { - if(!isset($p->$k)){ + if (!isset($p->$k)) { continue; } $p->$k = $v; - fb($v,$k); + fb($v, $k); } catch(Exception $e) { fb($e); -- 2.39.5