Files
AtomicOld/simpla/ActionsAdmin.php
2026-02-14 19:34:54 +03:00

75 lines
1.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Simpla CMS
*
* @copyright 2011 Denis Pikusov
* @link http://simplacms.ru
* @author Denis Pikusov
*
*/
require_once('api/Simpla.php');
class ActionsAdmin extends Simpla
{
public function fetch()
{
// Обработка действий
if($this->request->method('post'))
{
// Действия с выбранными
$ids = $this->request->post('check');
if(is_array($ids))
switch($this->request->post('action'))
{
case 'disable':
{
$this->actions->update_post($ids, array('visible'=>0));
break;
}
case 'enable':
{
$this->actions->update_post($ids, array('visible'=>1));
break;
}
case 'delete':
{
foreach($ids as $id)
$this->actions->delete_post($id);
break;
}
}
}
$filter = array();
$filter['page'] = max(1, $this->request->get('page', 'integer'));
$filter['limit'] = 20;
// Поиск
$keyword = $this->request->get('keyword', 'string');
if(!empty($keyword))
{
$filter['keyword'] = $keyword;
$this->design->assign('keyword', $keyword);
}
$posts_count = $this->actions->count_posts($filter);
// Показать все страницы сразу
if($this->request->get('page') == 'all')
$filter['limit'] = $posts_count;
$posts = $this->actions->get_posts($filter);
$this->design->assign('posts_count', $posts_count);
$this->design->assign('pages_count', ceil($posts_count/$filter['limit']));
$this->design->assign('current_page', $filter['page']);
$this->design->assign('posts', $posts);
return $this->design->fetch('actions.tpl');
}
}