예제 #1
0
 public function index()
 {
     error_reporting(E_ALL);
     $foto = new Foto();
     $largura = Samus_Keeper::getUrl(2);
     $altura = Samus_Keeper::getUrl(3);
     $foto->setTamanho($largura, $altura);
     $foto->setQualidade(87);
     $foto->exibirImagem(Samus_Keeper::getUrl(1));
     $this->setTemplateFile("vazio");
 }
예제 #2
0
 /**
  * Método responsável pela exibição da página, por aqui é feita a mágica de
  * colocar todas as propriedades encapsuladas na visão
  *
  * @param string $directory diretorio do template
  * @param string $metodo método de filtro
  * @param array $args argumentos do método de filtro
  */
 public function assignClass($directory = "", $metodo = "", array $args = array())
 {
     //coloca na sessão a página atual
     $_SESSION[Samus::SESSION_PAGE_NAME] = "";
     foreach (Samus_Keeper::getUrl() as $url) {
         $_SESSION[Samus::SESSION_PAGE_NAME] .= $url . "-";
     }
     $_SESSION[Samus::SESSION_PAGE_NAME] = substr($_SESSION[Samus::SESSION_PAGE_NAME], 0, -1);
     $ref = new ReflectionClass($this);
     if (!empty($metodo)) {
         /*@var $refMetodo ReflectionMethod*/
         $refMetodo = $ref->getMethod($metodo);
         $refMetodo->invoke($this, $args);
     }
     $ref = new ReflectionObject($this);
     $met = $ref->getMethods();
     $ai = new ArrayIterator($met);
     $minhaArray = array();
     while ($ai->valid()) {
         $metName = $ai->current()->getName();
         if (substr($metName, 0, 3) == "get" && $metName[3] != "_") {
             $prop = substr($metName, 3);
             $prop = strtolower(substr($prop, 0, 1)) . substr($prop, 1);
             $minhaArray[$prop] = $ai->current()->invoke($this);
             /**
              * Atribui para a classe de visão todas as propriedades do
              * objeto depois de executar o método especificado (aki é a
              * chave do negócio)
              */
             $this->smarty->assign($prop, $ai->current()->invoke($this));
         }
         $ai->next();
     }
     $properties = $ref->getProperties();
     foreach ($properties as $prop) {
         /*@var $prop ReflectionProperty */
         if ($prop->isPublic()) {
             $this->smarty->assign($prop->getName(), $prop->getValue($this));
         }
     }
     $this->assignGlobals();
     if (empty($this->templateFile) && $this->templateFile !== false) {
         /**
          * Exibe um template com o mesmo nome da classe especificada com a primeira
          * letra como minuscula
          */
         $templateName = UtilString::upperToUnderline(substr($ref->getName(), 0, strlen(Samus::getControlsClassSufix()) * -1));
         if ($this->mode == self::MODE_VIEW) {
             /*******************************************************************
              * DEFAULT CSS e JS
              * sf_current_js
              * sf_current_css
              ******************************************************************/
             $cssFile = WEB_DIR . Samus::$defaultCSSDir . $directory . $templateName . '.css';
             /**
              * @todo verificar se esta linha esta errada ta parecendo que na versão
              * online não esta inserindo este arkivo
              */
             if (file_exists($cssFile)) {
                 $this->smarty->assign("sf_current_css", WEB_URL . Samus::$defaultCSSDir . $directory . $templateName . '.css');
             }
             $jsFile = WEB_DIR . Samus::$defaultJavaScriptDir . $directory . $templateName . '.js';
             if (is_file($jsFile)) {
                 $this->smarty->assign("sf_current_js", WEB_URL . Samus::$defaultJavaScriptDir . $directory . $templateName . '.js');
             }
             $realTemplateFile = $directory . $templateName . Samus::getViewFileExtension();
         } elseif ($this->mode == self::MODE_JAVASCRIPT) {
             $realTemplateFile = WEB_DIR . $directory . $templateName . Samus::getJavaScriptFileExtension();
         } elseif ($this->mode == self::MODE_CSS) {
             $realTemplateFile = WEB_DIR . Samus::getDefaultCSSDir() . $directory . $templateName . Samus::getCssFileExtension();
         } else {
             $realTemplateFile = $directory . $templateName . Samus::getViewFileExtension();
         }
         $this->smarty->display($realTemplateFile);
     } elseif ($this->templateFile === false) {
         $cssFile = WEB_DIR . Samus::$defaultCSSDir . $this->templateFile . '.css';
         if (is_file($cssFile)) {
             $this->smarty->assign("sf_current_css", $cssFile);
         }
         $jsFile = WEB_DIR . Samus::$defaultJavaScriptDir . $this->templateFile . '.js';
         if (is_file($jsFile)) {
             $this->smarty->assign("sf_current_js", WEB_URL . Samus::$defaultJavaScriptDir . $this->templateFile . '.js');
         }
         $this->smarty->display("sf/empty.tpl");
     } else {
         /*******************************************************************
          * DEFAULT CSS e JS CONFORME O TEMPLATE ESPECIFICADO
          * sf_current_js
          * sf_current_css
          ******************************************************************/
         $cssFile = WEB_DIR . Samus::$defaultCSSDir . $this->templateFile . '.css';
         if (is_file($cssFile)) {
             $this->smarty->assign("sf_current_css", $cssFile);
         }
         $jsFile = WEB_DIR . Samus::$defaultJavaScriptDir . $this->templateFile . '.js';
         if (is_file($jsFile)) {
             $this->smarty->assign("sf_current_js", WEB_URL . Samus::$defaultJavaScriptDir . $this->templateFile . '.js');
         }
         $this->smarty->display($this->templateFile);
     }
 }
예제 #3
0
 /**
  * Obtem um valor da url
  * @param $pos int
  * @return string
  */
 public static function getURL($pos = "")
 {
     return Samus_Keeper::getUrl($pos);
 }