本文整理汇总了PHP中RSFormProHelper::getAllDirectoryFields方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::getAllDirectoryFields方法的具体用法?PHP RSFormProHelper::getAllDirectoryFields怎么用?PHP RSFormProHelper::getAllDirectoryFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::getAllDirectoryFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save($data)
{
$table = JTable::getInstance('RSForm_Directory', 'Table');
$input = JFactory::getApplication()->input;
$db = JFactory::getDbo();
if (isset($data['groups']) && is_array($data['groups'])) {
$registry = new JRegistry();
$registry->loadArray($data['groups']);
$data['groups'] = $registry->toString();
} else {
$data['groups'] = '';
}
// Check if the entry exists
$this->_db->setQuery('SELECT COUNT(' . $this->_db->qn('formId') . ') FROM ' . $this->_db->qn('#__rsform_directory') . ' WHERE ' . $this->_db->qn('formId') . ' = ' . (int) $data['formId'] . ' ');
if (!$this->_db->loadResult()) {
$this->_db->setQuery('INSERT INTO ' . $this->_db->qn('#__rsform_directory') . ' SET ' . $this->_db->qn('formId') . ' = ' . (int) $data['formId'] . ' ');
$this->_db->execute();
}
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
// Store directory fields
$fields = RSFormProHelper::getAllDirectoryFields($table->formId);
$listingFields = $input->get('dirviewable', array(), 'array');
$searchableFields = $input->get('dirsearchable', array(), 'array');
$editableFields = $input->get('direditable', array(), 'array');
$detailsFields = $input->get('dirindetails', array(), 'array');
$csvFields = $input->get('dirincsv', array(), 'array');
$cids = $input->get('dircid', array(), 'array');
$orderingFields = $input->get('dirorder', array(), 'array');
// empty
$db->setQuery('DELETE FROM ' . $db->qn('#__rsform_directory_fields') . ' WHERE ' . $db->qn('formId') . ' = ' . (int) $table->formId . '');
$db->execute();
foreach ($fields as $field) {
$viewable = (int) in_array($field->FieldId, $listingFields);
$searchable = (int) in_array($field->FieldId, $searchableFields);
$editable = (int) in_array($field->FieldId, $editableFields);
$indetails = (int) in_array($field->FieldId, $detailsFields);
$incsv = (int) in_array($field->FieldId, $csvFields);
$ordering = $orderingFields[array_search($field->FieldId, $cids)];
$values = array("`formId`='" . $table->formId . "'", "`componentId`='" . $field->FieldId . "'", "`viewable`='" . $viewable . "'", "`searchable`='" . $searchable . "'", "`editable`='" . $editable . "'", "`indetails`='" . $indetails . "'", "`incsv`='" . $incsv . "'", "`ordering`='" . $ordering . "'");
$db->setQuery("INSERT INTO #__rsform_directory_fields SET " . implode(", ", $values));
$db->execute();
}
return true;
}