本文整理汇总了PHP中RSFormProHelper::copyComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::copyComponent方法的具体用法?PHP RSFormProHelper::copyComponent怎么用?PHP RSFormProHelper::copyComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::copyComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: componentsDuplicate
function componentsDuplicate()
{
$formId = JRequest::getInt('formId');
$cids = JRequest::getVar('cid');
JArrayHelper::toInteger($cids, array());
foreach ($cids as $cid) {
RSFormProHelper::copyComponent($cid, $formId);
}
$this->setRedirect('index.php?option=com_rsform&task=forms.edit&formId=' . $formId, JText::sprintf('RSFP_COMPONENTS_COPIED', count($cids)));
}
示例2: copy
function copy()
{
$db = JFactory::getDBO();
// Get the selected items
$cid = JRequest::getVar('cid', array(0), 'post', 'array');
// Force array elements to be integers
JArrayHelper::toInteger($cid, array(0));
$total = 0;
foreach ($cid as $formId) {
if (empty($formId)) {
continue;
}
$total++;
$original =& JTable::getInstance('RSForm_Forms', 'Table');
$original->load($formId);
$original->FormName .= ' copy';
$original->FormTitle .= ' copy';
$original->FormId = null;
$copy =& JTable::getInstance('RSForm_Forms', 'Table');
$copy->bind($original);
$copy->store();
$copy->FormLayout = str_replace('rsform_' . $formId . '_page', 'rsform_' . $copy->FormId . '_page', $copy->FormLayout);
if ($copy->FormLayout != $original->FormLayout) {
$copy->store();
}
$newFormId = $copy->FormId;
// copy language
$db->setQuery("SELECT * FROM #__rsform_translations WHERE `reference`='forms' AND `form_id`='" . $formId . "'");
$translations = $db->loadObjectList();
foreach ($translations as $translation) {
$db->setQuery("INSERT INTO #__rsform_translations SET `form_id`='" . $newFormId . "', `lang_code`='" . $db->getEscaped($translation->lang_code) . "', `reference`='forms', `reference_id`='" . $db->getEscaped($translation->reference_id) . "', `value`='" . $db->getEscaped($translation->value) . "'");
$db->query();
}
$componentRelations = array();
$conditionRelations = array();
$db->setQuery("SELECT ComponentId FROM #__rsform_components WHERE FormId='" . $formId . "' ORDER BY `Order`");
$components = $db->loadResultArray();
foreach ($components as $r) {
$componentRelations[$r] = RSFormProHelper::copyComponent($r, $newFormId);
}
// copy conditions
$db->setQuery("SELECT * FROM #__rsform_conditions WHERE form_id='" . $formId . "'");
if ($conditions = $db->loadObjectList()) {
foreach ($conditions as $condition) {
$new_condition =& JTable::getInstance('RSForm_Conditions', 'Table');
$new_condition->bind($condition);
$new_condition->id = null;
$new_condition->form_id = $newFormId;
$new_condition->component_id = $componentRelations[$condition->component_id];
$new_condition->store();
$conditionRelations[$condition->id] = $new_condition->id;
}
$db->setQuery("SELECT * FROM #__rsform_condition_details WHERE condition_id IN (" . implode(',', array_keys($conditionRelations)) . ")");
if ($details = $db->loadObjectList()) {
foreach ($details as $detail) {
$new_detail =& JTable::getInstance('RSForm_Condition_Details', 'Table');
$new_detail->bind($detail);
$new_detail->id = null;
$new_detail->condition_id = $conditionRelations[$detail->condition_id];
$new_detail->component_id = $componentRelations[$detail->component_id];
$new_detail->store();
}
}
}
// copy post to location
$db->setQuery("SELECT * FROM #__rsform_posts WHERE form_id='" . $formId . "'");
if ($post = $db->loadObject()) {
$db->setQuery("INSERT INTO #__rsform_posts SET `form_id`='" . (int) $newFormId . "', `enabled`='" . (int) $post->enabled . "', `method`='" . (int) $post->method . "', `silent`='" . (int) $post->silent . "', `url`=" . $db->quote($post->url));
$db->query();
}
}
$this->setRedirect('index.php?option=com_rsform&task=forms.manage', JText::sprintf('RSFP_FORMS_COPIED', $total));
}