All pastes #1690699 Raw Edit

Static controller for Zend frame

public php v1 · immutable
#1690699 ·published 2009-11-28 05:35 UTC
rendered paste body
<?php/*Static controller that mimics somethingOh boy, I'm tired...Well, if you use the Zend framework you may want to what it doesIt's pretty self-explanatoryYou know that views you really don't need a controller for them? Okay, it's for them.In my case it's even more important.Why I'm not going to tell you (just some rules in the router).By Henrique Vicente - henriquevicente at gmail dot comhttp://flickr.com/photos/henriquev/*/class StaticController extends Zend_Controller_Action{	public function docsAction()	{		$request = $this->getRequest();				$uri = explode("?", $_SERVER['REQUEST_URI'], 2);		$find_path = (mb_substr($uri[0], -1) != '/') ? mb_substr($uri[0], 1) : mb_substr($uri[0], 1, -1);				if(!mb_strpos($find_path, ".") && !mb_strpos($find_path, "\\"))		{			$get_fs_path = APPLICATION_PATH."/views/scripts/static/".$find_path.".phtml";			$find_path_realpath = realpath($get_fs_path);//security... check if exists, etc			if($find_path_realpath && $find_path_realpath == $get_fs_path) //check if it's really a path that exists			{				$found = true;				//instead of docs.phtml...				$this->_helper->viewRenderer->setScriptAction($find_path);			}		}				//IF NOT FOUND		if(!isset($found)) $this->_forward("notstatic");//workaround to say a page does not exists	}}