openrat-cms

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

commit aaed438644fb3aeba75e23f188d1e1d274e9a19e
parent a719aa3ce03eaa6179919428db4203d3b7915cec
Author: Jan Dankert <devnull@localhost>
Date:   Mon, 20 Aug 2018 23:32:54 +0200

Neues Eingabefeld "Einstellungen" für Dateien (wird nach und nach auch für anderen Typen ausgerollt).

Diffstat:
modules/cms-core/action/FileAction.class.php | 14++++++++++++++
modules/cms-core/model/BaseObject.class.php | 71++++++++++++++++++++++-------------------------------------------------
modules/cms-ui/themes/default/html/views/file/edit.php | 18++++++++++++++++--
modules/cms-ui/themes/default/html/views/file/edit.tpl.src.xml | 2+-
modules/template-engine/components/html/form/Form.class.php | 11+++++++++--
modules/template-engine/components/template.xsd | 2++
6 files changed, 64 insertions(+), 54 deletions(-)

diff --git a/modules/cms-core/action/FileAction.class.php b/modules/cms-core/action/FileAction.class.php @@ -49,6 +49,7 @@ class FileAction extends ObjectAction parent::__construct(); $this->file = new File( $this->getRequestId() ); + $this->file->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID); $this->file->load(); } @@ -63,6 +64,19 @@ class FileAction extends ObjectAction $this->file->filename = $upload->filename; $this->file->extension = $upload->extension; $this->file->size = $upload->size; + + $this->file->settings = $this->getRequestVar( 'settings'); + + // Validate YAML-Settings + try { + \Spyc::YAMLLoad( $this->file->settings); + } + catch( \Exception $e ) + { + throw new \ValidationException( 'settings' ); + } + + $this->file->save(); $this->file->value = $upload->value; diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php @@ -179,6 +179,12 @@ namespace cms\model { public $typeid; + + /** + * @type array + */ + public $settings; + /** <strong>Konstruktor</strong> * F?llen des neuen Objektes mit Init-Werten * Es werden die Standardwerte aus der Session benutzt, um @@ -333,6 +339,7 @@ SQL 'languageid' =>$this->languageid, 'modelid' =>$this->modelid, 'projectid' =>$this->projectid, + 'settings' =>$this->settings, 'type' =>$this->getType() ); } @@ -629,6 +636,8 @@ SQL $this->description = $row['descr']; } + $this->settings = $row['settings']; + $this->checkName(); } @@ -638,84 +647,49 @@ SQL * Laden des Objektes * @deprecated bitte objectLoad() benutzen */ - function load() + public function load() { $this->objectLoad(); } - /** - * Lesen von logischem Namen und Beschreibung - * Diese Eigenschaften sind sprachabhaengig und stehen deswegen in einer - * separaten Tabelle - * @access private - */ - function objectLoadName() - { - die(); - global $SESS; - $db = db_connection(); - - $sql = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND languageid={languageid}'); - $sql->setInt('objectid' , $this->objectid ); - $sql->setInt('languageid', $this->languageid); - $res = $sql->query(); - - if ($res->numRows() == 0) - { - // Wenn Name in dieser Sprache nicht vorhanden, dann irgendeinen Namen lesen - $sql = $db->sql('SELECT *'.' FROM {{name}}'.' WHERE objectid={objectid}'.' AND name != {blank}'); - $sql->setInt ('objectid' , $this->objectid ); - $sql->setInt ('languageid', $this->languageid); - $sql->setString('blank' , '' ); - - $res = $sql->execute(); - } - $row = $res->fetchRow(); - - $this->name = $row['name']; - $this->desc = $row['description']; - - // Falls leer, id<objectnr> als Dateinamen verwenden - if ($this->name == '') - $this->name = $this->filename; - } /** * Eigenschaften des Objektes in Datenbank speichern */ - function objectSave( $withName = true ) + public function objectSave( $withName = true ) { - global $SESS; $db = db_connection(); $this->checkFilename(); - $sql = $db->sql( <<<SQL + $stmt = $db->sql( <<<SQL UPDATE {{object}} SET parentid = {parentid}, lastchange_date = {time} , lastchange_userid = {userid} , - filename = {filename} + filename = {filename}, + settings = {settings} WHERE id={objectid} SQL ); if ( $this->isRoot ) - $sql->setNull('parentid'); - else $sql->setInt ('parentid',$this->parentid ); + $stmt->setNull('parentid'); + else $stmt->setInt ('parentid',$this->parentid ); $user = \Session::getUser(); $this->lastchangeUser = $user; $this->lastchangeDate = now(); - $sql->setInt ('time' ,$this->lastchangeDate ); - $sql->setInt ('userid' ,$this->lastchangeUser->userid ); - $sql->setString('filename', $this->filename); - $sql->setInt ('objectid', $this->objectid); + $stmt->setInt ('time' ,$this->lastchangeDate ); + $stmt->setInt ('userid' ,$this->lastchangeUser->userid ); + $stmt->setString('filename', $this->filename); + $stmt->setString('settings', $this->settings); + $stmt->setInt ('objectid', $this->objectid); - $sql->query(); + $stmt->query(); // Nur wenn nicht Wurzelordner if ( !$this->isRoot && $withName ) @@ -798,7 +772,6 @@ SQL */ function ObjectSaveName() { - global $SESS; $db = db_connection(); $sql = $db->sql(<<<SQL diff --git a/modules/cms-ui/themes/default/html/views/file/edit.php b/modules/cms-ui/themes/default/html/views/file/edit.php @@ -1,6 +1,6 @@ - <form name="" target="_self" data-target="view" action="./" data-method="<?php echo OR_METHOD ?>" data-action="<?php echo OR_ACTION ?>" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="<?php echo OR_ACTION ?>" 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="<?php echo OR_ACTION ?>" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="<?php echo OR_METHOD ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="<?php echo OR_METHOD ?>" data-action="<?php echo OR_ACTION ?>" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="<?php echo OR_ACTION ?>" data-async="" data-autosave=""><input type="submit" class="invisible" /><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="languageid" value="<?php echo $languageid ?>" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="<?php echo OR_ACTION ?>" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="<?php echo OR_METHOD ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <div class="label"> @@ -9,7 +9,7 @@ <div class="input"> <br/> - <input size="40" id="req1534452414568081199_file" type="file" name="file" class="upload" /> + <input size="40" id="req1534800225391961163_file" type="file" name="file" class="upload" /> <br/> @@ -17,5 +17,19 @@ </div> </div> + <fieldset class="<?php echo '1'?" open":" closed" ?><?php echo '1'?" show":"" ?>"><legend><div class="arrow arrow-right on-closed"></div><div class="arrow arrow-down on-open"></div><?php echo lang('settings') ?></legend><div> + <div class="line"> + <div class="label"> + <label for="<?php echo REQUEST_ID ?>_settings" class="label"> + <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'SETTINGS'.'')))); ?></span> + + </label> + </div> + <div class="input"> + <textarea name="settings" data-extension="" data-mimetype="" data-mode="yaml" class="editor code-editor"><?php echo ${'settings'} ?></textarea> + + </div> + </div> + </div></fieldset> <div class="bottom"><div class="command "><input type="submit" class="submit ok" value="OK" /></div></div></form> \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/file/edit.tpl.src.xml b/modules/cms-ui/themes/default/html/views/file/edit.tpl.src.xml @@ -1,6 +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-engine/components/template.xsd"> - <form> + <form languageid="var:languageid"> <header views="value" /> <part class="label" /> <part class="line"> diff --git a/modules/template-engine/components/html/form/Form.class.php b/modules/template-engine/components/html/form/Form.class.php @@ -15,6 +15,9 @@ class FormComponent extends Component public $id = '<?php echo OR_ID ?>'; + public $languageid = null; + public $modelid = null; + public $label; public $cancel = false; @@ -30,7 +33,7 @@ class FormComponent extends Component public $enctype = 'application/x-www-form-urlencoded'; - public $async = true; + public $async = false; public $autosave = false; @@ -46,7 +49,7 @@ class FormComponent extends Component echo '<form'; echo ' name="' . $this->htmlvalue($this->name) . '"'; - + echo ' target="_self"'; echo ' data-target="' . $this->htmlvalue($this->target) . '"'; echo ' action="./"'; @@ -65,6 +68,10 @@ class FormComponent extends Component if ( $this->target!='top') echo '<input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" />'; + if ( !empty($this->languageid)) + echo '<input type="hidden" name="'.REQ_PARAM_LANGUAGE_ID.'" value="' . $this->htmlvalue($this->languageid) . '" />'; + if ( !empty($this->modelid)) + echo '<input type="hidden" name="'.REQ_PARAM_MODEL_ID.'" value="' . $this->htmlvalue($this->modelid) . '" />'; echo '<input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" />'; echo '<input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="' . $this->htmlvalue($this->action) . '" />'; echo '<input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="' . $this->htmlvalue($this->subaction) . '" />'; diff --git a/modules/template-engine/components/template.xsd b/modules/template-engine/components/template.xsd @@ -1684,6 +1684,8 @@ <xsd:attribute name="action" type="xsd:string"/> <xsd:attribute name="subaction" type="xsd:string"/> <xsd:attribute name="id" type="xsd:string"/> + <xsd:attribute name="languageid" type="xsd:string"/> + <xsd:attribute name="modelid" type="xsd:string"/> <xsd:attribute name="label" type="xsd:string"/> <xsd:attribute name="cancel" type="xsd:boolean"/> <xsd:attribute name="visible" type="xsd:boolean"/>