try {
$api = new ws3API();
$api->uploadThemeFile($this->args['theme_id'], $this->args['fieldname'], $dest);
- }catch (Exception $e){
+ } catch (Exception $e) {
}
$readOnly = array(1);
$dao = new wsDAOTheme($core->con);
- $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',' . implode(',', $demos) . ') DESC, theme_id DESC', $demos,$this->xml);
+ $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',' . implode(',', $demos) . ') DESC, theme_id DESC', $demos, $this->xml);
foreach ($themes as $theme) {
$t = $this->xml->addChild('theme');
$t->addAttribute('id', $theme->theme_id);
public function renameTheme()
{
global $core;
-
$dao = new wsDAOTheme($core->con);
$dao->rename($this->args['theme_id'], $this->args['text']);
+
}
public function duplicateTheme()
}\r
$c->parametres = serialize($p);\r
$c->update('WHERE theme_id=\'' . $this->con->escape($data['theme_id']) . '\'');\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'], 'themes_vue', true));\r
return $r->theme_id + 1;\r
}\r
\r
- public function delete($theme_id, $onlyFiles = false)\r
+ public function delete($theme_id)\r
{\r
if (is_null($theme_id) || $theme_id == '') {\r
return;\r
}\r
- if (!$onlyFiles) {\r
- $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
- $api = new ws3API();\r
- $api->deleteTheme($theme_id);\r
- }\r
- $fref = WS_THEMES . '/' . $theme_id;\r
- if (file_exists($fref)) {\r
- files::deltree($fref);\r
- }\r
- if (file_exists($fref . '.jpg')) {\r
- unlink($fref . '.jpg');\r
- }\r
+\r
+ $api = new ws3API();\r
+ $api->deleteTheme($theme_id);\r
}\r
\r
public function rename($theme_id, $newname)\r
{\r
- $c = $this->con->openCursor('themes');\r
- $c->nom = $newname;\r
- $c->update('WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
-\r
- $theme = $this->selectById($theme_id, 'themes_vue', true);\r
- $theme->nom = $newname;\r
$api = new ws3API();\r
- $api->updateTheme($theme);\r
+ $api->renameTheme($theme_id, $newname);\r
}\r
\r
public function duplicate($theme_id, $proprietaire)\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 = $nextID;\r
- $c->nom = $theme->nom . ' (copy)';\r
- $c->parametres = serialize($theme->parametres);\r
- $c->signature = $theme->signature;\r
- $c->icones = $theme->icones;\r
- $c->proprietaire = $proprietaire;\r
- $c->date = TIME;\r
- $c->insert();\r
-\r
- $this->delete($nextID, true);\r
- // Copie des fichiers\r
- $from = WS_THEMES . '/' . $theme_id;\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
- `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
- try {\r
- $theme = $this->selectById($nextID, 'themes_vue', true);\r
- $api = new ws3API();\r
- $api->createTheme($theme);\r
- } catch (Exception $e) {\r
- print_r($e);\r
- exit;\r
- }\r
+ $api = new ws3API();\r
+ $newId = ws3API::getResponseBody($api->cloneTheme($theme_id));\r
\r
- return $this->selectById($c->theme_id);\r
+ return $this->selectById($newId);\r
}\r
\r
}
\ No newline at end of file
return $this->restPost('/api/fluidbook-theme', ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]);\r
}\r
\r
+ public function renameTheme($theme_id, $newname)\r
+ {\r
+ global $core;\r
+ return $this->restPut('/api/fluidbook-theme/' . $theme_id . '/rename', ['api_token' => $core->user->api_token, 'newname' => $newname]);\r
+ }\r
+\r
+ public function cloneTheme($theme_id)\r
+ {\r
+ global $core;\r
+ return $this->restPost('/api/fluidbook-theme/' . $theme_id . '/clone', ['api_token' => $core->user->api_token]);\r
+ }\r
+\r
public function updateTheme($theme)\r
{\r
global $core;\r
return $data;\r
}\r
\r
+ public static function getResponseBody(Zend_Http_Response $response)\r
+ {\r
+ return $response->getBody();\r
+ }\r
+\r
}
\ No newline at end of file