Files
marianek.pl/admin/ajax/pages.php
2024-10-25 23:02:37 +02:00

64 lines
1.8 KiB
PHP

<?php
$a = \S::get( 'a' );
if ( $a == 'save_articles_order' )
{
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kolejności wyświetlania artykułów wystąpił błąd. Proszę spróbować ponownie.' ];
if ( \admin\factory\Pages::save_articles_order( \S::get( 'page_id' ), \S::get( 'articles' ) ) )
$response = [ 'status' => 'ok' ];
echo json_encode( $response );
exit;
}
if ( $a == 'save_pages_order' )
{
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kolejności stron wystąpił błąd. Proszę spróbować ponownie.' ];
if ( \admin\factory\Pages::save_pages_order( \S::get( 'menu_id' ), \S::get( 'pages' ) ) )
$response = [ 'status' => 'ok' ];
echo json_encode( $response );
exit;
}
if ( $a == 'generate_seo_link' )
{
$response = [ 'status' => 'error', 'msg' => 'Podczas generowania pola "seo link" wystąpił błąd. Proszę spróbować ponownie.' ];
if ( $seo_link = \admin\factory\Pages::generate_seo_link( \S::get( 'title' ), \S::get( 'page_id' ), \S::get( 'article_id' ), \S::get( 'category_id' ) ) )
$response = [ 'status' => 'ok', 'seo_link' => $seo_link ];
echo json_encode( $response );
exit;
}
if ( $a == 'cookie_menus' )
{
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
if ( $array[ \S::get( 'menu_id' ) ] == 0 )
$array[ \S::get( 'menu_id' ) ] = 1;
else
$array[ \S::get( 'menu_id' ) ] = 0;
$array = serialize( $array );
setcookie( 'cookie_menus', $array, time() + 3600 * 24 * 365 );
}
if ( $a == 'cookie_pages' )
{
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
if ( $array[ \S::get( 'page_id' ) ] == 0 )
$array[ \S::get( 'page_id' ) ] = 1;
else
$array[ \S::get( 'page_id' ) ] = 0;
$array = serialize( $array );
setcookie( 'cookie_pages', $array, time() + 3600 * 24 * 365 );
}