1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?php
namespace MatthiasWeb\RealMediaLibrary\folder;
use MatthiasWeb\RealMediaLibrary\attachment;
use MatthiasWeb\RealMediaLibrary\general;
use MatthiasWeb\RealMediaLibrary\order;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Root extends order\Sortable {
private static $me = null;
public function __construct() {
parent::__construct(-1, null, "/" . __('Unorganized', RML_TD), "/", "/");
}
public function persist() {
throw new \Exception("You can not persist the root folder.");
}
public function getSlug($force = false, $fromSetName = false) {
return $this->slug;
}
public function getAbsolutePath($force = false, $fromSetName = false) {
return $this->absolutePath;
}
public function getCnt($forceReload = false) {
return attachment\Structure::getInstance()->getCntRoot();
}
public function setParent($id, $ord = -1, $force = false) {
throw new \Exception("You can not set a parent for the root folder.");
}
public function setName($name, $supress_validation = false) {
throw new \Exception("You can not set a name for the root folder.");
}
public function setRestrictions($restrictions = array()) {
throw new \Exception("You can not set permissions for the root folder.");
}
public function getChildren() {
return attachment\Structure::getInstance()->getTree();
}
public function getAllowedChildrenTypes() {
return apply_filters("RML/Folder/Types/" . $this->getType(), array(RML_TYPE_FOLDER, RML_TYPE_COLLECTION));
}
public function getType() {
return RML_TYPE_ROOT;
}
public function getContentCustomOrder() {
return "2";
}
public function getTypeName($default = null) {
return parent::getTypeName($default === null ? __('Unorganized', RML_TD) : $default);
}
public function getTypeDescription($default = null) {
return parent::getTypeDescription($default === null ? __('Unorganized is the same as a root folder. Here you can find all files which are not assigned to a folder.', RML_TD) : $default);
}
public static function getInstance() {
if (self::$me == null) {
self::$me = new Root();
}
return self::$me;
}
}
?>