?> </th> <th class="cel_user optional"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&type=wanted&sort=user', T_('User'), 'sort_wanted_user'); ?> </th> <th class="cel_action essential"><?php echo T_('Actions'); ?> </th> </tr> </thead> <tbody> <?php foreach ($object_ids as $wanted_id) { $libitem = new Wanted($wanted_id); $libitem->format(); ?> <tr id="walbum_<?php echo $libitem->mbid; ?> " class="<?php echo UI::flip_class(); ?> "> <?php require AmpConfig::get('prefix') . UI::find_template('show_wanted_album_row.inc.php'); ?> </tr> <?php }
case 'remove_wanted': if (AmpConfig::get('wanted') && isset($_REQUEST['mbid'])) { $mbid = $_REQUEST['mbid']; $walbum = new Wanted(Wanted::get_wanted($mbid)); Wanted::delete_wanted($mbid); ob_start(); $walbum->accepted = false; $walbum->id = 0; $walbum->show_action_buttons(); $results['wanted_action_' . $mbid] = ob_get_clean(); } break; case 'accept_wanted': if (AmpConfig::get('wanted') && isset($_REQUEST['mbid'])) { $mbid = $_REQUEST['mbid']; $walbum = new Wanted(Wanted::get_wanted($mbid)); $walbum->accept(); ob_start(); $walbum->show_action_buttons(); $results['wanted_action_' . $mbid] = ob_get_clean(); } break; case 'reloadnp': ob_start(); show_now_playing(); $results['now_playing'] = ob_get_clean(); ob_start(); $data = Song::get_recently_played(); Song::build_cache(array_keys($data)); require_once AmpConfig::get('prefix') . UI::find_template('show_recently_played.inc.php'); $results['recently_played'] = ob_get_clean();
<?php /* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) * Copyright 2001 - 2015 Ampache.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License v2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ $object_ids = Wanted::get_wanted_list(); $browse = new Browse(); $browse->set_type('wanted'); $browse->set_static_content(true); $browse->save_objects($object_ids); $browse->show_objects($object_ids); $browse->store();
/** * Format data. */ public function format() { if ($this->artist) { $artist = new Artist($this->artist); $artist->format(); $this->f_artist_link = $artist->f_link; } else { $wartist = Wanted::get_missing_artist($this->artist_mbid); $this->f_artist_link = $wartist['link']; } $this->link = AmpConfig::get('web_path') . "/albums.php?action=show_missing&mbid=" . $this->mbid . "&artist=" . $this->artist . "&artist_mbid=" . $this->artist_mbid . "\" title=\"" . $this->name; $this->f_link = "<a href=\"" . $this->link . "\">" . $this->name . "</a>"; $user = new User($this->user); $user->format(); $this->f_user = $user->f_name; }
/** * format * This takes the current song object * and does a ton of formating on it creating f_??? variables on the current * object */ public function format($details = true) { // Format the artist name if ($this->artist) { $this->f_artist_full = $this->get_artist_name(); $this->f_artist_link = "<a href=\"" . AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $this->artist . "\" title=\"" . scrub_out($this->f_artist_full) . "\"> " . scrub_out($this->f_artist) . "</a>"; } else { $wartist = Wanted::get_missing_artist($this->artist_mbid); $this->f_artist_link = $wartist['link']; $this->f_artist_full = $wartist['name']; } $this->f_artist = $this->f_artist_full; // Format the title $this->f_title_full = $this->title; $this->f_title = $this->title; $this->link = "#"; $this->f_link = "<a href=\"" . scrub_out($this->link) . "\" title=\"" . scrub_out($this->f_artist) . " - " . scrub_out($this->title) . "\"> " . scrub_out($this->f_title) . "</a>"; $this->f_album_link = "<a href=\"" . AmpConfig::get('web_path') . "/albums.php?action=show_missing&mbid=" . $this->album_mbid . "&artist=" . $this->artist . "\" title=\"" . $this->f_album . "\">" . $this->f_album . "</a>"; // Format the track (there isn't really anything to do here) $this->f_track = $this->track; return true; }
$chr = ""; } else { $chr = $match; } /* Enclose this in the purty box! */ require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php'; show_alphabet_list('artists', 'artists.php', $match); show_alphabet_form($chr, T_('Show Artists starting with'), "artists.php?action=match"); require AmpConfig::get('prefix') . '/templates/show_box_bottom.inc.php'; if ($match === "Browse") { show_artists(); } elseif ($match === "Show_all") { $offset_limit = 999999; show_artists(); } else { if ($chr == '') { show_artists('A'); } else { show_artists($chr); } } break; case 'show_missing': set_time_limit(600); $mbid = $_REQUEST['mbid']; $wartist = Wanted::get_missing_artist($mbid); require AmpConfig::get('prefix') . '/templates/show_missing_artist.inc.php'; break; } // end switch UI::show_footer();
$searchreq = array('limit' => $limit, 'type' => 'label', 'rule_1_input' => $search, 'rule_1_operator' => '2', 'rule_1' => 'name'); $sres = Search::run($searchreq); // Litmit not reach, new search with another operator if (count($sres) < $limit) { $searchreq['limit'] = $limit - count($sres); $searchreq['rule_1_operator'] = '0'; $sres = array_unique(array_merge($sres, Search::run($searchreq))); } foreach ($sres as $id) { $label = new Label($id); $label->format(false); $results[] = array('type' => T_('Labels'), 'link' => $label->link, 'label' => $label->name, 'value' => $label->name, 'rels' => '', 'image' => Art::url($label->id, 'label', null, 10)); } } if ($target == 'missing_artist' && AmpConfig::get('wanted')) { $sres = Wanted::search_missing_artists($search); $i = 0; foreach ($sres as $r) { $results[] = array('type' => T_('Missing Artists'), 'link' => AmpConfig::get('web_path') . '/artists.php?action=show_missing&mbid=' . $r['mbid'], 'label' => $r['name'], 'value' => $r['name'], 'rels' => '', 'image' => ''); $i++; if ($i >= $limit) { break; } } } if ($target == 'user' && AmpConfig::get('sociable')) { $searchreq = array('limit' => $limit, 'type' => 'user', 'rule_1_input' => $search, 'rule_1_operator' => '2', 'rule_1' => 'username'); $sres = Search::run($searchreq); // Litmit not reach, new search with another operator if (count($sres) < $limit) { $searchreq['limit'] = $limit - count($sres);
?> </th> <th class="cel_user optional"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&type=wanted&sort=user', T_('User'), 'sort_wanted_user'); ?> </th> <th class="cel_action essential"><?php echo T_('Actions'); ?> </th> </tr> </thead> <tbody> <?php foreach ($object_ids as $wanted_id) { $walbum = new Wanted($wanted_id); $walbum->format(); ?> <tr id="walbum_<?php echo $walbum->mbid; ?> " class="<?php echo UI::flip_class(); ?> "> <?php require AmpConfig::get('prefix') . '/templates/show_wanted_album_row.inc.php'; ?> </tr> <?php }
} if (isset($_GET['order'])) { $songs = explode(";", $_GET['order']); $track = $_GET['offset'] ? intval($_GET['offset']) + 1 : 1; foreach ($songs as $song_id) { if ($song_id != '') { Song::update_track($track, $song_id); ++$track; } } } break; case 'show_missing': set_time_limit(600); $mbid = $_REQUEST['mbid']; $walbum = new Wanted(Wanted::get_wanted($mbid)); if (!$walbum->id) { $walbum->mbid = $mbid; if (isset($_REQUEST['artist'])) { $artist = new Artist($_REQUEST['artist']); $walbum->artist = $artist->id; $walbum->artist_mbid = $artist->mbid; } elseif (isset($_REQUEST['artist_mbid'])) { $walbum->artist_mbid = $_REQUEST['artist_mbid']; } } $walbum->load_all(); $walbum->format(); require AmpConfig::get('prefix') . UI::find_template('show_missing_album.inc.php'); break; // Browse by Album
/** * check * * Searches for an album; if none is found, insert a new one. */ public static function check($name, $year = 0, $disk = 0, $mbid = null, $readonly = false) { if ($mbid == '') { $mbid = null; } $trimmed = Catalog::trim_prefix(trim($name)); $name = $trimmed['string']; $prefix = $trimmed['prefix']; // Not even sure if these can be negative, but better safe than llama. $year = abs(intval($year)); $disk = abs(intval($disk)); if (!$name) { $name = T_('Unknown (Orphaned)'); $year = 0; $disk = 0; } if (isset(self::$_mapcache[$name][$year][$disk][$mbid])) { return self::$_mapcache[$name][$year][$disk][$mbid]; } $sql = 'SELECT `id` FROM `album` WHERE `name` = ? AND `disk` = ? AND `year` = ? AND `mbid` '; $params = array($name, $disk, $year); if ($mbid) { $sql .= '= ? '; $params[] = $mbid; } else { $sql .= 'IS NULL '; } $sql .= 'AND `prefix` '; if ($prefix) { $sql .= '= ?'; $params[] = $prefix; } else { $sql .= 'IS NULL'; } $db_results = Dba::read($sql, $params); if ($row = Dba::fetch_assoc($db_results)) { $id = $row['id']; self::$_mapcache[$name][$year][$disk][$mbid] = $id; return $id; } if ($readonly) { return null; } $sql = 'INSERT INTO `album` (`name`, `prefix`, `year`, `disk`, `mbid`) VALUES (?, ?, ?, ?, ?)'; $db_results = Dba::write($sql, array($name, $prefix, $year, $disk, $mbid)); if (!$db_results) { return null; } $id = Dba::insert_id(); // Remove from wanted album list if any request on it if (!empty($mbid) && AmpConfig::get('wanted')) { try { Wanted::delete_wanted_release($mbid); } catch (Exception $e) { debug_event('wanted', 'Cannot process wanted releases auto-removal check: ' . $e->getMessage(), '1'); } } self::$_mapcache[$name][$year][$disk][$mbid] = $id; return $id; }
UI::show_header(); /** * action switch */ switch ($_REQUEST['action']) { case 'search': if ($_REQUEST['rule_1'] != 'missing_artist') { $browse = new Browse(); require_once AmpConfig::get('prefix') . '/templates/show_search_form.inc.php'; require_once AmpConfig::get('prefix') . '/templates/show_search_options.inc.php'; $results = Search::run($_REQUEST); $browse->set_type($_REQUEST['type']); $browse->show_objects($results); $browse->store(); } else { $wartists = Wanted::search_missing_artists($_REQUEST['rule_1_input']); require_once AmpConfig::get('prefix') . '/templates/show_missing_artists.inc.php'; echo '<a href="http://musicbrainz.org/search?query=' . rawurlencode($_REQUEST['rule_1_input']) . '&type=artist&method=indexed" target="_blank">' . T_('View on MusicBrainz') . '</a><br />'; } break; case 'save_as_smartplaylist': if (!Access::check('interface', 25)) { UI::access_denied(); exit; } $playlist = new Search(); $playlist->parse_rules(Search::clean_request($_REQUEST)); $playlist->save(); show_confirmation(T_('Search Saved'), sprintf(T_('Your Search has been saved as a Smart Playlist with name %s'), $playlist->name), AmpConfig::get('web_path') . "/browse.php?action=smartplaylist"); break; case 'descriptor':
/** * format * This takes the current song object * and does a ton of formating on it creating f_??? variables on the current * object */ public function format() { // Format the filename preg_match("/^.*\\/(.*?)\$/", $this->file, $short); $this->f_file = htmlspecialchars($short[1]); // Format the artist name if ($this->artist) { $this->f_artist_full = $this->get_artist_name(); $this->f_artist_link = "<a href=\"" . AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $this->artist . "\" title=\"" . scrub_out($this->f_artist_full) . "\"> " . scrub_out($this->f_artist) . "</a>"; } else { $wartist = Wanted::get_missing_artist($this->artist_mbid); $this->f_artist_link = $wartist['link']; $this->f_artist_full = $wartist['name']; } $this->f_artist = $this->f_artist_full; // Format the title $this->f_title_full = $this->title; $this->f_title = $this->title; $this->link = "#"; $this->f_link = "<a href=\"" . scrub_out($this->link) . "\" title=\"" . scrub_out($this->f_artist) . " - " . scrub_out($this->title) . "\"> " . scrub_out($this->f_title) . "</a>"; $this->f_album_link = "<a href=\"" . AmpConfig::get('web_path') . "/albums.php?action=show_missing&mbid=" . $this->album_mbid . "&artist=" . $this->artist . "\" title=\"" . $this->f_album . "\">" . $this->f_album . "</a>"; // Format the track (there isn't really anything to do here) $this->f_track = $this->track; return true; }