TemplateAction.class.php

gehe zur Dokumentation dieser Datei
00001 <?php
00002 // ---------------------------------------------------------------------------
00003 // $Id$
00004 // ---------------------------------------------------------------------------
00005 // OpenRat Content Management System
00006 // Copyright (C) 2002-2004 Jan Dankert, cms@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.23  2008-10-07 20:00:32  dankert
00024 // Entfernen Methode "edit".
00025 //
00026 // Revision 1.22  2008-09-11 19:06:14  dankert
00027 // in src() Abfrage auf Modus.
00028 //
00029 // Revision 1.21  2007-11-24 14:17:42  dankert
00030 // MimeType in Template ermitteln. Auswahl der Erweiterung ?ber Auswahl-Box.
00031 //
00032 // Revision 1.20  2007-11-16 22:56:19  dankert
00033 // Dialog-Verbesserung f?r Hinzuf?gen von Element im Template-Quellcode.
00034 //
00035 // Revision 1.19  2007-11-15 21:42:46  dankert
00036 // Beim Anlegen von Seitenvorlagen Beispiel-Vorlagen anbieten.
00037 //
00038 // Revision 1.18  2007-11-05 20:51:03  dankert
00039 // Aufruf von "addValidationError(...)" bei Eingabefehlern.
00040 //
00041 // Revision 1.17  2007-10-10 19:49:20  dankert
00042 // Anzeige von abh?ngigen Seiten in den Template-Eigenschaften.
00043 //
00044 // Revision 1.16  2007-10-10 19:08:55  dankert
00045 // Beim Hinzuf?gen von Vorlagen das Kopieren einer anderen Vorlage erlauben. Korrektur beim L?schen von Vorlagen.
00046 //
00047 // Revision 1.15  2007-05-21 20:04:10  dankert
00048 // Korrektur f?r Anzeige des Vorlagen-Quelltextes.
00049 //
00050 // Revision 1.14  2007-04-08 21:33:42  dankert
00051 // Bei Ausw?hlen einer Vorlage die Elementliste starten.
00052 //
00053 // Revision 1.13  2007/03/11 00:27:12  dankert
00054 // Beim Ausw?hlen einer Vorlage aus der Liste diese sofort anzeigen.
00055 //
00056 // Revision 1.12  2006/01/29 17:18:59  dankert
00057 // Steuerung der Aktionsklasse ?ber .ini-Datei, dazu umbenennen einzelner Methoden
00058 //
00059 // Revision 1.11  2006/01/23 23:10:46  dankert
00060 // *** empty log message ***
00061 //
00062 // Revision 1.10  2005/11/07 22:32:20  dankert
00063 // Neue Methode "edit()"
00064 //
00065 // Revision 1.9  2005/01/05 23:11:14  dankert
00066 // Nach hinzuf?gen von Elementen nicht speichern
00067 //
00068 // Revision 1.8  2004/12/27 23:34:51  dankert
00069 // Aenderung Konstruktor
00070 //
00071 // Revision 1.7  2004/12/19 15:17:11  dankert
00072 // div. Korrekturen
00073 //
00074 // Revision 1.6  2004/12/15 23:25:13  dankert
00075 // Sprachvariablen korrigiert
00076 //
00077 // Revision 1.5  2004/09/30 20:31:19  dankert
00078 // Auch leere Extension speichern
00079 //
00080 // Revision 1.4  2004/07/09 20:57:29  dankert
00081 // Dynamische Bereiche (IFEMPTY...)
00082 //
00083 // Revision 1.3  2004/05/07 21:34:58  dankert
00084 // Url ?ber Html::url erzeugen
00085 //
00086 // Revision 1.2  2004/05/02 14:49:37  dankert
00087 // Einf?gen package-name (@package)
00088 //
00089 // Revision 1.1  2004/04/24 15:14:52  dankert
00090 // Initiale Version
00091 //
00092 // ---------------------------------------------------------------------------
00093 
00101 class TemplateAction extends Action
00102 {
00103      var $defaultSubAction = 'show';
00104      var $template;
00105      var $element;
00106 
00107 
00108      function TemplateAction()
00109      {
00110           if   ( $this->getRequestId() != 0 )
00111           {
00112                $this->template = new Template( $this->getRequestId() );
00113                $this->template->load();
00114                $this->setTemplateVar( 'templateid',$this->template->templateid );
00115           }
00116           else
00117           {
00118                $this->defaultSubAction = 'listing';
00119           }
00120 
00121           if   ( intval($this->getRequestVar('elementid')) != 0 )
00122           {
00123                $this->element = new Element( $this->getRequestVar('elementid') );
00124                $this->element->load();
00125                $this->setTemplateVar( 'elementid',$this->element->elementid );
00126           }
00127      }
00128 
00129 
00130      function savesrc()
00131      {
00132           // Speichern des Quelltextes
00133           //
00134           $text = $this->getRequestVar('src');
00135           
00136           foreach( $this->template->getElementNames() as $elid=>$elname )
00137           {
00138                $text = str_replace('{{'.$elname.'}}'  ,'{{'.$elid.'}}',$text );
00139                $text = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$text );
00140                $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY'   ).':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFEMPTY:'   .$elid.':BEGIN}}',$text );
00141                $text = str_replace('{{'.lang('TEMPLATE_SRC_IFEMPTY'   ).':'.$elname.':'.lang('TEMPLATE_SRC_END'  ).'}}','{{IFEMPTY:'   .$elid.':END}}'  ,$text );
00142                $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_BEGIN').'}}','{{IFNOTEMPTY:'.$elid.':BEGIN}}',$text );
00143                $text = str_replace('{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$elname.':'.lang('TEMPLATE_SRC_END'  ).'}}','{{IFNOTEMPTY:'.$elid.':END}}'  ,$text );
00144           }
00145      
00146           $this->template->src = $text;
00147           $this->template->save();
00148           $this->template->load();
00149           
00150           $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
00151      }
00152 
00153 
00154 
00155 
00156      function srcaddelement()
00157      {
00158           $text = $this->template->src;
00159 
00160           switch( $this->getRequestVar('type') )
00161           {
00162                case 'addelement':
00163                     $text .= "\n".'{{'.$this->getRequestVar('elementid').'}}';
00164                     break;
00165           
00166                case 'addicon':
00167                     $text .= "\n".'{{->'.$this->getRequestVar('writable_elementid').'}}';
00168                     break;
00169 
00170                case 'addifempty':
00171                     $text .= "\n".'{{IFEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}}  {{IFEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
00172                     break;
00173 
00174                case 'addifnotempty':
00175                     $text .= "\n".'{{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':BEGIN}}  {{IFNOTEMPTY:'.$this->getRequestVar('writable_elementid').':END}}';
00176                     break;
00177           
00178                default:
00179                     $this->addValidationError('type');
00180                     $this->callSubAction('srcelement');
00181                     return;
00182           }
00183           
00184           $this->template->src = $text;
00185 
00186           $this->template->save();
00187           $this->template->load();
00188 
00189           $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
00190      }
00191 
00192 
00193      // Speichern der Template-Eigenschaftens
00194      //
00195      function savename()
00196      {
00197           
00198           if   ($this->getRequestVar('name') == "")
00199           {
00200                $this->addValidationError('name');
00201                $this->callSubAction('name');
00202                return;
00203           }
00204           else
00205           {
00206                $this->template->name = $this->getRequestVar('name');
00207                $this->template->save();
00208                $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
00209           }
00210      }
00211 
00212 
00213      // Speichern der Template-Eigenschaftens
00214      //
00215      function delete()
00216      {
00217           if   ( $this->getRequestVar('delete') != '' )
00218           {
00219                $this->template->delete();
00220                $this->addNotice('template',$this->template->name,'DELETED',OR_NOTICE_OK);
00221           }
00222           else
00223           {
00224                $this->addNotice('template',$this->template->name,'CANCELED',OR_NOTICE_WARN);
00225           }
00226      }
00227 
00228 
00232      function remove()
00233      {
00234           $this->setTemplateVar('name',$this->template->name);
00235      }
00236 
00237 
00241      function pages()
00242      {
00243           $pages = array();
00244           $pageids = $this->template->getDependentObjectIds();
00245           
00246           foreach( $pageids as $pageid )
00247           {
00248                $page = new Page($pageid);
00249                $page->load();
00250                
00251                $pages[$pageid] = $page->name;
00252           }
00253           
00254           $this->setTemplateVar('pages',$pages);
00255      }
00256 
00257 
00258      // Speichern der Dateiendung
00259      //
00260      function saveextension()
00261      {
00262           if   ( $this->getRequestVar('type') == "list" )
00263                $this->template->extension = $this->getRequestVar('extension');
00264           else
00265                $this->template->extension = $this->getRequestVar('extensiontext');
00266           
00267           $this->template->save(); 
00268           $this->addNotice('template',$this->template->name,'SAVED','ok');
00269      }
00270 
00271 
00272      function addel()
00273      {
00274           // Die verschiedenen Element-Typen
00275           $types = array();
00276 
00277           foreach( Element::getAvailableTypes() as $t )
00278           {
00279                $types[ $t ] = lang('EL_'.$t);
00280           }
00281 
00282           // Code-Element nur fuer Administratoren (da voller Systemzugriff!)        
00283           if   ( !$this->userIsAdmin() )
00284                unset( $types['code'] );
00285           
00286           $this->setTemplateVar('types',$types);
00287      }
00288      
00289      
00290      
00291      // Element hinzuf?gen
00292      //
00293      function addelement()
00294      {
00295           if  ( $this->getRequestVar('name') != '' )
00296           {
00297                $this->template->addElement( $this->getRequestVar('name'),$this->getRequestVar('description'),$this->getRequestVar('type') );
00298                $this->setTemplateVar('tree_refresh',true);
00299                $this->addNotice('template',$this->template->name,'SAVED','ok');
00300           }
00301           else
00302           {
00303                $this->addValidationError('name');
00304                $this->callSubAction('addel');
00305           }
00306 
00307      }
00308 
00309 
00313      function add()
00314      {
00315           $this->setTemplateVar( 'templates',Template::getAll() );
00316 
00317           $examples = array();
00318           $dir = opendir( 'examples/templates');
00319           while( $file = readdir($dir) )
00320           {
00321                if   ( substr($file,0,1) != '.')
00322                {
00323                     $examples[$file] = $file;
00324                }
00325           }
00326           
00327           $this->setTemplateVar( 'examples',$examples );
00328      }
00329      
00330      
00331      
00332      function addtemplate()
00333      {
00334           // Hinzufuegen eines Templates
00335           if   ( $this->getRequestVar('name') == '' )
00336           {
00337                $this->addValidationError('name');
00338                $this->callSubAction('add');
00339                return;
00340           }
00341 
00342           // Hinzufuegen eines Templates
00343           switch( $this->getRequestVar('type') )
00344           {
00345                case 'empty':
00346 
00347                     $template = new Template();
00348                     $template->add( $this->getRequestVar('name') );
00349                     $this->addNotice('template',$template->name,'ADDED','ok');
00350                     break;
00351                     
00352                case 'copy':
00353                     
00354                     $copy_templateid = intval($this->getRequestVar('templateid') );
00355                     
00356                     if   ( $copy_templateid == 0 )
00357                     {
00358                          $this->addValidationError('templateid');
00359                          $this->callSubAction('add');
00360                          return;
00361                     }
00362                     
00363                     $template = new Template();
00364                     $template->add( $this->getRequestVar('name') );
00365                     $this->addNotice('template',$template->name,'ADDED','ok');
00366 
00367                     $copy_template = new Template( $copy_templateid );
00368                     $copy_template->load();
00369                     foreach( $copy_template->getElements() as $element )
00370                     {
00371                          $element->load();
00372                          $element->templateid = $template->templateid;
00373                          $element->add();
00374                          $element->save();
00375                     }
00376                     
00377                     $this->addNotice('template',$copy_template->name,'COPIED','ok');
00378 
00379                     break;
00380 
00381                case 'example':
00382 
00383                     $template = new Template();
00384 
00385                     $model = Session::getProjectModel();
00386                     $template->modelid = $model->modelid;
00387                     
00388                     $template->add( $this->getRequestVar('name') );
00389 
00390                     $example = parse_ini_file('examples/templates/'.$this->getRequestVar('example'),true);
00391 
00392                     foreach( $example as $exampleKey=>$exampleElement )
00393                     {
00394                          if   ( !is_array($exampleElement) )
00395                          {
00396                               $template->$exampleKey = $exampleElement;
00397                          }
00398                          else
00399                          {
00400                               $element = new Element();
00401                               $element->templateid = $template->templateid;
00402                               $element->name       = $exampleKey;
00403                               $element->writable   = true;
00404                               $element->add();
00405 
00406                               foreach( $exampleElement as $ePropName=>$ePropValue)
00407                                    $element->$ePropName = $ePropValue;
00408                               
00409                               $element->defaultText = str_replace(';',"\n",$element->defaultText);
00410                               $element->save();
00411 //                            Html::debug($element,"Element");
00412                          }
00413                     }
00414 //                  Html::debug($template,"Template");
00415                     $template->name = $this->getRequestVar('name');
00416                     $template->src = str_replace(';',"\n",$template->src);
00417                     
00418                     foreach( $template->getElementNames() as $elid=>$elname )
00419                     {
00420                          $template->src = str_replace('{{'.$elname.'}}'  ,'{{'.$elid.'}}'  ,$template->src );
00421                          $template->src = str_replace('{{->'.$elname.'}}','{{->'.$elid.'}}',$template->src );
00422                     }
00423                     
00424                     $template->save();
00425                     $this->addNotice('template',$template->name,'ADDED','ok');
00426 
00427                     break;
00428                default:
00429                     $this->addValidationError('type');
00430                     $this->callSubAction('add');
00431                     return;
00432           }
00433 
00434 
00435           $this->setTemplateVar('tree_refresh',true);
00436      }
00437 
00438      
00439      function prop()
00440      {
00441      }
00442      
00443      
00444      
00448      function name()
00449      {
00450           $this->setTemplateVar('name'     ,$this->template->name       );
00451           $this->setTemplateVar('extension',$this->template->extension  );
00452           $this->setTemplateVar('mime_type',$this->template->mimeType() );
00453      }
00454 
00455 
00456 
00460      function extension()
00461      {
00462 
00463           global $conf;
00464           $mime_types = array();
00465           foreach( $conf['mime-types'] as $ext=>$type )
00466                $mime_types[$ext] = $ext.' - '.$type;
00467 
00468           $this->setTemplateVar('mime_types',$mime_types);
00469 
00470           $this->setTemplateVar('extension'    ,$this->template->extension);
00471           $this->setTemplateVar('extensiontext',$this->template->extension);
00472           
00473           if   ( isset($mime_types[$this->template->extension]) )
00474                $this->setTemplateVar('type','list');
00475           else
00476                $this->setTemplateVar('type','text');
00477      }
00478 
00479 
00480 
00484      function show()
00485      {
00486           $text = $this->template->src;
00487      
00488           foreach( $this->template->getElementIds() as $elid )
00489           {
00490                $element = new Element( $elid );
00491                $element->load();
00492                $url = Html::url( 'element','edit',$this->template->templateid,array('elementid'=>$elid));
00493                
00494                $text = str_replace('{{'.$elid.'}}',$element->name,
00495                                    $text );
00496                $text = str_replace('{{->'.$elid.'}}','',
00497                                    $text );
00498 
00499                $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}','',
00500                                    $text );
00501                $text = str_replace('{{IFEMPTY:'.$elid.':END}}','',
00502                                    $text );
00503 
00504                $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}','',
00505                                    $text );
00506                $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}','',
00507                                    $text );
00508                                    
00509                unset( $element );
00510           }
00511      
00512           echo $text;
00513           
00514           exit();
00515      }
00516 
00517 
00521      function edit()
00522      {
00523           $text = htmlentities( $this->template->src );
00524           $text = str_replace("\n",'<br/>',$text);
00525      
00526           foreach( $this->template->getElementIds() as $elid )
00527           {
00528                $element = new Element( $elid );
00529                $element->load();
00530                $url = Html::url( 'element','name',$elid );
00531                
00532                $text = str_replace('{{'.$elid.'}}',
00533                                    '<a href="'.$url.'" class="el_'.
00534                                    $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
00535                                    $element->name.'}}</a>',
00536                                    $text );
00537                $text = str_replace('{{-&gt;'.$elid.'}}',
00538                                    '<a href="'.$url.'" class="el_'.
00539                                    $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{-&gt;'.
00540                                    $element->name.'}}</a>',
00541                                    $text );
00542 
00543                $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
00544                                    '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
00545                                    $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
00546                                    $text );
00547                $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
00548                                    '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
00549                                    $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
00550                                    $text );
00551 
00552                $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
00553                                    '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
00554                                    $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
00555                                    $text );
00556                $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
00557                                    '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
00558                                    $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
00559                                    $text );
00560                                    
00561                unset( $element );
00562           }
00563      
00564           $this->setTemplateVar('text',$text);
00565           
00566           $this->forward('template_show');
00567      }
00568 
00569 
00570      // Anzeigen der Template-Elemente
00571      //
00572      function el()
00573      {
00574           global $conf_php;
00575           $list = array();
00576      
00577           foreach( $this->template->getElementIds() as $elid )
00578           {
00579                $element = new Element( $elid );
00580                $element->load();
00581 
00582                $list[$elid]         = array();
00583                $list[$elid]['url' ] = Html::url('element','name',$elid);
00584                $list[$elid]['name'] = $element->name;
00585                $list[$elid]['desc'] = $element->desc;
00586                $list[$elid]['type'] = $element->type;
00587                
00588                unset( $element );
00589           }
00590           $this->setTemplateVar('el',$list); 
00591      }
00592 
00593 
00594 
00595      function srcelement()
00596      {
00597           $elements           = array();
00598           $writable_elements = array();
00599      
00600           foreach( $this->template->getElementIds() as $elid )
00601           {
00602                $element = new Element( $elid );
00603                $element->load();
00604 
00605                $elements[$elid] = $element->name;
00606 
00607                if   ( $element->isWritable() )
00608                     $writable_elements[$elid] = $element->name;
00609           }
00610 
00611           $this->setTemplateVar('elements'         ,$elements         );
00612           $this->setTemplateVar('writable_elements',$writable_elements);
00613      }
00614      
00615      
00616      
00620      function src()
00621      {
00622           if   ( $this->isEditMode() )
00623           {
00624                $text = $this->template->src;
00625           
00626                foreach( $this->template->getElementIds() as $elid )
00627                {
00628                     $element = new Element( $elid );
00629                     $element->load();
00630      
00631                     $text = str_replace('{{'.$elid.'}}',
00632                                                '{{'.$element->name.'}}',
00633                                                $text );
00634                     $text = str_replace('{{->'.$elid.'}}',
00635                                                '{{->'.$element->name.'}}',
00636                                                $text );
00637                     $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
00638                                                '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
00639                                                $text );
00640                     $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
00641                                                '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
00642                                                $text );
00643                     $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
00644                                                '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
00645                                                $text );
00646                     $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
00647                                                '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
00648                                                $text );
00649                }
00650      
00651                $this->setTemplateVar( 'src',$text );
00652           }
00653           else
00654           {
00655                $text = htmlentities( $this->template->src );
00656                $text = str_replace("\n",'<br/>',$text);
00657           
00658                foreach( $this->template->getElementIds() as $elid )
00659                {
00660                     $element = new Element( $elid );
00661                     $element->load();
00662                     $url = Html::url( 'element','name',$elid );
00663                     
00664                     $text = str_replace('{{'.$elid.'}}',
00665                                         '<a href="'.$url.'" class="el_'.
00666                                         $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
00667                                         $element->name.'}}</a>',
00668                                         $text );
00669                     $text = str_replace('{{-&gt;'.$elid.'}}',
00670                                         '<a href="'.$url.'" class="el_'.
00671                                         $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{-&gt;'.
00672                                         $element->name.'}}</a>',
00673                                         $text );
00674      
00675                     $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
00676                                         '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
00677                                         $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
00678                                         $text );
00679                     $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
00680                                         '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
00681                                         $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
00682                                         $text );
00683      
00684                     $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
00685                                         '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
00686                                         $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
00687                                         $text );
00688                     $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
00689                                         '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
00690                                         $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
00691                                         $text );
00692                                         
00693                     unset( $element );
00694                }
00695           
00696                $this->setTemplateVar('src',$text);
00697           }
00698           
00699      }
00700 
00701 
00702      // Anzeigen aller Templates
00703      //
00704      function listing()
00705      {
00706           global $conf_php;
00707 
00708           $list = array();
00709      
00710           foreach( Template::getAll() as $id=>$name )
00711           {
00712                $list[$id] = array();
00713                $list[$id]['name'] = $name;
00714                $list[$id]['url' ] = Html::url('main','template',$id,array(REQ_PARAM_TARGETSUBACTION=>'el'));
00715           }
00716           
00717 //        $var['templatemodelid'] = htmlentities( $id   );
00718 //        $var['text']            = htmlentities( $text );
00719           $this->setTemplateVar('templates',$list);
00720      }
00721 
00722      
00723      function checkMenu( $menu ) {
00724 
00725           switch( $menu)
00726           {
00727                case 'remove':
00728                     return (count($this->template->getDependentObjectIds()) == 0);
00729 
00730                case 'pages':
00731                     return (count($this->template->getDependentObjectIds()) > 0);
00732                     
00733                default:
00734                     return true;
00735 
00736           }
00737      }
00738      
00739 }

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