コード例 #1
0
function congregation_admin()
{
    ?>
<div class="wrap">
	<h2>Disciples Congregational Search
	<a href="#" class="add-new-h2" id="AddNewCongregation">Add New Congregation</a></h2>
	<div id="message" class="updated hidden"><p id="Message"></p><p id="Dismiss">[<a href="javascript:void(0);" id="DismissLink">Dismiss</a>]</p><div style="clear:both;"> </div> </div>
	<?php 
    // check for Google API
    $options = get_option('congregation_search_settings');
    if ($options['congregation_search_setting_APIKey'] == '') {
        ?>
			<div id="message" class="error"><p id="Message">A Google API Key for the Geolocation and the Google Mapping Javascript API (v3) is required. Please aquire a key and provide it in the "Settings" section before continuing.</p><div style="clear:both;"> </div> </div>
		<?php 
        return;
    }
    // check for an edit request
    $AdminAction = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    if ($AdminAction == 'edit') {
        $CongregationQueryStringPIN = intval($_GET['PIN']);
        if (is_int($CongregationQueryStringPIN)) {
            // show the edit form
            edit_congregation($CongregationQueryStringPIN);
        }
    } elseif ($AdminAction == 'save_congregation') {
        // save the posted congregational data
        save_congregation_form();
    } else {
        // show the basic search form
        echo init_congregation_search(true, '', false, 0);
    }
    ?>

	<div id="CongregationResult" style="display:none;">
		<h3 id="EditFormTitle">Edit Congregation</h3>
		<div class="congregation-edit-form">
			<div class="edit-form" style="width:49%;display:inline-block;">
				<form method="post" action="" id="editCongregationForm">
					<input type="hidden" id="SaveType" value="existing" />
					<input type="hidden" id="PIN" />
					<div class="congregation-pin">
						<label>PIN</label>
						<input type="text" disabled="true" id="CongregationPIN" required/>
					</div>
					<div class="congregation-name">
						<label for="CongregationName">Congregation Name</label>
						<input type="text" id="CongregationName" name="CongregationName" required/>
					</div>
					<div class="congregation-ein">
						<label for="EIN">EIN</label>
						<input type="text" id="EIN" name="EIN" />
					</div>
					<div class="congregation-address1">
						<label for="Address1">Address 1</label>
						<input type="text" id="Address1" name="Address1" required/>
					</div>
					<div class="congregation-address2">
						<label for="Address2">Address 2</label>
						<input type="text" id="Address2"  />
					</div>
					<div class="congregation-city">
						<label for="City">City</label>
						<input type="text" id="City" name="City" required />
					</div>
					<div class="congregation-state">
						<label for="State">State/Province</label>
						<?php 
    congregation_get_state_dropdown('State', '', '');
    ?>
					</div>
					<div class="congregation-postalcode">
						<label for="PostalCode">Postal Code</label>
						<input type="text" name="PostalCode" id="PostalCode" required />
					</div>
					<div class="congregation-phone">
						<label for="Phone">Phone</label>
						<input type="text" id="Phone"  />
					</div>
					<div class="congregation-email">
						<label for="Email">Email</label>
						<input type="text" id="Email" name="email" />
					</div>
					<div class="congregation-website">
						<label for="Website">Website</label>
						<input type="text" id="Website"  />
					</div>
					<div class="congregation-region">
						<label for="Region">Region</label>
						<input type="text" id="Region" />
					</div>
					<div><a href="javascript:void(0);" id="GeocodeAddress">Geocode the Address</a></div>
					<div class="congregation-latitude">
						<label for="Latitude">Latitude</label>
						<input type="text" id="Latitude"  />
					</div>
					<div class="congregation-longitude">
						<label for="Longitude">Longitude</label>
						<input type="text" id="Longitude"  />
					</div>
					<div class="congregation-donotautoupdate">
						<label for="DoNotAutoUpdate">Do not auto update</label>
						<input type="checkbox" id="DoNotAutoUpdate" />
						<span>When checked this will prevent automatic data updates from overwriting or deleting all current information about this congregation.</span>
					</div>
					<div class="congregation-savecancel-buttons">
						<a href="#" id="SaveEdit" class="button button-primary">Save Congregation</a>
						<a href="#" id="CancelEdit" class="secondary-button">Cancel</a> | 
						<a href="#" id="DeleteCongregation" class="secondary-button delete-button">Delete</a>
					</div>
				</form>
			</div>
			<div id="map-canvas" style="width:600px; height: 580px; display:inline-block;box-shadow: 3px 5px 10px rgba(0,0,0,0.2);"></div>
		</div>
		<script type="text/javascript">
		
			jQuery(document).ready(function(){ 
				jQuery("#editCongregationForm").validate({
					rules: {
						CongregationPIN: {
							required: true,
							number: true
						},
						CongregationName: "required",
						Address1: "required",
						City: "required",
						State: "required",
						PostalCode: "required",
						Email: {
							email: true
						}
					}
				}); 
			});
		</script> 
	</div>

</div>
	<?php 
}
コード例 #2
0
function Congregation_Search_fn($atts, $content)
{
    global $add_my_script;
    $add_my_script = true;
    $attribs = shortcode_atts(array('usemap' => 'true', 'paging_limit' => 0), $atts);
    $UseMap = true;
    $PagingLimit = 0;
    if (isset($attribs['usemap'])) {
        $UseMap = $attribs['usemap'];
    }
    if (isset($attribs['paging_limit'])) {
        $PagingLimit = intval($attribs['paging_limit']);
    }
    $results_template = '';
    // Check to make certain the required tokens are provided
    if (strpos($content, '{CONGREGATION_NAME}') !== false && strpos($content, '{LOOPTEMPLATE}') !== false && strpos($content, '{/LOOPTEMPLATE}') !== false) {
        // use the shortcode content as the template
        $results_template = $content;
    } else {
        // use the default template
        $results_template = '<h2>Found {RESULTS_COUNT} congregations...</h2>
		<table id="congregation-results"><tbody>
		{LOOPTEMPLATE}<tr>
<td class="congregation-name">{CONGREGATION_NAME}</td>
<td class="congregation-address">{ADDRESS1}<br/>{CITY}, {STATE} {POSTALCODE}<br/><a href="http://{WEBSITE}" target="_blank">{WEBSITE}</a></td>
<td class="congregation-distance">{DISTANCE}</td>
</tr>{/LOOPTEMPLATE}
		</tbody></table>';
    }
    // initialize search
    $ReturnResult = init_congregation_search(false, $results_template, $UseMap, $PagingLimit);
    return $ReturnResult;
}