}
$dao = new wsDAODocument($core->con);
+ $daoBook = new wsDAOBook($core->con);
+ $book = $daoBook->selectById($this->args['book_id']);
$documents = [];
foreach ($_FILES as $varname => $infos) {
if ($infos['error']) {
}
// Initialisation du document
$data = array();
+ $data['region'] = $book->region;
$data['proprietaire'] = $core->user->utilisateur_id;
$data['pages'] = 0;
$data['version'] = 2;
}
}
+ public function testDocuments()
+ {
+ global $core;
+
+ $toload = $this->xml->addChild('toLoad');
+ $alreadyLoaded = $this->xml->addChild('alreadyLoaded');
+
+ $hash = array();
+
+ foreach ($this->args['fileName'] as $k => $name) {
+ $o = new wsDocumentLocalInfos();
+ $o->fileName = $name;
+ $o->fileSize = intval($this->args['fileSize'][$k]);
+ $o->modificationDate = intval($this->args['modificationDate'][$k]);
+ $o->creationDate = intval($this->args['creationDate'][$k]);
+
+ $hash[$k] = md5(serialize($o));
+ }
+
+ $in = array();
+ foreach ($hash as $h) {
+ $in[] = "'" . $h . "'";
+ }
+
+ $sql = 'SELECT document_id,localHash FROM documents WHERE localHash';
+ if (count($in) == 1) {
+ $sql .= ' = ' . implode(',', $in);
+ } else {
+ $sql .= ' IN (' . implode(',', $in) . ')';
+ }
+
+ $al = array();
+ $r = $core->con->select($sql);
+ while ($r->fetch()) {
+ $k = array_search($r->localHash, $hash);
+
+ if (!file_exists(wsDocument::getDir($r->document_id) . 'crop.pdf')) {
+ continue;
+ }
+
+ $al[$k] = true;
+ $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]);
+ $f->addAttribute('document_id', $r->document_id);
+ }
+
+ foreach ($this->args['fileName'] as $k => $name) {
+ if (!isset($al[$k])) {
+ $toload->addChild('file', $name);
+ }
+ }
+ }
+
+
public function getPagesOfBook()
{
global $core;
global $core;
$dao = new wsDAOBook($core->con);
- // $log = $dao->compile($this->args['book_id'], '2');
+ // $log = $dao->compile($this->args['book_id'], '2');
$book = $dao->selectById($this->args['book_id']);
$viewer = 'viewer';
wsMaintenance::timeoutRequest('https://workshop.fluidbook.com/maintenance/processBookPages/' . $book_id, 1);\r
}\r
\r
- public static function getRegionDir($id)\r
+ public static function getRegionDir($id, $root = true)\r
{\r
if (!isset(self::$_bookDirs[$id])) {\r
self::$_bookDirs[$id] = self::_getRegion($id);\r
}\r
- return (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/';\r
+ if ($root) {\r
+ return (self::$_bookDirs[$id] === 'UE' ? WS_FILES : US_FILES) . '/';\r
+ } else {\r
+ return (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/';\r
+ }\r
}\r
\r
\r
public static function getDir($id, $dir, $addSlash = true, $onlyroot = false)\r
{\r
- $res = self::getRegionDir($id);\r
+ $res = self::getRegionDir($id,false);\r
$res .= $dir . '/';\r
if (!$onlyroot) {\r
$res .= $id . '/';\r
}
- $res = $this->getRelativeBase();
+ $res .= $this->getRelativeBase();
if ($ext != '') {
$res .= '.' . $ext;
}
protected function getPathBase($ext = '')
{
- $base=wsBook::getRegionDir($this->book_id);
+ $base = wsBook::getRegionDir($this->book_id,true);
if (!file_exists($base . '/packager/download')) {
mkdir($base . '/packager/download', 0777, true);
}
if ($ext != '') {
$res .= '.' . $ext;
}
-
return $res;
}