function amrmeta_listfields($listindex = 1) { global $aopt; global $amain; global $amr_nicenames, $excluded_nicenames, $ausersadminurl; $linktypes = amr_linktypes(); /* check if we have some options already in Database. - use their names, if not, use default, else overwrite .*/ if (!($checkifusingdefault = ausers_get_option('amr-users-nicenames')) or empty($amr_nicenames)) { //$text = __('Possible fields not configured! default list being used. Please build complete nicenames list.','amr-users'); amrmeta_check_find_fields(); exit; } $config =& $aopt['list'][$listindex]; $sel =& $config['selected']; /* sort our controlling index by the selected display order for ease of viewing */ foreach ($amr_nicenames as $i => $n) { if (isset($config['selected'][$i]) or isset($config['sortby'][$i]) or isset($config['included'][$i]) or isset($config['includeonlyifblank'][$i]) or isset($config['excluded'][$i]) or isset($config['excludeifblank'][$i]) or isset($config['sortdir'][$i])) { $keyfields[$i] = $i; } } if (isset($keyfields)) { $nicenames = auser_sortbyother($amr_nicenames, $keyfields); } else { $nicenames = $amr_nicenames; } if (count($sel) > 0) { uasort($sel, 'amr_usort'); $nicenames = auser_sortbyother($nicenames, $sel); /* sort for display with the selected fields first */ } echo '<br /><p class="clear"><input id="submit" class="button-primary" type="submit" name="updateoverview" value="'; _e('Update overview settings', 'amr-users'); echo '" />' . ' <a href="' . wp_nonce_url($ausersadminurl . '?page=ameta-admin-general.php&tab=overview', 'amr-meta') . '" title="' . __('Go to overview of all lists', 'amr-users') . '" >' . __('Manage lists', 'amr-users') . '</a>' . ' | <a href="' . wp_nonce_url($ausersadminurl . '?page=ameta-admin-general.php&tab=fields', 'amr-meta') . '" title="' . __('Find Fields (must have sample data in them)', 'amr-users') . '" >' . __('Find Fields', 'amr-users') . '</a>' . '</p>'; amr_meta_overview_onelist_headings(); amr_meta_overview_onelist_headings_middle(); amr_meta_overview_onelist_settings($listindex); amr_meta_overview_onelist_headings_end(); echo '<br /><br />'; echo PHP_EOL . '<div class="wrap">' . PHP_EOL . '<input id="submit" class="button-primary" type="submit" name="update" value="'; _e('Update field settings', 'amr-users'); echo '" /> '; amr_userlist_submenu($listindex); echo '<br />'; echo PHP_EOL . '<div class="clear userlistfields">'; echo '<table class="widefat" style="padding-right: 2px;"><thead style="text-align:center;"><tr>' . PHP_EOL . '<th style="text-align:right;">' . __('Field name', 'amr-users') . '</th>' . PHP_EOL . '<th style="width:1em;"><a href="#" title="' . __('Blank to hide, Enter a number to select and specify column order. Eg: 1 2 6 8', 'amr-users') . '"> ' . __('Display order', 'amr-users') . '</a></th>' . PHP_EOL . '<th><a href="#" title="' . __('Html to appear before if there is a value', 'amr-users') . '"> ' . __('Before:', 'amr-users') . '</a></th>' . PHP_EOL . '<th><a href="#" title="' . __('Html to appear after if there is a value', 'amr-users') . '"> ' . __('After:', 'amr-users') . '</a></th>' . PHP_EOL . '<th style="width:2em;"><a href="#" title="' . __('Type of link to be generated on the field value', 'amr-users') . '"> ' . __('Link Type:', 'amr-users') . '</a></th>' . PHP_EOL . '<th><a href="#" title="' . __('Eg: value1,value2', 'amr-users') . '"> ' . __('Include:', 'amr-users') . '</a></th>' . PHP_EOL . '<th><a href="#" title="' . __('Tick to include a user ONLY if there is no value', 'amr-users') . '"> ' . __('Include ONLY if Blank:', 'amr-users') . '</a></th>' . PHP_EOL . '<th><a href="#" title="' . __('Eg: value1,value2.', 'amr-users') . ' ' . __('Display the field to set up the exclusion, then you can undisplay it afterwards.', 'amr-users') . '"> ' . __('But Exclude:', 'amr-users') . '</a></th>' . PHP_EOL . '<th><a href="#" title="' . __('Tick to exclude a user if there is no value', 'amr-users') . '"> ' . __('Exclude if Blank:', 'amr-users') . '</a></th>' . PHP_EOL . '<th style="width:1em;"><a href="#" title="' . __('Enter integers, need not be contiguous', 'amr-users') . ' ' . __('Maximum 2 sort level. Can switch off display.', 'amr-users') . '"> ' . __('Sort Order:', 'amr-users') . '</a></th>' . PHP_EOL . '<th style="width:2em;"><a href="#" title="' . __('For sort order. Default is ascending', 'amr-users') . '"> ' . __('Sort Descending:', 'amr-users') . '</a></th>' . PHP_EOL . '</tr></thead><tbody>'; foreach ($nicenames as $i => $f) { /* list through all the possible fields*/ echo PHP_EOL . '<tr>'; $l = 'l' . $listindex . '-' . $i; if ($i === 'comment_count') { $f .= '<a title="' . __('Explanation of comment total functionality', 'amr-users') . '" href="http://wpusersplugin.com/comment-totals-by-authors/">**</a>'; } echo '<td style="text-align:right;">' . $f . '</td>'; echo '<td><input type="text" size="1" id="' . $l . '" name="list[' . $listindex . '][selected][' . $i . ']"' . ' value="'; if (isset($sel[$i]) or !empty($config['included'][$i]) or !empty($config['excluded'][$i]) or !empty($config['excludeifblank'][$i]) or !empty($config['includeonlyifblank'][$i]) or !empty($config['sortby'][$i]) or !empty($config['sortdir'][$i])) { if (isset($sel[$i])) { echo $sel[$i]; } echo '" /></td>'; if (!empty($sel[$i])) { /* don't need label - use previous lable*/ echo '<td><input type="text" size="10" name="list[' . $listindex . '][before][' . $i . ']"'; if (isset($config['before'][$i])) { echo ' value="' . stripslashes($config['before'][$i]) . '"'; } //handle slashes returned by quotes echo ' /></td>'; // do not use htmlentities2 here - break foreigh chars echo '<td><input type="text" size="10" name="list[' . $listindex . '][after][' . $i . ']"'; if (isset($config['after'][$i])) { echo ' value="' . stripslashes($config['after'][$i]) . '"'; } echo ' /></td>'; } else { echo '<td>-</td><td>-</td>'; } if (isset($sel[$i]) and !strpos($sel[$i], '.')) { // if not a partial cell, then can have link type //if (isset($sel[$i]) and !strpos($sel[$i],'.')) { echo '<td><select id="links' . $l . '" ' . ' name="list[' . $listindex . '][links][' . $i . ']" >'; foreach ($linktypes as $lti => $linktype) { echo ' <option value="' . $lti . '" '; if (!empty($config['links'][$i]) and $config['links'][$i] === $lti) { echo ' selected = "selected" '; } echo ' >' . $linktype . '</option>'; } echo '</select></td>'; } else { echo '<td>-</td>'; } // echo '<td><select name="list['.$listindex.'][included]['.$i.']"'; // echo amr_users_dropdown ($choices, $config['included'][$i]); // echo '</select>'; echo '<td><input type="text" size="20" name="list[' . $listindex . '][included][' . $i . ']"'; if (isset($config['included'][$i])) { echo ' value="' . implode(',', $config['included'][$i]) . '"'; } echo ' /></td>'; $l = 'c' . $listindex . '-' . $i; echo '<td><input type="checkbox" name="list[' . $listindex . '][includeonlyifblank][' . $i . ']"'; if (isset($config['includeonlyifblank'][$i])) { echo ' checked="checked" />'; if (isset($config['excludeifblank'][$i])) { /* check for inconsistency and flag */ echo '<span style="color:#D54E21; font-size:larger;">*</span>'; } } else { echo '/>'; } echo '</td>'; $l = 'x' . $listindex . '-' . $i; echo '<td><input type="text" size="20" id="' . $l . '" name="list[' . $listindex . '][excluded][' . $i . ']"'; if (isset($config['excluded'][$i])) { if (is_array($config['excluded'][$i])) { $val = implode(',', $config['excluded'][$i]); } else { $val = $config['excluded'][$i]; } echo ' value="' . $val . '"'; } echo ' /></td>'; $l = 'b' . $listindex . '-' . $i; echo '<td><input type="checkbox" id="' . $l . '" name="list[' . $listindex . '][excludeifblank][' . $i . ']"'; if (isset($config['excludeifblank'][$i])) { echo ' checked="checked" />'; if (isset($config['includeonlyifblank'][$i])) { /* check for inconsistency and flag */ echo '<span style="color:#D54E21; font-size:larger;">*</span>'; } } else { echo '/>'; } echo '</td>'; $l = 's' . $listindex . '-' . $i; echo '<td>' . '<input type="text" size="2" id="' . $l . '" name="list[' . $listindex . '][sortby][' . $i . ']"'; if (isset($config['sortby'][$i])) { echo ' value="' . $config['sortby'][$i] . '"'; } echo ' /></td>' . '<td><input type="checkbox" id="sd' . $l . '" name="list[' . $listindex . '][sortdir][' . $i . ']"'; echo ' value="SORT_DESC"'; if (isset($config['sortdir'][$i])) { echo ' checked="checked"'; } echo ' />' . '</td>'; } else { echo '" /></td>'; echo '<td> - </td>' . '<td> - </td>' . '<td> - </td>' . '<td> - </td>' . '<td> - </td>' . '<td> - </td>' . '<td> - </td>' . '<td> - </td>' . '<td> - </td>'; } echo '</tr>'; } echo PHP_EOL . '</tbody></table>'; echo PHP_EOL . '</div><!-- end userlistfield -->'; echo PHP_EOL . '</div><!-- end wrap -->'; return; }
function amr_meta_nice_names_page() { /* may be able to work generically */ global $amr_nicenames; global $ausersadminurl; //amr_meta_main_admin_header('Find fields, make nice names' ); amr_meta_admin_headings($plugin_page = ''); // does the nonce check etc if (isset($_POST['action']) and !($_POST['action'] === "save")) { return; } echo PHP_EOL . '<div class="clear" style="clear:both;"> </div>' . PHP_EOL; if (isset($_POST['update']) and $_POST['update'] === "Update") { /* Validate the input and save */ if (amrmeta_validate_nicenames()) { // updates inside the function now } else { echo '<h2>' . __('Validation failed', 'amr-users') . '</h2>'; } } if (isset($_POST['resetnice'])) { delete_option('amr-users-nicenames'); // delete then rebuild } if (isset($_POST['rebuild']) or isset($_POST['resetnice'])) { /* Rebuild the nicenames - could take a while */ $amr_nicenames = ameta_rebuildnicenames(); echo '<h3>' . __('Rebuild Complete.', 'amr-users') . '</h3>'; return; } else { amrmeta_check_find_fields(); } echo alist_rebuild_names_update(); ameta_list_nicenames_for_input($amr_nicenames); }