first commit
This commit is contained in:
61
autoload/admin/factory/class.Adverts.php
Normal file
61
autoload/admin/factory/class.Adverts.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class Adverts {
|
||||
|
||||
public static function getAcitveAdvert()
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getAcitveAdvert';
|
||||
|
||||
if ( !$advert = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> query( 'SELECT * FROM pp_adverts WHERE ( date_start <= "' . date( 'Y-m-d' ) . '" OR date_start = "0000-00-00" ) AND ( date_end >= "' . date( 'Y-m-d' ) . '" OR date_end = "0000-00-00" ) AND enabled = 1 LIMIT 1' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$advert = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
$cache -> store( $key, $advert, $config['cache_expire'] );
|
||||
}
|
||||
return $advert;
|
||||
}
|
||||
|
||||
public static function deleteAdvert( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT image FROM pp_adverts WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( '../' . $row['image'] ) )
|
||||
unlink( '../' . $row['image'] );
|
||||
|
||||
$query2 = $db -> prepare( 'DELETE FROM pp_adverts WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
680
autoload/admin/factory/class.Articles.php
Normal file
680
autoload/admin/factory/class.Articles.php
Normal file
@@ -0,0 +1,680 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Articles {
|
||||
|
||||
public static function cloneArticle( $id )
|
||||
{
|
||||
global $db;
|
||||
if ( $art_id = \System::duplicateMysqlRow( 'pp_articles', 'id', $id, array( 'date_add' ) ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_articles_langs WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $lang_id = \System::duplicateMysqlRow( 'pp_articles_langs', 'id', $row['id'], array( 'seo_link', 'date_modify' ) ) )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_articles_langs SET article_id = :article_id WHERE id = :id' );
|
||||
$query2 -> bindValue( ':article_id', $art_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $lang_id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_articles SET date_modify = :date_modify WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id', $art_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':date_modify', \System::getDate(), \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_articles SET thumbnail = NULL WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id', $art_id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function changeArticleEnabled( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT enabled FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$enabled = $row['enabled'];
|
||||
$query -> closeCursor();
|
||||
|
||||
$enabled ? $enabled_new = 0 : $enabled_new = 1;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_articles SET enabled = :enabled WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled_new, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getPagesWithArticles()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages ORDER BY id_menu ASC, o ASC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
unset( $articles );
|
||||
|
||||
$row['title'] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
|
||||
$query2 = $db -> query( 'SELECT article_id AS id FROM pp_articles_pages AS pap, pp_articles AS pa WHERE pa.id = pap.article_id AND page_id = ' . $row['id'] . ' AND archive = 0 ORDER BY o ASC' );
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$row2['title'] = \System::getArticleTitle( $row2['id'] );
|
||||
$articles[] = $row2;
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$row['articles'] = $articles;
|
||||
$pages[] = $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function deleteArticle( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCache( '../upload/files/article_' . $id . '/' );
|
||||
\System::deleteCache( '../upload/galeries/article_' . $id . '/' );
|
||||
|
||||
$query = $db -> prepare( 'SELECT thumbnail FROM pp_articles WHERE id = :id AND thumbnail IS NOT NULL' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( "../" . $row['thumbnail'] ) )
|
||||
unlink( "../" . $row['thumbnail'] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_pages WHERE article_id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_langs WHERE article_id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_img WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_file WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::rewriteHtacces();
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function restoreArticle( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_articles SET archive = 0 WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::rewriteHtacces();
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getArticleFiles( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_file WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$files[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
public static function getArticleImages( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_img WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$images[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
public static function deleteNonAssignImages()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT * FROM pp_articles_img WHERE id_article = 0' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( "../" . $row['src'] ) )
|
||||
unlink( "../" . $row['src'] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> query( 'DELETE FROM pp_articles_img WHERE id_article = 0' );
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getArticleVersionByVersionId( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT version FROM pp_articles_langs WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $version_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['version'];
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function getArticleIdByVersionId( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT article_id FROM pp_articles_langs WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $version_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['article_id'];
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function getMaxArticleVersion( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT MAX( version ) FROM pp_articles_langs WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0];
|
||||
$query -> closeCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function restoreArticleVersion( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$article_id = \admin\factory\Articles::getArticleIdByVersionId( $version_id );
|
||||
$version = \admin\factory\Articles::getArticleVersionByVersionId( $version_id );
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_langs WHERE article_id = :article_id AND version = :version' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':version', $version, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( !$max_ver )
|
||||
$max_ver = self::getMaxArticleVersion( $row['article_id'] ) + 1;
|
||||
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_articles_langs ( text, meta_description, meta_keywords, title, article_id, lang_id, version ) VALUES ( :text, :meta_description, :meta_keywords, :title, :article_id, :lang_id, :version )' );
|
||||
$query2 -> bindValue( ':text', $row['text'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_description', $row['meta_description'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_keywords', $row['meta_keywords'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':title', $row['title'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':article_id', $row['article_id'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['lang_id'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':version', $max_ver, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
return true;
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getVersions( $id, $from, $lpk )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , title , version , date_modify FROM pp_articles_langs WHERE article_id = :article_id GROUP BY version ORDER BY version DESC LIMIT ' . $from . ',' . $lpk );
|
||||
$query -> bindValue( ':article_id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$articles[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function getCountVersions( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT COUNT( DISTINCT( version ) ) FROM pp_articles_langs WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$row[0];
|
||||
$query -> closeCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getArticleParam( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getPagesAssign( $id = '', $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE parent_id = :parent_id ORDER BY id_menu ASC, o ASC' );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$row['title'] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT page_id FROM pp_articles_pages WHERE article_id = :article_id AND page_id = :page_id' );
|
||||
$query2 -> bindValue( ':article_id', (int)$id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':page_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
$row['check'] = 1;
|
||||
else
|
||||
$row['check'] = 0;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$row['subpages'] = self::getPagesAssign( $id, $row['id'] );
|
||||
|
||||
$pages[] = $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function getArticleParamLanguage( $id = '', $version = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT id, name FROM pp_langs WHERE enabled = 1' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $version )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id AND version = :version ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':version', $version, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
}
|
||||
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$lg['title'] = $row2['title'];
|
||||
$lg['meta_description'] = $row2['meta_description'];
|
||||
$lg['meta_keywords'] = $row2['meta_keywords'];
|
||||
$lg['text'] = $row2['text'];
|
||||
$lg['seo_link'] = $row2['seo_link'];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$lg['title'] = '';
|
||||
$lg['meta_description'] = '';
|
||||
$lg['meta_keywords'] = '';
|
||||
$lg['text'] = '';
|
||||
$lg['seo_link'] = '';
|
||||
}
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $row['name'];
|
||||
$language[] = $lg;
|
||||
}
|
||||
return $language;
|
||||
}
|
||||
|
||||
public static function getMaxArticleOrder()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT MAX(o) FROM pp_articles_pages' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0];
|
||||
$query -> closeCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function saveArticle()
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
|
||||
$date = \System::getDate();
|
||||
$pages = \System::formGet( 'pages' );
|
||||
$print = \System::formGetInt( 'print' );
|
||||
$show_date = \System::formGetInt( 'show_date' );
|
||||
$show_title = \System::formGetInt( 'show_title' );
|
||||
$article_id = \System::formGetInt( 'id' );
|
||||
$enabled = \System::formGetInt( 'enabled' );
|
||||
$show_author = \System::formGetInt( 'show_author' );
|
||||
$keep_archive = \System::formGetInt( 'keep_archive' );
|
||||
$layout = \System::formGetInt( 'layout' );
|
||||
$replace_menu = \System::formGetInt( 'replace_menu_title' );
|
||||
$comments_enabled = \System::formGetInt( 'comments_enabled' );
|
||||
|
||||
$sql = 'UPDATE
|
||||
pp_articles
|
||||
SET
|
||||
show_title = :show_title, enabled = :enabled, print = :print, show_date = :show_date, date_modify = :date_modify, show_author = :show_author, keep_archive = :keep_archive,
|
||||
id_layout = :id_layout, replace_menu_title = :replace_menu, comments_enabled = :comments_enabled
|
||||
WHERE
|
||||
id = :id';
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':print', $print, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':show_date', $show_date, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':date_modify', $date, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':show_author', $show_author, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':keep_archive', $keep_archive, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_layout', $layout, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':replace_menu', $replace_menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':comments_enabled', $comments_enabled, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$not_in = '0';
|
||||
if ( is_array( $pages ) ) foreach ( $pages as $pag )
|
||||
{
|
||||
if ( $not_in )
|
||||
$not_in .= ',';
|
||||
$not_in .= $pag;
|
||||
}
|
||||
|
||||
if ( $not_in != '' )
|
||||
{
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_pages WHERE article_id = :article_id AND page_id NOT IN (' . $not_in . ')' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'SELECT page_id FROM pp_articles_pages WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$tab_tmp[] = $row['page_id'];
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( is_array( $pages ) )
|
||||
{
|
||||
$o = self::getMaxArticleOrder() + 1;
|
||||
$query = $db -> prepare( 'INSERT INTO pp_articles_pages ( page_id, article_id, o ) VALUES ( :page_id, :article_id, :o )' );
|
||||
foreach ( $pages as $pag )
|
||||
{
|
||||
if ( !is_array( $tab_tmp ) || !in_array( $pag , $tab_tmp ) )
|
||||
{
|
||||
$query -> bindValue( ':page_id', $pag, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':o', $o, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$o++;
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
if ( $article_id )
|
||||
{
|
||||
$version = self::getMaxArticleVersion( $article_id ) + 1;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = stripslashes( \System::saveString( \System::formGet( 'title_' . $row['id'] ) ) );
|
||||
$meta_description = stripslashes( \System::saveString( \System::formGet( 'meta_description_' . $row['id'] ) ) );
|
||||
$meta_keywords = stripslashes( \System::saveString( \System::formGet( 'meta_keywords_' . $row['id'] ) ) );
|
||||
$text = stripslashes( \System::formGet( 'text_' . $row['id'] ) );
|
||||
$seo_link = \System::formGet( 'seo_link_' . $row['id'] );
|
||||
|
||||
if ( $seo_link == 'link seo' )
|
||||
$seo_link = '';
|
||||
|
||||
if ( $meta_description == 'meta description' )
|
||||
$meta_description = '';
|
||||
|
||||
if ( $meta_keywords == 'meta keywords' )
|
||||
$meta_keywords = '';
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT id, version FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() && !$keep_archive )
|
||||
{
|
||||
while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$query3 = $db -> prepare( 'UPDATE pp_articles_langs SET text = :text, meta_description = :meta_description, meta_keywords = :meta_keywords, title = :title, seo_link = :seo_link WHERE article_id = :article_id AND lang_id = :lang_id AND version = :version' );
|
||||
$query3 -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':version', $row2['version'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query3 = $db -> prepare( 'INSERT INTO pp_articles_langs ( text, meta_description, meta_keywords, title, article_id, lang_id, version, seo_link ) VALUES ( :text, :meta_description, :meta_keywords, :title, :article_id, :lang_id, :version, :seo_link )' );
|
||||
$query3 -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':version', $version, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
\System::rewriteHtacces();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function addArticle()
|
||||
{
|
||||
global $user, $db;
|
||||
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
|
||||
$date = \System::getDate();
|
||||
$pages = \System::formGet( 'pages' );
|
||||
$enabled = \System::formGetInt( 'enabled' );
|
||||
$print = \System::formGetInt( 'print' );
|
||||
$show_date = \System::formGetInt( 'show_date' );
|
||||
$show_title = \System::formGetInt( 'show_title' );
|
||||
$show_author = \System::formGetInt( 'show_author' );
|
||||
$keep_archive = \System::formGetInt( 'keep_archive' );
|
||||
$layout = \System::formGetInt( 'layout' );
|
||||
$replace_menu = \System::formGetInt( 'replace_menu_title' );
|
||||
$comments_enabled = \System::formGetInt( 'comments_enabled' );
|
||||
|
||||
if ( \System::getSessionVar( 'check' ) == \System::formGet( 'check' ) )
|
||||
return false;
|
||||
|
||||
\System::setSessionVar( 'check', \System::formGet( 'check' ) );
|
||||
|
||||
$sql = 'INSERT INTO
|
||||
pp_articles
|
||||
( show_title , enabled , print , show_date , date_add , date_modify , show_author , author , keep_archive, id_layout, replace_menu_title, comments_enabled )
|
||||
VALUES
|
||||
( :show_title , :enabled , :print , :show_date , :date_add , :date_modify , :show_author , :author , :keep_archive, :id_layout, :replace_menu, :comments_enabled )';
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':print', $print, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':show_date', $show_date, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':date_add', $date, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':date_modify', $date, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':show_author', $show_author, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':author', $user -> _values['id'], \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':keep_archive', $keep_archive, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_layout', $layout, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':replace_menu', $replace_menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':comments_enabled', $comments_enabled, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$article_id = $db -> lastInsertId();
|
||||
|
||||
if ( $article_id )
|
||||
{
|
||||
if ( is_array( $pages ) )
|
||||
{
|
||||
$o = self::getMaxArticleOrder() + 1;
|
||||
$query = $db -> prepare( 'INSERT INTO pp_articles_pages ( page_id, article_id, o ) VALUES ( :page_id, :article_id, :o )' );
|
||||
foreach ( $pages as $page )
|
||||
{
|
||||
$query -> bindValue( ':page_id', $page, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':o', $o, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$o++;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = \System::saveString( \System::formGet( 'title_' . $row['id'] ) );
|
||||
$meta_description = \System::saveString( \System::formGet( 'meta_description_' . $row['id'] ) );
|
||||
$meta_keywords = \System::saveString( \System::formGet( 'meta_keywords_' . $row['id'] ) );
|
||||
$text = stripslashes( \System::formGet( 'text_' . $row['id'] ) );
|
||||
$seo_link = \System::formGet( 'seo_link_' . $row['id'] );
|
||||
|
||||
if ( $seo_link == 'link seo' )
|
||||
$seo_link = '';
|
||||
|
||||
if ( $meta_description == 'meta description' )
|
||||
$meta_description = '';
|
||||
|
||||
if ( $meta_keywords == 'meta keywords' )
|
||||
$meta_keywords = '';
|
||||
|
||||
$sql = 'INSERT INTO
|
||||
pp_articles_langs
|
||||
( article_id, lang_id, text, meta_description, meta_keywords, title, version, seo_link )
|
||||
VALUES
|
||||
( :article_id, :lang_id, :text, :meta_description, :meta_keywords, :title, :version, :seo_link )';
|
||||
$query2 = $db -> prepare( $sql );
|
||||
$query2 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':version', 0, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
\System::rewriteHtacces();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function setAsArchive( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_articles SET archive = :archive WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':archive' , 1 , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::rewriteHtacces();
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
230
autoload/admin/factory/class.Banners.php
Normal file
230
autoload/admin/factory/class.Banners.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function getBannersAll()
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
|
||||
$key = 'getBannersAll';
|
||||
|
||||
if ( !$banners = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare('SELECT title, link, image FROM pp_banner WHERE enabled = :enabled ORDER BY o');
|
||||
$query -> bindValue(':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$banners[] = $row;
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $banners, $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $banners;
|
||||
}
|
||||
|
||||
public static function getCountBanners()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_banner' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
public static function getBanners( $from, $lpk )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$lp = 1;
|
||||
$tab = \System::getComboYesNo();
|
||||
$banners = '';
|
||||
|
||||
$query = $db -> prepare( 'SELECT title, link, enabled, id, o FROM pp_banner ORDER BY o ASC LIMIT ' . $from . ',' . $lpk );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$ban['title'] = $row['title'];
|
||||
$ban['link'] = $row['link'];
|
||||
$ban['lp'] = $lp;
|
||||
$ban['enabled'] = $tab[$row['enabled']];
|
||||
$ban['id'] = $row['id'];
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_banner WHERE o > :o ORDER BY o ASC LIMIT 1' );
|
||||
$query2 -> bindValue( ':o', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$ban['down'] = true;
|
||||
else
|
||||
$ban['down'] = false;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_banner WHERE o < :o ORDER BY o ASC LIMIT 1' );
|
||||
$query2 -> bindValue( ':o', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$ban['up'] = true;
|
||||
else
|
||||
$ban['up'] = false;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$akcja = "function mycallbackform(v,m,f){
|
||||
if( v == true )
|
||||
document.location.href='index.php?rw=del&id=" . $row['id'] . "';
|
||||
}";
|
||||
$akcja .= "$.prompt( 'Na pewno chcesz usunąć wybrany baner?',{ callback: mycallbackform, buttons: { tak: true, nie: false }, focus: 1 })";
|
||||
$akcja = 'onClick="'.$akcja.'"';
|
||||
$ban['action'] = $akcja;
|
||||
$banners[] = $ban;
|
||||
$lp++;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $banners;
|
||||
}
|
||||
|
||||
public static function getMaxOrder()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT MAX(o) FROM pp_banner' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0]+1;
|
||||
}
|
||||
|
||||
public static function moveBannerDown( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT o FROM pp_banner WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$o1 = $row['o'];
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, o FROM pp_banner WHERE o > :order ORDER BY o ASC LIMIT 1' );
|
||||
$query -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function moveBannerUp( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT o FROM pp_banner WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$o1 = $row['o'];
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, o FROM pp_banner WHERE o < :order ORDER BY o DESC LIMIT 1' );
|
||||
$query -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteBanner( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT image FROM pp_banner WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( "../" . $row['image'] ) && $row['image'] )
|
||||
unlink("../" . $row['image']);
|
||||
|
||||
$query2 = $db -> prepare( 'DELETE FROM pp_banner WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
19
autoload/admin/factory/class.GuestBook.php
Normal file
19
autoload/admin/factory/class.GuestBook.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
|
||||
class GuestBook
|
||||
{
|
||||
public function deleteEntry( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_guest_book WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
20
autoload/admin/factory/class.Languages.php
Normal file
20
autoload/admin/factory/class.Languages.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public function deleteTranslation( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_langs_text WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
254
autoload/admin/factory/class.Layouts.php
Normal file
254
autoload/admin/factory/class.Layouts.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Layouts {
|
||||
|
||||
public static function getLayouts()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT id, name FROM pp_layouts' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layouts[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $layouts;
|
||||
}
|
||||
|
||||
public static function getLayout( $id, $admin = false )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getLayout:' . $id;
|
||||
if ( $admin || !$layout = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_layouts WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row;
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $layout, $config['cache_expire_long'] );
|
||||
}
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public static function getActiveLayout()
|
||||
{
|
||||
global $db , $site, $cache, $config;
|
||||
|
||||
$key = 'getActiveLayout:' . $site -> _values['id'];
|
||||
|
||||
if ( !$layout = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_layouts_pages, pp_layouts WHERE page_id = :page_id AND pp_layouts.id = layout_id ORDER BY layout_id DESC LIMIT 1' );
|
||||
$query -> bindValue( ':page_id', $site -> _values['id'], \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( !$layout )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT html , css , javascript FROM pp_layouts WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row;
|
||||
$query -> closeCursor();
|
||||
}
|
||||
$cache -> store( $key, $layout, $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public static function getSelectedPages( $id )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getSelectedPages:' . $id;
|
||||
|
||||
if ( !$pages = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT page_id FROM pp_layouts_pages WHERE layout_id = :layout_id' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$pages[] = $row['page_id'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $pages , $config['cache_expire'] );
|
||||
}
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function getPagesAssign( $id = '', $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE parent_id = :parent_id ORDER BY id_menu ASC, o ASC' );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$row['title'] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
$row['check'] = 0;
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT page_id FROM pp_layouts_pages WHERE layout_id = :layout_id AND page_id = :page_id' );
|
||||
$query2 -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':page_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
$row['check'] = 1;
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
|
||||
$row['subpages'] = self::getPagesAssign( $id, $row['id'] );
|
||||
|
||||
$pages[] = $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function addLayout()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$html = \System::formGet( 'html' );
|
||||
$css = \System::formGet( 'css' );
|
||||
$js = \System::formGet( 'js' );
|
||||
$pages = \System::formGet( 'pages' );
|
||||
|
||||
if ( $enabled == 1 )
|
||||
{
|
||||
$query = $db -> prepare( 'UPDATE pp_layouts SET enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 0, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts ( name , enabled , html , css , javascript ) VALUES ( :name , :enabled , :html , :css , :javascript )' );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':html', $html, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':css', $css, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':javascript', $js, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$id = $db -> lastInsertId();
|
||||
|
||||
if ( is_array( $pages ) ) foreach ( $pages as $page )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id , page_id ) VALUES ( :layout_id , :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function saveLayout()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$id = \System::formGetInt( 'id' );
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$html = \System::formGet( 'html' );
|
||||
$css = \System::formGet( 'css' );
|
||||
$js = \System::formGet( 'js' );
|
||||
$pages = \System::formGet( 'pages' );
|
||||
|
||||
if ( $enabled )
|
||||
{
|
||||
$query = $db -> prepare( 'UPDATE pp_layouts SET enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 0, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
$html = addslashes( $html );
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_layouts SET name = :name , enabled = :enabled , html = :html , css = :css , javascript = :javascript WHERE id = :id' );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':html', $html, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':css', $css, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':javascript', $js, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE layout_id = :layout_id' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( is_array( $pages ) ) foreach ( $pages as $page )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id , page_id ) VALUES ( :layout_id , :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteLayout( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_layouts' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row[0] <= 1 )
|
||||
return false;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE layout_id = :layout_id' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_layouts WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row[0] == 0 )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_layouts SET enabled = :enabled LIMIT 1' );
|
||||
$query2 -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
65
autoload/admin/factory/class.Menu.php
Normal file
65
autoload/admin/factory/class.Menu.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Menu
|
||||
{
|
||||
public static function getMenuType()
|
||||
{
|
||||
return array( 0 => 'menu poziome', 1 => 'menu pionowe' );
|
||||
}
|
||||
|
||||
public static function getMenu()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_menu ORDER BY id ASC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$Menu[] = $row;
|
||||
$query -> closeCursor();
|
||||
return $Menu;
|
||||
}
|
||||
|
||||
public static function getMenuName( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT name FROM pp_menu WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['name'];
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteMenu( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$flag = true;
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_pages WHERE id_menu=:id_menu' );
|
||||
$query -> bindValue( ':id_menu', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row[0] > 0 )
|
||||
$flag = false;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $flag )
|
||||
{
|
||||
$query = $db -> prepare( 'DELETE FROM pp_menu WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
\System::setAlert( 'Menu został usunięte.' );
|
||||
}
|
||||
else
|
||||
\System::setAlert( 'Nie można usunąć wybranego menu z powodu przypisanych podstron.' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
18
autoload/admin/factory/class.Newsletter.php
Normal file
18
autoload/admin/factory/class.Newsletter.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class Newsletter {
|
||||
|
||||
public function deleteEmail( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_newsletter_emails WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
419
autoload/admin/factory/class.Pages.php
Normal file
419
autoload/admin/factory/class.Pages.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Pages
|
||||
{
|
||||
public static function getPageLayout( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT layout_id FROM pp_layouts_pages WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['layout_id'];
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getSortTypes()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sort = array();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , name FROM pp_page_sorts ORDER BY name ASC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$st['id'] = $row['id'];
|
||||
$st['name'] = $row['name'];
|
||||
$sort[] = $st;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $sort;
|
||||
}
|
||||
|
||||
public static function getPageTypes()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$pages = array();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , name FROM pp_page_types WHERE enabled = :enabled ORDER BY name ASC' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$pg['id'] = $row['id'];
|
||||
$pg['name'] = $row['name'];
|
||||
$pages[] = $pg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function getAssignedArticles( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT article_id FROM pp_articles_pages WHERE page_id = :page_id ORDER BY o DESC' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$articles[] = \article\FArticle::loadArticle( $row['article_id'] );
|
||||
$query -> closeCursor();
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function getPageParam( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$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() )
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function getPageParamLanguage( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, name FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$lg = '';
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_pages_langs WHERE page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$lg = $row2;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $row['name'];
|
||||
$language[] = $lg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $language;
|
||||
}
|
||||
|
||||
public static function getPageTitle( $id, $language = 'pl' )
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
|
||||
$key = 'pageTitle:' . $id . ':' . $language;
|
||||
|
||||
if ( !$title = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT title 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', $language, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$title = $row['title'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $title , $config['cache_expire_long' ] );
|
||||
}
|
||||
if ( $title == '' )
|
||||
{
|
||||
$key = 'pageTitle:' . $id;
|
||||
if ( !$title = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT title FROM pp_pages_langs WHERE page_id = :page_id AND title != "" LIMIT 1' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$title = $row['title'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $title , $config['cache_expire_long' ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
public static function getPages( $menu_id = 1, $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, id_menu, enabled FROM pp_pages WHERE 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', $menu_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$row['title'] = self::getPageTitle( $row['id'] );
|
||||
$row['subpages'] = self::getPages( $menu_id, $row['id'] );
|
||||
$pages[] = $row;
|
||||
}
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function selectMaxOrder()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT MAX(o) FROM pp_pages' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$order = $row[0]+1;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public static function savePage()
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$show_title = \System::formGet( 'show_title' );
|
||||
$sort_type = \System::formGet( 'sort_type' );
|
||||
$page_type_id = \System::formGet( 'page_type_id' );
|
||||
$link = \System::formGet( 'link' );
|
||||
$page_id = \System::formGetInt( 'id' );
|
||||
$article_number = \System::formGetInt( 'article_number' );
|
||||
$parent_id = \System::formGetInt( 'parent_id' );
|
||||
$only_for_logged = \System::formGetInt( 'only_for_logged' );
|
||||
$menu = \System::formGetInt( 'menu_id' );
|
||||
$contact_form = \System::formGetInt( 'contact_form' );
|
||||
$layout_id = \System::formGetInt( 'layout_id' );
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_pages SET contact_form = :contact_form, only_for_logged = :only_for_logged, link = :link, id_menu = :id_menu, id_page_type = :id_page_type, id_sort_type = :id_sort_type, article_number = :article_number, show_title = :show_title, enabled = :enabled, parent_id = :parent_id WHERE id = :id ' );
|
||||
$query -> bindValue( ':only_for_logged', $only_for_logged, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_page_type', $page_type_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_sort_type', $sort_type, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_number', $article_number, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':link', $link, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':contact_form', $contact_form, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $page_id )
|
||||
{
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id, page_id ) VALUES ( :layout_id, :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $layout_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = \System::formGet( 'title_' . $row['id'] );
|
||||
$meta_description = \System::formGet( 'meta_description_' . $row['id'] );
|
||||
$meta_keywords = \System::formGet( 'meta_keywords_' . $row['id'] );
|
||||
$meta_title = \System::formGet( 'meta_title_' . $row['id'] );
|
||||
$seo_link = \System::seo( \System::formGet( 'seo_link_' . $row['id'] ) );
|
||||
|
||||
if ( $title )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_pages_langs WHERE page_id=:page_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
{
|
||||
$query3 = $db -> prepare( 'UPDATE
|
||||
pp_pages_langs
|
||||
SET
|
||||
seo_link = :seo_link, title = :title, meta_description = :meta_description, meta_keywords = :meta_keywords, meta_title = :meta_title
|
||||
WHERE
|
||||
page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query3 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_title', $meta_title, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query3 = $db -> prepare( 'INSERT INTO
|
||||
pp_pages_langs
|
||||
( page_id, lang_id, title, meta_description, meta_keywords, seo_link, meta_title )
|
||||
VALUES
|
||||
( :page_id, :lang_id, :title, :meta_description, :meta_keywords, :seo_link, :meta_title )' );
|
||||
$query3 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_title', $meta_title, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
\System::rewriteHtacces();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function addPage()
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$show_title = \System::formGet( 'show_title' );
|
||||
$sort_type = \System::formGet( 'sort_type' );
|
||||
$page_type_id = \System::formGet( 'page_type_id' );
|
||||
$link = \System::formGet( 'link' );
|
||||
$check = \System::formGet( 'check' );
|
||||
$o = \System::formGetInt( 'o' );
|
||||
$article_number = \System::formGetInt( 'article_number' );
|
||||
$parent_id = \System::formGetInt( 'parent_id' );
|
||||
$only_for_logged = \System::formGetInt( 'only_for_logged' );
|
||||
$menu = \System::formGetInt( 'menu_id' );
|
||||
$contact_form = \System::formGetInt( 'contact_form' );
|
||||
$layout_id = \System::formGetInt( 'layout_id' );
|
||||
|
||||
if ( $check != \System::getSessionVar( 'check' ) )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_pages
|
||||
( only_for_logged, id_menu, id_page_type, id_sort_type, article_number, show_title, enabled, o, parent_id, link, contact_form )
|
||||
VALUES
|
||||
( :only_for_logged, :id_menu, :id_page_type, :id_sort_type, :article_number, :show_title, :enabled, :o, :parent_id, :link, :contact_form )' );
|
||||
$query -> bindValue( ':only_for_logged', $only_for_logged, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_page_type', $page_type_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_sort_type', $sort_type, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_number', $article_number, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':o', $o, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':link', $link, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':contact_form', $contact_form, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$page_id = $db -> lastInsertId();
|
||||
|
||||
if ( $page_id )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id, page_id ) VALUES ( :layout_id, :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $layout_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = \System::formGet( 'title_' . $row['id'] );
|
||||
$meta_description = \System::formGet( 'meta_description_' . $row['id'] );
|
||||
$meta_keywords = \System::formGet( 'meta_keywords_' . $row['id'] );
|
||||
$meta_title = \System::formGet( 'meta_title_' . $row['id'] );
|
||||
$seo_link = \System::seo( \System::formGet( 'seo_link_' . $row['id'] ) );
|
||||
|
||||
if ( $title )
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO
|
||||
pp_pages_langs
|
||||
( page_id, lang_id, title, meta_description, meta_keywords, meta_title, seo_link )
|
||||
VALUES
|
||||
( :page_id, :lang_id, :title, :meta_description, :meta_keywords, :meta_title, :seo_link )' );
|
||||
$query2 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_title', $meta_title, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
\System::setSessionVar( 'check', $check );
|
||||
\System::rewriteHtacces();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deletePage( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT COUNT( 0 ) FROM pp_pages WHERE parent_id = :parent_id' );
|
||||
$query -> bindValue( ':parent_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$count = $row[0];
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $count )
|
||||
{
|
||||
\System::setAlert( 'Strona nie może być usunięta z powodu przypisanych podstron.' );
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_pages WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_pages_langs WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::setAlert( 'Strona została usunięta.' );
|
||||
\System::rewriteHtacces();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
57
autoload/admin/factory/class.Restriction.php
Normal file
57
autoload/admin/factory/class.Restriction.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Restriction
|
||||
{
|
||||
public function isBannedEmail( $email )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare('SELECT id FROM pp_banned_email WHERE email = :email');
|
||||
$query -> bindValue(':email' , $email , \PDO::PARAM_STR);
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isBannedLogin( $login )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare('SELECT id FROM pp_banned_email WHERE login = :login');
|
||||
$query -> bindValue(':login' , $login , \PDO::PARAM_STR);
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteBannedEmail( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_banned_email WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Zbanowany adres email został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public function deleteBannedLogin( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_banned_login WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Zbanowany login został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
174
autoload/admin/factory/class.SContainers.php
Normal file
174
autoload/admin/factory/class.SContainers.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class SContainers {
|
||||
|
||||
public function deleteContainer( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_static_container_langs WHERE static_container_id = :static_container_id' );
|
||||
$query -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_static_container WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getContainer( $id )
|
||||
{
|
||||
global $db, $lang;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_static_container WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_static_container_langs WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $lang -> get_language(), \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$row['content'] = $row2['content'];
|
||||
return $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function saveContainer()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$id = \System::formGetInt( 'id' );
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_static_container SET name = :name, enabled = :enabled WHERE id = :id' );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$text = \System::formGet( 'text_' . $row['id'] );
|
||||
|
||||
if ( $text )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_static_container_langs WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
{
|
||||
$query3 = $db -> prepare( 'UPDATE pp_static_container_langs SET content = :content WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query3 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':content', $text, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query3 = $db -> prepare( 'INSERT INTO pp_static_container_langs ( static_container_id, lang_id, content ) VALUES ( :static_container_id, :lang_id, :content )' );
|
||||
$query3 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':content', $text, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
\System::rewriteHtacces();
|
||||
\System::setAlert( 'Strona została zapisana.' );
|
||||
}
|
||||
}
|
||||
|
||||
public function addContainer()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$check = \System::formGet( 'check' );
|
||||
|
||||
if ( \System::getSessionVar( 'check' ) != $check )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_static_container ( name, enabled ) VALUES ( :name, :enabled )' );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$container_id = $db -> lastInsertId();
|
||||
|
||||
if ( $container_id )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$text = \System::formGet( 'text_' . $row['id'] );
|
||||
|
||||
if ( $text )
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_static_container_langs ( static_container_id, lang_id, content ) VALUES ( :static_container_id, :lang_id, :content )' );
|
||||
$query2 -> bindValue( ':static_container_id', $container_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':content', $text, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
\System::setSessionVar( 'check', $check );
|
||||
\System::setAlert( 'Kontener został dodany.' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getContainerParamLanguage( $id = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, name FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
unset( $lg );
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_static_container_langs WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$lg = $row2;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $row['name'];
|
||||
$language[] = $lg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
117
autoload/admin/factory/class.Settings.php
Normal file
117
autoload/admin/factory/class.Settings.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function getSystemSettings( $param )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT value FROM pp_settings WHERE param = :param' );
|
||||
$query -> bindValue( ':param' , $param , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$out = $row['value'];
|
||||
$query -> closeCursor();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function saveSettings()
|
||||
{
|
||||
$firm_name = \System::saveString( \System::formGet( 'firm_name' ) );
|
||||
\admin\factory\Settings::saveParam( 'firm_name' , $firm_name );
|
||||
|
||||
$street = \System::saveString( \System::formGet( 'street' ) );
|
||||
\admin\factory\Settings::saveParam( 'street' , $street );
|
||||
|
||||
$postal_code = \System::saveString( \System::formGet( 'postal_code' ) );
|
||||
\admin\factory\Settings::saveParam( 'postal_code' , $postal_code );
|
||||
|
||||
$city = \System::saveString( \System::formGet( 'city' ) );
|
||||
\admin\factory\Settings::saveParam( 'city' , $city );
|
||||
|
||||
$nip = \System::saveString( \System::formGet( 'nip' ) );
|
||||
\admin\factory\Settings::saveParam( 'nip' , $nip );
|
||||
|
||||
$email = \System::saveString( \System::formGet( 'email' ) );
|
||||
\admin\factory\Settings::saveParam( 'email' , $email );
|
||||
|
||||
$phone = \System::saveString( \System::formGet( 'phone' ) );
|
||||
\admin\factory\Settings::saveParam( 'phone' , $phone );
|
||||
|
||||
$fax = \System::saveString( \System::formGet( 'fax' ) );
|
||||
\admin\factory\Settings::saveParam( 'fax' , $fax );
|
||||
|
||||
$account = \System::saveString( \System::formGet( 'account' ) );
|
||||
\admin\factory\Settings::saveParam( 'account' , $account );
|
||||
|
||||
$person = \System::saveString( \System::formGet( 'person' ) );
|
||||
\admin\factory\Settings::saveParam( 'person' , $person );
|
||||
|
||||
$admin_email = \System::saveString( \System::formGet( 'admin_email' ) );
|
||||
\admin\factory\Settings::saveParam( 'admin_email' , $admin_email );
|
||||
|
||||
$email_host = \System::saveString( \System::formGet( 'email_host' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_host' , $email_host );
|
||||
|
||||
$email_port = \System::saveString( \System::formGet( 'email_port' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_port' , $email_port );
|
||||
|
||||
$email_login = \System::saveString( \System::formGet( 'email_login' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_login' , $email_login );
|
||||
|
||||
$email_password = \System::saveString( \System::formGet( 'email_password' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_password' , $email_password );
|
||||
|
||||
$google_map_key = \System::saveString( \System::formGet( 'google_map_key' ) );
|
||||
\admin\factory\Settings::saveParam( 'google_map_key' , $google_map_key );
|
||||
|
||||
$facebook_url = \System::saveString( \System::formGet( 'facebook_url' ) );
|
||||
\admin\factory\Settings::saveParam( 'facebook_url' , $facebook_url );
|
||||
|
||||
|
||||
$user_register = \System::saveString( \System::formGet( 'user_register' ) );
|
||||
\admin\factory\Settings::saveParam( 'user_register' , $user_register );
|
||||
|
||||
$contact_form = \System::saveString( \System::formGet( 'contact_form' ) );
|
||||
\admin\factory\Settings::saveParam( 'contact_form' , $contact_form );
|
||||
|
||||
$register = \System::formGetInt( 'register' );
|
||||
\admin\factory\Settings::saveParam( 'register' , $register );
|
||||
|
||||
$info = \System::formGet( 'info' );
|
||||
\admin\factory\Settings::saveParam( 'info' , $info );
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
\System::setAlert( 'Ustawienia zostały zapisane.' );
|
||||
}
|
||||
|
||||
public static function saveParam( $param, $value )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_settings WHERE param = :param' );
|
||||
$query -> bindValue( ':param', $param, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_settings SET value = :value WHERE param = :param' );
|
||||
$query2 -> bindValue( ':value' , $value , \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':param' , $param , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_settings ( value, param ) VALUES ( :value, :param )' );
|
||||
$query2 -> bindValue( ':value' , $value , \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':param' , $param , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
31
autoload/admin/factory/class.Users.php
Normal file
31
autoload/admin/factory/class.Users.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Users {
|
||||
|
||||
public function deleteAdmin( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Administrator został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public function deleteUser( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Użytkownik został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user