Empty commit

This commit is contained in:
Git 2013-01-03 08:00:30 +00:00
parent f6023f377e
commit 0b222b00b4
11 changed files with 100 additions and 35 deletions

View File

@ -1,5 +1,39 @@
<?
class Format {
class Format
{
/**
* Torrent Labels
* Map a common display string to a CSS class
* Indexes are lower case
* Note the "tl_" prefix for "torrent label"
*
* There are five basic types:
* * tl_free (leech status)
* * tl_snatched
* * tl_reported
* * tl_approved
* * tl_notice (default)
*
* @var array Strings
*/
private static $TorrentLabels = array(
'default' => '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('<strong class="torrent_label %1$s" title="%2$s">%2$s</strong>',
display_str($class), display_str($text));
}
}

View File

@ -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[]='<strong class="snatched_torrent_label">Snatched!</strong>'; }
if ($Data['FreeTorrent'] == '1') { $Info[]='<strong class="freeleech_torrent_label">Freeleech!</strong>'; }
if ($Data['FreeTorrent'] == '2') { $Info[]='<strong class="neutral_leech_torrent_label">Neutral Leech!</strong>'; }
if ($Data['PersonalFL']) { $Info[]='<strong class="personal_freeleech_torrent_label">Personal Freeleech!</strong>'; }
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);
}

View File

@ -147,7 +147,7 @@
$DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]";
}
if ($Edition['IsSnatched']) {
$DisplayName .= ' <strong class="snatched_torrent_label">Snatched!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
$EditionInfo = array();

View File

@ -192,14 +192,14 @@ function compare($X, $Y){
$DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if ($Torrent['IsSnatched']) {
$DisplayName .= ' <strong class="snatched_torrent_label">Snatched!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if ($Torrent['FreeTorrent'] == '1') {
$DisplayName .= ' <strong class="freeleech_torrent_label">Freeleech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') {
$DisplayName .= ' <strong class="neutral_leech_torrent_label">Neutral Leech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
} elseif ($Torrent['PersonalFL']) {
$DisplayName .= ' <strong class="personal_freeleech_torrent_label">Personal Freeleech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>

View File

@ -267,14 +267,14 @@ function compare($X, $Y){
$DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if ($Torrent['IsSnatched']) {
$DisplayName .= ' <strong class="snatched_torrent_label">Snatched!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if ($Torrent['FreeTorrent'] == '1') {
$DisplayName .= ' <strong class="freeleech_torrent_label">Freeleech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') {
$DisplayName .= ' <strong class="neutral_leech_torrent_label">Neutral Leech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Neutral Leech!');
} elseif ($Torrent['PersonalFL']) {
$DisplayName .= ' <strong class="personal_freeleech_torrent_label">Personal Freeleech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>

View File

@ -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.='<strong class="snatched_torrent_label">Snatched!</strong>'; }
if($IsSnatched) { if($GroupCategoryID == 1) { $ExtraInfo .= ' / '; } $ExtraInfo.= Format::torrent_label('Snatched!'); }
if($ExtraInfo!='') {
$ExtraInfo = "- [$ExtraInfo]";
}

View File

@ -310,14 +310,14 @@
$DisplayName = $Number .' - <a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if($Torrent['IsSnatched']) {
$DisplayName .= ' <strong class="snatched_torrent_label">Snatched!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if ($Torrent['FreeTorrent'] == '1') {
$DisplayName .= ' <strong class="freeleech_torrent_label">Freeleech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') {
$DisplayName .= ' <strong class="neutral_leech_torrent_label">Neutral Leech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
} elseif (Torrents::has_token($TorrentID)) {
$DisplayName .= ' <strong class="personal_freeleech_torrent_label">Personal Freeleech!</strong>';
$DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>

View File

@ -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.'<strong class="freeleech_torrent_label">Freeleech!</strong>'; $AddExtra=" / "; }
if($Torrents['freetorrent'][$Key]=="1") { $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!'); $AddExtra=" / "; }
?>
<tr class="group_torrent groupid_<?=$GroupID?> <?=$HideGroup?>">
<td colspan="3">
@ -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.'<strong class="freeleech_torrent_label">Freeleech!</strong>'; $AddExtra=" / "; }
if($Torrents['freetorrent'][0]=="1") { $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!'); $AddExtra=" / "; }
if($ExtraInfo!='') { $ExtraInfo="[".$ExtraInfo."]"; }
if($GroupYear>0) { $ExtraInfo.=" [".$GroupYear."]"; }

View File

@ -1080,7 +1080,7 @@ function header_link($SortKey,$DefaultWay="desc") {
}
$ExtraInfo = Torrents::torrent_info($Data, true, true);
} elseif ($Data['IsSnatched']) {
$ExtraInfo = '<strong class="snatched_torrent_label">Snatched!</strong>';
$ExtraInfo = Format::torrent_label('Snatched!');
} else {
$ExtraInfo = '';
}

View File

@ -472,17 +472,17 @@ function filelist($Str) {
if(!$ExtraInfo) {
$ExtraInfo = $GroupName ; $AddExtra=' / ';
}
if($IsSnatched) { $ExtraInfo.=$AddExtra.'<strong class="snatched_torrent_label">Snatched!</strong>'; $AddExtra=' / '; }
if($FreeTorrent == '1') { $ExtraInfo.=$AddExtra.'<strong class="freeleech_torrent_label">Freeleech!</strong>'; $AddExtra=' / '; }
if($FreeTorrent == '2') { $ExtraInfo.=$AddExtra.'<strong class="neutral_leech_torrent_label">Neutral Leech!</strong>'; $AddExtra=' / '; }
if($PersonalFL) { $ExtraInfo.=$AddExtra.'<strong class="personal_freeleech_torrent_label">Personal Freeleech!</strong>'; $AddExtra=' / '; }
if($Reported) { $ExtraInfo.=$AddExtra.'<strong>Reported</strong>'; $AddExtra=' / '; }
if(!empty($BadTags)) { $ExtraInfo.=$AddExtra.'<strong>Bad Tags</strong>'; $AddExtra=' / '; }
if(!empty($BadFolders)) { $ExtraInfo.=$AddExtra.'<strong>Bad Folders</strong>'; $AddExtra=' / '; }
if(!empty($CassetteApproved)) { $ExtraInfo.=$AddExtra.'<strong>Cassette Approved</strong>'; $AddExtra=' / '; }
if(!empty($LossymasterApproved)) { $ExtraInfo.=$AddExtra.'<strong>Lossy Master Approved</strong>'; $AddExtra=' / '; }
if(!empty($LossywebApproved)) { $ExtraInfo.=$AddExtra.'<strong>Lossy WEB Approved</strong>'; $AddExtra = ' / '; }
if(!empty($BadFiles)) { $ExtraInfo.=$AddExtra.'<strong>Bad File Names</strong>'; $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

View File

@ -246,10 +246,10 @@
$DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if($Torrent['IsSnatched']) {
$DisplayName .=' <strong class="snatched_torrent_label">Snatched!</strong>';
$DisplayName .=' ' . Format::torrent_label('Snatched!');
}
if(!empty($Torrent['FreeTorrent'])) {
$DisplayName .=' <strong class="freeleech_torrent_label">Freeleech!</strong>';
$DisplayName .=' ' . Format::torrent_label('Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>