NOCL_Orderlicious_Base
(Usage - Concept - Properties - Functions)
Version: 1.0 (Versions)
Location: cl_objects.php
The central class, NOCL_Orderlicious_Base, contains the basic properties and functions that all the Orderlicious Element Objects have in common and is the class they all extend.
Usage
This class is only ever used as a base to be extended upon by more specific classes for the elements.
If it is referred to, it is as "extends NOCL_Orderlicious_Base" in a class definition.
Concept
Because element classes have a lot of basic properties and functions in common, it has made more sense to define them once, and then extend that definition for the specific elements as they are instantiated.
NOCL_Orderlicious_Base, is that extendable class.
Specific element classes take an NOCL_Orderlicious_Base and add their own properties before running functions to incorporate them into the complete list of element properties.
Properties
These properties mirror fields in the database and are loaded and saved as a matter of process
-
-
- $id
- (Public) The record ID for this element in its table in the database - $startDate
- (Public) Date before which this element is not at all active or available - $endDate
- (Public) Date after which this element is not at all active or available - $asset_id - Legacy from Joomla database setup. Not really needed by this class.
- $params - Legacy from Joomla database setup. Not really needed by this class.
- $published - Legacy from Joomla database setup. Not really needed by this class.
- $created_by - Legacy from Joomla database setup. Not really needed by this class.
- $modified_by - Legacy from Joomla database setup. Not really needed by this class.
- $created - Legacy from Joomla database setup. Not really needed by this class.
- $modified - Legacy from Joomla database setup. Not really needed by this class.
- $checked_out - Legacy from Joomla database setup. Not really needed by this class.
- $checked_out_time - Legacy from Joomla database setup. Not really needed by this class.
- $version - Legacy from Joomla database setup. Not really needed by this class.
- $hits - Legacy from Joomla database setup. Not really needed by this class.
- $access - Legacy from Joomla database setup. Not really needed by this class.
- $ordering - Legacy from Joomla database setup. Not really needed by this class
- $id
-
These properties are references to internal data
-
-
- $elTypRef
- An instantiation of the Element Type Reference class. - $parentElement
- The Element that contains this Element as a child. - $parentLink
- The Link object that sits between the Parent Element and this Child. - $fieldList
- Contains the full list of fields for this object, including extending class fields, if they exist. - $formDefinition
- Contains the full list of fields for this object, including extending class fields, if they exist.
- $elTypRef
-
-
- $baseFieldList
- Contains an array of the database field names that each of the tables have in common. These generally match the parameters listed above as the parameters are usually populated from the database.
- $baseFieldList
Values
- id
- asset_id
- end_date
- start_date
- params
- published
- created_by
- modified_by
- created
- modified
- checked_out
- checked_out_time
- version
- hits
- access
- ordering
- id
Functions
nocl_orderlicious_object also contains the functions that each element will be required to perform. Reading records, saving records, defining field lists, etc.
__construct()
The construct function is called when the class is instantiated. You can either send an id number or not with the call.
In this instance, if you send a $recordId, the class will be instantiated, and then the nominated Element will be loaded into its properties, and then its children. This will cascade all the way through the model.
If you just want this Element loaded without automatically populating its children, then instantiate without a parameter and use $elementInstantiation->loadRecord(x); (where $elementInstantiation is the instantiation created.) to load the record on its own.
Version
1.0
Usage
$restaurantElement = new NOCL_Restaurant( $initPackage [, $recordId ] );
Note: NOCL_Orderlicious_Base is an extended class, instantiated when an element class (Eg: NOCL_Restaurant) is instantiated. So calling __construct() happens in a NOCL_Orderlicious_Base object automatically when the element class is instantiated. Any parameters sent to the extending class are also sent to this extended class.
Paramenters
-
-
-
-
- $initPackage
- Array containing the Element Type Reference object from the Parent, the Parent Element, and the Parent Link Object to the Parent Element - $recordId
- (Optional) The record id of the element being loaded. Defaults to null
- $initPackage
-
-
-
Returns
Silently after setting property values internally. Actually, returns this class (and its descendant(s)) as an object.
Process
-
-
-
-
- From $initPackage[0], populate $this->elTypRef
- From $initPackage[1], populate $this->parentElement
- From $initPackage[2], populate $this->parentLink
- Setup $this->fieldList
Merge the arrays: $this->baseFieldList, $this->outerFieldList & $this->xtraFieldList (or at least the ones that exist) - If the $recordID parameter has been included and is a number greater than zero
-
- Run $this->loadRecord() using $recordID as a parameter to load the record into memory
- Run $this->loadChildren() to load the child elements. (though this has been disabled for the moment - it will probably be re enabled and this message should go away - make sure its gone from the version copy too.
- Run $this->loadRecord() using $recordID as a parameter to load the record into memory
- Otherwise
- Return silently
- Return silently
-
- From $initPackage[0], populate $this->elTypRef
-
-
-
loadRecord()
Loads the element's record from the appropriate database and stores it in memory
Version
1.0
Usage
$restaurantElement->loadRecord( [ $recordId ] );
Paramenters
-
-
-
-
- $recordId
- (Optional) The record id of the element being loaded. Defaults to null
- $recordId
-
-
-
Returns
true or false, depending on result
Process
-
-
-
-
- Depending on whether there is a $recordID added as a parameter, either $this->id is set from the parameter or the parameter $recordID is set to the value or $this->id. If this doesn't leave us with both a $recordID and a $this->id with values above zero to work with, return false.
- If the $recordID parameter is empty
-
- If $this->id is a number greater than zero
-
- $recordID = $this->id
- $recordID = $this->id
- Otherwise
- Set $this->id to 0
- Return False
- Set $this->id to 0
-
- If $this->id is a number greater than zero
- Otherwise
- Set $this->id to $recordID
- if $this->id is not a number greater than 0
- Set $this->id to 0
- Return False
- Set $this->id to 0
- Set $this->id to $recordID
-
- If the $recordID parameter is empty
- Depending on whether there is a $recordID added as a parameter, either $this->id is set from the parameter or the parameter $recordID is set to the value or $this->id. If this doesn't leave us with both a $recordID and a $this->id with values above zero to work with, return false.
-
-
-
-
-
-
-
- Work out the Table Name to use when Querying the Database
- Make Database Connection
Set up a new JFactory Database object and call it $db. - Instantiate a query
From $db, we get a new query called $query. - Add SELECT statement to $query
In the query we select every field name from $this->fieldList - Add FROM statement to $query
The from table is generated by adding the table prefix "#__orderlicious_" with the Element Type name. - Add WHERE statement to $query
Where is just where record.id == $this->id - Remember the query details for debugging later
Set a property onto the class called $this->loadQuery, and populate it with the $query object created above.
(Note: this is a debugging feature and may currently be turned off) - Run $query on database
Set the query into the database object and execute it. - Check for a result
If the result has more than 0 rows, we set $result as an object containing the returned sql results
- Populate class parameters
From $result, we populate the class properties with the values returned from the database.
(E.g: $this->id = $result->id; $this->activeConditions = $result->active_conditions; (etc))
NOTE: there is a set of legacy properties that have their values set, if they exist. These have names slightly different to their database field nam,es (usually a capital letter) and need to be set here rather than dynamically, if they do exist. Usually, only when an NOCL_Orderlicious_Outer_Object is being utelised. - Add $this->xtraFieldList values to class paramters
For each item in the $this->xtraFieldList, we add the value from the database to the corresponding class property.
- Populate class parameters
- Get out
If all that runs successfully:
-
- then the function returns True.
- then the function returns True.
- otherwise (including if no records are returned by the query):
- the return is False.
-
- Work out the Table Name to use when Querying the Database
-
-
-
setFormFields()
Loads a nocl_form_definition object into memory and populates its $startFields and $endFields properties
Version
1.0
Usage
$restaurantElement->setFormFields();
Paramenters
None
Returns
Silently
Process
-
-
-
-
- Instantiate a new nocl_form_definition as $this->formFields
- Add form fields to $this->formFields using $this->formFields->addFormField()
- Add fields for the start of the form
- Name
- Display Name
- Short Display
- Description
- Add fields for the end of the form
- Allow Available
- Available
- Allow Active
- Active
- Start Date
- End Date
- Add fields for the start of the form
- Instantiate a new nocl_form_definition as $this->formFields
-
-
-
loadChildren()
Takes $childElements array from the extending class and for each Element type listed, loads any children of that type into memory.
Version
1.0
Usage
$restaurantElement->loadChildren();
Paramenters
None
Returns
Silently
Process
-
-
-
-
- For each array element in $childElements property,
- Set a parameter name to register the number of child elements created for this type
Use the Element Type proprty and add "s_count" to create the string. E.g: menus_count - Create the new property with the name we just created, and populate it by running the loadChildElements() function to load the child elements and return the number of children loaded.
- Set a parameter name to register the number of child elements created for this type
- For each array element in $childElements property,
-
-
-
loadChildElements()
Instantiates and loads child elements into a child element group property.
Version
1.0
Usage
$restaurantElement->loadChildElements();
Paramenters
-
-
-
-
- $childTypeID
- The Index ID of the Child Element Type
(See Element Types for information on this value)
- $childTypeID
-
-
-
Returns
The number of child elements loaded
Process
-
-
-
-
- The function grabs a new JFactory Database object and calls it $db.
- From $db, we get a new query called $query.
- In the $query we SELECT field `id`
- The FROM table is the Global Group Item table, or `#__orderlicious_global_group_item`.
- Where is where the record parent_id == $this->id,
- and the parent type == the $this->elementIndex property
- and the group type == the $groupType parameter
- and the published field == 1
- and the parent type == the $this->elementIndex property
- The reults are to be ordered by order_position
- In the $query we SELECT field `id`
- We then set a property onto the class called $this->loadQuery, and populate it with the query object we're about to try run. (Note: This is for debugging purposes and may be currently turned off)
- Set the query into the database object and execute it.
- Set the property name to use
- Look up $groupType in the Element Type Reference property ($this->elTypRef) - Create an empty array property named by $propertyName.
- The function grabs a new JFactory Database object and calls it $db.
-
- If the result has more than 0 rows, we set $results as an associative array containing the returned sql results
- Populate the Child Element Group property
For each $results, we populate a new Child Element Group (pscl_global_group_item) object with its own data record, and Child element. This new child element and its containing group is appended to the array in the property we created 3 steps ago
- Populate the Child Element Group property
- Return the count of child records created by this function.
- If the result has more than 0 rows, we set $results as an associative array containing the returned sql results
-
-
-
childLists()
Reads the list of available child types from extending class and produces an array of fields for child record fields in an edit form
Version
1.0
Usage:
$listOfChildFields = $this->childLists();
Paramenters:
None
Returns:
Array of form field definition arrays for each Child Element type of this Element. (See here for more info)
Process:
-
-
-
-
- Create an new empty array to manipulate and ultimately return
- For each $this->childElements (as set from the extending class),
- Add a new associative array to hold the field definition.
- Set Values:
- Field Type:
- "fType" = "multiSel" - Element Type
- "mType" = - Field Name
- "fName" = - Field Label
- - Help Text
- - Field Value
- - Source Value
- - Record ID
-
-
-
-
$retVal[] = array(
'fType'=>'multiSel',
'mType'=>'ingredient',
'fName'=>$this->tableName . 'Ingredients',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . 's',
'fHelpText'=>'Enter the name for this restaurant here. This is the name you reference it with in the admin part of the site.',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id);
/**
*
* defineEditForm() V1.0
*
* The information behind an edit form has no need to be dealt with unless
* it is needed. This function instantiates an edit form object.
*
* Usage
* $restaurantElement->defineEditForm();
*
* Paramenters
* None
*
* Returns
* Silently after setting property values internally.
*
*/
public function defineEditForm() {
$this->formDefinition = new NOCL_Form_Definition($this->$xtraFormFields);
}
defineEditForm()
The information behind an edit form has no need to be dealt with unless it is needed. This function instantiates an edit form object.
Version
1.0
Usage:
$restaurantElement->defineEditForm();
Paramenters:
None
Returns:
Silently after setting property values internally.
Process:
-
-
-
-
- Set $this->formDefinition as a new NOCL_Form_Definition
- Pass $this->xtraFormFields as a parameter
- Set $this->formDefinition as a new NOCL_Form_Definition
-
-
-
-
-
-
-
-
- Otherwise
- Set the class parameters for Element Type, Field Type, Name, Label and Record ID with the appropriate parameter values.
- Otherwise
- If the submitted Field Value isn't null
- Set the class Field Value property with the submitted parameter value
- Set the class Field Value property with the submitted parameter value
- If the submitted Placeholder Text is null
-
- Set the class Placeholder Text property to an empty string
- Set the class Placeholder Text property to an empty string
- Otherwise
- Set the class Placeholder Text property with the submitted parameter value
- Set the class Placeholder Text property with the submitted parameter value
-
- If the submitted Help Text is null
-
- Set the class Help Text property to an empty string.
- Set the class Help Text property to an empty string.
- Otherwise
- Set the class Help Text property with the submitted value
- Set the class Help Text property with the submitted value
-
- If the field type is an Availability Selector
- Append an extra description of how to use the Availability Selector to the Help Text property.
- If the field type is a MultiSelect Selector
- If the source field parameter is not null
- Set the class Source field property with the submitted value.
- Return True
- If the source field parameter is not null
-
-
-
-
public function childLists() {
$retVal = array();
foreach ($this->childElements as $childElement) {
$retVal[] = array(
'fType'=>'multiSel',
'mType'=>'ingredient',
'fName'=>$this->tableName . 'Ingredients',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . 's',
'fHelpText'=>'Enter the name for this restaurant here. This is the name you reference it with in the admin part of the site.',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id);
}
return $retVal;
}
Location: cl_objects.php
This class defines a form field in an edit form for Orderlicious elements.
Concept
This class manages the presentation of an edit form field to the web page.
it holds in memory the values a form will need when including a field. Many of them together make up the content of the form itself.
The nocl_form_field is held in an array in a nocl_form_definition instantiation. .
Properties
-
-
- $element type
- The type of element this form field is for - $fieldType
- The type of field being displayed: text | textarea | checkbox | availSel | multiSel - $name
- The name of field being displayed - $label
- Tthe label that should be displayed with the field - $placeholder
- What should appear in the placeholder text, if anything - $helptext
- The helptext that appears for the field when needed - $fValue
- The value of field being displayed - $recordId
- The record id of the field being presented - $sValue
- The source value(s) for the field
- $element type
-
Functions
__construct()
Usage:
$formDefinition[] = new nocl_form_field($elementType, $fieldType, $fieldName, $fieldLabel, $fieldValue, $recordId, [$helptext[, $placeholder[, $sourceValue]]]);
paramenters:
-
-
-
-
- $elementType
- The type of element this form field is for - $fieldType
- The type of field being displayed: text | textarea | checkbox | availSel | multiSel - $fieldName
- The name of field being displayed - $fieldLabel
- The label that should be displayed with the field - $fieldValue
- The value of field being displayed - $recordId
- The record id of the field being presented - $helptext
- (Optional) Tthe helptext that appears for the field when needed - $placeholder
- {Optional} What should appear in the placeholder text, if anything - $sourceValue
- (optional - usually for "select" options) The source value(s) for the field
- $elementType
-
-
-
returns:
Silently after setting property values internally. Actually, returns this class as an object.
process:
-
-
-
-
- If required parameters have been entered,
- Run $this->setValues, using the input parameters as parameters for the function.
- If required parameters have been entered,
-
-
-
setValues()
Usage:
$formField->setValues($elementType, $fieldType, $fieldName, $fieldLabel, $fieldValue, $recordId, [$helptext[, $placeholder[, $sourceValue]]]);
Paramenters:
-
-
-
-
- $elementType
- The type of element this form field is for - $fieldType
- The type of field being displayed: text | textarea | checkbox | availSel | multiSel - $fieldName
- The name of field being displayed - $fieldLabel
- The label that should be displayed with the field - $fieldValue
- The value of field being displayed - $recordId
- The record id of the field being presented - $helptext
- (Optional) Tthe helptext that appears for the field when needed - $placeholder
- {Optional} What should appear in the placeholder text, if anything - $sourceValue
- (optional - usually for "select" options) The source value(s) for the field
- $elementType
-
-
-
Returns:
True on successful completion
Process:
-
-
-
-
- If any required parameters have not been entered (Element Type, Field Type, Name, Label and Record ID),
-
- Return False.
- Return False.
- Otherwise
- Set the class parameters for Element Type, Field Type, Name, Label and Record ID with the appropriate parameter values.
-
- If the submitted Field Value isn't null
- Set the class Field Value property with the submitted parameter value
- Set the class Field Value property with the submitted parameter value
- If the submitted Placeholder Text is null
-
- Set the class Placeholder Text property to an empty string
- Set the class Placeholder Text property to an empty string
- Otherwise
- Set the class Placeholder Text property with the submitted parameter value
- Set the class Placeholder Text property with the submitted parameter value
-
- If the submitted Help Text is null
-
- Set the class Help Text property to an empty string.
- Set the class Help Text property to an empty string.
- Otherwise
- Set the class Help Text property with the submitted value
- Set the class Help Text property with the submitted value
-
- If the field type is an Availability Selector
- Append an extra description of how to use the Availability Selector to the Help Text property.
- If the field type is a MultiSelect Selector
- If the source field parameter is not null
- Set the class Source field property with the submitted value.
- Return True
- If the source field parameter is not null
- If any required parameters have not been entered (Element Type, Field Type, Name, Label and Record ID),
-
-
-
-
-
-
-
-
- function.
-
-
-
-
-
-
-
-
-
- function.
-
-
-
-
public function childLists() {
$retVal = array();
foreach ($this->childElements as $childElement) {
$retVal[] = array(
'fType'=>'multiSel',
'mType'=>'ingredient',
'fName'=>$this->tableName . 'Ingredients',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . 's',
'fHelpText'=>'Enter the name for this restaurant here. This is the name you reference it with in the admin part of the site.',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id);
}
return $retVal;
}
nocl_orderlicious_object {
public $id = 0;
public $name = null;
public $displayName = null;
public $shortDisplay = null;
public $description = null;
public $activeConditions = null;
public $availableConditions = null;
public $allowActive = null;
public $allowAvailable = null;
public $startDate = null;
public $endDate = null;
public $asset_id = null;
public $params = null;
public $published = null;
public $created_by = null;
public $modified_by = null;
public $created = null;
public $modified = null;
public $checked_out = null;
public $checked_out_time = null;
public $version = null;
public $hits = null;
public $access = null;
public $ordering = null;
public $parentElement;
public $parentLink;
public $elementTypes = new nocl_element_types;
public $parent_types = array('Select type', 'category', 'item',
'base', 'image', 'ingredient', 'sauce', 'size');
public $group_types = array('Select type', 'base', 'image',
'ingredient', 'sauce', 'size', 'size', 'ingredient', 'item', 'category',
'menu', 'location', 'restaurant');
public $fieldList = array('id', 'asset_id', 'active_conditions',
'allow_active', 'allow_available', 'available_conditions', 'description',
'displayname', 'end_date', 'name', 'shortdisplay', 'start_date', 'params',
'published', 'created_by', 'modified_by', 'created', 'modified',
'checked_out', 'checked_out_time', 'version', 'hits', 'access', 'ordering');
public $headFormFields = array(
array('fType'=>'text',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . ' Name',
'fPlaceholder'=>ucfirst($this->tableName) . ' Name goes here',
'fHelpText'=>'Enter the name for this ' . $this->tableName
. ' here. This is the name you reference it with in '
. 'the admin sections of the site.',
'fValue'=>$this->name,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'text',
'fName'=>'displayName',
'fLabel'=>'Display Name',
'fPlaceholder'=>'Display Name goes here',
'fHelpText'=>'Enter the display version of the name for this ' . $this->tableName
. ' here. It will be used whenever the ' . $this->tableName
. ' name is referenced in full',
'fValue'=>$this->displayName,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'text',
'fName'=>'shortName',
'fLabel'=>'Short Display Name',
'fPlaceholder'=>'Short Name goes here',
'fHelpText'=>'Enter a truncated version of the name for this ' . $this->tableName
. ' here. It will be used whenever a brief reference is required.',
'fValue'=>$this->shortDisplay,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'textarea',
'fName'=>'description',
'fLabel'=>'Description',
'fPlaceholder'=>'Enter a description...',
'fHelpText'=>'Enter a description for this ' . $this->tableName . '.',
'fValue'=>$this->description,
'tType'=>$this->tableName,
'rId'=>$this->id)
);
public $baseFormFields = array(
array('fType'=>'checkbox',
'fName'=>$this->tableName . 'AllowAvailable',
'fLabel'=>'Allow Available',
'fHelpText'=>'Is this ' . $this->tableName
. 'allowed to be available?',
'fValue'=>$this->allowAvailable,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'availSel',
'fName'=>$this->tableName . 'Available',
'fLabel'=>'Available',
'fHelpText'=>'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.',
'fValue'=>$this->availableConditions,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'checkbox',
'fName'=>$this->tableName . 'AllowActive',
'fLabel'=>'Allow Active',
'fHelpText'=>'Is this ' . $this->tableName
. 'allowed to be active?',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'availSel',
'fName'=>$this->tableName . 'Name',
'fLabel'=>'Active',
'fHelpText'=>'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.',
'fValue'=>$this->activeConditions,
'tType'=>$this->tableName,
'rId'=>$this->id)
);
public function __construct($id = null) {
$this->fieldList = array_merge($this->fieldList, $this->xtraFieldList);
if (!is_null($id)) {
if (!empty($id) && ($id > 0)) {
$this->loadRecord($id);
$this->loadChildren();
}
}
}
public function loadRecord($id = null) {
//$this->loadingRecordID = $id;
// Use the input for a record id, or if it is missing, use $this->id
if (is_null($id)) {
if (!empty($this->id) && ($this->id > 0)) {
$id = $this->id;
} else {
$this->id = 0;
return false;
}
} else {
$this->id = $id;
if (!$this->id > 0) {
$this->id = 0;
return false;
}
}
//$this->stilLoadingRecordID = $id;
//$this->stilLoadingRecordID_again = $id;
// set the database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName($this->fieldList));
$query->from($db->quoteName(
'#__orderlicious_' . $this->tableName));
$query->where($db->quoteName('id') . '=' . $id);
$this->loadQuery = $query;
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$result = $db->loadObject();
$this->id = $result->id;
$this->name = $result->name;
$this->displayName = $result->displayname;
$this->shortDisplay = $result->shortdisplay;
$this->description = $result->description;
$this->activeConditions = $result->active_conditions;
$this->availableConditions = $result->available_conditions;
$this->allowActive = $result->allow_active;
$this->allowAvailable = $result->allow_available;
$this->startDate = $result->start_date;
$this->endDate = $result->end_date;
$this->asset_id = $result->asset_id;
$this->params = $result->params;
$this->published = $result->published;
$this->created_by = $result->created_by;
$this->modified_by = $result->modified_by;
$this->created = $result->created;
$this->modified = $result->modified;
$this->checked_out = $result->checked_out;
$this->checked_out_time = $result->checked_out_time;
$this->version = $result->version;
$this->hits = $result->hits;
$this->access = $result->access;
$this->ordering = $result->ordering;
foreach ($this->xtraFieldList as $fieldName) {
$this->$fieldName = $result->$fieldName;
}
return true;
}
return false;
}
public function loadChildElements($parentType, $groupType) {
$parent_types = array('Select type', 'category', 'item', 'base',
'image', 'ingredient', 'sauce', 'size');
$group_types = array('Select type', 'base', 'image', 'ingredient', 'sauce', 'size', 'size', 'ingredient', 'item', 'category', 'menu',
'location', 'restaurant');
// set the database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__orderlicious_global_group_item'));
$query->where($db->quoteName("parent_id") . "=" . $this->id);
$query->where($db->quoteName("parent_type") . "=" . $parentType);
$query->where($db->quoteName("group_type") . "=" . $groupType);
$query->where($db->quoteName("published") . "=1");
$query->orderby($db->quoteName("order_position"));
//$this->childQueries[] = $query;
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$results = $db->loadAssocList();
//$this->childResults[] = $results;
foreach ($results as $result) {
Make it: $propertyName = $elTypRef->childElements[$groupType] ;
$propertyName = $group_types[$groupType];
//$this->propertyName = $propertyName;
$this->$propertyName[]
= new nocl_global_group_item($result['id'], $groupType);
$this->$propertyName[count($this->$propertyName) - 1]->parentElement = $this;
$this->$propertyName[count($this->$propertyName) - 1]->childObj->parentElement = $this;
$this->$propertyName[count($this->$propertyName) - 1]->childObj->parentLink
= $this->$propertyName[count($this->$propertyName) - 1];
}
return count($results);
}
}
public function loadChildren() {
foreach ($this->childElements as $cEl) {
$paramName = $cEl['ceName'] . "s_count";
$this->$paramName = $this->loadChildElements($cEl['parentType'], $cEl['groupType']);
}
}
public function formFieldList() {
return array_merge($this->headFormFields, $this->xtraFormFields,
$this->baseFormFields, $this->childLists());
}
public function childLists() {
$retVal = array();
foreach ($this->childElements as $childElement) {
$retVal[] = array(
'fType'=>'multiSel',
'mType'=>'ingredient',
'fName'=>$this->tableName . 'Ingredients',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . 's',
'fHelpText'=>'Enter the name for this restaurant here. This is the name you reference it with in the admin part of the site.',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id);
}
return $retVal;
}
public function setFormFields() {
$this->formFields = new nocl_form_definition();
$this->formFields->addFormField(0, $this->tableName, 'text', $this->tableName . '_name',
ucfirst($this->tableName) . ' Name', $this->name,
'Enter the name for this ' . $this->tableName . ' here. This is the name you reference it with in '
. 'the admin sections of the site.', $this->id, ucfirst($this->tableName) . ' Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'text', 'display_name', 'Display Name', $this->displayName, $this->id,
'Enter the display version of the name for this ' . $this->tableName
. ' here. It will be used whenever the ' . $this->tableName . ' name is referenced in full',
'Display Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'text', 'short_name', 'Short Name', $this->shortName, $this->id,
'Enter a truncated version of the name for this ' . $this->tableName
. ' here. It will be used whenever a brief reference is required.',
'Short Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'textarea', 'description', 'Description',
$this->description, $this->id, 'Enter a description for this ' . $this->tableName . '.',
'Enter a description...');
$this->formFields->addFormField(2, $this->tableName, 'checkbox', 'allow_available', 'Allow Available',
$this->allowAvailable, $this->id, '',
'Is this ' . $this->tableName . 'allowed to be available?');
$this->formFields->addFormField(2, $this->tableName, 'availSel', 'available', 'Available',
$this->availableConditions, $this->id, 'Select a block of hours with a start time '
. 'and end time, or select End of Day to not have an end time. Then select '
. 'which days this applies to. Add as many as you need.');
$this->formFields->addFormField(2, $this->tableName, 'checkbox', 'allow_active',
'Allow Active', $this->allowActive, $this->id, '',
'Is this ' . $this->tableName . 'allowed to be active?');
$this->formFields->addFormField(2, $this->tableName, 'availSel', 'active', 'Active',
$this->activeConditions, $this->id, '',
'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.');
}
}
class nocl_orderlicious_object {
public $id = 0;
public $name = null;
public $displayName = null;
public $shortDisplay = null;
public $description = null;
public $activeConditions = null;
public $availableConditions = null;
public $allowActive = null;
public $allowAvailable = null;
public $startDate = null;
public $endDate = null;
public $asset_id = null;
public $params = null;
public $published = null;
public $created_by = null;
public $modified_by = null;
public $created = null;
public $modified = null;
public $checked_out = null;
public $checked_out_time = null;
public $version = null;
public $hits = null;
public $access = null;
public $ordering = null;
public $parentElement;
public $parentLink;
public $elementTypes = new nocl_element_types;
public $parent_types = array('Select type', 'category', 'item',
'base', 'image', 'ingredient', 'sauce', 'size');
public $group_types = array('Select type', 'base', 'image',
'ingredient', 'sauce', 'size', 'size', 'ingredient', 'item', 'category',
'menu', 'location', 'restaurant');
public $fieldList = array('id', 'asset_id', 'active_conditions',
'allow_active', 'allow_available', 'available_conditions', 'description',
'displayname', 'end_date', 'name', 'shortdisplay', 'start_date', 'params',
'published', 'created_by', 'modified_by', 'created', 'modified',
'checked_out', 'checked_out_time', 'version', 'hits', 'access', 'ordering');
public $headFormFields = array(
array('fType'=>'text',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . ' Name',
'fPlaceholder'=>ucfirst($this->tableName) . ' Name goes here',
'fHelpText'=>'Enter the name for this ' . $this->tableName
. ' here. This is the name you reference it with in '
. 'the admin sections of the site.',
'fValue'=>$this->name,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'text',
'fName'=>'displayName',
'fLabel'=>'Display Name',
'fPlaceholder'=>'Display Name goes here',
'fHelpText'=>'Enter the display version of the name for this ' . $this->tableName
. ' here. It will be used whenever the ' . $this->tableName
. ' name is referenced in full',
'fValue'=>$this->displayName,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'text',
'fName'=>'shortName',
'fLabel'=>'Short Display Name',
'fPlaceholder'=>'Short Name goes here',
'fHelpText'=>'Enter a truncated version of the name for this ' . $this->tableName
. ' here. It will be used whenever a brief reference is required.',
'fValue'=>$this->shortDisplay,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'textarea',
'fName'=>'description',
'fLabel'=>'Description',
'fPlaceholder'=>'Enter a description...',
'fHelpText'=>'Enter a description for this ' . $this->tableName . '.',
'fValue'=>$this->description,
'tType'=>$this->tableName,
'rId'=>$this->id)
);
public $baseFormFields = array(
array('fType'=>'checkbox',
'fName'=>$this->tableName . 'AllowAvailable',
'fLabel'=>'Allow Available',
'fHelpText'=>'Is this ' . $this->tableName
. 'allowed to be available?',
'fValue'=>$this->allowAvailable,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'availSel',
'fName'=>$this->tableName . 'Available',
'fLabel'=>'Available',
'fHelpText'=>'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.',
'fValue'=>$this->availableConditions,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'checkbox',
'fName'=>$this->tableName . 'AllowActive',
'fLabel'=>'Allow Active',
'fHelpText'=>'Is this ' . $this->tableName
. 'allowed to be active?',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'availSel',
'fName'=>$this->tableName . 'Name',
'fLabel'=>'Active',
'fHelpText'=>'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.',
'fValue'=>$this->activeConditions,
'tType'=>$this->tableName,
'rId'=>$this->id)
);
public function __construct($id = null) {
$this->fieldList = array_merge($this->fieldList, $this->xtraFieldList);
if (!is_null($id)) {
if (!empty($id) && ($id > 0)) {
$this->loadRecord($id);
$this->loadChildren();
}
}
}
public function loadRecord($id = null) {
//$this->loadingRecordID = $id;
// Use the input for a record id, or if it is missing, use $this->id
if (is_null($id)) {
if (!empty($this->id) && ($this->id > 0)) {
$id = $this->id;
} else {
$this->id = 0;
return false;
}
} else {
$this->id = $id;
if (!$this->id > 0) {
$this->id = 0;
return false;
}
}
//$this->stilLoadingRecordID = $id;
//$this->stilLoadingRecordID_again = $id;
// set the database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName($this->fieldList));
$query->from($db->quoteName(
'#__orderlicious_' . $this->tableName));
$query->where($db->quoteName('id') . '=' . $id);
$this->loadQuery = $query;
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$result = $db->loadObject();
$this->id = $result->id;
$this->name = $result->name;
$this->displayName = $result->displayname;
$this->shortDisplay = $result->shortdisplay;
$this->description = $result->description;
$this->activeConditions = $result->active_conditions;
$this->availableConditions = $result->available_conditions;
$this->allowActive = $result->allow_active;
$this->allowAvailable = $result->allow_available;
$this->startDate = $result->start_date;
$this->endDate = $result->end_date;
$this->asset_id = $result->asset_id;
$this->params = $result->params;
$this->published = $result->published;
$this->created_by = $result->created_by;
$this->modified_by = $result->modified_by;
$this->created = $result->created;
$this->modified = $result->modified;
$this->checked_out = $result->checked_out;
$this->checked_out_time = $result->checked_out_time;
$this->version = $result->version;
$this->hits = $result->hits;
$this->access = $result->access;
$this->ordering = $result->ordering;
foreach ($this->xtraFieldList as $fieldName) {
$this->$fieldName = $result->$fieldName;
}
return true;
}
return false;
}
public function loadChildElements($parentType, $groupType) {
$parent_types = array('Select type', 'category', 'item', 'base',
'image', 'ingredient', 'sauce', 'size');
$group_types = array('Select type', 'base', 'image', 'ingredient', 'sauce', 'size', 'size', 'ingredient', 'item', 'category', 'menu',
'location', 'restaurant');
// set the database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__orderlicious_global_group_item'));
$query->where($db->quoteName("parent_id") . "=" . $this->id);
$query->where($db->quoteName("parent_type") . "=" . $parentType);
$query->where($db->quoteName("group_type") . "=" . $groupType);
$query->where($db->quoteName("published") . "=1");
$query->orderby($db->quoteName("order_position"));
//$this->childQueries[] = $query;
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$results = $db->loadAssocList();
//$this->childResults[] = $results;
foreach ($results as $result) {
$propertyName = $group_types[$groupType];
//$this->propertyName = $propertyName;
$this->$propertyName[]
= new nocl_global_group_item($result['id'], $groupType);
$this->$propertyName[count($this->$propertyName) - 1]->parentElement = $this;
$this->$propertyName[count($this->$propertyName) - 1]->childObj->parentElement = $this;
$this->$propertyName[count($this->$propertyName) - 1]->childObj->parentLink
= $this->$propertyName[count($this->$propertyName) - 1];
}
return count($results);
}
}
public function loadChildren() {
foreach ($this->childElements as $cEl) {
$paramName = $cEl['ceName'] . "s_count";
$this->$paramName = $this->loadChildElements($cEl['parentType'], $cEl['groupType']);
}
}
public function formFieldList() {
return array_merge($this->headFormFields, $this->xtraFormFields,
$this->baseFormFields, $this->childLists());
}
public function childLists() {
$retVal = array();
foreach ($this->childElements as $childElement) {
$retVal[] = array(
'fType'=>'multiSel',
'mType'=>'ingredient',
'fName'=>$this->tableName . 'Ingredients',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . 's',
'fHelpText'=>'Enter the name for this restaurant here. This is the name you reference it with in the admin part of the site.',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id);
}
return $retVal;
}
public function setFormFields() {
$this->formFields = new nocl_form_definition();
$this->formFields->addFormField(0, $this->tableName, 'text', $this->tableName . '_name',
ucfirst($this->tableName) . ' Name', $this->name,
'Enter the name for this ' . $this->tableName . ' here. This is the name you reference it with in '
. 'the admin sections of the site.', $this->id, ucfirst($this->tableName) . ' Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'text', 'display_name', 'Display Name', $this->displayName, $this->id,
'Enter the display version of the name for this ' . $this->tableName
. ' here. It will be used whenever the ' . $this->tableName . ' name is referenced in full',
'Display Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'text', 'short_name', 'Short Name', $this->shortName, $this->id,
'Enter a truncated version of the name for this ' . $this->tableName
. ' here. It will be used whenever a brief reference is required.',
'Short Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'textarea', 'description', 'Description',
$this->description, $this->id, 'Enter a description for this ' . $this->tableName . '.',
'Enter a description...');
$this->formFields->addFormField(2, $this->tableName, 'checkbox', 'allow_available', 'Allow Available',
$this->allowAvailable, $this->id, '',
'Is this ' . $this->tableName . 'allowed to be available?');
$this->formFields->addFormField(2, $this->tableName, 'availSel', 'available', 'Available',
$this->availableConditions, $this->id, 'Select a block of hours with a start time '
. 'and end time, or select End of Day to not have an end time. Then select '
. 'which days this applies to. Add as many as you need.');
$this->formFields->addFormField(2, $this->tableName, 'checkbox', 'allow_active',
'Allow Active', $this->allowActive, $this->id, '',
'Is this ' . $this->tableName . 'allowed to be active?');
$this->formFields->addFormField(2, $this->tableName, 'availSel', 'active', 'Active',
$this->activeConditions, $this->id, '',
'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.');
}
}
class nocl_orderlicious_object {
public $id = 0;
public $name = null;
public $displayName = null;
public $shortDisplay = null;
public $description = null;
public $activeConditions = null;
public $availableConditions = null;
public $allowActive = null;
public $allowAvailable = null;
public $startDate = null;
public $endDate = null;
public $asset_id = null;
public $params = null;
public $published = null;
public $created_by = null;
public $modified_by = null;
public $created = null;
public $modified = null;
public $checked_out = null;
public $checked_out_time = null;
public $version = null;
public $hits = null;
public $access = null;
public $ordering = null;
public $parentElement;
public $parentLink;
public $elementTypes = new nocl_element_types;
public $parent_types = array('Select type', 'category', 'item',
'base', 'image', 'ingredient', 'sauce', 'size');
public $group_types = array('Select type', 'base', 'image',
'ingredient', 'sauce', 'size', 'size', 'ingredient', 'item', 'category',
'menu', 'location', 'restaurant');
public $fieldList = array('id', 'asset_id', 'active_conditions',
'allow_active', 'allow_available', 'available_conditions', 'description',
'displayname', 'end_date', 'name', 'shortdisplay', 'start_date', 'params',
'published', 'created_by', 'modified_by', 'created', 'modified',
'checked_out', 'checked_out_time', 'version', 'hits', 'access', 'ordering');
public $headFormFields = array(
array('fType'=>'text',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . ' Name',
'fPlaceholder'=>ucfirst($this->tableName) . ' Name goes here',
'fHelpText'=>'Enter the name for this ' . $this->tableName
. ' here. This is the name you reference it with in '
. 'the admin sections of the site.',
'fValue'=>$this->name,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'text',
'fName'=>'displayName',
'fLabel'=>'Display Name',
'fPlaceholder'=>'Display Name goes here',
'fHelpText'=>'Enter the display version of the name for this ' . $this->tableName
. ' here. It will be used whenever the ' . $this->tableName
. ' name is referenced in full',
'fValue'=>$this->displayName,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'text',
'fName'=>'shortName',
'fLabel'=>'Short Display Name',
'fPlaceholder'=>'Short Name goes here',
'fHelpText'=>'Enter a truncated version of the name for this ' . $this->tableName
. ' here. It will be used whenever a brief reference is required.',
'fValue'=>$this->shortDisplay,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'textarea',
'fName'=>'description',
'fLabel'=>'Description',
'fPlaceholder'=>'Enter a description...',
'fHelpText'=>'Enter a description for this ' . $this->tableName . '.',
'fValue'=>$this->description,
'tType'=>$this->tableName,
'rId'=>$this->id)
);
public $baseFormFields = array(
array('fType'=>'checkbox',
'fName'=>$this->tableName . 'AllowAvailable',
'fLabel'=>'Allow Available',
'fHelpText'=>'Is this ' . $this->tableName
. 'allowed to be available?',
'fValue'=>$this->allowAvailable,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'availSel',
'fName'=>$this->tableName . 'Available',
'fLabel'=>'Available',
'fHelpText'=>'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.',
'fValue'=>$this->availableConditions,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'checkbox',
'fName'=>$this->tableName . 'AllowActive',
'fLabel'=>'Allow Active',
'fHelpText'=>'Is this ' . $this->tableName
. 'allowed to be active?',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id),
array('fType'=>'availSel',
'fName'=>$this->tableName . 'Name',
'fLabel'=>'Active',
'fHelpText'=>'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.',
'fValue'=>$this->activeConditions,
'tType'=>$this->tableName,
'rId'=>$this->id)
);
/**
*
* __construct() V1.0
*
* The construct function is called when the class is instantiated.
* You can either send an id number or not with the call.
*
* Usage
* $restaurantElement = new nocl_restaurant( [ $recordId ] );
*
* Note: nocl_orderlicious_object is an extended class, instantiated
* when an element class (Eg: nocl_restaurant) is instantiated.
* So calling __construct() happens in a nocl_orderlicious_object
* object automatically when the element class is instantiated.
* Any parameters sent to the extending class are also sent to this
* extended class.
*
* Paramenters
* $recordId - (Optional) The record id of the element being loaded. Defaults to null
*
* Returns
* Silently after setting property values internally.
*
*/
public function __construct($id = null) {
// Leave this one out and trigger it manually when required
//$this->fieldList = array_merge($this->fieldList, $this->xtraFieldList);
if (!is_null($id)) {
if (!empty($id) && ($id > 0)) {
$this->loadRecord($id);
$this->loadChildren();
}
}
}
/**
*
* loadRecord() V1.0
*
* Loads the element's record from the appropriate database and stores it in memory
*
* Usage
* $restaurantElement->loadRecord( [ $recordId ] );
*
* Paramenters
* $recordId - (Optional) The record id of the element being loaded. Defaults to null
*
* Returns
* True or False, depending on result
*
*/
public function loadRecord($id = null) {
// Use the input for a record id, or if it is missing, use $this->id
if (is_null($id)) {
if (!empty($this->id) && ($this->id > 0)) {
$id = $this->id;
} else {
$this->id = 0;
return false;
}
} else {
$this->id = $id;
if (!$this->id > 0) {
$this->id = 0;
return false;
}
}
// set the database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName($this->fieldList));
$query->from($db->quoteName(
'#__orderlicious_' . $this->tableName));
$query->where($db->quoteName('id') . '=' . $id);
$this->loadQuery = $query;
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$result = $db->loadObject();
$this->id = $result->id;
$this->name = $result->name;
$this->displayName = $result->displayname;
$this->shortDisplay = $result->shortdisplay;
$this->description = $result->description;
$this->activeConditions = $result->active_conditions;
$this->availableConditions = $result->available_conditions;
$this->allowActive = $result->allow_active;
$this->allowAvailable = $result->allow_available;
$this->startDate = $result->start_date;
$this->endDate = $result->end_date;
$this->asset_id = $result->asset_id;
$this->params = $result->params;
$this->published = $result->published;
$this->created_by = $result->created_by;
$this->modified_by = $result->modified_by;
$this->created = $result->created;
$this->modified = $result->modified;
$this->checked_out = $result->checked_out;
$this->checked_out_time = $result->checked_out_time;
$this->version = $result->version;
$this->hits = $result->hits;
$this->access = $result->access;
$this->ordering = $result->ordering;
foreach ($this->xtraFieldList as $fieldName) {
$this->$fieldName = $result->$fieldName;
}
return true;
}
return false;
}
public function loadChildElements($parentType, $groupType) {
$parent_types = array('Select type', 'category', 'item', 'base',
'image', 'ingredient', 'sauce', 'size');
$group_types = array('Select type', 'base', 'image', 'ingredient', 'sauce', 'size', 'size', 'ingredient', 'item', 'category', 'menu',
'location', 'restaurant');
// set the database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__orderlicious_global_group_item'));
$query->where($db->quoteName("parent_id") . "=" . $this->id);
$query->where($db->quoteName("parent_type") . "=" . $parentType);
$query->where($db->quoteName("group_type") . "=" . $groupType);
$query->where($db->quoteName("published") . "=1");
$query->orderby($db->quoteName("order_position"));
//$this->childQueries[] = $query;
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$results = $db->loadAssocList();
//$this->childResults[] = $results;
foreach ($results as $result) {
$propertyName = $group_types[$groupType];
//$this->propertyName = $propertyName;
$this->$propertyName[]
= new nocl_global_group_item($result['id'], $groupType);
$this->$propertyName[count($this->$propertyName) - 1]->parentElement = $this;
$this->$propertyName[count($this->$propertyName) - 1]->childObj->parentElement = $this;
$this->$propertyName[count($this->$propertyName) - 1]->childObj->parentLink
= $this->$propertyName[count($this->$propertyName) - 1];
}
return count($results);
}
}
public function loadChildren() {
foreach ($this->childElements as $cEl) {
$paramName = $cEl['ceName'] . "s_count";
$this->$paramName = $this->loadChildElements($cEl['parentType'], $cEl['groupType']);
}
}
public function formFieldList() {
return array_merge($this->headFormFields, $this->xtraFormFields,
$this->baseFormFields, $this->childLists());
}
public function childLists() {
$retVal = array();
foreach ($this->childElements as $childElement) {
$retVal[] = array(
'fType'=>'multiSel',
'mType'=>'ingredient',
'fName'=>$this->tableName . 'Ingredients',
'fName'=>$this->tableName . 'Name',
'fLabel'=>ucfirst($this->tableName) . 's',
'fHelpText'=>'Enter the name for this restaurant here. This is the name you reference it with in the admin part of the site.',
'fValue'=>$this->allowActive,
'tType'=>$this->tableName,
'rId'=>$this->id);
}
return $retVal;
}
public function setFormFields() {
$this->formFields = new nocl_form_definition();
$this->formFields->addFormField(0, $this->tableName, 'text', $this->tableName . '_name',
ucfirst($this->tableName) . ' Name', $this->name,
'Enter the name for this ' . $this->tableName . ' here. This is the name you reference it with in '
. 'the admin sections of the site.', $this->id, ucfirst($this->tableName) . ' Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'text', 'display_name', 'Display Name', $this->displayName, $this->id,
'Enter the display version of the name for this ' . $this->tableName
. ' here. It will be used whenever the ' . $this->tableName . ' name is referenced in full',
'Display Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'text', 'short_name', 'Short Name', $this->shortName, $this->id,
'Enter a truncated version of the name for this ' . $this->tableName
. ' here. It will be used whenever a brief reference is required.',
'Short Name goes here');
$this->formFields->addFormField(0, $this->tableName, 'textarea', 'description', 'Description',
$this->description, $this->id, 'Enter a description for this ' . $this->tableName . '.',
'Enter a description...');
$this->formFields->addFormField(2, $this->tableName, 'checkbox', 'allow_available', 'Allow Available',
$this->allowAvailable, $this->id, '',
'Is this ' . $this->tableName . 'allowed to be available?');
$this->formFields->addFormField(2, $this->tableName, 'availSel', 'available', 'Available',
$this->availableConditions, $this->id, 'Select a block of hours with a start time '
. 'and end time, or select End of Day to not have an end time. Then select '
. 'which days this applies to. Add as many as you need.');
$this->formFields->addFormField(2, $this->tableName, 'checkbox', 'allow_active',
'Allow Active', $this->allowActive, $this->id, '',
'Is this ' . $this->tableName . 'allowed to be active?');
$this->formFields->addFormField(2, $this->tableName, 'availSel', 'active', 'Active',
$this->activeConditions, $this->id, '',
'Select a block of hours with a start '
. 'time and and end time, or select End of Day '
. 'to not have an end time. Then select which '
. 'days this applies to. Add as many as you need.');
}
}