Xataface 2.0
Xataface Application Framework
Public Member Functions | Static Public Member Functions | Data Fields
Dataface_ModuleTool Class Reference

Public Member Functions

 getDbVersion ($modname)
 Returns the current database version of the module.
 getFsVersion ($modname, $path)
 Returns the file system version of the specified module.
 updateModule ($modname, $path)
 Updates a module so that the database version is the same as the file system version.
 getModuleURL ($file)
 Returns the URL of the module that contains the given file. This will either return a URL in the DATAFACE_SITE_URL/modules directory or the DATAFACE_URL/modules depending on where the file is located.
 displayBlock ($blockName, $params=array())
loadModule ($name, $path=null)
 loadModules ()
 getMigrations ()
 migrate ($modules=array())
 install ($modules=array())
 getInstalledModules ()
 getUninstalledModules ()

Static Public Member Functions

static & getInstance ()

Data Fields

 $_modules
 $_db_versions

Detailed Description

A tool to help manage and work with modules. Use this class to load and install modules, and perform maintenance on them.

Definition at line 6 of file ModuleTool.php.


Member Function Documentation

displayBlock ( blockName,
params = array() 
)

Displays a block as defined in all of the registered modules.

Parameters:
string$blockNameThe name of the block.
array$paramsParameters that are passed to the block.
Returns:
boolean True if at least one module defines this block. False otherwise.
Since:
0.6.14
Author:
Steve Hannah <shannah@sfu.ca> Feb. 27, 2007

Definition at line 171 of file ModuleTool.php.

getDbVersion ( modname)

Returns the current database version of the module.

Definition at line 28 of file ModuleTool.php.

getFsVersion ( modname,
path 
)

Returns the file system version of the specified module.

The file system version should be stored in a file named version.txt inside the module's directory. It should be in the format:

Parameters:
string$modnameThe name of the module (e.g. modules_grid)
string$pathThe path to the module's file (e.g. modules/grid/grid.php)
Returns:
int The file system version.

Definition at line 65 of file ModuleTool.php.

getInstalledModules ( )

Indicates whether a given module is currently installed.

Returns:
boolean True if it is installed. function isInstalled($moduleName){ $mod_obj = $this->loadModule($mod); if ( PEAR::isError($mod_obj) ) return false; if ( method_exists($mod_obj,'isInstalled')) return $mod_obj->isInstalled(); return false; }

/** Returns a list of names of modules that are currently installed.

Definition at line 337 of file ModuleTool.php.

static& getInstance ( ) [static]

Definition at line 13 of file ModuleTool.php.

getMigrations ( )

Returns an array of modules that require migrations. [Module Name] -> [Description of migration] performed.

Definition at line 266 of file ModuleTool.php.

getModuleURL ( file)

Returns the URL of the module that contains the given file. This will either return a URL in the DATAFACE_SITE_URL/modules directory or the DATAFACE_URL/modules depending on where the file is located.

This method is designed for modules to be able to figure out where they are so that they can include resources like stylesheets and javascripts.

Parameters:
string$fileThe path to a file in the module's directory.
Returns:
string The URL to the module's directory.
Exceptions:
ExceptionIf this doesn't appear to be in the module's directory.

Example

Inside the module modules_tagger, the method to include javascripts contains:

 $baseURL = Dataface_ModuleTool::getInstance()->getModuleURL(__FILE__);
 $app->addHeadContent(
     '<script src="'.htmlspecialchars($baseURL.'/js/tagger.js').'"></script>'
 );

Definition at line 150 of file ModuleTool.php.

getUninstalledModules ( )

Returns an array of names of modules that have not been installed, but can be installed.

Definition at line 350 of file ModuleTool.php.

install ( modules = array())

Installs the specified modules.

Parameters:
array$modulesArray of module names to install.
Returns:
Associative array of status messages: [Module Name]-> [Install status]

Definition at line 307 of file ModuleTool.php.

& loadModule ( name,
path = null 
)

Loads a module and returns a reference to it.

Parameters:
string$nameThe name of the module's class.

Definition at line 198 of file ModuleTool.php.

loadModules ( )

Load modules.

Definition at line 252 of file ModuleTool.php.

migrate ( modules = array())

Performs migrations on the specified modules.

Parameters:
$modulesThe names of the modules to migrate. If omitted, all modules will be migrated.
Returns:
an associative array of log entries for each migration.

Definition at line 287 of file ModuleTool.php.

updateModule ( modname,
path 
)

Updates a module so that the database version is the same as the file system version.

Parameters:
string$modnameThe name of the module.
string$pathThe path to the module.

Definition at line 82 of file ModuleTool.php.


Field Documentation

$_db_versions

Definition at line 10 of file ModuleTool.php.

$_modules

Definition at line 8 of file ModuleTool.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations