core/api/modules/slider_edit/class.php

75 lines
3.1 KiB
PHP
Raw 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
class main{
var $db; // Здесь объект для работы с MySQL
var $id;
function __construct( $smarty, $settings, $db ){
$this -> db = $db;
if( $settings['cachePage'] > 0 ){
$smarty -> caching = true;
$smarty -> cache_lifetime = $settings['cachePage'];
}
$db -> free_sql2("CREATE TABLE IF NOT EXISTS `slider` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`img` varchar(10) NOT NULL,
`h3` varchar(250) NOT NULL,
`txt` varchar(250) NOT NULL,
`link` varchar(250) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$this -> settings = $settings;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_news($limit){ // получение новостей
$a['cat']=1;
$a['public']=1;
$db=$this->db;
$db->or_by_desc=1;
$postrow=$db->get_massiv('pages', $a, 'd', $limit);
@$num = count($postrow);
for($i = 0; $i < $num; $i++){
$y=substr($postrow[$i]['d'], 0, 4);
$m=substr($postrow[$i]['d'], 5, 2);
$d=substr($postrow[$i]['d'], 8, 2);
$postrow[$i]['dd']=$d . '.' . $m . '.' . $y;
}
return $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_last_page( $limit ){ // Получаем последние страницы
$db = $this -> db;
$db -> or_by_desc = 1;
$a['public']=1;
$postrow = $db -> get_massiv( 'pages', $a, 't', $limit );
@$num = count ( $postrow );
for ( $i = 0; $i < $num; $i++ ) {
$a['id'] = $postrow[$i]['pages_cat'];
$postrow[$i]['pages_cat'] = $db -> get_val ( 'pages_cat', $a, 'title' );
}
return $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_slider(){ // Получаем слайдер
$db = $this -> db;
$db->or_by_desc=0;
$db -> get_massiv ( 'slider' ); //исполняем функцию с параметрами
$sliders = $db->result; //получаем результат
$this->id=$sliders[0]['id'];
return $sliders;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_carusel(){ // Получаем баннеры из папки
if ( file_exists ( MYDIR . '/files/template/banner' ) ) {
include_once ( MYDIR . '/api/php/list_file.php' );
$listfile = list_file ( MYDIR . '/files/template/banner' );
$c = count ( $listfile );
for ( $i = 0; $i < $c; $i++ ) $karusel[$i] = '/files/template/banner/' . $listfile[$i];
return $karusel;
}
}
}
?>