Esempio n. 1
0
function _package_edition_package_list_xml($base, $edition_tag, $url_root = '', $cdn = '', $output = 'string', $timestamp = '*', $content_xml_url = "content.xml")
{
    $url_root = pugpig_strip_domain($url_root);
    $contents = _package_edition_package_contents($base, $edition_tag, $timestamp);
    if (!file_exists($contents['html_archive'])) {
        return NULL;
    }
    $total_size = 0;
    //$content_xml = "content.xml";
    $d = new DomDocument('1.0', 'UTF-8');
    $d->formatOutput = TRUE;
    $package = $d->createElement('package');
    $package->setAttribute('root', $content_xml_url);
    $comment = "Generated: " . date(DATE_RFC822);
    $package->appendChild($d->createComment($comment));
    $part = $d->createElement('part');
    $part->setAttribute('name', 'html');
    $part->setAttribute('src', $url_root . $contents['html_url']);
    $part->setAttribute('size', $contents['html_size']);
    $total_size += $contents['html_size'];
    $part->setAttribute('modified', gmdate(DATE_ATOM, $contents['html_timestamp']));
    $package->appendChild($part);
    if (is_numeric($contents['assets_size']) && $contents['assets_size'] > 0) {
        $part = $d->createElement('part');
        $part->setAttribute('name', 'assets');
        $part->setAttribute('src', $cdn . $url_root . $contents['assets_url']);
        $part->setAttribute('size', $contents['assets_size']);
        $total_size += $contents['assets_size'];
        $part->setAttribute('modified', gmdate(DATE_ATOM, $contents['assets_timestamp']));
        $package->appendChild($part);
    }
    $package->setAttribute('size', $total_size);
    $d->appendChild($package);
    if ($output == 'string') {
        return $d->saveXML();
    } else {
        $d->save($output);
        return $output;
    }
}
function _package_edition_package_list_xml_using_files($base, $edition_tag, $url_root = '', $cdn = '', $output_type = 'string', $timestamp = '*', $content_xml_url = "content.xml")
{
    $content = _package_edition_package_contents($base, $edition_tag, $timestamp);
    $bucket_infos = array();
    $url_root_without_domain = pugpig_strip_domain($url_root);
    foreach ($content as $key => $values) {
        if ($key === 'xml_timestamp' || endsWith($key, '_size') || endsWith($key, '_is_cdn')) {
            continue;
        }
        $bucket_infos[$key] = array('zips' => array(), 'is_cdn' => empty($content[$key . '_is_cdn']) ? false : $content[$key . '_is_cdn']);
        foreach ($values as $value) {
            $bucket_infos[$key]['zips'][] = $value['archive'];
        }
    }
    return _package_edition_package_list_xml_core($base, $edition_tag, $bucket_infos, $url_root, $cdn, $output_type, $timestamp, $content_xml_url);
}