Пример #1
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     if ('admin' == $request->getModuleName() && 'Login' != $request->getControllerName()) {
         // Immediate ACL check to make sure they have identity
         $allowUser = defined('DEBUG_MODE') ? true : false;
         // blacklist system
         $user = $request->getParam('User', null);
         if ($user instanceof Showcase_User) {
             // OK user has identity, check the roles
             //$allowUser = Zend_registry::get('Acl')->isAllowed($user->getRoles(), "CMS User") ? true : false;
             $allowUser = $user->isCmsaccess;
         }
         if (!$allowUser) {
             $request->setControllerName('Login')->setModuleName('index')->setActionName('index')->setDispatched(false);
         } else {
             Showcase_Controller_Action_HelperBroker::addPath(Package::buildPath(SITE_DIR, 'classes', 'Controller', 'Action', 'Helper', 'Admin'), 'Showcase_Controller_Action_Helper_Admin');
             // Cretae a new helper path for administrative privileges
             //$request->setParam('Admin', Showcase_Admin::getInstance());
             // Set the instance of the Admin object
             //$request->getParam('View')->assign('admin', $request->getParam('Admin'));
             // And inject it into the view so it can help things for Smarty
             // Include the CMS JS scripts
             //$request->getParam('View')->assign('javaScripts', array('/include/js/admin/js/cms'));
             // Check if the user wants to force a manual cache clearance
             //if ($request->getParam('flushCache')) {
             //	Showcase_Content_Cache::flushCache();
             //}
         }
     }
 }
Пример #2
0
 public static function addPath($path, $prefix = 'Zend_Controller_Action_Helper')
 {
     // make sure it ends in a PATH_SEPARATOR
     if (substr($path, -1, 1) != DIRECTORY_SEPARATOR) {
         $path .= DIRECTORY_SEPARATOR;
     }
     // make sure it ends in a PATH_SEPARATOR
     $prefix = rtrim($prefix, '_') . '_';
     $info['dir'] = $path;
     $info['prefix'] = $prefix;
     self::$_paths = array_merge(array($info), self::$_paths);
     return;
 }
Пример #3
0
function smarty_function_url($params, Smarty $smarty)
{
    $url = null;
    if (($urlHelper = Showcase_Controller_Action_HelperBroker::getStaticHelper('url')) && $urlHelper instanceof Showcase_Controller_Action_Helper_Url) {
        $assignVar = null;
        $uriParams = array();
        foreach ($params as $key => $val) {
            if ('assign' == $key) {
                $assignVar = $val;
            } elseif (!$val) {
            } else {
                $uriParams[$key] = strval($val);
            }
        }
        if (array_key_exists('route', $uriParams)) {
            // this is a route
            $routeName = $uriParams['route'];
            unset($uriParams['route']);
            try {
                $url = $urlHelper->url($uriParams, $routeName, true);
            } catch (Zend_Exception $e) {
                echo $e->getMessage();
            }
        } else {
            foreach (array('action', 'controller', 'module') as $key) {
                if (array_key_exists($key, $uriParams)) {
                    ${$key} = $uriParams[$key];
                    unset($uriParams[$key]);
                } else {
                    ${$key} = null;
                }
            }
            $url = $urlHelper->simple($action, $controller, $module, $uriParams, true);
        }
        if (0 !== strpos(strrev($url), '/')) {
            $url .= '/';
        }
        if ($sessionId = Showcase_Session::getSessionKey()) {
            $url .= "sid/{$sessionId}";
        }
        $url = $url ? 0 === strpos($url, '/') ? $url : '/' . $url : '#';
        if (!$assignVar) {
            echo $url;
        } else {
            $smarty->assign($assignVar, $url);
        }
    }
}