LanguageAction.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.11  2007-05-24 19:47:48  dankert
00024 // Direktes Ausw?hlen von Sprache/Modell in der Projektauswahlliste.
00025 //
00026 // Revision 1.10  2007-05-08 21:16:20  dankert
00027 // Korrektur und Erweiterung von Hinzuf?gen/Bearbeiten von Sprachen.
00028 //
00029 // Revision 1.9  2007/01/21 22:26:45  dankert
00030 // Korreketur beim Hinzuf?gen/Entfernen von Sprachen.
00031 //
00032 // Revision 1.8  2006/01/29 17:18:59  dankert
00033 // Steuerung der Aktionsklasse ?ber .ini-Datei, dazu umbenennen einzelner Methoden
00034 //
00035 // Revision 1.7  2004/12/25 20:50:13  dankert
00036 // Korrektur Sprach-Aenderung
00037 //
00038 // Revision 1.6  2004/12/19 14:55:00  dankert
00039 // Korrektur der Laenderlisten
00040 //
00041 // Revision 1.5  2004/12/13 22:17:51  dankert
00042 // URL-Korrektur
00043 //
00044 // Revision 1.4  2004/11/27 13:06:44  dankert
00045 // Ausgabe von Meldungen
00046 //
00047 // Revision 1.3  2004/11/10 22:37:23  dankert
00048 // Korrektur Auswahl-Url
00049 //
00050 // Revision 1.2  2004/05/02 14:49:37  dankert
00051 // Einf?gen package-name (@package)
00052 //
00053 // Revision 1.1  2004/04/24 15:14:52  dankert
00054 // Initiale Version
00055 //
00056 // ---------------------------------------------------------------------------
00057 
00058 
00065 class LanguageAction extends Action
00066 {
00067      var $defaultSubAction = 'listing';
00068 
00073      var $language;
00074      var $project;
00075 
00076 
00080      function LanguageAction()
00081      {
00082           if   ( $this->getRequestId() != 0 )
00083           {
00084                $this->language = new Language( $this->getRequestId() );
00085                $this->language->load();
00086           }
00087           
00088           $this->project = Session::getProject();
00089      }
00090 
00091 
00095      function add()
00096      {
00097           global $conf;
00098           $countryList = $conf['countries'];
00099 
00100           foreach( $this->project->getLanguageIds() as $id )
00101           {
00102                if   ( $id == $this->language->languageid )
00103                     continue;      
00104 
00105                $l = new Language( $id );
00106                $l->load();
00107 
00108                unset( $countryList[$l->isoCode] );
00109           }
00110 
00111           asort( $countryList );        
00112           $this->setTemplateVar('isocodes'  ,$countryList );
00113      }
00114      
00115      
00116      function addlanguage()
00117      {
00118           global $conf;
00119           $countryList = $conf['countries'];
00120           
00121           // Hinzufuegen einer Sprache
00122           $iso =    $this->getRequestVar('isocode');
00123           $language = new Language();
00124           $language->projectid = $this->project->projectid;
00125           $language->isoCode   = $iso;
00126           $language->name      = $countryList[$iso];
00127           $language->add();
00128      }
00129 
00130 
00136      function setdefault()
00137      {
00138           $this->language->setDefault();
00139      }
00140 
00141 
00142 
00146      function remove()
00147      {
00148           $this->setTemplateVar('name'   ,$this->language->name   );
00149      }
00150      
00151      
00155      function delete() 
00156      {
00157           if   ( $this->getRequestVar('confirm') == '1' )
00158                $this->language->delete();
00159      }
00160      
00161 
00165      function save()
00166      {
00167           global $conf;
00168 
00169           if   ( $this->hasRequestVar('name') )
00170           {
00171                $this->language->name    = $this->getRequestVar('name'   );
00172                $this->language->isoCode = $this->getRequestVar('isocode');
00173           }
00174           else
00175           {
00176                $countryList = $conf['countries'];
00177                $iso = $this->getRequestVar('isocode');
00178                $this->language->name    = $countryList[$iso];
00179                $this->language->isoCode = strtolower( $iso );
00180           }
00181           
00182           $this->language->save();
00183      }
00184 
00185 
00186 
00187      function listing()
00188      {
00189           global $conf;
00190           $countryList = $conf['countries'];
00191 
00192           $list = array();
00193           
00194           $actLanguage = Session::getProjectLanguage();
00195           $this->setTemplateVar('act_languageid',$actLanguage->languageid);
00196      
00197           foreach( $this->project->getLanguageIds() as $id )
00198           {
00199                $l = new Language( $id );
00200                $l->load();
00201                
00202                unset( $countryList[strtoupper($l->isoCode)] );
00203                
00204                $list[$id] = array();
00205                $list[$id]['name'   ] = $l->name;
00206                $list[$id]['isocode'] = $l->isoCode;
00207                
00208                if   ( $this->userIsAdmin() )
00209                {
00210                     $list[$id]['url' ] = Html::url('main','language',$id,
00211                                                    array(REQ_PARAM_TARGETSUBACTION=>'edit') );
00212                
00213                     if   ( ! $l->isDefault )
00214                          $list[$id]['default_url'] = Html::url( 'language','setdefault',$id );
00215                }
00216                     
00217                if   ( $actLanguage->languageid != $l->languageid )
00218                     $list[$id]['select_url']  = Html::url( 'index','language',$id );
00219           }
00220           
00221 //        if   ( $this->userIsAdmin() )
00222 //        {
00223 //             asort($countryList);
00224 //             $this->setTemplateVar('isocodes',$countryList);
00225 //        }
00226 
00227           $this->setTemplateVar('el',$list);
00228 
00229           $this->forward('language_list');
00230      }
00231 
00232 
00233 
00234      function edit()
00235      {
00236           global $conf;
00237           $countryList = $conf['countries'];
00238 
00239           foreach( $this->project->getLanguageIds() as $id )
00240           {
00241                if   ( $id == $this->language->languageid )
00242                     continue;      
00243 
00244                $l = new Language( $id );
00245                $l->load();
00246 
00247                unset( $countryList[$l->isoCode] );
00248           }
00249 
00250           asort( $countryList );        
00251           $this->setTemplateVar('isocodes'  ,$countryList               );
00252           $this->setTemplateVar('isocode'   ,strtoupper($this->language->isoCode) );
00253      }
00254      
00255 
00256 
00257      function advanced()
00258      {
00259           $this->setTemplateVar('isocode',$this->language->isoCode);
00260           $this->setTemplateVar('name'   ,$this->language->name   );
00261      }
00262      
00263      
00264      
00265      
00266 
00267      function checkmenu( $menu )
00268      {
00269           switch( $menu )
00270           {
00271                case 'remove':
00272                     $actLanguage = Session::getProjectLanguage();
00273                     return
00274                          $this->userIsAdmin()                 &&
00275                          count( $this->language->getAll() ) >= 2 &&
00276                          isset($this->language) &&
00277                          $actLanguage->languageid != $this->language->languageid;
00278                     
00279                case 'add':
00280                     return
00281                          $this->userIsAdmin();
00282                
00283                default:
00284                     return true;
00285           }
00286      }
00287 }

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