Devoloping one's own modules
Posted: Wed Dec 26, 2007 8:42 pm
Hi,
I tried to get started with module programming. So I had a look at the tutorial in the wiki, which helped me quite much 'til now. Unfortunately there's nothing said about writing an admin panel, so I tried to have a look at other modules. I was able to install it, and it installs the link in the admin panel correctly. But, When I click on it, I get the following error:
That's my current code (I'm sorry for pasting about 100 lines, but I've no idea which are the relevant ones):
--edit--
and, as I see now, the table [cms_]module_sendeplan_shows is NOT created, only module_sendeplan_shows_seq. Can somebody explain me why? And by the way, what are these sequences (_seq) for?
I tried to get started with module programming. So I had a look at the tutorial in the wiki, which helped me quite much 'til now. Unfortunately there's nothing said about writing an admin panel, so I tried to have a look at other modules. I was able to install it, and it installs the link in the admin panel correctly. But, When I click on it, I get the following error:
The menu link is also away now, but when I go to another page, it's there again. Could anyone please help me?Fatal error: Call to a member function GetFriendlyName() on a non-object in ...\admin\moduleinterface.php on line 120
That's my current code (I'm sorry for pasting about 100 lines, but I've no idea which are the relevant ones):
Code: Select all
<?php
class Sendeplan extends CMSModule{
function GetName(){
return 'Sendeplan';
}
function GetFriendlyName(){
return "Sendeplan";#$this->Lang('friendlyname');
}
function GetVersion(){
return '1.0';
}
function GetHelp(){
return $this->Lang('help');
}
function GetAuthor(){
return 'Fabian Lenzen';
}
function GetAuthorEmail(){
return 'fabian.lenzen@web.de';
}
function GetChangeLog(){
return $this->Lang('changelog');
}
function IsPluginModule(){
return true;
}
function HasAdmin(){
return true;
}
function GetAdminSection(){
return 'content';
}
function GetAdminDescription(){
return $this->Lang('moddescription');
}
function VisibleToAdminUser(){
return $this->CheckPermission('Modify Sendeplan');
}
function GetDependencies(){
return array();
}
function MinimumCMSVersion(){
return "0.13";
}
function Install(){
// The module needs a database to store the shows to be broadcasted.
// let's set it up here.
$db = $this->cms->db;
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$dict = NewDataDictionary($db);
$flds =
"id I KEY,
short X,
long XL";
$sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_sendeplan_shows', $flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
$db->CreateSequence(cms_db_prefix().'module_sendeplan_shows_seq');
// left to create the permission structure.
$this->CreatePermission('Modify Sendeplan', $this->Lang('modsendeplan'));
// and the template
$this->SetTemplate('display', 'hiho');
}
function InstallPostMessage(){
return $this->Lang('postinstall');
}
function Uninstall(){
$db = $this->cms->db;
$dict = NewDataDictionary($db);
$sqlarray = $dict->DropTableSQL(cms_db_prefix() . 'module_sendeplan_shows');
$dict->ExecuteSQLArray($sqlarray);
$db->DropSequence(cms_db_prefix() . 'module_sendeplan_shows_seq' );
$this->RemovePermission('Modify Sendeplan');
}
function UninstallPostMessage(){
return $this->Lang('postuninstall');
}
function DoAction($action, $id, $params, $returnid=-1){
switch ($action){
case 'default':
$db =& $this->GetDb();
$sql = 'SELECT * FROM ' . cms_db_prefix() . 'module_sendeplan_shows;';
$dbresult =& $db->Execute($sql);
$items = Array();
while($dbresult && $row = $dbresult->FetchRow()){
$i = count($list);
$items[$i]['name'] = $row['name'];
$items[$i]['short'] = $row['short'];
$items[$i]['long'] = $row['price'];
}
$this->smarty->assign('items', $items);
echo $this->smarty->ProcessTemplate('template.tpl');
break;
case 'defaultadmin':
echo $this->StartTabHeaders();
echo $this->SetTabHeader('template', 'template', true);
echo $this->StartTabContent();
echo $this->StartTab('template', $params);
echo "hallo welt";
echo $this->EndTab();
echo $this->EndTabContent();
}
}
}
?>
and, as I see now, the table [cms_]module_sendeplan_shows is NOT created, only module_sendeplan_shows_seq. Can somebody explain me why? And by the way, what are these sequences (_seq) for?