| .. | |||||
| Admin_model.php | |||||
| Album_model.php | |||||
| Banner_model.php | |||||
| Category_model.php | |||||
| Contact_model.php | |||||
| Gallery_model.php | |||||
| Identity_model.php | |||||
| Ion_auth_model.php | |||||
| Menu_model.php | |||||
| My_model.php | |||||
| Posting_model.php | |||||
| Submenu_model.php | |||||
| index.html |
| Server IP : 103.169.32.36 / Your IP : 216.73.217.13 Web Server : Apache System : Linux web.dpmptsp 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : apache ( 48) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/dpmptsp/public_html/newsigniter/application/models/ |
Upload File : |
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Posting_model extends CI_Model {
public $perPage = 15;
public function getChoice()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('choice', 'Y');
$this->db->where('posting.is_active', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(4);
return $this->db->get()->result();
}
public function getThread()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('thread', 'Y');
$this->db->where('posting.is_active', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(4);
return $this->db->get()->result();
}
public function getFeatured()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('featured', 'Y');
$this->db->where('posting.is_active', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(3);
return $this->db->get()->result();
}
public function getLastNews()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(5);
return $this->db->get()->result();
}
public function getBeritaPilihan()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->db->where('posting.choice', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(5);
return $this->db->get()->result();
}
public function getLastPost()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->db->where('(posting.id_category=1 OR posting.id_category=6)');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(10);
return $this->db->get()->result();
}
public function getMostPopular()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('thread', 'Y');
$this->db->where('posting.is_active', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(1);
return $this->db->get()->row();
}
public function getVideoGames()
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('category.slug', 'video-game');
$this->db->where('posting.is_active', 'Y');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(5);
return $this->db->get()->result();
}
public function getAllPosting($page)
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->paginate($page);
$this->db->order_by('posting.id', 'desc');
return $this->db->get()->result();
}
public function getPosting($seo_title)
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('seo_title', $seo_title);
return $this->db->get()->row();
}
public function getPostingById($id)
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.id', $id);
return $this->db->get()->row();
}
public function getPostingByCategory($category, $page)
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->db->where('category.slug', $category);
$this->paginate($page);
$this->db->order_by('posting.id', 'desc');
return $this->db->get()->result();
}
public function getPostingByKeyword($filter, $page)
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->db->like('title', $filter);
$this->db->or_like('content', $filter);
$this->paginate($page);
$this->db->order_by('posting.id', 'desc');
return $this->db->get()->result();
}
public function countPosting($category = null)
{
if($category){
$idCategory = $this->_getIdCategory($category);
$this->db->where('id_category', $idCategory->id);
}
$this->db->where('posting.is_active', 'Y');
return $this->db->count_all_results('posting');
}
public function countPosting2($filter = null)
{
if($filter){
$this->db->like('title', $filter);
$this->db->or_like('content', $filter);
}
$this->db->where('posting.is_active', 'Y');
return $this->db->count_all_results('posting');
}
public function _getIdCategory($category)
{
$this->db->where('slug', $category);
return $this->db->get('category')->row();
}
public function getDefaultValues()
{
return [
'title' => '',
'seo_title' => '',
'content' => '',
'featured' => 'N',
'choice' => 'N',
'thread' => 'N',
'id_category' => '',
'photo' => '',
'is_active' => 'Y',
'date' => ''
];
}
public function uploadImage(){
$config = [
'upload_path' => './images/posting',
'encrypt_name' => TRUE,
'allowed_types' => 'jpg|jpeg|gif|png|JPG|PNG',
'max_size' => 1000,
'max_width' => 0,
'max_height' => 0,
'overwrite' => TRUE,
'file_ext_tolower'=> TRUE
];
$this->load->library('upload', $config);
if(!$this->upload->do_upload('photo')){
$data['error_string'] = 'Upload error: '.$this->upload->display_errors('','');
exit();
}
return $this->upload->data('file_name');
}
public function deleteImage($fileName){
if(file_exists("./images/posting/$fileName")){
unlink("./images/posting/$fileName");
}
}
public function paginate($page){
return $this->db->limit($this->perPage, $this->calculateRealOffset($page));
}
public function calculateRealOffset($page){
if(is_null($page) || empty($page)){
$offset = 0;
}else{
$offset = ($page * $this->perPage) - $this->perPage;
}
return $offset;
}
public function makePagination($baseUrl, $uriSegment, $totalRows = null){
$this->load->library('pagination');
$config = [
'base_url' => $baseUrl,
'uri_segment' => $uriSegment,
'per_page' => $this->perPage,
'total_rows' => $totalRows,
'use_page_numbers' => true,
'full_tag_open' => '<ul class="nav-x uc-pagination hstack gap-1 justify-center ft-secondary" data-uc-margin="">',
'full_tag_close' => '</ul>',
'attributes' => ['class' => ''],
'first_link' => 'First',
'last_link' => 'Last',
'first_tag_open' => '<li>',
'first_tag_close' => '</li>',
'prev_link' => '<',
'prev_tag_open' => '<li>',
'prev_tag_close' => '</li>',
'next-link' => '>',
'next_tag_open' => '<li>',
'next_tag_close' => '</li>',
'last_tag_open' => '<li>',
'last_tag_close' => '</li>',
'cur_tag_open' => '<li><a href="#" class="uc-active">',
'cur_tag_close' => '<span class="sr-only">(current)</span></a></li>',
'num_tag_open' => '<li>',
'num_tag_close' => '</li>'
];
$this->pagination->initialize($config);
return $this->pagination->create_links();
}
public function loadMoreData($page)
{
$this->db->from('posting');
$this->db->join('category', 'category.id = posting. id_category');
$this->db->where('posting.is_active', 'Y');
$this->db->where('(posting.id_category=1 OR posting.id_category=6)');
$this->db->order_by('posting.id', 'desc');
$this->db->limit(4,$page);
return $this->db->get()->result();
}
}
/* End of file Category_model.php */
| .. | |||||
| Admin_model.php | |||||
| Album_model.php | |||||
| Banner_model.php | |||||
| Category_model.php | |||||
| Contact_model.php | |||||
| Gallery_model.php | |||||
| Identity_model.php | |||||
| Ion_auth_model.php | |||||
| Menu_model.php | |||||
| My_model.php | |||||
| Posting_model.php | |||||
| Submenu_model.php | |||||
| index.html |