When I use my pagination I do not want it to count certain files in my array. I have tried array diff but not working.
How can I make it so that does not count any thing that is in my $not_count array()
and so my $config['total_rows'] = $counted_files;
show correct count.
<?php
class Extension_permissions extends Admin_Controller {
public function __construct() {
parent::__construct();
$this->load->model('admin/extension/model_extension_permissions');
if ($this->model_extension_permissions->check_permission_access() == true) {
return true;
} else {
redirect('admin/permission');
}
}
public function index($page = 0) {
$data['title'] = "Permissions";
$controller_files = $this->model_extension_permissions->get_installed_permissions('name');
$data['controller_files'] = array();
$files = glob(FCPATH . 'application/modules/admin/controllers/*/*.php') ;
$per_page = 1;
$offset = $page * $per_page;
$paginatedFiles = array();
$not_count = array(
FCPATH . 'application/modules/admin/controllers/common/dashboard.php',
FCPATH . 'application/modules/admin/controllers/common/login.php',
FCPATH . 'application/modules/admin/controllers/common/logout.php',
FCPATH . 'application/modules/admin/controllers/common/header.php',
FCPATH . 'application/modules/admin/controllers/common/footer.php'
);
$counted_files = array_diff($not_count, count($files)) ;
if ($counted_files) {
$paginatedFiles = array_slice($files, $offset, $per_page);
}
if ($paginatedFiles) {
foreach ($paginatedFiles as $file) {
$controller = basename(strtolower($file), '.php');
$modules = $this->model_extension_permissions->get_permissions_by_controller($controller);
$module_data = array();
foreach ($modules as $module) {
$module_data[] = array(
'permission_id' => $module['permission_id'],
'name' => ucwords(str_replace('_', ' ', $controller) . ' > ' . $module['name']),
'edit' => site_url('admin/extension/permissions/update' .'/'. $controller .'/'. $module['permission_id']),
'delete' => site_url('admin/extension/permissions/uninstall' .'/'. $controller .'/'. $module['permission_id'])
);
}
$data['controller_files'][] = array(
'name' => $controller,
'controller' => $controller,
'module' => $module_data,
'install' => site_url('admin/extension/permissions/install') .'/'.$controller,
'installed' => in_array($controller, $controller_files)
);
}
}
$this->load->library('pagination');
$config['base_url'] = base_url()."admin/extension/permissions";
$config['total_rows'] = $counted_files;
$config['per_page'] = $per_page;
$config['num_links'] = 200;
$config['uri_segment'] = 4;
$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);
$this->parser->parse('template/extension/extension_permissions', $data);
}
}