<?php /** * Template Name: Faves **/ get_header(); $faves = new FavesAdmin(); if (is_user_logged_in()) { if ('sort' == $_REQUEST['action']) { $faves->sort($_REQUEST); } } ?> <!-- content --> <div id="content"> <?php if (have_posts()) { ?> <?php while (have_posts()) { the_post(); ?> <!-- page --> <div class="page"> <h1><?php the_title();
/** * The admin menu for our faves system */ function favesMenu() { if (isset($_GET['page']) && $_GET['page'] == basename(__FILE__)) { if (isset($_POST['action'])) { switch ($_POST['action']) { case 'add': FavesAdmin::add($_REQUEST); break; case 'edit': FavesAdmin::edit($_REQUEST); break; case 'delete': FavesAdmin::burninate($_REQUEST['id']); break; case 'install': FavesAdmin::install(); break; default: break; } } } ?> <?php if (isset($_REQUEST['add'])) { ?> <div id="message" class="updated fade"><p><strong><?php echo __('Fave saved.'); ?> </strong></p></div> <?php } ?> <div class="wrap"> <div id="admin-options"> <h2><?php _e('Manage My Faves'); ?> </h2> <?php if (FavesAdmin::check() == true && FavesAdmin::count() != '') { ?> <table class="form-table" style="margin-bottom:30px;"> <tr> <th>Title</th> <th style="text-align:center;">Feed</th> <th style="text-align:center;" colspan="2">Actions</th> </tr> <?php foreach (FavesAdmin::collect() as $fave) { ?> <tr> <td><?php echo $fave->title; ?> </td> <td style="text-align:center;"><a href="<?php echo $fave->feed_url; ?> " title="<?php echo $fave->feed_url; ?> "><img src="<?php bloginfo('template_directory'); ?> /images/icon-feed.gif" alt="View"/></a></td> <td style="text-align:center;"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=<?php echo $this->filename; ?> &gather=true&id=<?php echo $fave->id; ?> "> <?php wp_nonce_field('wicketpixie-settings'); ?> <input type="submit" value="Edit" /> <input type="hidden" name="action" value="gather" /> </form> </td> <td style="text-align:center;"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=<?php echo $this->filename; ?> &delete=true&id=<?php echo $fave->id; ?> "> <?php wp_nonce_field('wicketpixie-settings'); ?> <input type="submit" name="action" value="Delete" /> <input type="hidden" name="action" value="delete" /> </form> </td> </tr> <?php } ?> </table> <?php } else { ?> <p>You don't have any Favorites, why not add some?</p> <?php } ?> <?php if (isset($_REQUEST['gather'])) { ?> <?php $data = FavesAdmin::gather($_REQUEST['id']); ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=<?php echo $this->filename; ?> &edit=true"> <?php wp_nonce_field('wicketpixie-settings'); ?> <h2>Editing "<?php echo $data[0]->title; ?> "</h2> <p><input type="text" name="title" id="title" value="<?php echo $data[0]->title; ?> " /></p> <p><input type="text" name="url" id="url" value="<?php echo $data[0]->feed_url; ?> " /></p> <p class="submit"> <input name="save" type="submit" value="Save Changes" /> <input type="hidden" name="action" value="edit" /> <input type="hidden" name="id" value="<?php echo $data[0]->id; ?> "> </p> </form> <?php } ?> <?php if (FavesAdmin::check() == true && !isset($_REQUEST['gather'])) { ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=<?php echo $this->filename; ?> &add=true" class="form-table"> <?php wp_nonce_field('wicketpixie-settings'); ?> <h2>Add a New Fave</h2> <p><input type="text" name="title" id="title" onfocus="if(this.value=='Fave Title')value=''" onblur="if(this.value=='')value='Fave Title';" value="Fave Title" /></p> <p><input type="text" name="url" id="url" onfocus="if(this.value=='Fave Feed URL')value=''" onblur="if(this.value=='')value='Fave Feed URL';" value="Fave Feed URL" /></p> <p class="submit"> <input name="save" type="submit" value="Add Fave" /> <input type="hidden" name="action" value="add" /> </p> </form> <?php } else { ?> <h2>Install the Faves table</h2> <p>Before you can add Faves, you must install the table first:</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=<?php echo $this->filename; ?> &install=true"> <p class="submit"> <input name="save" type="submit" value="Install Faves" /> <input type="hidden" name="action" value="install" /> </p> </form> <?php } ?> </div> <?php include_once 'advert.php'; }
?> "> <input type="hidden" name="action" value="sort"> <input type="hidden" name="id" value="<?php echo $fave->id; ?> "> <strong>Current Place: <?php echo $fave->sortorder; ?> </strong> | New Place <select name="newsort" id="newsort-<?php echo $fave->id; ?> "> <?php foreach (FavesAdmin::positions() as $place) { ?> <option value="<?php echo $place->sortorder; ?> "><?php echo $place->sortorder; ?> </option> <?php } ?> </select> <input type="submit" value="Sort" /> </form> <?php
/** * The admin menu for our faves system */ function favesMenu() { $faves = new FavesAdmin(); if ($_GET['page'] == basename(__FILE__)) { if ('add' == $_REQUEST['action']) { $faves->add($_REQUEST); } if ('edit' == $_REQUEST['action']) { $faves->edit($_REQUEST); } if ('delete' == $_REQUEST['action']) { $faves->burninate($_REQUEST['id']); } } ?> <?php if (isset($_REQUEST['add'])) { ?> <div id="message" class="updated fade"><p><strong><?php echo __('Fave saved.'); ?> </strong></p></div> <?php } ?> <div class="wrap"> <div id="admin-options"> <h2><?php _e('Manage My Faves'); ?> </h2> <?php if ($faves->check() != 'false' && $faves->count() != '') { ?> <table class="form-table" style="margin-bottom:30px;"> <tr> <th>Title</th> <th style="text-align:center;">Feed</th> <th style="text-align:center;" colspan="2">Actions</th> </tr> <?php foreach ($faves->collect() as $fave) { ?> <tr> <td><?php echo $fave->title; ?> </td> <td style="text-align:center;"><a href="<?php echo $fave->feed_url; ?> " title="<?php echo $fave->feed_url; ?> "><img src="<?php bloginfo('template_directory'); ?> /images/icon-feed.gif" alt="View"/></a></td> <td style="text-align:center;"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=faves.php&gather=true&id=<?php echo $fave->id; ?> "> <input type="submit" value="Edit" /> <input type="hidden" name="action" value="gather" /> </form> </td> <td style="text-align:center;"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=faves.php&delete=true&id=<?php echo $fave->id; ?> "> <input type="submit" name="action" value="Delete" /> <input type="hidden" name="action" value="delete" /> </form> </td> </tr> <?php } ?> </table> <?php } else { ?> <p>You don't have any Favorites, why not add some?</p> <?php } ?> <?php if (isset($_REQUEST['gather'])) { ?> <?php $data = $faves->gather($_REQUEST['id']); ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=faves.php&edit=true"> <h2>Editing "<?php echo $data[0]->title; ?> "</h2> <p><input type="text" name="title" id="title" value="<?php echo $data[0]->title; ?> " /></p> <p><input type="text" name="url" id="url" value="<?php echo $data[0]->feed_url; ?> " /></p> <p class="submit"> <input name="save" type="submit" value="Save Changes" /> <input type="hidden" name="action" value="edit" /> <input type="hidden" name="id" value="<?php echo $data[0]->id; ?> "> </p> </form> <?php } ?> <?php if ($faves->check() != 'false' && !isset($_REQUEST['gather'])) { ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ?page=faves.php&add=true" class="form-table"> <h2>Add a New Fave</h2> <p><input type="text" name="title" id="title" onfocus="if(this.value=='Fave Title')value=''" onblur="if(this.value=='')value='Fave Title';" value="Fave Title" /></p> <p><input type="text" name="url" id="url" onfocus="if(this.value=='Fave Feed URL')value=''" onblur="if(this.value=='')value='Fave Feed URL';" value="Fave Feed URL" /></p> <p class="submit"> <input name="save" type="submit" value="Add Fave" /> <input type="hidden" name="action" value="add" /> </p> </form> <?php } ?> </div> <?php include_once 'advert.php'; }