本文整理汇总了PHP中RSFormProHelper::getDirectoryFormProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::getDirectoryFormProperties方法的具体用法?PHP RSFormProHelper::getDirectoryFormProperties怎么用?PHP RSFormProHelper::getDirectoryFormProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::getDirectoryFormProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
public function download()
{
$app = JFactory::getApplication();
$model = $this->getModel('directory');
$directory = $model->getDirectory();
if (!$directory->enablecsv) {
JError::raiseWarning(500, JText::_('RSFP_VIEW_DIRECTORY_NO_CSV'));
return $app->redirect(JURI::root());
}
if (!$model->isValid()) {
JError::raiseWarning(500, $model->getError());
return $app->redirect(JURI::root());
}
$db = JFactory::getDbo();
$params = $app->getParams('com_rsform');
$menu = $app->getMenu();
$active = $menu->getActive();
$formId = $params->get('formId');
$cids = JRequest::getVar('cid');
JArrayHelper::toInteger($cids);
$fields = RSFormProHelper::getDirectoryFields($formId);
$headers = RSFormProHelper::getDirectoryStaticHeaders();
$downloadableFields = array();
$downloadableFieldCaptions = array();
foreach ($fields as $field) {
if ($field->incsv) {
$downloadableFields[] = (object) array('name' => $field->FieldName, 'static' => $field->componentId < 0 && isset($headers[$field->componentId]) ? 1 : 0);
$downloadableFieldCaptions[] = $field->FieldCaption;
}
}
list($multipleSeparator, $uploadFields, $multipleFields, $secret) = RSFormProHelper::getDirectoryFormProperties($formId);
// Get submissions
$db->setQuery("SELECT * FROM #__rsform_submissions WHERE FormId='" . (int) $formId . "' AND SubmissionId IN (" . implode(',', $cids) . ")");
$submissions = $db->loadObjectList('SubmissionId');
// Get values
$names = array();
foreach ($downloadableFields as $field) {
if (!$field->static) {
$names[] = $db->q($field->name);
}
}
$query = $db->getQuery(true);
$query->select($db->qn('SubmissionId'))->select($db->qn('FieldName'))->select($db->qn('FieldValue'))->from($db->qn('#__rsform_submission_values'))->where($db->qn('FormId') . '=' . $db->q($formId));
if ($cids) {
$query->where($db->qn('SubmissionId') . ' IN (' . implode(',', $cids) . ')');
}
if ($names) {
$query->where($db->qn('FieldName') . ' IN (' . implode(',', $names) . ')');
}
$db->setQuery($query);
$values = $db->loadObjectList();
// Combine them
foreach ($values as $item) {
if (!isset($submissions[$item->SubmissionId]->values)) {
$submissions[$item->SubmissionId]->values = array();
}
// process here
if (in_array($item->FieldName, $uploadFields)) {
$item->FieldValue = '<a href="' . JURI::root() . 'index.php?option=com_rsform&task=submissions.view.file&hash=' . md5($item->SubmissionId . $secret . $item->FieldName) . '">' . basename($item->FieldValue) . '</a>';
} elseif (in_array($item->FieldName, $multipleFields)) {
$item->FieldValue = str_replace("\n", $multipleSeparator, $item->FieldValue);
}
$submissions[$item->SubmissionId]->values[$item->FieldName] = $item->FieldValue;
}
$enclosure = '"';
$delimiter = ',';
$download_name = $active->alias . '.csv';
header('Cache-Control: public, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
if (!preg_match('#MSIE#', $_SERVER['HTTP_USER_AGENT'])) {
header("Pragma: no-cache");
}
header("Expires: 0");
header("Content-Description: File Transfer");
header("Expires: Sat, 01 Jan 2000 01:00:00 GMT");
if (preg_match('#Opera#', $_SERVER['HTTP_USER_AGENT'])) {
header("Content-Type: application/octetstream");
} else {
header("Content-Type: application/octet-stream");
}
header('Content-Disposition: attachment; filename="' . $download_name . '"');
header("Content-Transfer-Encoding: binary\n");
ob_end_clean();
echo $enclosure . implode($enclosure . $delimiter . $enclosure, $downloadableFieldCaptions) . $enclosure . "\n";
foreach ($cids as $cid) {
$row = array();
foreach ($downloadableFields as $field) {
$value = '';
if (!$field->static && isset($submissions[$cid]->values[$field->name])) {
$value = $submissions[$cid]->values[$field->name];
} elseif ($field->static && isset($submissions[$cid]->{$field->name})) {
// Show a text for the "confirmed" column.
if ($field->name == 'confirmed') {
$value = $submissions[$cid]->{$field->name} ? JText::_('RSFP_YES') : JText::_('RSFP_NO');
} else {
$value = $submissions[$cid]->{$field->name};
}
}
$row[] = $value;
}
//.........这里部分代码省略.........
示例2: getItems
/**
* Get Submissions
*/
public function getItems()
{
if ($query = $this->getListQuery()) {
$this->_db->setQuery($query, $this->getStart(), $this->getLimit());
$items = $this->_db->loadObjectList();
} else {
$items = array();
}
list($multipleSeparator, $uploadFields, $multipleFields, $secret) = RSFormProHelper::getDirectoryFormProperties($this->params->get('formId'));
$this->uploadFields = $uploadFields;
$this->multipleFields = $multipleFields;
if ($items) {
foreach ($items as $i => $item) {
foreach ($uploadFields as $field) {
if (isset($item->{$field})) {
$item->{$field} = '<a href="' . JRoute::_('index.php?option=com_rsform&task=submissions.view.file&hash=' . md5($item->SubmissionId . $secret . $field)) . '">' . htmlspecialchars(basename($item->{$field})) . '</a>';
}
}
foreach ($multipleFields as $field) {
if (isset($item->{$field})) {
$item->{$field} = str_replace("\n", $multipleSeparator, htmlentities($item->{$field}, ENT_COMPAT, 'utf-8'));
}
}
$items[$i] = $item;
}
}
return $items;
}