Ralf Becker wrote:
Hi Vincent,
do you have an own so-object, or do you use so_sql as the tutorial. In
the later case you need to instantiate it in the constructor of bo like:
$this->so =& CreateObject(‘etemplate.so_sql’,‘myapp’,‘mytable’);
I personally prefer to extend the objects: so --> bo --> ui, as it saves
all these stubs als your bo_projekte::save().
------------- bo-class -------------------------------------------------
require_once(EGW_INCLUDE_ROOT.’/etemplate/inc/class.so_sql.inc.php’);
class bo_projekte extends so_sql
{
function bo_projekte()
{
// call the constructor of the extended class
$this->so_sql(‘projekte’,‘table-name’);
}
// more bo stuff …
}
------------- ui-class -------------------------------------------------
require_once(EGW_INCLUDE_ROOT.’/projekte/inc/class.bo_projekte.inc.php’);
class ui_projekte extends bo_projekte
{
function ui_projekte()
{
// call the constructor of the extended class
$this->bo_projekte();
}
function edit($content=null)
{
if (is_array($content))
{
if ($content[‘button’][‘save’])
{
unset($content[‘button’]);
$this->data = $content;
$this->save();
}
}
else
{
// initialising, eg.
$content = $this->read($_GET[‘id’]);
}
$tpl =& CreateObject(‘etemplate.etemplate’,‘projekte.edit’);
$tpl->exec(‘projekte.ui_projekte.edit’,$content);
}
}
Ralf
I try to do it this way but i get the same error:
Fatal error: Call to a member function save() on a non-object in
/var/www/egroupware/projekte/inc/class.ui_projekte.inc.php on line 58
here it is ui, bo, so
-------------------------ui -------------------------
require_once(EGW_INCLUDE_ROOT.’/projekte/inc/class.bo_projekte.inc.php’);
// CONSTRUCTOR der Klasse
// Klasse ui_projekte erbt alles von der Klasse bo_projekte (extends)
class ui_projekte extends bo_projekte
{
var $public_functions = array(
“edit” => True,
“writeLangFile” => True
);
function ui_projekte()
{
$this->tmpl =& CreateObject(‘etemplate.etemplate’, ‘projekte.edit’);
// call the constructor of the bo extended class
$this->bo_projekte();
// ALT $this->bo =& CreateObject('projekte.bo_projekte');
$this->html =& $GLOBALS['egw']->html;
if(!@is_object($GLOBALS['egw']->js))
{
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
}
}
function edit($content=null)
{
// Check if function was called as call back
if (is_array($content))
{
$r_id = $content['id'];
if ($r_id>0) // if we have an id -> read the entry
{
$content = $this->bo->read($content['id']);
}
if (isset($content['save']))
{
unset($content['save']);
$msg .= (!$this->bo->save($content))?lang('Entry
Saved’):lang(‘Error: while saving’);
}
elseif (isset($content[‘read’]))
{
unset($content[‘id’]);
unset($content[‘read’]);
$found = $this->bo->so->search($content, False,
‘name, beschreibung’);
if (!$found)
{
$msg .= lang('Nothing matched the search
criteria’);
}
else
{
$content = $found[0];
}
}
}
else
{
$content = array();
}
//now we fill the content array for the next call to etemplate.exec
$content = $content + array (
'msg' => $msg
);
$sel_options = array(
'status' => $this->bo->status
);
$no_button = array(
);
$preserv = array(
'id' => $this->data['id']
);
$this->tmpl->exec(
'projekte.ui_projekte.edit', // setting this function as the
callback
$content,$sel_options, $no_button,$preserv
);
}
}
?>
-------------------------bo -------------------------
require_once(EGW_INCLUDE_ROOT.’/etemplate/inc/class.so_sql.inc.php’);
class bo_projekte extends so_sql
{
var $status = array(
’’ => ‘Bitte w?hlen Sie …’,
‘angebot’ => ‘Angebot’,
‘auftrag’ => ‘Auftrag’,
‘ausfuehrung’ => ‘Ausf?hrung’,
‘abgeschlossen’ => ‘Abgeschlossen’,
‘archiviert’ => ‘Archiviert’
);
function bo_projekte()
{
// call the constructor of the extended class
// AppName, Tabellenname
$this->so_sql('projekte','egw_projekte');
// $this->so =& CreateObject('projekte.so_projekte');
}
function save($content)
{
echo ("<BR> -------------- bo SAVE -----------------
");
$this->so->save($content);
}
function read($content)
{
$this->so->search($content);
}
}
?>
-------------------------so -------------------------
include_once(PHPGW_INCLUDE_ROOT . ‘/etemplate/inc/class.so_sql.inc.php’);
class so_projekte extends so_sql
{
function so_projekte()
{
$this->so_sql(‘projekte’,‘egw_projekte’);
$this->empty_on_write = “’’”;
}
}
?>
–
View this message in context: http://www.nabble.com/own-Application---Fatal-error%3A-Call-to-a-member-function-on-a-non-object-tf2372708s3741.html#a6625823
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share your
opinions on IT & business topics through brief surveys – and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
eGroupWare-developers mailing list
eGroupWare-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-developers