openrat-cms

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

FolderAction.class.php (2908B)


      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\Permission;
     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     /**
     41      * @var Folder
     42      */
     43 	protected $folder;
     44 
     45     public function __construct()
     46 	{
     47         parent::__construct();
     48     }
     49 
     50 
     51     public function init()
     52     {
     53 		$folder = new Folder( $this->request->getId() );
     54 		$folder->languageid = $this->request->getLanguageId(); // FIXME
     55 		$folder->load();
     56 
     57 		$this->lastModified( $folder->lastchangeDate);
     58 
     59 		$this->setBaseObject($folder);
     60 	}
     61 
     62 
     63 	protected function setBaseObject($folder ) {
     64 
     65 		$this->folder = $folder;
     66 
     67 		parent::setBaseObject( $folder );
     68 	}
     69 
     70 
     71 
     72 
     73 
     74 	/**
     75 	 * Ermittelt die maximale Gr��e einer hochzuladenden Datei.<br>
     76 	 * Der Wert wird aus der PHP- und OpenRat-Konfiguration ermittelt.<br>
     77 	 *
     78 	 * @return Integer maximale Dateigroesse in Bytes
     79 	 */
     80 	protected function maxFileSize()
     81 	{
     82 		// When querying memory size values:
     83 		// Many ini memory size values, such as upload_max_filesize,
     84 		// are stored in the php.ini file in shorthand notation.
     85 		// ini_get() will return the exact string stored in the php.ini file
     86 		// and NOT its integer equivalent.
     87 
     88 		$_10GB = 10 * 1024 * 1024 * 1024; // 10GB
     89 		$sizes = [];
     90 
     91 		foreach( ['upload_max_filesize','post_max_size','memory_limit'] as $setting )
     92 		{
     93 			$memLimit = $this->stringToBytes(ini_get($setting));
     94 
     95 			if	($memLimit )
     96 				$sizes[] = $memLimit;
     97 		}
     98 
     99 		$confMaxSize = Configuration::subset(['content','file'])->get('max_file_size',$_10GB) * 1024;
    100 
    101 		if	( $confMaxSize )
    102 			$sizes[] = $confMaxSize;
    103 
    104 		return min($sizes); // Using the minimum of all sizes.
    105 	}
    106 
    107 	/**
    108 	 * Umwandlung von abgek�rzten Bytewerten ("Shorthand Notation") wie
    109 	 * "4M" oder "500K" in eine ganzzahlige Byteanzahl.<br>
    110 	 * <br>
    111 	 * Quelle: http://de.php.net/manual/de/function.ini-get.php
    112 	 *
    113 	 * @param String Abgek�rzter Bytewert
    114 	 * @return Integer Byteanzahl
    115 	 */
    116 	protected function stringToBytes($val)
    117 	{
    118 		$val  = trim($val);
    119 		$last = strtolower($val[strlen($val)-1]);
    120 		$val  = intval($val);
    121 		// Achtung: Der Trick ist das "Fallthrough", kein "break" vorhanden!
    122 		switch($last)
    123 		{
    124 			case 'g':
    125 				$val *= 1024;
    126 			case 'm':
    127 				$val *= 1024;
    128 			case 'k':
    129 				$val *= 1024;
    130 		}
    131 
    132      	return intval($val);
    133 	}
    134 
    135 }