Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/channel/components/manage.php
Строк: 169
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_channel_manage extends VModule_Admin_channel
{
    private 
$tpl;
    private 
$filter;
    private 
$option;
    public function 
__construct()
    {
        
parent::__construct();
        
$this->tpl             VF::factory('template');
        
$this->filter        VF::factory('filter');
    }
    
    public function 
render()
    {
        
$cmodel        VModel::load('channel''channel'true);
        
$errors       = array();
        
$messages     = array();
        
$warnings     = array();
        
        if (isset(
$_POST['action']) && isset($_POST['channel_id'])) {
            
$action  trim($_POST['action']);
            
$channel_id = (isset($_POST['channel_id'])) ? (int) $_POST['channel_id'] : NULL;
            if (
$channel_id) {
                switch (
$action) {
                    case 
'delete':
                        
$cmodel->delete($channel_id);
                        
$messages[] = 'Channel deleted!';
                        break;
                    default:
                        
$errors[] = 'Invalid action! What exactly did you click!?';
                }
            } else {
                
$errors[] = 'Invalid channel id! Are you sure this channel exists!?';
            }
        }

       if (isset(
$_POST['submit_actions'])) {
            
$ids    = (isset($_POST['checked'])) ? array_keys($_POST['checked']) : array();
            
$action trim($_POST['action']);
            if (
$ids) {
                if (
$action == 'delete') {
                    
$cmodel->delete($ids);
                    
$messages[] = 'Selected channels deleted!';
                } else {
                    
$errors[] = 'Invalid action! What exactly did you select!?';
                }
            } else {
                
$errors[] = 'You must select at least one channel!';
            }
        }
        
        
$this->option    = array(
            
'name'    => '''network_id' => 0'username' => '',
            
'sort'    => 'c.channel_id''order' => 'DESC''display' => 10
        
);
        
        if (!isset(
$_POST['submit_reset'])) {
            if (isset(
$_SESSION['search_channel_option'])) {
                if (
array_diff_assoc($this->option$_SESSION['search_channel_option'])) {
                    
$warnings[] = 'Results are selected based on your search criteria/options! If you want to see all results please reset the current search!';
                    
$this->option $_SESSION['search_channel_option'];
                }
            }
        }
        
        
$page            = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
        
$params            $this->getParams();
        
$channels_total    $cmodel->count($params);
        
$pagination        VPagination::get($page$channels_total$params['display']);
        
        
$this->tpl->menu        'channel';
        
$this->tpl->submenu        'channel_manage';
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
$this->tpl->warnings    $warnings;
        
$this->tpl->meta_title    'Admin::Channel::Manage';
        
$this->tpl->option        $this->option;
        
$this->tpl->pagination    $pagination;
        
$this->tpl->channels    $cmodel->channels(array(), $params$pagination['limit']);
        
$this->tpl->networks    VModel::load('network''channel'true)->networks(array(), array('sort' => 'n.name''order' => 'ASC'), 0);
        
$this->tpl->load(array('header''channel_manage''footer'));
        
$this->tpl->display();
    }
    
    private function 
getParams()
    {
        
$params    = array();
        if (isset(
$_POST['submit_search'])) {
            
$this->option['name']        = $this->filter->get('name');
            
$this->option['network_id']    = (int) trim($_POST['network_id']);
            
$this->option['username']    = $this->filter->get('username');
            
$this->option['sort']        = $this->filter->get('sort');
            
$this->option['order']        = $this->filter->get('order');
            
$this->option['display']    = (int) trim($_POST['display']);
        }
        
        if (
$this->option['name'] != '') {
            
$params[]    = "c.name LIKE '".$this->db->escape($this->option['name'])."%'";
        }
        
        if (
$this->option['network_id'] > 0) {
            
$params[]    = "c.network_id = ".$this->option['network_id'];
        }
        
        if (
$this->option['username'] != '') {
            if (
$user_id VModel::load('user''user'true)->exists('username'$this->option['username'])) {
                
$params[]    = "c.user_id = ".$user_id;
            }
        }
        
        return array(
            
'where'        => ($params) ? implode('AND '$params) : '',
            
'sort'        => $this->option['sort'],
            
'order'        => $this->option['order'],
            
'display'    => $this->option['display']
        );
    }
}
?>
Онлайн: 0
Реклама