*/ class ArticleGenerator { function newArticle($directory, $articlefile, $blog) { $article = file_get_contents($directory . $articlefile); echo "
"; if(substr($article, 0, 6) == "%TITLE"){ $title = substr($article, 8, strpos($article, "\n") - 8); if($blog == ""){ $link = "./?article=" . substr($articlefile, 0, -3); } else { $link = "./?blog=$blog&article=" . substr($articlefile, 0, -3); } echo "

$title

"; $article = substr($article, strpos($article, "\n") + 1); } if(substr($article, 0, 5) == "%DATE"){ $date = substr($article, 7, strpos($article, "\n") - 7); echo "$date"; $article = substr($article, strpos($article, "\n") + 1); } if(substr($article, 0, 7) == "%AUTHOR"){ $author = substr($article, 9, strpos($article, "\n") - 9); $article = substr($article, strpos($article, "\n") + 1); } if(substr($article, 0, 5) == "%TAGS"){ $tags = substr($article, 7, strpos($article, "\n") - 7); $tags = explode(", ", $tags); $article = substr($article, strpos($article, "\n") + 1); } //TODO Code detection echo Parsedown::instance() ->setBreaksEnabled(true) ->text($article); echo "$author
"; foreach ($tags as $tag) { if($_GET['blog'] == ""){ echo "$tag "; } else { echo "$tag "; } } echo "
"; echo "
" . "\n"; } function getTags($directory, $articlefile){ $article = file_get_contents($directory . $articlefile); if(substr($article, 0, 6) == "%TITLE"){ $article = substr($article, strpos($article, "\n") + 1); } if(substr($article, 0, 5) == "%DATE"){ $article = substr($article, strpos($article, "\n") + 1); } if(substr($article, 0, 7) == "%AUTHOR"){ $article = substr($article, strpos($article, "\n") + 1); } if(substr($article, 0, 5) == "%TAGS"){ $tags = substr($article, 7, strpos($article, "\n") - 7); $tags = explode(", ", $tags); } return $tags; } }