00001 <?php
00002
00011 class TKSnapMediaFileEditor extends TKSnapEditor {
00021 protected function showEditor($cm, $failed) {
00022 $form = new TKForm();
00023 $table = $form->addTable();
00024 $table->addTextTo('header', 'Upload File', array('colspan' => 2, 'style' => array('font-size' => '1.4em')));
00025 $table->addText("File File", array('class' => array('snapInfoLabel')));
00026 $upload = $table->addFormInput('file', 'fileUpload');
00027 $upload->size = 40;
00028 $form->addText("<br />\n");
00029 $form->addFormInput('submit', 'snap2ed_save', "Submit");
00030 $form->addFormInput('submit', 'snap2ed_saveAndExit', "Save and Exit");
00031 $form->addFormInput('submit', 'snap2ed_exit', "Exit without Saving");
00032
00033 $this->add($form);
00034 }
00035
00044 protected function processSave($oldCM) {
00045 if(isset($_FILES['fileUpload']) && $_FILES['fileUpload']['name'] != '') {
00046 $fileName = $_FILES['fileUpload']['name'];
00047 $tmpFile = $_FILES['fileUpload']['tmp_name'];
00048 }
00049 else {
00050
00051 $fileName = $oldCM->getPath();
00052 $tmpFile = $oldCM->getPath();
00053 }
00054
00055 $cmNew = new SnapContentMediaFile($this->version);
00056 if(!$cmNew->uploadFile($tmpFile, $fileName)) {
00057 $html = "<p><b>Error:</b> Error saving file: " . $cmNew->getLastError() . "</p>";
00058 $this->addText($html);
00059 return false;
00060 }
00061
00062 return $cmNew;
00063 }
00064 }
00065
00066 ?>