Move article save/delete logic from monolithic factory to ArticleRepository with DI-based controller actions, following the established refactoring pattern. - ArticleRepository: add save() with 9 private helpers, archive() method - ArticlesController: add save() and delete() actions with DI - Factory methods delegate to repository (backward compatibility) - Router: add article_save/article_delete action mappings - Old controls methods marked @deprecated - 59 tests, 123 assertions passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84 lines
3.0 KiB
PHP
84 lines
3.0 KiB
PHP
<?php
|
|
namespace admin\controls;
|
|
|
|
class Articles
|
|
{
|
|
public static function gallery_order_save()
|
|
{
|
|
if ( \admin\factory\Articles::gallery_order_save( \S::get( 'article_id' ), \S::get( 'order' ) ) )
|
|
echo json_encode( [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.' ] );
|
|
|
|
exit;
|
|
}
|
|
|
|
public static function browse_list()
|
|
{
|
|
return \admin\view\Articles::browse_list();
|
|
}
|
|
|
|
/**
|
|
* @deprecated Routing kieruje do admin\Controllers\ArticlesController::delete().
|
|
* Ta metoda pozostaje tylko jako fallback dla starej architektury.
|
|
*/
|
|
public static function article_delete()
|
|
{
|
|
if ( \admin\factory\Articles::articles_set_archive( \S::get( 'id' ) ) )
|
|
\S::alert( 'Artykuł został przeniesiony do archiwum.' );
|
|
header( 'Location: /admin/articles/view_list/' );
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* @deprecated Routing kieruje do admin\Controllers\ArticlesController::save().
|
|
* Ta metoda pozostaje tylko jako fallback dla starej architektury.
|
|
*/
|
|
public static function article_save()
|
|
{
|
|
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania artykułu wystąpił błąd. Proszę spróbować ponownie.' ];
|
|
$values = json_decode( \S::get( 'values' ), true );
|
|
|
|
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_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['block_direct_access']
|
|
) )
|
|
$response = [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.', 'id' => $id ];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* @deprecated Routing kieruje do admin\Controllers\ArticlesController::edit().
|
|
* Ta metoda pozostaje tylko jako fallback dla starej architektury.
|
|
*/
|
|
public static function article_edit() {
|
|
global $user;
|
|
|
|
if ( !$user ) {
|
|
header( 'Location: /admin/' );
|
|
exit;
|
|
}
|
|
|
|
\admin\factory\Articles::delete_nonassigned_images();
|
|
\admin\factory\Articles::delete_nonassigned_files();
|
|
|
|
return \Tpl::view( 'articles/article-edit', [
|
|
'article' => \admin\factory\Articles::article_details( (int)\S::get( 'id' ) ),
|
|
'menus' => \admin\factory\Pages::menus_list(),
|
|
'languages' => \admin\factory\Languages::languages_list(),
|
|
'layouts' => \admin\factory\Layouts::layouts_list(),
|
|
'user' => $user
|
|
] );
|
|
}
|
|
|
|
/**
|
|
* @deprecated Routing kieruje do admin\Controllers\ArticlesController::list().
|
|
* Ta metoda pozostaje tylko jako fallback dla starej architektury.
|
|
*/
|
|
public static function view_list()
|
|
{
|
|
return \admin\view\Articles::articles_list();
|
|
}
|
|
}
|
|
?>
|