This package implements the pj DataProvider Framework library under Joomla! CMS. Refer there for detailed description of InfoBase, SearchKey, IDataProvider and MySqlDataProvider.

This documentation is powered by the Dispute component based on the pj DataProvider for Joomla! and pj DataProvider Framework respectively.

Usage:

pj DataProvider Framework package (lib_pj) is an alternative database concept beside of Joomla's JDatabase framework.

The developer designs new classes extending the InfoBase class and registers them at start-up in the singleton DataProviderBase instance. It is not necessary to add any code to bare class declarations, although it is convenient to outsource specific functionality there.

The framework offers full database access for registered InfoBase classes, including retrieving by ID or by queries passed either as string or as SearchKey structure. It recognizes changes of instance data and inserts, updates and deletes instances together with corresponding table rows, optionally in nested transactions. It ensures that at any time, there exists just one unique instance of InfoBase extending class corresponding to one database table row.

The developer has to write an extension of the DataProviderBase class and outsource his/her business layer functions there.

PjTools functions are located in the file /libraries/pj/PjTools.php.

const EMAIL_REGEX Regex constant to check email addresses. This one is from mootools.js.
function array_update (array &$target, array $source1 [, array $source2...])

Overwrites elements in $target with the same key elements from $source... beginning with $source1.

Returns $target.

Note, that $target is passed by reference. Use a copy of $target if you need to preserve original values.

Example:

$myTarget = array ('a' => 6, 'c' => 'no update');
array_update ($myTarget, array ('b' => 10, 'a' => '10'));

// $myTarget: 'a' => '10', 'c' => 'no update'

function canonicUriPath ($src, &$uri = null, &$path = null)

Creates canonical uri and file path if exists inside the site file structure.

Returns true the $src points to own site.

$src: input URL
$uri: outputs $src's canonized uri
$path: outputs file path corresponding to $src if the file exists inside the site's file structure

function writeFile($path, $content, $mode = 'wb')

Writes $content into $path file. Canonizes $path and creates folder if necessary.

Returns canonialized $path

$path: full file path
$content: content to be written
$mode: fopen() mode, default 'wb'

Throws Exception error_get_last() if mkdir(), fopen() or fwrite() failed

function joomla_var_show ($var, $cls = '', $fn = '', $msg = '', $depth = PHP_INT_MAX)

Debugging helper function.

Outputs the $var structure in the Joomla! page's Message block.

$cls: optional title displayed in the message's first line. It can also be e.g.'__CLASS__, __FILE__ or even __METHOD__.
$fn: optional title part displayed in the message's header. If provided, the header title is displayed in the form "$cls::$fn". If $cls = __FILE__ and $fn = __LINE__, the header title will look like "[source file path]::[line number]".
$msg: optional message to be displayed in the message header
$depth: Maximum structure depth the $var will be analyzed.

function var_show ($var, $depth = PHP_INT_MAX)

Debugging helper function.

Returns $var structure as HTML string.

$depth: Maximum structure depth the $var will be analyzed.

function joomla_trace ()

Debugging helper function.

Outputs the debug_print_backtrace() in the Joomla! page's Message block.

function PjTrace ($msg)

Debugging helper function.

Outputs the $msg in the Joomla! page's Message block if the Joomla! system debugging is on.

PjTrace is looked for by MySqlDataProvider. If the Joomla! system debugging is on, the Joomla! page's Message block will display its resolved queries.