commit ed4204f0a870b996c5f7377167145ec3a4abf9e4
parent 771fd3851b068c6101f2f87835e2dcd6f0302534
Author: Jan Dankert <devnull@localhost>
Date: Sun, 28 Oct 2012 23:32:10 +0100
Vereinfachte Bearbeitung von Vorlagen.
Diffstat:
6 files changed, 108 insertions(+), 169 deletions(-)
diff --git a/action/TemplateAction.class.php b/action/TemplateAction.class.php
@@ -334,6 +334,25 @@ class TemplateAction extends Action
*/
function editView()
{
+ // Elemente laden
+ $list = array();
+
+ foreach( $this->template->getElementIds() as $elid )
+ {
+ $element = new Element( $elid );
+ $element->load();
+
+ $list[$elid] = array();
+ $list[$elid]['id' ] = $elid;
+ $list[$elid]['name' ] = $element->name;
+ $list[$elid]['description'] = $element->desc;
+ $list[$elid]['type' ] = $element->type;
+
+ unset( $element );
+ }
+ $this->setTemplateVar('elements',$list);
+
+
$text = htmlentities( $this->template->src );
$text = str_replace("\n",'<br/>',$text);
@@ -341,34 +360,34 @@ class TemplateAction extends Action
{
$element = new Element( $elid );
$element->load();
- $url = Html::url( 'element','name',$elid );
+ $url = 'javascript:openNewAction(\''.$element->name.'\',\'element\',\''.$elid.'\');';
$text = str_replace('{{'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
+ '<a href="'.$url.'" class="element el_'.
+ $element->getTypeClass().'" title="'.$element->desc.'">{{'.
$element->name.'}}</a>',
$text );
$text = str_replace('{{->'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{->'.
+ '<a href="'.$url.'" class="element el_'.
+ $element->getTypeClass().'" title="'.$element->desc.'">{{->'.
$element->name.'}}</a>',
$text );
$text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
$text );
$text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
$element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
$text );
$text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
$text );
$text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
+ '<a href="'.$url.'" class="element el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
$element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
$text );
@@ -379,31 +398,6 @@ class TemplateAction extends Action
}
- // Anzeigen der Template-Elemente
- //
- function elView()
- {
- global $conf_php;
- $list = array();
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $list[$elid] = array();
- $list[$elid]['id' ] = $elid;
- $list[$elid]['name'] = $element->name;
- $list[$elid]['desc'] = $element->desc;
- $list[$elid]['type'] = $element->type;
-
- unset( $element );
- }
- $this->setTemplateVar('el',$list);
- }
-
-
-
function srcelementView()
{
$elements = array();
@@ -431,82 +425,34 @@ class TemplateAction extends Action
*/
function srcView()
{
- if ( $this->isEditMode() )
- {
- $text = $this->template->src;
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
-
- $text = str_replace('{{'.$elid.'}}',
- '{{'.$element->name.'}}',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '{{->'.$element->name.'}}',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
- $text );
- }
+ $text = $this->template->src;
- $this->setTemplateVar( 'src',$text );
- }
- else
+ foreach( $this->template->getElementIds() as $elid )
{
- $text = htmlentities( $this->template->src );
- $text = str_replace("\n",'<br/>',$text);
-
- foreach( $this->template->getElementIds() as $elid )
- {
- $element = new Element( $elid );
- $element->load();
- $url = Html::url( 'element','name',$elid );
-
- $text = str_replace('{{'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{'.
- $element->name.'}}</a>',
- $text );
- $text = str_replace('{{->'.$elid.'}}',
- '<a href="'.$url.'" class="el_'.
- $element->getTypeClass().'" target="cms_main_main" title="'.$element->desc.'">{{->'.
- $element->name.'}}</a>',
- $text );
-
- $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}</a>',
- $text );
- $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
- '<a href="'.$url.'" class="el_'.$element->getTypeClass().'" title="'.$element->desc.'">{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.
- $element->name.':'.lang('TEMPLATE_SRC_END').'}}</a>',
- $text );
-
- unset( $element );
- }
-
- $this->setTemplateVar('src',$text);
+ $element = new Element( $elid );
+ $element->load();
+
+ $text = str_replace('{{'.$elid.'}}',
+ '{{'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{->'.$elid.'}}',
+ '{{->'.$element->name.'}}',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}',
+ '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
+ $text );
+ $text = str_replace('{{IFEMPTY:'.$elid.':END}}',
+ '{{'.lang('TEMPLATE_SRC_IFEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}',
+ '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_BEGIN').'}}',
+ $text );
+ $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}',
+ '{{'.lang('TEMPLATE_SRC_IFNOTEMPTY').':'.$element->name.':'.lang('TEMPLATE_SRC_END').'}}',
+ $text );
}
+
+ $this->setTemplateVar( 'src',$text );
}
diff --git a/language/de.ini.php b/language/de.ini.php
@@ -1161,3 +1161,5 @@ MENU_SIZE_DESC =Bildgröße ändern
LICENSE="Lizenz"
MENU_TREE=Navigation
MENU_TREE_DESC=Navigation
+SRC="Quellcode"
+EDIT="Bearbeiten"
diff --git a/themes/default/css/openrat.css.php b/themes/default/css/openrat.css.php
@@ -718,7 +718,8 @@ ul.tree ul
div.entry.selected,
div.dropdown > div.entry:hover,
-div.dropdown > div.entry:hover > a
+div.dropdown > div.entry:hover > a,
+a.element
{
/*border:1px solid <?php echo $_GET['text_color']; ?>;*/
background-color:<?php echo $_GET['title_background_color']; ?>;
diff --git a/themes/default/templates/template/edit.tpl.src.xml b/themes/default/templates/template/edit.tpl.src.xml
@@ -1,11 +1,56 @@
<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openrat.de/template ../template.xsd">
- <header views="src,addel,srcelement,el,remove"></header>
- <window name="TEMPLATE_SHOW">
- <row>
+ <header views="src,remove"></header>
+
+ <table>
+ <row class="headline">
+ <column>
+ <text key="name"></text>
+ </column>
+ <column>
+ <text key="type"></text>
+ </column>
+ </row>
+ <list list="elements" extract="true">
+ <row class="data">
+ <column id="var:id" name="var:name" action="element">
+ <image elementtype="var:type"></image>
+ <text var="name" title="var:description"></text>
+ </column>
<column>
- <text var="text" escape="false" type="code"></text>
+ <text key="var:type" prefix="EL_"></text>
+ </column>
+ </row>
+ </list>
+ <if empty="el">
+ <row>
+ <column colspan="2">
+ <text key="GLOBAL_NOT_FOUND"></text>
</column>
</row>
- </window>
+ </if>
+ <row class="data">
+ <column colspan="2" class="clickable">
+ <link type="view" subaction="addel">
+ <image icon="add" />
+ <text key="menu_template_addel"></text>
+ </link>
+ </column>
+ </row>
+ </table>
+
+ <group title="message:src">
+ <table>
+ <row class="data">
+ <column class="clickable">
+ <link type="view" subaction="src">
+ <image icon="template" />
+ <text key="edit"></text>
+ </link>
+ </column>
+ </row>
+ </table>
+
+ <text var="text" escape="false" type="code"></text>
+ </group>
</output>
\ No newline at end of file
diff --git a/themes/default/templates/template/el.tpl.src.xml b/themes/default/templates/template/el.tpl.src.xml
@@ -1,39 +0,0 @@
-<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.openrat.de/template ../template.xsd">
- <table>
- <row class="headline">
- <column>
- <text key="name"></text>
- </column>
- <column>
- <text key="type"></text>
- </column>
- </row>
- <list list="el" extract="true">
- <row class="data">
- <column id="var:id" name="var:name" action="element">
- <image elementtype="var:type"></image>
- <text var="name"></text>
- </column>
- <column>
- <text key="var:type" prefix="EL_"></text>
- </column>
- </row>
- </list>
- <if empty="el">
- <row>
- <column colspan="2">
- <text key="GLOBAL_NOT_FOUND"></text>
- </column>
- </row>
- </if>
- <row class="data">
- <column colspan="2">
- <link type="view" subaction="addel">
- <image icon="add"/>
- <text key="menu_template_addel"></text>
- </link>
- </column>
- </row>
- </table>
-</output>
-\ No newline at end of file
diff --git a/themes/default/templates/template/src.tpl.src.xml b/themes/default/templates/template/src.tpl.src.xml
@@ -2,21 +2,6 @@
xsi:schemaLocation="http://www.openrat.de/template ../template.xsd">
<header back="true"></header>
<form>
- <row>
- <column>
- <inputarea rows="25" cols="80" name="src" class="editor"></inputarea>
- </column>
- </row>
- <row>
- <column class="act">
- <button type="ok"></button>
- <if false="mode:edit">
- <link class="action" action="template" subaction="srcelement">
- <text key="menu_template_srcelement"></text>
- </link>
- </if>
- </column>
- </row>
+ <inputarea rows="25" cols="80" name="src" class="editor"></inputarea>
</form>
- <focus field="src"></focus>
</output>
\ No newline at end of file