$db->documents->index('index_documents_proprietaire', 'BTREE', 'proprietaire');\r
$db->documents->index('index_documents_version', 'BTREE', 'version');\r
// .\r
- // Table pages des documents\r
- $db->document_links->document_id('integer', 0, false);\r
- $db->document_links->links('text', 0, false);\r
- $db->document_links->rulers('text', 0, false);\r
- // Clés\r
- $db->document_links->primary('pk_document_links', 'document_id');\r
-\r
- // .\r
- // Tables versions des liens\r
- $db->document_links_versions->document_id('integer', 0, false);\r
- $db->document_links_versions->links('text', 0, false);\r
- $db->document_links_versions->rulers('text', 0, false);\r
- $db->document_links_versions->comments('varchar', 128, false);\r
- $db->document_links_versions->user('integer', 0, false);\r
- $db->document_links_versions->update('integer', 0, false);\r
- // .\r
- $db->document_links_versions->primary('pk_document_links_version', 'document_id', 'update');\r
- $db->document_links_versions->index('idx_document_links_version_update', 'BTREE', 'update');\r
-\r
- $db->special_links_versions->book_id('integer', 0, false);\r
- $db->special_links_versions->links('text', 0, false);\r
- $db->special_links_versions->rulers('text', 0, false);\r
- $db->special_links_versions->update('integer', 0, false);\r
-\r
- $db->special_links_versions->primary('pk_special_links_versionsn', 'book_id', 'update');\r
- $db->special_links_versions->index('idx_special_links_versions_update', 'BTREE', 'update');\r
\r
// Table Books\r
$db->books->book_id('integer', 0, false);\r
. 'GROUP BY e.entreprise_id');\r
$this->views->createView('entreprises_vue', 'SELECT e.*,i.impaye AS impaye '\r
. 'FROM entreprises_inter e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise');\r
-// $this->views->createView('entreprises_ws', 'SELECT e.*, a.prenom AS administrateur, r.nom AS revendeur,a.utilisateur_id AS ws_super_admin, fb.ca AS ca\r
-//FROM entreprises e\r
-//LEFT JOIN ws_entreprises_tree ri ON ri.entreprise_id=e.entreprise_id\r
-//LEFT JOIN utilisateurs ur ON e.ws_admin=ur.utilisateur_id\r
-//LEFT JOIN entreprises r ON ur.entreprise=r.entreprise_id\r
-//LEFT JOIN ws_entreprises_tree wet ON wet.entreprise_id=r.entreprise_id\r
-//LEFT JOIN ca_fluidbook fb ON e.entreprise_id=fb.client\r
-//LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id');\r
+ $this->views->createView('entreprises_ws', 'SELECT e.*, a.prenom AS administrateur, r.nom AS revendeur,a.utilisateur_id AS ws_super_admin, fb.ca AS ca\r
+FROM entreprises e\r
+LEFT JOIN ws_entreprises_tree ri ON ri.entreprise_id=e.entreprise_id\r
+LEFT JOIN utilisateurs ur ON e.ws_admin=ur.utilisateur_id\r
+LEFT JOIN entreprises r ON ur.entreprise=r.entreprise_id\r
+LEFT JOIN ws_entreprises_tree wet ON wet.entreprise_id=r.entreprise_id\r
+LEFT JOIN ca_fluidbook fb ON e.entreprise_id=fb.client\r
+LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id');\r
$this->views->createView('clients_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, e.site AS site, e.type AS type '\r
. 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0');\r
$this->views->createView('utilisateurs_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, '\r
\r
$theme = false;\r
if ($_SERVER['HTTP_HOST'] == 'workshop.studio-france.com') {\r
- $theme = 'studiofrance';\r
+ $theme = 'studiofrance';\r
}\r
\r
\r
//define('DB_HOST', ':/var/run/mysqld/mysqld.sock');\r
\r
\r
-if ($_SERVER['SERVER_ADDR'] == '91.121.74.76') {\r
- define('AMARCORD', true);\r
- define('SERVER', 'amarcord');\r
- define('DB_HOST', 'alien.cubedesigners.com');\r
-} else {\r
-\r
- define('SERVER', 'alien');\r
- define('DB_HOST', '127.0.0.1');\r
- define('AMARCORD', false);\r
-\r
-}\r
-define('DB_NAME', 'extranet');\r
+define('SERVER', 'alien');\r
+//define('DB_HOST', '127.0.0.1');\r
+define('DB_HOST', 'localhost');\r
+//define('DB_HOST', ':/var/run/mysqld/mysqld.sock');\r
+define('AMARCORD', false);\r
+define('DB_NAME', 'extranet_clean');\r
define('DB_USER', 'extranet');\r
define('DB_PASSWORD', 'WvcAeYBDnrB93RXa');\r
\r
\r
\r
if ($ws) {\r
- define('MODE', 'ws');\r
+ define('MODE', 'ws');\r
} elseif ($extranet) {\r
- define('MODE', 'extranet');\r
+ define('MODE', 'extranet');\r
}\r
\r
define('STATIC_SERVER', SCHEME . '://' . $_SERVER['HTTP_HOST'] . WEBROOT);\r
define('IMG', WEBROOT . '/images/' . MODE);\r
\r
if (THEME) {\r
- $faviconroot = IMG . '/white/' . THEME . '/favicon';\r
+ $faviconroot = IMG . '/white/' . THEME . '/favicon';\r
} else {\r
- $faviconroot = IMG . '/favicon';\r
+ $faviconroot = IMG . '/favicon';\r
}\r
\r
\r
// New Way
wsLinks::saveLinksInFile($book_id, $core->user->utilisateur_id, $comments, $links, $rulers);
-
- // Old way
- $dao = new wsDAODocument($core->con);
- $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), $comments, $core->user->utilisateur_id);
}
protected function _importLinksAsAutobookmarkText($book_id)
global $core;
wsLinks::getLinksFromAutobookmarkText(file_get_contents($_FILES['file']['tmp_name']), $links, $rulers);
-
- $dao = new wsDAODocument($core->con);
- $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), 'Import from fwstk text export', $core->user->utilisateur_id);
+ wsLinks::saveLinksInFile($book_id, $core->user->utilisateur_id, 'Import links from Autobookmark file', $links, $rulers);
}
public static function offsetLinks($args, &$x)
\r
if (!$this->reload) {\r
wsLinks::addLinksFromPDF($this->bookId);\r
- $log = $dao->putLinksFromCSV($this->currentDoc->document_id);\r
- $this->currentDoc->addToLog($log);\r
}\r
$this->processedDoc++;\r
\r
$maxHeight = max($size[1], $maxHeight);
}
-
- $daoDoc->getLinksAndRulersFromFile($this->args['book_id'], $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($this->args['book_id'], $links, $rulers);
$this->json = true;
$comments = isset($this->args['comments']) ? $this->args['comments'] : 'Saved from editor';
- //
- $dao = new wsDAODocument($core->con);
- $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers'], $comments, $core->user->utilisateur_id, false);
-
- $daoBook = new wsDAOBook($core->con);
- $daoBook->setSpecialLinksAndRulers($this->args['book_id'], $this->args['specialLinks'], $this->args['specialRulers']);
-
wsLinks::saveLinksInFile($this->args['book_id'], $core->user->utilisateur_id, $comments,
$this->args['links'], $this->args['rulers'],
$this->args['specialLinks'], $this->args['specialRulers']);
$this->xml->addChild('texts', json_encode($GLOBALS['__l10n']));
}
- public function copyLinks()
- {
- global $core;
- $daoDocument = new wsDAODocument($core->con);
- $daoDocument->copyLinks($this->args['fromDoc'], $this->args['toDoc']);
- }
-
public function compile()
{
global $core;
}
}
- public static function compactLinks()
- {
- global $core;
- $r = $core->con->select('SELECT * FROM `document_links_versions` GROUP BY document_id,links,rulers');
- $keep = array();
- while ($r->fetch()) {
- if (!isset($keep[$r->document_id])) {
- $keep[$r->document_id] = array();
- }
- $keep[$r->document_id][] = $r->update;
- }
-
- foreach ($keep as $document_id => $dates) {
- $core->con->execute('DELETE FROM document_links_versions WHERE document_id=' . $document_id . ' AND `update` NOT IN(' . implode(',', $dates) . ')');
- }
- }
-
- public static function checkSerializeLinks()
- {
- global $core;
- $r = $core->con->select('SELECT * FROM document_links_versions');
- while ($r->fetch()) {
- if (substr($r->links, 1, 1) == ':') {
- $links = unserialize($r->links);
- $rulers = unserialize($r->rulers);
- $c = $core->con->openCursor('document_links_versions');
- $c->rulers = json_encode($rulers);
- $c->links = json_encode($links);
- $c->update('WHERE document_id=' . $r->document_id . ' AND `update`=' . $r->update);
- }
- }
- }
-
- public static function moveLinksToVersionDB()
- {
- global $core;
- $r = $core->con->select('SELECT * FROM document_links');
- $d = array();
- while ($r->fetch()) {
- if (!isset($d[$r->document_id])) {
- $d[$r->document_id] = array();
- }
- if (!isset($d[$r->document_id][$r->update])) {
- $d[$r->document_id][$r->update] = array();
- }
- if (!isset($d[$r->document_id][$r->update][$r->document_page])) {
- $d[$r->document_id][$r->update]['links'][$r->document_page] = json_decode($r->links);
- $d[$r->document_id][$r->update]['rulers'][$r->document_page] = json_encode($r->rulers);
- }
- }
-
- $c = $core->con->openCursor('document_links_versions');
- foreach ($d as $document_id => $updates) {
- $c->document_id = $document_id;
- foreach ($updates as $date => $dummy) {
- $c->update = $date;
- $c->links = json_encode($d[$document_id][$date]['links']);
- $c->rulers = json_encode($d[$document_id][$date]['rulers']);
- try {
- $c->insert();
- } catch (Exception $e) {
- // fb($e);
- }
- }
- }
- }
-
public static function importFromOldWS($args)
{
global $core;
$to = $args[1];
global $core;
- $dao = new wsDAODocument($core->con);
+ wsLinks::getLinksAndRulersFromFile($from, $fromlinks, $fromrulers);
- $dao->getLinksAndRulers($from, $fromlinks, $fromrulers);
if (!$eraseTo) {
- $dao->getLinksAndRulers($to, $tolinks, $torulers);
+ wsLinks::getLinksAndRulersFromFile($to, $tolinks, $torulers);
$tolinks = array_merge($tolinks, $fromlinks);
$torulers = array_merge($torulers, $fromrulers);
$cmd = "cp -r $wf1 $wt";
echo `$cmd`;
}
-
- $dao->setLinksAndRulers($to, $tolinks, $torulers, 'Copy links from #' . $from . ' to #' . $to, $core->user->utilisateur_id);
+ wsLinks::saveLinksInFile($to, $core->user->utilisateur_id, 'Copy links from #' . $from . ' to #' . $to, $tolinks, $torulers);
}
public static function importBooks($oldBooks)
$newid = $r->document_id + 1;
self::_duplicateLines('documents', 'document_id', $doc, $newid);
- self::_duplicateLines('document_links', 'document_id', $doc, $newid);
- self::_duplicateLines('document_links_versions', 'document_id', $doc, $newid);
$f = wsDocument::getDir($doc);
$t = WS_DOCS . '/' . $newid;
$dir = WS_BOOKS . '/working/' . $book_id;
- $dao = new wsDAODocument($core->con);
- $dao->getLinksAndRulers($book_id, $links, $rulers);
-
+ wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
foreach ($links as $link) {
if ($link['type'] != 4) {
continue;
$format = $args[1];
$dir = WS_BOOKS . '/working/' . $book_id;
- wsLinks::getLinksAndRulers($book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
foreach ($links as $link) {
if ($link['type'] != 4) {
{
global $core;
$book_id = $args[0];
- wsLinks::getLinksAndRulers($book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
$newlinks = array();
foreach ($links as $link) {
$newlinks[] = $link;
}
- $dao = new wsDAODocument($core->con);
- $dao->setLinksAndRulers($book_id, json_encode($newlinks), json_encode($rulers), 'Autobookmark links correction', $core->user->utilisateur_id);
+ wsLinks::saveLinksInFile($book_id, $core->user->utilisateur_id, 'Autobookmark links correction', $newlinks, $rulers);
}
public static function compress()
$book_id = $args[0];
$direction = $args[1];
$value = intval($args[2]);
- wsLinks::getLinksAndRulers($book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
if ($direction == 'y') {
$k = 'top';
$newlinks[] = $link;
}
- $dao = new wsDAODocument($core->con);
- $dao->setLinksAndRulers($book_id, json_encode($newlinks), json_encode($rulers), 'Offset links positions (' . $direction . ' :: ' . $value . ')', $core->user->utilisateur_id);
+ wsLinks::saveLinksInFile($book_id, $core->user->utilisateur_id, 'Offset links positions (' . $direction . ' :: ' . $value . ')', $newlinks, $rulers);
}
public static function duplicateBook($args)
public static function _reencodeVideos($book_id, $format)
{
- wsLinks::getLinksAndRulers($book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
foreach ($links as $l) {
if ($l['type'] == 10) {
$to = $l['to'];
$exporter->export($id, $x, 'install_hosting', 'online', "/airtahitiexport/" . $id, '');
}
}
-
- public static function moveLinksToFiles($args)
- {
- CubeIT_Util_PHP::neverStop();
-
- global $core;
-
- if (isset($args[0]) && $args[0]) {
- $books = [$args[0]];
- } else {
- $r = $core->con->select('SELECT * FROM books ORDER BY book_id DESC');
- $books = [];
- while ($r->fetch()) {
- $books[] = $r->book_id;
- }
- }
-
-
- foreach ($books as $id) {
- $dir = wsLinks::getLinksDir($id);
- /** @var $book wsBook */
- $dao = new wsDAODocument($core->con);
- $updates = $dao->getLinksVersions($id);
-
- $max = 0;
- foreach ($updates as $time => $update) {
- $max = max($max, $time);
- self::_writeLinks($id, $dir, $time, $update);
- }
- self::_writeLinks($id, $dir, $max, $updates[$max], 'latest');
- }
- }
-
- protected static function _writeLinks($book_id, $dir, $time, $data, $version = 'time')
- {
- if ($version === 'time') {
- $version = $time;
- }
-
- $file = $dir . '/' . $version . '.links.gz';
- $meta = $dir . '/' . $version . '.meta.gz';
- if (file_exists($file)) {
- return;
- }
-
- $links = [];
- $rulers = [];
-
- wsLinks::getLinksAndRulers($book_id, $links, $rulers, $time);
-
- $res = ['links' => $links, 'rulers' => $rulers];
- file_put_contents($file, gzencode(json_encode($res)));
- file_put_contents($meta, gzencode(json_encode($data)));
- }
}
public static function clients($args)
{
global $core;
+
cubePage::truePopup();
cubePage::autoComplete();
cubePage::emptyfield();
$admin = wsDroits::admin();
+
+
+
if ($admin) {
$liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], null, 'entreprises_ws');
} else {
$liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user, 'entreprises_ws');
}
+
$res = '<table class="liste">';
$res .= '<tr><th>' . commonUrl::orderby('#', 'entreprise_id', $settings, 'sort' . $change) . '</th>';
$res .= '<th>' . commonUrl::orderby(__('Raison sociale'), 'nom', $settings, 'sort' . $change) . '</th>';
}
$res .= '<th class="min"></th><th class="min"></th></tr>';
$i = 0;
+
foreach ($liste as $id => $client) {
if (!is_array($client->contacts)) {
$client->contacts = array();
$this->makeTextsIndexes($book, $pages, $index, $textes);
- $daoDoc->getLinksAndRulers($book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
$audiodescription = array();
{
// New way
wsLinks::addLinksFromPDF($book_id);
-
- // Old way
- $daoBook = new wsDAOBook($this->con);
- $pages = $daoBook->getPagesOfBook($book_id);
-
- foreach ($pages as $page => $infos) {
- $docs[] = $infos['document_id'];
- }
-
- $docs = array_unique($docs);
- foreach ($docs as $document_id) {
- $this->putLinksFromCSV($document_id);
- }
}
public function restoreLinksVersion($book_id, $update, $user = 0)
// New way
wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers, $update);
wsLinks::saveLinksInFile($book_id, $user, $comments, $links, $rulers, [], []);
-
- // OLD Way
- wsLinks::getLinksAndRulers($book_id, $links, $rulers, $update);
-
- $this->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), $comments, $user);
-
- $r = $this->con->select('SELECT * FROM special_links_versions WHERE `update`=' . $update . ' AND book_id=\'' . $this->con->escape($book_id) . '\'');
- if ($r->count()) {
- $daoBook = new wsDAOBook($this->con);
- $daoBook->setSpecialLinksAndRulers($book_id, $r->links, $r->rulers);
- }
- }
-
- public function putLinksFromCSV($document_id)
- {
- $log = array('Copie des liens du PDF vers la base de données');
- $document = $this->selectById($document_id);
-
- $booleans = array('video_loop', 'video_auto_start', 'video_controls', 'video_sound_on');
-
- $links = array();
-
- for ($page = 1; $page <= $document->generalInfos['pages']; $page++) {
- $links[$page] = array();
-
- $csv = wsDocument::getDir($document->document_id) . '/p' . $page . '.csv';
- if (!file_exists($csv) && file_exists($csv . '.gz')) {
- $csv = 'compress.zlib://' . $csv . '.gz';
- } elseif (!file_exists($csv)) {
- $log[] = 'Links file of page ' . $page . ' not found';
- continue;
- }
-
- $newformat = (filemtime($csv) > 1363685416);
-
- $log[] = 'Links file of page ' . $page . ' found';
-
- $fp = fopen($csv, 'rb');
-
- while (true) {
- $line = fgetcsv($fp, 512, ';', '"');
- // End of file
- if (!$line) {
- break;
- }
- // Commentaire || ligne vide
- if (substr($line[0], 0, 1) == '#' || is_null($line[0])) {
- continue;
- }
- $link = array();
- if ($newformat) {
- $cols = array('page' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'type' => '', 'to' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical');
- } else {
- $cols = array('page' => '', 'type' => '', 'to' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical');
- }
- $k = 0;
- foreach ($cols as $col => $default) {
- if (isset($line[$k])) {
- if (in_array($k, $booleans)) {
- $link[$col] = ($line[$k] == '1');
- } else {
- $link[$col] = utf8_encode($line[$k]);
- }
- } else {
- $link[$col] = $default;
- }
- $k++;
- }
- $link['page'] = $page;
- $links[$page][] = $link;
- }
-
- $log[] = 'Added ' . count($links) . ' links';
- }
-
- wsLinks::setDocumentLinks($document_id, json_encode($links), json_encode(array()), 0, 'Links imported from PDF', TIME);
-
-
- return implode("\n", $log);
- }
-
- public function setLinksAndRulers($book_id, $links, $rulers, $comments = '', $user = 0, $handleSpecials = true)
- {
- $daoBook = new wsDAOBook($this->con);
- $pages = $daoBook->getPagesOfBook($book_id, false);
-
- if (is_array($links)) {
- $links = json_encode($links);
- }
- if (is_array($rulers)) {
- $rulers = json_encode($rulers);
- }
- $links = json_decode($links, false);
- $rulers = json_decode($rulers, false);
-
- $links = wsLinks::encryptLinks($links);
-
- $t = array();
-
- foreach ($links as $link) {
- if (!isset($t[$link->page])) {
- $t[$link->page] = array('links' => array(), 'rulers' => array());
- }
- $link->to = trim($link->to);
- $t[$link->page]['links'][] = $link;
- }
- foreach ($rulers as $ruler) {
- if (!isset($t[$ruler->page])) {
- $t[$ruler->page] = array('links' => array(), 'rulers' => array());
- }
- $t[$ruler->page]['rulers'][] = $ruler;
- }
-
- $links = array();
- $rulers = array();
-
- foreach ($pages as $p) {
- if (!isset($links[$p['document_id']])) {
- $links[$p['document_id']] = array();
- $rulers[$p['document_id']] = array();
- }
-
- if (!isset($links[$p['document_id']][$p['document_page']])) {
- $links[$p['document_id']][$p['document_page']] = array();
- $rulers[$p['document_id']][$p['document_page']] = array();
- }
- }
-
- $specialLinks = array();
- $specialRulers = array();
-
- foreach ($t as $page => $tt) {
- if (!is_int($page) && $handleSpecials) {
- if (isset($tt['links'])) {
- $specialLinks = array_merge($specialLinks, $tt['links']);
- }
- if (isset($tt['rulers'])) {
- $specialRulers = array_merge($specialRulers, $tt['rulers']);
- }
- continue;
- }
-
- if (!isset($pages[$page])) {
- continue;
- }
-
- $infos = $pages[$page];
- $doc_id = $infos['document_id'];
- $doc_page = $infos['document_page'];
-
- if (!isset($links[$doc_id])) {
- $links[$doc_id] = array();
- $rulers[$doc_id] = array();
- }
- if (!isset($links[$doc_id][$doc_page])) {
- $links[$doc_id][$doc_page] = array();
- $rulers[$doc_id][$doc_page] = array();
- }
-
- foreach ($tt['links'] as $link) {
- $link->to = trim($link->to);
- $links[$doc_id][$doc_page][] = $link;
- }
-
- foreach ($tt['rulers'] as $ruler) {
- $rulers[$doc_id][$doc_page][] = $ruler;
- }
- }
-
- foreach ($links as $document_id => $dummy) {
- wsLinks::setDocumentLinks($document_id, json_encode($links[$document_id]), json_encode($rulers[$document_id]), $user, $comments, TIME);
- }
- if ($handleSpecials) {
- $daoBook->setSpecialLinksAndRulers($book_id, $specialLinks, $specialRulers);
- }
-
- $c = $this->con->openCursor('books');
- $c->changedate = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function copyLinks($from, $to)
- {
- $sql = 'REPLACE INTO document_links_versions (`document_id`,`links`,`rulers`,`update`) '
- . 'SELECT \'' . $to . '\',`links`,`rulers`,`update` FROM document_links_versions WHERE document_id=\'' . $from . '\'';
-
- $this->con->execute($sql);
- }
-
- public function setLinksFromOldFluidbook($book_id)
- {
- $daoBook = new wsDAOBook($this->con);
- $pages = $daoBook->getPagesOfBook($book_id);
-
- $book = $daoBook->selectById($book_id);
- $width = $book->parametres->width;
-
- $xml = simplexml_load_file('https://ws.fluidbook.com/books/' . $book_id . '/data/links.xml');
- echo $xml;
- $links = $xml->xpath('//oneLink');
-
- $res = array();
- $lpages = array();
- foreach ($links as $l) {
- if ((string)$l->page == '') {
- continue;
- }
-
- $left = floatval((string)$l->startX);
- $right = floatval((string)$l->endX);
- $top = floatval((string)$l->startY);
- $bottom = floatval((string)$l->endY);
-
- $lwidth = abs($right - $left);
- $lheight = abs($bottom - $top);
-
- $left = min($left, $right);
- $top = min($top, $bottom);
-
- $link = array();
- $link['page'] = (string)$l->page;
- $link['numerotation'] = false;
- $link['left'] = $left;
- $link['width'] = $lwidth;
- if ($link['left'] > $width) {
- $link['page']++;
- $link['left'] -= $width;
- }
- $page = $link['page'];
- $link['top'] = $top;
- $link['height'] = $lheight;
- $link['infobulle'] = '';
- $link['target'] = '_blank';
- $link['to'] = (string)$l->linkTo;
- $link['type'] = intval((string)$l->linkType);
- $link['video_loop'] = ((string)$l->loopFlag == '1');
- $link['video_auto_start'] = true;
- $link['video_controls'] = ((string)$l->playerActive == '1');
- $link['video_sound_on'] = ((string)$l->soundOn == '1');
-
- $dir = WS_BOOKS . '/working/' . $book_id . '/';
-
- if ($link['type'] == '4' || $link['type'] == '6') {
- if (!stristr($link['to'], ':/')) {
- if (!file_exists($dir)) {
- mkdir($dir, 0755, true);
- }
- copy('https://ws.fluidbook.com/books/' . $book_id . '/data/' . $link['to'], $dir . '/' . $link['to']);
- }
- }
-
- if (!isset($lpages[$page])) {
- $lpages[$page] = array();
- }
- $lpages[$page][] = $link;
- }
-
-
- $links = array();
- foreach ($pages as $p => $infos) {
- if (!isset($links[$infos['document_id']])) {
- $links[$infos['document_id']] = array();
- }
- if (isset($lpages[$p])) {
- $links[$infos['document_id']][$infos['document_page']] = $lpages[$p];
- }
- }
-
- krsort($links);
-
- foreach ($links as $document_id => $l) {
- wsLinks::setDocumentLinks($document_id, json_encode($l), json_encode(array()), 0, 'Import from Fluidbook V1', TIME);
- }
-
- $c = $this->con->openCursor('books');
- $c->changedate = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function getLinksAndRulers($book_id, &$links, &$rulers, $time = null)
- {
- return wsLinks::getLinksAndRulers($book_id, $links, $rulers, $time);
- }
-
- public function getLinksAndRulersFromFile($book_id, &$links, &$rulers, $time = 'latest')
- {
- return wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers, $time);
- }
-
- public function getLinksVersions($book_id)
- {
-
- $r = $this->con->select('SELECT * FROM special_links_versions WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- $specials = ['links' => 0, 'rulers' => 0];
- while ($r->fetch()) {
- $ll = json_decode($r->links);
- $lr = json_decode($r->rulers);
- $specials[$r->update] = ['links' => count($ll), 'rulers' => count($lr)];
- }
-
- // Get composition versions
- $r = $this->con->select('SELECT * FROM book_pages_versions WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- $docs = [];
- while ($r->fetch()) {
- $c = unserialize($r->composition);
- foreach ($c as $infos) {
- $docs[] = $infos['document_id'];
- }
- }
-
- if (!$docs) {
- return [];
- }
-
- $res = array();
- $sql = 'SELECT * FROM document_links_versions WHERE document_id IN(' . implode(',', $docs) . ')';
- $r = $this->con->select($sql);
-
- while ($r->fetch()) {
- if (!isset($res[$r->update])) {
- if (isset($specials[$r->update])) {
- $res[$r->update] = $specials[$r->update];
- } else {
- $res[$r->update] = array('links' => 0, 'rulers' => 0);
- }
- }
-
- $ll = json_decode($r->links);
- foreach ($ll as $lll) {
- $res[$r->update]['links'] += count($lll);
- }
- $rr = json_decode($r->rulers);
- foreach ($rr as $rrr) {
- $res[$r->update]['rulers'] += count($rrr);
- }
- $res[$r->update]['comments'] = $r->comments;
- $res[$r->update]['user'] = $r->user;
- }
-
- return $res;
}
public function getNextId()
return false;
}
- public static function setDocumentLinks($document_id, $links, $rulers, $user, $comments, $time)
- {
- global $core;
- $c = $core->con->openCursor('document_links_versions');
- $c1 = $core->con->openCursor('document_links');
- $c1->document_id = $c->document_id = $document_id;
- $c1->links = $c->links = $links;
- $c1->rulers = $c->rulers = $rulers;
- $c->comments = $comments;
- $c->user = $user;
- $c->update = $time;
- $c->insert();
-
- $core->con->execute('DELETE FROM document_links WHERE document_id=' . $document_id);
- $c1->insert();
- }
-
- public static function getDocumentLastLinks($document_id)
- {
- global $core;
-
- $r = $core->con->select('SELECT * FROM document_links WHERE document_id=\'' . $document_id . '\'');
- if (!$r->count()) {
- $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $document_id . ' ORDER BY `update` DESC LIMIT 1');
- $c = $core->con->openCursor('document_links');
- $c->document_id = $document_id;
- $c->links = $r->links;
- $c->rulers = $r->rulers;
- try {
- $c->insert();
- } catch (Exception $e) {
- fb($e);
- }
- }
-
- return self::_recordToLinks($r);
- }
-
- public static function getDocumentVersionLinks($document_id, $time)
- {
- global $core;
- $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $document_id . ' AND `update`<=' . $time . ' ORDER BY `update` DESC LIMIT 1');
- return self::_recordToLinks($r);
- }
-
- protected static function _recordToLinks($r)
- {
- if (mb_substr($r->links, 1, 1) == ':') {
- $ll = unserialize($r->links);
- $rr = unserialize($r->rulers);
- } else {
- $ll = json_decode($r->links, true);
- $rr = json_decode($r->rulers, true);
- }
-
- return array('links' => $ll, 'rulers' => $rr);
- }
-
public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = null)
{
- global $core;
-
- $daoBook = new wsDAOBook($core->con);
- $pages = $daoBook->getPagesOfBookAt($book_id, $time);
-
- $documents = [];
- foreach ($pages as $p => $infos) {
- $documents[] = $infos['document_id'];
- }
- $documents = array_unique($documents);
-
- $tlinks = array();
- $trulers = array();
-
- $links = array();
- $rulers = array();
-
- foreach ($documents as $d) {
- if (is_null($time)) {
- $lr = self::getDocumentLastLinks($d);
- } else {
- $lr = self::getDocumentVersionLinks($d, $time);
- }
- $tlinks[$d] = $lr['links'];
- $trulers[$d] = $lr['rulers'];
- }
-
- $i = 1;
- foreach ($pages as $p => $infos) {
- if (isset($tlinks[$infos['document_id']][$infos['document_page']])) {
- $l = $tlinks[$infos['document_id']][$infos['document_page']];
- foreach ($l as $link) {
- $link = (array)$link;
- $link['page'] = $p;
- $link['id'] = $i;
- if (!isset($link['rot'])) {
- $link['rot'] = 0;
- }
- $links[] = $link;
- $i++;
- }
- }
- if (isset($trulers[$infos['document_id']][$infos['document_page']])) {
- $ru = $trulers[$infos['document_id']][$infos['document_page']];
- if (is_array($ru)) {
- foreach ($ru as $ruler) {
- $ruler['page'] = $p;
- $rulers[] = $ruler;
- }
- }
- }
-
- }
-
- $daoBook = new wsDAOBook($core->con);
- $book = $daoBook->selectById($book_id);
-
- $rulers = array_merge($rulers, $book->specialRulers);
- $links = array_merge($links, $book->specialLinks);
+ return self::getLinksAndRulersFromFile($book_id,$links,$rulers,$time);
}
public static function getLinksAndRulersFromFile($book_id, &$links, &$rulers, $time = 'latest')
$this->vdir->copyDirectory($d['dir'], $d['fdir']);
}
- $daoDoc = new wsDAODocument($core->con);
- $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($this->book_id, $links, $rulers);
// Custom landing page content
if ($this->book->parametres->landingPage != '') {
return $res;
}
- public function addFontKit($font){
- $this->vdir->copyDirectory('style/fonts/Montserrat');
+ public function addFontKit($font)
+ {
+ $path = 'style/fonts/Montserrat';
+ $this->stylesheets[] = $path . '/font.css';
+ $this->vdir->copyDirectory($this->assets . '/' . $path, $path);
}
public function writeArticles()
return;
}
- if($this->book->parametres->articlesFont!=='OpenSans'){
+ if ($this->book->parametres->articlesFont !== 'OpenSans') {
$this->addFontKit($this->book->parametres->articlesFont);
}
$this->vdir->copyDirectory($d['dir'], $d['fdir']);
}
- $daoDoc = new wsDAODocument($core->con);
- $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($this->book_id, $links, $rulers);
// Custom landing page content
if ($this->book->parametres->landingPage != '') {
</oneLink> */
$xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><links><oneLink /></links>');
- $daoDoc = new wsDAODocument($core->con);
- $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);
+ wsLinks::getLinksAndRulersFromFile($this->book_id, $links, $rulers);
foreach ($links as $link) {
$one = $xml->addChild('oneLink');