/** * This helper provides MediaWiki-like diffing tools. * $Id: DiffHelper.php 1161 2007-08-02 19:31:00Z alex $ */ function show_documents_diff($document1, $document2, $fields, $module) { if (get_class($document1) != get_class($document2)) { return; } $haveDiff = false; foreach ($fields as $field) { $field1 = $document1->getRaw($field); $field2 = $document2->getRaw($field); $display_line_numbers = false; if ($field == 'filename') { $diff = show_imgs_diff($field1, $field2); } else { if ($field == 'conditions_levels') { $fs = array($field1, $field2); foreach ($fs as &$f) { foreach ($f as &$row) { $row = implode(' | ', $row); } $f = implode("\n", $f); } $diff = show_texts_diff($fs[0], $fs[1], true); } else { if (is_int($field1) || is_int($field2)) { $display_line_numbers = true; $field1 = get_field_value($field, $module, $field1); $field2 = get_field_value($field, $module, $field2); } else { if (is_array($field1) || is_array($field2)) { $display_line_numbers = true; foreach ($field1 as &$value) { $value = get_field_value($field, $module, $value); } foreach ($field2 as &$value) { $value = get_field_value($field, $module, $value); } $field1 = implode(", ", $field1); $field2 = implode(", ", $field2); } } $diff = show_texts_diff($field1, $field2, $display_line_numbers); } } if ($diff) { if (!$haveDiff) { $haveDiff = true; } echo '<table class="diff">' . "\n"; echo '<caption>' . __($field) . '</caption>' . "\n"; echo '<tr><td class="diff-symbol"></td><td class="diff-content"></td><td style="diff-symbol;"></td><td class="diff-content"></td></tr>'; echo "{$diff}\n"; echo '</table>' . "\n"; } } if (!$haveDiff) { echo '<p>' . __('No difference') . '</p>' . "\n"; } }
private function render_field_attribute($listing, $field_slug, $field_attribute) { $field = awpcp_get_extra_field_by_slug($field_slug); switch ($field_attribute) { case 'label': $output = $field->field_label; break; case 'value': $output = $this->render_field_value($field, get_field_value($listing->ad_id, $field_slug)); break; case 'raw': $output = $this->render_field_raw_value($field, get_field_value($listing->ad_id, $field_slug)); break; } return $output; }
<?php include "functions.php"; $table_name = "kids"; $arr_column = get_table_fields($table_name); $arr_table_values = get_table_values($table_name); $str = "CREATE TABLE IF NOT EXISTS " . $table_name . " ("; foreach ($arr_column as $key => $value) { $str .= $value['Field'] . " " . get_field_value($value) . ", "; } $str = rtrim($str, ", "); $str .= ")&#"; //echo "<pre>"; //print_r($arr_table_values); //echo "</pre>"; foreach ($arr_table_values as $key => $value) { $str .= build_insert_str($table_name, $value) . "&#"; } //header("Content-Type: text/html charset=utf-8"); $str = utf8_encode(nl2br(rtrim($str, "&#"))); echo json_encode($str); mysqli_close($connection);
function generate_fields($data) { global $dbh; global $settings; $item = $data['rows'][$data['item_id']]; foreach ($data['info'] as $key => $field) { $value = $item[$key]; $t_f = $data['name'] . ',' . $key; $note = $settings['field_note'][$t_f] ? ' <span class="note">' . $settings['field_note'][$t_f] . '</span>' : ''; $required_mark = $settings['field_required'][$t_f] == 'true' ? '<span class="loud">*</span>' : ''; $required = $settings['field_required'][$t_f] == 'true' ? 'required' : ''; $field_format = $settings['field_format'][$t_f] ? $settings['field_format'][$t_f] : get_datatype_formats($field['type_lengthless'], $primary_only = true); // 'text_field' $is_relational = $settings['field_format'][$t_f] == 'relational' ? true : false; $field_option = $settings['field_option'][$t_f]; // If field is hidden, add a hidden input and skip if ($settings['field_hidden'][$t_f] == 'true') { ?> <input type="hidden" name="<?php echo $key; ?> " value="<?php echo esc_attr($value); ?> "> <?php continue; } ////////////////////////////////////////////////////////////////////////////// ?> <div class="field"> <?php //////////////////////////////////////////////////////////////////////////////s // Check if field is relational if ($is_relational) { // Get options // REMINDER: MUST CHECK THE SQL STATEMENT TO ENSURE THERE IS NOTHING MALICIOUS! if ($sth = $dbh->query($field_option['relational']['sql'])) { $option_fields = explode(",", $field_option['relational']["option"]); if ($field_option['relational']["style"] == 'fancy') { unset($row_options); while ($row_array = $sth->fetch()) { $row_options[$row_array[$field_option['relational']["value"]]] = $row_array; } ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <table id="fancy_<?php echo $key; ?> " cellpadding="0" cellspacing="0" border="0" class="simple_sortable"> <tbody class="check_no_rows"> <tr class="item no_rows"><td colspan="3">No items</td></tr> <?php $value_array = array_filter(explode(',', $value)); foreach ($value_array as $ordered_value) { // Should save only ID for fancy... so we can edit items with a unique key $id = str_replace('"', """, $ordered_value); // Make visible option with multiple fields (field1,field2) unset($option_array); foreach ($option_fields as $temp) { $option_array[] = get_field_value($field_option['relational']["add_from_table"], $temp, $row_options[$ordered_value][$temp], 'code'); } // Only show found $found = $value == $ordered_value ? true : strpos($value, "," . $ordered_value . ","); if ($found !== false) { ?> <tr class="item" replace_with="<?php echo $id; ?> "> <td class="order handle"><img src="media/site/icons/ui-splitter-horizontal.png" width="16" height="16" /></td> <td> <div class="wrap"> <?php echo implode($field_option['relational']["option_glue"], $option_array); ?> <input type="hidden" name="<?php echo $key; ?> []" value="<?php echo $id; ?> "> <a class="badge edit_fancy modal" href="edit.php?modal=<?php echo $key; ?> &table=<?php echo $field_option['relational']["add_from_table"]; ?> &parent_table=<?php echo $_GET['table']; ?> &item=<?php echo $id; ?> " style="display:none;">Edit</a> </div> </td> <td width="10%"><a class="ui-icon ui-icon-close right remove_fancy" href=""></a></td> </tr> <?php } } ?> </tbody> </table> <?php if (!$field_option['relational']["only_new"]) { ?> <span class="fancy_new"> <select field="<?php echo $key; ?> " table="<?php echo $field_option['relational']["add_from_table"]; ?> " parent_table="<?php echo $_GET['table']; ?> "> <option value="">Select One</option> <?php foreach ($row_options as $row_option) { $option_value = $row_option[$field_option['relational']["value"]]; // Make visible option with multiple fields (field1,field2) $safe_value = str_replace('"', """, $option_value); unset($option_array); foreach ($option_fields as $temp) { $option_array[] = get_field_value($field_option['relational']["add_from_table"], $temp, $row_option[$temp], 'text'); } // Only show non-used //$found = ($value == $option_value)? true : strpos($value, ",".$option_value.","); //if($found === false){ ?> <option value="<?php echo $safe_value; ?> "><?php echo implode($field_option['relational']["option_glue"], $option_array); ?> </option> <?php } ?> </select> <span> or </span> <?php } ?> <a class="modal button pill" href="edit.php?modal=<?php echo $key; ?> &table=<?php echo $field_option['relational']["add_from_table"]; ?> &parent_table=<?php echo $_GET['table']; ?> ">Add New</a></span> <?php } elseif ($field_option['relational']["style"] == 'checkboxes_radios') { ////////////////////////////////////////////////////////////////////////////// // Checkboxes or Radio Buttons $multiple = $field_option['relational']["multiple"] ? 'checkbox' : 'radio'; $array_code = $field_option['relational']["multiple"] ? '[]' : ''; ?> <label class="primary" <?php echo $required != '' ? 'class="required_multi" require="' . $key . $array_code . '"' : ''; ?> ><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <?php while ($row_options = $sth->fetch()) { $option_value = $row_options[$field_option['relational']["value"]]; // Make visible option with multiple fields (field1,field2) $safe_value = str_replace('"', """, $option_value); unset($option_array); foreach ($option_fields as $temp) { $option_array[] = $row_options[$temp]; } if ($field_option['relational']["multiple"]) { $found = $value == $option_value ? 1 : strpos($value, "," . $option_value . ","); $selected = $found !== false ? 'checked="checked"' : ''; } else { $selected = $value == $option_value ? 'checked="checked"' : ''; } ?> <label class="multi_inputs"><input name="<?php echo $key . $array_code; ?> " value="<?php echo $safe_value; ?> " <?php echo $selected; ?> type="<?php echo $multiple; ?> "><?php echo implode($field_option['relational']["option_glue"], $option_array); ?> </label> <?php } } else { ////////////////////////////////////////////////////////////////////////////// // Default dropdown or multi-select list $multiple = $field_option['relational']["multiple"] ? 'multiple="multiple"' : ''; $array_code = $field_option['relational']["multiple"] ? '[]' : ''; ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <select name="<?php echo $key . $array_code; ?> " <?php echo $multiple; ?> class="<?php echo $required; ?> "> <?php if (!$field_option['relational']["multiple"]) { ?> <option value="NULL">Select One</option><?php } while ($row_options = $sth->fetch()) { $option_value = $row_options[$field_option['relational']["value"]]; // Make visible option with multiple fields (field1,field2) $safe_value = str_replace('"', """, $option_value); unset($option_array); foreach ($option_fields as $temp) { $option_array[] = $row_options[$temp]; } if ($field_option['relational']["multiple"]) { $found = $value == $option_value ? 1 : strpos($value, "," . $option_value . ","); $selected = $found !== false ? 'selected="selected"' : ''; } else { $selected = $value == $option_value ? 'selected="selected"' : ''; } ?> <option value="<?php echo $safe_value; ?> " <?php echo $selected; ?> ><?php echo implode($field_option['relational']["option_glue"], $option_array); ?> </option> <?php } ?> </select> <?php } } else { echo '<b class="warning">Error:</b> Update the options for this field on the <a class="warning" href="settings.php">settings page</a>.'; } } elseif ($field_format == 'media') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <table id="media_<?php echo $key; ?> " cellpadding="0" cellspacing="0" border="0" class="simple_sortable media_dropzone_target" parent_item="<?php echo $key; ?> " extensions="<?php echo $field_option['media']["extensions"]; ?> " media_type="relational"> <tbody class="check_no_rows"> <tr class="item no_rows"><td colspan="4">No media</td></tr> <?php $media_array = explode(',', $value); $media_array = array_filter($media_array); // Prepare the query once and run it for each media item // Reminder: This can be moved FURTHER up to before foreach to prepare only ONCE $sth = $dbh->prepare("SELECT * FROM `directus_media` WHERE `active` = '1' AND `id` = :id "); $sth->bindParam(':id', $media_id); foreach ($media_array as $media_id) { $sth->execute(); if ($media = $sth->fetch()) { ?> <tr class="item" replace_with="media_<?php echo $media_id; ?> "> <td class="order handle"><img src="media/site/icons/ui-splitter-horizontal.png" width="16" height="16" /></td> <td class="thumb"><?php generate_media_image($media['extension'], $media['source'], $media['height'], $media['width'], $media['file_size']); ?> </td> <td> <div class="wrap"> <?php echo $media['title']; ?> <input type="hidden" name="<?php echo $key; ?> []" value="<?php echo $media_id; ?> "> <a class="badge edit_fancy modal" href="inc/media_modal.php?type=relational&replace=true&parent_item=<?php echo $key; ?> &id=<?php echo $media['id']; ?> " style="display:none;">Edit</a> </div> </td> <td width="10%"><a tabindex="-1" class="ui-icon ui-icon-close right remove_media" href=""></a></td> </tr> <?php } } ?> </tbody> </table> <span class="fancy_new"> <a tabindex="-1" class="modal button pill" href="inc/media_modal.php?type=relational&parent_item=<?php echo $key; echo $field_option['media']["new_only"] ? '&new_only=true' : ''; echo $field_option['media']["extensions"] ? '&extensions=' . $field_option['media']["extensions"] : ''; ?> ">Add Media</a> <?php echo $field_option['media']["extensions"] ? ' <span class="note">(' . implode(' or ', array_filter(explode(',', str_replace(' ', '', strtolower($field_option['media']["extensions"]))))) . ')</span>' : ''; ?> </span> <?php } elseif ($field_format == 'options') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <?php $array_code = $field_option['options']["multiple"] ? '[]' : ''; // Get multiple options if ($field_option['options']["style"] != 'checkboxes_radios') { $select_code = 'selected="selected"'; $multiple = $field_option['options']["multiple"] ? 'multiple="multiple"' : ''; ?> <select name="<?php echo $key . $array_code; ?> " <?php echo $multiple; ?> class="<?php echo $required; ?> "> <?php } else { $select_code = 'checked="checked"'; $multiple = $field_option['options']["multiple"] ? 'checkbox' : 'radio'; } if (!$field_option['options']["multiple"]) { ?> <option value="NULL">Select One</option><?php } $option_array = array_filter(explode(',', $field_option['options']["values"])); foreach ($option_array as $option_value) { // Clean up the value a bit $option_value = trim($option_value); // Make safe the attribute value $safe_value = str_replace('"', """, $option_value); if ($field_option['options']["multiple"]) { $found = $value == $option_value ? 1 : strpos($value, "," . $option_value . ","); $selected = $found !== false ? $select_code : ''; } else { $selected = $value == $option_value ? $select_code : ''; } if ($field_option['options']["style"] == 'checkboxes_radios') { ?> <label class="multi_inputs"><input name="<?php echo $key . $array_code; ?> " value="<?php echo $safe_value; ?> " <?php echo $selected; ?> type="<?php echo $multiple; ?> "><?php echo $option_value; ?> </label><?php } else { ?> <option value="<?php echo $safe_value; ?> " <?php echo $selected; ?> ><?php echo $option_value; ?> </option><?php } } if ($field_option['options']["style"] != 'checkboxes_radios') { ?> </select><?php } } elseif ($field_format == 'tags') { $tags = explode(',', $value); $tags = array_filter($tags); ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input id="input_<?php echo $key; ?> " class="short_half tag_input <?php echo $field_option['tags']["autocomplete"] ? 'tag_autocomplete' : ''; ?> " type="text"> <input tabindex="-1" field="<?php echo $key; ?> " class="tag_add button pill" type="button" value="Add"> <input id="hidden_<?php echo $key; ?> " type="hidden" name="<?php echo $key; ?> " value="<?php echo esc_attr($value); ?> " class="<?php echo $required; ?> "> <div id="tags_<?php echo $key; ?> " class="tags_list clearfix"> <?php foreach ($tags as $tag_key => $tag_value) { ?> <span class="tag" tag="<?php echo $tag_value; ?> "><?php echo $tag_value; ?> <a class="tag_remove" tabindex="-1" href="#">×</a></span> <?php } ?> </div> <?php } elseif ($field_format == 'checkbox') { ?> <label class="primary" for="<?php echo $key; ?> "> <input name="<?php echo $key; ?> " type="checkbox" value="1" <?php echo $value == 1 ? 'checked="checked"' : ''; ?> > <?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <?php } elseif ($field['type_lengthless'] == 'date') { $value = $value ? $value : date('Y-m-d'); ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input name="<?php echo $key; ?> " value="<?php echo $value ? $value : date('Y-m-d'); ?> " maxlength="10" class="small short_10 text_center date datepicker <?php echo $required; ?> " type="text" size="10"> <?php } elseif ($field['type_lengthless'] == 'time') { $value = $value ? $value : date('h:i:s'); ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input name="<?php echo $key; ?> " value="<?php echo $value; ?> " maxlength="8" class="small short_8 text_center date <?php echo $required; ?> " type="text" size="10"> <?php } elseif ($field['type_lengthless'] == 'year') { $value = $value ? $value : date('Y'); ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input name="<?php echo $key; ?> " value="<?php echo $value; ?> " maxlength="4" class="small short_4 text_center year force_numeric <?php echo $required; ?> " type="text" size="10"> <?php } elseif ($field['type_lengthless'] == 'datetime') { $value_time = $value ? strtotime($value) : strtotime('now'); $month = date('m', $value_time); ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <div class="datetime_fields"> <select class="month"> <option value="01" <?php echo $month == '01' ? 'selected="selected"' : ''; ?> >Jan</option> <option value="02" <?php echo $month == '02' ? 'selected="selected"' : ''; ?> >Feb</option> <option value="03" <?php echo $month == '03' ? 'selected="selected"' : ''; ?> >Mar</option> <option value="04" <?php echo $month == '04' ? 'selected="selected"' : ''; ?> >Apr</option> <option value="05" <?php echo $month == '05' ? 'selected="selected"' : ''; ?> >May</option> <option value="06" <?php echo $month == '06' ? 'selected="selected"' : ''; ?> >Jun</option> <option value="07" <?php echo $month == '07' ? 'selected="selected"' : ''; ?> >Jul</option> <option value="08" <?php echo $month == '08' ? 'selected="selected"' : ''; ?> >Aug</option> <option value="09" <?php echo $month == '09' ? 'selected="selected"' : ''; ?> >Sep</option> <option value="10" <?php echo $month == '10' ? 'selected="selected"' : ''; ?> >Oct</option> <option value="11" <?php echo $month == '11' ? 'selected="selected"' : ''; ?> >Nov</option> <option value="12" <?php echo $month == '12' ? 'selected="selected"' : ''; ?> >Dec</option> </select> <input class="small short_1 text_center day force_numeric" type="text" size="2" maxlength="2" value="<?php echo date('j', $value_time); ?> ">, <input class="small short_4 text_center year force_numeric" type="text" size="4" maxlength="4" value="<?php echo date('Y', $value_time); ?> "> @ <input class="small short_1 text_center hour force_numeric" type="text" size="2" maxlength="2" value="<?php echo date('H', $value_time); ?> "> : <input class="small short_1 text_center minute force_numeric" type="text" size="2" maxlength="2" value="<?php echo date('i', $value_time); ?> "> : <input class="small short_1 text_center second force_numeric" type="text" size="2" maxlength="2" value="<?php echo date('s', $value_time); ?> "> <input class="small short_6 text_center datetime <?php echo $required; ?> " type="hidden" name="<?php echo $key; ?> " value="<?php echo $value ? $value : date('Y-m-j H:i:s', $value_time); ?> "> </div> <?php } elseif ($field_format == 'text_area') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <div class="textarea_format clearfix"> <ul> <li><a href="#" class="text_format_button" tabindex="-1" format="bold"><strong>Bold</strong></a></li> <li><a href="#" class="text_format_button" tabindex="-1" format="italic"><em>Italic</em></a></li> <li><a href="#" class="text_format_button" tabindex="-1" format="link">Link</a></li> <li><a href="#" class="text_format_button" tabindex="-1" format="mail">Mail</a></li> <li><a href="#" class="text_format_button" tabindex="-1" format="image">Insert Image</a></li> <li><a href="#" class="text_format_button" tabindex="-1" format="excerpt">Excerpt</a></li> <li><a href="#" class="text_format_button" tabindex="-1" format="blockquote">Blockquote</a></li> </ul> </div> <textarea class="textarea_formatted media_dropzone_target" parent_item="text_area_<?php echo $key; ?> " extensions="jpg,gif,png" media_type="inline" rows="<?php echo $field_option['text_area']["height"] ? $field_option['text_area']["height"] : '8'; ?> " id="text_area_<?php echo $key; ?> " name="<?php echo $key; ?> " class="<?php echo $required; ?> "><?php echo esc_attr(br2nl($value)); ?> </textarea> <?php } elseif ($field_format == 'table_view') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <textarea rows="4" id="text_area_<?php echo $key; ?> " name="<?php echo $key; ?> " class="<?php echo $required; ?> "><?php echo $value; ?> </textarea> <a tabindex="-1" class="edit_table_view button pill" csv-id="text_area_<?php echo $key; ?> " href="inc/edit_table.php">Edit in table view</a> <span class="note">You can always paste a CSV file above to start with</span> <?php } elseif ($field_format == 'short_name') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input class="track_max_length short_name <?php echo $required; ?> " short_name="<?php echo $field_option['short_name']["field"]; ?> " name="<?php echo $key; ?> " type="text" value="<?php echo esc_attr($value); ?> " maxlength="<?php echo $field['type_length']; ?> "> <span class="char_count"><?php echo $field['type_length'] - strlen($value); ?> </span> <?php } elseif ($field_format == 'numeric') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input class="track_max_length force_numeric <?php echo $required; ?> " name="<?php echo $key; ?> " type="text" value="<?php echo esc_attr($value); ?> " maxlength="<?php echo $field['type_length']; ?> "> <span class="char_count"><?php echo $field['type_length'] - strlen($value); ?> </span> <?php } elseif ($field_format == 'password') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input class="track_max_length <?php echo $required; ?> <?php echo $field_option['password']["unmask"] ? 'unmask' : ''; ?> " name="<?php echo $key; ?> " type="password" value="<?php echo esc_attr($value); ?> " maxlength="<?php echo $field['type_length']; ?> "> <span class="char_count"><?php echo $field['type_length'] - strlen($value); ?> </span> <?php } elseif ($field_format == 'password_confirm') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input class="track_max_length <?php echo $required; ?> " name="<?php echo $key; ?> " type="password" value="<?php echo esc_attr($value); ?> " maxlength="<?php echo $field['type_length']; ?> "> <span class="char_count"><?php echo $field['type_length'] - strlen($value); ?> </span> <?php } elseif ($field_format == 'color') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> # <input class="small short_6 text_center color_field <?php echo $required; ?> " name="<?php echo $key; ?> " type="text" value="<?php echo $value ? strtoupper(esc_attr($value)) : 'FFFFFF'; ?> " maxlength="6"> <span class="color_box" color_box="<?php echo $key; ?> " style="background-color:#<?php echo $value ? esc_attr($value) : 'FFFFFF'; ?> ;"></span> <?php } elseif ($field_format == 'histogram') { // Get highest value for this field across the table $histogram_table = get_rows_info($data['name']); $histogram_sql = $histogram_table['active'] == true ? "AND `active` = '1' " : ""; $sth = $dbh->query("SELECT max({$key}) as peak_amount FROM `" . $data['name'] . "` WHERE id != '" . $data['item_id'] . "' {$histogram_sql}"); $peak_amount = ($peak = $sth->fetch()) ? $peak["peak_amount"] : 0; ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input class="small short_6 force_numeric histogram <?php echo $required; ?> " name="<?php echo $key; ?> " type="text" value="<?php echo esc_attr($value); ?> " maxlength="<?php echo $field['type_length']; ?> "> <span class="histogram_bar" peak_amount="<?php echo $peak_amount; ?> "><span this_amount="<?php echo esc_attr($value); ?> "></span></span> <span title="<?php echo esc_attr($value) . '/' . $peak_amount; ?> " class="histogram_percent">0%</span> <?php } elseif ($field_format == 'rating') { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <div class="editable_rating"> <div class="rating_system" style="width:<?php echo 16 * $field_option['rating']["max"]; ?> px;"> <div class="rating_bar" style="width:<?php echo 16 * $value; ?> px;"> </div> <?php for ($i = 1; $i <= $field_option['rating']["max"]; $i++) { ?> <span class="star" alt="<?php echo $i; ?> " count="<?php echo $i; ?> "></span><?php } ?> </div> <input class="small short_2 text_center rating_input <?php echo $required; ?> " name="<?php echo $key; ?> " type="text" value="<?php echo esc_attr($value); ?> " maxlength="<?php echo $field['type_length']; ?> "> out of <?php echo $field_option['rating']["max"]; ?> </div> <?php } else { ?> <label class="primary" for="<?php echo $key; ?> "><?php echo uc_convert($key) . $required_mark; ?> </label> <?php echo $note; ?> <br> <input class="<?php echo $field_format == 'email' ? 'validate_email short_half' : ''; ?> <?php echo $field['type_length'] > 0 ? 'track_max_length' : ''; ?> <?php echo $required; ?> " name="<?php echo $key; ?> " type="<?php echo $field_format == 'email' ? 'email' : 'text'; ?> " value="<?php echo esc_attr($value); ?> " <?php echo $field['type_length'] > 0 ? 'maxlength="' . $field['type_length'] . '"' : ''; ?> > <?php if ($field['type_length'] > 0) { ?> <span class="char_count"><?php echo $field['type_length'] - strlen($value); ?> </span> <?php } ?> <?php } ?> </div> <?php } }
if (is_array($field_value)) { $field_value = va_date($date_edit_format, $field_value); } } else { if ($column_type == DATETIME) { $field_value = $db->f($column_name, DATETIME); if (is_array($field_value)) { $field_value = va_date($datetime_edit_format, $field_value); } } else { // check if it's a common field and we can get data directly from the record set if (isset($db_columns[$column_name]) || $related_column_name && isset($related_columns[$related_column_name])) { $field_value = $db->f($column_name); } else { // otherwise it's a custom field $field_value = get_field_value($column_name); } if ($apply_translation) { $field_value = get_translation($field_value); } } } } } } } } } } } }
function display_x_fields_data($adid, $single = true) { global $wpdb; $ad = AWPCP_Ad::find_by_id($adid); $fields = awpcp_get_extra_fields_by_category($ad->ad_category_id, array('hide_private' => true, 'context' => $single ? 'single' : 'listings')); $show_empty = get_awpcp_option('show-empty-extra-fields-in-ads'); $visible = array(); foreach ($fields as $i => $field) { $value = (array) get_field_value($adid, $field->field_name); if ($show_empty || !empty($value) && strlen($value[0]) > 0) { $visible[] = array('field' => $field, 'value' => $value); } } $allow_html_in_labels = get_awpcp_option('allow-html-in-extra-field-labels'); $count = count($visible); $columns = get_awpcp_option('display-extra-fields-in-columns', 1); $rows = ceil($count / $columns); $shown = 0; $classes = array('awpcp-extra-fields', 'awpcp-extra-fields-columns-' . $columns, 'clearfix'); $html = '<div class="' . join(' ', $classes) . '">'; foreach ($visible as $i => $data) { $field = $data['field']; $value = $data['value']; $classes = array('cladinfo', 'awpcp-extra-field-' . $field->field_name); $css = awpcp_get_grid_item_css_class($classes, $shown, $columns, $rows); $field_label = stripslashes($field->field_label_view); $field_label = $allow_html_in_labels ? $field_label : esc_html($field_label); if ($show_empty || !empty($value) && strlen($value[0]) > 0) { $html .= '<div class="' . esc_attr(join(' ', $css)) . '">'; $html .= '<label>' . $field_label . ':</label> '; if (count($value) > 1) { $html .= '<ul class="awpcp-extra-field-value-list">'; foreach ($value as $v) { $v = awpcp_extra_fields_render_field_single_value($field, $v); $html .= '<li>' . $v . '</li>'; } $html .= '</ul>'; } else { if (count($value) > 0) { $value = awpcp_extra_fields_render_field_single_value($field, $value[0]); if ($field->field_input_type === 'Textarea Input') { $html .= sprintf('<div class="awpcp-extra-field-value">%s</div>', $value); } else { $html .= sprintf('<span class="awpcp-extra-field-value">%s</span>', $value); } } } $html .= '</div>'; $shown++; } } $html .= '</div>'; return $html; }
function pmproan2c_update_fields_paypal_after_checkout($user_id) { global $current_user; $first_name = get_field_value("first_name"); $last_name = get_field_value("last_name"); $country = get_field_value("country"); $state = get_field_value("state"); $city = get_field_value("city"); $address = get_field_value("address"); $zipcode = get_field_value("zipcode"); $phone = get_field_value("phone"); $country_code = get_field_value("country_code"); update_user_meta($user_id, "first_name", $first_name); update_user_meta($user_id, "last_name", $last_name); update_user_meta($user_id, "country", $country); update_user_meta($user_id, "state", $state); update_user_meta($user_id, "city", $city); update_user_meta($user_id, "address", $address); update_user_meta($user_id, "zipcode", $zipcode); update_user_meta($user_id, "phone", $phone); update_user_meta($user_id, "country_code", $country_code); }
function get_edit_item_form($op, $item_r, $HTTP_VARS, &$upload_file_fields) { // is at least one field a compulsory field? $compulsory_fields = FALSE; $upload_file_fields = FALSE; $results = fetch_item_attribute_type_rs($item_r['s_item_type'], 'not_instance_field_types'); if ($results) { $formContents .= "\n<table>"; while ($item_attribute_type_r = db_fetch_assoc($results)) { if ($item_attribute_type_r['s_field_type'] == 'ITEM_ID') { continue; } // need to provide a proper encoded form if upload encountered, assume upload where file attribute encountered if ($item_attribute_type_r['file_attribute_ind'] == 'Y') { $upload_file_fields = TRUE; } if ($op == 'refresh' || $op == 'edit' || $op == 'newinstance') { if (is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) { $item_attribute_type_r['attribute_val'] = fetch_attribute_val_r($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); } else { $item_attribute_type_r['attribute_val'] = fetch_attribute_val($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); } } if ($op == 'refresh') { $old_value = get_old_field_value($item_r, $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val']); $new_value = get_field_value($op, $item_r, $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val'], $HTTP_VARS); // this represents multiple selections for a single value, lookup / multi value attributes will // be dealt with together. if (is_not_empty_array($new_value) && !is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) { foreach ($new_value as $key => $val) { $new_value[$key] = filter_item_input_field($item_attribute_type_r, $val); } } else { $new_value = filter_item_input_field($item_attribute_type_r, $new_value); // If no HTTP value, especially where FILE UPLOAD is being concerned, attempt to get from database again. if (($op == 'edit' || $op == 'newinstance') && $new_value === NULL) { $new_value = get_old_field_value($item_r, $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val']); } } } else { //if($op == 'refresh') $old_value = FALSE; $new_value = get_field_value($op, $item_r, $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val'], $HTTP_VARS); if (is_not_empty_array($new_value) && !is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) { foreach ($new_value as $key => $val) { $new_value[$key] = filter_item_input_field($item_attribute_type_r, $val); } } else { $new_value = filter_item_input_field($item_attribute_type_r, $new_value); // If no HTTP value, especially where FILE UPLOAD is being concerned, attempt to get from database again. if (($op == 'edit' || $op == 'newinstance') && $new_value === NULL) { $new_value = get_old_field_value($item_r, $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val']); } } } // Enforce compulsory indicator for TITLE. if ($item_attribute_type_r['s_field_type'] == 'TITLE') { $item_attribute_type_r['compulsory_ind'] = 'Y'; $override_title_articles_r = get_opendb_config_var('item_input', 'title_articles'); if (is_not_empty_array($override_title_articles_r)) { if (is_not_empty_array($new_value)) { foreach ($new_value as $key => $val) { $new_value[$key] = trim(format_title_grammar_article($val, $override_title_articles_r)); } } else { $new_value = trim(format_title_grammar_article($new_value, $override_title_articles_r)); } } } $formContents .= get_item_form_row($op, $item_r, $item_attribute_type_r, $old_value, $new_value); if ($item_attribute_type_r['compulsory_ind'] == 'Y') { $compulsory_fields = TRUE; } } //while db_free_result($results); $formContents .= "\n</table>"; $help_block_r = NULL; if ($op == 'refresh') { $help_block_r[] = array('img' => 'rs.gif', 'text' => get_opendb_lang_var('refreshed')); } $help_block_r[] = array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory'); $formContents .= format_help_block($help_block_r); return $formContents; } else { return FALSE; } }
function print_rows(&$members) { global $vars; global $db; $list = array(); //try to free memory // now we got list of customers // then create array with output records settype($vars['user_field'], 'array'); settype($vars['payment_field'], 'array'); settype($vars['product_name'], 'array'); $user_add_fields = array(); foreach ($vars['user_field'] as $k => $v) { if (preg_match('/^data\\.(.+)$/', $v, $regs)) { $user_add_fields[] = $regs[1]; } } $products = array(); foreach ($db->get_products_list() as $p) { $products[$p['product_id']] = $p['title']; } // print header foreach ($vars['user_field'] as $k) { print_header_item($GLOBALS['user_fields'][$k]); } $max = 1; if (!in_array($vars['multi_type'], array('discard', 'rows'))) { foreach ($members as $u) { if (count($u['PAYMENTS']) > $max) { $max = count($u['PAYMENTS']); } } } for ($i = 0; $i < $max; $i++) { foreach ($vars['payment_field'] as $k) { print_header_item($GLOBALS['payment_fields'][$k]); } } print "\n"; //-- switch ($vars['multi_type']) { case 'discard': foreach ($members as $u) { $o = array(); $u['name'] = $u['name_f'] . ' ' . $u['name_l']; foreach ($vars['user_field'] as $k) { if (strpos($k, "data.") !== 0) { $o[] = $u[$k]; } else { preg_match('/^data\\.(.+)$/', $k, $regs); $k2 = $regs[1]; $o[] = get_field_value($u['data'][$k2]); } } // foreach ($user_add_fields as $k) // $o[] = get_field_value($u['data'][$k]); foreach ((array) @$u['PAYMENTS'] as $p) { $p['product_name'] = $products[$p['product_id']]; foreach ($vars['payment_field'] as $k) { $o[] = $p[$k]; } break; } print_line($o); } break; case 'cols': foreach ($members as $u) { $o = array(); $u['name'] = $u['name_f'] . ' ' . $u['name_l']; foreach ($vars['user_field'] as $k) { if (strpos($k, "data.") !== 0) { $o[] = $u[$k]; } else { preg_match('/^data\\.(.+)$/', $k, $regs); $k2 = $regs[1]; $o[] = get_field_value($u['data'][$k2]); } } // foreach ($user_add_fields as $k) // $o[] = get_field_value($u['data'][$k]); foreach ($u['PAYMENTS'] as $p) { $p['product_name'] = $products[$p['product_id']]; foreach ($vars['payment_field'] as $k) { $o[] = $p[$k]; } } print_line($o); } break; case 'rows': foreach ($members as $u) { foreach ((array) @$u['PAYMENTS'] as $p) { $p['product_name'] = $products[$p['product_id']]; $u['name'] = $u['name_f'] . ' ' . $u['name_l']; $o = array(); foreach ($vars['user_field'] as $k) { if (strpos($k, "data.") !== 0) { $o[] = $u[$k]; } else { preg_match('/^data\\.(.+)$/', $k, $regs); $k2 = $regs[1]; $o[] = get_field_value($u['data'][$k2]); } } // foreach ($user_add_fields as $k) // $o[] = get_field_value($u['data'][$k]); foreach ($vars['payment_field'] as $k) { $o[] = $p[$k]; } print_line($o); } } break; } }