commit 22a87c97bb99dfe64692d70f9163d8d387e1f853
parent f1f29bce6d61ba21e41f82bad5e02fa1173701af
Author: Jan Dankert <devnull@localhost>
Date: Sat, 22 Sep 2012 05:56:43 +0200
Fix: Bildgröße ändern.
Diffstat:
4 files changed, 170 insertions(+), 84 deletions(-)
diff --git a/action/FileAction.class.php b/action/FileAction.class.php
@@ -237,55 +237,98 @@ class FileAction extends ObjectAction
return $formats2;
}
+
+
+ /**
+ * Anzeigen des Inhaltes
+ */
+ function sizeView()
+ {
+ $this->setTemplateVars( $this->file->getProperties() );
+
+ $format = $this->imageFormat();
+
+ if ( $format == 0 )
+ {
+ $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',OR_NOTICE_WARN);
+ }
+
+ $formats = $this->imageFormats();
+
+ if ( empty($formats) )
+ $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',OR_NOTICE_WARN);
+
+ $sizes = array();
+ foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s )
+ $sizes[strval($s/100)] = $s.'%';
+
+ $jpeglist = array();
+ for ($i=10; $i<=95; $i+=5)
+ $jpeglist[$i]=$i.'%';
+
+ $this->setTemplateVar('factors' ,$sizes );
+ $this->setTemplateVar('jpeglist' ,$jpeglist );
+ $this->setTemplateVar('formats' ,$formats );
+ $this->setTemplateVar('format' ,$format );
+ $this->setTemplateVar('factor' ,1 );
+
+ $this->file->getImageSize();
+ $this->setTemplateVar('width' ,$this->file->width );
+ $this->setTemplateVar('height',$this->file->height );
+ $this->setTemplateVar('type' ,'input' );
+ }
+
+
+
/**
* Bildgroesse eines Bildes aendern
*/
- function resize()
+ public function sizePost()
{
$width = intval($this->getRequestVar('width' ));
$height = intval($this->getRequestVar('height' ));
$jpegcompression = $this->getRequestVar('jpeg_compression') ;
$format = $this->getRequestVar('format' ) ;
- $factor = $this->getRequestVar('factor' ) ;
-
- if ( $this->getRequestVar('type') == 'input' &&
- ! $this->hasRequestVar('width' ) &&
- ! $this->hasRequestVar('height') )
- {
- $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' );
- $this->addValidationError('height','');
- $this->callSubAction('size');
- return;
+ $factor = $this->getRequestVar('factor' ) ;
+
+ if ( $this->getRequestVar('type') == 'input' &&
+ ! $this->hasRequestVar('width' ) &&
+ ! $this->hasRequestVar('height') )
+ {
+ $this->addValidationError('width','INPUT_NEW_IMAGE_SIZE' );
+ $this->addValidationError('height','');
+ $this->callSubAction('size');
+ return;
}
-
- if ( $this->hasRequestVar('copy') )
- {
- // Datei neu anlegen.
- $imageFile = new File($this->file->objectid);
- $imageFile->load();
- $imageFile->name = lang('copy_of').' '.$imageFile->name;
- $imageFile->desription = lang('copy_of').' '.$imageFile->description;
- $imageFile->filename = $imageFile->filename.'_resized_'.time();
- $imageFile->add();
- $imageFile->copyValueFromFile( $this->file->objectid );
- }
- else
- {
- $imageFile = $this->file;
- }
-
- if ( $this->getRequestVar('type') == 'factor')
- {
- $width = 0;
- $height = 0;
- }
- else
- {
- $factor = 1;
- }
-
- $imageFile->write();
+
+ if ( $this->hasRequestVar('copy') )
+ {
+ // Datei neu anlegen.
+ $imageFile = new File($this->file->objectid);
+ $imageFile->load();
+ $imageFile->name = lang('copy_of').' '.$imageFile->name;
+ $imageFile->desription = lang('copy_of').' '.$imageFile->description;
+ $imageFile->filename = $imageFile->filename.'_resized_'.time();
+ $imageFile->add();
+ $imageFile->copyValueFromFile( $this->file->objectid );
+ }
+ else
+ {
+ $imageFile = $this->file;
+ }
+
+ if ( $this->getRequestVar('type') == 'factor')
+ {
+ $width = 0;
+ $height = 0;
+ }
+ else
+ {
+ $factor = 1;
+ }
+
+ $imageFile->write();
$imageFile->imageResize( intval($width),intval($height),$factor,$this->imageFormat(),$format,$jpegcompression );
$imageFile->setTimestamp();
@@ -406,46 +449,6 @@ class FileAction extends ObjectAction
/**
* Anzeigen des Inhaltes
*/
- function size()
- {
- $this->setTemplateVars( $this->file->getProperties() );
-
- $format = $this->imageFormat();
-
- if ( $format == 0 )
- {
- $this->addNotice( 'image','','IMAGE_RESIZING_UNKNOWN_TYPE',OR_NOTICE_WARN);
- }
-
- $formats = $this->imageFormats();
-
- if ( empty($formats) )
- $this->addNotice( 'image','','IMAGE_RESIZING_NOT_AVAILABLE',OR_NOTICE_WARN);
-
- $sizes = array();
- foreach( array(10,25,50,75,100,125,150,175,200,250,300,350,400,500,600,800) as $s )
- $sizes[strval($s/100)] = $s.'%';
-
- $jpeglist = array();
- for ($i=10; $i<=95; $i+=5)
- $jpeglist[$i]=$i.'%';
-
- $this->setTemplateVar('factors' ,$sizes );
- $this->setTemplateVar('jpeglist' ,$jpeglist );
- $this->setTemplateVar('formats' ,$formats );
- $this->setTemplateVar('format' ,$format );
- $this->setTemplateVar('factor' ,1 );
-
- $this->file->getImageSize();
- $this->setTemplateVar('width' ,$this->file->width );
- $this->setTemplateVar('height',$this->file->height );
- $this->setTemplateVar('type' ,'input' );
- }
-
-
- /**
- * Anzeigen des Inhaltes
- */
function extractView()
{
$this->setTemplateVars( $this->file->getProperties() );
diff --git a/action/FileAction.ini.php b/action/FileAction.ini.php
@@ -32,7 +32,6 @@ goto=prop
[size]
menu=prop
-target=resize
editable=true
[remove]
diff --git a/themes/default/templates/file/prop.tpl.src.xml b/themes/default/templates/file/prop.tpl.src.xml
@@ -1,5 +1,6 @@
<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openrat.de/template ../template.xsd">
+ <header views="size,compress,uncompress,extract"></header>
<form>
<fieldset>
<part class="line">
diff --git a/themes/default/templates/file/size.tpl.src.xml b/themes/default/templates/file/size.tpl.src.xml
@@ -1,3 +1,86 @@
-<output xmlns="http://www.openrat.de/template"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"><dummy><form><window width="70%" widths="5%,40%,55%"><row><cell colspan="2"><text text="IMAGE_OLD_SIZE"></text></cell><cell><text var="width"></text><text raw="_*_"></text><text var="height"></text></cell></row><if not="" empty="formats"><if true="mode:edit"><row><cell colspan="3"><fieldset title="message:IMAGE_NEW_SIZE"></fieldset></cell></row><row><cell><radio name="type" value="factor"></radio></cell><cell><label for="type_factor"><text text="FILE_IMAGE_SIZE_FACTOR"></text></label></cell><cell><selectbox name="factor" list="factors"></selectbox><set var="factor" value="1"></set></cell></row><row><cell><radio name="type" value="input"></radio></cell><cell><label for="type_input"><text text="FILE_IMAGE_NEW_WIDTH_HEIGHT"></text></label></cell><cell><input name="width" size="10"></input><text raw="_*_"></text><input name="height" size="10"></input></cell></row><row><cell colspan="3"><fieldset title="message:options"></fieldset></cell></row><row><cell colspan="2"><label for="format"><text text="FILE_IMAGE_FORMAT"></text></label></cell><cell><selectbox name="format" list="formats"></selectbox></cell></row><row><cell colspan="2"><label for="jpeglist_compression"><text text="FILE_IMAGE_JPEG_COMPRESSION"></text></label></cell><cell><set var="jpeg_compression" value="70"></set><selectbox list="jpeglist" name="jpeg_compression"></selectbox></cell></row><row><cell colspan="3"><checkbox name="copy"></checkbox><label for="copy"><text key="copy"></text></label></cell></row></if><row><cell class="act" colspan="3"><button type="ok"></button></cell></row></if></window><focus field="width"></focus></form></dummy></output>-
\ No newline at end of file
+<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.openrat.de/template ../template.xsd">
+ <form>
+ <row>
+ <cell colspan="2">
+ <text text="IMAGE_OLD_SIZE"></text>
+ </cell>
+ <cell>
+ <text var="width"></text>
+ <text raw="_*_"></text>
+ <text var="height"></text>
+ </cell>
+ </row>
+ <if not="" empty="formats">
+ <row>
+ <cell colspan="3">
+ <fieldset title="message:IMAGE_NEW_SIZE"></fieldset>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <radio name="type" value="factor"></radio>
+ </cell>
+ <cell>
+ <label for="type_factor">
+ <text text="FILE_IMAGE_SIZE_FACTOR"></text>
+ </label>
+ </cell>
+ <cell>
+ <selectbox name="factor" list="factors"></selectbox>
+ <set var="factor" value="1"></set>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <radio name="type" value="input"></radio>
+ </cell>
+ <cell>
+ <label for="type_input">
+ <text text="FILE_IMAGE_NEW_WIDTH_HEIGHT"></text>
+ </label>
+ </cell>
+ <cell>
+ <input name="width" size="10"></input>
+ <text raw="_*_"></text>
+ <input name="height" size="10"></input>
+ </cell>
+ </row>
+ <row>
+ <cell colspan="3">
+ <fieldset title="message:options"></fieldset>
+ </cell>
+ </row>
+ <row>
+ <cell colspan="2">
+ <label for="format">
+ <text text="FILE_IMAGE_FORMAT"></text>
+ </label>
+ </cell>
+ <cell>
+ <selectbox name="format" list="formats"></selectbox>
+ </cell>
+ </row>
+ <row>
+ <cell colspan="2">
+ <label for="jpeglist_compression">
+ <text text="FILE_IMAGE_JPEG_COMPRESSION"></text>
+ </label>
+ </cell>
+ <cell>
+ <set var="jpeg_compression" value="70"></set>
+ <selectbox list="jpeglist" name="jpeg_compression"></selectbox>
+ </cell>
+ </row>
+ <row>
+ <cell colspan="3">
+ <checkbox name="copy"></checkbox>
+ <label for="copy">
+ <text key="copy"></text>
+ </label>
+ </cell>
+ </row>
+ </if>
+ <focus field="width"></focus>
+ </form>
+</output>+
\ No newline at end of file