<commit_before><?php
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007 <NAME> <<EMAIL>>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 * @package jojo_article
 */

$numarticles = Jojo::getOption('article_num_sidebar_articles', 3);

if ($numarticles) {
$exclude = (boolean)(Jojo::getOption('article_sidebar_exclude_current', 'no')=='yes');
//some of the articles we're getting might have expired or not yet gone live, so put in a buffer
$num = $numarticles + 20;
    /* Create latest Articles array for sidebar: getArticles(x, start, categoryid) = list x# of articles */
    if (Jojo::getOption('article_sidebar_categories', 'no')=='yes') {
        $categories = Jojo::selectQuery("SELECT * FROM {articlecategory}");
        $allarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, 'all',  'ar_date desc', $exclude);
        $allarticles = array_slice ($allarticles, 0, $numarticles);
        $smarty->assign('allarticles',  $allarticles);
        foreach ($categories as $c) {
            $catarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, $c['articlecategoryid'],  $c['sortby'], $exclude );
            if (isset($catarticles[0])) {
                $smarty->assign('articles_' . str_replace(array('-', '/'), array('_', ''), $catarticles[0]['pg_url']), $catarticles);
            }
        }
    } else {
        if (Jojo::getOption('article_sidebar_randomise', 0) > 0) {
            $num = Jojo::getOption('article_sidebar_randomise', 0) + 20;
            $recentarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, 'all',  'ar_date desc', $exclude);
            $recentarticles = array_slice ($recentarticles, 0, Jojo::getOption('article_sidebar_randomise', 0));
            shuffle($recentarticles);
        } else {
            $recentarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, 'all', 'ar_date desc', $exclude);
        }
        $recentarticles = array_slice($recentarticles, 0, $numarticles);
        $smarty->assign('articles', $recentarticles );
    }

}
/** Example usage in theme template:
            {if $articles}
            <div id='news' class="sidebarbox">
                <h2>News</h2>
                {foreach from=$articles key=key item=article}
                    {if $article.ar_image}<img src="images/v7000/articles/{$article.ar_image}" alt = "{$article.title}" class="float-right"/>{/if}
                    <h3>{$article.title}</h3>
                    <p class='news-content'>{$article.bodyplain|truncate:150:"..."} <a class='links' href='{$article.url}'>&gt; Read More</a></p>
                {/foreach}
                <p class="links">&gt; <a href='{$SITEURL}/{$articles[0].categoryurl}'>See all {$articles[0].category}</a></p>
            </div>
            {/if}
*/<commit_msg>add missing slice to sr=artcile category arrays<commit_after><?php
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007 <NAME> <<EMAIL>>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 * @package jojo_article
 */

$numarticles = Jojo::getOption('article_num_sidebar_articles', 3);

if ($numarticles) {
$exclude = (boolean)(Jojo::getOption('article_sidebar_exclude_current', 'no')=='yes');
//some of the articles we're getting might have expired or not yet gone live, so put in a buffer
$num = $numarticles + 50;
    /* Create latest Articles array for sidebar: getArticles(x, start, categoryid) = list x# of articles */
    if (Jojo::getOption('article_sidebar_categories', 'no')=='yes') {
        $categories = Jojo::selectQuery("SELECT * FROM {articlecategory}");
        $allarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, 'all',  'ar_date desc', $exclude);
        $allarticles = array_slice ($allarticles, 0, $numarticles);
        $smarty->assign('allarticles',  $allarticles);
        foreach ($categories as $c) {
            $catarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, $c['articlecategoryid'],  $c['sortby'], $exclude );
            if (isset($catarticles[0])) {
                $catarticles = array_slice ($catarticles, 0, $numarticles);
                $smarty->assign('articles_' . str_replace(array('-', '/'), array('_', ''), $catarticles[0]['pg_url']), $catarticles);
            }
        }
    } else {
        if (Jojo::getOption('article_sidebar_randomise', 0) > 0) {
            $num = Jojo::getOption('article_sidebar_randomise', 0) + 50;
            $recentarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, 'all',  'ar_date desc', $exclude);
            $recentarticles = array_slice ($recentarticles, 0, Jojo::getOption('article_sidebar_randomise', 0));
            shuffle($recentarticles);
        } else {
            $recentarticles = Jojo_Plugin_Jojo_article::getArticles($num, 0, 'all', 'ar_date desc', $exclude);
        }
        $recentarticles = array_slice($recentarticles, 0, $numarticles);
        $smarty->assign('articles', $recentarticles );
    }

}
/** Example usage in theme template:
            {if $articles}
            <div id='news' class="sidebarbox">
                <h2>News</h2>
                {foreach from=$articles key=key item=article}
                    {if $article.ar_image}<img src="images/v7000/articles/{$article.ar_image}" alt = "{$article.title}" class="float-right"/>{/if}
                    <h3>{$article.title}</h3>
                    <p class='news-content'>{$article.bodyplain|truncate:150:"..."} <a class='links' href='{$article.url}'>&gt; Read More</a></p>
                {/foreach}
                <p class="links">&gt; <a href='{$SITEURL}/{$articles[0].categoryurl}'>See all {$articles[0].category}</a></p>
            </div>
            {/if}
*/
{'fraction_non_alphanumeric': 0.17324290998766953, 'fraction_numerical': 0.01587546239210851, 'mean_word_length': 3.0530918176139914, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4417048', 'n_tokens_mistral': 2192, 'n_tokens_neox': 1971, 'n_words': 431}