protected function template($template=null,$variables=null,$return=false)
    {
        if (!$template) {
            $template = Utility::getClassName($this);
        } else if (gettype($template)=="array") {
            if (gettype($variables)=="boolean") {
                $return = $variables;
            }
            $variables = $template;
            $template = Utility::getClassName($this);
        }

        $currentDir = $this->getWidgetFolder();

        $themeBase = $this->getThemeBase();
        if ($themeBase && is_file($currentDir."/$template.$themeBase.tpl.php")) {
            $template.=".$themeBase";
        }

        //Try the template with base, if found then use it
        if (!is_file($currentDir."/$template.tpl.php")) {
            throw new \Exception("Could not find template [$template.tpl.php]");
        }

        ob_start();
        if ($variables) {
            foreach ($variables as $key=>$value) {
                $$key = $value;
            }
        }
        include $currentDir."/$template.tpl.php";
        $output = ob_get_clean();
        //$output = preg_replace('/\s+/S'," ", $output);
        if ($return) {
            return $output;
        } else {
            echo $output;
        }
        
    }
protected function template($template=null,$variables=null,$return=false)
    {
        if (!$template) {
            $template = Utility::getClassName($this);
        } else if (gettype($template)=="array") {
            if (gettype($variables)=="boolean") {
                $return = $variables;
            }
            $variables = $template;
            $template = Utility::getClassName($this);
        }

        $currentDir = $this->getWidgetFolder();

        $themeBase = $this->getThemeBase();
        if ($themeBase && is_file($currentDir."/$template.$themeBase.tpl.php")) {
            $template.=".$themeBase";
        }

        //Try the template with base, if found then use it
        if (!is_file($currentDir."/$template.tpl.php")) {
            throw new \Exception("Could not find template [$template.tpl.php]");
        }

        ob_start();
        if ($variables) {
            foreach ($variables as $key=>$value) {
                $$key = $value;
            }
        }
        include $currentDir."/$template.tpl.php";
        $output = ob_get_clean();
        //$output = preg_replace('/\s+/S'," ", $output);
        if ($return) {
            return $output;
        } else {
            echo $output;
        }
        
    }
protected function template ( $ template = null , $ variables = null , $ return = false ) { if ( ! $ template ) { $ template = Utility :: getClassName ( $ this ) ; } else if ( gettype ( $ template ) == "array" ) { if ( gettype ( $ variables ) == "boolean" ) { $ return = $ variables ; } $ variables = $ template ; $ template = Utility :: getClassName ( $ this ) ; } $ currentDir = $ this -> getWidgetFolder ( ) ; $ themeBase = $ this -> getThemeBase ( ) ; if ( $ themeBase && is_file ( $ currentDir . "/$template.$themeBase.tpl.php" ) ) { $ template .= ".$themeBase" ; } //Try the template with base, if found then use it if ( ! is_file ( $ currentDir . "/$template.tpl.php" ) ) { throw new \ Exception ( "Could not find template [$template.tpl.php]" ) ; } ob_start ( ) ; if ( $ variables ) { foreach ( $ variables as $ key => $ value ) { $ $ key = $ value ; } } include $ currentDir . "/$template.tpl.php" ; $ output = ob_get_clean ( ) ; //$output = preg_replace('/\s+/S'," ", $output); if ( $ return ) { return $ output ; } else { echo $ output ; } }
Loading template and inject parameters

@param string $template  The template name that will be used
to render widget content.
@param array  $variables The variables to fill the template
@param bool   $return    Whether template will render content or
return the content

@return string It could return html of widget
if $return parameter is set to true
Loading template and inject parameters