openrat-cms

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

commit fe95f5b51fb075881840db0eeb4bfdac77b94c68
parent 3a5610bd53fd88e31098d2132fd72ac49e9c9733
Author: Jan Dankert <devnull@localhost>
Date:   Tue, 28 Aug 2018 23:18:27 +0200

Benutzen von Fluent-Interfaces, auch bei der Konfiguration.

Diffstat:
modules/cms-core/Dispatcher.class.php | 2+-
modules/cms-core/action/Action.class.php | 2++
modules/cms-core/action/ElementAction.class.php | 3++-
modules/cms-core/action/UserAction.class.php | 8++++----
modules/cms-core/model/Acl.class.php | 19++++++++++++++++++-
modules/cms-core/model/BaseObject.class.php | 13++++++++++++-
modules/cms-core/model/File.class.php | 2++
modules/cms-core/model/Project.class.php | 8+++++---
modules/cms-core/model/Value.class.php | 4+---
modules/cms-publish/PublicLinkSchema.class.php | 6++----
modules/configuration/Configuration.class.php | 10++++++++++
11 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/modules/cms-core/Dispatcher.class.php b/modules/cms-core/Dispatcher.class.php @@ -41,7 +41,7 @@ class Dispatcher */ public function doAction() { - define('PRODUCTION', config()->is('production')); + define('PRODUCTION', Conf()->is('production')); define('DEVELOPMENT', !PRODUCTION); diff --git a/modules/cms-core/action/Action.class.php b/modules/cms-core/action/Action.class.php @@ -47,6 +47,8 @@ namespace cms\action { public $publishing; public $refresh; + public $security = SECURITY_USER; + protected $templateVars = Array(); /** diff --git a/modules/cms-core/action/ElementAction.class.php b/modules/cms-core/action/ElementAction.class.php @@ -337,7 +337,8 @@ class ElementAction extends Action case 'dateformat': //$ini_date_format = config('date','format'); - $ini_date_format = config()->subset('date')->get('format'); + //$ini_date_format = Conf()->subset('date')->get('format'); + $ini_date_format = config()['date']['format']; $dateformat = array(); $this->setTemplateVar('dateformat',''); diff --git a/modules/cms-core/action/UserAction.class.php b/modules/cms-core/action/UserAction.class.php @@ -384,10 +384,10 @@ class UserAction extends Action /* @var $acl Acl */ if ( !isset($projects[$acl->projectid])) { - $projects[$acl->projectid] = array(); - $p = new Project($acl->projectid); - $p->load(); - $projects[$acl->projectid]['projectname'] = $p->name; + $p = Project::create( $acl->projectid ); + + $projects[$acl->projectid] = array(); + $projects[$acl->projectid]['projectname'] = $p->load()->name; $projects[$acl->projectid]['rights' ] = array(); } diff --git a/modules/cms-core/model/Acl.class.php b/modules/cms-core/model/Acl.class.php @@ -175,7 +175,10 @@ class Acl var $transmit = false; - /** + public $projectid; + + + /** * Konstruktor. * * @param Integer Acl-ID @@ -500,5 +503,19 @@ SQL $stmt->setInt ('languageid',$this->languageid); $stmt->query(); + + } + + /** + * Liefert das Projekt-Objekt. + * + * @return Project + * @throws \ObjectNotFoundException + */ + public function getProject() { + return Project::create( $this->projectid ); + } + + } \ No newline at end of file diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php @@ -651,7 +651,7 @@ SQL */ public function load() { - $this->objectLoad(); + return $this->objectLoad(); } @@ -1541,6 +1541,17 @@ SQL } } + + /** + * Liefert das Projekt-Objekt. + * + * @return Project + * @throws \ObjectNotFoundException + */ + public function getProject() { + return Project::create( $this->projectid ); + } + } diff --git a/modules/cms-core/model/File.class.php b/modules/cms-core/model/File.class.php @@ -238,6 +238,8 @@ class File extends BaseObject } $this->objectLoad(); + + return $this; } diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php @@ -79,8 +79,8 @@ class Project extends ModelBase if ( empty( Project::$cache[ $projectid ] ) ) { $project = new Project( $projectid ); - Project::$cache[ $projectid ] = $project; - $project->load(); + + Project::$cache[ $projectid ] = $project->load(); } return Project::$cache[ $projectid ]; } @@ -224,7 +224,7 @@ class Project extends ModelBase /** * @throws \ObjectNotFoundException */ - public function load() + public function load() { $db = db_connection(); @@ -247,6 +247,8 @@ class Project extends ModelBase $this->content_negotiation = $row['flags']&PROJECT_FLAG_CONTENT_NEGOTIATION; $this->publishFileExtension = $row['flags']&PROJECT_FLAG_PUBLISH_FILE_EXTENSION; $this->publishPageExtension = $row['flags']&PROJECT_FLAG_PUBLISH_PAGE_EXTENSION; + + return $this; } diff --git a/modules/cms-core/model/Value.class.php b/modules/cms-core/model/Value.class.php @@ -1360,9 +1360,7 @@ SQL $inhalt = $this->page->projectid; break; case 'project_name': - $project = new Project( $this->page->projectid ); - $project->load(); - $inhalt = $project->name; + $inhalt = Project::create( $this->page->projectid )->load()->name; break; case 'language_id': $inhalt = $this->page->languageid; diff --git a/modules/cms-publish/PublicLinkSchema.class.php b/modules/cms-publish/PublicLinkSchema.class.php @@ -42,8 +42,7 @@ class PublicLinkSchema $f = new File( $to->objectid ); - $p = new Project( $to->projectid ); - $p->load(); + $p = Project::create( $to->projectid )->load(); $f->content_negotiation = $p->content_negotiation; $f->load(); @@ -111,8 +110,7 @@ class PublicLinkSchema $schema = OR_LINK_SCHEMA_ABSOLUTE; // Target is in another Project. So we have to create an absolute URL. - $targetProject = new Project( $to->projectid ); - $targetProject->load(); + $targetProject = Project::create( $to->projectid )->load(); $inhalt = $targetProject->url; if ( ! strpos($inhalt,'://' ) === FALSE ) { diff --git a/modules/configuration/Configuration.class.php b/modules/configuration/Configuration.class.php @@ -32,6 +32,16 @@ function config( $part1=null,$part2=null,$part3=null ) } +/** + * @return Config + */ +function Conf() { + + global $conf; + return new Config( $conf ); + +} + class Config { private $config = array();