mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
added xslt_widget: renders html via Seek3r/ceb's xslt-templates
Example is the tpl etemplates.xslt_widget.test with the xslt-file etemplate/templates/default/test.xsl
This commit is contained in:
parent
b81315af45
commit
c9170e138e
97
etemplate/inc/class.xslt_widget.inc.php
Normal file
97
etemplate/inc/class.xslt_widget.inc.php
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
/**************************************************************************\
|
||||||
|
* phpGroupWare - eTemplate Extension - XSLT Widget *
|
||||||
|
* http://www.phpgroupware.org *
|
||||||
|
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||||
|
* -------------------------------------------- *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the *
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||||
|
* option) any later version. *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@class xslt_widget
|
||||||
|
@author ralfbecker
|
||||||
|
@abstract widget that generates its html-output via a xslt file with its in $options and the content as xml
|
||||||
|
@discussion The following data is placed in the xml: value,name,label(translated),statustext(translated),readonly
|
||||||
|
@discussion and all widget-attributes as descript in the referenz, using there xml-names.
|
||||||
|
@discussion This widget is generating html, so it does not work (without an extra implementation) in an other UI
|
||||||
|
*/
|
||||||
|
class xslt_widget
|
||||||
|
{
|
||||||
|
var $public_functions = array(
|
||||||
|
'pre_process' => True,
|
||||||
|
'render' => True
|
||||||
|
);
|
||||||
|
var $human_name = 'XSLT Template'; // this is the name for the editor
|
||||||
|
|
||||||
|
function xslt_widget($ui='')
|
||||||
|
{
|
||||||
|
$this->xslttemplates = CreateObject('phpgwapi.xslttemplates',PHPGW_INCLUDE_ROOT);
|
||||||
|
|
||||||
|
switch($ui)
|
||||||
|
{
|
||||||
|
case '':
|
||||||
|
case 'html':
|
||||||
|
$this->ui = 'html';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo "UI='$ui' not implemented";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
|
||||||
|
{
|
||||||
|
return False; // no extra label
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(&$cell,$form_name,&$value,$readonly,&$extension_data,&$tmpl)
|
||||||
|
{
|
||||||
|
//echo "<p>xslt_widget::render: name='$cell[name]', name='$form_name', value='$value'</p>";
|
||||||
|
$func = 'render_'.$this->ui;
|
||||||
|
|
||||||
|
if (!method_exists($this,$func))
|
||||||
|
return False;
|
||||||
|
|
||||||
|
return $this->$func($cell,$form_name,$value,$readonly,$tmpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
function render_html($cell,$form_name,$value,$readonly,&$tmpl)
|
||||||
|
{
|
||||||
|
list($app,$file) = split('\\.',$cell['size'],2);
|
||||||
|
$pref_templ = $GLOBALS['phpgw_info']['server']['template_set'];
|
||||||
|
$path = "$app/templates/$pref_templ/$file";
|
||||||
|
if (!file_exists(PHPGW_SERVER_ROOT.'/'.$path.'.xsl'))
|
||||||
|
{
|
||||||
|
$path = "$app/templates/default/$file";
|
||||||
|
}
|
||||||
|
$this->xslttemplates->add_file($path);
|
||||||
|
|
||||||
|
$this->xslttemplates->set_var('value',$value);
|
||||||
|
$this->xslttemplates->set_var('name',$form_name);
|
||||||
|
$this->xslttemplates->set_var('readonly',$readonly);
|
||||||
|
$this->xslttemplates->set_var('label',$cell['no_lang'] ? $cell['label'] : lang($cell['label']));
|
||||||
|
$this->xslttemplates->set_var('statustext',lang($cell['help']));
|
||||||
|
list($span,$class) = explode(',',$cell['span']);
|
||||||
|
list($src,$options) = explode(',',$cell['size']);
|
||||||
|
$this->xslttemplates->set_var('attr',array(
|
||||||
|
'id' => $cell['name'],
|
||||||
|
'label' => $cell['label'],
|
||||||
|
'statustext' => $cell['help'],
|
||||||
|
'no_lang' => $cell['no_lang'],
|
||||||
|
'needed' => $cell['needed'],
|
||||||
|
'readonly' => $cell['readonly'],
|
||||||
|
'onchange' => $cell['onchange'],
|
||||||
|
'span' => $span,
|
||||||
|
'class' => $class,
|
||||||
|
'src' => $src,
|
||||||
|
'options' => $options,
|
||||||
|
'align' => $cell['align']
|
||||||
|
));
|
||||||
|
return $this->xslttemplates->parse();
|
||||||
|
}
|
||||||
|
}
|
25
etemplate/templates/default/test.xsl
Normal file
25
etemplate/templates/default/test.xsl
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<xsl:template match="PHPGW">
|
||||||
|
<xsl:value-of select="label"/>
|
||||||
|
<input>
|
||||||
|
<xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
|
||||||
|
<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="readonly!=0">
|
||||||
|
<xsl:attribute name="READONLY"/>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="statustext!=''">
|
||||||
|
<xsl:attribute name="onFocus">self.status='<xsl:value-of select="statustext"/>'; return true;</xsl:attribute>
|
||||||
|
<xsl:attribute name="onBlur">self.status=''; return true;</xsl:attribute>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="attr/class!=''">
|
||||||
|
<xsl:attribute name="class"><xsl:value-of select="attr/class"/></xsl:attribute>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
</input>
|
||||||
|
</xsl:template>
|
197
etemplate/templates/default/test.xul
Normal file
197
etemplate/templates/default/test.xul
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<overlay>
|
||||||
|
<grid id="etemplate.test.keys" template="" lang="" group="0" version="0.9.13.003">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<textbox size="30" label="Name" id="name" statustext="name of the eTemplate, should be in form application.function[.subTemplate]"/>
|
||||||
|
<textbox size="12" label="Template" id="template" statustext="name of phpgw-template set (e.g. verdilak): '' = default (will read pref. template, us 'default' to read default template '')"/>
|
||||||
|
<textbox size="7" maxlength="5" label="Lang" id="lang" statustext="language-short (eg. 'en' for english) for language-dependent template ('' reads your pref. languages or the default, us 'default' to read the default template '')"/>
|
||||||
|
<textbox size="12" maxlength="10" label="Version" id="version" statustext="version-number, should be in the form: major.minor.revision.number (eg. 0.9.13.001 all numbers filled up with zeros)"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test.edit-buttons" template="" lang="" group="0" version="0.9.15.002">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<button label="Read" id="read" statustext="read eTemplate from database (for the keys above)"/>
|
||||||
|
<button label="Show (no save)" id="show" statustext="shows/displays eTemplate for testing, does NOT save it before"/>
|
||||||
|
<button label="Save" id="save" statustext="save the eTemplate under the above keys (name, ...), change them for a SaveAs"/>
|
||||||
|
<button label="Delete" id="delete" statustext="deletes the eTemplate spez. above"/>
|
||||||
|
<button label="Dump4Setup" id="dump" statustext="writes a 'etemplates.inc.php' file (for application in Name) in the setup-dir of the app"/>
|
||||||
|
<button label="Write Langfile" id="langfile" statustext="creates an english ('en') langfile from label and helptexts (for application in Name)"/>
|
||||||
|
<button label="Export XML" id="export_xml" statustext="export the loaded eTemplate into a xml-file"/>
|
||||||
|
<button label="Import XML" id="import_xml" statustext="import an eTemplate from a xml-file"/>
|
||||||
|
<file id="file" statustext="xml-file to import"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test.col_header" template="" lang="" group="0" version="0.9.13.003" width="100%">
|
||||||
|
<columns>
|
||||||
|
<column width="5%"/>
|
||||||
|
<column width="5%"/>
|
||||||
|
<column width="60%"/>
|
||||||
|
<column width="30%"/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<button label="+" no_lang="1" id="insert_col[0]" statustext="insert new column in front of all"/>
|
||||||
|
<button label=">|<" no_lang="1" id="exchange_col[$c_]" statustext="exchange this two columns"/>
|
||||||
|
<description options="b" no_lang="1" align="center" id=".col"/>
|
||||||
|
<textbox size="5" label="Width" align="right" id="width[$col_]" statustext="width of column (in percent or pixel)"/>
|
||||||
|
<button label="-" no_lang="1" align="right" id="delete_col[$c_]" statustext="delete whole column (can NOT be undone!!!)"/>
|
||||||
|
<button label="+" no_lang="1" align="right" id="insert_col[$c_]" statustext="insert new column behind this one"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test.row_header" template="" lang="" group="0" version="0.9.13.005" height="100%">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<button label="+" no_lang="1" id="insert_row[0]" statustext="insert new row in front of first Line"/>
|
||||||
|
<description value="Height" align="center"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<description options="b" no_lang="1" align="center" id=".row"/>
|
||||||
|
<textbox size="5" id="height[h$row_]" statustext="height of row (in percent or pixel)"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<button label="-" no_lang="1" align="center" id="delete_row[$row_]" statustext="remove Row (can NOT be undone!!!)"/>
|
||||||
|
<description value="class, Valign" align="center"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<button label="+" no_lang="1" id="insert_row[$row_]" statustext="insert new row after this one"/>
|
||||||
|
<textbox size="5" id="class[c$row_]" statustext="CSS-class name for this row, preset: 'nmh' = NextMatch header, 'nmr' = alternating NM row, 'nmr0'+'nmr1' NM rows"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test.cell_opts" template="" lang="" group="0" version="0.9.13.004" width="100%">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<checkbox label="%s needed" align="center" id="needed" statustext="check if field has to be filled by user"/>
|
||||||
|
<checkbox label="%s readonly" align="center" id="readonly" statustext="check if content should only be displayed but not altered (the content is not send back then!)"/>
|
||||||
|
<checkbox label="%s disabled" align="center" id="disabled" statustext="if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell"/>
|
||||||
|
<checkbox label="%s onChange" align="center" id="onchange" statustext="enable JavaScript onChange submit"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test.cell" template="" lang="" group="0" version="0.9.15.001" height="100%">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row class="nmr">
|
||||||
|
<description value="Type"/>
|
||||||
|
<menulist statustext="type of the field (select Label if field should be empty)">
|
||||||
|
<menupopup id="type"/>
|
||||||
|
</menulist>
|
||||||
|
<description value="Options" align="center"/>
|
||||||
|
<textbox size="10" id="size" statustext="Label:[bold][italic] Text:[len][,max] Numbers:[min][,[max][,len]] T.area:[rows][,cols] Radiob.:value H.Rule:[width] Templ.:[IndexInContent] Select:[multiselect] Date:[values: eg. 'Y-m-d']"/>
|
||||||
|
<description value="Span, Class" align="center"/>
|
||||||
|
<textbox size="10" id="span" statustext="number of colums the field/cell should span or 'all' for the remaining columns, CSS-class name (for the TD tag)"/>
|
||||||
|
</row>
|
||||||
|
<row class="nmr">
|
||||||
|
<description value="Label"/>
|
||||||
|
<textbox id="label" statustext="displayed in front of input or input is inserted for a '%s' in the label (label of the Submitbutton or Image-filename)"/>
|
||||||
|
<checkbox span="2" label="%s NoTranslation" align="center" id="no_lang" statustext="select if content of field should not be translated (label gets always translated)"/>
|
||||||
|
<description value="Align" align="center"/>
|
||||||
|
<menulist statustext="alignment of label and input-field in table-cell">
|
||||||
|
<menupopup id="align"/>
|
||||||
|
</menulist>
|
||||||
|
</row>
|
||||||
|
<row class="nmr">
|
||||||
|
<description value="Name"/>
|
||||||
|
<textbox id="name" statustext="index/name of returned content (name of the Template, Link / Method for Image)"/>
|
||||||
|
<grid span="4" id="etemplate.test.cell_opts"/>
|
||||||
|
</row>
|
||||||
|
<row class="nmr">
|
||||||
|
<description value="Help"/>
|
||||||
|
<textbox size="50" span="all" id="help" statustext="displayed in statusline of browser if input-field gets focus"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test.edit" template="" lang="" group="0" version="0.9.13.002" border="1" class="editorEdit">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row class="nmh">
|
||||||
|
<image src="navbar.gif" align="center"/>
|
||||||
|
<grid content="Col$col," id="etemplate.test.col_header"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<grid content="Row$row," class="nmh" id="etemplate.test.row_header"/>
|
||||||
|
<grid content="$col$row" id="etemplate.test.cell"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
<styles>
|
||||||
|
.editorEdit { border-color: black }
|
||||||
|
</styles>
|
||||||
|
</grid>
|
||||||
|
<grid id="etemplate.test" template="" lang="" group="" version="0.9.15.002" width="100%">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<description options="bi" value="Editable Templates - Editor" no_lang="1" id="msg"/>
|
||||||
|
<button label="DB-Tools" align="right" id="db_tools" statustext="to start the DB-Tools"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<hrule span="all"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<grid span="all" id="etemplate.test.keys"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<grid span="all" id="etemplate.test.edit-buttons"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<textbox span="all" label="Width, Height, Border, class, Spacing, Padding" id="size" statustext="width, height, border-line-thickness, CSS-class name, Celspaceing, Cellpadding (for TABLE tag)"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<grid span="all" id="etemplate.test.edit"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<description span="all" value="CSS-styles"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<textbox multiline="true" cols="10" rows="80" span="all" id="style" statustext="embeded CSS styles, eg. '.red { background: red; }' (note the '.' before the class-name) or '@import url(...)' (class names are global for the whole page!)"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
</overlay>
|
Loading…
Reference in New Issue
Block a user