/** * Renames a media file */ function renMedia() { global $_ARRAYLANG; $objFile = new \File(); // file or dir $fileName = !empty($_POST['renName']) ? $_POST['renName'] : 'empty'; $oldName = empty($_POST['oldExt']) ? contrexx_input2raw($_POST['oldName']) : contrexx_input2raw($_POST['oldName'] . '.' . $_POST['oldExt']); if (!is_dir($this->path . $oldName)) { $ext = !empty($_POST['renExt']) && \FWValidator::is_file_ending_harmless($_POST['renName'] . '.' . $_POST['renExt']) ? $_POST['renExt'] : 'txt'; $fileName = $fileName . '.' . $ext; } \Cx\Lib\FileSystem\FileSystem::clean_path($fileName); $makeCopy = isset($_POST['mediaInputAsCopy']) && $_POST['mediaInputAsCopy'] == 1; if (!$makeCopy) { // rename old to new if (is_dir($this->path . $oldName)) { $result = $objFile->renameDir($this->path, $this->webPath, $oldName, $fileName); } else { $result = $objFile->renameFile($this->path, $this->webPath, $oldName, $fileName); } } else { // copy old to new if (is_dir($this->path . $oldName)) { $result = $objFile->copyDir($this->path, $this->webPath, $oldName, $this->path, $this->webPath, $fileName); } else { $result = $objFile->copyFile($this->path, $oldName, $this->path, $fileName); } } if ($result == 'error') { \Message::error($_ARRAYLANG['TXT_MEDIA_MSG_ERROR_EDIT']); return; } else { $_SESSION['media_highlight_name'] = array($result); \Message::ok($_ARRAYLANG['TXT_MEDIA_MSG_EDIT']); } // save image $this->_objImage->loadImage($this->path . $result); $this->_objImage->saveNewImage($this->path . $result, true); }
/** * Renames a media file */ function renMedia() { global $_ARRAYLANG, $objTemplate; $obj_file = new \File(); // file or dir $fileName = !empty($_POST['renName']) ? $_POST['renName'] : 'empty'; if (empty($_POST['oldExt'])) { $oldName = $_POST['oldName']; } else { $oldName = $_POST['oldName'] . '.' . $_POST['oldExt']; } if (!is_dir($this->path . $oldName)) { $ext = !empty($_POST['renExt']) && \FWValidator::is_file_ending_harmless($_POST['renName'] . '.' . $_POST['renExt']) ? $_POST['renExt'] : 'txt'; $fileName = $fileName . '.' . $ext; } \Cx\Lib\FileSystem\FileSystem::clean_path($fileName); if (!isset($_POST['mediaInputAsCopy']) || $_POST['mediaInputAsCopy'] != 1) { // rename old to new if (is_dir($this->path . $oldName)) { $this->dirLog = $obj_file->renameDir($this->path, $this->webPath, $oldName, $fileName); if ($this->dirLog == "error") { $objTemplate->setVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_EDIT']); } else { $this->highlightName[] = $this->dirLog; $objTemplate->setVariable('CONTENT_OK_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_EDIT']); } } else { $this->dirLog = $obj_file->renameFile($this->path, $this->webPath, $oldName, $fileName); if ($this->dirLog == "error") { $objTemplate->setVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_EDIT']); } else { $this->highlightName[] = $this->dirLog; $objTemplate->setVariable('CONTENT_OK_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_EDIT']); } } } elseif (isset($_POST['mediaInputAsCopy']) && $_POST['mediaInputAsCopy'] == 1) { // copy old to new if (is_dir($this->path . $oldName)) { $this->dirLog = $obj_file->copyDir($this->path, $this->webPath, $oldName, $this->path, $this->webPath, $fileName); if ($this->dirLog == "error") { $objTemplate->setVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_EDIT']); } else { $this->highlightName[] = $this->dirLog; $objTemplate->setVariable('CONTENT_OK_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_EDIT']); } } else { $this->dirLog = $obj_file->copyFile($this->path, $oldName, $this->path, $fileName); if ($this->dirLog == "error") { $objTemplate->setVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_EDIT']); } else { $this->highlightName[] = $this->dirLog; $objTemplate->setVariable('CONTENT_OK_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_EDIT']); } } } // save image $this->_objImage->loadImage($this->path . $this->dirLog); $this->_objImage->saveNewImage($this->path . $this->dirLog, true); }