{$pageUrl|default:null}
{$noindex_val = null}
{$nofollow_val = null}
{$json_data = null}
{$h1 = null}
{for $i=1 to 5}
    {assign var="mesh_text_$i" value=null}
    {assign var="mesh_url_$i" value=null}
    {assign var="mesh_$i" value=null}
{/for}

{loop type="better_seo_loop" name="better_seo_data" object_id=$object_id object_type=$object_type lang_id=$edit_language_id}
{$noindex_val = $NOINDEX}
{$nofollow_val = $NOFOLLOW}
{$json_data = $JSON_DATA}
{$h1 = $H1}
{for $i=1 to 5}
    {assign var="mesh_text_$i" value={$MESH_TEXT_{$i}}}
    {assign var="mesh_url_$i" value={$MESH_URL_{$i}}}
    {assign var="mesh_$i" value={$MESH_{$i}}}
{/for}
{/loop}
{form name = "betterseo_form"}
    <form method="POST" action="{url path="/admin/module/betterseo/save" object_id=$object_id object_type=$object_type lang_id=$edit_language_id}">
        <div class="panel panel-default">
            <div class="panel-heading">
                <label>{intl l="label.noindex" d="betterseo.bo.default"}</label>
            </div>
            <div class="panel-body">

                {form_hidden_fields form=$form}
                {if $form_error}
                    <div class="row">
                        <div class="col-md-12">
                            <div class="alert alert-danger">{$form_error_message}</div>
                        </div>
                    </div>
                {/if}

                <div class="panel-body text-right">
                    <button type="submit" name="save_mode" value="stay" class="form-submit-button btn btn-sm btn-default btn-success">
                        {intl l='Save'} <span class="glyphicon glyphicon-ok"></span>
                    </button>
                </div>

                {form_field  field="noindex_checkbox"}
                    <div class="{if $error} has-error{/if}">
                        <input id="{$label_attr.for}" type="checkbox" name="{$name}" value="1" {if $noindex_val == 1} checked {/if}/>
                        <label class="control-label danger" for="{$label_attr.for}">{intl l=$label d="betterseo.bo.default"}</label>
                        {if $error}
                            <div class="text-danger">
                                {$message}
                            </div>
                        {/if}
                    </div>
                {/form_field}

                {form_field  field="nofollow_checkbox"}
                    <div class="{if $error} has-error{/if}">
                        <input id="{$label_attr.for}" type="checkbox" name="{$name}" value="1" {if $nofollow_val == 1} checked {/if}/>
                        <label class="control-label danger" for="{$label_attr.for}">{intl l=$label d="betterseo.bo.default"}</label>
                        {if $error}
                            <div class="text-danger">
                                {$message}
                            </div>
                        {/if}
                    </div>
                {/form_field}
                <div class="help-block">
                    {intl l="noindex_nofollow.help" d="betterseo.bo.default"}
                </div>

                {form_field  field="h1"}
                    <div class="{if $error} has-error{/if}">
                        <label class="control-label danger" for="{$label_attr.for}">{intl l=$label d="betterseo.bo.default"}</label>
                        <input type="text" id="{$label_attr.for}"  class="form-control" name="{$name}" value="{$h1}"/>
                        {if $error}
                            <div class="text-danger">
                                {$message}
                            </div>
                        {/if}
                        <div class="help-block">
                        </div>
                    </div>
                {/form_field}

                {form_field field="json_data"}
                    <div class="form-group">
                        <label for="{$label_attr.for}" class="control-label">{$label}</label>
                        <textarea name={$name} id="{$label_attr.for}" cols="30" rows="10" class="form-control">{$json_data}</textarea>
                    </div>
                {/form_field}

                <hr/>
                <table class="table table-striped">
                    <caption>{intl l="Mesh" d="betterseo.bo.default"}</caption>
                    <thead>
                    <tr>
                        {for $i=1 to 5}
                            <th>
                                {intl l="Text" d="betterseo.bo.default"} {$i}
                            </th>
                        {/for}
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                    {for $i=1 to 5}
                        {$textVar = "MESH_$i"}

                        <td>
                            {form_field  field="mesh_$i"}
                                <div class="{if $error} has-error{/if}">
                                    <input type="text" id="{$label_attr.for}"  class="form-control" name="{$name}" value="{$mesh_{$i}}"/>
                                    {if $error}
                                        <div class="text-danger">
                                            {$message}
                                        </div>
                                    {/if}
                                </div>
                            {/form_field}
                        </td>
                    {/for}
                    </tr>
                    </tbody>
                </table>

                <hr/>
                <table class="table table-striped">
                    <caption>{intl l="Mesh links" d="betterseo.bo.default"}</caption>
                    <thead>
                        <tr>
                            <th>

                            </th>
                            <th>
                                {intl l="Link text" d="betterseo.bo.default"}
                            </th>
                            <th>
                                {intl l="Link URL" d="betterseo.bo.default"}
                            </th>
                        </tr>
                    </thead>
                    <tbody>

                    {for $i=1 to 5}
                        {$urlVar = "MESH_URL_$i"}
                        {$textVar = "MESH_TEXT_$i"}

                        <tr>
                            <td>
                                {intl l="Link" d="betterseo.bo.default"} {$i}
                            </td>
                            <td>
                                {form_field  field="mesh_text_$i"}
                                    <div class="{if $error} has-error{/if}">
                                        <label class="control-label danger" for="{$label_attr.for}">{intl l=$label d="betterseo.bo.default"}</label>
                                        <input type="text" id="{$label_attr.for}"  class="form-control" name="{$name}" value="{$mesh_text_{$i}}"/>
                                        {if $error}
                                            <div class="text-danger">
                                                {$message}
                                            </div>
                                        {/if}
                                    </div>
                                {/form_field}
                            </td>
                            <td>
                                {form_field  field="mesh_url_$i"}
                                    <div class="{if $error} has-error{/if}">
                                        <label class="control-label danger" for="{$label_attr.for}">{intl l=$label d="betterseo.bo.default"}</label>
                                        <input type="url" id="{$label_attr.for}"  class="form-control" name="{$name}" value="{$mesh_url_{$i}}"/>
                                        {if $error}
                                            <div class="text-danger">
                                                {$message}
                                            </div>
                                        {/if}
                                    </div>
                                {/form_field}
                            </td>
                        </tr>
                    {/for}
                    </tbody>
                </table>


            </div>
            <div class="panel-body text-right">
                <button type="submit" name="save_mode" value="stay" class="form-submit-button btn btn-sm btn-default btn-success">
                    {intl l='Save'} <span class="glyphicon glyphicon-ok"></span>
                </button>

            </div>
        </div>
    </form>

{/form}
