* @license MIT License * @link http://marcel-kapfer.de/rangitaki */ class BlogListGenerator { /** * A function to generate a blog nav item * * @param string $directory The directory of the blog file * @param string $blogname The name of the blog file * @param string $blogmaintitle The name of the main blog */ function listBlog($directory, $blogname, $blogmaintitle) { $blog = file_get_contents($directory . $blogname); // get content of the blog file $blog = $blog . "\n"; // add a line break as a security measurement if (substr($blog, 0, 6) == "%TITLE") { // check if the first line includes a title $blog = substr($blog, 8, strpos($blog, "\n") - 8); // grab the title if ($blog == "main") { // if on main blog echo "$blogmaintitle"; // create a nav item to the main blog } else { $link = "./?blog=" . substr($blogname, 0, -3); // create a link to the blog echo "$blog"; // create a nav item to the blog } } } /** * A function to get the name of a blog * * @param string $file The path of the blog file * @return string */ function getName($file) { $blog = file_get_contents($file); // get the content of the blog file $blog = $blog . "\n"; // add a line break as a securit measure if(substr($blog, 0, 6) == "%TITLE") { // check if first line includes a title $blog = substr($blog, 8, strpos($blog, "\n") - 8); // grab the title return $blog; // return it } } }