commit fcd742dbafac5c8321da1516d94a2c07fcbbd750
parent 377e087d2bde44f479bedeb4f3c07d0697aad409
Author: Jan Dankert <devnull@localhost>
Date: Wed, 22 Aug 2018 00:56:23 +0200
Elemente können nach der letzten Umbauaktion nun wieder gelesen und gespeichert werden.
Diffstat:
10 files changed, 135 insertions(+), 61 deletions(-)
diff --git a/modules/cms-core/action/ElementAction.class.php b/modules/cms-core/action/ElementAction.class.php
@@ -90,22 +90,21 @@ class ElementAction extends Action
public function removePost()
{
if ( !$this->hasRequestVar('confirm') )
- {
- $this->addValidationError('confirm');
- return;
- }
-
+ throw new \ValidationException('confirm');
+
$type = $this->getRequestVar('type','abc');
if ( $type == 'value' )
{
+ // Nur Inhalte löschen
$this->element->deleteValues();
- $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK);
+ $this->addNotice('element',$this->element->name,'DELETED',OR_NOTICE_OK);
}
elseif ( $type == 'all' )
{
+ // Element löschen
$this->element->delete();
- $this->addNotice('element',$this->template->name,'DELETED',OR_NOTICE_OK);
+ $this->addNotice('element',$this->element->name,'DELETED',OR_NOTICE_OK);
}
}
@@ -124,7 +123,7 @@ class ElementAction extends Action
else
{
// Neuen Typ setzen und speichern
- $this->element->setType( $this->getRequestVar('type') );
+ $this->element->updateTypeId( $this->getRequestVar('typeid') );
$this->addNotice('element',$this->element->name,'SAVED',OR_NOTICE_OK);
}
}
@@ -160,7 +159,7 @@ class ElementAction extends Action
$this->setTemplateVar('types',$types);
// Aktueller Typ
- $this->setTemplateVar('type',$this->element->type);
+ $this->setTemplateVar('typeid',$this->element->typeid);
}
@@ -592,7 +591,11 @@ class ElementAction extends Action
$folders = array();
// Ermitteln aller verf?gbaren Objekt-IDs
- foreach( Folder::getAllFolders() as $id )
+ $template = new Template( $this->element->templateid );
+ $template->load();
+ $project = new Project( $template->projectid );
+
+ foreach( $project->getAllFolders() as $id )
{
$o = new BaseObject( $id );
$o->load();
diff --git a/modules/cms-core/action/TemplateAction.class.php b/modules/cms-core/action/TemplateAction.class.php
@@ -224,8 +224,12 @@ class TemplateAction extends Action
// Code-Element nur fuer Administratoren (da voller Systemzugriff!)
if ( !$this->userIsAdmin() )
unset( $types[ELEMENT_TYPE_CODE] );
-
+
+ // Auswahlmoeglichkeiten:
$this->setTemplateVar('types',$types);
+
+ // Vorbelegung:
+ $this->setTemplateVar('typeid',ELEMENT_TYPE_TEXT);
}
@@ -237,22 +241,26 @@ class TemplateAction extends Action
{
$name = $this->getRequestVar('name',OR_FILTER_ALPHANUM);
+
if ( empty($name) )
- {
- $this->addValidationError('name');
- $this->callSubAction('addel');
- return;
- }
-
- $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('type') );
- $this->setTemplateVar('tree_refresh',true);
-
+ throw new \ValidationException('name');
+
+ $newElement = $this->template->addElement( $name,$this->getRequestVar('description'),$this->getRequestVar('typeid') );
+
if ( $this->hasRequestVar('addtotemplate') )
{
- $elnames = $this->template->getElementNames();
- $elid = array_search($name,$elnames);
- $this->template->src .= "\n".'{{'.$elid.'}}';
- $this->template->save();
+ $project = new Project( $this->template->projectid);
+ $modelIds = $project->getModelIds();
+
+ foreach( $modelIds as $modelId )
+ {
+ $template = new Template( $this->template->templateid );
+ $template->modelid = $modelId;
+ $template->load();
+ $template->src .= "\n".'{{'.$newElement->elementid.'}}';
+ $template->save();
+ }
+
}
$this->addNotice('template',$this->template->name,'SAVED',OR_NOTICE_OK);
diff --git a/modules/cms-core/model/Element.class.php b/modules/cms-core/model/Element.class.php
@@ -172,14 +172,17 @@ class Element
$this->elementid = intval($sql->getOne())+1;
$sql = $db->sql( 'INSERT INTO {{element}}'.
- ' (id,templateid,name,descr,type,writable) '.
- " VALUES ( {elementid},{templateid},{name},{description},{type},{writable} ) " );
+ ' (id,templateid,name,descr,typeid,flags) '.
+ " VALUES ( {elementid},{templateid},{name},{description},{typeid},{flags} ) " );
- $sql->setInt ( 'elementid' ,$this->elementid );
+ $flags = 0;
+ $flags += ELEMENT_FLAG_WRITABLE * intval($this->writable);
+
+ $sql->setInt ( 'elementid' ,$this->elementid );
$sql->setString ( 'name' ,$this->name );
- $sql->setString ( 'type' ,$this->type );
+ $sql->setInt ( 'typeid' ,$this->typeid );
$sql->setInt ( 'templateid' ,$this->templateid );
- $sql->setBoolean( 'writable' ,$this->writable );
+ $sql->setBoolean( 'flags' ,$flags );
$sql->setString ( 'description',$this->desc );
$sql->query();
@@ -259,12 +262,9 @@ SQL
' descr = {desc},'.
' typeid = {typeid},'.
' subtype = {subtype},'.
- ' with_icon = {withIcon},'.
' dateformat = {dateformat},'.
- ' wiki = {wiki},'.
- ' html = {html},'.
- ' all_languages = {allLanguages},'.
- ' writable = {writable},'.
+ ' flags = {flags},'.
+ ' format = {format},'.
' decimals = {decimals},'.
' dec_point = {decPoint},'.
' thousand_sep = {thousandSep},'.
@@ -274,18 +274,21 @@ SQL
' default_objectid= {defaultObjectId}'.
' WHERE id={elementid}' );
- $sql->setInt ( 'elementid' ,$this->elementid );
+ $flags = 0;
+ $flags += ELEMENT_FLAG_WITH_ICON * intval($this->withIcon );
+ $flags += ELEMENT_FLAG_HTML_ALLOWED * intval($this->html );
+ $flags += ELEMENT_FLAG_ALL_LANGUAGES * intval($this->allLanguages);
+ $flags += ELEMENT_FLAG_WRITABLE * intval($this->writable );
+
+ $sql->setInt ( 'elementid' ,$this->elementid );
$sql->setInt ( 'templateid' ,$this->templateid );
$sql->setString ( 'name' ,$this->name );
$sql->setString ( 'desc' ,$this->desc );
- $sql->setString ( 'typeid' ,$this->typeid );
+ $sql->setInt ( 'typeid' ,$this->typeid );
$sql->setString ( 'subtype' ,$this->subtype );
- $sql->setBoolean( 'withIcon' ,$this->withIcon );
$sql->setString ( 'dateformat' ,$this->dateformat );
- $sql->setBoolean( 'wiki' ,$this->wiki );
- $sql->setBoolean( 'html' ,$this->html );
- $sql->setBoolean( 'writable' ,$this->writable );
- $sql->setBoolean( 'allLanguages' ,$this->allLanguages );
+ $sql->setInt ( 'flags' ,$flags );
+ $sql->setInt ( 'format' ,$this->format );
$sql->setInt ( 'decimals' ,$this->decimals );
$sql->setString ( 'decPoint' ,$this->decPoint );
$sql->setString ( 'thousandSep' ,$this->thousandSep );
@@ -306,24 +309,25 @@ SQL
/**
- * Setzt den Typ des Elementes und schreibt diesen sofort in die Datenbank.
+ * Aktualisiert den Typ des Elementes und schreibt diesen sofort in die Datenbank.
*
- * @param String Der neue Typ, siehe getAvailableTypes() f?r m?gliche Typen
- * @see #type
+ * @param String Der neue Typ, siehe getAvailableTypes() fuer moegliche Typen
+ * @see #typeid
*/
- public function setType( $type )
+ public function updateTypeId($typeid )
{
- $this->type = $type;
+ $this->typeid = $typeid;
+
$db = db_connection();
- $sql = $db->sql( 'UPDATE {{element}}'.
- ' SET type = {type}'.
+ $stmt = $db->sql( 'UPDATE {{element}}'.
+ ' SET typeid = {typeid}'.
' WHERE id={elementid}' );
- $sql->setInt ( 'elementid',$this->elementid );
- $sql->setString ( 'type' ,$this->type );
+ $stmt->setInt ( 'elementid',$this->elementid );
+ $stmt->setString ( 'typeid' ,$this->typeid );
- $sql->query();
+ $stmt->execute();
}
@@ -422,8 +426,9 @@ SQL
}
/**
- * Ermitteln aller benutzbaren Elementtypen
- * @return array
+ * Ermitteln aller benutzbaren Elementtypen.
+ *
+ * @return array id->name
*/
public static function getAvailableTypes()
{
diff --git a/modules/cms-core/model/Template.class.php b/modules/cms-core/model/Template.class.php
@@ -287,16 +287,18 @@ SQL
* Hinzuf?gen eines Elementes
* @param String Name des Elementes
*/
- public function addElement( $name,$description='',$type='text' )
+ public function addElement($name, $description='', $typeid=ELEMENT_TYPE_TEXT )
{
$element = new Element();
$element->name = $name;
$element->desc = $description;
- $element->type = $type;
+ $element->typeid = $typeid;
$element->templateid = $this->templateid;
$element->format = ELEMENT_FORMAT_TEXT;
$element->writable = true;
$element->add();
+
+ return $element;
}
diff --git a/modules/cms-ui/themes/default/html/views/element/advanced.php b/modules/cms-ui/themes/default/html/views/element/advanced.php
@@ -2,7 +2,7 @@
- <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="1" 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="<?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 ?>" />
<fieldset class="<?php echo '1'?" open":" closed" ?><?php echo '1'?" show":"" ?>"><div>
<div class="line">
<div class="label">
@@ -10,7 +10,7 @@
</div>
<div class="input">
- <div class="inputholder"><select id="<?php echo REQUEST_ID ?>_type" name="type" title="" class=""<?php if (count($types)<=1) echo ' disabled="disabled"'; ?> size=1"><?php include_once( 'modules/template-engine/components/html/selectbox/component-select-box.php') ?><?php component_select_option_list($types,$type,0,1) ?><?php if (count($types)==0) { ?><input type="hidden" name="type" value="" /><?php } ?><?php if (count($types)==1) { ?><input type="hidden" name="type" value="<?php echo array_keys($types)[0] ?>" /><?php } ?>
+ <div class="inputholder"><select id="<?php echo REQUEST_ID ?>_typeid" name="typeid" title="" class=""<?php if (count($types)<=1) echo ' disabled="disabled"'; ?> size=1"><?php include_once( 'modules/template-engine/components/html/selectbox/component-select-box.php') ?><?php component_select_option_list($types,$typeid,0,1) ?><?php if (count($types)==0) { ?><input type="hidden" name="typeid" value="" /><?php } ?><?php if (count($types)==1) { ?><input type="hidden" name="typeid" value="<?php echo array_keys($types)[0] ?>" /><?php } ?>
</select></div>
</div>
</div>
diff --git a/modules/cms-ui/themes/default/html/views/element/advanced.tpl.src.xml b/modules/cms-ui/themes/default/html/views/element/advanced.tpl.src.xml
@@ -8,7 +8,7 @@
<text text="ELEMENT_TYPE"></text>
</part>
<part class="input">
- <selectbox name="type" list="types" lang="true"></selectbox>
+ <selectbox name="typeid" list="types" lang="true"></selectbox>
</part>
</part>
</group>
diff --git a/modules/cms-ui/themes/default/html/views/template/addel.php b/modules/cms-ui/themes/default/html/views/template/addel.php
@@ -0,0 +1,55 @@
+
+
+
+
+ <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 ?>" />
+ <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<?php if ('') echo ' disabled="true"' ?> id="<?php echo REQUEST_ID ?>_name" name="name<?php if ('') echo '_disabled' ?>" type="text" maxlength="256" class="text" 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('element_type')))); ?></span>
+
+ </div>
+ <div class="input">
+ <?php $text= 'text'; ?>
+
+ <div class="inputholder"><select id="<?php echo REQUEST_ID ?>_typeid" name="typeid" title="" class=""<?php if (count($types)<=1) echo ' disabled="disabled"'; ?> size=1"><?php include_once( 'modules/template-engine/components/html/selectbox/component-select-box.php') ?><?php component_select_option_list($types,$typeid,0,1) ?><?php if (count($types)==0) { ?><input type="hidden" name="typeid" value="" /><?php } ?><?php if (count($types)==1) { ?><input type="hidden" name="typeid" value="<?php echo array_keys($types)[0] ?>" /><?php } ?>
+ </select></div>
+ </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('options') ?></legend><div>
+ </div></fieldset>
+ <div class="line">
+ <div class="label">
+ </div>
+ <div class="input">
+ <label for="<?php echo REQUEST_ID ?>_addtotemplate" class="label">
+ <?php { $tmpname = 'addtotemplate';$default = '1';$readonly = '';
+ if ( isset($$tmpname) )
+ $checked = $$tmpname;
+ else
+ $checked = $default;
+
+ ?><input class="checkbox" type="checkbox" id="<?php echo REQUEST_ID ?>_<?php echo $tmpname ?>" name="<?php echo $tmpname ?>" <?php if ($readonly) echo ' disabled="disabled"' ?> value="1" <?php if( $checked ) echo 'checked="checked"' ?> /><?php
+
+ if ( $readonly && $checked )
+ {
+ ?><input type="hidden" name="<?php echo $tmpname ?>" value="1" /><?php
+ }
+ } ?>
+
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_template_srcelement'.'')))); ?></span>
+
+ </label>
+ </div>
+ </div>
+ <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/template/addel.tpl.src.xml b/modules/cms-ui/themes/default/html/views/template/addel.tpl.src.xml
@@ -18,7 +18,7 @@
</part>
<part class="input">
<set var="text" value="text"></set>
- <selectbox list="types" default="text" name="type" lang="true"></selectbox>
+ <selectbox list="types" name="typeid" lang="true"></selectbox>
</part>
</part>
diff --git a/modules/cms-ui/themes/default/html/views/template/edit.php b/modules/cms-ui/themes/default/html/views/template/edit.php
@@ -37,7 +37,7 @@
<?php } ?>
<tr class="data">
<td colspan="2" class="clickable">
- <a target="_self" data-type="view" data-action="template" data-method="addel" data-id="<?php echo $templateid ?>" data-extra="[]" href="<?php echo Html::url('template','addel',$templateid,array()) ?>">
+ <a target="_self" data-type="dialog" data-action="template" data-method="addel" data-id="<?php echo $templateid ?>" data-extra="{'dialogAction':'template','dialogMethod':'addel'}" href="<?php echo Html::url('template','addel',$templateid,array('dialogAction'=>'template','dialogMethod'=>'addel')) ?>">
<img class="" title="" src="./modules/cms-ui/themes/default/images/icon/add.png" />
<span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_template_addel'.'')))); ?></span>
diff --git a/modules/cms-ui/themes/default/html/views/template/edit.tpl.src.xml b/modules/cms-ui/themes/default/html/views/template/edit.tpl.src.xml
@@ -31,7 +31,7 @@
</if>
<row class="data">
<column colspan="2" class="clickable">
- <link type="view" subaction="addel" action="template" id="var:templateid">
+ <link type="dialog" subaction="addel" action="template" id="var:templateid">
<image icon="add" />
<text key="menu_template_addel"></text>
</link>