}
move_uploaded_file($infos['tmp_name'], $dest);
- $api = new ws3API();
- $api->uploadThemeField($this->args['theme_id'], $this->args['fieldname'], $dest);
+ try {
+ $api = new ws3API();
+ $api->uploadThemeFile($this->args['theme_id'], $this->args['fieldname'], $dest);
+ }catch (Exception $e){
+
+ }
if (isset($this->args['type']) && $this->args['type'] == 'favicon') {
$icotool = new cubeCommandLine('icotool');
{
global $core;
$dao = new wsDAOTheme($core->con);
-
$theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id);
+
$this->xml->addChild('theme_id', $theme->theme_id);
if (isset($this->args['book_id'])) {
$dao = new wsDAOBook($core->con);
$dao->setTheme($this->args['book_id'], $this->args['theme']);
}
- public function postThemeShot()
- {
- file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data']));
- }
-
public function getAllIcones()
{
global $core;
return;
}
- $this->_compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+ $lockId = $book_id;
+ if ($forceTheme) {
+ $lockId .= '-' . wsTheme::hashThemeArray($forceTheme);
+ }
+
+ $this->_compileLock = WS_BOOKS . '/locks/' . $lockId . '.lock';
while (file_exists($this->_compileLock) && filemtime($this->_compileLock) > (time() - 900)) {
return wsBook::getAssetDirOfBook($book_id, $dir) . $path;
}
- public function compileHTML5($book_id, $book, $dev = false, $delete = true,$forceTheme=false)
+ public function compileHTML5($book_id, $book, $dev = false, $delete = true, $forceTheme = false)
{
$version = $book->parametres->mobileLVersion;
if ($dev) {
$version = 'dev';
}
- $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book,$forceTheme);
+ $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book, $forceTheme);
$htmlCompiler->compile($delete);
self::$lastHTML5Compiler = $htmlCompiler;
return $theme;\r
}\r
\r
- protected function _table($table)\r
+ protected function _table($table, $force_table = false)\r
{\r
+ if ($force_table) {\r
+ return $table;\r
+ }\r
+\r
global $core;\r
\r
- if (false && $core->user->utilisateur_id == 5) {\r
- if ($table === 'themes_vue') {\r
- return 'ws3_theme_vue';\r
- } else if ($table === 'themes') {\r
- return 'ws3_theme';\r
- }\r
- } else {\r
- return $table;\r
+ //if (is_object($core->user) && $core->user->utilisateur_id == 5) {\r
+ if ($table === 'themes_vue') {\r
+ return 'ws3_theme_vue';\r
+ } else if ($table === 'themes') {\r
+ return 'ws3_theme';\r
}\r
+ //} else {\r
+ // return $table;\r
+ //}\r
}\r
\r
- public function selectById($theme_id, $table = 'themes_vue')\r
+ public function selectById($theme_id, $table = 'themes_vue', $force_table = false)\r
{\r
- $r = $this->con->select('SELECT * FROM ' . $this->_table($table) . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
+ $r = $this->con->select('SELECT * FROM ' . $this->_table($table, $force_table) . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
return $this->singleton($r);\r
}\r
\r
if (file_exists(WS_THEMES . '/' . $data['theme_id'] . '.jpg')) {\r
unlink(WS_THEMES . '/' . $data['theme_id'] . '.jpg');\r
}\r
+ if (file_exists(WS_FILES . '/themes3/' . $data['theme_id'] . '.jpg')) {\r
+ unlink(WS_FILES . '/themes3/' . $data['theme_id'] . '.jpg');\r
+ }\r
\r
$api = new ws3API();\r
- $api->updateTheme($this->selectById($data['theme_id']));\r
+ $api->updateTheme($this->selectById($data['theme_id'], 'themes_vue', true));\r
}\r
\r
protected function getNextId()\r
$c->nom = $newname;\r
$c->update('WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
\r
- $theme = $this->selectById($theme_id);\r
+ $theme = $this->selectById($theme_id, 'themes_vue', true);\r
$theme->nom = $newname;\r
$api = new ws3API();\r
$api->updateTheme($theme);\r
if (is_null($theme_id) || $theme_id == '') {\r
return;\r
}\r
+\r
+ $nextID = $this->getNextId();\r
+ echo $nextID;\r
$theme = $this->selectById($theme_id);\r
// Copie des données\r
$c = $this->con->openCursor('themes');\r
- $c->theme_id = $this->getNextId();\r
+ $c->theme_id = $nextID;\r
$c->nom = $theme->nom . ' (copy)';\r
$c->parametres = serialize($theme->parametres);\r
$c->signature = $theme->signature;\r
$c->date = TIME;\r
$c->insert();\r
\r
- $this->delete($c->theme_id, true);\r
+ $this->delete($nextID, true);\r
// Copie des fichiers\r
$from = WS_THEMES . '/' . $theme_id;\r
- $to = WS_THEMES . '/' . $c->theme_id;\r
- $dr = opendir($from);\r
+ $to = WS_THEMES . '/' . $nextID;\r
if (!file_exists($to)) {\r
mkdir($to, 0777, true);\r
} else {\r
files::deltree($to);\r
mkdir($to, 0777, true);\r
- } //.\r
- while ($file = readdir($dr)) {\r
- if ($file == '.' || $file == '..') {\r
- continue;\r
- }\r
- copy($from . '/' . $file, $to . '/' . $file);\r
- }\r
+ } //\r
+ `cp -r $from/* $to`;\r
if (file_exists($from . '.jpg')) {\r
copy($from . '.jpg', $to . '.jpg');\r
}\r
+ $thumb = '/data1/extranet/toolbox/storage/themes/';\r
+ if (file_exists($thumb . $theme_id . '.jpg')) {\r
+ copy($thumb . $theme_id . '.jpg', $thumb . $nextID . '.jpg');\r
+ }\r
\r
-\r
- $theme = $this->selectById($c->theme_id);\r
try {\r
+ $theme = $this->selectById($nextID, 'themes_vue', true);\r
$api = new ws3API();\r
$api->createTheme($theme);\r
} catch (Exception $e) {\r
exit;\r
}\r
\r
- return $theme;\r
+ return $this->selectById($c->theme_id);\r
}\r
\r
}
\ No newline at end of file