mirror of
https://github.com/Radarr/Radarr
synced 2024-12-30 20:05:41 +00:00
37 lines
No EOL
1.1 KiB
C#
37 lines
No EOL
1.1 KiB
C#
using System.Linq;
|
|
using System;
|
|
using System.Web.Mvc;
|
|
using System.Web.Mvc.Html;
|
|
|
|
namespace NzbDrone.Web.Helpers
|
|
{
|
|
public static class IsCurrentActionHelper
|
|
{
|
|
private static bool IsCurrentController(HtmlHelper helper, string actionName, string controllerName)
|
|
{
|
|
var currentControllerName = (string) helper.ViewContext.RouteData.Values["controller"];
|
|
|
|
if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName,
|
|
string controllerName)
|
|
{
|
|
string result;
|
|
|
|
if (IsCurrentController(helper, actionName, controllerName))
|
|
{
|
|
result = "<li class='current_page_item'>";
|
|
}
|
|
else
|
|
{
|
|
result = "<li>";
|
|
}
|
|
|
|
return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>";
|
|
}
|
|
}
|
|
} |