function toHTML() { $deck_id = $_GET['deck_id']; $deck = new Deck(); $deck->createFromID($deck_id); $slides = $deck->getSlidesFull(); $slides_to_string = array(); $image_local_path = array(); $image_name = array(); $image_paths = array(); $slides_to_string = $this->createSlideString($deck_id); foreach ($slides as $slide) { $img_pattern = '/\\.\\/upload\\/media\\/images\\/\\d+\\/\\d+\\..../'; preg_match_all($img_pattern, $slide->content, $matches); if (count($matches[0])) { foreach ($matches[0] as $img_path) { $image_paths[] = $img_path; } } } $html = " \n\t\t<!DOCTYPE html>\n\t\t<!--[if lt IE 7]> <html class=\"no-js ie6\" lang=\"en\"> <![endif]-->\n\t\t<!--[if IE 7]> <html class=\"no-js ie7\" lang=\"en\"> <![endif]-->\n\t\t<!--[if IE 8]> <html class=\"no-js ie8\" lang=\"en\"> <![endif]-->\n\t\t<!--[if gt IE 8]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->\n\t\t<head>\n\t\t\t<meta charset=\"utf-8\">\n\t\t\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n\n\t\t\t<title>" . $deck->title . "</title>\n\n\t\t\t<meta name=\"author\" content=" . $deck->owner->username . ">\n\t\t\t<meta name=\"deck_id\" content=" . $deck->deck_id . ">\n\t\t\t<meta name=\"deck_revision_id\" content=" . $deck->id . ">\n\t\t\t<meta name=\"viewport\" content=\"width=1024, user-scalable=no\">\n\n\t\t\t<!-- Core and extension CSS files -->\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/core/deck.core.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/goto/deck.goto.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/menu/deck.menu.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/navigation/deck.navigation.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/status/deck.status.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/hash/deck.hash.css\">\n\n\t\t\t<!-- Theme CSS files (menu swaps these out) -->\n\t\t\t<link rel=\"stylesheet\" id=\"style-theme-link\" href=\"default_theme/default.css\">\n\t\t\t<link rel=\"stylesheet\" id=\"transition-theme-link\" href=\"deck.js/themes/transition/horizontal-slide.css\">\n\n\t\t\t<!-- Custom CSS just for this page -->\n\t\t\t<link rel=\"stylesheet\" href=\"deck.js/introduction/introduction.css\">\n\t\t\t<link rel=\"stylesheet\" href=\"local.css\">\n\n\t\t\t<script src=\"deck.js/modernizr.custom.js\"></script>\n\t\t\t<script src=\"deck.js/jquery.js\"></script>\n\n\t\t\t<!-- client syntax highlightning -->\n\t\t\t<link href=\"deck.js/syntax/shThemeDefault.css\" rel=\"stylesheet\" type=\"text/css\" />\n\t\t\t<script src=\"deck.js/syntax/shCore.js\" type=\"text/javascript\"></script>\n\t\t\t<script src=\"deck.js/syntax/shAutoloader.js\" type=\"text/javascript\"></script>\n\t\t\t<script src=\"deck.js/syntax/shBrushTurtle.js\" type=\"text/javascript\"></script>\n\t\t\t<script type=\"text/javascript\" src=\"deck.js/MathJax.js\"></script>\n\n<script type=\"text/javascript\">\n\t\t\tfunction htmlDecode(input){\n\t\t\t\t var e = document.createElement(\"div\");\n\t\t\t\t e.innerHTML = input;\n\t\t\t\t return e.childNodes.length === 0 ? \"\" : e.childNodes[0].nodeValue;\n\t\t\t}\n\t\t\tfunction removeBRs(input){\n\t\t\t\tvar r=input.replace(/<br>/gi,\"\"); \n\t\t\t\tr=r.replace(/<br[0-9a-zA-Z]+>/gi,\"\");\n\t\t\t\treturn r;\n\t\t\t}\n\t\t\t\tSyntaxHighlighter.defaults['toolbar'] = false;\n\t\t\t\tSyntaxHighlighter.all();\n\t\t\t\t</script>\n\t\t\t<script type=\"text/x-mathjax-config\">\n\t\t\t\$(function() {\n\t\t\t MathJax.Hub.Config({\n\t\t\t\t\tskipStartupTypeset: true,\n\t\t\t\t\textensions: [\"tex2jax.js\"],\n\t\t\t\t\tjax: [\"input/TeX\", \"output/HTML-CSS\"],\n\t\t\t\t\ttex2jax: {\n\t\t\t\t\tinlineMath: [ ['\$','\$'], [\"\\(\",\"\\)\"] ],\n\t\t\t\t\tdisplayMath: [ ['\$\$','\$\$'], [\"\\[\",\"\\]\"] ],\n\t\t\t\t\tprocessEscapes: true\n\t\t\t\t\t},\n\t\t\t\t\t\"HTML-CSS\": { availableFonts: [\"TeX\"] }\n\t\t\t });\n\t\t\t\t\$.deck('.slide');\n\t\t\t\tMathJax.Hub.Queue([\"Typeset\",MathJax.Hub,'slide-area']);\n\t\t\t\t});\n\t\t\t\t</script>\t\t\t\n\t\t</head>\t\t\n\t\t\n\t\t<body class=\"deck-container\">\n\n\t\t\t<div class=\"theme-menu\">\n\t\t\t\t<h2>Themes</h2>\n\n\t\t\t\t<label for=\"style-themes\">Style:</label>\n\t\t\t\t<select id=\"style-themes\">\n\t\t\t\t\t<option selected value=\"default_theme/default.css\">Default</option>\n\t\t\t\t\t<option value=\"deck.js/themes/style/web-2.0.css\">Web 2.0</option>\n\t\t\t\t\t<option value=\"deck.js/themes/style/swiss.css\">Swiss</option>\n\t\t\t\t\t<option value=\"deck.js/themes/style/neon.css\">Neon</option>\n\t\t\t\t\t<option value=\"\">None</option>\n\t\t\t\t</select>\n\n\t\t\t\t<label for=\"transition-themes\">Transition:</label>\n\t\t\t\t<select id=\"transition-themes\">\n\t\t\t\t\t<option selected value=\"deck.js/themes/transition/horizontal-slide.css\">Horizontal Slide</option>\n\t\t\t\t\t<option value=\"deck.js/themes/transition/vertical-slide.css\">Vertical Slide</option>\n\t\t\t\t\t<option value=\"deck.js/themes/transition/fade.css\">Fade</option>\n\t\t\t\t\t<option value=\"\">None</option>\n\t\t\t\t</select>\n\t\t\t</div>" . $slides_to_string . "</div>\n\t\t\t</div>\n\t\t</div>\n\t\t\n\t\t<a href=\"#\" class=\"deck-prev-link\" title=\"Previous\">←</a>\n\t\t<a href=\"#\" class=\"deck-next-link\" title=\"Next\">→</a>\n\n\t\t<p class=\"deck-status\">\n\t\t\t<span class=\"deck-status-current\"></span>\n\t\t\t/\n\t\t\t<span class=\"deck-status-total\"></span>\n\t\t</p>\n\n\t\t<form action=\".\" method=\"get\" class=\"goto-form\">\n\t\t\t<label for=\"goto-slide\">Go to slide:</label>\n\t\t\t<input type=\"number\" name=\"slidenum\" id=\"goto-slide\">\n\t\t\t<input type=\"submit\" value=\"Go\">\n\t\t</form>\n\n\t\t<a href=\".\" title=\"Permalink to this slide\" class=\"deck-permalink\">#</a>\n\n\n\t\t<!-- Deck Core and extensions -->\n\t\t<script src=\"deck.js/core/deck.core.js\"></script>\n\t\t<script src=\"deck.js/extensions/menu/deck.menu.js\"></script>\n\t\t<script src=\"deck.js/extensions/goto/deck.goto.js\"></script>\n\t\t<script src=\"deck.js/extensions/status/deck.status.js\"></script>\n\t\t<script src=\"deck.js/extensions/navigation/deck.navigation.js\"></script>\n\t\t<script src=\"deck.js/extensions/hash/deck.hash.js\"></script>\n\t\t<!-- Specific to this page -->\n\t\t<script src=\"deck.js/introduction/introduction.js\"></script>\n\t\t<!-- Code Mirror -->\n\t\t<link rel=\"stylesheet\" href=\"codemirror/lib/codemirror.css\">\n\t\t<script src=\"codemirror/lib/codemirror.js\"></script>\n\t\t<script src=\"codemirror/mode/javascript/javascript.js\"></script>\n\t\t<script src=\"codemirror/mode/xml/xml.js\"></script>\n\t\t<script src=\"codemirror/mode/htmlmixed/htmlmixed.js\"></script>\n\t\t<script src=\"codemirror/mode/css/css.js\"></script>\n\t\t<script src=\"codemirror/mode/php/php.js\"></script>\n\t\t<script src=\"codemirror/mode/ntriples/ntriples.js\"></script>\n\t\t<script src=\"codemirror/mode/sparql/sparql.js\"></script>\n\t\t<script src=\"codemirror/lib/util/formatting.js\"></script>\n\t\t<!-- Code Mirror for deck.js -->\n\t\t<link rel=\"stylesheet\" href=\"deck.js/extensions/codemirror/deck.codemirror.css\">\n\t\t<script src=\"deck.js/extensions/codemirror/deck.codemirror.js\"></script>\n\t\t</body>\n\t\t</html>"; $zipName = "archive.zip"; $libraries_folder = 'deck.js' . DS; $createZipFile = new createDirZip(); $createZipFile->get_files_from_folder(ROOT . DS . 'libraries' . DS . 'frontend' . DS . 'deck.js' . DS, $libraries_folder); $fileToZip = "index.html"; $createZipFile->addFile($html, $fileToZip); $fileContents = file_get_contents(ROOT . DS . "libraries" . DS . "frontend" . DS . "MathJax" . DS . "MathJax.js"); $fileToZip = $libraries_folder . "MathJax.js"; $createZipFile->addFile($fileContents, $fileToZip); $fileContents = file_get_contents(ROOT . DS . "libraries" . DS . "frontend" . DS . "jquery.js"); $fileToZip = $libraries_folder . "jquery.js"; $createZipFile->addFile($fileContents, $fileToZip); $fileContents = file_get_contents(ROOT . DS . "libraries" . DS . "frontend" . DS . "jquery.min.js"); $fileToZip = $libraries_folder . "jquery.min.js"; $createZipFile->addFile($fileContents, $fileToZip); $createZipFile->get_files_from_folder(ROOT . DS . 'libraries' . DS . 'frontend' . DS . 'codemirror' . DS, 'codemirror' . DS); // adding images foreach ($image_paths as $im) { $fileContents = file_get_contents($im); $fileToZip = split('\\/', $im); $fileToZip = $fileToZip[count($fileToZip) - 1]; $createZipFile->addFile($fileContents, $fileToZip); } //add default theme $style = new Style(); $tmp = $style->getStyle($deck->default_theme); $createZipFile->addFile($tmp['css'], 'default_theme/default.css'); $date = date('Y-m-d'); $zipName = $this->sluggify($deck->title) . '_' . $date . "_" . $zipName; $fd = fopen($zipName, "wb"); $out = fwrite($fd, $createZipFile->getZippedfile()); fclose($fd); $createZipFile->forceDownload($zipName); @unlink($zipName); }
function style() { $deckid = $_GET['deck']; $styleid = isset($_GET['id']) ? $_GET['id'] : 1; $response = 0; $deck = new Deck(); $deck->createFromIDLite($deckid); //show error if deck does not exist if (!isset($deck->deck_id)) { header('Location: ' . BASE_PATH . 'error/404'); die; } $slides = $deck->getSlidesFull(); $deck->slides = $slides; $style = new Style(); $style->createFromID($styleid); //show error if style does not exist if (!isset($style->name)) { header('Location: ' . BASE_PATH . 'error/404'); die; } $styles = $style->getAll(); //$this->set ( 'user', $current_user ); $this->set('response', $response); $this->set('deck', $deck); $this->set('styleObj', $style); $this->set('styles', $styles); $this->set('page_title', "SlideWiki Style - " . $style->name); }