Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Known runtime contexts are:

Runtime ContextSetting NameConfigured From
Front-EndIs Front-End?/index.php
Theme NameURL
Mod-Rewrite UrlsSystem Setting
Admin ConsoleIs Admin Console?/admin/index.php

Typical URL examples:

URLWhere
No Format
http://www.website.tld/index.php?env=-platform%2Flogin%2Fregister%3Am0-1-1-1-s-
to the "platform/login/register" template in "advanced" theme on Front-End when Mod-Rewrite is disabled
No Format
http://www.website.tld/platform/login/register.html
to the "platform/login/register" template in "advanced" theme on Front-End when Mod-Rewrite is enabled
No Format
http://www.website.tld/admin/index.php?env=-languages%2Fphrase_list%3Am0--1--r-
to the "languages/phrase_list" template in Admin Console

If a need arises to build url to Admin Console from Front-End or vice versa then this can be done, to the certain extent, using this code:

...

Code Block
// Use Admin context.
$backup = $this->Application->applyRuntimeContext(new AdminRuntimeContext());
// do something
$this->Application->applyRuntimeContext($backup);
 
// Use Front-End context from current theme.
$backup = $this->Application->applyRuntimeContext(new FrontEndRuntimeContext());
// do something
$this->Application->applyRuntimeContext($backup);
 
// Use Front-End context from primary theme.
$backup = $this->Application->applyRuntimeContext(new FrontEndRuntimeContext('default'));
// do something
$this->Application->applyRuntimeContext($backup);

// Use Front-End context from given theme.
$backup = $this->Application->applyRuntimeContext(new FrontEndRuntimeContext(5));
// do something
$this->Application->applyRuntimeContext($backup);

Plan:

  1. create "kApplication::themePath" public property and use it instead of THEMES_PATH constant (keep constant for BC)
  2. create "kApplication::modRewrite" public property and use it instead of MOD_REWRITE constant (keep constant for BC)
  3. add "FrontEndRuntimeContext" class, that will be able to calculate values for "isAdmin", "themePath" and "modRewrite" application properties for a given theme
  4. add "AdminRuntimeContext" class, that will be able to calculate values for "isAdmin", "themePath" and "modRewrite" application properties for Admin Console
  5. change "kUrlManager::LoadStructureTemplateMapping" method to allow to be called several times in a row
  6. extract configuration code of "TemplatesCache" class, that depends on values changed by runtime context into separate "configure" method
  7. create "kApplication::applyRuntimeContext(AbstractRuntimeContext $runtime_context)" method, that will:
    1. set values of kApplication properties from matching properties of runtime context
    2. initialize "theme.current" object (front-end only)
    3. set "m_theme" request variable
    4. call "TemplatesCache::configure" method
    5. call "kUrlManager::LoadStructureTemplateMapping" method
    6. return runtime context that was used prior to this method was called

Related Tasks