<commit_before><?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: articles.php
| Author: PHP-Fusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) {
    die("Access Denied");
}

if (!function_exists("display_main_articles")) {
    /**
     * Articles Page Template
     * @param $info
     */
    function display_main_articles($info) {

        $articles_settings = \PHPFusion\Articles\ArticlesServer::get_article_settings();
        $locale = fusion_get_locale();

        add_to_head("<script type='text/javascript' src='".INCLUDES."jquery/jquery.cookie.js'></script>");

        $cookie_expiry = time() + 7 * 24 * 3600;
        if (empty($_COOKIE['fusion_articles_view'])) {
            setcookie("fusion_articles_view", 1, $cookie_expiry);
        } elseif (isset($_POST['switchview']) && isnum($_POST['switchview'])) {
            setcookie("fusion_articles_view", intval($_POST['switchview'] == 2 ? 2 : 1), $cookie_expiry);
            redirect(FUSION_REQUEST);
        }

        opentable($locale['article_0000']);
        echo render_breadcrumbs();
		?>
		
		<div class="panel panel-default panel-articles-header">
		
		  <!-- Display Informations -->
		  <div class="panel-body">
		    <div class="pull-right">
			  <a class="btn btn-sm btn-default" href="<?php echo INFUSIONS."articles/articles.php"; ?>" title="<?php echo $locale['article_0001']; ?>"><i class="fa fa-fw fa-desktop"></i> <?php echo $locale['article_0001']; ?></a>
			  <button type="button" class="btn btn-sm btn-primary" data-toggle="collapse" data-target="#articlescat" aria-expanded="true" aria-controls="articlescat" title="<?php echo $locale['article_0002']; ?>">
			    <i class="fa fa-fw fa-folder"></i>
			  </button>
			</div>
			<div class="overflow-hide">
			  <h3 class="display-inline text-dark"><?php echo $info['article_cat_name']; ?></h3><br />
			  <?php if ($info['article_cat_description']) { ?>
			  <div class="article-cat-description"><?php echo $info['article_cat_description']; ?></div>
			  <br />
			  <?php } ?>
			  <span class="strong text-smaller"><?php echo $locale['article_0004']; ?></span>
			  <span class="text-dark text-smaller"><?php echo ($info['article_last_updated'] > 0 ? showdate("newsdate", $info['article_last_updated']) : $locale['na']); ?></span>
			</div>
		  </div>
		
		  <!-- Diplay Categories -->
		  <div id="articlescat" class="panel-collapse collapse m-b-10">
		    <!--pre_articles_cat_idx-->
			<ul class="list-group">
			  <li class="list-group-item">
				<hr class="m-t-0 m-b-5">
				<span class="display-inline-block m-b-10 strong text-smaller text-uppercase"><?php echo $locale['article_0003']; ?></span><br />
				<?php
					if (is_array($info['article_categories']) && !empty($info['article_categories'])) {
						foreach ($info['article_categories'] as $cat_id => $cat_data) {
							if (!isset($_GET['cat_id']) || $_GET['cat_id'] != $cat_id) {
								echo "<a href='".INFUSIONS."articles/articles.php?cat_id=".$cat_id."' class='btn btn-sm btn-default m-5'>".$cat_data['name']."</a>";
							}
						}
					} else {
						echo "<div class='well text-center'>".$locale['article_0060']."</div>";
					}
				?>
			  </li>
			</ul>
		    <!--sub_articles_cat_idx-->
		  </div>
		</div>

	    <!-- Display Sorting Options -->
	    <div class="row m-t-20 m-b-20">
	      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		  
		    <!-- Display View Options -->
		    <?php echo openform("viewform", "post", FUSION_REQUEST, array("max_tokens" => 1, "class" => "pull-right display-inline-block m-l-10")); ?>
			<div class="btn-group">
			  <?php $active = isset($_COOKIE['fusion_articles_view']) && isnum($_COOKIE['fusion_articles_view']) && $_COOKIE['fusion_articles_view'] == 2 ? 2 : 1; ?>
			  <?php echo form_button("switchview", "", "1", array("class" => "btn-sm btn-default nsv".($active == "1" ? " active" : ""), "icon" => "fa fa-fw fa-th-large", "alt" => $locale['article_0040'])); ?>
			  <?php echo form_button("switchview", "", "2", array("class" => "btn-sm btn-default nsv".($active == "2" ? " active" : ""), "icon" => "fa fa-fw fa-bars", "alt" => $locale['article_0041'])); ?>
	        </div>
			<?php echo closeform(); ?>
			
			<!-- Display Filters -->
			<div class="display-inline-block">
			  <span class="text-dark strong m-r-10"><?php echo $locale['show']; ?></span>
			  <?php $i = 0;
				foreach ($info['article_filter'] as $link => $title) {
					$filter_active = (!isset($_GET['type']) && $i == '0') || isset($_GET['type']) && stristr($link, $_GET['type']) ? "text-dark strong" : "";
					echo "<a href='".$link."' class='display-inline $filter_active m-r-10'>".$title."</a>";
					$i++;
				}
			  ?>
			</div>
		  </div>
		</div>
		
		<!-- Display Articles -->
	    <?php
        $articleColumn = $active == 2 ? 12 : 4;
        if (!empty($info['article_items'])) {
		?>
			<div class="row">
				<?php foreach ($info['article_items'] as $i => $article_info) {?>
					<div class="col-xs-12 col-sm-<?php echo $articleColumn; ?> col-md-<?php echo $articleColumn; ?> col-lg-<?php echo $articleColumn; ?>">
					<?php echo (isset($_GET['cat_id'])) ? "<!--pre_articles_cat_idx-->\n" : "<!--articles_prepost_".$i."-->\n"; ?>
					<?php render_article($article_info['article_subject'], $article_info['article_article'], $article_info, ($active == 2 ? true : false)); ?>
					<?php echo (isset($_GET['cat_id'])) ? "<!--sub_articles_cat_idx-->" : "<!--sub_articles_idx-->\n"; ?>
					</div>
				<?php } ?>
			</div>
			<?php
            if ($info['article_total_rows'] > $articles_settings['article_pagination']) {
                $type_start = isset($_GET['type']) ? "type=".$_GET['type']."&amp;" : "";
                $cat_start = isset($_GET['cat_id']) ? "cat_id=".$_GET['cat_id']."&amp;" : ""; ?><commit_msg>Update articles.php<commit_after><?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: articles.php
| Author: PHP-Fusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) {
    die("Access Denied");
}

if (!function_exists("display_main_articles")) {
    /**
     * Articles Page Template
     * @param $info
     */
    function display_main_articles($info) {

        $articles_settings = \PHPFusion\Articles\ArticlesServer::get_article_settings();
        $locale = fusion_get_locale();

        add_to_head("<script type='text/javascript' src='".INCLUDES."jquery/jquery.cookie.js'></script>");

        $cookie_expiry = time() + 7 * 24 * 3600;
        if (empty($_COOKIE['fusion_articles_view'])) {
            setcookie("fusion_articles_view", 1, $cookie_expiry);
        } elseif (isset($_POST['switchview']) && isnum($_POST['switchview'])) {
            setcookie("fusion_articles_view", intval($_POST['switchview'] == 2 ? 2 : 1), $cookie_expiry);
            redirect(FUSION_REQUEST);
        }

        opentable($locale['article_0000']);
        echo render_breadcrumbs();
		?>
		
		<div class="panel panel-default panel-articles-header">
		
		  <!-- Display Informations -->
		  <div class="panel-body">
		    <div class="pull-right">
			  <a class="btn btn-sm btn-default" href="<?php echo INFUSIONS."articles/articles.php"; ?>" title="<?php echo $locale['article_0001']; ?>"><i class="fa fa-fw fa-desktop"></i> <?php echo $locale['article_0001']; ?></a>
			  <button type="button" class="btn btn-sm btn-primary" data-toggle="collapse" data-target="#articlescat" aria-expanded="true" aria-controls="articlescat" title="<?php echo $locale['article_0002']; ?>">
			    <i class="fa fa-fw fa-folder"></i>
			  </button>
			</div>
			<div class="overflow-hide">
			  <h3 class="display-inline text-dark"><?php echo $info['article_cat_name']; ?></h3><br />
			  <?php if ($info['article_cat_description']) { ?>
			  <div class="article-cat-description"><?php echo $info['article_cat_description']; ?></div>
			  <br />
			  <?php } ?>
			  <span class="strong text-smaller"><?php echo $locale['article_0004']; ?></span>
			  <span class="text-dark text-smaller"><?php echo ($info['article_last_updated'] > 0 ? showdate("newsdate", $info['article_last_updated']) : $locale['na']); ?></span>
			</div>
		  </div>
		
		  <!-- Diplay Categories -->
		  <div id="articlescat" class="panel-collapse collapse m-b-10">
		    <!--pre_articles_cat_idx-->
			<ul class="list-group">
			  <li class="list-group-item">
				<hr class="m-t-0 m-b-5">
				<span class="display-inline-block m-b-10 strong text-smaller text-uppercase"><?php echo $locale['article_0003']; ?></span><br />
				<?php
					if (is_array($info['article_categories']) && !empty($info['article_categories'])) {
						foreach ($info['article_categories'] as $cat_id => $cat_data) {
							if (!isset($_GET['cat_id']) || $_GET['cat_id'] != $cat_id) {
								echo "<a href='".INFUSIONS."articles/articles.php?cat_id=".$cat_id."' class='btn btn-sm btn-default m-5'>".$cat_data['name']."</a>";
							}
						}
					} else {
						echo "<div class='well text-center'>".$locale['article_0060']."</div>";
					}
				?>
			  </li>
			</ul>
		    <!--sub_articles_cat_idx-->
		  </div>
		</div>

	    <!-- Display Sorting Options -->
	    <div class="row m-t-20 m-b-20">
	      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		  
		    <!-- Display View Options -->
		    <?php echo openform("viewform", "post", FUSION_REQUEST, array("max_tokens" => 1, "class" => "pull-right display-inline-block m-l-10")); ?>
			<div class="btn-group">
			  <?php $active = isset($_COOKIE['fusion_articles_view']) && isnum($_COOKIE['fusion_articles_view']) && $_COOKIE['fusion_articles_view'] == 2 ? 2 : 1; ?>
			  <?php echo form_button("switchview", "", "1", array("class" => "btn-sm btn-default nsv".($active == "1" ? " active" : ""), "icon" => "fa fa-fw fa-th-large", "alt" => $locale['article_0040'])); ?>
			  <?php echo form_button("switchview", "", "2", array("class" => "btn-sm btn-default nsv".($active == "2" ? " active" : ""), "icon" => "fa fa-fw fa-bars", "alt" => $locale['article_0041'])); ?>
	        </div>
			<?php echo closeform(); ?>
			
			<!-- Display Filters -->
			<div class="display-inline-block">
			  <span class="text-dark strong m-r-10"><?php echo $locale['show']; ?></span>
			  <?php $i = 0;
				foreach ($info['article_filter'] as $link => $title) {
					$filter_active = (!isset($_GET['type']) && $i == '0') || isset($_GET['type']) && stristr($link, $_GET['type']) ? "text-dark strong" : "";
					echo "<a href=".$link." class='display-inline $filter_active m-r-10'>".$title."</a>";
					$i++;
				}
			  ?>
			</div>
		  </div>
		</div>
		
		<!-- Display Articles -->
	    <?php
        $articleColumn = $active == 2 ? 12 : 4;
        if (!empty($info['article_items'])) {
		?>
			<div class="row">
				<?php foreach ($info['article_items'] as $i => $article_info) {?>
					<div class="col-xs-12 col-sm-<?php echo $articleColumn; ?> col-md-<?php echo $articleColumn; ?> col-lg-<?php echo $articleColumn; ?>">
					<?php echo (isset($_GET['cat_id'])) ? "<!--pre_articles_cat_idx-->\n" : "<!--articles_prepost_".$i."-->\n"; ?>
					<?php render_article($article_info['article_subject'], $article_info['article_article'], $article_info, ($active == 2 ? true : false)); ?>
					<?php echo (isset($_GET['cat_id'])) ? "<!--sub_articles_cat_idx-->" : "<!--sub_articles_idx-->\n"; ?>
					</div>
				<?php } ?>
			</div>
			<?php
            if ($info['article_total_rows'] > $articles_settings['article_pagination']) {
                $type_start = isset($_GET['type']) ? "type=".$_GET['type']."&amp;" : "";
                $cat_start = isset($_GET['cat_id']) ? "cat_id=".$_GET['cat_id']."&amp;" : ""; ?>
{'fraction_non_alphanumeric': 0.2441012108040981, 'fraction_numerical': 0.014281279105867743, 'mean_word_length': 3.000310462589258, 'pattern_counts': {'":': 0, '<': 203, '<?xml version=': 0, '>': 229, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3300669', 'n_tokens_mistral': 4718, 'n_tokens_neox': 4071, 'n_words': 837}