Files
cmsPRO/admin/ajax/pages.php
2026-02-22 21:59:33 +01:00

92 lines
2.6 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('lang'), \S::get('pid')))
$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);
}
if ( $a == 'google_url_preview' )
{
$settings = \front\factory\Settings::settings_details();
$structure = $settings['links_structure'];
if ( $structure )
{
if ( \S::get( 'page_id' ) )
{
$seo_link = \admin\factory\Pages::google_url_preview(\S::get('page_id'), \S::get('title'), \S::get('lang_id'), \S::get('pid'), 0, \S::get('seo_link'));
echo $seo_link;
}
else
{
$seo_link = \admin\factory\Pages::google_url_preview(0, \S::get('title'), \S::get('lang_id'), \S::get('pid'), \S::max_db_value('pp_pages', 'id') + 1, \S::get('seo_link'));
echo $seo_link;
}
}
else
{
if ( \S::get( 'seo_link' ) )
echo \S::get( 'seo_link' );
else
{
if ( \S::get( 'page_id' ) )
echo $prefix . 's-' . \S::get('page_id') . '-' . \S::seo(\S::get('title'));
else
echo $prefix . 's-' . ( \S::max_db_value('pp_pages', 'id') + 1 ) . '-' . \S::seo(\S::get('title'));
}
}
}