<commit_before><?php // vim:ts=4:sw=4:et:fdm=marker
/**
 * A base class for all Visual objects in Agile Toolkit. The
 * important distinctive property of all Views is abiltiy
 * to render themselves (produce HTML) automatically and
 * recursively.
 *
 * @link http://agiletoolkit.org/learn/understand/view
*//*
==ATK4===================================================
   This file is part of Agile Toolkit 4 
    http://agiletoolkit.org/
  
   (c) 2008-2012 <NAME> <<EMAIL>>
   Distributed under Affero General Public License v3
   
   See http://agiletoolkit.org/about/license
 =====================================================ATK4=*/
abstract class AbstractView extends AbstractObject {
    /**
     * $template is an SMLite object containing indexed HTML
     * template. 
     *
     * Example:
     *
     * $view->template->set('title', $my_title);
     *
     * Assuming you have tag <?$template?> in template file associated
     * with this view - will insert text into this tag.
     *
     * @see AbstractObject::add();
     * @see AbstractView::defaultTemplate();
     */
    public $template=false;

    /**
     * @internal
     *
     * $template_flush is set to a spot on the template, which
     * should be flushed out. When using AJAX we want to show
     * only certain region from our template. However several
     * childs may want to put their data. This property will
     * be set to region's name my call_ajax_render and if it's
     * set, call_ajax_render will echo it and return false.
     */
    public $template_flush=false;

    /**
     * $spot defines a place on a parent's template where render() will
     * output() resulting HTML
     *
     * @see output()
     * @see render()
     * @see AbstractObject::add();
     * @see defaultSpot();
     */
    public $spot;

    /**
     * When using setModel() with Views some views will want to populate
     * fields, columns etc corresponding to models meta-data. That is the
     * job of Controller. When you create a custom controller for your view
     * set this property to point at your controller and it will be used
     * automatically */
    public $default_controller=null;

    public $auto_track_element=true;

    // {{{ Basic Operations
    /** Duplicate view and it's template. Will not duplicate children */
    function __clone(){
        throw $this->exception('Can\'t clone Views');
        //parent::__clone();
        //if($this->template)$this->template=clone $this->template;
    }
    /** Get associated model. It's safe to access $object->model directly. */
    function getModel(){
        return $this->model;
    }
    /** Associate view with a model. Different models may behave differently. */
    function setModel($model,$actual_fields=undefined){
        parent::setModel($model);

        // Some models will want default controller to be associated
        if($this->model->default_controller){
            $this->controller = $this->model->setController($this->model->default_controller);
        }

        // Use our default controller if present
        if($this->default_controller){
            $this->controller = $this->setController($this->default_controller);
        }

        if($this->controller){
            if($this->controller->hasMethod('setActualFields'))$this->controller->setActualFields($actual_fields);
            if($this->controller->hasMethod('_bindView'))$this->controller->_bindView();
        }

        if($this->model instanceof Model_Table)$this->dq=$this->model->_dsql();    // compatibility

        return $this->model;
    }

    /** @internal  used by getHTML */
    public $_tsBuffer='';
    function _tsBuffer($t,$data){
        $this->_tsBuffer.=$data;
    }
    /** Converting View into string will render recursively and produce HTML. If argument is passed, JavaScript will be added 
        * into on_ready section of your document like when rendered normally. Note that you might require to destroy object 
        * if you don't want it's HTML to appear normally */
    function getHTML($destroy=true,$execute_js=true){
        $this->addHook('output',array($this,'_tsBuffer'));
        $this->recursiveRender();
        $this->removeHook('output',array($this,'_tsBuffer'));
        $ret=$this->_tsBuffer;
        $this->_tsBuffer='';
        if($execute_js && $this->api->jquery)$this->api->jquery->getJS($this);
        if($destroy)$this->destroy();
        return $ret;
    }

    // }}}

    // {{{ Template Setup

    /** @internal Called automatically during init for template initalization */
    function initializeTemplate($template_spot=null,$template_branch=null){
        if(!$template_spot)$template_spot=$this->defaultSpot();
        $this->spot=$template_spot;
        if($this->owner->template && 
                !$this->owner->template->is_set($this->spot))throw
            $this->exception('Spot is not found in owner\'s template')
                ->addMoreInfo('spot',$this->spot);
        if(!isset($template_branch))$template_branch=$this->defaultTemplate();
        if(isset($template_branch)){
<commit_msg>notice<commit_after><?php // vim:ts=4:sw=4:et:fdm=marker
/**
 * A base class for all Visual objects in Agile Toolkit. The
 * important distinctive property of all Views is abiltiy
 * to render themselves (produce HTML) automatically and
 * recursively.
 *
 * @link http://agiletoolkit.org/learn/understand/view
*//*
==ATK4===================================================
   This file is part of Agile Toolkit 4 
    http://agiletoolkit.org/
  
   (c) 2008-2012 <NAME> <<EMAIL>>
   Distributed under Affero General Public License v3
   
   See http://agiletoolkit.org/about/license
 =====================================================ATK4=*/
abstract class AbstractView extends AbstractObject {
    /**
     * $template is an SMLite object containing indexed HTML
     * template. 
     *
     * Example:
     *
     * $view->template->set('title', $my_title);
     *
     * Assuming you have tag <?$template?> in template file associated
     * with this view - will insert text into this tag.
     *
     * @see AbstractObject::add();
     * @see AbstractView::defaultTemplate();
     */
    public $template=false;

    /**
     * @internal
     *
     * $template_flush is set to a spot on the template, which
     * should be flushed out. When using AJAX we want to show
     * only certain region from our template. However several
     * childs may want to put their data. This property will
     * be set to region's name my call_ajax_render and if it's
     * set, call_ajax_render will echo it and return false.
     */
    public $template_flush=false;

    /**
     * $spot defines a place on a parent's template where render() will
     * output() resulting HTML
     *
     * @see output()
     * @see render()
     * @see AbstractObject::add();
     * @see defaultSpot();
     */
    public $spot;

    /**
     * When using setModel() with Views some views will want to populate
     * fields, columns etc corresponding to models meta-data. That is the
     * job of Controller. When you create a custom controller for your view
     * set this property to point at your controller and it will be used
     * automatically */
    public $default_controller=null;

    public $auto_track_element=true;

    // {{{ Basic Operations
    /** Duplicate view and it's template. Will not duplicate children */
    function __clone(){
        throw $this->exception('Can\'t clone Views');
        //parent::__clone();
        //if($this->template)$this->template=clone $this->template;
    }
    /** Get associated model. It's safe to access $object->model directly. */
    function getModel(){
        return $this->model;
    }
    /** Associate view with a model. Different models may behave differently. */
    function setModel($model,$actual_fields=undefined){
        parent::setModel($model);

        // Some models will want default controller to be associated
        if($this->model->default_controller){
            $this->controller = $this->model->setController($this->model->default_controller);
        }

        // Use our default controller if present
        if($this->default_controller){
            $this->controller = $this->setController($this->default_controller);
        }

        if($this->controller){
            if($this->controller->hasMethod('setActualFields'))$this->controller->setActualFields($actual_fields);
            if($this->controller->hasMethod('_bindView'))$this->controller->_bindView();
        }

        if($this->model instanceof Model_Table)$this->dq=$this->model->_dsql();    // compatibility

        return $this->model;
    }

    /** @internal  used by getHTML */
    public $_tsBuffer='';
    function _tsBuffer($t,$data){
        $this->_tsBuffer.=$data;
    }
    /** Converting View into string will render recursively and produce HTML. If argument is passed, JavaScript will be added 
        * into on_ready section of your document like when rendered normally. Note that you might require to destroy object 
        * if you don't want it's HTML to appear normally */
    function getHTML($destroy=true,$execute_js=true){
        $this->addHook('output',array($this,'_tsBuffer'));
        $this->recursiveRender();
        $this->removeHook('output',array($this,'_tsBuffer'));
        $ret=$this->_tsBuffer;
        $this->_tsBuffer='';
        if($execute_js && $this->api->jquery)$this->api->jquery->getJS($this);
        if($destroy)$this->destroy();
        return $ret;
    }

    // }}}

    // {{{ Template Setup

    /** @internal Called automatically during init for template initalization */
    function initializeTemplate($template_spot=null,$template_branch=null){
        if(!$template_spot)$template_spot=$this->defaultSpot();
        $this->spot=$template_spot;
        if(@$this->owner->template && 
                !$this->owner->template->is_set($this->spot))throw
            $this->exception('Spot is not found in owner\'s template')
                ->addMoreInfo('spot',$this->spot);
        if(!isset($template_branch))$template_branch=$this->defaultTemplate();
        if(isset($template_branch)){

{'fraction_non_alphanumeric': 0.14606191222570533, 'fraction_numerical': 0.00274294670846395, 'mean_word_length': 2.8950782144219764, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7350516', 'n_tokens_mistral': 2780, 'n_tokens_neox': 2667, 'n_words': 798}