generate() public method

输出字符串
public generate ( ) : string
return string
コード例 #1
0
ファイル: compile.php プロジェクト: joyqi/logecho
            if ('archive' != $type && !empty($post[$type])) {
                foreach ($post[$type] as $meta) {
                    $item['category'][] = ['feeds_url' => $meta['url'], 'name' => $meta['name']];
                }
            }
        }
        $feeds->addItem($item);
    }
    $target = $context->dir . '_target/' . $config['target'];
    $targetDir = dirname($target);
    if (!is_dir($targetDir)) {
        if (!mkdir($targetDir, 0755, true)) {
            le_fatal('feeds directory is not exists "%s"', $targetDir);
        }
    }
    file_put_contents($target, $feeds->generate());
});
// generate sitemap
le_add_workflow('generate_sitemap', function () use($context) {
    $fp = fopen($context->dir . '_target/sitemap.xml', 'wb');
    if (!$fp) {
        le_fatal('can not write sitemap.xml');
    }
    $base = isset($context->data['url']) ? rtrim($context->data['url'], '/') : '/';
    fwrite($fp, '<?xml version="1.0" encoding="UTF-8"?>
<urlset
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">');
    foreach ($context->sitemap as $url => $priority) {