本文整理汇总了PHP中RSMembershipHelper::isCode方法的典型用法代码示例。如果您正苦于以下问题:PHP RSMembershipHelper::isCode方法的具体用法?PHP RSMembershipHelper::isCode怎么用?PHP RSMembershipHelper::isCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSMembershipHelper
的用法示例。
在下文中一共展示了RSMembershipHelper::isCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldsValidation
public static function getFieldsValidation($membership_id = null, $upgrade = null)
{
$return = array();
if (is_null($upgrade)) {
$fields = RSMembership::getCustomFields(array('published' => 1, 'required' => 1));
} else {
$fields = array();
}
if (!is_null($membership_id)) {
$membership_fields = RSMembership::getCustomMembershipFields($membership_id, array('published' => 1, 'required' => 1));
$fields = array_merge($fields, $membership_fields);
}
foreach ($fields as $field) {
$js = '';
switch ($field->type) {
case 'select':
case 'multipleselect':
case 'textarea':
case 'textbox':
case 'calendar':
$element = 'rsm_' . $field->name;
$js .= "if (document.getElementById('" . $element . "').value.length == 0)" . "\n";
break;
case 'checkbox':
case 'radio':
$field->values = RSMembershipHelper::isCode($field->values);
$field->values = str_replace("\r\n", "\n", $field->values);
$field->values = explode("\n", $field->values);
$ids = array();
foreach ($field->values as $i => $value) {
$element = 'rsm_field_' . $field->id . '_' . $i;
$ids[] = "!document.getElementById('" . $element . "').checked";
}
$element = '';
$js .= "if (" . implode(" && ", $ids) . ")" . "\n";
break;
}
$validation_message = JText::_($field->validation);
if (empty($validation_message)) {
$validation_message = JText::sprintf('COM_RSMEMBERSHIP_VALIDATION_DEFAULT_ERROR', JText::_($field->label));
}
$validation_message = str_replace(array("\r\n", "\r"), "\n", $validation_message);
$validation_message = str_replace("\n", '\\n', $validation_message);
$js .= "{\n";
$js .= "msg.push('" . JText::_($validation_message, true) . "');" . "\n";
if (@$element) {
$js .= "document.getElementById('" . $element . "').className += ' rsm_field_error';\n";
}
$js .= "}\n";
$return[] = $js;
}
return $return;
}
示例2: getFieldsValidation
function getFieldsValidation()
{
$return = array();
$db = JFactory::getDBO();
$db->setQuery("SELECT * FROM #__rsmembership_fields WHERE published='1' AND required = '1' ORDER BY ordering");
$fields = $db->loadObjectList();
foreach ($fields as $field) {
$js = '';
switch ($field->type) {
case 'select':
case 'multipleselect':
case 'textarea':
case 'textbox':
case 'calendar':
$element = 'rsm_' . $field->name;
$js .= "if (document.getElementById('" . $element . "').value.length == 0)" . "\n";
break;
case 'checkbox':
case 'radio':
$field->values = RSMembershipHelper::isCode($field->values);
$field->values = str_replace("\r\n", "\n", $field->values);
$field->values = explode("\n", $field->values);
$ids = array();
foreach ($field->values as $i => $value) {
$element = 'rsm_field_' . $field->id . '_' . $i;
$ids[] = "!document.getElementById('" . $element . "').checked";
}
$element = '';
$js .= "if (" . implode(" && ", $ids) . ")" . "\n";
break;
}
$validation_message = JText::_($field->validation);
if (empty($validation_message)) {
$validation_message = JText::sprintf('RSM_VALIDATION_DEFAULT_ERROR', JText::_($field->label));
}
$validation_message = str_replace(array("\r\n", "\r"), "\n", $validation_message);
$validation_message = str_replace("\n", '\\n', $validation_message);
$js .= "{\n";
$js .= "msg.push('" . JText::_($validation_message, true) . "');" . "\n";
if (@$element) {
$js .= "document.getElementById('" . $element . "').className += ' rsm_field_error';\n";
}
$js .= "}\n";
$return[] = $js;
}
return $return;
}