commit d57bc0b289ba3bbd321235ca4eddd868415242ad
parent 4f3b2cd31e18570bfa397e71e6a66f9e86b3eb2b
Author: Jan Dankert <develop@jandankert.de>
Date: Thu, 30 May 2019 00:10:13 +0200
New: Aliases integriert, jedoch noch nicht sprachspezifisch (folgt noch).
Diffstat:
12 files changed, 510 insertions(+), 374 deletions(-)
diff --git a/modules/cms-core/action/AliasAction.class.php b/modules/cms-core/action/AliasAction.class.php
@@ -67,7 +67,7 @@ class AliasAction extends ObjectAction
function infoView()
{
- $this->setTemplateVars( $this->link->getProperties() );
+ $this->setTemplateVars( $this->alias->getProperties() );
}
diff --git a/modules/cms-core/action/ElementAction.class.php b/modules/cms-core/action/ElementAction.class.php
@@ -545,34 +545,13 @@ class ElementAction extends Action
case 'folderObjectId':
- $folders = array();
// Ermitteln aller verf?gbaren Objekt-IDs
$template = new Template( $this->element->templateid );
$template->load();
$project = new Project( $template->projectid );
- foreach( $project->getAllFolders() as $id )
- {
- $o = new BaseObject( $id );
- $o->load();
-
- $folders[ $id ] = '';
- if ( !$o->isRoot )
- {
- $f = new Folder( $o->parentid );
- $f->load();
- $names = $f->parentObjectNames(true,true);
- foreach( $names as $fid=>$name )
- $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH);
- $folders[ $id ] = implode( ' » ',$names );
- $folders[ $id ] .= ' » ';
- }
- $folders[ $id ] .= $o->name;
- }
-
- asort( $folders ); // Sortieren
-
+ $folders = $project->getAllFlatFolders();
$this->setTemplateVar('folders',$folders);
$this->setTemplateVar('folderobjectid' ,$this->element->folderObjectId );
diff --git a/modules/cms-core/action/ObjectAction.class.php b/modules/cms-core/action/ObjectAction.class.php
@@ -479,6 +479,17 @@ class ObjectAction extends Action
$this->baseObject->filename = BaseObject::urlify( $this->getRequestVar('filename') );
$this->baseObject->save();
+ $alias = $this->baseObject->getAlias();
+ $alias->filename = BaseObject::urlify( $this->getRequestVar( 'alias_filename') );
+ $alias->parentid = $this->getRequestId('alias_folderid');
+
+ // If no alias, remove the alias
+ if ( ! $alias->filename )
+ $alias->delete();
+ else
+ $alias->save();
+
+
// Name/Beschreibung für alle Sprachen speichern.
foreach( $this->baseObject->getNames() as $name )
{
@@ -506,7 +517,13 @@ class ObjectAction extends Action
*/
public function propView()
{
- $this->setTemplateVar( 'filename', $this->baseObject->filename );
+ $this->setTemplateVar( 'filename', $this->baseObject->filename );
+ $alias = $this->baseObject->getAlias();
+ $this->setTemplateVar( 'alias' , $alias->filename );
+ $this->setTemplateVar( 'alias_folderid', $alias->parentid );
+
+ $project = Project::create( $this->baseObject->projectid );
+ $this->setTemplateVar( 'folders' , $project->getAllFlatFolders() );
$nameProps = array();
foreach( $this->baseObject->getNames() as $name )
diff --git a/modules/cms-core/model/Alias.class.php b/modules/cms-core/model/Alias.class.php
@@ -15,6 +15,7 @@ class Alias extends BaseObject
public function __construct( $objectid='' )
{
+ $this->isAlias = true;
parent::__construct( $objectid );
}
@@ -26,20 +27,43 @@ class Alias extends BaseObject
*/
public function load()
{
- $sql = db()->sql( 'SELECT *'.
- ' FROM {{alias}}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $row = $sql->getRow();
+ if ( $this->objectid != null )
+ {
+ $sql = db()->sql( 'SELECT *'.
+ ' FROM {{alias}}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ }
+ elseif ( $this->linkedObjectId != null && intval($this->languageid) != 0 )
+ {
+ $sql = db()->sql( 'SELECT *'.
+ ' FROM {{alias}}'.
+ ' WHERE link_objectid={objectid}'.
+ ' AND languageid={languageid}' );
+ $sql->setInt( 'objectid' ,$this->linkedObjectId );
+ $sql->setInt( 'languageid',$this->languageid );
+ }
+ elseif ( $this->linkedObjectId != null )
+ {
+ $sql = db()->sql( 'SELECT *'.
+ ' FROM {{alias}}'.
+ ' WHERE link_objectid={objectid}');
+ $sql->setInt( 'objectid' ,$this->linkedObjectId );
+ }
+
+
+ $row = $sql->getRow();
if ( count($row ) != 0 )
{
+ $this->aliasid = $row['id' ];
+ $this->objectid = $row['objectid' ];
$this->linkedObjectId = $row['link_objectid'];
- $this->languageid = $row['languageid '];
- }
+ $this->languageid = $row['languageid' ];
- $this->objectLoad();
- }
+ $this->objectLoad();
+ }
+ }
/**
@@ -47,9 +71,12 @@ class Alias extends BaseObject
*/
public function delete()
{
+ if ( ! $this->isPersistent() )
+ return;
+
$sql = db()->sql( 'DELETE FROM {{alias}} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
+ ' WHERE id={aliasid}' );
+ $sql->setInt( 'aliasid',$this->aliasid );
$sql->query();
@@ -62,13 +89,16 @@ class Alias extends BaseObject
*/
public function save()
{
+ if ( ! $this->isPersistent() )
+ $this->add();
+
$sql = db()->sql('UPDATE {{alias}} SET '.
- ' link_objectid = {linkobjectid}'.
+ ' link_objectid = {linkobjectid},'.
' languageid = {languageid}'.
' WHERE objectid={objectid}' );
$sql->setInt ('objectid' ,$this->objectid );
$sql->setInt ('linkobjectid',$this->linkedObjectId );
- $sql->setInt ('languageid' ,$this->languageid );
+ $sql->setIntOrNull('languageid' ,$this->languageid );
$sql->query();
@@ -99,11 +129,11 @@ class Alias extends BaseObject
VALUES( {linkid},{objectid},{linkobjectid},{languageid} )
SQL
);
- $stmt->setInt ('id' ,$this->aliasid );
+ $stmt->setInt ('linkid' ,$this->aliasid );
$stmt->setInt ('objectid' ,$this->objectid );
$stmt->setInt ('linkobjectid',$this->linkedObjectId );
- $stmt->setInt ('languageid' ,$this->languageid );
+ $stmt->setIntOrNull('languageid' ,$this->languageid );
$stmt->query();
}
diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php
@@ -238,17 +238,29 @@ class BaseObject
}
- // Kompletten Dateinamen des Objektes erzeugen
- function full_filename()
+ /**
+ * Kompletten Dateinamen des Objektes erzeugen
+ * @return String
+ */
+ public function full_filename()
{
- $path = $this->path();
+ // Do we have an alias for this object?
+ $alias = $this->getAlias();
+ if ( $alias->filename )
+ {
+ return $alias->full_filename();
+ }
+ else
+ {
+ $path = $this->path();
- if ($path != '')
- $path.= '/';
+ if ($path != '')
+ $path.= '/';
- $path.= $this->filename();
+ $path.= $this->filename();
- return $path;
+ return $path;
+ }
}
/**
@@ -903,6 +915,8 @@ SQL
$sql = $db->sql('DELETE FROM {{object}} WHERE id={objectid}');
$sql->setInt('objectid', $this->objectid);
$sql->query();
+
+ $this->objectid = null;
}
@@ -1170,7 +1184,7 @@ SQL
if ($this->isPage ) return self::TYPEID_PAGE;
if ($this->isLink ) return self::TYPEID_LINK;
if ($this->isUrl ) return self::TYPEID_URL;
- if ($this->isAlias ) return self::TYPEID_URL;
+ if ($this->isAlias ) return self::TYPEID_ALIAS;
}
@@ -1541,6 +1555,23 @@ SQL
}
+ public function getAlias()
+ {
+ $alias = new Alias();
+ $alias->projectid = $this->projectid;
+ $alias->linkedObjectId = $this->objectid;
+ $alias->load();
+
+ return $alias;
+ }
+
+
+
+ public function isPersistent()
+ {
+ return intval( $this->objectid ) > 0;
+ }
+
}
diff --git a/modules/cms-core/model/File.class.php b/modules/cms-core/model/File.class.php
@@ -132,7 +132,7 @@ class File extends BaseObject
*/
public function filename()
{
- if ( !empty( $this->extension ) )
+ if ( $this->extension )
return parent::filename().'.'.$this->extension;
else
return parent::filename();
diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php
@@ -9,6 +9,7 @@ define('PROJECT_FLAG_PUBLISH_PAGE_EXTENSION',8);
use database\Database;
use Session;
+use Text;
/**
@@ -1018,6 +1019,37 @@ SQL
}
+ /**
+ * @return array
+ */
+ public function getAllFlatFolders() {
+
+ $folders = array();
+
+ foreach( $this->getAllFolders() as $id )
+ {
+ $o = new BaseObject( $id );
+ $o->load();
+
+ $folders[ $id ] = '';
+ if ( !$o->isRoot )
+ {
+ $f = new Folder( $o->parentid );
+ $f->load();
+ $names = $f->parentObjectNames(true,true);
+ foreach( $names as $fid=>$name )
+ $names[$fid] = Text::maxLength($name,15,'..',STR_PAD_BOTH);
+ $folders[ $id ] = implode( ' » ',$names );
+ $folders[ $id ] .= ' » ';
+ }
+ $folders[ $id ] .= $o->name;
+ }
+
+ asort( $folders ); // Sortieren
+
+ return $folders;
+ }
+
}
?>
\ No newline at end of file
diff --git a/modules/cms-core/model/require.php b/modules/cms-core/model/require.php
@@ -7,10 +7,11 @@ require_once( __DIR__.'/Value.class.php' );
require_once( __DIR__.'/Acl.class.php' );
require_once( __DIR__.'/Template.class.php' );
require_once( __DIR__.'/TemplateModel.class.php' );
-require_once( __DIR__ .'/BaseObject.class.php');
-require_once( __DIR__ .'/Name.class.php');
+require_once( __DIR__.'/BaseObject.class.php');
+require_once( __DIR__.'/Name.class.php');
require_once( __DIR__.'/Folder.class.php' );
require_once( __DIR__.'/Link.class.php' );
+require_once( __DIR__.'/Alias.class.php' );
require_once( __DIR__.'/Url.class.php' );
require_once( __DIR__.'/File.class.php' );
require_once( __DIR__.'/Image.class.php' );
diff --git a/modules/cms-publish/PublishPublic.class.php b/modules/cms-publish/PublishPublic.class.php
@@ -36,6 +36,10 @@ class PublishPublic extends Publish
else
$schema = OR_LINK_SCHEMA_ABSOLUTE;
+ // If the target has an alias, use this alias as the target.
+ $alias = $to->getAlias();
+ if ( $alias->filename )
+ $to = $alias;
switch( $to->typeid )
{
diff --git a/modules/database/Statement.class.php b/modules/database/Statement.class.php
@@ -1,295 +1,307 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2006 Jan Dankert, jandankert@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-namespace database;
-use database\driver\PDODriver;
-use Exception;
-use RuntimeException;
-
-/**
- * Darstellung einer Datenbank-Abfrage.
- *
- * @author Jan Dankert
- * @package openrat.database
- */
-class Statement
-{
-
- /**
- * SQL-Objekt.
- *
- * @var SQL
- */
- var $sql;
-
- /**
- * Client.
- *
- * @var PDODriver
- */
- var $client;
-
-
- /**
- * Datenbank-Konfiguration
- * @var array
- */
- var $conf;
-
- /**
- * Statement
- * @var \PDOStatement
- */
- var $stmt;
-
- /**
- * Statement constructor.
- * @param $sql string Sql
- * @param $client Database
- * @param $conf array
- */
- public function __construct($sql, $client, $conf )
- {
- // Tabellen-Praefixe ergaenzen.
- $this->conf = $conf;
- $this->client = $client;
-
- $sql = str_replace('{{',$conf['prefix'],$sql);
- $sql = str_replace('}}',$conf['suffix'],$sql);
-
- $this->sql = new Sql( $sql );
-
- // Statement an die Datenbank schicken
- $this->stmt = $this->client->prepare( $this->sql->query,$this->sql->param );
- }
-
-
- /**
- * Ausfuehren einer Datenbankanfrage.
- *
- * @return Object (Result)
- */
- public function query()
- {
- return $this->execute();
- }
-
-
- /**
- * Ausfuehren einer Datenbankanfrage.
- *
- * @param SQL-Objekt
- * @return Object (Result)
- */
- public function execute( )
- {
- // Ausfuehren...
- $result = $this->client->query($this->stmt, $this->sql);
-
- if ( $result === FALSE )
- {
- throw new RuntimeException( 'Database-Statement '.$this->sql->query.' could not be executed: '.$this->client->error);
- }
-
- return $result;
- }
-
-
- /**
- * Ermittelt genau 1 Datenbankergebnis aus einer SQL-Anfrage.
- * Falls es mehrere Treffer gibt, wird die 1. Spalte aus der 1. Zeile genommen.
- *
- * @return String
- */
- public function &getOne()
- {
- $none = '';
- $result = $this->query();
-
- $row = $this->client->fetchRow( $this->stmt, $result,0 );
-
- if ( ! is_array($row) )
- return $none;
-
- $keys = array_keys($row);
-
- return $row[ $keys[0] ];
- }
-
-
- /**
- * Ermittelt eine Zeile aus der Datenbank.
- *
- * @return array
- */
- public function &getRow()
- {
- $result = $this->query();
-
- $row = $this->client->fetchRow( $this->stmt, $result,0 );
-
- if ( ! is_array($row) )
- $row = array();
-
- return $row;
- }
-
-
- /**
- * Ermittelt eine (die 1.) Spalte aus dem Datenbankergebnis.
- *
- * @return array
- */
- public function &getCol()
- {
- $result = $this->query();
-
- $i = 0;
- $col = array();
- while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) )
- {
- if ( empty($row) )
- break;
-
- $keys = array_keys($row);
- $col[] = $row[ $keys[0] ];
- }
-
- return $col;
- }
-
-
- /**
- * Ermittelt ein assoziatives Array aus der Datenbank.
- *
- * @return array
- */
- public function &getAssoc()
- {
- $force_array = false;
-
- $results = array();
- $result = $this->query();
-
- $i = 0;
-
- while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) )
- {
- if ( empty($row) )
- break;
-
- $keys = array_keys($row);
- $key1 = $keys[0];
- $id = $row[$key1];
-
- if ( count($row) > 2 || $force_array )
- {
- unset( $row[$key1] );
- $results[ $id ] = $row;
- }
- else
- {
- $key2 = $keys[1];
-
- $results[ $id ] = $row[$key2];
- }
- }
-
- return $results;
- }
-
-
- /**
- * Ermittelt alle Datenbankergebniszeilen.
- *
- * @return array
- */
- public function &getAll()
- {
- $result = $this->query();
-
- $results = array();
- $i = 0;
-
- while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) )
- {
- $results[] = $row;
- }
-
- return $results;
- }
-
-
- /**
- * Setzt eine Ganzzahl als Parameter.<br>
- * @param $name string
- * @param $value integer
- */
- function setInt( $name,$value )
- {
- $this->client->bind( $this->stmt, $name, (int)$value );
- }
-
-
-
- /**
- * Setzt eine Zeichenkette als Parameter.<br>
- *
- * @param $name string
- * @param $value string
- */
- function setString( $name,$value )
- {
- $this->client->bind( $this->stmt, $name, (string)$value );
- }
-
-
-
- /**
- * Setzt einen bool'schen Wert als Parameter.<br>
- * Ist der Parameterwert wahr, dann wird eine 1 gesetzt. Sonst 0.<br>
- *
- * @param $name string
- * @param $value bool
-
- */
- function setBoolean( $name,$value )
- {
- if ( $value )
- $this->setInt( $name,1 );
- else
- $this->setInt( $name,0 );
- }
-
-
-
- /**
- * Setzt einen Parameter auf den Wert <code>null</code>.<br>
- *
- * @param $name string Name des Parameters
- */
- function setNull( $name )
- {
- $this->client->bind( $this->stmt, $name, null );
- }
-
-
-}
-
-
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2006 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+namespace database;
+use database\driver\PDODriver;
+use Exception;
+use RuntimeException;
+
+/**
+ * Darstellung einer Datenbank-Abfrage.
+ *
+ * @author Jan Dankert
+ * @package openrat.database
+ */
+class Statement
+{
+
+ /**
+ * SQL-Objekt.
+ *
+ * @var SQL
+ */
+ var $sql;
+
+ /**
+ * Client.
+ *
+ * @var PDODriver
+ */
+ var $client;
+
+
+ /**
+ * Datenbank-Konfiguration
+ * @var array
+ */
+ var $conf;
+
+ /**
+ * Statement
+ * @var \PDOStatement
+ */
+ var $stmt;
+
+ /**
+ * Statement constructor.
+ * @param $sql string Sql
+ * @param $client Database
+ * @param $conf array
+ */
+ public function __construct($sql, $client, $conf )
+ {
+ // Tabellen-Praefixe ergaenzen.
+ $this->conf = $conf;
+ $this->client = $client;
+
+ $sql = str_replace('{{',$conf['prefix'],$sql);
+ $sql = str_replace('}}',$conf['suffix'],$sql);
+
+ $this->sql = new Sql( $sql );
+
+ // Statement an die Datenbank schicken
+ $this->stmt = $this->client->prepare( $this->sql->query,$this->sql->param );
+ }
+
+
+ /**
+ * Ausfuehren einer Datenbankanfrage.
+ *
+ * @return Object (Result)
+ */
+ public function query()
+ {
+ return $this->execute();
+ }
+
+
+ /**
+ * Ausfuehren einer Datenbankanfrage.
+ *
+ * @param SQL-Objekt
+ * @return Object (Result)
+ */
+ public function execute( )
+ {
+ // Ausfuehren...
+ $result = $this->client->query($this->stmt, $this->sql);
+
+ if ( $result === FALSE )
+ {
+ throw new RuntimeException( 'Database-Statement '.$this->sql->query.' could not be executed: '.$this->client->error);
+ }
+
+ return $result;
+ }
+
+
+ /**
+ * Ermittelt genau 1 Datenbankergebnis aus einer SQL-Anfrage.
+ * Falls es mehrere Treffer gibt, wird die 1. Spalte aus der 1. Zeile genommen.
+ *
+ * @return String
+ */
+ public function &getOne()
+ {
+ $none = '';
+ $result = $this->query();
+
+ $row = $this->client->fetchRow( $this->stmt, $result,0 );
+
+ if ( ! is_array($row) )
+ return $none;
+
+ $keys = array_keys($row);
+
+ return $row[ $keys[0] ];
+ }
+
+
+ /**
+ * Ermittelt eine Zeile aus der Datenbank.
+ *
+ * @return array
+ */
+ public function &getRow()
+ {
+ $result = $this->query();
+
+ $row = $this->client->fetchRow( $this->stmt, $result,0 );
+
+ if ( ! is_array($row) )
+ $row = array();
+
+ return $row;
+ }
+
+
+ /**
+ * Ermittelt eine (die 1.) Spalte aus dem Datenbankergebnis.
+ *
+ * @return array
+ */
+ public function &getCol()
+ {
+ $result = $this->query();
+
+ $i = 0;
+ $col = array();
+ while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) )
+ {
+ if ( empty($row) )
+ break;
+
+ $keys = array_keys($row);
+ $col[] = $row[ $keys[0] ];
+ }
+
+ return $col;
+ }
+
+
+ /**
+ * Ermittelt ein assoziatives Array aus der Datenbank.
+ *
+ * @return array
+ */
+ public function &getAssoc()
+ {
+ $force_array = false;
+
+ $results = array();
+ $result = $this->query();
+
+ $i = 0;
+
+ while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) )
+ {
+ if ( empty($row) )
+ break;
+
+ $keys = array_keys($row);
+ $key1 = $keys[0];
+ $id = $row[$key1];
+
+ if ( count($row) > 2 || $force_array )
+ {
+ unset( $row[$key1] );
+ $results[ $id ] = $row;
+ }
+ else
+ {
+ $key2 = $keys[1];
+
+ $results[ $id ] = $row[$key2];
+ }
+ }
+
+ return $results;
+ }
+
+
+ /**
+ * Ermittelt alle Datenbankergebniszeilen.
+ *
+ * @return array
+ */
+ public function &getAll()
+ {
+ $result = $this->query();
+
+ $results = array();
+ $i = 0;
+
+ while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) )
+ {
+ $results[] = $row;
+ }
+
+ return $results;
+ }
+
+
+ /**
+ * Setzt eine Ganzzahl als Parameter.<br>
+ * @param $name string
+ * @param $value integer
+ */
+ function setInt( $name,$value )
+ {
+ $this->client->bind( $this->stmt, $name, (int)$value );
+ }
+
+
+
+ /**
+ * Setzt eine Ganzzahl als Parameter.<br>
+ * @param $name string
+ * @param $value integer
+ */
+ function setIntOrNull( $name,$value )
+ {
+ $this->client->bind( $this->stmt, $name, $value );
+ }
+
+
+
+ /**
+ * Setzt eine Zeichenkette als Parameter.<br>
+ *
+ * @param $name string
+ * @param $value string
+ */
+ function setString( $name,$value )
+ {
+ $this->client->bind( $this->stmt, $name, (string)$value );
+ }
+
+
+
+ /**
+ * Setzt einen bool'schen Wert als Parameter.<br>
+ * Ist der Parameterwert wahr, dann wird eine 1 gesetzt. Sonst 0.<br>
+ *
+ * @param $name string
+ * @param $value bool
+
+ */
+ function setBoolean( $name,$value )
+ {
+ if ( $value )
+ $this->setInt( $name,1 );
+ else
+ $this->setInt( $name,0 );
+ }
+
+
+
+ /**
+ * Setzt einen Parameter auf den Wert <code>null</code>.<br>
+ *
+ * @param $name string Name des Parameters
+ */
+ function setNull( $name )
+ {
+ $this->client->bind( $this->stmt, $name, null );
+ }
+
+
+}
+
+
?>
\ No newline at end of file
diff --git a/modules/database/driver/PDODriver.class.php b/modules/database/driver/PDODriver.class.php
@@ -191,7 +191,7 @@ class PDODriver
elseif( is_null($value))
$type = PDO::PARAM_NULL;
else
- throw new RuntimeException( 'Unknown type' );
+ throw new RuntimeException( 'Unknown type for parameter '.$name.': '.gettype($value) );
$stmt->bindValue($name,$value,$type);
}
diff --git a/modules/util/Tree.class.php b/modules/util/Tree.class.php
@@ -15,10 +15,9 @@ use cms\model\Value;
/**
- * Darstellen einer Baumstruktur mit Administrationfunktionen
- * @author $Author$
- * @version $Revision$
- * @package openrat.services
+ * Navigation tree.
+ *
+ * @author Jan Dankert
*/
class Tree
{
@@ -27,27 +26,22 @@ class Tree
private $userIsAdmin = false;
/**
- * Alle Elemente des Baumes
+ * Konstruktor.
*/
- var $elements;
- var $confCache = array();
-
- // Konstruktor
-
- function __construct()
+ public function __construct()
{
// Feststellen, ob der angemeldete Benutzer ein Administrator ist
$user = Session::getUser();
$this->userIsAdmin = $user->isAdmin;
}
- function root()
+ public function root()
{
$this->overview();
}
- function overview()
+ public function overview()
{
$treeElement = new TreeElement();
$treeElement->id = 0;
@@ -87,7 +81,7 @@ class Tree
}
- function userandgroups()
+ public function userandgroups()
{
if ( !$this->userIsAdmin )
throw new SecurityException();
@@ -112,7 +106,7 @@ class Tree
}
- function projects()
+ public function projects()
{
// Schleife ueber alle Projekte
foreach (Project::getAllProjects() as $id => $name) {
@@ -140,7 +134,7 @@ class Tree
}
- function project($projectid)
+ public function project($projectid)
{
$project = new Project($projectid);
@@ -235,7 +229,7 @@ class Tree
}
- function users()
+ public function users()
{
if ( !$this->userIsAdmin )
throw new SecurityException();
@@ -266,7 +260,7 @@ class Tree
}
- function groups()
+ public function groups()
{
if ( !$this->userIsAdmin )
throw new SecurityException();
@@ -291,7 +285,7 @@ class Tree
}
- function userofgroup($id)
+ public function userofgroup($id)
{
if ( !$this->userIsAdmin )
throw new SecurityException();
@@ -316,7 +310,7 @@ class Tree
}
- function page($id)
+ public function page($id)
{
$page = new Page($id);
$page->languageid = $_REQUEST[REQ_PARAM_LANGUAGE_ID];
@@ -353,7 +347,7 @@ class Tree
}
- function pageelement($id)
+ public function pageelement($id)
{
$ids = explode('_',$id);
if ( count($ids) > 1 )
@@ -396,7 +390,7 @@ class Tree
}
- function value($id)
+ public function value($id)
{
//echo "id: $id";
if ($id != 0) {
@@ -432,7 +426,7 @@ class Tree
}
- function link($id)
+ public function link($id)
{
$link = new Link($id);
$link->load();
@@ -467,6 +461,41 @@ class Tree
}
+ public function alias($id)
+ {
+ $alias = new \cms\model\Alias($id);
+ $alias->load();
+
+ $o = new BaseObject($alias->linkedObjectId);
+ $o->load();
+
+ $treeElement = new TreeElement();
+ $treeElement->id = $o->objectid;
+ $treeElement->internalId = $o->objectid;
+ $treeElement->text = $o->name;
+ $treeElement->description = lang('GLOBAL_' . $o->getType()) . ' ' . $id;
+
+ if ($o->desc != '')
+ $treeElement->description .= ': ' . $o->desc;
+ else
+ $treeElement->description .= ' - ' . lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
+
+ $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]);
+
+ // Besonderheiten fuer bestimmte Objekttypen
+ if ($o->isPage) {
+ // Nur wenn die Seite beschreibbar ist, werden die
+ // Elemente im Baum angezeigt
+ if ($o->hasRight(Acl::ACL_WRITE))
+ $treeElement->type = 'pageelements';
+ }
+
+ $this->addTreeElement($treeElement);
+ }
+
+
public function url($id)
{
// URLs have no sub-nodes.
@@ -477,14 +506,15 @@ class Tree
/**
* Laedt Elemente zu einem Ordner
*/
- function folder($id)
+ public function folder($id)
{
$f = new Folder($id);
$t = time();
$f->languageid = $_REQUEST[REQ_PARAM_LANGUAGE_ID];
$f->modelid = $_REQUEST[REQ_PARAM_MODEL_ID];
- foreach ($f->getObjects() as /*@var BaseObject */$o) {
+ /** @var BaseObject $o */
+ foreach ($f->getObjects() as $o) {
// Wenn keine Leseberechtigung
if (!$o->hasRight(Acl::ACL_READ))
continue;
@@ -510,7 +540,7 @@ class Tree
}
- function templates($projectid)
+ public function templates($projectid)
{
$project = new Project($projectid);
@@ -532,7 +562,7 @@ class Tree
}
- function template($id)
+ public function template($id)
{
$t = new Template($id);
@@ -569,7 +599,7 @@ class Tree
/**
* Sprachen
*/
- function languages($projectid)
+ public function languages($projectid)
{
// Sprachvarianten
//
@@ -590,7 +620,7 @@ class Tree
// Projektvarianten
//
- function models($projectid)
+ public function models($projectid)
{
$project = new Project($projectid);