commit 063a123f3f90f57626cc60fc04b1e8f51cc2e79c
parent 18266c104313461bfdf92f23361674b5547f72da
Author: dankert <devnull@localhost>
Date: Sat, 23 Jan 2010 01:54:41 +0100
Generierung der Dateinamen mit Hilfe eines Formates aus der Konfigurationdatei \"publish.ini.php\"
Diffstat:
2 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/objectClasses/File.class.php b/objectClasses/File.class.php
@@ -42,6 +42,8 @@ class File extends Object
var $height = null;
var $tmpfile;
+
+ var $content_negotiation = false;
@@ -84,8 +86,15 @@ class File extends Object
$filename = parent::full_filename();
- if ( !empty($this->extension) )
- $filename .= '.'.$this->extension;
+ if ( $this->content_negotiation && config('publish','negotiation','file_negotiate_type' ) )
+ {
+ // Link auf Datei: Extension bleibt aufgrund Content-Negotiation leer
+ }
+ else
+ {
+ if ( !empty($this->extension) )
+ $filename .= '.'.$this->extension;
+ }
$this->fullFilename = $filename;
return $filename;
@@ -409,7 +418,7 @@ class File extends Object
/**
* Lesen der Datei aus der Datenbank.
*
- * Es werden nur die Meta-Daten (Erweiterung, Größe) gelesen. Zum Lesen des
+ * Es werden nur die Meta-Daten (Erweiterung, Gr��e) gelesen. Zum Lesen des
* Datei-Inhaltes muss #loadValue() aufgerufen werden.
*/
function load()
@@ -435,7 +444,7 @@ class File extends Object
/**
- * Unwiderrufliches Löschen der Datei aus der Datenbank.
+ * Unwiderrufliches L�schen der Datei aus der Datenbank.
*/
function delete()
{
@@ -605,7 +614,7 @@ EOF
/**
- * Fügt die Datei der Datenbank hinzu.
+ * F�gt die Datei der Datenbank hinzu.
*/
function add()
{
diff --git a/objectClasses/Page.class.php b/objectClasses/Page.class.php
@@ -50,6 +50,7 @@ class Page extends Object
var $cut_index = false;
var $default_language = false;
var $withLanguage = false;
+ var $withModel = false;
var $link = false;
var $fullFilename = '';
@@ -188,6 +189,7 @@ class Page extends Object
$inhalt = $this->up_path();
$f = new File( $objectid );
+ $f->content_negotiation = $content_negotiation;
$f->load();
$inhalt .= $f->full_filename();
break;
@@ -201,6 +203,7 @@ class Page extends Object
$p->cut_index = $cut_index;
$p->content_negotiation = $content_negotiation;
$p->withLanguage = $this->withLanguage;
+ $p->withModel = $this->withModel;
$p->load();
$inhalt .= $p->full_filename();
break;
@@ -499,29 +502,42 @@ class Page extends Object
if ( !empty($filename) )
$filename .= '/';
- if ( !$this->cut_index || $this->filename != config('publish','default') )
+ if ( $this->cut_index && $this->filename == config('publish','default') )
{
- $filename .= $this->filename();
+ // Link auf Index-Datei, der Dateiname bleibt leer.
+ }
+ else
+ {
+ $format = config('publish','format');
+ $format = str_replace('{filename}',$this->filename(),$format );
- if ( !$this->content_negotiation )
+ if ( !$this->withLanguage || $this->content_negotiation && config('publish','negotiation','page_negotiate_language' ) )
+ {
+ $format = str_replace('{language}' ,'',$format );
+ $format = str_replace('{language_sep}','',$format );
+ }
+ else
+ {
+ $l = new Language( $this->languageid );
+ $l->load();
+ $format = str_replace('{language}' ,$l->isoCode ,$format );
+ $format = str_replace('{language_sep}',config('publish','language_sep'),$format );
+ }
+
+ if ( !$this->withModel || $this->content_negotiation && config('publish','negotiation','page_negotiate_type' ) )
+ {
+ $format = str_replace('{type}' ,'',$format );
+ $format = str_replace('{type_sep}','',$format );
+ }
+ else
{
- if ( !$this->default_language && $this->withLanguage )
- {
- $l = new Language( $this->languageid );
- $l->load();
- $filename .= '.'.$l->isoCode;
- }
-
$t = new Template( $this->templateid );
$t->modelid = $this->modelid;
$t->load();
- $filename .= '.'.$t->extension;
-
- if ( $this->default_language && $this->withLanguage )
- {
- $filename .= '.'.$t->extension;
- }
+ $format = str_replace('{type}' ,$t->extension ,$format );
+ $format = str_replace('{type_sep}',config('publish','type_sep'),$format );
}
+ $filename .= $format;
}
$this->fullFilename = $filename;
@@ -753,8 +769,8 @@ class Page extends Object
foreach( $allLanguages as $languageid=>$x )
{
$this->languageid = $languageid;
- $this->withLanguage = count($allLanguages) > 1;
- $this->withModel = count($allModels) > 1;
+ $this->withLanguage = count($allLanguages) > 1 || config('publish','filename_language') == 'always';
+ $this->withModel = count($allModels ) > 1 || config('publish','filename_type' ) == 'always';
// Schleife ueber alle Projektvarianten
foreach( $allModels as $projectmodelid=>$x )