00001 <?php
00002
00011 class TKSnapMediaNetlogoEditor extends TKSnapEditor {
00021 protected function showEditor($cm, $failed) {
00022 $form = new TKForm();
00023 $table = $form->addTable();
00024 $table->addTextTo('header', 'Upload Applet', array('colspan' => 2, 'style' => array('font-size' => '1.4em')));
00025
00026 $table->addText("Applet File (.nlogo)", array('class' => array('snapInfoLabel')));
00027 $upload = $table->addFormInput('file', 'fileUpload');
00028 $table->addRow();
00029 $table->addText("Applet Width", array('class' => array('snapInfoLabel')));
00030 $table->addFormInput('text', 'width', $failed ? $_REQUEST['width'] : $cm->getWidth());
00031 $table->addRow();
00032 $table->addText("Applet Height", array('class' => array('snapInfoLabel')));
00033 $table->addFormInput('text', 'height', $failed ? $_REQUEST['height'] : $cm->getHeight());
00034 $upload->size = 40;
00035 $form->addText("<br />\n");
00036 $form->addFormInput('submit', 'snap2ed_save', "Submit");
00037 $form->addFormInput('submit', 'snap2ed_saveAndExit', "Save and Exit");
00038 $form->addFormInput('submit', 'snap2ed_exit', "Exit without Saving");
00039
00040 $this->add($form);
00041 }
00042
00051 protected function processSave($oldCM) {
00052 if(isset($_FILES['fileUpload'])) {
00053 $fileName = $_FILES['fileUpload']['name'];
00054 $tmpFile = $_FILES['fileUpload']['tmp_name'];
00055 }
00056 else
00057 $tmpFile = "";
00058
00059 $width = $_REQUEST['width'];
00060 $height = $_REQUEST['height'];
00061
00062 $cmNew = new SnapContentMediaNetlogoApplet($this->version);
00063
00064 if($tmpFile == "") {
00065 if($width != "") $stat = $cmNew->setWidth($oldCM, $width);
00066 if($height != "" && $stat) $stat = $cmNew->setHeight($oldCM, $height);
00067 }
00068 else
00069 $stat = $cmNew->uploadApplet($tmpFile, $fileName, $width, $height);
00070
00071 if(!$stat) {
00072 $cmNew->delete();
00073 $html = "<p><b>Error:<b/> Could not save applet: " . $cmNew->getLastError() . "</p>";
00074 $this->addText($html);
00075 return false;
00076 }
00077
00078 return $cmNew;
00079 }
00080 }
00081
00082 ?>