Skip to content
Alexander Selifonov edited this page Sep 26, 2016 · 16 revisions

waPluginator is a tool for processing a sets of files to create a "stub" for further work - it can be initial set of files of a new module (or plugin) in your application, or a complete page (landing page for example) to publish in your site.

Before using waPluginator, you will have to define a set of templates:

  • choose a collections of files that will play a role of templates for generating output modules.
  • Modify them, by adding macros for further preprocessing, and move all of them into one zip file or subfolder.
  • Place this zip file / folder in the directory containing main waPluginator.php file.
  • Edit waPluginator.xml configuration file. It should contain <template ... > block with description of new attached "template".

BTW, you can leave intact configuration xml files waPluginator.xml and colorSchemes.xml as they can be overwritten if you pull latest version from github right in your folder. You can create your own config files and activate them by setConfigFile(), see a description of function setConfigFile() in function list.

Your set can contain php, html, css, js and other "source" files that will be preprocessed and files that will be copied as is (for example, font files and images).

What files will be processed, depends on their extensions. Initially waPluginator treats as "processable" the following files:

  • 'txt', 'php', 'inc', 'phtml', 'css', 'scss', 'less', 'htm', 'html', 'js', 'rb', 'py', 'c', 'cpp', 'xml', 'xhtml', 'json' All other files will be just copied as is from source to destination directory.

If you need other files to be processed, add their extensions by calling addSourceFileType($ext) (This is not needed for files that will be compiled by registered compilers - see compilers page).

waPluginator uses code preprocessor (latest version can be found in a github repository Current module placed in "lib" subfolder here.

Installing

  • Download current version of waPluginator and install it in current folder of your project or one of folders listed in "include_path"
  • If you're planning to use scss source files and want them to be compiled to css, you have to download current version of scssphp PHP library from github and install it into scssphp subfolder in one of folders listed in "include_path", so this code will work: include_once("scssphp/scss.inc.php")
  • If you're planning to use less source files and want them to be compiled to css, you have to download current version of lessc.inc.php library from github and copy it in one of folders listed in "include_path", so this code will work: include_once("lessc.inc.php")
  • In your code add a command include_once("waPluginator.php")
  • Don't forget to add one of jquery versions in your html code (any version from 1.10 to 2.x must be OK). jQuery version 2.2 included in demo/ durectory of this distributive.
  • Add js script as_jsfunclib.js to your HTML code. It is used for AJAX restoring previously used variable values and putting them to form fields. Script can be found in demo/ directory.

Using example

include_once('waPluginator/waPluginator.php');
// waPluginator::setBaseUri('./backend.php'); // USe it if you have your own backend module
waPluginator::autoLocalize();
waPluginator::setOptions(array(
        'appname' =>'Your application name'
       ,'author' =>'My Name'
       ,'email' =>'Myemail [at] acme.com'
       ,'link' =>'http://www.yoursite.com'
    )
);
$params = array_merge($_GET,$_POST);
if(!empty($params['action'])) {
    waPluginator::performAction($params);
    exit;
}
else {
    app::setPageTitle('Plugin generator');
    app::appendHtml('<br>');
    app::appendHtml(waPluginator::designerForm(true));
    app::finalize();
}

When you press "generate", waPluginator processes all files in chosen template, generates output files, and saves your values entered in designer associated with a chosen "class name" id.

When you open designer next time and enter the same class name, these values will be restored in the form. To do that, waPluginator saves them in file cfg/waPluginator.data, in current directory. If for some reason you want to use another directory as a "cfg folder", just change it :

waPluginator::$FOLDER_CFG = '../myfolder/';