Exemplo n.º 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;
    }
}
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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 = 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;
 }