Difference between revisions of "Addons"
Line 1: | Line 1: | ||
This article explais, how to create an addon for GExtension. | This article explais, how to create an addon for GExtension. | ||
+ | |||
+ | See [[Code Structure] for information about how GExtension is coded. '''IMPORTANT!''' | ||
== Folder Structure == | == Folder Structure == | ||
Line 5: | Line 7: | ||
That's your main addon folder, where all files of your addon should be in. Additionally, you can create the following subfolders: | That's your main addon folder, where all files of your addon should be in. Additionally, you can create the following subfolders: | ||
− | |||
/api | /api | ||
/assets | /assets | ||
Line 16: | Line 17: | ||
The meaning and function of those folders are explained below. Please try to imitate the folder structure of the GExtension core files. | The meaning and function of those folders are explained below. Please try to imitate the folder structure of the GExtension core files. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Addon Folder == | == Addon Folder == |
Revision as of 12:48, 19 April 2017
This article explais, how to create an addon for GExtension.
See [[Code Structure] for information about how GExtension is coded. IMPORTANT!
Contents
Folder Structure
The folder structure is similar to the one of Garry's Mod. First, you should create a folder: "addons/[your-addon]"
That's your main addon folder, where all files of your addon should be in. Additionally, you can create the following subfolders:
/api /assets /language /main /pages /request /settings /themes
The meaning and function of those folders are explained below. Please try to imitate the folder structure of the GExtension core files.
Addon Folder
Additionaly to the subfolders named above, the main addon folder can contain some more files:
- addon.txt: Optional. Contains a json object with information about the addon, important at the moment are, "author" and "version".
- install.php: Optional. If existent, gives the user the ability to run a one-time setup to complete the addon installation. Possible by navigating to Admin -> Settings -> Addons. Must contain a function Install(). The process will create a installed.txt in the main addon folder, containing the date of the installation and the steamid64 of the user who ran it.
- uninstall.php: Optional. If existent, this script will be run when the addon gets uninstalled (by navigating to Admin -> Settings -> Addons). Should be used to remove any leftovers. Must contain a function Uninstall()
Section: pages
Name and first line
The pages section represents all pages a user could be able to visit. The filename should be <rawname>.php, where <rawname> is a lowercase identifiert. Pages for administrative purposes should begin with "admin_".
The first line of a page PHP file should always be the following:
<!--{"language":"<language-identifier>","icon":"<fontawesome-icon>","place":"<main|help|admin|user|none>","position":<position>}-->
Example:
<!--{"language":"search","icon":"fa-search","place":"main","position":40,"nologin":true}-->
Additionally is it possible to add the "nonlogin" paramter, to define that a page can be used without being logged in. See FontAwesome for icons.
Security Check
To verify that the file was included by GExtension, it's required to include the following code after the first line:
<?php if(!isset($G_MAIN)){ die(json_encode(array("error" => "authentification failed"))); } ?>
Other
After creating a page, it is available under index.php?t=<rawname>. <rawname> is the name of the file without ".php".
You may want to allow a common page for all groups:
Permissions::AllowPagesForEveryone($rawname1, $rawname2, ...);
Check out existing pages for examples.
Working In Progress
This artile will be extended soon.