File modules/util/Html.class.php

Last commit: Sun Feb 13 19:39:49 2022 +0100	dankert	Refactoring: Special output type "preview" for previewing pages and files.
1 <?php 2 // OpenRat Content Management System 3 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 2 8 // of the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 20 namespace util; 21 use cms\action\RequestParams; 22 use cms\base\Configuration; 23 24 /** 25 * Bereitstellen von Methoden fuer die Darstellung von HTML-Elementen 26 * 27 * @author $Author$ 28 * @version $Revision$ 29 * @package openrat.services 30 */ 31 class Html 32 { 33 34 35 /** 36 * creates a relative url to an action. 37 * 38 * @param string Aktion, die aufgerufen werden soll 39 * @param string Unteraktion, die innerhalb der Aktion aufgerufen werden soll 40 * @param int Id fuer diesen Aufruf 41 * @param array Weitere beliebige Parameter 42 * @deprecated UI logic, should not be used on the server. 43 */ 44 public static function url($action, $subaction = '', $id = '', $params = array()) 45 { 46 if (intval($id) == 0) 47 $id = ''; 48 49 $conf = Configuration::Conf(); 50 51 // Session-Id ergaenzen 52 if ($conf->subset('interface')->subset('url')->is('add_sessionid',false)) 53 $params[session_name()] = session_id(); 54 55 if ($conf->subset('security')->is('use_post_token'.true)) 56 $params['token'] = Session::token(); 57 58 if (isset($params['objectid']) && !isset($params['id'])) 59 $params['id'] = $params['objectid']; 60 61 $params[RequestParams::PARAM_ACTION ] = $action; 62 63 if ( $subaction ) 64 $params[RequestParams::PARAM_SUBACTION] = $subaction; 65 66 if ( $id ) 67 $params[RequestParams::PARAM_ID] = $id; 68 69 $urlParameterList = array_map( function($name,$value) { 70 return urlencode($name) . '=' . urlencode($value); 71 },array_keys($params),$params); 72 73 // We do not escape '&' as '&amp;' here, as it would brake things like Ajax-Urls. 74 // Maybe the escaping should be controlled by a parameter. 75 return './?'.implode('&', $urlParameterList); 76 } 77 78 79 /** 80 * creates a relative url to the UI. 81 * 82 * @param string $action Aktion, die aufgerufen werden soll 83 * @param $id string Unteraktion, die innerhalb der Aktion aufgerufen werden soll 84 */ 85 public static function locationUrl($action, $id = '') 86 { 87 if (intval($id) == 0) 88 $id = ''; 89 90 return './#/'.$action.'/'.$id; 91 } 92 }
Download modules/util/Html.class.php
History Sun, 13 Feb 2022 19:39:49 +0100 dankert Refactoring: Special output type "preview" for previewing pages and files. Fri, 23 Oct 2020 23:09:52 +0200 Jan Dankert Refactoring: Using the new config classes. Tue, 29 Sep 2020 22:17:11 +0200 Jan Dankert Refactoring: Do not use global constants. Sat, 26 Sep 2020 12:20:43 +0200 Jan Dankert Refactoring: No global variables like $SESS any more. All constants are capsulated by classes. Sat, 26 Sep 2020 10:32:02 +0200 Jan Dankert Refactoring: No global $conf array any more. Sat, 26 Sep 2020 04:26:55 +0200 Jan Dankert Refactoring: read configuration values with a class. Sat, 26 Sep 2020 03:03:47 +0200 Jan Dankert Refactoring: less global functions. Sat, 22 Feb 2020 23:58:02 +0100 Jan Dankert Refactoring: Namespacing for module 'util'. Wed, 4 Sep 2019 00:11:56 +0200 Jan Dankert New: TemplateCompiler zum Umwandeln aller Templates. Ggf. entfällt dann das Adhoc-Compiling der Templates. Tue, 30 Apr 2019 22:49:48 +0200 Jan Dankert Aktuelles Objekt im Navigationsbaum markieren. Tue, 11 Dec 2018 00:56:52 +0100 Jan Dankert Das Escaping des '&' hat an vielen Stellen Probleme bereitet. Ausgebaut! Dann soll der W3C-Validator halt meckern. Sun, 23 Sep 2018 22:26:00 +0200 Jan Dankert Die IndexAction soll beim Start des UI auch die Action und Id ermitteln. Damit die Id gesetzt werden kann, muss die Id über den Dispatcher in die Action gebracht werden. Dazu muss erst der Request gesetzt werden, bevor die weitere Verarbeitung geschieht, daher geschieht die fachliche Initialisierung der Actions jetzt (wieder) über eine init()-Methode, die vom Dispatcher aufgerufen wird. Wed, 29 Aug 2018 01:33:22 +0200 Jan Dankert Aufgeräumt: Die RenderParams werden zu beginn erzeugt und werden in den Dispatcher und die Action reingereicht. Dadurch entfällt das Durchreichen von Action/Method. Fri, 29 Dec 2017 01:35:50 +0100 Jan Dankert Großes Refactoring: Neues Modul CMS-UI. Dieses enthält sämtliche Logik für die Bedienoberfläche. TODO: Modul CMS-API. Sat, 16 Dec 2017 23:21:31 +0100 Jan Dankert Eigenes Modul für alle Util-Klassen.