Exemplo n.º 1
0
 /**
  * Adds breadcrumbs dynamically based on current module, submodule and action.
  * This might look a bit rough to the user.
  * Please prefer adding breadcrumbs manually via add().
  */
 public static function addDynamicBreadcrumbs()
 {
     $module = strtolower(TargetRoute::getModule());
     $controller = strtolower(TargetRoute::getController());
     $action = TargetRoute::getActionNameWithoutPrefix();
     if (isset($module) and $module !== 'controlcenter') {
         $url = 'index.php?mod=' . $module;
         // Level 2
         // do not add ctrl part, if controller and module are the same
         if ($controller !== '' and $controller !== $module) {
             $url .= '&ctrl=' . $controller;
             $module .= ' ' . $controller;
         }
         self::add($module, $url);
         // Level 3
         if ($action !== '') {
             $url .= '&action=' . $action;
             self::add($action, $url);
         }
     }
 }
Exemplo n.º 2
0
Arquivo: Smarty.php Projeto: ksst/kf
 /**
  * Renderer_Smarty->render.
  *
  * Returns the mainframe layout with inserted modulcontent (templatename).
  *
  * 1. assign common values and constants
  * 2. fetch the modultemplate and assigns it as $content
  * 3. return the wrapper layout tpl
  *
  * @param string $template Template Filename
  *
  * @return null|string tpl layout
  */
 public function render($template = null, $viewdata = null)
 {
     if ($viewdata !== null) {
         $this->assign($viewdata);
     }
     // assign common template values and Application constants as Smarty Template Variables.
     $constants = $this->getConstants();
     foreach ($constants as $const => $value) {
         $this->renderer->assignGlobal($const, $value);
     }
     /*
      * Assign the original template name and the requested module
      * This is used in template_not_found.tpl to provide a link to the templateeditor
      */
     $this->renderer->assignGlobal('modulename', TargetRoute::getModule());
     $this->renderer->assignGlobal('actionname', TargetRoute::getActionName());
     $this->renderer->assignGlobal('templatename', $template);
     /*
      * Rendering depends on the RenderMode.
      *
      * The RenderMode "PARTIAL" means, that only the content template is rendered.
      *
      * The RenderMode "LAYOUT" means, that the content template is embedded,
      * into a layout template, by replacing the {$content} placeholder.
      */
     if ($this->getRenderMode() === 'PARTIAL') {
         return $this->fetch($template);
     }
     if ($this->getRenderMode() === 'LAYOUT') {
         // assign the modulecontent
         $this->assign('content', $this->fetch($template));
         return $this->fetch($this->getLayoutTemplate());
     }
 }
Exemplo n.º 3
0
Arquivo: Config.php Projeto: ksst/kf
 /**
  * Write module configuration file.
  *
  * @param $array The configuration array to write.
  * @param string $module The name of a module.
  *
  * @return bool
  */
 public function writeModuleConfig(array $array, $module = null)
 {
     // if no modulename is set, determine the name of the current module
     $module = $module === null ? \Koch\Router\TargetRoute::getModule() : ucfirst($module);
     $file = realpath(APPLICATION_MODULES_PATH . $module . DIRECTORY_SEPARATOR . $module . '.config.php');
     return $this->write($file, $array);
 }
Exemplo n.º 4
0
/**
 * Smarty Currentmodule.
 *
 * Displays the name of the current module
 *
 * Examples:
 * <pre>
 * {pagination}
 * </pre>
 *
 * Type:     function<br>
 * Name:     currentmodule<br>
 * Purpose:  display name of current module<br>
 *
 * @return string
 */
function Smarty_function_currentmodule()
{
    return \Koch\Router\TargetRoute::getModule();
}
Exemplo n.º 5
0
Arquivo: Mapper.php Projeto: ksst/kf
 /**
  * Returns Module Template Paths.
  *
  * @param string $module
  *
  * @return string[] Module Template Paths
  */
 public static function getModuleTemplatePaths($module = null)
 {
     // fetch modulename for template path construction
     if (empty($module)) {
         $module = TargetRoute::getModule();
     }
     // fetch renderer name for template path construction
     $renderer = TargetRoute::getRenderEngine();
     // compose templates paths in the module dir
     $module_paths = [APPLICATION_MODULES_PATH, APPLICATION_MODULES_PATH . $module . DIRECTORY_SEPARATOR, APPLICATION_MODULES_PATH . $module . '/View/', APPLICATION_MODULES_PATH . $module . '/View/' . ucfirst($renderer) . DIRECTORY_SEPARATOR];
     return $module_paths;
 }
Exemplo n.º 6
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;
 }