<commit_before><?php


class SiteController extends Zend_Controller_Action
{

    /**
     * [EN]If a action don't exist, just redirect to the basic
     *
     * @param string $name
     * @param array $var
     */
    function __call($name, $var)
    {
        $this->_redirect ( 'default/site/basic', array ('exit' => 1 ) );
        return false;
    }


    /**
     * [EN] I think this is needed for something. can't remember
     *
     */
    function init()
    {

        $this->view->url = Zend_Registry::get ( 'config' )->site->url;
    }


    /**
     * Same as __call
     *
     */
    function indexAction()
    {

        $this->_forward ( 'basic' );
    }


    /**
     * Show the source code for this controller
     *
     */
    function codeAction()
    {

        $this->render ( 'code' );
    }


    /**
     * [EN] Simplify the datagrid creation process
     * [EN] Instead of having to write "long" lines of code we can simplify this.
     * [EN] In fact if you have a Class that extends the Zend_Controller_Action
     * [EN] It's not a bad idea put this piece o code there. May be very useful
     * 
     *
     * @return unknown
     */
    function grid()
    {

        $export = $this->getRequest ()->getParam ( 'export' );
        
        $db = Zend_Registry::get ( 'db' );
        
        switch ($export)
        {
            case 'odt' :
                $grid = "Bvb_Grid_Deploy_Odt";
                break;
            case 'ods' :
                $grid = "Bvb_Grid_Deploy_Ods";
                break;
            case 'xml' :
                $grid = "Bvb_Grid_Deploy_Xml";
                break;
            case 'csv' :
                $grid = "Bvb_Grid_Deploy_Csv";
                break;
            case 'excel' :
                $grid = "Bvb_Grid_Deploy_Excel";
                break;
            case 'word' :
                $grid = "Bvb_Grid_Deploy_Word";
                break;
            case 'wordx' :
                $grid = "Bvb_Grid_Deploy_Wordx";
                break;
            case 'pdf' :
                $grid = "Bvb_Grid_Deploy_Pdf";
                break;
            case 'print' :
                $grid = "Bvb_Grid_Deploy_Print";
                break;
            default :
                $grid = "Bvb_Grid_Deploy_Table";
                break;
        }
        
        $grid = new $grid ( $db, 'Grid Example', 'media/temp', array ('download' ) );
        $grid->escapeOutput ( false );
        $grid->addTemplateDir ( 'My/Template/Table', 'My_Template_Table', 'table' );
        $grid->addElementDir ( 'My/Validate', 'My_Validate', 'validator' );
        $grid->addElementDir ( 'My/Filter', 'My_Filter', 'filter' );
        $grid->addFormatterDir ( 'My/Formatter', 'My_Formatter' );
        $grid->imagesUrl = $this->getRequest ()->getBaseUrl () . '/public/images/';
        $grid->cache = array ('use' => 0, 'instance' => Zend_Registry::get ( 'cache' ), 'tag' => 'grid' );
        
        return $grid;
    }


    /**
     * A simple action that shows pictures in a complete diferent template
     *
     */
    function imagesAction()
    {

        $grid = $this->grid ( 'table' );
        $grid->from ( 'images' )
        ->addColumn ( 'url', array ('decorator' => '<a href="{{url}}"><img src="{{url}}" border="0"></a>', 'title' => '<NAME> - Image Gallery' ) )
        ->noOrder ( 1 )
        ->setPagination ( 10000 )
        ->setTemplate ( 'images' );
        
        $this->view->pages = $grid->deploy ();<commit_msg>Some more testing...<commit_after><?php


class SiteController extends Zend_Controller_Action
{

    /**
     * [EN]If a action don't exist, just redirect to the basic
     *
     * @param string $name
     * @param array $var
     */
    function __call($name, $var)
    {
        $this->_redirect ( 'default/site/basic', array ('exit' => 1 ) );
        return false;
    }


    /**
     * [EN] I think this is needed for something. can't remember
     *
     */
    function init()
    { 

        $this->view->url = Zend_Registry::get ( 'config' )->site->url;
    }


    /**
     * Same as __call
     *
     */
    function indexAction()
    {

        $this->_forward ( 'basic' );
    }


    /**
     * Show the source code for this controller
     *
     */
    function codeAction()
    {

        $this->render ( 'code' );
    }


    /**
     * [EN] Simplify the datagrid creation process
     * [EN] Instead of having to write "long" lines of code we can simplify this.
     * [EN] In fact if you have a Class that extends the Zend_Controller_Action
     * [EN] It's not a bad idea put this piece o code there. May be very useful
     * 
     *
     * @return unknown
     */
    function grid()
    {

        $export = $this->getRequest ()->getParam ( 'export' );
        
        $db = Zend_Registry::get ( 'db' );
        
        switch ($export)
        {
            case 'odt' :
                $grid = "Bvb_Grid_Deploy_Odt";
                break;
            case 'ods' :
                $grid = "Bvb_Grid_Deploy_Ods";
                break;
            case 'xml' :
                $grid = "Bvb_Grid_Deploy_Xml";
                break;
            case 'csv' :
                $grid = "Bvb_Grid_Deploy_Csv";
                break;
            case 'excel' :
                $grid = "Bvb_Grid_Deploy_Excel";
                break;
            case 'word' :
                $grid = "Bvb_Grid_Deploy_Word";
                break;
            case 'wordx' :
                $grid = "Bvb_Grid_Deploy_Wordx";
                break;
            case 'pdf' :
                $grid = "Bvb_Grid_Deploy_Pdf";
                break;
            case 'print' :
                $grid = "Bvb_Grid_Deploy_Print";
                break;
            default :
                $grid = "Bvb_Grid_Deploy_Table";
                break;
        }
        
        $grid = new $grid ( $db, 'Grid Example', 'media/temp', array ('download' ) );
        $grid->escapeOutput ( false );
        $grid->addTemplateDir ( 'My/Template/Table', 'My_Template_Table', 'table' );
        $grid->addElementDir ( 'My/Validate', 'My_Validate', 'validator' );
        $grid->addElementDir ( 'My/Filter', 'My_Filter', 'filter' );
        $grid->addFormatterDir ( 'My/Formatter', 'My_Formatter' );
        $grid->imagesUrl = $this->getRequest ()->getBaseUrl () . '/public/images/';
        $grid->cache = array ('use' => 0, 'instance' => Zend_Registry::get ( 'cache' ), 'tag' => 'grid' );
        
        return $grid;
    }

    
    function unionAction()
    {
    	$db = Zend_Registry::get('db');
		   		
		$select1 = "SELECT bug_id as id FROM bugs" ;
		$select2 = "SELECT price as id from products";
		
		$select = $db->select()
					->order('id')
			       ->union(array($select1, $select2));
		    		
		$grid = $this->grid ( 'table' );
		$grid->queryFromZendDbSelect ( $select, $db );
		    	 $this->view->pages = $grid->deploy ();
        $this->render ( 'index' );
    }

    /**
     * A simple action that shows pictures in a complete diferent template
     *
     */
    function imagesAction()
    {

        $grid = $this->grid ( 'table' );
        $grid->from ( 'images' )
        ->addColumn ( 'url', array ('decorator' => '<a href="{{url}}"><img src="{{url}}" border="0"></a>', 'title' => '<NAME> - Image Gallery' ) )
        ->noOrder ( 1 )
        ->setPagination ( 10000 )
        ->setTemplate ( 'images' );
        
        $this->view->pages = $grid->deploy ();
{'fraction_non_alphanumeric': 0.1459170013386881, 'fraction_numerical': 0.0029451137884872825, 'mean_word_length': 1.6013231197771587, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2482009', 'n_tokens_mistral': 2372, 'n_tokens_neox': 2239, 'n_words': 543}