commit 1f1b5a191d6ad8b205614c927365531237d6d35f
parent 8ca3fc51e0dd8564e9bc06a123e2f3d3e285d364
Author: dankert <devnull@localhost>
Date: Wed, 10 Nov 2004 23:46:27 +0100
*** empty log message ***
Diffstat:
5 files changed, 1700 insertions(+), 1621 deletions(-)
diff --git a/functions/request.inc.php b/functions/request.inc.php
@@ -1,48 +1,45 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// DaCMS Content Management System
-// Copyright (C) 2002 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.
-// ---------------------------------------------------------------------------
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// DaCMS Content Management System
+// Copyright (C) 2002 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.
+// ---------------------------------------------------------------------------
// $Log$
-// Revision 1.1 2004-05-02 19:27:22 dankert
-// Initiale Version
-//
-// ---------------------------------------------------------------------------
-
-if (isset($_SESSION))
- $SESS = &$_SESSION;
-else $SESS = &$HTTP_SESSION_VARS;
-
-if (isset($_FILES))
- $FILES = &$_FILES;
-else $FILES = &$HTTP_POST_FILES;
-
-$REQ = array_merge($HTTP_GET_VARS,$HTTP_POST_VARS,$_GET,$_POST);
-
-function request_into_session( $name )
-{
- global $REQ,$SESS;
-
- if (isset($REQ[$name]))
- {
- $SESS[$name] = $REQ[$name];
- }
-}
-
+// Revision 1.2 2004-11-10 22:44:36 dankert
+// *** empty log message ***
+//
+// Revision 1.1 2004/05/02 19:27:22 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+
+$REQ = array_merge($HTTP_GET_VARS,$HTTP_POST_VARS,$_GET,$_POST);
+
+function request_into_session( $name )
+{
+ global $REQ,$SESS;
+
+ if (isset($REQ[$name]))
+ {
+ $SESS[$name] = $REQ[$name];
+ }
+}
+
?>
\ No newline at end of file
diff --git a/objectClasses/File.class.php b/objectClasses/File.class.php
@@ -1,453 +1,466 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// DaCMS Content Management System
-// Copyright (C) 2002 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.
-// ---------------------------------------------------------------------------
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// DaCMS Content Management System
+// Copyright (C) 2002 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.
+// ---------------------------------------------------------------------------
// $Log$
-// Revision 1.2 2004-05-02 14:41:31 dankert
-// Einfügen package-name (@package)
-//
-// Revision 1.1 2004/04/24 15:15:12 dankert
-// Initiale Version
-//
-// Revision 1.1 2003/10/27 23:21:55 dankert
-// Methode(n) hinzugefügt: savevalue(), save()
-//
-// ---------------------------------------------------------------------------
-
-
-/**
- * Darstellen einer Datei
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class File extends Object
-{
- var $fileid;
-
- var $size = 0;
- var $value = '';
- var $extension = '';
- var $log_filenames = array();
- var $publish = null;
-
- /**
- * Um Probleme mit BLOB-Feldern und Datenbank-Besonderheiten zu vermeiden,
- * kann der Binärinhalt BASE64-kodiert gespeichert werden.
- * @type Boolean
- */
- var $storeValueAsBase64 = false;
-
- function File( $objectid='' )
- {
- global $conf,$SESS;
-
- if ( isset($conf['database_'.$SESS['dbid']]['base64']) &&
- $conf['database_'.$SESS['dbid']]['base64'] == true )
- $this->storeValueAsBase64 = true;
- else $this->storeValueAsBase64 = false;
-
- $this->Object( $objectid );
- $this->isFile = true;
- }
-
-
- /**
- * Ermitteln des Dateinamens dieser Datei
- *
- * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
- */
- function full_filename()
- {
- $filename = parent::full_filename();
-
- if ( $this->extension != '' )
- {
- $filename .= '.'.$this->extension;
- }
-
- return $filename;
- }
-
-
- /**
- * Ermitteln des Dateinamens dieser Datei (ohne Pfadangabe)
- *
- * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
- */
- function filenameWithExtension()
- {
- if ( $this->extension != '' )
- return $this->filename.'.'.$this->extension;
- else return $this->filename;
- }
-
-
- /**
- * Ermitteln aller Eigenschaften
- *
- * @return Array
- */
- function getProperties()
- {
- return array_merge( parent::getProperties(),
- Array('full_filename'=>$this->full_filename(),
- 'extension' =>$this->extension,
- 'size' =>$this->size,
- 'mimetype' =>$this->mimetype() ) );
- }
-
-
- function getFileObjectIdsByExtension( $extension )
- {
- global $SESS;
- $db = db_connection();
-
- $sqlquery = 'SELECT * FROM {t_object} ';
-
- if ( $extension != '' )
- {
- $sqlquery .= " WHERE extension='";
-
- $ext = explode(',',$extension);
- $sqlquery .= implode( "' OR extension='",$ext );
- $sqlquery .= "' AND is_file=1 AND projectid={projectid}";
- }
- else
- {
- $sqlquery .= " WHERE is_file=1 AND projectid={projectid}";
- }
-
- $sql = new Sql( $sqlquery );
- $sql->setInt( 'projectid',$SESS['projectid'] );
-
- return $db->getCol( $sql->query );
- }
-
-
- /**
- * Es werden Objekte zu einer Dateierweiterung ermittelt
- * @param String Dateierweiterung ohne führenden Punkt (z.B. 'jpeg')
- * @return Array Liste der gefundenen Objekt-IDs
- */
- function getObjectIdsByExtension( $extension )
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT {t_file}.objectid FROM {t_file} '.
- ' LEFT JOIN {t_object} '.
- ' ON {t_object}.id={t_file}.objectid'.
- ' WHERE {t_file}.extension={extension}'.
- ' AND {t_object}.projectid={projectid}' );
- $sql->setInt ( 'projectid',$this->projectid );
- $sql->setString( 'extension',$extension );
-
- return $db->getCol( $sql->query );
- }
-
-
- function mimeType()
- {
- global $conf_languagedir,$conf_php;
- $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
-
- if ( isset($mime_types[ strtolower($this->extension) ]) )
- $mime = $mime_types[ strtolower($this->extension) ];
- else $mime = 'application/octet-stream';
-
- return( $mime );
- }
-
-
- function imageResize( $newWidth,$newHeight )
- {
- global $conf;
-
- // Schalter, ob GD in Version 2 verfuegbar ist
- $gd2 = $conf['gd']['version2'];
-
- $this->write(); // Datei schreiben
-
- // Bildinformationen ermitteln
- $size = getimagesize( $this->tmpfile() );
-
- // Breite und Hoehe des aktuellen Bildes
- $oldWidth = $size[0];
- $oldHeight = $size[1];
- $aspectRatio = $oldHeight / $oldWidth; // Seitenverhaeltnis
-
- // Wenn nur Breite oder Hoehe angegeben ist, dann
- // das Seitenverhaeltnis beibehalten
- if ( $newWidth == 0 )
- $newWidth = $newHeight / $aspectRatio;
-
- if ( $newHeight == 0 )
- $newHeight = $newWidth * $aspectRatio;
-
- switch( $size[2] )
- {
- case '1': // GIF
-
- $oldImage = ImageCreateFromGIF( $this->tmpfile );
- $newImage = ImageCreate($newWidth,$newHeight);
- ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- ImageGIF($newImage, $this->tmpfile() );
- $this->extension = 'gif';
-
- break;
-
- case '2': // JPEG
-
- $oldImage = ImageCreateFromJPEG($this->tmpfile);
-
- if ( $gd2 )
- {
- // Verwende TrueColor
- $newImage = imageCreateTrueColor( $newWidth,$newHeight );
-
- ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
- else
- {
- // GD Version 1.x unterstützt kein TrueColor
- $newImage = ImageCreate($newWidth,$newHeight);
-
- ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
-
- ImageJPEG($newImage, $this->tmpfile );
- $this->extension = 'jpeg';
-
- break;
-
- case '3': // PNG
-
- $oldImage = imagecreatefrompng($this->tmpfile);
- if ( $gd2 )
- {
- // Verwende TrueColor
- $newImage = imageCreateTrueColor( $newWidth,$newHeight );
-
- ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
- else
- {
- // GD Version 1.x unterstützt kein TrueColor
- $newImage = ImageCreate($newWidth,$newHeight);
-
- ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
- $newHeight,$oldWidth,$oldHeight);
- }
-
- imagepng( $newImage,$this->tmpfile() );
- $this->extension = 'png';
-
- break;
-
- default:
- die('unsupported type for resizing');
- }
-
- $f = fopen( $this->tmpfile(), "r" );
- $this->value = fread( $f,filesize($this->tmpfile()) );
- fclose( $f );
- }
-
-
- // Lesen der Datei aus der Datenbank
- function load()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT id,extension,size'.
- ' FROM {t_file}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $row = $db->getRow( $sql->query );
-
- $this->fileid = $row['id' ];
- $this->extension = $row['extension'];
- $this->size = $row['size' ];
-
- $this->objectLoad();
- }
-
-
-
- function delete()
- {
- $db = db_connection();
-
- // Datei löschen
- $sql = new Sql( 'DELETE FROM {t_file} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $db->query( $sql->query );
-
- $this->objectDelete();
- }
-
-
- /**
- * Stellt fest, ob es sich bei dieser Datei um ein Bild handelt
- */
- function isImage()
- {
- return eregi('jpe?g|png|gif',$this->extension);
- }
-
-
- function extension()
- {
- if ($this->extension != '')
- return $this->extension;
-
- $this->load();
- return $this->extension;
- }
-
-
- // Einen Dateinamen in Dateiname und Extension aufteilen
- function parse_filename($filename)
- {
- $filename = basename($filename);
-
- $p = strrpos($filename, '.');
- if ($p !== false)
- {
- $this->extension = substr($filename, $p +1);
- $this->filename = substr($filename, 0, $p);
- }
- else
- {
- $this->extension = '';
- $this->filename = $filename;
- }
- }
-
-
- function save()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('UPDATE {t_file} SET '.
- ' size = {size},'.
- ' extension = {extension}'.
- ' WHERE objectid={objectid}' );
- $sql->setString('size' ,$this->size );
- $sql->setString('extension',$this->extension );
- $sql->setString('objectid' ,$this->objectid );
- $db->query( $sql->query );
-
- $this->objectSave();
- }
-
-
- // Lesen der Datei aus der Datenbank
- function loadValue()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT size,value'.
- ' FROM {t_file}'.
- ' WHERE objectid={objectid}' );
- $sql->setInt( 'objectid',$this->objectid );
- $row = $db->getRow( $sql->query );
-
- $this->value = $row['value'];
- $this->size = $row['size' ];
-
- if ( $this->storeValueAsBase64 )
- $this->value = base64_decode( $this->value );
-
- return( $this->value );
- }
-
-
- // Lesen der Datei aus der Datenbank
- function saveValue( $value = '' )
- {
- $db = db_connection();
-
- $sql = new Sql( 'UPDATE {t_file}'.
- ' SET value={value}, '.
- ' size={size} '.
- ' WHERE objectid={objectid}' );
- $sql->setString( 'objectid' ,$this->objectid );
- $sql->setInt ( 'size' ,strlen($this->value) );
-
- if ( $this->storeValueAsBase64 )
- $sql->setString( 'value' ,base64_encode($this->value) );
- else $sql->setString( 'value' ,$this->value );
-
- $db->query( $sql->query );
- }
-
-
- // Lesen der Datei aus der Datenbank und schreiben in temporaere Datei
- function write()
- {
- $f = fopen( $this->tmpfile(),'w' );
- fwrite( $f,$this->loadValue() );
- fclose( $f );
- }
-
-
- function add()
- {
- $db = db_connection();
-
- $this->objectAdd();
-
- $sql = new Sql('SELECT MAX(id) FROM {t_file}');
- $this->fileid = intval($db->getOne($sql->query))+1;
-
- $sql = new Sql('INSERT INTO {t_file}'.
- ' (id,objectid,extension,size,value)'.
- " VALUES( {fileid},{objectid},{extension},0,'' )" );
- $sql->setInt ('fileid' ,$this->fileid );
- $sql->setInt ('objectid' ,$this->objectid );
- $sql->setString('extension',$this->extension );
-
- $db->query( $sql->query );
-
- $this->saveValue();
- }
-
-
- function publish()
- {
- if ( ! is_object($this->publish) )
- $this->publish = new Publish();
-
- $this->write();
- $this->publish->copy( $this->tmpfile(),$this->full_filename() );
-
-// $this->log_filenames = $this->publish->log_filenames;
- }
-}
-
+// Revision 1.3 2004-11-10 22:45:24 dankert
+// *** empty log message ***
+//
+// Revision 1.2 2004/05/02 14:41:31 dankert
+// Einf?gen package-name (@package)
+//
+// Revision 1.1 2004/04/24 15:15:12 dankert
+// Initiale Version
+//
+// Revision 1.1 2003/10/27 23:21:55 dankert
+// Methode(n) hinzugef?gt: savevalue(), save()
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Darstellen einer Datei
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class File extends Object
+{
+ var $fileid;
+
+ var $size = 0;
+ var $value = '';
+ var $extension = '';
+ var $log_filenames = array();
+ var $publish = null;
+
+ /**
+ * Um Probleme mit BLOB-Feldern und Datenbank-Besonderheiten zu vermeiden,
+ * kann der Bin?rinhalt BASE64-kodiert gespeichert werden.
+ * @type Boolean
+ */
+ var $storeValueAsBase64 = false;
+
+ function File( $objectid='' )
+ {
+ global $conf,$SESS;
+
+ $db = Session::getDatabase();
+ $this->storeValueAsBase64 = $db->conf['base64'];
+
+ $this->Object( $objectid );
+ $this->isFile = true;
+ }
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Datei
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
+ */
+ function full_filename()
+ {
+ $filename = parent::full_filename();
+
+ if ( $this->extension != '' )
+ {
+ $filename .= '.'.$this->extension;
+ }
+
+ return $filename;
+ }
+
+
+ /**
+ * Ermitteln des Dateinamens dieser Datei (ohne Pfadangabe)
+ *
+ * @return String Kompletter Dateiname, z.B. '/pfad/datei.jpeg'
+ */
+ function filenameWithExtension()
+ {
+ if ( $this->extension != '' )
+ return $this->filename.'.'.$this->extension;
+ else return $this->filename;
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return array_merge( parent::getProperties(),
+ Array('full_filename'=>$this->full_filename(),
+ 'extension' =>$this->extension,
+ 'size' =>$this->size,
+ 'mimetype' =>$this->mimetype() ) );
+ }
+
+
+ function getFileObjectIdsByExtension( $extension )
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sqlquery = 'SELECT * FROM {t_object} ';
+
+ if ( $extension != '' )
+ {
+ $sqlquery .= " WHERE extension='";
+
+ $ext = explode(',',$extension);
+ $sqlquery .= implode( "' OR extension='",$ext );
+ $sqlquery .= "' AND is_file=1 AND projectid={projectid}";
+ }
+ else
+ {
+ $sqlquery .= " WHERE is_file=1 AND projectid={projectid}";
+ }
+
+ $sql = new Sql( $sqlquery );
+ $sql->setInt( 'projectid',$SESS['projectid'] );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ /**
+ * Es werden Objekte zu einer Dateierweiterung ermittelt
+ * @param String Dateierweiterung ohne f?hrenden Punkt (z.B. 'jpeg')
+ * @return Array Liste der gefundenen Objekt-IDs
+ */
+ function getObjectIdsByExtension( $extension )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT {t_file}.objectid FROM {t_file} '.
+ ' LEFT JOIN {t_object} '.
+ ' ON {t_object}.id={t_file}.objectid'.
+ ' WHERE {t_file}.extension={extension}'.
+ ' AND {t_object}.projectid={projectid}' );
+ $sql->setInt ( 'projectid',$this->projectid );
+ $sql->setString( 'extension',$extension );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function mimeType()
+ {
+ global $conf_languagedir,$conf_php;
+ $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
+
+ if ( isset($mime_types[ strtolower($this->extension) ]) )
+ $mime = $mime_types[ strtolower($this->extension) ];
+ else $mime = 'application/octet-stream';
+
+ return( $mime );
+ }
+
+
+ function imageResize( $newWidth,$newHeight )
+ {
+ global $conf;
+
+ // Schalter, ob GD in Version 2 verfuegbar ist
+ $gd2 = $conf['gd']['version2'];
+
+ $this->write(); // Datei schreiben
+
+ // Bildinformationen ermitteln
+ $size = getimagesize( $this->tmpfile() );
+
+ // Breite und Hoehe des aktuellen Bildes
+ $oldWidth = $size[0];
+ $oldHeight = $size[1];
+ $aspectRatio = $oldHeight / $oldWidth; // Seitenverhaeltnis
+
+ // Wenn nur Breite oder Hoehe angegeben ist, dann
+ // das Seitenverhaeltnis beibehalten
+ if ( $newWidth == 0 )
+ $newWidth = $newHeight / $aspectRatio;
+
+ if ( $newHeight == 0 )
+ $newHeight = $newWidth * $aspectRatio;
+
+ switch( $size[2] )
+ {
+ case '1': // GIF
+
+ $oldImage = ImageCreateFromGIF( $this->tmpfile );
+ $newImage = ImageCreate($newWidth,$newHeight);
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ ImageGIF($newImage, $this->tmpfile() );
+ $this->extension = 'gif';
+
+ break;
+
+ case '2': // JPEG
+
+ $oldImage = ImageCreateFromJPEG($this->tmpfile);
+
+ if ( $gd2 )
+ {
+ // Verwende TrueColor
+ $newImage = imageCreateTrueColor( $newWidth,$newHeight );
+
+ ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ // GD Version 1.x unterst?tzt kein TrueColor
+ $newImage = ImageCreate($newWidth,$newHeight);
+
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+
+ ImageJPEG($newImage, $this->tmpfile );
+ $this->extension = 'jpeg';
+
+ break;
+
+ case '3': // PNG
+
+ $oldImage = imagecreatefrompng($this->tmpfile);
+ if ( $gd2 )
+ {
+ // Verwende TrueColor
+ $newImage = imageCreateTrueColor( $newWidth,$newHeight );
+
+ ImageCopyResampled($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+ else
+ {
+ // GD Version 1.x unterst?tzt kein TrueColor
+ $newImage = ImageCreate($newWidth,$newHeight);
+
+ ImageCopyResized($newImage,$oldImage,0,0,0,0,$newWidth,
+ $newHeight,$oldWidth,$oldHeight);
+ }
+
+ imagepng( $newImage,$this->tmpfile() );
+ $this->extension = 'png';
+
+ break;
+
+ default:
+ die('unsupported type for resizing');
+ }
+
+ $f = fopen( $this->tmpfile(), "r" );
+ $this->value = fread( $f,filesize($this->tmpfile()) );
+ fclose( $f );
+ }
+
+
+ // Lesen der Datei aus der Datenbank
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id,extension,size'.
+ ' FROM {t_file}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $db->getRow( $sql->query );
+
+ $this->fileid = $row['id' ];
+ $this->extension = $row['extension'];
+ $this->size = $row['size' ];
+
+ $this->objectLoad();
+ }
+
+
+
+ function delete()
+ {
+ $db = db_connection();
+
+ // Datei l?schen
+ $sql = new Sql( 'DELETE FROM {t_file} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $db->query( $sql->query );
+
+ $this->objectDelete();
+ }
+
+
+ /**
+ * Stellt anhand der Dateiendung fest, ob es sich bei dieser Datei um ein Bild handelt
+ */
+ function isImage()
+ {
+ return eregi('jpe?g|png|gif',$this->extension);
+ }
+
+
+ function extension()
+ {
+ if ($this->extension != '')
+ return $this->extension;
+
+ $this->load();
+ return $this->extension;
+ }
+
+
+ // Einen Dateinamen in Dateiname und Extension aufteilen
+ function parse_filename($filename)
+ {
+ $filename = basename($filename);
+
+ $p = strrpos($filename, '.');
+ if ($p !== false)
+ {
+ $this->extension = substr($filename, $p +1);
+ $this->filename = substr($filename, 0, $p);
+ }
+ else
+ {
+ $this->extension = '';
+ $this->filename = $filename;
+ }
+ }
+
+
+ function save()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_file} SET '.
+ ' size = {size},'.
+ ' extension = {extension}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setString('size' ,$this->size );
+ $sql->setString('extension',$this->extension );
+ $sql->setString('objectid' ,$this->objectid );
+ $db->query( $sql->query );
+
+ $this->objectSave();
+ }
+
+
+ /**
+ * Kopieren des Inhaltes von einer anderen Datei
+ * @param ID der Datei, von der der Inhalt kopiert werden soll
+ */
+ function copyValueFromFile( $otherfileid )
+ {
+ $of = new File( $otherfileid );
+ $this->value = &$of->loadValue();
+ $this->saveValue();
+ }
+
+
+ // Lesen der Datei aus der Datenbank
+ function loadValue()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT size,value'.
+ ' FROM {t_file}'.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt( 'objectid',$this->objectid );
+ $row = $db->getRow( $sql->query );
+
+ $this->value = $row['value'];
+ $this->size = $row['size' ];
+
+ if ( $this->storeValueAsBase64 )
+ $this->value = base64_decode( $this->value );
+
+ return( $this->value );
+ }
+
+
+ // Lesen der Datei aus der Datenbank
+ function saveValue( $value = '' )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'UPDATE {t_file}'.
+ ' SET value={value}, '.
+ ' size={size} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setString( 'objectid' ,$this->objectid );
+ $sql->setInt ( 'size' ,strlen($this->value) );
+
+ if ( $this->storeValueAsBase64 )
+ $sql->setString( 'value' ,base64_encode($this->value) );
+ else $sql->setString( 'value' ,$this->value );
+
+ $db->query( $sql->query );
+ }
+
+
+ // Lesen der Datei aus der Datenbank und schreiben in temporaere Datei
+ function write()
+ {
+ $f = fopen( $this->tmpfile(),'w' );
+ fwrite( $f,$this->loadValue() );
+ fclose( $f );
+ }
+
+
+ function add()
+ {
+ $db = db_connection();
+
+ $this->objectAdd();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_file}');
+ $this->fileid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_file}'.
+ ' (id,objectid,extension,size,value)'.
+ " VALUES( {fileid},{objectid},{extension},0,'' )" );
+ $sql->setInt ('fileid' ,$this->fileid );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setString('extension',$this->extension );
+
+ $db->query( $sql->query );
+
+ $this->saveValue();
+ }
+
+
+ function publish()
+ {
+ if ( ! is_object($this->publish) )
+ $this->publish = new Publish();
+
+ $this->write();
+ $this->publish->copy( $this->tmpfile(),$this->full_filename() );
+
+// $this->log_filenames = $this->publish->log_filenames;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/objectClasses/Folder.class.php b/objectClasses/Folder.class.php
@@ -1,660 +1,726 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002-2004 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.
-// ---------------------------------------------------------------------------
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002-2004 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.
+// ---------------------------------------------------------------------------
// $Log$
-// Revision 1.2 2004-05-02 14:41:31 dankert
-// Einfügen package-name (@package)
-//
-// ---------------------------------------------------------------------------
-
-
-/**
- * Darstellen eines Ordners
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class Folder extends Object
-{
- var $folderid;
- var $projectid;
- var $parentfolders = array();
- var $subfolders = array();
- var $filenames = true;
- var $name = '';
- var $filename = '';
- var $desc = '';
- var $publish = null;
-
-
- function Folder( $objectid='' )
- {
- $this->Object( $objectid );
- $this->isFolder = true;
- }
-
-
- function add()
- {
- $this->objectAdd();
-
- $db = db_connection();
-
- $sql = new Sql('SELECT MAX(id) FROM {t_folder}');
- $this->folderid = intval($db->getOne($sql->query))+1;
-
- $sql = new Sql('INSERT INTO {t_folder}'.
- ' (id,objectid)'.
- ' VALUES( {folderid},{objectid} )' );
- $sql->setInt ('folderid' ,$this->folderid );
- $sql->setInt ('objectid' ,$this->objectid );
-
- $db->query( $sql->query );
- }
-
-
-
- function getRootFolderId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new SQL('SELECT id FROM {t_folder}'.
- ' WHERE parentid IS NULL'.
- ' AND projectid={projectid}' );
-
- // Wenn Methode statisch aufgerufen wird, ist $this nicht vorhanden
- if ( isset($this) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- // Datenbankabfrage ausführen
- return $db->getOne( $sql->query );
- }
-
-
- function load()
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT * FROM {t_folder} WHERE objectid={objectid}');
- $sql->setInt('objectid',$this->objectid);
-
- $row = $db->getRow( $sql->query );
-
- $this->objectLoad();
-
- $this->folderid = $row['id' ];
- }
-
-
-
- function save()
- {
- $db = db_connection();
-
-// $sql = new Sql('UPDATE {t_folder}'.
-// 'SET xx ={xx}'.
-// ' WHERE objectid={objectid}' );
-// $sql->setInt('parentid' ,$this->parentId);
-// $sql->setInt('objectid' ,$this->objectid);
-// $db->query( $sql->query );
-
- $this->objectSave();
- }
-
-
-
- function setOrderId( $orderid )
- {
- $db = db_connection();
-
- $sql = new Sql('UPDATE {t_folder} '.
- ' SET orderid={orderid}'.
- ' WHERE id={folderid}');
- $sql->setInt('folderid',$this->folderid);
- $sql->setInt('orderid' ,$orderid );
-
- $db->query( $sql->query );
- }
-
-
-
-// function getSubFolders()
-// {
-// global $SESS;
-// $db = db_connection();
-//
-// $sql = new Sql('SELECT id FROM {t_folder}'.
-// ' WHERE parentid={folderid}'.
-// ' AND projectid={projectid}'.
-// ' ORDER BY orderid ASC' );
-// $sql->setInt('folderid' ,$SESS['folderid' ]);
-// $sql->setInt('projectid',$SESS['projectid']);
-//
-// return( $db->getCol( $sql->query ));
-// }
-
-
- function getObjectIds()
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object}'.
- ' WHERE parentid={objectid}'.
- ' ORDER BY orderid ASC' );
- $sql->setInt('projectid',$this->projectid );
- $sql->setInt('objectid' ,$this->objectid );
-
- return( $db->getCol( $sql->query ) );
- }
-
-
- function publish( $subdirs = false )
- {
- if ( ! is_object($this->publish) )
- $this->publish = new Publish();
-
- foreach( $this->getObjectIds() as $oid )
- {
- $o = new Object( $oid );
- $o->load();
-
- if ( $o->isPage )
- {
- $p = new Page( $oid );
- $p->load();
- $p->publish = &$this->publish;
- $p->publish();
- }
-
- if ( $o->isFile )
- {
- $f = new File( $oid );
- $f->load();
- $f->publish = &$this->publish;
- $f->publish();
- }
-
- if ( $o->isFolder && $subdirs )
- {
- $f = new Folder( $oid );
- $f->load();
- $f->publish = &$this->publish;
- $f->publish( true );
- }
- }
- }
-
-
- function getObjectIdByFileName( $filename )
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object}'.
- ' WHERE parentid={objectid}'.
- ' AND filename={filename}' );
- $sql->setInt ('objectid' ,$this->objectid );
- $sql->setString('filename' ,$filename );
-
- return( intval($db->getOne( $sql->query )) );
- }
-
-
- function getAllObjectIds()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object}'.
- ' WHERE projectid={projectid}'.
- ' ORDER BY orderid ASC' );
- $sql->setInt('projectid',$SESS['projectid']);
-
- return( $db->getCol( $sql->query ) );
- }
-
-
- function getRootObjectId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object}'.
- ' WHERE parentid IS NULL'.
- ' AND projectid={projectid}' );
-
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return( $db->getOne( $sql->query ) );
- }
-
-
- function getOtherFolders()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object}'.
- ' WHERE is_folder=1'.
- ' and id != {objectid} '.
- ' AND projectid={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return( $db->getCol( $sql->query ) );
- }
-
-
- function getAllFolders()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object}'.
- ' WHERE is_folder=1'.
- ' AND projectid={projectid}' );
-
- if ( !isset($this->projectid) )
- $sql->setInt( 'projectid',$SESS['projectid'] );
- else $sql->setInt( 'projectid',$this->projectid );
-
- return( $db->getCol( $sql->query ) );
- }
-
-
- function getPages()
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object} '.
- ' WHERE parentid={objectid} AND is_page=1'.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $db->getCol( $sql->query );
- }
-
-
- function getFiles()
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object} '.
- ' WHERE parentid={objectid} AND is_file=1'.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $db->getCol( $sql->query );
- }
-
-
- function getLinks()
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object} '.
- ' WHERE parentid={objectid} AND is_link=1'.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- return $db->getCol( $sql->query );
- }
-
-
- // Rechte für diesen Ordner hinzufügen
- function addrights( $rights,$inherit = true )
- {
- global $SESS;
-
- $SESS['rights'][$rights['projectid']][$this->folderid]['show'] = true;
-
- if ($rights['read'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['read'] = 1;
- if ($rights['write'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['write'] = 1;
- if ($rights['create'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['create'] = 1;
- if ($rights['delete'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['delete'] = 1;
- if ($rights['publish'] == '1')
- $SESS['rights'][$rights['projectid']][$this->folderid]['publish'] = 1;
-
- // Rechte auf Unterordner vererben
- // sowie für übergeordnete Ordner die Anzeige erzwingen
- if ( $inherit )
- {
- // Übergeordnete Ordner ermitteln
- $parentfolder = $this->parentObjectIds();
-
- // Übergeordnete Ordner immer anzeigen (Schalter 'show'=true)
- foreach( $parentfolder as $folderid=>$name )
- {
- $f = new Folder( $folderid );
- $f->projectid = $this->projectid;
- $f->addrights( array('projectid'=>$rights['projectid']),false );
- unset($f);
- }
-
- $f = new Folder( 'null' );
- $f->projectid = $this->projectid;
- $f->addrights( array('projectid'=>$rights['projectid']),false );
- unset($f);
-
-
- // Unterordner ermitteln
- //echo "Kurz vor subfolderberechnung, folderid ist ".$this->folderid.'<br>';
- $subfolder = $this->subfolder();
-
- // Rechte weitergeben
- foreach( $subfolder as $folderid=>$name )
- {
- $f = new Folder( $folderid );
- $f->projectid = $this->projectid;
- $f->addrights( $rights,false );
- unset($f);
- }
- }
- }
-
-
- // Ermitteln aller übergeordneten Ordner
- //
- function parentfolder_bak( $with_root = false, $with_self = false )
- {
- $db = db_connection();
- $this->parentfolders = array();
-
- // Übergeordneten Ordner lesen
- $sql = new Sql('SELECT parentid FROM {t_folder} WHERE id={folderid}');
-
- $sql->setInt('folderid',$this->folderid);
- $parentid = $db->getOne( $sql->query );
-
- // Ordner ist bereits höchster Ordner
- if ( !is_numeric($parentid))
- {
- // Falls Anzeige höchster oder aktueller Ordner
- if ( $with_root && $with_self )
- {
- if ( $this->filenames )
- $this->parentfolders[ $this->folderid ] = $this->filename;
- else $this->parentfolders[ $this->folderid ] = $this->name;
- }
-
- return $this->parentfolders;
- }
-
- // Aktuellen Ordner hinzufügen
- if ( $with_self )
- {
- if ( $this->filenames )
- $this->parentfolders[ $this->folderid ] = $this->filename;
- else $this->parentfolders[ $this->folderid ] = $this->name;
- }
-
- // Schleife über alle übergeordneten Ordner
- while( is_numeric($parentid) )
- {
- $sql = new Sql('SELECT * FROM {t_folder} WHERE id={folderid}');
- $sql->setInt('folderid',$parentid);
-
- $row_folder = $db->getRow( $sql->query );
-
- if (is_numeric($row_folder['parentid']) || $with_root)
- {
- if ( $this->filenames )
- $this->parentfolders[ $parentid ] = $row_folder['filename'];
- else $this->parentfolders[ $parentid ] = $row_folder['name'];
- }
-
- $parentid = $row_folder['parentid'];
- }
-
-
- // Reihenfolge umdrehen
- $this->parentfolders = array_reverse($this->parentfolders,true);
-
- return $this->parentfolders;
- }
-
-
- // Ermitteln aller übergeordneten Ordner
- //
- function parentObjectIds( $with_root = false, $with_self = false )
- {
- $db = db_connection();
- $this->parentfolders = array();
-
- // Übergeordneten Ordner lesen
- $sql = new Sql('SELECT parentid FROM {t_object} WHERE id={objectid}');
-
- $sql->setInt('objectid',$this->objectid);
- $parentid = $db->getOne( $sql->query );
-
- // Ordner ist bereits höchster Ordner
- if ( !is_numeric($parentid))
- {
- // Falls Anzeige höchster oder aktueller Ordner
- if ( $with_root && $with_self )
- {
- $this->parentfolders[] = $this->objectid;
- }
-
- return $this->parentfolders;
- }
-
- // Aktuellen Ordner hinzufügen
- if ( $with_self )
- {
- $this->parentfolders[] = $this->objectid;
- }
-
- // Schleife über alle übergeordneten Ordner
- while( is_numeric($parentid) )
- {
- $sql = new Sql('SELECT parentid FROM {t_object} WHERE id={objectid}');
- $sql->setInt('objectid',$parentid);
-
- $row_folder = $db->getRow( $sql->query );
-
- if (is_numeric($row_folder['parentid']) || $with_root)
- {
- $this->parentfolders[] = $parentid;
- }
-
- $parentid = $row_folder['parentid'];
- }
-
-
- // Reihenfolge umdrehen
- $this->parentfolders = array_reverse($this->parentfolders,true);
-
- return $this->parentfolders;
- }
-
-
- function parentObjectFileNames( $with_root = false, $with_self = false )
- {
- $erg = array();
-
- foreach( $this->parentObjectIds( $with_root,$with_self ) as $oid )
- {
- $f = new Folder( $oid );
- $f->load();
- $erg[$oid] = $f->filename;
- }
-
- return $erg;
- }
-
- function parentObjectNames( $with_root = false, $with_self = false )
- {
- $erg = array();
-
- foreach( $this->parentObjectIds( $with_root,$with_self ) as $oid )
- {
- $f = new Folder( $oid );
- $f->load();
- $erg[$oid] = $f->name;
- }
- return $erg;
- }
-
-
- // Ermitteln aller Unterordner
- //
- function subfolder()
- {
- $db = db_connection();
-
- $sql = new Sql('SELECT id FROM {t_object} '.
- ' WHERE parentid={objectid} AND is_folder=1'.
- ' ORDER BY orderid ASC' );
- $sql->setInt( 'objectid' ,$this->objectid );
-
- $this->subfolders = $db->getCol( $sql->query );
-
- return $this->subfolders;
- }
-
-
- // Ermitteln aller Unterordner (rekursives Absteigen)
- //
- function getAllSubFolderIds()
- {
- global $SESS;
-
- $ids = array();
-
- foreach( $this->getSubFolderIds() as $id )
- {
-// echo "durchlaufe $id";
- $ids[] = $id;
-
- $f = new Folder( $id );
- $f->projectid = $this->projectid;
-
- foreach( $f->getAllSubFolderIds() as $xid )
- {
- $ids[] = $xid;
- }
- }
-
-// print_r( $ids );
- return $ids;
- }
-
-
- /**
- * Loeschen dieses Ordners.
- * Der Ordner wird nur geloescht, wenn er keine Unterelemente mehr enthält.
- * Zum Loeschen inklusive Unterelemente dient die Methode deleteAll()
- */
- function delete()
- {
- $db = db_connection();
-
- // Nur loeschen, wenn es keine Unterelemente gibt
- if ( count( $this->getObjectIds() ) == 0 )
- {
- $sql = new Sql( 'UPDATE {t_element} '.
- ' SET folderobjectid=NULL '.
- ' WHERE folderobjectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $db->query( $sql->query );
-
- $sql = new Sql( 'DELETE FROM {t_folder} '.
- ' WHERE objectid={objectid}' );
- $sql->setInt('objectid',$this->objectid);
- $db->query( $sql->query );
-
- $this->objectDelete();
- }
- }
-
-
- /**
- * Rekursives loeschen aller Inhalte
- *
- * Loeschen aller Inhalte dieses Ordners
- * inclusive aller Unterelemente
- */
- function deleteAll()
- {
- $db = db_connection();
-
- // Löschen aller Unterordner
- foreach( $this->subfolder() as $folderid )
- {
- $folder = new Folder( $folderid );
- {
- $folder->deleteAll();
- }
- }
-
- // Löschen aller Seiten,Verknuepfungen und Dateien in
- // diesem Ordner
- foreach( $this->getObjectIds() as $oid )
- {
- $object = new Object( $oid );
- {
- $object->load();
-
- if ( $object->isPage )
- {
- $page = new Page( $oid );
- $page->load();
- $page->delete();
- }
-
- if ( $object->isLink )
- {
- $link = new Link( $oid );
- $link->load();
- $link->delete();
- }
-
- if ( $object->isFile )
- {
- $file = new File( $oid );
- $file->load();
- $file->delete();
- }
- }
- }
-
- // Zum Abschluss den aktuellen Ordner loeschen
- $this->delete();
- }
-
-
- function getSubFolderIds()
- {
- return $this->subfolder();
- }
-}
-
-
+// Revision 1.3 2004-11-10 22:45:56 dankert
+// *** empty log message ***
+//
+// Revision 1.2 2004/05/02 14:41:31 dankert
+// Einf?gen package-name (@package)
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Darstellen eines Ordners
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class Folder extends Object
+{
+ var $folderid;
+ var $projectid;
+ var $parentfolders = array();
+ var $subfolders = array();
+ var $filenames = true;
+ var $name = '';
+ var $filename = '';
+ var $desc = '';
+ var $publish = null;
+
+
+ function Folder( $objectid='' )
+ {
+ $this->Object( $objectid );
+ $this->isFolder = true;
+ }
+
+
+ function add()
+ {
+ $this->objectAdd();
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_folder}');
+ $this->folderid = intval($db->getOne($sql->query))+1;
+
+ $sql = new Sql('INSERT INTO {t_folder}'.
+ ' (id,objectid)'.
+ ' VALUES( {folderid},{objectid} )' );
+ $sql->setInt ('folderid' ,$this->folderid );
+ $sql->setInt ('objectid' ,$this->objectid );
+
+ $db->query( $sql->query );
+ }
+
+
+
+ function getRootFolderId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new SQL('SELECT id FROM {t_folder}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ // Wenn Methode statisch aufgerufen wird, ist $this nicht vorhanden
+ if ( isset($this) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ // Datenbankabfrage ausf?hren
+ return $db->getOne( $sql->query );
+ }
+
+
+ function hasFilename( $filename )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT COUNT(*) FROM {t_object}'.' WHERE parentid={objectid} AND filename={filename}');
+
+ if ( intval($this->objectid)== 0 )
+ $sql->setNull('objectid');
+ else
+ $sql->setString('objectid', $this->objectid);
+
+ $sql->setString('filename', $filename );
+
+ return( $db->getOne($sql->query) > 0 );
+ }
+
+
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT * FROM {t_folder} WHERE objectid={objectid}');
+ $sql->setInt('objectid',$this->objectid);
+
+ $row = $db->getRow( $sql->query );
+
+ $this->objectLoad();
+
+ $this->folderid = $row['id' ];
+ }
+
+
+
+ function save()
+ {
+ $db = db_connection();
+
+// $sql = new Sql('UPDATE {t_folder}'.
+// 'SET xx ={xx}'.
+// ' WHERE objectid={objectid}' );
+// $sql->setInt('parentid' ,$this->parentId);
+// $sql->setInt('objectid' ,$this->objectid);
+// $db->query( $sql->query );
+
+ $this->objectSave();
+ }
+
+
+
+ function setOrderId( $orderid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('UPDATE {t_folder} '.
+ ' SET orderid={orderid}'.
+ ' WHERE id={folderid}');
+ $sql->setInt('folderid',$this->folderid);
+ $sql->setInt('orderid' ,$orderid );
+
+ $db->query( $sql->query );
+ }
+
+
+
+// function getSubFolders()
+// {
+// global $SESS;
+// $db = db_connection();
+//
+// $sql = new Sql('SELECT id FROM {t_folder}'.
+// ' WHERE parentid={folderid}'.
+// ' AND projectid={projectid}'.
+// ' ORDER BY orderid ASC' );
+// $sql->setInt('folderid' ,$SESS['folderid' ]);
+// $sql->setInt('projectid',$SESS['projectid']);
+//
+// return( $db->getCol( $sql->query ));
+// }
+
+
+ // Liest alle Objekte in diesem Ordner
+ function getObjectIds()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt('projectid',$this->projectid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ // Liest alle Objekte in diesem Ordner
+ function getObjectIdsByType()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY is_link,is_page,is_file,is_folder,orderid ASC' );
+ $sql->setInt('projectid',$this->projectid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ // Liest alle Objekte in diesem Ordner sortiert nach dem Namen (nicht Dateinamen!)
+ function getObjectIdsByName()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT {t_object}.id FROM {t_object}'.
+ ' LEFT JOIN {t_name} ON {t_object}.id={t_name}.objectid AND {t_name}.languageid={languageid} '.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY {t_name}.name,{t_object}.filename ASC');
+ $sql->setInt('objectid' , $this->objectid );
+ $sql->setInt('languageid', $this->languageid);
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ // Liest alle Objekte in diesem Ordner
+ function getObjectIdsByLastChange()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid={objectid}'.
+ ' ORDER BY lastchange_date,orderid ASC' );
+ $sql->setInt('projectid',$this->projectid );
+ $sql->setInt('objectid' ,$this->objectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function publish( $subdirs = false )
+ {
+ if ( ! is_object($this->publish) )
+ $this->publish = new Publish();
+
+ foreach( $this->getObjectIds() as $oid )
+ {
+ $o = new Object( $oid );
+ $o->load();
+
+ if ( $o->isPage )
+ {
+ $p = new Page( $oid );
+ $p->load();
+ $p->publish = &$this->publish;
+ $p->publish();
+ }
+
+ if ( $o->isFile )
+ {
+ $f = new File( $oid );
+ $f->load();
+ $f->publish = &$this->publish;
+ $f->publish();
+ }
+
+ if ( $o->isFolder && $subdirs )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $f->publish = &$this->publish;
+ $f->publish( true );
+ }
+ }
+ }
+
+
+ function getObjectIdByFileName( $filename )
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid={objectid}'.
+ ' AND filename={filename}' );
+ $sql->setInt ('objectid' ,$this->objectid );
+ $sql->setString('filename' ,$filename );
+
+ return( intval($db->getOne( $sql->query )) );
+ }
+
+
+ function getAllObjectIds()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt('projectid',$SESS['projectid']);
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function getRootObjectId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE parentid IS NULL'.
+ ' AND projectid={projectid}' );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return( $db->getOne( $sql->query ) );
+ }
+
+
+ function getOtherFolders()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE is_folder=1'.
+ ' and id != {objectid} '.
+ ' AND projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function getAllFolders()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object}'.
+ ' WHERE is_folder=1'.
+ ' AND projectid={projectid}' );
+
+ if ( !isset($this->projectid) )
+ $sql->setInt( 'projectid',$SESS['projectid'] );
+ else $sql->setInt( 'projectid',$this->projectid );
+
+ return( $db->getCol( $sql->query ) );
+ }
+
+
+ function getPages()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_page=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getFiles()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_file=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ function getLinks()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_link=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ return $db->getCol( $sql->query );
+ }
+
+
+ // Rechte f?r diesen Ordner hinzuf?gen
+ function addrights( $rights,$inherit = true )
+ {
+ global $SESS;
+
+ $SESS['rights'][$rights['projectid']][$this->folderid]['show'] = true;
+
+ if ($rights['read'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['read'] = 1;
+ if ($rights['write'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['write'] = 1;
+ if ($rights['create'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['create'] = 1;
+ if ($rights['delete'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['delete'] = 1;
+ if ($rights['publish'] == '1')
+ $SESS['rights'][$rights['projectid']][$this->folderid]['publish'] = 1;
+
+ // Rechte auf Unterordner vererben
+ // sowie f?r ?bergeordnete Ordner die Anzeige erzwingen
+ if ( $inherit )
+ {
+ // ?bergeordnete Ordner ermitteln
+ $parentfolder = $this->parentObjectIds();
+
+ // ?bergeordnete Ordner immer anzeigen (Schalter 'show'=true)
+ foreach( $parentfolder as $folderid=>$name )
+ {
+ $f = new Folder( $folderid );
+ $f->projectid = $this->projectid;
+ $f->addrights( array('projectid'=>$rights['projectid']),false );
+ unset($f);
+ }
+
+ $f = new Folder( 'null' );
+ $f->projectid = $this->projectid;
+ $f->addrights( array('projectid'=>$rights['projectid']),false );
+ unset($f);
+
+
+ // Unterordner ermitteln
+ //echo "Kurz vor subfolderberechnung, folderid ist ".$this->folderid.'<br>';
+ $subfolder = $this->subfolder();
+
+ // Rechte weitergeben
+ foreach( $subfolder as $folderid=>$name )
+ {
+ $f = new Folder( $folderid );
+ $f->projectid = $this->projectid;
+ $f->addrights( $rights,false );
+ unset($f);
+ }
+ }
+ }
+
+
+ // Ermitteln aller ?bergeordneten Ordner
+ //
+ function parentfolder_bak( $with_root = false, $with_self = false )
+ {
+ $db = db_connection();
+ $this->parentfolders = array();
+
+ // ?bergeordneten Ordner lesen
+ $sql = new Sql('SELECT parentid FROM {t_folder} WHERE id={folderid}');
+
+ $sql->setInt('folderid',$this->folderid);
+ $parentid = $db->getOne( $sql->query );
+
+ // Ordner ist bereits h?chster Ordner
+ if ( !is_numeric($parentid))
+ {
+ // Falls Anzeige h?chster oder aktueller Ordner
+ if ( $with_root && $with_self )
+ {
+ if ( $this->filenames )
+ $this->parentfolders[ $this->folderid ] = $this->filename;
+ else $this->parentfolders[ $this->folderid ] = $this->name;
+ }
+
+ return $this->parentfolders;
+ }
+
+ // Aktuellen Ordner hinzuf?gen
+ if ( $with_self )
+ {
+ if ( $this->filenames )
+ $this->parentfolders[ $this->folderid ] = $this->filename;
+ else $this->parentfolders[ $this->folderid ] = $this->name;
+ }
+
+ // Schleife ?ber alle ?bergeordneten Ordner
+ while( is_numeric($parentid) )
+ {
+ $sql = new Sql('SELECT * FROM {t_folder} WHERE id={folderid}');
+ $sql->setInt('folderid',$parentid);
+
+ $row_folder = $db->getRow( $sql->query );
+
+ if (is_numeric($row_folder['parentid']) || $with_root)
+ {
+ if ( $this->filenames )
+ $this->parentfolders[ $parentid ] = $row_folder['filename'];
+ else $this->parentfolders[ $parentid ] = $row_folder['name'];
+ }
+
+ $parentid = $row_folder['parentid'];
+ }
+
+
+ // Reihenfolge umdrehen
+ $this->parentfolders = array_reverse($this->parentfolders,true);
+
+ return $this->parentfolders;
+ }
+
+
+ // Ermitteln aller ?bergeordneten Ordner
+ //
+ function parentObjectIds( $with_root = false, $with_self = false )
+ {
+ $db = db_connection();
+ $this->parentfolders = array();
+
+ // ?bergeordneten Ordner lesen
+ $sql = new Sql('SELECT parentid FROM {t_object} WHERE id={objectid}');
+
+ $sql->setInt('objectid',$this->objectid);
+ $parentid = $db->getOne( $sql->query );
+
+ // Ordner ist bereits h?chster Ordner
+ if ( !is_numeric($parentid))
+ {
+ // Falls Anzeige h?chster oder aktueller Ordner
+ if ( $with_root && $with_self )
+ {
+ $this->parentfolders[] = $this->objectid;
+ }
+
+ return $this->parentfolders;
+ }
+
+ // Aktuellen Ordner hinzuf?gen
+ if ( $with_self )
+ {
+ $this->parentfolders[] = $this->objectid;
+ }
+
+ // Schleife ?ber alle ?bergeordneten Ordner
+ while( is_numeric($parentid) )
+ {
+ $sql = new Sql('SELECT parentid FROM {t_object} WHERE id={objectid}');
+ $sql->setInt('objectid',$parentid);
+
+ $row_folder = $db->getRow( $sql->query );
+
+ if (is_numeric($row_folder['parentid']) || $with_root)
+ {
+ $this->parentfolders[] = $parentid;
+ }
+
+ $parentid = $row_folder['parentid'];
+ }
+
+
+ // Reihenfolge umdrehen
+ $this->parentfolders = array_reverse($this->parentfolders,true);
+
+ return $this->parentfolders;
+ }
+
+
+ function parentObjectFileNames( $with_root = false, $with_self = false )
+ {
+ $erg = array();
+
+ foreach( $this->parentObjectIds( $with_root,$with_self ) as $oid )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $erg[$oid] = $f->filename;
+ }
+
+ return $erg;
+ }
+
+ function parentObjectNames( $with_root = false, $with_self = false )
+ {
+ $erg = array();
+
+ foreach( $this->parentObjectIds( $with_root,$with_self ) as $oid )
+ {
+ $f = new Folder( $oid );
+ $f->load();
+ $erg[$oid] = $f->name;
+ }
+ return $erg;
+ }
+
+
+ // Ermitteln aller Unterordner
+ //
+ function subfolder()
+ {
+ $db = db_connection();
+
+ $sql = new Sql('SELECT id FROM {t_object} '.
+ ' WHERE parentid={objectid} AND is_folder=1'.
+ ' ORDER BY orderid ASC' );
+ $sql->setInt( 'objectid' ,$this->objectid );
+
+ $this->subfolders = $db->getCol( $sql->query );
+
+ return $this->subfolders;
+ }
+
+
+ // Ermitteln aller Unterordner (rekursives Absteigen)
+ //
+ function getAllSubFolderIds()
+ {
+ global $SESS;
+
+ $ids = array();
+
+ foreach( $this->getSubFolderIds() as $id )
+ {
+// echo "durchlaufe $id";
+ $ids[] = $id;
+
+ $f = new Folder( $id );
+ $f->projectid = $this->projectid;
+
+ foreach( $f->getAllSubFolderIds() as $xid )
+ {
+ $ids[] = $xid;
+ }
+ }
+
+// print_r( $ids );
+ return $ids;
+ }
+
+
+ /**
+ * Loeschen dieses Ordners.
+ * Der Ordner wird nur geloescht, wenn er keine Unterelemente mehr enth?lt.
+ * Zum Loeschen inklusive Unterelemente dient die Methode deleteAll()
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Nur loeschen, wenn es keine Unterelemente gibt
+ if ( count( $this->getObjectIds() ) == 0 )
+ {
+ $sql = new Sql( 'UPDATE {t_element} '.
+ ' SET folderobjectid=NULL '.
+ ' WHERE folderobjectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+ $sql = new Sql( 'DELETE FROM {t_folder} '.
+ ' WHERE objectid={objectid}' );
+ $sql->setInt('objectid',$this->objectid);
+ $db->query( $sql->query );
+
+ $this->objectDelete();
+ }
+ }
+
+
+ /**
+ * Rekursives loeschen aller Inhalte
+ *
+ * Loeschen aller Inhalte dieses Ordners
+ * inclusive aller Unterelemente
+ */
+ function deleteAll()
+ {
+ $db = db_connection();
+
+ // L?schen aller Unterordner
+ foreach( $this->subfolder() as $folderid )
+ {
+ $folder = new Folder( $folderid );
+ {
+ $folder->deleteAll();
+ }
+ }
+
+ // L?schen aller Seiten,Verknuepfungen und Dateien in
+ // diesem Ordner
+ foreach( $this->getObjectIds() as $oid )
+ {
+ $object = new Object( $oid );
+ {
+ $object->load();
+
+ if ( $object->isPage )
+ {
+ $page = new Page( $oid );
+ $page->load();
+ $page->delete();
+ }
+
+ if ( $object->isLink )
+ {
+ $link = new Link( $oid );
+ $link->load();
+ $link->delete();
+ }
+
+ if ( $object->isFile )
+ {
+ $file = new File( $oid );
+ $file->load();
+ $file->delete();
+ }
+ }
+ }
+
+ // Zum Abschluss den aktuellen Ordner loeschen
+ $this->delete();
+ }
+
+
+ function getSubFolderIds()
+ {
+ return $this->subfolder();
+ }
+}
+
+
?>
\ No newline at end of file
diff --git a/objectClasses/Language.class.php b/objectClasses/Language.class.php
@@ -1,241 +1,244 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002-2004 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.
-// ---------------------------------------------------------------------------
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002-2004 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.
+// ---------------------------------------------------------------------------
// $Log$
-// Revision 1.2 2004-05-02 14:41:31 dankert
-// Einfügen package-name (@package)
-//
-// ---------------------------------------------------------------------------
-
-
-/**
- * Darstellen einer Sprache. Jeder Seiteninhalt wird einer Sprache zugeordnet.
- *
- * @version $Revision$
- * @author $Author$
- * @package openrat.objects
- */
-class Language
-{
- var $languageid = 0;
- var $error = '';
- var $projectid;
-
- var $name = '';
- var $isoCode = '';
- var $isDefault = false;
-
-
- // Konstruktor
- function Language( $languageid='' )
- {
- global $SESS;
-
- if ( is_numeric($languageid) )
- $this->languageid = $languageid;
-
- $this->projectid = $SESS['projectid'];
- }
-
-
- // Lesen aller Sprachen aus der Datenbank
- function getAll()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql( "SELECT id,name FROM {t_language} ".
- " WHERE projectid = {projectid} ".
- " ORDER BY name" );
-
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return $db->getAssoc( $sql->query );
- }
-
-
- // Lesen aus der Datenbank
- function load()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT * FROM {t_language}'.
- ' WHERE id={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
-
- $row = $db->getRow( $sql->query );
-
- $this->name = $row['name'];
- $this->isoCode = $row['isocode'];
- if ( $row['is_default'] == '1' )
- $this->isDefault = true;
- else $this->isDefault = false;
- }
-
-
- // Speichern der Sprache in der Datenbank
- function save()
- {
- $db = db_connection();
-
- // Gruppe speichern
- $sql = new Sql( 'UPDATE {t_language} '.
- 'SET name = {name}, '.
- ' isocode = {isocode} '.
- 'WHERE id={languageid}' );
- $sql->setString( 'name' ,$this->name );
- $sql->setString( 'isocode' ,$this->isoCode );
-
- $sql->setInt( 'languageid',$this->languageid );
-
- // Datenbankabfrage ausfuehren
- $db->query( $sql->query );
- }
-
-
- /**
- * Ermitteln aller Eigenschaften dieser Sprache
- * @return Array
- */
- function getProperties()
- {
- return Array( 'name' =>$this->name,
- 'isocode'=>$this->isoCode );
- }
-
-
- /**
- * Neue Sprache hinzufügen
- */
- function add( $isocode='' )
- {
- global $SESS;
- global $iso;
- $db = db_connection();
-
- if ( $isocode != '' )
- {
- // Kleiner Trick, damit "no" (Norwegen) in der .ini-Datei stehen kann
- $isocode = str_replace('_','',$isocode);
-
- $this->isocode = $isocode;
- $codes = GlobalFunctions::getIsoCodes();
- $this->name = $codes[ $isocode ];
- }
-
- $sql = new Sql('SELECT MAX(id) FROM {t_language}');
- $this->languageid = intval($db->getOne($sql->query))+1;
-
- // Sprache hinzufügen
- $sql = new Sql( 'INSERT INTO {t_language} '.
- '(id,projectid,name,isocode,is_default) VALUES( {languageid},{projectid},{name},{isocode},0 )');
- $sql->setInt ('languageid',$this->languageid );
- $sql->setInt ('projectid' ,$this->projectid );
- $sql->setString('name' ,$this->name );
- $sql->setString('isocode' ,$this->isoCode );
-
- // Datenbankbefehl ausfuehren
- $db->query( $sql->query );
- }
-
-
- // Diese Sprache als 'default' markieren.
- function setDefault()
- {
- global $SESS;
- $db = db_connection();
-
- // Zuerst alle auf nicht-Standard setzen
- $sql = new Sql( 'UPDATE {t_language} '.
- ' SET is_default = 0 '.
- ' WHERE projectid={projectid}' );
- $sql->setInt('projectid',$SESS['projectid'] );
- $db->query( $sql->query );
-
- // Jetzt die gewünschte Sprachvariante auf Standard setzen
- $sql = new Sql( 'UPDATE {t_language} '.
- ' SET is_default = 1 '.
- ' WHERE id={languageid}' );
- $sql->setInt('languageid',$this->languageid );
- $db->query( $sql->query );
- }
-
-
- function getDefaultId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql( 'SELECT id FROM {t_language} '.
- ' WHERE projectid={projectid}'.
- ' ORDER BY is_default DESC' );
-
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return $db->getOne( $sql->query );
- }
-
-
- // Sprache entfernen
- function delete()
- {
- $db = db_connection();
-
- // Sprache löschen
-// $sql = new Sql( 'SELECT COUNT(*) FROM {t_language} WHERE projectid={projectid}' );
-// $sql->setInt( 'projectid',$this->projectid );
-// $count = $db->getOne( $sql->query );
-//
-// // Nur löschen, wenn es mindestens 2 Sprachen gibt
-// if ( $count >= 2 )
-// {
- // Inhalte mit dieser Sprache löschen
- $sql = new Sql( 'DELETE FROM {t_value} WHERE languageid={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
- $db->query( $sql->query );
-
- // Inhalte mit dieser Sprache löschen
- $sql = new Sql( 'DELETE FROM {t_name} WHERE languageid={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
- $db->query( $sql->query );
-
- // Sprache löschen
- $sql = new Sql( 'DELETE FROM {t_language} WHERE id={languageid}' );
- $sql->setInt( 'languageid',$this->languageid );
- $db->query( $sql->query );
-
- // Andere Sprache auf "Default" setzen
- $sql = new Sql( 'SELECT id FROM {t_language} WHERE projectid={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
- $new_default_languageid = $db->getOne( $sql->query );
-
- $sql = new Sql( 'UPDATE {t_language} SET is_default=1 WHERE id={languageid}' );
- $sql->setInt( 'languageid',$new_default_languageid );
- $db->query( $sql->query );
-// }
- }
-}
-
+// Revision 1.3 2004-11-10 22:46:18 dankert
+// *** empty log message ***
+//
+// Revision 1.2 2004/05/02 14:41:31 dankert
+// Einf?gen package-name (@package)
+//
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Darstellen einer Sprache. Jeder Seiteninhalt wird einer Sprache zugeordnet.
+ *
+ * @version $Revision$
+ * @author $Author$
+ * @package openrat.objects
+ */
+class Language
+{
+ var $languageid = 0;
+ var $error = '';
+ var $projectid;
+
+ var $name = '';
+ var $isoCode = '';
+ var $isDefault = false;
+
+
+ // Konstruktor
+ function Language( $languageid='' )
+ {
+ global $SESS;
+
+ if ( is_numeric($languageid) )
+ $this->languageid = $languageid;
+
+ $this->projectid = $SESS['projectid'];
+ }
+
+
+ // Lesen aller Sprachen aus der Datenbank
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( "SELECT id,name FROM {t_language} ".
+ " WHERE projectid = {projectid} ".
+ " ORDER BY name" );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ // Lesen aus der Datenbank
+ function load()
+ {
+ $db = Session::getDatabase();
+
+ $sql = new Sql( 'SELECT * FROM {t_language}'.
+ ' WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name' ];
+ $this->isoCode = $row['isocode' ];
+ $this->projectid = intval( $row['projectid'] );
+
+ $this->isDefault = ( $row['is_default'] == '1' );
+ }
+
+
+ // Speichern der Sprache in der Datenbank
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = new Sql( 'UPDATE {t_language} '.
+ 'SET name = {name}, '.
+ ' isocode = {isocode} '.
+ 'WHERE id={languageid}' );
+ $sql->setString( 'name' ,$this->name );
+ $sql->setString( 'isocode' ,$this->isoCode );
+
+ $sql->setInt( 'languageid',$this->languageid );
+
+ // Datenbankabfrage ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Ermitteln aller Eigenschaften dieser Sprache
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'name' =>$this->name,
+ 'isocode'=>$this->isoCode );
+ }
+
+
+ /**
+ * Neue Sprache hinzuf?gen
+ */
+ function add( $isocode='' )
+ {
+ global $SESS;
+ global $iso;
+ $db = db_connection();
+
+ if ( $isocode != '' )
+ {
+ // Kleiner Trick, damit "no" (Norwegen) in der .ini-Datei stehen kann
+ $isocode = str_replace('_','',$isocode);
+
+ $this->isocode = $isocode;
+ $codes = GlobalFunctions::getIsoCodes();
+ $this->name = $codes[ $isocode ];
+ }
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_language}');
+ $this->languageid = intval($db->getOne($sql->query))+1;
+
+ // Sprache hinzuf?gen
+ $sql = new Sql( 'INSERT INTO {t_language} '.
+ '(id,projectid,name,isocode,is_default) VALUES( {languageid},{projectid},{name},{isocode},0 )');
+ $sql->setInt ('languageid',$this->languageid );
+ $sql->setInt ('projectid' ,$this->projectid );
+ $sql->setString('name' ,$this->name );
+ $sql->setString('isocode' ,$this->isoCode );
+
+ // Datenbankbefehl ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ // Diese Sprache als 'default' markieren.
+ function setDefault()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Zuerst alle auf nicht-Standard setzen
+ $sql = new Sql( 'UPDATE {t_language} '.
+ ' SET is_default = 0 '.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$SESS['projectid'] );
+ $db->query( $sql->query );
+
+ // Jetzt die gew?nschte Sprachvariante auf Standard setzen
+ $sql = new Sql( 'UPDATE {t_language} '.
+ ' SET is_default = 1 '.
+ ' WHERE id={languageid}' );
+ $sql->setInt('languageid',$this->languageid );
+ $db->query( $sql->query );
+ }
+
+
+ function getDefaultId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_language} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getOne( $sql->query );
+ }
+
+
+ // Sprache entfernen
+ function delete()
+ {
+ $db = db_connection();
+
+ // Sprache l?schen
+// $sql = new Sql( 'SELECT COUNT(*) FROM {t_language} WHERE projectid={projectid}' );
+// $sql->setInt( 'projectid',$this->projectid );
+// $count = $db->getOne( $sql->query );
+//
+// // Nur l?schen, wenn es mindestens 2 Sprachen gibt
+// if ( $count >= 2 )
+// {
+ // Inhalte mit dieser Sprache l?schen
+ $sql = new Sql( 'DELETE FROM {t_value} WHERE languageid={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $db->query( $sql->query );
+
+ // Inhalte mit dieser Sprache l?schen
+ $sql = new Sql( 'DELETE FROM {t_name} WHERE languageid={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $db->query( $sql->query );
+
+ // Sprache l?schen
+ $sql = new Sql( 'DELETE FROM {t_language} WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$this->languageid );
+ $db->query( $sql->query );
+
+ // Andere Sprache auf "Default" setzen
+ $sql = new Sql( 'SELECT id FROM {t_language} WHERE projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $new_default_languageid = $db->getOne( $sql->query );
+
+ $sql = new Sql( 'UPDATE {t_language} SET is_default=1 WHERE id={languageid}' );
+ $sql->setInt( 'languageid',$new_default_languageid );
+ $db->query( $sql->query );
+// }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/objectClasses/Model.class.php b/objectClasses/Model.class.php
@@ -1,229 +1,229 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// OpenRat Content Management System
-// Copyright (C) 2002-2004 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.
-// ---------------------------------------------------------------------------
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002-2004 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.
+// ---------------------------------------------------------------------------
// $Log$
-// Revision 1.2 2004-04-25 12:58:24 dankert
-// Spalte "selflink" entfernt
-//
-// ---------------------------------------------------------------------------
-
-/**
- * Diese Klasse stellt ein Projektmodell dar. Ein Projektmodell ist eine Darstellungsart
- * der Inhalte. Zu jedem Projektmodell gibt es einen anderen Templatequelltext.
- * Beispiel: Neben HTML gibt es ein Projektmodell fuer WML oder XML. Die Inhalte sind gleich,
- * aber die Art der Ausgabe ist jeweils anders.
- *
- * @package openrat.objects
- * @author $Author$
- * @version $Rev: $
- */
-class Model
-{
- var $modelid = 0;
- var $error = '';
- var $projectid;
-
- var $name = '';
- var $isDefault = false;
-
-
- /**
- * Konstruktor
- */
- function Model( $modelid='' )
- {
- global $SESS;
-
- if ( is_numeric($modelid) )
- $this->modelid = $modelid;
-
- $this->projectid = $SESS['projectid'];
- }
-
-
- /**
- * Lesen aller Projektmodelle aus der Datenbank
- */
- function getAll()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql( "SELECT id,name FROM {t_model} ".
- " WHERE projectid = {projectid} ".
- " ORDER BY name" );
-
- if ( isset($this) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return $db->getAssoc( $sql->query );
- }
-
-
- /**
- * Lesen aus der Datenbank
- */
- function load()
- {
- $db = db_connection();
-
- $sql = new Sql( 'SELECT * FROM {t_model}'.
- ' WHERE id={modelid}' );
- $sql->setInt( 'modelid',$this->modelid );
-
- $row = $db->getRow( $sql->query );
-
- $this->name = $row['name'];
-
- if ( $row['is_default'] == '1' )
- $this->isDefault = true;
- else $this->isDefault = false;
- }
-
-
- /**
- * Speichern des Projektmodells
- */
- function save()
- {
- $db = db_connection();
-
- // Gruppe speichern
- $sql = new Sql( 'UPDATE {t_model} '.
- ' SET name = {name} '.
- ' WHERE id={modelid}' );
- $sql->setString( 'name' ,$this->name );
-
- $sql->setInt( 'modelid',$this->modelid );
-
- // Datenbankabfrage ausfuehren
- $db->query( $sql->query );
- }
-
-
- /**
- * Alle notwendigen Eigenschaften dieses Projektmodells
- * werden als Array zurueckgegeben
- *
- * @return Array
- */
- function getProperties()
- {
- return Array( 'modelid' =>$this->modelid,
- 'projectid'=>$this->projectid,
- 'isDefault'=>$this->isDefault,
- 'name' =>$this->name );
- }
-
-
- /**
- * Modell hinzufuegen
- * @param String Name des Modells (optional)
- */
- function add( $name = '' )
- {
- if ( $name != '' )
- $this->name = $name;
-
- $db = db_connection();
-
- $sql = new Sql('SELECT MAX(id) FROM {t_model}');
- $this->modelid = intval($db->getOne($sql->query))+1;
-
- // Modell hinzufügen
- $sql = new Sql( 'INSERT INTO {t_model} '.
- "(id,projectid,name,extension,is_default) VALUES( {modelid},{projectid},{name},'',0 )");
-
- $sql->setInt ('modelid' ,$this->modelid );
- $sql->setInt ('projectid',$this->projectid );
- $sql->setString('name' ,$this->name );
-
- // Datenbankbefehl ausfuehren
- $db->query( $sql->query );
- }
-
-
- function getDefaultId()
- {
- global $SESS;
- $db = db_connection();
-
- $sql = new Sql( 'SELECT id FROM {t_model} '.
- ' WHERE projectid={projectid}'.
- ' ORDER BY is_default DESC' );
- if ( isset($this->projectid) )
- $sql->setInt('projectid',$this->projectid );
- else $sql->setInt('projectid',$SESS['projectid'] );
-
- return $db->getOne( $sql->query );
- }
-
-
-
- // Diese Sprache als 'default' markieren.
- function setDefault()
- {
- global $SESS;
- $db = db_connection();
-
- // Zuerst alle auf nicht-Standard setzen
- $sql = new Sql( 'UPDATE {t_model} '.
- ' SET is_default = 0 '.
- ' WHERE projectid={projectid}' );
- $sql->setInt('projectid',$this->projectid );
- $db->query( $sql->query );
-
- // Jetzt die gewünschte Sprachvariante auf Standard setzen
- $sql = new Sql( 'UPDATE {t_model} '.
- ' SET is_default = 1 '.
- ' WHERE id={modelid}' );
- $sql->setInt('modelid',$this->modelid );
- $db->query( $sql->query );
- }
-
-
- /**
- * Entfernen des Projektmodells aus der Datenbank
- * Es wird dabei nicht geprueft, ob noch ein anders Projektmodell
- * vorhanden ist.
- */
- function delete()
- {
- $db = db_connection();
-
- // Modell löschen
- $sql = new Sql( 'DELETE FROM {t_model} WHERE id={modelid}' );
- $sql->setInt( 'modelid',$this->modelid );
- $db->query( $sql->query );
-
- // Anderes Modell auf "Default" setzen (sofern vorhanden)
- $sql = new Sql( 'SELECT id FROM {t_model} WHERE projectid={projectid}' );
- $sql->setInt( 'projectid',$this->projectid );
- $new_default_modelid = $db->getOne( $sql->query );
-
- $sql = new Sql( 'UPDATE {t_model} SET is_default=1 WHERE id={modelid}' );
- $sql->setInt( 'modelid',$new_default_modelid );
- $db->query( $sql->query );
- }
-}
-
+// Revision 1.3 2004-11-10 22:46:27 dankert
+// *** empty log message ***
+//
+// Revision 1.2 2004/04/25 12:58:24 dankert
+// Spalte "selflink" entfernt
+//
+// ---------------------------------------------------------------------------
+
+/**
+ * Diese Klasse stellt ein Projektmodell dar. Ein Projektmodell ist eine Darstellungsart
+ * der Inhalte. Zu jedem Projektmodell gibt es einen anderen Templatequelltext.
+ * Beispiel: Neben HTML gibt es ein Projektmodell fuer WML oder XML. Die Inhalte sind gleich,
+ * aber die Art der Ausgabe ist jeweils anders.
+ *
+ * @package openrat.objects
+ * @author $Author$
+ * @version $Rev: $
+ */
+class Model
+{
+ var $modelid = 0;
+ var $error = '';
+ var $projectid;
+
+ var $name = '';
+ var $isDefault = false;
+
+
+ /**
+ * Konstruktor
+ */
+ function Model( $modelid='' )
+ {
+ if ( is_numeric($modelid) )
+ $this->modelid = $modelid;
+ }
+
+
+ /**
+ * Lesen aller Projektmodelle aus der Datenbank
+ */
+ function getAll()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( "SELECT id,name FROM {t_model} ".
+ " WHERE projectid = {projectid} ".
+ " ORDER BY name" );
+
+ if ( isset($this) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getAssoc( $sql->query );
+ }
+
+
+ /**
+ * Lesen aus der Datenbank
+ */
+ function load()
+ {
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT * FROM {t_model}'.
+ ' WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$this->modelid );
+
+ $row = $db->getRow( $sql->query );
+
+ $this->name = $row['name' ];
+ $this->projectid = $row['projectid'];
+
+ if ( $row['is_default'] == '1' )
+ $this->isDefault = true;
+ else $this->isDefault = false;
+ }
+
+
+ /**
+ * Speichern des Projektmodells
+ */
+ function save()
+ {
+ $db = db_connection();
+
+ // Gruppe speichern
+ $sql = new Sql( 'UPDATE {t_model} '.
+ ' SET name = {name} '.
+ ' WHERE id={modelid}' );
+ $sql->setString( 'name' ,$this->name );
+
+ $sql->setInt( 'modelid',$this->modelid );
+
+ // Datenbankabfrage ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Alle notwendigen Eigenschaften dieses Projektmodells
+ * werden als Array zurueckgegeben
+ *
+ * @return Array
+ */
+ function getProperties()
+ {
+ return Array( 'modelid' =>$this->modelid,
+ 'projectid'=>$this->projectid,
+ 'isDefault'=>$this->isDefault,
+ 'name' =>$this->name );
+ }
+
+
+ /**
+ * Modell hinzufuegen
+ * @param String Name des Modells (optional)
+ */
+ function add( $name = '' )
+ {
+ if ( $name != '' )
+ $this->name = $name;
+
+ $db = db_connection();
+
+ $sql = new Sql('SELECT MAX(id) FROM {t_model}');
+ $this->modelid = intval($db->getOne($sql->query))+1;
+
+ // Modell hinzuf?gen
+ $sql = new Sql( 'INSERT INTO {t_model} '.
+ "(id,projectid,name,extension,is_default) VALUES( {modelid},{projectid},{name},'',0 )");
+
+ $sql->setInt ('modelid' ,$this->modelid );
+ $sql->setInt ('projectid',$this->projectid );
+ $sql->setString('name' ,$this->name );
+
+ // Datenbankbefehl ausfuehren
+ $db->query( $sql->query );
+ }
+
+
+ function getDefaultId()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ $sql = new Sql( 'SELECT id FROM {t_model} '.
+ ' WHERE projectid={projectid}'.
+ ' ORDER BY is_default DESC' );
+ if ( isset($this->projectid) )
+ $sql->setInt('projectid',$this->projectid );
+ else $sql->setInt('projectid',$SESS['projectid'] );
+
+ return $db->getOne( $sql->query );
+ }
+
+
+
+ // Diese Sprache als 'default' markieren.
+ function setDefault()
+ {
+ global $SESS;
+ $db = db_connection();
+
+ // Zuerst alle auf nicht-Standard setzen
+ $sql = new Sql( 'UPDATE {t_model} '.
+ ' SET is_default = 0 '.
+ ' WHERE projectid={projectid}' );
+ $sql->setInt('projectid',$this->projectid );
+ $db->query( $sql->query );
+
+ // Jetzt die gew?nschte Sprachvariante auf Standard setzen
+ $sql = new Sql( 'UPDATE {t_model} '.
+ ' SET is_default = 1 '.
+ ' WHERE id={modelid}' );
+ $sql->setInt('modelid',$this->modelid );
+ $db->query( $sql->query );
+ }
+
+
+ /**
+ * Entfernen des Projektmodells aus der Datenbank
+ * Es wird dabei nicht geprueft, ob noch ein anders Projektmodell
+ * vorhanden ist.
+ */
+ function delete()
+ {
+ $db = db_connection();
+
+ // Modell l?schen
+ $sql = new Sql( 'DELETE FROM {t_model} WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$this->modelid );
+ $db->query( $sql->query );
+
+ // Anderes Modell auf "Default" setzen (sofern vorhanden)
+ $sql = new Sql( 'SELECT id FROM {t_model} WHERE projectid={projectid}' );
+ $sql->setInt( 'projectid',$this->projectid );
+ $new_default_modelid = $db->getOne( $sql->query );
+
+ $sql = new Sql( 'UPDATE {t_model} SET is_default=1 WHERE id={modelid}' );
+ $sql->setInt( 'modelid',$new_default_modelid );
+ $db->query( $sql->query );
+ }
+}
+
?>
\ No newline at end of file