Wizards Toolkit Documentation

Materialize.php

Wizards Toolkit functions for MaterializeCSS and HTML template methodology.

All rights reserved.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tags
author
Programming Labs
license
All rights reserved
version
2.0

Table of Contents

wzMenu()  : html
Create data-driven menu based on Menu Set.
wzNavBar()  : html
Hard-coded navbar when you do not want to use data-driven menus.
wzDisplayData()  : html
This receives form field HTML with tokens and replaces the @tokens@ with data.
wzFormLabel()  : html
This is called by many form-creating functions to generate the Label text.
wzFormText()  : html
Creates an input text field.
wzFormTextArea()  : html
Creates a textarea field.
wzFormRadio()  : html
Creates input form fields for type="radio".
wzFormCheckbox()  : html
Creates input form field for type="checkbox".
wzFormSwitch()  : html
Creates input form field for type="checkbox" but with Switch user interface
wzFormSelect()  : html
Creates html for Select drop list.
wzFormSelectFont()  : html
Similar to wzFormSelect but this one shows font styles while displaying select drop list of fonts
wzFileUpload()  : html
Used to create file input field for uploading files.
wzFormFile()  : html
Used to create file input field for uploading files. Check to see whether to use wzFileUpload instead.
wzUpdateBtns()  : html
Create cancel, save and possibly copy buttons. If read-only then instead shows a "Return" button.
wzPageList()  : html
By passing a SQL SELECT this will build a nice looking page.
wzChatList()  : html
Create list of chat data.
wzSaveChat()  : html
This creates HTML with saveChat JavaScript function. Used at bottom of chatEdit.php.
wzForumList()  : html
Create list of Forum data.
wzSendNoteForum()  : html
This creates HTML with sendNote JavaScript function. Used at bottom of forumEdit.php.

Functions

wzMenu()

Create data-driven menu based on Menu Set.

wzMenu( string  $fncMenuSetName [, string  $fncSpecial = 'N' ] ) : html

This uses the wzMenuSets data table and the child tables of wzMenuGroups, wzMenuItems, and wzPages. This creates both the top-menu and in case the screen is small, it creates the side-bar menu code as well.

The menu structures are available in the WTK /admin/ website.

Parameters
$fncMenuSetName : string

must match wzMenuSets.MenuName

$fncSpecial : string = 'N'

defaults to 'N', if set to 'BreadCrumbs' then adds code for Breadcrumbs to use

Return values
html

of drop and side-menus

wzNavBar()

Hard-coded navbar when you do not want to use data-driven menus.

wzNavBar( string  $fncHeader ) : html

Example usage: wzSearchReplace('', wzNavBar('Wizards Toolkit'));

Parameters
$fncHeader : string

pass this in for the top-center title to show

Return values
html

of top navbar and side-menu

wzDisplayData()

This receives form field HTML with tokens and replaces the @tokens@ with data.

wzDisplayData( string  $fncColName , string  $fncHtm [, string  $fncTable = '' ][ , string  $fncDefaultIfBlank = '' ][ , string  $fncPrepType = 'text' ]) : html

This is called within other MaterializeCSS PHP functions. It sets class="active" for label when there is data in the form field.

wzSearchReplace('', wzNavBar('Wizards Toolkit'));
Parameters
$fncColName : string

data column name

$fncHtm : string

that has tokens to be changed into data

$fncTable : string = ''

defaults to '' blank; if passed then prepares field for WTK updating and saving

$fncDefaultIfBlank : string = ''

defaults to ''; if currently no value in data, use this default

$fncPrepType : string = 'text'

defaults to 'text' and used by wzFormPrepUpdField

Tags
uses
function

wzFormPrepUpdField

Return values
html

returns modified passed $fncHtm with data values

wzFormLabel()

This is called by many form-creating functions to generate the Label text.

wzFormLabel( string  $fncLabel , string  $fncColName ) : html

If a Label is passed it is returned directly. Otherwise this uses the Column Name and inserts spaces. Generally this will only be called by internal functions.

Parameters
$fncLabel : string

can be passed '' blank value

$fncColName : string

data column name like what was passed to wzFormText

Return values
html

returns text to use as Label

wzFormText()

Creates an input text field.

wzFormText( string  $fncTable , string  $fncColName [, string  $fncType = 'text' ][ , string  $fncLabel = '' ][ , string  $fncColSize = 'm6 s12' ][ , string  $fncRequired = 'N' ][ , string  $fncHelpText = '' ]) : html

If a special Type is passed then additional validation and class styles are added. Special Types include:

  • date
  • time
  • number
  • email
  • tel
  • timepicker
Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncType : string = 'text'

becomes type="$fncType" and triggers enhancements of JS validation and class styles

$fncLabel : string = ''

optionally passed, if not then uses $fncColName

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

$fncRequired : string = 'N'

defaults to 'N'

$fncHelpText : string = ''

defaults to '', pass to add

Tags
uses
function

wzFormLabel

uses
function

wzDisplayData

Return values
html

returns surrounding HTML for input form field

wzFormTextArea()

Creates a textarea field.

wzFormTextArea( string  $fncTable , string  $fncColName [, string  $fncLabel = '' ][ , string  $fncColSize = 'm12 s12' ][ , string  $fncRequired = 'N' ][ , string  $fncHelpText = '' ]) : html
Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncLabel : string = ''

optionally passed, if not then uses $fncColName

$fncColSize : string = 'm12 s12'

defaults to 'm6 s12'

$fncRequired : string = 'N'

defaults to 'N'

$fncHelpText : string = ''

defaults to '', pass to add

Tags
uses
function

wzFormLabel

uses
function

wzDisplayData

Return values
html

returns surrounding HTML for textarea

wzFormRadio()

Creates input form fields for type="radio".

wzFormRadio( string  $fncTable , string  $fncColName , string  $fncLabel , array<string|int, mixed>  $fncValueArray [, string  $fncColSize = 'm6 s12' ]) : html

Example calling method: $pgValues = array(
    'Male' => 'M',
    'Female' => 'F',
    'Uncertain' => 'U'
);
$pgHtm .= wzFormRadio('pets', 'Gender', 'Pet Gender', $pgValues, 'm2 s6');

Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncLabel : string

optionally passed, if not then uses $fncColName

$fncValueArray : array<string|int, mixed>

must contain values

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

Tags
uses
function

wzFormLabel

uses
function

wzFormPrepUpdField

Return values
html

returns surrounding HTML for radio fields

wzFormCheckbox()

Creates input form field for type="checkbox".

wzFormCheckbox( string  $fncTable , string  $fncColName , string  $fncLabel , array<string|int, mixed>  $fncValueArray [, string  $fncColSize = 'm6 s12' ]) : html

The $pgValues array needs to pass what the value should be when 'checked' and when 'not' checked.

Example calling method: $pgValues = array(
    'checked' => 'Y',
    'not' => 'N'
);
$pgHtm .= wzFormCheckbox('pets', 'CanTreat', 'Allowed to give Treats', $pgValues, 'm3 s6');

Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncLabel : string

optionally passed, if not then uses $fncColName

$fncValueArray : array<string|int, mixed>

must contain values

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

Tags
uses
function

wzFormLabel

uses
function

wzFormPrepUpdField

Return values
html

returns surrounding HTML for checkbox field

wzFormSwitch()

Creates input form field for type="checkbox" but with Switch user interface

wzFormSwitch( string  $fncTable , string  $fncColName , string  $fncLabel , array<string|int, mixed>  $fncValueArray [, string  $fncColSize = 'm6 s12' ]) : html

The $pgValues array needs to pass what the value should be when 'checked' and when 'not' checked.

Example calling method: $pgValues = array(
    'checked' => 'Y',
    'not' => 'N'
);
$pgHtm .= wzFormSwitch('wzShortURL', 'PasswordYN', 'Use Password', $pgValues, 'm2 s12');

Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncLabel : string

optionally passed, if not then uses $fncColName

$fncValueArray : array<string|int, mixed>

must contain values

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

Tags
uses
function

wzFormLabel

uses
function

wzFormPrepUpdField

Return values
html

returns surrounding HTML for checkbox field

wzFormSelect()

Creates html for Select drop list.

wzFormSelect( string  $fncTable , string  $fncColName , string  $fncSQL , array<string|int, mixed>  $fncFilter , string  $fncDisplayField , string  $fncValueField [, string  $fncLabel = '' ][ , string  $fncColSize = 'm6 s12' ][ , string  $fncShowBlank = 'N' ]) : html

The SQL query to use to generate a list of values and display values needs to be passed.

Example calling method: $pgSQL = "SELECT LookupValue, LookupDisplay FROM wzLookups WHERE LookupType = 'USAstate' ORDER BY LookupValue ASC";
$pgHtm .= wzFormSelect('pets', 'State', $pgSQL, [], 'LookupDisplay', 'LookupValue','','m4 s6');

Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncSQL : string

SQL query to retrieve value and display to show in select

$fncFilter : array<string|int, mixed>

SQL PDO values if necessary or pass blank array []

$fncDisplayField : string

column name from $fncSQL to display

$fncValueField : string

column name from $fncSQL to use as value in options

$fncLabel : string = ''

optionally passed, if not then uses $fncColName

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

$fncShowBlank : string = 'N'

defaults to 'N'

Tags
uses
function

wzFormLabel

uses
function

wzFormPrepUpdField

uses
function

wzGetSelectOptions

Return values
html

returns surrounding HTML for checkbox field

wzFormSelectFont()

Similar to wzFormSelect but this one shows font styles while displaying select drop list of fonts

wzFormSelectFont ( string  $fncTable , string  $fncColName , string  $fncSQL , array<string|int, mixed>  $fncFilter , string  $fncDisplayField , string  $fncValueField [, string  $fncLabel = '' ][ , string  $fncColSize = 'm6 s12' ]) : html

The SQL query to use to generate a list of values and display values needs to be passed.

Example calling method: $pgSQL = "SELECT LookupValue, LookupDisplay FROM wzLookups WHERE LookupType = ? ORDER BY LookupDisplay ASC";
$pgTmp .= wzFormSelectFont('LandingPage', 'BodyFont', $pgSQL, ['Font'], 'LookupDisplay', 'LookupValue', 'Body Font', 'm6 s12');

Parameters
$fncTable : string

data table

$fncColName : string

data column name

$fncSQL : string

SQL query to retrieve value and display to show in select

$fncFilter : array<string|int, mixed>

SQL PDO values if necessary or pass blank array []

$fncDisplayField : string

column name from $fncSQL to display

$fncValueField : string

column name from $fncSQL to use as value in options

$fncLabel : string = ''

optionally passed, if not then uses $fncColName

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

Tags
uses
function

wzFormLabel

uses
function

wzFormPrepUpdField

Return values
html

returns surrounding HTML for checkbox field

wzFileUpload()

Used to create file input field for uploading files.

wzFileUpload(string $fncTable, string $fncColPath, string $fncFilePath, string $fncFileName[, string $fncRefresh = '' ]) : html

Example calling method: $pgCamera = wzFileUpload('wzUsers','FilePath','../imgs/user/','NewFileName','myPhoto');
$pgHtm = wzReplace($pgHtm, '@wzFileUpload@', $pgCamera);

Parameters
$fncTable : string

data table

$fncColPath : string

stuff

$fncFilePath : string
$fncFileName : string

stuff

$fncRefresh : string = ''

defaults to '' blank

Return values
html

returns surrounding HTML for input type="file"

wzFormFile()

Used to create file input field for uploading files. Check to see whether to use wzFileUpload instead.

wzFormFile(string $fncTable, string $fncColPath, string $fncFilePath, string $fncFileName[, string $fncLabel = '' ][, string $fncColSize = 'm6 s12' ][, string $fncRefresh = '' ][, string $fncAccept = 'accept="image/*"' ]) : html

Example calling method: $pgHtm .= wzFormFile('pets','FilePath','/imgs/pets/','NewFileName','Pet Photo','m4 s12');

Parameters
$fncTable : string

data table

$fncColPath : string

stuff

$fncFilePath : string
$fncFileName : string

stuff

$fncLabel : string = ''

optionally passed, if not then uses $fncColName

$fncColSize : string = 'm6 s12'

defaults to 'm6 s12'

$fncRefresh : string = ''

defaults to '' blank

$fncAccept : string = 'accept="image/*"'

defaults to 'accept="image/*"'

Return values
html

returns surrounding HTML for input type="file"

wzUpdateBtns()

Create cancel, save and possibly copy buttons. If read-only then instead shows a "Return" button.

wzUpdateBtns(string $fncReturnTo[, string $fncForm = 'wtkForm' ][, string $fncSave = '/wz/lib/Save' ][, string $fncCopy = '' ]) : html

Example calling method: $pgHtm .= wzUpdateBtns('petList');

Parameters
$fncReturnTo : string

which PHP page to return to; do not need to include '.php'

$fncForm : string = 'wtkForm'

defaults to 'wtkForm'

$fncSave : string = '/wz/lib/Save'

defaults to '/wz/lib/Save'

$fncCopy : string = ''

defaults to '' blank; if not blank then shows Copy button

Return values
html

returns html with update and cancel buttons

wzPageList()

By passing a SQL SELECT this will build a nice looking page.

wzPageList(string $fncSQL, array<string|int, mixed> $fncSqlFilter[, string $fncLink = '' ][, string $fnc2Rows = 'N' ]) : html

Expects SQL SELECT to contain: UID, Header, TopRight, Description and optionally Row2Left, Row2Right

if $fncLink then must have UID in the SELECT result set.

Example calling method: $pgSQL =<<<SQLVAR
SELECT e.UID,
  DATE_FORMAT(e.AddDate, '%b %D at %l:%i%p') AS TopRight,
  e.Subject AS Header,
  REPLACE(e.EmailBody,' href="', ' href="#" title="') AS Description
  FROM wzEmailsSent e
WHERE e.SendToUserUID = ?
ORDER BY e.UID DESC
SQLVAR;

$pgHtm = '

' . "\n";
$pgHtm .= '   
' . "\n";
$pgHtm .= wzPageList($pgSQL, [$gloUserUID], '/wz/messageDetail');
$pgHtm = wzReplace($pgHtm, 'There is no data available.','no messages yet');
$pgHtm .= '   
' . "\n";
$pgHtm .= '
' . "\n";

Parameters
$fncSQL : string

SELECT query

$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

$fncLink : string = ''

defaults to '' blank, if passed then ajaxGo link is created

$fnc2Rows : string = 'N'

defaults to 'N'; if 'Y' passed then 2nd row shows

Return values
html

returns html with update and cancel buttons

wzChatList()

Create list of chat data.

wzChatList(string $fncSQL, array<string|int, mixed> $fncSqlFilter) : html

Example calling method: $pgSQL =<<<SQLVAR
SELECT c.UID, c.Message, c.SendByUserUID,
  DATE_FORMAT(c.AddDate, '%b %D, %Y') AS AddDate
   FROM wzChat c
WHERE (c.SendToUserUID = :ToUserUID
    AND c.SendByUserUID = :UserUID)
    OR (c.SendByUserUID = :ToUser2UID
    AND c.SendToUserUID = :User2UID)
ORDER BY c.UID ASC
SQLVAR;
$pgSQL = wzSqlPrep($pgSQL);
$pgSqlFilter = array (
   'ToUserUID' => $gloId,
   'UserUID' => $gloUserUID,
   'ToUser2UID' => $gloId,
   'User2UID' => $gloUserUID
);
$pgChat = wzChatList($pgSQL, $pgSqlFilter);

Parameters
$fncSQL : string

SELECT query

$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

Return values
html

returns html with list of a chat discussion

wzSaveChat()

This creates HTML with saveChat JavaScript function. Used at bottom of chatEdit.php.

wzSaveChat(int $fncToUserUID) : html
Parameters
$fncToUserUID : int

the UID of the wzUsers you want to chat with

Return values
html

returns html with Javascript:saveChat($fncToUserUID)

wzForumList()

Create list of Forum data.

wzForumList(string $fncSQL, array<string|int, mixed> $fncSqlFilter) : html

Example calling method: $pgSQL =<<<SQLVAR
SELECT f.UID, f.ForumMsg, u.FilePath, u.NewFileName,
  CONCAT(u.FirstName, ' ', COALESCE(u.LastName,'')) AS UserName,
  DATE_FORMAT(f.AddDate, '%b %D, %Y at %l:%i %p') AS AddDate
   FROM wzForumMsgs f
     INNER JOIN wzUsers u ON u.UID = f.UserUID
WHERE f.ForumUID = ?
ORDER BY f.UID ASC
SQLVAR;
$pgForum = wzForumList($pgSQL, [$gloId]);

Parameters
$fncSQL : string

SELECT query

$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

Return values
html

returns html with list of a chat discussion

wzSendNoteForum()

This creates HTML with sendNote JavaScript function. Used at bottom of forumEdit.php.

wzSendNoteForum(int $fncParentUID[, string $fncVer = '' ]) : html
Parameters
$fncParentUID : int

the UID of the wzForum table

$fncVer : string = ''

defaults to ''; only needed if more than one needed on a page

Return values
html

returns html with Javascript:sendNote($fncToUserUID)

Search results