root = $path; BoostSiteTools_Upgrades::upgrade($this); } function load_pages() { return new BoostPages($this->root); } function refresh_quickbook() { $this->update_quickbook(true); } function update_in_progress_pages() { $pages = $this->load_pages(); $pages->scan_for_new_quickbook_pages(); $pages->convert_quickbook_pages('in_progress'); $pages->save(); } function update_quickbook($refresh = false) { $pages = $this->load_pages(); if (!$refresh) { $pages->scan_for_new_quickbook_pages(); $pages->save(); } // Translate new and changed pages $pages->convert_quickbook_pages($refresh ? 'refresh' : 'update'); // Extract data for generating site from $pages: $history_pages = array(); $released_versions = array(); $beta_versions = array(); $all_versions = array(); $all_downloads = array(); $news = array(); foreach($pages->reverse_chronological_pages() as $page) { switch($page->section) { case 'news': if ($page->is_published()) { $news[] = $page; } break; case 'history': if ($page->is_published()) { $all_versions[] = $page; if (!$page->is_release) { $history_pages[] = $page; $news[] = $page; } else { if ($page->is_published('released')) { $all_downloads[] = $page; $history_pages[] = $page; $released_versions[] = $page; $news[] = $page; } else if ($page->is_published('beta')) { $beta_versions[] = $page; } } } break; case 'downloads': if ($page->is_published('released')) { $all_downloads[] = $page; } break; default: echo "Unknown website section: {$page->section}.\n"; break; } } $released_versions_entries = array_map(function ($x) { return $x->index_info(); }, $released_versions); $beta_versions_entries = array_map(function ($x) { return $x->index_info(); }, $beta_versions); $history_pages_entries = array_map(function ($x) { return $x->index_info(); }, $history_pages); $news_entries = array_map(function ($x) { return $x->index_info(); }, $news); $downloads = array_filter(array( $this->get_downloads('live', 'Current', $released_versions_entries, 1), $this->get_downloads('beta', 'Beta', $beta_versions_entries), )); $index_page_variables = array( 'history_pages' => $history_pages_entries, 'news' => $news_entries, 'downloads' => $downloads, ); // Generate 'Index' pages BoostPages::write_template( "{$this->root}/generated/download-items.html", __DIR__.'/templates/download.php', $index_page_variables); BoostPages::write_template( "{$this->root}/generated/history-items.html", __DIR__.'/templates/history.php', $index_page_variables); BoostPages::write_template( "{$this->root}/generated/news-items.html", __DIR__.'/templates/news.php', $index_page_variables); BoostPages::write_template( "{$this->root}/generated/home-items.html", __DIR__.'/templates/index.php', $index_page_variables); # Generate RSS feeds if (!$refresh) { $rss = new BoostRss($this->root, "generated/state/rss-items.txt"); $rss->generate_rss_feed($pages, array( 'path' => 'generated/downloads.rss', 'link' => 'users/download/', 'title' => 'Boost Downloads', 'pages' => $all_downloads, 'count' => 3 )); $rss->generate_rss_feed($pages, array( 'path' => 'generated/history.rss', 'link' => 'users/history/', 'title' => 'Boost History', 'pages' => $history_pages, )); $rss->generate_rss_feed($pages, array( 'path' => 'generated/news.rss', 'link' => 'users/news/', 'title' => 'Boost News', 'pages' => $news, 'count' => 5 )); $rss->generate_rss_feed($pages, array( 'path' => 'generated/dev.rss', 'link' => '', 'title' => 'Release notes for work in progress boost', 'pages' => $all_versions, 'count' => 5 )); } # Create a list of release in reverse version order # # This is normally the default order, but it's possible that a point # release might be released after a later major release. $releases_by_version = $released_versions; usort($releases_by_version, function($x, $y) { $x_has_version = array_key_exists('version', $x->release_data); $y_has_version = array_key_exists('version', $y->release_data); if (!$x_has_version) { return $y_has_version ? 1 : 0; } if (!$y_has_version) { return -1; } return $y->release_data['version']->compare( $x->release_data['version']); }); $latest_version = $releases_by_version[0]->release_data['version']; # Write out the current version for reference file_put_contents(__DIR__.'/../../generated/current_version.txt', $latest_version); # Update doc/.htaccess $final_doc_dir = $latest_version->final_doc_dir(); $redirect_block = "# REDIRECT_UPDATE_START\n"; $redirect_block .= "#\n"; $redirect_block .= "# This section is automatically updated.\n"; $redirect_block .= "# Any edits will be overwritten.\n"; $redirect_block .= "#\n"; $redirect_block .= "# Redirect from symbolic names to current versions.\n"; $redirect_block .= "RewriteRule ^libs/release(/.*)?\\\$ libs/{$final_doc_dir}\\\$1 [R=303]\n"; $redirect_block .= "RewriteRule ^libs/development(/.*)?\\\$ libs/{$final_doc_dir}\\\$1 [R=303]\n"; $redirect_block .= "#\n"; $redirect_block .= "# REDIRECT_UPDATE_END\n"; $htaccss_file = __DIR__.'/../../doc/.htaccess'; $htaccess = file_get_contents($htaccss_file); $count = 0; $htaccess = preg_replace( '@^# REDIRECT_UPDATE_START$.*^# REDIRECT_UPDATE_END$\n@ms', $redirect_block, $htaccess, -1, $count); if ($count != 1) { throw new BoostException("Error updating doc/.htaccess"); } file_put_contents($htaccss_file, $htaccess); # Generate documentation list $documentation_list = <<Documentation >