@using System.Linq
@using MrCMS.Entities.Documents.Web
@using MrCMS.Helpers
@using MrCMS.Web.Areas.Admin.Helpers
@using MrCMS.Website
@model Webpage
<div class="display-inline">
    <i class="glyphicon glyphicon-question-sign" rel="tooltip" data-placement="top" data-original-title="This is the URL which people will see in the browser bar.
            For example if your Permalink is /hello-world and your domain is www.example.com, your full URL will be www.example.com/hello-world">&nbsp;</i>

    @Resource("Admin Webpage Seo Permalink", "Permalink"): /<span id="url-span">@Model.UrlSegment</span> @Html.TextBoxFor(x => x.UrlSegment, new { @class = "form-control", style = "display:none;" })
    @Html.ValidationMessageFor(x => x.UrlSegment, "", new { @class = "error" })
    <button id="change-url" class="btn btn-default btn-xs">Change</button>


    <hr />
    <div class="display-inline">
        <i class="glyphicon glyphicon-question-sign" rel="tooltip" data-placement="top" data-original-title="Mr CMS is great - it saves old Urls as you change the page Url so that search engines never miss a page. If you change your page from /my-page to /my-page2, Mr CMS will remember this and redirect the old Url to the new Url">&nbsp;</i> Url History

        @Html.ActionLink(Resource("Add"), "Add", "UrlHistory", new { webpageId = Model.Id }, new { @class = "btn btn-xs btn-success", data_toggle = "fb-modal" })
    </div>
    @if (Model.Urls.Any())
    {
        <table class="table table-striped table-condensed margin-top-10">
            <tbody>
                @foreach (var url in Model.Urls.OrderByDescending(history => history.CreatedOn))
                {
                    <tr>
                        <td>
                            <a href="http://@Model.Site.BaseUrl/@url.UrlSegment" target="_blank">http://@Model.Site.BaseUrl/@url.UrlSegment</a>
                        </td>
                        <td>
                            @Html.ActionLink("Delete", "Delete", "UrlHistory", new { id = url.Id }, new { @class = "btn btn-xs btn-danger", data_toggle = "fb-modal" })
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    }
    else
    {
        @Resource("Admin Webpage Seo No URL History", "No URL History")
    }

</div>

@if (!(Model is Redirect))
{
    <hr />
    <div class="form-group">
        @Html.LabelFor(x => x.MetaTitle)
        @Html.TextBoxFor(x => x.MetaTitle, new { @class = "form-control" })
        @Html.ValidationMessageFor(x => x.MetaTitle, "", new { @class = "error" })
    </div>
    <div class="form-group">
        @Html.LabelFor(x => x.MetaDescription)
        @Html.TextBoxFor(x => x.MetaDescription, new { @class = "form-control" })
        @Html.ValidationMessageFor(x => x.MetaDescription, "", new { @class = "error" })
    </div>
    <div class="form-group">
        @Html.LabelFor(x => x.MetaKeywords)
        @Html.TextBoxFor(x => x.MetaKeywords, new { @class = "form-control" })
        @Html.ValidationMessageFor(x => x.MetaKeywords, "", new { @class = "error" })
    </div>
    <div class="form-group">
        @Html.LabelFor(x => x.ExplicitCanonicalLink)
        @Html.TextBoxFor(x => x.ExplicitCanonicalLink, new { @class = "form-control" })
        @Html.ValidationMessageFor(x => x.ExplicitCanonicalLink, "", new { @class = "error" })
    </div>
    <hr />
    <h4>@Resource("Admin Webpage Seo SEO Analysis", "SEO Analysis") </h4>
    @Html.LabelFor(webpage => webpage.SEOTargetPhrase)
    <div class="input-group">
        @Html.TextBoxFor(webpage => webpage.SEOTargetPhrase, new { @class = "form-control" })
        <span class="input-group-btn">
            <button data-seo-analyze="true" class="btn btn-default">@Resource("Admin Webpage Seo Analyze", "Analyze")</button>
        </span>
    </div>

    <div data-seo-analysis-summary="true">
    </div>

    <hr />

    <div class="form-group">
        @Html.InlineCheckboxFor(webpage => webpage.RevealInNavigation)
    </div>
    <div class="form-group">
        @Html.InlineCheckboxFor(webpage => webpage.IncludeInSitemap)
    </div>
    <div class="form-group">
        @Html.InlineCheckboxFor(webpage => webpage.RequiresSSL)
    </div>
}
<hr />

<div class="form-group">
    @Html.LabelFor(x => x.CustomHeaderScripts)
    @Html.TextAreaFor(x => x.CustomHeaderScripts, new { @class = "form-control" })
    @Html.ValidationMessageFor(x => x.CustomHeaderScripts, "", new { @class = "error" })
</div>
<div class="form-group">
    @Html.LabelFor(x => x.CustomFooterScripts)
    @Html.TextAreaFor(x => x.CustomFooterScripts, new { @class = "form-control" })
    @Html.ValidationMessageFor(x => x.CustomFooterScripts, "", new { @class = "error" })
</div>
@if (Model.IsTypeCachable())
{
    <hr />
    <h4>@Resource("Advanced")</h4>
    <hr class="small-margin" />
    <div class="form-group">
        @Html.InlineCheckboxFor(widget => widget.DoNotCache)
    </div>
}
<hr />
<strong>@Resource("Page type"):</strong> @Model.GetMetadata().Name
<br />
<strong>@Resource("Created On"): </strong>@Model.CreatedOn
<br />
<strong>@Resource("Last Updated"): </strong>@Model.UpdatedOn
<br />
<strong>Page Id: </strong>@Model.Id