本文整理汇总了PHP中RSFormProHelper::componentNameExists方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::componentNameExists方法的具体用法?PHP RSFormProHelper::componentNameExists怎么用?PHP RSFormProHelper::componentNameExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::componentNameExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateName
public function validateName()
{
$input = JFactory::getApplication()->input;
$componentName = trim(JRequest::getVar('componentName', ''));
if (preg_match('#([^a-zA-Z0-9_ ])#', $componentName) || empty($componentName) || $componentName == 'elements') {
echo '0|' . JText::_('RSFP_UNIQUE_NAME_MSG');
$this->close();
}
//on file upload component, check destination
$componentType = $input->getInt('componentType');
if ($componentType == 9) {
$destination = JRequest::getVar('destination');
$destination = RSFormProHelper::getRelativeUploadPath($destination);
if (empty($destination)) {
echo '2|' . JText::_('RSFP_ERROR_DESTINATION_MSG');
$this->close();
}
if (!is_dir($destination)) {
echo '2|' . JText::_('RSFP_ERROR_DESTINATION_MSG');
$this->close();
}
if (!is_writable($destination)) {
echo '2|' . JText::_('RSFP_ERROR_DESTINATION_WRITABLE_MSG');
$this->close();
}
}
$currentComponentId = $input->getInt('currentComponentId');
$componentId = $input->getInt('componentId');
$formId = $input->getInt('formId');
$exists = RSFormProHelper::componentNameExists($componentName, $formId, $currentComponentId);
if ($exists) {
echo '0|' . JText::_('RSFP_UNIQUE_NAME_MSG');
} else {
echo 'Ok';
}
$this->close();
}
示例2: componentsValidateName
/**
* Validates a component name
*/
function componentsValidateName()
{
$componentName = trim(JRequest::getVar('componentName', ''));
if (preg_match('#([^a-zA-Z0-9_ ])#', $componentName) || empty($componentName)) {
echo '0|' . JText::_('RSFP_UNIQUE_NAME_MSG');
exit;
}
//on file upload component, check destination
$componentType = JRequest::getInt('componentType');
if ($componentType == 9) {
$destination = JRequest::getVar('destination');
if (empty($destination)) {
echo '2|' . JText::_('RSFP_ERROR_DESTINATION_MSG');
exit;
}
if (!is_dir($destination)) {
echo '2|' . JText::_('RSFP_ERROR_DESTINATION_MSG');
exit;
}
if (!is_writable($destination)) {
echo '2|' . JText::_('RSFP_ERROR_DESTINATION_WRITABLE_MSG');
exit;
}
}
if ($componentType == 6) {
$mindate = JRequest::getVar('mindate');
$maxdate = JRequest::getVar('maxdate');
if ($mindate && $maxdate && @strtotime($mindate) > @strtotime($maxdate)) {
echo '2|' . JText::_('RSFP_CALENDAR_DATES_ERROR_MSG');
exit;
}
}
$currentComponentId = JRequest::getInt('currentComponentId');
$componentId = JRequest::getInt('componentId');
$formId = JRequest::getInt('formId');
$exists = RSFormProHelper::componentNameExists($componentName, $formId, $currentComponentId);
if ($exists) {
echo '0|' . JText::_('RSFP_UNIQUE_NAME_MSG');
} else {
echo 'Ok';
}
exit;
}
示例3: copyComponent
public static function copyComponent($sourceComponentId, $toFormId)
{
$sourceComponentId = (int) $sourceComponentId;
$toFormId = (int) $toFormId;
$db = JFactory::getDBO();
$db->setQuery("SELECT * FROM #__rsform_components WHERE ComponentId='" . $sourceComponentId . "'");
$component = $db->loadObject();
if (!$component) {
return false;
}
//get max ordering
$db->setQuery("SELECT MAX(`Order`)+1 FROM #__rsform_components WHERE FormId = '" . $toFormId . "'");
$component->Order = $db->loadResult();
$db->setQuery("INSERT INTO #__rsform_components SET `FormId`='" . $toFormId . "', `ComponentTypeId`='" . $component->ComponentTypeId . "', `Order`='" . $component->Order . "',`Published`='" . $component->Published . "'");
$db->execute();
$newComponentId = $db->insertid();
$db->setQuery("SELECT * FROM #__rsform_properties WHERE ComponentId='" . $sourceComponentId . "'");
$properties = $db->loadObjectList();
foreach ($properties as $property) {
if ($property->PropertyName == 'NAME' && $toFormId == $component->FormId) {
$property->PropertyValue .= ' copy';
while (RSFormProHelper::componentNameExists($property->PropertyValue, $toFormId)) {
$property->PropertyValue .= mt_rand(0, 9);
}
}
$db->setQuery("INSERT INTO #__rsform_properties SET ComponentId='" . $newComponentId . "', PropertyName='" . $db->escape($property->PropertyName) . "', PropertyValue='" . $db->escape($property->PropertyValue) . "'");
$db->execute();
}
// copy language
$db->setQuery("SELECT * FROM #__rsform_translations WHERE `reference`='properties' AND `reference_id` LIKE '" . $sourceComponentId . ".%'");
$translations = $db->loadObjectList();
foreach ($translations as $translation) {
$reference_id = $newComponentId . '.' . end(explode('.', $translation->reference_id, 2));
$db->setQuery("INSERT INTO #__rsform_translations SET `form_id`='" . $toFormId . "', `lang_code`='" . $db->escape($translation->lang_code) . "', `reference`='properties', `reference_id`='" . $db->escape($reference_id) . "', `value`='" . $db->escape($translation->value) . "'");
$db->execute();
}
return $newComponentId;
}