Row.php

00001 <?php
00009 class Dsao_Db_Table_GameText_Row extends Zend_Db_Table_Row_Abstract
00010 {
00014   protected $_isEncoded = false;
00015 
00021   protected function _encode()
00022   {
00023     // Falls Zeile weder de-, noch kodiert ist
00024     if (!$this->_isEncoded)
00025     {
00026       // Falls Inhalt geaendert wurde
00027       if (!$this->_cleanData
00028           || ($this->_data['content'] != $this->_cleanData['content']))
00029       {
00030         $content = $this->_data['content'];
00031 
00032         // Ggf. Slashes entfernen
00033         if (get_magic_quotes_gpc())
00034         {
00035           $content = stripslashes($content);
00036         }
00037 
00038         $filter = new Zend_Filter_StringTrim();
00039 
00040         // Ueberfluessige Leerzeichen entfernen
00041         $content = $filter->filter($content);
00042 
00043         $this->content = $content;
00044       }
00045     }
00046 
00047     $this->_isEncoded = true;
00048   }
00049 
00055   public function delete()
00056   {
00057     // Falls die Zeile noch nicht in Datenbank ist, abbrechen
00058     if (!$this->_cleanData)
00059     {
00060       return false;
00061     }
00062 
00063     // Inhalt loeschen
00064     $this->content = null;
00065     $this->timeLastEdited = new Zend_Db_Expr('NOW()');
00066 
00067     // Falls Autor nicht mit dem editierenden Benutzer uebereinstimmt
00068     if (Dsao_Registry::get('user')->username
00069         != $this->_data['author'])
00070     {
00071       $this->lastEditedBy = Dsao_Registry::get('user')->username;
00072     }
00073 
00074     parent::save();
00075   }
00076 
00086   public function save($username = 'System')
00087   {
00088     // Falls Objekt übergeben wurde
00089     if (is_object($username) && $username instanceof Dsao_User)
00090     {
00091       $username = $username->username;
00092     }
00093 
00094     // Kodieren
00095     $this->_encode();
00096 
00097     // Falls Zeile editiert wurde, Zeit der letzten Editierung und Autor setzen
00098     if ($this->_cleanData)
00099     {
00100       $this->lastEditedBy = $username;
00101       $this->timeLastEdited = new Zend_Db_Expr('NOW()');
00102     }
00103 
00104     return parent::save();
00105   }
00106 
00112   public function toArrayDecoded()
00113   {
00114     $rowArray = $this->toArray();
00115 
00116     // Zeit formatieren
00117 
00118     // Zeit der Erstellung formatieren
00119     $timeCreation = new Dsao_Time($this->_data['timeCreated']);
00120     $rowArray['timeCreated'] = $timeCreation->format();
00121 
00122     // Falls Text editiert wurde
00123     if (isset($this->_data['timeLastEdited'])
00124         && null != $this->_data['timeLastEdited'])
00125     {
00126       $timeLastEdited = new Dsao_Time($this->_data['timeLastEdited']);
00127       $rowArray['timeLastEdited'] = $timeLastEdited->format();
00128     }
00129     // Ansonsten Zeit der Erstellung nehmen
00130     else
00131     {
00132       $rowArray['timeLastEdited'] = $rowArray['timeCreated'];
00133     }
00134 
00135     // Falls keine Aenderung vorgenommen wurde hat der Autor den Text zuletzt
00136     // bearbeitet
00137     if (!isset($this->_data['lastEditedBy'])
00138         || null == $this->_data['lastEditedBy'])
00139     {
00140       $rowArray['lastEditedBy'] = $this->_data['author'];
00141     }
00142 
00143     $filter = new Dsao_Filter_Texts();
00144 
00145     // Zeilenumbrueche umsetzen
00146     $rowArray['content'] = $filter->filter($this->_data['content']);
00147 
00148     return $rowArray;
00149   }
00150 }

Erzeugt am Fri Sep 18 19:04:11 2009 für DSA online - Morgendaemmerung von  doxygen 1.5.7.1