function display() { // TODO: Specifying the version only works *after* a release, as // new libraries will still have develop/master as their // version. This works for now as version is always // master/develop, but might change in the future. $version = BoostVersion::from(array_key_exists('version', $this->args) ? $this->args['version'] : 'master'); $page = $this->args['page']; $libs = BoostLibraries::load(); $categorized = $libs->get_categorized_for_version($version, 'name', 'BoostLibraries::filter_released'); // TODO: Shouldn't really have to sort this here. uasort($categorized, function ($a, $b) { $a = $a['title']; $b = $b['title']; if ($a === 'Miscellaneous') { $a = 'ZZZZZZZZ'; } if ($b === 'Miscellaneous') { $b = 'ZZZZZZZZ'; } return $a > $b ?: ($a < $b ? -1 : 0); }); $alphabetic = $libs->get_for_version($version, 'name', 'BoostLibraries::filter_released'); $params = array('categorized' => array(), 'alphabetic' => array(), 'unreleased_libs' => array(), 'unreleased_lib_count' => 0); foreach ($categorized as $category) { $template_value = $category; $template_value['libraries'] = array(); foreach ($category['libraries'] as $index => $library) { $template_value['libraries'][] = $this->rewrite_library($library, $index); } $params['categorized'][] = $template_value; } foreach ($alphabetic as $index => $library) { $params['alphabetic'][] = $this->rewrite_library($library, $index); } if ($version->is_unreleased()) { $index = 0; foreach ($alphabetic as $library) { if ($library['boost-version']->is_unreleased() || $library['boost-version']->is_beta()) { $params['unreleased_libs'][] = $this->rewrite_library($library, $index++); } } } else { $index = 0; foreach ($alphabetic as $library) { if ($library['boost-version']->major() == $version->major() && $library['boost-version']->minor() == $version->minor()) { $params['unreleased_libs'][] = $this->rewrite_library($library, $index++); } } } $params['unreleased_lib_count'] = count($params['unreleased_libs']); // Better support for other branches? $template_dir = BOOST_REPOS_DIR . '/boost-' . ((string) $version == 'develop' ? 'develop' : 'master') . '/' . $page; echo BoostSimpleTemplate::render(file_get_contents($template_dir), $params); }
function load($path) { $realpath = $this->normalize_path($path); if ($realpath) { if (array_key_exists($realpath, $this->cache)) { return $this->cache[$realpath]; } else { if (is_file($realpath)) { return $this->cache[$realpath] = BoostSimpleTemplate::parse_template(file_get_contents($realpath)); } else { return $this->cache[$realpath] = null; } } } else { return null; } }