Files
inwestprofil.fr/autoload/front/view/class.Articles.php
Jacek Pyziak 86c704fd31 Add table of contents generation and header ID processing to Articles class
- Implemented `generateTableOfContents` method to create a structured table of contents from article content.
- Added `processHeaders` method to ensure headers have unique IDs for linking.
- Updated `generateHeadersIds` to apply ID generation to headers in article content.
- Modified `article_full` method to include table of contents in rendered articles.
- Enhanced `submenu_details` and `subpages` methods in Menu class to support language ID.
- Updated caching mechanisms to include language ID for subpages and menu details.
- Refactored various methods in Articles view class for improved readability and consistency.
- Added new sftp configuration file for deployment settings.
2026-03-05 22:38:16 +01:00

144 lines
4.0 KiB
PHP

<?php
namespace front\view;
class Articles
{
public static function password_view( $values )
{
$tpl = new \Tpl;
if ( is_array( $values ) ) foreach ( $values as $key => $val )
$tpl -> $key = $val;
return $tpl -> render( 'articles/password-view' );
}
public static function map( $settings, $map_counter )
{
$tpl = new \Tpl;
$tpl -> settings = $settings;
$tpl -> map_counter = $map_counter;
return $tpl -> render( 'articles/map' );
}
public static function tags_cloud()
{
global $settings;
if ( !$settings['tags'] )
return false;
$tpl = new \Tpl;
$tpl -> tags = \front\factory\Articles::tags();
return $tpl -> render( 'articles/tags-cloud' );
}
public static function news( $page_id, $articles )
{
$tpl = new \Tpl;
$tpl -> page_id = $page_id;
$tpl -> articles = $articles;
return $tpl -> render( 'articles/news' );
}
public static function articles_list( $articles )
{
$tpl = new \Tpl;
$tpl -> articles = $articles;
return $tpl -> render( 'articles/articles-list' );
}
public static function article( $values )
{
$tpl = new \Tpl;
if ( is_array( $values ) ) foreach ( $values as $key => $val )
$tpl -> $key = $val;
return $tpl -> render( 'articles/article' );
}
public static function article_full( $article_id, $lang_id )
{
$tpl = new \Tpl;
$tpl -> article = \front\factory\Articles::article_details( $article_id, $lang_id );
return $tpl -> render( 'articles/article-full' );
}
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 )
$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-miniatures' );
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;
}
public static function entry_articles_list( $page, $lang_id, $bs = 1 )
{
global $page;
$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;
}
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 )
{
$article_details = \front\factory\Articles::article_details( $article, $lang_id );
if ( $article_details['password'] and !\S::get_session( 'article-' . $article . '-' . $article_details['password'] ) )
$out .= \front\view\Articles::password_view( [ 'article' => $article ] );
else
{
$out .= \Tpl::view( 'articles/article-full', [
'article' => $article_details,
'table_of_contents' => \front\factory\Articles::generateTableOfContents( $article_details['language']['text'] )
] );
}
}
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;
}
}