public function initContent()
 {
     parent::initContent();
     theme_check_memory_limit(true);
     if (Tools::getIsset('invalid_urls')) {
         // base and server urls have to start with the same symbols
         $this->errors[] = $this->l(sprintf('An error has occurred. The Themler start URL %s does not match Shop Domain or SSL Domain %s. This may be due to one of the following reasons: 1. server protocol does not match (HTTP/HTTPS) 2. www prefix is missing in one of the links', $this->_serverUrl . $_SERVER['REQUEST_URI'], $this->_baseUrl));
     }
     if (Tools::getIsset('invalid_php_version')) {
         $this->errors[] = $this->l(sprintf('Unable to open theme. Your server is running php version %s but Themler requires %s or higher. Please upgrade PHP version to continue.', $this->_php_version, $this->_required_php_version));
     }
     if (Tools::getIsset('no_project')) {
         $this->errors[] = $this->l(sprintf('The theme `%s` cannot be opened because /project/project.json file is missing or corrupted.', $this->_getThemeName()));
     }
     if ($this->ajax) {
         try {
             $themeName = $this->_getThemeName();
             $this->_checkPermissions($themeName);
             moveInnerPreview($themeName);
             $data = $this->_getThemlerData($themeName);
             echo $this->_buildPage($themeName);
         } catch (PermissionsException $e) {
             die(buildErrorsPage($e->getMessage()));
         }
     } else {
         $edit = Tools::getValue('edit', '');
         if (!empty($edit)) {
             $title = $this->l('Slider settings');
             $this->content .= $this->renderThemeSettingsForm();
         } else {
             $title = $this->l('List of Themes');
             $this->content .= $this->_formRendererHelper->renderThemesListForm($this->getThemesInfo());
         }
         $this->context->smarty->assign(array('content' => $this->content, 'title' => $title));
     }
 }
function theme_out_of_memory_handler($cannot_allocate)
{
    if ($cannot_allocate) {
        $msg = <<<EOL
            <h3>PHP Memory Configuration Error</h3>

            <p>Themler requires at least 64Mb of PHP memory. Please increase your PHP memory to continue.
            For more information, please check this <a href="http://answers.billiondigital.com/articles/5826/out-of-memory" target="_blank">link</a>.</p>
EOL;
    } else {
        $current_memory = get_memory_limit() / 1024 / 1024 . 'Mb';
        $msg = <<<EOL
            <h3>PHP Memory Configuration Error</h3>

            <p>Themler requires at least 64Mb of PHP memory (you have "{$current_memory}"). Please increase your PHP memory to continue.
            For more information, please check this <a href="http://answers.billiondigital.com/articles/5826/out-of-memory" target="_blank">link</a>.</p>
EOL;
    }
    $page = buildErrorsPage($msg);
    die($page);
}