
Öffentliche Methoden | |
| FileAction () | |
| replace () | |
| savevalue () | |
| saveprop () | |
| show () | |
| imageFormat () | |
| imageExt () | |
| imageFormats () | |
| resize () | |
| prop () | |
| edit () | |
| upload () | |
| editvalue () | |
| size () | |
| extract () | |
| uncompress () | |
| compress () | |
| douncompress () | |
| doextract () | |
| docompress () | |
| pub () | |
| pubnow () | |
| getCompressionTypes () | |
| getArchiveTypes () | |
| checkMenu ($name) | |
Öffentliche Attribute | |
| $file | |
| $defaultSubAction = 'show' | |
Definiert in Zeile 29 der Datei FileAction.class.php.
| FileAction::checkMenu | ( | $ | name | ) |
Ermittelt, ob der Men�punkt aktiv ist. Ob ein Men�punkt als aktiv angezeigt werden soll, steht meist erst zur Laufzeit fest.
Diese Methode kann von den Unterklassen �berschrieben werden. Falls diese Methode nicht �berschrieben wird, sind alle Men�punkte aktiv.
| String | $name Logischer Name des Men�punktes |
Erneute Implementation von Action.
Definiert in Zeile 615 der Datei FileAction.class.php.
Benutzt getArchiveTypes() und getCompressionTypes().
00616 { 00617 $archiveTypes = $this->getArchiveTypes(); 00618 $compressionTypes = $this->getCompressionTypes(); 00619 00620 switch( $name ) 00621 { 00622 case 'uncompress': 00623 return in_array($this->file->extension,$compressionTypes); 00624 00625 case 'compress': 00626 return !in_array($this->file->extension,$compressionTypes); 00627 00628 case 'extract': 00629 return in_array($this->file->extension,$archiveTypes); 00630 00631 case 'size': 00632 return $this->file->isImage(); 00633 00634 case 'editvalue': 00635 return substr($this->file->mimeType(),0,5)=='text/'; 00636 00637 default: 00638 return true; 00639 } 00640 }
| FileAction::compress | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 373 der Datei FileAction.class.php.
Benutzt getCompressionTypes(), lang() und Action::setTemplateVar().
00374 { 00375 $formats = array(); 00376 foreach( $this->getCompressionTypes() as $t ) 00377 $formats[$t] = lang('compression_'.$t); 00378 00379 $this->setTemplateVar('formats' ,$formats ); 00380 }
| FileAction::docompress | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 518 der Datei FileAction.class.php.
Benutzt Action::callSubAction() und Action::getRequestVar().
00519 { 00520 $format = $this->getRequestVar('format'); 00521 00522 switch( $format ) 00523 { 00524 case 'gz': 00525 if ( $this->getRequestVar('replace') ) 00526 { 00527 $this->file->value = gzencode( $this->file->loadValue() ); 00528 $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz' ); 00529 $this->file->save(); 00530 $this->file->saveValue(); 00531 00532 } 00533 else 00534 { 00535 $newFile = new File(); 00536 $newFile->name = $this->file->name; 00537 $newFile->parentid = $this->file->parentid; 00538 $newFile->value = gzencode( $this->file->loadValue() ); 00539 $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.gz' ); 00540 $newFile->add(); 00541 } 00542 00543 break; 00544 00545 case 'bzip2': 00546 if ( $this->getRequestVar('replace') ) 00547 { 00548 $this->file->value = bzcompress( $this->file->loadValue() ); 00549 $this->file->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' ); 00550 $this->file->save(); 00551 $this->file->saveValue(); 00552 00553 } 00554 else 00555 { 00556 $newFile = new File(); 00557 $newFile->name = $this->file->name; 00558 $newFile->parentid = $this->file->parentid; 00559 $newFile->value = bzcompress( $this->file->loadValue() ); 00560 $newFile->parse_filename( $this->file->filename.'.'.$this->file->extension.'.bz2' ); 00561 $newFile->add(); 00562 } 00563 00564 break; 00565 default: 00566 die( 'unknown extract type: '.$format ); 00567 } 00568 00569 $this->callSubAction('edit'); 00570 }
| FileAction::doextract | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 441 der Datei FileAction.class.php.
Benutzt $file, Action::addNotice() und Action::callSubAction().
00442 { 00443 switch( $this->file->extension ) 00444 { 00445 case 'tar': 00446 $folder = new Folder(); 00447 $folder->parentid = $this->file->parentid; 00448 $folder->name = $this->file->name; 00449 $folder->filename = $this->file->filename; 00450 $folder->add(); 00451 00452 $tar = new ArchiveTar(); 00453 $tar->openTAR( $this->file->loadValue() ); 00454 00455 foreach( $tar->files as $file ) 00456 { 00457 $newFile = new File(); 00458 $newFile->name = $file['name']; 00459 $newFile->parentid = $folder->objectid; 00460 $newFile->value = $file['file']; 00461 $newFile->parse_filename( $file['name'] ); 00462 $newFile->lastchangeDate = $file['time']; 00463 $newFile->add(); 00464 00465 $this->addNotice('file',$newFile->name,'ADDED'); 00466 } 00467 00468 unset($tar); 00469 00470 break; 00471 00472 case 'zip': 00473 00474 $folder = new Folder(); 00475 $folder->parentid = $this->file->parentid; 00476 $folder->name = $this->file->name; 00477 $folder->filename = $this->file->filename; 00478 $folder->description = $this->file->fullFilename; 00479 $folder->add(); 00480 00481 $zip = new ArchiveUnzip(); 00482 $zip->open( $this->file->loadValue() ); 00483 00484 $lista = $zip->getList(); 00485 00486 if(sizeof($lista)) foreach($lista as $fileName=>$trash){ 00487 00488 00489 $newFile = new File(); 00490 $newFile->name = basename($fileName); 00491 $newFile->description = 'Extracted: '.$this->file->fullFilename.' -> '.$fileName; 00492 $newFile->parentid = $folder->objectid; 00493 $newFile->parse_filename( basename($fileName) ); 00494 00495 $newFile->value = $zip->unzip($fileName); 00496 $newFile->add(); 00497 00498 $this->addNotice('file',$newFile->name,'ADDED'); 00499 unset($newFile); 00500 } 00501 00502 $zip->close(); 00503 unset($zip); 00504 00505 break; 00506 00507 default: 00508 die( 'cannot extract file with extension: '.$this->file->extension ); 00509 } 00510 $this->callSubAction('edit'); 00511 }
| FileAction::douncompress | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 386 der Datei FileAction.class.php.
Benutzt Action::callSubAction() und Action::getRequestVar().
00387 { 00388 switch( $this->file->extension ) 00389 { 00390 case 'gz': 00391 if ( $this->getRequestVar('replace') ) 00392 { 00393 $this->file->value = gzinflate( substr($this->file->loadValue(),10)); 00394 $this->file->parse_filename( $this->file->filename ); 00395 $this->file->save(); 00396 $this->file->saveValue(); 00397 } 00398 else 00399 { 00400 $newFile = new File(); 00401 $newFile->name = $this->file->name; 00402 $newFile->parentid = $this->file->parentid; 00403 $newFile->value = gzinflate( substr($this->file->loadValue(),10)); 00404 $newFile->parse_filename( $this->file->filename ); 00405 $newFile->add(); 00406 } 00407 00408 break; 00409 00410 case 'bz2': 00411 if ( $this->getRequestVar('replace') ) 00412 { 00413 $this->file->value = bzdecompress($this->file->loadValue()); 00414 $this->file->parse_filename( $this->file->filename ); 00415 $this->file->save(); 00416 $this->file->saveValue(); 00417 } 00418 else 00419 { 00420 $newFile = new File(); 00421 $newFile->name = $this->file->name; 00422 $newFile->parentid = $this->file->parentid; 00423 $newFile->value = bzdecompress( $this->file->loadValue() ); 00424 $newFile->parse_filename( $this->file->filename ); 00425 $newFile->add(); 00426 } 00427 00428 break; 00429 00430 default: 00431 die( 'cannot extract file with extension: '.$this->file->extension ); 00432 } 00433 $this->callSubAction('edit'); 00434 }
| FileAction::edit | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 288 der Datei FileAction.class.php.
Benutzt $conf und Action::setTemplateVars().
00289 { 00290 global $conf; 00291 // MIME-Types aus Datei lesen 00292 $this->setTemplateVars( $this->file->getProperties() ); 00293 }
| FileAction::editvalue | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 307 der Datei FileAction.class.php.
Benutzt $conf, Action::setTemplateVar() und Action::setTemplateVars().
00308 { 00309 global $conf; 00310 // MIME-Types aus Datei lesen 00311 $this->setTemplateVars( $this->file->getProperties() ); 00312 $this->setTemplateVar('value',$this->file->loadValue()); 00313 }
| FileAction::extract | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 354 der Datei FileAction.class.php.
Benutzt imageFormat() und Action::setTemplateVars().
00355 { 00356 $this->setTemplateVars( $this->file->getProperties() ); 00357 00358 $imageFormat = $this->imageFormat(); 00359 }
| FileAction::FileAction | ( | ) |
Konstruktor
Definiert in Zeile 37 der Datei FileAction.class.php.
Benutzt Session::getObject(), Action::getRequestId(), Action::lastModified() und Session::setObject().
00038 { 00039 if ( $this->getRequestId() != 0 ) 00040 { 00041 $this->file = new File( $this->getRequestId() ); 00042 $this->file->load(); 00043 Session::setObject( $this->file ); 00044 } 00045 else 00046 { 00047 $this->file = Session::getObject(); 00048 } 00049 00050 $this->lastModified( $this->file->lastchangeDate ); 00051 }
| FileAction::getArchiveTypes | ( | ) |
Definiert in Zeile 605 der Datei FileAction.class.php.
Wird benutzt von checkMenu().
00606 { 00607 $archiveTypes = array(); 00608 $archiveTypes[] = 'tar'; 00609 $archiveTypes[] = 'zip'; 00610 return $archiveTypes; 00611 }
| FileAction::getCompressionTypes | ( | ) |
Definiert in Zeile 596 der Datei FileAction.class.php.
Wird benutzt von checkMenu() und compress().
00597 { 00598 $compressionTypes = array(); 00599 if ( function_exists('gzencode' ) ) $compressionTypes[] = 'gz'; 00600 if ( function_exists('gzencode' ) ) $compressionTypes[] = 'zip'; 00601 if ( function_exists('bzipcompress') ) $compressionTypes[] = 'bz2'; 00602 return $compressionTypes; 00603 }
| FileAction::imageExt | ( | ) |
Definiert in Zeile 155 der Datei FileAction.class.php.
Benutzt imageFormat().
00156 { 00157 switch( $this->imageFormat() ) 00158 { 00159 case IMG_GIF: 00160 return 'GIF'; 00161 case IMG_JPG: 00162 return 'JPEG'; 00163 case IMG_PNG: 00164 return 'PNG'; 00165 } 00166 }
| FileAction::imageFormat | ( | ) |
Definiert in Zeile 132 der Datei FileAction.class.php.
Wird benutzt von extract(), imageExt(), resize() und size().
00133 { 00134 if ( ! function_exists( 'imagetypes' ) ) 00135 return 0; 00136 00137 $ext = strtolower($this->file->extension); 00138 $types = imagetypes(); 00139 $formats = array( 'gif' =>IMG_GIF, 00140 'jpg' =>IMG_JPG, 00141 'jpeg'=>IMG_JPG, 00142 'png' =>IMG_PNG ); 00143 00144 if ( !isset($formats[$ext]) ) 00145 return 0; 00146 00147 if ( $types & $formats[$ext] ) 00148 return $formats[$ext]; 00149 00150 return 0; 00151 }
| FileAction::imageFormats | ( | ) |
Definiert in Zeile 170 der Datei FileAction.class.php.
Wird benutzt von size().
00171 { 00172 if ( ! function_exists( 'imagetypes' ) ) 00173 return array(); 00174 00175 $types = imagetypes(); 00176 $formats = array( IMG_GIF => 'gif', 00177 IMG_JPG => 'jpeg', 00178 IMG_PNG => 'png' ); 00179 $formats2 = $formats; 00180 00181 foreach( $formats as $b=>$f ) 00182 if ( !($types & $b) ) 00183 unset( $formats2[$b] ); 00184 00185 return $formats2; 00186 }
| FileAction::prop | ( | ) |
Definiert in Zeile 247 der Datei FileAction.class.php.
Benutzt $conf, Action::setTemplateVar(), Action::setTemplateVars() und Html::url().
00248 { 00249 00250 global $conf; 00251 00252 if ( $this->file->filename == $this->file->objectid ) 00253 $this->file->filename = ''; 00254 00255 // Eigenschaften der Datei uebertragen 00256 $this->setTemplateVars( $this->file->getProperties() ); 00257 00258 $this->setTemplateVar('size',number_format($this->file->size/1000,0,',','.').' kB' ); 00259 $this->setTemplateVar('full_filename',$this->file->full_filename()); 00260 00261 if ( is_file($this->file->tmpfile())) 00262 { 00263 $this->setTemplateVar('cache_filename' ,$this->file->tmpfile()); 00264 $this->setTemplateVar('cache_filemtime',@filemtime($this->file->tmpfile())); 00265 } 00266 00267 // Alle Seiten mit dieser Datei ermitteln 00268 $pages = $this->file->getDependentObjectIds(); 00269 00270 $list = array(); 00271 foreach( $pages as $id ) 00272 { 00273 $o = new Object( $id ); 00274 $o->load(); 00275 $list[$id] = array(); 00276 $list[$id]['url' ] = Html::url('main','page',$id); 00277 $list[$id]['name'] = $o->name; 00278 } 00279 asort( $list ); 00280 $this->setTemplateVar('pages',$list); 00281 $this->setTemplateVar('edit_filename',$conf['filename']['edit']); 00282 }
| FileAction::pub | ( | ) |
Datei ver?ffentlichen
Definiert in Zeile 576 der Datei FileAction.class.php.
Benutzt Action::forward().
00577 { 00578 $this->forward('file_pub'); 00579 }
| FileAction::pubnow | ( | ) |
Datei ver?ffentlichen
Definiert in Zeile 585 der Datei FileAction.class.php.
Benutzt Action::addNotice().
00586 { 00587 $this->file->publish(); 00588 $this->file->publish->close(); 00589 $this->addNotice('file',$this->file->fullFilename,'PUBLISHED'.($this->file->publish->ok?'':'_ERROR'),$this->file->publish->ok,array(),$this->file->publish->log); 00590 00591 $this->callSubaction('pub'); 00592 }
| FileAction::replace | ( | ) |
Ersetzt den Inhalt mit einer anderen Datei
Definiert in Zeile 57 der Datei FileAction.class.php.
Benutzt Action::addNotice().
00058 { 00059 $upload = new Upload(); 00060 00061 $this->file->filename = $upload->filename; 00062 $this->file->extension = $upload->extension; 00063 $this->file->size = $upload->size; 00064 $this->file->save(); 00065 00066 $this->file->value = $upload->value; 00067 $this->file->saveValue(); 00068 $this->file->setTimestamp(); 00069 00070 //$setTemplateVar('tree_refresh',true); 00071 $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok'); 00072 }
| FileAction::resize | ( | ) |
Bildgroesse eines Bildes aendern
Definiert in Zeile 192 der Datei FileAction.class.php.
Benutzt Action::addNotice(), Action::addValidationError(), Action::callSubAction(), Action::getRequestVar(), Action::hasRequestVar(), imageFormat() und lang().
00193 { 00194 $width = intval($this->getRequestVar('width' )); 00195 $height = intval($this->getRequestVar('height' )); 00196 $jpegcompression = $this->getRequestVar('jpeg_compression') ; 00197 $format = $this->getRequestVar('format' ) ; 00198 $factor = $this->getRequestVar('factor' ) ; 00199 00200 if ( $this->getRequestVar('type') == 'input' && 00201 ! $this->hasRequestVar('width' ) && 00202 ! $this->hasRequestVar('height') ) 00203 { 00204 $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' ); 00205 $this->addValidationError('height',''); 00206 $this->callSubAction('size'); 00207 return; 00208 } 00209 00210 if ( $this->hasRequestVar('copy') ) 00211 { 00212 // Datei neu anlegen. 00213 $imageFile = new File($this->file->objectid); 00214 $imageFile->load(); 00215 $imageFile->name = lang('copy_of').' '.$imageFile->name; 00216 $imageFile->desription = lang('copy_of').' '.$imageFile->description; 00217 $imageFile->filename = $imageFile->filename.'_resized_'.time(); 00218 $imageFile->add(); 00219 $imageFile->copyValueFromFile( $this->file->objectid ); 00220 } 00221 else 00222 { 00223 $imageFile = $this->file; 00224 } 00225 00226 if ( $this->getRequestVar('type') == 'factor') 00227 { 00228 $width = 0; 00229 $height = 0; 00230 } 00231 else 00232 { 00233 $factor = 1; 00234 } 00235 00236 $imageFile->write(); 00237 00238 $imageFile->imageResize( intval($width),intval($height),$factor,$this->imageFormat(),$format,$jpegcompression ); 00239 $imageFile->setTimestamp(); 00240 $imageFile->save(); // Um z.B. Groesse abzuspeichern 00241 $imageFile->saveValue(); 00242 00243 $this->addNotice($imageFile->getType(),$imageFile->name,'IMAGE_RESIZED','ok'); 00244 }
| FileAction::saveprop | ( | ) |
Abspeichern der Eigenschaften zu dieser Datei.
Definiert in Zeile 89 der Datei FileAction.class.php.
Benutzt Action::addNotice() und Action::getRequestVar().
00090 { 00091 // Eigenschaften speichern 00092 $this->file->filename = $this->getRequestVar('filename' ); 00093 $this->file->name = $this->getRequestVar('name' ); 00094 $this->file->extension = $this->getRequestVar('extension' ); 00095 $this->file->desc = $this->getRequestVar('description'); 00096 00097 $this->file->save(); 00098 $this->file->setTimestamp(); 00099 $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok'); 00100 }
| FileAction::savevalue | ( | ) |
Definiert in Zeile 75 der Datei FileAction.class.php.
Benutzt Action::addNotice() und Action::getRequestVar().
00076 { 00077 $this->file->value = $this->getRequestVar('value'); 00078 $this->file->saveValue(); 00079 00080 $this->addNotice($this->file->getType(),$this->file->name,'VALUE_SAVED','ok'); 00081 $this->file->setTimestamp(); 00082 }
| FileAction::show | ( | ) |
Anzeigen des Inhaltes, der Inhalt wird samt Header direkt auf die Standardausgabe geschrieben
Definiert in Zeile 107 der Datei FileAction.class.php.
00108 { 00109 // Angabe Content-Type 00110 header('Content-Type: '.$this->file->mimeType() ); 00111 header('X-File-Id: '.$this->file->fileid ); 00112 00113 // Angabe Content-Disposition 00114 // - Bild soll "inline" gezeigt werden 00115 // - Dateiname wird benutzt, wenn der Browser das Bild speichern moechte 00116 header('Content-Disposition: inline; filename='.$this->file->filenameWithExtension() ); 00117 header('Content-Transfer-Encoding: binary' ); 00118 header('Content-Description: '.$this->file->name ); 00119 00120 $this->file->write(); // Bild aus Datenbank laden 00121 00122 // Groesse des Bildes in Bytes 00123 // Der Browser hat so die Moeglichkeit, einen Fortschrittsbalken zu zeigen 00124 header('Content-Length: '.filesize($this->file->tmpfile()) ); 00125 00126 00127 readfile( $this->file->tmpfile() ); 00128 exit; 00129 }
| FileAction::size | ( | ) |
Anzeigen des Inhaltes
Definiert in Zeile 319 der Datei FileAction.class.php.
Benutzt imageFormat(), imageFormats(), Action::setTemplateVar() und Action::setTemplateVars().
00320 { 00321 $this->setTemplateVars( $this->file->getProperties() ); 00322 00323 $format = $this->imageFormat(); 00324 00325 if ( $format != 0 ) 00326 $formats = $this->imageFormats(); 00327 else 00328 $formats = array(); 00329 00330 $sizes = array(); 00331 foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s ) 00332 $sizes[strval($s/100)] = $s.'%'; 00333 00334 $jpeglist = array(); 00335 for ($i=10; $i<=95; $i+=5) 00336 $jpeglist[$i]=$i.'%'; 00337 00338 $this->setTemplateVar('factors' ,$sizes ); 00339 $this->setTemplateVar('jpeglist' ,$jpeglist ); 00340 $this->setTemplateVar('formats' ,$formats ); 00341 $this->setTemplateVar('format' ,$format ); 00342 $this->setTemplateVar('factor' ,1 ); 00343 00344 $this->file->getImageSize(); 00345 $this->setTemplateVar('width' ,$this->file->width ); 00346 $this->setTemplateVar('height',$this->file->height ); 00347 $this->setTemplateVar('type' ,'input' ); 00348 }
| FileAction::uncompress | ( | ) |
| FileAction::upload | ( | ) |
| FileAction::$defaultSubAction = 'show' |
Definiert in Zeile 32 der Datei FileAction.class.php.
| FileAction::$file |
1.5.8