openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 2097f71a80363c153d8cf8cc3cb2405358a707d5
parent 1f30479f5dba7351a3b19d70e7015a62aec75334
Author: Jan Dankert <develop@jandankert.de>
Date:   Thu,  4 Mar 2021 02:24:45 +0100

New: The calculation of the mime types should be done in the generators.

Diffstat:
Mmodules/cms/action/page/PageInfoAction.class.php | 9++++++++-
Mmodules/cms/action/page/PageShowAction.class.php | 7+++----
Mmodules/cms/generator/BaseGenerator.class.php | 8++++++++
Mmodules/cms/generator/FileGenerator.class.php | 16++++++++++++++++
Mmodules/cms/generator/PageGenerator.class.php | 12++++++++++++
Mmodules/cms/generator/ValueGenerator.class.php | 9+++++++++
Mmodules/cms/model/File.class.php | 1+
Mmodules/cms/model/Page.class.php | 3++-
Mmodules/cms/ui/themes/default/html/views/page/info.php | 64+++++++++++++++++++++++++++++++++++++++++++++++++---------------
Mmodules/cms/ui/themes/default/html/views/page/info.tpl.src.xml | 49++++++++++++++++++++++++++++++++++++++++---------
10 files changed, 148 insertions(+), 30 deletions(-)

diff --git a/modules/cms/action/page/PageInfoAction.class.php b/modules/cms/action/page/PageInfoAction.class.php @@ -53,7 +53,14 @@ class PageInfoAction extends PageAction implements Method { $pagecontext->modelId = $modelid; $pageGenerator = new PageGenerator( $pagecontext ); - $filenames[] = $pageGenerator->getPublicFilename(); + $filenames[] = [ + 'filename' => $pageGenerator->getPublicFilename(), + 'mimetype' => $pageGenerator->getMimeType(), + 'modelid' => $modelid, + 'modelname' => $model, + 'languageid' => $languageid, + 'languagename'=> $language, + ]; } $this->setTemplateVar('filenames',$filenames ); diff --git a/modules/cms/action/page/PageShowAction.class.php b/modules/cms/action/page/PageShowAction.class.php @@ -20,10 +20,6 @@ class PageShowAction extends PageAction implements Method { $this->page->load(); - $project = $this->page->getProject(); - - header('Content-Type: '.$this->page->mimeType().'; charset=UTF-8' ); - // HTTP-Header mit Sprachinformation setzen. $language = new Language( $this->page->languageid); $language->load(); @@ -34,6 +30,9 @@ class PageShowAction extends PageAction implements Method { $pageContext = $this->createPageContext( Producer::SCHEME_PREVIEW); $generator = new PageGenerator( $pageContext ); + header('Content-Type: '.$generator->getMimeType().'; charset=UTF-8' ); + + $template = new Template( $this->page->templateid ); $templateModel = $template->loadTemplateModelFor( $pageContext->modelId ); $templateModel->load(); diff --git a/modules/cms/generator/BaseGenerator.class.php b/modules/cms/generator/BaseGenerator.class.php @@ -38,4 +38,12 @@ abstract class BaseGenerator implements Generator * @return mixed */ protected abstract function generate(); + + + /** + * Calculates the MIME-Type + * + * @return string + */ + public abstract function getMimeType(); } \ No newline at end of file diff --git a/modules/cms/generator/FileGenerator.class.php b/modules/cms/generator/FileGenerator.class.php @@ -105,4 +105,20 @@ class FileGenerator extends BaseGenerator } + + /** + * Calculates the MIME type of this file. + * + * @return string + */ + public function getMimeType() + { + $file = new File( $this->context->sourceObjectId ); + $file->load(); + $ext = strtolower( $file->getRealExtension() ); + + $mimeType = File::getMimeType( $ext ); + + return( $mimeType ); + } } \ No newline at end of file diff --git a/modules/cms/generator/PageGenerator.class.php b/modules/cms/generator/PageGenerator.class.php @@ -249,4 +249,16 @@ class PageGenerator extends BaseGenerator return $page->path().'/'.$format; } + + + + public function getMimeType() + { + $page = new Page( $this->context->sourceObjectId ); + $page->load(); + $templateModel = new TemplateModel( $page->templateid,$this->context->modelId ); + $templateModel->load(); + + return $templateModel->mimeType(); + } } \ No newline at end of file diff --git a/modules/cms/generator/ValueGenerator.class.php b/modules/cms/generator/ValueGenerator.class.php @@ -1066,4 +1066,13 @@ class ValueGenerator extends BaseGenerator { return null; } + + + /** + * @return string always blank + */ + public function getMimeType() + { + return ''; // Values does not have a mime type. + } } \ No newline at end of file diff --git a/modules/cms/model/File.class.php b/modules/cms/model/File.class.php @@ -382,6 +382,7 @@ class File extends BaseObject * Ermittelt den Mime-Type zu dieser Datei * * @return String Mime-Type + * @deprecated use FileGenerator for this. */ public function mimeType() { diff --git a/modules/cms/model/Page.class.php b/modules/cms/model/Page.class.php @@ -346,7 +346,8 @@ SQL /** * Ermittelt den Mime-Type zu dieser Seite * - * @return String Mime-Type + * @return String Mime-Type + * @deprecated this is model-dependant! Use the same method in PageGenerator. */ function mimeType() { diff --git a/modules/cms/ui/themes/default/html/views/page/info.php b/modules/cms/ui/themes/default/html/views/page/info.php @@ -55,6 +55,55 @@ </div> </section> <?php } ?> + <section class="<?php echo O::escapeHtml('or-group or-collapsible or-collapsible--is-open or-collapsible--show') ?>"><?php echo O::escapeHtml('') ?> + <h2 class="<?php echo O::escapeHtml('or-collapsible-title or-group-title or-collapsible-act-switch') ?>"><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-closed or-collapsible--on-closed') ?>"><?php echo O::escapeHtml('') ?></i> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-open or-collapsible--on-open') ?>"><?php echo O::escapeHtml('') ?></i> + <span><?php echo O::escapeHtml(''.@O::lang('filename').'') ?></span> + </h2> + <div class="<?php echo O::escapeHtml('or-collapsible-value or-group-value') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-wrapper') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-area') ?>"><?php echo O::escapeHtml('') ?> + <table width="<?php echo O::escapeHtml('100%') ?>" class="<?php echo O::escapeHtml('or-table') ?>"><?php echo O::escapeHtml('') ?> + <tr class="<?php echo O::escapeHtml('or-table-header') ?>"><?php echo O::escapeHtml('') ?> + <td><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('language').'') ?></span> + </td> + <td><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('model').'') ?></span> + </td> + <td><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('filename').'') ?></span> + </td> + <td><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('file_mimetype').'') ?></span> + </td> + </tr> + <?php foreach((array)@$filenames as $list_key=>$list_value) { extract($list_value); ?> + <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> + <td><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('language') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml(''.@$languageid.'') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/language/'.@$languageid.'') ?>" class="<?php echo O::escapeHtml('or-link or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@$languagename.'') ?></span> + </a> + </td> + <td><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('model') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml(''.@$modelid.'') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/model/'.@$modelid.'') ?>" class="<?php echo O::escapeHtml('or-link or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@$modelname.'') ?></span> + </a> + </td> + <td><?php echo O::escapeHtml('') ?> + <span class="<?php echo O::escapeHtml('or-filename') ?>"><?php echo O::escapeHtml(''.@$filename.'') ?></span> + </td> + <td><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(' ( '.@$mimetype.' )') ?></span> + </td> + </tr> + <?php } ?> + </table> + </div> + </div> + </div> + </section> <section class="<?php echo O::escapeHtml('or-group or-collapsible or-collapsible--is-closed or-collapsible--show') ?>"><?php echo O::escapeHtml('') ?> <h2 class="<?php echo O::escapeHtml('or-collapsible-title or-group-title or-collapsible-act-switch') ?>"><?php echo O::escapeHtml('') ?> <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-closed or-collapsible--on-closed') ?>"><?php echo O::escapeHtml('') ?></i> @@ -65,21 +114,6 @@ <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('full_filename').'') ?></h3> <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> - <span class="<?php echo O::escapeHtml('or-filename') ?>"><?php echo O::escapeHtml(''.@$full_filename.'') ?></span> - </div> - </section> - <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> - <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('full_filename').'') ?></h3> - <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> - <?php foreach((array)@$filenames as $list_key=>$filename) { ?> - <span class="<?php echo O::escapeHtml('or-filename') ?>"><?php echo O::escapeHtml(''.@$filename.'') ?></span> - <br /><?php echo O::escapeHtml('') ?> - <?php } ?> - </div> - </section> - <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> - <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('full_filename').'') ?></h3> - <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> <span class="<?php echo O::escapeHtml('or-filename') ?>"><?php echo O::escapeHtml(''.@$tmp_filename.'') ?></span> </div> </section> diff --git a/modules/cms/ui/themes/default/html/views/page/info.tpl.src.xml b/modules/cms/ui/themes/default/html/views/page/info.tpl.src.xml @@ -32,17 +32,48 @@ </fieldset> </group> </list> - <group title="${message:additional_info}" open="false"> - <fieldset label="${message:full_filename}"> - <text value="${full_filename}" class="filename"/> - </fieldset> - - <fieldset label="${message:full_filename}"> - <list list="${filenames}" value="filename"> + <group title="${message:filename}" open="true"> + <table filter="false"> + <row header="true"> + <column> + <text value="${message:language}" /> + </column> + <column> + <text value="${message:model}" /> + </column> + <column> + <text value="${message:filename}" /> + </column> + <column> + <text value="${message:file_mimetype}" /> + </column> + </row> + <list list="${filenames}" extract="true"> + <row class="data"> + <column> + <link type="open" id="${languageid}" action="language" clickable="true"> + <text value="${languagename}" /> + </link> + </column> + <column> + <link type="open" id="${modelid}" action="model" clickable="true"> + <text value="${modelname}" /> + </link> + </column> + <column> <text value="${filename}" class="filename"/> - <newline /> + </column> + <column> + <text value=" ( ${mimetype} )" /> + </column> + </row> </list> - </fieldset> + + </table> + </group> + + <group title="${message:additional_info}" open="false"> + <fieldset label="${message:full_filename}"> <text value="${tmp_filename}" class="filename"/> </fieldset>