Example #1
0
 /**
  * Rename Media Data
  *
  * @global  array   $_ARRAYLANG
  * @return  string  parsed content
  */
 function _renameMedia()
 {
     global $_ARRAYLANG;
     $this->_objTpl->loadTemplateFile('module_media_rename.html', true, true);
     $this->pageTitle = $_ARRAYLANG['TXT_MEDIA_RENAME_FILE'];
     $check = true;
     if (empty($this->getFile) || empty($this->getPath)) {
         $check = false;
     }
     if ($check) {
         if (!file_exists($this->path . $this->getFile)) {
             $check = false;
         }
     }
     if ($check == false || MediaLibrary::isIllegalFileName($this->getFile)) {
         // file doesn't exist
         $this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_FILE_DONT_EXISTS' => MediaLibrary::isIllegalFileName($this->getFile) ? $_ARRAYLANG['TXT_MEDIA_FILE_DONT_EDIT'] : $_ARRAYLANG['TXT_MEDIA_FILE_DONT_EXISTS']));
         $this->_objTpl->parse('mediaErrorFile');
     } else {
         if ($check == true) {
             // file exists
             $this->_objTpl->setVariable(array('TXT_MEDIA_RENAME_NAME' => $_ARRAYLANG['TXT_MEDIA_RENAME_NAME'], 'TXT_MEDIA_RENAME_EXT' => $_ARRAYLANG['TXT_MEDIA_RENAME_EXT']));
             $this->_objTpl->setVariable(array('MEDIA_EDIT_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=ren&path=' . $this->webPath, 'TXT_MEDIA_EDIT_FILE' => $_ARRAYLANG['TXT_MEDIA_EDIT_FILE'], 'MEDIA_DIR' => $this->webPath, 'MEDIA_FILE' => $this->getFile, 'TXT_MEDIA_INSERT_AS_COPY' => $_ARRAYLANG['TXT_MEDIA_INSERT_AS_COPY'], 'TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET']));
             $icon = $this->_getIcon($this->path . $this->getFile);
             $fileName = $this->getFile;
             // extension
             if (is_file($this->path . $this->getFile)) {
                 $info = pathinfo($this->getFile);
                 $fileExt = $info['extension'];
                 $ext = !empty($fileExt) ? '.' . $fileExt : '';
                 $fileName = substr($this->getFile, 0, strlen($this->getFile) - strlen($ext));
                 $this->_objTpl->setVariable(array('MEDIA_ORGFILE_EXT' => $fileExt . ''));
                 $this->_objTpl->parse('mediaFileExt');
             }
             // edit name
             $this->_objTpl->setVariable(array('MEDIA_FILE_ICON' => self::_getIconWebPath() . $icon . '.png', 'MEDIA_ORGFILE_NAME' => $fileName));
             $this->_objTpl->parse('mediaFile');
         }
     }
     // variables
     $this->_objTpl->setVariable(array('TXT_MEDIA_BACK' => $_ARRAYLANG['TXT_MEDIA_BACK'], 'MEDIA_BACK_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath));
 }
Example #2
0
 /**
  * Delete files
  *
  * @global     array    $_ARRAYLANG
  * @return     boolean  true if file deleted successfully and false if it failed
  */
 function _deleteFiles()
 {
     global $_ARRAYLANG;
     // check permissions
     if (!$this->manageAccessGranted()) {
         $this->_strErrorMessage = $_ARRAYLANG['TXT_MEDIA_DIRCREATION_NOT_ALLOWED'];
         return false;
     }
     if (MediaLibrary::isIllegalFileName($this->getFile)) {
         $this->_strErrorMessage = $_ARRAYLANG['TXT_MEDIA_FILE_DONT_DELETE'];
         return false;
     }
     if (isset($_GET['path'])) {
         if (isset($_GET['file'])) {
             $filePath = $this->path . $this->getFile;
             if (unlink($filePath)) {
                 $this->_strOkMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_DELETED_SUCESSFULLY'], '<strong>' . htmlentities($this->getFile, ENT_QUOTES, CONTREXX_CHARSET) . '</strong>');
                 return true;
             } else {
                 $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_NOT_FOUND'], htmlentities($this->getFile, ENT_QUOTES, CONTREXX_CHARSET));
                 return false;
             }
         } else {
             $this->deleteDirectory($this->path);
         }
     }
 }