/** * Shows the Flash MP3 Player * * @param string $release_slug The release_slug of the release to display a player for. * @return void * @author Alex Andrews <*****@*****.**> **/ function show_player($release_slug) { global $artists, $artist, $current_artist; global $releases, $release, $current_release; $release = get_release_by_slug($release_slug, FALSE, FALSE); if (is_wp_error($release)) { ribcage_404(); } $artist['artist_name'] = get_artistname_by_id($release['release_artist']); if (is_wp_error($artist)) { ribcage_404(); } $url = release_soundcloud_url(false); ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>ROR Player</title> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css"> </head> <body> <iframe width="100%" height="465" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $url; ?> "></iframe> </iframe> </body> </html> <?php return 0; }
/** * Stream a whole release as xspf or m3u. * * @return void * @param string $release_slug The slug of the release to stream * @param string $stream_format The format of the streaming, either xspf or m3u **/ function stream_release($release_slug, $stream_format) { global $wp_query, $release, $artist; global $tracks, $track, $current_track; if (empty($release_slug)) { return new WP_Error('ribcage-no-release-to-stream', __("You didn't specify a release to stream.")); ribcage_404(); } $release = get_release_by_slug($release_slug, TRUE, FALSE); if (is_wp_error($release)) { ribcage_404(); } $artist['artist_name'] = get_artistname_by_id($release['release_artist']); if (is_wp_error($artist)) { ribcage_404(); } $tracks = $release['release_tracks']; $track = $tracks[$current_track]; if (is_wp_error($release)) { ribcage_404(); } if ($stream_format == 'xspf') { $load = ribcage_load_template('./stream/xspf.php'); } elseif ($stream_format == 'm3u') { $load = ribcage_load_template('stream/m3u.php'); } if (is_wp_error($load)) { return $load; } }
function show_player($release_slug) { global $artists, $artist, $current_artist; global $releases, $release, $current_release; $release = get_release_by_slug($release_slug, FALSE, FALSE); $artist['artist_name'] = get_artistname_by_id($release['release_artist']); ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>ROR Player</title> <style type="text/css" media="screen"> * { margin: 0; padding: 0; } </style> <body> <embed src="<?php echo get_option('siteurl'); ?> /wp-content/plugins/ribcage/flash/mp3player.swf" width="320" height="140" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=<?php echo get_option('siteurl') . '/stream/' . $release_slug . '/xspf/'; ?> &height=140&width=320&displaywidth=120&showicons=false&repeat=list&autostart=true&shuffle=false&callback=<?php echo get_option('siteurl'); ?> /player/stats/" /> </body> </html> <?php return 0; }
/** * 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 } }
/** * Add a review of a specific release. * * @return void */ function ribcage_manage_reviews() { global $releases, $release, $artist, $tracks, $track; $release = get_release($_REQUEST['release'], false, true); $reviews = $release['release_reviews']; $artist['artist_name'] = get_artistname_by_id($release['release_artist']); ?> <div class="wrap"> <h2>Manage Reviews of <?php artist_name(); ?> - <?php release_title(); ?> </h2> <?php if (count($reviews) == 0) { echo "<p>No reviews yet. Why not add one now?</p>"; } else { register_column_headers('ribcage-manage-reviews', array('cb' => '<input type="checkbox" />', 'review_' => 'Reviewer')); echo "<pre>" . print_r($reviews) . "</pre>"; } ?> <h3>Add a review</h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="review_url">Review URL</label></th> <td><input type="text" name="review_url" value="" class="regular-text code"/><span class="description">The URL of the review, if the review is online.</span> </td> </tr> <tr valign="top"> <th scope="row"><label for="review_url">Publication</label></th> <td><input type="text" name="review_url" value="" class="regular-text code"/><span class="description">The name of the publication that reviewed the release</span> </td> </tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="Add Review" /> </p> </form> </div> <?php }
/** * Displays a form used for editing or adding a product to database. * * @param string $error Error message from the manage_products form. * @param bool $related_to_release If true then we are passing from adding a release in general so we set the relation to this automatically * @return void */ function ribcage_edit_product_form($error = 0, $related_to_release = 0) { global $artist; global $release, $releases; global $product; if (isset($_REQUEST['product'])) { $product = get_product($_REQUEST['product']); } $releases = list_recent_releases_blurb(); if ($error) { echo '<div id="message" class="error"><p><strong>' . $error . '</strong></p></div>'; } ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <?php if (isset($_REQUEST['product'])) { ?> <h2>Editing <?php product_name(); ?> </h2> <form action="<?php echo home_url(); ?> /wp-admin/admin.php?page=manage_products&product=<?php product_id(); ?> &ribcage_action=edited" method="post" id="ribcage_edit_artist" name="edit_artist"> <?php } else { ?> <h2>Add A Product</h2> <form action="<?php echo home_url(); ?> /wp-admin/admin.php?page=manage_products&ribcage_action=add" method="post" id="ribcage_edit_artist" name="edit_artist"> <?php } ?> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="product_name">Name</label></th> <td> <input type="text" value="<?php product_name(); ?> " name="product_name" id="product_name" class="regular-text"/> </td> </tr> <tr valign="top"> <th scope="row"><label for="product_name">Price</label></th> <td> <input type="text" value="<?php echo $product['product_cost']; ?> " name="product_cost" id="product_cost" class="regular-text"/> </td> </tr> <tr valign="top"> <th scope="row"><label for="product_related_release">Related To Release</label></th> <td> <select name="product_related_release" id="product_related_release"> <option value = "">None</option> <?php while (have_releases()) { the_release(); ?> <?php $artist['artist_name'] = get_artistname_by_id($release['release_artist']); ?> <?php if ($release['release_id'] == $product['product_related_release']) { ?> <option selected value="<?php release_id(); ?> "><?php artist_name(); ?> - <?php release_title(); ?> </option> <?php } else { ?> <option value="<?php release_id(); ?> "><?php artist_name(); ?> - <?php release_title(); ?> </option> <?php } ?> <?php } ?> </select> </td> </tr> <tr valign="top"> <th scope="row"><label for="product_name">Product Description</label></th> <td> <textarea rows="10" cols="100" name="product_description" id="product_description" class="regular-text"><?php product_description(); ?> </textarea> </td> </tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="Save Changes" /> </p> </form> </div> <?php }