User Menu
Keywords
WikyBlog.com
What CMS
|
Plugins > Namespace ClassAll plugins and data types actually require a namespace. A normal wiki page uses the "page" namespace and all special pages go through the "special" namespace. By creating another namespace with an appropriate class, plugins like the event and event map data types at Gaboons.com and the forum at PapyrusBB.com can be created. The easiest way to start a namespace data type is to use the Custom Data Types tool in the administrator's control panel, but to make a truly customized plugin, you'll need to dabble in the php code. Namespace: Hello World (3.1)We'll start with the minimum implementation of a Namespace Class by again, sending the Hello World message.
config.php<?php $installInfo['class'] = 'helloNamespace31'; hello.php<?php class helloNamespace31{ var $links = array(); function helloNamespace31($type){ $this->objectType = $type; } function getOwner(&$pathArray){ return $GLOBALS['wbAdminUser']; } function getStep1(&$pathArray){} function getStep2(){ message('Hello World'); } } See Plugin 3.1.helloNamespace
Custom Data Types Tool (3.2)The fastest and easiest way to create a new namespace class is to use the Custom Data Types tool in the administrator's control panel. By using this tool, the required configuration, MySQL table and the PHP class are automatically created. Here's an simplified example of the resulting code. config.php<?php $installInfo['class'] = 'helloNamespace32'; $installInfo['dbTable'] = "`{$wbTablePrefix}xt_hellonamespace32`"; class.php<?php defined('WikyBlog') or die('Not an entry point...'); class helloNamespace32 extends dbPage{ var $content; var $dbValues = array('owner'=>1,'title'=>1,'content'=>1); var $userValues = array('content'=>1,'keywords'=>1); function helloNamespace32($type){ $this->objectType = $type; $this->setDbInfo(); } function setLinks(){ global $page,$pageOwner,$langA; parent::setLinks(); $page->displayTitle = $langA[$this->objectType] .' > '.toDisplay($this->title); $page->regLink('?','32helloNamespace'); } function newPage(){ global $includeDir,$page,$userLanguage,$langA; parent::newPage(); if( $this->editable ){ $this->content = wbLang::text('DEFAULT_CONTENT',$this->uniqLink); if( empty($page->userCmd) && cookies() ){ $page->userCmd = 'edit'; } }else{ $this->content = $langA['DEFAULT_CONTENT_PROTECTED']; } } } sql.php<?php defined('WikyBlog') or die('Not an entry point...'); $dbData = 'a:1:{s:19:"xt_hellonamespace32";a:5:{s:6:"Engine";s:6:"MyISAM";s:9:"Collation";s:15:"utf8_general_ci";s:15:"Default_charset";s:4:"utf8";s:7:"columns";a:6:{s:7:"file_id";s:47:"`file_id` int(8) unsigned NOT NULL DEFAULT \'0\' ";s:5:"owner";s:29:"`owner` varchar(20) NOT NULL ";s:5:"title";s:29:"`title` varchar(40) NOT NULL ";s:7:"summary";s:37:"`summary` varchar(200) DEFAULT NULL ";s:10:"hitcounter";s:56:"`hitcounter` mediumint(8) unsigned NOT NULL DEFAULT \'0\' ";s:7:"content";s:24:"`content` text NOT NULL ";}s:4:"keys";a:2:{s:7:"PRIMARY";s:30:"PRIMARY KEY (`owner`, `title`)";s:7:"file_id";s:28:"UNIQUE `file_id` (`file_id`)";}}}'; Notes
|