Empty commit

This commit is contained in:
Git 2012-11-18 08:00:19 +00:00
parent 1908c8fae2
commit 4de82e6477
7 changed files with 163 additions and 43 deletions

View File

@ -370,6 +370,63 @@ public static function selected($Name, $Value, $Attribute='selected', $Array = a
}
}
/**
* Return a css class name if certain conditions are met. Mainly useful to mark links as 'active'
*
* @param mixed $Target The variable to compare all values against
* @param mixed $Tests The condition values. Type and dimension determines test type
* Scalar: $Tests must be equal to $Target for a match
* Vector: All elements in $Tests must correspond to equal values in $Target
* 2-dimensional array: At least one array must be identical to $Target
* @param string $ClassName CSS class name to return
* @param bool $AddAttribute Whether to include the "class" attribute in the output
* @param string $UserIDKey Key in _REQUEST for a user id parameter, which if given will be compared to $LoggedUser[ID]
*
* @return class name on match, otherwise an empty string
*/
public static function add_class($Target, $Tests, $ClassName, $AddAttribute, $UserIDKey = false) {
global $LoggedUser;
if ($UserIDKey && isset($_REQUEST[$UserIDKey]) && $LoggedUser['ID'] != $_REQUEST[$UserIDKey]) {
return '';
}
$Pass = true;
if (!is_array($Tests)) {
// Scalars are nice and easy
$Pass = $Tests === $Target;
} elseif (!is_array($Tests[0])) {
// Test all values in vectors
foreach ($Tests as $Type => $Part) {
if (!isset($Target[$Type]) || $Target[$Type] !== $Part) {
$Pass = false;
break;
}
}
} else {
// Loop to the end of the array or until we find a matching test
foreach ($Tests as $Test) {
$Pass = true;
// If $Pass remains true after this test, it's a match
foreach ($Test as $Type => $Part) {
if (!isset($Target[$Type]) || $Target[$Type] !== $Part) {
$Pass = false;
break;
}
}
if ($Pass) {
break;
}
}
}
if (!$Pass) {
return '';
}
if ($AddAttribute) {
return ' class="'.$ClassName.'"';
}
return " $ClassName";
}
/**
* Detect the encoding of a string and transform it to UTF-8.
*

View File

@ -18,10 +18,17 @@ public static function show_header($PageTitle='',$JSIncludes='')
{
global $Document, $Cache, $DB, $LoggedUser, $Mobile, $Classes;
if($PageTitle!='') { $PageTitle.=' :: '; }
if ($PageTitle != '') {
$PageTitle .= ' :: ';
}
$PageTitle .= SITE_NAME;
$PageID = array(
$Document, // Document
empty($_REQUEST['action']) ? false : $_REQUEST['action'], // Action
empty($_REQUEST['type']) ? false : $_REQUEST['type'] // Type
);
if(!is_array($LoggedUser) || empty($LoggedUser['ID'])) {
if (!is_array($LoggedUser) || empty($LoggedUser['ID'])) {
require(SERVER_ROOT.'/design/publicheader.php');
} else {
require(SERVER_ROOT.'/design/privateheader.php');
@ -43,7 +50,6 @@ public static function show_footer ($Options=array())
else { require(SERVER_ROOT.'/design/privatefooter.php'); }
}
/**
* This is a generic function to load a template fromm /design and render it.
* The template should be in /design/my_template_name.php, and have a class

View File

@ -95,12 +95,20 @@
<div id="logo"><a href="index.php"></a></div>
<div id="userinfo">
<ul id="userinfo_username">
<li id="nav_userinfo"><a href="user.php?id=<?=$LoggedUser['ID']?>" class="username"><?=$LoggedUser['Username']?></a></li>
<li id="nav_useredit" class="brackets"><a href="user.php?action=edit&amp;userid=<?=$LoggedUser['ID']?>">Edit</a></li>
<li id="nav_logout" class="brackets"><a href="logout.php?auth=<?=$LoggedUser['AuthKey']?>">Logout</a></li>
<li id="nav_userinfo"<?=Format::add_class($PageID, array('user',false,false), 'active', true, 'id')?>>
<a href="user.php?id=<?=$LoggedUser['ID']?>" class="username"><?=$LoggedUser['Username']?></a>
</li>
<li id="nav_useredit" class="brackets<?=Format::add_class($PageID, array('user','edit'), 'active', false)?>">
<a href="user.php?action=edit&amp;userid=<?=$LoggedUser['ID']?>">Edit</a>
</li>
<li id="nav_logout" class="brackets">
<a href="logout.php?auth=<?=$LoggedUser['AuthKey']?>">Logout</a>
</li>
</ul>
<ul id="userinfo_major">
<li id="nav_upload" class="brackets"><a href="upload.php">Upload</a></li>
<li id="nav_upload" class="brackets<?=Format::add_class($PageID, array('upload'), 'active', false)?>">
<a href="upload.php">Upload</a>
</li>
<?
if(check_perms('site_send_unlimited_invites')) {
$Invites = ' (∞)';
@ -110,19 +118,33 @@
$Invites = '';
}
?>
<li id="nav_invite" class="brackets"><a href="user.php?action=invite">Invite<?=$Invites?></a></li>
<li id="nav_donate" class="brackets"><a href="donate.php">Donate</a></li>
<li id="nav_invite" class="brackets<?=Format::add_class($PageID, array('user','invite'), 'active', false)?>">
<a href="user.php?action=invite">Invite') . $Invites?></a>
</li>
<li id="nav_donate" class="brackets<?=Format::add_class($PageID, array('donate'), 'active', false)?>">
<a href="donate.php"><?='Donate</a>
</li>
</ul>
<ul id="userinfo_stats">
<li id="stats_seeding"><a href="torrents.php?type=seeding&amp;userid=<?=$LoggedUser['ID']?>">Up</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span></li>
<li id="stats_leeching"><a href="torrents.php?type=leeching&amp;userid=<?=$LoggedUser['ID']?>">Down</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesDownloaded'])?></span></li>
<li id="stats_ratio">Ratio: <span class="stat"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span></li>
<li id="stats_seeding">
<a href="torrents.php?type=seeding&amp;userid=<?=$LoggedUser['ID']?>">Up</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span>
</li>
<li id="stats_leeching">
<a href="torrents.php?type=leeching&amp;userid=<?=$LoggedUser['ID']?>">Down</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesDownloaded'])?></span>
</li>
<li id="stats_ratio">
Ratio: <span class="stat"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
</li>
<? if(!empty($LoggedUser['RequiredRatio'])) {?>
<li id="stats_required"><a href="rules.php?p=ratio">Required</a>: <span class="stat" title="<?=number_format($LoggedUser['RequiredRatio'], 5)?>"><?=number_format($LoggedUser['RequiredRatio'], 2)?></span></li>
<li id="stats_required">
<a href="rules.php?p=ratio">Required</a>: <span class="stat" title="<?=number_format($LoggedUser['RequiredRatio'], 5)?>"><?=number_format($LoggedUser['RequiredRatio'], 2)?></span>
</li>
<? }
if($LoggedUser['FLTokens'] > 0) { ?>
<li id="fl_tokens"><a href="wiki.php?action=article&amp;id=754">Tokens: </a><span class="stat"><a href="userhistory.php?action=token_history&amp;userid=<?=$LoggedUser['ID']?>"><?=$LoggedUser['FLTokens']?></a></span></li>
<li id="fl_tokens">
<a href="wiki.php?action=article&amp;id=754">Tokens: </a><span class="stat"><a href="userhistory.php?action=token_history&amp;userid=<?=$LoggedUser['ID']?>"><?=$LoggedUser['FLTokens']?></a></span>
</li>
<? } ?>
</ul>
<?
@ -138,7 +160,7 @@
JOIN forums_last_read_topics AS l ON s.UserID = l.UserID AND s.TopicID = l.TopicID
JOIN forums_topics AS t ON l.TopicID = t.ID
JOIN forums AS f ON t.ForumID = f.ID
WHERE (f.MinClassRead <= ".$LoggedUser['Class']." OR f.ID IN ('$PermittedForums'))
WHERE (f.MinClassRead <= ".$LoggedUser['Class']." OR f.ID IN ('$PermittedForums')
AND l.PostID < t.LastPostID
AND s.UserID = ".$LoggedUser['ID'].
(!empty($RestrictedForums) ? "
@ -147,33 +169,68 @@
$Cache->cache_value('subscriptions_user_new_'.$LoggedUser['ID'], $NewSubscriptions, 0);
} ?>
<ul id="userinfo_minor"<?=$NewSubscriptions ? ' class="highlite"' : ''?>>
<li id="nav_inbox"><a onmousedown="Stats('inbox');" href="inbox.php">Inbox</a></li>
<li id="nav_staffinbox"><a onmousedown="Stats('staffpm');" href="staffpm.php">Staff Inbox</a></li>
<li id="nav_uploaded"><a onmousedown="Stats('uploads');" href="torrents.php?type=uploaded&amp;userid=<?=$LoggedUser['ID']?>">Uploads</a></li>
<li id="nav_bookmarks"><a onmousedown="Stats('bookmarks');" href="bookmarks.php?type=torrents">Bookmarks</a></li>
<ul id="userinfo_minor">
<li id="nav_inbox"<?=Format::add_class($PageID, array('inbox'), 'active', true)?>>
<a onmousedown="Stats('inbox');" href="inbox.php">Inbox</a>
</li>
<li id="nav_staffinbox"<?=Format::add_class($PageID, array('staffpm'), 'active', true)?>>
<a onmousedown="Stats('staffpm');" href="staffpm.php">Staff Inbox</a>
</li>
<li id="nav_uploaded"<?=Format::add_class($PageID, array('torrents',false,'uploaded'), 'active', true, 'userid')?>>
<a onmousedown="Stats('uploads');" href="torrents.php?type=uploaded&amp;userid=<?=$LoggedUser['ID']?>">Uploads</a>
</li>
<li id="nav_bookmarks"<?=Format::add_class($PageID, array('bookmarks'), 'active', true)?>>
<a onmousedown="Stats('bookmarks');" href="bookmarks.php?type=torrents">Bookmarks</a>
</li>
<? if (check_perms('site_torrents_notify')) { ?>
<li id="nav_notifications"><a onmousedown="Stats('notifications');" href="user.php?action=notify">Notifications</a></li>
<? }
?>
<li id="nav_subscriptions"><a onmousedown="Stats('subscriptions');" href="userhistory.php?action=subscriptions"<?=($NewSubscriptions ? ' class="new-subscriptions"' : '')?>>Subscriptions</a></li>
<li id="nav_comments"><a onmousedown="Stats('comments');" href="comments.php">Comments</a></li>
<li id="nav_friends"><a onmousedown="Stats('friends');" href="friends.php">Friends</a></li>
<li id="nav_notifications" <?=Format::add_class($PageID, array(array('torrents','notify'),array('user','notify')), 'active', true, 'userid')?>>
<a onmousedown="Stats('notifications');" href="user.php?action=notify">Notifications</a>
</li>
<? } ?>
<li id="nav_subscriptions"<?=Format::add_class($PageID, array('userhistory','subscriptions'), 'active', true)?>>
<a onmousedown="Stats('subscriptions');" href="userhistory.php?action=subscriptions"<?=($NewSubscriptions ? ' class="new-subscriptions"' : '')?>>Subscriptions</a>
</li>
<li id="nav_comments"<?=Format::add_class($PageID, array('comments'), 'active', true, 'userid')?>>
<a onmousedown="Stats('comments');" href="comments.php">Comments</a>
</li>
<li id="nav_friends"<?=Format::add_class($PageID, array('friends'), 'active', true)?>>
<a onmousedown="Stats('friends');" href="friends.php">Friends</a>
</li>
</ul>
</div>
<div id="menu">
<h4 class="hidden">Site Menu</h4>
<ul>
<li id="nav_index"><a href="index.php">Home</a></li>
<li id="nav_torrents"><a href="torrents.php">Torrents</a></li>
<li id="nav_collages"><a href="collages.php">Collages</a></li>
<li id="nav_requests"><a href="requests.php">Requests</a></li>
<li id="nav_forums"><a href="forums.php">Forums</a></li>
<li id="nav_irc"><a href="chat.php">IRC</a></li>
<li id="nav_top10"><a href="top10.php">Top 10</a></li>
<li id="nav_rules"><a href="rules.php">Rules</a></li>
<li id="nav_wiki"><a href="wiki.php">Wiki</a></li>
<li id="nav_staff"><a href="staff.php">Staff</a></li>
<li id="nav_index"<?=Format::add_class($PageID, array('index'), 'active', true)?>>
<a href="index.php">Home</a>
</li>
<li id="nav_torrents"<?=Format::add_class($PageID, array('torrents',false,false), 'active', true)?>>
<a href="torrents.php">Torrents</a>
</li>
<li id="nav_collages"<?=Format::add_class($PageID, array('collages'), 'active', true)?>>
<a href="collages.php">Collages</a>
</li>
<li id="nav_requests"<?=Format::add_class($PageID, array('requests'), 'active', true)?>>
<a href="requests.php">Requests</a>
</li>
<li id="nav_forums"<?=Format::add_class($PageID, array('forums'), 'active', true)?>>
<a href="forums.php">Forums</a>
</li>
<li id="nav_irc"<?=Format::add_class($PageID, array('chat'), 'active', true)?>>
<a href="chat.php">IRC</a>
</li>
<li id="nav_top10"<?=Format::add_class($PageID, array('top10'), 'active', true)?>>
<a href="top10.php">Top 10</a>
</li>
<li id="nav_rules"<?=Format::add_class($PageID, array('rules'), 'active', true)?>>
<a href="rules.php">Rules</a>
</li>
<li id="nav_wiki"<?=Format::add_class($PageID, array('wiki'), 'active', true)?>>
<a href="wiki.php">Wiki</a>
</li>
<li id="nav_staff"<?=Format::add_class($PageID, array('staff'), 'active', true)?>>
<a href="staff.php">Staff</a>
</li>
</ul>
</div>
<?

View File

@ -569,7 +569,7 @@ function compare($X, $Y){
$ZIPPrefs = 1;
}
?>
<div class="box">
<div class="box box_zipdownload">
<div class="head colhead_dark"><strong>Collector</strong></div>
<div class="pad">
<form class="download_form" name="zip" action="artist.php" method="post">

View File

@ -91,11 +91,11 @@
$Row = 'a';
if($CloseTable) {
$CloseTable = false;
echo "\t</table>";
echo "\t</table><br />";
}
$CurClass = $Class;
$CloseTable = true;
echo '<br /><h3>'.$ClassName.'s</h3>';
echo '<h3>'.$ClassName.'s</h3>';
?>
<table class="staff" width="100%">
<tr class="colhead">

View File

@ -720,7 +720,7 @@ function header_link($SortKey,$DefaultWay="desc") {
</select>
</td>
</tr>
<tr id="group_results">
<tr id="search_group_results">
<td class="label">
<label for="group_results">Group by release:</label>
</td>

View File

@ -48,8 +48,8 @@
}
$Title = $Announce;
$AnnounceSSL = $Announce . " - https://" . SSL_SITE_URL . "/torrents.php?id=$GroupID / https://" . SSL_SITE_URL . "/torrents.php?action=download&id=$TorrentID";
$Announce .= " - https://" . SSL_SITE_URL . "/torrents.php?id=$GroupID / https://" . SSL_SITE_URL . "/torrents.php?action=download&id=$TorrentID";
$AnnounceSSL = $Announce . " - https://" . SSL_SITE_URL . "/torrents.php?id=$GroupID / https://" . SSL_SITE_URL . "/torrents.php?action=download&id=$ExtraTorrentID";
$Announce .= " - https://" . SSL_SITE_URL . "/torrents.php?id=$GroupID / https://" . SSL_SITE_URL . "/torrents.php?action=download&id=$ExtraTorrentID";
$AnnounceSSL .= " - " . trim($Properties['TagList']);
$Announce .= " - " . trim($Properties['TagList']);