コード例 #1
0
ファイル: config.php プロジェクト: vstorm83/propertease
 function check($view)
 {
     $ret = true;
     switch ($view) {
         case 'config_confirm':
             if ($this->_data->config_data->confirm_link == '' and $this->_data->config_data->confirm_text == '') {
                 $msg = JText::_('COM_FLEXICONTACT_ALL_BLANK');
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             break;
             // case 'config_confirm'
         // case 'config_confirm'
         case 'config_text':
             if (stristr($this->_data->config_data->top_text, "{flexicontactplus") != false) {
                 $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' - {flexicontactplus...}';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if (stristr($this->_data->config_data->bottom_text, "{flexicontactplus") != false) {
                 $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' - {flexicontactplus...}';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             break;
             // case 'config_text'
             if ($this->_data->config_data->confirm_link == '' and $this->_data->config_data->confirm_text == '') {
                 $msg = JText::_('COM_FLEXICONTACT_ALL_BLANK');
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             break;
             // case 'config_text'
         // case 'config_text'
         case 'config_edit':
             FCP_Common::strip_quotes($this->_data->name);
             if (!FCP_Common::clean_string($this->_data->name, false)) {
                 $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_CONFIG_NAME') . ')';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if (strstr($this->_data->name, ' ') != false) {
                 $msg = JText::_('COM_FLEXICONTACT_NO_SPACE') . ' (' . JText::_('COM_FLEXICONTACT_CONFIG_NAME') . ')';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if ($this->_exists($this->_data->name, $this->_data->language, $this->_data->id)) {
                 $msg = JText::_('COM_FLEXICONTACT_CONFIG_DUP');
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             break;
             // case 'config_edit'
         // case 'config_edit'
         case 'config_general':
             $msg = JText::_('COM_FLEXICONTACT_INVALID');
             if (!FCP_Common::clean_string($this->_data->config_data->send_text)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_SEND_TEXT') . ')';
                 $ret = false;
             }
             if (!FCP_Common::clean_string($this->_data->config_data->email_from)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_FIELD_FROM_ADDRESS') . ')';
                 $ret = false;
             } else {
                 $check_msg = FCP_Admin::validate_email_address($this->_data->config_data->email_from, true);
                 if ($check_msg != '') {
                     $msg .= ' (' . JText::_('COM_FLEXICONTACT_FIELD_FROM_ADDRESS') . ' ' . $check_msg . ')';
                     $ret = false;
                 }
             }
             if (!FCP_Common::clean_string($this->_data->config_data->email_to)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_TO') . ')';
                 $ret = false;
             } else {
                 $check_msg = FCP_Admin::validate_email_address($this->_data->config_data->email_to, false);
                 if ($check_msg != '') {
                     $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_TO') . ' ' . $check_msg . ')';
                     $ret = false;
                 }
             }
             if (!FCP_Common::clean_string($this->_data->config_data->email_cc)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_CC') . ')';
                 $ret = false;
             } else {
                 $check_msg = FCP_Admin::validate_email_list($this->_data->config_data->email_cc);
                 if ($check_msg != '') {
                     $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_CC') . ' ' . $check_msg . ')';
                     $ret = false;
                 }
             }
             if (!FCP_Common::clean_string($this->_data->config_data->email_bcc)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_BCC') . ')';
                 $ret = false;
             } else {
                 $check_msg = FCP_Admin::validate_email_list($this->_data->config_data->email_bcc);
                 if ($check_msg != '') {
                     $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_BCC') . ' ' . $check_msg . ')';
                     $ret = false;
                 }
             }
             if (!FCP_Common::clean_string($this->_data->config_data->email_from_name)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_FIELD_FROM_NAME') . ')';
                 $ret = false;
             }
             if (!FCP_Common::clean_string($this->_data->config_data->agreement_prompt)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_AGREEMENT_REQUIRED') . ' ' . JText::_('COM_FLEXICONTACT_V_PROMPT') . ')';
                 $ret = false;
             }
             if (!FCP_Common::clean_string($this->_data->config_data->agreement_name)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_AGREEMENT_REQUIRED') . ' ' . JText::_('COM_FLEXICONTACT_NAME') . ')';
                 $ret = false;
             }
             if (!FCP_Common::clean_string($this->_data->config_data->white_list)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_ATTACHMENT_WHITE_LIST') . ' (' . $this->_data->config_data->white_list . ')';
                 $ret = false;
             }
             if (!FCP_Common::is_posint($this->_data->config_data->max_file_size) or $this->_data->config_data->max_file_size == 0) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_ATTACHMENT_MAX_SIZE') . ' (' . $this->_data->config_data->max_file_size . ')';
                 $ret = false;
             }
             $max_size = FCP_Admin::get_max_file_size();
             if ($max_size > LAFC_MAX_FILE_SIZE) {
                 // Maximum file size must be the lesser of our constant or PHP INI setting
                 $max_size = LAFC_MAX_FILE_SIZE;
             }
             if ($this->_data->config_data->max_file_size > $max_size) {
                 $msg .= ' (' . JText::sprintf('COM_FLEXICONTACT_MAX_SIZE_EXCEEDED', $max_size) . ' (' . $this->_data->config_data->max_file_size . ')';
                 $ret = false;
             }
             if (!$ret) {
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             break;
             // case 'config_general'
         // case 'config_general'
         case 'config_captcha':
             $ret = true;
             $check_string = JText::_('COM_FLEXICONTACT_INVALID');
             $msg = $check_string;
             if (!FCP_Common::clean_string($this->_data->config_data->magic_word)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_MAGIC_WORD') . ')';
                 $ret = false;
             }
             if (!FCP_Common::clean_string($this->_data->config_data->magic_word_prompt)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_MAGIC_WORD_LABEL') . ')';
                 $ret = false;
             }
             if ($this->_data->config_data->magic_word != '' and $this->_data->config_data->magic_word_prompt == '') {
                 $this->_app->enqueueMessage(JText::_('COM_FLEXICONTACT_REQUIRED') . ' (' . JText::_('COM_FLEXICONTACT_MAGIC_WORD_LABEL') . ')', 'error');
                 $ret = false;
             }
             if (!FCP_Common::is_posint($this->_data->config_data->num_images)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_CAPTCHA_NUMBER') . ')';
                 $ret = false;
             }
             if (!FCP_Common::is_posint($this->_data->config_data->image_height, true)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_HEIGHT') . ')';
                 $ret = false;
             } elseif ($this->_data->config_data->image_height > 150) {
                 $this->_data->config_data->image_height = 150;
             }
             if (!FCP_Common::is_posint($this->_data->config_data->image_width, true)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_WIDTH') . ')';
                 $ret = false;
             } elseif ($this->_data->config_data->image_width > 150) {
                 $this->_data->config_data->image_width = 150;
             }
             if (!FCP_Common::is_posint($this->_data->config_data->captcha_height, true)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_SECURE_CAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_V_HEIGHT') . ')';
                 $ret = false;
             }
             if (!FCP_Common::is_posint($this->_data->config_data->captcha_width, true)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_SECURE_CAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_V_WIDTH') . ')';
                 $ret = false;
             }
             if (!FCP_Common::clean_string($this->_data->config_data->secure_captcha_prompt)) {
                 $msg .= ' (' . JText::_('COM_FLEXICONTACT_SECURE_CAPTCHA_LABEL') . ')';
                 $ret = false;
             }
             if ($this->_data->config_data->recaptcha_theme != 0) {
                 if (strlen($this->_data->config_data->recaptcha_public_key) != 40) {
                     $msg .= ' (' . JText::_('COM_FLEXICONTACT_RECAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_RECAPTCHA_PUBLIC_KEY') . ')';
                     $ret = false;
                 }
                 if (strlen($this->_data->config_data->recaptcha_private_key) != 40) {
                     $msg .= ' (' . JText::_('COM_FLEXICONTACT_RECAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_RECAPTCHA_PRIVATE_KEY') . ')';
                     $ret = false;
                 }
             }
             if (!$ret) {
                 if ($msg != $check_string) {
                     $this->_app->enqueueMessage($msg, 'error');
                 }
                 return false;
             }
             break;
             // case 'config_captcha'
         // case 'config_captcha'
         case 'config_field':
             $field =& $this->_data->config_data->all_fields[$this->_data->field_index];
             if ($field->field_type == LAFC_FIELD_CHECKBOX_H) {
                 $msg = JText::sprintf('COM_FLEXICONTACT_FIELD_TYPE_DEPRECATED', JText::_('COM_FLEXICONTACT_FIELD_CHECKBOX_M'));
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if ($field->field_type == LAFC_FIELD_NONE) {
                 $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_FIELD_TYPE') . ')';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if (!FCP_Common::clean_string($field->prompt)) {
                 $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_V_PROMPT') . ')';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if (strlen($field->prompt) > LAFC_MAX_PROMPT_LENGTH) {
                 $msg = JText::_('COM_FLEXICONTACT_MAX_LENGTH') . ' (' . JText::_('COM_FLEXICONTACT_V_PROMPT') . ')';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             if (!FCP_Common::clean_string($field->css_class)) {
                 $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_CSS_CLASS') . ')';
                 $this->_app->enqueueMessage($msg, 'error');
                 return false;
             }
             // Default value does not need to be verified at all since this allows for default to be a POST data variable
             // If the subject contains a variable, then the subject MUST be invisible.
             if ($field->field_type == LAFC_FIELD_SUBJECT) {
                 $num_vars = substr_count(strtoupper($field->default_value), "%V_");
                 $ret_title = true;
                 // Visible?
                 if ($num_vars > 0 and $field->visible == 1) {
                     $ret_title = false;
                 }
                 if (!$ret_title) {
                     $msg = JText::_('COM_FLEXICONTACT_PAGE_TITLE_ERROR');
                     $this->_app->enqueueMessage($msg, 'error');
                     return false;
                 }
             }
             if ($field->field_type == LAFC_FIELD_SUBJECT or $field->field_type == LAFC_FIELD_FROM_NAME or $field->field_type == LAFC_FIELD_FROM_ADDRESS or $field->field_type == LAFC_FIELD_RECIPIENT) {
                 $count = 0;
                 foreach ($this->_data->config_data->all_fields as $one_field) {
                     if ($one_field->field_type == $field->field_type) {
                         $count++;
                     }
                 }
                 if ($count > 1) {
                     switch ($field->field_type) {
                         case LAFC_FIELD_SUBJECT:
                             $fieldname = JText::_('COM_FLEXICONTACT_FIELD_SUBJECT');
                             break;
                         case LAFC_FIELD_FROM_NAME:
                             $fieldname = JText::_('COM_FLEXICONTACT_FIELD_FROM_NAME');
                             break;
                         case LAFC_FIELD_FROM_ADDRESS:
                             $fieldname = JText::_('COM_FLEXICONTACT_FIELD_FROM_ADDRESS');
                             break;
                         case LAFC_FIELD_RECIPIENT:
                             $fieldname = JText::_('COM_FLEXICONTACT_FIELD_RECIPIENT');
                             break;
                         default:
                             $fieldname = '';
                     }
                     $msg = JText::sprintf('COM_FLEXICONTACT_ONLY_ONE_FIELD', $fieldname);
                     $this->_app->enqueueMessage($msg, 'error');
                     return false;
                 }
             }
             if ($field->field_type == LAFC_FIELD_LIST) {
                 if ($field->delimiter == '') {
                     $field->delimiter = ',';
                 }
                 return true;
             }
             if ($field->field_type == LAFC_FIELD_RECIPIENT) {
                 $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
                 foreach ($list_array['RAW'] as $raw_string) {
                     if (substr_count($raw_string, ',') != 1) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ': ' . htmlentities($raw_string);
                         $this->_app->enqueueMessage($msg, 'error');
                         return false;
                         // must return here to avoid "Undefined offset" errors
                     }
                 }
                 foreach ($list_array['LEFT'] as $recipient_name) {
                     if (!FCP_Common::clean_string($recipient_name, false)) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_NAME') . ': ' . $recipient_name;
                         $this->_app->enqueueMessage($msg, 'error');
                         $ret = false;
                     }
                 }
                 foreach ($list_array['RIGHT'] as $email_address) {
                     $check_msg = FCP_Admin::validate_email_address($email_address, false);
                     if ($check_msg != '') {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_EMAIL') . ': ' . htmlentities($email_address);
                         $this->_app->enqueueMessage($msg, 'error');
                         $ret = false;
                     }
                 }
                 if (!$ret) {
                     return false;
                 }
             }
             if ($field->field_type == LAFC_FIELD_RADIO_V or $field->field_type == LAFC_FIELD_RADIO_H) {
                 if ($field->delimiter == '') {
                     $field->delimiter = ',';
                 }
                 $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
                 foreach ($list_array['RAW'] as $raw_string) {
                     if (substr_count($raw_string, $field->delimiter) > 1) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ': ' . htmlentities($raw_string);
                         $this->_app->enqueueMessage($msg, 'error');
                         return false;
                         // must return here to avoid "Undefined offset" errors
                     }
                 }
                 foreach ($list_array['RIGHT'] as $description) {
                     if (!FCP_Common::clean_string($description)) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_TEXT') . ': ' . htmlentities($description);
                         $this->_app->enqueueMessage($msg, 'error');
                         $ret = false;
                     }
                 }
                 $num_buttons = count($list_array['LEFT']);
                 if (!FCP_Common::is_posint($field->default_button) or $field->default_button > $num_buttons) {
                     $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_DEFAULT_BUTTON') . ' (' . $field->default_button . ')';
                     $this->_app->enqueueMessage($msg, 'error');
                     $ret = false;
                 }
                 if (!$ret) {
                     return false;
                 }
             }
             if ($field->field_type == LAFC_FIELD_CHECKBOX_M) {
                 if ($field->delimiter == '') {
                     $field->delimiter = ',';
                 }
             }
             if ($field->field_type == LAFC_FIELD_ADVANCED) {
                 if (!empty($field->regex)) {
                     if (@preg_match($field->regex, 'x') === false) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_REGEX');
                         $this->_app->enqueueMessage($msg, 'error');
                         return false;
                     }
                 }
                 if (!empty($field->sql)) {
                     $result = $this->ladb_loadResult($field->sql);
                     if ($result === false) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_SQL_QUERY') . '<br />' . $this->ladb_error_text;
                         $this->_app->enqueueMessage($msg, 'error');
                         return false;
                     }
                     if (!is_numeric($result)) {
                         $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_SQL_QUERY') . '<br />' . JText::_('COM_FLEXICONTACT_SQL_NUMERIC');
                         $this->_app->enqueueMessage($msg, 'error');
                         return false;
                     }
                 }
             }
             // Visible property ONLY applies to the Subject field
             if ($field->field_type != LAFC_FIELD_SUBJECT) {
                 $field->visible = 1;
             }
             if ($field->height < LAFC_FIELD_HEIGHT_MIN) {
                 $field->height = LAFC_FIELD_HEIGHT_MIN;
             }
             if ($field->height > LAFC_FIELD_HEIGHT_MAX) {
                 $field->height = LAFC_FIELD_HEIGHT_MAX;
             }
             // don't allow the tooltip field to include double quotes - change them to single quotes
             $field->tooltip = str_replace('"', "'", $field->tooltip);
             // don't allow the default_value field to include double quotes - change them to single quotes
             $field->default_value = str_replace('"', "'", $field->default_value);
             break;
             //case 'config_field'
     }
     return true;
 }
コード例 #2
0
ファイル: email.php プロジェクト: vstorm83/propertease
 function get_field_value($config_data, $field_index)
 {
     $field_id = sprintf('field%03d', $field_index);
     // form the post data field name
     if (!isset($config_data->all_fields[$field_index])) {
         return '';
     }
     $field = $config_data->all_fields[$field_index];
     // point to the field configuration
     $yes_text = JText::_('JYES');
     $no_text = JText::_('JNO');
     switch ($field->field_type) {
         case LAFC_FIELD_CHECKBOX_L:
         case LAFC_FIELD_CHECKBOX_R:
         case LAFC_FIELD_CHECKBOX_H:
             // CHECKBOX_M has already been built by init_data()
             if (isset($this->data->{$field_id})) {
                 return $yes_text;
             } else {
                 return $no_text;
             }
             break;
         case LAFC_FIELD_LIST:
             $list_index = $this->data->{$field_id};
             // get the selection from the input data
             if (!FCP_Common::is_posint($list_index, false)) {
                 // should be an integer
                 break;
             }
             $list_array = FCP_Common::split_list($field->list_list, $field->delimiter);
             return $list_array['LEFT'][$list_index];
             // only one string for list boxes
             break;
         case LAFC_FIELD_RADIO_V:
         case LAFC_FIELD_RADIO_H:
             $list_index = $this->data->{$field_id};
             // get the selection from the input data
             if (!FCP_Common::is_posint($list_index, false)) {
                 return '';
             }
             $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
             return $list_array['RIGHT'][$list_index];
             // return the right hand string
             break;
         case LAFC_FIELD_RECIPIENT:
             return $this->data->recipient_name;
             break;
         case LAFC_FIELD_TEXTAREA:
             return nl2br(htmlspecialchars($this->data->{$field_id}));
         case LAFC_FIELD_ATTACHMENT:
             $pathname = str_replace('\\', '/', $this->data->{$field_id});
             // otherwise basename does not remove C:\fakepath\ in Unix
             return basename($pathname);
         default:
             return $this->data->{$field_id};
     }
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: vstorm83/propertease
 static function draw_field($field, $data, $config_data)
 {
     $html = '';
     $div_id = $field->div_id;
     $field_id = $field->id;
     $error_id = $field->error_id;
     if (!$field->visible) {
         $html = '';
         return $html;
     }
     // Tooltip or Info button?
     $title = '';
     $field_class = '';
     $info_button = '';
     if ($field->tooltip_type == TOOLTIP_TIP) {
         if (!empty($field->tooltip)) {
             $title = ' title="' . self::tooltipText($field->tooltip) . '" ';
             $field_class = ' class="hasTooltip"';
         }
     } else {
         if (!empty($field->tooltip)) {
             $info_button = ' ' . self::make_info($field->tooltip);
         }
     }
     // Placeholder
     if (empty($field->placeholder)) {
         $placeholder = '';
     } else {
         $placeholder = ' placeholder="' . $field->placeholder . '"';
     }
     switch ($field->field_type) {
         case LAFC_FIELD_FROM_ADDRESS:
         case LAFC_FIELD_FROM_NAME:
         case LAFC_FIELD_SUBJECT:
         case LAFC_FIELD_TEXT:
         case LAFC_FIELD_ADVANCED:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_text" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $size = self::size($field->width);
             $html .= "\n" . '<input type="text" ' . $field_class . $size . ' name="' . $field_id . '" id="' . $field_id . '"' . $placeholder . ' value="' . $data->{$field_id} . '"' . $title . ' />';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_TEXT_NUMERIC:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_text fcp_numeric" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $size = self::size($field->width);
             $html .= "\n" . '<input type="text" ' . $field_class . $size . ' name="' . $field_id . '" id="' . $field_id . '"' . $placeholder . ' value="' . $data->{$field_id} . '" onkeypress="return numbersOnly(event)"' . $title . ' />';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_TEXTAREA:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_textarea" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $size = self::size($field->width, 'cols');
             $html .= "\n" . '<textarea name="' . $field_id . '"' . ' id="' . $field_id . '" ' . $field_class . $title . $placeholder . ' rows="' . $field->height . '"' . $size . '>' . $data->{$field_id} . '</textarea>';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_LIST:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_list" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $list_array = FCP_Common::split_list($field->list_list, $field->delimiter);
             $list_html = FCP_Common::make_list($field_id, $data->{$field_id}, $list_array['LEFT'], 0, $field_class . $title);
             $html .= "\n" . $list_html;
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_RECIPIENT:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_list" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
             $list_html = FCP_Common::make_list($field_id, $data->{$field_id}, $list_array['LEFT'], 0, $field_class . $title);
             $html .= "\n" . $list_html;
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_CHECKBOX_L:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_checkbox fcp_checkbox_l" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             if ($data->{$field_id}) {
                 $checked = 'checked = "checked"';
             } else {
                 $checked = '';
             }
             $checkbox = '<input type="checkbox" class="fcp_lcb"' . $title . ' name="' . $field_id . '" id="' . $field_id . '" value="1" ' . $checked . '/>';
             $html .= "\n" . $checkbox;
             $html .= self::draw_label($field, 'fcp_lcb', $title);
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_CHECKBOX_R:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_checkbox fcp_checkbox_r" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field, '', $title);
             if ($data->{$field_id}) {
                 $checked = 'checked = "checked"';
             } else {
                 $checked = '';
             }
             $html .= "\n" . '<input type="checkbox" ' . $field_class . $title . ' name="' . $field_id . '" id="' . $field_id . '" value="1" ' . $checked . '/>';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_CHECKBOX_H:
             if ($field->css_class == '') {
                 $html .= "\n" . '<span class="fcp_checkbox fcp_checkbox_h" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<span class="fcp_ufield ' . $field->css_class . '" id="' . $div_id . '">';
             }
             if ($data->{$field_id}) {
                 $checked = 'checked = "checked"';
             } else {
                 $checked = '';
             }
             $checkbox = '<input type="checkbox" ' . $field_class . ' name="' . $field_id . '" id="' . $field_id . '" value="1" ' . $checked . '/>';
             $html .= "\n" . $checkbox;
             if ($field->mandatory) {
                 $html .= "\n" . '<span class="fcp_mandatory"><span ' . $field_class . '>' . $field->prompt . '</span></span>';
             } else {
                 $html .= "\n" . '<span>' . $field->prompt . '</span>';
             }
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</span>';
             break;
         case LAFC_FIELD_CHECKBOX_M:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_checkbox fcp_checkbox_m" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field, '', $title);
             $html .= "\n" . '<div class="fcp_checkbox_inner">';
             $list_array = FCP_Common::split_list($field->list_list, $field->delimiter);
             $html .= self::make_checkbox_list($field_id, $list_array['LEFT'], $title);
             $html .= "\n" . '</div>';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_FIXED_TEXT:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_fixed_text" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $html .= "\n" . '<span>' . $field->default_value . '</span>';
             // note that we do not end the div
             // because there might be horizontal checkboxes that need to go in it
             break;
         case LAFC_FIELD_DATE:
             require_once LAFC_HELPER_PATH . '/date_pickers.php';
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_date" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $html .= FCP_date_picker::make_date_field($config_data, $field_id, $data->{$field_id});
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_FIELDSET_START:
             if ($field->prompt == '') {
                 $legend = '';
             } else {
                 $legend = '<legend>' . $field->prompt . '</legend>';
             }
             $size = self::size($field->width);
             if ($field->css_class == '') {
                 $html .= "\n" . '<fieldset class="fcp_fieldset"' . $size . '>' . $legend;
             } else {
                 $html .= "\n" . '<fieldset class="fcp_fieldset ' . $field->css_class . $size . '">' . $legend;
             }
             break;
         case LAFC_FIELD_FIELDSET_END:
             $html .= "\n" . '</fieldset>';
             break;
         case LAFC_FIELD_RADIO_H:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_radio" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $html .= "\n" . '<div class="fcp_radio_h_inner">';
             $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
             $html .= self::make_radio_list($field_id, $data->{$field_id}, $list_array['LEFT'], 'fcp_radio_h', $title);
             $html .= "\n" . '</div>';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_RADIO_V:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_radio" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $html .= "\n" . '<div class="fcp_radio_v_inner">';
             $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
             $html .= self::make_radio_list($field_id, $data->{$field_id}, $list_array['LEFT'], 'fcp_radio_v', $title);
             $html .= "\n" . '</div>';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_PASSWORD:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_password" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $size = self::size($field->width);
             $html .= "\n" . '<input type="password" ' . $field_class . $size . ' name="' . $field_id . '" id="' . $field_id . '"' . $placeholder . ' value="' . $data->{$field_id} . '"' . $title . ' />';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
         case LAFC_FIELD_ATTACHMENT:
             if ($field->css_class == '') {
                 $html .= "\n" . '<div class="fcp_line fcp_attachment" id="' . $div_id . '">';
             } else {
                 $html .= "\n" . '<div class="fcp_line ' . $field->css_class . '" id="' . $div_id . '">';
             }
             $html .= self::draw_label($field);
             $size = self::size($field->width);
             $html .= "\n" . '<input type="file" ' . $field_class . $size . ' name="' . $field_id . '" id="' . $field_id . '"' . $title . ' />';
             $html .= $info_button;
             $html .= '<span id="' . $error_id . '"></span>';
             $html .= "\n" . '</div>';
             break;
     }
     return $html;
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: vstorm83/propertease
    function display($tpl = null)
    {
        $order_text = ucfirst(JText::_('JFIELD_ORDERING_LABEL'));
        $id_text = ucfirst(JText::_('JGLOBAL_FIELD_ID_LABEL'));
        $yes_text = ucfirst(JText::_('JYES'));
        $no_text = ucfirst(JText::_('JNO'));
        FCP_Admin::make_title('COM_FLEXICONTACT_CONFIG_FIELDS_NAME', $this->config_data, $this->config_count);
        JToolBarHelper::custom('add_default_fields', 'default.png', 'default_f2.png', 'COM_FLEXICONTACT_RESTORE_DEFAULT_FIELDS', false);
        $num_fields = count($this->config_data->config_data->all_fields);
        if ($num_fields < LAFC_MAX_FIELDS) {
            JToolBarHelper::addNew();
        }
        JToolBarHelper::editList();
        JToolBarHelper::deleteList();
        JToolBarHelper::cancel();
        $field_types = FCP_Admin::make_field_type_list();
        require_once LAFC_HELPER_PATH . '/date_pickers.php';
        $validation_types = FCP_date_picker::validation_type_list();
        $pagination = new JPagination($num_fields, 0, 1000);
        // we don't actually use pagination but we need this for the ordering tools
        // Joomla 3.0 took away the Javascript checkAll() function. Joomla.checkAll() first appeared in 1.7
        $check_all = 'onclick="Joomla.checkAll(this);"';
        // draw the form
        ?>
	<form action="index.php" method="post" name="adminForm" id="adminForm" >
	<input type="hidden" name="option" value="<?php 
        echo LAFC_COMPONENT;
        ?>
" />
	<input type="hidden" name="controller" value="field" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="view" value="config_field_list" />
	<input type="hidden" name="boxchecked" value="0" />
	<?php 
        echo '<table>';
        echo '<table class="adminlist table table-striped">';
        echo '<thead>';
        echo '      <th width="1">' . $id_text . '</th>';
        echo '      <th width="1"><input type="checkbox" name="toggle" value="" ' . $check_all . ' /></th>';
        echo '      <th width="1"></th>';
        echo '      <th width="1"></th>';
        echo '      <th width="1" nowrap="nowrap">' . $order_text . ' ' . JHTML::_('grid.order', $this->config_data->config_data->all_fields) . '</th>';
        echo '		<th nowrap="nowrap" width="20%">' . JText::_('COM_FLEXICONTACT_V_PROMPT') . '</th>';
        echo '		<th nowrap="nowrap" width="10%" colspan="2">' . JText::_('COM_FLEXICONTACT_FIELD_TYPE') . '</th>';
        echo '		<th nowrap="nowrap" width="5%" >' . JText::_('COM_FLEXICONTACT_V_MANDATORY') . '</th>';
        echo '		<th nowrap="nowrap" width="5%" >' . JText::_('COM_FLEXICONTACT_V_WIDTH') . '</th>';
        echo '		<th nowrap="nowrap" width="5%" >' . JText::_('COM_FLEXICONTACT_V_HEIGHT') . '</th>';
        echo '		<th nowrap="nowrap">' . JText::_('COM_FLEXICONTACT_DETAILS') . '</th>';
        echo '	</tr>';
        echo '</thead>';
        for ($i = 0; $i < $num_fields; $i++) {
            $field =& $this->config_data->config_data->all_fields[$i];
            $field_type_name = $field_types[$field->field_type];
            $checked = JHTML::_('grid.id', $i, $i);
            if ($field->mandatory == 1) {
                $mandatory = $yes_text;
            } else {
                $mandatory = $no_text;
            }
            if ($field->visible == 1) {
                $visible = $yes_text;
            } else {
                $visible = $no_text;
            }
            $width = '';
            $height = '';
            $details = '';
            switch ($field->field_type) {
                case LAFC_FIELD_FROM_ADDRESS:
                    $width = $field->width;
                    break;
                case LAFC_FIELD_FROM_NAME:
                case LAFC_FIELD_TEXT:
                case LAFC_FIELD_PASSWORD:
                case LAFC_FIELD_TEXT_NUMERIC:
                case LAFC_FIELD_FIELDSET_START:
                    $width = $field->width;
                    if ($field->default_value != '') {
                        $details = JText::_('COM_FLEXICONTACT_DEFAULT') . ': ' . $field->default_value;
                    }
                    break;
                case LAFC_FIELD_SUBJECT:
                    $width = $field->width;
                    if ($field->default_value != '') {
                        $details = JText::_('COM_FLEXICONTACT_DEFAULT') . ': ' . $field->default_value . ', ' . JText::_('COM_FLEXICONTACT_VISIBLE') . ': ' . $visible;
                    } else {
                        $details = JText::_('COM_FLEXICONTACT_VISIBLE') . ': ' . $visible;
                    }
                    break;
                case LAFC_FIELD_TEXTAREA:
                    $width = $field->width;
                    $height = $field->height;
                    break;
                case LAFC_FIELD_LIST:
                    $list_array = FCP_Common::split_list($field->list_list, $field->delimiter);
                    $field_id = sprintf('field%03d', $i);
                    $list_html = FCP_Common::make_list($field_id, 0, $list_array['LEFT']);
                    $details = $list_html;
                    break;
                case LAFC_FIELD_FIXED_TEXT:
                    $details = $field->default_value;
                    break;
                case LAFC_FIELD_ADVANCED:
                    $width = $field->width;
                    $details = $field->regex;
                    if (!empty($field->sql)) {
                        if (!empty($details)) {
                            $details .= '<br />';
                        }
                        $details .= $field->sql;
                    }
                    if ($field->error_msg != '') {
                        $details .= ' [' . $field->error_msg . ']';
                    }
                    break;
                case LAFC_FIELD_RECIPIENT:
                    $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
                    $field_id = sprintf('field%03d', $i);
                    $list_html = FCP_Common::make_list($field_id, 0, $list_array['LEFT']);
                    $details = $list_html;
                    break;
                case LAFC_FIELD_RADIO_V:
                case LAFC_FIELD_RADIO_H:
                    $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter);
                    $details = implode(", ", $list_array['RIGHT']);
                    break;
                case LAFC_FIELD_CHECKBOX_M:
                    $list_array = FCP_Common::split_list($field->list_list, $field->delimiter);
                    $details = implode(", ", $list_array['LEFT']);
                    break;
                case LAFC_FIELD_DATE:
                    $details = $validation_types[$field->validation_type];
            }
            $image = FCP_Admin::get_icon_image($field->field_type);
            $link = JRoute::_(LAFC_COMPONENT_LINK . '&controller=field&task=edit&cid[]=' . $i);
            $field_id = sprintf('%02d', $i + 1);
            echo "\n<tr>";
            echo '  <td>' . JHTML::link($link, $field_id) . '</td>';
            echo '  <td align="center">' . $checked . '</td>';
            echo '  <td>' . $pagination->orderUpIcon($i, true) . '</td>';
            echo '  <td>' . $pagination->orderDownIcon($i, true) . '</td>';
            echo '  <td><input type="text" name="order[]" size="5" value="' . ($i + 1) . '" class="text_area" style="text-align: center" /></td>';
            echo '  <td nowrap="nowrap">' . JHTML::link($link, $field->prompt) . '</td>';
            echo '  <td align="center">' . $image . '</td>';
            echo '  <td nowrap="nowrap">' . $field_type_name . '</td>';
            echo '  <td align="center">' . $mandatory . '</td>';
            echo '  <td align="center">' . $width . '</td>';
            echo '  <td align="center">' . $height . '</td>';
            echo '  <td align="left">' . $details . '</td>';
            echo "\n</tr>";
        }
        echo '</table></form>';
    }