</label><br />
				<?php 
_e('- OR -', 'adrotate');
?>
<br />
				<label for="adrotate_image_dropdown">
					<?php 
_e('Banner folder:', 'adrotate');
?>
 <select tabindex="5" name="adrotate_image_dropdown" style="min-width: 200px;">
   						<option value=""><?php 
_e('No image selected', 'adrotate');
?>
</option>
						<?php 
echo adrotate_folder_contents($image_dropdown);
?>
					</select><br />
				</label>
				<em><?php 
_e('Use %image% in the code. Accepted files are:', 'adrotate');
?>
 jpg, jpeg, gif, png, swf <?php 
_e('and', 'adrotate');
?>
 flv. <?php 
_e('Use either the text field or the dropdown. If the textfield has content that field has priority.', 'adrotate');
?>
</em>
			</td>
		</tr>
示例#2
0
function adrotate_edit()
{
    global $wpdb, $userdata;
    $thetime = current_time('timestamp');
    $message = $_GET['message'];
    if ($_GET['edit_banner']) {
        $banner_edit_id = $_GET['edit_banner'];
    }
    ?>

	<div class="wrap">
		<?php 
    if (!$banner_edit_id) {
        ?>
		<h2>Add banner</h2>
		<?php 
        $startshow = $thetime;
        $endshow = $thetime + 31536000;
    } else {
        ?>
		<h2>Edit banner</h2>
		<?php 
        $edit_banner = $wpdb->get_row("SELECT * FROM `" . $wpdb->prefix . "adrotate` WHERE `id` = '{$banner_edit_id}'");
        $startshow = $edit_banner->startshow;
        $endshow = $edit_banner->endshow;
    }
    list($sday, $smonth, $syear) = split(" ", gmdate("d m Y", $startshow));
    list($eday, $emonth, $eyear) = split(" ", gmdate("d m Y", $endshow));
    if ($message == 'no_access') {
        ?>
			<div id="message" class="updated fade"><p>Action prohibited.</p></div>
		<?php 
    } else {
        if ($message == 'updated') {
            ?>
			<div id="message" class="updated fade"><p>Banner <strong>updated</strong>.</p></div>
		<?php 
        } else {
            if ($message == 'field_error') {
                ?>
			<div id="message" class="updated fade"><p>Not all fields met the requirements.</p></div>
		<?php 
            } else {
                if ($message == 'reset') {
                    ?>
			<div id="message" class="updated fade"><p>banner statistics reset.</p></div>
		<?php 
                } else {
                    if ($message == 'renew') {
                        ?>
			<div id="message" class="updated fade"><p>banner renewed.</p></div>
		<?php 
                    }
                }
            }
        }
    }
    $groups = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "adrotate_groups` ORDER BY `id`");
    if ($groups) {
        ?>
		  	<form method="post" action="admin.php?page=adrotate3">
		    	<input type="hidden" name="adrotate_username" value="<?php 
        echo $userdata->display_name;
        ?>
" />
		    	<input type="hidden" name="adrotate_id" value="<?php 
        echo $banner_edit_id;
        ?>
" />

		    	<table class="widefat" style="margin-top: .5em">

					<thead>
					<tr valign="top">
						<th colspan="4" bgcolor="#DDD">Create your banner, all fields are required!</th>
					</tr>
					</thead>

					<tbody>
			      	<tr>
				        <th scope="row" width="25%">Title:</th>
				        <td colspan="3"><input tabindex="1" name="adrotate_title" type="text" size="67" class="search-input" autocomplete="off" value="<?php 
        echo $edit_banner->title;
        ?>
" /></td>
			      	</tr>
			      	<tr>
				        <th scope="row" width="25%">Code:</th>
				        <td colspan="3"><textarea tabindex="2" name="adrotate_bannercode" cols="70" rows="10"><?php 
        echo stripslashes($edit_banner->bannercode);
        ?>
</textarea>
				        <br /><em>Options: %id%<?php 
        if ($edit_banner->magic == 0) {
            ?>
, %image%, %link%<?php 
        }
        ?>
. HTML/JavaScript allowed, use with care!</em></td>
			      	</tr>
			      	<tr>
					    <th scope="row">Group:</th>
				        <td colspan="3">
				        <select tabindex="3" name='adrotate_group' id='cat' class='postform'>
						<?php 
        foreach ($groups as $group) {
            $class = 'alternate' != $class ? 'alternate' : '';
            ?>
						    <option value="<?php 
            echo $group->id;
            ?>
" <?php 
            if ($group->id == $edit_banner->group) {
                echo 'selected';
            }
            ?>
><?php 
            echo $group->id;
            ?>
 - <?php 
            echo $group->name;
            ?>
</option>
				    	<?php 
        }
        ?>
				    	</select>
						</td>
					</tr>
					</tbody>

					<thead>
					<tr valign="top">
						<th colspan="4" bgcolor="#DDD">Advanced (Everything below is optional)</th>
					</tr>
					</thead>

					<tbody>
			      	<tr>
				        <th scope="row">Display From:</th>
				        <td>
				        	<input tabindex="4" name="adrotate_sday" class="search-input" type="text" size="4" maxlength="2" value="<?php 
        echo $sday;
        ?>
" /> /
							<select tabindex="5" name="adrotate_smonth">
								<option value="01" <?php 
        if ($smonth == "01") {
            echo 'selected';
        }
        ?>
>January</option>
								<option value="02" <?php 
        if ($smonth == "02") {
            echo 'selected';
        }
        ?>
>February</option>
								<option value="03" <?php 
        if ($smonth == "03") {
            echo 'selected';
        }
        ?>
>March</option>
								<option value="04" <?php 
        if ($smonth == "04") {
            echo 'selected';
        }
        ?>
>April</option>
								<option value="05" <?php 
        if ($smonth == "05") {
            echo 'selected';
        }
        ?>
>May</option>
								<option value="06" <?php 
        if ($smonth == "06") {
            echo 'selected';
        }
        ?>
>June</option>
								<option value="07" <?php 
        if ($smonth == "07") {
            echo 'selected';
        }
        ?>
>July</option>
								<option value="08" <?php 
        if ($smonth == "08") {
            echo 'selected';
        }
        ?>
>August</option>
								<option value="09" <?php 
        if ($smonth == "09") {
            echo 'selected';
        }
        ?>
>September</option>
								<option value="10" <?php 
        if ($smonth == "10") {
            echo 'selected';
        }
        ?>
>October</option>
								<option value="11" <?php 
        if ($smonth == "11") {
            echo 'selected';
        }
        ?>
>November</option>
								<option value="12" <?php 
        if ($smonth == "12") {
            echo 'selected';
        }
        ?>
>December</option>
							</select> /
							<input tabindex="6" name="adrotate_syear" class="search-input" type="text" size="4" maxlength="4" value="<?php 
        echo $syear;
        ?>
" />
				        </td>
				        <th scope="row">Until:</th>
				        <td>
				        	<input tabindex="7" name="adrotate_eday" class="search-input" type="text" size="4" maxlength="2" value="<?php 
        echo $eday;
        ?>
"  /> /
							<select tabindex="8" name="adrotate_emonth">
								<option value="01" <?php 
        if ($emonth == "01") {
            echo 'selected';
        }
        ?>
>January</option>
								<option value="02" <?php 
        if ($emonth == "02") {
            echo 'selected';
        }
        ?>
>February</option>
								<option value="03" <?php 
        if ($emonth == "03") {
            echo 'selected';
        }
        ?>
>March</option>
								<option value="04" <?php 
        if ($emonth == "04") {
            echo 'selected';
        }
        ?>
>April</option>
								<option value="05" <?php 
        if ($emonth == "05") {
            echo 'selected';
        }
        ?>
>May</option>
								<option value="06" <?php 
        if ($emonth == "06") {
            echo 'selected';
        }
        ?>
>June</option>
								<option value="07" <?php 
        if ($emonth == "07") {
            echo 'selected';
        }
        ?>
>July</option>
								<option value="08" <?php 
        if ($emonth == "08") {
            echo 'selected';
        }
        ?>
>August</option>
								<option value="09" <?php 
        if ($emonth == "09") {
            echo 'selected';
        }
        ?>
>September</option>
								<option value="10" <?php 
        if ($emonth == "10") {
            echo 'selected';
        }
        ?>
>October</option>
								<option value="11" <?php 
        if ($emonth == "11") {
            echo 'selected';
        }
        ?>
>November</option>
								<option value="12" <?php 
        if ($emonth == "12") {
            echo 'selected';
        }
        ?>
>December</option>
							</select> /
							<input tabindex="9" name="adrotate_eyear" class="search-input" type="text" size="4" maxlength="4" value="<?php 
        echo $eyear;
        ?>
" />
						</td>
			      	</tr>
			      	<tr>
					    <th scope="row">Max Clicks:</th>
				        <td colspan="3">Disable after <input tabindex="10" name="adrotate_maxclicks" type="text" size="5" class="search-input" autocomplete="off" value="<?php 
        echo $edit_banner->maxclicks;
        ?>
" /> clicks! <em>Leave empty or 0 to skip this.</em></td>
					</tr>
			      	<tr>
					    <th scope="row">Max Shown:</th>
				        <td colspan="3">Disable after <input tabindex="11" name="adrotate_maxshown" type="text" size="5" class="search-input" autocomplete="off" value="<?php 
        echo $edit_banner->maxshown;
        ?>
" /> views! <em>Leave empty or 0 to skip this.</em></td>
					</tr>
				<?php 
        if ($edit_banner->magic == 0) {
            ?>
			      	<tr>
				        <th scope="row">Banner image:</th>
				        <td colspan="3"><select tabindex="12" name="adrotate_image" style="min-width: 200px;">
       						<option value="none">No image or remote</option>
							<?php 
            echo adrotate_folder_contents($edit_banner->image);
            ?>
						</select>
						<br /><em>Use %image% in the code. Accepted files are: jpg, jpeg, gif, png, swf and flv.</em></td>
			      	</tr>
			      	<tr>
				        <th scope="row" width="25%">Clicktracking:</th>
				        <td colspan="3">Enable? <input tabindex="13" type="checkbox" name="adrotate_tracker" <?php 
            if ($edit_banner->tracker == 'Y') {
                ?>
checked="checked" <?php 
            }
            ?>
 /> url: <input tabindex="14" name="adrotate_link" type="text" size="52" class="search-input" value="<?php 
            echo $edit_banner->link;
            ?>
" />
				        <br /><em>Use %link% in the code. Do not check the box if you cannot specify an url (eg, you do not use &lt;a href="http://somelink"&gt;).</em></td>
			      	</tr>
				<?php 
        }
        ?>
			      	<tr>
				        <th scope="row">Activate the banner:</th>
				        <td colspan="3"><select tabindex="15" name="adrotate_active">
						<?php 
        if ($edit_banner->active == "no") {
            ?>
						<option value="no">No! Do not show the banner anywhere.</option>
						<option value="yes">Yes! The banner will be shown at random intervals.</option>
						<?php 
        } else {
            ?>
						<option value="yes">Yes! The banner will be shown at random intervals.</option>
						<option value="no">No! Do not show the banner anywhere.</option>
						<?php 
        }
        ?>
						</select></td>
			      	</tr>
					</tbody>
				<?php 
        if ($banner_edit_id) {
            ?>
					<thead>
					<tr valign="top">
						<th colspan="4">Preview</th>
					</tr>
					</thead>

					<tbody>
			      	<tr>
				        <td colspan="4"><?php 
            echo adrotate_banner($edit_banner->group, $banner_edit_id, null, null, true);
            ?>
				        <br /><em>Note: While this preview is an accurate one, it might look different then it does on the website.
						<br />This is because of CSS differences. Your themes CSS file is not active here!</em></td>
			      	</tr>
			      	</tbody>

					<thead>
					<tr valign="top">
						<th colspan="4">Ad Code</th>
					</tr>
					</thead>

					<tbody>
			      	<tr>
				        <th>In a post or page:</th>
				        <td>[adrotate group="<?php 
            echo $edit_banner->group;
            ?>
" banner="<?php 
            echo $banner_edit_id;
            ?>
"]</td>
				        <th>Directly in a theme:</th>
				        <td>&lt;?php echo adrotate_banner('<?php 
            echo $edit_banner->group;
            ?>
', '<?php 
            echo $banner_edit_id;
            ?>
'); ?&gt;</td>
			      	</tr>
			      	<tr>
				        <th>&nbsp;</th>
				        <td>[adrotate group="<?php 
            echo $edit_banner->group;
            ?>
"]</td>
				        <th>&nbsp;</th>
				        <td>&lt;?php echo adrotate_banner('<?php 
            echo $edit_banner->group;
            ?>
'); ?&gt;</td>
			      	</tr>
			      	</tbody>

					<thead>
					<tr valign="top">
						<th colspan="4" bgcolor="#DDD">Statistics</th>
					</tr>
					</thead>

					<tbody>

			      	<tr>
				        <th scope="row">Added:</th>
				        <td width="25%"><?php 
            echo date("F d Y H:i", $edit_banner->thetime);
            ?>
</td>
				        <th scope="row">Updated:</th>
				        <td width="25%"><?php 
            echo date("F d Y H:i", $edit_banner->updated);
            ?>
</td>
			      	</tr>
			      	<tr>
				        <th scope="row">Clicked:</th>
				        <td width="25%"><?php 
            if ($edit_banner->tracker == "Y") {
                echo $edit_banner->clicks;
            } else {
                echo 'N/A';
            }
            ?>
</td>
				        <th scope="row">Shown:</th>
				        <td width="25%"><?php 
            echo $edit_banner->shown;
            ?>
</td>
			      	</tr>
			      	<tr>
				        <th scope="row">CTR:</th>
   						<?php 
            if ($banner->shown == 0) {
                $edit_banner->shown = 1;
            }
            ?>
				        <td width="25%"><?php 
            if ($edit_banner->tracker == "Y") {
                echo round(100 / $edit_banner->shown * $edit_banner->clicks, 2) . ' %';
            } else {
                echo 'N/A';
            }
            ?>
</td>
				        <th scope="row">Actions:</th>
				        <td width="25%"><input onclick="return confirm('You are about to reset the stats for this banner!\n\n\'OK\' to continue, \'Cancel\' to stop.')" type="submit" value="reset" name="adrotate_action" class="button-secondary delete" />
				        <input onclick="return confirm('Renew this banner for 1 more year?\n\n\'OK\' to continue, \'Cancel\' to stop.')" type="submit" value="renew" name="adrotate_action" class="button-secondary delete" /></td>
			      	</tr>
					</tbody>
				<?php 
        }
        ?>

				</table>

				<br class="clear" />
				<?php 
        adrotate_credits();
        ?>

		    	<p class="submit">
					<input tabindex="16" type="submit" name="adrotate_submit" class="button-primary" value="Save banner" />
					<a href="admin.php?page=adrotate" class="button">Cancel</a>
		    	</p>

		  	</form>
		<?php 
    } else {
        ?>
		    <table class="form-table">
		    	<thead>
				<tr valign="top">
					<th>Error!</th>
				</tr>
				</thead>

				<tbody>
		      	<tr>
			        <td>You should create atleast one group before adding banners! <a href="admin.php?page=adrotate4">Add a group now</a>.</td>
		      	</tr>
		      	</tbody>
			</table>
		<?php 
    }
    ?>
	</div>
<?php 
}