<commit_before><?php
/**
 * Koowa Framework - http://developer.joomlatools.com/koowa
 *
 * @copyright	Copyright (C) 2007 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://github.com/joomlatools/koowa for the canonical source repository
 */


/**
 * Grid Template Helper
 *
 * @author  <NAME> <https://github.com/johanjanssens>
 * @package Koowa\Component\Koowa
 */
class ComKoowaTemplateHelperGrid extends KTemplateHelperAbstract
{
    /**
     * Render a radio field
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function radio($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'row'  		=> null,
            'attribs' => array()
        ));

        if($config->row->isLockable() && $config->row->locked())
        {
            $html = $this->getTemplate()->renderHelper('behavior.tooltip');
            $html .= '<span class="koowa-tooltip koowa_icon koowa-icon-locked"
                           title="'.$this->getTemplate()->renderHelper('grid.lock_message', array('row' => $config->row)).'">
					</span>';
        }
        else
        {
            $column = $config->row->getIdentityColumn();
            $value  = $config->row->{$column};

            $attribs = $this->buildAttributes($config->attribs);

            $html = '<input type="radio" class="-koowa-grid-checkbox" name="%s[]" value="%s" %s />';
            $html = sprintf($html, $column, $value, $attribs);
        }

        return $html;
    }
    /**
     * Render a checkbox field
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function checkbox($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'row'  		=> null,
            'attribs' => array()
        ));

        if($config->row->isLockable() && $config->row->locked())
        {
            $html = $this->getTemplate()->renderHelper('behavior.tooltip');
            $html .= '<span class="koowa-tooltip koowa_icon koowa-icon-locked"
                           title="'.$this->getTemplate()->renderHelper('grid.lock_message', array('row' => $config->row)).'">
					</span>';
        }
        else
        {
            $column = $config->row->getIdentityColumn();
            $value  = $config->row->{$column};

            $attribs = $this->buildAttributes($config->attribs);


            $html = '<input type="checkbox" class="-koowa-grid-checkbox" name="%s[]" value="%s" %s />';
            $html = sprintf($html, $column, $value, $attribs);
        }

        return $html;
    }

    /**
     * Render a search box
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function search($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'search'      => null,
            'placeholder' => $this->translate('Find by title or description&hellip;')
        ));

        $html  = '<label for="search"><i class="icon-search"></i></label>';
        $html .= '<input type="search" name="search" id="search" placeholder="'.$config->placeholder.'" value="'.$this->escape($config->search).'" />';
        $html .= '<button>'.$this->translate('Go').'</button>';
        $html .= '<button onclick="document.getElementById(\'search\').value=\'\';this.form.submit();">'.$this->translate('Reset').'</button>';

        return $html;
    }

    /**
     * Render a checkall header
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function checkall($config = array())
    {
        $html = '<input type="checkbox" class="-koowa-grid-checkall" />';
        return $html;
    }

    /**
     * Render a sorting header
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function sort($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'title'   	=> '',
            'column'  	=> '',
            'direction' => 'asc',
            'sort'		=> ''
        ));


        //Set the title
        if(empty($config->title)) {
            $config->title = ucfirst($config->column);
        }

        //Set the direction
        $direction	= strtolower($config->direction);
        $direction 	= in_array($direction, array('asc', 'desc')) ? $direction : 'asc';

        //Set the class
        $class = '';
        if($config->column == $config->sort)
        {
            $direction = $direction == 'desc' ? 'asc' : 'desc'; // toggle
            $class = 'class="-koowa-'.$direction.'"';
        }

        $url = clone $this->getTemplate()->getView()->getUrl();

        $query 				= $url->getQuery(1);
        $query['sort'] 		= $config->column;
        $query['direction'] = $direction;
        $url->setQuery($query);

        $html  = '<a href="'.$url.'" title="'.$this->translate('Click to sort by this column').'"  '.$class.'>';
        $html .= $this->translate($config->title);
        $html .= '</a>';

        // Mark the current column
        if ($config->column == $config->sort) {
            $icon = 'sort_'.(strtolower($config->direction) === 'asc' ? 'asc' : 'desc');
            $html .= ' <img src="media://system/images/'.$icon.'.png">';
        }
        else {
            $html .= ' <span class="koowa_icon koowa-icon-sort"><i></i></span>';
        }

        return $html;
    }<commit_msg>Use icons instead of images for grid sort<commit_after><?php
/**
 * Koowa Framework - http://developer.joomlatools.com/koowa
 *
 * @copyright	Copyright (C) 2007 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://github.com/joomlatools/koowa for the canonical source repository
 */


/**
 * Grid Template Helper
 *
 * @author  <NAME> <https://github.com/johanjanssens>
 * @package Koowa\Component\Koowa
 */
class ComKoowaTemplateHelperGrid extends KTemplateHelperAbstract
{
    /**
     * Render a radio field
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function radio($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'row'  		=> null,
            'attribs' => array()
        ));

        if($config->row->isLockable() && $config->row->locked())
        {
            $html = $this->getTemplate()->renderHelper('behavior.tooltip');
            $html .= '<span class="koowa-tooltip koowa_icon koowa-icon-locked"
                           title="'.$this->getTemplate()->renderHelper('grid.lock_message', array('row' => $config->row)).'">
					</span>';
        }
        else
        {
            $column = $config->row->getIdentityColumn();
            $value  = $config->row->{$column};

            $attribs = $this->buildAttributes($config->attribs);

            $html = '<input type="radio" class="-koowa-grid-checkbox" name="%s[]" value="%s" %s />';
            $html = sprintf($html, $column, $value, $attribs);
        }

        return $html;
    }
    /**
     * Render a checkbox field
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function checkbox($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'row'  		=> null,
            'attribs' => array()
        ));

        if($config->row->isLockable() && $config->row->locked())
        {
            $html = $this->getTemplate()->renderHelper('behavior.tooltip');
            $html .= '<span class="koowa-tooltip koowa_icon koowa-icon-locked"
                           title="'.$this->getTemplate()->renderHelper('grid.lock_message', array('row' => $config->row)).'">
					</span>';
        }
        else
        {
            $column = $config->row->getIdentityColumn();
            $value  = $config->row->{$column};

            $attribs = $this->buildAttributes($config->attribs);


            $html = '<input type="checkbox" class="-koowa-grid-checkbox" name="%s[]" value="%s" %s />';
            $html = sprintf($html, $column, $value, $attribs);
        }

        return $html;
    }

    /**
     * Render a search box
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function search($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'search'      => null,
            'placeholder' => $this->translate('Find by title or description&hellip;')
        ));

        $html  = '<label for="search"><i class="icon-search"></i></label>';
        $html .= '<input type="search" name="search" id="search" placeholder="'.$config->placeholder.'" value="'.$this->escape($config->search).'" />';
        $html .= '<button>'.$this->translate('Go').'</button>';
        $html .= '<button onclick="document.getElementById(\'search\').value=\'\';this.form.submit();">'.$this->translate('Reset').'</button>';

        return $html;
    }

    /**
     * Render a checkall header
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function checkall($config = array())
    {
        $html = '<input type="checkbox" class="-koowa-grid-checkall" />';
        return $html;
    }

    /**
     * Render a sorting header
     *
     * @param 	array 	$config An optional array with configuration options
     * @return	string	Html
     */
    public function sort($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'title'   	=> '',
            'column'  	=> '',
            'direction' => 'asc',
            'sort'		=> ''
        ));


        //Set the title
        if(empty($config->title)) {
            $config->title = ucfirst($config->column);
        }

        //Set the direction
        $direction	= strtolower($config->direction);
        $direction 	= in_array($direction, array('asc', 'desc')) ? $direction : 'asc';

        //Set the class
        $class = '';
        if($config->column == $config->sort)
        {
            $direction = $direction == 'desc' ? 'asc' : 'desc'; // toggle
            $class = 'class="-koowa-'.$direction.'"';
        }

        $url = clone $this->getTemplate()->getView()->getUrl();

        $query 				= $url->getQuery(1);
        $query['sort'] 		= $config->column;
        $query['direction'] = $direction;
        $url->setQuery($query);

        $html  = '<a href="'.$url.'" title="'.$this->translate('Click to sort by this column').'"  '.$class.'>';
        $html .= $this->translate($config->title);

        // Mark the current column
        if ($config->column == $config->sort) {
            if (strtolower($config->direction) === 'asc') {
                $html .= '<span class="arrow_sort_asc">▼</span>';
            } else {
                $html .= '<span class="arrow_sort_desc">▲</span>';
            }
        }
        else {
            $html .= ' <span class="koowa_icon koowa-icon-sort koowa_icon--12"><i></i></span>';
        }

        $html .= '</a>';

        return $html;
    }
{'fraction_non_alphanumeric': 0.1811631497683994, 'fraction_numerical': 0.001887116143420827, 'mean_word_length': 2.0843915343915342, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 200, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '937856', 'n_tokens_mistral': 3483, 'n_tokens_neox': 3399, 'n_words': 696}