<commit_before><?php
/**
 * CakeGanache : (https://github.com/gezeresolutionsweb/cakeganache)
 * Copyright (c) <NAME> (http://www.gezere.com)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) <NAME> (http://www.gezere.com)
 * @link          http://www.gezere.com
 * @package       CakeGanache.View.Helper
 * @since         CakeGanache v 0.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

App::import('Helper', 'Html') ;
App::import('Routing', 'Router') ;

class GanacheCalendarHelper extends AppHelper {
    public $helpers = array('Html') ;

    public function getHeader() {
        $html = '<thead>';
        $html .= '<tr>';
        $html .= '<td>' . __d( 'cakeganache', 'Monday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Tuesday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Wednesday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Thursday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Friday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Saturday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Sunday' ) . '</td>';
        $html .= '</tr>';
        $html .= '</thead>';

        return $html;
    }

    public function getBody( $elements, $year = null, $month = null ) {
	if( is_null( $month ) ) {
		$month = date( 'm' );
	}

	if( is_null( $year ) ) {
		$year = date( 'Y' );
	}

	$time = strtotime( $year . '-' . $month . '-01' );
        $nbEmpty = (int) date( 'w', $time ) - 1;
        $numberOfDays = date( 't', $time );
	if( $nbEmpty < 0 ) {
		$nbEmpty = 6;
	}

        $html = '<tbody>';
        $html .= '<tr>';


        $html .= str_repeat( '<td>&nbsp;</td>', $nbEmpty );

        $ct = 0;
        $ctWeek = $nbEmpty + 1;
        while( $ct < $numberOfDays ) {
            if( $ctWeek > 7 ) {
                $html .= '</tr>';
                $html .= '<tr>';
                $ctWeek = 1;
            }

            $html .= '<td>';

	    $day = $ct + 1;
            if( $day < 10 ) {
                $day = '0' . $day;
            }


            $html .= '<strong>' . $day . '</strong>';

            if( !empty( $elements[ $year . '-' . $month . '-' . $day ] ) ) {
                $html .= '<br />';
                foreach( $elements[ $year . '-' . $month . '-' . $day ] as $event  ) {
                    $html .= $event . '<br />';
                }
            }



            $html .= '</td>';


            $ct++;
            $ctWeek++;
	    $day++;
            // Create a new row.
        }

            // Generate trailing empty cell.
            $html .= str_repeat( '<td>&nbsp;</td>', 7 - $ctWeek + 1 );

        $html .= '</tr>';
        $html .= '<tbody>';

        return $html;

    }

    /**
     * Show full calendar with elements
     * @return The full calendar (HTML string)
    **/
    public function showFullCalendar ( $elements = array(), $year = null, $month = null ) {
        // @todo need to refacto with BSHtml::tag() function.
        
        $html = '<table class="calendar table table-bordered">';
        $html .= $this->getHeader();
        $html .= $this->getBody( $elements, $year, $month );
        $html .= '</table>';
                
        return $html;
    }
    
}<commit_msg>* Replace hardcode classes for the respective constants.<commit_after><?php
/**
 * CakeGanache : (https://github.com/gezeresolutionsweb/cakeganache)
 * Copyright (c) <NAME> (http://www.gezere.com)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) <NAME> (http://www.gezere.com)
 * @link          http://www.gezere.com
 * @package       CakeGanache.View.Helper
 * @since         CakeGanache v 0.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

App::import('Helper', 'Html') ;
App::import('Routing', 'Router') ;

class GanacheCalendarHelper extends AppHelper {
    public $helpers = array('Html') ;

    public function getHeader() {
        $html = '<thead>';
        $html .= '<tr>';
        $html .= '<td>' . __d( 'cakeganache', 'Monday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Tuesday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Wednesday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Thursday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Friday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Saturday' ) . '</td>';
        $html .= '<td>' . __d( 'cakeganache', 'Sunday' ) . '</td>';
        $html .= '</tr>';
        $html .= '</thead>';

        return $html;
    }

    public function getBody( $elements, $year = null, $month = null ) {
	if( is_null( $month ) ) {
		$month = date( 'm' );
	}

	if( is_null( $year ) ) {
		$year = date( 'Y' );
	}

	$time = strtotime( $year . '-' . $month . '-01' );
        $nbEmpty = (int) date( 'w', $time ) - 1;
        $numberOfDays = date( 't', $time );
	if( $nbEmpty < 0 ) {
		$nbEmpty = 6;
	}

        $html = '<tbody>';
        $html .= '<tr>';


        $html .= str_repeat( '<td>&nbsp;</td>', $nbEmpty );

        $ct = 0;
        $ctWeek = $nbEmpty + 1;
        while( $ct < $numberOfDays ) {
            if( $ctWeek > 7 ) {
                $html .= '</tr>';
                $html .= '<tr>';
                $ctWeek = 1;
            }

            $html .= '<td>';

	    $day = $ct + 1;
            if( $day < 10 ) {
                $day = '0' . $day;
            }


            $html .= '<strong>' . $day . '</strong>';

            if( !empty( $elements[ $year . '-' . $month . '-' . $day ] ) ) {
                $html .= '<br />';
                foreach( $elements[ $year . '-' . $month . '-' . $day ] as $event  ) {
                    $html .= $event . '<br />';
                }
            }



            $html .= '</td>';


            $ct++;
            $ctWeek++;
	    $day++;
            // Create a new row.
        }

            // Generate trailing empty cell.
            $html .= str_repeat( '<td>&nbsp;</td>', 7 - $ctWeek + 1 );

        $html .= '</tr>';
        $html .= '<tbody>';

        return $html;

    }

    /**
     * Show full calendar with elements
     * @return The full calendar (HTML string)
    **/
    public function showFullCalendar ( $elements = array(), $year = null, $month = null ) {
        // @todo need to refacto with BSHtml::tag() function.
        
        $html = '<table class="calendar ' . GA_TABLE . ' ' . GA_TABLE_BORDERED . '">';
        $html .= $this->getHeader();
        $html .= $this->getBody( $elements, $year, $month );
        $html .= '</table>';
                
        return $html;
    }
    
}
{'fraction_non_alphanumeric': 0.20524269047961977, 'fraction_numerical': 0.005185078496327236, 'mean_word_length': 1.6728252501924556, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 85, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, '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': '5756221', 'n_tokens_mistral': 2357, 'n_tokens_neox': 2212, 'n_words': 567}