</script> <?php $fieldset_data['elements']['tax'] = array('title' => 'Tax', 'fields' => array(ob_get_clean())); $fieldset_data['elements']['currency'] = array('title' => 'Currency', 'field' => array('type' => 'select', 'options' => get_multiple('currency', '', 'currency_id'), 'name' => 'currency_id', 'value' => $job['currency_id'], 'options_array_id' => 'code')); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); if (module_config::c('job_enable_description', 1)) { if (!module_job::can_i('edit', 'Jobs') && !$job['description']) { // no description, no ability to edit description, don't show anything. } else { // can edit description $fieldset_data = array('heading' => array('title' => _l('Job Description'), 'type' => 'h3'), 'class' => 'tableclass tableclass_form tableclass_full'); if (module_job::can_i('edit', 'Jobs')) { $fieldset_data['elements'] = array(array('field' => array('type' => 'wysiwyg', 'name' => 'description', 'value' => $job['description']))); } else { $fieldset_data['elements'] = array(array('fields' => array(module_security::purify_html($job['description'])))); } echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); } } /**** ADVANCED ***/ if (module_job::can_i('view', 'Job Advanced')) { ob_start(); ?> <table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tableclass_full"> <tbody> <?php if (class_exists('module_website', false) && module_website::is_plugin_enabled()) { ?>
$search_bar = array('elements' => array('name' => array('title' => _l('File Name / Description:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : '')))); if (class_exists('module_job', false)) { $search_bar['elements']['job'] = array('title' => _l('Job:'), 'field' => array('type' => 'select', 'name' => 'search[job_id]', 'value' => isset($search['job_id']) ? $search['job_id'] : '', 'options' => module_job::get_jobs(), 'options_array_id' => 'name')); } echo module_form::search_bar($search_bar); $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['file_name'] = array('title' => 'File Name', 'callback' => function ($file) { echo module_file::link_open($file['file_id'], true); if (isset($file['file_url']) && strlen($file['file_url'])) { echo ' '; echo '<a href="' . htmlspecialchars($file['file_url']) . '">' . htmlspecialchars($file['file_url']) . '</a>'; } }, 'cell_class' => 'row_action'); $columns['file_description'] = array('title' => 'Description', 'callback' => function ($file) { echo module_security::purify_html($file['description']); }); $columns['file_status'] = array('title' => 'Status', 'callback' => function ($file) { echo nl2br(htmlspecialchars($file['status'])); }); $columns['file_size'] = array('title' => 'Size', 'callback' => function ($file) { if ($file['bucket']) { // how many files are under this bucket? $search = array(); $search['bucket_parent_file_id'] = $file['file_id']; echo _l('%s files', count(module_file::get_files($search))); } else { if (file_exists($file['file_path'])) { echo module_file::format_bytes(filesize($file['file_path'])); } }
function get_form_element($element, $viewing_revision = false, $data_record = array()) { $has_write_access = !$viewing_revision; // convert our data field to an element. $element['name'] = isset($element['name']) && !empty($element['name']) ? $element['name'] : 'data_field[' . $element['data_field_id'] . ']'; $element['id'] = 'data_field_' . $element['data_field_id'] . ''; $element['type'] = $element['field_type']; if (!isset($element['value'])) { $element['value'] = ''; } if (!$has_write_access) { //$element['disabled'] = 'disabled'; $element['class'] = 'data_field_view'; } $highlight = false; $this->ajax_edit = false; $input_name = $element['name']; if (!$input_name) { return false; } if (isset($element['id']) && $element['id']) { $input_id = $element['id']; } else { $element['id'] = $input_name; $input_id = $input_name; } //if(!$value && isset($_REQUEST[$input_name]))$value = $_REQUEST[$input_name]; if (!$element['value']) { $element['value'] = $element['default']; } if (!is_array($element['value'])) { //$value=htmlspecialchars($value); } if (!isset($element['class'])) { $element['class'] = ''; } $attr = $attr_other = ''; if ($has_write_access) { if ($element['type'] == 'radio' || $element['type'] == 'checkbox_list') { // hacky! if ($element['required']) { $attr_other .= ' class="form_field form_field_required"'; } else { $attr_other .= ' class="form_field"'; } } else { $element['class'] .= " form_field"; if ($element['required']) { $element['class'] .= " form_field_required"; } } switch ($element['type']) { case 'date': $element['class'] .= " date_field"; if (!isset($element['size']) || !$element['size']) { $element['size'] = 8; } if (strtolower($element['value']) == 'now') { $element['value'] = print_date(time()); } break; case 'datetime': $element['class'] .= " date_time_field"; if (!isset($element['size']) || !$element['size']) { $element['size'] = 12; } if (strtolower($element['value']) == 'now') { $element['value'] = print_date(time(), true); } break; } } switch ($element['type']) { case 'checkbox_list': case 'radio': $element['attributes'] = array(); foreach (explode("\n", trim($element['field_data'])) as $line) { $line = trim($line); if (preg_match('/^attributes=/', $line)) { $line = preg_replace('/^attributes=/', '', $line); $element['attributes'] = explode("|", $line); break; } } break; case 'select': if (!isset($element['attributes']) || !is_array($element['attributes']) || !count($element['attributes'])) { $element['attributes'] = array(); foreach (explode("\n", trim($element['field_data'])) as $line) { $line = trim($line); if (preg_match('/^attributes=/', $line)) { $line = preg_replace('/^attributes=/', '', $line); if (preg_match('#hook:([\\w_]+)$#', $line, $matches)) { // see if we get anything back from this hook. $attributes = array(); $attributes = hook_filter_var($matches[1], $attributes, $element); if (is_array($attributes)) { $element['attributes'] = $attributes; } else { $element['attributes'] = array('Unable to call hook: ' . $matches[1]); } } else { $element['attributes'] = explode("|", $line); } break; } } } break; } if (!isset($element['style'])) { $element['style'] = ''; } // we have to apply some custom width/height styles if they exist. $width = $height = false; foreach (explode("\n", trim($element['field_data'])) as $line) { $line = trim($line); if (preg_match('/^width=/', $line)) { $line = preg_replace('/^width=/', '', $line); $width = (int) $line; } if (preg_match('/^height=/', $line)) { $line = preg_replace('/^height=/', '', $line); $height = (int) $line; } } if (!$height && $height < _MIN_INPUT_HEIGHT) { $height = _MIN_INPUT_HEIGHT; } switch ($element['type']) { case 'text': case 'date': case 'datetime': if ($width) { $element['style'] .= 'width:' . $width . 'px; '; } break; case 'radio': if ($width) { $attr_other .= ' style="width:' . $width . 'px; "'; } break; case 'textarea': case 'textbox': if ($width) { $element['style'] .= 'width:' . $width . 'px; '; } if ($has_write_access && $height) { $element['style'] .= 'height:' . $height . 'px; '; } break; } if (isset($element['width'])) { unset($element['width']); } if (isset($element['height'])) { unset($element['height']); } if (isset($element['multiple']) && $element['multiple']) { $element['multiple'] = true; // pass 'multiple' through to the UCM form builder which should handle everything $value_unserialize = @unserialize($element['value']); if (is_array($value_unserialize)) { $element['values'] = $value_unserialize; // 'values' is used in the UCM field generation tool } $element['name'] = $element['name'] . '[]'; } else { $element['multiple'] = false; } if (!$has_write_access && $element['multiple'] && isset($element['values']) && is_array($element['values'])) { $element['value'] = $element['values']; } if (is_array($element['value']) && count($element['value'])) { $all_values = $element['value']; } else { $all_values = array($element['value']); } if ($element['type'] == 'checkbox_list') { $test = @unserialize($element['value']); if (is_array($test) && count($test)) { $all_values = array($test); } else { $all_values = array($element['value']); } } if ($element['type'] == "cancel" && !isset($element['onclick'])) { $element['onclick'] = "history.go(-1);"; } if ($highlight) { $element['class'] .= " form_field_highlight"; } /*if(!$has_write_access){ $element['class'] .= ' form_disabled'; }*/ $attribute_keys = array('class', 'disabled', 'onclick', 'onfocus', 'onmouseup', 'onmousedown', 'onchange', 'size', 'cols', 'rows', 'width', 'style'); foreach ($element as $key => $val) { if (!is_array($val) && !trim($val)) { continue; } if (in_array(strtolower($key), $attribute_keys)) { if (in_array(strtolower($key), array('size', 'cols', 'rows', 'width', 'height')) && (int) $val == 0) { continue; } $attr .= ' ' . $key . '="' . $val . '"'; } } // check for default values, these are cleared when submitting the form if ($element['default']) { $has_default = true; } $real_input_id = $input_id; $real_input_name = $input_name; ob_start(); foreach ($all_values as $value_key => $value) { if (!$has_write_access) { // disabled. if (isset($width) && $width && $element['type'] != 'encrypted') { echo '<span ' . $attr; echo ' style="width:' . $width . 'px;"'; echo '> '; } // display value differently depending on value type. switch ($element['type']) { case 'checkbox_list': $other = ''; if (is_array($value)) { if (isset($value['other_val'])) { $other = $value['other_val']; unset($value['other_val']); } echo implode(', ', array_keys($value)); } echo ' ' . $other; break; case 'select': if (isset($element['attributes'])) { $attributes = $element['attributes']; } else { $attributes = array(); } if (isset($attributes[0])) { $new_attributes = array(); foreach ($attributes as $aid => $a) { $new_attributes[$aid + 1] = $a; } $attributes = $new_attributes; } if (isset($attributes[$value])) { echo $attributes[$value]; } break; case 'textarea': case 'textbox': echo nl2br(htmlspecialchars($value)); break; case 'file': if ($value) { $file_data = @unserialize($value); $file_link = 'includes/plugin_data/upload/' . $file_data['file']; if (is_file($file_link)) { $download_link = self::link_public_file_download($data_record['data_record_id'], $data_record['data_type_id'], $element['data_field_group_id'], $element['data_field_id']); echo '<a href="' . $download_link . '" target="_blank">' . $file_data['name'] . '</a>'; } else { echo 'File Not Found'; } } break; case 'wysiwyg': echo module_security::purify_html($value); break; case 'encrypted': if (class_exists('module_encrypt', false)) { ob_start(); $element['type'] = 'text'; module_form::generate_form_element($element); $enc_html = ob_get_clean(); echo module_encrypt::parse_html_input('custom_data', $enc_html, false); } break; case 'created_date_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'); break; case 'created_date': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'); break; case 'created_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'); break; case 'updated_date_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A')); break; case 'updated_date': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A')); break; case 'updated_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A')); break; case 'created_by': echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'); break; case 'updated_by': echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A')); break; case 'url': echo '<a href="' . htmlspecialchars($value) . '" target="_blank">' . htmlspecialchars($value) . '</a>'; break; default: echo htmlspecialchars($value); break; } if (isset($width) && $width && $element['type'] != 'encrypted') { echo ' </span>'; } } else { // update for UCM: use the ucm form generator if (isset($element['default']) && $element['default'] && !$element['value']) { $element['value'] = $element['default']; } switch ($element['type']) { case 'wysiwyg': $element['options']['inline'] = false; module_form::generate_form_element($element); break; case "radio": $has_val = false; foreach ($element['attributes'] as $attribute) { $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute); ?> <span class="field_radio"> <input type="radio" name="<?php echo $input_name; ?> " id="<?php echo $this_input_id; ?> " value="<?php echo htmlspecialchars($attribute); ?> "<?php if ($attribute == $value || strtolower($attribute) == 'other' && !$has_val) { // assumes "OTHER" is always last... fix with a separate loop before hand checking all vals if (strtolower($attribute) != 'other') { $has_val = true; } echo " checked"; } echo ' ' . $attr; if (strtolower($attribute) == 'other') { echo ' onmouseup="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; echo ' onchange="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; } ?> > <label for="<?php echo $this_input_id; ?> "><?php echo $attribute; ?> </label> <?php if (strtolower($attribute) == 'other') { ?> <span class="data_field_input"> <input type="text" name="other_<?php echo $input_name; ?> " id="other_<?php echo $this_input_id; ?> " value="<?php if (!$has_val) { echo htmlspecialchars($value); } ?> " onchange="$('input[type=radio]',$(this).parent())[0].checked = true;" <?php echo $attr . $attr_other; ?> > </span> <?php } ?> </span> <?php } break; case "checkbox_list": $has_val = false; if (!is_array($value)) { $value = array(); } foreach ($element['attributes'] as $attribute) { $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute); ?> <span class="field_radio"> <input type="checkbox" name="<?php echo $input_name; ?> [<?php echo htmlspecialchars($attribute); ?> ]" id="<?php echo $this_input_id; ?> " value="1"<?php if (isset($value[$attribute])) { if (strtolower($attribute) != 'other') { $has_val = true; } echo " checked"; } echo ' ' . $attr; if (strtolower($attribute) == 'other') { echo ' onmouseup="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; echo ' onchange="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; } ?> > <label for="<?php echo $this_input_id; ?> "><?php echo $attribute; ?> </label> <?php if (strtolower($attribute) == 'other') { ?> <span class="data_field_input"> <input type="text" name="<?php echo $input_name; ?> [other_val]" id="other_<?php echo $this_input_id; ?> " value="<?php echo isset($value['other_val']) ? htmlspecialchars($value['other_val']) : ''; ?> " onchange="$('input[type=radio]',$(this).parent())[0].checked = true;" <?php echo $attr . $attr_other; ?> > </span> <?php } ?> </span> <?php } break; case "file": $this->has_files = true; ?> <input type="file" name="<?php echo $input_name; ?> " id="<?php echo $input_id; ?> " value="<?php echo $value; ?> "<?php echo $attr; ?> > <?php break; case 'select': $attributes = isset($element['attributes']) ? $element['attributes'] : array(); if (isset($attributes[0])) { $new_attributes = array(); foreach ($attributes as $aid => $a) { $new_attributes[$aid + 1] = $a; } $attributes = $new_attributes; } $element['options'] = $attributes; module_form::generate_form_element($element); break; case 'encrypted': if (class_exists('module_encrypt', false)) { ob_start(); $element['type'] = 'text'; module_form::generate_form_element($element); $enc_html = ob_get_clean(); echo module_encrypt::parse_html_input('custom_data', $enc_html); } break; case 'created_date_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'); break; case 'created_date': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'); break; case 'created_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'); break; case 'updated_date_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A')); break; case 'updated_date': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A')); break; case 'updated_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A')); break; case 'created_by': echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'); break; case 'updated_by': echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A')); break; case 'url': $element['type'] = 'text'; module_form::generate_form_element($element); break; default: module_form::generate_form_element($element); } if (isset($element['after_link']) && $element['after_link']) { if (preg_match('/^https?:\\/\\//', $value) || ($have_www = preg_match('/^www\\./', $value) || ($have_www = preg_match('/\\.com/', $value) && !preg_match('/\\w@\\w/', $value)))) { // we have a url if ($have_www) { $value = "http://" . $value; } ?> <a href="<?php echo $value; ?> " target="_blank">»</a> <?php } if (preg_match('/\\w@\\w/', $value)) { ?> <a href="mailto:<?php echo $value; ?> ">»</a> <?php } } } // editable echo ' '; } // foreach all values //${$element_id} = ob_get_clean(); // we just print the html for now return ob_get_clean(); }
public static function get_replace_fields($quote_id, $quote_data = false) { if (!$quote_data) { $quote_data = self::get_quote($quote_id); } $data = array('quote_number' => htmlspecialchars($quote_data['name']), 'quote_name' => htmlspecialchars($quote_data['name']), 'project_type' => _l(module_config::c('project_name_single', 'Website')), 'print_link' => self::link_public_print($quote_id), 'quote_url' => self::link_public($quote_id), 'title' => module_config::s('admin_system_name'), 'create_date' => print_date($quote_data['date_create'])); if (isset($quote_data['customer_id']) && $quote_data['customer_id']) { $customer_data = module_customer::get_replace_fields($quote_data['customer_id'], $quote_data['contact_user_id'] ? $quote_data['contact_user_id'] : false); $data = array_merge($data, $customer_data); // so we get total_amount_due and stuff. } $user_details = array('staff_first_name' => '', 'staff_last_name' => '', 'staff_email' => '', 'staff_phone' => '', 'staff_fax' => '', 'staff_mobile' => ''); if (isset($quote_data['user_id']) && $quote_data['user_id']) { $user_data = module_user::get_user($quote_data['user_id'], false); if ($user_data && $user_data['user_id'] == $quote_data['user_id']) { $user_details = array('staff_first_name' => $user_data['name'], 'staff_last_name' => $user_data['last_name'], 'staff_email' => $user_data['email'], 'staff_phone' => $user_data['phone'], 'staff_fax' => $user_data['fax'], 'staff_mobile' => $user_data['mobile']); } } $data = array_merge($data, $user_details); foreach ($quote_data as $key => $val) { if (strpos($key, 'date') !== false) { $quote_data[$key] = print_date($val); } } if (isset($quote_data['description'])) { $quote_data['description'] = module_security::purify_html($quote_data['description']); } // $customer_data = $quote_data['customer_id'] ? module_customer::get_replace_fields($quote_data['customer_id']) : array(); // $website_data = $quote_data['website_id'] ? module_website::get_replace_fields($quote_data['website_id']) : array(); // $data = array_merge($data,$customer_data,$website_data,$quote_data); $data = array_merge($data, $quote_data); $website_url = $project_names = $project_names_and_url = array(); if ($quote_data['website_id']) { $website_data = module_website::get_website($quote_data['website_id']); if ($website_data && $website_data['website_id'] == $quote_data['website_id']) { if (isset($website_data['url']) && $website_data['url']) { $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']); $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')'; } else { $website_data['name_url'] = $website_data['name']; } $project_names[$website_data['website_id']] = $website_data['name']; $project_names_and_url[$website_data['website_id']] = $website_data['name_url']; $fields = module_website::get_replace_fields($website_data['website_id'], $website_data); foreach ($fields as $key => $val) { if (!isset($data[$key]) || !$data[$key] && $val) { $data[$key] = $val; } } } } $data['website_name'] = $data['project_name'] = forum_text(count($project_names) ? implode(', ', $project_names) : ''); $data['website_name_url'] = forum_text(count($project_names_and_url) ? implode(', ', $project_names_and_url) : ''); $data['website_url'] = forum_text(count($website_url) ? implode(', ', $website_url) : ''); if (class_exists('module_group', false) && module_group::is_plugin_enabled()) { // get the quote groups $wg = array(); $g = array(); if ($quote_id > 0) { $quote_data = module_quote::get_quote($quote_id); foreach (module_group::get_groups_search(array('owner_table' => 'quote', 'owner_id' => $quote_id)) as $group) { $g[$group['group_id']] = $group['name']; } /*// get the website groups foreach(module_group::get_groups_search(array( 'owner_table' => 'website', 'owner_id' => $quote_data['website_id'], )) as $group){ $wg[$group['group_id']] = $group['name']; }*/ } $data['quote_group'] = implode(', ', $g); /*$data['website_group'] = implode(', ',$wg);*/ } // addition. find all extra keys for this quote and add them in. // we also have to find any EMPTY extra fields, and add those in as well. if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $all_extra_fields = module_extra::get_defaults('quote'); foreach ($all_extra_fields as $e) { $data[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'quote', 'owner_id' => $quote_id)); foreach ($extras as $e) { $data[$e['extra_key']] = $e['extra']; } } // also do this for customer fields /*if($quote_data['customer_id']){ $all_extra_fields = module_extra::get_defaults('customer'); foreach($all_extra_fields as $e){ $data[$e['key']] = _l('N/A'); } $extras = module_extra::get_extras(array('owner_table'=>'customer','owner_id'=>$quote_data['customer_id'])); foreach($extras as $e){ $data[$e['extra_key']] = $e['extra']; } }*/ return $data; }
public static function generate_form_element($setting) { if (isset($setting['ignore']) && $setting['ignore']) { return; } // type defaults if ($setting['type'] == 'currency') { $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'currency'; } if ($setting['type'] == 'date') { $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'date_field'; $setting['type'] = 'text'; } if ($setting['type'] == 'time') { $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'time_field'; $setting['type'] = 'text'; } if ($setting['type'] == 'select' || $setting['type'] == 'wysiwyg') { if (!isset($setting['id']) || !$setting['id']) { $setting['id'] = $setting['name']; } } if ($setting['type'] == 'save_button') { $setting['type'] = 'submit'; $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'submit_button save_button'; } if ($setting['type'] == 'delete_button') { $setting['type'] = 'submit'; $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'submit_button delete_button'; } if (isset($setting['label']) && (!isset($setting['id']) || !$setting['id'])) { // labels need ids $setting['id'] = md5($setting['name']); } $attributes = ''; foreach (array('size', 'style', 'autocomplete', 'placeholder', 'class', 'id', 'onclick') as $attr) { if (isset($setting[$attr])) { $attributes .= ' ' . $attr . '="' . $setting[$attr] . '"'; } } if (!isset($setting['value'])) { $setting['value'] = ''; } ob_start(); // handle multiple options $loop_count = 1; if (isset($setting['multiple']) && $setting['multiple']) { // has to have at least 1 value if ($setting['multiple'] === true) { // create our wrapper id. $multiple_id = md5(serialize($setting)); echo '<div id="' . $multiple_id . '">'; } else { $multiple_id = $setting['multiple']; } if (!isset($setting['values'])) { $setting['values'] = array($setting['value']); } $loop_count = count($setting['values']); } for ($x = 0; $x < $loop_count; $x++) { if (isset($setting['multiple']) && $setting['multiple']) { $setting['value'] = isset($setting['values'][$x]) ? $setting['values'][$x] : false; echo '<div class="dynamic_block">'; } switch ($setting['type']) { case 'currency': echo currency('<input type="text" name="' . $setting['name'] . '" value="' . htmlspecialchars($setting['value']) . '"' . $attributes . '>', true, isset($setting['currency_id']) ? $setting['currency_id'] : false); break; case 'number': ?> <input type="number" name="<?php echo $setting['name']; ?> " value="<?php echo htmlspecialchars($setting['value']); ?> "<?php echo $attributes; ?> > <?php break; case 'text': ?> <input type="text" name="<?php echo $setting['name']; ?> " value="<?php echo htmlspecialchars($setting['value']); ?> "<?php echo $attributes; ?> > <?php break; case 'password': ?> <input type="password" name="<?php echo $setting['name']; ?> " value="<?php echo htmlspecialchars($setting['value']); ?> "<?php echo $attributes; ?> > <?php break; case 'hidden': ?> <input type="hidden" name="<?php echo $setting['name']; ?> " value="<?php echo htmlspecialchars($setting['value']); ?> "<?php echo $attributes; ?> > <?php break; case 'textarea': ?> <textarea name="<?php echo $setting['name']; ?> " rows="6" cols="50"<?php echo $attributes; ?> ><?php echo htmlspecialchars($setting['value']); ?> </textarea> <?php break; case 'wysiwyg': self::load_wysiwyg(); ?> <?php if (!isset($setting['options']) || !isset($setting['options']['inline']) || $setting['options']['inline']) { ?> <div style="border:1px solid #EFEFEF;" data-name="<?php echo $setting['name']; ?> " <?php echo $attributes; ?> ><?php echo module_security::purify_html($setting['value']); ?> </div> <?php if ($setting['name'] != $setting['id']) { ?> <!-- we update this on change, needed because tinymce jquery has issues with name[] form elements --> <input type="hidden" name="<?php echo $setting['name']; ?> " id="<?php echo $setting['id']; ?> _postback" value="<?php echo htmlspecialchars(module_security::purify_html($setting['value'])); ?> "> <?php } ?> <?php } else { ?> <textarea name="<?php echo $setting['name']; ?> " rows="6" cols="50"<?php echo $attributes; ?> ><?php echo htmlspecialchars($setting['value']); ?> </textarea> <?php } ?> <script type="text/javascript"> $(function() { $('#<?php echo $setting['id']; ?> ').tinymce({ // Location of TinyMCE script <?php if (!isset($setting['options']) || !isset($setting['options']['inline']) || $setting['options']['inline']) { ?> inline: true, <?php } ?> script_url : '<?php echo _BASE_HREF; ?> includes/plugin_form/js/tinymce4.0.11/tinymce.min.js', relative_urls : false, convert_urls : false, // General options theme : "modern", statusbar: false, /*plugins: [ "advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste" ], toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",*/ plugins: [ "advlist autolink autoresize link image lists charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking", "table directionality emoticons template textcolor paste textcolor" ], toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | formatselect fontselect fontsizeselect", toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | inserttime preview | forecolor backcolor", toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | visualchars visualblocks nonbreaking", menubar: false, toolbar_items_size: 'small', width : '100%', browser_spellcheck: true, contextmenu: false, setup : function(ed) { ed.on("init", function() { if(typeof tinymce_focus != 'undefined'){ $(ed.getDoc()).contents().find('body').focus(function(){tinymce_focus();}); } if(typeof tinymce_blur != 'undefined'){ $(ed.getDoc()).contents().find('body').blur(function(){tinymce_blur();}); } }); <?php if (!isset($setting['options']) || !isset($setting['options']['inline']) || $setting['options']['inline']) { if ($setting['name'] != $setting['id']) { ?> ed.on("change", function() { $('#<?php echo $setting['id']; ?> _postback').val(ed.getContent()); }); <?php } } ?> } }); }); </script> <?php break; case 'select': // copied from print_select_box() if (isset($setting['allow_new']) && $setting['allow_new']) { $attributes .= ' onchange="dynamic_select_box(this);"'; } ?> <select name="<?php echo $setting['name']; ?> "<?php echo $attributes; ?> > <?php if (!isset($setting['blank']) || $setting['blank']) { ?> <option value=""><?php echo !isset($setting['blank']) || $setting['blank'] === true ? _l('- Select -') : htmlspecialchars($setting['blank']); ?> </option> <?php } $found_selected = false; $current_val = 'Enter new value here'; $sel = ''; foreach ($setting['options'] as $key => $val) { if (is_array($val)) { if (!$setting['options_array_id']) { if (isset($val[$setting['id']])) { $setting['options_array_id'] = $setting['id']; } else { $setting['options_array_id'] = key($val); } } $printval = $val[$setting['options_array_id']]; } else { $printval = $val; } if (strlen($printval) == 0) { continue; } $sel .= '<option value="' . htmlspecialchars($key) . '"'; // to handle 0 elements: if ($setting['value'] !== false && $setting['value'] !== '' && $key == $setting['value']) { $current_val = $printval; $sel .= ' selected'; $found_selected = true; } $sel .= '>' . htmlspecialchars($printval) . '</option>'; } if ($setting['value'] && !$found_selected) { $sel .= '<option value="' . htmlspecialchars($setting['value']) . '" selected>' . htmlspecialchars($setting['value']) . '</option>'; } if (isset($setting['allow_new']) && $setting['allow_new'] && get_display_mode() != 'mobile') { $sel .= '<option value="create_new_item">' . _l(' - Create New - ') . '</option>'; } if (isset($setting['allow_new']) && $setting['allow_new']) { //$sel .= '<input type="text" name="new_'.$id.'" style="display:none;" value="'.$current_val.'">'; } echo $sel; ?> <?php /*foreach($setting['options'] as $key=>$val){ ?> <option value="<?php echo $key;?>"<?php echo $setting['value'] == $key ? ' selected':'' ?>><?php echo htmlspecialchars($val);?></option> <?php }*/ ?> </select> <?php break; case 'checkbox': ?> <input type="hidden" name="default_<?php echo $setting['name']; ?> " value="1"> <input type="checkbox" name="<?php echo $setting['name']; ?> " value="1" <?php if ($setting['value']) { echo ' checked'; } echo $attributes; ?> > <?php break; case 'check': ?> <input type="checkbox" name="<?php echo $setting['name']; ?> " value="<?php echo $setting['value']; ?> " <?php if ($setting['checked']) { echo ' checked'; } echo $attributes; ?> > <?php break; case 'submit': ?> <input type="submit" name="<?php echo htmlspecialchars($setting['name']); ?> " value="<?php echo htmlspecialchars($setting['value']); ?> " <?php echo $attributes; ?> /> <?php break; case 'button': ?> <input type="button" name="<?php echo htmlspecialchars($setting['name']); ?> " value="<?php echo htmlspecialchars($setting['value']); ?> " <?php echo $attributes; ?> /> <?php break; case 'html': ?> <div<?php echo $attributes; ?> ><?php echo $setting['value']; ?> </div> <?php break; } if (isset($setting['multiple']) && $setting['multiple']) { echo '<a href="#" class="add_addit" onclick="return seladd(this);">+</a> <a href="#" class="remove_addit" onclick="return selrem(this);">-</a>'; echo '</div>'; } } if (isset($setting['multiple']) && $setting['multiple']) { if ($setting['multiple'] === true) { echo '</div>'; } echo '<script type="text/javascript"> set_add_del("' . $multiple_id . '"); </script>'; } $html = ob_get_clean(); if (isset($setting['encrypt']) && $setting['encrypt'] && class_exists('module_encrypt', false)) { $html = module_encrypt::parse_html_input($setting['page_name'], $html); } echo $html; if (isset($setting['label']) && strlen($setting['label'])) { echo '<label for="' . htmlspecialchars($setting['id']) . '">' . _l($setting['label']) . '</label>'; } if (isset($setting['help']) && (count($setting['help']) || strlen($setting['help']))) { _h($setting['help']); } }
$hide__ines[$line_number] = $line; unset($print__ines[$line_number]); } else { // not hidden yet. $print__ines[$line_number] = $line; } } ksort($hide__ines); ksort($print__ines); //echo module_security::purify_html(implode("\n",$hide__ines)); echo '<hr>'; echo module_security::purify_html(implode("\n", $print__ines)); //print_r($print__ines); if (count($hide__ines)) { echo '<a href="#" onclick="jQuery(this).parent().find(\'div\').show(); jQuery(this).hide(); return false;">' . _l('- show quoted text -') . '</a> '; echo '<div style="display:none;">'; echo module_security::purify_html(implode("\n", $hide__ines)); echo '</div>'; //print_r($hide__ines); } } else { echo $text; } /*if($ticket_message['cache']=='autoreply'){ ?> </div> <?php }else */ if ($do_we_hide) { ?> </div>
$value = isset($data['date_updated']) && $data['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data['date_updated'])) : (isset($data['date_created']) && $data['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data['date_created'])) : _l('N/A')); break; case 'created_by': $value = isset($data['create_user_id']) && (int) $data['create_user_id'] > 0 ? module_user::link_open($data['create_user_id'], true) : _l('N/A'); break; case 'updated_by': $value = isset($data['update_user_id']) && (int) $data['update_user_id'] > 0 ? module_user::link_open($data['update_user_id'], true) : (isset($data['create_user_id']) && (int) $data['create_user_id'] > 0 ? module_user::link_open($data['create_user_id'], true) : _l('N/A')); break; } } else { switch ($settings['field_type']) { case 'encrypted': $value = '*******'; break; case 'wysiwyg': $value = module_security::purify_html($value); break; case 'select': // todo - do this for the other field types as well.. $settings['value'] = $value; $value = $module->get_form_element($settings, true, $data); break; case 'url': if (!is_array($value)) { $value = array($value); } $foo = array(); foreach ($value as $v) { $foo[] = '<a href="' . htmlspecialchars($v) . '" target="_blank">' . htmlspecialchars($v) . '</a>'; } $value = implode(', ', $foo);
<?php } ?> </td> </tr> <tr> <th> <?php _e('Message:'); ?> </th> <td id="email_message"> <?php if (!$can_edit_emails) { if (strlen($email['html_content'])) { echo module_security::purify_html($email['html_content']); } else { echo forum_text($email['text_content']); } } else { ?> <textarea name="content" id="email_content_editor" rows="10" cols="30" style="width:450px; height: 350px;"><?php echo htmlspecialchars($email['text_content']); ?> </textarea> <script type="text/javascript" src="<?php echo _BASE_HREF; ?> js/tiny_mce3.4.4/jquery.tinymce.js"></script> <script type="text/javascript">