openrat-cms

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

commit 20861a34238a0dee0d2e44be7d97ceda733a0448
parent 72ddd239ea905b2b91b5a5cfd23ebef133364d3c
Author: Jan Dankert <devnull@localhost>
Date:   Mon, 26 Nov 2018 22:04:20 +0100

Eingabefeld für Templatesourcen erhält ein Prefix, da es auch mehrere Eingabefelder pro Variante/Sprache geben kann (nicht hier, aber in anderen Views).

Diffstat:
modules/cms-core/action/TemplateAction.class.php | 42+++++++++++++++++++++++-------------------
modules/cms-ui/themes/default/html/views/file/edit.php | 2+-
modules/cms-ui/themes/default/html/views/folder/createfile.php | 6+++---
modules/cms-ui/themes/default/html/views/folder/createfolder.php | 4++--
modules/cms-ui/themes/default/html/views/folder/createpage.php | 4++--
modules/cms-ui/themes/default/html/views/language/edit.php | 4++--
modules/cms-ui/themes/default/html/views/model/edit.php | 4++--
modules/cms-ui/themes/default/html/views/template/src.php | 2+-
modules/cms-ui/themes/default/html/views/template/src.tpl.src.xml | 2+-
modules/cms-ui/themes/default/html/views/title/show.php | 2+-
modules/template-engine/components/html/FieldComponent.class.php | 28++++++++++++++++++++++++++++
modules/template-engine/components/html/HtmlComponent.class.php | 10++++++++++
modules/template-engine/components/html/editor/Editor.class.php | 20++++++++++----------
modules/template-engine/components/html/input/Input.class.php | 15+++------------
modules/template-engine/components/html/table/Table.class.php | 3+--
modules/template-engine/engine/TemplateEngine.class.php | 4+++-
16 files changed, 93 insertions(+), 59 deletions(-)

diff --git a/modules/cms-core/action/TemplateAction.class.php b/modules/cms-core/action/TemplateAction.class.php @@ -87,26 +87,30 @@ class TemplateAction extends Action foreach( $models as $modelId => $modelName ) { - $templatemodel = new TemplateModel($this->template->templateid, $modelId); - $templatemodel->load(); - - $text = $this->getRequestVar($modelName, 'raw'); - - foreach ($this->template->getElementNames() as $elid => $elname) { - $text = str_replace('{{' . $elname . '}}', '{{' . $elid . '}}', $text); - $text = str_replace('{{->' . $elname . '}}', '{{->' . $elid . '}}', $text); - $text = str_replace('{{' . lang('TEMPLATE_SRC_IFEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_BEGIN') . '}}', '{{IFEMPTY:' . $elid . ':BEGIN}}', $text); - $text = str_replace('{{' . lang('TEMPLATE_SRC_IFEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_END') . '}}', '{{IFEMPTY:' . $elid . ':END}}', $text); - $text = str_replace('{{' . lang('TEMPLATE_SRC_IFNOTEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_BEGIN') . '}}', '{{IFNOTEMPTY:' . $elid . ':BEGIN}}', $text); - $text = str_replace('{{' . lang('TEMPLATE_SRC_IFNOTEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_END') . '}}', '{{IFNOTEMPTY:' . $elid . ':END}}', $text); + if ($this->hasRequestVar('source_'.$modelName)) + { + $templatemodel = new TemplateModel($this->template->templateid, $modelId); + $templatemodel->load(); + + // Nur wenn das Eingabefeld im Request vorhanden ist, speichern wir etwas ab. + $text = $this->getRequestVar('source_'.$modelName, 'raw'); + + foreach ($this->template->getElementNames() as $elid => $elname) { + $text = str_replace('{{' . $elname . '}}', '{{' . $elid . '}}', $text); + $text = str_replace('{{->' . $elname . '}}', '{{->' . $elid . '}}', $text); + $text = str_replace('{{' . lang('TEMPLATE_SRC_IFEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_BEGIN') . '}}', '{{IFEMPTY:' . $elid . ':BEGIN}}', $text); + $text = str_replace('{{' . lang('TEMPLATE_SRC_IFEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_END') . '}}', '{{IFEMPTY:' . $elid . ':END}}', $text); + $text = str_replace('{{' . lang('TEMPLATE_SRC_IFNOTEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_BEGIN') . '}}', '{{IFNOTEMPTY:' . $elid . ':BEGIN}}', $text); + $text = str_replace('{{' . lang('TEMPLATE_SRC_IFNOTEMPTY') . ':' . $elname . ':' . lang('TEMPLATE_SRC_END') . '}}', '{{IFNOTEMPTY:' . $elid . ':END}}', $text); + } + + $templatemodel->src = $text; + + if ( !$templatemodel->isPersistent() ) + $templatemodel->add(); + else + $templatemodel->save(); } - - $templatemodel->src = $text; - - if ( !$templatemodel->isPersistent() ) - $templatemodel->add(); - else - $templatemodel->save(); } $this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK); 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="req1541213796418648492_file" type="file" name="file" class="upload" /> + <input size="40" id="req1543263821943001488_file" type="file" name="file" class="upload" /> <br/> diff --git a/modules/cms-ui/themes/default/html/views/folder/createfile.php b/modules/cms-ui/themes/default/html/views/folder/createfile.php @@ -2,7 +2,7 @@ - <form name="" target="_self" data-target="upload" action="./" data-method="createfile" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="multipart/form-data" class="folder" 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="folder" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="createfile" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="upload" action="./" data-method="createfile" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="multipart/form-data" 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="createfile" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <input type="hidden" name="type" value="file"/> <div class="line"> @@ -13,7 +13,7 @@ </label> </div> <div class="input"> - <input size="40" id="req15379905191788469430_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" /> + <input size="40" id="req15431736221794568957_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" /> </div> </div> @@ -65,7 +65,7 @@ </div> </div> - <div class="bottom"><div class="command 1"><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/createfolder.php b/modules/cms-ui/themes/default/html/views/folder/createfolder.php @@ -2,7 +2,7 @@ - <form name="" target="_self" data-target="view" action="./" data-method="createfolder" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="folder" 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="folder" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="createfolder" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="createfolder" 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="createfolder" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <input type="hidden" name="languageid" value="<?php echo $languageid ?>"/> <div class="line"> @@ -25,5 +25,5 @@ </div> </div> - <div class="bottom"><div class="command 1"><input type="submit" class="submit ok" value="<?php echo lang('add') ?>" /></div></div></form> + <div class="or-form-actionbar"><input type="submit" class="or-form-btn or-form-btn--primary" value="<?php echo lang('add') ?>" /></div></form> \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/folder/createpage.php b/modules/cms-ui/themes/default/html/views/folder/createpage.php @@ -2,7 +2,7 @@ - <form name="" target="_self" data-target="view" action="./" data-method="createpage" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="folder" 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="folder" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="createpage" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="createpage" 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="createpage" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <div class="line"> <div class="label"> <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_TEMPLATE')))); ?></span> @@ -33,5 +33,5 @@ </div> </div> - <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/language/edit.php b/modules/cms-ui/themes/default/html/views/language/edit.php @@ -2,7 +2,7 @@ - <form name="" target="_self" data-target="view" action="./" data-method="edit" data-action="language" data-id="<?php echo OR_ID ?>" method="post" enctype="application/x-www-form-urlencoded" class="language" 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="language" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="edit" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="edit" data-action="language" data-id="<?php echo OR_ID ?>" method="post" enctype="application/x-www-form-urlencoded" class="or-form language" 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="language" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="edit" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <div class="line"> <div class="label"> <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('GLOBAL_LANGUAGE')))); ?></span> @@ -13,5 +13,5 @@ </select></div> </div> </div> - <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/model/edit.php b/modules/cms-ui/themes/default/html/views/model/edit.php @@ -2,7 +2,7 @@ - <form name="" target="_self" data-target="view" action="./" data-method="edit" data-action="model" data-id="<?php echo OR_ID ?>" method="post" enctype="application/x-www-form-urlencoded" class="model" 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="model" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="edit" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="edit" data-action="model" data-id="<?php echo OR_ID ?>" method="post" enctype="application/x-www-form-urlencoded" class="or-form model" 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="model" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="edit" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <div class="line"> <div class="label"> <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('GLOBAL_NAME')))); ?></span> @@ -13,5 +13,5 @@ </div> </div> - <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/template/src.php b/modules/cms-ui/themes/default/html/views/template/src.php @@ -5,7 +5,7 @@ <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 $name ?></legend><div> <?php $$name= $source; ?> - <textarea name="<?php echo $name ?>" data-extension="" data-mimetype="" data-mode="htmlmixed" class="editor code-editor"><?php echo ${$name} ?></textarea> + <textarea name="<?php if ('source') echo 'source'.'_' ?><?php echo $name ?><?php if ('') echo '_disabled' ?>" data-extension="" data-mimetype="" data-mode="htmlmixed" class="editor code-editor"><?php echo ${$name} ?></textarea> </div></fieldset> <?php } ?> diff --git a/modules/cms-ui/themes/default/html/views/template/src.tpl.src.xml b/modules/cms-ui/themes/default/html/views/template/src.tpl.src.xml @@ -6,7 +6,7 @@ <group title="var:name"> <set var="var:name" value="var:source" /> - <editor type="code" name="var:name" mode="htmlmixed" /> + <editor type="code" prefix="source" name="var:name" mode="htmlmixed" /> </group> </list> diff --git a/modules/cms-ui/themes/default/html/views/title/show.php b/modules/cms-ui/themes/default/html/views/title/show.php @@ -467,7 +467,7 @@ <div class="toolbar-icon search"> <img class="image-icon image-icon--method" title="" src="./modules/cms-ui/themes/default/images/icon/method/search.svg" /> - <div class="inputholder"><input placeholder="<?php echo lang('search') ?>" id="<?php echo REQUEST_ID ?>_text" name="text<?php if ('') echo '_disabled' ?>" type="text" maxlength="256" class="text" value="<?php echo Text::encodeHtml(@$text) ?>" /><?php if ('') { ?><input type="hidden" name="text" value="<?php $text ?>"/><?php } ?></div> + <div class="inputholder"><input placeholder="<?php echo lang('search') ?>" id="<?php echo REQUEST_ID ?>_text" name="<?php if ('') echo ''.'_' ?>text<?php if ('') echo '_disabled' ?>" type="text" maxlength="256" class="" value="<?php echo Text::encodeHtml(@$text) ?>" /><?php if ('') { ?><input type="hidden" name="text" value="<?php $text ?>"/><?php } ?></div> <div class="arrow arrow-down"> </div> diff --git a/modules/template-engine/components/html/FieldComponent.class.php b/modules/template-engine/components/html/FieldComponent.class.php @@ -0,0 +1,28 @@ +<?php + +namespace template_engine\components; + + +abstract class FieldComponent extends HtmlComponent +{ + + public $prefix; + public $name; + public $readonly = false; + + + protected function outputNameAttribute() { + + $out = ' name="'; + + if(isset($this->readonly)) + $out .= '<?php if ('.$this->value($this->prefix).') '."echo ".$this->value($this->prefix).".'_' ?>"; + $out .= $this->htmlvalue($this->name); + + if(isset($this->readonly)) + $out .= '<?php if ('.$this->value($this->readonly).') '."echo '_disabled' ?>"; + $out .= '"'; + + return $out; + } +} diff --git a/modules/template-engine/components/html/HtmlComponent.class.php b/modules/template-engine/components/html/HtmlComponent.class.php @@ -0,0 +1,10 @@ +<?php + +namespace template_engine\components; + +abstract class HtmlComponent extends Component +{ + + public $class; + +} diff --git a/modules/template-engine/components/html/editor/Editor.class.php b/modules/template-engine/components/html/editor/Editor.class.php @@ -2,7 +2,7 @@ namespace template_engine\components; -class EditorComponent extends Component +class EditorComponent extends FieldComponent { public $type; public $name; @@ -15,25 +15,25 @@ class EditorComponent extends Component switch( $this->type ) { case 'html': - echo '<textarea name="'.$this->htmlvalue($this->name).'" class="editor html-editor" id="pageelement_edit_editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; - + echo '<textarea '.$this->outputNameAttribute().' class="editor html-editor" id="pageelement_edit_editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; + break; - + case 'wiki': - echo '<textarea name="'.$this->htmlvalue($this->name).'" class="editor wiki-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; + echo '<textarea '.$this->outputNameAttribute().' class="editor wiki-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; break; - + case 'text': case 'raw': - echo '<textarea name="'.$this->htmlvalue($this->name).'" class="editor text-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; + echo '<textarea '.$this->outputNameAttribute().' class="editor text-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; break; - + case 'markdown': - echo '<textarea name="'.$this->htmlvalue($this->name).'" class="editor markdown-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; + echo '<textarea '.$this->outputNameAttribute().' class="editor markdown-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; break; case 'code': - echo '<textarea name="'.$this->htmlvalue($this->name).'" data-extension="'.$this->htmlvalue($this->extension).'" data-mimetype="'.$this->htmlvalue($this->mimetype).'" data-mode="'.$this->htmlvalue($this->mode).'" class="editor code-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; + echo '<textarea '.$this->outputNameAttribute().' data-extension="'.$this->htmlvalue($this->extension).'" data-mimetype="'.$this->htmlvalue($this->mimetype).'" data-mode="'.$this->htmlvalue($this->mode).'" class="editor code-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; break; diff --git a/modules/template-engine/components/html/input/Input.class.php b/modules/template-engine/components/html/input/Input.class.php @@ -2,11 +2,8 @@ namespace template_engine\components; -class InputComponent extends Component +class InputComponent extends FieldComponent { - - public $class = 'text'; - public $default; public $type = 'text'; @@ -25,8 +22,6 @@ class InputComponent extends Component public $onchange; - public $readonly = false; - public $hint; public $icon; @@ -60,12 +55,8 @@ class InputComponent extends Component echo ' id="'.'<?php echo REQUEST_ID ?>_'.$this->htmlvalue($this->name).'"'; - // Attribute name="..." - echo ' name="'; - echo $this->htmlvalue($this->name); - if(isset($this->readonly)) - echo '<?php if ('.$this->value($this->readonly).') '."echo '_disabled' ?>"; - echo '"'; + // Output Attribute name="..." + echo $this->outputNameAttribute(); if($this->required) echo ' required="required"'; diff --git a/modules/template-engine/components/html/table/Table.class.php b/modules/template-engine/components/html/table/Table.class.php @@ -2,10 +2,9 @@ namespace template_engine\components; -class TableComponent extends Component +class TableComponent extends HtmlComponent { - public $class = ''; public $width = '100%'; public function begin() diff --git a/modules/template-engine/engine/TemplateEngine.class.php b/modules/template-engine/engine/TemplateEngine.class.php @@ -40,7 +40,9 @@ class TemplateEngine { // Imports the base class of all component types. require_once (dirname(__FILE__).'/../components/'.$this->renderType.'/Component.class.' . PHP_EXT); - + require_once (dirname(__FILE__).'/../components/'.$this->renderType.'/HtmlComponent.class.' . PHP_EXT); + require_once (dirname(__FILE__).'/../components/'.$this->renderType.'/FieldComponent.class.' . PHP_EXT); + try { $confCompiler = $this->config;