_galerie = (string)$galerie;
$this->_total = (int)$this->getCount();
$this->_typ = (int)$typ;
$this->_limit = (int)$limit;
$this->_pagpage = (int)$page;
$this->_galerieUrl = (string)$url;
$this->_pos = $pos;
}
public function createLinks( $links, $list_class ) {
$last = ceil( $this->_total / $this->_limit );
$start = ( ( $this->_pagpage - $links ) > 0 ) ? $this->_pagpage - $links : 1;
$end = ( ( $this->_pagpage + $links ) < $last ) ? $this->_pagpage + $links : $last;
$html = '
';
$class = ( $this->_pagpage == 1 ) ? "disabled" : "";
if($class == 'disabled'){
$html .= '- «
';
}else{
$html .= '- «
';
}
if ( $start > 1 ) {
$html .= '- 1
';
$html .= '- ...
';
}
for ( $i = $start ; $i <= $end; $i++ ) {
$class = ( $this->_pagpage == $i ) ? "active" : "";
$html .= '- ' . $i . '
';
}
if ( $end < $last ) {
$html .= '- ...
';
$html .= '- ' . $last . '#target
';
}
$class = ( $this->_pagpage == $last ) ? "disabled" : "";
if($class == 'disabled'){
$html .= '- »
';
}else{
$html .= '- »
';
}
$html .= '
';
return $html;
}
public function getData(){
global $wpdb;
$table_name = $wpdb->prefix .'art_images';
$row = $wpdb->get_results( $wpdb->prepare(
"SELECT *
FROM ".$table_name."
where galerie_name = %s LIMIT %d , %d ",
$this->_galerie,
($this->_pagpage - 1) * $this->_limit,
$this->_limit ));
$result = new \stdClass();
$result->page = $this->_page;
$result->limit = $this->_limit;
$result->total = $this->_total;
$result->data = $row;
return $result;
}
public function getAll() {
global $wpdb;
$table_name = $wpdb->prefix . 'art_images';
$row = $wpdb->get_results( $wpdb->prepare(
" SELECT *
FROM $table_name
WHERE galerie_name = %s
",
$this->_galerie
));
$result = new \stdClass();
$result->data = $row;
return $result ;
}
public function getCount(){
global $wpdb;
$table_name = $wpdb->prefix . 'art_images';
$galCount = $wpdb->get_results( $wpdb->prepare(
"SELECT *
FROM $table_name
WHERE galerie_name = %s",
$this->_galerie
) );
$count = count($galCount);
return $count;
} //END getCount
}
?>