diff --git a/browse.php b/browse.php index 1f2d6958..138dccd4 100644 --- a/browse.php +++ b/browse.php @@ -55,6 +55,7 @@ switch ($_REQUEST['action']) { case 'movie': case 'clip': case 'personal_video': + case 'label': $browse->set_type($_REQUEST['action']); $browse->set_simple_browse(true); break; @@ -181,6 +182,14 @@ switch ($_REQUEST['action']) { $browse->update_browse_from_session(); $browse->show_objects(); break; + case 'label': + if (AmpConfig::get('catalog_disable')) { + $browse->set_filter('catalog_enabled', '1'); + } + $browse->set_sort('name','ASC'); + $browse->update_browse_from_session(); + $browse->show_objects(); + break; default: break; diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index 7ccb9132..6c598ac6 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -7,7 +7,7 @@ ; if this config file is up to date ; this is compared against a value hard-coded ; into the init script -config_version = 27 +config_version = 28 ;################### ; Path Vars # @@ -493,6 +493,11 @@ wanted_types = "album,official" ; EchoNest provides several music services. Currently used for missing song 30 seconds preview. ;echonest_api_key = "" +; Labels +; Use labels to browse artists per label membership. +; DEFAULT: false +;label = "false" + ; Broadcasts ; Allow users to broadcast music. ; This feature requires advanced server configuration, please take a look on the wiki for more information. diff --git a/labels.php b/labels.php new file mode 100644 index 00000000..2d2ad80a --- /dev/null +++ b/labels.php @@ -0,0 +1,83 @@ + 0) { + $label = new Label($label_id); + $label->format(); + $object_ids = $label->get_artists(); + $object_type = 'artist'; + require_once AmpConfig::get('prefix') . '/templates/show_label.inc.php'; + UI::show_footer(); + exit; + } + case 'show_add_label': + if (Access::check('interface','50') || AmpConfig::get('upload_allow_edit')) { + require_once AmpConfig::get('prefix') . '/templates/show_add_label.inc.php'; + } else { + echo T_('Label cannot be found.'); + } + break; +} // end switch + +UI::show_footer(); diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 926bfdb6..e58965ea 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -85,6 +85,14 @@ class Artist extends database_object implements library_item * @var string $f_tags */ public $f_tags; + /** + * @var array $labels + */ + public $labels; + /** + * @var string $f_labels + */ + public $f_labels; /** * @var int $object_cnt */ @@ -331,7 +339,7 @@ class Artist extends database_object implements library_item if (AmpConfig::get('catalog_disable')) { $sql .= "AND `catalog`.`enabled` = '1' "; } - $sql .= "ORDER BY album, track"; + $sql .= "ORDER BY `song`.`album`, `song`.`track`"; $db_results = Dba::read($sql, array($this->id)); $results = array(); @@ -454,6 +462,11 @@ class Artist extends database_object implements library_item $this->tags = Tag::get_top_tags('artist', $this->id); $this->f_tags = Tag::get_display($this->tags, true, 'artist'); + if (AmpConfig::get('label')) { + $this->labels = Label::get_labels($this->id); + $this->f_labels = Label::get_display($this->labels, true); + } + $this->object_cnt = $extra_info['object_cnt']; } @@ -789,6 +802,10 @@ class Artist extends database_object implements library_item $this->update_tags($data['edit_tags'], $override_childs, $add_to_childs, $current_id, true); } + if (AmpConfig::get('label') && isset($data['edit_labels'])) { + Label::update_label_list($data['edit_labels'], $this->id, true); + } + return $current_id; } // update diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index ea147415..357c1fab 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -326,6 +326,10 @@ class Browse extends Query $video_type = $type; $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php'; break; + case 'label': + $box_title = T_('Labels'); + $box_req = AmpConfig::get('prefix') . '/templates/show_labels.inc.php'; + break; default: // Rien a faire break; diff --git a/lib/class/label.class.php b/lib/class/label.class.php new file mode 100644 index 00000000..76228ff7 --- /dev/null +++ b/lib/class/label.class.php @@ -0,0 +1,475 @@ +get_info($id); + foreach ($info as $key=>$value) { + $this->$key = $value; + } + + return true; + } + + public function display_art($thumb) + { + if (Art::has_db($this->id, 'label')) { + Art::display('label', $this->id, $this->get_fullname(), $thumb, $this->link); + } + } + + public function format($details = true) + { + $this->f_name = scrub_out($this->name); + $this->link = AmpConfig::get('web_path') . '/labels.php?action=show&label=' . scrub_out($this->id); + $this->f_link = "link . "\" title=\"" . $this->f_name . "\">" . $this->f_name; + $this->artists = count($this->get_artists()); + } + + public function get_catalogs() + { + return array(); + } + + public function get_childrens() + { + $medias = array(); + $artists = $this->get_artists(); + foreach ($artists as $artist_id) { + $medias[] = array( + 'object_type' => 'artist', + 'object_id' => $album_id + ); + } + return array('artist' => $medias); + } + + public function get_default_art_kind() + { + return 'default'; + } + + public function get_description() + { + return $this->summary; + } + + public function get_fullname() + { + return $this->f_name; + } + + public function get_keywords() + { + $keywords = array(); + $keywords['label'] = array('important' => true, + 'label' => T_('Label'), + 'value' => $this->f_name); + return $keywords; + } + + public function get_medias($filter_type = null) + { + $medias = array(); + if (!$filter_type || $filter_type == 'song') { + $songs = $this->get_songs(); + foreach ($songs as $song_id) { + $medias[] = array( + 'object_type' => 'song', + 'object_id' => $song_id + ); + } + } + return $medias; + } + + public function get_parent() + { + return null; + } + + public function get_user_owner() + { + return $this->user; + } + + public function search_childrens($name) + { + $search['type'] = "artist"; + $search['rule_0_input'] = $name; + $search['rule_0_operator'] = 4; + $search['rule_0'] = "title"; + $artists = Search::run($search); + + $childrens = array(); + foreach ($artists as $artist) { + $childrens[] = array( + 'object_type' => 'artist', + 'object_id' => $artist + ); + } + return $childrens; + } + + public function can_edit($user = null) + { + if (!$user) { + $user = $GLOBALS['user']->id; + } + + if (!$user) + return false; + + if (AmpConfig::get('upload_allow_edit')) { + if ($this->user !== null && $user == $this->user) + return true; + } + + return Access::check('interface', 50, $user); + } + + public function update(array $data) + { + if (self::lookup($data, $this->id) !== 0) { + return false; + } + + $name = isset($data['name']) ? $data['name'] : $this->name; + $category = isset($data['category']) ? $data['category'] : $this->category; + $summary = isset($data['summary']) ? $data['summary'] : $this->summary; + $address = isset($data['address']) ? $data['address'] : $this->address; + $email = isset($data['email']) ? $data['email'] : $this->email; + $website = isset($data['website']) ? $data['website'] : $this->website; + + $sql = "UPDATE `label` SET `name` = ?, `category` = ?, `summary` = ?, `address` = ?, `email` = ?, `website` = ? WHERE `id` = ?"; + Dba::write($sql, array($name, $category, $summary, $address, $email, $website, $this->id)); + + $this->name = $name; + $this->category = $category; + $this->summary = $summary; + $this->address = $address; + $this->email = $email; + $this->website = $website; + + return $this->id; + } + + public static function create(array $data) + { + if (self::lookup($data) !== 0) { + return false; + } + + $name = $data['name']; + $category = $data['category']; + $summary = $data['summary']; + $address = $data['address']; + $email = $data['email']; + $website = $data['website']; + $user = $data['user'] ?: $GLOBALS['user']->id; + $creation_date = $data['creation_date'] ?: time(); + + $sql = "INSERT INTO `label` (`name`, `category`, `summary`, `address`, `email`, `website`, `user`, `creation_date`) " . + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + Dba::write($sql, array($name, $category, $summary, $address, $email, $website, $user, $creation_date)); + + $id = Dba::insert_id(); + return $id; + } + + public static function lookup(array $data, $id = 0) + { + $ret = -1; + $name = trim($data['name']); + if (!empty($name)) { + $ret = 0; + $sql = "SELECT `id` FROM `label` WHERE `name` = ?"; + $params = array($name); + if ($id > 0) { + $sql .= " AND `id` != ?"; + $params[] = $id; + } + $db_results = Dba::read($sql, $params); + if ($row = Dba::fetch_assoc($db_results)) { + $ret = $row['id']; + } + } + + return $ret; + } + + public static function gc() + { + // Don't remove labels, it could still be used as description in a search + } + + public function get_artists() + { + $sql = "SELECT `artist` FROM `label_asso` WHERE `label` = ?"; + $db_results = Dba::read($sql, array($this->id)); + $results = array(); + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row['artist']; + } + + return $results; + } + + public function add_artist_assoc($artist_id) + { + $sql = "INSERT INTO `label_asso` (`label`, `artist`, `creation_date`) VALUES (?, ?, ?)"; + return Dba::write($sql, array($this->id, $artist_id, time())); + } + + public function remove_artist_assoc($artist_id) + { + $sql = "DELETE FROM `label_asso` WHERE `label` = ? AND `artist` = ?"; + return Dba::write($sql, array($this->id, $artist_id)); + } + + /** + * get_songs + * gets the songs for this label + * @return int[] + */ + public function get_songs() + { + $sql = "SELECT `song`.`id` FROM `song` " . + "LEFT JOIN `label_asso` ON `label_asso`.`artist` = `song`.`artist` "; + if (AmpConfig::get('catalog_disable')) { + $sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` "; + } + $sql .= "WHERE `label_asso`.`label` = ? "; + if (AmpConfig::get('catalog_disable')) { + $sql .= "AND `catalog`.`enabled` = '1' "; + } + $sql .= "ORDER BY `song`.`album`, `song`.`track`"; + $db_results = Dba::read($sql, array($this->id)); + + $results = array(); + while ($r = Dba::fetch_assoc($db_results)) { + $results[] = $r['id']; + } + + return $results; + + } // get_songs + + public static function get_all_labels() + { + $sql = "SELECT `id`, `name` FROM `label`"; + $db_results = Dba::read($sql); + $results = array(); + while ($row = Dba::fetch_assoc($db_results)) { + $results[$row['id']] = $row['name']; + } + return $results; + } + + public static function get_labels($artist_id) + { + $sql = "SELECT `label`.`id`, `label`.`name` FROM `label` " . + "LEFT JOIN `label_asso` ON `label_asso`.`label` = `label`.`id` " . + "WHERE `label_asso`.`artist` = ?"; + $db_results = Dba::read($sql, array($artist_id)); + $results = array(); + while ($row = Dba::fetch_assoc($db_results)) { + $results[$row['id']] = $row['name']; + } + return $results; + } + + /** + * get_display + * This returns a csv formated version of the labels that we are given + */ + public static function get_display($labels, $link=false) + { + if (!is_array($labels)) { return ''; } + + $results = ''; + + // Iterate through the labels, format them according to type and element id + foreach ($labels as $label_id=>$value) { + if ($link) { + $results .= ''; + } + $results .= $value; + if ($link) { + $results .= ''; + } + $results .= ', '; + } + + $results = rtrim($results, ', '); + + return $results; + + } // get_display + + /** + * update_label_list + * Update the labels list based on commated list (ex. label1,label2,label3,..) + */ + public static function update_label_list($labels_comma, $artist_id, $overwrite) + { + debug_event('label.class', 'Updating labels for values {'.$labels_comma.'} artist {'.$artist_id.'}', '5'); + + $clabels = Label::get_labels($artist_id); + $editedLabels = explode(",", $labels_comma); + + if (is_array($clabels)) { + foreach ($clabels as $clid => $clv) { + if ($clid) { + $clabel = new Label($clid); + debug_event('label.class', 'Processing label {'.$clabel->name.'}...', '5'); + $found = false; + + foreach ($editedLabels as $lk => $lv) { + if ($clabel->name == $lv) { + $found = true; + break; + } + } + + if ($found) { + debug_event('label.class', 'Already found. Do nothing.', '5'); + unset($editedLabels[$lk]); + } else if ($overwrite) { + debug_event('label.class', 'Not found in the new list. Delete it.', '5'); + $clabel->remove_artist_assoc($artist_id); + } + } + } + } + + // Look if we need to add some new labels + foreach ($editedLabels as $lk => $lv) { + if ($lv != '') { + debug_event('label.class', 'Adding new label {'.$lv.'}', '5'); + $label_id = Label::lookup(array('name' => $lv)); + if ($label_id === 0) { + debug_event('label.class', 'Creating a label directly from artist editing is not allowed.', '5'); + //$label_id = Label::create(array('name' => $lv)); + } + if ($label_id > 0) { + $clabel = new Label($label_id); + $clabel->add_artist_assoc($artist_id); + } + } + } + + return true; + } // update_tag_list + + /** + * clean_to_existing + * Clean label list to existing label list only + * @param array|string $labels + * @return array|string + */ + public static function clean_to_existing($labels) + { + if (is_array($labels)) { + $ar = $labels; + } else { + $ar = explode(",", $labels); + } + + $ret = array(); + foreach ($ar as $label) { + $label = trim($label); + if (!empty($label)) { + if (Label::lookup(array('name' => $label)) > 0) { + $ret[] = $label; + } + } + } + + return (is_array($labels) ? $ret : implode(",", $ret)); + } +} diff --git a/lib/class/query.class.php b/lib/class/query.class.php index cd714375..9b1b9b02 100644 --- a/lib/class/query.class.php +++ b/lib/class/query.class.php @@ -213,6 +213,12 @@ class Query ), 'user' => array( 'starts_with' + ), + 'label' => array( + 'alpha_match', + 'regex_match', + 'regex_not_match', + 'starts_with' ) ); @@ -356,6 +362,11 @@ class Query 'length', 'codec', 'release_date' + ), + 'label' => array( + 'name', + 'category', + 'user' ) ); @@ -675,6 +686,7 @@ class Query case 'movie': case 'personal_video': case 'clip': + case 'label': // Set it $this->_state['type'] = $type; $this->set_base_sql(true, $custom_base); @@ -1018,6 +1030,10 @@ class Query $this->set_select("`personal_video`.`id`"); $sql = "SELECT %%SELECT%% FROM `personal_video` "; break; + case 'label': + $this->set_select("`label`.`id`"); + $sql = "SELECT %%SELECT%% FROM `label` "; + break; case 'playlist_song': case 'song': default: @@ -1635,6 +1651,25 @@ class Query break; } // end filter break; + case 'label': + switch ($filter) { + case 'alpha_match': + $filter_sql = " `label`.`name` LIKE '%" . Dba::escape($value) . "%' AND "; + break; + case 'regex_match': + if (!empty($value)) $filter_sql = " `label`.`name` REGEXP '" . Dba::escape($value) . "' AND "; + break; + case 'regex_not_match': + if (!empty($value)) $filter_sql = " `label`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND "; + break; + case 'starts_with': + $filter_sql = " `label`.`name` LIKE '" . Dba::escape($value) . "%' AND "; + break; + default: + // Rien a faire + break; + } // end filter + break; } // end switch on type return $filter_sql; @@ -1956,6 +1991,19 @@ class Query break; } break; + case 'label': + switch ($field) { + case 'name': + $sql = "`label`.`name`"; + break; + case 'category': + $sql = "`label`.`category`"; + break; + case 'user': + $sql = "`label`.`user`"; + break; + } + break; default: // Rien a faire break; diff --git a/lib/class/search.class.php b/lib/class/search.class.php index 5c1a8804..bb037949 100644 --- a/lib/class/search.class.php +++ b/lib/class/search.class.php @@ -238,6 +238,13 @@ class Search extends playlist_object 'widget' => array('input', 'text') ); + $this->types[] = array( + 'name' => 'label', + 'label' => T_('Label'), + 'type' => 'text', + 'widget' => array('input', 'text') + ); + $this->types[] = array( 'name' => 'tag', @@ -498,6 +505,20 @@ class Search extends playlist_object 'widget' => array('input', 'text') ); break; + case 'label': + $this->types[] = array( + 'name' => 'name', + 'label' => T_('Name'), + 'type' => 'text', + 'widget' => array('input', 'text') + ); + $this->types[] = array( + 'name' => 'category', + 'label' => T_('Category'), + 'type' => 'text', + 'widget' => array('input', 'text') + ); + break; } // end switch on searchtype } // end constructor @@ -1112,7 +1133,7 @@ class Search extends playlist_object switch ($rule[0]) { case 'anywhere': - $where[] = "(`artist`.`name` $sql_match_operator '$input' OR `album`.`name` $sql_match_operator '$input' OR `song_data`.`comment` $sql_match_operator '$input' OR `song`.`file` $sql_match_operator '$input' OR `song`.`title` $sql_match_operator '$input')"; + $where[] = "(`artist`.`name` $sql_match_operator '$input' OR `album`.`name` $sql_match_operator '$input' OR `song_data`.`comment` $sql_match_operator '$input' OR `song_data`.`label` $sql_match_operator '$input' OR `song`.`file` $sql_match_operator '$input' OR `song`.`title` $sql_match_operator '$input')"; $join['album'] = true; $join['artist'] = true; $join['song_data'] = true; @@ -1150,6 +1171,10 @@ class Search extends playlist_object $where[] = "`song_data`.`comment` $sql_match_operator '$input'"; $join['song_data'] = true; break; + case 'label': + $where[] = "`song_data`.`label` $sql_match_operator '$input'"; + $join['song_data'] = true; + break; case 'played': $where[] = " `song`.`played` = '$input'"; break; @@ -1405,4 +1430,54 @@ class Search extends playlist_object 'having_sql' => $having_sql ); } + + /** + * label_to_sql + * + * Handles the generation of the SQL for label searches. + */ + private function label_to_sql() + { + $sql_logic_operator = $this->logic_operator; + $where = array(); + $table = array(); + + foreach ($this->rules as $rule) { + $type = $this->name_to_basetype($rule[0]); + $operator = array(); + foreach ($this->basetypes[$type] as $op) { + if ($op['name'] == $rule[1]) { + $operator = $op; + break; + } + } + $input = $this->_mangle_data($rule[2], $type, $operator); + $sql_match_operator = $operator['sql']; + + switch ($rule[0]) { + case 'name': + $where[] = "`label`.`name` $sql_match_operator '$input'"; + break; + case 'category': + $where[] = "`label`.`category` $sql_match_operator '$input'"; + break; + default: + // Nihil + break; + } // switch on ruletype + } // foreach rule + + $where_sql = implode(" $sql_logic_operator ", $where); + + return array( + 'base' => 'SELECT DISTINCT(`label`.`id`) FROM `label`', + 'join' => $join, + 'where' => $where, + 'where_sql' => $where_sql, + 'table' => $table, + 'table_sql' => '', + 'group_sql' => '', + 'having_sql' => '' + ); + } } diff --git a/lib/class/update.class.php b/lib/class/update.class.php index a77dbeed..7e004366 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -497,6 +497,9 @@ class Update $update_string = " - Add WebDAV backend preference.
"; $version[] = array('version' => '370032','description' => $update_string); + $update_string = " - Add Label tables.
"; + $version[] = array('version' => '370033','description' => $update_string); + return $version; } @@ -3407,4 +3410,37 @@ class Update return $retval; } + + /** + * update_370033 + * + * Add Label tables. + */ + public static function update_370033() + { + $retval = true; + + $sql = "CREATE TABLE `label` (" . + "`id` int(11) unsigned NOT NULL AUTO_INCREMENT," . + "`name` varchar(80) NOT NULL," . + "`category` varchar(40) NULL," . + "`summary` TEXT CHARACTER SET utf8 NULL," . + "`address` varchar(256) NULL," . + "`email` varchar(128) NULL," . + "`website` varchar(256) NULL," . + "`user` int(11) unsigned NULL," . + "`creation_date` int(11) unsigned NULL," . + "PRIMARY KEY (`id`)) ENGINE = MYISAM"; + $retval = Dba::write($sql) ? $retval : false; + + $sql = "CREATE TABLE `label_asso` (" . + "`id` int(11) unsigned NOT NULL AUTO_INCREMENT," . + "`label` int(11) unsigned NOT NULL," . + "`artist` int(11) unsigned NOT NULL," . + "`creation_date` int(11) unsigned NULL," . + "PRIMARY KEY (`id`)) ENGINE = MYISAM"; + $retval = Dba::write($sql) ? $retval : false; + + return $retval; + } } diff --git a/lib/init.php b/lib/init.php index aab2d03f..5286e516 100644 --- a/lib/init.php +++ b/lib/init.php @@ -66,7 +66,7 @@ if (!empty($link)) { $results['load_time_begin'] = $load_time_begin; /** This is the version.... fluf nothing more... **/ $results['version'] = '3.8.0-develop'; -$results['int_config_version'] = '27'; +$results['int_config_version'] = '28'; if (!empty($results['force_ssl'])) { $http_type = 'https://'; diff --git a/lib/javascript/tools.js b/lib/javascript/tools.js index e9b63560..454bab09 100644 --- a/lib/javascript/tools.js +++ b/lib/javascript/tools.js @@ -198,6 +198,7 @@ function handleShareAction(url) { /***************************************************/ var tag_choices = undefined; +var label_choices = undefined; function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix) { var parent = this; @@ -222,12 +223,29 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro }, type: 'post', dataType: 'xml' }); return; + } + parent.editLabelChoices = new Array(); + if (label_choices == undefined && label_choices != '') { + // Load tag map + $.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_labels', { + success: function(data) { + label_choices = $(data).find('content').text(); + if (label_choices != '') { + showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix); + } + }, type: 'post', dataType: 'xml' + }); + return; } var splitted = tag_choices.split(','); var i; for (i = 0; i < splitted.length; ++i) { parent.editTagChoices.push($.trim(splitted[i])); } + splitted = label_choices.split(','); + for (i = 0; i < splitted.length; ++i) { + parent.editLabelChoices.push($.trim(splitted[i])); + } parent.dialog_buttons = {}; this.dialog_buttons[jsSaveTitle] = function () { @@ -289,6 +307,14 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro singleFieldDelimiter: ',', availableTags: parent.editTagChoices }); + } + if ($('#edit_labels').length > 0) { + $("#edit_labels").tagit({ + allowSpaces: true, + singleField: true, + singleFieldDelimiter: ',', + availableTags: parent.editLabelChoices + }); } }); }, diff --git a/server/edit.server.php b/server/edit.server.php index 6a9622e4..19a637fd 100644 --- a/server/edit.server.php +++ b/server/edit.server.php @@ -90,6 +90,7 @@ switch ($_REQUEST['action']) { $libitem = new $object_type($_POST['id']); if ($libitem->get_user_owner() == $GLOBALS['user']->id && AmpConfig::get('upload_allow_edit') && !Access::check('interface', 50)) { // TODO: improve this uniqueless check + if (isset($_POST['user'])) unset($_POST['user']); if (isset($_POST['artist'])) unset($_POST['artist']); if (isset($_POST['artist_name'])) unset($_POST['artist_name']); if (isset($_POST['album'])) unset($_POST['album']); @@ -99,6 +100,9 @@ switch ($_REQUEST['action']) { if (isset($_POST['edit_tags'])) { $_POST['edit_tags'] = Tag::clean_to_existing($_POST['edit_tags']); } + if (isset($_POST['edit_labels'])) { + $_POST['edit_labels'] = Label::clean_to_existing($_POST['edit_labels']); + } // Check mbid and *_mbid match as it is used as identifier if (isset($_POST['mbid'])) { $_POST['mbid'] = $libitem->mbid; diff --git a/server/index.ajax.php b/server/index.ajax.php index cf0d38fb..840c922b 100644 --- a/server/index.ajax.php +++ b/server/index.ajax.php @@ -127,6 +127,25 @@ switch ($_REQUEST['action']) { $results['concerts'] = ob_get_clean(); } break; + case 'labels': + if (AmpConfig::get('label') && isset($_REQUEST['artist'])) { + $labels = Label::get_labels($_REQUEST['artist']); + $object_ids = array(); + if (count($labels) > 0) { + foreach ($labels as $id => $label) { + $object_ids[] = $id; + } + } + $browse = new Browse(); + $browse->set_type('label'); + $browse->set_simple_browse(true); + $browse->save_objects($object_ids); + $browse->store(); + ob_start(); + require_once AmpConfig::get('prefix') . '/templates/show_labels.inc.php'; + $results['labels'] = ob_get_clean(); + } + break; case 'wanted_missing_albums': if (AmpConfig::get('wanted') && (isset($_REQUEST['artist']) || isset($_REQUEST['artist_mbid']))) { if (isset($_REQUEST['artist'])) { diff --git a/server/tag.ajax.php b/server/tag.ajax.php index e7450a9a..1e21485f 100644 --- a/server/tag.ajax.php +++ b/server/tag.ajax.php @@ -34,6 +34,10 @@ switch ($_REQUEST['action']) { $tags = Tag::get_display(Tag::get_tags()); $results['tags'] = $tags; break; + case 'get_labels': + $labels = Label::get_display(Label::get_all_labels()); + $results['labels'] = $labels; + break; case 'add_tag': debug_event('tag.ajax', 'Adding new tag...', '5'); Tag::add_tag_map($_GET['type'],$_GET['object_id'],$_GET['tag_id']); diff --git a/templates/show_add_label.inc.php b/templates/show_add_label.inc.php new file mode 100644 index 00000000..924b7a22 --- /dev/null +++ b/templates/show_add_label.inc.php @@ -0,0 +1,76 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + +
+ + +
+ + +
+
+ + +
+
+ diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php index d96e3f86..c29c7592 100644 --- a/templates/show_artist.inc.php +++ b/templates/show_artist.inc.php @@ -165,6 +165,9 @@ if (AmpConfig::get('show_played_times')) {
  • + + +
  • @@ -212,6 +215,14 @@ if (AmpConfig::get('show_concerts')) {
    + +id, 'labels')); +?> +
    + +
    diff --git a/templates/show_edit_artist_row.inc.php b/templates/show_edit_artist_row.inc.php index 13bc541c..4229e5af 100644 --- a/templates/show_edit_artist_row.inc.php +++ b/templates/show_edit_artist_row.inc.php @@ -53,6 +53,12 @@ + + + + + +   diff --git a/templates/show_edit_label_row.inc.php b/templates/show_edit_label_row.inc.php new file mode 100644 index 00000000..88230089 --- /dev/null +++ b/templates/show_edit_label_row.inc.php @@ -0,0 +1,59 @@ + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + +
    +
    diff --git a/templates/show_label.inc.php b/templates/show_label.inc.php new file mode 100644 index 00000000..58db2493 --- /dev/null +++ b/templates/show_label.inc.php @@ -0,0 +1,104 @@ + +set_type($object_type); + +UI::show_box_top($label->f_name, 'info-box'); +?> +
    + +
    +
    + id, $label->f_name, 2); ?> +
    + address) + echo scrub_out($label->address) . "
    "; + if ($label->email) + echo "email) . "\">" . scrub_out($label->email) . "
    "; + if ($label->website) + echo "website) . "\">" . scrub_out($label->website) . "
    "; + ?> +
    +
    +
    + summary)); ?> +
    +
    +
    + +
    +

    :

    + +
    + +
    +
    + +
    +
    +
    +show_objects($object_ids, true); + $browse->store(); +?> +
    +
    +
    diff --git a/templates/show_label_row.inc.php b/templates/show_label_row.inc.php new file mode 100644 index 00000000..00e374dc --- /dev/null +++ b/templates/show_label_row.inc.php @@ -0,0 +1,49 @@ + +f_name); +?> + + id, $name, 1, AmpConfig::get('web_path') . '/labels.php?action=show&label=' . $libitem->id); + ?> + + +f_link; ?> +category; ?> +artists; ?> + + + + + + + + +can_edit()) { ?> + + + + + diff --git a/templates/show_labels.inc.php b/templates/show_labels.inc.php new file mode 100644 index 00000000..69d2c5d2 --- /dev/null +++ b/templates/show_labels.inc.php @@ -0,0 +1,76 @@ + + +
    + +
    + +get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?> + + + + + + + + + + + + + + format(); + ?> + + + + + + + + + + + + + + + + + + + + + +
    id . '&type=label&sort=name', T_('Label'),'label_sort_name'); ?>id . '&type=label&sort=category', T_('Category'),'label_sort_category'); ?>
    id . '&type=label&sort=name', T_('Label'),'label_sort_name'); ?>id . '&type=label&sort=category', T_('Category'),'label_sort_category'); ?>
    + + +get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?> diff --git a/templates/show_song.inc.php b/templates/show_song.inc.php index 56d3fc3f..ef70bf22 100644 --- a/templates/show_song.inc.php +++ b/templates/show_song.inc.php @@ -117,7 +117,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id; $songprops[gettext_noop('Links')] .= " f_artist) . "%22+%22" . rawurlencode($song->f_title) . "%22&type=track\" target=\"_blank\">" . UI::get_icon('lastfm', T_('Search on Last.fm ...')) . ""; $songprops[gettext_noop('Length')] = scrub_out($song->f_time); $songprops[gettext_noop('Comment')] = scrub_out($song->comment); - $songprops[gettext_noop('Label')] = scrub_out($song->label); + $songprops[gettext_noop('Label')] = AmpConfig::get('label') ? "label) . "\">" . scrub_out($song->label) . "" : scrub_out($song->label); $songprops[gettext_noop('Song Language')]= scrub_out($song->language); $songprops[gettext_noop('Catalog Number')] = scrub_out($song->catalog_number); $songprops[gettext_noop('Bitrate')] = scrub_out($song->f_bitrate); diff --git a/templates/sidebar_home.inc.php b/templates/sidebar_home.inc.php index b26155fd..4bf8315d 100644 --- a/templates/sidebar_home.inc.php +++ b/templates/sidebar_home.inc.php @@ -32,6 +32,9 @@
  • + +
  • +