$db->books->chapters('text', 0, false);\r
$db->books->links('text', 0, false);\r
$db->books->rulers('text', 0, false);\r
- $db->books->extras('text',0,false);\r
+ $db->books->extras('text', 0, false);\r
+ $db->books->traductions('text', 0, false);\r
$db->books->date('integer', 0, false);\r
// Clés\r
$db->books->primary('pk_books', 'book_id');\r
. 'FROM themes t '\r
. 'LEFT JOIN books b ON t.theme_id=b.theme '\r
. 'GROUP BY t.theme_id');\r
- //cubeDb::mysqlConvert($this->con);\r
+ // cubeDb::mysqlConvert($this->con);\r
touch($cache);\r
}\r
\r
}\r
}\r
\r
+ public function saveSettings()\r
+ {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setSettings($this->args['book_id'], $this->args['settings']);\r
+ }\r
+\r
public function setChapters()\r
{\r
global $core;\r
$this->xml->addChild('infos', $res);\r
}\r
\r
- public function getLangs($book_id = null)\r
+ public function getLangs()\r
{\r
global $core;\r
\r
if (isset($this->args['book_id'])) {\r
$dao = new wsDAOBook($core->con);\r
$book = $dao->selectById($this->args['book_id']);\r
+ if ($book->traductions != array()) {\r
+ $bookLang = $this->xml->addChild('book_lang', json_encode($book->traductions));\r
+ }\r
}\r
\r
$dao = new wsDAOLang($core->con);\r
$l->addAttribute('nom', $lang->nom);\r
$l->addAttribute('embeded', $lang->embeded);\r
$l->addAttribute('public', $lang->public);\r
- $l->addAttribute('selected', (isset($book) && $book->lang == $lang->lang_id)?'1':'0');\r
+ if ((isset($book) && $book->lang == $lang->lang_id)) {\r
+ $l->addAttribute('selected', '1');\r
+ $bookLang->addAttribute('id', $lang->lang_id);\r
+ $bookLang->addAttribute('nom', $lang->nom . ' (' . __('modifié') . ')');\r
+ $bookLang->addAttribute('embeded', $lang->embeded);\r
+ $bookLang->addAttribute('public', $lang->public);\r
+ }\r
}\r
}\r
+\r
+ public function saveLang()\r
+ {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setLang($this->args['book_id'], $this->args['lang_id'], $this->args['traductions']);\r
+ }\r
}\r
\r
?>
\ No newline at end of file
$book->rulers = json_decode($r->rulers, false);\r
}\r
\r
+ if ($r->traductions == '') {\r
+ $book->traductions = array();\r
+ } else {\r
+ $book->traductions = json_decode($r->traductions);\r
+ }\r
+\r
$p = unserialize($r->parametres);\r
if (!$p || $p->isEmpty()) {\r
$p = new wsBookParametres($book);\r
$book = new wsBook();\r
$book->book_id = 'new';\r
$book->nom = '';\r
- $book->lang ='fr';\r
+ $book->lang = 'fr';\r
$book->theme = 1;\r
$book->proprietaire = '';\r
$book->proprietaire_id = 0;\r
return $this->selectById($book_id);\r
}\r
\r
- public function creeEmpty($createur,$lang)\r
+ public function creeEmpty($createur, $lang)\r
{\r
$c = $this->con->openCursor('books');\r
$c->proprietaire = $createur;\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
\r
+ public function setLang($book_id, $base, $traductions)\r
+ {\r
+ $c = $this->con->openCursor('books');\r
+ $c->lang = $base;\r
+ $c->traductions = json_encode(json_decode($traductions, false));\r
+ $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+ }\r
+\r
+ public function setSettings($book_id, $settings)\r
+ {\r
+ $book = $this->selectById($book_id);\r
+ $parametres = $book->parametres;\r
+ $new = json_decode($settings, false);\r
+ fb($new);\r
+ foreach($new as $k => $v) {\r
+ $parametres->$k = $v;\r
+ }\r
+ $c = $this->con->openCursor('books');\r
+ $c->parametres = serialize($parametres);\r
+ $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+ fb($parametres);\r
+ }\r
+\r
public function getLinksFromCSV($book_id)\r
{\r
$booleans = array('video_loop', 'video_auto_start', 'video_controls', 'video_sound_on');\r
protected $links;\r
protected $rulers;\r
protected $extras;\r
+ protected $traductions;\r
}\r
\r
?>
\ No newline at end of file
$this->datas = array();\r
}\r
\r
- public function isEmpty(){\r
- return count($this->datas)==0;\r
+ public function isEmpty()\r
+ {\r
+ return count($this->datas) == 0;\r
}\r
\r
public function setParent($parent)\r
\r
switch ($this->fields[$varname]['type']) {\r
case 'integer':\r
- $value = intval($value);\r
+ if (!is_int($value)) {\r
+ $value = intval($value);\r
+ }\r
break;\r
case 'float':\r
- $value = floatval($value);\r
+ if (!is_float($value)) {\r
+ $value = floatval($value);\r
+ }\r
break;\r
case 'boolean':\r
- $value = ($value == '' || $value == '0' || $value == 'false')?false:true;\r
+ if (!is_bool($value)) {\r
+ $value = ($value == '' || $value == '0' || $value == 'false')?false:true;\r
+ }\r
break;\r
case 'color':\r
case 'couleur':\r
$value = cubeMath::fill($value, 6);\r
break;\r
case 'date':\r
- $value = intval($value);\r
+ if (!is_int($value)) {\r
+ $value = intval($value);\r
+ }\r
break;\r
default:\r
$value = (string)$value;\r