/** * Manages artists - adds, deletes, edits. * * @author Alex Andrews <*****@*****.**> * @return void **/ function ribcage_manage_artists() { global $artists; global $artist; $index = false; // If we aren't on an artist page then we are on the index page. if (isset($_REQUEST['artist'])) { $artist_id = (int) $_REQUEST['artist']; } elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'add_artist') { $index = false; } else { $index = true; } register_column_headers('ribcage-manage-artist', array('cb' => '<input type="checkbox" />', 'artist' => 'Artist')); if (isset($_REQUEST['ribcage_action'])) { global $wpdb; // Refactor, this is a terrible place for this to do this. if ($_REQUEST['ribcage_action'] !== 'add') { check_admin_referer('manage_artists'); } else { check_admin_referer('add_artist'); } unset($_POST['_wpnonce']); unset($_POST['_wp_http_referer']); unset($_POST['Submit']); //split apart associative array into different parts to prepare for implodes $post_keys = array_keys($_POST); $post_vals = array_values($_POST); //construct field name list and vals to post $string_keys = implode($post_keys, ","); $string_vals = "'" . implode($post_vals, "','") . "'"; $wpdb->show_errors(); switch ($_REQUEST['ribcage_action']) { case 'edit': $sql = "UPDATE " . $wpdb->prefix . "ribcage_artists\n\t\t\t\t\t\tSET "; $i = 0; foreach ($post_keys as $field) { $sql .= $field . "='" . $post_vals[$i] . "', "; $i++; } $sql .= " artist_id = " . $artist_id . " \n\t\t\t\t\t\tWHERE artist_id = " . $artist_id; $results = $wpdb->query($sql); $wpdb->hide_errors(); $artist = get_artist($artist_id); $message = 'updated'; break; case 'add': $sql = "INSERT INTO " . $wpdb->prefix . "ribcage_artists\n\t\t\t\t\t\t({$string_keys})\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$string_vals})"; $results = $wpdb->query($sql); $wpdb->hide_errors(); $artist = get_artist_by_slug($_POST['artist_slug']); $message = 'added'; break; case 'delete': $del_artist = get_artistname_by_id($_REQUEST['artist']); delete_artist($_REQUEST['artist']); $message = "{$del_artist} deleted"; $index = 1; break; } echo '<div id="message" class="updated fade"><p><strong>Artist ' . $message . '.</strong></p></div>'; } if (!$index) { if (isset($_REQUEST['artist'])) { $artist = get_artist($_REQUEST['artist']); } ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <?php if ($_REQUEST['page'] == 'add_artist') { ?> <h2>Add Artist</h2> <form action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?> &ribcage_action=add" method="post" id="ribcage_edit_artist" name="edit_artist"> <?php wp_nonce_field('add_artist'); ?> <?php } ?> <?php if (isset($_REQUEST['artist'])) { ?> <h2>Managing <?php artist_name(); ?> </h2> <form action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?> &ribcage_action=edit" method="post" id="ribcage_edit_artist" name="edit_artist"> <?php wp_nonce_field('manage_artists'); ?> <?php } ?> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="artist_name">Name</label></th> <td> <input type="text" value="<?php artist_name(); ?> " name="artist_name" id="artist_name" class="regular-text"/> </td> </tr> <tr valign="top"> <th scope="row">Sort Name</th> <td> <input type="text" value="<?php artist_name_sort(); ?> " name="artist_name_sort" id="artist_name_sort" class="regular-text" /> <span class="description">The name of the artist to be alphabetized. For example, 'Butterfly, The'.</span> </td> </tr> <tr valign="top"> <th scope="row">Artist Slug</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_slug(); ?> " name="artist_slug" id="artist_slug" /><span class="description">The URL you want for the artist - for example <a href="<?php echo home_url(); ?> /artists/artist_slug</span> </td> </tr> <tr valign="top"> <th scope="row">Signup Date</th> <td> <input type="text" style="width:100px;" class="regular-text code" value="<?php echo $artist['artist_signed']; ?> " name="artist_signed" id="artist_signed" maxlength="50" /><span class="description">The date the artist signed for your label</span> </td> </tr> <tr valign="top"> <th scope="row">Creative Commons license</th> <td> <?php echo ribcage_cc_dropdown($artist_license_val); ?> </td> </tr> <tr valign="top"> <th scope="row">Artist's Music Brainz ID</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_musicbrainz(); ?> " name="artist_mbid" id="artist_mbid" maxlength="50" /> </td> </tr> <tr valign="top"> <th scope="row">Website URL</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_website_link(); ?> " name="artist_link_website" id="artist_link_website" maxlength="200" /> </td> </tr> <tr valign="top"> <th scope="row">MySpace URL</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_myspace_link(); ?> " name="artist_link_myspace" id="artist_link_myspace" maxlength="200" /> </td> </tr> <tr valign="top"> <th scope="row">Facebook URL</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_facebook_link(); ?> " name="artist_link_facebook" id="artist_link_facebook" maxlength="200" /> </td> </tr> <tr valign="top"> <th scope="row">Artist Biography</th> <td> <textarea rows="5" cols="50" name="artist_bio" id="artist_bio" class="regular-text"><?php echo $artist['artist_bio']; ?> </textarea> </td> </tr> <tr valign="top"> <th scope="row">Short One Paragraph Description of Artist</th> <td> <textarea rows="5" cols="50" name="artist_blurb_tiny" id="artist_blurb_tiny" class="regular-text"><?php echo $artist['artist_blurb_tiny']; ?> </textarea> </td> </tr> <tr valign="top"> <th scope="row">Artist Picture 1</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_picture_1(); ?> " name="artist_picture_1" id="artist_picture_1" maxlength="200" /> </td> </tr> <tr valign="top"> <th scope="row">Artist Picture 2</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_picture_2(); ?> " name="artist_picture_2" id="artist_picture_2" maxlength="200" /> </td> </tr> <tr valign="top"> <th scope="row">Artist Picture 3</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php artist_picture_3(); ?> " name="artist_picture_3" id="artist_picture_3" maxlength="200" /> </td> </tr> <tr valign="top"> <th scope="row">Artist Picture HQ Zipfile URL</th> <td> <input type="text" style="width:320px;" class="regular-text code" value="<?php echo $artist_picture_zip_val; ?> " name="artist_picture_zip" id="artist_picture_zip" maxlength="200" /> </td> </tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="Save Changes" /> </p> </form> </div> <?php } else { ?> <?php $artists = list_artists_blurb(); $alt = 0; ?> <div class="wrap"> <div id="icon-plugins" class="icon32"><br /></div> <h2>Manage Artists</h2> <form action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?> " method="post" id="ribcage_manage_artists" name="manage_artists"> <table class="widefat post fixed" cellspacing="0"> <thead> <tr> <?php print_column_headers('ribcage-manage-artist'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('ribcage-manage-artist', FALSE); ?> </tr> </tfoot> <tbody> <?php while (have_artists()) { the_artist(); ?> <?php $manage_link = wp_nonce_url('?page=ribcage&artist=' . artist_id(false), 'manage_artists'); $delete_link = wp_nonce_url('?page=ribcage&artist=' . artist_id(false) . '&ribcage_action=delete', 'manage_artists'); ?> <?php echo $alt % 2 ? '<tr valign="top" class="">' : '<tr valign="top" class="alternate">'; ++$alt; ?> <th scope="row" class="check-column"><input type="checkbox" name="artistcheck[]" value="2" /></th> <td class="column-name"> <strong><a class="row-title" href="?page=manage_artists&artist=<?php artist_id(); ?> " title="<?php artist_name(); ?> " ><?php artist_name(); ?> </strong></a><br /><div class="row-actions"><span class='edit'><a href="<?php echo $manage_link; ?> ">Edit</a> | </span><span class='delete'><a class='submitdelete' href='<?php echo $delete_link; ?> ' onclick="if ( confirm('You are about to delete \'<?php artist_name(); ?> \'\n \'Cancel\' to stop, \'OK\' to delete.') ) { return true;}return false;">Delete</a></span></div></td> </tr> <?php } ?> </tbody> </table> </form> </div> <?php } }
?> <?php wp_reset_query(); ?> <?php if (isset($wp_query->query_vars['artist_slug'])) { ?> <div class="mod"> <h3>Artist Feeds</h3> <ul> <li class="rss"><a href="/<?php artist_slug(); ?> /feed/" title="RSS 2.0 Feed">Releases</a></li> <li class="rss"><a href="/tag/<?php artist_slug(); ?> " title="RSS 2.0 Feed">News</a></li> <li class="rss"><a href="/?dbem_rss=main&category=<?php artist_id(); ?> " title="RSS 2.0 Feed">Events</a></li> </ul> </div> <?php } ?> </div> <?php get_footer();
/** * Manage releases panel - sends you out to add releases, remove releases, add reviews (and eventually add tracks). * * @return void */ function ribcage_manage_releases() { global $release, $releases, $artist, $tracks; $total_downloads = 0; $nonce = wp_create_nonce('ribcage_manage_releases'); if (isset($_REQUEST['release'])) { switch ($_REQUEST['ribcage_action']) { case 'stats': ribcage_release_stats(); return; break; case 'edit': check_admin_referer('ribcage_manage_releases'); ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <?php $release = get_release($_REQUEST['release']); $artist = get_artist($release['release_artist']); $tracks = $release['release_tracks']; ?> <h2>Editing <?php release_title(); ?> </h2> <?php ribcage_release_form(); ?> <?php ribcage_tracks_form(); ?> </div> <?php return; break; case 'reviews': check_admin_referer('ribcage_manage_releases'); ribcage_manage_reviews(); return; break; case 'delete': check_admin_referer('ribcage_manage_releases'); delete_release($_REQUEST['release']); $message = " deleted"; break; } } if (isset($message)) { echo '<div id="message" class="updated fade"><p><strong>Release ' . $message . '.</strong></p></div>'; } register_column_headers('ribcage-manage-releases', array('cb' => '<input type="checkbox" />', 'release_image' => '', 'release_title' => 'Release', 'release_date' => 'Release Date', 'local_downloads' => 'Local Downloads', 'remote_downloads' => 'Remote Downloads', 'total_downloads' => 'Total Downloads')); $releases = list_recent_releases_blurb(); ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <h2>Manage Releases</h2> <form action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?> " method="post" id="ribcage_edit_artist" name="edit_artist"> <table class="widefat post fixed" cellspacing="0"> <thead> <tr> <?php print_column_headers('ribcage-manage-releases'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('ribcage-manage-releases', FALSE); ?> </tr> </tfoot> <tbody> <?php while (have_releases()) { the_release(); ?> <?php $artist = get_artist($release['release_artist']); ?> <?php echo $alt % 2 ? '<tr valign="top" class="">' : '<tr valign="top" class="alternate">'; ++$alt; ?> <th scope="row" class="check-column"><input type="checkbox" name="artistcheck[]" value="2" /></th> <td class="column-icon"><img src="<?php release_cover_tiny(); ?> " height="65px" width="65px" alt="<?php release_title(); ?> " /></td> <td class="column-name"><strong><a class="row-title" href="?page=manage_releases&release=<?php artist_id(); ?> " title="<?php artist_name(); ?> " ><?php artist_name(); ?> - <?php release_title(); ?> </strong></a><br /><div class="row-actions"><span class='stats'><a href="?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=stats&_wpnonce=<?php echo $nonce; ?> ">Stats</a></span> | <span class='edit'><a href="?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=edit&_wpnonce=<?php echo $nonce; ?> ">Edit</a></span> | <span class='reviews'><a href="?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=reviews&_wpnonce=<?php echo $nonce; ?> ">Reviews</a></span> | <span class='delete'><a class='submitdelete' href='?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=delete&_wpnonce=<?php echo $nonce; ?> ' onclick="if ( confirm('You are about to delete \'<?php artist_name(); ?> - <?php release_title(); ?> \'\n \'Cancel\' to stop, \'OK\' to delete.') ) { return true;}return false;">Delete</a></span></div></td> <td class="column-name"><?php echo date('j F Y', strtotime($release['release_date'])); ?> </td> <td class="column-name"><?php release_downloads(); ?> </td> <td class="column-name"><?php //remote_downloads(); ?> </td> <td class="column-name"><?php //echo number_format(remote_downloads(FALSE)+release_downloads(FALSE)); $total_downloads = $total_downloads + remote_downloads(FALSE)+release_downloads(FALSE); update_option('ribcage_total_downloads', $total_downloads); ?> </td> </tr> <?php } ?> </tbody> </table> </form> <p>Served <?php echo number_format($total_downloads); ?> downloads so far.</p> </div> <?php update_option('ribcage_total_downloads', $total_downloads); }
/** * Displays a drop down menu of all the artists. * * @param string $var_name Optional variable name which the dropdown corresponds to. For example release_artist is the default. * @param int $artist_id Optional artist to make selected. */ function ribcage_artists_dropdown($var_name = 'release_artist', $artist_id = null) { global $artists, $artist; $artists = list_artists_blurb(); $artist = $artists[$current_artist]; ?> <select name="<?php echo $var_name; ?> " id="<?php echo $var_name; ?> "> <?php while (have_artists()) { the_artist(); ?> <?php if ($artist['artist_id'] == $artist_id) { ?> <option selected value="<?php artist_id(); ?> "><?php artist_name(); ?> </option> <?php } else { ?> <option value="<?php artist_id(); ?> "><?php artist_name(); ?> </option> <?php } ?> <?php } ?> <?php }