Properties

$tableName

$tableName : 

Type

$createTableSQL

$createTableSQL : 

Type

$createTableKeysSQL

$createTableKeysSQL : 

Type

$enableImportInitializationData

$enableImportInitializationData : 

Type

$dummyFieldTypes

$dummyFieldTypes : 

Type

$postFormHTML

$postFormHTML : 

Type

$data

$data : 

Type

$showInEditForm

$showInEditForm : 

Type

$enablePreCreate

$enablePreCreate : 

Type

$enablePostCreate

$enablePostCreate : 

Type

$enablePreStore

$enablePreStore : 

Type

$enablePostStore

$enablePostStore : 

Type

$enablePreLoad

$enablePreLoad : 

Type

$enablePostLoad

$enablePostLoad : 

Type

$enablePreDelete

$enablePreDelete : 

Type

$enablePostDelete

$enablePostDelete : 

Type

$enablePreRestore

$enablePreRestore : 

Type

$enablePostRestore

$enablePostRestore : 

Type

$baseTableSQL

$baseTableSQL : 

Type

$baseTableKeysSQL

$baseTableKeysSQL : 

Type

Methods

__construct()

__construct() 

init()

init() 

importInitializationData()

importInitializationData(  $html = array()) 

Performs the SQL requests required to define basic data for the current table / record

Parameters

$html

createSQLTable()

createSQLTable(integer  $showSQL,   $html = array(), boolean  $importInitializationData = false) : integer

Creates the SQL table for this record in the database

Parameters

integer $showSQL

generate HTML showing the result of the SQL request and feed the $html array passed by reference with it

$html
boolean $importInitializationData

Fill the table with initialization data after creation if this data is available

Returns

integer —

returns 1 if successful creation, 0 otherwise.

importSQLDump()

importSQLDump(  $filepath,   $showSQL,   $html = array()) 

Import a given SQL dump

Parameters

$filepath

absolute file path

$showSQL
$html

loadL10n()

loadL10n(  $pluginRelativePath,   $subDir = '',   $forceClassName = '') 

Parameters

$pluginRelativePath
$subDir
$forceClassName

load()

load(  $uid) : integer

loads a database record given its uid and returns the count of records found

Parameters

$uid

the uid of the record to load

Returns

integer —

the count of data rows loaded for this record, or 0 if nothings has been loaded

loadRow()

loadRow(  $row) 

Loads a row from the SQL table associated with the object into the object data array

Parameters

$row

array an SQL row

loadKey()

loadKey(  $row,   $key,   $value) 

Loads a key from the given SQL row and stores its value into the object data['key'] array

Parameters

$row

array an SQL row

$key

string the column identifier in the SQL row and in the data array (both must always match)

$value

string the value to store in the key

convertFilesValue()

convertFilesValue(  $activeValue) 

Parameters

$activeValue

stripTemplateInfo()

stripTemplateInfo(  $templateData) 

Parameters

$templateData

stripMicroTemplateInfo()

stripMicroTemplateInfo(  $microTemplateData) 

Parameters

$microTemplateData

glueWithTemplateInfo()

glueWithTemplateInfo(  $templateName,   $strippedTemplateContent) 

glues 'value' keys of template content with the rest of the record definition This is required since only keys named 'value' are stored in the database to minimize space taken

Parameters

$templateName

String the name of the template to load the specification from

$strippedTemplateContent

Array the content loaded from the database, stripped from the useless fields, keeping only value fields

glueWithMicrotemplateInfo()

glueWithMicrotemplateInfo(  $microtemplateName,   $strippedTemplateContent) 

glues 'value' keys of microtemplate content with the rest of the record definition This is required since only keys named 'value' are stored in the database to minimize space taken

Parameters

$microtemplateName
$strippedTemplateContent

Array the content loaded from the database, stripped from the useless fields, keeping only value fields

getNextAvailableUid()

getNextAvailableUid() : integer

Returns the next available Uid if you badly need it before storing your record.

USE WITH CAUTION : it DOES NOT RESERVE the uid, so there is a slight risk that a record can be created by another script between the time you ask for the Uid and the time you effectively create your record. If possible prefer using the autoincrement feature by setting a void value "" to the uid field. This can be usefull for performance reason sometimes though

Returns

integer —

the uid of the next record created.

store()

store(  $updateDates = true,   $forceCreate = false,   $debug = false) : integer

Stores an existing record or creates a new record

Parameters

$updateDates

boolean set to false if you don't want mindflow to automatically set creation_date and modification_date, thus overwriting values you may have set manually

$forceCreate

boolean forces the creation of a new record with a new uid, even if the current record's uid already exists in the database.

$debug

boolean forces an echo of the SQL Request generated

Returns

integer —

the uid of the record stored or created. 0 if creation / storage has failed

getKeySQL()

getKeySQL(  $keyName,   $keyData) : string

Returns the SQL command for storing a given key from the data array, processing the values : dates are converted from localized format to SQL format, slug texts are slugified, arrays are serialized

Parameters

$keyName

string the name of the key

$keyData

array the data associated with the key

Returns

string —

the sql segment prepared for storing the given key

delete()

delete() 

desactivates a record in the database. The record can be recovered by switching its deleted field back to 0.

restore()

restore() 

reactivates a record in the database.

delete_forever()

delete_forever() 

This will definitely erase the record from the database. Prefer delete() in order to be able to recover records.

toHTML()

toHTML() : string

Outputs the record as html

Returns

string

showRecordEditTable()

showRecordEditTable(  $request,   $moduleName,   $subModuleName,   $mainKey,   $keyProcessors = array(),   $page = NULL,   $availableActions = array('view' => 0, 'edit' => 1, 'delete' => 1, 'clone' => 1),   $advancedOptions = array('ajaxActions' => 0, 'showPrint' => true, 'showResultsCount' => true)) : string

Outputs an HTML table of all the records available in this class

Parameters

$request

array The list of keys fetched from SQL, which will make the columns of the table. format must be array('SELECT' => '', 'FROM' => '', 'JOIN' => '', 'WHERE' => '');

$moduleName

string The name of the module or plugin displaying this record

$subModuleName
$mainKey

string The key of the field best describing the name of this record, used for deletion dialog : "Are you sure you want to delete the record $mainKey ?"

$keyProcessors

array An array of processing functions indexed by key name (as found in $keysList) for pre-processing values before displaying these in the table. processing function definition must be located in the record's own class file

$page

int requests displaying the page number given from the results list

$availableActions

array lists the action icons available in the actions column. Default value is array('view'=>0,'edit'=>1,'delete'=>1). Additionally, a custom function can be supplied as a string for the value of 'view','edit','delete','sortUp','sortDown'. This URL can contain some of the following markers that will be automatically substituted : {subdir}, {record_class}, {record_uid}, {module_id}, {submodule_id}, {your_custom_column_name} (this latest value has to exist as a valid column in the record table). Example value for $availableActions : array( 'view' => 'myClass::makeHTMLActionLink("viewFaq","{subdir}","{record_uid}")', 'edit' => 'myClass::makeHTMLActionLink("editFaq","{subdir}","{record_uid}")', 'delete' => 1, 'sortUp' => 'myClass::makeJSONActionLink("sortUp","{subdir}","{record_uid}")', 'sortDown' => 'myClass::makeJSONActionLink("sortDown","{subdir}","{record_uid}")', 'myCustomAction1' => 'myClass::makeJSONActionLink("customAction1","{subdir}","{record_uid}")', ),

$advancedOptions

array allows specifying more options using the following format array(

 'ajaxActions' => 0, //boolean processes action links as ajax requests rather than as regular links
 'newRecordButtonHTML' => '' //string allows inserting some custom HTML code on top of the record edit table, usualy a create new record button
 'hideColumns' => 'column1,column2', //string coma separated list of field names. removes from the recordEditTable display some columns specified in the SELECT of the request. This can be usefull if you need to have some field value retrevied for usage in a keyprocessor function, but you do not want it to be displayed
 'forceNumRowsPerPage' => '32', //int overrides the default number of rows per page
 //'showNumRowsPerPageSelector' => true, //boolean displays a selector allowing the user to set the number of rows per page
 'showResultsCount' => true, //boolean shows the total number of results
 'listRecordsInAllLanguages' => true, //force listing the records not only from current language, but from all languages
 'columnClasses' => array( //adds custom CSS classes to array columns. Useful for responsive design or other purpose.
     'columnIndex1' => 'columnClassName',
     'columnIndex2' => 'columnClassName',
 ),
 'debugSQL' => 0 //show SQL request
 'showPrint' => true, //displays print button
 'printMode' => true, //disables the display of buttons useless for printed version arround the record table
 'editRecordButtons' => array( //set available buttons in edit / create record forms opened in AJAX from the showRecordEditTable view
     'showSaveButton' => true,
     'showSaveCloseButton' => true,
     'showPreviewButton' => true,
     'showCloseButton' => true
 ),
 'formAttributes' = array(
     'method'=>'POST',
     //'onsubmit'=>'sendForm();',
     'role'=>'form',
     'class'=>'form-horizontal',
     'enctype'=>'x-www-form-urlencoded'
 )

)

Returns

string

preLoad()

preLoad() 

postLoad()

postLoad() 

preCreate()

preCreate() 

postCreate()

postCreate() 

preStore()

preStore() 

postStore()

postStore() 

preDelete()

preDelete() 

postDelete()

postDelete() 

preRestore()

preRestore() 

postRestore()

postRestore() 

onSubmit()

onSubmit() 

getActiveRecords()

getActiveRecords(  $language = '') : mixed

Lists all the records available in the class as SQL result rows

Parameters

$language

Returns

mixed —

an array of rows as returned by a SQL request

getPreviewUrl()

getPreviewUrl() : string

This function must be overloaded with your custom code.

Returns an URL where the record can be previewed from the backend.

Returns

string

getUrl()

getUrl() : string

This function must be overloaded with your custom code.

Returns the URL for viewing the record from a frontend page This function may return different URL values according to the context the record is being viewed : Say you have a website with 3 main sections : foot trips, car trips, bike trips. You want to display a news record which is generic to the 3 sections, but you want it to be seen in each section. So according to which section the news item is called from, getUrl() may return : /foot-trips/news/my-news-item.html or /car-trips/news/my-news-item.html

Returns

string

getCanonicalUrl()

getCanonicalUrl() : string

This function must be overloaded with your custom code.

Returns the MAIN URL for viewing the record from a frontend page If a record may have different display URLs (see getUrl() function doc about this), often you must only supply one main / unique / canonical URL to search engines so you avoid duplicate contents This function will return the canonical URL of your object

Returns

string

tableExists()

tableExists() : boolean

Check if a table exists in the current database.

Returns

boolean —

TRUE if table exists, FALSE if no table found.

formatDate()

formatDate(string  $key, string  $value, string  $locale, array  $row) : string

Formats a date for displaying it in the showRecordEditTable

Parameters

string $key

current key name

string $value

value of the key

string $locale

currently displayed locale

array $row

whole row data for the current record. Usefull if it is required to check the value of another key

Returns

string —

the formated date

formatDateTimeMs()

formatDateTimeMs(string  $key, string  $value, string  $locale, array  $row) : string

Formats a datetime featuring milliseconds for displaying it in the showRecordEditTable

Parameters

string $key

current key name

string $value

value of the key

string $locale

currently displayed locale

array $row

whole row data for the current record. Usefull if it is required to check the value of another key

Returns

string —

the formated date

formatDateTime()

formatDateTime(string  $key, string  $value, string  $locale, array  $row) : string

Formats a datetime for displaying it in the showRecordEditTable

Parameters

string $key

current key name

string $value

value of the key

string $locale

currently displayed locale

array $row

whole row data for the current record. Usefull if it is required to check the value of another key

Returns

string —

the formated date

formatTime()

formatTime(string  $key, string  $value, string  $locale, array  $row) : string

Formats a time for displaying it in the showRecordEditTable

Parameters

string $key

current key name

string $value

value of the key

string $locale

currently displayed locale

array $row

whole row data for the current record. Usefull if it is required to check the value of another key

Returns

string —

the formated date

formatTimestamp()

formatTimestamp(string  $value, string  $locale, array  $row) : string

Formats a timestamp for displaying it in the showRecordEditTable

Parameters

string $value

value of the key

string $locale

currently displayed locale

array $row

whole row data for the current record. Usefull if it is required to check the value of another key

Returns

string —

the formated date

getDeletedName()

getDeletedName(  $key,   $value,   $locale,   $row) 

Parameters

$key
$value
$locale
$row

makeSlug()

makeSlug(  $value,   $increment) 

Parameters

$value
$increment

searchRecordTypeahead()

searchRecordTypeahead(  $searchValue,   $formID,   $fulltextFields,   $varcharFields,   $equalFields,   $orderByFields,   $titleFields,   $tableName,   $recordClass,   $callingFieldName,   $callingRecordClass) : array

Searches the given $searchValue into the given $tableName and tries to match it with the specified $fieldNames. This function is intended to be executed from the recordSelectField search function

Parameters

$searchValue

string the value we are searching for

$formID

string the id attribute associated with the form the recordSelectField search function is being executed from

$fulltextFields

string coma separated list of fulltext fields/columns being searched in

$varcharFields
$equalFields

string coma separated list of varchar fields/columns being searched in

$orderByFields

string coma separated list fields/columns to sort the result by

$titleFields

string coma separated list of fields to display as title for the found items in the search result set

$tableName

string the table name in the SQL database of the type of record being investigated

$recordClass

string the class name of the type of record being investigated

$callingFieldName

string the field name (or you may call it key) of the record from which the search was launched

$callingRecordClass

string the class name of the record from which the search was launched

Returns

array

getClassName()

getClassName() 

__clone()

__clone() 

Clones a dbRecord, but does not store it. It is the responsability of the user to call ->store() on the new object.

Also if there are files linked to the record, the developper overloading this function should copy these, and adjust file paths to the new record directory.

listCountries()

listCountries() 

loadByISO2()

loadByISO2(  $ISO2) 

Parameters

$ISO2

checkZipCode()

checkZipCode(  $zipCode,   $coutryISO2Code) 

Parameters

$zipCode
$coutryISO2Code

getCountryName()

getCountryName(  $isoCode2) 

Parameters

$isoCode2