ratatoeskr/sys/pluginpackage.php

Handle plugin packages easily.

License

This file is part of Ratatöskr.  Unlike the other parts of Ratatöskr, this file ist not licensed under the MIT / X11 License, but under the WTFPL, to make it even easier to use this file in other projects.  See “ratatoeskr/licenses/wtfpl” for more information.

Summary
ratatoeskr/sys/pluginpackage.phpHandle plugin packages easily.
Functions
dir2arrayPack a directory into an array.
array2dirUnpack an array into a directory.
InvalidPackageAn Exception that PluginPackage’s function can throw, if the package is invalid.
PluginPackageA plugin package representation.
Variables
Mandatory values
Optional values
Functions
validateValidate, if the variables are set correctly.
loadLoad a plugin package from binary data.
saveSave the plugin.
extract_metaGet just the metadata of this package.
PluginPackageMetaOnly the metadata of a PluginPackage.
Variables
Mandatory values
Optional values

Functions

dir2array

function dir2array($dir)

Pack a directory into an array.

Parameters

$dirThe directory to pack.

Returns

Associative array.  Keys are filenames, values are either the file’s content as a string or another array, if it’s a directory.

array2dir

function array2dir($a,
$dir)

Unpack an array into a directory.

Parameters

$aArray to unpack.
$dirDirectory to unpack to.

InvalidPackage

An Exception that PluginPackage’s function can throw, if the package is invalid.

PluginPackage

A plugin package representation.

Summary
Variables
Mandatory values
Optional values
Functions
validateValidate, if the variables are set correctly.
loadLoad a plugin package from binary data.
saveSave the plugin.
extract_metaGet just the metadata of this package.

Variables

Mandatory values

$codeThe plugin code
$classnameThe name of the plugins main class
$nameName of the plugin (must be at least one character, allowed chars: a-z A-Z 0-9 - _)
$authorThe author of the plugin (preferably in the format: Name<mail@address>)
$versiontextA text to describe the current version, something like “1.1 Beta”
$versioncountA number for this version, should be increased with every release
$apiThe used API version
$short_descriptionA short description.

Optional values

$updatepathA URL that points to a update information resource (serialize’d array(“current-version” => VERSIONCOUNT, “dl-path” => DOWNLOAD PATH); will get overwritten/set by the default repository software.
$webA URL to the webpage for the plugin.  If left empty, the default repository software will set this to the description page of your plugin.
$licenseThe license text of your plugin.
$helpA help / manual (formatted in HTML) for your plugin.
$custompubdir2array ‘d directory that contains custom public(i.e. can later be accessed from the web) data.
$customprivdir2array ‘d directory that contains custom private data.
$tplsdir2array ‘d directory containing custom STE templates.

Functions

validate

public function validate()

Validate, if the variables are set correctly.  Will throw an InvalidPackage exception if invalid.

load

public static function load($plugin_raw)

Load a plugin package from binary data.

Parameters

$plugin_rawThe raw package to load.

Returns

The PluginPackage object.

Throws

InvalidPackage if package is invalid.

save

public function save()

Save the plugin.

Returns

A binary plugin package.

Throws

InvalidPackage if package is invalid.

extract_meta

public function extract_meta()

Get just the metadata of this package.

Returns

A PluginPackageMeta object.

PluginPackageMeta

Variables

Mandatory values

$nameName of the plugin (must be at least one character, allowed chars: a-z A-Z 0-9 - _)
$authorThe author of the plugin (preferably in the format: Name<mail@address>)
$versiontextA text to describe the current version, something like “1.1 Beta”
$versioncountA number for this version, should be increased with every release
$apiThe used API version
$short_descriptionA short description.

Optional values

$updatepathA URL that points to a update information resource (serialize’d array(“current-version” => VERSIONCOUNT, “dl-path” => DOWNLOAD PATH); will get overwritten/set by the default repository software.
$webA URL to the webpage for the plugin.  If left empty, the default repository software will set this to the description page of your plugin.
$licenseThe license text of your plugin.
function dir2array($dir)
Pack a directory into an array.
function array2dir($a,
$dir)
Unpack an array into a directory.
A plugin package representation.
public function validate()
Validate, if the variables are set correctly.
public static function load($plugin_raw)
Load a plugin package from binary data.
public function save()
Save the plugin.
public function extract_meta()
Get just the metadata of this package.
An Exception that PluginPackage’s function can throw, if the package is invalid.
Only the metadata of a PluginPackage.
Close