function amrical_choose_fields()
{
    global $amr_options;
    //$nonce = wp_create_nonce('amr-ical-events-list'); /* used for security to verify that any action request comes from this plugin's forms */
    amrical_admin_heading(__('Choose event and calendar fields ', 'amr-ical-events-list'));
    $inuse = amr_whats_in_use();
    $desc = amr_set_helpful_descriptions();
    if (isset($_POST['action']) and $_POST['action'] == "save") {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'amr-ical-events-list')) {
            die("Cancelled due to failed security check");
        }
        /* Validate the input and save */
        if (isset($_POST['reset'])) {
            echo '<div class="updated"><p>';
            _e('Resetting....', 'amr-ical-events-list');
            delete_option('amr-event-fields-in-use');
            echo '</p></div>';
            $inuse = amr_whats_in_use();
        } else {
            $inuse = amr_ical_validate_fields($inuse);
        }
    }
    array_multisort(array_values($inuse), SORT_DESC, array_keys($inuse), SORT_ASC, $inuse);
    //$fields - an array of fields used in a column
    echo '<p>' . __('Choose a subset of fields to work with:') . '</p>';
    echo '<div style="columns: 300px 2;">';
    foreach ($inuse as $f => $bool) {
        echo '<p><lable><input type="checkbox" name="inuse[' . $f . ']" ';
        if ($bool) {
            echo ' checked="checked" >';
        } else {
            echo '>';
        }
        echo '<b>' . $f . '</b> (' . $bool . 'x)';
        if (!empty($desc[$f])) {
            echo ' - <em>' . $desc[$f] . '</em>';
        }
        echo '</lable></p>';
    }
    amr_ical_submit_buttons(__('Reset', 'amr-ical-events-list'));
    echo '</div></form></div>';
}
Example #2
0
function amrical_compropsoption($i)
{
    global $amr_options;
    global $amr_csize;
    $inuse = amr_whats_in_use();
    $listtype = $amr_options['listtypes'][$i];
    $desc = amr_set_helpful_descriptions();
    echo '<fieldset id="comprop" class="props" >
		<h4 class="trigger"><a href="#">';
    _e('Specify fields to show:', 'amr-ical-events-list');
    echo '</a></h4>
		<div class="toggle_container"><p><em>';
    _e('Note: a 0 (zero) in column = do not show that field.', 'amr-ical-events-list');
    echo '</em></p><p><em>';
    _e('Uppercase fields are those defined in the iCal specification.', 'amr-ical-events-list');
    echo '</em>
		<a title="RFC5545" href="http://tools.ietf.org/html/rfc5545">RFC 5545</a></p>
		<p><em>';
    _e('Lowercase fields are additional fields added by this plugin and derived from the iCal fields for your convenience.', 'amr-ical-events-list');
    _e('Fields show if "column" > 0 and if there is data available in your event or ics file.', 'amr-ical-events-list');
    echo '</em></p>';
    echo '<table  class="widefat layout">';
    $thead = '<tr>' . '<th>' . __('Field', 'amr-ical-events-list') . '</th>' . '<th>' . __('Column', 'amr-ical-events-list') . '<br /><em>' . __('(0 to hide)', 'amr-ical-events-list') . '</em></th>' . '<th>' . __('Order', 'amr-ical-events-list') . '</th>' . '<th>' . __('Before', 'amr-ical-events-list') . '</th>' . '<th>' . __('After', 'amr-ical-events-list') . '</th>' . '</tr>';
    echo '<thead>' . $thead . '</thead>';
    echo '<tfoot>' . $thead . '</tfoot>';
    echo '<tbody>';
    $listtype['compprop'] = apply_filters('amr_ics_component_properties', $listtype['compprop']);
    // add arrays of field array('Column' => 0, 'Order' => 510, 'Before' => '', 'After' => '');
    foreach ($inuse as $f => $bool) {
        if (!isset($listtype['compprop'][$f])) {
            // we got a new field
            $listtype['compprop'][$f] = array('Column' => 0, 'Order' => 510, 'Before' => '', 'After' => '');
        }
    }
    foreach ($listtype['compprop'] as $p => $pv) {
        /* for each specification, eg: p= SUMMARY  */
        if (!empty($inuse[$p])) {
            $text = '<em class="desc">' . (!empty($desc[$p]) ? $desc[$p] : '') . '</em>';
            echo "\n\t\t" . '<tr style="border-bottom: 0; "><td style="border-bottom: 0; "><b>' . $p . '</b></th>';
            foreach ($pv as $s => $sv) {
                /* for each specification eg  $s = column*/
                echo '<td style="border-bottom: 0; ">' . '<input type="text" size="' . $amr_csize[$s] . '"  class="' . $s . '"  id="' . $p . $s . '"  name="' . 'ComP[' . $p . '][' . $s . ']"  value= "' . htmlspecialchars($sv) . '"  />' . '</td>';
            }
            echo '</tr><tr ><td colspan="5" style="padding: 0 20px 20px; 0" >' . $text . '</td></tr>';
            echo "\n\t\t" . '</fieldset> <!-- end of layout -->';
        }
    }
    echo "\n" . '</tbody></table></div></fieldset>  <!-- end of compprop -->';
    return;
}