User Tools

Site Tools


nupusi:nucleus:pluginmethods

Plugin Methods

All Nucleus plugins must inherit from the PHP class NucleusPlugin. If this sounds complicated, don't worry, it isn't. It even makes your life easier, allowing you to only implement the methods that your plugin needs, and giving access to some auxiliary functions.

Redefinable methods

Method Signature Explanation
getName()Returns the name of the plugin. This will be the name that will show up on the list of installed plugins. You should definately redefine this method, since the default implementation returns Undefined
getAuthor()Returns the name of author of the plugin. This name will show up on the list of installed plugins. You should definately redefine this method, since the default implementation returns Undefined
getURL()Returns the URL of the site where the plugin can be downloaded, or where additional information about the plugin can be found. If no such site exists, a mailto:-link with the authors email address is appropriate. You should definately redefine this method, since the default implementation returns Undefined
getDescription()Returns a longer description of the plugin. This will show up on the list of installed plugins. The default implementation returns Undefined
getVersion()Returns the current version of the plugin. Returns 0.0 by default
getMinNucleusVersion()(v2.0b) Returns the minimum required Nucleus version. By default, this returns 155 (v1.55). If you are using plugin features that were introduced later, please implement this function (e.g. v2.0 ⇒ 200). Please note that Nucleus v1.55 does not use this function at all, so it remains possible to install newer plugins there, even if they use newer features.
getMinNucleusPatchLevel()(v3.1) Returns the minimum required Nucleus patch level that needs to be present when running the minimal required Nucleus version (getMinNucleusVersion). By default, this returns 0. This function is generally used when new plugin features are available only as patches to the latest released Nucleus version.
init()Initializes the plugin. This method gets called immediately after the plugin object is created and the plugid-attribute has been set. By default, this method does nothing.
doSkinVar($skinType)When plugins are called using the <%plugin(…)%>-skinvar, this method will be called. the $skinType parameter contains the type of skin (item, archive, …) from where the plugin is called. Don't get confused by the fact that there's only one parameter. Multiple parameters can still be passed. More info on implementing the doSkinVar method. By default, this method does no output at all.
doTemplateVar(&$item)Basically the same as doSkinVar, but this time for calls of the <%plugin(…)%>-var in templates (item header/body/footer and dateheader/footer). By default, this method forwards the handling to the doSkinVar-method, using template as skintype. More information on implementing the doTemplateVar method
doTemplateCommentsVar(&$item, &$comment)(v2.0b) Basically the same as doSkinVar, but this time for calls of the <%plugin(…)%>-var in templates (comments-related parts). By default, this method forwards the handling to the doSkinVar-method, using template as skintype. More information on implementing the doTemplateCommentsVar method
doAction($type)When a plugin wants to allow user interaction, it can allow actions through action.php. This is the script that Nucleus uses itself to handle new comments and karma votes. Called with the correct parameters, the doAction-method from a plugin can be called. The $type contains an optional message type. Extra variables from the request can be accessed from within the doAction method. By default, this method returns a string No Such Action which will trigger an error message. More info on doAction.
install()This method gets called on the moment the plugin is installed. It can perform initializing actions, such as the creation of database tables, the creation of plugin options, etc… By default, this method does nothing.
unInstall()Called when the plugin is uninstalled. It's a good thing to clean up information your plugin created in the database at this point. By default, this method does nothing.
getEventList()Plugins can subscribe to events. Events get generated whenever Nucleus performs a certain action. An AddItem event for example, will call all plugins that subscribed to this event. The called method will be event_AddItem($params). The $params-parameter is an associative array containing several fields of information, like the itemid for AddItem. Returns an empty array by default, indicating that the plugin does not subscribe to any event at all. More information about events.
getTableList()This method should return an array of database tables that the plugin has created. It's used in the backup feature that Nucleus offers, so plugin tables are also included in the backup. By default, returns an empty array.
hasAdminArea()Should return 1 if the plugin has an admin area of its own, and 0 if it doesn't. By default, 0 is returned.
getPluginDep()(v3.2) Returns an array of plugin names. Nucleus refuses to install the plugin if any of these plugins is not installed. By default, an empty array is returned. More information on plugin dependencies.

Non-redefinable methods

Method Signature Explanation
createOption(…)
createBlogOption(…)(v2.2)
createCategoryOption(…)(v2.2)
createMemberOption(…)(v2.2)
createItemOption(…)(v3.2)
Creates a new option
deleteOption(…)
deleteBlogOption(…)(v2.2)
deleteCategoryOption(…)(v2.2)
deleteMemberOption(…)(v2.2)
deleteItemOption(…)(v3.2)
Deletes an option
setOption(…)
setBlogOption(…)(v2.2)
setCategoryOption(…)(v2.2)
setMemberOption(…)(v2.2)
setItemOption(…)(v3.2)
Sets the value of an option
getOption(…)
getBlogOption(…)(v2.2)
getCategoryOption(…)(v2.2)
getMemberOption(…)(v2.2)
getItemOption(…)(v3.2)
Retrieves the value of an option
getAllBlogOptions(…)(v2.2)
getAllCategoryOptions(…)(v2.2)
getAllMemberOptions(…)(v2.2)
getAllItemOptions(…)(v3.2)
For a given option, returns an associative of all values (one value per context)
getBlogOptionTop(…)(v3.2)
getMemberOptionTop(…)(v3.2)
getCategoryOptionTop(…)(v3.2)
getItemOptionTop(…)(v3.2)
For a given option, returns the top of all values
getID()Returns the ID for this plugin (this is the ID internally used inside Nucleus)
getAdminURL()Returns the URL of where the admin area of the plugin is located (if there is no such admin area, this information is invalid)
getDirectory()Returns the path in the servers filesystem where the extra files for the plugin are stored (if there are no such files, this information makes no sense). The result is something like “…/nucleus/plugins/plugname/
getShortName()Returns the part of the plugin classname without the ”NP_”-part, and in all-lowercase. This information is used in the functions getAdminURL and getDirectory
nupusi/nucleus/pluginmethods.txt · Last modified: 2008/12/06 13:56 (external edit)