commit 62cbe18a467b00a4792f96397283e470752ea2e1
parent d41faf68385e538a919ff3c777ab6757b3e8c58d
Author: dankert <devnull@localhost>
Date: Sun, 25 Apr 2004 14:58:24 +0200
Spalte "selflink" entfernt
Diffstat:
1 file changed, 82 insertions(+), 50 deletions(-)
diff --git a/objectClasses/Model.class.php b/objectClasses/Model.class.php
@@ -1,24 +1,40 @@
<?php
-#
-# 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.
-#
-
-
+// ---------------------------------------------------------------------------
+// $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;
@@ -29,7 +45,9 @@ class Model
var $isDefault = false;
- // Konstruktor
+ /**
+ * Konstruktor
+ */
function Model( $modelid='' )
{
global $SESS;
@@ -41,7 +59,9 @@ class Model
}
- // Lesen aller Projektmodelle aus der Datenbank
+ /**
+ * Lesen aller Projektmodelle aus der Datenbank
+ */
function getAll()
{
global $SESS;
@@ -59,7 +79,9 @@ class Model
}
- // Lesen aus der Datenbank
+ /**
+ * Lesen aus der Datenbank
+ */
function load()
{
$db = db_connection();
@@ -70,7 +92,7 @@ class Model
$row = $db->getRow( $sql->query );
- $this->name = $row['name'];
+ $this->name = $row['name'];
if ( $row['is_default'] == '1' )
$this->isDefault = true;
@@ -78,7 +100,9 @@ class Model
}
- // Speichern der Sprache in der Datenbank
+ /**
+ * Speichern des Projektmodells
+ */
function save()
{
$db = db_connection();
@@ -96,13 +120,25 @@ class Model
}
+ /**
+ * Alle notwendigen Eigenschaften dieses Projektmodells
+ * werden als Array zurueckgegeben
+ *
+ * @return Array
+ */
function getProperties()
{
- return Array( 'name'=>$this->name );
+ return Array( 'modelid' =>$this->modelid,
+ 'projectid'=>$this->projectid,
+ 'isDefault'=>$this->isDefault,
+ 'name' =>$this->name );
}
- // Modell hinzufuegen
+ /**
+ * Modell hinzufuegen
+ * @param String Name des Modells (optional)
+ */
function add( $name = '' )
{
if ( $name != '' )
@@ -115,7 +151,7 @@ class Model
// Modell hinzufügen
$sql = new Sql( 'INSERT INTO {t_model} '.
- "(id,projectid,name,extension,selflink,is_default) VALUES( {modelid},{projectid},{name},'',0,0 )");
+ "(id,projectid,name,extension,is_default) VALUES( {modelid},{projectid},{name},'',0 )");
$sql->setInt ('modelid' ,$this->modelid );
$sql->setInt ('projectid',$this->projectid );
@@ -165,32 +201,28 @@ class Model
}
- // Modell entfernen
+ /**
+ * Entfernen des Projektmodells aus der Datenbank
+ * Es wird dabei nicht geprueft, ob noch ein anders Projektmodell
+ * vorhanden ist.
+ */
function delete()
{
$db = db_connection();
-// $sql = new Sql( 'SELECT COUNT(*) FROM {t_model} WHERE projectid={projectid}' );
-// $sql->setInt( 'projectid',$this->projectid );
-// $count = $db->getOne( $sql->query );
-//
-// // Nur löschen, wenn es mindestens 2 Modelle gibt
-// if ( $count >= 2 )
-// {
- // 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
- $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 );
-// }
+ // 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 );
}
}