article = $article; return $tpl->render( 'articles/article' ); } /** * Renderuje liste artykulow w trybie miniaturek z pagerem. */ public static function miniatureArticlesList( $articles, $ls, $bs, $page ) { $out = ''; if ( is_array( $articles ) ) foreach ( $articles as $article ) { $tpl = new \Shared\Tpl\Tpl; $tpl->article = $article; $out .= $tpl->render( 'articles/article-miniature' ); } if ( $ls > 1 ) { $tpl = new \Shared\Tpl\Tpl; $tpl->ls = $ls; $tpl->bs = $bs ? $bs : 1; $tpl->page = $page; $out .= $tpl->render( 'site/pager' ); } return $out; } /** * Renderuje liste artykulow w trybie wprowadzen z pagerem. */ public static function entryArticlesList( $articles, $ls, $bs, $page ) { $tpl = new \Shared\Tpl\Tpl; $tpl->page_id = $page['id']; $tpl->articles = $articles; $out = $tpl->render( 'articles/articles-entries' ); if ( $ls > 1 ) { $tpl = new \Shared\Tpl\Tpl; $tpl->ls = $ls; $tpl->bs = $bs ? $bs : 1; $tpl->page = $page; $out .= $tpl->render( 'site/pager' ); } return $out; } /** * Renderuje liste pelnych artykulow z pagerem. */ public static function fullArticlesList( $articles, $ls, $bs, $page ) { $out = ''; if ( is_array( $articles ) ) foreach ( $articles as $article ) { $tpl = new \Shared\Tpl\Tpl; $tpl->article = $article; $out .= $tpl->render( 'articles/article-full' ); } if ( $ls > 1 ) { $tpl = new \Shared\Tpl\Tpl; $tpl->ls = $ls; $tpl->bs = $bs ? $bs : 1; $tpl->page = $page; $out .= $tpl->render( 'site/pager' ); } return $out; } /** * Renderuje box z aktualnosciami. */ public static function news( $page_id, $articles ) { $tpl = new \Shared\Tpl\Tpl; $tpl->page_id = $page_id; $tpl->articles = $articles; return $tpl->render( 'articles/news' ); } /** * Renderuje prosta liste artykulow (news-list). */ public static function newsList( $articles ) { return \Shared\Tpl\Tpl::view( 'articles/news-list', [ 'articles' => $articles ] ); } // ========================================================================= // UTILITY (czyste transformacje HTML, brak DB) // ========================================================================= /** * Generuje spis tresci z naglowkow HTML. */ public static function generateTableOfContents( $content ) { $result = ''; $currentLevel = []; preg_match_all( '/<(h[1-6])([^>]*)>(.*?)<\/\1>/', $content, $matches, PREG_SET_ORDER ); $firstLevel = true; foreach ( $matches as $match ) { $level = intval( substr( $match[1], 1 ) ); while ( $level < count( $currentLevel ) ) { $result .= ''; array_pop( $currentLevel ); } if ( $level > count( $currentLevel ) ) { while ( $level > count( $currentLevel ) ) { if ( count( $currentLevel ) > 0 || $firstLevel ) { $result .= '