Page.class.php

gehe zur Dokumentation dieser Datei
00001 <?php
00002 // ---------------------------------------------------------------------------
00003 // $Id$
00004 // ---------------------------------------------------------------------------
00005 // DaCMS Content Management System
00006 // Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 // ---------------------------------------------------------------------------
00022 // $Log$
00023 // Revision 1.32  2009-04-20 23:24:58  dankert
00024 // Korrektur: Veröffentlichen mehrerer Varianten gleichzeitig.
00025 //
00026 // Revision 1.31  2009-04-18 00:56:14  dankert
00027 // Beim Verarbeiten von if-empty-Bereichen der Seitenvorlage keine regulären Ausdrücke mehr verwenden (da Binärausgaben wie PDF-Dokumente dabei beschädigt werden).
00028 //
00029 // Revision 1.30  2009-03-17 01:39:43  dankert
00030 // Funktionsfähigkeit bei enable_cache=false
00031 //
00032 // Revision 1.29  2009-03-17 01:27:29  dankert
00033 // Überarbeitung der temporären Dateinamen.
00034 //
00035 // Revision 1.28  2009-03-02 22:41:45  dankert
00036 // Bugfix in setTimestamp()
00037 //
00038 // Revision 1.27  2008-10-07 20:03:54  dankert
00039 // URLs ggf. mit Parameter "oid" aufbauen, um absolute URL zu erzwingen.
00040 //
00041 // Revision 1.26  2008-09-11 19:01:16  dankert
00042 // Korrektur fuer Veroeffentlichen (nur deaktiveren, wenn keine Dateiendung vorliegt.)
00043 //
00044 // Revision 1.25  2007-12-11 00:22:31  dankert
00045 // Cache von Dateien und Seiten zur Performancesteigerung beim Ver?ffentlichen.
00046 //
00047 // Revision 1.24  2007-11-24 14:18:12  dankert
00048 // MimeType in Template ermitteln.
00049 //
00050 // Revision 1.23  2007-11-24 12:16:32  dankert
00051 // Neue Methode mimeType()
00052 //
00053 // Revision 1.22  2007-11-07 23:29:05  dankert
00054 // Wenn Seite direkt aufgerufen wird, dann sofort Seitenelement anzeigen.
00055 //
00056 // Revision 1.21  2007-06-13 22:01:22  dankert
00057 // Korrektur: Dateiname Icon zum Bearbeiten.
00058 //
00059 // Revision 1.20  2007-04-22 00:16:44  dankert
00060 // Fehlermeldung vermeiden, wenn eine Objekt-Id nicht in der Datenbank vorhanden ist.
00061 //
00062 // Revision 1.19  2005/11/07 22:36:10  dankert
00063 // Beruecksichtigen von absoluten Pfadangaben
00064 //
00065 // Revision 1.18  2004/12/29 20:21:42  dankert
00066 // Korrektur Bearbeiten-Funktion, Parameter zu Html::url()
00067 //
00068 // Revision 1.17  2004/12/28 22:55:51  dankert
00069 // Korrektur Dateinamen-Ermittlung
00070 //
00071 // Revision 1.16  2004/12/26 01:06:31  dankert
00072 // Perfomanceverbesserung Seite/Elemente
00073 //
00074 // Revision 1.15  2004/12/25 21:05:29  dankert
00075 // Korrektur Edit-Icons
00076 //
00077 // Revision 1.14  2004/12/19 21:48:31  dankert
00078 // Links auf andere Objekte korrigiert
00079 //
00080 // Revision 1.13  2004/12/19 15:23:06  dankert
00081 // Aussschalten content-negotiation
00082 //
00083 // Revision 1.12  2004/12/15 23:17:53  dankert
00084 // temporaere Dateien vom System
00085 //
00086 // Revision 1.11  2004/11/29 23:24:36  dankert
00087 // Korrektur Veroeffentlichung
00088 //
00089 // Revision 1.10  2004/11/10 22:47:17  dankert
00090 // Methode copyValuesFromPage() zum Kopiern einer Seite
00091 //
00092 // Revision 1.9  2004/10/14 21:10:57  dankert
00093 // neue Methode getElementIds()
00094 //
00095 // Revision 1.8  2004/10/05 10:01:56  dankert
00096 // Austauschen einer Vorlage
00097 //
00098 // Revision 1.7  2004/07/09 20:57:14  dankert
00099 // Dynamische Bereiche (IFEMPTY...)
00100 //
00101 // Revision 1.6  2004/07/07 20:47:22  dankert
00102 // Korrektur f. Verkn?pfungen
00103 //
00104 // Revision 1.5  2004/05/07 21:41:14  dankert
00105 // Url ?ber Html::url erzeugen
00106 //
00107 // Revision 1.4  2004/05/02 14:41:31  dankert
00108 // Einf?gen package-name (@package)
00109 //
00110 // Revision 1.3  2004/05/02 11:40:00  dankert
00111 // Freigabestatus der Seiteninhalte verarbeiten
00112 //
00113 // Revision 1.2  2004/04/24 15:28:17  dankert
00114 // Korrektur: relative Pfad bei Listen
00115 //
00116 // Revision 1.1  2004/04/24 15:15:12  dankert
00117 // Initiale Version
00118 //
00119 // Revision 1.1  2004/03/20 14:15:00  dankert
00120 // Kommentare
00121 //
00122 // ---------------------------------------------------------------------------
00123 
00124 
00133 class Page extends Object
00134 {
00135      var $pageid;
00136      var $templateid;
00137      var $template;
00138 
00139      var $simple = false;
00140      var $public = false;
00141 
00142      var $el = array();
00143 
00144      var $icons = false;
00145      var $src   = '';
00146      var $edit  = false;
00147 
00148      var $content_negotiation = false;
00149      var $cut_index           = false;
00150      var $default_language    = false;
00151      var $withLanguage        = false;
00152      var $link                = false;
00153      var $fullFilename = '';
00154 
00155      var $log_filenames       = array();
00156      var $modelid = 0;
00157      
00158      var $publish = null;
00159      var $up_path = '';
00160 
00161 
00162      function Page( $objectid='' )
00163      {
00164           $this->Object( $objectid );
00165           $this->isPage = true;
00166      }
00167 
00168 
00175      function getObjectIdFromPageId( $pageid )
00176      {
00177           $db = db_connection();
00178 
00179           $sql  = new Sql( 'SELECT objectid FROM {t_page} '.
00180                            '  WHERE id={pageid}' );
00181           $sql->setInt('pageid',$pageid);
00182 
00183           return $db->getOne( $sql->query );
00184      }
00185 
00186 
00193      function getPageIdFromObjectId( $objectid )
00194      {
00195           $db = db_connection();
00196 
00197           $sql  = new Sql( 'SELECT id FROM {t_page} '.
00198                            '  WHERE objectid={objectid}' );
00199           $sql->setInt('objectid',$objectid);
00200 
00201           return $db->getOne( $sql->query );
00202      }
00203 
00204 
00210      function getProperties()
00211      {
00212           return array_merge( parent::getProperties(),
00213                               array('full_filename'=>$this->fullFilename,
00214                                     'pageid'       =>$this->pageid,
00215                                     'templateid'   =>$this->templateid,
00216                                     'mime_type'    =>$this->mimeType() ) );
00217      }
00218 
00219 
00224      function parentfolder()
00225      {
00226           $folder = new Folder();
00227           $folder->folderid = $this->folderid;
00228           
00229           return $folder->parentfolder( false,false );
00230      }
00231 
00232 
00233 /*
00234      function path_to_file( $fileid )
00235      {
00236           global $conf_php;
00237           
00238           if   ( $this->public )
00239           { 
00240                $inhalt = $this->up_path();
00241                
00242                $file = new File();
00243                $file->fileid = $fileid;
00244                $file->load();
00245 
00246                $inhalt .= $file->full_filename();
00247           }
00248           else
00249           {
00250                $inhalt = "file.$conf_php?fileaction=show&fileid=".$fileid;
00251                $inhalt = sid($inhalt);
00252           }
00253           
00254           return $inhalt;
00255      }
00256 */
00257 
00264      function path_to_object( $objectid )
00265      {
00266           global $conf_php,
00267                  $SESS;
00268           $inhalt = '';
00269           
00270           if   ( ! Object::available( $objectid) )
00271                return '';
00272                
00273           $param = array('oid'=>'__OID__'.$objectid.'__'); 
00274                
00275           $object = new Object( $objectid );
00276           $object->objectLoad();
00277           
00278           $cut_index           = ( is_object($this->publish) && $this->publish->cut_index           );
00279           $content_negotiation = ( is_object($this->publish) && $this->publish->content_negotiation );
00280 
00281           if   ( $this->public )
00282           { 
00283                switch( $object->getType() )
00284                {
00285                     case 'file':
00286 
00287                          $inhalt  = $this->up_path();
00288                          
00289                          $f = new File( $objectid );
00290                          $f->load();
00291                          $inhalt .= $f->full_filename();
00292                          break;
00293 
00294                     case 'page':
00295 
00296                          $inhalt  = $this->up_path();
00297                          
00298                          $p = new Page( $objectid );
00299                          $p->languageid          = $this->languageid;
00300                          $p->cut_index           = $cut_index;
00301                          $p->content_negotiation = $content_negotiation;
00302                          $p->withLanguage        = $this->withLanguage;
00303                          $p->load();
00304                          $inhalt .= $p->full_filename();
00305                          break;
00306 
00307                     case 'link':
00308                          $link = new Link( $objectid );
00309                          $link->load();
00310 
00311                          if   ( $link->isLinkToObject )
00312                          {
00313                               $linkedObject = new Object( $link->linkedObjectId );
00314                               $linkedObject->load();
00315 
00316                               switch( $linkedObject->getType() )
00317                               {
00318                                    case 'file':
00319                                         $f = new File( $link->linkedObjectId );
00320                                         $f->load();
00321                                         $inhalt  = $this->up_path();
00322                                         $inhalt .= $f->full_filename();
00323                                    break;
00324                
00325                                    case 'page':
00326                                         $p = new Page( $link->linkedObjectId );
00327                                         $p->languageid          = $this->languageid;
00328                                         $p->cut_index           = $cut_index;
00329                                         $p->content_negotiation = $content_negotiation;
00330                                         $p->load();
00331                                         $inhalt  = $this->up_path();
00332                                         $inhalt .= $p->full_filename();
00333                                    break;
00334                               }
00335                          }
00336                          else
00337                          {
00338                               $inhalt = $link->url;
00339                          }
00340                          break;
00341                }
00342           }
00343           else
00344           {
00345                // Interne Verlinkungen in der Seitenvorschau
00346                switch( $object->getType() )
00347                {
00348                     case 'file':
00349                          $inhalt = Html::url('file','show',$objectid,$param);
00350                          break;
00351 
00352                     case 'page':
00353                          $inhalt = Html::url('page','show',$objectid,$param);
00354                          break;
00355 
00356                     case 'link':
00357                          $link = new Link( $objectid );
00358                          $link->load();
00359 
00360                          if   ( $link->isLinkToObject )
00361                          {
00362                               $linkedObject = new Object( $link->linkedObjectId );
00363                               $linkedObject->load();
00364 
00365                               switch( $linkedObject->getType() )
00366                               {
00367                                    case 'file':
00368                                         $inhalt = Html::url('file','show',$link->linkedObjectId,$param);
00369                                    break;
00370                
00371                                    case 'page':
00372                                         $inhalt = Html::url('page','show',$link->linkedObjectId,$param);
00373                                    break;
00374                               }
00375                          }
00376                          else
00377                          {
00378                               $inhalt = $link->url;
00379                          }
00380                          break;
00381                }
00382           }
00383           
00384           return $inhalt;
00385      }
00386 
00387 
00388 
00396      function up_path()
00397      {
00398           global $conf;
00399 
00400           if   ( $conf['filename']['url'] == 'absolute' )
00401           {
00402                $this->up_path = '/';
00403                return $this->up_path;
00404           }
00405                
00406           if   ( $this->up_path != '' )
00407                return $this->up_path;
00408 
00409           $folder = new Folder( $this->parentid );
00410           $folder->load();
00411           $folder->parentObjectIds(false,true);
00412           $f = count( $folder->parentfolders );
00413           
00414           if   ( $f == 0 )
00415           {
00416                $this->up_path = './';
00417           }
00418           else
00419           {
00420                $this->up_path = str_repeat( '../',$f );
00421           }
00422 
00423           return $this->up_path;
00424      }
00425 
00426 
00430      function add()
00431      {
00432           $db = db_connection();
00433 
00434           $this->objectAdd(); // Hinzuf?gen von Objekt (dabei wird Objekt-ID ermittelt)
00435 
00436           $sql = new Sql('SELECT MAX(id) FROM {t_page}');
00437           $this->pageid = intval($db->getOne($sql->query))+1;
00438 
00439           $sql = new Sql('INSERT INTO {t_page}'.
00440                          ' (id,objectid,templateid)'.
00441                          ' VALUES( {pageid},{objectid},{templateid} )' );
00442           $sql->setInt   ('pageid'    ,$this->pageid     );
00443           $sql->setInt   ('objectid'  ,$this->objectid   );
00444           $sql->setInt   ('templateid',$this->templateid );
00445 
00446           $db->query( $sql->query );
00447      }
00448 
00449 
00453      function load()
00454      {
00455           $db = db_connection();
00456 
00457           $sql  = new Sql( 'SELECT * FROM {t_page} '.
00458                            '  WHERE objectid={objectid}' );
00459           $sql->setInt('objectid',$this->objectid);
00460           $row = $db->getRow( $sql->query );
00461 
00462           $this->pageid      = $row['id'        ];
00463           $this->templateid  = $row['templateid'];
00464 
00465           $this->objectLoad();
00466      }
00467 
00468 
00469      function delete()
00470      {
00471           global $db;
00472 
00473           $sql = new Sql( 'DELETE FROM {t_value} '.
00474                           '  WHERE pageid={pageid}' );
00475           $sql->setInt('pageid',$this->pageid);
00476           $db->query( $sql->query );
00477 
00478           $sql = new Sql( 'DELETE FROM {t_page} '.
00479                           '  WHERE objectid={objectid}' );
00480           $sql->setInt('objectid',$this->objectid);
00481           $db->query( $sql->query );
00482           
00483           $this->objectDelete();
00484      }
00485 
00486 
00491      function copyValuesFromPage( $otherpageid )
00492      {
00493           $this->load();
00494 
00495           foreach( $this->getElementIds() as $elementid )
00496           {
00497                foreach( Language::getAll() as $lid=>$lname )
00498                {
00499                     $val = new Value();
00500                     $val->publish = false;
00501                     $val->element = new Element( $elementid );
00502      
00503                     $val->objectid   = $otherpageid;
00504                     $val->pageid     = Page::getPageIdFromObjectId( $otherpageid );
00505                     $val->languageid = $lid;
00506                     $val->load();
00507 
00508                     // Inhalt nur speichern, wenn vorher vorhanden    
00509                     if   ( $val->valueid != 0 )
00510                     {
00511                          $val->objectid   = $this->objectid;
00512                          $val->pageid     = Page::getPageIdFromObjectId( $this->objectid );
00513                          $val->save();
00514                     }
00515                }
00516           }
00517      }
00518 
00519 
00520 
00521 
00522      function save()
00523      {
00524           $db = db_connection();
00525 
00526           $sql = new Sql('UPDATE {t_page}'.
00527                          '  SET templateid ={templateid}'.
00528                          '  WHERE objectid={objectid}' );
00529           $sql->setInt('templateid' ,$this->templateid);
00530           $sql->setInt('objectid'   ,$this->objectid  );
00531           $db->query( $sql->query );
00532 
00533           $this->objectSave();
00534      }
00535 
00536 
00537      
00538      function replaceTemplate( $newTemplateId,$replaceElementMap )
00539      {
00540           $oldTemplateId = $this->templateid;
00541 
00542           $db = db_connection();
00543 
00544           // Template-id dieser Seite aendern
00545           $this->templateid = $newTemplateId;
00546 
00547           $sql = new Sql('UPDATE {t_page}'.
00548                          '  SET templateid ={templateid}'.
00549                          '  WHERE objectid={objectid}' );
00550           $sql->setInt('templateid' ,$this->templateid);
00551           $sql->setInt('objectid'   ,$this->objectid  );
00552           $db->query( $sql->query );
00553 
00554 
00555           // Inhalte umschluesseln, d.h. die Element-Ids aendern
00556           $template = new Template( $oldTemplateId );
00557           foreach( $template->getElementIds() as $oldElementId )
00558           {
00559                if   ( !isset($replaceElementMap[$oldElementId])  ||
00560                      intval($replaceElementMap[$oldElementId]) < 1 )
00561                {
00562                     Logger::debug( 'deleting value of elementid '.$oldElementId );
00563                     $sql = new Sql('DELETE FROM {t_value}'.
00564                                    '  WHERE pageid={pageid}'.
00565                                    '    AND elementid={elementid}' );
00566                     $sql->setInt('pageid'   ,$this->pageid);
00567                     $sql->setInt('elementid',$oldElementId      );
00568                     
00569                     $db->query( $sql->query );
00570                }
00571                else
00572                {
00573                     $newElementId = intval($replaceElementMap[$oldElementId]);
00574 
00575                     Logger::debug( 'updating elementid '.$oldElementId.' -> '.$newElementId );
00576                     $sql = new Sql('UPDATE {t_value}'.
00577                                    '  SET elementid ={newelementid}'.
00578                                    '  WHERE pageid   ={pageid}'.
00579                                    '    AND elementid={oldelementid}' );
00580                     $sql->setInt('pageid'      ,$this->pageid);
00581                     $sql->setInt('oldelementid',$oldElementId      );
00582                     $sql->setInt('newelementid',$newElementId      );
00583                     $db->query( $sql->query );
00584                }
00585           }
00586      }
00587 
00588 
00589      
00595      function full_filename()
00596      {
00597           $filename = $this->path();
00598 
00599           if   ( !empty($filename) )
00600                $filename .= '/';
00601 
00602           if   ( !$this->cut_index || $this->filename != 'index' )
00603           {
00604                $filename .= $this->filename();
00605                
00606                if   ( !$this->content_negotiation )
00607                {
00608                     if   ( !$this->default_language && $this->withLanguage )
00609                     {         
00610                          $l = new Language( $this->languageid );
00611                          $l->load();
00612                          $filename .= '.'.$l->isoCode;
00613                     }
00614           
00615                     $t = new Template( $this->templateid );
00616                     $t->modelid = $this->modelid;
00617                     $t->load();
00618                     $filename .= '.'.$t->extension;
00619           
00620                     if   ( $this->default_language && $this->withLanguage )
00621                     {         
00622                          $filename .= '.'.$t->extension;
00623                     }
00624                }
00625           }
00626 
00627           $this->fullFilename = $filename;
00628           return $filename;
00629      }
00630 
00631 
00632 //   function language_filename()
00633 //   {
00634 //        global $SESS;
00635 //        
00636 //        $db = db_connection();
00637 //
00638 //        $sql  = new Sql( 'SELECT COUNT(*) FROM {t_language}'.
00639 //                         ' WHERE projectid={projectid}' );
00640 //        $sql->setInt('projectid',$SESS['projectid']);
00641 //
00642 //        if   ( $db->getOne( $sql->query ) == 1 )
00643 //        {
00644 //             // Wenn es nur eine Sprache gibt, keine Sprachangabe im Dateinamen
00645 //             return '';
00646 //        }
00647 //        else
00648 //        {
00649 //             $sql = new Sql( 'SELECT isocode FROM {t_language}'.
00650 //                             ' WHERE id={languageid}' );
00651 //             $sql->setInt('languageid',$this->languageid);
00652 //             $isocode = $db->getOne( $sql->query );
00653 //
00654 //             return strtolower( $isocode );
00655 //        }         
00656 //   }
00657 
00658 
00665      function getElementIds()
00666      {
00667           $t = new Template( $this->templateid );
00668           
00669           return $t->getElementIds();
00670      }
00671 
00672 
00673 
00680      function getElements()
00681      {
00682           if   ( !isset($this->template) )
00683                $this->template = new Template( $this->templateid );
00684           
00685           return $this->template->getElements();
00686      }
00687 
00688 
00689 
00696      function getWritableElements()
00697      {
00698           if   ( !isset($this->template) )
00699                $this->template = new Template( $this->templateid );
00700           
00701           return $this->template->getWritableElements();
00702      }
00703 
00704 
00705 
00712      function generate_elements()
00713      {
00714           $this->values = array();
00715           
00716           if   ( $this->simple )
00717                $elements = $this->getWritableElements();
00718           else
00719                $elements = $this->getElements();
00720                
00721           foreach( $elements as $elementid=>$element )
00722           {
00723                // neues Inhaltobjekt erzeugen
00724                $val = new Value();
00725                $val->publish = $this->public;
00726                $val->element = $element;
00727 
00728                $val->objectid   = $this->objectid;
00729                $val->pageid     = $this->pageid;
00730                $val->languageid = $this->languageid;
00731                $val->simple     = $this->simple;
00732                $val->modelid    = $this->modelid;
00733                $val->page       = $this;
00734                $val->generate();
00735                $val->page       = null;
00736                $this->values[$elementid] = $val;
00737           }
00738      }
00739 
00740 
00745      function generate()
00746      {
00747           global $conf;
00748           
00749           if   ( $conf['cache']['enable_cache'] && is_file($this->tmpfile() ))
00750           {
00751                $this->value = implode('',file($this->tmpfile()));
00752                return $this->value;
00753           }
00754      
00755           $this->template = new Template( $this->templateid );
00756           $this->template->modelid = $this->modelid;
00757           $this->template->load();
00758           $this->ext = $this->template->extension;
00759 
00760           $this->generate_elements();
00761            
00762           $src = $this->template->src;
00763 
00764           // Ersetzen der Platzhalter durch die Element-Inhalte
00765           
00766           foreach( $this->values as $id=>$value )
00767           {
00768                $inh = $value->value;
00769                $src = str_replace( '{{'.$id.'}}',$inh,$src );
00770                
00771                // Dynamische Bereiche ein- oder ausblenden
00772                if   ( $inh == '' )
00773                {
00774                     // Wenn Feld leer
00775                     $src = str_replace( '{{IFEMPTY:'.$id.':BEGIN}}','',$src );
00776                     $src = str_replace( '{{IFEMPTY:'.$id.':END}}'  ,'',$src );
00777 
00778                     $src = Text::entferneVonBis( $src,'{{IFNOTEMPTY:'.$id.':BEGIN}}','{{IFNOTEMPTY:'.$id.':END}}' );
00779                }
00780                else
00781                {
00782                     // Wenn Feld gefuellt
00783                     $src = str_replace( '{{IFNOTEMPTY:'.$id.':BEGIN}}','',$src );
00784                     $src = str_replace( '{{IFNOTEMPTY:'.$id.':END}}'  ,'',$src );
00785                     
00786                     $src = Text::entferneVonBis( $src,'{{IFEMPTY:'.$id.':BEGIN}}','{{IFEMPTY:'.$id.':END}}' );
00787                }
00788                
00789                if   ( $this->icons )
00790                     $src = str_replace( '{{->'.$id.'}}','<a href="'.Html::url('pageelement','edit',$this->objectid,array('elementid'=>$id)).'" title="'.$value->element->desc.'" target="cms_main_main"><img src="'.OR_THEMES_DIR.$conf['interface']['theme'].'/images/icon_el_'.$value->element->type.IMG_ICON_EXT.'" border="0"></a>',$src );
00791                else
00792                     $src = str_replace( '{{->'.$id.'}}','',$src );
00793           }
00794 
00795           #Html::debug(strlen($src),'laenge am ende');
00796           
00797           $this->value = &$src;
00798 
00799           // Store in cache.
00800           $f = fopen( $this->tmpfile(),'w' );
00801           fwrite( $f,$this->value );
00802           fclose( $f );
00803           
00804           return $this->value;
00805      }
00806 
00807 
00811      function write()
00812      {
00813           if   ( !is_file($this->tmpfile()))
00814                $this->generate();
00815      }
00816 
00817 
00821      function publish()
00822      {
00823           global $SESS;
00824           $db = db_connection();
00825           
00826           if   ( ! is_object($this->publish) )
00827                $this->publish = new Publish();
00828           
00829           $this->public              = true;
00830 
00831           // Schleife ueber alle Sprachvarianten
00832           $allLanguages = Language::getAll();
00833           
00834           foreach( $allLanguages as $languageid=>$x )
00835           {
00836                $this->languageid   = $languageid;
00837                $this->withLanguage = count($allLanguages) > 1;
00838 
00839                // Schleife ueber alle Projektvarianten
00840                foreach( Model::getAll() as $projectmodelid=>$x )
00841                {
00842                     $this->modelid = $projectmodelid;
00843                
00844                     $this->load();
00845                     $this->generate();
00846                     $this->write();
00847 
00848                     // Vorlage ermitteln.
00849                     $t = new Template( $this->templateid );
00850                     $t->modelid = $this->modelid;
00851                     $t->load();
00852                     // Nur wenn eine Datei-Endung vorliegt wird die Seite veroeffentlicht
00853                     if   ( !empty($t->extension) )
00854                     {    
00855                          $this->publish->copy( $this->tmpfile(),$this->full_filename() );
00856                          unlink( $this->tmpfile() );
00857                          $this->publish->publishedObjects[] = $this->getProperties();
00858                     }
00859                }
00860           }
00861 
00862      }
00863      
00864 
00870      function mimeType()
00871      {
00872           if   ( ! is_object($this->template) )
00873           {
00874                $this->template = new Template( $this->templateid );
00875                $this->template->modelid = $this->modelid;
00876                $this->template->load();
00877           }
00878 
00879           $this->mime_type = $this->template->mimeType();
00880                
00881           return( $this->mime_type );
00882      }
00883 
00884      
00885      
00889      function tmpfile()
00890      {
00891           $db = db_connection();
00892           $filename = $this->getTempFileName( array('db'=>$db->id,
00893                                                     'o' =>$this->objectid,
00894                                                     'l' =>$this->languageid,
00895                                                     'm' =>$this->modelid,
00896                                                     'p' =>intval($this->public),
00897                                                     's' =>intval($this->simple)   ) );
00898           return $filename;
00899      }
00900      
00901      
00902      
00903      function setTimestamp()
00904      {
00905           $tmpFilename = $this->tmpfile();
00906           
00907           if   ( is_file($tmpFilename) )
00908                unlink( $tmpFilename);
00909           
00910           parent::setTimestamp();
00911      }
00912      
00913 }
00914 
00915 
00916 ?>

Erzeugt am Thu May 14 00:55:48 2009 für OpenRat von  doxygen 1.5.8