diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-05-16 01:14:09 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-05-16 01:14:09 +0000 |
commit | 3893266308662006a5c658fcdbaabf6c532183e2 (patch) | |
tree | dba9b8e5f9596d97087a03286ff7800d20a25273 /modules/php_musicbrainz | |
parent | 164616c0f1b2361cb6f3e0e0040359301e1b8068 (diff) | |
download | ampache-3893266308662006a5c658fcdbaabf6c532183e2.tar.gz ampache-3893266308662006a5c658fcdbaabf6c532183e2.tar.bz2 ampache-3893266308662006a5c658fcdbaabf6c532183e2.zip |
php_musicbrainz: Even more code cleanup, add support for rating submission.
Diffstat (limited to 'modules/php_musicbrainz')
-rw-r--r-- | modules/php_musicbrainz/mbLabelAlias.php | 4 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbMetadata.php | 152 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbQuery.php | 22 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbRelation.php | 2 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbReleaseEvent.php | 52 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbUser.php | 50 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbUtil.php | 100 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbUtil_countrynames.php | 496 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbUtil_languagenames.php | 790 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbUtil_releasetypenames.php | 36 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbUtil_scriptnames.php | 108 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbWebService.php | 8 | ||||
-rw-r--r-- | modules/php_musicbrainz/mbXmlParser.php | 798 | ||||
-rw-r--r-- | modules/php_musicbrainz/xml/xmlParser.php | 209 |
14 files changed, 1432 insertions, 1395 deletions
diff --git a/modules/php_musicbrainz/mbLabelAlias.php b/modules/php_musicbrainz/mbLabelAlias.php index d9922730..4d62cba6 100644 --- a/modules/php_musicbrainz/mbLabelAlias.php +++ b/modules/php_musicbrainz/mbLabelAlias.php @@ -1,4 +1,4 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - class mbLabelArtist extends mbArtistAlias { } +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +class mbLabelAlias extends mbArtistAlias { } ?> diff --git a/modules/php_musicbrainz/mbMetadata.php b/modules/php_musicbrainz/mbMetadata.php index 9581d8f1..f860a58d 100644 --- a/modules/php_musicbrainz/mbMetadata.php +++ b/modules/php_musicbrainz/mbMetadata.php @@ -1,92 +1,92 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ class mbMetadata { - private $artist = null; - private $track = null; - private $release = null; - private $label = null; - private $rating = null; - private $artistList; - private $trackList; - private $releaseList; - private $userList; + private $artist = null; + private $track = null; + private $release = null; + private $label = null; + private $rating = null; + private $artistList; + private $trackList; + private $releaseList; + private $userList; - function mbMetadata() { - $this->artistList = array(); - $this->trackList = array(); - $this->releaseList = array(); - $this->userList = array(); - } + public function __construct() { + $this->artistList = array(); + $this->trackList = array(); + $this->releaseList = array(); + $this->userList = array(); + } - function setArtist(mbArtist $artist) { $this->artist = $artist; } - function setTrack(mbTrack $track) { $this->track = $track; } - function setRating(mbRating $rating) { $this->rating = $rating; } - function setRelease(mbRelease $release) { $this->release = $release; } - function setLabel(mbLabel $label) { $this->label = $label; } + public function setArtist(mbArtist $artist) { $this->artist = $artist; } + public function setTrack(mbTrack $track) { $this->track = $track; } + public function setRating(mbRating $rating) { $this->rating = $rating; } + public function setRelease(mbRelease $release) { $this->release = $release; } + public function setLabel(mbLabel $label) { $this->label = $label; } - function getArtist($remove=false) { - $a = $this->artist; - if ($remove) - $this->artist = null; - return $a; - } + public function getArtist($remove=false) { + $a = $this->artist; + if ($remove) + $this->artist = null; + return $a; + } - function getTrack($remove=false) { - $t = $this->track; - if ($remove) - $this->track = null; - return $t; - } + public function getTrack($remove=false) { + $t = $this->track; + if ($remove) + $this->track = null; + return $t; + } - function getRating($remove=false) { - $r = $this->rating; - if ($remove) { - $this->rating = null; - } - return $r; - } + public function getRating($remove=false) { + $r = $this->rating; + if ($remove) { + $this->rating = null; + } + return $r; + } - function getRelease($remove=false) { - $r = $this->release; - if ($remove) - $this->release = null; - return $r; - } + public function getRelease($remove=false) { + $r = $this->release; + if ($remove) + $this->release = null; + return $r; + } - function getLabel($remove=false) { - $l = $this->label; - if ($remove) - $this->label = null; - return $l; - } + public function getLabel($remove=false) { + $l = $this->label; + if ($remove) + $this->label = null; + return $l; + } - function getUserList() { return $this->userList; } - function getArtistResults() { return $this->artistList; } - function getTrackResults() { return $this->trackList; } - function getReleaseResults() { return $this->releaseList; } + public function getUserList() { return $this->userList; } + public function getArtistResults() { return $this->artistList; } + public function getTrackResults() { return $this->trackList; } + public function getReleaseResults() { return $this->releaseList; } - function getUserList2($remove) { - $ul = $this->userList; - $this->userList = array(); - return $ul; - } + public function getUserList2($remove) { + $ul = $this->userList; + $this->userList = array(); + return $ul; + } - function getArtistResults2($remove) { - $al = $this->artistList; - $this->artistList = array(); - return $al; - } + public function getArtistResults2($remove) { + $al = $this->artistList; + $this->artistList = array(); + return $al; + } - function getTrackResults2($remove) { - $tl = $this->trackList; - $this->trackList = array(); - return $tl; - } + public function getTrackResults2($remove) { + $tl = $this->trackList; + $this->trackList = array(); + return $tl; + } - function getReleaseResults2($remove) { - $rl = $this->releaseList; - $this->releaseList = array(); - return $rl; - } + public function getReleaseResults2($remove) { + $rl = $this->releaseList; + $this->releaseList = array(); + return $rl; + } } ?> diff --git a/modules/php_musicbrainz/mbQuery.php b/modules/php_musicbrainz/mbQuery.php index 0c2ab3a6..87575e63 100644 --- a/modules/php_musicbrainz/mbQuery.php +++ b/modules/php_musicbrainz/mbQuery.php @@ -123,6 +123,26 @@ class MusicBrainzQuery { } } + /* + * submitRatings + * Expects a multidimensional array + * [n] => Array ( + * [mbid] => UUID + * [entity_type] => [artist|release|track|label] + * [rating] => [0-5] + * ) + */ + public function submitUserRating($entityURI, $rating) { + $mbid = extractUuid($entityURI); + $entity = extractEntityType($entityURI); + + $params['id'] = $mbid; + $params['entity'] = $entity; + $params['rating'] = $rating; + + $this->ws->post('rating', '', $params); + } + public function submitPuids(array $tracks2puids) { if (empty($this->clientId)) { throw WebServiceError("Please supply a client ID"); @@ -133,7 +153,7 @@ class MusicBrainzQuery { foreach ($tracks2puids as $puid => $track) { $params[] = array('puid', extractUuid($puid).' '.$track); } - $this->ws->post("track", "", urlencode($params)); + $this->ws->post("track", "", $params); } } ?> diff --git a/modules/php_musicbrainz/mbRelation.php b/modules/php_musicbrainz/mbRelation.php index 1482fc5f..411e2f25 100644 --- a/modules/php_musicbrainz/mbRelation.php +++ b/modules/php_musicbrainz/mbRelation.php @@ -22,7 +22,7 @@ class mbRelation { public function __construct($relationType = '', $targetType = '', $targetId = '', - $direction = DIR_BOTH, + $direction = self::DIR_BOTH, array $attributes = array(), $beginDate = '', $endDate = '', diff --git a/modules/php_musicbrainz/mbReleaseEvent.php b/modules/php_musicbrainz/mbReleaseEvent.php index 3131ea55..4da695d4 100644 --- a/modules/php_musicbrainz/mbReleaseEvent.php +++ b/modules/php_musicbrainz/mbReleaseEvent.php @@ -1,32 +1,32 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - class mbReleaseEvent { - private $country; - private $dateStr; - private $catalogNumber; - private $barcode; - private $label = null; +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +class mbReleaseEvent { + private $country; + private $dateStr; + private $catalogNumber; + private $barcode; + private $label = null; - function mbReleaseEvent( $country = '', $dateStr = '' ) { - $this->country = $country; - $this->dateStr = $dateStr; - } + public function __construct($country = '', $dateStr = '') { + $this->country = $country; + $this->dateStr = $dateStr; + } - function setCountry ( $country ) { $this->country = $country; } - function getCountry ( ) { return $this->country; } - function setCatalogNumber( $c_number ) { $this->catalogNumber = $c_number; } - function getCatalogNumber( ) { return $this->catalogNumber; } - function setBarcode ( $barcode ) { $this->barcode = $barcode; } - function getBarcode ( ) { return $this->barcode; } - function setDate ( $date ) { $this->date = $date; } - function getDate ( ) { return $this->date; } + public function setCountry ($country ) { $this->country = $country; } + public function getCountry ( ) { return $this->country; } + public function setCatalogNumber($c_number) { $this->catalogNumber = $c_number; } + public function getCatalogNumber( ) { return $this->catalogNumber; } + public function setBarcode ($barcode ) { $this->barcode = $barcode; } + public function getBarcode ( ) { return $this->barcode; } + public function setDate ($date ) { $this->date = $date; } + public function getDate ( ) { return $this->date; } - function setLabel( Label $label ) { - $this->label = $label; - } + public function setLabel(Label $label) { + $this->label = $label; + } - function getLabel() { - return $this->label; - } - } + public function getLabel() { + return $this->label; + } +} ?> diff --git a/modules/php_musicbrainz/mbUser.php b/modules/php_musicbrainz/mbUser.php index 8317bebb..ee9349fd 100644 --- a/modules/php_musicbrainz/mbUser.php +++ b/modules/php_musicbrainz/mbUser.php @@ -1,34 +1,34 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - class mbUser { - private $name; - private $showNag = false; - private $types = array(); +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +class mbUser { + private $name; + private $showNag = false; + private $types = array(); - function mbUser() { - } + public function __construct() { + } - function setName( $name ) { $this->name = $name; } - function getName() { return $this->name; } + public function setName($name) { $this->name = $name; } + public function getName() { return $this->name; } - function getShowNag() { - return $this->showNag; - } + public function getShowNag() { + return $this->showNag; + } - function setShowNag( $value ) { - $this->setShowNag = $value; - } + public function setShowNag($value) { + $this->setShowNag = $value; + } - function addType( $type ) { - $this->types[] = $type; - } + public function addType($type) { + $this->types[] = $type; + } - function getNumTypes() { - return count($this->types); - } + public function getNumTypes() { + return count($this->types); + } - function getType( $i ) { - return $this->types[$i]; - } - } + public function getType($i) { + return $this->types[$i]; + } +} ?> diff --git a/modules/php_musicbrainz/mbUtil.php b/modules/php_musicbrainz/mbUtil.php index 4ebdb33a..ab8a2ac4 100644 --- a/modules/php_musicbrainz/mbUtil.php +++ b/modules/php_musicbrainz/mbUtil.php @@ -1,63 +1,77 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - class mbValueError extends Exception {} +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +class mbValueError extends Exception {} - function extractFragment( $type ) { - if ( ( $p = parse_url( $type ) ) == false ) { - return $type; +function extractFragment($type) { + if (($p = parse_url($type)) == false) { + return $type; + } + return $p['fragment']; +} + +function extractEntityType($uri) { + if (empty($uri)) { return $uri; } + + $types = array('artist/', 'release/', 'track/', 'label/', 'release-group/'); + foreach ($types as $type) { + if (strpos($uri, $type) !== false) { + return rtrim($type, '/'); } - return $p['fragment']; } + throw new mbValueError("$uri is not a valid MusicBrainz URI.", 1); +} - function extractUuid( $uid ) { - if ( empty($uid) ) - return $uid; - - $types = array( "artist/", "release/", "track/" ); - for ( $i = 0; $i < 3; $i++ ) { - if ( ($pos = strpos( $uid, $types[$i] )) !== false ) { - $pos += strlen($types[$i]); - if ( $pos + 36 == strlen($uid) ) { - return substr( $uid, $pos, 36 ); - } - } - } +function extractUuid($uid) { + if (empty($uid)) { return $uid; } - if ( strlen($uid) == 36 ) - return $uid; + if (strlen($uid) == 36) { return $uid; } - throw new mbValueError( "$uid is not a valid MusicBrainz ID.", 1 ); - } + $types = array("artist/", "release/", "track/", "label/", "release-group/"); + foreach ($types as $type) { + if (($pos = strpos($uid, $type)) !== false) { + $pos += strlen($type); + if ($pos + 36 == strlen($uid)) { + return substr($uid, $pos, 36); + } + } + } - require_once( 'mbUtil_countrynames.php' ); - function getCountryName( $id ) { - if ( isset( $mbCountryNames[$id] ) ) - return $mbCountryNames[$id]; + throw new mbValueError("$uid is not a valid MusicBrainz ID.", 1); +} - return ""; +require_once('mbUtil_countrynames.php'); +function getCountryName($id) { + if (isset($mbCountryNames[$id])) { + return $mbCountryNames[$id]; } - require_once( 'mbUtil_languagenames.php' ); - function getLanguageName( $id ) { - if ( isset( $mbLanguageNames[$id] ) ) - return $mbLanguageNames[$id]; + return ""; +} - return ""; +require_once('mbUtil_languagenames.php'); +function getLanguageName($id) { + if (isset($mbLanguageNames[$id])) { + return $mbLanguageNames[$id]; } - require_once( 'mbUtil_scriptnames.php' ); - function getScriptName( $id ) { - if ( isset( $mbScriptNames[$id] ) ) - return $mbScriptNames[$id]; + return ""; +} - return ""; +require_once('mbUtil_scriptnames.php'); +function getScriptName($id) { + if (isset($mbScriptNames[$id])) { + return $mbScriptNames[$id]; } - require_once( 'mbUtil_releasetypenames.php' ); - function getReleaseTypeName( $id ) { - if ( isset( $mbReleaseTypeNames[$id] ) ) - return $mbReleaseTypeNames[$id]; + return ""; +} - return ""; +require_once('mbUtil_releasetypenames.php'); +function getReleaseTypeName($id) { + if (isset($mbReleaseTypeNames[$id])) { + return $mbReleaseTypeNames[$id]; } + + return ""; +} ?> diff --git a/modules/php_musicbrainz/mbUtil_countrynames.php b/modules/php_musicbrainz/mbUtil_countrynames.php index c2fa37f8..13694957 100644 --- a/modules/php_musicbrainz/mbUtil_countrynames.php +++ b/modules/php_musicbrainz/mbUtil_countrynames.php @@ -1,250 +1,250 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - $mbCountryNames = array( - "BD" => "Bangladesh", - "BE" => "Belgium", - "BF" => "Burkina Faso", - "BG" => "Bulgaria", - "BB" => "Barbados", - "WF" => "Wallis and Futuna Islands", - "BM" => "Bermuda", - "BN" => "Brunei Darussalam", - "BO" => "Bolivia", - "BH" => "Bahrain", - "BI" => "Burundi", - "BJ" => "Benin", - "BT" => "Bhutan", - "JM" => "Jamaica", - "BV" => "Bouvet Island", - "BW" => "Botswana", - "WS" => "Samoa", - "BR" => "Brazil", - "BS" => "Bahamas", - "BY" => "Belarus", - "BZ" => "Belize", - "RU" => "Russian Federation", - "RW" => "Rwanda", - "RE" => "Reunion", - "TM" => "Turkmenistan", - "TJ" => "Tajikistan", - "RO" => "Romania", - "TK" => "Tokelau", - "GW" => "Guinea-Bissau", - "GU" => "Guam", - "GT" => "Guatemala", - "GR" => "Greece", - "GQ" => "Equatorial Guinea", - "GP" => "Guadeloupe", - "JP" => "Japan", - "GY" => "Guyana", - "GF" => "French Guiana", - "GE" => "Georgia", - "GD" => "Grenada", - "GB" => "United Kingdom", - "GA" => "Gabon", - "SV" => "El Salvador", - "GN" => "Guinea", - "GM" => "Gambia", - "GL" => "Greenland", - "GI" => "Gibraltar", - "GH" => "Ghana", - "OM" => "Oman", - "TN" => "Tunisia", - "JO" => "Jordan", - "HT" => "Haiti", - "HU" => "Hungary", - "HK" => "Hong Kong", - "HN" => "Honduras", - "HM" => "Heard and Mc Donald Islands", - "VE" => "Venezuela", - "PR" => "Puerto Rico", - "PW" => "Palau", - "PT" => "Portugal", - "SJ" => "Svalbard and Jan Mayen Islands", - "PY" => "Paraguay", - "IQ" => "Iraq", - "PA" => "Panama", - "PF" => "French Polynesia", - "PG" => "Papua New Guinea", - "PE" => "Peru", - "PK" => "Pakistan", - "PH" => "Philippines", - "PN" => "Pitcairn", - "PL" => "Poland", - "PM" => "St. Pierre and Miquelon", - "ZM" => "Zambia", - "EH" => "Western Sahara", - "EE" => "Estonia", - "EG" => "Egypt", - "ZA" => "South Africa", - "EC" => "Ecuador", - "IT" => "Italy", - "VN" => "Viet Nam", - "SB" => "Solomon Islands", - "ET" => "Ethiopia", - "SO" => "Somalia", - "ZW" => "Zimbabwe", - "SA" => "Saudi Arabia", - "ES" => "Spain", - "ER" => "Eritrea", - "MD" => "Moldova, Republic of", - "MG" => "Madagascar", - "MA" => "Morocco", - "MC" => "Monaco", - "UZ" => "Uzbekistan", - "MM" => "Myanmar", - "ML" => "Mali", - "MO" => "Macau", - "MN" => "Mongolia", - "MH" => "Marshall Islands", - "MK" => "Macedonia, The Former Yugoslav Republic of", - "MU" => "Mauritius", - "MT" => "Malta", - "MW" => "Malawi", - "MV" => "Maldives", - "MQ" => "Martinique", - "MP" => "Northern Mariana Islands", - "MS" => "Montserrat", - "MR" => "Mauritania", - "UG" => "Uganda", - "MY" => "Malaysia", - "MX" => "Mexico", - "IL" => "Israel", - "FR" => "France", - "IO" => "British Indian Ocean Territory", - "SH" => "St. Helena", - "FI" => "Finland", - "FJ" => "Fiji", - "FK" => "Falkland Islands (Malvinas)", - "FM" => "Micronesia, Federated States of", - "FO" => "Faroe Islands", - "NI" => "Nicaragua", - "NL" => "Netherlands", - "NO" => "Norway", - "NA" => "Namibia", - "VU" => "Vanuatu", - "NC" => "New Caledonia", - "NE" => "Niger", - "NF" => "Norfolk Island", - "NG" => "Nigeria", - "NZ" => "New Zealand", - "ZR" => "Zaire", - "NP" => "Nepal", - "NR" => "Nauru", - "NU" => "Niue", - "CK" => "Cook Islands", - "CI" => "Cote d'Ivoire", - "CH" => "Switzerland", - "CO" => "Colombia", - "CN" => "China", - "CM" => "Cameroon", - "CL" => "Chile", - "CC" => "Cocos (Keeling) Islands", - "CA" => "Canada", - "CG" => "Congo", - "CF" => "Central African Republic", - "CZ" => "Czech Republic", - "CY" => "Cyprus", - "CX" => "Christmas Island", - "CR" => "Costa Rica", - "CV" => "Cape Verde", - "CU" => "Cuba", - "SZ" => "Swaziland", - "SY" => "Syrian Arab Republic", - "KG" => "Kyrgyzstan", - "KE" => "Kenya", - "SR" => "Suriname", - "KI" => "Kiribati", - "KH" => "Cambodia", - "KN" => "Saint Kitts and Nevis", - "KM" => "Comoros", - "ST" => "Sao Tome and Principe", - "SI" => "Slovenia", - "KW" => "Kuwait", - "SN" => "Senegal", - "SM" => "San Marino", - "SL" => "Sierra Leone", - "SC" => "Seychelles", - "KZ" => "Kazakhstan", - "KY" => "Cayman Islands", - "SG" => "Singapore", - "SE" => "Sweden", - "SD" => "Sudan", - "DO" => "Dominican Republic", - "DM" => "Dominica", - "DJ" => "Djibouti", - "DK" => "Denmark", - "VG" => "Virgin Islands (British)", - "DE" => "Germany", - "YE" => "Yemen", - "DZ" => "Algeria", - "US" => "United States", - "UY" => "Uruguay", - "YT" => "Mayotte", - "UM" => "United States Minor Outlying Islands", - "LB" => "Lebanon", - "LC" => "Saint Lucia", - "LA" => "Lao People's Democratic Republic", - "TV" => "Tuvalu", - "TW" => "Taiwan", - "TT" => "Trinidad and Tobago", - "TR" => "Turkey", - "LK" => "Sri Lanka", - "LI" => "Liechtenstein", - "LV" => "Latvia", - "TO" => "Tonga", - "LT" => "Lithuania", - "LU" => "Luxembourg", - "LR" => "Liberia", - "LS" => "Lesotho", - "TH" => "Thailand", - "TF" => "French Southern Territories", - "TG" => "Togo", - "TD" => "Chad", - "TC" => "Turks and Caicos Islands", - "LY" => "Libyan Arab Jamahiriya", - "VA" => "Vatican City State (Holy See)", - "VC" => "Saint Vincent and The Grenadines", - "AE" => "United Arab Emirates", - "AD" => "Andorra", - "AG" => "Antigua and Barbuda", - "AF" => "Afghanistan", - "AI" => "Anguilla", - "VI" => "Virgin Islands (U.S.)", - "IS" => "Iceland", - "IR" => "Iran (Islamic Republic of)", - "AM" => "Armenia", - "AL" => "Albania", - "AO" => "Angola", - "AN" => "Netherlands Antilles", - "AQ" => "Antarctica", - "AS" => "American Samoa", - "AR" => "Argentina", - "AU" => "Australia", - "AT" => "Austria", - "AW" => "Aruba", - "IN" => "India", - "TZ" => "Tanzania, United Republic of", - "AZ" => "Azerbaijan", - "IE" => "Ireland", - "ID" => "Indonesia", - "UA" => "Ukraine", - "QA" => "Qatar", - "MZ" => "Mozambique", - "BA" => "Bosnia and Herzegovina", - "CD" => "Congo, The Democratic Republic of the", - "CS" => "Serbia and Montenegro", - "HR" => "Croatia", - "KP" => "Korea (North), Democratic People's Republic of", - "KR" => "Korea (South), Republic of", - "SK" => "Slovakia", - "SU" => "Soviet Union (historical, 1922-1991)", - "TL" => "East Timor", - "XC" => "Czechoslovakia (historical, 1918-1992)", - "XE" => "Europe", - "XG" => "East Germany (historical, 1949-1990)", - "XU" => "[Unknown Country]", - "XW" => "[Worldwide]", - "YU" => "Yugoslavia (historical, 1918-1992)" - ); +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +$mbCountryNames = array( + "BD" => "Bangladesh", + "BE" => "Belgium", + "BF" => "Burkina Faso", + "BG" => "Bulgaria", + "BB" => "Barbados", + "WF" => "Wallis and Futuna Islands", + "BM" => "Bermuda", + "BN" => "Brunei Darussalam", + "BO" => "Bolivia", + "BH" => "Bahrain", + "BI" => "Burundi", + "BJ" => "Benin", + "BT" => "Bhutan", + "JM" => "Jamaica", + "BV" => "Bouvet Island", + "BW" => "Botswana", + "WS" => "Samoa", + "BR" => "Brazil", + "BS" => "Bahamas", + "BY" => "Belarus", + "BZ" => "Belize", + "RU" => "Russian Federation", + "RW" => "Rwanda", + "RE" => "Reunion", + "TM" => "Turkmenistan", + "TJ" => "Tajikistan", + "RO" => "Romania", + "TK" => "Tokelau", + "GW" => "Guinea-Bissau", + "GU" => "Guam", + "GT" => "Guatemala", + "GR" => "Greece", + "GQ" => "Equatorial Guinea", + "GP" => "Guadeloupe", + "JP" => "Japan", + "GY" => "Guyana", + "GF" => "French Guiana", + "GE" => "Georgia", + "GD" => "Grenada", + "GB" => "United Kingdom", + "GA" => "Gabon", + "SV" => "El Salvador", + "GN" => "Guinea", + "GM" => "Gambia", + "GL" => "Greenland", + "GI" => "Gibraltar", + "GH" => "Ghana", + "OM" => "Oman", + "TN" => "Tunisia", + "JO" => "Jordan", + "HT" => "Haiti", + "HU" => "Hungary", + "HK" => "Hong Kong", + "HN" => "Honduras", + "HM" => "Heard and Mc Donald Islands", + "VE" => "Venezuela", + "PR" => "Puerto Rico", + "PW" => "Palau", + "PT" => "Portugal", + "SJ" => "Svalbard and Jan Mayen Islands", + "PY" => "Paraguay", + "IQ" => "Iraq", + "PA" => "Panama", + "PF" => "French Polynesia", + "PG" => "Papua New Guinea", + "PE" => "Peru", + "PK" => "Pakistan", + "PH" => "Philippines", + "PN" => "Pitcairn", + "PL" => "Poland", + "PM" => "St. Pierre and Miquelon", + "ZM" => "Zambia", + "EH" => "Western Sahara", + "EE" => "Estonia", + "EG" => "Egypt", + "ZA" => "South Africa", + "EC" => "Ecuador", + "IT" => "Italy", + "VN" => "Viet Nam", + "SB" => "Solomon Islands", + "ET" => "Ethiopia", + "SO" => "Somalia", + "ZW" => "Zimbabwe", + "SA" => "Saudi Arabia", + "ES" => "Spain", + "ER" => "Eritrea", + "MD" => "Moldova, Republic of", + "MG" => "Madagascar", + "MA" => "Morocco", + "MC" => "Monaco", + "UZ" => "Uzbekistan", + "MM" => "Myanmar", + "ML" => "Mali", + "MO" => "Macau", + "MN" => "Mongolia", + "MH" => "Marshall Islands", + "MK" => "Macedonia, The Former Yugoslav Republic of", + "MU" => "Mauritius", + "MT" => "Malta", + "MW" => "Malawi", + "MV" => "Maldives", + "MQ" => "Martinique", + "MP" => "Northern Mariana Islands", + "MS" => "Montserrat", + "MR" => "Mauritania", + "UG" => "Uganda", + "MY" => "Malaysia", + "MX" => "Mexico", + "IL" => "Israel", + "FR" => "France", + "IO" => "British Indian Ocean Territory", + "SH" => "St. Helena", + "FI" => "Finland", + "FJ" => "Fiji", + "FK" => "Falkland Islands (Malvinas)", + "FM" => "Micronesia, Federated States of", + "FO" => "Faroe Islands", + "NI" => "Nicaragua", + "NL" => "Netherlands", + "NO" => "Norway", + "NA" => "Namibia", + "VU" => "Vanuatu", + "NC" => "New Caledonia", + "NE" => "Niger", + "NF" => "Norfolk Island", + "NG" => "Nigeria", + "NZ" => "New Zealand", + "ZR" => "Zaire", + "NP" => "Nepal", + "NR" => "Nauru", + "NU" => "Niue", + "CK" => "Cook Islands", + "CI" => "Cote d'Ivoire", + "CH" => "Switzerland", + "CO" => "Colombia", + "CN" => "China", + "CM" => "Cameroon", + "CL" => "Chile", + "CC" => "Cocos (Keeling) Islands", + "CA" => "Canada", + "CG" => "Congo", + "CF" => "Central African Republic", + "CZ" => "Czech Republic", + "CY" => "Cyprus", + "CX" => "Christmas Island", + "CR" => "Costa Rica", + "CV" => "Cape Verde", + "CU" => "Cuba", + "SZ" => "Swaziland", + "SY" => "Syrian Arab Republic", + "KG" => "Kyrgyzstan", + "KE" => "Kenya", + "SR" => "Suriname", + "KI" => "Kiribati", + "KH" => "Cambodia", + "KN" => "Saint Kitts and Nevis", + "KM" => "Comoros", + "ST" => "Sao Tome and Principe", + "SI" => "Slovenia", + "KW" => "Kuwait", + "SN" => "Senegal", + "SM" => "San Marino", + "SL" => "Sierra Leone", + "SC" => "Seychelles", + "KZ" => "Kazakhstan", + "KY" => "Cayman Islands", + "SG" => "Singapore", + "SE" => "Sweden", + "SD" => "Sudan", + "DO" => "Dominican Republic", + "DM" => "Dominica", + "DJ" => "Djibouti", + "DK" => "Denmark", + "VG" => "Virgin Islands (British)", + "DE" => "Germany", + "YE" => "Yemen", + "DZ" => "Algeria", + "US" => "United States", + "UY" => "Uruguay", + "YT" => "Mayotte", + "UM" => "United States Minor Outlying Islands", + "LB" => "Lebanon", + "LC" => "Saint Lucia", + "LA" => "Lao People's Democratic Republic", + "TV" => "Tuvalu", + "TW" => "Taiwan", + "TT" => "Trinidad and Tobago", + "TR" => "Turkey", + "LK" => "Sri Lanka", + "LI" => "Liechtenstein", + "LV" => "Latvia", + "TO" => "Tonga", + "LT" => "Lithuania", + "LU" => "Luxembourg", + "LR" => "Liberia", + "LS" => "Lesotho", + "TH" => "Thailand", + "TF" => "French Southern Territories", + "TG" => "Togo", + "TD" => "Chad", + "TC" => "Turks and Caicos Islands", + "LY" => "Libyan Arab Jamahiriya", + "VA" => "Vatican City State (Holy See)", + "VC" => "Saint Vincent and The Grenadines", + "AE" => "United Arab Emirates", + "AD" => "Andorra", + "AG" => "Antigua and Barbuda", + "AF" => "Afghanistan", + "AI" => "Anguilla", + "VI" => "Virgin Islands (U.S.)", + "IS" => "Iceland", + "IR" => "Iran (Islamic Republic of)", + "AM" => "Armenia", + "AL" => "Albania", + "AO" => "Angola", + "AN" => "Netherlands Antilles", + "AQ" => "Antarctica", + "AS" => "American Samoa", + "AR" => "Argentina", + "AU" => "Australia", + "AT" => "Austria", + "AW" => "Aruba", + "IN" => "India", + "TZ" => "Tanzania, United Republic of", + "AZ" => "Azerbaijan", + "IE" => "Ireland", + "ID" => "Indonesia", + "UA" => "Ukraine", + "QA" => "Qatar", + "MZ" => "Mozambique", + "BA" => "Bosnia and Herzegovina", + "CD" => "Congo, The Democratic Republic of the", + "CS" => "Serbia and Montenegro", + "HR" => "Croatia", + "KP" => "Korea (North), Democratic People's Republic of", + "KR" => "Korea (South), Republic of", + "SK" => "Slovakia", + "SU" => "Soviet Union (historical, 1922-1991)", + "TL" => "East Timor", + "XC" => "Czechoslovakia (historical, 1918-1992)", + "XE" => "Europe", + "XG" => "East Germany (historical, 1949-1990)", + "XU" => "[Unknown Country]", + "XW" => "[Worldwide]", + "YU" => "Yugoslavia (historical, 1918-1992)" +); ?> diff --git a/modules/php_musicbrainz/mbUtil_languagenames.php b/modules/php_musicbrainz/mbUtil_languagenames.php index 3e56bf82..782d37a0 100644 --- a/modules/php_musicbrainz/mbUtil_languagenames.php +++ b/modules/php_musicbrainz/mbUtil_languagenames.php @@ -1,397 +1,397 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - $mbLanguageNames = array( - "ART" => "Artificial (Other)", - "ROH" => "Raeto-Romance", - "SCO" => "Scots", - "SCN" => "Sicilian", - "ROM" => "Romany", - "RON" => "Romanian", - "OSS" => "Ossetian; Ossetic", - "ALE" => "Aleut", - "MNI" => "Manipuri", - "NWC" => "Classical Newari; Old Newari; Classical Nepal Bhasa", - "OSA" => "Osage", - "MNC" => "Manchu", - "MWR" => "Marwari", - "VEN" => "Venda", - "MWL" => "Mirandese", - "FAS" => "Persian", - "FAT" => "Fanti", - "FAN" => "Fang", - "FAO" => "Faroese", - "DIN" => "Dinka", - "HYE" => "Armenian", - "DSB" => "Lower Sorbian", - "CAR" => "Carib", - "DIV" => "Divehi", - "TEL" => "Telugu", - "TEM" => "Timne", - "NBL" => "Ndebele, South; South Ndebele", - "TER" => "Tereno", - "TET" => "Tetum", - "SUN" => "Sundanese", - "KUT" => "Kutenai", - "SUK" => "Sukuma", - "KUR" => "Kurdish", - "KUM" => "Kumyk", - "SUS" => "Susu", - "NEW" => "Newari; Nepal Bhasa", - "KUA" => "Kuanyama; Kwanyama", - "MEN" => "Mende", - "LEZ" => "Lezghian", - "GLA" => "Gaelic; Scottish Gaelic", - "BOS" => "Bosnian", - "GLE" => "Irish", - "EKA" => "Ekajuk", - "GLG" => "Gallegan", - "AKA" => "Akan", - "BOD" => "Tibetan", - "GLV" => "Manx", - "JRB" => "Judeo-Arabic", - "VIE" => "Vietnamese", - "IPK" => "Inupiaq", - "UZB" => "Uzbek", - "BRE" => "Breton", - "BRA" => "Braj", - "AYM" => "Aymara", - "CHA" => "Chamorro", - "CHB" => "Chibcha", - "CHE" => "Chechen", - "CHG" => "Chagatai", - "CHK" => "Chuukese", - "CHM" => "Mari", - "CHN" => "Chinook jargon", - "CHO" => "Choctaw", - "CHP" => "Chipewyan", - "CHR" => "Cherokee", - "CHU" => "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic", - "CHV" => "Chuvash", - "CHY" => "Cheyenne", - "MSA" => "Malay", - "III" => "Sichuan Yi", - "ACE" => "Achinese", - "IBO" => "Igbo", - "IBA" => "Iban", - "XHO" => "Xhosa", - "DEU" => "German", - "CAT" => "Catalan; Valencian", - "DEL" => "Delaware", - "DEN" => "Slave (Athapascan)", - "CAD" => "Caddo", - "TAT" => "Tatar", - "RAJ" => "Rajasthani", - "SPA" => "Spanish; Castilian", - "TAM" => "Tamil", - "TAH" => "Tahitian", - "AFH" => "Afrihili", - "ENG" => "English", - "CSB" => "Kashubian", - "NYN" => "Nyankole", - "NYO" => "Nyoro", - "SID" => "Sidamo", - "NYA" => "Chichewa; Chewa; Nyanja", - "SIN" => "Sinhala; Sinhalese", - "AFR" => "Afrikaans", - "LAM" => "Lamba", - "SND" => "Sindhi", - "MAR" => "Marathi", - "LAH" => "Lahnda", - "NYM" => "Nyamwezi", - "SNA" => "Shona", - "LAD" => "Ladino", - "SNK" => "Soninke", - "MAD" => "Madurese", - "MAG" => "Magahi", - "MAI" => "Maithili", - "MAH" => "Marshallese", - "LAV" => "Latvian", - "MAL" => "Malayalam", - "MAN" => "Mandingo", - "ZND" => "Zande", - "ZEN" => "Zenaga", - "KBD" => "Kabardian", - "ITA" => "Italian", - "VAI" => "Vai", - "TSN" => "Tswana", - "TSO" => "Tsonga", - "TSI" => "Tsimshian", - "BYN" => "Blin; Bilin", - "FIJ" => "Fijian", - "FIN" => "Finnish", - "EUS" => "Basque", - "CEB" => "Cebuano", - "DAN" => "Danish", - "NOG" => "Nogai", - "NOB" => "Norwegian Bokmål; Bokmål, Norwegian", - "DAK" => "Dakota", - "CES" => "Czech", - "DAR" => "Dargwa", - "DAY" => "Dayak", - "NOR" => "Norwegian", - "KPE" => "Kpelle", - "GUJ" => "Gujarati", - "MDF" => "Moksha", - "MAS" => "Masai", - "LAO" => "Lao", - "MDR" => "Mandar", - "GON" => "Gondi", - "SMS" => "Skolt Sami", - "SMO" => "Samoan", - "SMN" => "Inari Sami", - "SMJ" => "Lule Sami", - "GOT" => "Gothic", - "SME" => "Northern Sami", - "BLA" => "Siksika", - "SMA" => "Southern Sami", - "GOR" => "Gorontalo", - "AST" => "Asturian; Bable", - "ORM" => "Oromo", - "QUE" => "Quechua", - "ORI" => "Oriya", - "CRH" => "Crimean Tatar; Crimean Turkish", - "ASM" => "Assamese", - "PUS" => "Pushto", - "DGR" => "Dogrib", - "LTZ" => "Luxembourgish; Letzeburgesch", - "NDO" => "Ndonga", - "GEZ" => "Geez", - "ISL" => "Icelandic", - "LAT" => "Latin", - "MAK" => "Makasar", - "ZAP" => "Zapotec", - "YID" => "Yiddish", - "KOK" => "Konkani", - "KOM" => "Komi", - "KON" => "Kongo", - "UKR" => "Ukrainian", - "TON" => "Tonga (Tonga Islands)", - "KOS" => "Kosraean", - "KOR" => "Korean", - "TOG" => "Tonga (Nyasa)", - "HUN" => "Hungarian", - "HUP" => "Hupa", - "CYM" => "Welsh", - "UDM" => "Udmurt", - "BEJ" => "Beja", - "BEN" => "Bengali", - "BEL" => "Belarusian", - "BEM" => "Bemba", - "AAR" => "Afar", - "NZI" => "Nzima", - "SAH" => "Yakut", - "SAN" => "Sanskrit", - "SAM" => "Samaritan Aramaic", - "SAG" => "Sango", - "SAD" => "Sandawe", - "RAR" => "Rarotongan", - "RAP" => "Rapanui", - "SAS" => "Sasak", - "SAT" => "Santali", - "MIN" => "Minangkabau", - "LIM" => "Limburgan; Limburger; Limburgish", - "LIN" => "Lingala", - "LIT" => "Lithuanian", - "EFI" => "Efik", - "BTK" => "Batak (Indonesia)", - "KAC" => "Kachin", - "KAB" => "Kabyle", - "KAA" => "Kara-Kalpak", - "KAN" => "Kannada", - "KAM" => "Kamba", - "KAL" => "Kalaallisut; Greenlandic", - "KAS" => "Kashmiri", - "KAR" => "Karen", - "KAU" => "Kanuri", - "KAT" => "Georgian", - "KAZ" => "Kazakh", - "TYV" => "Tuvinian", - "AWA" => "Awadhi", - "URD" => "Urdu", - "DOI" => "Dogri", - "TPI" => "Tok Pisin", - "MRI" => "Maori", - "ABK" => "Abkhazian", - "TKL" => "Tokelau", - "NLD" => "Dutch; Flemish", - "OJI" => "Ojibwa", - "OCI" => "Occitan (post 1500); Provençal", - "WOL" => "Wolof", - "JAV" => "Javanese", - "HRV" => "Croatian", - "DYU" => "Dyula", - "SSW" => "Swati", - "MUL" => "Multiple languages", - "HIL" => "Hiligaynon", - "HIM" => "Himachali", - "HIN" => "Hindi", - "BAS" => "Basa", - "GBA" => "Gbaya", - "WLN" => "Walloon", - "BAD" => "Banda", - "NEP" => "Nepali", - "CRE" => "Cree", - "BAN" => "Balinese", - "BAL" => "Baluchi", - "BAM" => "Bambara", - "BAK" => "Bashkir", - "SHN" => "Shan", - "ARP" => "Arapaho", - "ARW" => "Arawak", - "ARA" => "Arabic", - "ARC" => "Aramaic", - "ARG" => "Aragonese", - "SEL" => "Selkup", - "ARN" => "Araucanian", - "LUS" => "Lushai", - "MUS" => "Creek", - "LUA" => "Luba-Lulua", - "LUB" => "Luba-Katanga", - "LUG" => "Ganda", - "LUI" => "Luiseno", - "LUN" => "Lunda", - "LUO" => "Luo (Kenya and Tanzania)", - "IKU" => "Inuktitut", - "TUR" => "Turkish", - "TUK" => "Turkmen", - "TUM" => "Tumbuka", - "COP" => "Coptic", - "COS" => "Corsican", - "COR" => "Cornish", - "ILO" => "Iloko", - "GWI" => "Gwich´in", - "TLI" => "Tlingit", - "TLH" => "Klingon; tlhIngan-Hol", - "POR" => "Portuguese", - "PON" => "Pohnpeian", - "POL" => "Polish", - "TGK" => "Tajik", - "TGL" => "Tagalog", - "FRA" => "French", - "BHO" => "Bhojpuri", - "SWA" => "Swahili", - "DUA" => "Duala", - "SWE" => "Swedish", - "YAP" => "Yapese", - "TIV" => "Tiv", - "YAO" => "Yao", - "XAL" => "Kalmyk", - "FRY" => "Frisian", - "GAY" => "Gayo", - "OTA" => "Turkish, Ottoman (1500-1928)", - "HMN" => "Hmong", - "HMO" => "Hiri Motu", - "GAA" => "Ga", - "FUR" => "Friulian", - "MLG" => "Malagasy", - "SLV" => "Slovenian", - "FIL" => "Filipino; Pilipino", - "MLT" => "Maltese", - "SLK" => "Slovak", - "FUL" => "Fulah", - "JPN" => "Japanese", - "VOL" => "Volapük", - "VOT" => "Votic", - "IND" => "Indonesian", - "AVE" => "Avestan", - "JPR" => "Judeo-Persian", - "AVA" => "Avaric", - "PAP" => "Papiamento", - "EWO" => "Ewondo", - "PAU" => "Palauan", - "EWE" => "Ewe", - "PAG" => "Pangasinan", - "PAM" => "Pampanga", - "PAN" => "Panjabi; Punjabi", - "KIR" => "Kirghiz", - "NIA" => "Nias", - "KIK" => "Kikuyu; Gikuyu", - "SYR" => "Syriac", - "KIN" => "Kinyarwanda", - "NIU" => "Niuean", - "EPO" => "Esperanto", - "JBO" => "Lojban", - "MIC" => "Mi'kmaq; Micmac", - "THA" => "Thai", - "HAI" => "Haida", - "ELL" => "Greek, Modern (1453-)", - "ADY" => "Adyghe; Adygei", - "ELX" => "Elamite", - "ADA" => "Adangme", - "GRB" => "Grebo", - "HAT" => "Haitian; Haitian Creole", - "HAU" => "Hausa", - "HAW" => "Hawaiian", - "BIN" => "Bini", - "AMH" => "Amharic", - "BIK" => "Bikol", - "BIH" => "Bihari", - "MOS" => "Mossi", - "MOH" => "Mohawk", - "MON" => "Mongolian", - "MOL" => "Moldavian", - "BIS" => "Bislama", - "TVL" => "Tuvalu", - "IJO" => "Ijo", - "EST" => "Estonian", - "KMB" => "Kimbundu", - "UMB" => "Umbundu", - "TMH" => "Tamashek", - "FON" => "Fon", - "HSB" => "Upper Sorbian", - "RUN" => "Rundi", - "RUS" => "Russian", - "PLI" => "Pali", - "SRD" => "Sardinian", - "ACH" => "Acoli", - "NDE" => "Ndebele, North; North Ndebele", - "DZO" => "Dzongkha", - "KRU" => "Kurukh", - "SRR" => "Serer", - "IDO" => "Ido", - "SRP" => "Serbian", - "KRO" => "Kru", - "KRC" => "Karachay-Balkar", - "NDS" => "Low German; Low Saxon; German, Low; Saxon, Low", - "ZUN" => "Zuni", - "ZUL" => "Zulu", - "TWI" => "Twi", - "NSO" => "Northern Sotho, Pedi; Sepedi", - "SOM" => "Somali", - "SON" => "Songhai", - "SOT" => "Sotho, Southern", - "MKD" => "Macedonian", - "HER" => "Herero", - "LOL" => "Mongo", - "HEB" => "Hebrew", - "LOZ" => "Lozi", - "GIL" => "Gilbertese", - "WAS" => "Washo", - "WAR" => "Waray", - "BUL" => "Bulgarian", - "WAL" => "Walamo", - "BUA" => "Buriat", - "BUG" => "Buginese", - "AZE" => "Azerbaijani", - "ZHA" => "Zhuang; Chuang", - "ZHO" => "Chinese", - "NNO" => "Norwegian Nynorsk; Nynorsk, Norwegian", - "UIG" => "Uighur; Uyghur", - "MYV" => "Erzya", - "INH" => "Ingush", - "KHM" => "Khmer", - "MYA" => "Burmese", - "KHA" => "Khasi", - "INA" => "Interlingua (International Auxiliary Language Association)", - "NAH" => "Nahuatl", - "TIR" => "Tigrinya", - "NAP" => "Neapolitan", - "NAV" => "Navajo; Navaho", - "NAU" => "Nauru", - "GRN" => "Guarani", - "TIG" => "Tigre", - "YOR" => "Yoruba", - "ILE" => "Interlingue", - "SQI" => "Albanian" - ); +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +$mbLanguageNames = array( + "ART" => "Artificial (Other)", + "ROH" => "Raeto-Romance", + "SCO" => "Scots", + "SCN" => "Sicilian", + "ROM" => "Romany", + "RON" => "Romanian", + "OSS" => "Ossetian; Ossetic", + "ALE" => "Aleut", + "MNI" => "Manipuri", + "NWC" => "Classical Newari; Old Newari; Classical Nepal Bhasa", + "OSA" => "Osage", + "MNC" => "Manchu", + "MWR" => "Marwari", + "VEN" => "Venda", + "MWL" => "Mirandese", + "FAS" => "Persian", + "FAT" => "Fanti", + "FAN" => "Fang", + "FAO" => "Faroese", + "DIN" => "Dinka", + "HYE" => "Armenian", + "DSB" => "Lower Sorbian", + "CAR" => "Carib", + "DIV" => "Divehi", + "TEL" => "Telugu", + "TEM" => "Timne", + "NBL" => "Ndebele, South; South Ndebele", + "TER" => "Tereno", + "TET" => "Tetum", + "SUN" => "Sundanese", + "KUT" => "Kutenai", + "SUK" => "Sukuma", + "KUR" => "Kurdish", + "KUM" => "Kumyk", + "SUS" => "Susu", + "NEW" => "Newari; Nepal Bhasa", + "KUA" => "Kuanyama; Kwanyama", + "MEN" => "Mende", + "LEZ" => "Lezghian", + "GLA" => "Gaelic; Scottish Gaelic", + "BOS" => "Bosnian", + "GLE" => "Irish", + "EKA" => "Ekajuk", + "GLG" => "Gallegan", + "AKA" => "Akan", + "BOD" => "Tibetan", + "GLV" => "Manx", + "JRB" => "Judeo-Arabic", + "VIE" => "Vietnamese", + "IPK" => "Inupiaq", + "UZB" => "Uzbek", + "BRE" => "Breton", + "BRA" => "Braj", + "AYM" => "Aymara", + "CHA" => "Chamorro", + "CHB" => "Chibcha", + "CHE" => "Chechen", + "CHG" => "Chagatai", + "CHK" => "Chuukese", + "CHM" => "Mari", + "CHN" => "Chinook jargon", + "CHO" => "Choctaw", + "CHP" => "Chipewyan", + "CHR" => "Cherokee", + "CHU" => "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic", + "CHV" => "Chuvash", + "CHY" => "Cheyenne", + "MSA" => "Malay", + "III" => "Sichuan Yi", + "ACE" => "Achinese", + "IBO" => "Igbo", + "IBA" => "Iban", + "XHO" => "Xhosa", + "DEU" => "German", + "CAT" => "Catalan; Valencian", + "DEL" => "Delaware", + "DEN" => "Slave (Athapascan)", + "CAD" => "Caddo", + "TAT" => "Tatar", + "RAJ" => "Rajasthani", + "SPA" => "Spanish; Castilian", + "TAM" => "Tamil", + "TAH" => "Tahitian", + "AFH" => "Afrihili", + "ENG" => "English", + "CSB" => "Kashubian", + "NYN" => "Nyankole", + "NYO" => "Nyoro", + "SID" => "Sidamo", + "NYA" => "Chichewa; Chewa; Nyanja", + "SIN" => "Sinhala; Sinhalese", + "AFR" => "Afrikaans", + "LAM" => "Lamba", + "SND" => "Sindhi", + "MAR" => "Marathi", + "LAH" => "Lahnda", + "NYM" => "Nyamwezi", + "SNA" => "Shona", + "LAD" => "Ladino", + "SNK" => "Soninke", + "MAD" => "Madurese", + "MAG" => "Magahi", + "MAI" => "Maithili", + "MAH" => "Marshallese", + "LAV" => "Latvian", + "MAL" => "Malayalam", + "MAN" => "Mandingo", + "ZND" => "Zande", + "ZEN" => "Zenaga", + "KBD" => "Kabardian", + "ITA" => "Italian", + "VAI" => "Vai", + "TSN" => "Tswana", + "TSO" => "Tsonga", + "TSI" => "Tsimshian", + "BYN" => "Blin; Bilin", + "FIJ" => "Fijian", + "FIN" => "Finnish", + "EUS" => "Basque", + "CEB" => "Cebuano", + "DAN" => "Danish", + "NOG" => "Nogai", + "NOB" => "Norwegian Bokmål; Bokmål, Norwegian", + "DAK" => "Dakota", + "CES" => "Czech", + "DAR" => "Dargwa", + "DAY" => "Dayak", + "NOR" => "Norwegian", + "KPE" => "Kpelle", + "GUJ" => "Gujarati", + "MDF" => "Moksha", + "MAS" => "Masai", + "LAO" => "Lao", + "MDR" => "Mandar", + "GON" => "Gondi", + "SMS" => "Skolt Sami", + "SMO" => "Samoan", + "SMN" => "Inari Sami", + "SMJ" => "Lule Sami", + "GOT" => "Gothic", + "SME" => "Northern Sami", + "BLA" => "Siksika", + "SMA" => "Southern Sami", + "GOR" => "Gorontalo", + "AST" => "Asturian; Bable", + "ORM" => "Oromo", + "QUE" => "Quechua", + "ORI" => "Oriya", + "CRH" => "Crimean Tatar; Crimean Turkish", + "ASM" => "Assamese", + "PUS" => "Pushto", + "DGR" => "Dogrib", + "LTZ" => "Luxembourgish; Letzeburgesch", + "NDO" => "Ndonga", + "GEZ" => "Geez", + "ISL" => "Icelandic", + "LAT" => "Latin", + "MAK" => "Makasar", + "ZAP" => "Zapotec", + "YID" => "Yiddish", + "KOK" => "Konkani", + "KOM" => "Komi", + "KON" => "Kongo", + "UKR" => "Ukrainian", + "TON" => "Tonga (Tonga Islands)", + "KOS" => "Kosraean", + "KOR" => "Korean", + "TOG" => "Tonga (Nyasa)", + "HUN" => "Hungarian", + "HUP" => "Hupa", + "CYM" => "Welsh", + "UDM" => "Udmurt", + "BEJ" => "Beja", + "BEN" => "Bengali", + "BEL" => "Belarusian", + "BEM" => "Bemba", + "AAR" => "Afar", + "NZI" => "Nzima", + "SAH" => "Yakut", + "SAN" => "Sanskrit", + "SAM" => "Samaritan Aramaic", + "SAG" => "Sango", + "SAD" => "Sandawe", + "RAR" => "Rarotongan", + "RAP" => "Rapanui", + "SAS" => "Sasak", + "SAT" => "Santali", + "MIN" => "Minangkabau", + "LIM" => "Limburgan; Limburger; Limburgish", + "LIN" => "Lingala", + "LIT" => "Lithuanian", + "EFI" => "Efik", + "BTK" => "Batak (Indonesia)", + "KAC" => "Kachin", + "KAB" => "Kabyle", + "KAA" => "Kara-Kalpak", + "KAN" => "Kannada", + "KAM" => "Kamba", + "KAL" => "Kalaallisut; Greenlandic", + "KAS" => "Kashmiri", + "KAR" => "Karen", + "KAU" => "Kanuri", + "KAT" => "Georgian", + "KAZ" => "Kazakh", + "TYV" => "Tuvinian", + "AWA" => "Awadhi", + "URD" => "Urdu", + "DOI" => "Dogri", + "TPI" => "Tok Pisin", + "MRI" => "Maori", + "ABK" => "Abkhazian", + "TKL" => "Tokelau", + "NLD" => "Dutch; Flemish", + "OJI" => "Ojibwa", + "OCI" => "Occitan (post 1500); Provençal", + "WOL" => "Wolof", + "JAV" => "Javanese", + "HRV" => "Croatian", + "DYU" => "Dyula", + "SSW" => "Swati", + "MUL" => "Multiple languages", + "HIL" => "Hiligaynon", + "HIM" => "Himachali", + "HIN" => "Hindi", + "BAS" => "Basa", + "GBA" => "Gbaya", + "WLN" => "Walloon", + "BAD" => "Banda", + "NEP" => "Nepali", + "CRE" => "Cree", + "BAN" => "Balinese", + "BAL" => "Baluchi", + "BAM" => "Bambara", + "BAK" => "Bashkir", + "SHN" => "Shan", + "ARP" => "Arapaho", + "ARW" => "Arawak", + "ARA" => "Arabic", + "ARC" => "Aramaic", + "ARG" => "Aragonese", + "SEL" => "Selkup", + "ARN" => "Araucanian", + "LUS" => "Lushai", + "MUS" => "Creek", + "LUA" => "Luba-Lulua", + "LUB" => "Luba-Katanga", + "LUG" => "Ganda", + "LUI" => "Luiseno", + "LUN" => "Lunda", + "LUO" => "Luo (Kenya and Tanzania)", + "IKU" => "Inuktitut", + "TUR" => "Turkish", + "TUK" => "Turkmen", + "TUM" => "Tumbuka", + "COP" => "Coptic", + "COS" => "Corsican", + "COR" => "Cornish", + "ILO" => "Iloko", + "GWI" => "Gwich´in", + "TLI" => "Tlingit", + "TLH" => "Klingon; tlhIngan-Hol", + "POR" => "Portuguese", + "PON" => "Pohnpeian", + "POL" => "Polish", + "TGK" => "Tajik", + "TGL" => "Tagalog", + "FRA" => "French", + "BHO" => "Bhojpuri", + "SWA" => "Swahili", + "DUA" => "Duala", + "SWE" => "Swedish", + "YAP" => "Yapese", + "TIV" => "Tiv", + "YAO" => "Yao", + "XAL" => "Kalmyk", + "FRY" => "Frisian", + "GAY" => "Gayo", + "OTA" => "Turkish, Ottoman (1500-1928)", + "HMN" => "Hmong", + "HMO" => "Hiri Motu", + "GAA" => "Ga", + "FUR" => "Friulian", + "MLG" => "Malagasy", + "SLV" => "Slovenian", + "FIL" => "Filipino; Pilipino", + "MLT" => "Maltese", + "SLK" => "Slovak", + "FUL" => "Fulah", + "JPN" => "Japanese", + "VOL" => "Volapük", + "VOT" => "Votic", + "IND" => "Indonesian", + "AVE" => "Avestan", + "JPR" => "Judeo-Persian", + "AVA" => "Avaric", + "PAP" => "Papiamento", + "EWO" => "Ewondo", + "PAU" => "Palauan", + "EWE" => "Ewe", + "PAG" => "Pangasinan", + "PAM" => "Pampanga", + "PAN" => "Panjabi; Punjabi", + "KIR" => "Kirghiz", + "NIA" => "Nias", + "KIK" => "Kikuyu; Gikuyu", + "SYR" => "Syriac", + "KIN" => "Kinyarwanda", + "NIU" => "Niuean", + "EPO" => "Esperanto", + "JBO" => "Lojban", + "MIC" => "Mi'kmaq; Micmac", + "THA" => "Thai", + "HAI" => "Haida", + "ELL" => "Greek, Modern (1453-)", + "ADY" => "Adyghe; Adygei", + "ELX" => "Elamite", + "ADA" => "Adangme", + "GRB" => "Grebo", + "HAT" => "Haitian; Haitian Creole", + "HAU" => "Hausa", + "HAW" => "Hawaiian", + "BIN" => "Bini", + "AMH" => "Amharic", + "BIK" => "Bikol", + "BIH" => "Bihari", + "MOS" => "Mossi", + "MOH" => "Mohawk", + "MON" => "Mongolian", + "MOL" => "Moldavian", + "BIS" => "Bislama", + "TVL" => "Tuvalu", + "IJO" => "Ijo", + "EST" => "Estonian", + "KMB" => "Kimbundu", + "UMB" => "Umbundu", + "TMH" => "Tamashek", + "FON" => "Fon", + "HSB" => "Upper Sorbian", + "RUN" => "Rundi", + "RUS" => "Russian", + "PLI" => "Pali", + "SRD" => "Sardinian", + "ACH" => "Acoli", + "NDE" => "Ndebele, North; North Ndebele", + "DZO" => "Dzongkha", + "KRU" => "Kurukh", + "SRR" => "Serer", + "IDO" => "Ido", + "SRP" => "Serbian", + "KRO" => "Kru", + "KRC" => "Karachay-Balkar", + "NDS" => "Low German; Low Saxon; German, Low; Saxon, Low", + "ZUN" => "Zuni", + "ZUL" => "Zulu", + "TWI" => "Twi", + "NSO" => "Northern Sotho, Pedi; Sepedi", + "SOM" => "Somali", + "SON" => "Songhai", + "SOT" => "Sotho, Southern", + "MKD" => "Macedonian", + "HER" => "Herero", + "LOL" => "Mongo", + "HEB" => "Hebrew", + "LOZ" => "Lozi", + "GIL" => "Gilbertese", + "WAS" => "Washo", + "WAR" => "Waray", + "BUL" => "Bulgarian", + "WAL" => "Walamo", + "BUA" => "Buriat", + "BUG" => "Buginese", + "AZE" => "Azerbaijani", + "ZHA" => "Zhuang; Chuang", + "ZHO" => "Chinese", + "NNO" => "Norwegian Nynorsk; Nynorsk, Norwegian", + "UIG" => "Uighur; Uyghur", + "MYV" => "Erzya", + "INH" => "Ingush", + "KHM" => "Khmer", + "MYA" => "Burmese", + "KHA" => "Khasi", + "INA" => "Interlingua (International Auxiliary Language Association)", + "NAH" => "Nahuatl", + "TIR" => "Tigrinya", + "NAP" => "Neapolitan", + "NAV" => "Navajo; Navaho", + "NAU" => "Nauru", + "GRN" => "Guarani", + "TIG" => "Tigre", + "YOR" => "Yoruba", + "ILE" => "Interlingue", + "SQI" => "Albanian" +); ?> diff --git a/modules/php_musicbrainz/mbUtil_releasetypenames.php b/modules/php_musicbrainz/mbUtil_releasetypenames.php index a655dcdc..465a3e16 100644 --- a/modules/php_musicbrainz/mbUtil_releasetypenames.php +++ b/modules/php_musicbrainz/mbUtil_releasetypenames.php @@ -1,20 +1,20 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - $mbReleaseTypeNames = array( - "http://musicbrainz.org/ns/mmd-1.0#None" => "None", - "http://musicbrainz.org/ns/mmd-1.0#Album" => "Album", - "http://musicbrainz.org/ns/mmd-1.0#Single" => "Single", - "http://musicbrainz.org/ns/mmd-1.0#EP" => "EP", - "http://musicbrainz.org/ns/mmd-1.0#Compilation" => "Compilation", - "http://musicbrainz.org/ns/mmd-1.0#Soundtrack" => "Soundtrack", - "http://musicbrainz.org/ns/mmd-1.0#Spokenword" => "Spokenword", - "http://musicbrainz.org/ns/mmd-1.0#Interview" => "Interview", - "http://musicbrainz.org/ns/mmd-1.0#Audiobook" => "Audiobook", - "http://musicbrainz.org/ns/mmd-1.0#Live" => "Live", - "http://musicbrainz.org/ns/mmd-1.0#Remix" => "Remix", - "http://musicbrainz.org/ns/mmd-1.0#Other" => "Other", - "http://musicbrainz.org/ns/mmd-1.0#Official" => "Official", - "http://musicbrainz.org/ns/mmd-1.0#Promotion" => "Promotion", - "http://musicbrainz.org/ns/mmd-1.0#Bootleg" => "Bootleg" - ); +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +$mbReleaseTypeNames = array( + "http://musicbrainz.org/ns/mmd-1.0#None" => "None", + "http://musicbrainz.org/ns/mmd-1.0#Album" => "Album", + "http://musicbrainz.org/ns/mmd-1.0#Single" => "Single", + "http://musicbrainz.org/ns/mmd-1.0#EP" => "EP", + "http://musicbrainz.org/ns/mmd-1.0#Compilation" => "Compilation", + "http://musicbrainz.org/ns/mmd-1.0#Soundtrack" => "Soundtrack", + "http://musicbrainz.org/ns/mmd-1.0#Spokenword" => "Spokenword", + "http://musicbrainz.org/ns/mmd-1.0#Interview" => "Interview", + "http://musicbrainz.org/ns/mmd-1.0#Audiobook" => "Audiobook", + "http://musicbrainz.org/ns/mmd-1.0#Live" => "Live", + "http://musicbrainz.org/ns/mmd-1.0#Remix" => "Remix", + "http://musicbrainz.org/ns/mmd-1.0#Other" => "Other", + "http://musicbrainz.org/ns/mmd-1.0#Official" => "Official", + "http://musicbrainz.org/ns/mmd-1.0#Promotion" => "Promotion", + "http://musicbrainz.org/ns/mmd-1.0#Bootleg" => "Bootleg" +); ?> diff --git a/modules/php_musicbrainz/mbUtil_scriptnames.php b/modules/php_musicbrainz/mbUtil_scriptnames.php index abadb147..d74fbca4 100644 --- a/modules/php_musicbrainz/mbUtil_scriptnames.php +++ b/modules/php_musicbrainz/mbUtil_scriptnames.php @@ -1,56 +1,56 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - $mbScriptNames = array( - "Yiii" => "Yi", - "Telu" => "Telugu", - "Taml" => "Tamil", - "Guru" => "Gurmukhi", - "Hebr" => "Hebrew", - "Geor" => "Georgian (Mkhedruli)", - "Ugar" => "Ugaritic", - "Cyrl" => "Cyrillic", - "Hrkt" => "Kanji & Kana", - "Armn" => "Armenian", - "Runr" => "Runic", - "Khmr" => "Khmer", - "Latn" => "Latin", - "Hani" => "Han (Hanzi, Kanji, Hanja)", - "Ital" => "Old Italic (Etruscan, Oscan, etc.)", - "Hano" => "Hanunoo (Hanunóo)", - "Ethi" => "Ethiopic (Ge'ez)", - "Gujr" => "Gujarati", - "Hang" => "Hangul", - "Arab" => "Arabic", - "Thaa" => "Thaana", - "Buhd" => "Buhid", - "Sinh" => "Sinhala", - "Orya" => "Oriya", - "Hans" => "Han (Simplified variant)", - "Thai" => "Thai", - "Cprt" => "Cypriot", - "Linb" => "Linear B", - "Hant" => "Han (Traditional variant)", - "Osma" => "Osmanya", - "Mong" => "Mongolian", - "Deva" => "Devanagari (Nagari)", - "Laoo" => "Lao", - "Tagb" => "Tagbanwa", - "Hira" => "Hiragana", - "Bopo" => "Bopomofo", - "Goth" => "Gothic", - "Tale" => "Tai Le", - "Mymr" => "Myanmar (Burmese)", - "Tglg" => "Tagalog", - "Grek" => "Greek", - "Mlym" => "Malayalam", - "Cher" => "Cherokee", - "Tibt" => "Tibetan", - "Kana" => "Katakana", - "Syrc" => "Syriac", - "Cans" => "Unified Canadian Aboriginal Syllabics", - "Beng" => "Bengali", - "Limb" => "Limbu", - "Ogam" => "Ogham", - "Knda" => "Kannada" - ); +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +$mbScriptNames = array( + "Yiii" => "Yi", + "Telu" => "Telugu", + "Taml" => "Tamil", + "Guru" => "Gurmukhi", + "Hebr" => "Hebrew", + "Geor" => "Georgian (Mkhedruli)", + "Ugar" => "Ugaritic", + "Cyrl" => "Cyrillic", + "Hrkt" => "Kanji & Kana", + "Armn" => "Armenian", + "Runr" => "Runic", + "Khmr" => "Khmer", + "Latn" => "Latin", + "Hani" => "Han (Hanzi, Kanji, Hanja)", + "Ital" => "Old Italic (Etruscan, Oscan, etc.)", + "Hano" => "Hanunoo (Hanunóo)", + "Ethi" => "Ethiopic (Ge'ez)", + "Gujr" => "Gujarati", + "Hang" => "Hangul", + "Arab" => "Arabic", + "Thaa" => "Thaana", + "Buhd" => "Buhid", + "Sinh" => "Sinhala", + "Orya" => "Oriya", + "Hans" => "Han (Simplified variant)", + "Thai" => "Thai", + "Cprt" => "Cypriot", + "Linb" => "Linear B", + "Hant" => "Han (Traditional variant)", + "Osma" => "Osmanya", + "Mong" => "Mongolian", + "Deva" => "Devanagari (Nagari)", + "Laoo" => "Lao", + "Tagb" => "Tagbanwa", + "Hira" => "Hiragana", + "Bopo" => "Bopomofo", + "Goth" => "Gothic", + "Tale" => "Tai Le", + "Mymr" => "Myanmar (Burmese)", + "Tglg" => "Tagalog", + "Grek" => "Greek", + "Mlym" => "Malayalam", + "Cher" => "Cherokee", + "Tibt" => "Tibetan", + "Kana" => "Katakana", + "Syrc" => "Syriac", + "Cans" => "Unified Canadian Aboriginal Syllabics", + "Beng" => "Bengali", + "Limb" => "Limbu", + "Ogam" => "Ogham", + "Knda" => "Kannada" +); ?> diff --git a/modules/php_musicbrainz/mbWebService.php b/modules/php_musicbrainz/mbWebService.php index a6377f64..43f00bdf 100644 --- a/modules/php_musicbrainz/mbWebService.php +++ b/modules/php_musicbrainz/mbWebService.php @@ -144,6 +144,10 @@ class mbWebService implements IWebService { fwrite($this->fSock, "Host: " . $this->host . "\r\n"); fwrite($this->fSock, "Accept: */*\r\n"); fwrite($this->fSock, "User-Agent: php_musicbrainz/1.0\r\n"); + if($post_data) { + fwrite($this->fSock, "Content-Type: application/x-www-form-urlencoded\r\n"); + fwrite($this->fSock, "Content-Length: " . (strlen($post_data . "\r\n")) . "\r\n"); + } if ($this->nonce) { $h1 = md5($this->username . ':' . $this->realm . ':' . $this->password); @@ -157,7 +161,6 @@ class mbWebService implements IWebService { } fwrite( $this->fSock, "Connection: close\r\n\r\n"); fwrite($this->fSock, $post_data . "\r\n\r\n"); - return true; } @@ -213,7 +216,8 @@ class mbWebService implements IWebService { if ($this->fSock == -1 && !$this->connect()) { return false; } - + $data = $this->build_query($data); + $data = ltrim($data, '?'); return $this->runRequest("POST", $uri, $data); } diff --git a/modules/php_musicbrainz/mbXmlParser.php b/modules/php_musicbrainz/mbXmlParser.php index ebfcaab5..83d0b8af 100644 --- a/modules/php_musicbrainz/mbXmlParser.php +++ b/modules/php_musicbrainz/mbXmlParser.php @@ -1,405 +1,405 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ class mbParseError extends Exception { } class mbXmlParser { - private $xml_parser; - private $factory; - - function mbXmlParser() { - $this->xml_parser = new xmlParser(); - $this->factory = new mbDefaultFactory(); - } - - private function parseList(XMLNode $node, array $list, $func) { - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - $list[] = call_user_func(array($this, $func), $cnode); - } - } - - private function parseResults(XMLNode $node, array $list, $func, $type) { - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - $object = call_user_func(array($this, $func), $cnode); - $score = $cnode->getAttribute("ext:score"); - eval('$to_add = new ' . $type . 'Result($object,$score);'); - $to_add->setCount($node->getAttribute("count")); - $to_add->setOffset($node->getAttribute("offset")); - $list[] = $to_add; - } - } - - private function parseRelations(XMLNode $node, MusicBrainzEntity $entity) { - $targetType = $node->getAttribute("target-type"); - if ($targetType == '') - return; - - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - if (strtolower($cnode->getName()) == "relation") { - $relation = $this->createRelation($cnode, $targetType); - if ($relation) - $entity->addRelation($relation); - } - } - } - - private function parseUserResults(XMLNode $node, array $userList) { - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - $userList[] = $this->createUser($cnode); - } - } - - private function createUser(XMLNode $node) { - $user = $this->factory->newUser(); - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cNode = $node->getChildNode($i); - $name = $cNode->getName(); - switch ($name) { - case "name": - $user->setName($cNode->getText()); - break; - case "ext:nag": - $user->setShowNag($node->getAttribute("show") == 'true' ? true : false); - break; - } - } - return $user; - } - - private function createArtistAlias(XMLNode $node) { - $aa = $this->factory->newArtistAlias(); - $aa->setType($node->getAttribute("type")); - $aa->setScript($node->getAttribute("script")); - $aa->setValue($node->getText()); - return $aa; - - } - - private function createTag(XMLNode $node) { - $tag = $this->factory->newTag(); - $tag->setCount($node->getAttribute("count")); - $tag->setName($node->getText()); - return $tag; - } - - private function createLabelAlias(XML $node) { - $la = $this->factory->newLabelAlias(); - $la->setType($node->getAttribute("type")); - $la->setScript($node->getAttribute("script")); - $la->setValue($node->getText()); - return $la; - } - - private function createDisc(XMLNode $node) { - $disc = $this->factory->newDisc(); - $disc->setId($node->getAttribute("id")); - return $disc; - } - - private function createReleaseEvent(XMLNode $node) { - $relEvent = $this->factory->newReleaseEvent(); - $relEvent->setCountry($node->getAttribute("country")); - $relEvent->setDate($node->getAttribute("date")); - $relEvent->setCatalogNumber($node->getAttribute("catalog-number")); - $relEvent->setBarcode($node->getAttribute("barcode")); - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - switch (strtolower($cnode->getName())) { - case 'label': - $relEvent->setLabel($this->createLabel($cnode)); - break; - } - } - return $relEvent; - } - - private function createRating(XMLNode $node) { - $rating = $this->factory->newRating(); - $rating->setRating($node->getText()); - return $rating; - } - - private function createLabel(XMLNode $node) { - $label = $this->factory->newLabel(); - $label->setId($node->getAttribute("id")); - $label->setType($node->getAttribute("type")); - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - switch (strtolower($cnode->getName())) { - case "name": - case "sort-name": - $label->setSortName($cnode->getText()); - break; - case "disambiguation": - $label->setDisambiguation($cnode->getText()); - break; - case "life-span": - $begin = $cnode->getAttribute("begin"); - $end = $cnode->getAttribute("end"); - if ($begin != "") { - $label->setBeginDate($begin); - } - if ($end != "") { - $label->setEndDate($end); - } - break; - case "alias-list": - $pAlias = $label->getAliases(); - $this->parseList($cnode, $pAlias, 'createAlias'); - break; - case "release-list": - $pRel = $label->getReleases(); - $label->setReleasesCount($cnode->getAttribute("count")); - $label->setReleasesOffset($cnode->getAttribute("offset")); - $this->parseList($cnode, $pRel, 'createRelease'); - break; - case "relation-list": - $this->parseRelations($cnode, $label); - break; - case "tag-list": - $pTag = $label->getTags(); - $this->parseList($cnode, $pTag, 'createTag'); - break; - } - } - - return $label; - } - - private function createArtist(XMLNode $node) { - $artist = $this->factory->newArtist(); - $artist->setId($node->getAttribute("id")); - $artist->setType($node->getAttribute("type")); - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - switch (strtolower($cnode->getName())) { - case "name": - $artist->setName($cnode->getText()); - break; - case "sort-name": - $artist->setSortName($cnode->getText()); - break; - case "disambiguation": - $artist->setDisambiguation($cnode->getText()); - break; - case "life-span": - $begin = $cnode->getAttribute("begin"); - $end = $cnode->getAttribute("end"); - if ($begin != "") { - $artist->setBeginDate($begin); - } - if ($end != "") { - $artist->setEndDate($end); - } - break; - case "alias-list": - $pAli = $artist->getAliases(); - $this->parseList($cnode, $pAli, 'createArtistAlias'); - break; - case "release-list": - $pRel = $artist->getReleases(); - $artist->setReleasesCount($cnode->getAttribute("count")); - $artist->setReleasesOffset($cnode->getAttribute("offset")); - $this->parseList($cnode, $pRel, 'createRelease'); - break; - case "relation-list": - $this->parseRelations($cnode, $artist); - break; - case "tag-list": - $pTag = $artist->getTags(); - $this->parseList($cnode, $pTag, 'createTag'); - break; - } - } - - return $artist; - } - - private function createTrack(XMLNode $node) { - $track = $this->factory->newTrack(); - $track->setId($node->getAttribute("id")); - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - switch(strtolower($cnode->getName())) { - case "title": - $track->setTitle($cnode->getText()); - break; - case "artist": - $track->setArtist($this->createArtist($cnode)); - break; - case "duration": - $track->setDuration($cnode->getText()); - break; - case "release-list": - $pRel = $track->getReleases(); - $track->setReleasesOffset($cnode->getAttribute("offset")); - $track->setReleasesCount($cnode->getAttribute("count")); - $this->parseList($cnode, $pRel, 'createRelease'); - break; - case "relation-list": - $this->parseRelations($cnode, $track); - break; - case "tag-list": - $pTag = $track->getTags(); - $this->parseList($cnode, $pTag, 'createTag'); - break; - } - } - - return $track; - } - - private function createRelease(XMLNode $node) { - $release = $this->factory->newRelease(); - $release->setId($node->getAttribute("id")); - $array = array(); - $types = $node->getAttribute("type"); - $types = explode(' ', $types); - foreach ($types as $one_type) { - $array[] = $one_type; - } - $release->setTypes($array); - - for ($i = 0; $i < $node->nChildNodes(); $i++) { - $cnode = $node->getChildNode($i); - switch (strtolower($cnode->getName())) { - case "title": - $release->setTitle($cnode->getText()); - break; - case "text-representation": - $release->setTextLanguage($cnode->getAttribute("language")); - $release->setTextScript($cnode->getAttribute("script")); - break; - case "asin": - $release->setAsin($cnode->getText()); - break; - case "artist": - $release->setArtist($this->createArtist($cnode)); - break; - case "release-event-list": - $pRelEv = $release->getReleaseEvents(); - $this->parseList($cnode, $pRelEv, 'createReleaseEvent'); - break; - case "disc-list": - $pDisc = $release->getDiscs(); - $this->parseList($cnode, $pDisc, 'createDisc'); - break; - case "track-list": - $pTrack = $release->getTracks(); - $release->setTracksOffset($cnode->getAttribute("offset")); - $release->setTracksCount($cnode->getAttribute("count")); - $this->parseList($cnode, $pTrack, 'createTrack'); - break; - case "relation-list": - $this->parseRelations($cnode, $release); - break; - case "tag-list": - $pTag = $release->getTags(); - $this->parseList($cnode, $pTag, 'createTag'); - break; - } - } - - return $release; - } - - private function createRelation(XMLNode $node, $type) { - $relation = $this->factory->newRelation(); - $relation->setType(extractFragment($node->getAttribute("type"))); // TODO: fixme - $relation->setTargetType($type); - $relation->setTargetId($node->getAttribute("target")); - - $dir = mbRelation::DIR_BOTH; - switch(strtolower($node->getAttribute("direction"))) { - case "forward": - $dir = mbRelation::DIR_FORWARD; - break; - case "backward": - $dir = mbRelation::DIR_BACKWARD; - break; - } - $relation->setDirection($dir); - - $relation->setBeginDate($node->getAttribute("begin")); - $relation->setEndDate($node->getAttribute("end")); - - // TODO: ns - $attrs = $node->getAttribute("attributes"); - $attributes = explode(' ', $attrs); - foreach ($attributes as $attr) - $relation->addAttribute($attr); - - $target = null; - if ($node->nChildNodes() > 0 ) { - $cnode = $node->getChildNode(0); - switch (strtolower($cnode->getName())) { - case "artist": - $target = $this->createArtist($cnode); - break; - case "release": - $target = $this->createRelease($cnode); - break; - case "track": - $target = $this->createTrack($cnode); - break; - } - } - $relation->setTarget($target); - - return $relation; - } - - function parse($data) { - $nodes = $this->xml_parser->parse($data); - - if ($nodes == false) { - throw new mbParseError($this->xml_parser->lastError(), 1); - } - - $md = new mbMetadata(); - - for ($i = 0; $i < $nodes->nChildNodes(); $i++) { - $node = $nodes->getChildNode($i); - $name = strtolower($node->getName()); - - switch ($name) { - case "artist": - $md->setArtist($this->createArtist($node)); - break; - case "track": - $md->setTrack($this->createTrack($node)); - break; - case "release": - $md->setRelease($this->createRelease($node)); - break; - case "label": - $md->setLabel($this->createLabel($node)); - break; - case "user-rating": - $md->setRating($this->createRating($node)); - break; - case "artist-list": - $pArt = $md->getArtistResults(); - $this->parseResults($node, $pArt, 'createArtist', 'Artist'); - break; - case "track-list": - $pTrack = $md->getTrackResults(); - $this->parseResults($node, $pTrack, 'createTrack', 'Track'); - break; - case "release-list": - $pRel = $md->getReleaseResults(); - $this->parseResults($node, $pRel, 'createRelease', 'Release'); - break; - case "ext:user-list": - $list = $md->getUserList(); - $this->parseUserResults($node, $list); - break; - } - } - return $md; - } + private $xml_parser; + private $factory; + + function mbXmlParser() { + $this->xml_parser = new xmlParser(); + $this->factory = new mbDefaultFactory(); + } + + private function parseList(XMLNode $node, array $list, $func) { + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + $list[] = call_user_func(array($this, $func), $cnode); + } + } + + private function parseResults(XMLNode $node, array $list, $func, $type) { + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + $object = call_user_func(array($this, $func), $cnode); + $score = $cnode->getAttribute("ext:score"); + eval('$to_add = new ' . $type . 'Result($object,$score);'); + $to_add->setCount($node->getAttribute("count")); + $to_add->setOffset($node->getAttribute("offset")); + $list[] = $to_add; + } + } + + private function parseRelations(XMLNode $node, MusicBrainzEntity $entity) { + $targetType = $node->getAttribute("target-type"); + if ($targetType == '') + return; + + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + if (strtolower($cnode->getName()) == "relation") { + $relation = $this->createRelation($cnode, $targetType); + if ($relation) + $entity->addRelation($relation); + } + } + } + + private function parseUserResults(XMLNode $node, array $userList) { + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + $userList[] = $this->createUser($cnode); + } + } + + private function createUser(XMLNode $node) { + $user = $this->factory->newUser(); + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cNode = $node->getChildNode($i); + $name = $cNode->getName(); + switch ($name) { + case "name": + $user->setName($cNode->getText()); + break; + case "ext:nag": + $user->setShowNag($node->getAttribute("show") == 'true' ? true : false); + break; + } + } + return $user; + } + + private function createArtistAlias(XMLNode $node) { + $aa = $this->factory->newArtistAlias(); + $aa->setType($node->getAttribute("type")); + $aa->setScript($node->getAttribute("script")); + $aa->setValue($node->getText()); + return $aa; + + } + + private function createTag(XMLNode $node) { + $tag = $this->factory->newTag(); + $tag->setCount($node->getAttribute("count")); + $tag->setName($node->getText()); + return $tag; + } + + private function createLabelAlias(XML $node) { + $la = $this->factory->newLabelAlias(); + $la->setType($node->getAttribute("type")); + $la->setScript($node->getAttribute("script")); + $la->setValue($node->getText()); + return $la; + } + + private function createDisc(XMLNode $node) { + $disc = $this->factory->newDisc(); + $disc->setId($node->getAttribute("id")); + return $disc; + } + + private function createReleaseEvent(XMLNode $node) { + $relEvent = $this->factory->newReleaseEvent(); + $relEvent->setCountry($node->getAttribute("country")); + $relEvent->setDate($node->getAttribute("date")); + $relEvent->setCatalogNumber($node->getAttribute("catalog-number")); + $relEvent->setBarcode($node->getAttribute("barcode")); + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + switch (strtolower($cnode->getName())) { + case 'label': + $relEvent->setLabel($this->createLabel($cnode)); + break; + } + } + return $relEvent; + } + + private function createRating(XMLNode $node) { + $rating = $this->factory->newRating(); + $rating->setRating($node->getText()); + return $rating; + } + + private function createLabel(XMLNode $node) { + $label = $this->factory->newLabel(); + $label->setId($node->getAttribute("id")); + $label->setType($node->getAttribute("type")); + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + switch (strtolower($cnode->getName())) { + case "name": + case "sort-name": + $label->setSortName($cnode->getText()); + break; + case "disambiguation": + $label->setDisambiguation($cnode->getText()); + break; + case "life-span": + $begin = $cnode->getAttribute("begin"); + $end = $cnode->getAttribute("end"); + if ($begin != "") { + $label->setBeginDate($begin); + } + if ($end != "") { + $label->setEndDate($end); + } + break; + case "alias-list": + $pAlias = $label->getAliases(); + $this->parseList($cnode, $pAlias, 'createAlias'); + break; + case "release-list": + $pRel = $label->getReleases(); + $label->setReleasesCount($cnode->getAttribute("count")); + $label->setReleasesOffset($cnode->getAttribute("offset")); + $this->parseList($cnode, $pRel, 'createRelease'); + break; + case "relation-list": + $this->parseRelations($cnode, $label); + break; + case "tag-list": + $pTag = $label->getTags(); + $this->parseList($cnode, $pTag, 'createTag'); + break; + } + } + + return $label; + } + + private function createArtist(XMLNode $node) { + $artist = $this->factory->newArtist(); + $artist->setId($node->getAttribute("id")); + $artist->setType($node->getAttribute("type")); + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + switch (strtolower($cnode->getName())) { + case "name": + $artist->setName($cnode->getText()); + break; + case "sort-name": + $artist->setSortName($cnode->getText()); + break; + case "disambiguation": + $artist->setDisambiguation($cnode->getText()); + break; + case "life-span": + $begin = $cnode->getAttribute("begin"); + $end = $cnode->getAttribute("end"); + if ($begin != "") { + $artist->setBeginDate($begin); + } + if ($end != "") { + $artist->setEndDate($end); + } + break; + case "alias-list": + $pAli = $artist->getAliases(); + $this->parseList($cnode, $pAli, 'createArtistAlias'); + break; + case "release-list": + $pRel = $artist->getReleases(); + $artist->setReleasesCount($cnode->getAttribute("count")); + $artist->setReleasesOffset($cnode->getAttribute("offset")); + $this->parseList($cnode, $pRel, 'createRelease'); + break; + case "relation-list": + $this->parseRelations($cnode, $artist); + break; + case "tag-list": + $pTag = $artist->getTags(); + $this->parseList($cnode, $pTag, 'createTag'); + break; + } + } + + return $artist; + } + + private function createTrack(XMLNode $node) { + $track = $this->factory->newTrack(); + $track->setId($node->getAttribute("id")); + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + switch(strtolower($cnode->getName())) { + case "title": + $track->setTitle($cnode->getText()); + break; + case "artist": + $track->setArtist($this->createArtist($cnode)); + break; + case "duration": + $track->setDuration($cnode->getText()); + break; + case "release-list": + $pRel = $track->getReleases(); + $track->setReleasesOffset($cnode->getAttribute("offset")); + $track->setReleasesCount($cnode->getAttribute("count")); + $this->parseList($cnode, $pRel, 'createRelease'); + break; + case "relation-list": + $this->parseRelations($cnode, $track); + break; + case "tag-list": + $pTag = $track->getTags(); + $this->parseList($cnode, $pTag, 'createTag'); + break; + } + } + + return $track; + } + + private function createRelease(XMLNode $node) { + $release = $this->factory->newRelease(); + $release->setId($node->getAttribute("id")); + $array = array(); + $types = $node->getAttribute("type"); + $types = explode(' ', $types); + foreach ($types as $one_type) { + $array[] = $one_type; + } + $release->setTypes($array); + + for ($i = 0; $i < $node->nChildNodes(); $i++) { + $cnode = $node->getChildNode($i); + switch (strtolower($cnode->getName())) { + case "title": + $release->setTitle($cnode->getText()); + break; + case "text-representation": + $release->setTextLanguage($cnode->getAttribute("language")); + $release->setTextScript($cnode->getAttribute("script")); + break; + case "asin": + $release->setAsin($cnode->getText()); + break; + case "artist": + $release->setArtist($this->createArtist($cnode)); + break; + case "release-event-list": + $pRelEv = $release->getReleaseEvents(); + $this->parseList($cnode, $pRelEv, 'createReleaseEvent'); + break; + case "disc-list": + $pDisc = $release->getDiscs(); + $this->parseList($cnode, $pDisc, 'createDisc'); + break; + case "track-list": + $pTrack = $release->getTracks(); + $release->setTracksOffset($cnode->getAttribute("offset")); + $release->setTracksCount($cnode->getAttribute("count")); + $this->parseList($cnode, $pTrack, 'createTrack'); + break; + case "relation-list": + $this->parseRelations($cnode, $release); + break; + case "tag-list": + $pTag = $release->getTags(); + $this->parseList($cnode, $pTag, 'createTag'); + break; + } + } + + return $release; + } + + private function createRelation(XMLNode $node, $type) { + $relation = $this->factory->newRelation(); + $relation->setType(extractFragment($node->getAttribute("type"))); // TODO: fixme + $relation->setTargetType($type); + $relation->setTargetId($node->getAttribute("target")); + + $dir = mbRelation::DIR_BOTH; + switch(strtolower($node->getAttribute("direction"))) { + case "forward": + $dir = mbRelation::DIR_FORWARD; + break; + case "backward": + $dir = mbRelation::DIR_BACKWARD; + break; + } + $relation->setDirection($dir); + + $relation->setBeginDate($node->getAttribute("begin")); + $relation->setEndDate($node->getAttribute("end")); + + // TODO: ns + $attrs = $node->getAttribute("attributes"); + $attributes = explode(' ', $attrs); + foreach ($attributes as $attr) + $relation->addAttribute($attr); + + $target = null; + if ($node->nChildNodes() > 0 ) { + $cnode = $node->getChildNode(0); + switch (strtolower($cnode->getName())) { + case "artist": + $target = $this->createArtist($cnode); + break; + case "release": + $target = $this->createRelease($cnode); + break; + case "track": + $target = $this->createTrack($cnode); + break; + } + } + $relation->setTarget($target); + + return $relation; + } + + function parse($data) { + $nodes = $this->xml_parser->parse($data); + + if ($nodes == false) { + throw new mbParseError($this->xml_parser->lastError(), 1); + } + + $md = new mbMetadata(); + + for ($i = 0; $i < $nodes->nChildNodes(); $i++) { + $node = $nodes->getChildNode($i); + $name = strtolower($node->getName()); + + switch ($name) { + case "artist": + $md->setArtist($this->createArtist($node)); + break; + case "track": + $md->setTrack($this->createTrack($node)); + break; + case "release": + $md->setRelease($this->createRelease($node)); + break; + case "label": + $md->setLabel($this->createLabel($node)); + break; + case "user-rating": + $md->setRating($this->createRating($node)); + break; + case "artist-list": + $pArt = $md->getArtistResults(); + $this->parseResults($node, $pArt, 'createArtist', 'Artist'); + break; + case "track-list": + $pTrack = $md->getTrackResults(); + $this->parseResults($node, $pTrack, 'createTrack', 'Track'); + break; + case "release-list": + $pRel = $md->getReleaseResults(); + $this->parseResults($node, $pRel, 'createRelease', 'Release'); + break; + case "ext:user-list": + $list = $md->getUserList(); + $this->parseUserResults($node, $list); + break; + } + } + return $md; + } } ?> diff --git a/modules/php_musicbrainz/xml/xmlParser.php b/modules/php_musicbrainz/xml/xmlParser.php index 7e3311cf..937be7b9 100644 --- a/modules/php_musicbrainz/xml/xmlParser.php +++ b/modules/php_musicbrainz/xml/xmlParser.php @@ -1,107 +1,106 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ - class XMLNode { - private $name; - private $attributes; - private $childNodes = array(); - private $parentNode; - - function XMLNode( $name, array $attributes, $parent=null ) { - $this->name = $name; - $this->attributes = $attributes; - $this->parentNode = $parent; - } - - function getParentNode() { - return $this->parentNode; - } - - function nChildNodes() { - return sizeof($this->childNodes); - } - - function getChildNode( $i ) { - return $this->childNodes[$i]; - } - - function setChildNode( XMLNode $node ) { - $this->childNodes[] = $node; - } - - function getName() { - return $this->name; - } - - function getAttribute( $name ) { - $name = strtoupper($name); - return isset($this->attributes[$name]) ? $this->attributes[$name] : - ""; - } - - function setText( $text ) { - $this->attributes['TEXT'] = $text; - } - - function getText() { - return $this->attributes['TEXT']; - } - } - - class xmlParser { - private $_parser; - private $_root_node = null; - private $_curr_node = null; - - public function xmlParser() { - $this->_parser = xml_parser_create(); - - xml_set_object($this->_parser, $this); - xml_set_default_handler( $this->_parser, 'text_handler' ); - xml_set_element_handler( $this->_parser, - 'start_element_handler', - 'end_element_handler' ); - } - - public function destroy() { - xml_parser_free($this->_parser); - } - - public function lastError() { - return $this->_last_error; - } - - public function parse( $data ) { - if ( !xml_parse( $this->_parser, $data ) ) { - $this->_last_error = xml_get_current_line_number($this->_parser) . ": ". xml_error_string($this->_parser); - return false; - } - return $this->_root_node; - } - - private function start_element_handler( $parser, $name, $attribs ) { - if ( !$this->_root_node ) { - $new_node = new XMLNode( $name, $attribs ); - $this->_root_node = $new_node; - $this->_curr_node = $new_node; - } - else { - $old_node = $this->_curr_node; - $new_node = new XMLNode( $name, $attribs, $old_node ); - $old_node->setChildNode( $new_node ); - $this->_curr_node = $new_node; - } - - } - - private function text_handler( $parser, $text ) { - if ( $this->_curr_node ) - $this->_curr_node->setText( $text ); - } - - private function end_element_handler( $parser, $name ) { - if ( $this->_root_node ) { - $this->_curr_node = $this->_curr_node->getParentNode(); - } - } - } +/* vim:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ +class XMLNode { + private $name; + private $attributes; + private $childNodes = array(); + private $parentNode; + + public function __construct($name, array $attributes, $parent=null) { + $this->name = $name; + $this->attributes = $attributes; + $this->parentNode = $parent; + } + + public function getParentNode() { + return $this->parentNode; + } + + public function nChildNodes() { + return sizeof($this->childNodes); + } + + public function getChildNode($i) { + return $this->childNodes[$i]; + } + + public function setChildNode(XMLNode $node) { + $this->childNodes[] = $node; + } + + public function getName() { + return $this->name; + } + + public function getAttribute($name) { + $name = strtoupper($name); + return isset($this->attributes[$name]) ? $this->attributes[$name] : ""; + } + + public function setText($text) { + $this->attributes['TEXT'] = $text; + } + + public function getText() { + return $this->attributes['TEXT']; + } +} + +class xmlParser { + private $_parser; + private $_root_node = null; + private $_curr_node = null; + + public function __construct() { + $this->_parser = xml_parser_create(); + + xml_set_object($this->_parser, $this); + xml_set_default_handler($this->_parser, 'text_handler'); + xml_set_element_handler($this->_parser, + 'start_element_handler', + 'end_element_handler'); + } + + public function destroy() { + xml_parser_free($this->_parser); + } + + public function lastError() { + return $this->_last_error; + } + + public function parse($data) { + if (!xml_parse($this->_parser, $data)) { + $this->_last_error = xml_get_current_line_number($this->_parser) . ": ". xml_error_string($this->_parser); + return false; + } + return $this->_root_node; + } + + private function start_element_handler($parser, $name, $attribs) { + if (!$this->_root_node) { + $new_node = new XMLNode($name, $attribs); + $this->_root_node = $new_node; + $this->_curr_node = $new_node; + } + else { + $old_node = $this->_curr_node; + $new_node = new XMLNode($name, $attribs, $old_node); + $old_node->setChildNode($new_node); + $this->_curr_node = $new_node; + } + + } + + private function text_handler($parser, $text) { + if ($this->_curr_node) + $this->_curr_node->setText($text); + } + + private function end_element_handler($parser, $name) { + if ($this->_root_node) { + $this->_curr_node = $this->_curr_node->getParentNode(); + } + } +} ?> |