static function DisplayFieldsHtml(&$row, $fieldlist, $style = 'table') { if (!count($fieldlist)) { return null; } $page = $fieldlist[0]->page; $cfg = CustomFieldsFactory::getConfig(); $category_filter = array(); if ($cfg['has_category'][$page]) { $db = JFactory::getDBO(); $db->setQuery("SELECT fid FROM #__" . APP_PREFIX . "_fields_categories WHERE cid = '" . $row->cat . "'"); $category_filter = $db->loadResultArray(); } $flist = array(); $field_object = JTable::getInstance('FieldsTable', 'JTheFactory'); foreach ($fieldlist as $field) { if ($field->categoryfilter && !in_array($field->id, $category_filter)) { continue; } $field_type = CustomFieldsFactory::getFieldType($field->ftype); $field_object->bind($field); $f = new stdClass(); $f->field = clone $field; $f->value = $row->{$field->db_name}; $f->html = $field_type->getFieldHTML($field_object, $row->{$field->db_name}); $flist[] = $f; } $func = 'DisplayFieldsHtml_' . ucfirst($style); $html = self::$func($flist); return $html; }
function getSQLFilter($field, $filter, $tableAlias = null) { $cfg = CustomFieldsFactory::getConfig(); $db = JFactory::getDBO(); if ($tableAlias) { $table_alias = $tableAlias . "."; } else { $table_alias = isset($cfg['aliases'][$field->own_table]) ? $cfg['aliases'][$field->own_table] . "." : ""; } $sql = " " . $table_alias . $field->db_name . "=" . $db->quote($filter); return $sql; }
function getSQLFilter($field, $filter, $tableAlias) { $cfg = CustomFieldsFactory::getConfig(); $db = JFactory::getDBO(); $filter = (array) $filter; if ($tableAlias) { $table_alias = $tableAlias . "."; } else { $table_alias = isset($cfg['aliases'][$field->own_table]) ? $cfg['aliases'][$field->own_table] . "." : ""; } $sql = array(); foreach ($filter as $v) { $sql[] = "(" . $table_alias . $field->db_name . " = " . $db->quote($v) . ")"; } $ret = implode(' OR ', $sql); return $ret ? "({$ret})" : $ret; }
function createHTMLObjectsForField($field) { $lists = new JObject(); $cfg = CustomFieldsFactory::getConfig(); $lists->curent_type = null; $lists->field_options = array(); $lists->field_types = CustomFieldsFactory::getFieldTypesList(); $opts = array(); foreach ($lists->field_types as $typename) { $item = CustomFieldsFactory::getFieldType($typename); $opts[] = JHTML::_('select.option', $item->class_name, $item->type_name); } $lists->field_types_html = JHTML::_('select.genericlist', $opts, 'ftype', 'class="inputbox"', "value", "text", $field->ftype); $lists->field_pages_categories = $cfg['has_category']; $validators = CustomFieldsFactory::getValidatorsList(); $opts = array(JHTML::_('select.option', "", JText::_("FACTORY_NONE"))); foreach ($validators as $validator) { $validatorObj = CustomFieldsFactory::getFieldValidator($validator); $opts[] = JHTML::_('select.option', $validatorObj->classname, JText::_($validatorObj->name)); } $lists->validate_type = JHTML::_('select.genericlist', $opts, 'validate_type', 'class="inputbox"', "value", "text", $field->validate_type); if ($field->ftype) { $lists->curent_type = CustomFieldsFactory::getFieldType($field->ftype); if ($lists->curent_type->has_options) { $lists->field_options = $field->getOptions(); } $lists->curent_type_params = $lists->curent_type->get('_params'); } if ($field->id) { //cannot change page for an existing field $lists->field_pages = $cfg['pages'][$field->page]; } else { $opts = array(); foreach ($cfg['pages'] as $k => $v) { $opts[] = JHTML::_('select.option', $k, $v); } $lists->field_pages = JHTML::_('select.genericlist', $opts, 'page', 'class="inputbox"', "value", "text", $field->page); } $lists->compulsory = JHTML::_("select.booleanlist", 'compulsory', " infoyes='" . JText::_('FACTORY_COMPULSORY_FIELD') . "' infono='" . JText::_('FACTORY_OPTIONAL_FIELD') . "'", $field->compulsory); $lists->search = JHTML::_("select.booleanlist", 'search', '', $field->search); $lists->status = JHTML::_("select.booleanlist", 'status', '', $field->status); return $lists; }
function getValues($section, $owner_id) { $cfg = CustomFieldsFactory::getConfig(); $db = $this->getDbo(); $db->setQuery("SELECT * FROM " . $cfg['tables'][$section] . " WHERE " . $cfg['pk'][$section] . " = '{$owner_id}' "); $ret = $db->loadObjectList(); return count($ret) ? $ret[0] : null; }
function ListFields() { /* * @var $model JTheFactoryModelFields; * */ $model = JModel::getInstance('Fields', 'JTheFactoryModel'); $filter_page = JRequest::getWord('filter_page'); $cfg = CustomFieldsFactory::getConfig(); $filters = array(); $opts[] = JHtml::_('select.option', '', JText::_("FACTORY_ALL")); foreach ($cfg['pages'] as $page => $text) { $opts[] = JHtml::_('select.option', $page, $text); } $filters['page'] = JHtml::_('select.genericlist', $opts, 'filter_page', "onchange=this.form.submit()", 'value', 'text', $filter_page); $rows = $model->getFields(false, $filter_page); $pagination = $model->getPagination(); $view = $this->getView('list'); $view->assign('filter_html', $filters); $view->assignRef('rows', $rows); $view->assignRef('pagination', $pagination); $view->display(); }