openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 55a1ab60d575d4b4cb0e7c90465c43308bd62624
parent c4e86c71326b5d66e534ab9fab5d1d0e5ac5fcd6
Author: Jan Dankert <devnull@localhost>
Date:   Thu, 29 Nov 2018 00:19:56 +0100

Filtern von Text-Objekten; Bugfix beim Anlegen von Bildern/Texten.

Diffstat:
modules/cms-core/action/FolderAction.class.php | 3+--
modules/cms-core/action/TextAction.class.php | 4++++
modules/cms-core/model/File.class.php | 76+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
modules/cms-core/model/Folder.class.php | 2+-
modules/cms-core/model/Image.class.php | 7++++---
modules/cms-core/model/Text.class.php | 8+++++---
modules/cms-ui/themes/default/html/views/file/edit.php | 2+-
modules/cms-ui/themes/default/html/views/file/value.php | 6+++---
modules/cms-ui/themes/default/html/views/folder/createimage.php | 0
modules/cms-ui/themes/default/html/views/folder/createimage.tpl.src.xml | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms-ui/themes/default/html/views/folder/createtext.php | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms-ui/themes/default/html/views/folder/createtext.tpl.src.xml | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms-ui/themes/default/html/views/project/prop.php | 10+++++-----
modules/cms-ui/themes/default/html/views/text/value.php | 26++++++++++++++++++++++++++
14 files changed, 322 insertions(+), 23 deletions(-)

diff --git a/modules/cms-core/action/FolderAction.class.php b/modules/cms-core/action/FolderAction.class.php @@ -245,9 +245,7 @@ class FolderAction extends ObjectAction public function createtextPost() { - $type = $this->getRequestVar('type' ); $name = $this->getRequestVar('name' ); - $filename = $this->getRequestVar('filename' ); $description = $this->getRequestVar('description'); $text = new Text(); @@ -300,6 +298,7 @@ class FolderAction extends ObjectAction $text->desc = $this->getRequestVar('description'); $text->filename = BaseObject::urlify( $name ); $text->parentid = $this->folder->objectid; + $text->projectid = $this->folder->projectid; } else { diff --git a/modules/cms-core/action/TextAction.class.php b/modules/cms-core/action/TextAction.class.php @@ -131,5 +131,9 @@ namespace cms\action } + public function valueView() + { + parent::valueView(); + } } } diff --git a/modules/cms-core/model/File.class.php b/modules/cms-core/model/File.class.php @@ -19,6 +19,10 @@ namespace cms\model; // Standard Mime-Type +use JSqueeze; +use Less_Parser; +use Logger; + define('OR_FILE_DEFAULT_MIMETYPE','application/octet-stream'); @@ -37,7 +41,12 @@ class File extends BaseObject var $extension = ''; var $log_filenames = array(); var $fullFilename = ''; + + /** + * @var \Publish + */ var $publish = null; + var $mime_type = ''; var $tmpfile; @@ -92,8 +101,9 @@ class File extends BaseObject } else { - if ( !empty($this->extension) ) - $filename .= '.'.$this->extension; + // Nein, wurde bereits in filename() ergänzt. + //if ( !empty($this->extension) ) + // $filename .= '.'.$this->extension; } $this->fullFilename = $filename; @@ -442,12 +452,14 @@ EOF } - function publish() + public function publish() { - if ( ! is_object($this->publish) ) + + if ( ! is_object($this->publish) ) $this->publish = new \Publish( $this->projectid ); $this->write(); + $this->filterValue(); $this->publish->copy( $this->tmpfile(),$this->full_filename(),$this->lastchangeDate ); $this->publish->publishedObjects[] = $this->getProperties(); @@ -457,7 +469,7 @@ EOF /** * Ermittelt einen tempor�ren Dateinamen f�r diese Datei. */ - function tmpfile() + public function tmpfile() { if ( $this->tmpfile == '' ) { @@ -505,6 +517,60 @@ EOF return substr($this->filename,$pos+1); } } + + private function filterValue() + { + $settings = $this->getTotalSettings(); + if ( isset( $settings['filter']) && is_array( $settings['filter'] ) ) + { + foreach( $settings['filter'] as $filterName ) + { + switch( $filterName) + { + case 'less': + + $parser = new Less_Parser(array( + 'sourceMap' => false, + 'indentation' => ' ', + 'outputSourceFiles' => false, + //'sourceMapBasepath' => $this->filename() + //'sourceMapBasepath' => './' + )); + + $parser->parse( $this->value ); + $this->value = $parser->getCss(); + + break; + + case 'less-minifier': + + $parser = new Less_Parser(array( + 'compress' => true, + 'sourceMap' => false, + 'indentation' => '' + )); + + $parser->parse( $this->value ); + $this->value = $parser->getCss(); + + break; + + case "js-minifier": + $jz = new JSqueeze(); + $this->value = $jz->squeeze( $this->value); + break; + + default: + Logger::warn("Filter not found: ".$filterName); + } + } + + // Store in cache. + $f = fopen( $this->tmpfile(),'w' ); + fwrite( $f,$this->value ); + fclose( $f ); + } + } } ?> \ No newline at end of file diff --git a/modules/cms-core/model/Folder.class.php b/modules/cms-core/model/Folder.class.php @@ -41,7 +41,7 @@ class Folder extends BaseObject function __construct( $objectid='' ) { parent::__construct( $objectid ); - $this->isFolder = true; + $this->isImage = true; } diff --git a/modules/cms-core/model/Image.class.php b/modules/cms-core/model/Image.class.php @@ -27,8 +27,6 @@ namespace cms\model; */ class Image extends File { - var $fileid; - /** * Breite eines Bildes. Ist nur verfuegbar, wenn vorher * #getImageSize() aufgerufen wurde. @@ -50,7 +48,10 @@ class Image extends File function __construct( $objectid='' ) { parent::__construct($objectid); - } + + $this->isImage = true; + $this->isFile = false; + } diff --git a/modules/cms-core/model/Text.class.php b/modules/cms-core/model/Text.class.php @@ -26,8 +26,6 @@ namespace cms\model; */ class Text extends File { - - /** * Konstruktor * @@ -35,7 +33,11 @@ class Text extends File */ function __construct( $objectid='' ) { - parent::__construct( $objectid ); + + parent::__construct( $objectid ); + + $this->isText = true; + $this->isFile = false; } } diff --git a/modules/cms-ui/themes/default/html/views/file/edit.php b/modules/cms-ui/themes/default/html/views/file/edit.php @@ -9,7 +9,7 @@ <div class="input"> <br/> - <input size="40" id="req1543442927474481529_file" type="file" name="file" class="upload" /> + <input size="40" id="req15434469071543274202_file" type="file" name="file" class="upload" /> <br/> diff --git a/modules/cms-ui/themes/default/html/views/file/value.php b/modules/cms-ui/themes/default/html/views/file/value.php @@ -1,6 +1,6 @@ - <form name="" target="_self" data-target="view" action="./" data-method="value" data-action="file" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="or-form file" data-async="" data-autosave=""><input type="submit" class="invisible" /><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="file" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="value" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="value" data-action="file" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="or-form file" data-async="" data-autosave=""><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="file" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="value" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <tr> <td> @@ -8,7 +8,7 @@ </td> <td> - <textarea name="value" data-extension="" data-mimetype="" data-mode="htmlmixed" class="editor code-editor"><?php echo ${'value'} ?></textarea> + <textarea name="<?php if ('') echo ''.'_' ?>value<?php if ('') echo '_disabled' ?>" data-extension="" data-mimetype="" data-mode="htmlmixed" class="editor code-editor"><?php echo ${'value'} ?></textarea> </td> </tr> @@ -21,7 +21,7 @@ </td> </tr> - <div class="bottom"><div class="command "><input type="submit" class="submit ok" value="OK" /></div></div></form> + <div class="or-form-actionbar"><input type="submit" class="or-form-btn or-form-btn--primary" value="OK" /></div></form> \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/folder/createimage.php b/modules/cms-ui/themes/default/html/views/folder/createimage.php diff --git a/modules/cms-ui/themes/default/html/views/folder/createimage.tpl.src.xml b/modules/cms-ui/themes/default/html/views/folder/createimage.tpl.src.xml @@ -0,0 +1,65 @@ +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openrat.de/template ../../../../../../template-engine/components/template.xsd"> + <header back="true"></header> + <form enctype="multipart/form-data" target="upload" type="upload" visible="true"> + <hidden name="type" default="file"></hidden> + <part class="line"> + <part class="label"> + <label for="name"> + <text text="global_FILE"></text> + </label> + </part> + <part class="input"> + <upload name="file" maxlength="var:maxlength" multiple="true"></upload> + </part> + </part> + + <part class="line filedropzone"> + <part class="label"> + </part> + <part class="input"> + </part> + </part> + + <part class="line"> + <part class="label"> + <text class="help" key="file_max_size"></text> + </part> + <part class="input"> + <text var="max_size"></text> + </part> + </part> + + <part class="line"> + <part class="label"> + <text key="HTTP_URL"></text> + </part> + <part class="input"> + <input name="url" size="50"></input> + </part> + </part> + <group title="message:description"></group> + + + <part class="line"> + <part class="label"> + <text text="global_NAME"></text> + </part> + <part class="input"> + <input name="name" size="50"></input> + </part> + </part> + + + <part class="line"> + <part class="label"> + <text text="global_DESCRIPTION"></text> + </part> + <part class="input"> + <inputarea rows="5" cols="50" name="description" default=""></inputarea> + </part> + </part> + + </form> + <focus field="name"></focus> +</output>+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/folder/createtext.php b/modules/cms-ui/themes/default/html/views/folder/createtext.php @@ -0,0 +1,69 @@ + + + + + <form name="" target="_self" data-target="view" action="./" data-method="createtext" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="or-form folder" data-async="" data-autosave=""><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="folder" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="createtext" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <div class="line"> + <div class="label"> + <label for="<?php echo REQUEST_ID ?>_name" class="label"> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_FILE')))); ?></span> + + </label> + </div> + <div class="input"> + <input size="40" id="req1543446099710444863_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" /> + + </div> + </div> + <div class="line filedropzone"> + <div class="label"> + </div> + <div class="input"> + </div> + </div> + <div class="line"> + <div class="label"> + <span class="help"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'file_max_size'.'')))); ?></span> + + </div> + <div class="input"> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities($max_size))); ?></span> + + </div> + </div> + <div class="line"> + <div class="label"> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'HTTP_URL'.'')))); ?></span> + + </div> + <div class="input"> + <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_url" name="<?php if ('') echo ''.'_' ?>url<?php if ('') echo '_disabled' ?>" type="text" maxlength="256" class="" value="<?php echo Text::encodeHtml(@$url) ?>" /><?php if ('') { ?><input type="hidden" name="url" value="<?php $url ?>"/><?php } ?></div> + + </div> + </div> + <fieldset class="toggle-open-close<?php echo '1'?" open":" closed" ?><?php echo '1'?" show":"" ?>"><legend class="on-click-open-close"><div class="arrow arrow-right on-closed"></div><div class="arrow arrow-down on-open"></div><?php echo lang('description') ?></legend><div> + </div></fieldset> + <div class="line"> + <div class="label"> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_NAME')))); ?></span> + + </div> + <div class="input"> + <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_name" name="<?php if ('') echo ''.'_' ?>name<?php if ('') echo '_disabled' ?>" type="text" maxlength="256" class="" value="<?php echo Text::encodeHtml(@$name) ?>" /><?php if ('') { ?><input type="hidden" name="name" value="<?php $name ?>"/><?php } ?></div> + + </div> + </div> + <div class="line"> + <div class="label"> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_DESCRIPTION')))); ?></span> + + </div> + <div class="input"> + <div class="inputholder"><textarea class="inputarea" name="<?php if ('') echo ''.'_' ?>description<?php if ('') echo '_disabled' ?>"><?php echo Text::encodeHtml('') ?></textarea></div> + + </div> + </div> + <div class="or-form-actionbar"><input type="submit" class="or-form-btn or-form-btn--primary" value="OK" /></div></form> + + + + \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/folder/createtext.tpl.src.xml b/modules/cms-ui/themes/default/html/views/folder/createtext.tpl.src.xml @@ -0,0 +1,64 @@ +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openrat.de/template ../../../../../../template-engine/components/template.xsd"> + <header back="true"></header> + <form> + <part class="line"> + <part class="label"> + <label for="name"> + <text text="global_FILE"></text> + </label> + </part> + <part class="input"> + <upload name="file" maxlength="var:maxlength" multiple="true"></upload> + </part> + </part> + + <part class="line filedropzone"> + <part class="label"> + </part> + <part class="input"> + </part> + </part> + + <part class="line"> + <part class="label"> + <text class="help" key="file_max_size"></text> + </part> + <part class="input"> + <text var="max_size"></text> + </part> + </part> + + <part class="line"> + <part class="label"> + <text key="HTTP_URL"></text> + </part> + <part class="input"> + <input name="url" size="50"></input> + </part> + </part> + <group title="message:description"></group> + + + <part class="line"> + <part class="label"> + <text text="global_NAME"></text> + </part> + <part class="input"> + <input name="name" size="50"></input> + </part> + </part> + + + <part class="line"> + <part class="label"> + <text text="global_DESCRIPTION"></text> + </part> + <part class="input"> + <inputarea rows="5" cols="50" name="description" default=""></inputarea> + </part> + </part> + + </form> + <focus field="name"></focus> +</output>+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/project/prop.php b/modules/cms-ui/themes/default/html/views/project/prop.php @@ -10,7 +10,7 @@ </label> </div> <div class="input"> - <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_name" name="name<?php if ('') echo '_disabled' ?>" type="text" maxlength="128" class="name" value="<?php echo Text::encodeHtml(@$name) ?>" /><?php if ('') { ?><input type="hidden" name="name" value="<?php $name ?>"/><?php } ?></div> + <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_name" name="<?php if ('') echo ''.'_' ?>name<?php if ('') echo '_disabled' ?>" type="text" maxlength="128" class="name" value="<?php echo Text::encodeHtml(@$name) ?>" /><?php if ('') { ?><input type="hidden" name="name" value="<?php $name ?>"/><?php } ?></div> </div> </div> @@ -20,7 +20,7 @@ </label> </div> <div class="input"> - <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_url" name="url<?php if ('') echo '_disabled' ?>" type="text" maxlength="255" class="text" value="<?php echo Text::encodeHtml(@$url) ?>" /><?php if ('') { ?><input type="hidden" name="url" value="<?php $url ?>"/><?php } ?></div> + <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_url" name="<?php if ('') echo ''.'_' ?>url<?php if ('') echo '_disabled' ?>" type="text" maxlength="255" class="" value="<?php echo Text::encodeHtml(@$url) ?>" /><?php if ('') { ?><input type="hidden" name="url" value="<?php $url ?>"/><?php } ?></div> </div> </div> @@ -32,7 +32,7 @@ </label> </div> <div class="input"> - <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_target_dir" name="target_dir<?php if ('') echo '_disabled' ?>" type="text" maxlength="255" class="filename" value="<?php echo Text::encodeHtml(@$target_dir) ?>" /><?php if ('') { ?><input type="hidden" name="target_dir" value="<?php $target_dir ?>"/><?php } ?></div> + <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_target_dir" name="<?php if ('') echo ''.'_' ?>target_dir<?php if ('') echo '_disabled' ?>" type="text" maxlength="255" class="filename" value="<?php echo Text::encodeHtml(@$target_dir) ?>" /><?php if ('') { ?><input type="hidden" name="target_dir" value="<?php $target_dir ?>"/><?php } ?></div> </div> </div> @@ -42,7 +42,7 @@ </label> </div> <div class="input"> - <div class="inputholder"><input<?php if (!config('publish','project','override_system_command')) echo ' disabled="true"' ?> id="<?php echo REQUEST_ID ?>_cmd_after_publish" name="cmd_after_publish<?php if (!config('publish','project','override_system_command')) echo '_disabled' ?>" type="text" maxlength="255" class="filename" value="<?php echo Text::encodeHtml(@$cmd_after_publish) ?>" /><?php if (!config('publish','project','override_system_command')) { ?><input type="hidden" name="cmd_after_publish" value="<?php $cmd_after_publish ?>"/><?php } ?></div> + <div class="inputholder"><input<?php if (!config('publish','project','override_system_command')) echo ' disabled="true"' ?> id="<?php echo REQUEST_ID ?>_cmd_after_publish" name="<?php if ('') echo ''.'_' ?>cmd_after_publish<?php if (!config('publish','project','override_system_command')) echo '_disabled' ?>" type="text" maxlength="255" class="filename" value="<?php echo Text::encodeHtml(@$cmd_after_publish) ?>" /><?php if (!config('publish','project','override_system_command')) { ?><input type="hidden" name="cmd_after_publish" value="<?php $cmd_after_publish ?>"/><?php } ?></div> </div> </div> @@ -98,7 +98,7 @@ </label> </div> <div class="input"> - <div class="inputholder"><input<?php if (!config('publish','ftp','enable')) echo ' disabled="true"' ?> id="<?php echo REQUEST_ID ?>_ftp_url" name="ftp_url<?php if (!config('publish','ftp','enable')) echo '_disabled' ?>" type="text" maxlength="256" class="filename" value="<?php echo Text::encodeHtml(@$ftp_url) ?>" /><?php if (!config('publish','ftp','enable')) { ?><input type="hidden" name="ftp_url" value="<?php $ftp_url ?>"/><?php } ?></div> + <div class="inputholder"><input<?php if (!config('publish','ftp','enable')) echo ' disabled="true"' ?> id="<?php echo REQUEST_ID ?>_ftp_url" name="<?php if ('') echo ''.'_' ?>ftp_url<?php if (!config('publish','ftp','enable')) echo '_disabled' ?>" type="text" maxlength="256" class="filename" value="<?php echo Text::encodeHtml(@$ftp_url) ?>" /><?php if (!config('publish','ftp','enable')) { ?><input type="hidden" name="ftp_url" value="<?php $ftp_url ?>"/><?php } ?></div> <br/> diff --git a/modules/cms-ui/themes/default/html/views/text/value.php b/modules/cms-ui/themes/default/html/views/text/value.php @@ -0,0 +1,25 @@ + + + <form name="" target="_self" data-target="view" action="./" data-method="value" data-action="text" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="or-form text" data-async="" data-autosave=""><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="text" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="value" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <tr> + <td> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('GLOBAL_VALUE')))); ?></span> + + </td> + <td> + <textarea name="<?php if ('') echo ''.'_' ?>value<?php if ('') echo '_disabled' ?>" data-extension="<?php echo $extension ?>" data-mimetype="<?php echo $mimetype ?>" data-mode="htmlmixed" class="editor code-editor"><?php echo ${'value'} ?></textarea> + + </td> + </tr> + <tr> + <td colspan="2" class="act"> + <div class="invisible"><input type="submit" name="ok" class="%class%" + title="Bestätigen" + value="&nbsp;&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;&nbsp;" /> + </div> + </td> + </tr> + <div class="or-form-actionbar"><input type="submit" class="or-form-btn or-form-btn--primary" value="OK" /></div></form> + + + + \ No newline at end of file