<commit_before><?php
/**
 * @version        $Id$
 * @category       Nooku
 * @package        Nooku_Server
 * @subpackage     Articles
 * @copyright      Copyright (C) 2009 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link           http://www.nooku.org
 */

/**
 * Article template helper class.
 *
 * @author     <NAME> <http://nooku.assembla.com/profile/arunasmazeika>
 * @category   Nooku
 * @package    Nooku_Server
 * @subpackage Articles
 */
class ComArticlesTemplateHelperArticle extends KTemplateHelperAbstract
{
    public function render($config = array()) {
        $config = new KConfig($config);

        $config->append(array('parameters' => JComponentHelper::getParams('com_articles')));

        $parameters = $config->parameters;
        $html       = '';

        $html .= $this->title($config);

        $html .= $this->timestamp($config);

        $html .= $this->content($config);

        return $html;
    }

    public function title($config = array()) {

        $config = new KConfig($config);

        $config->append(array('parameters' => JComponentHelper::getParams('com_articles')))
            ->append(array('linkable' => true));

        $article = $config->row;

        $html = '<h2>';
        $html .= $config->linkable ? $this->link(array_merge($config->toArray(),
            array('text' => $article->title))) : $article->title;
        $html .= '</h2>';

        return $html;
    }

    public function content($config = array()) {
        $config = new KConfig($config);

        $config->append(array('parameters' => JComponentHelper::getParams('com_articles')))
            ->append(array('show_more' => $config->parameters->get(show_readmore)));

        $article = $config->row;

        $html = '';

        // Only show more links if there is actually something else to show.
        if ($config->show_more && $article->fulltext) {
            $html .= $article->introtext;
            $html .= $this->link(array('row' => $article));
        } else {
            $html .= $article->introtext . $article->fulltext;
        }

        return $html;
    }

    public function link($config = array()) {
        $config = new KConfig($config);

        $config->append(array(
            'attribs'   => array(),
            'text'      => 'Read more',
            'translate' => true));

        $article = $config->row;
        $text    = $config->text;

        if ($config->tanslate) {
            $text = JText::_($text);
        }

        $attribs = KHelperArray::toString($config->attribs);

        $html = '';

        $html .= '<a ' . $attribs . ' href="' . JRoute::_(ComArticlesHelperRoute::getArticleRoute($article->id,
            $article->category_id,
            $article->section_id)) . '">';<commit_msg>Added some extra params for more flexibility while rendering articles.<commit_after><?php
/**
 * @version        $Id$
 * @category       Nooku
 * @package        Nooku_Server
 * @subpackage     Articles
 * @copyright      Copyright (C) 2009 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link           http://www.nooku.org
 */

/**
 * Article template helper class.
 *
 * @author     <NAME> <http://nooku.assembla.com/profile/arunasmazeika>
 * @category   Nooku
 * @package    Nooku_Server
 * @subpackage Articles
 */
class ComArticlesTemplateHelperArticle extends KTemplateHelperAbstract
{
    public function render($config = array()) {
        $config = new KConfig($config);

        $config->append(array('parameters' => JComponentHelper::getParams('com_articles')));

        $parameters = $config->parameters;
        $html       = '';

        $html .= $this->title($config);

        $html .= $this->timestamp($config);

        $html .= $this->content($config);

        return $html;
    }

    public function title($config = array()) {

        $config = new KConfig($config);

        $config->append(array('parameters' => JComponentHelper::getParams('com_articles')))
            ->append(array('title_heading' => 2, 'linkable' => true));

        $article = $config->row;

        $html = "<h{$config->title_heading}>";
        $html .= $config->linkable ? $this->link(array_merge($config->toArray(),
            array('text' => $article->title))) : $article->title;
        $html .= "</h{$config->title_heading}>";

        return $html;
    }

    public function content($config = array()) {
        $config = new KConfig($config);

        $config->append(array('parameters' => JComponentHelper::getParams('com_articles')))
            ->append(array('show_images' => true, 'show_more' => $config->parameters->get(show_readmore)));

        $article = $config->row;

        $html = '';

        // Only show more links if there is actually something else to show.
        if ($config->show_more && $article->fulltext) {
            $html .= $article->introtext;
            $html .= $this->link(array('row' => $article));
        } else {
            $html .= $article->introtext . $article->fulltext;
        }

        if (!$config->show_images) {
            // Strip images from content.
            $html = preg_replace('/<img[^>]*>/', '', $html);
        }

        return $html;
    }

    public function link($config = array()) {
        $config = new KConfig($config);

        $config->append(array(
            'attribs'   => array(),
            'text'      => 'Read more',
            'translate' => true));

        $article = $config->row;
        $text    = $config->text;

        if ($config->tanslate) {
            $text = JText::_($text);
        }

        $attribs = KHelperArray::toString($config->attribs);

        $html = '';

        $html .= '<a ' . $attribs . ' href="' . JRoute::_(ComArticlesHelperRoute::getArticleRoute($article->id,
            $article->category_id,
            $article->section_id)) . '">';
{'fraction_non_alphanumeric': 0.1713572023313905, 'fraction_numerical': 0.0034970857618651123, 'mean_word_length': 2.3, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 106, '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': '5626242', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1720, 'n_words': 342}