Ejemplo n.º 1
0
 public function albums($atts = null, $content = null, $code = "")
 {
     global $wpdb, $_wt_options;
     require_once WT_PLUGIN_PATH . 'admin/template.php';
     require_once WT_PLUGIN_PATH . 'admin/handlers.php';
     require_once WT_PLUGIN_PATH . 'dwoo/dwooAutoload.php';
     $dwoo = new Dwoo();
     # CONFIG PARAMS
     $attr = shortcode_atts(self::$album_default, $atts);
     # TEMPLATE
     $theme_file_name = empty($attr["theme_file_name"]) ? 0 : $attr["theme_file_name"];
     #ARTIST
     $artists_to_show = empty($attr["artist"]) ? 0 : explode(",", $attr["artist"]);
     #ALBUMS
     $albums_to_show = empty($attr["album"]) ? 0 : explode(",", $attr["album"]);
     #EXCLUDE ALBUMS
     $albums_to_hide = empty($attr["exclude"]) ? 0 : explode(",", $attr["exclude"]);
     #GENRE
     $genre_to_show = empty($attr["genre"]) ? 0 : explode(",", $attr["genre"]);
     #ORDER
     $order = strtolower($attr["order_by"]) == "order" ? "album_order" : "album_title";
     #DIRECTION
     $direction = strtoupper($attr["direction"]) == "ASC" ? "ASC" : "DESC";
     #START WITH
     $start_with = $attr["start_with"];
     #TYPE
     $album_type = !empty($attr["type"]) ? $attr["type"] : 0;
     #TYPE
     $album_genre = !empty($attr["genre"]) ? $attr["genre"] : 0;
     #LIMIT
     $limit = $attr["limit"] && is_numeric($attr["limit"]) ? " LIMIT {$attr['limit']} " : "";
     $albums = 0;
     # GET RESULTS
     $conds = array();
     $conds_str = "";
     if (!empty($start_with)) {
         $conds[] = "UPPER(album.album_title) LIKE UPPER('{$start_with}%')";
     }
     if ($albums_to_show) {
         $conds[] = $this->columns_sql("album.album_id", $albums_to_show);
     }
     if ($albums_to_hide) {
         $conds[] = $this->columns_sql("album.album_id", $albums_to_hide, null, "!=");
     }
     if ($artists_to_show) {
         $conds[] = $this->columns_sql("album.album_artist_id", $artists_to_show);
     }
     if ($album_type) {
         $conds[] = "album.album_type='{$album_type}'";
     }
     if ($album_genre) {
         $conds_str .= " JOIN wp_wtr_attachment AS att ON album.album_id = att.attachment_target_id";
         $conds[] = "att.attachment_target='album'";
         $conds[] = "att.attachment_type='genre'";
         $conds[] = $this->columns_sql("att.attachment_info", $genre_to_show);
     }
     if (count($conds) > 0) {
         $conds_str .= " WHERE " . implode(" AND ", $conds);
     }
     $albums = $wpdb->get_results("SELECT * FROM " . WORDTOUR_ALBUMS . " as album LEFT JOIN " . WORDTOUR_ARTISTS . " as artist ON artist.artist_id=album.album_artist_id {$conds_str} GROUP BY album.album_id ORDER BY {$order} {$direction} {$limit}", "ARRAY_A");
     //$this->result_unique("album_id",$albums);
     # SET TEMPLATE
     $tpl = array();
     if ($albums) {
         $albumObj = new WT_Album();
         foreach ($albums as $album) {
             $albumObj->id = $album["album_id"];
             $tpl["data"][] = $albumObj->template($album);
         }
     } else {
         $tpl["data"] = array();
     }
     include WT_PLUGIN_PATH . 'theme/layout.renderer.php';
     return $html;
 }
Ejemplo n.º 2
0
     break;
 case "quickupdate_album":
     $album = new WT_Album($_POST["album_id"]);
     $album->quick_update($_POST);
     $album->db_response("json");
     break;
 case "delete_album":
     unset($_POST["action"]);
     $artist = new WT_Album($_POST["album_id"]);
     $artist->delete($_POST["_nonce"]);
     $artist->db_response("json");
     break;
 case "delete_all_albums":
     unset($_POST["action"]);
     if ($_POST["id"]) {
         $album = new WT_Album();
         $album->delete_all(json_decode(stripslashes($_POST["id"])), $_POST["_nonce"]);
         $album->db_response("json");
     }
     break;
 case "import_album_info":
     global $_wt_options;
     $api_key = $_wt_options->options("lastfm_key");
     $artist = $_POST['artist'];
     $album = $_POST['album'];
     $lastfm_base_url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={$api_key}";
     $lastfm_query = "&artist=" . urlencode($artist) . "&album=" . urlencode($album) . "&format=json&autocorrect=1";
     $lastfm_query_url = $lastfm_base_url . $lastfm_query;
     $response = wt_file_get_contents($lastfm_query_url);
     $response = json_decode($response);
     if ($response->album) {
Ejemplo n.º 3
0
function albums_rows($rows)
{
    global $wpdb;
    if (!$rows) {
        ?>
		<tr class="empty">
			<td colspan="5"><p>No Albums Found</p></td>
		</tr> 
	<?php 
    } else {
        ?>
	<?php 
        $album = new WT_Album();
        foreach ($rows as $row) {
            echo get_album_row_html($album->db_out($row));
        }
    }
}
Ejemplo n.º 4
0
 public function similar($data = 0)
 {
     global $wpdb;
     $result = array();
     try {
         if (!$data) {
             $data = $this->data["album_genre"];
         }
         $artist_id = $this->data["album_artist_id"];
         $album_id = $this->data["album_id"];
         if ($data) {
             $genres = array();
             foreach ($data as $genre) {
                 $genres[] = "att.attachment_info='{$genre['0']}'";
             }
             if (count($genres)) {
                 $genre_sql = "(" . implode(" OR ", $genres) . ")";
                 $sql = "SELECT * FROM " . WORDTOUR_ALBUMS . " as album \n\t\t\t\t\t\t\tJOIN " . WORDTOUR_ATTACHMENT . " AS att ON album.album_id = att.attachment_target_id \n\t\t\t\t\t\t\tAND att.attachment_target='album' AND att.attachment_type='genre' AND album.album_id != {$album_id} \n\t\t\t\t\t\t\tAND {$genre_sql} GROUP BY album.album_id ORDER BY album.album_title LIMIT 5";
                 $albums = $wpdb->get_results($sql, "ARRAY_A");
                 $albums_obj = new WT_Album();
                 foreach ($albums as $album) {
                     $albums_obj->id = $album["album_id"];
                     $albums_obj->retrieve();
                     $result[] = $albums_obj->template();
                 }
             }
         }
     } catch (Exception $e) {
         return array();
     }
     return $result;
 }