<?php

class Waindigo_InstallUpgrade_ViewAdmin_AddOn_Download extends XenForo_ViewAdmin_Base
{

    public function renderRaw()
    {
        $addOn = $this->_params['addOn'];
        $zipFile = $this->_params['zipFile'];

        $zipFilename = 'addon-' . $addOn['addon_id'] . '-' . $addOn['version_string'] . '.' . $zipFile['last_modified'] .
             '.zip';

        $this->_response->setHeader('Content-type', 'application/octet-stream', true);
        $this->setDownloadFileName($zipFilename);

        $this->_response->setHeader('Content-Length', strlen($zipFile['contents']), true);
        $this->_response->setHeader('Last-Modified', date('r', $zipFile['last_modified']), true);

        echo $zipFile['contents'];
    }
}