public function calculateModuleTemplatePath($templateName)
    {
        $moduleList = $this->getModuleList();
        $theme = $this->getTheme();

        $moduleTemplates = $moduleList->getModuleTemplates();
        $activeModules = $moduleList->getActiveModuleInfo();
        $finalTemplatePath = '';

        if (is_array($moduleTemplates) && is_array($activeModules)) {
            foreach ($moduleTemplates as $sModuleId => $aTemplates) {
                // check if module is active
                if (isset($activeModules[$sModuleId])) {
                    $foundTemplate = null;
                    $fileSystem = $this->getFileSystem();

                    // check if template for our active themes exists
                    foreach ((array) $theme->getActiveThemesList() as $oneActiveThemeId) {
                        if (isset($aTemplates[$oneActiveThemeId], $aTemplates[$oneActiveThemeId][$templateName])) {
                            $foundTemplate = $fileSystem->combinePaths($this->getModulesPath(), $aTemplates[$oneActiveThemeId][$templateName]);
                        }
                    }

                    // if not found in theme specific configurations
                    if (!$foundTemplate && isset($aTemplates[$templateName])) {
                        $foundTemplate = $fileSystem->combinePaths($this->getModulesPath(), $aTemplates[$templateName]);
                    }

                    if ($foundTemplate) {
                        if ($fileSystem->isReadable($foundTemplate)) {
                            $finalTemplatePath = $foundTemplate;
                            break;
                        } else {
                            throw oxNew('oxException', sprintf('Cannot find template file "%s".', $foundTemplate));
                        }
                    }
                }
            }
        }

        if (!$finalTemplatePath) {
            throw oxNew('oxException', sprintf('Cannot find template "%s" in modules configuration.', $templateName));
        }

        return $finalTemplatePath;
    }