Files
kobcrane-montaze.pl/autoload/admin/controls/class.Pages.php
Jacek Pyziak c9ed7b5d5d Add author management functionality and update routing rules
- Updated .htaccess rules to allow trailing slashes for specific routes.
- Introduced a new .gitignore file to exclude the cache directory.
- Created project configuration file for Serena with language and tool settings.
- Implemented Authors class for managing author data, including methods for saving, deleting, and editing authors.
- Added factory class for Authors to handle database interactions related to authors.
- Developed Article class to manage article data and interactions, including fetching articles and updating views.
- Created Page class with a placeholder method for sorting pages.
- Added front factory class for fetching author details with caching.
2026-02-27 11:28:56 +01:00

156 lines
5.6 KiB
PHP

<?php
namespace admin\controls;
class Pages
{
static public function pages_url_browser()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'pages/pages-browse-list', [
'menus' => \admin\factory\Pages::menus_list(),
'modal' => true
] );
}
static public function browse_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::browse_list(
\admin\factory\Pages::menus_list()
);
}
public static function menu_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Pages::menu_delete( \S::get( 'id' ) ) )
\S::set_message( 'Menu zostało usunięte.' );
else
\S::alert( 'Podczas usuwania menu wystąpił błąd. Aby usunąć menu nie może ono posiadać przypiętych stron.' );
header( 'Location: /admin/pages/view_list/' );
exit;
}
public static function page_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Pages::page_delete( \S::get( 'id' ) ) )
\S::set_message( 'Strona została usunięta.' );
else
\S::alert( 'Podczas usuwania strony wystąpił błąd. Aby usunąć stronę nie może ona posiadać przypiętych podstron.' );
header( 'Location: /admin/pages/view_list/' );
exit;
}
public static function page_articles()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::page_articles( \S::get( 'id' ),
\admin\factory\Pages::page_articles( \S::get( 'id' ) ) );
}
public static function page_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania strony wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $id = \admin\factory\Pages::page_save(
$values['id'], $values['title'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['menu_id'],
$values['parent_id'], $values['page_type'], $values['sort_type'], $values['layout_id'], $values['articles_limit'], $values['show_title'],
$values['status'], $values['link'], $values['noindex'], $values['start'], $values['site_title'], $values['block_direct_access'], $values['cache'], $values['canonical']
) )
$response = [ 'status' => 'ok', 'msg' => 'Strona została zapisana.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function page_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::page_edit(
\admin\factory\Pages::page_details(
\S::get( 'id' )
), \S::get( 'pid' ), \S::get( 'menu_id' ),
\admin\factory\Pages::menu_lists(),
\admin\factory\Layouts::layouts_list(),
\admin\factory\Languages::languages_list(),
\admin\factory\Settings::settings_details()
);
}
public static function menu_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania menu wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( \admin\factory\Pages::menu_save( $values['id'], $values['name'],
$values['status'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Menu zostało zapisane.' ];
echo json_encode( $response );
exit;
}
public static function menu_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::menu_edit(
\admin\factory\Pages::menu_details( \S::get( 'id' ) )
);
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::pages_list(
\admin\factory\Pages::menus_list()
);
}
}
?>