Commit e2c01659 authored by Gerd Schachtschneider's avatar Gerd Schachtschneider
Browse files

Init basis xataface and common folder/files

parents
# nur wegen sortierung, statt in index.php
__sql__ = "SELECT lst.*, IF(vReit.reiter IS NULL, 0, 1) AS exist FROM list_reiter AS lst LEFT JOIN view_reiter AS vReit ON lst.reiter = vReit.reiter ORDER BY reiter"
[__global__]
noLinkFromListView = 1
[autoID]
# nur noch fuer alte DB's
noLinkFromListView = 0
widget:label = "TabID"
order = 10
[tabID]
noLinkFromListView = 0
order = 10
[reiter]
widget:type = select
widget:focus = 1
vocabulary = tables
widget:label = "Tabelle"
column:legend = "[Link]"
filter = 1
order = 20
[kategorie]
widget:type = select
vocabulary = kategorie
filter = 1
order = 30
[favorit]
widget:type = checkbox
widget:label = "Favorit"
widget:description = "Für den schnelleren Zugriff unter dem Menüpunkt 'Favorit'"
filter = 1
order = 40
[history]
widget:type = checkbox
widget:label = "Historie"
widget:description = "Soll History-Tabelle erhalten bleiben. Per Default werden alle per Cronjob gelöscht. In Views unbedeutend"
filter = 1
order = 50
[bedeutung]
widget:atts:size = 75
order = 60
[exist]
#transient = 1
visibility:list = hidden
filter = 1
order = 70
-- view auf list_reiter, weil COLLATE nicht erlaubt in xataface
-- !! achtung fuer jeden view einer datenbank eigenes TABLE_SCHAEMA !!
CREATE OR REPLACE VIEW view_reiter AS
SELECT
CONVERT(table_name USING utf8) COLLATE utf8_unicode_ci AS reiter,
table_type
FROM
information_schema.tables
WHERE
-- fuer jede db setzen
table_schema = 'mpidb_xxx' AND
( table_type = 'base table' OR table_type = 'view' )
;
<link rel="stylesheet" type="text/css" href="styles.css"/>
{*-------------------------------------------------------------------------------
* Dataface Web Application Framework
* Copyright (C) 2005-2006 Steve Hannah (shannah@sfu.ca)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*-------------------------------------------------------------------------------
*}
{load_record}
{use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_section"}
{if $ENV.prefs.show_result_controller}
{block name="before_details_controller"}
<div id="details-controller">{include file="Dataface_Details_Controller.html"}</div>
{block name="after_details_controller"}
{/if}
{block name="before_record_heading"}
{define_slot name="record_heading"}
<h2 class="dataface-record-title">{if $ENV.record}<span class="dataface-current-record-prelabel"><b>{translate id="templates.Dataface_Record.LABEL_CURRENT_RECORD"}Current Record{/translate}:</b> </span>{$ENV.record->getTitle()}{else}No Records Matched your Request{/if}</h2>
{/define_slot}
{block name="after_record_heading"}
{block name="before_record_tabs"}
{if $ENV.prefs.show_record_tabs}{record_tabs mincount=2 id="record_tabs" id_prefix="record-tabs-" class="contentViews" selected_action=$ENV.mode}
{actions var="menus" category="record_actions"}
{if $menus|@count > 0 }
<div id="contentActionsWrapper" class="contentActions">
<ul>
{foreach from=$menus item="menu" key="name"}
<li>
<a href="{$menu.url}"
id="record-actions-menu-{$menu.id}"
onmouseup="if (activeButton != null) resetButton(activeButton);"
title="{$menu.description}">
<img src="{$menu.icon}"
alt="" width="16" height="16" />
{$menu.label}
</a>
</li>
{/foreach}
</ul>
</div>
{/if}
<div class="documentContent" id="region-content" style="border: 1px solid gray">
{/if}
{block name="before_record_content"}
{define_slot name="record_content"}
Record Content goes here ...
{/define_slot}
{block name="after_record_content"}
{if $ENV.prefs.show_record_tabs}
</div>
{/if}
{block name="before_record_footer"}
{define_slot name="record_footer"}{/define_slot}
{block name="after_record_footer"}
{/fill_slot}
{/use_macro}
\ No newline at end of file
<?php
/**
* A delegate class for the entire application to handle custom handling of
* some functions such as permissions and preferences.
*/
class conf_ApplicationDelegate
{
/**
* Returns permissions array. This method is called every time an action is
* performed to make sure that the user has permission to perform the action.
* @param record A Dataface_Record object (may be null) against which we check
* permissions.
* @see Dataface_PermissionsTool
* @see Dataface_AuthenticationTool
*/
function getPermissions(&$record)
{
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
// if the user is null then nobody is logged in... no access.
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
// This will force a login prompt.
$role = $user->val('role');
return Dataface_PermissionsTool::getRolePermissions($role);
// Returns all of the permissions for the user's current role.
}
function block__tables_menu_tail()
{
$user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
// if the user is null then nobody is logged in... no access.
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
// This will force a login prompt.
$role = $user->val('role'); // get Role from mpi_users
if ( $role == 'MANAGER' or $role == 'ADMIN')
{
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$url = basename(DATAFACE_SITE_URL);
$cnt = count($app->_tables);
if ( count($app->_tables) <= 13 )
// entsprechend dataface/Dataface/Application.php
{
echo ' <li><a href="/'.$url.'/index.php?-table=mpi_users";
accesskey="accesskeys-navigation";
class="table-selection-tab";
title="Users";
id="TableLink_mpi_users">
Benutzer
</a></li>';
} else {
echo ' <div class="portletContent">
<a href="/'.$url.'/index.php?-table=mpi_users"
accesskey="accesskeys-navigation"
class="navItem "
title="Benutzer"
id="TableLink_mpi_users">
<img src="'.DATAFACE_URL.'/images/folder_icon.gif" alt="" class="navIconRoot" title="Benutzer" />
<span class="navItemText"> Benutzer </span>
</a>
</div>';
}
}
}
}
?>
/* global settings */
#left_column { display: none; }
/* body { font-size: 72%; } */
/* #main_table { font-size: 105%; } */
legend { background-color: transparent; }
div.top { background-color: whitesmoke; }
div.documentContent { background-color: #FFFCED; }
table.Dataface_QuickForm-table-wrapper { width: 100%; }
table.xf-grid-table { white-space: nowrap; }
table.xf-grid-table td { vertical-align: top; }
/* .discreet { color: DarkSlateBlue; text-align: left }
.portalMessage { background-color: #FFAAAA; }
.horizontalDivider { display: none; } */
.contentViews li a:hover,
.contentViews .selected a,
.contentActions li,
.contentActions li a,
.contentActions { color: #426071; background-color: #bed0da; border-color: #426071; float: none; }
.contentViews,
.contentViews li,
.contentViews li a { color: #426071; border-color: #426071; }
/* Ueberschriften allg. etwas groesser per Default */
h1 { font-size: 120%; }
h2 { font-size: 115%; }
h3 { font-size: 110%; }
h4 { font-size: 105%; }
/* Text im Modus Ansicht etwas vergroessern */
table.record-view-table td { font-size: 100%; }
table.record-view-table th { font-size: 100%; }
li.Dataface_GlanceList-item { font-size: 110%; }
.date { font-weight: normal; }
/* global table edit background colors */
td.Dataface_QuickForm-label-cell {
width: 17%;
/* color: #00264d; */
text-align: right;
vertical-align: top;
background-color: #aec4d0; }
td.Dataface_QuickForm-widget-cell,
tr.listing.odd td { background-color: #f2f2f2; }
tr.listing.even td { background-color: #fafafa; }
[__global__]
noLinkFromListView = 1
[autoID]
widget:label = "TabID"
[reiter]
key = PRI
widget:label = "Tabelle"
column:legend = "[Link]"
filter = 1
[kategorie]
filter = 1
[favorit]
visibility:list = hidden
[history]
visibility:list = hidden
[bedeutung]
widget:atts:size = 75
<?php
class tables_list_reiter {
/*
// geht leider wegen xataface parser nicht, deshalb per view
function __sql__() {
$app = Dataface_Application::getInstance();
$db = $app->_conf['_database']['name'];
return "SELECT lst.*, IF(shw.reiter IS NULL, 0, 1) AS exist FROM list_reiter AS lst LEFT JOIN ( SELECT CONVERT(table_name USING utf8) COLLATE utf8_unicode_ci AS reiter, table_type FROM information_schema.tables WHERE table_schema = '$db' AND ( table_type = 'base table' OR table_type = 'view' ))AS shw ON lst.reiter = shw.reiter";
}
*/
// loeschen nur fuer admin oder manager erlaubt
function getPermissions($record) {
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('role'); // get Role from mpi_users
if ( $role == 'MANAGER' or $role == 'ADMIN') return;
return Dataface_PermissionsTool::getRolePermissions('EDIT');
}
// zeige alle noch nicht erfassten tabellen als auswahl
function valuelist__tables() {
$app = Dataface_Application::getInstance();
$db = $app->_conf['_database']['name'];
static $user = -1;
if ( !is_array($tables) ) {
$tables = array();
$res = mysql_query("SHOW FULL TABLES FROM $db WHERE NOT EXISTS ( SELECT * FROM list_reiter AS lst WHERE lst.reiter = Tables_in_$db COLLATE utf8_unicode_ci )", df_db());
if ( !$res ) throw new Exception(mysql_error(df_db()));
while ($row = mysql_fetch_row($res)) $tables[$row[0]] = $row[1].' : '.$row[0];
}
return $tables;
}
function reiter__renderCell( &$record ) {
$table = $record->strval('reiter');
if ( $record->strval('exist') == '0' ) return '<font color="red">'.$table.'</font>';
return '<a href="'.DATAFACE_SITE_HREF.'?-table='.$table.'">'.$table.'</a>';
}
function beforeSave(&$record) {
if ($record->strval('bedeutung') == NULL) {
$record->setValue('bedeutung', $record->strval('reiter'));
}
}
}
?>
<table width="80%">
<tr>
<th>&#160;&#160;&#160;&#160;</th>
<td></td>
<th>Plz</th>
<td>{$elements.plz.html}</td>
<th>Ort</th>
<td>{$elements.ort.html}</td>
<th>Strasse</th>
<td>{$elements.strasse.html}</td>
</tr>
<tr>
<th>&#160;&#160;&#160;&#160;</th>
<td></td>
<th>Bundesland</th>
<td>{$elements.stateBundesland.html}</td>
<th>Land</th>
<td>{$elements.land.html}</td>
</tr>
</table>
<?php
class tables_view_favorit {
// check login & editieren nicht erlaubt
function getPermissions($record) {
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
return Dataface_PermissionsTool::getRolePermissions('READ ONLY');
}
// table read only
function getRoles(&$record) {
return 'READ ONLY';
}
function reiter__renderCell( &$record ) {
$table = $record->strval('reiter');
return '<a href="'.DATAFACE_SITE_HREF.'?-table='.$table.'">'.$table.'</a>';
}
function block__after_result_list_content() {
$url = DATAFACE_SITE_HREF."?-table=list_reiter&-action=list";
echo 'Zum hinzuf&uuml;gen setze Checkbox Favorit in der gew&uuml;nschten Tabelle <a href='.$url.'>list_reiter</a>';
}
function autoID__renderCell(&$record) {
$table = 'list_reiter';
$action = 'edit';
$field = 'autoID';
$tabID = $record->val($field);
$name = $tabID;
$url = DATAFACE_SITE_HREF."?-table=${table}&-action=${action}&${field}=${tabID}";
return '<div style="text-align:left;"><a href="'.$url.'">'.$name.'</a></div>';
}
}
?>
<?php
class tables_view_reiter {
// check login & editieren nicht erlaubt
function getPermissions($record)
{
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
return Dataface_PermissionsTool::getRolePermissions('READ ONLY');
}
}
?>
[forgot_password]
;; entspricht disabled
[manage]
;; entspricht disabled
[my_profile]
;; entspricht disabled
[change_password]
;; entspricht disabled
[rss]
;; entspricht disabled
[record_rss > rss]
;; entspricht disabled
[related_rss]
;; entspricht disabled
[export_xml]
;; entspricht disabled
[view_xml]
;; entspricht disabled
[related_xml > export_xml]
;; entspricht disabled
[xml_list]
;; entspricht disabled
[printable_report]
icon="{$site_url}/images/printer.png"
category=result_list_actions
description="See this product list in a printable format"
url="{$app->url('-action=printable_report')}"
;; # bestimmte Tabellen nur
;; condition="$query['-table'] == 'mpi_kosten'"
;; # nur admin darf drucken
;; permission=reports
<link rel="stylesheet" type="text/css" href="styles.css"/>
<link rel="stylesheet" type="text/css" href="custom.css"/>
[kategorie]
__sql__ = "SELECT kategorie FROM list_katReiter ORDER BY kategorie"
<?php
class tables_view_reiter {
// check login & editieren nicht erlaubt
function getPermissions($record)
{
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
return Dataface_PermissionsTool::getRolePermissions('READ ONLY');
}
}
?>
{if $section.field.description}<div class="formHelp">{$section.field.description|escape}</div>{/if}
{block name="before_quickform_table"}
{if $section.field.display_style=='inline'}
{assign var="table_tag" value="span"}
{assign var="tr_tag" value="span"}
{assign var="td_tag" value="span"}
{assign var="th_tag" value="span"}
{assign var="thead_tag" value="span"}
{assign var="tbody_tag" value="span"}
{else}
{assign var="table_tag" value="table"}
{assign var="tr_tag" value="tr"}
{assign var="td_tag" value="td"}
{assign var="th_tag" value="th"}
{assign var="thead_tag" value="thead"}
{assign var="tbody_tag" value="tbody"}
{/if}
<{$table_tag} width="100%" class="Dataface_QuickForm-table-wrapper xf-form-group {if $section.field.display_style=='inline'}xf-form-group-inline{/if} " data-xf-record-id="{$form_record_id|escape}">
{*
#03 - Inner elements loop
--------------------------
Now we go through each element in this section and render
it.
*}
{foreach from=$elements item=element}
{*
#04 - Render Element
------------------------------
This section is used to render an element to be displayed.
*}
{block name="before_`$element.field.name`_row" table=$element.field.tablename}
{define_slot name="`$element.field.name`_row" table=$element.field.tablename}
<{$tr_tag} id="{$element.field.name}_form_row">
{if $element.field.widget.template}
<{$td_tag} colspan="2">{include file=$element.field.widget.template element=$element}</{$td_tag}>
{else}
<{$td_tag} {if $element.field.display == 'block'}colspan="2" class="Dataface_QuickForm-textarea-label-cell Dataface_QuickForm-block-label-cell"{/if} valign="top" {if $element.field.display != 'block'}align="right" class="Dataface_QuickForm-label-cell {$element.field.tablename} {$element.field.relationship}"{/if}>
<div class="field {if $element.error}error{/if}" id="{$element.field.tablename}-{$element.field.name}-label-wrapper">
<label>
{if $element.field.label_link or $element.field.label_click}
<a href="{if $element.field.label_link}{$element.field.label_link|escape}{else}#{/if}" target="_blank" {if $element.field.label_click}onclick="{$element.field.label_click|escape}" {/if}class="field-label-link no-link-icon">
{/if}{$element.field.widget.label}{if $element.field.label_link or $element.field.label_click}</a>
{/if}
</label>
{if $element.required}
<span style="color: #ff0000" class="fieldRequired" title="required">&nbsp;</span>
{/if}
{if $element.field.display != 'block'}
</div>
</{$td_tag}>
<{$td_tag} class="Dataface_QuickForm-widget-cell {$element.field.tablename} {$element.field.relationship} {if $isText} Dataface_QuickForm-textarea-widget-cell{/if}">
<div class="field {if $element.error}error{/if}" id="{$element.field.tablename}-{$element.field.name}-wrapper">
{/if}
{if $element.error}
<div class="fieldError" style="color: #ff0000">{$element.error}</div>
{/if}
{if $element.field.display == 'block'}{if !$element.frozen}
<div class="formHelp">{$element.field.widget.description}</div>
{else}
<div class="formHelp">{$element.field.widget.frozen_description}</div>
{/if}
{/if}
{if $element.properties.preview}
<div id="{$element.field.tablename}-{$element.field.name}-preview">
{define_slot name="`$element.field.name`_preview_image" src=$element.properties.image_preview}
{if $element.properties.image_preview}