Chapter 1: Introduction Up Main page Chapter 3: Your First InterWorx Plugin 

2 Getting the Lay of the Land

2.1 Basic Requirements

Plugin developers should have some experience with the PHP programming language and at a minimum a basic understanding of object-oriented programming.

2.2 NodeWorx vs SiteWorx

  • NodeWorx is the server level control panel interface, accessible via http://yourserver.tld:2443/nodeworx . It provides server-level controls for managing SiteWorx accounts, reseller accounts, system services, backups and restoring, and clustering, as well as system-level IP management, distribution, and much more.
  • SiteWorx is the website level control panel interface, accessible via http://yoursite.tld:2443/siteworx . It provides tools for maintaining domain-level users, IPs, e-mail accounts, MySQL databases, statistics analysis, backups, an interface for uploading and downloading files to and from your web space, among other services.

2.3 Controllers and Actions

  • A controller is a part of programming architecture that houses the actions for a particular segment of an application. The controller actions allow the user to modify the interface and output as needed. Each controller generally corresponds to a “page” in the control panel.
  • An action is a thing that can be performed. Some actions change things, some actions query data.
  • The default action for a controller is called the indexAction. This action is executed when the controller is loaded without any other actions being called. It is the action that generally displays the default content for the controller or page, if applicable.
  • Commit actions are those that perform a measurable, concrete change to the system. As opposed to actions that simply query information or list data, commit actions are typically used to add, edit, or delete data records at a user’s request. Commit actions with forms require clear and concise function comments, with the following format:
    Figure 2.1 ~iworx/plugins/cloudflare/Ctrl/SW/Cloudflare.php
    1/**
    2 * Enable Cloudflare for a subdomain.
    3 *
    4 * @param Form_SW_Cloudflare_Enable $Form
    5 */
    6public function enableCommitAction( Form_SW_Cloudflare_Enable $Form ) {
    
  • Plugins can hook into existing Controller Actions, or establish new Controllers and Actions.
  • Plugins can also take advantage of existing InterWorx actions.

2.4 Menus

NodeWorx and SiteWorx each have menus that are used to navigate through their respective interfaces. There are two types of “menu styles”, known as the “big” and “small” menu styles. The big menu style displays the menu as a full page set of icons when the user logs in. The small menu style displays the menu on the left hand side of the interface. Plugins can interact with the menu, and any change made will automatically be reflected in either menu style.
Plugins interact with the menus by defining updateSiteworxMenu() or updateNodeworxMenu() functions in the Plugin Class file (see below).
figure images/plugins/small-menu-style.png
Figure 2.2 Small Menu Style Example

figure images/plugins/big-menu-style.png
Figure 2.3 Big Menu Style Example

2.5 Templates

Plugin templates are view components responsible for the elements displayed to the user. Managed by the plugin controllers, templates are where visual elements are defined and laid out.

Via the controller actions, developers can modify the template output (and thereby the view) to reflect state changes in the plugin data.

2.6 Files and Directory Structure

  • Required Files
    The required files for a proper plugin structure are few, but each is key to the proper functioning of the plugin:
    • Plugin Directory: ~iworx/plugins/[plugin-name]
      This is the directory where all files relevant to the plugin are stored. Here, ’plugin-name’ should be short, hyphen separated (no spaces or underscores), and lowercase.
    • Plugin INI file: ~iworx/plugins/[plugin-name]/plugin.ini
      The plugin INI contains plugin metadata, such as the version, author, and a brief description.
    • Plugin Class file: ~iworx/plugins/[plugin-name]/Plugin/[PluginName].php
      This is the core of the plugin and contains the majority of its functionality, such as data storage, InterWorx menu updates, and enabling/disabling of the plugin. ’PluginName.php’ should reflect the naming of ’plugin-name’ above, with hyphens removed and each word capitalized.
  • Optional Files
    The following files are optional to the core operation of a plugin, but allow users to further personalize their plugin interface:
    • Plugin NodeWorx Controller file: ~iworx/plugins/[plugin-name]/Ctrl/Nodeworx/[PluginUrl].php
      With this file present, a user will be able to control how the plugin is represented in the NodeWorx interface (if necessary). The naming of this file determines the URL of the controller — in this case we’d find it at /nodeworx/plugin/url.
    • Plugin SiteWorx Controller file: ~iworx/plugins/[plugin-name]/Ctrl/Siteworx/[PluginUrl].php
      Much like above, this file allows for control of the plugin with regards to the SiteWorx interface. The naming of this file determines the URL of the controller — in this case we’d find it at /siteworx/plugin/url.
    • Plugin default template file: ~iworx/plugins/[plugin-name]/templates/default.tpl
      The core template file, this file controls the layout and presentation of the plugin’s output in-browser.
  • Other files can be included as necessary, such as those for input forms, images, payloads, formatters, custom libraries, and data sources. These are more advanced features and described in detail later on.
 Chapter 1: Introduction Up Main page Chapter 3: Your First InterWorx Plugin 

(C) 2017 by InterWorx LLC