/** * Request-Handler * @return boolean */ public function request() { if ($this->buttonClicked('uploadFile') && !is_null(\fpcm\classes\http::getFiles())) { $uploader = new \fpcm\model\files\fileuploader(\fpcm\classes\http::getFiles()); $res = $uploader->processArticleTemplateUpload(); if ($res == true) { $this->view->addNoticeMessage('SAVE_SUCCESS_UPLOADTPLFILE'); } else { $this->view->addErrorMessage('SAVE_FAILED_UPLOADTPLFILE'); } return true; } $delFiles = $this->getRequestVar('deltplfiles'); if ($this->buttonClicked('fileDelete') && is_array($delFiles) && count($delFiles)) { $delFiles = array_map('base64_decode', $delFiles); $deletedOk = array(); $deletedFailed = array(); foreach ($delFiles as $delFile) { $articleTplFile = new \fpcm\model\files\templatefile($delFile); if (!$articleTplFile->delete()) { $deletedFailed[] = \fpcm\model\files\ops::removeBaseDir($delFile); continue; } $deletedOk[] = \fpcm\model\files\ops::removeBaseDir($delFile); } if (count($deletedOk)) { $this->view->addNoticeMessage('DELETE_SUCCESS_FILES', array('{{filenames}}' => implode(', ', $deletedOk))); } if (count($deletedFailed)) { $this->view->addErrorMessage('DELETE_FAILED_FILES', array('{{filenames}}' => implode(', ', $deletedFailed))); } return true; } if ($this->buttonClicked('saveTemplates') && !is_null($this->getRequestVar('template'))) { $this->cache->cleanup(); $templateContents = $this->getRequestVar('template'); $tplSaveError = array(); $tplSaveOk = array(); foreach ($templateContents as $templateName => $newContent) { $tplObj = $this->{$templateName . 'Template'}; $tplObj->setContent($newContent); $res = $tplObj->save(); if (is_null($res) && $templateName == 'commentForm') { $this->view->addErrorMessage('SAVE_FAILED_TEMPLATE_CF_URLMISSING'); } elseif (!$res) { $tplSaveError[] = $tplObj->getFilename(); } else { $tplSaveOk[] = $tplObj->getFilename(); } } if (count($tplSaveError)) { $this->view->addErrorMessage('SAVE_FAILED_TEMPLATE', array('{{filenames}}' => implode(', ', $tplSaveError))); } if (count($tplSaveOk)) { $this->view->addNoticeMessage('SAVE_SUCCESS_TEMPLATE', array('{{filenames}}' => implode(', ', $tplSaveOk))); } } return true; }
public function request() { if (!is_null(\fpcm\classes\http::getFiles())) { $uploader = new \fpcm\model\files\fileuploader(\fpcm\classes\http::getFiles()); $res = $uploader->processModuleUpload(); if ($res == true) { $this->view->addNoticeMessage('SAVE_SUCCESS_UPLOADMODULE'); } else { $this->view->addErrorMessage('SAVE_FAILED_UPLOADMODULE'); } } return true; }
public function request() { if (!is_null($this->getRequestVar('mode'))) { $this->mode = (int) $this->getRequestVar('mode'); if ($this->mode > 1) { $this->view->setShowHeader(false); $this->view->setShowFooter(false); } } if (!is_null(\fpcm\classes\http::getFiles())) { $uploader = new \fpcm\model\files\fileuploader(\fpcm\classes\http::getFiles()); $result = $uploader->processUpload($this->session->getUserId()); if (count($result['success'])) { $this->view->addNoticeMessage('SAVE_SUCCESS_UPLOADPHP', array('{{filenames}}' => implode(', ', $result['success']))); } if (count($result['error'])) { $this->view->addErrorMessage('SAVE_FAILED_UPLOADPHP', array('{{filenames}}' => implode(', ', $result['error']))); } } if ($this->buttonClicked('deleteFiles') && !is_null($this->getRequestVar('filenames'))) { $fileNames = array_map('base64_decode', $this->getRequestVar('filenames')); $deletedOk = array(); $deletedFailed = array(); foreach ($fileNames as $fileName) { $image = new \fpcm\model\files\image($fileName, '', '', false); if ($image->delete()) { $deletedOk[] = $fileName; } else { $deletedFailed[] = $fileName; } } if (count($deletedOk)) { $this->view->addNoticeMessage('DELETE_SUCCESS_FILES', array('{{filenames}}' => implode(', ', $deletedOk))); } if (count($deletedFailed)) { $this->view->addErrorMessage('DELETE_FAILED_FILES', array('{{filenames}}' => implode(', ', $deletedFailed))); } } if ($this->buttonClicked('createThumbs') && !is_null($this->getRequestVar('filenames'))) { $fileNames = array_map('base64_decode', $this->getRequestVar('filenames')); $success = array(); $failed = array(); foreach ($fileNames as $fileName) { $image = new \fpcm\model\files\image($fileName, '', '', false); if ($image->createThumbnail()) { $success[] = $fileName; } else { $deletedFailed[] = $fileName; } } if (count($success)) { $this->view->addNoticeMessage('DELETE_SUCCESS_NEWTHUMBS', array('{{filenames}}' => implode(', ', $success))); } if (count($failed)) { $this->view->addErrorMessage('DELETE_FAILED_NEWTHUMBS', array('{{filenames}}' => implode(', ', $failed))); } } if ($this->buttonClicked('renameFiles') && !is_null($this->getRequestVar('filenames') && $this->getRequestVar('newfilename'))) { $fileNames = array_map('base64_decode', $this->getRequestVar('filenames')); $fileName = array_shift($fileNames); $image = new \fpcm\model\files\image($fileName, '', '', false); $newname = $this->getRequestVar('newfilename'); if ($image->rename($newname, $this->session->getUserId())) { $this->view->addNoticeMessage('DELETE_SUCCESS_RENAME', array('{{filename1}}' => $fileName, '{{filename2}}' => $newname)); } else { $this->view->addErrorMessage('DELETE_FAILED_RENAME', array('{{filename1}}' => $fileName, '{{filename2}}' => $newname)); } $this->fileList->createFilemanagerThumbs(); } return true; }