\r
}\r
\r
-}\r
+ public static function hasRightsOnBook($book_id)\r
+ {\r
+ global $core;\r
+ if (self::admin()) {\r
+ return true;\r
+ }\r
+ $daoBook = new wsDAOBook($core->con);\r
+ $books = $daoBook->getListe(null, null, null, true);\r
+ foreach ($books as $book) {\r
+ if ($book->book_id == $book_id) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
\r
-?>
\ No newline at end of file
+}
\ No newline at end of file
}
$daoBook->setComposition($book_id, $pages, false);
}
+
+ public static function downloadWorkingFiles($args)
+ {
+ global $core;
+
+ $book_id = $args[0];
+
+ if (!wsDroits::hasRightsOnBook($book_id)) {
+ echo ':(';
+ return;
+ }
+
+ $tmp = CubeIT_Files::tempnam() . ".zip";
+ CubeIT_Util_Zip::archive(WS_BOOKS . '/working/' . $book_id, $tmp);
+ header('Content-Type: application/zip');
+ header('Content-Disposition: attachment; filename="working_' . $book_id . '.zip"');
+ header('Content-Length: ' . filesize($tmp));
+ ob_end_clean();
+ readfile($tmp);
+ unlink($tmp);
+ exit;
+ }
}
return $res;\r
}\r
\r
+ public static function excelToArrayKeyVars($excelFile)\r
+ {\r
+ $worksheets = self::excelToArray($excelFile);\r
+ $res = [];\r
+ foreach ($worksheets as $worksheet) {\r
+\r
+ foreach ($worksheet as $i => $line) {\r
+ if ($i === 0) {\r
+ $vars = [];\r
+ foreach ($line as $j => $varname) {\r
+ if ($j === 0) {\r
+ continue;\r
+ }\r
+ $vars[$j] = $varname;\r
+ }\r
+ } else {\r
+ $r = [];\r
+ foreach ($vars as $j => $varname) {\r
+ $r[$varname] = trim($line[$j]);\r
+ }\r
+ $res[trim($line[0])] = $r;\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ return $res;\r
+ }\r
+\r
public static function excelToArrayKeyValMulti($excelFile)\r
{\r
$worksheets = self::excelToArray($excelFile);\r
if (!$this->book->parametres->tagcommander_prod) {
$id .= '/uat';
}
- $this->book->parametres->googleAnalyticsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Head.js"></script>';
+
+ $default = ['page_name' => '', 'page_cat1_name' => '', 'page_cat2_name' => '', 'page_cat3_name' => ''];
+ $this->config->tagcommander_default_vars = array_merge($default, $this->parseVariables($this->book->parametres->tagcommander_default_vars));
+ $this->config->tagcommander_default_vars['env_work'] = $this->book->parametres->tagcommander_prod ? 'prod' : 'pre-prod';
+
+ $this->book->parametres->googleAnalyticsCustom .= '<script>window.tc_vars=' . json_encode($this->config->tagcommander_default_vars) . ';</script><script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Head.js"></script>';
$this->book->parametres->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Analytics.js"></script>';
$this->book->parametres->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Medias.js"></script>';
+
+
+ if ($this->book->parametres->tagcommander_plan) {
+ $plan = wsUtil::excelToArrayKeyVars($this->wdir . '/' . $this->book->parametres->tagcommander_plan);
+ $fixedplan = [];
+ foreach ($plan as $k => $v) {
+ $e = explode('#', $k);
+ if (count($e) === 2) {
+ $k = $e[1];
+ }
+
+ $fixedplan[trim($k, '#/')] = $v;
+ }
+ $this->config->tagcommander_plan = $fixedplan;
+ }
}
}
}
$this->vdir->file_put_contents('imsmanifest.xml', $manifest);
+
+ $this->config->scorm_variables = $this->book->parametres->scorm_variables = $this->parseVariables($this->book->parametres->scorm_variables);
+ if ($this->book->parametres->scorm_quizdata) {
+ $this->config->scorm_quizdata = wsUtil::excelToArray($this->wdir . '/' . $this->book->parametres->scorm_quizdata);
+ }
+ }
+
+ protected function parseVariables($f)
+ {
$variables = [];
- $e = CubeIT_Text::explodeNewLines($this->book->parametres->scorm_variables);
+ $f = str_replace("\r", "\n", $f);
+ $e = CubeIT_Text::explodeNewLines($f);
foreach ($e as $item) {
$item = trim($item);
if ($item == '') {
continue;
}
$f = explode('=', $item, 2);
- $variables[$f[0]] = $f[1];
- }
- $this->config->scorm_variables = $this->book->parametres->scorm_variables = $variables;
- if ($this->book->parametres->scorm_quizdata) {
- $this->config->scorm_quizdata = wsUtil::excelToArray($this->wdir . '/' . $this->book->parametres->scorm_quizdata);
+ $variables[trim($f[0])] = trim($f[1]);
}
+ return $variables;
}
protected function writePrint()