98 lines
2.7 KiB
PHP
98 lines
2.7 KiB
PHP
<?
|
|
namespace controls;
|
|
class BackendSites
|
|
{
|
|
static public function topic_delete()
|
|
{
|
|
if ( \factory\BackendSites::topic_delete( \S::get( 'id' ) ) )
|
|
{
|
|
\S::alert( 'Temat został usunięty' );
|
|
header( 'Location: /backend_sites/topics/' );
|
|
exit;
|
|
}
|
|
else
|
|
{
|
|
\S::alert( 'Nie można usunąć tematu' );
|
|
header( 'Location: /backend_sites/topics/' );
|
|
exit;
|
|
}
|
|
}
|
|
|
|
static public function topic_accept()
|
|
{
|
|
if ( \factory\BackendSites::topic_accept( \S::get( 'id' ) ) )
|
|
{
|
|
\S::alert( 'Temat został zaakceptowany' );
|
|
header( 'Location: /backend_sites/topics/' );
|
|
exit;
|
|
}
|
|
}
|
|
|
|
static public function topic_unaccept()
|
|
{
|
|
if ( \factory\BackendSites::topic_unaccept( \S::get( 'id' ) ) )
|
|
{
|
|
\S::alert( 'Temat został odrzucony' );
|
|
header( 'Location: /backend_sites/topics/' );
|
|
exit;
|
|
}
|
|
}
|
|
|
|
static public function topic_save()
|
|
{
|
|
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania klienta wystąpił błąd. Proszę spróbować ponownie.' ];
|
|
|
|
$values = \S::json_to_array( \S::get( 'values' ) );
|
|
|
|
$id = \factory\BackendSites::topic_save(
|
|
(int)$values[ 'id' ], $values[ 'strona' ], $values[ 'kategoria' ], $values[ 'kategoria_id' ], $values[ 'temat' ], $values[ 'data_publikacji' ], $values[ 'opublikowany' ], $values[ 'zaakceptowany' ]
|
|
);
|
|
|
|
if ( $id )
|
|
$response = [ 'status' => 'ok', 'msg' => 'Projekt został zapisany.', 'id' => $id ];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
|
|
static public function topic_edit()
|
|
{
|
|
return \Tpl::view( 'backend_sites/topic_edit', [
|
|
'topic' => \factory\BackendSites::topic( (int)\S::get( 'id' ) )
|
|
] );
|
|
}
|
|
|
|
static public function topics()
|
|
{
|
|
return \Tpl::view( 'backend_sites/topics' );
|
|
}
|
|
|
|
static public function collective_topics()
|
|
{
|
|
return \Tpl::view( 'backend_sites/collective_topics' );
|
|
}
|
|
|
|
static public function collective_topic_edit()
|
|
{
|
|
return \Tpl::view( 'backend_sites/collective_topic_edit',[
|
|
'collective_topic' => \factory\BackendSites::collective_topic( \S::get( 'id' ) ),
|
|
] );
|
|
}
|
|
|
|
static public function collective_topic_save()
|
|
{
|
|
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania klienta wystąpił błąd. Proszę spróbować ponownie.' ];
|
|
|
|
$values = \S::json_to_array( \S::get( 'values' ) );
|
|
|
|
$id = \factory\BackendSites::collective_topic_save(
|
|
(int)$values[ 'id' ], $values[ 'strona' ], $values[ 'kategoria' ], $values[ 'kategoria_id' ], $values[ 'temat_ogolny' ], $values[ 'data_przetworzenia' ], $values[ 'przetworzony' ]
|
|
);
|
|
|
|
if ( $id )
|
|
$response = [ 'status' => 'ok', 'msg' => 'Projekt został zapisany.', 'id' => $id ];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
} |