Location: PHPKode > projects > CenterFlow > app/app_controller.php
<?php
class AppController extends Controller
{
	var $helpers = array('Html','Text','Javascript');
		
    function checkSession()
    {
        // If the session info hasn't been set...
        if (!$this->Session->check('Person'))
        {
        	$ref = base64_encode($this->here);
            // Force the user to login
            $this->redirect(CF_ROOT."/people/login/$ref");
            exit();
        }
    }
    
    function beforeRender()
    {
    	if(!$this->pageTitle || empty($this->pageTitle))
    	{
    		$this->pageTitle = ucwords($this->name.' :: '.$this->action);
    	}
    	$this->pageTitle = 'centerFLOW-'.$this->pageTitle;
    	$this->set('cfroot',CF_ROOT);
    }
    
    function xmlencode($id, $max_depth = null)
	{
		$this->helpers = array('Xml');
		$model = Inflector::singularize($this->name);
		$conditions = array("$model.id"=>$id);
		$fields = null;
		$order  = null;
		$recursive = 3;
		$data = $this->$model->find($conditions,$fields,$order,$recursive);
		$this->set('data', $data);
		$this->set('max_depth',$max_depth);
		$this->layout = 'xml';
	}

	function jsonencode($id)
	{
		$model = Inflector::singularize($this->name);
		$conditions = array("$model.id"=>$id);
		$fields = null;
		$order  = null;
		$recursive = 3;
		
		$data = json_encode($this->$model->find($conditions,$fields,$order,$recursive));
		$data = str_replace("'","\'",$data);
		$this->set('data',$data);
		$this->layout = 'ajax';
		$this->action = 'empty';
	}
}

vendor('kaanon');
?>
Return current item: CenterFlow