<?php
goweb::loadClass('Zend_View');
/**
 * Goweb Sitemanager 5 Framework
 *
 * Classe View intermédia 
 *
 * @version    5.1.9
 * @category   Goweb
 * @package    Goweb_View
 * @author     I&D <dev@goweb.pt>, Pedro Pinto <ppinto@goweb.pt>
 * @copyright  2010 (c) Goweb (http://www.goweb.pt)
 *
 *
 */

class Goweb_View extends Zend_View{

    /**
     * Define o directório onde se encontram as views.
     *
     * @param String $path O directório onde se encontram as views.
     */
    public function setViewsPath($path){
        $this->setScriptPath($path);
    }

    /**
     * Inclui uma view.
     *
     * @param String $file Nome do ficheiro a incluir
     * @return String
     */
    public function includeView($file){
        return $this->render($file);
    }

    /**
     * Includes the view script in a scope with only public $this variables.
     *
     * @param string The view script to execute.
     */
    protected function _run()
    {
        extract(get_object_vars($this));
        if ($this->_useViewStream && $this->useStreamWrapper()) {
            include 'zend.view://' . func_get_arg(0);
        } else {
            include func_get_arg(0);
        }
    }

    /**
     * Escapes a value for output in a view script.
     *
     * @param mixed $var The output to escape.
     * @return mixed The escaped value.
     */
    public function escape($var){
        return htmlentities($var, ENT_COMPAT, CHARSET, false);
    }

    /**
     * Corrigir valor Float
     *
     * @param string $valor
     * @return string
     */
    public function fixValor($valor){
        if (!is_string($valor)) return $valor;
        if (strpos($valor, ',') !== false && strpos($valor, '.') !== false){
            $valor = str_replace('.', '', $valor);
        }
        $valor = str_replace(',', '.', $valor);
        return $valor;
    }
}