<?php
$query = "SELECT * FROM article_categ WHERE cat_id='$list_parent_id'";
$result = mysql_query ($query);
$line = mysql_fetch_assoc($result);

$is_sales_view = false;
if(isset($_SESSION['user_id']) && intval($_SESSION['user_id']) > 0) {
	$is_sales_view = true;
	$admin_category_link = '<a class="user-action-inline-old" href="/admin/article_categ.php?cat_id='.$list_parent_id.'" target="_blank">e</a>';
}

?>
<section class="article-category">
    <div class="box box-success">
        <div class="box-header with-border text-left">
            <i class="fa fa-bookmark fa-fw text-success pull-left"></i>
            <?php
                echo $line["title_en"];
                if($is_sales_view) echo $admin_category_link;
            ?>
        </div>
        <div class="box-body no-padding text-left">
            <ul class="list-unstyled list-links">
                <?php
                $query = "SELECT * FROM  article WHERE parent_id='$list_parent_id' AND (active='yes' OR (active_from <= NOW() AND active_to >= NOW())) ORDER BY order_seq ASC";
                $result = mysql_query ($query);
                while($line = mysql_fetch_array($result)){
                    $external_url = fix_url(trim($line['url']));
                    $nofollow_link = intval($line['nofollow']) == 1 ? ' rel="nofollow" ' : '';
                    echo '<li>';
                    if($external_url != ''){
                        echo '<a href="',$external_url,'" ' . $nofollow_link;
                        if($line["_blank"] == 'yes'){
                            echo  ' target="_blank"';
                        }
                        echo ' class="leftLink">';
                    }
                    else {
                        echo '<a href="', $real_path_http;
                        if(trim($line["title_tr"]) != ''){
                            echo 'article_', $line["title_tr"];
                        }
                        else {
                            echo 'content.php?article_id=',$line["article_id"],'&subject=standalone&parent_id=',$list_parent_id;
                        }
                        echo '" class="leftLink">';
                    }
                    echo '<i class="fa fa-angle-double-right"></i> ' . $line["title_en"], '</a>';


                    if($is_sales_view) {
                        $admin_article_link = '<a class="user-action-inline-old" href="/admin/article.php?article_id='.$line["article_id"].'" target="_blank">e</a>';
                        echo $admin_article_link;
                    }

                    echo '</li>';
                }
                ?>
            </ul>
        </div>
    </div>
</section>