LanguageAction.class.php
gehe zur Dokumentation dieser Datei00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
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
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
00222
00223
00224
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 }