mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:18 +01:00
inital import: example app et_media of the tutorial
This commit is contained in:
parent
92063df450
commit
28faa7a146
162
etemplate/doc/et_media/inc/class.et_media.inc.php
Normal file
162
etemplate/doc/et_media/inc/class.et_media.inc.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - eTemplates - Tutoria Example - a simple MediaDB *
|
||||
* 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$ */
|
||||
|
||||
if(!isset($GLOBALS['phpgw_info']['flags']['included_classes']['so_sql']))
|
||||
{
|
||||
include(PHPGW_API_INC . '/../../etemplate/inc/class.so_sql.inc.php');
|
||||
$GLOBALS['phpgw_info']['flags']['included_classes']['so_sql'] = True;
|
||||
}
|
||||
|
||||
class et_media extends so_sql
|
||||
{
|
||||
var $messages = array(
|
||||
'nothing_found' => 'Nothing matched search criteria !!!',
|
||||
'anz_found' => '%d matches on search criteria',
|
||||
'saved' => 'Entry saved',
|
||||
'error_writeing' => 'Error: writeing !!!'
|
||||
);
|
||||
var $types = array(
|
||||
'' => 'Select one ...',
|
||||
'cd' => 'Compact Disc',
|
||||
'dvd' => 'DVD',
|
||||
'book' => 'Book',
|
||||
'video' => 'Video Tape'
|
||||
);
|
||||
|
||||
function et_media($lang_on_messages = True)
|
||||
{
|
||||
$this->tmpl = CreateObject('etemplate.etemplate','et_media.edit');
|
||||
|
||||
$this->so_sql('et_media','phpgw_et_media'); // sets up our storage layer using the table 'phpgw_et_media'
|
||||
$this->empty_on_write = "''"; // that means if a column is empty how to write in the db, the default is NULL
|
||||
|
||||
$this->public_functions += array(
|
||||
'edit' => True,
|
||||
'writeLangFile' => True
|
||||
);
|
||||
|
||||
if ($lang_on_messages)
|
||||
{
|
||||
reset($this->messages);
|
||||
while (list($key,$msg) = each($this->messages))
|
||||
$this->messages[$key] = lang($msg);
|
||||
}
|
||||
}
|
||||
|
||||
function edit($content='',$msg = '')
|
||||
{
|
||||
if (is_array($content)) // not first call from index
|
||||
{
|
||||
if ($content['id'] > 0)
|
||||
{
|
||||
$this->read($content);
|
||||
}
|
||||
//echo "<p>edit: content ="; _debug_array($content);
|
||||
$this->data_merge($content);
|
||||
//echo "<p>edit: data ="; _debug_array($this->data);
|
||||
|
||||
if (isset($content['save']))
|
||||
{
|
||||
$msg .= $this->messages[!$this->save() ? 'saved' : 'error_writeing'];
|
||||
}
|
||||
elseif (isset($content['read']))
|
||||
{
|
||||
unset($content['id']);
|
||||
$found = $this->search($content,False,'name,author');
|
||||
|
||||
if (!$found)
|
||||
{
|
||||
$msg .= $this->messages['nothing_found'];
|
||||
}
|
||||
elseif (count($found) == 1)
|
||||
{
|
||||
$this->init($found[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->show($found);
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif (isset($content['cancel']))
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
elseif (isset($content['delete']))
|
||||
{
|
||||
$this->delete();
|
||||
$this->init();
|
||||
}
|
||||
elseif (isset($content['entry']['edit']))
|
||||
{
|
||||
list($id) = each($content['entry']['edit']);
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->read(array('id' => $id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now we filling the content array for the next call to etemplate.exec
|
||||
|
||||
$content = $this->data + array(
|
||||
'msg' => $msg
|
||||
);
|
||||
$sel_options = array(
|
||||
'type' => $this->types
|
||||
);
|
||||
$no_button = array(
|
||||
'delete' => !$this->data[$this->db_key_cols[$this->autoinc_id]]
|
||||
);
|
||||
$this->tmpl->exec('et_media.et_media.edit',$content,$sel_options,$no_button,array(
|
||||
'id' => $this->data['id']
|
||||
));
|
||||
}
|
||||
|
||||
function show($found)
|
||||
{
|
||||
if (!is_array($found) || !count($found))
|
||||
{
|
||||
$this->edit();
|
||||
return;
|
||||
}
|
||||
reset($found);
|
||||
for ($row=1; list($key,$data) = each($found); ++$row)
|
||||
{
|
||||
$entry[$row] = $data;
|
||||
}
|
||||
$content = array(
|
||||
'msg' => sprintf($this->messages['anz_found'],count($found)),
|
||||
'entry' => $entry
|
||||
);
|
||||
$this->tmpl->read('et_media.show');
|
||||
|
||||
$this->tmpl->exec('et_media.et_media.edit',$content);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function writeLangFile
|
||||
@abstract writes langfile with all templates and messages registered here
|
||||
@discussion can be called via http://domain/phpgroupware/index.php?et_media.et_media.writeLangFile
|
||||
*/
|
||||
function writeLangFile()
|
||||
{
|
||||
$etm = new et_media(False); // no lang on messages
|
||||
|
||||
$this->tmpl->writeLangFile('et_media','en',$etm->messages);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
13
etemplate/doc/et_media/index.php
Normal file
13
etemplate/doc/et_media/index.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$GLOBALS['phpgw_info']['flags'] = array(
|
||||
'currentapp' => 'et_media',
|
||||
'noheader' => True,
|
||||
'nonavbar' => True
|
||||
);
|
||||
include('../header.inc.php');
|
||||
|
||||
$et_media = CreateObject('et_media.et_media');
|
||||
|
||||
$et_media->edit();
|
||||
|
||||
$GLOBALS['phpgw']->common->phpgw_footer();
|
23
etemplate/doc/et_media/setup/phpgw_en.lang
Normal file
23
etemplate/doc/et_media/setup/phpgw_en.lang
Normal file
@ -0,0 +1,23 @@
|
||||
%d matches on search criteria et_media en %d matches on search criteria
|
||||
author et_media en Author
|
||||
cancel et_media en Cancel
|
||||
clears the form, without changing anything et_media en clears the form, without changing anything
|
||||
click here to edit the entry et_media en click here to edit the entry
|
||||
delete et_media en Delete
|
||||
deletes an entry et_media en deletes an entry
|
||||
description et_media en Description
|
||||
edit et_media en Edit
|
||||
entry saved et_media en Entry saved
|
||||
error: writeing !!! et_media en Error: writeing !!!
|
||||
etemplates mediadb et_media en eTemplates MediaDB
|
||||
here goes the name of the publication / record et_media en here goes the name of the publication / record
|
||||
name et_media en Name
|
||||
nothing matched search criteria !!! et_media en Nothing matched search criteria !!!
|
||||
please use name, first name et_media en please use Name, First Name
|
||||
read et_media en Read
|
||||
reads or searches for entries matching the criteria above et_media en reads or searches for entries matching the criteria above
|
||||
save et_media en Save
|
||||
saves the change to the db et_media en saves the change to the db
|
||||
select the type fitting most et_media en select the type fitting most
|
||||
type et_media en Type
|
||||
we have a fulltext search using that description et_media en we have a fulltext search using that description
|
17
etemplate/doc/et_media/setup/setup.inc.php
Normal file
17
etemplate/doc/et_media/setup/setup.inc.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$setup_info['et_media']['name'] = 'et_media';
|
||||
$setup_info['et_media']['title'] = 'eT-Media';
|
||||
$setup_info['et_media']['version'] = '0.9.15.001';
|
||||
$setup_info['et_media']['app_order'] = 100; // at the end
|
||||
$setup_info['et_media']['tables'] = array('phpgw_et_media');
|
||||
$setup_info['et_media']['enable'] = 1;
|
||||
|
||||
/* Dependacies for this app to work */
|
||||
$setup_info['et_media']['depends'][] = array(
|
||||
'appname' => 'phpgwapi',
|
||||
'versions' => Array('0.9.13','0.9.14','0.9.15')
|
||||
);
|
||||
$setup_info['et_media']['depends'][] = array( // this is only necessary as long the etemplate-class is not in the api
|
||||
'appname' => 'etemplate',
|
||||
'versions' => Array('0.9.13','0.9.14','0.9.15')
|
||||
);
|
17
etemplate/doc/et_media/setup/tables_current.inc.php
Normal file
17
etemplate/doc/et_media/setup/tables_current.inc.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$phpgw_baseline = array(
|
||||
'phpgw_et_media' => array(
|
||||
'fd' => array(
|
||||
'id' => array('type' => 'auto','nullable' => False),
|
||||
'name' => array('type' => 'varchar','precision' => '100','nullable' => False),
|
||||
'author' => array('type' => 'varchar','precision' => '100','nullable' => False),
|
||||
'descr' => array('type' => 'text','nullable' => False),
|
||||
'type' => array('type' => 'varchar','precision' => '20','nullable' => False)
|
||||
),
|
||||
'pk' => array('id'),
|
||||
'fk' => array(),
|
||||
'ix' => array(),
|
||||
'uc' => array()
|
||||
)
|
||||
);
|
Loading…
Reference in New Issue
Block a user