web/wp-content/plugins/gigs-calendar/settings.ajax.php
branchwordpress
changeset 112 fb7cd02b9848
parent 111 6b96085291d7
child 123 561aa6d282f6
equal deleted inserted replaced
111:6b96085291d7 112:fb7cd02b9848
     1 <?php
       
     2 require_once 'ajaxSetup.php';
       
     3 
       
     4 $date_defaults = array(
       
     5 	'short' => 'm/d/y',
       
     6 	'archive' => 'm/d/y',
       
     7 	'long' => 'l, F j, Y',
       
     8 );
       
     9 
       
    10 
       
    11 switch ( $_POST['action'] ) :
       
    12 	case 'load':
       
    13 		$listFields = array(
       
    14 			'city' => __('City', $gcd),
       
    15 			'country' => __('Country', $gcd),
       
    16 			'venue' => __('Venue', $gcd),
       
    17 			'eventName' => __('Event Name', $gcd),
       
    18 			'date' => __('Date', $gcd),
       
    19 			'time' => __('Time', $gcd),
       
    20 			'shortNotes' => __('Short Notes', $gcd),
       
    21 			'tickets' => __('Ticket Link', $gcd),
       
    22 			'map' => __('Map Link', $gcd),
       
    23 		);
       
    24 		
       
    25 		$titleFields = array(
       
    26 			'city' => __('City', $gcd),
       
    27 			'venue' => __('Venue', $gcd),
       
    28 			'country' => __('Country', $gcd),
       
    29 			'eventName' => __('Event Name', $gcd),
       
    30 			'date' => __('Date', $gcd),
       
    31 		);
       
    32 		
       
    33 		$defaults = array(
       
    34 			'archive' => -1,
       
    35 			'category' => get_option('default_category'),
       
    36 			'no-upcoming' => __('Sorry, there aren&rsquo;t any upcoming gigs right now.  Check back soon!', $gcd),
       
    37 			'no-past' => __('There aren&rsquo;t any gigs here right now.  Check back soon!', $gcd),
       
    38 			'silk-link' => 1,
       
    39 			'b4b-link' => 1,
       
    40 			'rss-link' => 1,
       
    41 			'gigs-table-show' => array_keys($listFields),
       
    42 			'gig-title-show' => array('city', 'date'),
       
    43 			'eventName-label' => __("Who", $gcd),
       
    44 			'ages-list' => array(__('All Ages', $gcd), __('21+', $gcd), __('16+', $gcd)),
       
    45 			'list-venue-link' => 0,
       
    46 			'list-headers' => 0,
       
    47 			'template' => 'basic',
       
    48 			'time-12h' => 1,
       
    49 			'calendar-position' => "bottom",
       
    50 			'tbd-text' => __("TBD"),
       
    51 			'tours-display' => 0,
       
    52 			'tours-empty' => 0,
       
    53 			'tours-sort' => 'date',
       
    54 			'user_level' => 'level_5',
       
    55 			'post-filtering' => 1,
       
    56 			'admin-only-settings' => 0,
       
    57 		);
       
    58 		
       
    59 		unset($defaults['gigs-table-show'][array_search('eventName', $defaults['gigs-table-show'])]);
       
    60 		unset($defaults['gigs-table-show'][array_search('country', $defaults['gigs-table-show'])]);
       
    61 		
       
    62 		if ( is_array($options) ) {
       
    63 			$options = array_merge($defaults, $options);
       
    64 		} else {
       
    65 			$options = $defaults;
       
    66 		}
       
    67 		if ( is_array($options['date']) ) {
       
    68 			$options['date'] = array_merge($date_defaults, $options['date']);
       
    69 		} else {
       
    70 			$options['date'] = $date_defaults;
       
    71 		}
       
    72 		
       
    73 		if ( (int) get_option('gig_db_version') == -1 ) {
       
    74 			die (__('Oops! It looks like you&rsquo;re missing some or all of the tables required for this plugin.  They should have been created automatically, but you can create them with the tables.sql file in the same folder as this plugin.  If you have any questions, you can use the feedback form in the next tab.'));
       
    75 		}
       
    76 		?>
       
    77 			<?php if ( empty($options['parent']) && $options['calendar-position'] != 'custom' ) : ?>
       
    78 				<div><?php _e('You need to select a page to list your calendar.  You may need to go create a <a href="page-new.php">new page</a> first.', $gcd) ?></div>
       
    79 			<?php endif; ?>
       
    80 			<?php if ( 4.1 > mysql_get_server_info() ) : ?>
       
    81 				<div>
       
    82 					<?php _e('<span style="font-weight: bold">Warning:</span> You are running MySQL server version <?php echo mysql_get_server_info(); ?>.  This plugin requires version 4.1 or higher to hide the future gig posts from your homepage.  Your best option is to use a plugin like <a href="http://wordpress.org/extend/plugins/advanced-category-excluder/">Advanced Category Excluder</a> to hide the gigs using the category option below.'); ?>
       
    83 				</div>
       
    84 			<?php endif; ?>
       
    85 			<form id="settings-form" method="post">
       
    86 				<input type="hidden" name="nonce" value="<?php echo $_POST['nonce']; ?>" />
       
    87 				<input type="hidden" name="action" value="save" />
       
    88 				<h3><?php _e('General Options', $gcd) ?></h3>
       
    89 				<div><label>
       
    90 					<?php _e('Select a location for the calendars on the page:', $gcd) ?> 
       
    91 					<select name="calendar-position">
       
    92 						<option value="top" <?php if ( isset($options['calendar-position']) && $options['calendar-position'] == 'top') echo 'selected="selected"'; ?>><?php _e('Top', $gcd) ?></option>
       
    93 						<option value="bottom" <?php if ( isset($options['calendar-position']) && $options['calendar-position'] == 'bottom') echo 'selected="selected"'; ?>><?php _e('Bottom', $gcd) ?></option>
       
    94 						<option value="custom" <?php if ( isset($options['calendar-position']) && $options['calendar-position'] == 'custom') echo 'selected="selected"'; ?>><?php _e('Custom', $gcd) ?></option>
       
    95 					</select>
       
    96 				</label></div>
       
    97 				
       
    98 				<div><label>
       
    99 					<?php _e('Display gigs as normal blog posts (turns off filtering):', $gcd) ?> 
       
   100 					<select name="post-filtering">
       
   101 						<option value="0" <?php if ( isset($options['post-filtering']) && $options['post-filtering'] == '0') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   102 						<option value="1" <?php if ( isset($options['post-filtering']) && $options['post-filtering'] == '1') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   103 					</select>
       
   104 				</label></div>
       
   105 				
       
   106 				<div><?php _e('Note: If you select the custom location option, you don&rsquo;t have to select a page, but you won&rsquo;t get a link back to the calendar', $gcd); ?></div>
       
   107 				<div><label>
       
   108 					<?php _e('Select a page to house your calendar:', $gcd) ?> 
       
   109 					<?php wp_dropdown_pages('show_option_none=' . __('--None--', $gcd) . '&name=parent&selected=' . $options['parent']); ?>
       
   110 				</label></div>
       
   111 				
       
   112 				<div><label>
       
   113 					<?php _e('Select a page to house your gigs archive:', $gcd) ?> 
       
   114 					<?php wp_dropdown_pages('show_option_none=' . __('--None--', $gcd) . '&name=archive&selected=' . $options['archive']); ?>
       
   115 				</label></div>
       
   116 
       
   117 				<div><label>
       
   118 					<?php _e('Select a category that gigs should be created under:', $gcd) ?> 
       
   119 					<select name="category">
       
   120 						<?php foreach ( get_categories(array('hide_empty'=>false)) as $cat ) : ?>
       
   121 							<?php if ( (float) $wp_version < 2.3 ) : ?>
       
   122 								<option value="<?php echo $cat->cat_ID ?>" <?php if ( isset($options['category']) && $options['category'] == $cat->cat_ID) echo 'selected="selected"'; ?>><?php echo $cat->cat_name ?></option>
       
   123 							<?php else : ?>
       
   124 								<option value="<?php echo $cat->term_id ?>" <?php if ( isset($options['category']) && $options['category'] == $cat->term_id) echo 'selected="selected"'; ?>><?php echo $cat->name ?></option>
       
   125 							<?php endif; ?>
       
   126 						<?php endforeach; ?>
       
   127 					</select>
       
   128 				</label></div>
       
   129 				
       
   130 				<div><label>
       
   131 					<?php _e('Display this message if there are no upcoming gigs:', $gcd) ?><br />
       
   132 					<textarea rows="2" cols="50" name="no-upcoming"><?php echo $options['no-upcoming'] ?></textarea>
       
   133 				</label></div>
       
   134 				
       
   135 				<div><label>
       
   136 					<?php _e('Display this message if there are no past gigs:', $gcd) ?><br />
       
   137 					<textarea rows="2" cols="50" name="no-past"><?php echo $options['no-past'] ?></textarea>
       
   138 				</label></div>
       
   139 
       
   140 				<h3><?php _e('Administration Options', $gcd) ?></h3>
       
   141 				
       
   142 				<div><label>
       
   143 					<?php _e('Minimum permission level to administer the calendar: ', $gcd) ?> 
       
   144 					<select name="user_level">
       
   145 						<?php
       
   146 							$levels = array(
       
   147 								'level_0' => __('Subscriber', $gcd),
       
   148 								'level_1' => __('Contributor', $gcd),
       
   149 								'level_2' => __('Author', $gcd),
       
   150 								'level_5' => __('Editor', $gcd),
       
   151 								'level_8' => __('Administrator', $gcd),
       
   152 							);
       
   153 							foreach ( $levels as $level => $name ) {
       
   154 								?>
       
   155 									<option value="<?php echo $level; ?>" <?php if ( $options['user_level'] == $level) echo 'selected="selected"'; ?>><?php echo $name ?></option>
       
   156 								<?php
       
   157 							}
       
   158 						?>
       
   159 					</select>
       
   160 				</label></div>
       
   161 				
       
   162 				<div><label>
       
   163 					<?php _e('Only allow blog administrators to change calendar settings:', $gcd) ?> 
       
   164 					<select name="admin-only-settings">
       
   165 						<option value="1" <?php if ( isset($options['admin-only-settings']) && $options['admin-only-settings'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   166 						<option value="0" <?php if ( isset($options['admin-only-settings']) && $options['admin-only-settings'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   167 					</select>
       
   168 				</label></div>
       
   169 
       
   170 				
       
   171 				<h4><?php _e('Performances', $gcd) ?></h4>
       
   172 				<div><?php _e('Options you want in the "ages" dropdown.', $gcd) ?></div>
       
   173 				<ul id="ages-list" class="sortable">
       
   174 					<?php foreach ( $options['ages-list'] as $field ) : ?>
       
   175 						<li class="ages-list-item">
       
   176 							<input type="hidden" name="ages-list[]" value="<?php echo $field ?>" />
       
   177 							<img alt="<? _e('Delete', $gcd) ?>" title="<? _e('Delete', $gcd) ?>" class="delete icon clickable" src="<?php echo $folder ?>images/delete.png" />
       
   178 							<span class="handle name"><?php echo $field ?></span>
       
   179 						</li>
       
   180 					<?php endforeach; ?>
       
   181 				</ul>
       
   182 				<input type="text" id="new-age" /> <img src="<?php echo $folder ?>images/add.png" id="add-new-age" alt="<? _e('Add', $gcd) ?>" title="<? _e('Add', $gcd) ?>" />
       
   183 				
       
   184 				<h3><?php _e('Display Options', $gcd) ?></h3>
       
   185 				<div><label>
       
   186 					<?php _e('Display template: ', $gcd) ?> 
       
   187 					<select name="template">
       
   188 						<?php
       
   189 							$templates = array();
       
   190 							$template_dir = opendir(dirname(__FILE__) . '/templates');
       
   191 							while ( $dir = readdir($template_dir) ) {
       
   192 								if ( substr($dir, 0, 1) != '.' && is_dir(dirname(__FILE__) . '/templates/' . $dir) ) {
       
   193 									$templates[] = $dir;
       
   194 								}
       
   195 							}
       
   196 							
       
   197 							if ( file_exists(ABSPATH . 'wp-content/gigs-templates') ) {
       
   198 								$template_dir = opendir(ABSPATH . 'wp-content/gigs-templates');
       
   199 								while ( $dir = readdir($template_dir) ) {
       
   200 									if ( substr($dir, 0, 1) != '.' && is_dir(ABSPATH . 'wp-content/gigs-templates/' . $dir) ) {
       
   201 										$templates[] = $dir;
       
   202 									}
       
   203 								}
       
   204 							}
       
   205 							
       
   206 							sort($templates);
       
   207 							foreach ( $templates as $dir ) {
       
   208 								?>
       
   209 									<option <?php if ( $options['template'] == $dir) echo 'selected="selected"'; ?>><?php echo $dir ?></option>
       
   210 								<?php
       
   211 							}
       
   212 						?>
       
   213 					</select>
       
   214 				</label></div>
       
   215 				
       
   216 				<div><label>
       
   217 					<?php _e('Short date format:', $gcd) ?>
       
   218 					<input type="text" name="date-short" value="<?php if ( isset($options['date']['short']) ) dtcGigs::escapeForInput($options['date']['short']); ?>" />
       
   219 				</label> <?php _e('(uses PHP&rsquo;s <a href="http://php.net/date">date()</a> function format)', $gcd) ?></div>
       
   220 				<div><label>
       
   221 					<?php _e('Archives date format:', $gcd) ?>
       
   222 					<input type="text" name="date-archive" value="<?php if ( isset($options['date']['archive']) ) dtcGigs::escapeForInput($options['date']['archive']); ?>" />
       
   223 				</label> <?php _e('(uses PHP&rsquo;s <a href="http://php.net/date">date()</a> function format)', $gcd) ?></div>
       
   224 				
       
   225 				<div><label>
       
   226 					<?php _e('Long date format:', $gcd) ?>
       
   227 					<input type="text" name="date-long" value="<?php if ( isset($options['date']['long']) ) dtcGigs::escapeForInput($options['date']['long']); ?>" />
       
   228 				</label> <?php _e('(uses PHP&rsquo;s <a href="http://php.net/date">date()</a> function format)', $gcd) ?></div>
       
   229 				
       
   230 				<div><label>
       
   231 					<?php _e('Time format:', $gcd) ?> 
       
   232 					<select name="time-12h">
       
   233 						<option value="1" <?php if ( isset($options['time-12h']) && $options['time-12h'] == '1') echo 'selected="selected"'; ?>><?php _e('12 Hour', $gcd) ?></option>
       
   234 						<option value="0" <?php if ( isset($options['time-12h']) && $options['time-12h'] == '0') echo 'selected="selected"'; ?>><?php _e('24 Hour', $gcd) ?></option>
       
   235 					</select>
       
   236 				</label></div>
       
   237 				
       
   238 				<div><label>
       
   239 					<?php _e('Text to display when the time is "To be determined":', $gcd) ?>
       
   240 					<input type="text" name="tbd-text" value="<?php if ( isset($options['tbd-text']) ) dtcGigs::escapeForInput($options['tbd-text']); ?>" />
       
   241 				</label></div>
       
   242 
       
   243 				
       
   244 				<h4><?php _e('Gigs page table', $gcd) ?></h4>
       
   245 				<div><?php _e('You can sort the fields by clicking on the names and dragging.', $gcd) ?></div>
       
   246 				<ul id="gigs-table" class="sortable">
       
   247 					<?php if ( isset($options['gigs-table-show']) && is_array($options['gigs-table-show']) ) : ?>
       
   248 						<?php foreach ( $options['gigs-table-show'] as $field ) : ?>
       
   249 							<li class="gigs-table-cell">
       
   250 								<input type="checkbox" name="gigs-table-show[]" value="<?php echo $field ?>" checked="checked" />
       
   251 								<span class="handle name"><?php echo $listFields[$field] ?></span>
       
   252 							</li>
       
   253 						<?php endforeach; ?>
       
   254 					<?php endif ?>
       
   255 					<?php foreach ( $listFields as $key => $value ) : ?>
       
   256 						<?php if ( !isset($options['gigs-table-show']) || !is_array($options['gigs-table-show']) || !in_array($key, $options['gigs-table-show']) ) : ?>
       
   257 							<li class="gigs-table-cell">
       
   258 								<input type="checkbox" name="gigs-table-show[]" value="<?php echo $key ?>" />
       
   259 								<span class="handle name"><?php echo $value ?></span>
       
   260 							</li>
       
   261 						<?php endif; ?>
       
   262 					<?php endforeach; ?>
       
   263 				</ul>
       
   264 				<div><label>
       
   265 					<?php _e('Field to use for the link to the gig:', $gcd) ?> 
       
   266 					<select name="gig-link-field">
       
   267 						<?php foreach ( $listFields as $key => $value ) : ?>
       
   268 							<?php if ( !in_array($key, array('tickets', 'map', 'shortNotes')) ) : ?>
       
   269 								<option value="<?php echo $key ?>" <?php if ( isset($options['gig-link-field']) && $options['gig-link-field'] == $key) echo 'selected="selected"'; ?>><?php echo $value; ?></option>
       
   270 							<?php endif; ?>
       
   271 						<?php endforeach; ?>
       
   272 					</select>
       
   273 				</label></div>
       
   274 				
       
   275 				<div><label>
       
   276 					<?php _e('Link to the venue&rsquo;s website from the gig list?', $gcd) ?> 
       
   277 					<select name="list-venue-link">
       
   278 						<option value="1" <?php if ( isset($options['list-venue-link']) && $options['list-venue-link'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   279 						<option value="0" <?php if ( isset($options['list-venue-link']) && $options['list-venue-link'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   280 					</select>
       
   281 				</label></div>
       
   282 				
       
   283 				<div><label>
       
   284 					<?php _e('Display column headers?', $gcd) ?> 
       
   285 					<select name="list-headers">
       
   286 						<option value="1" <?php if ( isset($options['list-headers']) && $options['list-headers'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   287 						<option value="0" <?php if ( isset($options['list-headers']) && $options['list-headers'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   288 					</select>
       
   289 				</label></div>
       
   290 				
       
   291 				<div><label>
       
   292 					<?php _e('Link to Gigs RSS feed?', $gcd) ?> 
       
   293 					<select name="rss-link">
       
   294 						<option value="1" <?php if ( isset($options['rss-link']) && $options['rss-link'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   295 						<option value="0" <?php if ( isset($options['rss-link']) && $options['rss-link'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   296 					</select>
       
   297 				</label></div>
       
   298 				
       
   299 				<h4><?php _e('Single Gig Page', $gcd) ?></h4>
       
   300 				
       
   301 				<div><?php _e('Select and drag the fields for the gig post title.', $gcd) ?></div>
       
   302 				<ul id="gig-title" class="sortable">
       
   303 					<?php if ( isset($options['gig-title-show']) && is_array($options['gig-title-show']) ) : ?>
       
   304 						<?php foreach ( $options['gig-title-show'] as $field ) : ?>
       
   305 							<li class="gig-title-cell">
       
   306 								<input type="checkbox" name="gig-title-show[]" value="<?php echo $field ?>" checked="checked" />
       
   307 								<span class="handle name"><?php echo $titleFields[$field] ?></span>
       
   308 							</li>
       
   309 						<?php endforeach; ?>
       
   310 					<?php endif ?>
       
   311 					<?php foreach ( $titleFields as $key => $value ) : ?>
       
   312 						<?php if ( !isset($options['gig-title-show']) || !is_array($options['gig-title-show']) || !in_array($key, $options['gig-title-show']) ) : ?>
       
   313 							<li class="gig-title-cell">
       
   314 								<input type="checkbox" name="gig-title-show[]" value="<?php echo $key ?>" />
       
   315 								<span class="handle name"><?php echo $value ?></span>
       
   316 							</li>
       
   317 						<?php endif; ?>
       
   318 					<?php endforeach; ?>
       
   319 				</ul>
       
   320 
       
   321 				<div><label>
       
   322 					<?php _e('Label next to the event name:', $gcd) ?>
       
   323 					<input type="text" name="eventName-label" value="<?php if ( isset($options['eventName-label']) ) dtcGigs::escapeForInput($options['eventName-label']); ?>" />
       
   324 				</label></div>
       
   325 
       
   326 				<h4><?php _e('Tours Options', $gcd) ?></h4>
       
   327 				<div><label>
       
   328 					<?php _e('Do you want to split gigs by tour on your calendar page?', $gcd) ?>
       
   329 					<select name="tours-display">
       
   330 						<option value="1" <?php if ( isset($options['tours-display']) && $options['tours-display'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   331 						<option value="0" <?php if ( isset($options['tours-display']) && $options['tours-display'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   332 					</select>
       
   333 				</label></div>
       
   334 				
       
   335 				<div><label>
       
   336 					<?php _e('Do you want to display empty tours?', $gcd) ?>
       
   337 					<select name="tours-empty">
       
   338 						<option value="1" <?php if ( isset($options['tours-empty']) && $options['tours-empty'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   339 						<option value="0" <?php if ( isset($options['tours-empty']) && $options['tours-empty'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   340 					</select>
       
   341 				</label></div>
       
   342 				
       
   343 				<div><label>
       
   344 					<?php _e('How should the tours be ordered?', $gcd) ?>
       
   345 					<select name="tours-sort">
       
   346 						<option value="date" <?php if ( isset($options['tours-sort']) && $options['tours-sort'] == 'date') echo 'selected="selected"'; ?>><?php _e('Date of the earliest gig', $gcd) ?></option>
       
   347 						<option value="alpha" <?php if ( isset($options['tours-sort']) && $options['tours-sort'] == 'alpha') echo 'selected="selected"'; ?>><?php _e('Alphabetical', $gcd) ?></option>
       
   348 						<!--<option value="custom" <?php if ( isset($options['tours-sort']) && $options['tours-sort'] == 'custom') echo 'selected="selected"'; ?>><?php _e('Custom', $gcd) ?></option>-->
       
   349 					</select>
       
   350 				</label></div>
       
   351 
       
   352 
       
   353 				<h3><?php _e('Credits', $gcd) ?></h3>
       
   354 				<div><label>
       
   355 					<?php _e('Do you want to link back to me for building this plugin?', $gcd) ?>
       
   356 					<select name="b4b-link">
       
   357 						<option value="1" <?php if ( isset($options['b4b-link']) && $options['b4b-link'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   358 						<option value="0" <?php if ( isset($options['b4b-link']) && $options['b4b-link'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   359 					</select>
       
   360 				</label></div>
       
   361 				<div style="margin: 0px 1.5em 1em;">
       
   362 					<?php _e('<b>Note</b>: It&rsquo;s ok to say "no".  I&rsquo;ve offered this freely with no expectations, but I&rsquo;d be very grateful if you said "yes"', $gcd) ?>
       
   363 				</div>
       
   364 				
       
   365 				<div><label>
       
   366 					<?php _e('Do you want to link back to <a target="_blank" href="http://www.famfamfam.com/lab/icons/silk/">Mark James</a> for the Silk icons?', $gcd) ?>
       
   367 					<select name="silk-link">
       
   368 						<option value="1" <?php if ( isset($options['silk-link']) && $options['silk-link'] == '1') echo 'selected="selected"'; ?>><?php _e('Yes', $gcd) ?></option>
       
   369 						<option value="0" <?php if ( isset($options['silk-link']) && $options['silk-link'] == '0') echo 'selected="selected"'; ?>><?php _e('No', $gcd) ?></option>
       
   370 					</select>
       
   371 				</label></div>
       
   372 				<div style="margin: 0px 1.5em;">
       
   373 					<?php _e('<b>Note</b>: The Silk Icons that I used in this plugin are licensed under the <a target="_blank" href="http://creativecommons.org/licenses/by/2.5/">Creative Commons</a>. You must link back to him somewhere on your site.  If you link to him on another page, giving him credit, or you have replaced the icons, or you do not display any of them publicly on your site, you may turn off this link.', $gcd) ?></div>
       
   374 							
       
   375 				<br /><br />
       
   376 				<div>
       
   377 					<input type="submit" class="button" value="<?php _e('Save Options', $gcd) ?>" /><br />
       
   378 					<?php _e('If you made changes that would affect posts, do you want changes applied to existing gigs (possibly breaking existing links)?', $gcd); ?>
       
   379 					<select name="apply-changes">
       
   380 						<option value="no"><?php _e('No', $gcd); ?></option>
       
   381 						<option value="future"><?php _e('Yes, future gigs only', $gcd); ?></option>
       
   382 						<option value="all"><?php _e('Yes, all gigs, please', $gcd); ?></option>
       
   383 					</select>
       
   384 				</div>
       
   385 			</form>
       
   386 			
       
   387 			<script type="text/javascript">
       
   388 				(function($){
       
   389 					setupEvents = function() {
       
   390 						jQuery("#settings form").ajaxForm({
       
   391 							url:pageTarget,
       
   392 							success:function(){
       
   393 								if ( jQuery("#gigs-menu li").length == 3 ) {
       
   394 									window.location.reload();
       
   395 								} else {
       
   396 									gigs_page_load("settings");
       
   397 								}
       
   398 							}
       
   399 						});
       
   400 						
       
   401 
       
   402 						$("#gigs-table").sortable({
       
   403 							handle : "span.name",
       
   404 							axis:'y'
       
   405 						});
       
   406 						
       
   407 						$("#gig-title").sortable({
       
   408 							handle : "span.name",
       
   409 							axis:'y'
       
   410 						});
       
   411 						
       
   412 						$("#ages-list").sortable({
       
   413 							handle : "span.name",
       
   414 							axis:'y'
       
   415 						});
       
   416 						
       
   417 						$("#add-new-age").click(function(){
       
   418 							$("#ages-list").append('<li class="ages-list-item"><input type="hidden" value="' + $("#new-age").val() + '" name="ages-list[]"/><img src="http://dev.ssdn.us/wp-content/plugins/gigs-calendar/images/delete.png" class="delete icon clickable" title="Delete" alt="Delete"/> <span class="handle name" style="-moz-user-select: none;">' + $("#new-age").val() + '</span></li>');
       
   419 							$("#new-age").val("");
       
   420 							$(".ages-list-item").find(".delete").unbind("click");
       
   421 							$(".ages-list-item").find(".delete").click(function(){
       
   422 								$(this).parents("li.ages-list-item").remove();
       
   423 							});
       
   424 
       
   425 						});
       
   426 						
       
   427 						
       
   428 						$("#new-age").keypress(function(e){
       
   429 							if ( e.keyCode == 13 ) {
       
   430 								$("#add-new-age").click();
       
   431 								return false;
       
   432 							}
       
   433 						});
       
   434 						
       
   435 						$(".ages-list-item").find(".delete").click(function(){
       
   436 							$(this).parents("li.ages-list-item").remove();
       
   437 						});
       
   438 						
       
   439 						
       
   440 					}
       
   441 				}(jQuery));
       
   442 				
       
   443 				setTimeout("setupEvents();");
       
   444 			</script>
       
   445 			
       
   446 
       
   447 		<?php
       
   448 		break;
       
   449 	case 'save':
       
   450 		$args = $_POST;
       
   451 		
       
   452 		$dates = array(
       
   453 			'short' => (empty($args['date-short']) ? $date_defaults['short'] : $args['date-short']),
       
   454 			'archive' => (empty($args['date-archive']) ? $date_defaults['archive'] : $args['date-archive']),
       
   455 			'long' => (empty($args['date-long']) ? $date_defaults['long'] : $args['date-long']),
       
   456 		);
       
   457 		
       
   458 		unset($args['apply-changes'], $args['nonce'], $args['action'], $args['date-long'], $args['date-archive'], $args['date-short'], $args['long-date-format'], $args['short-date-format']);
       
   459 		
       
   460 		foreach ( $args as $key => $value ) {
       
   461 			if ( is_string($value) ) {
       
   462 				$args[$key] = stripslashes($value);
       
   463 			}
       
   464 		}
       
   465 		
       
   466 		$options = get_option('gigs-calendar');
       
   467 		if ( is_array($options) ) {
       
   468 			$args = array_merge($options, $args);
       
   469 		}
       
   470 		if ( is_array($args['date']) ) {
       
   471 			$args['date'] = array_merge($args['date'], $dates);
       
   472 		} else {
       
   473 			$args['date'] = $dates;
       
   474 		}
       
   475 
       
   476 		update_option('gigs-calendar', $args);
       
   477 		$options = get_option('gigs-calendar');
       
   478 		if ( $_POST['apply-changes'] != 'no' ) {
       
   479 			$g = new gig();
       
   480 			$g->search('future' == $_POST['apply-changes'] ? 'date >= CURDATE()' : null);
       
   481 			while ( $g->fetch() ) {
       
   482 				$g->save(false);
       
   483 			}
       
   484 		}
       
   485 		break;
       
   486 endswitch;
       
   487 
       
   488 ?>