openrat-cms

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

commit 7d6e297bae244b6a21cd1f6661d8617432d2ad7e
parent 68e7722c48d3bd3d9830b08004ee6965a2241b4e
Author: Jan Dankert <develop@jandankert.de>
Date:   Tue, 29 Sep 2020 22:17:11 +0200

Refactoring: Do not use global constants.

Diffstat:
modules/cms/Dispatcher.class.php | 10++--------
modules/cms/action/Action.class.php | 923+++++++++++++++++++++++++++++++++++++++----------------------------------------
modules/cms/action/ElementAction.class.php | 22+++++++++++-----------
modules/cms/action/FileAction.class.php | 22+++++++++++-----------
modules/cms/action/FolderAction.class.php | 10+++++-----
modules/cms/action/GroupAction.class.php | 12++++++------
modules/cms/action/ImageAction.class.php | 4++--
modules/cms/action/LanguageAction.class.php | 4++--
modules/cms/action/LinkAction.class.php | 8++++----
modules/cms/action/LoginAction.class.php | 72+++++++++++++++++++++++++++++++++++-------------------------------------
modules/cms/action/ModelAction.class.php | 8++++----
modules/cms/action/ObjectAction.class.php | 28++++++++++++++--------------
modules/cms/action/PageAction.class.php | 12++++++------
modules/cms/action/PageelementAction.class.php | 12++++++------
modules/cms/action/ProfileAction.class.php | 6+++---
modules/cms/action/ProjectAction.class.php | 24++++++++++++------------
modules/cms/action/RequestParams.class.php | 353+++++++++++++++++++++++++++++++++++++++----------------------------------------
modules/cms/action/SearchAction.class.php | 2+-
modules/cms/action/StartAction.class.php | 55++++++++++++++++++++++++++-----------------------------
modules/cms/action/TemplateAction.class.php | 22+++++++++++-----------
modules/cms/action/TextAction.class.php | 118++++++++++++++++++++++++++++++++++++++-----------------------------------------
modules/cms/action/UrlAction.class.php | 6+++---
modules/cms/action/UserAction.class.php | 10+++++-----
modules/cms/action/UserlistAction.class.php | 2+-
modules/cms/action/WebdavAction.class.php | 4++--
modules/cms/api/API.class.php | 3+--
modules/cms/auth/RememberAuth.class.php | 2+-
modules/cms/generator/PageGenerator.class.php | 2+-
modules/cms/generator/link/PreviewLink.class.php | 4++--
modules/cms/model/Acl.class.php | 2+-
modules/cms/model/Alias.class.php | 2+-
modules/cms/model/BaseObject.class.php | 14+++++++-------
modules/cms/model/Element.class.php | 6+++---
modules/cms/model/File.class.php | 9++++-----
modules/cms/model/Group.class.php | 4++--
modules/cms/model/Link.class.php | 2+-
modules/cms/model/Name.class.php | 2+-
modules/cms/model/Page.class.php | 2+-
modules/cms/model/Project.class.php | 6+++---
modules/cms/model/Template.class.php | 2+-
modules/cms/model/User.class.php | 2+-
modules/cms/model/Value.class.php | 2+-
modules/cms/ui/UI.class.php | 2+-
modules/cms/ui/action/IndexAction.class.php | 2+-
modules/cms/ui/action/TreeAction.class.php | 3++-
modules/cms/ui/themes/default/html/views/projectlist/show.php | 38--------------------------------------
modules/database/Column.class.php | 18+++++++++---------
modules/database/DbVersion.class.php | 22+++++++++++-----------
modules/database/Table.class.php | 2+-
modules/template_engine/components/html/form/Form.class.php | 12++++++------
modules/template_engine/components/html/link/Link.class.php | 2+-
modules/util/Html.class.php | 12+++++++-----
modules/util/Transformer.class.php | 2+-
modules/util/Tree.class.php | 31++++++++++++++++---------------
modules/util/exception/ObjectNotFoundException.class.php | 10++++++++++
55 files changed, 953 insertions(+), 1018 deletions(-)

diff --git a/modules/cms/Dispatcher.class.php b/modules/cms/Dispatcher.class.php @@ -289,12 +289,6 @@ class Dispatcher $do->request = $this->request; $do->init(); - if(!defined('OR_ID')) - //if (isset($REQ[REQ_PARAM_ID])) - define('OR_ID', $this->request->id); - //else - // define('OR_ID', ''); - $this->checkAccess($do); // POST-Request => ...Post() wird aufgerufen. @@ -316,7 +310,7 @@ class Dispatcher $declaredActionName = strtolower(substr($declaredClassName,0,strpos($declaredClassName,'Action'))); $params = []; foreach( $method->getParameters() as $parameter ) { - $params[ $parameter->getName() ] = $this->request->getRequiredRequestVar($parameter->getName(),OR_FILTER_RAW); + $params[ $parameter->getName() ] = $this->request->getRequiredRequestVar($parameter->getName(),RequestParams::FILTER_RAW); } $method->invokeArgs($do,$params); // <== Executing the Action @@ -347,7 +341,7 @@ class Dispatcher $firstDbContact = ! Session::getDatabaseId() || $this->request->hasRequestVar('dbid'); if ( $this->request->hasRequestVar('dbid') ) - $dbid = $this->request->getRequestVar('dbid',OR_FILTER_ALPHANUM); + $dbid = $this->request->getRequestVar('dbid',RequestParams::FILTER_ALPHANUM); elseif ( Session::getDatabaseId() ) $dbid = Session::getDatabaseId(); elseif ( isset($_COOKIE['or_dbid']) ) diff --git a/modules/cms/action/Action.class.php b/modules/cms/action/Action.class.php @@ -1,470 +1,458 @@ <?php -namespace { - - class ObjectNotFoundException extends Exception - { - } - - - define('OR_NOTICE_OK', 'ok'); - define('OR_NOTICE_INFO', 'info'); - define('OR_NOTICE_WARN', 'warning'); - define('OR_NOTICE_ERROR', 'error'); - -} - - -namespace cms\action { - - use cms\model\BaseObject; - use cms\model\ModelBase; - use cms\model\User; - use util\ClassUtils; - use util\exception\ValidationException; - use util\Html; - use util\Session; - use logger\Logger; - use util\Http; - use util\Text; - - - /** - * Eltern-Klasse fuer alle Actions. - * - * Diese Klasse stellt grundlegende action-uebergreifende Methoden - * bereit. - * Dient als Ueberklasse fuer alle abgeleiteten Action-Klassen in - * diesem Package bzw. Verzeichnis. - * - * @author Jan Dankert - * @package openrat.actions - * @abstract - */ - class Action - { - const SECURITY_GUEST = 1; // Jeder (auch nicht angemeldete) dürfen diese Aktion ausführen - const SECURITY_USER = 2; // Angemeldete Benutzer dürfen diese Aktion ausführen - const SECURITY_ADMIN = 3; // Nur Administratoren dürfen diese Aktion ausführen - - public $security = self::SECURITY_USER; // Default. - - protected $templateVars = array( 'output'=>array() ); - - /** - * Aktuell angemeldeter Benutzer.<br> - * Wird im Konstruktor gesetzt. - * - * @var Object Benutzer - */ - var $currentUser; - - /** - * @var RequestParams - */ - public $request; - - - /** - * Will be called by the Dispatcher right after the contruction of this class instance. - */ - public function init() - { - - } - - - protected function setStyle($style) - { - $this->setControlVar("new_style", $style); - } - - - public function __construct() - { - //$this->request = new RequestParams(); - - $this->currentUser = Session::getUser(); - - $this->templateVars['errors'] = array(); - $this->templateVars['notices'] = array(); - $this->templateVars['control'] = array(); - $this->templateVars['output'] = array(); - } - - /** - * Liest eine Session-Variable - * - * @param String $varName Schl�ssel - * @return mixed - */ - protected function getSessionVar($varName) - { - return Session::get($varName); - } - - - /** - * Setzt eine Session-Variable - * - * @param string $varName Schluessel - * @param mixed $value Inhalt - * @return mixed - */ - protected function setSessionVar($varName, $value) - { - Session::set($varName,$value); - } - - - /** - * Ermittelt den Inhalt der gew�nschten Request-Variablen. - * Falls nicht vorhanden, wird "" zur�ckgegeben. - * - * @param String $varName Schl�ssel - * @return String Inhalt - */ - protected function getRequestVar($varName, $transcode = OR_FILTER_TEXT) - { - return $this->request->getRequestVar($varName,$transcode); - } - - - /** - * Ermittelt, ob der aktuelle Request eine Variable mit dem - * angegebenen Namen enth�lt. - * - * @param String $varName Schl�ssel - * @return boolean true, falls vorhanden. - */ - protected function hasRequestVar($varName) - { - return $this->request->hasRequestVar($varName); - } - - - /** - * Ermittelt die aktuelle Id aus dem Request.<br> - * Um welche ID es sich handelt, ist abh�ngig von der Action. - * - * @return Integer - */ - protected function getRequestId( $name = null ) - { - if ( is_null($name) ) - return $this->request->getRequestId(); - else - return intval($this->request->getRequestVar($name,OR_FILTER_NUMBER)); - } - - - /** - * Setzt eine Variable f�r die Oberfl�che. - * - * @param String $varName Schl�ssel - * @param Mixed $value - */ - protected function setTemplateVar($varName, $value) - { - $this->templateVars['output'][$varName] = $value; - } - - - /** - * Setzt eine Variable f�r die Oberfl�che. - * - * @param String $varName Schl�ssel - * @param Mixed $value - * @deprecated Diese Schicht soll keine Dialog-Logik enthalten. - */ - protected function setControlVar($varName, $value) - { - $this->templateVars['control'][$varName] = $value; - } - - - /** - * Setzt eine Liste von Variablen f�r die Oberfl�che. - * - * @param array $varList Assoziatives Array - */ - protected function setTemplateVars($varList) - { - foreach ($varList as $name => $value) { - $this->setTemplateVar($name, $value); - } - } - - - /** - * F�gt einen Validierungsfehler hinzu. - * - * @param String $name Name des validierten Eingabefeldes - * @param String Textschl�ssel der Fehlermeldung (optional) - */ - public function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array()) - { - if (!empty($message)) - $this->addNotice('', '', $message, OR_NOTICE_ERROR, $vars, $log); - - $this->templateVars['errors'][] = $name; - } - - - public function handleResult($result) - { - // TODO - - } - - - /** - * @param $baseObject ModelBase - * @param $key String - * @param array $vars - * @param string $message - */ - protected function addNoticeFor($baseObject,$key,$vars = array(), $message='') { - $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,OR_NOTICE_OK,$vars,array($message)); +namespace cms\action; + +use cms\model\BaseObject; +use cms\model\ModelBase; +use cms\model\User; +use util\ClassUtils; +use util\exception\ValidationException; +use util\Html; +use util\Session; +use logger\Logger; +use util\Http; +use util\Text; + + +/** + * Eltern-Klasse fuer alle Actions. + * + * Diese Klasse stellt grundlegende action-uebergreifende Methoden + * bereit. + * Dient als Ueberklasse fuer alle abgeleiteten Action-Klassen in + * diesem Package bzw. Verzeichnis. + * + * @author Jan Dankert + * @package openrat.actions + * @abstract + */ +class Action +{ + const SECURITY_GUEST = 1; // Jeder (auch nicht angemeldete) dürfen diese Aktion ausführen + const SECURITY_USER = 2; // Angemeldete Benutzer dürfen diese Aktion ausführen + const SECURITY_ADMIN = 3; // Nur Administratoren dürfen diese Aktion ausführen + + const NOTICE_OK = 'ok'; + const NOTICE_INFO = 'info'; + const NOTICE_WARN = 'warning'; + const NOTICE_ERROR = 'error'; + + public $security = self::SECURITY_USER; // Default. + + protected $templateVars = array( 'output'=>array() ); + + /** + * Aktuell angemeldeter Benutzer.<br> + * Wird im Konstruktor gesetzt. + * + * @var Object Benutzer + */ + var $currentUser; + + /** + * @var RequestParams + */ + public $request; + + + /** + * Will be called by the Dispatcher right after the contruction of this class instance. + */ + public function init() + { + + } + + + protected function setStyle($style) + { + $this->setControlVar("new_style", $style); + } + + + public function __construct() + { + //$this->request = new RequestParams(); + + $this->currentUser = Session::getUser(); + + $this->templateVars['errors'] = array(); + $this->templateVars['notices'] = array(); + $this->templateVars['control'] = array(); + $this->templateVars['output'] = array(); + } + + /** + * Liest eine Session-Variable + * + * @param String $varName Schl�ssel + * @return mixed + */ + protected function getSessionVar($varName) + { + return Session::get($varName); + } + + + /** + * Setzt eine Session-Variable + * + * @param string $varName Schluessel + * @param mixed $value Inhalt + * @return mixed + */ + protected function setSessionVar($varName, $value) + { + Session::set($varName,$value); + } + + + /** + * Ermittelt den Inhalt der gew�nschten Request-Variablen. + * Falls nicht vorhanden, wird "" zur�ckgegeben. + * + * @param String $varName Schl�ssel + * @return String Inhalt + */ + protected function getRequestVar($varName, $transcode = RequestParams::FILTER_TEXT) + { + return $this->request->getRequestVar($varName,$transcode); + } + + + /** + * Ermittelt, ob der aktuelle Request eine Variable mit dem + * angegebenen Namen enth�lt. + * + * @param String $varName Schl�ssel + * @return boolean true, falls vorhanden. + */ + protected function hasRequestVar($varName) + { + return $this->request->hasRequestVar($varName); + } + + + /** + * Ermittelt die aktuelle Id aus dem Request.<br> + * Um welche ID es sich handelt, ist abh�ngig von der Action. + * + * @return Integer + */ + protected function getRequestId( $name = null ) + { + if ( is_null($name) ) + return $this->request->getRequestId(); + else + return intval($this->request->getRequestVar($name,RequestParams::FILTER_NUMBER)); + } + + + /** + * Setzt eine Variable f�r die Oberfl�che. + * + * @param String $varName Schl�ssel + * @param Mixed $value + */ + protected function setTemplateVar($varName, $value) + { + $this->templateVars['output'][$varName] = $value; + } + + + /** + * Setzt eine Variable f�r die Oberfl�che. + * + * @param String $varName Schl�ssel + * @param Mixed $value + * @deprecated Diese Schicht soll keine Dialog-Logik enthalten. + */ + protected function setControlVar($varName, $value) + { + $this->templateVars['control'][$varName] = $value; + } + + + /** + * Setzt eine Liste von Variablen f�r die Oberfl�che. + * + * @param array $varList Assoziatives Array + */ + protected function setTemplateVars($varList) + { + foreach ($varList as $name => $value) { + $this->setTemplateVar($name, $value); } - - /** - * @param $baseObject ModelBase - * @param $key String - * @param array $vars - * @param string $message - */ - protected function addInfoFor($baseObject,$key,$vars = array(), $message='') { - $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,OR_NOTICE_INFO,$vars,array($message)); - } - - /** - * @param $baseObject ModelBase - * @param $key String - * @param array $vars - * @param string $message - */ - protected function addWarningFor($baseObject,$key,$vars = array(), $message='') { - $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,OR_NOTICE_WARN,$vars,array($message)); - } - - /** - * @param $baseObject ModelBase - * @param $key String - * @param array $vars - * @param string $message - */ - protected function addErrorFor($baseObject,$key,$vars = array(), $message='') { - $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,OR_NOTICE_ERROR,$vars,array($message)); - } - - /** - * F�gt ein Meldung hinzu. - * - * @param String $type Typ des Objektes, zu dem diese Meldung geh�rt. - * @param String $name Name des Objektes, zu dem diese Meldung geh�rt. - * @param String $text Textschl�ssel der Fehlermeldung (optional) - * @param String $status Einer der Werte OR_NOTICE_(OK|WARN|ERROR) - * @param array $vars Variablen f�r den Textschl�ssel - * @param array $log Weitere Hinweistexte f�r diese Meldung. - */ - protected function addNotice($type, $name, $text, $status = OR_NOTICE_OK, $vars = array(), $log = array()) - { - if ($status === true) - $status = OR_NOTICE_OK; - elseif ($status === false) - $status = OR_NOTICE_ERROR; - - $this->templateVars['notice_status'] = $status; - $this->templateVars['status'] = $status; - $this->templateVars['success'] = ($status == OR_NOTICE_ERROR ? 'false' : 'true'); - - if (!is_array($log)) - $log = array($log); - - if (!is_array($vars)) - $vars = array($vars); - - $this->templateVars['notices'][] = array('type' => $type, - 'name' => $name, - 'key' => $text, - 'vars' => $vars, - 'text' => \cms\base\Language::lang($text, $vars), - 'log' => $log, - 'status' => $status); - } - - - public function getOutputData() - { - return $this->templateVars; - } - - /** - * Ruft eine weitere Subaction auf. - * - * @param String $subActionName Name der n�chsten Subaction. Es muss eine Methode mit diesem Namen geben. - * @deprecated - */ - protected function callSubAction($subActionName) - { - return; - } - - - /** - * Calling another action method. - * - * @param String $method Name of next method to call. - */ - protected function nextSubAction($method) - { - Logger::trace("next subaction is '$method'"); - - $this->request->method = $method; - - $methodName = $method . ($_SERVER['REQUEST_METHOD'] == 'POST' ? 'Post' : 'View'); - $this->$methodName(); - } - - - /** - * Ermitteln, ob Benutzer Administratorrechte besitzt - * @return Boolean TRUE, falls der Benutzer ein Administrator ist. - */ - protected function userIsAdmin() - { - $user = $this->getUserFromSession(); - return is_object($user) && $user->isAdmin; - } - - - /** - * Ermitteln des Benutzerobjektes aus der Session - * @return User - */ - protected function getUserFromSession() - { - return Session::getUser(); - } - - - /** - * Benutzen eines sog. "Conditional GET". - * - * Diese Funktion setzt einen "Last-Modified"-HTTP-Header. - * Ist der Inhalt der Seite nicht neuer, so wird der Inhalt - * der Seite nicht ausgegeben, sondern nur HTTP-Status 304 - * ("304 not modified") gesetzt. - * Der Rest der Seite muss dann nicht mehr erzeugt werden, - * wodurch die Performance stark erhoeht werden kann. - * - * Credits: Danke an Charles Miller - * @see http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers - * - * Gefunden auf: - * @see http://simon.incutio.com/archive/2003/04/23/conditionalGet - * - * @param $time int Letztes Aenderungsdatum des Objektes - * @param $expirationDuration int Gültigkeitsdauer - */ - protected function lastModified($time, $expirationDuration = 0) - { - if ( DEVELOPMENT ) - return; - - // Conditional-Get eingeschaltet? - if (!\cms\base\Configuration::config('cache', 'conditional_get')) - return; - - $expires = substr(date('r', time() + $expirationDuration - date('Z')), 0, -5) . 'GMT'; - $lastModified = substr(date('r', $time - date('Z')), 0, -5) . 'GMT'; - $etag = '"' . base_convert($time, 10, 36) . '"'; - - // Header senden - header('Expires: ' . $expires); - header('Last-Modified: ' . $lastModified); - header('ETag: ' . $etag); - - // Die vom Interpreter sonst automatisch gesetzten - // Header uebersteuern - header('Cache-Control: must-revalidate'); - header('Pragma:'); - - // See if the client has provided the required headers - $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false; - $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false; - - // Bug in Apache 2.2, mod_deflat adds '-gzip' to E-Tag - if (substr($if_none_match, -6) == '-gzip"') - $if_none_match = substr($if_none_match, 0, -6) . '"'; - - // At least one of the headers is there - check them - if ($if_none_match && $if_none_match != $etag) - return; // etag is there but doesn't match - - if ($if_modified_since && $if_modified_since != $lastModified) - return; // if-modified-since is there but doesn't match - - if (!$if_modified_since && !$if_none_match) - return; - - // Der entfernte Browser bzw. Proxy holt die Seite nun aus seinem Cache - header('HTTP/1.0 304 Not Modified'); - exit; // Sofortiges Skript-Ende - } - - - /** - * @param $max int max Anzahl der Sekunden, die die Seite im Browsercache bleiben darf - */ - protected function maxAge($max = 3600) - { - // Die Header "Last-Modified" und "ETag" wurden bereits in der - // Methode "lastModified()" gesetzt. - - header('Expires: ' . substr(date('r', time() - date('Z') + $max), 0, -5) . 'GMT'); - header('Pragma: '); // 'Pragma' ist Bullshit und - // wird von den meisten Browsern ignoriert. - header('Cache-Control: public, max-age=' . $max . ", s-maxage=" . $max); - } - - - /** - * Erzeugt einen Redirect auf einen bestimmte URL. - */ - protected function redirect($url) - { - $this->setControlVar('redirect', $url); - } - - - protected function setCookie($name,$value='' ) { - - if (empty($value)) - $expire = time(); // Cookie wird gelöscht. - else - $expire = time() + 60 * 60 * 24 * \cms\base\Configuration::config('security', 'cookie', 'expire'); - - $secure = \cms\base\Configuration::config('security', 'cookie', 'secure'); - $httponly = \cms\base\Configuration::config('security', 'cookie', 'httponly'); - $samesite = \cms\base\Configuration::config('security', 'cookie', 'samesite'); - - $cookieAttributes = [ - rawurlencode($name).'='.rawurlencode($value), - 'Expires='.date('r',$expire), - 'Path='.COOKIE_PATH - ]; - - if ( $secure ) - $cookieAttributes[] = 'Secure'; - - if ( $httponly ) - $cookieAttributes[] = 'HttpOnly'; - - $cookieAttributes[] = 'SameSite='.$samesite; - - header('Set-Cookie: '.implode('; ',$cookieAttributes) ); - } - } - -}- \ No newline at end of file + } + + + /** + * F�gt einen Validierungsfehler hinzu. + * + * @param String $name Name des validierten Eingabefeldes + * @param String Textschl�ssel der Fehlermeldung (optional) + */ + public function addValidationError($name, $message = "COMMON_VALIDATION_ERROR", $vars = array(), $log = array()) + { + if (!empty($message)) + $this->addNotice('', '', $message, Action::NOTICE_ERROR, $vars, $log); + + $this->templateVars['errors'][] = $name; + } + + + public function handleResult($result) + { + // TODO - + } + + + /** + * @param $baseObject ModelBase + * @param $key String + * @param array $vars + * @param string $message + */ + protected function addNoticeFor($baseObject,$key,$vars = array(), $message='') { + $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,Action::NOTICE_OK,$vars,array($message)); + } + + /** + * @param $baseObject ModelBase + * @param $key String + * @param array $vars + * @param string $message + */ + protected function addInfoFor($baseObject,$key,$vars = array(), $message='') { + $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,Action::NOTICE_INFO,$vars,array($message)); + } + + /** + * @param $baseObject ModelBase + * @param $key String + * @param array $vars + * @param string $message + */ + protected function addWarningFor($baseObject,$key,$vars = array(), $message='') { + $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,Action::NOTICE_WARN,$vars,array($message)); + } + + /** + * @param $baseObject ModelBase + * @param $key String + * @param array $vars + * @param string $message + */ + protected function addErrorFor($baseObject,$key,$vars = array(), $message='') { + $this->addNotice( strtolower(ClassUtils::getSimpleClassName($baseObject)),$baseObject->getName(),$key,Action::NOTICE_ERROR,$vars,array($message)); + } + + /** + * F�gt ein Meldung hinzu. + * + * @param String $type Typ des Objektes, zu dem diese Meldung geh�rt. + * @param String $name Name des Objektes, zu dem diese Meldung geh�rt. + * @param String $text Textschl�ssel der Fehlermeldung (optional) + * @param String $status Einer der Werte Action::NOTICE_(OK|WARN|ERROR) + * @param array $vars Variablen f�r den Textschl�ssel + * @param array $log Weitere Hinweistexte f�r diese Meldung. + */ + protected function addNotice($type, $name, $text, $status = Action::NOTICE_OK, $vars = array(), $log = array()) + { + if ($status === true) + $status = Action::NOTICE_OK; + elseif ($status === false) + $status = Action::NOTICE_ERROR; + + $this->templateVars['notice_status'] = $status; + $this->templateVars['status'] = $status; + $this->templateVars['success'] = ($status == Action::NOTICE_ERROR ? 'false' : 'true'); + + if (!is_array($log)) + $log = array($log); + + if (!is_array($vars)) + $vars = array($vars); + + $this->templateVars['notices'][] = array('type' => $type, + 'name' => $name, + 'key' => $text, + 'vars' => $vars, + 'text' => \cms\base\Language::lang($text, $vars), + 'log' => $log, + 'status' => $status); + } + + + public function getOutputData() + { + return $this->templateVars; + } + + /** + * Ruft eine weitere Subaction auf. + * + * @param String $subActionName Name der n�chsten Subaction. Es muss eine Methode mit diesem Namen geben. + * @deprecated + */ + protected function callSubAction($subActionName) + { + return; + } + + + /** + * Calling another action method. + * + * @param String $method Name of next method to call. + */ + protected function nextSubAction($method) + { + Logger::trace("next subaction is '$method'"); + + $this->request->method = $method; + + $methodName = $method . ($_SERVER['REQUEST_METHOD'] == 'POST' ? 'Post' : 'View'); + $this->$methodName(); + } + + + /** + * Ermitteln, ob Benutzer Administratorrechte besitzt + * @return Boolean TRUE, falls der Benutzer ein Administrator ist. + */ + protected function userIsAdmin() + { + $user = $this->getUserFromSession(); + return is_object($user) && $user->isAdmin; + } + + + /** + * Ermitteln des Benutzerobjektes aus der Session + * @return User + */ + protected function getUserFromSession() + { + return Session::getUser(); + } + + + /** + * Benutzen eines sog. "Conditional GET". + * + * Diese Funktion setzt einen "Last-Modified"-HTTP-Header. + * Ist der Inhalt der Seite nicht neuer, so wird der Inhalt + * der Seite nicht ausgegeben, sondern nur HTTP-Status 304 + * ("304 not modified") gesetzt. + * Der Rest der Seite muss dann nicht mehr erzeugt werden, + * wodurch die Performance stark erhoeht werden kann. + * + * Credits: Danke an Charles Miller + * @see http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers + * + * Gefunden auf: + * @see http://simon.incutio.com/archive/2003/04/23/conditionalGet + * + * @param $time int Letztes Aenderungsdatum des Objektes + * @param $expirationDuration int Gültigkeitsdauer + */ + protected function lastModified($time, $expirationDuration = 0) + { + if ( DEVELOPMENT ) + return; + + // Conditional-Get eingeschaltet? + if (!\cms\base\Configuration::config('cache', 'conditional_get')) + return; + + $expires = substr(date('r', time() + $expirationDuration - date('Z')), 0, -5) . 'GMT'; + $lastModified = substr(date('r', $time - date('Z')), 0, -5) . 'GMT'; + $etag = '"' . base_convert($time, 10, 36) . '"'; + + // Header senden + header('Expires: ' . $expires); + header('Last-Modified: ' . $lastModified); + header('ETag: ' . $etag); + + // Die vom Interpreter sonst automatisch gesetzten + // Header uebersteuern + header('Cache-Control: must-revalidate'); + header('Pragma:'); + + // See if the client has provided the required headers + $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false; + $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false; + + // Bug in Apache 2.2, mod_deflat adds '-gzip' to E-Tag + if (substr($if_none_match, -6) == '-gzip"') + $if_none_match = substr($if_none_match, 0, -6) . '"'; + + // At least one of the headers is there - check them + if ($if_none_match && $if_none_match != $etag) + return; // etag is there but doesn't match + + if ($if_modified_since && $if_modified_since != $lastModified) + return; // if-modified-since is there but doesn't match + + if (!$if_modified_since && !$if_none_match) + return; + + // Der entfernte Browser bzw. Proxy holt die Seite nun aus seinem Cache + header('HTTP/1.0 304 Not Modified'); + exit; // Sofortiges Skript-Ende + } + + + /** + * @param $max int max Anzahl der Sekunden, die die Seite im Browsercache bleiben darf + */ + protected function maxAge($max = 3600) + { + // Die Header "Last-Modified" und "ETag" wurden bereits in der + // Methode "lastModified()" gesetzt. + + header('Expires: ' . substr(date('r', time() - date('Z') + $max), 0, -5) . 'GMT'); + header('Pragma: '); // 'Pragma' ist Bullshit und + // wird von den meisten Browsern ignoriert. + header('Cache-Control: public, max-age=' . $max . ", s-maxage=" . $max); + } + + + /** + * Erzeugt einen Redirect auf einen bestimmte URL. + */ + protected function redirect($url) + { + $this->setControlVar('redirect', $url); + } + + + protected function setCookie($name,$value='' ) { + + if (empty($value)) + $expire = time(); // Cookie wird gelöscht. + else + $expire = time() + 60 * 60 * 24 * \cms\base\Configuration::config('security', 'cookie', 'expire'); + + $secure = \cms\base\Configuration::config('security', 'cookie', 'secure'); + $httponly = \cms\base\Configuration::config('security', 'cookie', 'httponly'); + $samesite = \cms\base\Configuration::config('security', 'cookie', 'samesite'); + + $cookieAttributes = [ + rawurlencode($name).'='.rawurlencode($value), + 'Expires='.date('r',$expire), + 'Path='.COOKIE_PATH + ]; + + if ( $secure ) + $cookieAttributes[] = 'Secure'; + + if ( $httponly ) + $cookieAttributes[] = 'HttpOnly'; + + $cookieAttributes[] = 'SameSite='.$samesite; + + header('Set-Cookie: '.implode('; ',$cookieAttributes) ); + } +} diff --git a/modules/cms/action/ElementAction.class.php b/modules/cms/action/ElementAction.class.php @@ -76,13 +76,13 @@ class ElementAction extends BaseAction { // Nur Inhalte löschen $this->element->deleteValues(); - $this->addNotice('element',$this->element->name,'DELETED',OR_NOTICE_OK); + $this->addNotice('element',$this->element->name,'DELETED',Action::NOTICE_OK); } elseif ( $type == 'all' ) { // Element löschen $this->element->delete(); - $this->addNotice('element',$this->element->name,'DELETED',OR_NOTICE_OK); + $this->addNotice('element',$this->element->name,'DELETED',Action::NOTICE_OK); } } @@ -106,9 +106,9 @@ class ElementAction extends BaseAction if ( $this->hasRequestVar('default_longtext')) - $this->element->defaultText = $this->getRequestVar('default_longtext',OR_FILTER_TEXT); + $this->element->defaultText = $this->getRequestVar('default_longtext',RequestParams::FILTER_TEXT); else - $this->element->defaultText = $this->getRequestVar('default_text',OR_FILTER_TEXT); + $this->element->defaultText = $this->getRequestVar('default_text',RequestParams::FILTER_TEXT); $this->element->subtype = $this->getRequestVar('subtype'); @@ -127,7 +127,7 @@ class ElementAction extends BaseAction if ( $this->hasRequestVar('select_items')) $this->element->code = $this->getRequestVar('select_items'); else - $this->element->code = $this->getRequestVar('code' ,OR_FILTER_RAW); + $this->element->code = $this->getRequestVar('code' ,RequestParams::FILTER_RAW); if ( $this->hasRequestVar('name') ) $this->element->name = $this->getRequestVar('name'); @@ -136,7 +136,7 @@ class ElementAction extends BaseAction $this->element->setPrefix( $this->getRequestVar('linkelement') ); if ( $this->hasRequestVar('parameters')) - $this->element->code = $this->getRequestVar('parameters',OR_FILTER_RAW); + $this->element->code = $this->getRequestVar('parameters',RequestParams::FILTER_RAW); $this->element->save(); $this->addNotice('element',$this->element->name,'SAVED'); @@ -456,7 +456,7 @@ class ElementAction extends BaseAction case Element::ELEMENT_TYPE_CODE: if ( $conf['security']['disable_dynamic_code'] ) - $this->addNotice('element',$this->element->name,'CODE_DISABLED',OR_NOTICE_WARN); + $this->addNotice('element',$this->element->name,'CODE_DISABLED',Action::NOTICE_WARN); $this->setTemplateVar('code',$this->element->code); break; @@ -608,13 +608,13 @@ class ElementAction extends BaseAction $this->element->typeid = $this->getRequestId('typeid'); - $this->element->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM); - $this->element->label= $this->getRequestVar('label' ,OR_FILTER_TEXT); - $this->element->desc = $this->getRequestVar('description',OR_FILTER_TEXT); + $this->element->name = $this->getRequestVar('name' ,RequestParams::FILTER_ALPHANUM); + $this->element->label= $this->getRequestVar('label' ,RequestParams::FILTER_TEXT); + $this->element->desc = $this->getRequestVar('description',RequestParams::FILTER_TEXT); $this->element->save(); - $this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('element',$this->element->name,'SAVED',Action::NOTICE_OK); } } diff --git a/modules/cms/action/FileAction.class.php b/modules/cms/action/FileAction.class.php @@ -61,7 +61,7 @@ class FileAction extends ObjectAction public function init() { $file = new File( $this->getRequestId() ); - $file->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID); + $file->languageid = $this->getRequestVar(RequestParams::PARAM_LANGUAGE_ID); $file->load(); $this->setBaseObject( $file ); @@ -131,9 +131,9 @@ class FileAction extends ObjectAction */ function advancedPost() { - $this->file->extension = $this->getRequestVar('extension' ,OR_FILTER_FILENAME); + $this->file->extension = $this->getRequestVar('extension' ,RequestParams::FILTER_FILENAME); - $typeid = $this->getRequestVar('type',OR_FILTER_NUMBER ); + $typeid = $this->getRequestVar('type',RequestParams::FILTER_NUMBER ); if ( ! in_array($typeid,[BaseObject::TYPEID_FILE,BaseObject::TYPEID_IMAGE,BaseObject::TYPEID_TEXT])) throw new ValidationException('type'); @@ -187,7 +187,7 @@ class FileAction extends ObjectAction $mime_type = $mime_types[$ext]; else // Wenn kein Mime-Type gefunden, dann Standardwert setzen - $mime_type = OR_FILE_DEFAULT_MIMETYPE; + $mime_type = File::DEFAULT_MIMETYPE; header('Content-Type: '.$mime_type ); header('Content-Encoding: gzip' ); @@ -373,7 +373,7 @@ class FileAction extends ObjectAction throw new \util\exception\UIException('','cannot uncompress file with extension: ' . $this->file->extension ); } - $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK); + $this->addNotice('file',$this->file->name,'DONE',Action::NOTICE_OK); $this->callSubAction('edit'); } @@ -475,12 +475,12 @@ class FileAction extends ObjectAction */ function compressPost() { - $format = $this->getRequestVar('format',OR_FILTER_ALPHANUM); + $format = $this->getRequestVar('format',RequestParams::FILTER_ALPHANUM); switch( $format ) { case 'gz': - if ( $this->getRequestVar('replace',OR_FILTER_NUMBER)=='1' ) + if ( $this->getRequestVar('replace',RequestParams::FILTER_NUMBER)=='1' ) { $this->file->value = gzencode( $this->file->loadValue(),1 ); $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz',FORCE_GZIP ); @@ -524,7 +524,7 @@ class FileAction extends ObjectAction throw new \util\exception\UIException('unknown compress type: ' . $format ); } - $this->addNotice('file',$this->file->name,'DONE',OR_NOTICE_OK); + $this->addNotice('file',$this->file->name,'DONE',Action::NOTICE_OK); $this->callSubAction('edit'); } @@ -547,7 +547,7 @@ class FileAction extends ObjectAction $publisher = new Publisher( $this->file->projectid ); $publisher->publish( $fileGenerator->getCache()->load()->getFilename(),$fileGenerator->getPublicFilename(),$this->file->lastchangeDate ); - $this->addNoticeFor($this->file,'PUBLISHED',OR_NOTICE_OK ); + $this->addNoticeFor($this->file,'PUBLISHED',Action::NOTICE_OK ); } @@ -582,11 +582,11 @@ class FileAction extends ObjectAction if ( $this->getRequestVar('delete') != '' ) { $this->file->delete(); - $this->addNotice('template',$this->file->filename,'DELETED',OR_NOTICE_OK); + $this->addNotice('template',$this->file->filename,'DELETED',Action::NOTICE_OK); } else { - $this->addNotice('template',$this->file->filename,'CANCELED',OR_NOTICE_WARN); + $this->addNotice('template',$this->file->filename,'CANCELED',Action::NOTICE_WARN); } } } diff --git a/modules/cms/action/FolderAction.class.php b/modules/cms/action/FolderAction.class.php @@ -589,7 +589,7 @@ class FolderAction extends ObjectAction $type == 'delete' && $o->hasRight( Acl::ACL_DELETE ) ) $objectList[ $id ] = $o->getProperties(); else - $this->addNotice($o->getType(),$o->name,'no_rights',OR_NOTICE_WARN); + $this->addNotice($o->getType(),$o->name,'no_rights',Action::NOTICE_WARN); } $ids = array_keys($objectList); @@ -628,7 +628,7 @@ class FolderAction extends ObjectAction else { // Was anderes als Dateien ignorieren. - $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN); + $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',Action::NOTICE_WARN); } } @@ -788,11 +788,11 @@ class FolderAction extends ObjectAction default: throw new \LogicException("Error while deleting: Unknown type: {$o->getType()}"); } - $this->addNotice($o->getType(),$o->name,'DELETED',OR_NOTICE_OK); + $this->addNotice($o->getType(),$o->name,'DELETED',Action::NOTICE_OK); } else { - $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN); + $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',Action::NOTICE_WARN); } break; @@ -978,7 +978,7 @@ class FolderAction extends ObjectAction $this->setTemplateVar('objectid' ,$this->folder->objectid ); if ( count($all_templates) == 0 ) - $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN); + $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',Action::NOTICE_WARN); } diff --git a/modules/cms/action/GroupAction.class.php b/modules/cms/action/GroupAction.class.php @@ -66,11 +66,11 @@ class GroupAction extends BaseAction { $this->group->delete(); - $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK); + $this->addNotice('group',$this->group->name,'DELETED',Action::NOTICE_OK); } else { - $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN); + $this->addNotice('group',$this->group->name,'NOTHING_DONE',Action::NOTICE_WARN); } } @@ -116,7 +116,7 @@ class GroupAction extends BaseAction { $this->group->addUser( $uid ); } - $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OR_NOTICE_OK,array('count'=>count($userid))); + $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',Action::NOTICE_OK,array('count'=>count($userid))); } elseif( intval($userid) > 0 ) { @@ -127,7 +127,7 @@ class GroupAction extends BaseAction else { // Es wurde kein Benutzer ausgew�hlt. - $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN); + $this->addNotice('group',$this->group->name,'NOTHING_DONE',Action::NOTICE_WARN); } } @@ -140,7 +140,7 @@ class GroupAction extends BaseAction { $this->group->delUser( intval($this->getRequestVar('userid')) ); - $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK); + $this->addNotice('group',$this->group->name,'DELETED',Action::NOTICE_OK); } @@ -209,7 +209,7 @@ class GroupAction extends BaseAction $conf = \cms\base\Configuration::rawConfig(); if ($conf['security']['authorize']['type']=='ldap') - $this->addNotice('group',$this->group->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN); + $this->addNotice('group',$this->group->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',Action::NOTICE_WARN); } diff --git a/modules/cms/action/ImageAction.class.php b/modules/cms/action/ImageAction.class.php @@ -62,13 +62,13 @@ class ImageAction extends FileAction if ( $format == 0 ) { - $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',OR_NOTICE_WARN); + $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',Action::NOTICE_WARN); } $formats = $this->imageFormats(); if ( empty($formats) ) - $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',OR_NOTICE_WARN); + $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',Action::NOTICE_WARN); $sizes = array(); foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s ) diff --git a/modules/cms/action/LanguageAction.class.php b/modules/cms/action/LanguageAction.class.php @@ -67,7 +67,7 @@ class LanguageAction extends BaseAction { $this->language->setDefault(); - $this->addNotice('language',$this->language->name,'DONE',OR_NOTICE_OK); + $this->addNotice('language',$this->language->name,'DONE',Action::NOTICE_OK); } @@ -114,7 +114,7 @@ class LanguageAction extends BaseAction $this->language->save(); - $this->addNotice('language',$this->language->name,'DONE',OR_NOTICE_OK); + $this->addNotice('language',$this->language->name,'DONE',Action::NOTICE_OK); } diff --git a/modules/cms/action/LinkAction.class.php b/modules/cms/action/LinkAction.class.php @@ -79,7 +79,7 @@ class LinkAction extends ObjectAction $this->link->linkedObjectId = $this->getRequestVar('targetobjectid'); $this->link->save(); - $this->addNotice('link',$this->link->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('link',$this->link->name,'SAVED',Action::NOTICE_OK); } @@ -108,9 +108,9 @@ class LinkAction extends ObjectAction { if ($this->getRequestVar('delete') != '') { $this->link->delete(); - $this->addNotice('link', $this->link->filename, 'DELETED', OR_NOTICE_OK); + $this->addNotice('link', $this->link->filename, 'DELETED', Action::NOTICE_OK); } else { - $this->addNotice('link', $this->link->filename, 'CANCELED', OR_NOTICE_WARN); + $this->addNotice('link', $this->link->filename, 'CANCELED', Action::NOTICE_WARN); } } @@ -132,7 +132,7 @@ class LinkAction extends ObjectAction $o->load(); echo '<a href="'.Html::url($o->getType(),'show',$o->objectid).'">'.$o->filename.'</a>'; } - catch( \ObjectNotFoundException $e ) { + catch( \util\exception\ObjectNotFoundException $e ) { echo '-'; } diff --git a/modules/cms/action/LoginAction.class.php b/modules/cms/action/LoginAction.class.php @@ -14,7 +14,7 @@ use util\FileUtils; use util\Http; use cms\auth\InternalAuth; use logger\Logger; -use \ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; use util\exception\UIException; use \security\Password; use util\Session; @@ -39,8 +39,6 @@ use util\Text; // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -define('PROJECTID_ADMIN',-1); - /** * Action-Klasse fuer die Start-Action * @author $Author$ @@ -82,14 +80,14 @@ class LoginAction extends BaseAction if ( !is_object($db) ) { - $this->addNotice('database','','DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('no connection')); + $this->addNotice('database','','DATABASE_CONNECTION_ERROR',Action::NOTICE_ERROR,array(),array('no connection')); //$this->callSubAction('showlogin'); return false; } if ( !$db->available ) { - $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error)); + $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',Action::NOTICE_ERROR,array(),array('Database Error: '.$db->error)); //$this->callSubAction('showlogin'); return false; } @@ -291,7 +289,7 @@ class LoginAction extends BaseAction if ( empty($dbids) ) - $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN); + $this->addNotice('','','no_database_configuration',Action::NOTICE_WARN); if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) ) $this->setTemplateVar('login_name',$_COOKIE['or_username']); @@ -329,10 +327,10 @@ class LoginAction extends BaseAction } - $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) ); + $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('languageid',$this->getRequestVar('languageid',RequestParams::FILTER_NUMBER) ); $this->setTemplateVar('register' ,$conf['login' ]['register' ]); $this->setTemplateVar('send_password',$conf['login' ]['send_password']); @@ -389,7 +387,7 @@ class LoginAction extends BaseAction if ( empty($dbids) ) - $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN); + $this->addNotice('','','no_database_configuration',Action::NOTICE_WARN); if ( !isset($_COOKIE['or_username']) ) $this->setTemplateVar('login_name',$_COOKIE['or_username']); @@ -404,10 +402,10 @@ class LoginAction extends BaseAction else $this->setTemplateVar('actdbid',$conf['database']['default']); - $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) ); + $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('languageid',$this->getRequestVar('languageid',RequestParams::FILTER_NUMBER) ); } @@ -549,10 +547,10 @@ class LoginAction extends BaseAction throw new \util\exception\SecurityException('login disabled'); $openid_user = $this->getRequestVar('openid_url' ); - $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM); - $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM); - $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM); - $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM); + $loginName = $this->getRequestVar('login_name' ,RequestParams::FILTER_ALPHANUM); + $loginPassword = $this->getRequestVar('login_password',RequestParams::FILTER_ALPHANUM); + $newPassword1 = $this->getRequestVar('password1' ,RequestParams::FILTER_ALPHANUM); + $newPassword2 = $this->getRequestVar('password2' ,RequestParams::FILTER_ALPHANUM); // Cookie setzen $this->setCookie('or_username',$loginName ); @@ -636,11 +634,11 @@ class LoginAction extends BaseAction if ( $conf['login']['nologin'] ) throw new \util\exception\SecurityException('login disabled'); - $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM); - $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM); - $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM); - $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM); - $token = $this->getRequestVar('user_token' ,OR_FILTER_ALPHANUM); + $loginName = $this->getRequestVar('login_name' ,RequestParams::FILTER_ALPHANUM); + $loginPassword = $this->getRequestVar('login_password',RequestParams::FILTER_ALPHANUM); + $newPassword1 = $this->getRequestVar('password1' ,RequestParams::FILTER_ALPHANUM); + $newPassword2 = $this->getRequestVar('password2' ,RequestParams::FILTER_ALPHANUM); + $token = $this->getRequestVar('user_token' ,RequestParams::FILTER_ALPHANUM); // Der Benutzer hat zwar ein richtiges Kennwort eingegeben, aber dieses ist abgelaufen. // Wir versuchen hier, das neue zu setzen (sofern eingegeben). @@ -823,7 +821,7 @@ class LoginAction extends BaseAction if ( \cms\base\Configuration::config()->subset('security')->is('renew_session_login',false) ) $this->recreateSession(); - $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname)); + $this->addNotice('user',$user->name,'LOGIN_OK',Action::NOTICE_OK,array('name'=>$user->fullname)); $this->setStyle( $user->style ); // Benutzer-Style setzen @@ -900,7 +898,7 @@ class LoginAction extends BaseAction // Der Style des Benutzers koennte auch stehen bleiben. Aber dann gäbe es Rückschlüsse darauf, wer zuletzt angemeldet war (Sicherheit!). $this->setStyle( \cms\base\Configuration::config('interface','style','default') ); - $this->addNotice('user',$user->name,'LOGOUT_OK',OR_NOTICE_OK); + $this->addNotice('user',$user->name,'LOGOUT_OK',Action::NOTICE_OK); } @@ -998,7 +996,7 @@ class LoginAction extends BaseAction return; } - $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) ); + $this->evaluateRequestVars( array(RequestParams::PARAM_LANGUAGE_ID=>$this->getRequestId()) ); } @@ -1011,7 +1009,7 @@ class LoginAction extends BaseAction return; } - $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) ); + $this->evaluateRequestVars( array(RequestParams::PARAM_MODEL_ID=>$this->getRequestId()) ); $user = Session::getUser(); } @@ -1072,7 +1070,7 @@ class LoginAction extends BaseAction else { Logger::warn('Guest login failed, user not found: '.$username); - $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) ); + $this->addNotice('user',$username,'LOGIN_FAILED',Action::NOTICE_WARN,array('name'=>$username) ); $user = null; } } @@ -1173,7 +1171,7 @@ class LoginAction extends BaseAction Session::set('registerCode',$registerCode ); - $email_address = $this->getRequestVar('mail',OR_FILTER_MAIL); + $email_address = $this->getRequestVar('mail',RequestParams::FILTER_MAIL); if ( ! Mail::checkAddress($email_address) ) { @@ -1188,11 +1186,11 @@ class LoginAction extends BaseAction if ( $mail->send() ) { - $this->addNotice('','','mail_sent',OR_NOTICE_OK); + $this->addNotice('','','mail_sent',Action::NOTICE_OK); } else { - $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); + $this->addNotice('','','mail_not_sent',Action::NOTICE_ERROR,array(),$mail->error); return; } } @@ -1302,9 +1300,9 @@ class LoginAction extends BaseAction $eMail->setVar('name',$user->getName()); $eMail->setVar('code',$code); if ( $eMail->send() ) - $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK); + $this->addNotice('user',$user->getName(),'mail_sent',Action::NOTICE_OK); else - $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error); + $this->addNotice('user',$user->getName(),'mail_not_sent',Action::NOTICE_ERROR,array(),$eMail->error); } else @@ -1351,7 +1349,7 @@ class LoginAction extends BaseAction if ( !$user->isValid() ) { // Benutzer konnte nicht geladen werden. - $this->addNotice('user',$username,'error',OR_NOTICE_ERROR); + $this->addNotice('user',$username,'error',Action::NOTICE_ERROR); return; } @@ -1364,13 +1362,13 @@ class LoginAction extends BaseAction if ( $eMail->send() ) { $user->setPassword( $newPw, false ); // Kennwort muss beim n?. Login ge?ndert werden. - $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK); + $this->addNotice('user',$username,'mail_sent',Action::NOTICE_OK); } else { // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den // Code per E-Mail erhalten hat. - $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error); + $this->addNotice('user',$username,'error',Action::NOTICE_ERROR,array(),$eMail->error); } } diff --git a/modules/cms/action/ModelAction.class.php b/modules/cms/action/ModelAction.class.php @@ -79,7 +79,7 @@ class ModelAction extends BaseAction if ( $this->hasRequestVar('is_default') ) $this->model->setDefault(); - $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); + $this->addNotice('model',$this->model->name,'DONE',Action::NOTICE_OK); } @@ -103,11 +103,11 @@ class ModelAction extends BaseAction if ( $this->hasRequestVar('confirm') ) { $this->model->delete(); - $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); + $this->addNotice('model',$this->model->name,'DONE',Action::NOTICE_OK); } else { - $this->addNotice('model',$this->model->name,'NOTHING_DONE',OR_NOTICE_WARN); + $this->addNotice('model',$this->model->name,'NOTHING_DONE',Action::NOTICE_WARN); } } @@ -119,7 +119,7 @@ class ModelAction extends BaseAction $this->model->setDefault(); - $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); + $this->addNotice('model',$this->model->name,'DONE',Action::NOTICE_OK); } diff --git a/modules/cms/action/ObjectAction.class.php b/modules/cms/action/ObjectAction.class.php @@ -62,7 +62,7 @@ class ObjectAction extends BaseAction $sourceObject = new BaseObject( $this->getRequestId()); $sourceObject->load(); - $targetFolder = new BaseObject( $this->getRequestVar('targetFolderId',OR_FILTER_NUMBER)); + $targetFolder = new BaseObject( $this->getRequestVar('targetFolderId',RequestParams::FILTER_NUMBER)); $targetFolder->load(); $this->setTemplateVar('source' ,$sourceObject->getProperties() ); @@ -73,7 +73,7 @@ class ObjectAction extends BaseAction if ( ! $targetFolder->hasRight(Acl::ACL_WRITE) ) { - $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR); + $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',Action::NOTICE_ERROR); } } @@ -84,8 +84,8 @@ class ObjectAction extends BaseAction public function copyPost() { $type = $this->getRequestVar('type'); - $targetObjectId = $this->getRequestVar('targetid',OR_FILTER_NUMBER); - $sourceObjectId = $this->getRequestVar('sourceid',OR_FILTER_NUMBER); + $targetObjectId = $this->getRequestVar('targetid',RequestParams::FILTER_NUMBER); + $sourceObjectId = $this->getRequestVar('sourceid',RequestParams::FILTER_NUMBER); $sourceObject = new BaseObject( $sourceObjectId ); $sourceObject->load(); @@ -96,7 +96,7 @@ class ObjectAction extends BaseAction // Prüfen, ob Schreibrechte im Zielordner bestehen. if ( ! $targetFolder->hasRight(Acl::ACL_WRITE) ) { - $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR); + $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',Action::NOTICE_ERROR); return; } @@ -118,7 +118,7 @@ class ObjectAction extends BaseAction // dann verschieben if ( in_array($targetObjectId,$allsubfolders) || $sourceObjectId == $targetObjectId ) { - $this->addNotice('folder',$sourceObject->name,'ERROR',OR_NOTICE_ERROR); + $this->addNotice('folder',$sourceObject->name,'ERROR',Action::NOTICE_ERROR); return; } } @@ -201,7 +201,7 @@ class ObjectAction extends BaseAction // von Verkn�pfungen vorhanden sein. if ( ! $targetFolder->hasRight(Acl::ACL_CREATE_LINK) ) { - $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',OR_NOTICE_ERROR); + $this->addNotice('folder', $targetFolder->name, 'NOT_WRITABLE',Action::NOTICE_ERROR); return; } @@ -275,7 +275,7 @@ class ObjectAction extends BaseAction return; } - $acl->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID); + $acl->languageid = $this->getRequestVar(RequestParams::PARAM_LANGUAGE_ID); $acl->write = ( $this->hasRequestVar('write' ) ); $acl->prop = ( $this->hasRequestVar('prop' ) ); @@ -313,7 +313,7 @@ class ObjectAction extends BaseAction - $this->addNotice('','','ADDED',OR_NOTICE_OK); + $this->addNotice('','','ADDED',Action::NOTICE_OK); $o->setTimestamp(); } @@ -378,7 +378,7 @@ class ObjectAction extends BaseAction if ( ! $this->hasRequestVar('inherit') ) { - $this->addNotice('folder',$folder->name,'NOTHING_DONE',OR_NOTICE_WARN); + $this->addNotice('folder',$folder->name,'NOTHING_DONE',Action::NOTICE_WARN); return; } @@ -426,7 +426,7 @@ class ObjectAction extends BaseAction } } - $this->addNotice('folder',$folder->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('folder',$folder->name,'SAVED',Action::NOTICE_OK); } @@ -475,7 +475,7 @@ class ObjectAction extends BaseAction $acl->delete(); // Weg mit der ACL - $this->addNotice('','','DELETED',OR_NOTICE_OK); + $this->addNotice('','','DELETED',Action::NOTICE_OK); } @@ -503,7 +503,7 @@ class ObjectAction extends BaseAction // Should we do this? if ( $this->hasRequestVar('creationTimestamp') && $this->userIsAdmin() ) - $this->baseObject->createDate = $this->getRequestVar('creationTimestamp',OR_FILTER_NUMBER); + $this->baseObject->createDate = $this->getRequestVar('creationTimestamp',RequestParams::FILTER_NUMBER); $this->baseObject->setCreationTimestamp(); @@ -607,7 +607,7 @@ class ObjectAction extends BaseAction $this->baseObject->save(); - $this->addNotice($this->baseObject->getType(),$this->baseObject->filename,'SAVED',OR_NOTICE_OK); + $this->addNotice($this->baseObject->getType(),$this->baseObject->filename,'SAVED',Action::NOTICE_OK); } diff --git a/modules/cms/action/PageAction.class.php b/modules/cms/action/PageAction.class.php @@ -161,7 +161,7 @@ class PageAction extends ObjectAction else { // sonst nur 1x speichern (fuer die aktuelle Sprache) - $value->languageid = $this->getSessionVar(REQ_PARAM_LANGUAGE_ID); + $value->languageid = $this->getSessionVar(RequestParams::PARAM_LANGUAGE_ID); $value->save(); } } @@ -503,10 +503,10 @@ class PageAction extends ObjectAction if ( $newTemplateId != 0 ) { $this->page->replaceTemplate( $newTemplateId,$replaceElementMap ); - $this->addNotice('page',$this->page->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('page',$this->page->name,'SAVED',Action::NOTICE_OK); } else - $this->addNotice('page',$this->page->name,'NOT_SAVED',OR_NOTICE_WARN); + $this->addNotice('page',$this->page->name,'NOT_SAVED',Action::NOTICE_WARN); } @@ -637,7 +637,7 @@ class PageAction extends ObjectAction { $this->setModelAndLanguage(); - $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array(REQ_PARAM_LANGUAGE_ID=>$this->page->getProject()->getDefaultLanguageId(),REQ_PARAM_MODEL_ID=>$this->page->getProject()->getDefaultModelId()) ) ); + $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array(RequestParams::PARAM_LANGUAGE_ID=>$this->page->getProject()->getDefaultLanguageId(),RequestParams::PARAM_MODEL_ID=>$this->page->getProject()->getDefaultModelId()) ) ); } @@ -807,11 +807,11 @@ class PageAction extends ObjectAction if ( $this->getRequestVar('delete') != '' ) { $this->page->delete(); - $this->addNotice('page',$this->page->filename,'DELETED',OR_NOTICE_OK); + $this->addNotice('page',$this->page->filename,'DELETED',Action::NOTICE_OK); } else { - $this->addNotice('page',$this->page->filename,'CANCELED',OR_NOTICE_WARN); + $this->addNotice('page',$this->page->filename,'CANCELED',Action::NOTICE_WARN); } } diff --git a/modules/cms/action/PageelementAction.class.php b/modules/cms/action/PageelementAction.class.php @@ -210,7 +210,7 @@ class PageelementAction extends BaseAction try{ $user->load(); - }catch (\ObjectNotFoundException $e) { + }catch (\util\exception\ObjectNotFoundException $e) { $user = new User(); // Empty User. } @@ -679,7 +679,7 @@ class PageelementAction extends BaseAction // Inhalt wieder herstellen, in dem er neu gespeichert wird. $this->value->save(); - $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_USE_FROM_ARCHIVE',OR_NOTICE_OK); + $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_USE_FROM_ARCHIVE',Action::NOTICE_OK); } @@ -702,7 +702,7 @@ class PageelementAction extends BaseAction // Inhalt freigeben $this->value->release(); - $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_RELEASED',OR_NOTICE_OK); + $this->addNotice('pageelement',$this->value->element->name,'PAGEELEMENT_RELEASED',Action::NOTICE_OK); } @@ -897,7 +897,7 @@ class PageelementAction extends BaseAction * <br> * Nicht zu verwechseln mit <i>Aftershave</i> :) * @param $value Value - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ private function afterSave( $value ) { @@ -917,7 +917,7 @@ class PageelementAction extends BaseAction $lastChangeTime = $value->getLastChangeTime(); if ( $lastChangeTime > $this->getRequestVar('value_time') ) { - $this->addNotice('pageelement',$value->element->name,'CONCURRENT_VALUE_CHANGE',OR_NOTICE_WARN,array('last_change_time'=>date(\cms\base\Language::lang('DATE_FORMAT'),$lastChangeTime))); + $this->addNotice('pageelement',$value->element->name,'CONCURRENT_VALUE_CHANGE',Action::NOTICE_WARN,array('last_change_time'=>date(\cms\base\Language::lang('DATE_FORMAT'),$lastChangeTime))); } // Inhalt speichern @@ -939,7 +939,7 @@ class PageelementAction extends BaseAction $value->save(); } - $this->addNotice('pageelement',$value->element->label,'SAVED',OR_NOTICE_OK); + $this->addNotice('pageelement',$value->element->label,'SAVED',Action::NOTICE_OK); $this->page->setTimestamp(); // "Letzte Aenderung" setzen // Falls ausgewaehlt die Seite sofort veroeffentlichen diff --git a/modules/cms/action/ProfileAction.class.php b/modules/cms/action/ProfileAction.class.php @@ -147,11 +147,11 @@ class ProfileAction extends BaseAction if ( $mail->send() ) { - $this->addNotice('user',$this->user->name,'mail_sent',OR_NOTICE_OK); // Meldung + $this->addNotice('user',$this->user->name,'mail_sent',Action::NOTICE_OK); // Meldung } else { - $this->addNotice('user',$this->user->name,'mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); // Meldung + $this->addNotice('user',$this->user->name,'mail_not_sent',Action::NOTICE_ERROR,array(),$mail->error); // Meldung return; } } @@ -185,7 +185,7 @@ class ProfileAction extends BaseAction $this->user->mail = $newMail; $this->user->save(); - $this->addNotice('user',$this->user->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('user',$this->user->name,'SAVED',Action::NOTICE_OK); } else { diff --git a/modules/cms/action/ProjectAction.class.php b/modules/cms/action/ProjectAction.class.php @@ -61,17 +61,17 @@ class ProjectAction extends BaseAction { if ( $this->getRequestVar('name') != '') { - $this->project->name = $this->getRequestVar('name' ,OR_FILTER_ALPHANUM); - $this->project->url = $this->getRequestVar('url' ,OR_FILTER_ALPHANUM); - $this->project->target_dir = $this->getRequestVar('target_dir' ,OR_FILTER_RAW ); - $this->project->ftp_url = $this->getRequestVar('ftp_url' ,OR_FILTER_RAW ); - $this->project->ftp_passive = $this->getRequestVar('ftp_passive' ,OR_FILTER_RAW ); - $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' ,OR_FILTER_RAW ); - $this->project->content_negotiation = $this->getRequestVar('content_negotiation',OR_FILTER_NUMBER ); - $this->project->cut_index = $this->getRequestVar('cut_index' ,OR_FILTER_NUMBER ); - $this->project->publishFileExtension = $this->getRequestVar('publishFileExtension',OR_FILTER_NUMBER ); - $this->project->publishPageExtension = $this->getRequestVar('publishPageExtension',OR_FILTER_NUMBER ); - $this->project->linkAbsolute = $this->getRequestVar('linksAbsolute' ,OR_FILTER_NUMBER ) == '1'; + $this->project->name = $this->getRequestVar('name' ,RequestParams::FILTER_ALPHANUM); + $this->project->url = $this->getRequestVar('url' ,RequestParams::FILTER_ALPHANUM); + $this->project->target_dir = $this->getRequestVar('target_dir' ,RequestParams::FILTER_RAW ); + $this->project->ftp_url = $this->getRequestVar('ftp_url' ,RequestParams::FILTER_RAW ); + $this->project->ftp_passive = $this->getRequestVar('ftp_passive' ,RequestParams::FILTER_RAW ); + $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' ,RequestParams::FILTER_RAW ); + $this->project->content_negotiation = $this->getRequestVar('content_negotiation',RequestParams::FILTER_NUMBER ); + $this->project->cut_index = $this->getRequestVar('cut_index' ,RequestParams::FILTER_NUMBER ); + $this->project->publishFileExtension = $this->getRequestVar('publishFileExtension',RequestParams::FILTER_NUMBER ); + $this->project->publishPageExtension = $this->getRequestVar('publishPageExtension',RequestParams::FILTER_NUMBER ); + $this->project->linkAbsolute = $this->getRequestVar('linksAbsolute' ,RequestParams::FILTER_NUMBER ) == '1'; $this->addNoticeFor($this->project,Messages::SAVED); $this->project->save(); // speichern @@ -218,7 +218,7 @@ class ProjectAction extends BaseAction case 'check_files': // Konsistenzprüfungen $this->project->checkLostFiles(); - $status = empty($this->project->log) ? OR_NOTICE_OK : OR_NOTICE_ERROR; + $status = empty($this->project->log) ? Action::NOTICE_OK : Action::NOTICE_ERROR; $this->addNotice('project',$this->project->name,'DONE',$status,array(),$this->project->log); break; diff --git a/modules/cms/action/RequestParams.class.php b/modules/cms/action/RequestParams.class.php @@ -1,209 +1,200 @@ <?php -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_OBJECT_ID' ,'objectid' ); - define('REQ_PARAM_LANGUAGE_ID' ,'languageid' ); - define('REQ_PARAM_MODEL_ID' ,'modelid' ); - define('REQ_PARAM_PROJECT_ID' ,'projectid' ); - define('REQ_PARAM_ELEMENT_ID' ,'elementid' ); - define('REQ_PARAM_TEMPLATE_ID' ,'templateid' ); - define('REQ_PARAM_DATABASE_ID' ,'dbid' ); - - /* Filter Types */ - define('OR_FILTER_ALPHA', 'abc'); - define('OR_FILTER_ALPHANUM', 'abc123'); - define('OR_FILTER_FILENAME', 'file'); - define('OR_FILTER_MAIL', 'mail'); - define('OR_FILTER_TEXT', 'text'); - define('OR_FILTER_NUMBER', '123'); - define('OR_FILTER_RAW', 'raw'); -} - - -namespace cms\action { - - use util\exception\ValidationException; - use util\Text; - - class RequestParams - { - public $action; - public $method; - public $id; - - public $isAction; - - /** - * @var bool - */ - public $isUIAction; - - /** - * RequestParams constructor. - */ - public function __construct() - { - $this->id = @$_REQUEST[REQ_PARAM_ID ]; - $this->action = @$_REQUEST[REQ_PARAM_ACTION ]; - $this->method = @$_REQUEST[REQ_PARAM_SUBACTION]; - - // Is this a POST request? - $this->isAction = @$_SERVER['REQUEST_METHOD'] == 'POST'; - } - - - - public function getRequiredRequestVar( $varName, $transcode ) { - $value = $this->getRequestVar($varName,$transcode); - - if ( empty( $value ) ) - throw new ValidationException($varName); - - return $value; - } +namespace cms\action; + +use util\exception\ValidationException; +use util\Text; + + +class RequestParams +{ + const PARAM_TOKEN = 'token' ; + const PARAM_ACTION = 'action' ; + const PARAM_SUBACTION = 'subaction' ; + const PARAM_ID = 'id' ; + const PARAM_OBJECT_ID = 'objectid' ; + const PARAM_LANGUAGE_ID = 'languageid' ; + const PARAM_MODEL_ID = 'modelid' ; + const PARAM_PROJECT_ID = 'projectid' ; + const PARAM_ELEMENT_ID = 'elementid' ; + const PARAM_TEMPLATE_ID = 'templateid' ; + const PARAM_DATABASE_ID = 'dbid' ; + + /* Filter Types */ + const FILTER_ALPHA ='abc'; + const FILTER_ALPHANUM ='abc123'; + const FILTER_FILENAME = 'file'; + const FILTER_MAIL = 'mail'; + const FILTER_TEXT = 'text'; + const FILTER_NUMBER = '123'; + const FILTER_RAW = 'raw'; + + public $action; + public $method; + public $id; + + public $isAction; + + /** + * @var bool + */ + public $isUIAction; + + /** + * RequestParams constructor. + */ + public function __construct() + { + $this->id = @$_REQUEST[self::PARAM_ID ]; + $this->action = @$_REQUEST[self::PARAM_ACTION ]; + $this->method = @$_REQUEST[self::PARAM_SUBACTION]; + + // Is this a POST request? + $this->isAction = @$_SERVER['REQUEST_METHOD'] == 'POST'; + } - /** - * Ermittelt den Inhalt der gew�nschten Request-Variablen. - * Falls nicht vorhanden, wird "" zur�ckgegeben. - * - * @param String $varName Schl�ssel - * @return String Inhalt - */ - public function getRequestVar($varName, $transcode = OR_FILTER_TEXT) - { - if($varName == REQ_PARAM_ID) - return $this->id; - if($varName == REQ_PARAM_ACTION) - return $this->action; + public function getRequiredRequestVar( $varName, $transcode ) { + $value = $this->getRequestVar($varName,$transcode); - if($varName == REQ_PARAM_SUBACTION) - return $this->method; + if ( empty( $value ) ) + throw new ValidationException($varName); + + return $value; + } - if (!isset($_REQUEST[$varName])) - return ''; - return $this->cleanText( $_REQUEST[$varName], $transcode ); - } + /** + * Ermittelt den Inhalt der gew�nschten Request-Variablen. + * Falls nicht vorhanden, wird "" zur�ckgegeben. + * + * @param String $varName Schl�ssel + * @return String Inhalt + */ + public function getRequestVar($varName, $transcode = self::FILTER_TEXT) + { + if($varName == self::PARAM_ID) + return $this->id; + if($varName == self::PARAM_ACTION) + return $this->action; - public function cleanText( $value, $transcode ) - { - switch ($transcode) { - case OR_FILTER_ALPHA: - $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - break; + if($varName == self::PARAM_SUBACTION) + return $this->method; + + if (!isset($_REQUEST[$varName])) + return ''; + + return $this->cleanText( $_REQUEST[$varName], $transcode ); + } - case OR_FILTER_ALPHANUM: - $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,_-!?%&/()'; - break; - case OR_FILTER_FILENAME: - // RFC 1738, Section 2.2: - // Thus, only alphanumerics, the special characters "$-_.+!*'(),", and - // reserved characters used for their reserved purposes may be used - // unencoded within a URL. - $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$-_.+!*(),' . "'"; - break; + public function cleanText( $value, $transcode ) + { + switch ($transcode) { + case self::FILTER_ALPHA: + $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + break; - case OR_FILTER_MAIL: - $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-@'; - break; + case self::FILTER_ALPHANUM: + $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,_-!?%&/()'; + break; - case OR_FILTER_TEXT: - // Allow all UTF-8 characters. - return mb_convert_encoding($value, 'UTF-8', 'UTF-8'); + case self::FILTER_FILENAME: + // RFC 1738, Section 2.2: + // Thus, only alphanumerics, the special characters "$-_.+!*'(),", and + // reserved characters used for their reserved purposes may be used + // unencoded within a URL. + $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$-_.+!*(),' . "'"; + break; - case OR_FILTER_NUMBER: - $white = '1234567890.'; - break; + case self::FILTER_MAIL: + $white = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-@'; + break; - case OR_FILTER_RAW: - return $value; + case self::FILTER_TEXT: + // Allow all UTF-8 characters. + return mb_convert_encoding($value, 'UTF-8', 'UTF-8'); - default: - throw new \LogicException('Unknown request filter', 'not found: ' . $transcode); - } + case self::FILTER_NUMBER: + $white = '1234567890.'; + break; - return Text::clean($value, $white); + case self::FILTER_RAW: + return $value; + + default: + throw new \LogicException('Unknown request filter', 'not found: ' . $transcode); } - /** - * Ermittelt, ob der aktuelle Request eine Variable mit dem - * angegebenen Namen enth�lt. - * - * @param String $varName Schl�ssel - * @return boolean true, falls vorhanden. - */ - public function hasRequestVar($varName) - { - return (isset($_REQUEST[$varName]) && (!empty($_REQUEST[$varName]) || $_REQUEST[$varName] == '0')); - } + return Text::clean($value, $white); + } + /** + * Ermittelt, ob der aktuelle Request eine Variable mit dem + * angegebenen Namen enth�lt. + * + * @param String $varName Schl�ssel + * @return boolean true, falls vorhanden. + */ + public function hasRequestVar($varName) + { + return (isset($_REQUEST[$varName]) && (!empty($_REQUEST[$varName]) || $_REQUEST[$varName] == '0')); + } - public function getRequiredRequestId( $varName ) { - $id = intval($this->getRequestVar($this->getRequestVar( $varName ))); + public function getRequiredRequestId( $varName ) { - if ( $id == 0 ) - throw new ValidationException($varName); + $id = intval($this->getRequestVar($this->getRequestVar( $varName ))); - return $id; - } + if ( $id == 0 ) + throw new ValidationException($varName); - /** - * Ermittelt die aktuelle Id aus dem Request.<br> - * Um welche ID es sich handelt, ist abh�ngig von der Action. - * - * @return Integer - */ - public function getRequestId() - { - if ($this->hasRequestVar('idvar')) - return intval($this->getRequestVar($this->getRequestVar('idvar'))); - else - return intval($this->getRequestVar(REQ_PARAM_ID)); - } - - - public function hasLanguageId() - { - return $this->hasRequestVar(REQ_PARAM_LANGUAGE_ID); - } - - public function getLanguageId() - { - return $this->getRequestVar(REQ_PARAM_LANGUAGE_ID,OR_FILTER_NUMBER); - } - - public function hasModelId() - { - return $this->hasRequestVar(REQ_PARAM_MODEL_ID); - } - - public function getModelId() - { - return $this->getRequestVar(REQ_PARAM_MODEL_ID,OR_FILTER_NUMBER); - } - public function getProjectId() - { - return $this->getRequestVar(REQ_PARAM_PROJECT_ID,OR_FILTER_NUMBER); - } - - public function getToken() - { - return $this->getRequestVar(REQ_PARAM_TOKEN,OR_FILTER_ALPHANUM); - } + return $id; + } + + /** + * Ermittelt die aktuelle Id aus dem Request.<br> + * Um welche ID es sich handelt, ist abh�ngig von der Action. + * + * @return Integer + */ + public function getRequestId() + { + if ($this->hasRequestVar('idvar')) + return intval($this->getRequestVar($this->getRequestVar('idvar'))); + else + return intval($this->getRequestVar(self::PARAM_ID)); + } + + + public function hasLanguageId() + { + return $this->hasRequestVar(self::PARAM_LANGUAGE_ID); + } + + public function getLanguageId() + { + return $this->getRequestVar(self::PARAM_LANGUAGE_ID,self::FILTER_NUMBER); + } + + public function hasModelId() + { + return $this->hasRequestVar(self::PARAM_MODEL_ID); + } + + public function getModelId() + { + return $this->getRequestVar(self::PARAM_MODEL_ID,self::FILTER_NUMBER); + } + public function getProjectId() + { + return $this->getRequestVar(self::PARAM_PROJECT_ID,self::FILTER_NUMBER); + } + + public function getToken() + { + return $this->getRequestVar(self::PARAM_TOKEN,self::FILTER_ALPHANUM); } } \ No newline at end of file diff --git a/modules/cms/action/SearchAction.class.php b/modules/cms/action/SearchAction.class.php @@ -165,7 +165,7 @@ class SearchAction extends BaseAction 'lastchange_date' => 0 ); $resultList[] = $userResult; } - catch( \ObjectNotFoundException $e) { + catch( \util\exception\ObjectNotFoundException $e) { ; // userid is unknown } } diff --git a/modules/cms/action/StartAction.class.php b/modules/cms/action/StartAction.class.php @@ -38,9 +38,6 @@ use util\Mail; // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -if ( !defined('PROJECTID_ADMIN') ) - define('PROJECTID_ADMIN',-1); - /** * Action-Klasse fuer die Start-Action * @author $Author$ @@ -89,9 +86,9 @@ class StartAction extends BaseAction function setDefaultDb() { - if ( $this->hasRequestVar(REQ_PARAM_DATABASE_ID) ) + if ( $this->hasRequestVar(RequestParams::PARAM_DATABASE_ID) ) { - $dbid = $this->getRequestVar(REQ_PARAM_DATABASE_ID); + $dbid = $this->getRequestVar(RequestParams::PARAM_DATABASE_ID); } else { @@ -122,7 +119,7 @@ class StartAction extends BaseAction if ( !$db->available ) { - $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',OR_NOTICE_ERROR,array(),array('Database Error: '.$db->error)); + $this->addNotice('database',$db->conf['description'],'DATABASE_CONNECTION_ERROR',Action::NOTICE_ERROR,array(),array('Database Error: '.$db->error)); $this->callSubAction('showlogin'); return false; } @@ -319,7 +316,7 @@ class StartAction extends BaseAction if ( empty($dbids) ) - $this->addNotice('','','no_database_configuration',OR_NOTICE_WARN); + $this->addNotice('','','no_database_configuration',Action::NOTICE_WARN); if ( !isset($this->templateVars['login_name']) && isset($_COOKIE['or_username']) ) $this->setTemplateVar('login_name',$_COOKIE['or_username']); @@ -358,10 +355,10 @@ class StartAction extends BaseAction $this->setTemplateVar('force_username',$username); } - $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,OR_FILTER_NUMBER) ); - $this->setTemplateVar('languageid',$this->getRequestVar('languageid',OR_FILTER_NUMBER) ); + $this->setTemplateVar('objectid' ,$this->getRequestVar('objectid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('projectid' ,$this->getRequestVar('projectid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('modelid' ,$this->getRequestVar('modelid' ,RequestParams::FILTER_NUMBER) ); + $this->setTemplateVar('languageid',$this->getRequestVar('languageid',RequestParams::FILTER_NUMBER) ); $this->setTemplateVar('register' ,$conf['login' ]['register' ]); $this->setTemplateVar('send_password',$conf['login' ]['send_password']); @@ -425,10 +422,10 @@ class StartAction extends BaseAction // Kein Projekt vorhanden. Eine Hinweismeldung ausgeben. if ( $this->userIsAdmin() ) // Administratoren bekommen bescheid, dass sie ein Projekt anlegen sollen - $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); + $this->addNotice('','','ADMIN_NO_PROJECTS_AVAILABLE',Action::NOTICE_WARN); else // Normale Benutzer erhalten eine Meldung, dass kein Projekt zur Verf�gung steht - $this->addNotice('','','NO_PROJECTS_AVAILABLE',OR_NOTICE_WARN); + $this->addNotice('','','NO_PROJECTS_AVAILABLE',Action::NOTICE_WARN); } //$this->metaValues(); @@ -496,7 +493,7 @@ class StartAction extends BaseAction if ( !$openId->checkAuthentication() ) { - $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',OR_NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) ); + $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED',Action::NOTICE_ERROR,array('name'=>$openId->user),array($openId->error) ); $this->addValidationError('openid_url',''); $this->callSubAction('showlogin'); return; @@ -569,10 +566,10 @@ class StartAction extends BaseAction throw new \util\exception\SecurityException('login disabled'); $openid_user = $this->getRequestVar('openid_url' ); - $loginName = $this->getRequestVar('login_name' ,OR_FILTER_ALPHANUM); - $loginPassword = $this->getRequestVar('login_password',OR_FILTER_ALPHANUM); - $newPassword1 = $this->getRequestVar('password1' ,OR_FILTER_ALPHANUM); - $newPassword2 = $this->getRequestVar('password2' ,OR_FILTER_ALPHANUM); + $loginName = $this->getRequestVar('login_name' ,RequestParams::FILTER_ALPHANUM); + $loginPassword = $this->getRequestVar('login_password',RequestParams::FILTER_ALPHANUM); + $newPassword1 = $this->getRequestVar('password1' ,RequestParams::FILTER_ALPHANUM); + $newPassword2 = $this->getRequestVar('password2' ,RequestParams::FILTER_ALPHANUM); // Cookie setzen $this->setCookie('or_username',$loginName ); @@ -638,7 +635,7 @@ class StartAction extends BaseAction $this->recreateSession(); $user = Session::getUser(); - $this->addNotice('user',$user->name,'LOGIN_OK',OR_NOTICE_OK,array('name'=>$user->fullname)); + $this->addNotice('user',$user->name,'LOGIN_OK',Action::NOTICE_OK,array('name'=>$user->fullname)); } // Benutzer ist angemeldet @@ -812,7 +809,7 @@ class StartAction extends BaseAction return; } - $this->evaluateRequestVars( array(REQ_PARAM_LANGUAGE_ID=>$this->getRequestId()) ); + $this->evaluateRequestVars( array(RequestParams::PARAM_LANGUAGE_ID=>$this->getRequestId()) ); } @@ -825,7 +822,7 @@ class StartAction extends BaseAction return; } - $this->evaluateRequestVars( array(REQ_PARAM_MODEL_ID=>$this->getRequestId()) ); + $this->evaluateRequestVars( array(RequestParams::PARAM_MODEL_ID=>$this->getRequestId()) ); } @@ -873,7 +870,7 @@ class StartAction extends BaseAction else { Logger::warn('Guest login failed, user not found: '.$username); - $this->addNotice('user',$username,'LOGIN_FAILED',OR_NOTICE_WARN,array('name'=>$username) ); + $this->addNotice('user',$username,'LOGIN_FAILED',Action::NOTICE_WARN,array('name'=>$username) ); $user = null; } } @@ -967,11 +964,11 @@ class StartAction extends BaseAction if ( $mail->send() ) { - $this->addNotice('','','mail_sent',OR_NOTICE_OK); + $this->addNotice('','','mail_sent',Action::NOTICE_OK); } else { - $this->addNotice('','','mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error); + $this->addNotice('','','mail_not_sent',Action::NOTICE_ERROR,array(),$mail->error); $this->callSubAction('register'); return; } @@ -1160,9 +1157,9 @@ class StartAction extends BaseAction $eMail->setVar('name',$user->getName()); $eMail->setVar('code',$code); if ( $eMail->send() ) - $this->addNotice('user',$user->getName(),'mail_sent',OR_NOTICE_OK); + $this->addNotice('user',$user->getName(),'mail_sent',Action::NOTICE_OK); else - $this->addNotice('user',$user->getName(),'mail_not_sent',OR_NOTICE_ERROR,array(),$eMail->error); + $this->addNotice('user',$user->getName(),'mail_not_sent',Action::NOTICE_ERROR,array(),$eMail->error); } else @@ -1209,7 +1206,7 @@ class StartAction extends BaseAction if ( !$user->isValid() ) { // Benutzer konnte nicht geladen werden. - $this->addNotice('user',$username,'error',OR_NOTICE_ERROR); + $this->addNotice('user',$username,'error',Action::NOTICE_ERROR); return; } @@ -1222,13 +1219,13 @@ class StartAction extends BaseAction if ( $eMail->send() ) { $user->setPassword( $newPw, false ); // Kennwort muss beim n�. Login ge�ndert werden. - $this->addNotice('user',$username,'mail_sent',OR_NOTICE_OK); + $this->addNotice('user',$username,'mail_sent',Action::NOTICE_OK); } else { // Sollte eigentlich nicht vorkommen, da der Benutzer ja auch schon den // Code per E-Mail erhalten hat. - $this->addNotice('user',$username,'error',OR_NOTICE_ERROR,array(),$eMail->error); + $this->addNotice('user',$username,'error',Action::NOTICE_ERROR,array(),$eMail->error); } } diff --git a/modules/cms/action/TemplateAction.class.php b/modules/cms/action/TemplateAction.class.php @@ -89,7 +89,7 @@ class TemplateAction extends BaseAction $templatemodel = new TemplateModel($this->template->templateid, $modelId); $templatemodel->load(); - $newSource = $this->request->getRequestVar('source',OR_FILTER_RAW); + $newSource = $this->request->getRequestVar('source',RequestParams::FILTER_RAW); /* // Not useful any more. Technical name of a element should not be changed. @@ -107,7 +107,7 @@ class TemplateAction extends BaseAction $templatemodel->save(); - $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('template',$this->template->name,'SAVED',Action::NOTICE_OK); } @@ -115,7 +115,7 @@ class TemplateAction extends BaseAction function srcelementPost() { - $tplModel = $this->template->loadTemplateModelFor( $this->request->getRequestVar(REQ_PARAM_MODEL_ID)); + $tplModel = $this->template->loadTemplateModelFor( $this->request->getRequestVar(RequestParams::PARAM_MODEL_ID)); $elementToAdd = new Element( $this->getRequestVar('elementid') ); $elementToAdd->load(); @@ -151,7 +151,7 @@ class TemplateAction extends BaseAction { $this->template->name = $this->getRequestVar('name'); $this->template->save(); - $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('template',$this->template->name,'SAVED',Action::NOTICE_OK); } } @@ -163,11 +163,11 @@ class TemplateAction extends BaseAction if ( $this->getRequestVar('delete') != '' ) { $this->template->delete(); - $this->addNotice('template',$this->template->name,'DELETED',OR_NOTICE_OK); + $this->addNotice('template',$this->template->name,'DELETED',Action::NOTICE_OK); } else { - $this->addNotice('template',$this->template->name,'CANCELED',OR_NOTICE_WARN); + $this->addNotice('template',$this->template->name,'CANCELED',Action::NOTICE_WARN); } } @@ -269,7 +269,7 @@ class TemplateAction extends BaseAction function addelPost() { - $name = $this->getRequestVar('name',OR_FILTER_ALPHANUM); + $name = $this->getRequestVar('name',RequestParams::FILTER_ALPHANUM); if ( empty($name) ) throw new \util\exception\ValidationException('name'); @@ -292,7 +292,7 @@ class TemplateAction extends BaseAction } - $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('template',$this->template->name,'SAVED',Action::NOTICE_OK); } @@ -345,7 +345,7 @@ class TemplateAction extends BaseAction $this->setTemplateVar('models',$project->getModels() ); - $modelId = $this->request->getRequestVar(REQ_PARAM_MODEL_ID); + $modelId = $this->request->getRequestVar(RequestParams::PARAM_MODEL_ID); if ( ! $modelId ) $modelId = Project::create( $this->template->projectid )->getDefaultModelId(); @@ -362,7 +362,7 @@ class TemplateAction extends BaseAction */ function showView() { - $modelId = $this->request->getRequestVar(REQ_PARAM_MODEL_ID); + $modelId = $this->request->getRequestVar(RequestParams::PARAM_MODEL_ID); if ( ! $modelId ) $modelId = Project::create( $this->template->projectid )->getDefaultModelId(); @@ -601,7 +601,7 @@ class TemplateAction extends BaseAction $this->addNotice( 'template', $this->template->name, 'PUBLISHED', - OR_NOTICE_OK, + Action::NOTICE_OK, array(), array_map( function($obj) { return $obj['full_filename']; diff --git a/modules/cms/action/TextAction.class.php b/modules/cms/action/TextAction.class.php @@ -1,16 +1,12 @@ <?php -namespace { - define('OR_FILE_FILTER_LESS',1); -} +namespace cms\action; -namespace cms\action -{ - use cms\model\BaseObject; +use cms\model\BaseObject; - use cms\model\Text; - use util\Html; +use cms\model\Text; +use util\Html; // OpenRat Content Management System // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de @@ -30,78 +26,76 @@ namespace cms\action // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - /** - * Action-Klasse zum Bearbeiten einer Datei - * @author Jan Dankert - * @package openrat.actions - */ - class TextAction extends FileAction - { - public $security = Action::SECURITY_USER; +/** + * Action-Klasse zum Bearbeiten einer Datei + * @author Jan Dankert + */ +class TextAction extends FileAction +{ + public $security = Action::SECURITY_USER; - private $text; + private $text; - /** - * Konstruktor - */ - function __construct() - { - parent::__construct(); - } + /** + * Konstruktor + */ + function __construct() + { + parent::__construct(); + } - public function init() - { + public function init() + { - $text = new Text($this->getRequestId()); - $text->load(); + $text = new Text($this->getRequestId()); + $text->load(); - $this->setBaseObject( $text ); - } + $this->setBaseObject( $text ); + } - protected function setBaseObject( $text ) { + protected function setBaseObject( $text ) { - $this->text = $text; + $this->text = $text; - parent::setBaseObject( $text ); - } + parent::setBaseObject( $text ); + } - public function valuePost() - { - $this->text->value = $this->getRequestVar('value', OR_FILTER_RAW); - $this->text->saveValue(); + public function valuePost() + { + $this->text->value = $this->getRequestVar('value', RequestParams::FILTER_RAW); + $this->text->saveValue(); - $this->addNotice($this->text->getType(), $this->text->name, 'VALUE_SAVED', 'ok'); - $this->text->setTimestamp(); - } + $this->addNotice($this->text->getType(), $this->text->name, 'VALUE_SAVED', 'ok'); + $this->text->setTimestamp(); + } - /** - * Only needed because there is a special template for text nodes. - */ - public function valueView() - { - parent::valueView(); - } + /** + * Only needed because there is a special template for text nodes. + */ + public function valueView() + { + parent::valueView(); + } - /** - * Only needed because there is a special template for text nodes. - */ - public function showView() { + /** + * Only needed because there is a special template for text nodes. + */ + public function showView() { - parent::showView(); - } + parent::showView(); + } - /** - * Only needed because there is a special template for text nodes. - */ - public function previewView() - { - parent::previewView(); - } - } + /** + * Only needed because there is a special template for text nodes. + */ + public function previewView() + { + parent::previewView(); + } } diff --git a/modules/cms/action/UrlAction.class.php b/modules/cms/action/UrlAction.class.php @@ -98,11 +98,11 @@ class UrlAction extends ObjectAction if ( $this->getRequestVar('delete') != '' ) { $this->url->delete(); - $this->addNotice('url',$this->url->filename,'DELETED',OR_NOTICE_OK); + $this->addNotice('url',$this->url->filename,'DELETED',Action::NOTICE_OK); } else { - $this->addNotice('url',$this->url->filename,'CANCELED',OR_NOTICE_WARN); + $this->addNotice('url',$this->url->filename,'CANCELED',Action::NOTICE_WARN); } } @@ -116,7 +116,7 @@ class UrlAction extends ObjectAction $this->url->save(); $this->url->setTimestamp(); - $this->addNotice('url',$this->url->name,'SAVED',OR_NOTICE_OK); + $this->addNotice('url',$this->url->name,'SAVED',Action::NOTICE_OK); } diff --git a/modules/cms/action/UserAction.class.php b/modules/cms/action/UserAction.class.php @@ -54,7 +54,7 @@ class UserAction extends BaseAction /** * UserAction constructor. - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ function __construct() { @@ -340,7 +340,7 @@ class UserAction extends BaseAction $conf = \cms\base\Configuration::rawConfig(); if ($conf['security']['authorize']['type']=='ldap') - $this->addNotice('user',$this->user->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',OR_NOTICE_WARN); + $this->addNotice('user',$this->user->name,'GROUPS_MAY_CONFLICT_WITH_LDAP',Action::NOTICE_WARN); } @@ -387,7 +387,7 @@ class UserAction extends BaseAction /** * Anzeigen der Benutzerrechte - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ function rightsView() { @@ -460,13 +460,13 @@ class UserAction extends BaseAction $this->setTemplateVar('show',Acl::getAvailableRights() ); if ( $this->user->isAdmin ) - $this->addNotice('user',$this->user->name,'ADMIN_NEEDS_NO_RIGHTS',OR_NOTICE_WARN); + $this->addNotice('user',$this->user->name,'ADMIN_NEEDS_NO_RIGHTS',Action::NOTICE_WARN); } /** * Wechselt zu einem ausgewählten User. - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function switchPost() { diff --git a/modules/cms/action/UserlistAction.class.php b/modules/cms/action/UserlistAction.class.php @@ -73,7 +73,7 @@ class UserlistAction extends BaseAction */ public function addPost( $name ) { - $name = $this->request->cleanText($name,OR_FILTER_ALPHANUM); + $name = $this->request->cleanText($name,RequestParams::FILTER_ALPHANUM); $user = User::loadWithName($name); diff --git a/modules/cms/action/WebdavAction.class.php b/modules/cms/action/WebdavAction.class.php @@ -136,7 +136,7 @@ class WebdavAction extends BaseAction // Authentisierung erzwingen (au�er bei Methode OPTIONS). // For the motivation for not checking OPTIONS requests see // http://pear.php.net/bugs/bug.php?id=5363 - if ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] != 'options' ) + if ( !is_object($user) && $_GET[RequestParams::PARAM_SUBACTION] != 'options' ) { Logger::debug( 'Checking Authentication' ); @@ -169,7 +169,7 @@ class WebdavAction extends BaseAction exit; } } - elseif ( !is_object($user) && $_GET[REQ_PARAM_SUBACTION] == 'options' ) + elseif ( !is_object($user) && $_GET[RequestParams::PARAM_SUBACTION] == 'options' ) { $this->setDefaultDb(); } diff --git a/modules/cms/api/API.class.php b/modules/cms/api/API.class.php @@ -5,12 +5,11 @@ namespace cms\api; use BadMethodCallException; use cms\action\RequestParams; use cms\base\Startup; -use cms\base\Version; use cms\Dispatcher; use Exception; use util\Http; use logger\Logger; -use ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; use util\exception\UIException; use util\exception\SecurityException; use util\json\JSON; diff --git a/modules/cms/auth/RememberAuth.class.php b/modules/cms/auth/RememberAuth.class.php @@ -6,7 +6,7 @@ use cms\auth\Auth; use database\Database; use cms\model\User; use logger\Logger; -use ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; /** * Authentifizierung mit einem Login-Token. diff --git a/modules/cms/generator/PageGenerator.class.php b/modules/cms/generator/PageGenerator.class.php @@ -199,7 +199,7 @@ class PageGenerator extends BaseGenerator * Creating the public filename of a page. * * @return string - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function getPublicFilename() { diff --git a/modules/cms/generator/link/PreviewLink.class.php b/modules/cms/generator/link/PreviewLink.class.php @@ -39,8 +39,8 @@ class PreviewLink implements LinkFormat $param = array( 'oid' => '__OID__'.$to->objectid.'__', - REQ_PARAM_MODEL_ID => $this->pageContext->modelId , - REQ_PARAM_LANGUAGE_ID => $this->pageContext->languageId ); + RequestParams::PARAM_MODEL_ID => $this->pageContext->modelId , + RequestParams::PARAM_LANGUAGE_ID => $this->pageContext->languageId ); // Interne Verlinkungen in der Seitenvorschau switch( $to->typeid ) diff --git a/modules/cms/model/Acl.class.php b/modules/cms/model/Acl.class.php @@ -512,7 +512,7 @@ SQL * Liefert das Projekt-Objekt. * * @return Project - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function getProject() { return Project::create( $this->projectid ); diff --git a/modules/cms/model/Alias.class.php b/modules/cms/model/Alias.class.php @@ -25,7 +25,7 @@ class Alias extends BaseObject /** * Lesen der Verknuepfung aus der Datenbank - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function load() { diff --git a/modules/cms/model/BaseObject.class.php b/modules/cms/model/BaseObject.class.php @@ -659,7 +659,7 @@ SQL * Es werden * - die sprachunabh?ngigen Daten wie Dateiname, Typ sowie Erstellungs- und ?nderungsdatum geladen * - die sprachabh?ngigen Daten wie Name und Beschreibung geladen - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ function objectLoad() { @@ -692,7 +692,7 @@ SQL $row = $stmt->getRow(); if (count($row) == 0) - throw new \ObjectNotFoundException('object '.$this->objectid.' not found'); + throw new \util\exception\ObjectNotFoundException('object '.$this->objectid.' not found'); $this->setDatabaseRow( $row ); } @@ -713,7 +713,7 @@ SQL $row = $sql->getRow(); if (count($row) == 0) - throw new \ObjectNotFoundException('objectid not found: '.$this->objectid); + throw new \util\exception\ObjectNotFoundException('objectid not found: '.$this->objectid); $this->parentid = $row['parentid' ]; $this->filename = $row['filename' ]; @@ -1504,7 +1504,7 @@ SQL * Liefert das Projekt-Objekt. * * @return Project - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function getProject() { return Project::create( $this->projectid ); @@ -1629,7 +1629,7 @@ SQL /** * Liefert alle Name-Objekte. * @return array - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function getNames() { @@ -1652,7 +1652,7 @@ SQL /** * Liefert alle Name-Objekte. * @return Name - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function getNameForLanguage( $languageId ) { @@ -1754,7 +1754,7 @@ SQL * Creates an Alias for a specific language. * @param $languageid could be null for the default alias. * @return Alias - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function getAliasForLanguage( $languageid ) { diff --git a/modules/cms/model/Element.class.php b/modules/cms/model/Element.class.php @@ -215,7 +215,7 @@ class Element extends ModelBase /** * Lesen des Elementes aus der Datenbank * Alle Eigenschaften des Elementes werden aus der Datenbank gelesen - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ function load() { @@ -235,12 +235,12 @@ SQL /** * @param $prop - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ function setDatabaseRow($prop ) { if ( count($prop) <= 0 ) - throw new \ObjectNotFoundException("Element not found"); + throw new \util\exception\ObjectNotFoundException("Element not found"); $this->elementid = $prop['id' ]; $this->templateid = $prop['templateid']; diff --git a/modules/cms/model/File.class.php b/modules/cms/model/File.class.php @@ -25,17 +25,16 @@ use cms\generator\PublishPublic; use logger\Logger; use util\cache\FileCache; -define('OR_FILE_DEFAULT_MIMETYPE','application/octet-stream'); - /** - * Datei. + * File. * * @author Jan Dankert - * @package openrat.objects */ class File extends BaseObject { + const DEFAULT_MIMETYPE = 'application/octet-stream'; + var $fileid; var $size = 0; @@ -145,7 +144,7 @@ class File extends BaseObject $this->mime_type = $mime_types[$ext]; else // Wenn kein Mime-Type gefunden, dann Standartwert setzen - $this->mime_type = OR_FILE_DEFAULT_MIMETYPE; + $this->mime_type = self::OR_FILE_DEFAULT_MIMETYPE; return( $this->mime_type ); } diff --git a/modules/cms/model/Group.class.php b/modules/cms/model/Group.class.php @@ -82,7 +82,7 @@ class Group extends ModelBase * Read a group. * @param $name string name of the group * @return Group - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public static function loadWithName( $name ) { @@ -100,7 +100,7 @@ class Group extends ModelBase } else { - throw new \ObjectNotFoundException( "Group does not exist: ".$name); + throw new \util\exception\ObjectNotFoundException( "Group does not exist: ".$name); } } diff --git a/modules/cms/model/Link.class.php b/modules/cms/model/Link.class.php @@ -29,7 +29,7 @@ class Link extends BaseObject /** * Lesen der Verknuepfung aus der Datenbank - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function load() { diff --git a/modules/cms/model/Name.class.php b/modules/cms/model/Name.class.php @@ -50,7 +50,7 @@ namespace cms\model { * Lesen der Eigenschaften aus der Datenbank * Es werden * - die sprachabh?ngigen Daten wie Name und Beschreibung geladen - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function load() { diff --git a/modules/cms/model/Page.class.php b/modules/cms/model/Page.class.php @@ -175,7 +175,7 @@ SQL $row = $sql->getRow(); if ( count($row)==0 ) - throw new \ObjectNotFoundException("Page with Id $this->objectid not found."); + throw new \util\exception\ObjectNotFoundException("Page with Id $this->objectid not found."); $this->pageid = $row['id' ]; $this->templateid = $row['templateid']; diff --git a/modules/cms/model/Project.class.php b/modules/cms/model/Project.class.php @@ -78,7 +78,7 @@ class Project extends ModelBase /** * @param $projectid * @return Project - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public static function create($projectid) { @@ -233,7 +233,7 @@ class Project extends ModelBase // Laden /** - * @throws \ObjectNotFoundException + * @throws \util\exception\ObjectNotFoundException */ public function load() { @@ -244,7 +244,7 @@ class Project extends ModelBase $row = $sql->getRow(); if ( empty($row) ) - throw new \ObjectNotFoundException('project '.$this->projectid.' not found'); + throw new \util\exception\ObjectNotFoundException('project '.$this->projectid.' not found'); $this->name = $row['name' ]; $this->url = $row['url' ]; diff --git a/modules/cms/model/Template.class.php b/modules/cms/model/Template.class.php @@ -67,7 +67,7 @@ class Template extends ModelBase $row = $stmt->getRow(); if ( empty($row) ) - throw new \ObjectNotFoundException("Template not found: ".$this->templateid); + throw new \util\exception\ObjectNotFoundException("Template not found: ".$this->templateid); $this->name = $row['name' ]; $this->projectid = $row['projectid']; diff --git a/modules/cms/model/User.class.php b/modules/cms/model/User.class.php @@ -273,7 +273,7 @@ SQL $row = $stmt->getRow(); if ( count($row) == 0 ) - throw new \ObjectNotFoundException(); + throw new \util\exception\ObjectNotFoundException(); $this->setDatabaseRow( $row ); } diff --git a/modules/cms/model/Value.class.php b/modules/cms/model/Value.class.php @@ -5,7 +5,7 @@ use cms\base\Startup; use util\ArrayUtils; use cms\generator\Publish; use cms\macros\MacroRunner; -use \ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; use logger\Logger; use util\exception\GeneratorException; use util\Text; diff --git a/modules/cms/ui/UI.class.php b/modules/cms/ui/UI.class.php @@ -9,7 +9,7 @@ use Exception; use util\Http; use logger\Logger; use LogicException; -use ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; use util\exception\UIException; use util\exception\SecurityException; use template_engine\engine\TemplateEngine; diff --git a/modules/cms/ui/action/IndexAction.class.php b/modules/cms/ui/action/IndexAction.class.php @@ -16,7 +16,7 @@ use util\json\JSON; use logger\Logger; use util\Less; use util\UIUtils; -use ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; use util\Session; diff --git a/modules/cms/ui/action/TreeAction.class.php b/modules/cms/ui/action/TreeAction.class.php @@ -4,6 +4,7 @@ namespace cms\ui\action; use cms\action\Action; use cms\action\BaseAction; +use cms\action\RequestParams; use cms\model\BaseObject; use cms\model\Element; use cms\model\Folder; @@ -103,7 +104,7 @@ class TreeAction extends BaseAction public function pathView() { $type = $this->getRequestVar('type'); - $id = $this->getRequestVar('id', OR_FILTER_ALPHANUM); + $id = $this->getRequestVar('id', RequestParams::FILTER_ALPHANUM); $result = $this->calculatePath($type, $id); $this->setTemplateVar('path', $result); diff --git a/modules/cms/ui/themes/default/html/views/projectlist/show.php b/modules/cms/ui/themes/default/html/views/projectlist/show.php @@ -1,37 +0,0 @@ - - - - - <table width="100%"> - <tr class="headline"> - <td> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(\cms\base\Language::lang(''.'name'.'')))); ?></span> - - </td> - </tr> - <?php foreach($projects as $list_key=>$list_value){ ?><?php extract($list_value) ?> - <tr class="data"> - <td class="clickable"> - <a target="_self" date-name="<?php echo $name ?>" name="<?php echo $name ?>" data-type="open" data-action="project" data-method="<?php echo OR_METHOD ?>" data-id="<?php echo $id ?>" data-extra="[]" href="<?php echo Html::url('project','',$id,array()) ?>"> - <img class="" title="" src="./modules/cms-ui/themes/default/images/icon/icon_project.png" /> - - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(Text::maxLength( $name,30,'..',constant('STR_PAD_BOTH') )))); ?></span> - - </a> - - </td> - </tr> - <?php } ?> - <tr class="data"> - <td class="clickable"> - <a target="_self" date-name="<?php echo \cms\base\Language::lang('new') ?>" name="<?php echo \cms\base\Language::lang('new') ?>" data-type="dialog" data-action="" data-method="add" data-id="<?php echo OR_ID ?>" data-extra="[]" href="<?php echo Html::url('','add','',array()) ?>"> - <img class="" title="" src="./modules/cms-ui/themes/default/images/icon/add.png" /> - - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(\cms\base\Language::lang('new')))); ?></span> - - </a> - - </td> - </tr> - </table> - - \ No newline at end of file diff --git a/modules/database/Column.class.php b/modules/database/Column.class.php @@ -70,14 +70,14 @@ class Column switch ($this->type) { case self::TYPE_INT: switch ($this->dbmsType) { - case OR_DB_TYPE_MYSQL: + case DbVersion::TYPE_MYSQL: if ($this->size == 1) $dbmsInternalType = 'TINYINT'; else $dbmsInternalType = 'INT'; break; - case OR_DB_TYPE_ORACLE: + case DbVersion::TYPE_ORACLE: $dbmsInternalType = 'NUMBER'; break; @@ -97,11 +97,11 @@ class Column case self::TYPE_TEXT: switch ($this->dbmsType) { - case OR_DB_TYPE_MYSQL: + case DbVersion::TYPE_MYSQL: $dbmsInternalType = 'MEDIUMTEXT'; break; - case OR_DB_TYPE_ORACLE: + case DbVersion::TYPE_ORACLE: $dbmsInternalType = 'CLOB'; break; @@ -113,19 +113,19 @@ class Column case self::TYPE_BLOB: switch ($this->dbmsType) { - case OR_DB_TYPE_MYSQL: + case DbVersion::TYPE_MYSQL: $dbmsInternalType = 'MEDIUMBLOB'; break; - case OR_DB_TYPE_ORACLE: + case DbVersion::TYPE_ORACLE: $dbmsInternalType = 'CLOB'; break; - case OR_DB_TYPE_POSTGRES: + case DbVersion::TYPE_POSTGRES: $dbmsInternalType = 'TEXT'; break; - case OR_DB_TYPE_SQLITE: + case DbVersion::TYPE_SQLITE: $dbmsInternalType = 'TEXT'; break; @@ -138,7 +138,7 @@ class Column throw new \LogicException( 'Unknown Column type: ' . $this->type); } - if ($this->dbmsType == OR_DB_TYPE_ORACLE) { + if ($this->dbmsType == DbVersion::TYPE_ORACLE) { // TEXT-columns must be nullable in Oracle, because empty strings are treated as NULL. BAD BAD BAD, Oracle! if ($this->type == self::TYPE_VARCHAR || $this->type == self::TYPE_TEXT) $nullable = true; diff --git a/modules/database/DbVersion.class.php b/modules/database/DbVersion.class.php @@ -3,14 +3,14 @@ namespace database; -define('OR_DB_TYPE_MYSQL',1); -define('OR_DB_TYPE_POSTGRES',2); -define('OR_DB_TYPE_SQLITE',3); -define('OR_DB_TYPE_ORACLE',4); - abstract class DbVersion { + const TYPE_MYSQL = 1; + const TYPE_POSTGRES = 2; + const TYPE_SQLITE = 3; + const TYPE_ORACLE = 4; + private $db; private $tablePrefix; private $tableSuffix; @@ -31,26 +31,26 @@ abstract class DbVersion switch ($db->conf['type']) { case 'mysql': case 'mysqli': - $this->dbmsType = OR_DB_TYPE_MYSQL; + $this->dbmsType = DbVersion::TYPE_MYSQL; break; case 'postgresql': - $this->dbmsType = OR_DB_TYPE_POSTGRES; + $this->dbmsType = DbVersion::TYPE_POSTGRES; break; case 'sqlite': case 'sqlite3': - $this->dbmsType = OR_DB_TYPE_SQLITE; + $this->dbmsType = DbVersion::TYPE_SQLITE; break; case 'pdo': $dsnParts = explode(':', $db->conf['dsn']); switch ($dsnParts[0]) { case 'mysql': - $this->dbmsType = OR_DB_TYPE_MYSQL; + $this->dbmsType = DbVersion::TYPE_MYSQL; break; case 'pgsql': - $this->dbmsType = OR_DB_TYPE_POSTGRES; + $this->dbmsType = DbVersion::TYPE_POSTGRES; break; case 'sqlite': - $this->dbmsType = OR_DB_TYPE_SQLITE; + $this->dbmsType = DbVersion::TYPE_SQLITE; break; default: throw new \LogicException('Unknown DBMS in PDO-DSN: ' . $dsnParts[0]); diff --git a/modules/database/Table.class.php b/modules/database/Table.class.php @@ -69,7 +69,7 @@ class Table { $tableName = $this->getSqlName(); - $table_opts = $this->dbmsType == OR_DB_TYPE_MYSQL ? ' ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci' : ''; + $table_opts = $this->dbmsType == DbVersion::TYPE_MYSQL ? ' ENGINE=InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci' : ''; $ddl = $this->db->sql('CREATE TABLE ' . $tableName . '(id INTEGER)' . $table_opts . ';'); // The syntax 'TYPE = InnoDB' was deprecated in MySQL 5.0 and was removed in MySQL 5.1 and later versions. diff --git a/modules/template_engine/components/html/form/Form.class.php b/modules/template_engine/components/html/form/Form.class.php @@ -132,7 +132,7 @@ class FormComponent extends Component $formContent->addChild( (new CMSElement('input')) ->addAttribute('type', 'hidden') - ->addAttribute('name', REQ_PARAM_LANGUAGE_ID) + ->addAttribute('name', RequestParams::PARAM_LANGUAGE_ID) ->addAttribute('value', $this->languageid) ); @@ -140,33 +140,33 @@ class FormComponent extends Component $formContent->addChild( (new CMSElement('input')) ->addAttribute('type', 'hidden') - ->addAttribute('name', REQ_PARAM_MODEL_ID) + ->addAttribute('name', RequestParams::PARAM_MODEL_ID) ->addAttribute('value', $this->modelid) ); $formContent->addChild( (new CMSElement('input')) ->addAttribute('type', 'hidden') - ->addAttribute('name', REQ_PARAM_TOKEN) + ->addAttribute('name', RequestParams::PARAM_TOKEN) ->addAttribute('value', $this->token) ); $formContent->addChild( (new CMSElement('input')) ->addAttribute('type', 'hidden') - ->addAttribute('name', REQ_PARAM_ACTION) + ->addAttribute('name', RequestParams::PARAM_ACTION) ->addAttribute('value', $this->action) ); $formContent->addChild( (new CMSElement('input')) ->addAttribute('type', 'hidden') - ->addAttribute('name', REQ_PARAM_SUBACTION) + ->addAttribute('name', RequestParams::PARAM_SUBACTION) ->addAttribute('value', $this->subaction) ); $formContent->addChild( (new CMSElement('input')) ->addAttribute('type', 'hidden') - ->addAttribute('name', REQ_PARAM_ID) + ->addAttribute('name', RequestParams::PARAM_ID) ->addAttribute('value', $this->id) ); diff --git a/modules/template_engine/components/html/link/Link.class.php b/modules/template_engine/components/html/link/Link.class.php @@ -130,7 +130,7 @@ class LinkComponent extends Component $data['action' ] = (!empty($this->action ))?$this->action :$this->request->action; $data['subaction'] = (!empty($this->subaction))?$this->subaction:$this->request->method; $data['id' ] = (!empty($this->id ))?$this->id :''; - $data[REQ_PARAM_TOKEN] = '${_token}'; + $data[RequestParams::PARAM_TOKEN] = '${_token}'; foreach( $this->getExtraParamArray() as $varname => $varvalue ) $data[$varname] = $varvalue; diff --git a/modules/util/Html.class.php b/modules/util/Html.class.php @@ -18,6 +18,8 @@ namespace util; +use cms\action\RequestParams; + /** * Bereitstellen von Methoden fuer die Darstellung von HTML-Elementen * @@ -84,9 +86,9 @@ class Html // if ( $id != '' ) // $id = '.'.$id; } else { - $params[REQ_PARAM_ACTION] = $action; - $params[REQ_PARAM_SUBACTION] = $subaction; - $params[REQ_PARAM_ID] = $id; + $params[RequestParams::PARAM_ACTION] = $action; + $params[RequestParams::PARAM_SUBACTION] = $subaction; + $params[RequestParams::PARAM_ID] = $id; } if (count($params) > 0) { @@ -95,8 +97,8 @@ class Html $urlParameterList[] = urlencode($var) . '=' . urlencode($value); } - $urlParameterList['_'] = @$urlParameterList[REQ_PARAM_ACTION] . '-' . @$urlParameterList[REQ_PARAM_ID]; - unset($urlParameterList[REQ_PARAM_ACTION], $urlParameterList[REQ_PARAM_ID]); + $urlParameterList['_'] = @$urlParameterList[RequestParams::PARAM_ACTION] . '-' . @$urlParameterList[RequestParams::PARAM_ID]; + unset($urlParameterList[RequestParams::PARAM_ACTION], $urlParameterList[RequestParams::PARAM_ID]); // We do not escape '&' as '&amp;' here, as it would brake things like Ajax-Urls. // Maybe the escaping should be controled by a parameter. diff --git a/modules/util/Transformer.class.php b/modules/util/Transformer.class.php @@ -5,7 +5,7 @@ namespace util; use cms\model\Link; use cms\model\BaseObject; use cms\model\Url; -use ObjectNotFoundException; +use \util\exception\ObjectNotFoundException; use wikiparser\model\DocumentElement; use wikiparser\parser\WikiParser; diff --git a/modules/util/Tree.class.php b/modules/util/Tree.class.php @@ -2,6 +2,7 @@ namespace util; +use cms\action\RequestParams; use cms\model\Acl; use cms\model\Element; use cms\model\File; @@ -160,11 +161,11 @@ class Tree // $treeElement->text = $folder->name; $treeElement->text = \cms\base\Language::lang('FOLDER_ROOT'); $treeElement->description = \cms\base\Language::lang('FOLDER_ROOT_DESC'); - $treeElement->extraId[REQ_PARAM_LANGUAGE_ID] = $defaultLanguageId; - $treeElement->extraId[REQ_PARAM_MODEL_ID] = $defaultModelId; + $treeElement->extraId[RequestParams::PARAM_LANGUAGE_ID] = $defaultLanguageId; + $treeElement->extraId[RequestParams::PARAM_MODEL_ID] = $defaultModelId; $treeElement->icon = 'folder'; $treeElement->action = 'folder'; -// $treeElement->url = Html::url( 'folder','',$folder->objectid,array(REQ_PARAM_TARGET=>'content') ); +// $treeElement->url = Html::url( 'folder','',$folder->objectid,array(RequestParams::PARAM_TARGET=>'content') ); $treeElement->type = 'folder'; $treeElement->internalId = $folder->objectid; $this->addTreeElement($treeElement); @@ -175,12 +176,12 @@ class Tree if ($userIsProjectAdmin) { $treeElement = new TreeElement(); $treeElement->id = $projectid; - $treeElement->extraId[REQ_PARAM_PROJECT_ID] = $projectid; - $treeElement->extraId[REQ_PARAM_MODEL_ID] = $defaultModelId; - $treeElement->extraId[REQ_PARAM_LANGUAGE_ID] = $defaultLanguageId; + $treeElement->extraId[RequestParams::PARAM_PROJECT_ID] = $projectid; + $treeElement->extraId[RequestParams::PARAM_MODEL_ID] = $defaultModelId; + $treeElement->extraId[RequestParams::PARAM_LANGUAGE_ID] = $defaultLanguageId; $treeElement->internalId = $projectid; $treeElement->text = \cms\base\Language::lang('TEMPLATES'); -// $treeElement->url = Html::url('template','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); +// $treeElement->url = Html::url('template','listing',0,array(RequestParams::PARAM_TARGETSUBACTION=>'listing',RequestParams::PARAM_TARGET=>'content')); $treeElement->description = \cms\base\Language::lang('TEMPLATES_DESC'); $treeElement->icon = 'templatelist'; $treeElement->action = 'templatelist'; @@ -194,11 +195,11 @@ class Tree $treeElement = new TreeElement(); $treeElement->description = ''; $treeElement->id = $projectid; - $treeElement->extraId[REQ_PARAM_PROJECT_ID] = $projectid; + $treeElement->extraId[RequestParams::PARAM_PROJECT_ID] = $projectid; $treeElement->internalId = $projectid; $treeElement->action = 'languagelist'; $treeElement->text = \cms\base\Language::lang('LANGUAGES'); -// $treeElement->url = Html::url('language','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); +// $treeElement->url = Html::url('language','listing',0,array(RequestParams::PARAM_TARGETSUBACTION=>'listing',RequestParams::PARAM_TARGET=>'content')); $treeElement->icon = 'languagelist'; $treeElement->description = \cms\base\Language::lang('LANGUAGES_DESC'); @@ -221,10 +222,10 @@ class Tree $treeElement->id = $projectid; $treeElement->internalId = $projectid; - $treeElement->extraId[REQ_PARAM_PROJECT_ID] = $projectid; + $treeElement->extraId[RequestParams::PARAM_PROJECT_ID] = $projectid; $treeElement->description = \cms\base\Language::lang('MODELS_DESC'); $treeElement->text = \cms\base\Language::lang('MODELS'); -// $treeElement->url = Html::url('model','listing',0,array(REQ_PARAM_TARGETSUBACTION=>'listing',REQ_PARAM_TARGET=>'content')); +// $treeElement->url = Html::url('model','listing',0,array(RequestParams::PARAM_TARGETSUBACTION=>'listing',RequestParams::PARAM_TARGET=>'content')); $treeElement->action = 'modellist'; $treeElement->icon = 'modellist'; $this->addTreeElement($treeElement); @@ -409,7 +410,7 @@ class Tree } $treeElement->action = $object->getType(); $treeElement->icon = $object->getType(); - $treeElement->extraId = array(REQ_PARAM_LANGUAGE_ID => $value->languageid); + $treeElement->extraId = array(RequestParams::PARAM_LANGUAGE_ID => $value->languageid); $treeElement->description = \cms\base\Language::lang('' . $object->getType()); if ($object->desc != '') @@ -444,7 +445,7 @@ class Tree $treeElement->action = $o->getType(); $treeElement->icon = $o->getType(); - $treeElement->extraId = array(REQ_PARAM_LANGUAGE_ID => $_REQUEST[REQ_PARAM_LANGUAGE_ID], REQ_PARAM_MODEL_ID => $_REQUEST[REQ_PARAM_MODEL_ID]); + $treeElement->extraId = array(RequestParams::PARAM_LANGUAGE_ID => $_REQUEST[RequestParams::PARAM_LANGUAGE_ID], RequestParams::PARAM_MODEL_ID => $_REQUEST[RequestParams::PARAM_MODEL_ID]); // Besonderheiten fuer bestimmte Objekttypen @@ -479,7 +480,7 @@ class Tree $treeElement->action = $o->getType(); $treeElement->icon = $o->getType(); - $treeElement->extraId = array(REQ_PARAM_LANGUAGE_ID => $_REQUEST[REQ_PARAM_LANGUAGE_ID], REQ_PARAM_MODEL_ID => $_REQUEST[REQ_PARAM_MODEL_ID]); + $treeElement->extraId = array(RequestParams::PARAM_LANGUAGE_ID => $_REQUEST[RequestParams::PARAM_LANGUAGE_ID], RequestParams::PARAM_MODEL_ID => $_REQUEST[RequestParams::PARAM_MODEL_ID]); // Besonderheiten fuer bestimmte Objekttypen if ($o->isPage) { @@ -519,7 +520,7 @@ class Tree $treeElement = new TreeElement(); $treeElement->id = $o->objectid; $treeElement->internalId = $o->objectid; - $treeElement->extraId = array(REQ_PARAM_LANGUAGE_ID => $f->languageid, REQ_PARAM_MODEL_ID => $f->modelid); + $treeElement->extraId = array(RequestParams::PARAM_LANGUAGE_ID => $f->languageid, RequestParams::PARAM_MODEL_ID => $f->modelid); $treeElement->text = $o->name; $treeElement->description = \cms\base\Language::lang('' . $o->getType()) . ' ' . $o->objectid; diff --git a/modules/util/exception/ObjectNotFoundException.class.php b/modules/util/exception/ObjectNotFoundException.class.php @@ -0,0 +1,10 @@ +<?php + +namespace util\exception; + +use Exception; + +class ObjectNotFoundException extends Exception +{ +} +