Configuring the plugin config file

From PHPDevShell

Jump to: navigation, search

The plugin file is extremely simple to setup. This will give you many possibilities in maintaining and installing your plugin for PHPDevShell.

Please see http://phpdevshell.org/project/dummyplugin for a plugin example.

You will be able to Install, Upgrade and Uninstall;

  • 8 Different menus items.
  • Unlimited queries.
  • Hook scripts.
  • Plugin Settings.

This makes it easy for the user to simply copy your plugin to the plugin folder and hit install. It will also give you the ability to distribute or sell your plugin separately.

So lets have a look inside the plugin.config.xml file. Let us explain the contents of the plugin.config.xml in detail;

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- Start plugin config XML -->
<config type="plugin">
    [contains][All install, upgrade and uninstall tags.]
    [params][type][string][This tells the system that this is a plugin config.]
    <name>
        [string][The name and folder of your plugin.]   
    </name>
    <version>
        [string][Human readable version number of your plugin.]
    </version>
    <description>
        [string][a Short description of your plugin.]
    </description>
    <founder>
        [string][If the plugin/script is modification by you, place the original authors names here.]
    </founder>
    <author>
        [string][Name of the developer for this plugin.]
    </author>
    <email>
        [string][Email address of the developer for this plugin.]
    </email>
    <homepage>
        [string][Plugin developers email address.]
    </homepage>
    <date>
        [string][Date the plugin was developed, modified etc, this is up to you.]
    </date>
    <copyright>
        [string][Copyright notice you would like to amend to your plugin.]
    </copyright>
    <license>
        [string][License this plugin is released under.]     
    </license>
    <info>
        [string][Detailed information and help for this plugin.]
        [note][Use <![CDATA[ ]]> tags to format html.]
    </info>
     <versionurl current="">
          [contains][The URL to the xml containing the latest plugin version available.]
          [param][current][int][mandatory][The software version might be different then the database version.]
     </versionurl>
    <install version="">
    [contains][All query, menu, hooks, settings installation tags.]
    [param][version][int][mandatory][The latest database version in numbers only.]
    [note][This is how the plugin manager will know to what version upgrade scripts should be executed.]
    [note][Always keep pluginInstall maintained to the latest menu, query, hooks and setting versions.]         
        <queries>
            [contains][All install queries to create the tables for your plugin.]
            <query>
                [string][This is a single actual sql query that will be executed]
                [note][SQL query be placed in <![CDATA[ ]]> tags.]
                </query>
                <query>
                [note][The query tag should be repeated for each query.]
                </query>
        </queries>
        <settings>
          [contains][Contains tags of all settings that needs to be installed to the general PHPDevShell settings database.]
             <setting write="">
                [string][Actual value of setting that needs to be stored.]
                [param][write][string][mandatory][The parameter id of the value to be stored.]
             </setting>
             <setting write="">
                [note][Setting tag needs to be repeated for each setting.]
             </setting>
        </settings>
        <menus>
          [contains][All types of menu items that needs to be installed.]
          [note][Tags inside menus can be nested and repeated.]
             <menu name="" type="" link="" hide="" rank="" newwindow="" plugin="" parentlink="" symlink="" template="" height="" noautopermission="">
                [contains][Menu items can be contained in itself, this will create a menu tree.]
                [param][name][string][not-mandatory][The name of the menu item, if empty the pluginName.menu.lang.php will be used.]
                [param][type][int][not-mandatory][There are 8 menu types, 1 is the default if left empty.]
                        [1][Plugin script] normal plugin menu item in your plugin folder.
                        [2][Link existing menu] item while staying in its own menu group when clicked.
                        [3][Link existing menu] item while jumping to original scripts menu group when clicked.
                        [4][External file] Include external PHP web applications into PHPDevShell.
                        [5][HTTP URL] Normal url to outside web.
                        [6][Empty Place Holder] This item will only serve as a unclickable menu place holder.
                        [7][iFrame] Link url to both external url or onsite url.
                        [8][Cronjob Menu Type] The same as a plugin script but is set as cronjob.
                [param][link][string][mandatory][The url, script location or symlink holder will be entered here depending on type.]
                [param][hide][int][not-mandatory][There are 4 hide types, 0 is the default if left empty.]
                        [0] Do not hide menu item.
                        [1] Hide menu item from both Menu System and Control Panel.
                        [2] Hide menu item from Control Panel only.
                        [3] Hide menu item from Menu System only.
                [param][rank][string][not-mandatory][If you want to ensure ranking positions, will auto rank if left empty.]
                        [int] Can be ranked with integer.
                        [last] Will be ranked last in a menu group.
                        [first] Will be ranked first in a menu group.
                [param][newwindow][int][not-mandatory][To make item open in new window set to 1, will not open in new if left empty.]
                [param][plugin][string][not-mandatory][Plugin name, use to install menu item to a different plugins menu structure.]
                [param][alias][string][not-mandatory][This allows you to create a custom alias for SEF menu url, if empty = auto created.]
                [param][parentlink][string][not-mandatory][Use with [param][plugin] or without to install in different structure.]
                [param][symlink][string][not-mandatory][Url or location with [param][plugin] or without to link to another menu item.]
                        [note][Symlink is mandatory for menu types 1,2,6]
                [param][template][string][not-mandatory][Set template to use with plugin, if template is unavailable it will be installed.]
                [param][template][string][not-mandatory][Set the height of an iframe menu type.]
                        [note][Height is mandatory for menu types 7]   
                [param][noautopermission][int][not-mandatory][Set to 1 to not add the installer of the plugin to permit menu item access.]
                <menu link="/sample1.php">
                    [note][Can be nested to present a deeper menu tree.]
                    <menu link="/sample2.php"></menu>
                    <menu link="/sample3.php">[note][Can be repeated.]</menu>
                </menu>
                [note][New menus on upgrades should be added here, this will always be the model on upgrades.]
            </menu>
        </menus>
        <hooks>
            [contains][Contains hook scripts to be installed inside other scripts and plugins.]
            <hook plugin="" hookinlink="" hookpoint="" hookprefix="">
                [contains][Nothing, works from parameters only.]
                [param][plugin][string][mandatory][Name of plugin where script is located to hook.]
                [param][hookinlink][string][mandatory][File location from [param][plugin] where script to be hooked is located.]
                [param][hookpoint][string][mandatory][What hook point should the script be hooked in.]
                        [note][Please see hook documentation to gain access and see what hooks point are available in scripts.]
                [param][hookprefix][string][mandatory][Your plugin hooks script to be called when hook location is reached.]
                        [note][To call sample.hooks.php name hookPrefix="sample", it will then load pluginName/hooks/sample.hook.php]
                        [note][In your sample.hooks.php you will set on what hook point will what piece of code run.]
                [note][Please see the hooks manual for more information on hooks.]
                [note][Hooks changes on upgrades should be done here, this will always be the model on upgrades.]
                </hook>
        </hooks>
    </install>
    <upgrade version="">
        [contains][All query, menu, settings upgrade tags.]
        [param][version][int][mandatory][This upgrade version, will upgrade until pluginInstall[version] is met.]
        [note][This is how the plugin manager will know to what version upgrade scripts should be executed.]
        <queries>
            [contains][All upgrade queries to create the tables for your plugin.]
            <query>
                [string][This is a single actual sql query that will be executed on upgrade.]
                [note][SQL query be placed in <![CDATA[ ]]> tags.]
                </query>
                <query>
                [note][The query tag should be repeated for each upgrade query.]
            </query>
        </queries>
        <settings>
          [contains][Contains tags of all settings that needs to be upgraded or removed from the general PHPDevShell settings database.]
          <setting write="">
              [string][Actual value of setting that needs to be stored.]
              [param][write][string][mandatory][The parameter id of the value to be stored.]
              </setting>
              <setting delete="">
               [contains][Nothing, works from parameters only.]
               [param][delete][string][mandatory][The parameter id of the value to be deleted.]
               </setting>
               <setting write="">
                [note][Setting tag needs to be repeated for each setting added.]
                </setting>
                <setting delete="">
                [note][Setting tag needs to be repeated for each setting deleted.]
                </setting>
        </settings>
        <menus>
         [contains][All menus that should be deleted.]
         [note][To add menus on upgrades the master pluginInstall must always be modified with latest menus.]
         [note][Old menus should still be deleted even though they have been removed from pluginInstall.]
            <menu delete="">
             [contains][Nothing, works from parameters only.]
             [param][delete][string][mandatory][The link to the item that needs to be deleted.]
             [note][It does not matter where link for this menu item exists, it will find it automatically.]
            </menu>
            <menu delete="sample/sample.php">
             [note][This tag can be repeated to delete multiple menus.]
            </menu>
        </menus>
    </upgrade>
   <upgrade version="">
        [note][This tag can be repeated with all child tags for each release that needs upgrade action.]
    </upgrade>
    <upgrade version="">
        [note][Will run through all pluginUpgrade on upgrade until pluginInstall version is met.]
    </upgrade>
    <uninstall>
        [contains][All actions that will be executed on uninstalling a plugin.]
        [note][Menus, settings and hooks will be uninstalled automatically for this plugin.]
        <queries>
            [contains][All uninstall queries that will be executed when requested.]
            <query>
                [string][This is a single actual sql query that will be executed on uninstalling plugin.]
                [note][SQL uninstall query be placed in <![CDATA[ ]]> tags.]
                </query>
                <query>
                [note][The query tag should be repeated for each uninstall query.]
                </query>
        </queries>
    </uninstall>
</config>

Well, that concludes it for the plugin config file. It might seem overwhelming at first but as soon as you start getting used to it, it is but a breeze. Lets not stop here, we need to take a look at a full example.