Bontiv-Sourceer source code viewer
Root | Help
./bontiv-cms/core/core_modbase.php
<?php
abstract class core_modbase {

    protected
$translator;
    protected
$template;

    function
__construct()
    {
       
$this->template = new template();
       
$this->translator = new translator(get_class($this));
       
$this->translator->load('common');
       
$session = new session();
    }
   
    public function
Start ($url)
    {
       
$url = explode('/', $url);
        if (!isset(
$url[1]) || $url[1] == '')
           
$url[1] = 'index';

        if (
method_exists($this, 'PAGE_' . $url[1]))
        {
           
$arg = $url;
            unset(
$arg[1], $arg[0]);
           
call_user_func_array(array($this, 'PAGE_' . $url[1]), $arg);
        }
        else
        {
            throw new
Error404();
        }
    }
   
    protected function
fetch($page, $class = NULL)
    {
        if (
$class == NULL)
           
$class = LastClass();
       
$class = explode('_', $class);
       
$class = 'mod_' . $class[1];

       
$theme = ROOTDIR . core_settings::Get('themedir') . DIRECTORY_SEPARATOR
           
. $this->template->theme . DIRECTORY_SEPARATOR
           
. 'modules' . DIRECTORY_SEPARATOR
           
. core_modules::modDir(get_class($this)) . DIRECTORY_SEPARATOR . $page;

        if (!
file_exists($theme))
        {
           
$theme = MODSDIR . core_modules::modDir($class) . DIRECTORY_SEPARATOR
           
. 'templates' . DIRECTORY_SEPARATOR . $page;
        }
       
       
$this->translator->apply($this->template);
        return
$this->template->fetch($theme);
    }
   
    protected function
display($page)
    {
        echo
$this->fetch($page, LastClass());
    }
   
    protected function
assign($tplvar, $translation)
    {
       
$this->template->assign($tplvar,
           
$this->translator->get($translation));        
    }
}
Presented with Bontiv-Sourceer