00001 <?php
00002
00003 class TKSnapJavaScriptEditor extends TKSnapEditor {
00004 protected function showEditor($cm, $failed) {
00005 if($failed)
00006 $content = $_REQUEST['editor'];
00007 else
00008 $content = $cm->getJavaScript();
00009 if(preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']))
00010 $whitespace = '';
00011 else
00012 $whitespace = 'whitespace: nowrap;';
00013 $html = "<form action=\"$_SERVER[REQUEST_URI]\" method=\"post\">
00014 <div style=\"text-align: center\">
00015 <textarea name=\"editor\" style=\"${whitespace}overflow: auto;\" rows=\"10\" cols=\"80\">" . htmlentities($content) . "</textarea><br />
00016 <input type=\"submit\" name=\"snap2ed_save\" value=\"Save\" />
00017 <input type=\"submit\" name=\"snap2ed_saveAndExit\" value=\"Save and Exit\" />
00018 <input type=\"submit\" name=\"snap2ed_exit\" value=\"Exit without Saving\" />
00019 </div>
00020 </form>
00021 <br />";
00022 $this->addText($html);
00023 }
00024
00025 protected function processSave($oldCM) {
00026 $content = $_REQUEST['editor'];
00027
00028 $cmNew = new SnapContentJavaScript($this->version);
00029 if(!$cmNew->setJavaScript($content)) {
00030 $html = "<p><b>Error:</b> Could not save document:</p><ul><li>" . implode("</li><li>", $cmNew->getLastError())
00031 . "</li></ul>";
00032 $this->addText($html);
00033 return false;
00034 }
00035
00036 return $cmNew;
00037 }
00038 }
00039
00040 ?>