Print

nocl_orderlicious_object

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:

 

 

 

 

 

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)
);

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

}