openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

FileAction.class.php (2402B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 use cms\base\Configuration;
      6 use cms\generator\FileContext;
      7 use cms\generator\FileGenerator;
      8 use cms\generator\Producer;
      9 use cms\generator\Publisher;
     10 use cms\generator\PublishOrder;
     11 use cms\model\BaseObject;
     12 use cms\model\File;
     13 use cms\model\Folder;
     14 use util\exception\ValidationException;
     15 use util\Html;
     16 use util\Upload;
     17 
     18 // OpenRat Content Management System
     19 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
     20 //
     21 // This program is free software; you can redistribute it and/or
     22 // modify it under the terms of the GNU General Public License
     23 // as published by the Free Software Foundation; either version 2
     24 // of the License, or (at your option) any later version.
     25 //
     26 // This program is distributed in the hope that it will be useful,
     27 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     28 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     29 // GNU General Public License for more details.
     30 //
     31 // You should have received a copy of the GNU General Public License
     32 // along with this program; if not, write to the Free Software
     33 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     34 
     35 
     36 /**
     37  * Action-Klasse zum Bearbeiten einer Datei
     38  *
     39  * @author Jan Dankert
     40  */
     41 class FileAction extends ObjectAction
     42 {
     43     /**
     44      * @var File
     45      */
     46 	protected $file;
     47 
     48 	/**
     49 	 * Konstruktor
     50 	 */
     51 	function __construct()
     52     {
     53         parent::__construct();
     54     }
     55 
     56 
     57     public function init()
     58     {
     59 		$file = new File( $this->request->getId() );
     60 		$file->load();
     61 
     62         $this->setBaseObject( $file );
     63 	}
     64 
     65 
     66 	protected function setBaseObject( $file ) {
     67 		$this->file = $file;
     68 
     69 		parent::setBaseObject( $file );
     70 	}
     71 
     72 
     73 	protected function getCompressionTypes()
     74 	{
     75 		$compressionTypes = array();
     76 		if	( function_exists('gzencode'    ) ) $compressionTypes[] = 'gz';
     77 		//if	( function_exists('gzencode'    ) ) $compressionTypes[] = 'zip';
     78 		if	( function_exists('bzipcompress') ) $compressionTypes[] = 'bz2';
     79 		return $compressionTypes;
     80 	}
     81 
     82 	protected function getArchiveTypes()
     83 	{
     84 		$archiveTypes = array();
     85 		$archiveTypes[] = 'tar';
     86 		$archiveTypes[] = 'zip';
     87 		return $archiveTypes;
     88 	}
     89 
     90 
     91 	/**
     92 	 * @return string MIME-type
     93 	 */
     94 	protected function getMimeType() {
     95 		$context = new FileContext( $this->file->objectid,Producer::SCHEME_PREVIEW );
     96 		$fileGenerator = new FileGenerator( $context );
     97 		return $fileGenerator->getMimeType();
     98 
     99 	}
    100 }