Print

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

These properties are references to internal data

Values

 

        1. id
        2. asset_id
        3. end_date
        4. start_date
        5. params
        6. published
        7. created_by
        8. modified_by
        9. created
        10. modified
        11. checked_out
        12. checked_out_time
        13. version
        14. hits
        15. access
        16. ordering

 

 

 

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

 

Returns

Silently after setting property values internally.  Actually, returns this class (and its descendant(s)) as an object.

 

Process

 

loadRecord()

Loads the element's record from the appropriate database and stores it in memory

Version

1.0

Usage

$restaurantElement->loadRecord( [ $recordId ] );

Paramenters

Returns

true or false, depending on result

Process

 

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

 

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

 

 

loadChildElements()

Instantiates and loads child elements into a child element group property.

Version

1.0

Usage

$restaurantElement->loadChildElements();

Paramenters

Returns

The number of child elements loaded

Process

 

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:

 

$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:

 

 

 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

 

 Functions

 

__construct()

Usage:

$formDefinition[] = new nocl_form_field($elementType, $fieldType, $fieldName, $fieldLabel, $fieldValue, $recordId, [$helptext[, $placeholder[, $sourceValue]]]);

 

paramenters:

 

returns:

Silently after setting property values internally.  Actually, returns this class as an object.

 

process:

 

 

setValues()

Usage:

$formField->setValues($elementType, $fieldType, $fieldName, $fieldLabel, $fieldValue, $recordId, [$helptext[, $placeholder[, $sourceValue]]]);

 

Paramenters:

 

Returns:

True on successful completion

 

Process:

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 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.');
}

}