diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php index 07c63e4..ffdc71e 100644 --- a/Models/RecipeModel.php +++ b/Models/RecipeModel.php @@ -119,6 +119,15 @@ final class RecipeModel return round($avg*2)/2; } + + public function getAuthorOrAnon(){ + $O_author = self::getAuthor(); + if ($O_author === null) { + return UserModel::getAnonUser(); + } else { + return $O_author; + } + } public function getAuthor(){ if($this->O_AUTHOR === null){ diff --git a/Views/recipe/view.php b/Views/recipe/view.php index d95c2b4..1229232 100644 --- a/Views/recipe/view.php +++ b/Views/recipe/view.php @@ -35,14 +35,7 @@ $O_recipe = $A_view["RECIPE"]; - getAuthor(); - if($O_author === null) { - echo '
By an anonymous user
'; - } else { - echo 'By '.$O_author->S_USERNAME.'
'; - } - ?> +By = $O_recipe->getAuthorOrAnon()->S_USERNAME ?>