first commit
This commit is contained in:
214
autoload/site/class.FSite.php
Normal file
214
autoload/site/class.FSite.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?
|
||||
namespace site;
|
||||
|
||||
class FSite {
|
||||
|
||||
public function getSiteMapPages( $id, $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages WHERE enabled = "1" AND id_menu = :id_menu AND parent_id = :parent_id ORDER BY o ASC' );
|
||||
$query -> bindValue( 'parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$page = new \site\Site( $row['id'] );
|
||||
$page -> _values['subpages'] = self::getSiteMapPages( $id, $row['id'] );
|
||||
$pages[] = $page;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function getSiteMap()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT id FROM pp_menu WHERE enabled = "1"' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$sitemap['pages'] = self::getSiteMapPages( $row['id'] );
|
||||
$sitemaps[] = $sitemap;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $sitemaps;
|
||||
}
|
||||
|
||||
public static function getContent()
|
||||
{
|
||||
global $site, $user;
|
||||
|
||||
$out = '';
|
||||
$ls = '';
|
||||
$bs = \System::formGet( 'bs' );
|
||||
$cat_id = \System::formGetInt( 'product_category' );
|
||||
|
||||
$link = 's,' . $site -> _values['id'] . ',[bs],' . \System::seo( $site -> _values['title'] );
|
||||
|
||||
switch ( $site -> _values['id_page_type'] )
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 12:
|
||||
$ls = ceil( \article\FArticle::getCountArticles() / $site -> _values['article_number'] );
|
||||
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
|
||||
$from = $site -> _values['article_number'] * ( $bs - 1 );
|
||||
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
|
||||
$articles = \article\FArticle::getArticles( $from );
|
||||
|
||||
if ( $site -> _values['id_page_type'] == 12 )
|
||||
$product_categories = \product\FCategory::getCategories( 0, $cat_id );
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$ls = ceil( \guestbook\FGuestBook::getCountEntries() / \guestbook\FGuestBook::getLimit() );
|
||||
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
$from = \guestbook\FGuestBook::getLimit() * ( $bs - 1 );
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
$quest_book = \guestbook\FGuestBook::getEntries( $from , \guestbook\FGuestBook::getLimit() );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $site -> _values['only_for_logged'] && !$user )
|
||||
return \user\VUser::drawLoginForm();
|
||||
|
||||
switch ( $site -> _values['id_page_type'] )
|
||||
{
|
||||
case 1:
|
||||
$out = \article\VArticle::drawEntryArticles( $articles );
|
||||
break;
|
||||
case 2:
|
||||
case 12:
|
||||
$out = \article\VArticle::drawFullArticles( $articles );
|
||||
break;
|
||||
case 3:
|
||||
$out = \article\VArticle::drawListArticles( $articles );
|
||||
break;
|
||||
case 4:
|
||||
$out = \article\VArticle::drawMiniatureArticles( $articles );
|
||||
break;
|
||||
case 5:
|
||||
$out = \guestbook\VGuestBook::drawGuestBook( $quest_book );
|
||||
break;
|
||||
case 6:
|
||||
$out = \newsletter\VNewsletter::drawNewsletterForm();
|
||||
break;
|
||||
case 7:
|
||||
$out = \site\VSite::drawContactSite();
|
||||
break;
|
||||
case 'registration':
|
||||
$out = \user\VUser::drawRegisterForm();
|
||||
break;
|
||||
case 'user_panel':
|
||||
$out = \user\VUser::drawUserPanel();
|
||||
break;
|
||||
case 'password_recovery':
|
||||
$out = \user\VUser::drawPassRecoveryForm();
|
||||
break;
|
||||
case 'search':
|
||||
$out = \site\VSite::drawSearchFormFull();
|
||||
break;
|
||||
case 'sitemap':
|
||||
$out = \site\VSite::drawSiteMap();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $site -> _values['contact_form'] )
|
||||
$out .= \site\VSite::drawContactForm();
|
||||
|
||||
if ( $ls > 1 )
|
||||
{
|
||||
$a = \System::getPagingVar( "a" , $bs , $ls );
|
||||
$b = \System::getPagingVar( "b" , $bs , $ls );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _a = $bs-$b;
|
||||
$tpl -> _b = $bs+$a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $link;
|
||||
$tpl -> _bs = $bs;
|
||||
$out .= $tpl -> fetch( 'site/paging' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function loadSiteStatic( $type )
|
||||
{
|
||||
global $lang;
|
||||
|
||||
switch( $type )
|
||||
{
|
||||
case 'registration':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_REJESTRACJA' ) );
|
||||
$site -> _values['id_page_type'] = 'registration';
|
||||
break;
|
||||
case 'password_recovery':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_ODZYSKIWANIE_HASLA' ) );
|
||||
$site -> _values['id_page_type'] = 'password_recovery';
|
||||
break;
|
||||
case 'search':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_WYSZUKIWARKA' ) );
|
||||
$site -> _values['id_page_type'] = 'search';
|
||||
break;
|
||||
case 'sitemap':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_MAPA_STRONY' ) );
|
||||
$site -> _values['id_page_type'] = 'sitemap';
|
||||
break;
|
||||
}
|
||||
return $site;
|
||||
}
|
||||
|
||||
public static function getMainSiteId()
|
||||
{
|
||||
global $db , $cache , $config;
|
||||
|
||||
$key = 'getMainSiteId';
|
||||
|
||||
if ( !$id = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages WHERE enabled = :enabled ORDER BY id_menu ASC, o ASC LIMIT 1' );
|
||||
$query -> bindValue( ':enabled' , 1 , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$id = $row['id'];
|
||||
}
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $id , $config['cache_expire_long'] );
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
autoload/site/class.Site.php
Normal file
43
autoload/site/class.Site.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?
|
||||
/* 2011-09-26 - dodanie typu strony LINK */
|
||||
|
||||
namespace site;
|
||||
|
||||
class Site {
|
||||
|
||||
public $_values;
|
||||
|
||||
public function __construct( $id = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ( !$id )
|
||||
$id = \site\FSite::getMainSiteId();
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT *, "' . $id . '" AS id FROM pp_pages_langs WHERE page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':page_id' , $id , \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id' , $current_lang , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
223
autoload/site/class.VSite.php
Normal file
223
autoload/site/class.VSite.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
namespace site;
|
||||
|
||||
class VSite {
|
||||
|
||||
public static function drawVisitCounter()
|
||||
{
|
||||
if ( !$visit = \System::getSessionVar( 'visit' ) )
|
||||
{
|
||||
$visit = file_get_contents( '.visit' );
|
||||
$visit ++;
|
||||
file_put_contents( '.visit', $visit );
|
||||
\System::setSessionVar( 'visit', $visit );
|
||||
}
|
||||
return '<div id="visit_counter">Odwiedziło nas: <span>' . $visit . '</span> osób</div>';
|
||||
}
|
||||
|
||||
public function drawStaticContainer( $id )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _container = \admin\factory\SContainers::getContainer( $id );
|
||||
return $tpl -> fetch( 'other/static-container' );
|
||||
}
|
||||
|
||||
public function drawAjaxContactForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/ajax-contact-form' );
|
||||
}
|
||||
|
||||
public static function drawTitle( $title )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _title = $title;
|
||||
return $tpl -> fetch( 'site/title' );
|
||||
}
|
||||
|
||||
public static function drawContactForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/contact-form' );
|
||||
}
|
||||
|
||||
public function drawCookieInformation()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/cookie-information' );
|
||||
}
|
||||
|
||||
public function getFacebookLikeBox()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/facebook-like-box' );
|
||||
}
|
||||
|
||||
public static function drawAlert()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _alert = \System::getSessionVar( 'alert' );
|
||||
$out = $tpl -> fetch( 'other/alert' );
|
||||
|
||||
\System::setSessionVar( 'alert', '' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawAdverts()
|
||||
{
|
||||
$advert = \admin\factory\Adverts::getAcitveAdvert();
|
||||
|
||||
if ( $advert && !\System::getSessionVar('advert_close') )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _advert = $advert;
|
||||
return $tpl -> fetch( 'other/advert' );
|
||||
}
|
||||
}
|
||||
|
||||
public function drawSiteMapPages( $pages )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _pages = $pages;
|
||||
return $tpl -> fetch( 'site/sitemap-pages' );
|
||||
}
|
||||
|
||||
public function drawSiteMap()
|
||||
{
|
||||
$sitemaps = \site\FSite::getSiteMap();
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _sitemaps = $sitemaps;
|
||||
return $tpl -> fetch( 'site/sitemap' );
|
||||
}
|
||||
|
||||
public static function drawSearchFormFull()
|
||||
{
|
||||
global $config , $lang;
|
||||
|
||||
$articles = '';
|
||||
$message = '';
|
||||
|
||||
if ( !isset( $config['search_limit'] ) )
|
||||
$limit = 10;
|
||||
else
|
||||
$limit = $config['search_limit'];
|
||||
|
||||
if ( \System::formGet( 's_text' ) )
|
||||
\System::setSessionVar( 'search_text' , \System::saveString( \System::formGet( 's_text' ) , true ) );
|
||||
|
||||
$text = \System::getSessionVar( 'search_text' );
|
||||
|
||||
if ( $text && strlen( $text ) >= 3 )
|
||||
{
|
||||
$bs = \System::formGet( 'bs' );
|
||||
$ls = ceil( \article\FArticle::searchArtileByTextCount( $text ) / $limit );
|
||||
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
$from = $limit * ( $bs - 1 );
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
|
||||
$articles = \article\FArticle::searchArtileByText( $text , $from , $limit );
|
||||
}
|
||||
else if ( $text )
|
||||
$message = $lang -> getTrans( 'T_MINIMALNA_ILOSC_ZNAKOW_WYSZUKIWARKA' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _text = $text;
|
||||
$tpl -> _articles = $articles;
|
||||
$tpl -> _message = $message;
|
||||
$out = $tpl -> fetch( 'site/search-results' );
|
||||
|
||||
if ( isset( $ls ) && $ls > 1 )
|
||||
{
|
||||
$a = \System::getPagingVar( "a" , $bs , $ls );
|
||||
$b = \System::getPagingVar( "b" , $bs , $ls );
|
||||
$link = '[bs],wyszukiwarka';
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _a = $bs-$b;
|
||||
$tpl -> _b = $bs+$a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $link;
|
||||
$tpl -> _bs = $bs;
|
||||
$out .= $tpl -> fetch( 'site/paging' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawSearchForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/search-form' );
|
||||
}
|
||||
|
||||
public static function drawNameDay()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _nameday = \System::getNameDay();
|
||||
return $tpl -> fetch( 'other/name-day');
|
||||
}
|
||||
|
||||
public static function drawClock()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _data = \System::getFormatDate();
|
||||
return $tpl -> fetch( 'other/clock' );
|
||||
}
|
||||
|
||||
public static function drawBanners()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _banners = \admin\factory\Banners::getBannersAll();
|
||||
return $tpl -> fetch( 'other/banners' );
|
||||
}
|
||||
|
||||
public static function drawCopyright()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/copyright' );
|
||||
}
|
||||
|
||||
public function drawGuestBook()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/guest-book' );
|
||||
}
|
||||
|
||||
public function drawContactSite()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _firm_name = \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
$tpl -> _street = \admin\factory\Settings::getSystemSettings( 'street' );
|
||||
$tpl -> _city = \admin\factory\Settings::getSystemSettings( 'city' );
|
||||
$tpl -> _postal_code = \admin\factory\Settings::getSystemSettings( 'postal_code' );
|
||||
$tpl -> _phone = \admin\factory\Settings::getSystemSettings( 'phone' );
|
||||
$tpl -> _fax = \admin\factory\Settings::getSystemSettings( 'fax' );
|
||||
$tpl -> _email = \admin\factory\Settings::getSystemSettings( 'email' );
|
||||
$tpl -> _nip = \admin\factory\Settings::getSystemSettings( 'nip' );
|
||||
$tpl -> _contact_form = \admin\factory\Settings::getSystemSettings( 'contact_form' );
|
||||
$tpl -> _info = \admin\factory\Settings::getSystemSettings( 'info' );
|
||||
return $tpl -> fetch( 'site/contact' );
|
||||
}
|
||||
|
||||
public static function drawContactMini()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _firm_name = \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
$tpl -> _street = \admin\factory\Settings::getSystemSettings( 'street' );
|
||||
$tpl -> _city = \admin\factory\Settings::getSystemSettings( 'city' );
|
||||
$tpl -> _postal_code = \admin\factory\Settings::getSystemSettings( 'postal_code' );
|
||||
$tpl -> _phone = \admin\factory\Settings::getSystemSettings( 'phone' );
|
||||
$tpl -> _fax = \admin\factory\Settings::getSystemSettings( 'fax' );
|
||||
$tpl -> _email = \admin\factory\Settings::getSystemSettings( 'email' );
|
||||
$tpl -> _nip = \admin\factory\Settings::getSystemSettings( 'nip' );
|
||||
return $tpl -> fetch( 'other/contact-mini' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user