ver. 0.280: Articles frontend migration, class.Article removal, Settings facade cleanup

- Add 8 frontend methods to ArticleRepository (with Redis cache)
- Create front\Views\Articles (rendering + utility methods)
- Rewire front\view\Site::show() and front\controls\Site::route() to repo + Views
- Update 5 article templates to use \front\Views\Articles::
- Convert front\factory\Articles and front\view\Articles to facades
- Remove class.Article (entity + static methods migrated to repo + Views)
- Remove front\factory\Settings facade (already migrated)
- Fix: eliminate global $lang from articleNoindex(), inline page sort query
- Tests: 450 OK, 1431 assertions (+13 new)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 15:52:03 +01:00
parent 3b32ea0b9b
commit 723cb1a5eb
35 changed files with 1070 additions and 642 deletions

View File

@@ -1,90 +1,57 @@
<?php
namespace front\view;
/**
* FASADA — deleguje do \Domain\Article\ArticleRepository i \front\Views\Articles
* Zachowana dla wstecznej kompatybilności. Nowy kod powinien używać bezpośrednio repo + Views.
*/
class Articles
{
public static function news( $page_id, $articles )
{
$tpl = new \Tpl;
$tpl -> page_id = $page_id;
$tpl -> articles = $articles;
return $tpl -> render( 'articles/news' );
return \front\Views\Articles::news( $page_id, $articles );
}
public static function full_article( $article_id, $lang_id )
{
$tpl = new \Tpl;
$tpl -> article = \front\factory\Articles::article_details( $article_id, $lang_id );
return $tpl -> render( 'articles/article' );
$repo = new \Domain\Article\ArticleRepository( $GLOBALS['mdb'] );
$article = $repo->articleDetailsFrontend( (int)$article_id, $lang_id );
return \front\Views\Articles::fullArticle( $article );
}
public static function miniature_articles_list( $page, $lang_id, $bs = 1 )
{
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
{
$tpl = new \Tpl;
$tpl -> article = \front\factory\Articles::article_details( $article, $lang_id );
$out .= $tpl -> render( 'articles/article-miniature' );
}
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
$tpl -> ls = $results['ls'];
$tpl -> bs = $bs ? $bs : 1;
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
return $out;
$repo = new \Domain\Article\ArticleRepository( $GLOBALS['mdb'] );
$results = $repo->pageArticles( $page, $lang_id, (int)$bs );
$articles = [];
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article_id )
$articles[] = $repo->articleDetailsFrontend( (int)$article_id, $lang_id );
return \front\Views\Articles::miniatureArticlesList( $articles, $results['ls'], $bs ?: 1, $page );
}
public static function entry_articles_list( $page, $lang_id, $bs = 1 )
{
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
$articles[] = \front\factory\Articles::article_details( $article, $lang_id );
$tpl = new \Tpl;
$tpl -> page_id = $page['id'];
$tpl -> articles = $articles;
$out .= $tpl -> render( 'articles/articles-entries' );
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
$tpl -> ls = $results['ls'];
$tpl -> bs = $bs ? $bs : 1;
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
return $out;
$repo = new \Domain\Article\ArticleRepository( $GLOBALS['mdb'] );
$results = $repo->pageArticles( $page, $lang_id, (int)$bs );
$articles = [];
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article_id )
$articles[] = $repo->articleDetailsFrontend( (int)$article_id, $lang_id );
return \front\Views\Articles::entryArticlesList( $articles, $results['ls'], $bs ?: 1, $page );
}
public static function full_articles_list( $page, $lang_id, $bs = 1 )
{
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
{
$tpl = new \Tpl;
$tpl -> article = \front\factory\Articles::article_details( $article, $lang_id );
$out .= $tpl -> render( 'articles/article-full' );
}
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
$tpl -> ls = $results['ls'];
$tpl -> bs = $bs ? $bs : 1;
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
return $out;
$repo = new \Domain\Article\ArticleRepository( $GLOBALS['mdb'] );
$results = $repo->pageArticles( $page, $lang_id, (int)$bs );
$articles = [];
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article_id )
$articles[] = $repo->articleDetailsFrontend( (int)$article_id, $lang_id );
return \front\Views\Articles::fullArticlesList( $articles, $results['ls'], $bs ?: 1, $page );
}
}
}