Exemple #1
0
/**
 * Renders the breadcrumb navigation.
 *
 * @link Koch_Breadcrumb::getTrail() is used for trail as default.
 *
 * @example
 * {breadcrumbs}
 *
 * @param array  $params
 * @param object $smarty Smarty Render Engine
 *
 * @return string
 */
function Smarty_function_breadcrumbs($params, $smarty)
{
    // handle trail params set directly to the smarty function call in the template
    if ($params['trail'] !== null && is_array($params['trail'])) {
        $trail = $params['trail'];
    } else {
        $trail = \Koch\View\Helper\Breadcrumb::getTrail();
    }
    #\Koch\Debug\Debug::firebug($trail);
    // is the seperator element set via the smarty function call?
    if ($params['separator'] !== null) {
        $separator = $params['separator'];
    } else {
        // no, take default seperator
        $separator = ' > ';
    }
    if ($params['length'] !== null) {
        $length = (int) $params['length'];
    } else {
        $length = 0;
    }
    $links = [];
    $trailSize = count($trail);
    for ($i = 0; $i < $trailSize; ++$i) {
        if ($length > 0) {
            $title = mb_substr($trail[$i]['title'], 0, $length);
        } else {
            $title = $trail[$i]['title'];
        }
        if (isset($trail[$i]['link']) && $i < $trailSize - 1) {
            // if parameter "title" (only) is not set, give links
            if (isset($params['title']) === false) {
                $links[] = sprintf('<a href="%s" title="%s">%s</a>', htmlspecialchars($trail[$i]['link']), htmlspecialchars($trail[$i]['title']), htmlspecialchars($trail[$i]['title']));
            } else {
                $links[] = $title;
            }
        } else {
            $links[] = $title;
        }
    }
    $breadcrumb_string = implode($separator . ' ', $links);
    if (isset($params['assign'])) {
        $smarty->assign('breadcrumb', $breadcrumb_string);
    } else {
        return $breadcrumb_string;
    }
}
Exemple #2
0
 /**
  * Breadcrumb Level 0    =>    Home or Controlcenter
  *
  * @param string $moduleName    The module name.
  * @param string $submoduleName The submodule name.
  */
 public static function initialize($moduleName = null, $submoduleName = null)
 {
     // ControlCenter (Backend)
     if ($moduleName == 'controlcenter' or $submoduleName == 'admin') {
         Breadcrumb::add('Control Center', '/index.php?mod=controlcenter');
     } else {
         // Home (Frontend)
         Breadcrumb::add('Home');
     }
 }
 /**
  * The dispatcher accepts the found route from the route mapper and
  * invokes the correct controller and method.
  *
  * Workflow
  * 1. fetches Route Object
  * 2. extracts info about correct controller, correct method with correct parameters
  * 3. tries to call the method "initializeModule" on the controller
  * 4. finally tries to call the controller with method(parms)!
  *
  * The dispatcher forwards to the pagecontroller = modulecontroller + moduleaction.
  */
 public function forward($request, $response)
 {
     // fetch the target route from the request
     $route = $request->getRoute();
     if ($route === null) {
         throw new \Exception('The dispatcher is unable to forward. No route object given.', 99);
     }
     //$route::debug();
     $classname = $route::getClassname();
     $method = $route::getMethod();
     $parameters = $route::getParameters();
     #$request_meth = Koch_HttpRequest::getRequestMethod();
     #$renderengine = $route::getRenderEngine();
     #$this->event_dispatcher->addEventHandler('onBeforeControllerMethodCall', new Koch_Event_InitializeModule());
     $route::dispatchable();
     $controllerInstance = new $classname($request, $response);
     /**
      * Initialize the Module
      *
      * by calling the "_initializeModule" method on the controller.
      * A module might(!) implement this method for initialization of helper objects.
      *
      * Note the underscore! The method name is intentionally underscored.
      * This places the method on top in the method navigator of your IDE.
      */
     if (true === method_exists($controllerInstance, '_initializeModule')) {
         $controllerInstance->_initializeModule();
     }
     /**
      * "Before Module Filter" is a prefilter on the module controller level.
      *
      *
      * It calls the "_beforeFilter" method on the module controller.
      * A module might(!) implement this method for initialization of helper objects.
      * Example usage: login_required.
      *
      * Note the underscore! The method name is intentionally underscored.
      * This places the method on top in the method navigator of your IDE.
      */
     if (true === method_exists($controllerInstance, '_beforeFilter')) {
         $controllerInstance->_beforeFilter();
     }
     // @todo move into a prefilter / and consider the request being ajax :) = no breadcrumbs
     Breadcrumb::initialize($route->getModuleName(), $route->getSubmoduleName());
     /**
      * Finally: dispatch to the requested controller method
      */
     if (true === method_exists($controllerInstance, $method)) {
         $controllerInstance->{$method}($parameters);
     }
     /**
      * "After Module Filter" is a postfilter on the module controller level.
      *
      * It calls the "_afterFilter" method on the module controller.
      * A module might(!) implement this method for running further processing
      * on reponse data.
      *
      * Note the underscore! The method name is intentionally underscored.
      * This places the method on top in the method navigator of your IDE.
      */
     if (true === method_exists($controllerInstance, '_afterFilter')) {
         $controllerInstance->_afterFilter();
     }
 }
Exemple #4
0
 /**
  * Adds a new breadcrumb
  *
  * @param string $title                  Name of the trail element. Use Gettext _('Title')!
  * @param string $link                   Link of the trail element
  * @param string $replace_array_position Position in the array to replace with name/trail. Start = 0.
  */
 public static function addBreadcrumb($title, $link = '', $replace_array_position = null)
 {
     \Koch\View\Helper\Breadcrumb::add($title, $link, $replace_array_position);
 }
Exemple #5
0
 /**
  * Constants for overall usage in all templates of all render engines.
  *
  * a) Assign Web Paths
  * b) Meta
  * c) Application version
  * d) Page related
  *
  * @return array $template_constants
  */
 public function getConstants()
 {
     $modulename = \Koch\Router\TargetRoute::getModule();
     $templateConstants = [];
     /*
      * a) Assign Web Paths
      *
      *    Watch it! These are relative (not absolute) paths. They are based on WWW_ROOT!
      */
     $templateConstants['www_root'] = WWW_ROOT;
     $templateConstants['www_root_uploads'] = WWW_ROOT . 'Uploads/';
     $templateConstants['www_root_modules'] = WWW_ROOT . 'Modules/' . $modulename . '/';
     $templateConstants['www_root_theme'] = $this->getTheme()->getWebPath();
     $templateConstants['www_root_themes'] = WWW_ROOT_THEMES;
     $templateConstants['www_root_themes_core'] = WWW_ROOT_THEMES_CORE;
     $templateConstants['www_root_themes_backend'] = WWW_ROOT_THEMES_BACKEND;
     $templateConstants['www_root_themes_frontend'] = WWW_ROOT_THEMES_FRONTEND;
     /*
      * b) Meta Informations
      */
     $templateConstants['meta'] = $this->config['meta'];
     /*
      * c) Application Version
      *
      *    Note: This is doubled functionality.
      *    You can use $smarty.const.APPLICATION_VERSION or $application_version in a template.
      */
     $templateConstants['application_version'] = APPLICATION_VERSION;
     $templateConstants['application_version_state'] = APPLICATION_VERSION_STATE;
     $templateConstants['application_version_name'] = APPLICATION_VERSION_NAME;
     $templateConstants['application_url'] = APPLICATION_URL;
     /*
      * d) Page related
      */
     // Page Title
     $templateConstants['pagetitle'] = $this->config['template']['pagetitle'];
     // Breadcrumb
     $templateConstants['trail'] = \Koch\View\Helper\Breadcrumb::getTrail();
     // Templatename itself
     $templateConstants['templatename'] = $this->getTemplate();
     // Help Tracking
     $templateConstants['helptracking'] = $this->config['help']['tracking'];
     /*
      * Debug Display
      */
     #\Koch\Debug\Debug::printR($templateConstants);
     return $templateConstants;
 }
Exemple #6
0
 /**
  * The dispatcher accepts the found route from the route mapper and
  * invokes the correct controller and method.
  *
  * Workflow
  * 1. fetches Route Object
  * 2. extracts info about correct controller, correct method with correct parameters
  * 3. tries to call the method "initializeModule" on the controller
  * 4. finally tries to call the controller with method(params)!
  *
  * The dispatcher forwards to the pagecontroller = modulecontroller + moduleaction.
  */
 public function forward()
 {
     $route = $this->request->getRoute();
     $classname = $route::getClassname();
     $method = $route::getMethod();
     $parameters = $route::getParameters();
     #$request_meth = \Koch\Http\HttpRequest::getRequestMethod();
     #$renderengine = $route::getRenderEngine();
     #$this->eventDispatcher->addEventHandler('onBeforeControllerMethodCall', new Koch\Event\InitializeModule());
     #\Koch\Debug\Debug::firebug($classname . ' ' . $method . ' ' . var_export($parameters, true));
     $controllerInstance = new $classname($this->request, $this->response);
     /*
      * Initialize the Module
      *
      * by calling the "_initializeModule" method on the controller.
      * A module might(!) implement this method for initialization of helper objects.
      * Basically it's a constructor! Keep it lightweight!
      *
      * Note the underscore! The method name is intentionally underscored.
      * This places the method on top in the method navigator of your IDE.
      */
     if (method_exists($controllerInstance, '_initializeModule')) {
         $controllerInstance->_initializeModule();
     }
     /*
      * "Before Module Filter" is a prefilter on the module controller level.
      *
      * It calls the "_beforeFilter" method on the module controller.
      * A module might(!) implement this method for initialization of helper objects.
      * Example usage: login_required.
      *
      * Note the underscore! The method name is intentionally underscored.
      * This places the method on top in the method navigator of your IDE.
      */
     if (method_exists($controllerInstance, '_beforeModuleFilter')) {
         $controllerInstance->_beforeModeFilter();
     }
     // @todo auto-attach a Module::onBootstrap method as event
     // @todo move into a prefilter / and consider the request being ajax = no breadcrumbs
     Breadcrumb::initialize($route->getModule(), $route->getController());
     /*
      * Finally: dispatch to the requested controller method
      */
     if (method_exists($controllerInstance, $method)) {
         $controllerInstance->{$method}($parameters);
     } else {
         echo 'Class ' . $classname . '->Method ' . $method . ' not found.';
     }
     /*
      * "After Module Filter" is a postfilter on the module controller level.
      *
      * It calls the "_afterFilter" method on the module controller.
      * A module might(!) implement this method for running further processing
      * on reponse data.
      *
      * Note the underscore! The method name is intentionally underscored.
      * This places the method on top in the method navigator of your IDE.
      */
     if (method_exists($controllerInstance, '_afterModuleFilter')) {
         $controllerInstance->_afterModuleFilter();
     }
     // @todo auto-attach a Module::onShutdown method as event
 }
 /**
  * Constants for overall usage in all templates of all render engines
  *
  * a) Assign Web Paths
  * b) Meta
  * c) Application version
  * d) Page related
  *
  * @return array $template_constants
  */
 public function getConstants()
 {
     $modulename = HttpRequest::getRoute()->getModuleName();
     $template_constants = array();
     /**
      * a) Assign Web Paths
      *
      *    Watch it! These Paths are relative (based on WWW_ROOT), not absolute!
      */
     $template_constants['www_root'] = WWW_ROOT;
     $template_constants['www_root_uploads'] = WWW_ROOT . 'uploads/';
     $template_constants['www_root_mod'] = WWW_ROOT . 'modules/' . $modulename . '/';
     $template_constants['www_root_theme'] = $this->getTheme()->getWebPath();
     $template_constants['www_root_themes'] = WWW_ROOT_THEMES;
     $template_constants['www_root_themes_core'] = WWW_ROOT_THEMES_CORE;
     $template_constants['www_root_themes_backend'] = WWW_ROOT_THEMES_BACKEND;
     $template_constants['www_root_themes_frontend'] = WWW_ROOT_THEMES_FRONTEND;
     /**
      * b) Meta Informations
      */
     $template_constants['meta'] = $this->config['meta'];
     /**
      * c) Clansuite Version
      *
      *    Note: This is doubled functionality.
      *    You can use $smarty.const.CLANSUITE_VERSION or $clansuite_version in a template.
      */
     $template_constants['clansuite_version'] = CLANSUITE_VERSION;
     $template_constants['clansuite_version_state'] = CLANSUITE_VERSION_STATE;
     $template_constants['clansuite_version_name'] = CLANSUITE_VERSION_NAME;
     $template_constants['clansuite_url'] = CLANSUITE_URL;
     /**
      * d) Page related
      */
     // Page Title
     $template_constants['pagetitle'] = $this->config['template']['pagetitle'];
     // Normal CSS (mainfile)
     $template_constants['css'] = $this->getTheme()->getCSSFile();
     // Normal Javascript (mainfile)
     $template_constants['javascript'] = $this->getTheme()->getJSFile();
     // Breadcrumb
     $template_constants['trail'] = \Koch\View\Helper\Breadcrumb::getTrail();
     // Templatename itself
     $template_constants['templatename'] = $this->getTemplate();
     // Help Tracking
     $template_constants['helptracking'] = $this->config['help']['tracking'];
     /**
      * Debug Display
      */
     #\Koch\Debug\Debug::printR($template_constants);
     return $template_constants;
 }