<div id="ctlppu_posts">
    <div class="col-md-12 container no-p-h">
        <div class="page-header title col-md-11">
            <h1>Website Analysis Ultimate Plugin by Squirrly SEO</h1>
            <button class="switch-view btn btn-default btn-md" href="item"><span
                        class="fa fa-th"></span><?php echo __(" Items View", _CTLPPU_PLUGIN_NAME_) ?></button>
            <button class="switch-view btn btn-default btn-md" href="table"><span class="fa fa-align-justify"></span>
                <?php echo __(" Table View", _CTLPPU_PLUGIN_NAME_) ?></button>
        </div>
        <?php if (defined('CTLPP_BOTH_ACTIVE') && CTLPP_BOTH_ACTIVE) { ?>
            <div class="alert alert-warning text-center"><b>Seems that you have two plugins active at the same time:
                    Website Analysis and Website Analysis Ultimate. Feel free to deactivate the first one.</b></div>
        <?php } ?>

        <div class="col-md-11 posts-place" data-display="item">
            <?php if (!empty($view->posts)) { ?>
                <?php foreach ($view->posts as $post) { ?>
                    <div class="item-post">
                        <div class="item-info"></div>
                        <div class="header">
                            <div class="title">
                                <?php echo __("Next update in", _CTLPPU_PLUGIN_NAME_) . " " . human_time_diff(strtotime(date('Y-m-d H:i:s')), $view->options->next_check); ?>
                            </div>
                            <div class="update">
                                <span class="fa fa-refresh"></span>
                            </div>
                        </div>
                        <div class="image">
                            <div class="image-thumbnail" style="background-image: url(
                            <?php echo ($post['seo_postImage'] <> '') ? ((!filter_var($post['seo_postImage'], FILTER_VALIDATE_URL) === false ? $post['seo_postImage'] : _CTLPPU_THEME_URL_ . 'img/imgerror.png')) : _CTLPPU_THEME_URL_ . 'img/noimage.jpg'; ?>
                                    )"></div>
                        </div>
                        <div class="item-circle">
                            <div class="event">
                                <a class="fa fa-external-link"
                                   title="<?php echo __("Visit the page", _CTLPPU_PLUGIN_NAME_) ?>"
                                   href="<?php echo $post['permalink']; ?>" target="_blank"
                                   style="outline: 0;text-decoration: none"></a>
                            </div>
                        </div>
                        <div class="info">
                            <div class="title">
                                <?php echo $post['seo_title']; ?>
                            </div>
                            <span class="date"><i
                                        class="glyphicon glyphicon-time"></i><?php echo ($post['post_date'] <> "0000-00-00 00:00:00") ? date("F j, Y, g:i a", strtotime($post['post_date'])) : __("unspecified", _CTLPPU_PLUGIN_NAME_); ?></span>

                            <div class="buttons">
                                <div class="button" data-value="content">Content</div>
                                <div class="button" data-value="seo">SEO</div>
                                <script>
                                </script>
                                <div class="button"
                                     data-value="advance"><?php echo __("Advanced", _CTLPPU_PLUGIN_NAME_) ?></div>
                            </div>


                            <div class="data">
                                <div class="data-category content">
                                    <?php foreach ($view->options->ctlppu_display_fields as $field) {
                                        ?>
                                        <?php if ($view->getFieldType($field) == "content") { ?>
                                            <div class="row">
                                                <div class="left" title="<?php echo $post[$field]['title'] ?>">
                                                    <span class="fa fa-<?php echo $post[$field]['icon'] ?>"></span>
                                                </div>
                                                <div class="right">
                                                    <div class="fa fa-info-circle" data-toggle="tooltip"
                                                         title="<?php echo $view->getPostTooltip($post[$field], $field) ?>"></div>
                                                    <?php
                                                    echo $view->getPostView($post[$field]);
                                                    ?>
                                                </div>
                                            </div>
                                        <?php }
                                    } ?>
                                </div>
                                <div class="data-category seo">
                                    <?php foreach ($view->options->ctlppu_display_fields as $field) {
                                        ?>
                                        <?php if ($view->getFieldType($field) == "seo") { ?>
                                            <div class="row">
                                                <div class="left" title="<?php echo $post[$field]['title'] ?>">
                                                    <span class="fa fa-<?php echo $post[$field]['icon'] ?>"></span>
                                                </div>
                                                <div class="right">
                                                    <div class="fa fa-info-circle" data-toggle="tooltip"
                                                         title="<?php echo $view->getPostTooltip($post[$field], $field) ?>"></div>
                                                    <?php
                                                    echo $view->getPostView($post[$field]);
                                                    ?>
                                                </div>
                                            </div>
                                        <?php }
                                    } ?>
                                </div>
                                <div class="data-category advance">
                                    <strong> <?php echo __("Do you want to get better SEO results ?", _CTLPPU_PLUGIN_NAME_) ?></strong></br>
                                    <a target="_blank" href="<?php echo ctlppu_get_signup_link(); ?>"><h4>Try Contentlook</h4>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php } ?>
            <?php } else {
                ?>
                <?php echo __("Error getting posts.", _CTLPPU_PLUGIN_NAME_) . '<a href="' . admin_url('admin.php?page=ctlpp_posts') . '">' . __("Try again", _CTLPPU_PLUGIN_NAME_) . "</a>"; ?>
                <?php
            } ?>
        </div>


        <div class="posts-place" data-display="table" style="display: none">
            <?php if (!empty($view->posts)) { ?>
                <table id="posts_table" class="display table dataTable" role="grid" aria-describedby="posts_table_info">
                    <thead>
                    <tr role="row">
                        <th class="sorting_asc" tabindex="0" aria-controls="posts_table" rowspan="1" colspan="1"
                            aria-sort="ascending" aria-label="Name: activate to sort column descending"
                            style="width: 178px;">
                            Title
                        </th>
                        <?php foreach ($view->options->ctlppu_display_fields as $field) { ?>
                            <th class="sorting" tabindex="0" aria-controls="posts_table" rowspan="1" colspan="1"
                                aria-label="<?php echo $post[$field]['title'] ?>: activate to sort column ascending"
                                style="width: 258px;"><?php echo $post[$field]['title'] ?></th>
                        <?php } ?>
                    </tr>
                    </thead>

                    <tfoot>
                    <tr role="row">
                        <th class="sorting_asc" tabindex="0" aria-controls="posts_table" rowspan="1" colspan="1"
                            aria-sort="ascending" aria-label="Name: activate to sort column descending"
                            style="min-width: 250px;">
                            Title
                        </th>
                        <?php foreach ($view->options->ctlppu_display_fields as $field) { ?>
                            <th class="sorting" tabindex="0" aria-controls="posts_table" rowspan="1" colspan="1"
                                aria-label="<?php echo $post[$field]['title'] ?>: activate to sort column ascending"
                                style="width: auto;"><?php echo $post[$field]['title'] ?></th>
                        <?php } ?>
                    </tr>
                    </tfoot>
                    <tbody>
                    <?php foreach ($view->posts as $post) { ?>
                        <tr role="row">
                            <td class="sorting_1"><a href="<?php echo $post['permalink'] ?>"
                                                     target="_blank"><?php echo $post['seo_title']; ?></a></td>
                            <?php foreach ($view->options->ctlppu_display_fields as $field) { ?>
                                <td>
                                    <?php echo $view->getPostView($post[$field], 'table'); ?>
                                </td>
                            <?php } ?>
                        </tr>
                    <?php } ?>
                    </tbody>
                </table>
            <?php } else {
                echo __("Error getting posts.", _CTLPPU_PLUGIN_NAME_) . '<a href="' . admin_url('admin.php?page=ctlpp_posts') . '">' . __("Try again", _CTLPPU_PLUGIN_NAME_) . "</a>";
            }
            ?>
        </div>

        <div id="message-next_updated"
             data-text="<?php echo __('Your next update will be ready in', _CTLPPU_PLUGIN_NAME_) . " " . human_time_diff(strtotime(date('Y-m-d H:i:s')), $view->options->next_check) ?>"></div>
        <script>
            jQuery(document).ready(function () {
                jQuery('#posts_table').dataTable();
            });
        </script>


    </div>

</div>


