Refactor article_save method to include show_table_of_contents and date_modify parameters
This commit is contained in:
@@ -98,8 +98,8 @@ class Articles
|
||||
$values['params'] = $params;
|
||||
|
||||
if ( $id = \admin\factory\Articles::article_save(
|
||||
$values['id'], $values['title'], $values['main_image'], $values['entry'], $values['text'], $values['table_of_contents'], $values['status'], $values['show_title'], $values['show_date_add'], $values['date_add'],
|
||||
$values['show_date_modify'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['layout_id'],
|
||||
$values['id'], $values['title'], $values['main_image'], $values['entry'], $values['text'], $values['table_of_contents'], $values['status'], $values['show_title'], $values['show_table_of_contents'], $values['show_date_add'], $values['date_add'],
|
||||
$values['show_date_modify'], $values['date_modify'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['layout_id'],
|
||||
$values['pages'], $values['noindex'], $values['repeat_entry'], $values['copy_from'], $values['social_icons'], $values['event_date'], $values['hidden-tags'], $values['block_direct_access'],
|
||||
$values['priority'], $values['password'], $values['pixieset'], $values['id_author'], $params
|
||||
) )
|
||||
|
||||
@@ -238,7 +238,7 @@ class Articles
|
||||
}
|
||||
|
||||
public static function article_save(
|
||||
$article_id, $title, $main_image, $entry, $text, $table_of_contents, $status, $show_title, $show_date_add, $date_add, $show_date_modify, $seo_link, $meta_title, $meta_description,
|
||||
$article_id, $title, $main_image, $entry, $text, $table_of_contents, $status, $show_title, $show_table_of_contents, $show_date_add, $date_add, $show_date_modify, $date_modify, $seo_link, $meta_title, $meta_description,
|
||||
$meta_keywords, $layout_id, $pages, $noindex, $repeat_entry, $copy_from, $social_icons, $event_date, $tags, $block_direct_access, $priority,
|
||||
$password, $pixieset, $id_author, $params )
|
||||
{
|
||||
@@ -251,10 +251,11 @@ class Articles
|
||||
{
|
||||
$mdb -> insert( 'pp_articles', [
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'show_table_of_contents' => $show_table_of_contents == 'on' ? 1 : 0,
|
||||
'show_date_add' => $show_date_add == 'on' ? 1 : 0,
|
||||
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
|
||||
'date_add' => $date_add ? $date_add : date( 'Y-m-d H:i:s' ),
|
||||
'date_modify' => $date_add ? $date_add : date( 'Y-m-d H:i:s' ),
|
||||
'date_add' => date( 'Y-m-d H:i:s' ),
|
||||
'date_modify' => date( 'Y-m-d H:i:s' ),
|
||||
'modify_by' => $user['id'],
|
||||
'layout_id' => $layout_id ? (int)$layout_id : null,
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
@@ -435,9 +436,11 @@ class Articles
|
||||
{
|
||||
$mdb -> update( 'pp_articles', [
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'show_table_of_contents' => $show_table_of_contents == 'on' ? 1 : 0,
|
||||
'show_date_add' => $show_date_add == 'on' ? 1 : 0,
|
||||
'date_add' => $date_add,
|
||||
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
|
||||
'date_modify' => date( 'Y-m-d H:i:s' ),
|
||||
'date_modify' => $date_modify,
|
||||
'modify_by' => $user['id'],
|
||||
'layout_id' => $layout_id ? (int)$layout_id : null,
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
|
||||
@@ -13,14 +13,14 @@ class Scontainers
|
||||
public static function container_save( $container_id, $title, $text, $status, $show_title, $src, $html )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
|
||||
if ( !$container_id )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers',
|
||||
[
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'src' => $src
|
||||
$mdb -> insert( 'pp_scontainers', [
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'src' => $src,
|
||||
'last_update' => date( 'Y-m-d H:i:s' )
|
||||
] );
|
||||
|
||||
$id = $mdb -> id();
|
||||
@@ -32,13 +32,12 @@ class Scontainers
|
||||
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers_langs',
|
||||
[
|
||||
'container_id' => (int) $id,
|
||||
'lang_id' => $row['id'],
|
||||
'title' => $title[$i],
|
||||
'text' => $text[$i],
|
||||
'html' => $html[$i]
|
||||
$mdb -> insert( 'pp_scontainers_langs', [
|
||||
'container_id' => (int) $id,
|
||||
'lang_id' => $row['id'],
|
||||
'title' => $title[$i],
|
||||
'text' => $text[$i],
|
||||
'html' => $html[$i]
|
||||
] );
|
||||
$i++;
|
||||
}
|
||||
@@ -60,14 +59,13 @@ class Scontainers
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> update( 'pp_scontainers',
|
||||
[
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'src' => $src
|
||||
],
|
||||
[
|
||||
'id' => (int) $container_id
|
||||
$mdb -> update( 'pp_scontainers', [
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'src' => $src,
|
||||
'last_update' => date( 'Y-m-d H:i:s' )
|
||||
], [
|
||||
'id' => (int) $container_id
|
||||
] );
|
||||
|
||||
$mdb -> delete( 'pp_scontainers_langs',
|
||||
@@ -109,7 +107,7 @@ class Scontainers
|
||||
public static function container_details( $container_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
|
||||
$container = $mdb -> get( 'pp_scontainers', '*', [ 'id' => (int) $container_id ] );
|
||||
|
||||
$results = $mdb -> select( 'pp_scontainers_langs', '*', [ 'container_id' => (int) $container_id ] );
|
||||
|
||||
@@ -10,7 +10,7 @@ class Articles
|
||||
$tpl -> $key = $val;
|
||||
return $tpl -> render( 'articles/password-view' );
|
||||
}
|
||||
|
||||
|
||||
public static function map( $settings, $map_counter )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
@@ -18,19 +18,19 @@ class Articles
|
||||
$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;
|
||||
@@ -38,14 +38,14 @@ class Articles
|
||||
$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;
|
||||
@@ -53,26 +53,26 @@ class Articles
|
||||
$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;
|
||||
@@ -81,24 +81,24 @@ class Articles
|
||||
$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;
|
||||
@@ -107,28 +107,29 @@ class Articles
|
||||
$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
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> article = $article_details;
|
||||
$out .= $tpl -> render( 'articles/article-full' );
|
||||
{
|
||||
$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;
|
||||
@@ -137,7 +138,7 @@ class Articles
|
||||
$tpl -> page = $page;
|
||||
$out .= $tpl -> render( 'site/pager' );
|
||||
}
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user