openrat-cms

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

commit 0782330f82a6ffa1fc41063db0d55498b8dc833b
parent d43585f4f79373821d4a8684b87219731b54a543
Author: Jan Dankert <develop@jandankert.de>
Date:   Thu, 29 Aug 2019 22:51:35 +0200

Cleanup: Embed-Views vollständig ausgebaut.

Diffstat:
modules/cms-core/action/Action.class.php | 3---
modules/cms-core/action/FileAction.class.php | 2+-
modules/cms-core/action/PageAction.class.php | 6++++--
modules/cms-core/action/RequestParams.class.php | 12+++---------
modules/cms-core/action/TemplateAction.class.php | 2+-
modules/cms-publish/PublishPreview.class.php | 3+--
modules/cms-ui/UI.class.php | 91++++++-------------------------------------------------------------------------
modules/template-engine/components/html/form/Form.class.php | 2--
8 files changed, 16 insertions(+), 105 deletions(-)

diff --git a/modules/cms-core/action/Action.class.php b/modules/cms-core/action/Action.class.php @@ -335,9 +335,6 @@ namespace cms\action { if ( DEVELOPMENT ) return; - if ( $this->request->isEmbedded ) - return; // Embedded-Views können keine HTTP-Header setzen, daher ist alles weitere überflüssig. - // Conditional-Get eingeschaltet? if (!config('cache', 'conditional_get')) return; diff --git a/modules/cms-core/action/FileAction.class.php b/modules/cms-core/action/FileAction.class.php @@ -115,7 +115,7 @@ class FileAction extends ObjectAction function previewView() { $this->file->publisher = new PublishPreview(); - $url = Html::url($this->file->getType(),'show',$this->file->objectid,array('target'=>'none',REQ_PARAM_EMBED=>'1') ); + $url = Html::url($this->file->getType(),'show',$this->file->objectid,array('target'=>'none') ); $this->setTemplateVar('preview_url',$url ); } diff --git a/modules/cms-core/action/PageAction.class.php b/modules/cms-core/action/PageAction.class.php @@ -620,11 +620,13 @@ class PageAction extends ObjectAction /** * Seite anzeigen */ - function previewView() + public function previewView() { - $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array(REQ_PARAM_LANGUAGE_ID=>$this->page->languageid,REQ_PARAM_MODEL_ID=>$this->page->modelid,REQ_PARAM_EMBED=>'1') ) ); + $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array(REQ_PARAM_LANGUAGE_ID=>$this->page->languageid,REQ_PARAM_MODEL_ID=>$this->page->modelid) ) ); } + + /** * Seite anzeigen */ diff --git a/modules/cms-core/action/RequestParams.class.php b/modules/cms-core/action/RequestParams.class.php @@ -3,12 +3,14 @@ namespace { /* Request Parameter Names */ + /* @deprecated */ define('REQ_PARAM_EMBED' ,'embed' ); + + // TODO: Change the following constants to class constants define('REQ_PARAM_TOKEN' ,'token' ); define('REQ_PARAM_ACTION' ,'action' ); define('REQ_PARAM_SUBACTION' ,'subaction' ); define('REQ_PARAM_ID' ,'id' ); - define('REQ_PARAM_SHORT' ,'_' ); define('REQ_PARAM_OBJECT_ID' ,'objectid' ); define('REQ_PARAM_LANGUAGE_ID' ,'languageid' ); define('REQ_PARAM_MODEL_ID' ,'modelid' ); @@ -39,7 +41,6 @@ namespace cms\action { public $action; public $method; public $id; - public $isEmbedded; public $isAction; @@ -51,13 +52,6 @@ namespace cms\action { $this->id = @$_REQUEST[REQ_PARAM_ID ]; $this->action = @$_REQUEST[REQ_PARAM_ACTION ]; $this->method = @$_REQUEST[REQ_PARAM_SUBACTION]; - $this->isEmbedded = @$_REQUEST[REQ_PARAM_EMBED]=='1'; - - if ( isset($_REQUEST[REQ_PARAM_SHORT])) { - list( $type, $id ) = array_pad( explode( '-', $_REQUEST[REQ_PARAM_SHORT] ), 2, '' ); - $this->action = Text::clean( strtolower($type),'abcdefghijklmnopqrstuvwxyz'); - $this->id = $id; - } // Is this a POST request? $this->isAction = @$_SERVER['REQUEST_METHOD'] == 'POST'; diff --git a/modules/cms-core/action/TemplateAction.class.php b/modules/cms-core/action/TemplateAction.class.php @@ -361,7 +361,7 @@ class TemplateAction extends Action */ function previewView() { - $this->setTemplateVar('preview_url',Html::url('template','show',$this->template->templateid,array('target'=>'none',REQ_PARAM_EMBED=>'1') ) ); + $this->setTemplateVar('preview_url',Html::url('template','show',$this->template->templateid,array('target'=>'none') ) ); } diff --git a/modules/cms-publish/PublishPreview.class.php b/modules/cms-publish/PublishPreview.class.php @@ -25,8 +25,7 @@ class PublishPreview extends Publish $param = array( 'oid' => '__OID__'.$to->objectid.'__', REQ_PARAM_MODEL_ID => $from->modelid , - REQ_PARAM_LANGUAGE_ID => $from->languageid , - REQ_PARAM_EMBED => '1' ); + REQ_PARAM_LANGUAGE_ID => $from->languageid ); if ( $from->icons ) $param['withIcons'] = '1'; diff --git a/modules/cms-ui/UI.class.php b/modules/cms-ui/UI.class.php @@ -17,10 +17,6 @@ use SecurityException; use template_engine\TemplateEngine; use template_engine\TemplateEngineInfo; -define('CMS_UI_REQ_PARAM_SUBACTION', 'subaction'); -define('CMS_UI_REQ_PARAM_ACTION', 'action'); -define('CMS_UI_REQ_PARAM_EMBED', 'embed'); - class UI { @@ -30,7 +26,6 @@ class UI public static function execute() { $request = new RequestParams(); - $request->isEmbedded = false; try { @@ -42,46 +37,13 @@ class UI // Sending the Content-Security-Policy. self::setContentSecurityPolicy(); - /*if(empty($_REQUEST[CMS_UI_REQ_PARAM_EMBED])) { - - $isPost = $_SERVER['REQUEST_METHOD'] == 'POST'; - - if($isPost) - { - $dispatcher = new Dispatcher(); - - $request->isAction = true; - $dispatcher->request = $request; + if (empty($request->action)) + $request->action = 'index'; - $data = $dispatcher->doAction(); + if (empty($request->method)) + $request->method = 'show'; - //$data['notices']; - - // POST-Action has ended, now we want to show the UI. - $request->action = 'index'; - $request->method = 'show'; - $request->isAction = false; - $request->isEmbedded = true; - UI::executeAction($request); - } - else - { - $request->action = 'index'; - $request->method = 'show'; - UI::executeAction($request); - } - - } - else - {*/ - if (empty($request->action)) - $request->action = 'index'; - - if (empty($request->method)) - $request->method = 'show'; - - UI::executeAction($request); - /*}*/ + UI::executeAction($request); } catch (BadMethodCallException $e) { // Action-Method does not exist. @@ -102,54 +64,13 @@ class UI } } - /** - * Shows a UI fragment. - * This can only be executed after a UI::execute()-call. - */ - public static function executeEmbedded($action, $subaction, $id) - { - $request = new RequestParams(); - - $request->isEmbedded = true; - $request->action = $action; - $request->id = $id; - $request->method = $subaction; - - // Embedded Actions are ALWAYS Queries (means: GET). - $request->isAction = false; - - try { - UI::executeAction($request); - - } catch (BadMethodCallException $e) { - // Action-Method does not exist. - return ""; - } catch (ObjectNotFoundException $e) { - Logger::warn("Embedded Action $action/$subaction: Object not found: " . $e->__toString()); // Nicht so schlimm, da dies bei gelöschten Objekten vorkommen kann. - return DEVELOPMENT ? $e->getMessage() : ""; - } catch (OpenRatException $e) { - Logger::warn( "Embedded Action $action/$subaction: ".$e->__toString() ); - return DEVELOPMENT ? $e->getMessage() : lang($e->key); - } catch (SecurityException $e) { - Logger::info( "Embedded Action $action/$subaction: ".$e->getMessage() ); - return DEVELOPMENT ? $e->getMessage() : ""; - } catch (Exception $e) { - Logger::warn( "Embedded Action $action/$subaction: ".$e->__toString() ); - return DEVELOPMENT ? $e->getMessage() : ""; - } - } - - private static function executeAction($request) { $dispatcher = new Dispatcher(); $dispatcher->request = $request; - if ( $request->isEmbedded ) - $data = $dispatcher->callActionMethod(); - else - $data = $dispatcher->doAction(); + $data = $dispatcher->doAction(); // The action is able to change its method and action name. diff --git a/modules/template-engine/components/html/form/Form.class.php b/modules/template-engine/components/html/form/Form.class.php @@ -77,8 +77,6 @@ class FormComponent extends Component // Enable Submit on Enter - no need for...we have a submit button at the end. // echo '<input type="submit" class="invisible" />'; - if ( $this->target!='top') - echo '<input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" />'; if ( !empty($this->languageid)) echo '<input type="hidden" name="'.REQ_PARAM_LANGUAGE_ID.'" value="' . $this->htmlvalue($this->languageid) . '" />'; if ( !empty($this->modelid))