diff --git a/classes/class_format.php b/classes/class_format.php index 41866708..6075c0bf 100644 --- a/classes/class_format.php +++ b/classes/class_format.php @@ -1,5 +1,39 @@ 'tl_notice', + 'snatched' => 'tl_snatched', + + 'freeleech' => 'tl_free', + 'neutral leech' => 'tl_free tl_neutral', + 'personal freeleech' => 'tl_free tl_personal', + + 'reported' => 'tl_reported', + 'bad tags' => 'tl_reported tl_bad_tags', + 'bad folders' => 'tl_reported tl_bad_folders', + 'bad file names' => 'tl_reported tl_bad_file_names', + + 'cassette approved' => 'tl_approved tl_cassete', + 'lossy master approved' => 'tl_approved tl_lossy_master', + 'lossy web approved' => 'tl_approved tl_lossy_web' + ); + /** * Shorten a string * @@ -463,4 +497,35 @@ public static function is_utf8($Str) { ); } + /** + * Modified accessor for the $TorrentLabels array + * + * Converts $text to lowercase and strips non-word characters + * + * @param string $text Search string + * @return string CSS class(es) + */ + public static function find_torrent_label_class ($text) + { + $index = mb_eregi_replace('(?:[^\w\d\s]+)', '', strtolower($text)); + if (isset(self::$TorrentLabels[$index])) return self::$TorrentLabels[$index]; + return self::$TorrentLabels['default']; + } + + /** + * Creates a strong element that notes the torrent's state. + * Eg: snatched/freeleech/neutral leech/reported + * + * The CSS class is infered using find_torrent_label_class($text) + * + * @param string $text Display text + * @param string $class Custom CSS class + * @return string Strong element + */ + public static function torrent_label ($text, $class='') + { + if (empty($class)) $class = self::find_torrent_label_class($text); + return sprintf('%2$s', + display_str($class), display_str($text)); + } } \ No newline at end of file diff --git a/classes/class_torrents.php b/classes/class_torrents.php index b018a406..c5da7c28 100644 --- a/classes/class_torrents.php +++ b/classes/class_torrents.php @@ -457,10 +457,10 @@ public static function torrent_info($Data, $ShowMedia = false, $ShowEdition = fa if (!empty($Data['RemasterTitle'])) { $EditionInfo[]=$Data['RemasterTitle']; } if (count($EditionInfo)) { $Info[]=implode(' ',$EditionInfo); } } - if ($Data['IsSnatched']) { $Info[]='Snatched!'; } - if ($Data['FreeTorrent'] == '1') { $Info[]='Freeleech!'; } - if ($Data['FreeTorrent'] == '2') { $Info[]='Neutral Leech!'; } - if ($Data['PersonalFL']) { $Info[]='Personal Freeleech!'; } + if ($Data['IsSnatched']) { $Info[]= Format::torrent_label('Snatched!'); } + if ($Data['FreeTorrent'] == '1') { $Info[]= Format::torrent_label('Freeleech!'); } + if ($Data['FreeTorrent'] == '2') { $Info[]= Format::torrent_label('Neutral Leech!'); } + if ($Data['PersonalFL']) { $Info[]= Format::torrent_label('Personal Freeleech!'); } return implode(' / ', $Info); } diff --git a/sections/better/transcode.php b/sections/better/transcode.php index 605a2021..88b11398 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -147,7 +147,7 @@ $DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]"; } if ($Edition['IsSnatched']) { - $DisplayName .= ' Snatched!'; + $DisplayName .= ' ' . Format::torrent_label('Snatched!'); } $EditionInfo = array(); diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index ec6c18d7..a8f4ebf0 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -192,14 +192,14 @@ function compare($X, $Y){ $DisplayName = ''.$GroupName.''; if ($Torrent['IsSnatched']) { - $DisplayName .= ' Snatched!'; + $DisplayName .= ' ' . Format::torrent_label('Snatched!'); } if ($Torrent['FreeTorrent'] == '1') { - $DisplayName .= ' Freeleech!'; + $DisplayName .= ' ' . Format::torrent_label('Freeleech!'); } elseif ($Torrent['FreeTorrent'] == '2') { - $DisplayName .= ' Neutral Leech!'; + $DisplayName .= ' ' . Format::torrent_label('Neutral leech!'); } elseif ($Torrent['PersonalFL']) { - $DisplayName .= ' Personal Freeleech!'; + $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!'); } $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?> diff --git a/sections/collages/collage.php b/sections/collages/collage.php index 782a889b..829a8772 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -267,14 +267,14 @@ function compare($X, $Y){ $DisplayName = ''.$GroupName.''; if ($Torrent['IsSnatched']) { - $DisplayName .= ' Snatched!'; + $DisplayName .= ' ' . Format::torrent_label('Snatched!'); } if ($Torrent['FreeTorrent'] == '1') { - $DisplayName .= ' Freeleech!'; + $DisplayName .= ' ' . Format::torrent_label('Freeleech!'); } elseif ($Torrent['FreeTorrent'] == '2') { - $DisplayName .= ' Neutral Leech!'; + $DisplayName .= ' ' . Format::torrent_label('Neutral Leech!'); } elseif ($Torrent['PersonalFL']) { - $DisplayName .= ' Personal Freeleech!'; + $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!'); } $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?> diff --git a/sections/top10/torrents.php b/sections/top10/torrents.php index a2c5e280..99261df6 100644 --- a/sections/top10/torrents.php +++ b/sections/top10/torrents.php @@ -453,7 +453,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) { if($Scene) { $ExtraInfo.=$AddExtra.'Scene'; $AddExtra=' / '; } if($Year>0) { $ExtraInfo.=$AddExtra.$Year; $AddExtra=' '; } if($RemasterTitle) { $ExtraInfo.=$AddExtra.$RemasterTitle; } - if($IsSnatched) { if($GroupCategoryID == 1) { $ExtraInfo .= ' / '; } $ExtraInfo.='Snatched!'; } + if($IsSnatched) { if($GroupCategoryID == 1) { $ExtraInfo .= ' / '; } $ExtraInfo.= Format::torrent_label('Snatched!'); } if($ExtraInfo!='') { $ExtraInfo = "- [$ExtraInfo]"; } diff --git a/sections/top10/votes.php b/sections/top10/votes.php index 30db9c02..74b5f2b7 100644 --- a/sections/top10/votes.php +++ b/sections/top10/votes.php @@ -310,14 +310,14 @@ $DisplayName = $Number .' - '.$GroupName.''; if($Torrent['IsSnatched']) { - $DisplayName .= ' Snatched!'; + $DisplayName .= ' ' . Format::torrent_label('Snatched!'); } if ($Torrent['FreeTorrent'] == '1') { - $DisplayName .= ' Freeleech!'; + $DisplayName .= ' ' . Format::torrent_label('Freeleech!'); } elseif ($Torrent['FreeTorrent'] == '2') { - $DisplayName .= ' Neutral Leech!'; + $DisplayName .= ' ' . Format::torrent_label('Neutral leech!'); } elseif (Torrents::has_token($TorrentID)) { - $DisplayName .= ' Personal Freeleech!'; + $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!'); } $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?> diff --git a/sections/torrents/browse.php b/sections/torrents/browse.php index ef1711cb..79066181 100644 --- a/sections/torrents/browse.php +++ b/sections/torrents/browse.php @@ -948,7 +948,7 @@ function header_link($SortKey,$DefaultWay="DESC") { if(trim($Torrents['remastertitle'][$Key])) { $ExtraInfo.=$AddExtra.$Torrents['remastertitle'][$Key]; $AddExtra=" - "; } elseif($Torrents['remastered'][$Key]=="1") { $ExtraInfo.=$AddExtra."Remastered"; $AddExtra=" - "; } if($Torrents['year'][$Key]>"0") { $ExtraInfo.=$AddExtra.$Torrents['year'][$Key]; $AddExtra=" / "; } - if($Torrents['freetorrent'][$Key]=="1") { $ExtraInfo.=$AddExtra.'Freeleech!'; $AddExtra=" / "; } + if($Torrents['freetorrent'][$Key]=="1") { $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!'); $AddExtra=" / "; } ?> @@ -988,7 +988,7 @@ function header_link($SortKey,$DefaultWay="DESC") { if(trim($Torrents['remastertitle'][0])) { $ExtraInfo.=$AddExtra.$Torrents['remastertitle'][0]; $AddExtra=" - "; } elseif($Torrents['remastered'][0]=="1") { $ExtraInfo.=$AddExtra."Remastered"; $AddExtra=" - "; } if($Torrents['year'][0]>"0") { $ExtraInfo.=$AddExtra.$Torrents['year'][0]; $AddExtra=" / "; } - if($Torrents['freetorrent'][0]=="1") { $ExtraInfo.=$AddExtra.'Freeleech!'; $AddExtra=" / "; } + if($Torrents['freetorrent'][0]=="1") { $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!'); $AddExtra=" / "; } if($ExtraInfo!='') { $ExtraInfo="[".$ExtraInfo."]"; } if($GroupYear>0) { $ExtraInfo.=" [".$GroupYear."]"; } diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php index 229d45f9..02222bf4 100644 --- a/sections/torrents/browse2.php +++ b/sections/torrents/browse2.php @@ -1080,7 +1080,7 @@ function header_link($SortKey,$DefaultWay="desc") { } $ExtraInfo = Torrents::torrent_info($Data, true, true); } elseif ($Data['IsSnatched']) { - $ExtraInfo = 'Snatched!'; + $ExtraInfo = Format::torrent_label('Snatched!'); } else { $ExtraInfo = ''; } diff --git a/sections/torrents/details.php b/sections/torrents/details.php index 2f502940..4aa1c6f4 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -472,17 +472,17 @@ function filelist($Str) { if(!$ExtraInfo) { $ExtraInfo = $GroupName ; $AddExtra=' / '; } - if($IsSnatched) { $ExtraInfo.=$AddExtra.'Snatched!'; $AddExtra=' / '; } - if($FreeTorrent == '1') { $ExtraInfo.=$AddExtra.'Freeleech!'; $AddExtra=' / '; } - if($FreeTorrent == '2') { $ExtraInfo.=$AddExtra.'Neutral Leech!'; $AddExtra=' / '; } - if($PersonalFL) { $ExtraInfo.=$AddExtra.'Personal Freeleech!'; $AddExtra=' / '; } - if($Reported) { $ExtraInfo.=$AddExtra.'Reported'; $AddExtra=' / '; } - if(!empty($BadTags)) { $ExtraInfo.=$AddExtra.'Bad Tags'; $AddExtra=' / '; } - if(!empty($BadFolders)) { $ExtraInfo.=$AddExtra.'Bad Folders'; $AddExtra=' / '; } - if(!empty($CassetteApproved)) { $ExtraInfo.=$AddExtra.'Cassette Approved'; $AddExtra=' / '; } - if(!empty($LossymasterApproved)) { $ExtraInfo.=$AddExtra.'Lossy Master Approved'; $AddExtra=' / '; } - if(!empty($LossywebApproved)) { $ExtraInfo.=$AddExtra.'Lossy WEB Approved'; $AddExtra = ' / '; } - if(!empty($BadFiles)) { $ExtraInfo.=$AddExtra.'Bad File Names'; $AddExtra=' / '; } + if($IsSnatched) { $ExtraInfo.=$AddExtra. Format::torrent_label('Snatched!'); $AddExtra=' / '; } + if($FreeTorrent == '1') { $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!'); $AddExtra=' / '; } + if($FreeTorrent == '2') { $ExtraInfo.=$AddExtra. Format::torrent_label('Neutral Leech!'); $AddExtra=' / '; } + if($PersonalFL) { $ExtraInfo.=$AddExtra. Format::torrent_label('Personal Freeleech!'); $AddExtra=' / '; } + if($Reported) { $ExtraInfo.=$AddExtra. Format::torrent_label('Reported'); $AddExtra=' / '; } + if(!empty($BadTags)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Tags'); $AddExtra=' / '; } + if(!empty($BadFolders)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Folders'); $AddExtra=' / '; } + if(!empty($CassetteApproved)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Cassette Approved'); $AddExtra=' / '; } + if(!empty($LossymasterApproved)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Lossy Master Approved'); $AddExtra=' / '; } + if(!empty($LossywebApproved)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Lossy WEB Approved'); $AddExtra = ' / '; } + if(!empty($BadFiles)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad File Names'); $AddExtra=' / '; } if($GroupCategoryID == 1 && ($RemasterTitle != $LastRemasterTitle diff --git a/sections/userhistory/subscribed_collages.php b/sections/userhistory/subscribed_collages.php index 9abeb68b..d25397f8 100644 --- a/sections/userhistory/subscribed_collages.php +++ b/sections/userhistory/subscribed_collages.php @@ -246,10 +246,10 @@ $DisplayName = ''.$GroupName.''; if($Torrent['IsSnatched']) { - $DisplayName .=' Snatched!'; + $DisplayName .=' ' . Format::torrent_label('Snatched!'); } if(!empty($Torrent['FreeTorrent'])) { - $DisplayName .=' Freeleech!'; + $DisplayName .=' ' . Format::torrent_label('Freeleech!'); } $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?>