当前位置: 首页>>代码示例>>PHP>>正文


PHP RSFormProHelper::sortFields方法代码示例

本文整理汇总了PHP中RSFormProHelper::sortFields方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::sortFields方法的具体用法?PHP RSFormProHelper::sortFields怎么用?PHP RSFormProHelper::sortFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RSFormProHelper的用法示例。


在下文中一共展示了RSFormProHelper::sortFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getEditFields

 public static function getEditFields($cid)
 {
     $db = JFactory::getDbo();
     $return = array();
     $values = JFactory::getApplication()->input->get('form', array(), 'array');
     $pattern = '#\\[p(.*?)\\]#is';
     $db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . (int) $cid . "'");
     $submission = $db->loadObject();
     if (empty($submission)) {
         $mainframe = JFactory::getApplication();
         $mainframe->redirect(JURI::root());
         return $return;
     }
     $validation = !empty($values) ? RSFormProHelper::validateForm($submission->FormId, 'directory') : array();
     $formFields = RSFormProHelper::getDirectoryFields($submission->FormId);
     $editable = array();
     foreach ($formFields as $formField) {
         if ($formField->editable) {
             $editable[] = $formField->FieldName;
         }
     }
     $db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='" . (int) $cid . "'");
     $fields = $db->loadObjectList();
     foreach ($fields as $field) {
         $submission->values[$field->FieldName] = $field->FieldValue;
     }
     unset($fields);
     $db->setQuery("SELECT p.PropertyValue, ct.ComponentTypeName, c.ComponentId FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (p.ComponentId=c.ComponentId) LEFT JOIN #__rsform_component_types ct ON (c.ComponentTypeId=ct.ComponentTypeId) WHERE c.FormId='" . $submission->FormId . "' AND c.Published='1' AND p.PropertyName='NAME' ORDER BY `Order`");
     $fields = $db->loadObjectList();
     if (empty($fields)) {
         return $return;
     }
     $componentIds = array();
     foreach ($fields as $field) {
         $componentIds[] = $field->ComponentId;
     }
     $properties = RSFormProHelper::getComponentProperties($componentIds);
     $fields = RSFormProHelper::sortFields($fields, $editable);
     foreach ($fields as $field) {
         if (!in_array($field->PropertyValue, $editable)) {
             continue;
         }
         $invalid = !empty($validation) && in_array($field->ComponentId, $validation) ? ' rsform-error' : '';
         $data = $properties[$field->ComponentId];
         $new_field = array();
         $new_field[0] = !empty($data['CAPTION']) ? $data['CAPTION'] : $field->PropertyValue;
         $new_field[2] = isset($data['REQUIRED']) && $data['REQUIRED'] == 'YES' ? '<strong class="formRequired">(*)</strong>' : '';
         $new_field[3] = $field->PropertyValue;
         $name = $field->PropertyValue;
         if (isset($values[$field->PropertyValue])) {
             $value = $values[$field->PropertyValue];
         } else {
             $value = isset($submission->values[$field->PropertyValue]) ? $submission->values[$field->PropertyValue] : '';
         }
         if ($data['NAME'] == 'RSEProPayment') {
             $field->ComponentTypeName = 'rsepropayment';
         }
         switch ($field->ComponentTypeName) {
             // skip this field for now, no need to edit it
             case 'freeText':
                 continue 2;
                 break;
             default:
                 if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) {
                     $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
                 } else {
                     $new_field[1] = '<input class="rs_inp rs_80' . $invalid . '" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />';
                 }
                 break;
             case 'textArea':
                 if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
                     $new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10);
                 } else {
                     $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
                 }
                 break;
             case 'radioGroup':
             case 'checkboxGroup':
             case 'selectList':
                 if ($field->ComponentTypeName == 'radioGroup') {
                     $data['SIZE'] = 0;
                     $data['MULTIPLE'] = 'NO';
                 } elseif ($field->ComponentTypeName == 'checkboxGroup') {
                     $data['SIZE'] = 5;
                     $data['MULTIPLE'] = 'YES';
                 }
                 $value = !empty($values) ? $value : RSFormProHelper::explode($value);
                 $items = RSFormProHelper::isCode($data['ITEMS']);
                 $items = RSFormProHelper::explode($items);
                 $options = array();
                 foreach ($items as $item) {
                     if (preg_match($pattern, $item, $match)) {
                         $item = preg_replace($pattern, '', $item);
                     }
                     // <OPTGROUP>
                     if (preg_match('/\\[g\\]/', $item)) {
                         $item = str_replace('[g]', '', $item);
                         $optgroup = new stdClass();
                         $optgroup->value = '<OPTGROUP>';
                         $optgroup->text = $item;
//.........这里部分代码省略.........
开发者ID:renekreijveld,项目名称:rsformpro-bootstrapped,代码行数:101,代码来源:rsform.php


注:本文中的RSFormProHelper::sortFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。