Admin_ThemesController::exportAction PHP Метод

exportAction() публичный Метод

public exportAction ( )
    public function exportAction()
    {
        $translator = \Zend_Registry::get('container')->getService('translator');
        $erro_msg = $translator->trans('Theme export was not successful. Check please that the server is not out of disk space.', array(), 'themes');
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
        if ($themeId = $this->_getParam('id', null)) {
            // it looks that a problem could happen here if the server is out of its disk space
            try {
                $exportPath = $this->getThemeService()->exportTheme($themeEntity = $this->getThemeService()->findById($themeId), $erro_msg);
                if (false === $exportPath) {
                    die($erro_msg);
                }
                // the Content-Type header would be set wrongly at ContentType.php
                $GLOBALS['header_content_type_set'] = true;
                // Chrome complains when the Content-Disposition header is set by Zend.
                $theme_name = trim(str_replace(array('"', ' '), array('_', '_'), $themeEntity->getName()));
                header('Content-Disposition: attachment; filename="' . $theme_name . '.zip"');
                $this->getResponse()->setHeader('Content-type', 'application/zip')->setHeader('Content-length', filesize($exportPath))->setHeader('Cache-control', 'private');
                if (!@readfile($exportPath)) {
                    die($erro_msg);
                }
                $this->getResponse()->sendResponse();
            } catch (Exception $exc) {
                echo $erro_msg;
            }
        }
    }