Copyright © 2006 solgracia
July 8th, 2006
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Abstract
This manual documents how sifbuilder works. sifbuilder intends to be a web site generator. For this, it incorporates a scriptable installation framework and an automatic installer, a package management system, a declarative site definition model, a remote execution framework, a test environment and a catalog of PHP programs and components.
Notice
This script should be run exclusively on a development site and only after having done a full backup of the whole system and database environments and knowing how to restore the last working snapshot. Please read the disclaimer before using this program.
sifbuilder is and Open Source program to create web sites. It lists, downloads and installs PHP components. Normally, these PHP components are wcm cores, modules, blocks and themes. It may backup and restore a web site and synchronize it with the packages registered in the update server. Complementing the automatic generation of web sites, it includes a module generator that generates the code of a functional module on the basis of the declarative definition of a relational schema.
Instructions may be passed to the program as script parameters or in a declarative xml file available either locally or via a url.
The basic components of the installation process are the sif packages -a sif package is referred to as a sip- containing the logic to download, explode, copy, activate and configure modules, blocks and themes to build the target site.
To abstract the building process, sifbuilder relies on the SIF framework that implements an API to common installation and configuration functions. These, available via the site object avaliable from each installation package, are implemented as classes covering module, block, panel and theme objects. Each installation package may extend the common API within thier own sip and export them form a dao. Currently, frameworks exist for PostNuke, OpenStar, XOOPS and MDPro. Cores that are automatically installed with sifbuilder but without a configuration API yet include drupal, joomla, sugarcrm, mantisbt and dotProject.
The latest release of sifbuilder may be downloaded from sourceforge at http://sf.net/projects/sifbuilder/
Sifbuilder may be used in the following scenarios.
There is a sourceforge forum at the sifbuilder project web site at Source Forgehttp://sf.net/forum/forum.php?thread_id=1190346&forum_id=428029
There is also a forum on sifbuilder for OsCommerce at the OsCommerce web site at http://forums.oscommerce.com/index.php?showtopic=107772&hl=sif
News on sifbuilder may be found at Sourceforge news: http://sf.net/news/?group_id=125777
News and forums are available also on the sifbuilder home at http:/www.sifbuilder.com/
Assuming that the PHP cli is in the include path,
php sifcmd.php i PostNuke07_core_postnuke
Will find the last release available for PostNuke, will download it from the package server and will install it in a site with parameters that will be prompted to the user.
php sifcmd.php b PostNuke07_script_intranet01
Will create a site with the packages specified in the build file for the PostNuke07_script_intranet01 sip. If the intention is to install the site onto the previously created instance, the command may be complemented with the -x option.
php sifcmd.php b PostNuke07_script_sifmoduler
Will create a module according to the relational model described in PostNuke07_script_sifmoduler_0_0_2_build.xml.
php sifcmd.php b --sifpacksdir=../sifpacksdir --sifnetsite=sis_sbos_at_localhost.xml --dev --reinstall OpenStar4_script_sifbuilderweb --buildfile=OpenStar4_script_sifbuilderweb_0_0_2_build_siftheme.xml
Will create, in forced mode and with pod pre-cleaning, a site as defined in OpenStar4_script_sifbuilderweb_0_0_2_build_siftheme.xml according to the site definition in sis_sbos_at_localhost.xml
php sifcmd.php b XOOPS2_core_xoops --sifnetsite=sbx2_at_localhost
Will create a core xoops site pre-cleaning the site database and filesystem if exist.
php sifcmd.php b XOOPS2_script_sif
Will create a composite xoops site as defined inthe xml build file in the XOOPS2_script_sif sip directory.
The main purpose of sifbuilder is to create a fully operational and configured web site with a single command instruction following the specifications in an xml site definition file.
It is still possible to install modules or blocks, apply themes or create module entities, such as publications or topics, on an existing web site.
In general, the sifbuilder process may be read as follows:
|
do create the web site http://{$site_admin_username}:{$site_admin_password}@{$site_host}/{$site_name}/{$site_pod}/ |
|
installed at directory file://{$dir_fs_document_root}/{$site_name}/{$site_pod}/ |
|
using the database: {$db_type}://{$db_username}:{$db_password}@{$db_server}/{$db_database} |
|
applying the sips listed in the command line. |
The general program usage is
php sifcmd.php [sifaction] [params] [sips]
A sifaction, or sifop, corresponds to a methods of the SifApi class. An important subset of these functions apply to sips and are aimed to transpose, transfer, install, remove, update or build packages onto sites. Some sif actions, however, refer to the program or to the site and do not require specification of sips as parameters.
params may be siteParams that refer to the usual parameters that determine the site to be generated and runParams that influence the way in which the program is run. Syntactically they are identical and siteParams could be considered as a subset of runParmas. However, siteParams may be specified other than as command options and are addressed separately in the code.
sip(s) are installation packages associated to PHP programs, modules, themes, blocks or scripts that encapsulate the generative logic. sips have associated specific sipParams that are defined from the .rcd file in the sip directory.
Besides the runParams, the siteParams and the sipParams, the configParams defined at the sifConfigParmas.php file complete the group of parameter sets that define the execution context and conform the behavior of the program.
Details of options are listed with # php sifcmd.php
sif actions are normally indicated as the first parameter in the command line following the sifcmd.php script file. They correlate to public methods in the SifApi class (preceeded by the 'sif_' prefix) and may correspond also to sip functions (proceeded by the 'sip_' prefix) in the sip classes.
| Action | Behaviour |
| ? | show_usage |
| b | sip_build_site |
| c | config_site |
| g | sip_transpose_site |
| h | show_history |
| i | sip_install_site |
| l | list_sips |
| r | sip_remove_site |
| s | show_config |
| t | run_usecase |
| u | sip_upgrade_site |
| x | empty_pod |
| backup_site | Backup a site. Create a sql dump of a site database and a zip file of the site file system. |
| build_program | Create a clone of the sifbuilder program in the sifbuilder/siftmp/sifUpload dir. It is used to generate the program for publication. |
| build_release | Build the release of sif packages and sif frameworks and copy it to the sifbuilder/siftmp/sifUpload dir. It is used to generate a release of installation packages to upload to the update server. |
| clean_site | For each directory in the site dir, clean the pod identified by that directory. The directory name is taken as the name of the database name and of the site root directory. Used to remove multiple sites that have been created under the same site name following that naming criteria. If all systems supported table prefixes, it should correspond to the db prefix instead of the db name. |
| clean_pod | Drop the database and remove file system of the current site. The database name and the site root directory are taken from the active site params. |
| config_site | Interactive definition of the siteParams defining the target site to be generated. |
| deldebug | Remove the debug file generated by sifbuilder. When running in command mode, sifbuilder outputs debug information to console or to file. When running in module mode, debug information is output only to file and this is the only way to find out why the script may not have come to an end or has jumped some step because of an error. The default debug file path is defined in the configParams and may be modified in a runParam. The deldebug action will work against the default debug path. However, if the level of debug output is high, information such as the credential may be output to file. If the default file has been left with the default value, that information may be accessible from the web. Therefore, the path to the debug file must always be non-accessible to web users. |
| dumpdb | Creates a xml dump of the database as generated by metabase. The file is saved in the dump_file_name configParam. |
| empty_site | Similar to clean_site but, instead of dropping the database, drops the tables within the database. This is relevant in some hosting sites that provide an already created database. |
| empty_pod | Empty the database and remove file system of the site defined by the siteParams. |
| list_sips | List the sips available in the sifbuilder installation, by default in the sips directory. |
| list_usecases | List the use cases available for the run_usecase action. Use cases are defined in the sifnet_usecases.php file in the sifbuilder root directory |
| restore_site | Creates the database with the sql file and the site file system with the tar file created by the backup action. |
| rlist | List the sips available in the update-server, by default www.sifbuilder.com. The output includes the sif package name and package release version, the status of the local package version in relation to the same in the update server, indication if the package is already installed in the target site as defined by siteParmas and the package description. For test, it is possible to make the local host play the role of the update server with the sifnetdomain runParam. |
| rsync | Synchronize sif packages and sif frameworks from update server into the sifbuilder working environment. This means that the sips and sifs directories will be replaced with the information downloaded from the sifnetdomain. A backup copy of existing sips and sifs will be created in tmpBackup. |
| run_usecase | Run a use case as defined in sifnet_usecases.php. A usecase may imply an upload from the lochost to the nethost, a download from the nethost to the lochost, or a sif action at the nethost against a netsite, as defined in the sifnet_config.php file. Usually, it is a combination of those action and may intend to test a local or a remote installation. |
| show_codes | List individual codes assigned to sif packages per core and package. |
| show_config | Show the configuration of the sifbuilder target site as defined by the siteParams. These parameters are set in the sifSiteParams.xml file, by means of the config_site sif action or as siteParams in the command line. |
| show_history | Show the history of installed packages as available in the sif registry. The history file is usually created and maintained in the site pod directory. |
| show_usage | Show the usage of the sifbuilder program as command line script. |
| show_version | Shows the version of the local sifbuilder installation and that of the program available in the update server. |
| sip_build_site | Build a site on the basis of the build files associated to the sips passed to the script. A build file may include specification of the siteParmas and runParams per site and of the buildParams per sip. The buildParams may include instructions to install modules, add blocks to panels, remove rows from blocks, apply themes, set configVars, create publications, add news, create forum categories. Since it supports the creation of multiple sites, a build file may specify the installation of PostNuke and Sugarcrm and the integration of sugar authentication in PostNuke. the sip_build_site action defaults to sip_install_site. |
| sip_install_site | Install a list of packages into the sif site. If the installation action applies to modules, it implies the module initialization and installation. If it applies to a them, it results normally in the application of the theme to the site. In all cases, it implies transpose and transfer of the package files. Installation of a sif package may have associated a number of dependencies. A dependency is usually a reference to a versioned package, eventually qualified by a core. A typical example is the installation of a pagesetter publication. It depends on pagesetter and therefore on the dependencies of pagesetter, notably PostNuke. Normally sifbuilder is going to check the dependencies not yet installed in the target site and, if this is not supported, in the sif registry, and propose them for installation.. In the force mode, sifbuilder will limit to the sips specified in the command. In this case, the behavior of the program may be affected by the modifiers 'complete' and 'reinstall'. |
| sip_remove_site | Will remove a package or list of packages from a target site as defined by the sifParams. |
| sip_transfer_site | Copy the package files from the sifbuilder packages area to the site file system. The default sifbuilder packages area is the packages directory in the sifbuilder directory. However, it may be useful to place it outside the sifbuilder root. This may be done with the 'sifpacksdir' runParam. |
| sip_transpose_site | The transpose sit action is composed of the download of the package tar form the package server and its uncompress to the sifbuilder packages area. The download will not be done if the tar, as define in the package record file, is already available, and it will not be uncompressed if the corresponding directory is not empty. In some cases, it may be useful to force the download or the uncompress. This may be done with the 'get' and 'unpack' runParmas. |
| sip_upgrade_site | Upgrade a list of packages at the sif site. An upgrade of a package is proposed if an installation is issued against a site having a precedent version of the intended module. |
The siteParams define the target site that sifbuilder will create or configure. siteParams may be passed as options to the sifbuilder script. The following command will install the PostNuke core on the site defined by the parameters in the instruction:
php sifcmd.php i --site_host=localhost --site_name=sifbuilder --site_pod=pn
--db_server=localhost --db_database=pn --db_prefix=pn --db_dbtype=mysql
--db_tabletype=myisam --db_username=root --db_password=pwd_root
--site_admin_username=admin --site_admin_password=pwd_admin
--dir_fs_document_root=D:/htdocs/ --sys_temp=pnTemp --encodedpwd=1
--enable_ssl=0 PostNuke07_core_postnuke
These parameters may also be set interactively and saved to the sifSiteParams.xml file by the config_site sif action, then listed by show_config. Various sif actions will directly call config_site and invite the use to set the site configuration params.
The following table lists the site parameters, which are normally used to build the configuration file in a new installation and to accreditate the program as admin within an existing site to preform the installation tasks:
| siteParam | Description |
| --site_host | the name of the target web host or virtual directory. If installed in a local server, the site_host will be localhost. This may also be site/dev.example or www.example.com. |
| --site_name | the name of the web site to be installed. This is a directory entry in the target web host. |
| --site_pod | this is the path to a section within the site. If localhost is the site_host and site_name is set to sifbuilder and site_pod is set to pn, the site directory will be in win similar to http://localhost/sifbuilder/pn/ |
| --site_admin_username | the user to be used to modify the tables in the site database. This will also be the admin user for the target site. |
| --site_admin_password | the password of the database owner user. |
| --db_database | the name of the database supporting the target site. |
| --db_dbtype | a database type supported by the target web content management site. |
| --db_tabletype | should normally be myisam. |
| --db_username | the user with root access to the database management system. This is necessary to create the core database if it does not exist. |
| --db_password | the password of the database user. |
| --db_prefix | the prefix for the tables to be used in the data management functions. |
| --dir_fs_document_root | This may be D:/webroot/ or /home/httpd/example.com/site/html/ . This is the absolute path to the web root dir including trailing slash. |
| --encodedpwd | tag specifying if the password is saved encoded in the database. This is generally true. |
| --enable_ssl | Support https - not implemented. |
| OPTIONAL | REQUIRED BY SOME WCM |
| --site_admin_email | emal for site admin |
| --site_admin_url | url for site admin |
The siteParams are dependent of the core web content management system or modular PHP application. The following table shows typical parameters with some wcms.
| siteParam | PostNuke | OpenStar | Xoops | MDPro | OsCommerce |
| site_name | sifbuilder | sifbuilder | sifbuilder | sifbuilder | sifbuilder |
| db_database | pn | os | xoop | md | osc |
| db_dbtype | mysql | mysql | mysql | mysql | mysql |
| db_tabletype | myisam | myisam | myisam | myisam | myisam |
| site_host | localhost | localhost | localhost | localhost | localhost |
| dir_fs_document_root | D:/htdocs/ | D:/htdocs/ | D:/htdocs/ | D:/htdocs/ | D:/htdocs/ |
| db_server | localhost | localhost | localhost | localhost | localhost |
| db_username | root | root | root | root | root |
| db_password | pwd_root | pwd_root | pwd_root | pwd_root | pwd_root |
| site_admin_username | admin | admin | admin | admin | admin |
| site_admin_password | pwd_admin | pwd_admin | pwd_admin | pwd_admin | pwd_admin |
| db_prefix | pn_ | os_ | xoops_ | md | [null] |
| site_pod | pn | os | xoops | md | osc |
| sys_temp | pnTemp | pnTemp | |||
| encodedpwd | true | true | true | true | false |
| enable_ssl | false | false | false | false | false |
A sample siteParams file, that should be customized for each wcm site, is:
<xml>
<site_host>localhost</site_host>
<site_name>sifbuilder</site_name>
<site_pod>os2</site_pod>
<db_server>localhost</db_server>
<db_database>os2</db_database>
<db_prefix>os_</db_prefix>
<db_dbtype>mysql</db_dbtype>
<db_tabletype>myisam</db_tabletype>
<db_username>root</db_username>
<db_password>pwd_root</db_password>
<site_admin_username>admin</site_admin_username>
<site_admin_password>pwd_admin</site_admin_password>
<dir_fs_document_root>d:/htdocs/</dir_fs_document_root>
<sys_temp>pnTemp</sys_temp>
<encodedpwd>1</encodedpwd>
<enable_ssl>0</enable_ssl>
</xml>
An option not to configure the siteParams each time that sample siteParams file, that should be customized for each wcm site, is to refer to the properties defined in a site class in sifnet_config_local.php or sifnet_config.php, if the local file has not been created. Thus,
php sifcmd.php i --sifnetsite=sbpn07_at_localhost PostNuke07_core_postnuke
will create a site wit hthe parameters defined in the sbpn07_at_localhost class. Those parameters may be passed also via a file. Thus,
php sifcmd.php i --sifnetsite=file://sbpn07_at_localhost.xml PostNuke07_core_postnuke
will take the siteParams from the local sbpn07_at_localhost.xml. The uri may refer to a xml file on the net:
php sifcmd.php i --sifnetsite=http://www.sifbuilder.com/downloads/sbpn07_at_localhost.xml
PostNuke07_core_postnuke
runParams are options that influence the behavior of the sifbuilder program. When passed in the command line they may either be switches, in the form of -s or --switch that set an option to true or false, or as parameters as --runParam=value. The runParams switches are the following:
| runParam | Behaviour |
| -f | --force |
| -g | --get |
| -h | --history |
| -n | --noinstall |
| -u | --unpack |
| -x | --cleanpod |
| -xx | --cleansite |
| -q | --quiet |
| -d | --error |
| -dd | --warning |
| -ddd | --info |
| -dddd | --debug |
| -ddddd | --verbose |
| -r | --rsync |
| -c | --complete |
| -v | --sifnetdorun |
| --get | Force download of package even if tarball found in packages dir. |
| --unpack | Force package tarball unzip even if package dir is not empty. |
| --cleanpod | Clean pod before proceeding with action. Implies complete sips list. |
| --cleansite | Clean site before proceeding with action. Implies complete sips list. |
| --deldb | Drop database. |
| --emptypod | Empty pod before proceeding with action. Implies complete sips list. |
| --emptysite | Empty site before proceeding with action. Implies complete sips list. |
| --force | Force the execution of the script on the default behavior without user interaction. |
| --noinstall | Jump package installation. |
| --history | Show history before proceeding with sif action. |
| --quiet | Remove debug output. |
| --error | Show error-level debug output. |
| --warning | Show warning-level debug output. |
| --info | Show info-level debug output. |
| --debug | Show debug output. |
| --verbose | Show verbose output. |
| --rsync | Synchronize sips and sifs before executing the sif action, normally an install or build. |
| --reinstall | Reinstall a package even if registered as installed. |
| --nocheck | Ignore running controls. |
| --notransfer | Do not copy package to site dir. |
| --notranspose | Do not download or explode package. |
| --noupd | Consider also the old version of packages. |
| --dev | Consider also packages in development status. |
| --modc | Copy packages when building the program. |
Some switches are sometimes referred to as modifiers. The reason for this terminological distinction is that, when passed to the program, modifiers have a particularly strong impact on the behavior of the program. They are not inherited when there is a possibility of recursivity.
The modifiers have to do with the pre-removal of a site: clean_site, clean_pod, empty_site and empty_pod; with the forced installation of a package even if it appears as already installed: reinstall; the addition of dependencies to the list of packages to process: complete; and with the run mode that eliminates interaction with the user: force .
The list of runParams, i.e.. of the options that are passed to the program with a value, excluding the siteParams, are:
| runParam | Behaviour |
| -p=value | --proxy |
| -s=value | --podid |
| --buildfile=value | Build file that will be used by the sip_build_site action. Otherwise, the default build file will be used. |
| --dbgtype=value | Type of debug output device: file, console, both. |
| --podid=value | podid. Shortcut to assign a single code to the database, prefix and site directory. |
| --proxy=value | Proxy to be used in http downloads. |
| --sifnetdomain=value | Domain that will be used as the sif server. |
| --siflochost=value | local host. Example, from-host in an upload, or to-host in a download. |
| --sifnethost=value | net host that where the sif action will be applied. |
| --sifnetsite=value | net site that where the sif action will be applied. |
| --sifnetconfigfile=value | sifnetconfigfile. |
| --sifnetusecasesfile=value | sifnetusecasesfile. |
| --sifnetdorun=value | sifnetdorun. |
| --sifpacksdir=value | the sifpacksdir, that defaults to the packages dir in the sifbuilder root, as defined in sifConfigParams, is the directory where the site packages will be download and uncompressed. If a new version of sifbuilder is downloaded and replaces the existing one, the site packages may be lost. Thereby, it may be useful to change that location, for example with the following option: --sifpacksdir=../sifpacksdir |
The installation of site components -modules, blocks, themes- is done by the sif packages (sips), usually on the basis of site packages that may have been downloaded from the servers where they are hosted. sips are composed of at least two files, a xml file ('sipRelease_rcd.xml') describing the package record, and a php file ('sipRelease_sip.php') that implements the processing logic.
sips usually contain a third component, xml files called build files, that encapsulate the logic to integrate a module into a target site. The build files are used by the sip_build_site sif action, which, by default, employs build file named sipRelease_build.xml, where sipRelease corresponds to the identifying name of the sip. Others may be included with the sip and referred to using the --buildfile=value runParam.
For most functions in sifbuilder, site packages including wcm cores, modules, blocks, themes and plugins, are normally downloded, exploded, transferred to the site directory, installed, activated and configured.
Ideally, the package is downloaded from the original download server. Then, it is exploded into the sifpacks directory. By default, if the tar ball is present, the download stepped is bypassed. Similarly, if the corresponding directory in the sifpacks directory is not empty, the package is not exploded. The transpose action, that includes the download and uncompression, is implied by default by the install action. This default behaviour may be modified with options such as --get, that forces the download of the site package, --exploded, that forces the decompression of the tar ball. The integrity of the files is controlled by the md5 signature that is defined at the moment in which the package is registered by sif.
Code generation usually relies on templates of classes and the declarative definition of a model to generate operational code with the support of functional libraries.
sifbuilder implements a model of code generation based on templates of files and classes following the target code. These classes are referred to as transcripts. The declarative model of the module is defined in xml streams that correspond to a relational model, inspired in the metabase schema files.
Transcripts are relative to the application or to individual tables. In the first case, the generation process will create one file; in the second a file per table in the relational schema. The scope of a transcript file is indicated in its file name.
sifmoduler is a PostNuke module that includes templates of files and classes following the model of the PostNuke 'example' module included in the PostNuke distribution.
The functional classes to generate the module are included in the sifbuilder module, which is, therefore, a dependency of sifmoduler.
There are three main types of transcripts to generate a PostNuke module: those corresponding to core classes, those related to language files, and those aimed to generate xanthia templates.
The transcripts related to the core files mirror the 'example' module. However, to generalize the classes associated to entities, the generated pnuserapi. and pnadminapi.php files simply contain the user and admin apis for each of the tables in the relational schema.
Data manipulation functions implemented as sql instructions. It would be possible to generate them as object methods.
The main core transcripts and the functions in the files or classes that they generate are the following.
| Scope | File | Description |
| appl | pnadmin | Refer to the pnadmin.php file. Includes the main, modifyconfig and updateconfig functions, as described in the example module. |
| appl | pnadminapi | Include the pnadminapi files for each of the tables in the declarative definition of the model. |
| appl | pninit | init, upgrade and remove |
| appl | pntables | Include the definition of the module tables |
| appl | pnuser | Include main, view, display and usermenu. |
| appl | pnuserapi | Include pnuserapi for each of the tables in the model definition. |
| appl | pnversion | generate version file. |
| tbl | pnadmin | sifrecordaction and dosifrecordaction functions. siftabledaction and dosiftableaction functions. display, new, create, modify, update, delete, view. |
| tbl | pnadminapi | get, dosifrecordaction, dosiftableaction, create, update functions. |
| tbl | pndao | create_table, drop_table. getall, getone, countitems, create, delete, deleteone, update, replace. |
| tbl | pnuser | view, display, usermenu. |
| tbl | pnuserapi | getall, get, countitems. |
Template transcripts generate the xanthia templates that called by pnRender. The are grouped by scope, appl or table, and by permissions, admin or user.
| Scope | File | Description |
| appl | admin_main | application main |
| appl | admin_menu | application menu |
| appl | admin_modifyconfig | modify configuration |
| appl | user_footer | footer template |
| appl | user_header | header template |
| appl | user_main | user main template |
| appl | user_menu | user menu |
| tbl | admin_display | display table rows. The item control is related to the field type. |
| tbl | admin_menu | entries for view, new and the generic siftableaction |
| tbl | admin_modify | displays the record and offers the update action. |
| tbl | admin_new | shows record template and insert new record |
| tbl | admin_sifrecordaction | generic sifrecordaction action |
| tbl | admin_siftableaction | generic siftableaction action |
| tbl | admin_view | list records and offer display, modify, delete and sifrecordaction per record |
| tbl | user_view | user view template |
The model of the module to be generated is declared in an xml stream that is passed to the generate_module function of the PostNuke07_script_sifmoduler sip.
Sip functions may be called form buildFiles. The PostNuke07_script_sifmoduler_0_0_2_build_example.xml build file contains the declaration of a module comparable to the 'example' module included in the PostNuke distribution.
The module, that will be named sifExample as defined in the declarative file, may be generated with the following instruction.
The following are features of sifbuilder specific to PostNuke
sifbuilder may be used as a module integrated in postnuke.
php sifcmd.php sip_install_site PostNuke07_mod_sifbuilder
The sifbuilder sip is structured as a standard PostNuke module. It can also be installed from the admin interface of a PostNuke site.
As postnuke module, sifbuilder exposes the force mode behavior of sifbuilder and offers the rlist, rsync and install functions.
| Function | Behaviour |
| rlist | rlist interrogates the master server to check the sips available centrally. Then it shows the names of the sips available in the master center and tags those that are available locally and those that are installed in the currently target site. |
| rsync | rsync downloads the sips installation packages and sifs frameworks and place them in the place of the existing ones in the sifdir. If dosipsbackup and dosifsbackup are set, a timestamped copy of the existing directories is created. |
| install | The install function behaves as the install operation in the command line run in force mode. It relies on three sets of parameters: the install parameters, the site parameters, and the sips passed for installation. |
The module, that will be named sifExample as defined in the declarative file, may be generated with the following instruction.
php sifcmd.php b PostNuke07_script_sifmoduler
--buildfile=PostNuke07_script_sifmoduler_0_0_2_build_example.xml
Code generation usually relies on templates of classes and the declarative definition of a model to generate operational code with the support of functional libraries.
sifbuilder implements a model of code generation based on templates of files and classes following the target code. These classes are referred to as transcripts. The declarative model of the module is defined in xml streams that correspond to a relational model, inspired in the metabase schema files.
Transcripts are relative to the application or to individual tables. In the first case, the generation process will create one file; in the second a file per table in the relational schema. The scope of a transcript file is indicated in its file name.
sifmoduler includes templates of files and classes following the model of the PostNuke 'example' module included in the PostNuke distribution.
The functional classes to generate the module are included in the sifbuilder module, which is, therefore, a dependency of sifmoduler.
There are three main types of transcripts to generate a PostNuke module: those corresponding to core classes, those related to language files, and those aimed to generate xanthia templates.
The transcripts related to the core files mirror the 'example' module. However, to generalize the classes associated to entities, the generated pnuserapi. and pnadminapi.php files simply contain the user and admin apis for each of the tables in the relational schema.
Data manipulation functions implemented as sql instructions. It would be possible to generate them as object methods.
The main core transcripts and the functions in the files or classes that they generate are the following.
| Scope | File | Description |
| appl | pnadmin | Refer to the pnadmin.php file. Includes the main, modifyconfig and updateconfig functions, as described in the example module. |
| appl | pnadminapi | Include the pnadminapi files for each of the tables in the declarative definition of the model. |
| appl | pninit | init, upgrade and remove |
| appl | pntables | Include the definition of the module tables |
| appl | pnuser | Include main, view, display and usermenu. |
| appl | pnuserapi | Include pnuserapi for each of the tables in the model definition. |
| appl | pnversion | generate version file. |
| tbl | pnadmin | sifrecordaction and dosifrecordaction functions. siftabledaction and dosiftableaction functions. display, new, create, modify, update, delete, view. |
| tbl | pnadminapi | get, dosifrecordaction, dosiftableaction, create, update functions. |
| tbl | pndao | create_table, drop_table. getall, getone, countitems, create, delete, deleteone, update, replace. |
| tbl | pnuser | view, display, usermenu. |
| tbl | pnuserapi | getall, get, countitems. |
Template transcripts generate the xanthia templates that called by pnRender. The are grouped by scope, appl or table, and by permissions, admin or user.
| Scope | File | Description |
| appl | admin_main | application main |
| appl | admin_menu | application menu |
| appl | admin_modifyconfig | modify configuration |
| appl | user_footer | footer template |
| appl | user_header | header template |
| appl | user_main | user main template |
| appl | user_menu | user menu |
| tbl | admin_display | display table rows. The item control is related to the field type. |
| tbl | admin_menu | entries for view, new and the generic siftableaction |
| tbl | admin_modify | displays the record and offers the update action. |
| tbl | admin_new | shows record template and insert new record |
| tbl | admin_sifrecordaction | generic sifrecordaction action |
| tbl | admin_siftableaction | generic siftableaction action |
| tbl | admin_view | list records and offer display, modify, delete and sifrecordaction per record |
| tbl | user_view | user view template |
The model of the module to be generated is declared in an xml stream that is passed to the generate_module function of the PostNuke07_script_sifmoduler sip.
Sip functions may be called form buildFiles. The PostNuke07_script_sifmoduler_0_0_2_build_example.xml build file referred to in the usage sample contains the declaration of a module comparable to the 'example' module included in the PostNuke distribution.
The sifbuilder sip is structured as a standard PostNuke module. It can also be installed from the admin interface of a PostNuke site.
As postnuke module, sifbuilder exposes the force mode behavior of sifbuilder and offers the rlist, rsync and install functions.
The fact that blocks in PostNuke may be created in the includes/blocks directory makes it possible automating the creation of blocks that consist of a title and a url anchored by an image.
The sif package takes the parameters from the build xml file and creates the block file required by PostNuke.
Typical xml build files are bound with the sip. Thus
php sifcmd.php b PostNuke07_script_sifblockdoer
--buildfile=PostNuke07_script_sifblockdoer_0_0_2_build_pn.xml
php sifcmd.php b PostNuke07_script_sifblockdoer
--buildfile=PostNuke07_script_sifblockdoer_0_0_2_build_sf.xml
will create bloks linking to the PostNuke and Sourceforge sites.
A sif contribution to the PostNuke community is the siftheme. It may be installed and activated by:
php sifcmd.php b PostNuke07_theme_sifbuilder
The main characteristic features of this theme include its php trigger code, that is wrapped in function; its html master template that is coded fully table-less to explore the possibilities of this approach; and the smarty tagged menu links that are displayed only when the relevant modules are registered.
A full site with this theme and referred to modules may be installed by:
php sifcmd.php b PostNuke07_script_sifbuilderweb -x
The content element of the tRSSNews block has the following controlled elements:
feed: latestitems,popular, indfeeds (default)
feeds: the csv list of feeds, ex. lexbus
The Weather module supports the weather_install_packages and weather_set_defaults specific sip functions.
weather_install_packages::package:=all will install all weather packages
weather_set_defaults::n_accid:=city code (ex. USNY0996 for New York) will define the default city to show weather
The weather config param method will define the method to access weather information. It may be set to 1 to grab data from MSNBC and 2 for XML data feed from The Weather Channel. The later requires registration that may de done athttp://registration.weather.com/registration/xmloap/step1
A script refers to an xml file that contains instructions associated to sips. When this file plays the main role of a sip the sip itself is considered as being of type script. Every sip may have associated one or more buildFiles and be run with the sip_build_site action associated to that sip, eventually with the --buildfile to specify an alternative buildFile. In may contexts, script and buildFile may be used indistinctively.
buildFiles may have a full mode and a reduced one. When specified in full mode, a buildFile starts with the sip_build_site xml element directly under the xml document element. This element may contain ore or more site elements, each one eventually with its own runParams and therefore with its own siteParams. The purpose of providing this option is to support the installation of sites including various cores, such as PostNuke and sugarcrm, that may be correlated, such as with pnSugar.
Besides the runParams, which otherwise are inherited from the command line, a site element must have a sips sub-element that will itself contain a number of elements corresponding to sips resident in sifbuilder. Each sip contains a buildParams element that will contain the functions and arguments specific to that sip. As a result, a possible chain of xml elements would be: xml, sip_build_site, site, sips, PostNuke07_core_postnuke, buildParams.
In their simplified mode, the contents of build files correspond to the contents of the buildParams element in the general model.
The following are examples of build files associated to script-type sips that encapsulate many of the functions and possibilities of sifbuilder. The sip associated to the script is usually derived from the name of the script itself. They may be run with the instruction: php sifcmd.php sip_build_site sip --buildfile=script
| buildFile | Description |
| PostNuke07_script_commerce01_0_0_1_build.xml | This script will install the most recent PostNuke core. Then, it will refer to the PostNuke07_script_pnLocals sip, that is used to support the configuration of the site. This will remove some blocks, add some rows to the Main Menu, update some config vars and modify the welcome message. Then, it will apply the xExtraLite theme. Finally, it will install the shop module and create the blocks that come with that site package. |
| PostNuke07_script_commerce02_0_0_1_build.xml | This script is similar to the previous one but, instead of installing the shop module, it will install pncommerce and the blocks provided with that package. |
net functions are the methods of a sif relation. A sif relation is composed of a lochost, a nethost and a connection. net functions may be of three types: actions from a lochost to the nethost, such as upload; from the nethost to the lochost, such as download; or at the nethost, such as a sif action on the nethost. They are built according to the type of the hosts (linux or windows) and of the connection (local windows or linux, ssh2key windows or linux and ssh2key or linux).
Calls to net functions are normally included in use cases. Use cases are usually defined as a combination of sif actions to be run in a nethost with specific runParams. The most important nefunction is sifnet_sifop_run that will remotely execute a sif action on a nethost. Others may support the installation and update of sifbuilder in a remote host.
| net function | Behaviour |
| sifnet_sifop_run | sifnet_sifop_run translates the sif function passed at the cmd line to be run at the net host. To do this, sifnet_relation reconstructs the sif cmd on the basis of the runParams and usecaseParams, and makes it run at the nethost. The reference to the nethost may be complemented with a reference to a netsite, typically for the creation of a web site. |
| sifnet_create_program_zip | Create a zip file with the contents of the lochost tmpuploaddir. Typically, this function is used following the build_program sif function that generates the sifbuilder program tree in that directory. |
| sifnet_upload_program | Copy the zip file resulting from the create_program_zip net function to the nethost userdir, that is intended to host the production copy of the sifbuilder program. |
| sifnet_explode_package | Explode the sifbuilder tarball in the nethost userdir. This is normally used after upload_program. |
| sifnet_upload_release | Upload a sips' release to the netsite in the nethost. Usually this is run after the build_release sif action. |
| sifnet_upload_packages | Upload a package from the siftmp/packages to the nethost packages dir in the nethost. |
usecases are functions in the sifnet_usecases.php file that normally create a sifrelation and call a series of net functions. The major different from running sifops directly from the command line, apart from the fact that various actions may be serialized, is the possibility to predefine the lochost and the nethost, so that a sif action directly may be run on a remote host.
Besides this, the purpose of the usecases, that originally were named testcases, is to list functions to be run and tested before releasing a new version of sifbuilder.
use cases may be listed with: # php sifcmd.php list_usecases
The general syntax to call a use case is:
php sifcmd.php run_usecase [options] {usecase}
Except for the modifyers, the runParams passed to the command line are parameters passed to the use case. Some parameters are specific to the execution of use case and particularly relevant.
| netuse param | description |
| sifnetconfigfile | reference to custom file containig the definition of hosts and sites. Defaults to sifnet_config_local.php if present and to sifnet_config.php otherwise. sifnet_config.php is included in the program distribution. Ideally, sifnet_config_local.php should be created and then this parameter should not be needed.. |
| sifnetdorun | Comit sifnet instructions. Usually passed as -v in the command line. This option may be chosen when there is a complete certitude on the instructions to be run and the result that they are going to produce. In this case, that switch may be carefully combined with the -x and -f modifyers. |
| siflochost | local host. Defaults to devhost, which is associated to the current working directory where sifcmd.php and the sifbuilder root are expected to be found. Example, from-host in an upload, or to-host in a download |
| sifnethost | net host where the sif action will be applied. Defaults to devhost in sifConfigParams. For use cases related to sip actions, this default should be fine. However, for site admin usecases, such as build_program, running it with --sifnethost=devhost will imply the removal fo the current working directory. |
| sifnetsite | net site where the sif action will be applied. If not present, the siteParams will be applied. The sifnetsite is defined at the sifnetconfigfile file. Since a site may be defined differently at different sites, for example at the local host and on the hosting serer, the naming convention used in some cases is ex. sbpn07_at_localhost, meaning the installation of PostNuke within the site sifbuilder on the localhost host. Besides correlation with the host, there must be a correlation between the sifnetsite and the sips applied to a site. Parametes, such as the database prefix, will typically depend on the core to be installed. Many usecases have the sifnetsite option set. That means that they refer to the definition of the site in sifnetconfigfile. If the parameters of the site have not been correctly defined there, running the usecase may not work at all or have undesirable effects. |
| sifnetusecasesfile | File containing the definition of the use cases. Defaults to sifnet_usecases.php that is included in the program distribution. Other use cases may be defined there.. |
| sifnetdomain | Domain that will be used as the sif server. This is not specific to sifnet functions and use cases but it is particularly relevant to test sifbuilder server in the localhost. |
Since lochost and nethost run params are defaulted to devhost and localhost in sifConfigParmams, use cases will not run properly if localhost has not been defined properly in sifnetconfigfile. For admin sifops, such as build_program, nethost should not be set to devhost. However, for normal site operations, the easiest way to run usecases may be to set devhost in sifnetconfigfile depending of the os and run run_usecase with --sifnethost=devhost.
Some usecases may have the sifnetsite specified in the code. In these cases, it is important to check that the definition of the site is correct in the sifnetconfigfile. Sometimes, the --sifnetsite parameter must be specified in the command line. In all cases, the correct specification of the sifnetsite and of the sifnethost are fundamental for the proper execution of the usecase. Incorrect specification of these parameters may provoke the removal of the complete file system.
build a sip on a site
A typical usecase corresponds to the application of the sip_build_site sifop to a sip, in this case to a script sip. In fact, since scripts usually cover multiple sips, checking the scripts is a good method to check the consistency of the program. Besides this, scripts are usually intended to build complete sites. Therefore, they constitute a section the usecases file. The example that is listed below refers to the creation of a commerce site with the shop module. The usecase should be run as follows:
php sifcmd.php run_usecase --siflochost=devhost --sifnetsite=sbpn07_at_localhost --sifnethost=devhost -f tc6201
In this case, the use case tc6201 is run on the nethost defined by the class 'localhost' with siteParams defined in the class 'sbpn07_at_localhost'. This is the code of that usecase:
function tc6201($args=array())
{
$desc = 'PostNuke07_script_commerce01 based on PostNuke07_mod_shop';
SifDebug::info($desc,__FUNCTION__ . '::');
if ($args['runParams']['op'] == 'sif_run_usecase') {
$usecaseParams = array();
$usecaseParams['sifop'] = 'sip_build_site';
$usecaseParams['options'] = ' --dev ';
$usecaseParams['sips'][] = 'PostNuke07_script_commerce01';
$args['usecaseParams'] = $usecaseParams;
$args['runParams']['sifpacksdir'] = '../sifpacksdir';
$sifnet_relation = sifnet_relation_factory::sifnet_get_sifnet_relation($args);
$sifnet_relation->sifnet_sifop_run();
}
}
Functions corresponding to usecases usually start by a call to the info debug that is run with the list_usecase sifop. Then there is a procedural part that is called by the 'run_usecase'
Install PostNuke and install/remove/update a module
This usecase installs the latest available version of PostNuke after having removed the file system and database environment of the target site. Afterwards, It will install a module, specifically Netquery, then remove it, then install it again and finally upgrade it to the latest avalable version.
function tc1117($args=array())
{
$desc = 'pn/remove/install/upgrade noupd - PostNuke07_mod_netquery';
SifDebug::info($desc,__FUNCTION__ . '::');
if ($args['runParams']['op'] == 'sif_run_usecase') {
$usecaseParams = array();
$usecaseParams['sips']=array();
$usecaseParams['sifop']='sip_install_site';
$usecaseParams['options'] = $options . ' --emptypod ';
$usecaseParams['sips'][]='PostNuke07_core_postnuke';
$args['runParams']['sifpacksdir'] = '../sifpacksdir';
$args['usecaseParams'] = $usecaseParams;
$sifnet_relation = sifnet_relation_factory::sifnet_get_sifnet_relation($args);
$sifnet_relation->sifnet_sifop_run();
// build
$usecaseParams['sips']=array();
$usecaseParams['sifop']='sip_build_site';
$usecaseParams['options'] = $options . ' --dev ';
$usecaseParams['sips'][]='PostNuke07_mod_netquery';
$args['runParams']['sifpacksdir'] = '../sifpacksdir';
$args['usecaseParams'] = $usecaseParams;
$sifnet_relation = sifnet_relation_factory::sifnet_get_sifnet_relation($args);
$sifnet_relation->sifnet_sifop_run();
// remove
$usecaseParams['sips']=array();
$usecaseParams['sifop']='sip_remove_site';
$usecaseParams['options'] = $options . ' ';
$usecaseParams['sips'][]='PostNuke07_mod_netquery';
$args['runParams']['sifpacksdir'] = '../sifpacksdir';
$args['usecaseParams'] = $usecaseParams;
$sifnet_relation = sifnet_relation_factory::sifnet_get_sifnet_relation($args);
$sifnet_relation->sifnet_sifop_run();
// build
$usecaseParams['sips']=array();
$usecaseParams['sifop']='sip_build_site';
$usecaseParams['options'] = $options . ' --noupd ';
$usecaseParams['sips'][]='PostNuke07_mod_netquery_3_1';
$args['runParams']['sifpacksdir'] = '../sifpacksdir';
$args['usecaseParams'] = $usecaseParams;
$sifnet_relation = sifnet_relation_factory::sifnet_get_sifnet_relation($args);
$sifnet_relation->sifnet_sifop_run();
// upgrade
$usecaseParams['sips']=array();
$usecaseParams['sifop']='sip_upgrade_site';
$usecaseParams['options'] = $options . ' --dev ';
$usecaseParams['sips'][]='PostNuke07_mod_netquery';
$args['runParams']['sifpacksdir'] = '../sifpacksdir';
$args['usecaseParams'] = $usecaseParams;
$sifnet_relation = sifnet_relation_factory::sifnet_get_sifnet_relation($args);
$sifnet_relation->sifnet_sifop_run();
}
}
Before running this usecase, it is fundamental to check a number of issues. Because of the way in which sifcmd.php is run, the current working directory must be the sifbuilder program root. The usecase assigns the value '../sifpacksdir' to the sifpacksdir runParam. This means that the packages that will be downloaded, in particular the PostNuke core and the various versions of the module, will be placed in a sibling directory. Thus, if the current working directory in win is d:/sifbuilder_1_0_0, the site packages will be downloaded to d:/sifpackages.
The first part of the use case calls the sip_install_site sifop with the PostNuke07_core_postnuke sip. This will install the PostNuke core. If necessary, the corresponding site package will be downloaded and uncompressed. Before creating the sifnet_relation, that will construct the sif instructions, the --emptypod is set. This means that the pod where the site will be created will be first remove and its database emptied.
Since there is no reference to the siteParmas, the default applies. This means that both lochost and nethost are assigned to devhost. The sifnetsite is associated to sbpn07_at_localhost. devhost and sbpn07_at_localhost are two classes defined at sifnet_config_local.php or, if this file does not exist in the sifbuilder root, defaulted in sifnet_config.php
The --emptypod option, which is synonym of -x, implies that the site pod directory of the nethost (as defined in the sifnetconfigfile) will be removed and its database emptied.
Then , the sip_build_site sipop will get and install the site package corresponding to the sip, in this case Netquery. Then, the sip_remove_site sifop will remove the module.
In the second part of the usecase, sip_build_site is called again, this time with the --noupd option, that means that the legacy site package versions will be taken into account. Furher, the specific package version is specified: PostNuke07_mod_netquery_3_1. This means that version 3.1 of that module will be downloaded, if available, then installed and eventually configured.
Finnnaly, sip_upgrade_site will be called with the same sip but without specification of the site package version. Thus, the latest one available will be transfered. In fact, since the --dev option is set, also development versions of the module will be considered. Since a previous version of the module is installed on the site, the package upgrade function will be called.
This usecase will be run with th following command.
php sifcmd.php t tc1118 -f -v
The same result could be obtained with a series of direct calls to sifbuilder:
php sifcmd.php i -x PostNuke07_core_postnuke --sifpacksdir=../sifpacksdir --sifnetsite=sbpn07_at_localhost php sifcmd.php b PostNuke07_mod_netquery --dev --sifpacksdir=../sifpacksdir --sifnetsite=sbpn07_at_localhost php sifcmd.php r PostNuke07_mod_netquery --sifnetsite=sbpn07_at_localhost php sifcmd.php b PostNuke07_mod_netquery_3_1 --noupd --sifpacksdir=../sifpacksdir --sifnetsite=sbpn07_at_localhost php sifcmd.php u PostNuke07_mod_netquery --dev --sifpacksdir=../sifpacksdir --sifnetsite=sbpn07_at_localhost
When running a usecase with run_usecase, the program will show the instructions to be run on the nethost. To effectively run the instructions, the -v runParam must be submitted in the command line. The code to be run should always be checked carefully before comitting it to be run on the nethost.
The sif framework includes the following objects.
| Object | |
| sip | The sip represents the installation package. It includes the methods in a build file or a site script. |
| package | A package is the component that will be added to the site. This is normally a wcm core, a module, block, theme, language pack. |
| site | A sip is run in the context of a site. A site provides access to the site, run and config params. It also plays the role of class factory for the other objects of the framework |
| module | Represents a module in a composite web site. |
| block | Represents a block in a composite web site. |
| theme | Represents a theme in a composite web site. |
| panel | Represents a panel in a composite web site. |
sif packages usually go through the following operations
| Action | Status | Query function | Retrieve function |
| transpose | transposed | ||
| transfer | transferred | isAvailable | getAllAvailable |
| install | installed | isInstalled | getAllInstalled |
| remove | |||
| upgrade | |||
| build |
The installation action may be divided into initialization and activation. Activation of a theme usually means making it the default one. Activation of a block usually means making it visible.
The interaction with the site objects requires that objects have a symbolic identifer that may be used in the declarative definition of the site specification.
For each content management system, the symbolic identifier is translated into one field in a table. In case of controlled values, such as the site panels, the accepted values of the symbolic identifiers are dependent on the specific wcm. Usually, the numeric codes are accepted.