openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

FolderAction.class.php (2943B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 use cms\base\Configuration;
      6 use cms\base\Startup;
      7 use cms\generator\FileContext;
      8 use cms\generator\FileGenerator;
      9 use cms\generator\PageContext;
     10 use cms\generator\PageGenerator;
     11 use cms\generator\Producer;
     12 use cms\generator\Publisher;
     13 use cms\generator\PublishOrder;
     14 use cms\model\Acl;
     15 use cms\model\BaseObject;
     16 use cms\model\File;
     17 use cms\model\Folder;
     18 use cms\model\Image;
     19 use cms\model\Link;
     20 use cms\model\Page;
     21 use cms\model\Project;
     22 use cms\model\Text;
     23 use cms\model\Url;
     24 use language\Messages;
     25 use util\ArchiveTar;
     26 use util\exception\ValidationException;
     27 use util\Html;
     28 use util\Http;
     29 use util\Session;
     30 use util\Upload;
     31 
     32 /**
     33  * Action-Klasse zum Bearbeiten eines Ordners.
     34  *
     35  * @author Jan Dankert
     36  */
     37 
     38 class FolderAction extends ObjectAction
     39 {
     40 	public $security = Action::SECURITY_USER;
     41 
     42     /**
     43      * @var Folder
     44      */
     45 	protected $folder;
     46 
     47     public function __construct()
     48 	{
     49         parent::__construct();
     50     }
     51 
     52 
     53     public function init()
     54     {
     55 		$folder = new Folder( $this->getRequestId() );
     56 		$folder->languageid = $this->request->getLanguageId(); // FIXME
     57 		$folder->load();
     58 
     59 		$this->lastModified( $folder->lastchangeDate);
     60 
     61 		$this->setBaseObject($folder);
     62 	}
     63 
     64 
     65 	protected function setBaseObject($folder ) {
     66 
     67 		$this->folder = $folder;
     68 
     69 		parent::setBaseObject( $folder );
     70 	}
     71 
     72 
     73 
     74 
     75 
     76 	/**
     77 	 * Ermittelt die maximale Gr��e einer hochzuladenden Datei.<br>
     78 	 * Der Wert wird aus der PHP- und OpenRat-Konfiguration ermittelt.<br>
     79 	 *
     80 	 * @return Integer maximale Dateigroesse in Bytes
     81 	 */
     82 	protected function maxFileSize()
     83 	{
     84 		// When querying memory size values:
     85 		// Many ini memory size values, such as upload_max_filesize,
     86 		// are stored in the php.ini file in shorthand notation.
     87 		// ini_get() will return the exact string stored in the php.ini file
     88 		// and NOT its integer equivalent.
     89 
     90 		$_10GB = 10 * 1024 * 1024 * 1024; // 10GB
     91 		$sizes = [];
     92 
     93 		foreach( ['upload_max_filesize','post_max_size','memory_limit'] as $setting )
     94 		{
     95 			$memLimit = $this->stringToBytes(ini_get($setting));
     96 
     97 			if	($memLimit )
     98 				$sizes[] = $memLimit;
     99 		}
    100 
    101 		$confMaxSize = Configuration::subset(['content','file'])->get('max_file_size',$_10GB) * 1024;
    102 
    103 		if	( $confMaxSize )
    104 			$sizes[] = $confMaxSize;
    105 
    106 		return min($sizes); // Using the minimum of all sizes.
    107 	}
    108 
    109 	/**
    110 	 * Umwandlung von abgek�rzten Bytewerten ("Shorthand Notation") wie
    111 	 * "4M" oder "500K" in eine ganzzahlige Byteanzahl.<br>
    112 	 * <br>
    113 	 * Quelle: http://de.php.net/manual/de/function.ini-get.php
    114 	 *
    115 	 * @param String Abgek�rzter Bytewert
    116 	 * @return Integer Byteanzahl
    117 	 */
    118 	protected function stringToBytes($val)
    119 	{
    120 		$val  = trim($val);
    121 		$last = strtolower($val[strlen($val)-1]);
    122 		$val  = intval($val);
    123 		// Achtung: Der Trick ist das "Fallthrough", kein "break" vorhanden!
    124 		switch($last)
    125 		{
    126 			case 'g':
    127 				$val *= 1024;
    128 			case 'm':
    129 				$val *= 1024;
    130 			case 'k':
    131 				$val *= 1024;
    132 		}
    133 
    134      	return intval($val);
    135 	}
    136 
    137 }