function print_page($subtitle, $body, $fragment) { $uri = 'http://' . $_SERVER["HTTP_HOST"] . preg_replace('/\\?.*$/', '', $_SERVER["REQUEST_URI"]); $canonical = $uri . "#!" . $fragment; $html = file_get_contents('print-template.html'); echo preg_replace(array('/\\{subtitle}/', '/\\{body}/', '/\\{canonical}/'), array($subtitle, fix_links($body), $canonical), $html); }
function print_index_page() { echo fix_links(file_get_contents("index-template.html")); }
$page = preg_replace('@' . $reference . '([^0-9])@', "<a href='{$url}'>{$reference}</a>\${1}", $page); } // Check to see if there are any back-references on this page. $this_page_url = '../' . $file; if (array_key_exists($this_page_url, $backlink_references)) { foreach ($backlink_references[$this_page_url] as $reference_label) { $backlink_url = $backlink_reference_map[$reference_label]; $reference_number = preg_replace('@[^-]*-@', '', $reference_label); // First, check to see if the back link already exists on the page. preg_match('@\\<a href="' . $backlink_url . '">\\s*<span[^>]*>' . $reference_number . '@im', $page, $matches); if (empty($matches)) { $page = preg_replace('@(\\<span[^>]*>' . $reference_number . '\\</span>)@', '<a href="' . $backlink_url . '">${1}</a>', $page); } } } $page = fix_links($page); // Remove any unreplaced page references; most of these were // probably linked in error. $page = preg_replace('@<a href="../###_[^"]*">([^<]*)</a>@', '${1}', $page); // Remove any links to the page that we are currently on. This // is typically just the page number at the bottom of the page. $page = preg_replace('@<a href="' . $this_page_url . '">([^<]*)</a>@', '${1}', $page); if ($singlepage && basename($file) != 'index.htm') { file_put_contents($singlepage, convert_singlepage($page, $input), FILE_APPEND); } file_put_contents($output, $page); $count++; //if ($count > 4) { // exit(0); //} }