<?php

class Bullhead_View_Helper_AppPath {

    
    function appPath($key=null)
    {
        $fc = Zend_Controller_Front::getInstance();
        $request    = $fc->getRequest();
        $user_params = $request->getUserParams();
        $action     = "";
        $controller = "";
        $module     = "";
        
        switch ($key) {
        case  $request->getActionKey() :
            if (!empty($user_params[$request->getActionKey()])) {
                $action= $user_params[$request->getActionKey()];
            }
        case  $request->getControllerKey():
            if (!empty($user_params[$request->getControllerKey()])) {
                $controller = $user_params[$request->getControllerKey()];
            }
        case  $request->getModuleKey() :
            if (!empty($user_params[$request->getModuleKey()])) {
                $module = $user_params[$request->getModuleKey()];
            }
        default :
            $base = $request->getBaseUrl();
            break;
        }
        
        $path = "{$base}";
        if (!empty($module)) $path .= "/{$module}";
        if (!empty($controller)) $path .= "/{$controller}";
        if (!empty($action)) $path .= "/{$action}";
        
        return $path;
    }
}

?>
