public function getThemeTemplates($themeName)
 {
     $path = FilesHelper::normalizePath(getThemeDir($themeName . _PREVIEW_SUFFIX_)) . '/templates/templates.php';
     if (file_exists($path)) {
         // TODO: Maybe we have to store all html and parse them after each update or export operation for backward
         require_once $path;
     } else {
         $templates = getTemplates();
         // backward with old themes which do not have templates.php file but plugin is already updated
     }
     $context = Context::getContext();
     $link = $context->link;
     $controllers = getTemplateControllers();
     $previewParam = 'theme_name=' . $themeName;
     $result = array();
     foreach ($templates as $type => $template) {
         $controller = $controllers[$type];
         $method = 'get' . $controller . 'Link';
         if (method_exists($link, $method)) {
             $lower = strtolower($controller);
             $item = Designer::getFirstItem($lower);
             if ($item > 0) {
                 $baseUrl = $link->{$method}($item);
                 $pos = strpos($baseUrl, '?');
                 if ($pos !== FALSE) {
                     // HACK: preview parameter must be first in URL in Debug mode
                     $mainPart = substr($baseUrl, 0, $pos);
                     $params = substr($baseUrl, $pos + 1);
                     $templateUrl = $mainPart . '?' . $previewParam . '&' . $params;
                 } else {
                     $templateUrl = $baseUrl . '?' . $previewParam;
                 }
             } else {
                 $templateUrl = $link->getPageLink('index') . '?' . $previewParam . '&missingContent=' . $lower;
             }
         } else {
             $templateUrl = $link->getPageLink($controller);
             if (strpos($templateUrl, $previewParam) === FALSE) {
                 // can be set in some case from Dispatcher.php
                 $templateUrl .= (strpos($templateUrl, '?') !== FALSE ? '&' : '?') . $previewParam;
             }
         }
         if (is_array($template)) {
             // updated theme with templates.php file
             foreach ($template as $t) {
                 $result[$t['name']] = $templateUrl . '&template=' . $type . '_' . $t['id'];
                 // format as {templateName_id.tpl}
             }
         } else {
             // backward with old themes which do not have templates.php file but plugin is already updated
             $result[$type] = $templateUrl;
         }
     }
     return $result;
 }
function getTemplateVars()
{
    $vars = array();
    $controllers = getTemplateControllers();
    foreach (Theme::getAvailable(false) as $themeName) {
        $themeDir = getThemeDir($themeName);
        $path = $themeDir . '/templates/templates.php';
        if (file_exists($path)) {
            require_once $path;
        }
        foreach ($controllers as $type => $controller) {
            $name = getTemplateName($themeName, $type);
            $value = Configuration::get($name, false);
            if (!$value && isset($templates)) {
                // template settings has not been saved to database yet or it's preview theme
                foreach ($templates[$type] as $t) {
                    if (isset($t['name']) && $t['name'] == $type) {
                        $value = $type . '_' . $t['id'];
                    }
                }
            }
            if ($value) {
                $c = strtolower($controller);
                $vars[$themeName][$c] = $value;
            }
        }
    }
    return $vars;
}
function getTemplateVars()
{
    $vars = array();
    $templates = getTemplateControllers();
    foreach (Theme::getAvailable(false) as $themeName) {
        foreach ($templates as $type => $controller) {
            $name = getTemplateName($themeName, $type);
            $value = Configuration::get($name);
            if ($value) {
                $c = strtolower($controller);
                $vars[$themeName][$c] = $value;
            }
        }
    }
    return $vars;
}