first commit
This commit is contained in:
1
_rejestracja/core/.htaccess
Normal file
1
_rejestracja/core/.htaccess
Normal file
@@ -0,0 +1 @@
|
||||
Options -Indexes
|
||||
89
_rejestracja/core/ErrorHandler.php
Normal file
89
_rejestracja/core/ErrorHandler.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* $Id: ErrorHandler.php 959 2008-07-29 06:34:41Z pawy $
|
||||
* Obsluga bledow
|
||||
*
|
||||
* @param integer $errno
|
||||
* @param string $errstr
|
||||
* @param string $errfile
|
||||
* @param integer $errline
|
||||
* @return unknown
|
||||
*/
|
||||
function AppErrorHandler($errno, $errstr, $errfile, $errline) {
|
||||
|
||||
|
||||
switch ($errno) {
|
||||
|
||||
case E_STRICT:
|
||||
break;
|
||||
|
||||
|
||||
case E_NOTICE:
|
||||
MFLog::Warn("Line: ".$errline." File: ".$errfile." Message: ".$errstr." Referer: ".getenv('HTTP_REFERER'));
|
||||
|
||||
if(Config::Get('ERROR_REDIRECT') != 'true') {
|
||||
echo "<span style=\"color: red;\">Unknown error type: [$errno] $errstr<br /></span>\n";
|
||||
echo $errfile.':'.$errline;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
if(!preg_match('/mysql_connect()/', $errstr)) {
|
||||
MFLog::Error("Line: ".$errline." File: ".$errfile." Message: ".$errstr." Referer: ".getenv('HTTP_REFERER'));
|
||||
|
||||
if(Config::Get('ERROR_REDIRECT') == 'true') {
|
||||
if(getenv('HTTP_REFERER')==Config::Get('URL_MAIN')) {
|
||||
Header("Location: ".Config::Get('URL_MAIN')."/error.html");
|
||||
} else {
|
||||
header("HTTP/1.0 302 Moved Temporarily");
|
||||
Header("Location: ".Config::Get('URL_MAIN'));
|
||||
}
|
||||
} else {
|
||||
echo "<span style=\"color: red;\">Unknown error type: [$errno] $errstr<br /></span>\n";
|
||||
echo $errfile.':'.$errline;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Don't execute PHP internal error handler */
|
||||
return true;
|
||||
}
|
||||
|
||||
set_error_handler("AppErrorHandler");
|
||||
|
||||
|
||||
/**
|
||||
* Obsluguje wyjatki
|
||||
*
|
||||
* @param Exception $exception
|
||||
*/
|
||||
function ExceptionHandler($exception) {
|
||||
|
||||
|
||||
|
||||
MFLog::Error("Line: ".$exception->getLine()." Message: ".$exception->getMessage()." Referer: ".getenv('HTTP_REFERER'));
|
||||
|
||||
if(ERROR_REDIRECT == 'true') {
|
||||
if(getenv('HTTP_REFERER')==Config::Get('URL_MAIN')) {
|
||||
Header("Location: ".Config::Get('URL_MAIN')."/error.html");
|
||||
} else {
|
||||
header("HTTP/1.0 302 Moved Temporarily");
|
||||
Header("Location: ".Config::Get('URL_MAIN'));
|
||||
}
|
||||
} else {
|
||||
echo "<br /><span style=\"color: red;\">Nie obsluzony wyjatek: " , $exception->getMessage(), "</span>\n".getenv('HTTP_REFERER');
|
||||
echo $exception;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
set_exception_handler('ExceptionHandler');
|
||||
if(Config::Get('ERROR_REDIRECT') == true) {
|
||||
ini_set('html_errors',false);
|
||||
ini_set('error_prepend_string','<html><head><META http-equiv="refresh" content="0;URL='.Config::Get('FATAL_ERROR_URL').'"></head></html>');
|
||||
//ini_set('error_append_string','"></head></html>');
|
||||
}
|
||||
?>
|
||||
700
_rejestracja/core/_model/DefaultDAL.class.php
Normal file
700
_rejestracja/core/_model/DefaultDAL.class.php
Normal file
@@ -0,0 +1,700 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Domyslna klasa DAL
|
||||
*
|
||||
* @author pawel
|
||||
*/
|
||||
abstract class DefaultDAL {
|
||||
|
||||
private static $cacheTime;
|
||||
private static $cachePath;
|
||||
private static $cacheId;
|
||||
|
||||
|
||||
|
||||
public static function DefaultRemoveDuplicate($objClassTable, $objClassTablePK,$optClassTableChangeArray, $changeDictionaryTo = null) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->BeginTransaction();
|
||||
// znajdujemy wszytkie duplikaty od otrzymanego id
|
||||
|
||||
//pobieramy nazwe
|
||||
$sql = "SELECT name FROM $objClassTable WHERE $objClassTablePK = $changeDictionaryTo";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
$name = $array[0]['name'];
|
||||
//znajdujemy wszytkie duplikaty tego sameogo pola
|
||||
$sql = "SELECT $objClassTablePK FROM $objClassTable WHERE name = '$name' AND $objClassTablePK != $changeDictionaryTo";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
// dodajemy wszytkie id tych samych rekordkow do tablicy
|
||||
$idDuplicateArray = array();
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$idDuplicateArray[]=$array[$i][$objClassTablePK];
|
||||
}
|
||||
|
||||
//var_dump($idDuplicateArray);
|
||||
self::DefaultMoveDictionary($objClassTable, $objClassTablePK, $optClassTableChangeArray, $idDuplicateArray, $changeDictionaryTo);
|
||||
|
||||
$db->CommitTransaction();
|
||||
}
|
||||
|
||||
|
||||
public static function DefaultMoveDictionary($objClassTable, $objClassTablePK,$optClassTableChangeArray, $changeDictionary = array(), $changeDictionaryTo = null) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->BeginTransaction();
|
||||
|
||||
if(count($changeDictionary) > 0)
|
||||
foreach($optClassTableChangeArray as $key => $value) {
|
||||
// pierwsze zmienic wszytkie istnijace z changedictionary na docelowe
|
||||
if($value == "nm_physician") {
|
||||
$sql = "UPDATE $value SET $objClassTablePK=$changeDictionaryTo,reload=1 WHERE $objClassTablePK ";
|
||||
}
|
||||
else {
|
||||
$sql = "UPDATE $value SET $objClassTablePK=$changeDictionaryTo WHERE $objClassTablePK ";
|
||||
}
|
||||
|
||||
$in = "";
|
||||
if(count($changeDictionary) == 1) {
|
||||
$sql .= " = " . $changeDictionary[0];
|
||||
}
|
||||
else if(count($changeDictionary) > 1) {
|
||||
$sql .= " IN (";
|
||||
foreach($changeDictionary as $key => $value) {
|
||||
$in.=$value . ", ";
|
||||
}
|
||||
$in = substr($in, 0, strlen($in)-2);
|
||||
$sql.=$in;
|
||||
$sql.=")";
|
||||
}
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
}
|
||||
|
||||
//usuniecie wszytkich z changedictionary
|
||||
if(count($changeDictionary) > 0)
|
||||
foreach($changeDictionary as $key => $value) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable($objClassTable);
|
||||
$dalData->setObjClassTablePK($objClassTablePK);
|
||||
$dalData->setObj($value);
|
||||
self::DefaultDelete($dalData);
|
||||
}
|
||||
$db->CommitTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Znajduje duplikaty (takie same pola w tabeli slowników)
|
||||
*
|
||||
* @param <type> $optClass
|
||||
* @param <type> $objClassTable
|
||||
* @param <type> $objClassName
|
||||
*/
|
||||
|
||||
public static function DefaultFindDuplicate($optClass, $objClassTable, $objClassName,$duplicateField) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = $objClassName. "_" .__FUNCTION__. "_" .md5($objClassTable);
|
||||
|
||||
if(QUERYCACHE_ENABLE==true && isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else {
|
||||
$select =" " . SQL::ToSelect($optClass) . " , count($duplicateField) as countField ";
|
||||
|
||||
$sql = " SELECT $select FROM " . $objClassTable . " WHERE 1=1";
|
||||
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
$sql.=" GROUP BY $duplicateField HAVING countField>1";
|
||||
|
||||
/*
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
*/
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className=$objClassName;
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->setCountField($array[$i]['countField']);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wykonanie zapytania
|
||||
*
|
||||
* @param klasa opcjonalna $optClass
|
||||
* @param tablica $objClassTable
|
||||
* @param nazwa klasy $objClassName
|
||||
* @param tablica pol do where $data
|
||||
* @param tablica pol do zapytania $queryFields
|
||||
* @param limit do zapytania $limit
|
||||
* @param sortowanie do zapytania $sortBy
|
||||
* @param opcjonalna liczba rekordow w odpowiedzi(true/false) $count
|
||||
* @return array
|
||||
*/
|
||||
public static function DefaultGetResult(DalData $dalObj, $showSql = null) {
|
||||
//Utils::ArrayDisplay($dalObj);
|
||||
if(!self::CacheControll($dalObj)) {
|
||||
$joinString = null;
|
||||
$selectString = null;
|
||||
|
||||
if(is_array($dalObj->getJoin())) {
|
||||
foreach($dalObj->getJoin() as $key => $value) {
|
||||
if(trim(SQL::ToSelect($key,$dalObj->getQueryFields())) != "")
|
||||
$selectString .="," . SQL::ToSelect($key,$dalObj->getQueryFields());
|
||||
$joinString .= $value;
|
||||
}
|
||||
}
|
||||
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
|
||||
$queryCacheName = $dalObj->getObjClassName(). "_" . $dalObj->getObjClassTable() . "_" .__FUNCTION__. "_" .md5(implode($dalObj->getQueryFields()));
|
||||
|
||||
if($dalObj->getCount() == true)
|
||||
$queryCacheName .="_count";
|
||||
|
||||
if(Config::Get('QUERYCACHE_ENABLE')==true && isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else {
|
||||
if($dalObj->getCount() == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect($dalObj->getOptClass(),$dalObj->getQueryFields()) . " " . $selectString . " " . $dalObj->getSelectFieldsQuery();
|
||||
|
||||
$sql = " SELECT $select FROM " . $dalObj->getObjClassTable() . " " . $joinString . " WHERE 1=1 ";
|
||||
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
foreach ($dalObj->getCondition() as $key => $value) {
|
||||
if($key == "id")
|
||||
$key = "id_" . $dalObj->getObjClassTable();
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."'" : "");
|
||||
}
|
||||
|
||||
$sql .=
|
||||
( trim($dalObj->getGroupBy()) ? " GROUP BY " . $dalObj->getGroupBy() : "").
|
||||
( trim($dalObj->getSortBy()) ? " ORDER BY " . $dalObj->getSortBy() : "").
|
||||
( $dalObj->getLimit() ? " LIMIT " . $dalObj->getLimit() : "").
|
||||
" ";
|
||||
|
||||
try {
|
||||
$stmt = $db->prepare($sql);
|
||||
|
||||
if($dalObj->getCacheTime()>0) {
|
||||
$stmt->CacheStart($dalObj->getCacheTime());
|
||||
}
|
||||
} catch(MysqlException $e) {
|
||||
|
||||
}
|
||||
//Utils::ArrayDisplay($stmt);
|
||||
$stmt->execute();
|
||||
//Utils::ArrayDisplay($stmt);
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if ($showSql) {
|
||||
Utils::ArrayDisplay($sql);
|
||||
}
|
||||
|
||||
|
||||
if($dalObj->getCount() == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className=$dalObj->getObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
|
||||
foreach($dalObj->getSelectFields() as $key => $value) {
|
||||
$func = "set" . $key;
|
||||
$obj->$func($array[$i][$key]);
|
||||
|
||||
|
||||
}
|
||||
if(is_array($dalObj->getJoin()))
|
||||
foreach ($dalObj->getJoin() as $key => $value) {
|
||||
$objArray = new $key();
|
||||
$objArray->FromArray($array[$i],1);
|
||||
$strFunciton="set" . $key;
|
||||
$obj->$strFunciton($objArray);
|
||||
}
|
||||
$done[] = $obj;
|
||||
}
|
||||
if($dalObj->getCacheObject()) {
|
||||
self::CacheWriter($done);
|
||||
}
|
||||
return $done;
|
||||
} else {
|
||||
return self::CacheReader();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function DefaultGetResultByLink(DalData $dalObj) {
|
||||
if(!self::CacheControll($dalObj)) {
|
||||
$joinString = null;
|
||||
$selectString = null;
|
||||
|
||||
if(is_array($dalObj->getJoin())) {
|
||||
foreach($dalObj->getJoin() as $key => $value) {
|
||||
if(trim(SQL::ToSelect($key,$dalObj->getQueryFields())) != "")
|
||||
$selectString .="," . SQL::ToSelect($key,$dalObj->getQueryFields());
|
||||
$joinString .= $value;
|
||||
}
|
||||
}
|
||||
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
|
||||
$queryCacheName = $dalObj->getObjClassName(). "_" . $dalObj->getObjClassTable() . "_" .__FUNCTION__. "_" .md5(implode($dalObj->getQueryFields()));
|
||||
|
||||
if($dalObj->getCount() == true)
|
||||
$queryCacheName .="_count";
|
||||
|
||||
if(Config::Get('QUERYCACHE_ENABLE')==true && isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else {
|
||||
if($dalObj->getCount() == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect($dalObj->getOptClass(),$dalObj->getQueryFields()) . " " . $selectString . " " . $dalObj->getSelectFieldsQuery();
|
||||
|
||||
if(is_array($dalObj->getDataArray('mf_link_id')))
|
||||
$select .= ", " . 'mf_link.id_source as id_source';
|
||||
}
|
||||
|
||||
|
||||
//in do pobierania kliku
|
||||
if(!is_array($dalObj->getDataArray('mf_link_id')))
|
||||
{
|
||||
if ($dalObj->getDataArray('mf_link_destination') != false)
|
||||
$sql = " SELECT $select FROM " . $dalObj->getObjClassTable() ." INNER JOIN mf_link ON " . $dalObj->getObjClassTable() . "." . $dalObj->getObjClassTablePK() . "=mf_link.id_destination AND mf_link.destination_type='" . $dalObj->getObjClassTable() . "' AND mf_link.source_type='" . $dalObj->getDataArray('mf_link_table') . "' AND mf_link.id_source=" . $dalObj->getDataArray('mf_link_id');
|
||||
else
|
||||
$sql = " SELECT $select FROM " . $dalObj->getObjClassTable() ." INNER JOIN mf_link ON " . $dalObj->getObjClassTable() . "." . $dalObj->getObjClassTablePK() . "=mf_link.id_source AND mf_link.source_type='" . $dalObj->getObjClassTable() . "' AND mf_link.destination_type='" . $dalObj->getDataArray('mf_link_table') . "' AND mf_link.id_destination=" . $dalObj->getDataArray('mf_link_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($dalObj->getDataArray('mf_link_destination') != false)
|
||||
$sql = " SELECT $select FROM " . $dalObj->getObjClassTable() ." INNER JOIN mf_link ON " . $dalObj->getObjClassTable() . "." . $dalObj->getObjClassTablePK() . "=mf_link.id_destination AND mf_link.destination_type='" . $dalObj->getObjClassTable() . "' AND mf_link.source_type='" . $dalObj->getDataArray('mf_link_table') . "' AND mf_link.id_source IN(" . implode(",", $dalObj->getDataArray('mf_link_id')) . ")";
|
||||
else
|
||||
$sql = " SELECT $select FROM " . $dalObj->getObjClassTable() ." INNER JOIN mf_link ON " . $dalObj->getObjClassTable() . "." . $dalObj->getObjClassTablePK() . "=mf_link.id_source AND mf_link.source_type='" . $dalObj->getObjClassTable() . "' AND mf_link.destination_type='" . $dalObj->getDataArray('mf_link_table') . "' AND mf_link.id_destination IN(" . implode(",", $dalObj->getDataArray('mf_link_id')) . ")";
|
||||
}
|
||||
$sql .= " " . $joinString . " WHERE 1=1 ";
|
||||
foreach ($dalObj->getCondition() as $key => $value) {
|
||||
if($key == "id")
|
||||
$key = "id_" . $dalObj->getObjClassTable();
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."'" : "");
|
||||
}
|
||||
$sql .=
|
||||
( trim($dalObj->getGroupBy()) ? " GROUP BY " . $dalObj->getGroupBy() : "").
|
||||
( trim($dalObj->getSortBy()) ? " ORDER BY " . $dalObj->getSortBy() : "").
|
||||
( $dalObj->getLimit() ? " LIMIT " . $dalObj->getLimit() : "").
|
||||
" ";
|
||||
try {
|
||||
$stmt = $db->prepare($sql);
|
||||
|
||||
if($dalObj->getCacheTime()>0) {
|
||||
$stmt->CacheStart($dalObj->getCacheTime());
|
||||
}
|
||||
} catch(MysqlException $e) {
|
||||
|
||||
}
|
||||
$stmt->execute();
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($dalObj->getCount() == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className=$dalObj->getObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
|
||||
foreach($dalObj->getSelectFields() as $key => $value) {
|
||||
$func = "set" . $key;
|
||||
$obj->$func($array[$i][$key]);
|
||||
|
||||
|
||||
}
|
||||
if(is_array($dalObj->getJoin()))
|
||||
foreach ($dalObj->getJoin() as $key => $value) {
|
||||
$objArray = new $key();
|
||||
$objArray->FromArray($array[$i],1);
|
||||
$strFunciton="set" . $key;
|
||||
$obj->$strFunciton($objArray);
|
||||
}
|
||||
if(is_array($dalObj->getDataArray('mf_link_id')))
|
||||
$done[$array[$i]['id_source']] = $obj;
|
||||
else
|
||||
$done[$obj->GetId()] = $obj;
|
||||
}
|
||||
if($dalObj->getCacheObject()) {
|
||||
self::CacheWriter($done);
|
||||
}
|
||||
return $done;
|
||||
} else {
|
||||
return self::CacheReader();
|
||||
}
|
||||
}
|
||||
|
||||
public static final function CacheControll(DalData $dalObj) {
|
||||
if($dalObj->getCacheObject()) {
|
||||
self::$cachePath = Config::Get('DBCACHE_PATH').'DAL/';
|
||||
self::$cacheTime = $dalObj->getCacheTime();
|
||||
self::$cacheId = md5(serialize($dalObj));
|
||||
|
||||
if(is_file(self::$cachePath.self::$cacheId) && filemtime(self::$cachePath.self::$cacheId) > (time() - self::$cacheTime)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final function CacheWriter($data) {
|
||||
$records = serialize($data);
|
||||
$fp = fopen(self::$cachePath.self::$cacheId, "w");
|
||||
fputs($fp, $records);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public static final function CacheReader() {
|
||||
return unserialize(file_get_contents(self::$cachePath.self::$cacheId));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOdanie rekordu
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param obiekt $obj
|
||||
* @return integer
|
||||
*/
|
||||
public static function DefaultInsert(DalData $dalObj) {
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
|
||||
if(!is_numeric($dalObj->getObj()->getId()) || $dalObj->getObj()->getId() == -1)
|
||||
$dalObj->getObj()->SetId('NULL');
|
||||
|
||||
$sql = "INSERT INTO " . $dalObj->getObjClassTable() . " (".SQL::ToInsertFields($dalObj->getObj()).") VALUES (" . SQL::ToInsertValues($dalObj->getObj()).")";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualizacja rekordu
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param primary key tablicy $objClassTablePK
|
||||
* @param aktualizowany obiekt $obj
|
||||
*/
|
||||
public static function DefaultUpdate(DalData $dalObj) {
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
|
||||
$sql = "UPDATE " . $dalObj->getObjClassTable() . " SET ". SQL::ToUpdateSet($dalObj->getObj()) ." WHERE " . $dalObj->getObjClassTablePK() ."=:*#1#* ";
|
||||
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam('*#1#*', $dalObj->getObj()->GetId());
|
||||
|
||||
$stmt->execute();
|
||||
//Utils::ArrayDisplay($dalObj->getObj()->GetId());
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
return $dalObj->getObj()->GetId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualizacja rekordu
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param primary key tablicy $objClassTablePK
|
||||
* @param tablica pol i wartosci $array
|
||||
* @param id elementu $id
|
||||
*/
|
||||
public static function UpdateField(DalData $dalObj) {
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
|
||||
$sql=array();
|
||||
|
||||
foreach($dalObj->getUpdateFileldArray() as $key => $value) {
|
||||
$sql[] = $key."='".$db->Escape($value)."'";
|
||||
}
|
||||
|
||||
$sql = "UPDATE " . $dalObj->getObjClassTable() . " SET ". implode(',', $sql) ." WHERE " . $dalObj->getObjClassTablePK() ."=:*#1#* ";
|
||||
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam('*#1#*', $dalObj->getUpdateFieldId());
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
return $dalObj->getUpdateFieldId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Usuniecie rekordu
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param primary key tablicy $objClassTablePK
|
||||
* @param identyfikator rekordu $id
|
||||
*/
|
||||
public static function DefaultDelete(DalData $dalObj) {
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
$obj = $dalObj->getObj();
|
||||
$sql = "DELETE FROM " . $dalObj->getObjClassTable() . " WHERE " . $dalObj->getObjClassTablePK() . "=:1";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $obj->getId())
|
||||
->execute();
|
||||
// Utils::ArrayDisplay($dalObj);
|
||||
// Utils::ArrayDisplay($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Usuniecie rekordu(obiektu) przy porownaniu wszystkich pol
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param primary key tablicy $objClassTablePK
|
||||
* @param identyfikator rekordu $id
|
||||
*/
|
||||
public static function DefaultExactDelete(DalData $dalObj) {
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
$sql = "DELETE FROM " . $dalObj->getObjClassTable() . " WHERE " . SQL::ToDeleteSet($dalObj->getObj());
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Usuniecie rekordu po nazwie pola
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param nazwa pola $field_name
|
||||
* @param identyfikator rekordu $id_mf_user
|
||||
*/
|
||||
public static function DefaultDeleteByField(DalData $dalObj) {
|
||||
$db = Registry::Get($dalObj->getDatabaseType());
|
||||
$sql = "DELETE FROM " . $dalObj->getObjClassTable() . " WHERE " . $dalObj->getFieldName() . " =:1";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $dalObj->getId())
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca obiekt po numerze id
|
||||
*
|
||||
* @param nazwa opcjonalnej klasy $optClass
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param nazwa klasy $objClassName
|
||||
* @param nazwa pola primary key $objClassTablePK
|
||||
* @param id rekordu $id
|
||||
* @return obj
|
||||
*/
|
||||
public static function DefaultGetById(DalData $dalObj) {
|
||||
|
||||
$dalObj->setUpdateFileldArray(array($dalObj->getObjClassTablePK()=>$dalObj->getId()));
|
||||
$dalObj->setLimit(1);
|
||||
|
||||
$result = self::DefaultGetResult($dalObj);
|
||||
|
||||
if(isset($result[0]) && is_object($result[0])) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new UserException('Brak rekordu w tablicy '.$dalObj->getObjClassTable().' o id <b>'.$dalObj->getId().'</b>!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Zapisanie lub aktualizacja obiektu
|
||||
*
|
||||
* @param nazwa tablicy $objClassTable
|
||||
* @param nazwa pola primary key $objClassTablePK
|
||||
* @param aktualizoawny obiekt $obj
|
||||
*/
|
||||
public static function DefaultSave(DalData $dalObj) {
|
||||
if($dalObj->getObj()->GetId()=='-1') {
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function DefaultGetByTag(DalData $dalObj) {
|
||||
$dalObj->setCondition(array($dalObj->getObjClassTablePK()=>'mf_link.id_destination', 'mf_link.destination_type'=>$dalObj->getObjClassTable(), 'wp_tag.id_wp_tag'=>'mf_link.id_source', 'mf_link.source_type'=>'wp_tag'));
|
||||
$dalObj->setJoin(array('wp_tag', 'mf_link'));
|
||||
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function DefaultGetByTagSuggest(DalData $dalObj) {
|
||||
$dalObj->setCondition(array($dalObj->getObjClassTablePK()=>'mf_link.id_destination', 'mf_link.destination_type'=>$dalObj->getObjClassTable(), 'wp_tag_suggest.id_wp_tag_suggest'=>'mf_link.id_source', 'mf_link.source_type'=>'wp_tag_suggest'));
|
||||
$dalObj->setJoin(array('wp_tag_suggest', 'mf_link'));
|
||||
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static abstract function Save($obj);
|
||||
|
||||
//public static abstract function Insert($obj);
|
||||
|
||||
//public static abstract function Update($obj);
|
||||
|
||||
//public static abstract function Delete($id);
|
||||
|
||||
public static abstract function GetById($id);
|
||||
|
||||
public static abstract function GetDalDataObj();
|
||||
|
||||
/**
|
||||
* Generator kodu JavaScript
|
||||
*
|
||||
* @param array $array
|
||||
* @param nazwa javascriptowa $jsName
|
||||
* @return string
|
||||
*/
|
||||
public static function ToJavaScriptArray($array, $jsName) {
|
||||
$js = "new Array(); \n";
|
||||
foreach($array as $key => $value) {
|
||||
$js .= $jsName . "[" . $key . "] = '" . $value . "'; \n";
|
||||
}
|
||||
return $js;
|
||||
}
|
||||
|
||||
/**
|
||||
* funkcja do js'a
|
||||
*
|
||||
* @param unknown_type $array
|
||||
* @return unknown
|
||||
*/
|
||||
public static function DirectArray($array) {
|
||||
$js = "new Array(";
|
||||
foreach($array as $value) {
|
||||
$js .= "'$value',";
|
||||
}
|
||||
$js = substr($js, 0, -1);
|
||||
$js .= ")";
|
||||
|
||||
return $js;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tworzy w katalogu temp klasy plik do zliczenia metoda DefaultFileCounterCountAndClean()
|
||||
*/
|
||||
public static function DefaultFileCounterAppend($objClassName, $id) {
|
||||
|
||||
$data['id'] = $id;
|
||||
$validator = new Validator($data);
|
||||
//$validator->setValues($data);
|
||||
$validator->IsNumber('id', 'Nie jest numerkiem!');
|
||||
if(!$validator->IsError()) {
|
||||
// Utils::Mkdirs(Config::Get('PATH_TEMP').'/DAL/'.$objClassName);
|
||||
// $fp = fopen(Config::Get('PATH_TEMP').'/DAL/'.$objClassName.'/'.$id.'_'.microtime(), "w");
|
||||
// fputs($fp, ' ');
|
||||
// fclose($fp);
|
||||
|
||||
if(Enviroment::CheckMemcache()) {
|
||||
if(!MfMemcache::exists($objClassName)) {
|
||||
MfMemcache::set($objClassName, array());
|
||||
}
|
||||
$memcacheContent = MfMemcache::get($objClassName);
|
||||
|
||||
if(isset($memcacheContent[$id])) {
|
||||
$newValue = ++$memcacheContent[$id];
|
||||
$memcacheContent[$id] = $newValue;
|
||||
} else {
|
||||
$memcacheContent[$id] = 1;
|
||||
}
|
||||
|
||||
MfMemcache::replace($objClassName, $memcacheContent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Zwraca tablice z liczba id w katalogu temp klasy oraz usuwa pliki
|
||||
*/
|
||||
public static function DefaultFileCounterCountAndClean($objClassName) {
|
||||
|
||||
echo"mem";
|
||||
if(Enviroment::CheckMemcache()) {echo "memcache1";
|
||||
if(MfMemcache::exists($objClassName)) {echo"memcache2";
|
||||
$validator = new Validator(array());
|
||||
$memcacheContent = MfMemcache::get($objClassName);
|
||||
print_R($memcacheContent);
|
||||
foreach($memcacheContent as $id => $count) {
|
||||
if($count>0) {
|
||||
$data['id'] = $id;
|
||||
|
||||
$validator->setValues($data);
|
||||
$validator->IsNumber('id', 'Nie jest numerkiem!');
|
||||
if(!$validator->IsError()) {
|
||||
$obj = WpCounterMemcacheDAL::GetResult(array('content_type'=>$objClassName, 'content_id'=>$id, 'time'=>date("Y-m-d")));
|
||||
if(isset($obj[0]) && is_object($obj[0])) {
|
||||
$counter = $obj[0];
|
||||
} else {
|
||||
$counter = new WpCounterMemcache();
|
||||
$counter->SetContentId($id);
|
||||
$counter->SetContentType($objClassName);
|
||||
$counter->SetTime(date("Y-m-d"));
|
||||
}
|
||||
|
||||
|
||||
$counter->SetCount(($counter->GetCount()+$count));
|
||||
|
||||
|
||||
WpCounterMemcacheDAL::Save($counter);
|
||||
} else { echo $id . "nie jest numerkiem!<br />";}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
MfMemcache::remove($objClassName);
|
||||
}
|
||||
}
|
||||
//return $counterData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
312
_rejestracja/core/_model/Image.class.php
Normal file
312
_rejestracja/core/_model/Image.class.php
Normal file
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description of ParagraphImage
|
||||
*
|
||||
* @author Kopi
|
||||
*/
|
||||
class Image extends DataObject {
|
||||
|
||||
static $tableName = 'mf_image';
|
||||
static $className = __CLASS__;
|
||||
static $fields = array(
|
||||
'id_mf_image' => 'id',
|
||||
'id_image_group' => 'idImageGroup',
|
||||
'id_wp_source' => 'idSource',
|
||||
'alt' => 'alt',
|
||||
'title' => 'title',
|
||||
'path' => 'path',
|
||||
'src' => 'src',
|
||||
'position' => 'position',
|
||||
'size' => 'size',
|
||||
'author' => 'author',
|
||||
'description' => 'description',
|
||||
'weight' => 'weight'
|
||||
);
|
||||
private $idImageGroup;
|
||||
private $alt;
|
||||
private $title;
|
||||
private $path;
|
||||
private $src;
|
||||
private $position;
|
||||
private $size;
|
||||
private $author;
|
||||
private $description;
|
||||
private $idSource;
|
||||
private $points;
|
||||
private $weight;
|
||||
private $linkType;
|
||||
public $source;
|
||||
public $articleArray = array();
|
||||
public $galleryArray = array();
|
||||
public $countryArray = array();
|
||||
|
||||
public function GetTableName() {
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields() {
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName() {
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getLinkType() {
|
||||
return $this->linkType;
|
||||
}
|
||||
|
||||
public function setLinkType($linkType) {
|
||||
$this->linkType = $linkType;
|
||||
}
|
||||
|
||||
public function GetIdparagraph() {
|
||||
return $this->idParagraph;
|
||||
}
|
||||
|
||||
public function SetIdparagraph($idParagraph) {
|
||||
$this->idParagraph = $idParagraph;
|
||||
}
|
||||
|
||||
public function GetAlt() {
|
||||
return $this->alt;
|
||||
}
|
||||
|
||||
public function SetAlt($alt) {
|
||||
$this->alt = $alt;
|
||||
}
|
||||
|
||||
public function getTitle($convert = null) {
|
||||
if (isset($convert) && $convert != '') {
|
||||
return iconv('iso-8859-2', $convert, $this->title);
|
||||
} else {
|
||||
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
|
||||
public function SetTitle($title) {
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function GetPath() {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function GetFullPath() {
|
||||
|
||||
return PATH_STATIC . "/upload/Article/gallery/" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullPathMini() {
|
||||
|
||||
return PATH_STATIC . "/upload/Article/th_" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullUrl() {
|
||||
|
||||
return URL_STATIC_CONTENT . "/upload/Article/" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullUrlMini() {
|
||||
|
||||
return URL_STATIC_CONTENT . "/upload/Article/th_" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullUrlId($id, $folder = 'Article') {
|
||||
|
||||
return URL_STATIC_CONTENT . "/upload/$folder/" . $id . "/" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullUrlMaxId($id, $folder = 'Article') {
|
||||
|
||||
return URL_STATIC_CONTENT . "/upload/$folder/" . $id . "/full_" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullUrlMiniId($id, $folder = 'Article') {
|
||||
|
||||
return URL_STATIC_CONTENT . "/upload/$folder/" . $id . "/" . "th_" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullUrlOrgId($id, $folder = 'Article') {
|
||||
|
||||
return URL_STATIC_CONTENT . "/upload/$folder/" . $id . "/" . "org_" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullPathId($id, $folder = 'Article') {
|
||||
|
||||
return PATH_STATIC_CONTENT . "upload/$folder/" . $id . "/" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullPathMaxId($id, $folder = 'Article') {
|
||||
|
||||
return PATH_STATIC_CONTENT . "upload/$folder/" . $id . "/full_" . $this->path;
|
||||
}
|
||||
|
||||
public function GetFullPathOrgId($id, $folder = 'Article') {
|
||||
|
||||
return PATH_STATIC_CONTENT . "upload/$folder/" . $id . "/org_" . $this->path;
|
||||
}
|
||||
|
||||
public function SetPath($path) {
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function GetSrc($convert = null) {
|
||||
if (isset($convert) && $convert != '') {
|
||||
return iconv('iso-8859-2', $convert, $this->src);
|
||||
} else {
|
||||
|
||||
return $this->src;
|
||||
}
|
||||
}
|
||||
|
||||
public function SetSrc($src) {
|
||||
$this->src = $src;
|
||||
}
|
||||
|
||||
public function GetPosition() {
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function SetPosition($position) {
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
public function getIdArticle() {
|
||||
return $this->idArticle;
|
||||
}
|
||||
|
||||
public function setIdArticle($idArticle) {
|
||||
$this->idArticle = $idArticle;
|
||||
}
|
||||
|
||||
public function getSize() {
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function setSize($size) {
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
public function getIdImageGroup() {
|
||||
return $this->idImageGroup;
|
||||
}
|
||||
|
||||
public function setIdImageGroup($idImageGroup) {
|
||||
$this->idImageGroup = $idImageGroup;
|
||||
}
|
||||
|
||||
public function getArticleArray() {
|
||||
return $this->articleArray;
|
||||
}
|
||||
|
||||
public function setArticleArray($articleArray) {
|
||||
$this->articleArray = $articleArray;
|
||||
}
|
||||
|
||||
public function setArticle($article) {
|
||||
$this->articleArray[] = $article;
|
||||
}
|
||||
|
||||
public function getGalleryArray() {
|
||||
return $this->galleryArray;
|
||||
}
|
||||
|
||||
public function setGalleryArray($galleryArray) {
|
||||
$this->galleryArray = $galleryArray;
|
||||
}
|
||||
|
||||
public function setGallery($gallery) {
|
||||
$this->galleryArray[] = $gallery;
|
||||
}
|
||||
|
||||
public function getCountryArray() {
|
||||
return $this->countryArray;
|
||||
}
|
||||
|
||||
public function setCountryArray($countryArray) {
|
||||
$this->countryArray = $countryArray;
|
||||
}
|
||||
|
||||
public function setCountry($country) {
|
||||
$this->countryArray[] = $country;
|
||||
}
|
||||
|
||||
public function getAuthor($convert = null) {
|
||||
if (isset($convert) && $convert != '') {
|
||||
return iconv('iso-8859-2', $convert, $this->author);
|
||||
} else {
|
||||
|
||||
return $this->author;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAuthor($author) {
|
||||
$this->author = $author;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function getIdSource() {
|
||||
return $this->idSource;
|
||||
}
|
||||
|
||||
public function setIdSource($idSource) {
|
||||
$this->idSource = $idSource;
|
||||
}
|
||||
|
||||
public function getSource() {
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function setSource($source) {
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
public function getPoints() {
|
||||
return $this->points;
|
||||
}
|
||||
|
||||
public function setPoints($points) {
|
||||
$this->points = $points;
|
||||
}
|
||||
|
||||
public function getWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
653
_rejestracja/core/_model/ImageDAL.class.php
Normal file
653
_rejestracja/core/_model/ImageDAL.class.php
Normal file
@@ -0,0 +1,653 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description of ParagraphImageDAL
|
||||
*
|
||||
* @author Kopi
|
||||
*/
|
||||
class ImageDAL {
|
||||
|
||||
public static function Insert($obj) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "INSERT INTO mf_image SET " . SQL::ToUpdateSet($obj);
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
}
|
||||
|
||||
public static function Update($obj)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_image SET ". SQL::ToUpdateSet($obj) ." WHERE id_mf_image=:1 ";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $obj->GetId())
|
||||
->execute();
|
||||
|
||||
}
|
||||
|
||||
public static function UpdateGroup($obj)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_image SET ". SQL::ToUpdateSet($obj) ." WHERE id_image_group=:1 ";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $obj->GetIdImageGroup())
|
||||
->execute();
|
||||
|
||||
}
|
||||
public static function UpdateSort($id, $sort)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_image SET position = :2 WHERE id_mf_image=:1 ";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $id)
|
||||
->bindParam(2, $sort)
|
||||
->execute();
|
||||
|
||||
}
|
||||
public static function UpdateTitle($idImageGroup,$title)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_image SET title=:*#1#* WHERE id_image_group=:*#2#*";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam("*#1#*", $title)
|
||||
->bindParam("*#2#*", $idImageGroup)
|
||||
->execute();
|
||||
}
|
||||
public static function UpdateAuthor($idImageGroup,$value)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_image SET author=:*#1#* WHERE id_image_group=:*#2#*";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam("*#1#*", $value)
|
||||
->bindParam("*#2#*", $idImageGroup)
|
||||
->execute();
|
||||
}
|
||||
public static function UpdateDescription($idImageGroup,$value)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_image SET description=:*#1#* WHERE id_image_group=:*#2#*";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam("*#1#*", $value)
|
||||
->bindParam("*#2#*", $idImageGroup)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public static function Delete($obj,$deleteLink = true)
|
||||
{
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "DELETE FROM mf_image WHERE id_mf_image =:1";
|
||||
$stmt=$db->Prepare($sql)
|
||||
->BindParam(1, $obj->GetId())
|
||||
->Execute();
|
||||
}
|
||||
|
||||
|
||||
public static function DeleteGroup($idGroup)
|
||||
{
|
||||
|
||||
$imageGroupArray = self::GetResult(array("id_image_group" => $idGroup));
|
||||
|
||||
foreach($imageGroupArray as $key => $image)
|
||||
{
|
||||
PhotoDAL::SimpleDelete(array(ArticleConst::$imageDir,$image->GetPath()));
|
||||
}
|
||||
|
||||
|
||||
//pobieramy wszystkie polaczenia zdjecia
|
||||
$mfLinkArrayObj = MfLinkDAL::GetResult(array('destination_type' => "'mf_image'", 'source_type' => "'mf_gallery'", 'id_destination' => $idGroup));
|
||||
|
||||
//usuwanie raz wszytkich
|
||||
MfLinkDAL::DeleteFromLink(null, null, $idGroup, 'mf_image');
|
||||
|
||||
foreach($mfLinkArrayObj as $key => $value)
|
||||
{
|
||||
// przeliczanie galerii
|
||||
MfLinkDAL::ReCountWeight($value->getIdSource(),"mf_gallery","mf_image");
|
||||
}
|
||||
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "DELETE FROM mf_image WHERE id_image_group=:1";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $idGroup)
|
||||
->execute();
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param <ParagrafImage> $obj
|
||||
* @param <array> $files - miejsce zapisu plikow array(katalog,plik)
|
||||
* @param <array> $size - rozmiar array(x,y)
|
||||
* @return <string> $fileName
|
||||
*/
|
||||
|
||||
public static $imageSize = array(1=> array(282,194),
|
||||
2=> array(159,110),
|
||||
3=> array(280,200),
|
||||
4=> array(175,350),
|
||||
5=> array(279,198),
|
||||
6=> array(630,400),
|
||||
7=> array(100,130),
|
||||
8=> array(250,30),
|
||||
9=> array(470,280)
|
||||
);
|
||||
public static function AddImage($obj,$files,$size = 0,$localStorage = false,$sizeArray = array(),$cropForce = true,$imgDir = null)
|
||||
{
|
||||
$crop = false;
|
||||
switch($size)
|
||||
{
|
||||
case 1:
|
||||
$arraySize = array(120,60);
|
||||
$crop = false;
|
||||
break;
|
||||
case 2:
|
||||
$arraySize = array(80,80);
|
||||
$crop = false;
|
||||
break;
|
||||
case 3:
|
||||
$arraySize = array(120,120);
|
||||
$crop = false;
|
||||
break;
|
||||
case 4:
|
||||
$arraySize = array(100,120);
|
||||
$crop = false;
|
||||
break;
|
||||
case 5:
|
||||
$arraySize = array(1600,1200);
|
||||
$crop = false;
|
||||
break;
|
||||
default:
|
||||
$arraySize = array(120,120);
|
||||
break;
|
||||
}
|
||||
$cropOption = "center";
|
||||
if($cropForce !== null)
|
||||
{
|
||||
$crop = $cropForce;
|
||||
$cropOption = null;
|
||||
}
|
||||
if(count($sizeArray) > 0)
|
||||
$arraySize = $sizeArray;
|
||||
|
||||
$src = md5(microtime());
|
||||
if($localStorage == true)
|
||||
$imagedir = is_null($imgDir)?'category':$imgDir;
|
||||
else
|
||||
$imagedir = is_null($imgDir)?'article':$imgDir;
|
||||
|
||||
$file = PhotoDAL::SimpleFileUpload($files, array($imagedir,$src), $arraySize, $cropOption,$crop,$localStorage);
|
||||
|
||||
if($file == "1")
|
||||
{
|
||||
MfLog::debug('nieprawidłowy plik bmp ');
|
||||
return false;
|
||||
}
|
||||
|
||||
if($file == "" && $localStorage == false)
|
||||
{
|
||||
MfLog::debug('edysk przymulil zdjecie dodane ponownie ');
|
||||
self::AddImage($obj, $files, $size, $localStorage, $sizeArray, $cropForce);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
//dodajemy z zipa i robimy insert do tablic i linkow
|
||||
public static function AddImageFromZip(&$obj,$files,$table = null,$id =null)
|
||||
{
|
||||
$zip_name = md5(microtime());
|
||||
move_uploaded_file($files['tmp_name'], 'temp/' . $zip_name . '.zip');
|
||||
$zip = new ZipArchive;
|
||||
$zip->open("temp/" . $zip_name . ".zip");
|
||||
mkdir('temp/extracted/' . $zip_name);
|
||||
$zip->extractTo('temp/extracted/' . $zip_name);
|
||||
$zip->close();
|
||||
unlink('temp/' . $zip_name . '.zip');
|
||||
|
||||
if ($handle = opendir('temp/extracted/' . $zip_name)) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$maxIdGroup = ImageDAL::GetMaxIdGroup();
|
||||
//$maxIdGroup++;
|
||||
MfLog::debug('pobrano max id grupy: '.$maxIdGroup);
|
||||
|
||||
if($table != null)
|
||||
{
|
||||
$maxWeight = MfLinkDAL::GetCount($id,$table,"mf_image");
|
||||
if($maxWeight == "" || $maxWeight == 0)
|
||||
$maxWeight = 0;
|
||||
}
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
if(strpos(strtolower($file), '.jpg',1) || strpos(strtolower($file), '.jpeg',1))
|
||||
{
|
||||
$db->BeginTransaction();
|
||||
|
||||
$files = array();
|
||||
$files["tmp_name"] = 'temp/extracted/' . $zip_name .'/' . $file;
|
||||
$files["type"] = "image/jpeg";
|
||||
|
||||
$obj->SetIdImageGroup($maxIdGroup);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 1));
|
||||
$obj->SetSize(1);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 2));
|
||||
$obj->SetSize(2);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 3));
|
||||
$obj->SetSize(3);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 4));
|
||||
$obj->SetSize(4);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 5));
|
||||
$obj->SetSize(5);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 6));
|
||||
$obj->SetSize(6);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
$obj->setPath(self::AddImage($obj, $files, 9));
|
||||
$obj->SetSize(9);
|
||||
$idImage = ImageDAL::Insert($obj);
|
||||
|
||||
MfLog::debug('rozpakowany obrazek: '.$file);
|
||||
|
||||
// linkujemy
|
||||
if($table != null)
|
||||
{
|
||||
$objLink = new MfLink();
|
||||
$objLink->SetSourceType($table);
|
||||
$objLink->SetIdSource($id);
|
||||
$objLink->SetDestinationType("mf_image");
|
||||
$objLink->SetIdDestination($maxIdGroup);
|
||||
$objLink->SetWeight($maxWeight);
|
||||
MfLinkDAL::Insert($objLink);
|
||||
|
||||
$maxWeight++;
|
||||
}
|
||||
|
||||
//usuwamy zdj<64>cie
|
||||
//unlink('temp/extracted/' . $zip_name .'/' .$file);
|
||||
$db->CommitTransaction();
|
||||
MfLog::debug('dodano obrazk do bazy: '.$file);
|
||||
|
||||
$maxIdGroup = ImageDAL::GetMaxIdGroup();
|
||||
|
||||
MfLog::debug('pobrano max id grupy: '.$maxIdGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
MfLog::debug('usuniety plik rozpoznany jako nieobrazek: '.$file);
|
||||
//if(is_file('temp/extracted/' . $zip_name .'/' .$file)) {unlink('temp/extracted/' . $zip_name .'/' .$file);}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
//rmdir('temp/extracted/' . $zip_name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pobieranie listy rekordow
|
||||
* @param <array> $data - pola do where
|
||||
* @param <array> $queryFields - pobierane pola
|
||||
* @param <string> $limit - limit rekordow
|
||||
* @param <string> $sortBy - sortowanie
|
||||
* @param <bool> $count - czy ma zwracac ilosc rekordow
|
||||
* @param <string> $group - grupowanie
|
||||
* @return <array> - tablica obiektow lub jesli usawiony count liczba rekordow
|
||||
*/
|
||||
|
||||
public static function GetResult($data,$limit = 0, $sortBy = null,$count = null,$groupBy = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
if($count == true)
|
||||
$select = 'count(*) as count';
|
||||
else
|
||||
$select =" " . SQL::ToSelect('Image');
|
||||
|
||||
$sql = " SELECT $select FROM mf_image WHERE 1=1 ";
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_image' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $groupBy ? " GROUP BY $groupBy " : "").
|
||||
( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$obj = new Image();
|
||||
$obj->FromArray($array[$i],1);
|
||||
|
||||
|
||||
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pobieranie listy rekordow
|
||||
* @param <array> $data - pola do where
|
||||
* @param <array> $queryFields - pobierane pola
|
||||
* @param <string> $limit - limit rekordow
|
||||
* @param <string> $sortBy - sortowanie
|
||||
* @param <bool> $count - czy ma zwracac ilosc rekordow
|
||||
* @param <string> $group - grupowanie
|
||||
* @return <array> - tablica obiektow lub jesli usawiony count liczba rekordow
|
||||
*/
|
||||
|
||||
public static function GetResultConnection($data,$limit = 0, $sortBy = null,$count = null,$groupBy = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
if($count == true)
|
||||
$select = 'count(*) as count';
|
||||
else
|
||||
$select =" " . SQL::ToSelect('Image') . ", " . SQL::ToSelect('Article') . ", " . SQL::ToSelect('Gallery') . ", " . SQL::ToSelect('Source') . ", " . SQL::ToSelect('Country');
|
||||
|
||||
$sql = " SELECT $select FROM mf_image LEFT JOIN mf_link ON mf_image.id_image_group=mf_link.id_destination
|
||||
LEFT JOIN wp_source ON wp_source.id_wp_source=mf_image.id_wp_source
|
||||
LEFT JOIN mf_article ON mf_link.id_source=mf_article.id_mf_article AND mf_link.source_type='mf_article' AND mf_link.destination_type='mf_image'
|
||||
LEFT JOIN mf_gallery ON mf_link.id_source=mf_gallery.id_mf_gallery AND mf_link.source_type='mf_gallery' AND mf_link.destination_type='mf_image'
|
||||
LEFT JOIN wp_country ON mf_link.id_source=wp_country.id_wp_country AND mf_link.source_type='wp_country' AND mf_link.destination_type='mf_image'
|
||||
|
||||
WHERE 1=1 ";
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_image' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $groupBy ? " GROUP BY $groupBy " : "").
|
||||
( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$obj = new Image();
|
||||
$obj->FromArray($array[$i],1);
|
||||
|
||||
if(!isset($done[$obj->GetId()]))
|
||||
$done[$obj->GetId()] = $obj;
|
||||
|
||||
$articleObj = new Article();
|
||||
$articleObj->FromArray($array[$i],1);
|
||||
|
||||
$galleryObj = new Gallery();
|
||||
$galleryObj->FromArray($array[$i],1);
|
||||
|
||||
$countryObj = new Country();
|
||||
$countryObj->FromArray($array[$i],1);
|
||||
|
||||
$objSource = new Source();
|
||||
$objSource->FromArray($array[$i],1);
|
||||
|
||||
$done[$obj->GetId()]->setSource($objSource);
|
||||
$done[$obj->GetId()]->setArticle($articleObj);
|
||||
$done[$obj->GetId()]->setGallery($galleryObj);
|
||||
$done[$obj->GetId()]->setCountry($countryObj);
|
||||
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table,$id,$data,$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
if($count == true)
|
||||
$select = 'count(*) as count';
|
||||
else
|
||||
$select =" " . SQL::ToSelect('Image') . ", mf_link.link_type ";
|
||||
|
||||
$sql = " SELECT $select FROM mf_image INNER JOIN mf_link ON mf_image.id_image_group=mf_link.id_destination WHERE mf_link.source_type='$table' AND mf_link.id_source=$id AND mf_link.destination_type='mf_image '";
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_image' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$obj = new Image();
|
||||
$obj->setLinkType($array[$i]['link_type']);
|
||||
$obj->FromArray($array[$i],1);
|
||||
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function GetMaxIdGroup()
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
// $sql = "SELECT MAX(id_image_group) as max FROM mf_image";
|
||||
//
|
||||
// $stmt = $db->prepare($sql)
|
||||
// ->execute();
|
||||
//
|
||||
// $array = $stmt->fetchAllAssoc();
|
||||
//
|
||||
// return $array[0]['max'];
|
||||
|
||||
//dodajemy do imagegroupdala
|
||||
$db->BeginTransaction();
|
||||
$imagegroupObj = new ImageGroup();
|
||||
$imagegroupObj->setAdds(1);
|
||||
$dalObj = ImageGroupDAL::GetDalDataObj();
|
||||
$dalObj->setObj($imagegroupObj);
|
||||
$id = ImageGroupDAL::Insert($dalObj);
|
||||
|
||||
$db->CommitTransaction();
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
public static function AvatarSave($file) {
|
||||
$id = self::GetMaxIdGroup();
|
||||
|
||||
Registry::get('db')->BeginTransaction();
|
||||
|
||||
|
||||
|
||||
$sizes = array(1,2,3);
|
||||
|
||||
$img = new Image();
|
||||
|
||||
foreach($sizes AS $size) {
|
||||
$img = new Image();
|
||||
$created = ImageDAL::AddImage($img,array('tmp_name' => $file,'type' => 'image/jpeg'),$size,true,null,null,'avatar');
|
||||
|
||||
$img->setIdImageGroup($id);
|
||||
$img->SetPath($created);
|
||||
$img->setSize($size);
|
||||
|
||||
ImageDAL::Insert($img);
|
||||
}
|
||||
|
||||
Registry::get('db')->CommitTransaction();
|
||||
|
||||
return array($id,$img->getPath());
|
||||
}
|
||||
|
||||
public static function PortfolioSave($file) {
|
||||
$id = self::GetMaxIdGroup();
|
||||
|
||||
Registry::get('db')->BeginTransaction();
|
||||
|
||||
|
||||
|
||||
$sizes = array(4,5);
|
||||
|
||||
$img = new Image();
|
||||
|
||||
foreach($sizes AS $size) {
|
||||
$img = new Image();
|
||||
$created = ImageDAL::AddImage($img,$file,$size,true,null,null,'portfolio');
|
||||
|
||||
$img->setIdImageGroup($id);
|
||||
$img->SetPath($created);
|
||||
$img->setSize($size);
|
||||
|
||||
ImageDAL::Insert($img);
|
||||
}
|
||||
|
||||
Registry::get('db')->CommitTransaction();
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function SaveImage($iid, $folder = 'Gallery', $idImageGroup = 0, $arrayDescription = array()) {
|
||||
if (!is_dir(PATH_STATIC_CONTENT."upload/".$folder."/".$iid."/")) {
|
||||
mkdir(PATH_STATIC_CONTENT."upload/".$folder."/".$iid);
|
||||
}
|
||||
|
||||
|
||||
if (SessionProxy::IsSetValue('_ARRAY_PHOTO_')) {
|
||||
|
||||
$arrayFiles = SessionProxy::GetValue('_ARRAY_PHOTO_');
|
||||
//Utils::ArrayDisplay($arrayFiles);
|
||||
if (isset($arrayFiles)) {
|
||||
//OfferDAL::UpdatePhoto($id, $arrayFiles[0]);
|
||||
if (count($arrayFiles) > 0 && !$idImageGroup && $idImageGroup == 0) {
|
||||
$objImageGroup = new ImageGroup();
|
||||
|
||||
$idImageGroup = ImageGroupDAL::Insert($objImageGroup);
|
||||
}
|
||||
foreach ($arrayFiles as $key => $files) {
|
||||
|
||||
foreach ($files as $k => $file) {
|
||||
$photo['id'] = $iid;
|
||||
$photo['kolejnosc'] = $key;
|
||||
$photo['nazwa'] = $file;
|
||||
|
||||
|
||||
$objImage = new Image();
|
||||
$objImage->SetPath($file);
|
||||
$objImage->setIdImageGroup($idImageGroup);
|
||||
if (key_exists($key, $arrayDescription)) {
|
||||
$objImage->SetDescription($arrayDescription[$key]);
|
||||
}
|
||||
|
||||
if ($k == 'th') {
|
||||
$objImage->setSize(1);
|
||||
} elseif ($k == 'full') {
|
||||
$objImage->setSize(3);
|
||||
} else {
|
||||
$objImage->setSize(2);
|
||||
}
|
||||
|
||||
|
||||
$idImage = ImageDAL::Insert($objImage);
|
||||
|
||||
$arrayPhoto[] = $photo;
|
||||
|
||||
//Utils::ArrayDisplay(PATH_STATIC_CONTENT."temp/".$file);
|
||||
|
||||
rename(PATH_STATIC_CONTENT."temp/".$file,PATH_STATIC_CONTENT."upload/".$folder."/".$iid."/".$file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
SessionProxy::ClearValue('_ARRAY_PHOTO_');
|
||||
|
||||
return $idImageGroup;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
81
_rejestracja/core/_model/ImageGroup.class.php
Normal file
81
_rejestracja/core/_model/ImageGroup.class.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* grupy obrazkow; InnoDB free: 10240 kB
|
||||
*
|
||||
*/
|
||||
|
||||
class ImageGroup extends DataObject {
|
||||
|
||||
|
||||
static $tableName ='mf_image_group';
|
||||
|
||||
static $className = __CLASS__;
|
||||
|
||||
static $classTablePK = 'id_mf_image_group';
|
||||
|
||||
protected $id;
|
||||
|
||||
private $adds;
|
||||
|
||||
static $fields = array(
|
||||
'id_mf_image_group' => 'id',
|
||||
'adds' => 'adds'
|
||||
);
|
||||
|
||||
/**
|
||||
* Setter for id (id_nmd_tag)
|
||||
*
|
||||
* @param integer $val
|
||||
*/
|
||||
public function SetId($val) {
|
||||
$this -> id = $val;
|
||||
}
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAdds() {
|
||||
return $this->adds;
|
||||
}
|
||||
|
||||
public function setAdds($adds) {
|
||||
$this->adds = $adds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
150
_rejestracja/core/_model/ImageGroupDAL.class.php
Normal file
150
_rejestracja/core/_model/ImageGroupDAL.class.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class ImageGroupDAL extends DefaultDAL {
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
public static function UpdateById($obj,$id) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_gallery SET ". SQL::ToUpdateSet($obj) ." WHERE id_mf_gallery=$id ";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
return $obj->GetId();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <type> $id
|
||||
* @return ForumThread
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
return self::GetResult(array());
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null, $cache = true) {
|
||||
|
||||
return self::DefaultGetResult(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), $data, $queryFields, $limit, $sortBy, $count, $cache);
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(!is_null(self::$objClassTable)) {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
eval('$return = '.$class.'::GetTableName();');
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return DalData
|
||||
*/
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
64
_rejestracja/core/_model/LinkLangDAL.class.php
Normal file
64
_rejestracja/core/_model/LinkLangDAL.class.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product
|
||||
*
|
||||
*/
|
||||
class LinkLangDAL {
|
||||
|
||||
public static function Add($id) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
$sql = "INSERT INTO mf_link_lang (id_lang_pl) VALUES ($id)";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
}
|
||||
|
||||
public static function Update($idPl, $idLang, $lang) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = 'SELECT id_lang_pl FROM mf_link_lang WHERE 1=1 ' .
|
||||
" AND id_lang_" . $lang . " = $idLang" .
|
||||
" GROUP BY id_lang_pl";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->execute($sql);
|
||||
if ($arrayLangId = $stmt->FetchArray()) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_link_lang SET id_lang_$lang = $idLang WHERE id_lang_pl = $idPl";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
} else {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
$sql = "INSERT INTO mf_link_lang (id_lang_pl, id_lang_$lang) VALUES ($idPl, $idLang)";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetSelected($idStructure, $lang) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = 'SELECT id_lang_pl FROM mf_link_lang WHERE 1=1 ' .
|
||||
" AND id_lang_" . $lang . " = $idStructure" .
|
||||
" GROUP BY id_lang_pl";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->execute($sql);
|
||||
if ($arrayLangId = $stmt->FetchArray()) {
|
||||
$idLangPl = $arrayLangId['id_lang_pl'];
|
||||
return $idLangPl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
73
_rejestracja/core/_model/Mailing.class.php
Normal file
73
_rejestracja/core/_model/Mailing.class.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
|
||||
class Mailing {
|
||||
|
||||
private $id;
|
||||
private $title;
|
||||
private $text;
|
||||
private $lastSend;
|
||||
private $dateSend;
|
||||
private $type;
|
||||
private $executed;
|
||||
|
||||
public function __construct($id = '', $title = '', $text = '', $lastSend = '', $dateSend= '', $type = '', $executed= '') {
|
||||
$this->SetId($id);
|
||||
$this->SetTitle($title);
|
||||
$this->SetText($text);
|
||||
$this->SetLastSend($lastSend);
|
||||
$this->SetDateSend($dateSend);
|
||||
$this->SetType($type);
|
||||
$this->SetExecuted($executed);
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
public function SetTitle($title) {
|
||||
$this->title = stripslashes($title);
|
||||
}
|
||||
public function SetText($text) {
|
||||
$this->text = stripslashes($text);
|
||||
}
|
||||
public function SetLastSend($lastSend) {
|
||||
$this->lastSend = $lastSend;
|
||||
}
|
||||
public function SetDateSend($dateSend) {
|
||||
$this->dateSend = $dateSend;
|
||||
}
|
||||
public function SetType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
public function SetExecuted($executed) {
|
||||
$this->executed = $executed;
|
||||
}
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
public function GetTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
public function GetText() {
|
||||
return $this->text;
|
||||
}
|
||||
public function GetTextClear() {
|
||||
return addslashes($this->text);
|
||||
}
|
||||
public function GetLastSend() {
|
||||
return $this->lastSend;
|
||||
}
|
||||
public function GetDateSend() {
|
||||
return $this->dateSend;
|
||||
}
|
||||
public function GetType() {
|
||||
return $this->type;
|
||||
}
|
||||
public function GetExecuted() {
|
||||
return $this->executed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
438
_rejestracja/core/_model/MailingDAL.class.php
Normal file
438
_rejestracja/core/_model/MailingDAL.class.php
Normal file
@@ -0,0 +1,438 @@
|
||||
<?
|
||||
|
||||
class MailingDAL {
|
||||
|
||||
public function GetAll($offset = 0, $limit = 50) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " SELECT ".
|
||||
" id_mf_mailing_archive, title, text, last_send, date_send, type, executed ".
|
||||
" FROM mf_mailing_archive ".
|
||||
" ORDER BY id_mf_mailing_archive LIMIT ".$offset.", ".$limit;
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
while (($row = $stmt->FetchArray())) {
|
||||
$obj = new Mailing(
|
||||
$row['id_mf_mailing_archive'],
|
||||
$row['title'],
|
||||
$row['text'],
|
||||
$row['last_send'],
|
||||
$row['date_send'],
|
||||
$row['type'],
|
||||
$row['executed']
|
||||
);
|
||||
|
||||
$arrayObj[] = $obj;
|
||||
}
|
||||
if(isset($arrayObj)) {
|
||||
return $arrayObj;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetCountAll() {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = " SELECT count(*) as ile ".
|
||||
" FROM mf_mailing_archive ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
return $array[0]["ile"];
|
||||
}
|
||||
|
||||
public function GetMailingToSend() {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " SELECT ".
|
||||
" id_mf_mailing_archive, title, text, last_send, date_send, type, executed ".
|
||||
" FROM mf_mailing_archive ".
|
||||
" WHERE executed = 0";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
if (($row = $stmt->FetchArray())) {
|
||||
$obj = new Mailing(
|
||||
$row['id_mf_mailing_archive'],
|
||||
$row['title'],
|
||||
$row['text'],
|
||||
$row['last_send'],
|
||||
$row['date_send'],
|
||||
$row['type'],
|
||||
$row['executed']
|
||||
);
|
||||
}
|
||||
if(isset($obj)) {
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetMailingById($id) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " SELECT ".
|
||||
" id_mf_mailing_archive, title, text, last_send, date_send, type, executed ".
|
||||
" FROM mf_mailing_archive ".
|
||||
" WHERE id_mf_mailing_archive = $id";
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
if (($row = $stmt->FetchArray())) {
|
||||
$obj = new Mailing(
|
||||
$row['id_mf_mailing_archive'],
|
||||
$row['title'],
|
||||
$row['text'],
|
||||
$row['last_send'],
|
||||
$row['date_send'],
|
||||
$row['type'],
|
||||
$row['executed']
|
||||
);
|
||||
}
|
||||
if(isset($obj)) {
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function CheckConfirm($code) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " SELECT ".
|
||||
" id_mf_subscription ".
|
||||
" FROM mf_subscription ".
|
||||
" WHERE MD5(email) = '$code'";
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
if (($row = $stmt->FetchArray())) {
|
||||
$sql = "UPDATE mf_subscription SET
|
||||
`confirmed` = 1,
|
||||
`active` = 1
|
||||
WHERE `id_mf_subscription` = :1 ";
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$db->prepare($sql)
|
||||
->bindParam(1, $row['id_mf_subscription'] )
|
||||
->execute();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetMailingAddressList($type = 1, $offset = 0, $limit = 50) {
|
||||
//$limit = $offset+5;
|
||||
//Utils::ArrayDisplay($offset." = ".$limit);
|
||||
$db = Registry::Get('db');
|
||||
if ($type == 1) {
|
||||
$sql = " SELECT login, name, surname FROM mf_user LIMIT ".$offset.", ".$limit;
|
||||
//Utils::ArrayDisplay(" ".$sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
$arrayUser = array();
|
||||
$arrayPackage = array();
|
||||
while (($row = $stmt->FetchArray())) {
|
||||
$arrayUser[] = array(
|
||||
'email' => $row['login'],
|
||||
'name' => $row['name']." ".$row['surname']
|
||||
);
|
||||
|
||||
if (count($arrayUser) == 5) {
|
||||
$arrayPackage[] = $arrayUser;
|
||||
$arrayUser = array();
|
||||
}
|
||||
}
|
||||
if (count($arrayUser) > 0) {
|
||||
|
||||
$arrayLast[] = $arrayUser;
|
||||
$arrayPackage = array_merge($arrayPackage, $arrayLast);
|
||||
|
||||
}
|
||||
|
||||
//Utils::ArrayDisplay($arrayPackage);
|
||||
} elseif ($type == 2) {
|
||||
$sql = " SELECT email, name FROM mf_subscription LIMIT ".$offset.", ".$limit;
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
$arrayUser = array();
|
||||
$arrayPackage = array();
|
||||
while (($row = $stmt->FetchArray())) {
|
||||
|
||||
$arrayUser[] = array(
|
||||
'email' => $row['email'],
|
||||
'name' => $row['name']
|
||||
);
|
||||
|
||||
|
||||
if (count($arrayUser) == 5) {
|
||||
$arrayPackage[] = $arrayUser;
|
||||
$arrayUser = array();
|
||||
}
|
||||
|
||||
}
|
||||
//Utils::ArrayDisplay($arrayUser);
|
||||
|
||||
if (count($arrayUser) > 0) {
|
||||
|
||||
$arrayLast[] = $arrayUser;
|
||||
$arrayPackage = array_merge($arrayPackage, $arrayLast);
|
||||
|
||||
}
|
||||
//Utils::ArrayDisplay($arrayPackage);
|
||||
|
||||
}
|
||||
if (isset($arrayPackage)) {
|
||||
return $arrayPackage;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetAllEmail($offset, $limit = 50) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " SELECT id_mf_subscription, email, name FROM mf_subscription ".
|
||||
" ORDER BY email ".
|
||||
" LIMIT ".$offset.", ".$limit
|
||||
;
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
// $arrayUser = array();
|
||||
// $arrayPackage = array();
|
||||
while (($row = $stmt->FetchArray())) {
|
||||
$arrayUser[] = array(
|
||||
'email' => $row['email'],
|
||||
'name' => $row['name'],
|
||||
'id' => $row['id_mf_subscription']
|
||||
);
|
||||
}
|
||||
if (isset($arrayUser)) {
|
||||
return $arrayUser;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetCountAllEmail() {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = " SELECT count(*) as ile ".
|
||||
" FROM mf_subscription ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
return $array[0]["ile"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Usuwa baner
|
||||
*
|
||||
* @param Int/array $id
|
||||
*/
|
||||
public static function Delete($id) {
|
||||
if (isset($id)) {
|
||||
if (is_array($id)) {
|
||||
$id_where = implode(",", $id);
|
||||
}
|
||||
else {
|
||||
$id_where = $id;
|
||||
}
|
||||
}
|
||||
$db = Registry::Get('db');
|
||||
$sql = "DELETE FROM mf_subscription WHERE id_mf_subscription IN ($id_where)";
|
||||
$db->prepare($sql)
|
||||
->bindParam(1, $id_where )
|
||||
->execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function InsertEmial($email, $name) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = " INSERT INTO mf_subscription (`email`, `name`, `date_add`) ".
|
||||
" VALUES (:01, :02, NOW()); ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $email)
|
||||
->bindParam("02", $name)
|
||||
->execute();
|
||||
|
||||
$insertionId = $stmt->GetInsertionId();
|
||||
return $insertionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice id nieaktywnych user'<27>w
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public static function CheckInactiveUser() {
|
||||
$db = Registry::Get('db');
|
||||
$sql = " SELECT ".
|
||||
" id_mf_subscription ".
|
||||
" FROM mf_subscription ".
|
||||
" WHERE date_add < (SELECT TIMESTAMPADD(DAY, -1 ,NOW())) ".
|
||||
" AND active = 0 ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
while (($row = $stmt->FetchArray())) {
|
||||
$arrayInactiveUser[] = $row['id_mf_subscription'];
|
||||
}
|
||||
if(isset($arrayInactiveUser)) {
|
||||
return $arrayInactiveUser;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* usuwa nieaktywnych/niepotwierdzonych user'ów
|
||||
*
|
||||
* @return count
|
||||
*/
|
||||
public static function ClearInactiveUser() {
|
||||
$id = MailingDAL::CheckInactiveUser();
|
||||
$logger = LoggerManager::getLogger(__CLASS__);
|
||||
$logger->debug("Czyszczenie niepotwierdzonych emaili");
|
||||
//Utils::ArrayDisplay($inactiveUser);
|
||||
if (isset($id)) {
|
||||
if (is_array($id)) {
|
||||
$id_where = implode(",", $id);
|
||||
}
|
||||
else {
|
||||
$id_where = $id;
|
||||
}
|
||||
}
|
||||
$db = Registry::Get('db');
|
||||
$sql = "DELETE FROM mf_subscription WHERE id_mf_subscription IN ($id_where)";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function UpdateLastSend($id, $offset) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_mailing_archive SET
|
||||
`last_send` = :01
|
||||
WHERE `id_mf_mailing_archive` = :02 ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $offset)
|
||||
->bindParam("02", $id)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function UpdateType($id) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_mailing_archive SET
|
||||
`type` = 2
|
||||
WHERE `id_mf_mailing_archive` = :01 ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $id)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function SetExecuted($id) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_mailing_archive SET
|
||||
`executed` = 1
|
||||
WHERE `id_mf_mailing_archive` = :01 ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $id)
|
||||
->execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dodaje nowe pytanie
|
||||
*
|
||||
* @param query $obj
|
||||
*/
|
||||
public static function Insert(Mailing $obj) {
|
||||
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = " INSERT INTO mf_mailing_archive (`title`, `text`, `last_send`, `date_send`, `type`, `executed`) ".
|
||||
" VALUES (:01, :02, :03, NOW(), :05, :06); ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $obj->GetTitle())
|
||||
->bindParam("02", $obj->GetText())
|
||||
->bindParam("03", $obj->GetLastSend())
|
||||
->bindParam("04", $obj->GetDateSend())
|
||||
->bindParam("05", $obj->GetType())
|
||||
->bindParam("06", $obj->GetExecuted())
|
||||
->execute();
|
||||
|
||||
$insertionId = $stmt->GetInsertionId();
|
||||
|
||||
|
||||
return $insertionId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modyfikuje dane pytania
|
||||
*
|
||||
* @param Query $obj
|
||||
*/
|
||||
public static function Update(Mailing $obj) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_mailing_archive SET
|
||||
`title` = :01,
|
||||
`text` = :02,
|
||||
`last_send` = :03,
|
||||
`date_send` = :04,
|
||||
`type` = :05,
|
||||
`executed` = :06
|
||||
WHERE `id_mf_mailing_archive` = :07 ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $obj->GetTitle())
|
||||
->bindParam("02", $obj->GetText())
|
||||
->bindParam("03", $obj->GetLastSend())
|
||||
->bindParam("04", $obj->GetDateSend())
|
||||
->bindParam("05", $obj->GetType())
|
||||
->bindParam("06", $obj->GetExecuted())
|
||||
->bindParam("07", $obj->GetId())
|
||||
->execute();
|
||||
|
||||
return $obj->GetId();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Zapisuje modyfikuje pytanie
|
||||
*
|
||||
* @param Query $obj
|
||||
*/
|
||||
public function Save(Mailing $obj) {
|
||||
$id = $obj->GetId();
|
||||
if ($id > 0) {
|
||||
MailingDAL::Update($obj);
|
||||
//$admin = AuthDAL::GetAdmin();
|
||||
} else {
|
||||
$id = MailingDAL::Insert($obj);
|
||||
//$admin = AuthDAL::GetAdmin();
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
155
_rejestracja/core/_model/MfAdmin.class.php
Normal file
155
_rejestracja/core/_model/MfAdmin.class.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa administratora
|
||||
*
|
||||
*/
|
||||
class MfAdmin extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_admin';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_admin';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_admin' =>'id',
|
||||
'login' =>'login',
|
||||
'password' =>'password',
|
||||
'email' =>'email',
|
||||
'last_login'=>'lastLogin'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $login;
|
||||
private $password;
|
||||
private $email;
|
||||
private $lastLogin;
|
||||
|
||||
private $adminAccessList;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetLogin() {
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function SetLogin($login) {
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
public function GetPassword() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function SetPassword($password) {
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
public function GetEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function SetEmail($email) {
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function GetLastLogin() {
|
||||
return $this->lastLogin;
|
||||
}
|
||||
|
||||
public function SetLastLogin($lastLogin) {
|
||||
$this->lastLogin = $lastLogin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetAdminAccessList() {
|
||||
|
||||
if(!is_array($this->adminAccessList)) {
|
||||
$data = MfAdminAccessDAL::GetUserAccessList($this->GetId());
|
||||
foreach($data as $dataObj) {
|
||||
$this->adminAccessList[$dataObj->GetRole()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->adminAccessList;
|
||||
}
|
||||
|
||||
public function SetAdminAccessList($adminAccessList) {
|
||||
$this->adminAccessList = $adminAccessList;
|
||||
}
|
||||
|
||||
public function CheckAccess($role) {
|
||||
$accesSet = $this->GetAdminAccessList();
|
||||
if(isset($accesSet[$role])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Funkcja kontrolna
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function IsAuthorized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
95
_rejestracja/core/_model/MfAdminAccess.class.php
Normal file
95
_rejestracja/core/_model/MfAdminAccess.class.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa administratora
|
||||
*
|
||||
*/
|
||||
class MfAdminAccess extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_admin_access';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_admin_access';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_admin_access' =>'id',
|
||||
'role' =>'role',
|
||||
'description' =>'description'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $role;
|
||||
private $description;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetRole() {
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
public function SetRole($role) {
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
232
_rejestracja/core/_model/MfAdminAccessDAL.class.php
Normal file
232
_rejestracja/core/_model/MfAdminAccessDAL.class.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy admina
|
||||
*
|
||||
*/
|
||||
class MfAdminAccessDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetUserAccessList($id) {
|
||||
|
||||
$data = array('mf_admin_to_group.id_mf_admin'=>$id);
|
||||
$queryFields = array();
|
||||
$count = null;
|
||||
$sortBy = null;
|
||||
$limit = null;
|
||||
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . ", mf_admin_to_group, mf_admin_group_to_access WHERE 1=1 AND mf_admin_access.id_mf_admin_access = mf_admin_group_to_access.id_mf_admin_access AND mf_admin_group_to_access.id_mf_agmin_group = mf_admin_to_group.id_mf_admin_group ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
$returnArray[$value['keyword']] = $value['replacement'];
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
167
_rejestracja/core/_model/MfAdminDAL.class.php
Normal file
167
_rejestracja/core/_model/MfAdminDAL.class.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy admina
|
||||
*
|
||||
*/
|
||||
class MfAdminDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
$returnArray[$value['keyword']] = $value['replacement'];
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
94
_rejestracja/core/_model/MfAdminGroup.class.php
Normal file
94
_rejestracja/core/_model/MfAdminGroup.class.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa administratora
|
||||
*
|
||||
*/
|
||||
class MfAdminGroup extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_admin_group';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_admin_group';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_admin_group' =>'id',
|
||||
'name' =>'name',
|
||||
'description' =>'description'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $description;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
167
_rejestracja/core/_model/MfAdminGroupDAL.class.php
Normal file
167
_rejestracja/core/_model/MfAdminGroupDAL.class.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy admina
|
||||
*
|
||||
*/
|
||||
class MfAdminGroupDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
$returnArray[$value['keyword']] = $value['replacement'];
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
93
_rejestracja/core/_model/MfAdminGroupToAccess.class.php
Normal file
93
_rejestracja/core/_model/MfAdminGroupToAccess.class.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa administratora
|
||||
*
|
||||
*/
|
||||
class MfAdminGroupToAccess extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_admin_group_to_access';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_admin_group_to_access';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_admin_group_to_access' =>'id',
|
||||
'id_mf_agmin_group' =>'idMfAdminGroup',
|
||||
'id_mf_admin_access' =>'idMfAdminAccess'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $idMfAdminGroup;
|
||||
private $idMfAdminAccess;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfAdminGroup() {
|
||||
return $this->idMfAdminGroup;
|
||||
}
|
||||
|
||||
public function SetIdMfAdminGroup($idMfAdminGroup) {
|
||||
$this->idMfAdminGroup = $idMfAdminGroup;
|
||||
}
|
||||
|
||||
public function GetIdMfAdminAccess() {
|
||||
return $this->idMfAdminAccess;
|
||||
}
|
||||
|
||||
public function SetIdMfAdminAccess($idMfAdminAccess) {
|
||||
$this->idMfAdminAccess = $idMfAdminAccess;
|
||||
}
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
167
_rejestracja/core/_model/MfAdminGroupToAccessDAL.class.php
Normal file
167
_rejestracja/core/_model/MfAdminGroupToAccessDAL.class.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy admina
|
||||
*
|
||||
*/
|
||||
class MfAdminGroupToAccessDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
$returnArray[$value['keyword']] = $value['replacement'];
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
95
_rejestracja/core/_model/MfAdminToGroup.class.php
Normal file
95
_rejestracja/core/_model/MfAdminToGroup.class.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa administratora
|
||||
*
|
||||
*/
|
||||
class MfAdminToGroup extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_admin_to_group';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_admin_to_group';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_admin_to_group' =>'id',
|
||||
'id_mf_admin_group' =>'idMfAdminGroup',
|
||||
'id_mf_admin' =>'idMfAdmin'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $idMfAdminGroup;
|
||||
private $idMfAdmin;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfAdminGroup() {
|
||||
return $this->idMfAdminGroup;
|
||||
}
|
||||
|
||||
public function SetIdMfAdminGroup($idMfAdminGroup) {
|
||||
$this->idMfAdminGroup = $idMfAdminGroup;
|
||||
}
|
||||
|
||||
public function GetIdMfAdmin() {
|
||||
return $this->idMfAdmin;
|
||||
}
|
||||
|
||||
public function SetIdMfAdmin($idMfAdmin) {
|
||||
$this->idMfAdmin = $idMfAdmin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
167
_rejestracja/core/_model/MfAdminToGroupDAL.class.php
Normal file
167
_rejestracja/core/_model/MfAdminToGroupDAL.class.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy admina
|
||||
*
|
||||
*/
|
||||
class MfAdminToGroupDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
$returnArray[$value['keyword']] = $value['replacement'];
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
162
_rejestracja/core/_model/MfArticleBox.class.php
Normal file
162
_rejestracja/core/_model/MfArticleBox.class.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Model dla klasy MfArticleBox
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
class MfArticleBox extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_article_box';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_article_box';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_article_box' => 'id',
|
||||
'name' => 'name',
|
||||
'shortnote' => 'shortnote',
|
||||
'description' => 'description',
|
||||
'publication' => 'publication',
|
||||
'date_publication' => 'datePublication',
|
||||
'lang' => 'lang'
|
||||
);
|
||||
protected $id;
|
||||
private $name;
|
||||
private $shortnote;
|
||||
private $description;
|
||||
private $publication;
|
||||
private $datePublication;
|
||||
private $lang;
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct($id = -1, $name = null, $shortnote = null, $description = null, $publication = null, $datePublication = null, $lang = null) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->shortnote = $shortnote;
|
||||
$this->description = $description;
|
||||
$this->publication = $publication;
|
||||
$this->datePublication = $datePublication;
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($s) {
|
||||
$this->name = $s;
|
||||
}
|
||||
|
||||
public function getShortnote() {
|
||||
return $this->shortnote;
|
||||
}
|
||||
|
||||
public function setShortnote($shortnote) {
|
||||
$this->shortnote = $shortnote;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function getPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function getDatePublication() {
|
||||
return $this->datePublication;
|
||||
}
|
||||
|
||||
public function setDatePublication($datePublication) {
|
||||
$this->datePublication = $datePublication;
|
||||
}
|
||||
|
||||
public function GetDatePublicationWithoutTime() {
|
||||
return substr($this->datePublication, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDatePublicationTime() {
|
||||
if (!$this->datePublication) {
|
||||
return '00';
|
||||
} else {
|
||||
return substr($this->datePublication, 11, -6);
|
||||
}
|
||||
}
|
||||
|
||||
public function getLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName() {
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields() {
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName() {
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
157
_rejestracja/core/_model/MfArticleBoxDAL.class.php
Normal file
157
_rejestracja/core/_model/MfArticleBoxDAL.class.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_article_box
|
||||
*
|
||||
*/
|
||||
class MfArticleBoxDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfArticleBox';
|
||||
protected static $objClassTable = 'mf_article_box';
|
||||
protected static $objClassTablePK = 'id_mf_article_box';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array('id'=>$id));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return MfArticleBox $obj
|
||||
*/
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfArticleBox(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
159
_rejestracja/core/_model/MfDictionary.class.php
Normal file
159
_rejestracja/core/_model/MfDictionary.class.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa slownika
|
||||
*
|
||||
*/
|
||||
class MfDictionary extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_dictionary';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_dictionary';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_dictionary' =>'id',
|
||||
'keyword' =>'keyword',
|
||||
'lang' =>'lang',
|
||||
'replacement' =>'replacement',
|
||||
//"(SELECT en.replacement FROM mf_dictionary en WHERE 1=1 AND MfDictionary_keyword = en.keyword AND lang = 'en')" =>'replacementEn'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $keyword;
|
||||
private $lang;
|
||||
private $replacement;
|
||||
private $replacementEn;
|
||||
private $replacementFr;
|
||||
private $replacementDe;
|
||||
private $replacementUa;
|
||||
private $replacementNo;
|
||||
private $replacementRu;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetKeyword() {
|
||||
return $this->keyword;
|
||||
}
|
||||
|
||||
public function SetKeyword($keyword) {
|
||||
$this->keyword = $keyword;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetReplacement() {
|
||||
return $this->replacement;
|
||||
}
|
||||
|
||||
public function SetReplacement($replacement) {
|
||||
$this->replacement = $replacement;
|
||||
}
|
||||
|
||||
public function GetReplacementEn() {
|
||||
return $this->replacementEn;
|
||||
}
|
||||
|
||||
public function SetReplacementEn($replacement) {
|
||||
$this->replacementEn = $replacement;
|
||||
}
|
||||
|
||||
public function GetReplacementFr() {
|
||||
return $this->replacementFr;
|
||||
}
|
||||
|
||||
public function SetReplacementFr($replacement) {
|
||||
$this->replacementFr = $replacement;
|
||||
}
|
||||
|
||||
public function GetReplacementDe() {
|
||||
return $this->replacementDe;
|
||||
}
|
||||
|
||||
public function SetReplacementDe($replacement) {
|
||||
$this->replacementDe = $replacement;
|
||||
}
|
||||
|
||||
public function GetReplacementUa() {
|
||||
return $this->replacementUa;
|
||||
}
|
||||
|
||||
public function SetReplacementUa($replacement) {
|
||||
$this->replacementUa = $replacement;
|
||||
}
|
||||
|
||||
public function GetReplacementNo() {
|
||||
return $this->replacementNo;
|
||||
}
|
||||
|
||||
public function SetReplacementNo($replacement) {
|
||||
$this->replacementNo = $replacement;
|
||||
}
|
||||
|
||||
public function GetReplacementRu() {
|
||||
return $this->replacementRu;
|
||||
}
|
||||
|
||||
public function SetReplacementRu($replacement) {
|
||||
$this->replacementRu = $replacement;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
289
_rejestracja/core/_model/MfDictionaryDAL.class.php
Normal file
289
_rejestracja/core/_model/MfDictionaryDAL.class.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy slownika
|
||||
*
|
||||
*/
|
||||
class MfDictionaryDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
|
||||
//MfFileDescriptionDAL::DeleteByParentId($obj->GetId());
|
||||
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
||||
*
|
||||
*/
|
||||
public static function DeleteByKey($keyword) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
$sql = "DELETE FROM mf_dictionary WHERE mf_dictionary.keyword = :01 ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01", $keyword)
|
||||
->execute();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll($data, $queryFields = array(), $limit = 0, $sortBy = null,$count = null) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$result = self::DefaultGetResult($dalData);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) .
|
||||
", (SELECT en.replacement FROM mf_dictionary en WHERE 1=1 AND MfDictionary_keyword = en.keyword AND lang = 'en') as MfDictionary_replacementEn" .
|
||||
", (SELECT ru.replacement FROM mf_dictionary ru WHERE 1=1 AND MfDictionary_keyword = ru.keyword AND lang = 'ru') as MfDictionary_replacementRu" .
|
||||
", (SELECT de.replacement FROM mf_dictionary de WHERE 1=1 AND MfDictionary_keyword = de.keyword AND lang = 'de') as MfDictionary_replacementDe" ;
|
||||
//", (SELECT fr.replacement FROM mf_dictionary fr WHERE 1=1 AND MfDictionary_keyword = fr.keyword AND lang = 'fr') as MfDictionary_replacementFr" .
|
||||
//", (SELECT ua.replacement FROM mf_dictionary ua WHERE 1=1 AND MfDictionary_keyword = ua.keyword AND lang = 'ua') as MfDictionary_replacementUa " ;
|
||||
//", (SELECT no.replacement FROM mf_dictionary no WHERE 1=1 AND MfDictionary_keyword = no.keyword AND lang = 'no') as MfDictionary_replacementNo " ;
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() .
|
||||
" WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
//Utils::ArrayDisplay($array);
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->SetReplacementEn($array[$i]['MfDictionary_replacementEn']);
|
||||
$obj->SetReplacementDe($array[$i]['MfDictionary_replacementDe']);
|
||||
$obj->SetReplacementRu($array[$i]['MfDictionary_replacementRu']);
|
||||
// $obj->SetReplacementFr($array[$i]['MfDictionary_replacementFr']);
|
||||
// $obj->SetReplacementUa($array[$i]['MfDictionary_replacementUa']);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
$returnArray[$value['keyword']] = $value['replacement'];
|
||||
}
|
||||
//Utils::ArrayDisplay($returnArray);
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function IsVariables($keyword, $lang) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::GetObjClassTable()." WHERE lang='".$lang."' AND keyword='".$keyword."'";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->execute($sql);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
if (count($array) > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
346
_rejestracja/core/_model/MfFile.class.php
Normal file
346
_rejestracja/core/_model/MfFile.class.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/**
|
||||
* Model pliku
|
||||
*
|
||||
*/
|
||||
class MfFile extends DataObject {
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_file';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_file';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
static $types = array(
|
||||
1 =>'pliki',
|
||||
);
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_file' =>'id',
|
||||
'date' =>'date' ,
|
||||
'publication' =>'publication' ,
|
||||
'weight' =>'weight' ,
|
||||
'name' =>'name',
|
||||
'picture' => 'picture',
|
||||
'id_mf_file_type' =>'type',
|
||||
'id_structure' =>'idStructure',
|
||||
'date_publication'=> 'datePublication',
|
||||
'zz_date_add' => 'addDate',
|
||||
'zz_date_edit' => 'editDate',
|
||||
'url' => 'url'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $date;
|
||||
private $publication;
|
||||
private $weight;
|
||||
private $name;
|
||||
private $lang;
|
||||
private $fileDescriptionObj;
|
||||
private $picture;
|
||||
private $pictureMini;
|
||||
private $special = 0;
|
||||
private $type;
|
||||
private $idStructure;
|
||||
private $datePublication;
|
||||
private $addDate;
|
||||
private $editDate;
|
||||
private $url;
|
||||
public $isLinked;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetDate() {
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function SetDate($date) {
|
||||
$this->date = $date;
|
||||
}
|
||||
public function GetSpecial() {
|
||||
return $this->special;
|
||||
}
|
||||
|
||||
public function SetSpecial($special) {
|
||||
$this->special = $special;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function GetWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function SetWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetNameExt() {
|
||||
$array = explode('.',$this->name);
|
||||
return end($array);
|
||||
}
|
||||
public function GetFileIcon() {
|
||||
|
||||
$array = explode('.',$this->name);
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/image/fileIcon/' . end($array).'.gif';
|
||||
//return end($array);
|
||||
}
|
||||
|
||||
public function GetNameUrl() {
|
||||
if ($this->GetName()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/File/' . $this->GetName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function GetNamePath() {
|
||||
if ($this->GetName()) {
|
||||
return Config::Get('PATH_STATIC_CONTENT') . '/upload/File/' . $this->GetName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetSize() {
|
||||
if ($this->GetName()) {
|
||||
return number_format(filesize(Config::Get('PATH_STATIC_CONTENT') . '/upload/File/' .$this->GetName()) / 1048576,2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
if($this->lang=='') {
|
||||
|
||||
$this->SetLang(Router::$curLang);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->fileDescriptionObj)) {
|
||||
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'id_mf_file'=>$this->GetId()));
|
||||
|
||||
$fileDescriptionObj = MfFileDescriptionDAL::GetResult($dalData);
|
||||
if(isset($fileDescriptionObj[0]) && is_object($fileDescriptionObj[0])) {
|
||||
$this->SetFileDescriptionObj($fileDescriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->fileDescriptionObj;
|
||||
}
|
||||
|
||||
public function SetFileDescriptionObj($fileDescriptionObj) {
|
||||
$this->fileDescriptionObj = $fileDescriptionObj;
|
||||
}
|
||||
public function SetMfFileDescription($fileDescriptionObj) {
|
||||
$this->fileDescriptionObj = $fileDescriptionObj;
|
||||
}
|
||||
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
public function GetMfLinkDescription() {
|
||||
return $this->mfLinkDescription;
|
||||
}
|
||||
|
||||
public function SetMfLinkDescription($mfLinkDescription) {
|
||||
$this->mfLinkDescription = $mfLinkDescription;
|
||||
}
|
||||
|
||||
public function SetPicture($picture) {
|
||||
$this->picture = $picture;
|
||||
}
|
||||
|
||||
public function GetPicture() {
|
||||
return $this->picture;
|
||||
}
|
||||
|
||||
public function GetPictureUrl() {
|
||||
if ($this->GetPicture()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/File/' . $this->GetPicture();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetDatePublication() {
|
||||
return $this->datePublication;
|
||||
}
|
||||
|
||||
public function GetDatePublicationWithoutTime() {
|
||||
return substr($this->datePublication, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDatePublicationTime() {
|
||||
if (!$this->datePublication) {
|
||||
return '00';
|
||||
} else {
|
||||
return substr($this->datePublication, 11, -6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function SetDatePublication($datePublication) {
|
||||
$this->datePublication = $datePublication;
|
||||
}
|
||||
|
||||
public function GetDateUpdate() {
|
||||
return $this->dateUpdate;
|
||||
}
|
||||
|
||||
public function GetDateUpdateWithoutTime() {
|
||||
return substr($this->dateUpdate, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDateUpdateTime() {
|
||||
return substr($this->dateUpdate, 11, -6);
|
||||
}
|
||||
|
||||
public function SetDateUpdate($dateUpdate) {
|
||||
$this->dateUpdate = $dateUpdate;
|
||||
}
|
||||
public function GetType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function SetType($type) {
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
public function GetIdStructure() {
|
||||
return $this->idStructure;
|
||||
}
|
||||
|
||||
public function SetIdStructure($idStructure) {
|
||||
$this->idStructure = $idStructure;
|
||||
}
|
||||
public function GetAddDate() {
|
||||
return $this->addDate;
|
||||
}
|
||||
|
||||
public function SetAddDate($add) {
|
||||
$this->addDate = $add;
|
||||
}
|
||||
|
||||
public function GetEditDate() {
|
||||
return $this->editDate;
|
||||
}
|
||||
|
||||
public function SetEditDate($edit) {
|
||||
$this->editDate = $edit;
|
||||
}
|
||||
public function GetUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function SetUrl($url) {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function getIsLinked(){
|
||||
return $this->isLinked;
|
||||
}
|
||||
|
||||
public function setIsLinked($isLinked){
|
||||
$this->isLinked = $isLinked;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
public function GetTypes(){
|
||||
return self::$types;
|
||||
}
|
||||
|
||||
public function GetTypeName($type){
|
||||
return self::$fields[$type];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
357
_rejestracja/core/_model/MfFileDAL.class.php
Normal file
357
_rejestracja/core/_model/MfFileDAL.class.php
Normal file
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obsługi plików
|
||||
*
|
||||
*/
|
||||
class MfFileDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
|
||||
MfFileDescriptionDAL::DeleteByParentId($obj->GetId());
|
||||
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
* @return MfFile $obj
|
||||
*/
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array('mf_file.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
$dalData->setJoin(array('MfFileDescription' => ' LEFT JOIN mf_file_description ON mf_file.id_mf_file=mf_file_description.id_mf_file'));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetResult($dalData) {
|
||||
$dalData->setJoin(array('MfFileDescription' => ' LEFT JOIN mf_file_description ON mf_file.id_mf_file=mf_file_description.id_mf_file'));
|
||||
return self::DefaultGetResult($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfFile(-1);
|
||||
$obj->SetFileDescriptionObj(MfFileDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetResultOld($data, $queryFields = array(), $limit = 0, $sortBy = null, $count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__ . "_" . __FUNCTION__ . "_" . md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
} else {
|
||||
if($count == true) {
|
||||
$select = "count(`mf_file`.`id_mf_file`) as count";
|
||||
} else {
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
}
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . ", mf_file_description WHERE 1=1 AND mf_file.id_mf_file=mf_file_description.id_mf_file ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if($key == "id") {
|
||||
$key = 'id_mf_file';
|
||||
}
|
||||
|
||||
if(is_array($value)) {
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
} else {
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."'": "");
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true) {
|
||||
return $array[0]['count'];
|
||||
}
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetList($data = array(), $limit = 20, $sortBy = 'id_mf_file') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setJoin(array('MfFileDescription' => ' LEFT JOIN mf_file_description ON mf_file.id_mf_file=mf_file_description.id_mf_file'));
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$result = self::GetResult($dalData);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public static function GetByLink($sourceType, $sourceId, $lang) {
|
||||
|
||||
$data = array('mf_link.source_type'=>'"'.$sourceType.'"', 'mf_link.id_source'=>$sourceId, 'mf_link.destination_type'=>'"'.self::GetObjClassTable().'"', 'mf_link.id_destination'=>self::GetObjClassTable().".".self::GetObjClassTablePK(), 'mf_link.id_mf_link'=>'mf_link_description.id_mf_link', 'mf_link_description.lang'=>'"'.$lang.'"');
|
||||
$sortBy = 'mf_link.link_type, mf_link.link_type';
|
||||
$queryFields = array();
|
||||
$limit = null;
|
||||
$count = null;
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
} else {
|
||||
if($count == true) {
|
||||
$select = "count(*) as count";
|
||||
} else {
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
}
|
||||
|
||||
$sql = " SELECT $select, mf_link_description.description as mf_link_description, mf_link.weight as mf_link_weight, mf_link.link_type as mf_link_type FROM " . self::GetObjClassTable() . ", mf_link, mf_link_description WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true) {
|
||||
return $array[0]['count'];
|
||||
}
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->SetMfLinkDescription($array[$i]['mf_link_description']);
|
||||
$obj->SetMfLinkWeight($array[$i]['mf_link_weight']);
|
||||
$obj->SetMfLinkType($array[$i]['mf_link_type']);
|
||||
$obj->SetLang($lang);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public function SaveFromPost($_POST, $className) {
|
||||
//Utils::ArrayDisplay($_POST);
|
||||
if (isset($_POST['File']['idFile']) && $_POST['File']['idFile'] > 0) {
|
||||
|
||||
$objFile = MfFileDAL::GetById($_POST['File']['idFile']);
|
||||
$objFileDescription = MfFileDescriptionDAL::GetResult(array('publication' => 1, 'lang' => $objFile->GetLang(), 'id_mf_file' => $objFile->GetId()), array('id_mf_file_description', 'title', 'description', 'shortnote'));
|
||||
$objFileDescription = $objFileDescription[0];
|
||||
} else {
|
||||
$objFile = new MfFile();
|
||||
$objFileDescription = new MfFileDescription();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// var_dump($objFileDescription->GetId());
|
||||
|
||||
$objFile->SetDate(date('Y-d-m'));
|
||||
$objFile->SetWeight(10);
|
||||
//$objFile->SetPublication(1);
|
||||
//Utils::ArrayDisplay($objFile);
|
||||
$iid = MfFileDAL::Save($objFile);
|
||||
|
||||
$objFileDescription->SetLang('pl');
|
||||
$objFileDescription->SetDescription($_POST['File']['tresc']);
|
||||
$objFileDescription->SetShortnote($_POST['File']['zajawka']);
|
||||
$objFileDescription->SetTitle($_POST['tytul']);
|
||||
$objFileDescription->SetBrowserTitle($_POST['File']['tytulWPrzegladarce']);
|
||||
$objFileDescription->SetPublication($_POST['publication']);
|
||||
$objFileDescription->SetIdMfFile($iid);
|
||||
|
||||
MfFileDescriptionDAL::Save($objFileDescription);
|
||||
|
||||
return $iid;
|
||||
}
|
||||
|
||||
public function Special($id = -1, $specjal) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
|
||||
$sql = "UPDATE mf_file SET special = $specjal
|
||||
WHERE id_mf_file = $id ";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
139
_rejestracja/core/_model/MfFileDescription.class.php
Normal file
139
_rejestracja/core/_model/MfFileDescription.class.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa jezykowa mfFilea
|
||||
*
|
||||
*/
|
||||
class MfFileDescription extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_file_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_file_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*
|
||||
* id_mf_file description lang publication
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_file_description' => 'id',
|
||||
'id_mf_file' => 'idMfFile' ,
|
||||
'description' => 'description' ,
|
||||
'title' => 'title' ,
|
||||
'lang' => 'lang',
|
||||
'publication' => 'publication'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $idMfFile;
|
||||
private $description;
|
||||
private $title;
|
||||
private $lang;
|
||||
private $publication;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfFile() {
|
||||
return $this->idMfFile;
|
||||
}
|
||||
|
||||
public function SetIdMfFile($idMfFile) {
|
||||
$this->idMfFile = $idMfFile;
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function GetTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function SetTitle($title) {
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
231
_rejestracja/core/_model/MfFileDescriptionDAL.class.php
Normal file
231
_rejestracja/core/_model/MfFileDescriptionDAL.class.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obsugi mf Filea
|
||||
*
|
||||
*/
|
||||
class MfFileDescriptionDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function DeleteByParentId($id) {
|
||||
$sql = "DELETE FROM `mf_file_description` WHERE `id_mf_file`=:0";
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->Prepare($sql)
|
||||
->BindParam(0, $id)
|
||||
->Execute();
|
||||
}
|
||||
|
||||
public static function GetResult($dalData) {
|
||||
return self::DefaultGetResult($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new MfFileDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetResultOld($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_file_description' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." '". $value['value'] ."' " : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."' " : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
188
_rejestracja/core/_model/MfHomeSite.class.php
Normal file
188
_rejestracja/core/_model/MfHomeSite.class.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa prostych artykulow
|
||||
*
|
||||
*/
|
||||
class MfHomeSite extends DataObject {
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_home_site';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_home_site';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
* `id_mf_home_site`, `lang``description`, `id_source`, `sort`, `photo`
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_home_site' =>'id',
|
||||
'lang' =>'lang' ,
|
||||
'name' =>'name',
|
||||
'description' =>'description',
|
||||
'id_source' => 'idSource',
|
||||
'sort' =>'sort',
|
||||
'photo' =>'photo',
|
||||
'type' =>'type',
|
||||
'source_url' =>'sourceUrl'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $lang;
|
||||
private $name;
|
||||
private $description;
|
||||
private $idSource;
|
||||
private $sort;
|
||||
private $photo;
|
||||
private $type;
|
||||
private $sourceUrl;
|
||||
public $objSource;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($d) {
|
||||
$this->description = $d;
|
||||
}
|
||||
public function GetIdSource() {
|
||||
return $this->idSource;
|
||||
}
|
||||
|
||||
public function SetIdSource($idSource) {
|
||||
$this->idSource = $idSource;
|
||||
}
|
||||
|
||||
public function GetSort() {
|
||||
return $this->sort;
|
||||
}
|
||||
|
||||
public function SetSort($sort) {
|
||||
$this->sort = $sort;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetSourceUrl() {
|
||||
return $this->sourceUrl;
|
||||
}
|
||||
|
||||
public function SetSourceUrl($sourceUrl) {
|
||||
$this->sourceUrl = $sourceUrl;
|
||||
}
|
||||
public function GetType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function SetType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
if($this->lang=='') {
|
||||
|
||||
$this->SetLang(Router::$curLang);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
public function SetPhoto($photo) {
|
||||
return $this->photo = $photo;
|
||||
}
|
||||
|
||||
public function GetPhoto() {
|
||||
return $this->photo;
|
||||
}
|
||||
|
||||
public function GetPhotoUrl() {
|
||||
if ($this->GetPhoto()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/home/' . $this->GetPhoto();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetPhotoPath() {
|
||||
if ($this->GetPhoto()) {
|
||||
return Config::Get('PATH_STATIC_CONTENT') . '/upload/home/' . $this->GetPhoto();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
179
_rejestracja/core/_model/MfHomeSiteBaner.class.php
Normal file
179
_rejestracja/core/_model/MfHomeSiteBaner.class.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa prostych artykulow
|
||||
*
|
||||
*/
|
||||
class MfHomeSiteBaner extends DataObject {
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_home_site_baner';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_home_site_baner';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
* `id_mf_home_site`, `lang``description`, `id_source`, `sort`, `photo`
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_home_site_baner' =>'id',
|
||||
'lang' =>'lang' ,
|
||||
'name' =>'name',
|
||||
'description' =>'description',
|
||||
'id_source' => 'idSource',
|
||||
'sort' =>'sort',
|
||||
'photo' =>'photo',
|
||||
'source_url' =>'sourceUrl'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $lang;
|
||||
private $name;
|
||||
private $description;
|
||||
private $idSource;
|
||||
private $sort;
|
||||
private $photo;
|
||||
private $sourceUrl;
|
||||
public $objSource;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($d) {
|
||||
$this->description = $d;
|
||||
}
|
||||
public function GetIdSource() {
|
||||
return $this->idSource;
|
||||
}
|
||||
|
||||
public function SetIdSource($idSource) {
|
||||
$this->idSource = $idSource;
|
||||
}
|
||||
|
||||
public function GetSort() {
|
||||
return $this->sort;
|
||||
}
|
||||
|
||||
public function SetSort($sort) {
|
||||
$this->sort = $sort;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetSourceUrl() {
|
||||
return $this->sourceUrl;
|
||||
}
|
||||
|
||||
public function SetSourceUrl($sourceUrl) {
|
||||
$this->sourceUrl = $sourceUrl;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
if($this->lang=='') {
|
||||
|
||||
$this->SetLang(Router::$curLang);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
public function SetPhoto($photo) {
|
||||
return $this->photo = $photo;
|
||||
}
|
||||
|
||||
public function GetPhoto() {
|
||||
return $this->photo;
|
||||
}
|
||||
|
||||
public function GetPhotoUrl() {
|
||||
if ($this->GetPhoto()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/home/' . $this->GetPhoto();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetPhotoPath() {
|
||||
if ($this->GetPhoto()) {
|
||||
return Config::Get('PATH_STATIC_CONTENT') . '/upload/home/' . $this->GetPhoto();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
168
_rejestracja/core/_model/MfHomeSiteBanerDAL.class.php
Normal file
168
_rejestracja/core/_model/MfHomeSiteBanerDAL.class.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obsługi strony głownej
|
||||
*
|
||||
*/
|
||||
class MfHomeSiteBanerDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
|
||||
MfFileDescriptionDAL::DeleteByParentId($obj->GetId());
|
||||
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTable().'.'.self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
return self::GetEmptyObj();
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalData) {
|
||||
//$dalData->setJoin(array('MfFileDescription' => ' LEFT JOIN mf_file_description ON mf_file.id_mf_file=mf_file_description.id_mf_file'));
|
||||
return self::DefaultGetResult($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfHomeSiteBaner(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @return DalData
|
||||
*/
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData ;
|
||||
}
|
||||
}
|
||||
?>
|
||||
168
_rejestracja/core/_model/MfHomeSiteDAL.class.php
Normal file
168
_rejestracja/core/_model/MfHomeSiteDAL.class.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obsługi strony głownej
|
||||
*
|
||||
*/
|
||||
class MfHomeSiteDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
|
||||
MfFileDescriptionDAL::DeleteByParentId($obj->GetId());
|
||||
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTable().'.'.self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
return self::GetEmptyObj();
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalData) {
|
||||
//$dalData->setJoin(array('MfFileDescription' => ' LEFT JOIN mf_file_description ON mf_file.id_mf_file=mf_file_description.id_mf_file'));
|
||||
return self::DefaultGetResult($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfHomeSite(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @return DalData
|
||||
*/
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData ;
|
||||
}
|
||||
}
|
||||
?>
|
||||
147
_rejestracja/core/_model/MfLink.class.php
Normal file
147
_rejestracja/core/_model/MfLink.class.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa sznurka
|
||||
*
|
||||
*/
|
||||
class MfLink extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_link';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_link';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_link' =>'id',
|
||||
'source_type' =>'sourceType',
|
||||
'id_source' =>'idSource',
|
||||
'destination_type' =>'destinationType',
|
||||
'id_destination'=>'idDestination',
|
||||
'weight'=>'weight',
|
||||
'link_type'=>'linkType',
|
||||
'published'=>'published'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $sourceType;
|
||||
private $idSource;
|
||||
private $destinationType;
|
||||
private $idDestination;
|
||||
private $weight = 0;
|
||||
private $linkType;
|
||||
private $published = 1;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetSourceType() {
|
||||
return $this->sourceType;
|
||||
}
|
||||
|
||||
public function SetSourceType($sourceType) {
|
||||
$this->sourceType = $sourceType;
|
||||
}
|
||||
|
||||
public function GetIdSource() {
|
||||
return $this->idSource;
|
||||
}
|
||||
|
||||
public function SetIdSource($idSource) {
|
||||
$this->idSource = $idSource;
|
||||
}
|
||||
|
||||
public function GetDestinationType() {
|
||||
return $this->destinationType;
|
||||
}
|
||||
|
||||
public function SetDestinationType($destinationType) {
|
||||
$this->destinationType = $destinationType;
|
||||
}
|
||||
|
||||
public function GetIdDestination() {
|
||||
return $this->idDestination;
|
||||
}
|
||||
|
||||
public function SetIdDestination($idDestination) {
|
||||
$this->idDestination = $idDestination;
|
||||
}
|
||||
|
||||
public function GetWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function SetWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
public function GetLinkType() {
|
||||
return $this->linkType;
|
||||
}
|
||||
|
||||
public function SetLinkType($linkType) {
|
||||
$this->linkType = $linkType;
|
||||
}
|
||||
|
||||
public function GetPublished() {
|
||||
return $this->published;
|
||||
}
|
||||
|
||||
public function SetPublished($published) {
|
||||
$this->published = $published;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
772
_rejestracja/core/_model/MfLinkDAL.class.php
Normal file
772
_rejestracja/core/_model/MfLinkDAL.class.php
Normal file
@@ -0,0 +1,772 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy linkow
|
||||
*
|
||||
*/
|
||||
class MfLinkDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
|
||||
if($obj->GetId()==-1) {
|
||||
return self::Insert($obj);
|
||||
|
||||
} else {
|
||||
return self::Update($obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
public static function UpdateSourceId($idNew,$id,$type) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_link SET id_source=$idNew WHERE id_source=$id AND source_type='$type'";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null,$groupBy = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
if($count == true)
|
||||
$queryCacheName.="_count";
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
//( $groupBy ? " GROUP BY $groupBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli liste slowek i cacheuje
|
||||
*
|
||||
* @param integer $cacheTime
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($lang, $cacheTime) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT keyword, replacement FROM ".self::$objClassTable." WHERE lang='".$lang."'";
|
||||
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach ($array as $keyword => $value) {
|
||||
|
||||
$returnArray[$keyword] = $value;
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
public static function DeleteFromLink($idSource = null, $sourceType = null, $idDestination = null, $destinationType = null) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "DELETE FROM `mf_link` WHERE 1=1 ";
|
||||
|
||||
if($idSource!= null )
|
||||
$sql.= " AND id_source = :01 ";
|
||||
|
||||
if($sourceType!= null)
|
||||
$sql.= " AND source_type = :02 ";
|
||||
|
||||
if($idDestination!= null)
|
||||
$sql.= " AND id_destination = :03 ";
|
||||
|
||||
if($destinationType!= null)
|
||||
$sql.= " AND destination_type = :04 ";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
|
||||
if($idSource!= null )
|
||||
$stmt->bindParam('01', $idSource);
|
||||
|
||||
if($sourceType!= null)
|
||||
$stmt->bindParam('02', $sourceType);
|
||||
|
||||
if($idDestination!= null)
|
||||
$stmt->bindParam('03', $idDestination);
|
||||
if($destinationType!= null)
|
||||
$stmt->bindParam('04', $destinationType);
|
||||
$stmt->execute();
|
||||
//Utils::ArrayDisplay($stmt);
|
||||
}
|
||||
|
||||
public static function SortLink($idSource,$sortedLinks,$sourceType,$destinationType)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
foreach ($sortedLinks as $weight => $idDestination)
|
||||
{
|
||||
$sql = "UPDATE mf_link SET weight = $weight WHERE id_source=:01 AND id_destination =:02 AND source_type=:03 AND destination_type=:04";
|
||||
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam("01", $idSource)
|
||||
->bindParam("02", $idDestination)
|
||||
->bindParam("03", $sourceType)
|
||||
->bindParam("04", $destinationType)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public static function SortLink2($sortedLinks)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
foreach ($sortedLinks as $weight => $idDestination)
|
||||
{
|
||||
$sql = "UPDATE mf_link SET weight = $weight WHERE id_mf_link=:01";
|
||||
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam("01", $idDestination)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function GetMaxWeight($idSource,$sourceType)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT MAX(weight) as max FROM mf_link WHERE id_source=:01 AND source_type=:02";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01",$idSource)
|
||||
->bindParam("02",$sourceType)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
return $array[0]['max'];
|
||||
}
|
||||
|
||||
public static function UpdateType(MfLink $obj)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE mf_link SET link_type='" . $obj->GetLinkType() . "' WHERE source_type='" . $obj->GetSourceType(). "' AND id_source='" . $obj->GetIdSource() . "' AND id_destination='" . $obj->GetIdDestination() . "' AND destination_type='" . $obj->GetdestinationType() . "'";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function GetCount($idSource,$sourceType,$destinationType)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT count(weight) as max FROM mf_link WHERE id_source=:01 AND source_type=:02 AND destination_type=:03";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01",$idSource)
|
||||
->bindParam("02",$sourceType)
|
||||
->bindParam("03",$destinationType)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
return $array[0]['max'];
|
||||
}
|
||||
|
||||
public static function GetCountDestination($sourceType,$destinationType)
|
||||
{
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql="SELECT count( id_destination ) as countDestination, id_source as id_source
|
||||
FROM `mf_link`
|
||||
WHERE `source_type` = :01
|
||||
AND `destination_type` = :02
|
||||
GROUP BY id_source
|
||||
";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->bindParam("01",$sourceType)
|
||||
->bindParam("02",$destinationType)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
$returnArray = array();
|
||||
foreach($array as $key => $value)
|
||||
{
|
||||
$returnArray[$value['id_source']] = $value['countDestination'];
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
public function ReCountWeight($idSource,$sourceType,$destinationType)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
$mfLinkArray = self::GetResult(array("id_source" => $idSource, "source_type" => "'" . $sourceType . "'", "destination_type" => "'" . $destinationType. "'"),array(),null,"weight");
|
||||
$weight = 0;
|
||||
foreach ($mfLinkArray as $key => $value)
|
||||
{
|
||||
$value->SetWeight($weight);
|
||||
MfLinkDAL::Update($value);
|
||||
$weight++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function GetQuerySourceIds($sourceType,$destinationType,$idDestination = array(),$limit = null,$cacheTime = 360)
|
||||
{
|
||||
$db = Registry::Get('db');
|
||||
$arrayReturn = array();
|
||||
$idDestnationSql = "";
|
||||
if(count($idDestination) > 1)
|
||||
{
|
||||
foreach($idDestination as $key => $value)
|
||||
{
|
||||
$idDestnationSql.=$value . ",";
|
||||
}
|
||||
$idDestnationSql = substr($idDestnationSql, 0,strlen($idDestnationSql)-1);
|
||||
$idDestnationSql = " IN (" . $idDestnationSql . ")";
|
||||
}
|
||||
else if(isset($idDestination[0]) && is_numeric($idDestination[0]))
|
||||
{
|
||||
$idDestnationSql="=" . $idDestination[0];
|
||||
}
|
||||
|
||||
$sql = "";
|
||||
if($idDestnationSql != "")
|
||||
{
|
||||
$sql = "SELECT id_source from mf_link WHERE source_type='$sourceType'
|
||||
AND destination_type='$destinationType' AND id_destination$idDestnationSql ORDER BY id_source DESC";
|
||||
if($limit != null)
|
||||
$sql .=" LIMIT $limit";
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->CacheStart($cacheTime);
|
||||
$stmt->execute();
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
if(count($array) == 1)
|
||||
return array($array[0]['id_source']);
|
||||
else if( count($array) > 1)
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$arrayReturn[]=$value['id_source'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arrayReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function GetArrayId($source , $destination, $idDestination) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_source FROM `mf_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND `id_destination` = $idDestination";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_source'];
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
public static function GetIdString($source , $destination, $idDestination, $idDestinationNotIN = null) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_source FROM `mf_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' ".
|
||||
($idDestination ? " AND `id_destination` = $idDestination " : "").
|
||||
($idDestinationNotIN ? " AND `id_destination` NOT IN ($idDestinationNotIN) " : "").
|
||||
" GROUP BY id_source ";
|
||||
$stmt=$db->prepare($sql)->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
if ($stmt->NumRows() > 0) {
|
||||
|
||||
}
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$ids = '( ';
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_source'];
|
||||
}
|
||||
if (count($returnArray) > 0) {
|
||||
$ids .= implode(',', $returnArray);
|
||||
} else {
|
||||
$ids .= '-1';
|
||||
}
|
||||
$ids .= ' )';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function GetIdStringClear($source , $destination, $idDestination) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_source FROM `mf_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND `id_destination` IN ( $idDestination ) GROUP BY id_source";
|
||||
$stmt=$db->prepare($sql)->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
if ($stmt->NumRows() > 0) {
|
||||
|
||||
}
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$ids = '';
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_source'];
|
||||
}
|
||||
if (count($returnArray) > 0) {
|
||||
$ids .= implode(',', $returnArray);
|
||||
} else {
|
||||
$ids .= '-1';
|
||||
}
|
||||
//$ids .= ' )';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function GetIdStringForDestinationArray($source , $destination, $destinationIds, $excludedSourceIds = "(-1)") {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_source FROM `mf_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND `id_destination` IN $destinationIds AND id_source NOT IN $excludedSourceIds GROUP BY id_source";
|
||||
$stmt=$db->prepare($sql)->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
if ($stmt->NumRows() > 0) {
|
||||
|
||||
}
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$ids = '( ';
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_source'];
|
||||
}
|
||||
if (count($returnArray) > 0) {
|
||||
$ids .= implode(',', $returnArray);
|
||||
} else {
|
||||
$ids .= '-1';
|
||||
}
|
||||
$ids .= ' )';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function GetArrayIdDestinaion($source , $destination, $idSource) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT `id_destination` FROM `mf_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND `id_source` = $idSource";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[$row['id_destination']] = $row['id_destination'];
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
public function GetIdStringDestinaion($source , $destination, $idSource) {
|
||||
$ids = '(-1)';
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_destination FROM `mf_link` WHERE `source_type` = :01 AND `destination_type` = :02 AND `id_source` = :03";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam ('01', $source)
|
||||
->bindParam ('02', $destination)
|
||||
->bindParam ('03', $idSource)
|
||||
->execute();
|
||||
|
||||
if ($stmt->NumRows() > 0) {
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$ids = '(';
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_destination'];
|
||||
}
|
||||
if (count($returnArray) > 0) {
|
||||
$ids .= implode(' ,', $returnArray);
|
||||
} else {
|
||||
$ids .= '-1';
|
||||
}
|
||||
$ids .= ' )';
|
||||
return $ids;
|
||||
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public static function DeleteAllLink($idSource, $sourceType, $destinationType) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "DELETE FROM `mf_link` WHERE id_source = :01 AND source_type = :02 AND destination_type = :04 ";
|
||||
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam ('01', $idSource)
|
||||
->bindParam ('02', $sourceType)
|
||||
->bindParam ('04', $destinationType)
|
||||
->execute();
|
||||
|
||||
}
|
||||
|
||||
public static function GetArrayList($table, $column, $destination, $lang = null, $source, $idSource, $where = '', $tableJoin = '', $limit = 0) {
|
||||
$array = array();
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " CHECK TABLE $table FAST QUICK";
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
$row = $stmt->FetchArray();
|
||||
|
||||
if (isset($row['Msg_type']) && strtolower($row['Msg_type']) != 'error') {
|
||||
if (isset($row[0]['Msg_type']) && $row[0]['Msg_type'] != 'error') {
|
||||
|
||||
$sql = 'SELECT '.$table.'.id_'.$destination.', '.$column.
|
||||
' FROM '.$table. ( $tableJoin ? " ,$tableJoin " : " ").
|
||||
' WHERE 1=1 '.
|
||||
$where . " " .
|
||||
( $limit ? " LIMIT " . $limit : "");
|
||||
//echo $sql;
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
$ids = '';
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$array[$row['id_'.$destination.'']] = array( 'name' => $row[$column], 'checked' => '', 'description' => '', 'icon' => null);
|
||||
$icon = null;
|
||||
foreach(SimpleArticle_MfArticleCategory::$exts as $ext) {
|
||||
$path = PATH_STATIC_CONTENT."image".DS."Admin".DS."Categories".DS."Icons".DS.$row['id_'.$destination.''].".".$ext;
|
||||
$url = URL_STATIC_CONTENT."/image/Admin/Categories/Icons/".$row['id_'.$destination.''].".".$ext;
|
||||
if(file_exists($path)) {
|
||||
$icon = $url;
|
||||
}
|
||||
$array[$row['id_'.$destination.'']]['icon'] = $icon;
|
||||
}
|
||||
$ids .= $row['id_'.$destination.''].",";
|
||||
}
|
||||
|
||||
$ids = substr($ids, 0, -1);
|
||||
$ids = !$ids ? "-1" : $ids;
|
||||
|
||||
// stary sql
|
||||
$sql = "SELECT a.id_destination FROM mf_link a WHERE source_type = '$source' AND destination_type = '$destination' ".
|
||||
" AND id_destination IN ($ids) AND id_source = '$idSource' ";
|
||||
//$sql = "SELECT id_desti//$sql =nation FROM mf_link a WHERE source_type = '$source' AND destination_type = '$destination' AND id_source = '$idSource'";
|
||||
|
||||
$stmt2 = $db->execute($sql);
|
||||
while(($row = $stmt2->FetchArray())) {
|
||||
$array[$row['id_destination']]['checked'] = 'checked';
|
||||
}
|
||||
}
|
||||
}
|
||||
//echo $where;
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function GetLinkedArticles($id, $data = array(), $queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
$data['mf_article.publication'] = array('value' => -1, 'condition' => '>');
|
||||
$data['mf_link.id_source'] = $id;
|
||||
$data['mf_link.destination_type'] = '\'mf_article\'';
|
||||
$data['mf_link.source_type'] = '\'mf_article\'';
|
||||
|
||||
if(!is_array($data)) {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
if($count == true)
|
||||
$queryCacheName .="_count";
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else {
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . ", " . SQL::ToSelect('MfArticle') . ", " . SQL::ToSelect('MfArticleDescription') . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " LEFT JOIN mf_article ON mf_article.id_mf_article=mf_link.id_destination LEFT JOIN mf_article_description ON mf_article.id_mf_article=mf_article_description.id_mf_article WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className = 'MfArticle';
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i], 1);
|
||||
|
||||
$objDesc = new MfArticleDescription();
|
||||
$objDesc->FromArray($array[$i], 1);
|
||||
$obj->SetArticleDescriptionObj($objDesc);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
public function IsLinked($idSource = null, $sourceType = null, $idDestination = null, $destinationType = null, $published = '-1', $idSourceSql = '=') {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT count(id_mf_link) as count FROM `mf_link` WHERE 1=1 AND published NOT IN (".$published.") ";
|
||||
|
||||
if($idSource!= null )
|
||||
$sql.= " AND id_source ".$idSourceSql." $idSource ";
|
||||
|
||||
if($sourceType!= null)
|
||||
$sql.= " AND source_type = :02 ";
|
||||
|
||||
if($idDestination!= null)
|
||||
$sql.= " AND id_destination ".$idSourceSql." $idDestination ";
|
||||
|
||||
if($destinationType!= null)
|
||||
$sql.= " AND destination_type = :04 ";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
|
||||
if($idSource!= null )
|
||||
$stmt->bindParam('01', $idSource);
|
||||
|
||||
if($sourceType!= null)
|
||||
$stmt->bindParam('02', $sourceType);
|
||||
|
||||
if($idDestination!= null)
|
||||
$stmt->bindParam('03', $idDestination);
|
||||
if($destinationType!= null)
|
||||
$stmt->bindParam('04', $destinationType);
|
||||
$stmt->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
|
||||
|
||||
return $array[0]['count'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
|
||||
public static function UpdateDestinationId($idNew,$id,$source, $destination) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_link SET id_destination=$idNew WHERE id_destination=$id AND source_type='$source' AND destination_type = '$destination'";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
}
|
||||
|
||||
public static function UpdatePublished($published = 1, $idSource = null, $sourceType = null, $destinationType = null, $idDestination = null, $idSourceSql = '=') {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "UPDATE `mf_link` ";
|
||||
|
||||
$sql.= " SET published = :05 ";
|
||||
|
||||
$sql.= "WHERE 1=1 ";
|
||||
|
||||
if($idSource!= null )
|
||||
$sql.= " AND id_source ".$idSourceSql." ".$idSource." ";
|
||||
|
||||
if($sourceType!= null)
|
||||
$sql.= " AND source_type = :02 ";
|
||||
|
||||
if($idDestination!= null)
|
||||
$sql.= " AND id_destination = :03 ";
|
||||
|
||||
if($destinationType!= null)
|
||||
$sql.= " AND destination_type = :04 ";
|
||||
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
|
||||
//if($idSource!= null )
|
||||
//$stmt->bindParam('01', $idSource);
|
||||
|
||||
if($sourceType!= null)
|
||||
$stmt->bindParam('02', $sourceType);
|
||||
|
||||
if($idDestination!= null)
|
||||
$stmt->bindParam('03', $idDestination);
|
||||
if($destinationType!= null)
|
||||
$stmt->bindParam('04', $destinationType);
|
||||
$stmt->bindParam('05', $published);
|
||||
$stmt->execute();
|
||||
//Utils::ArrayDisplay($stmt);
|
||||
}
|
||||
}
|
||||
?>
|
||||
129
_rejestracja/core/_model/MfLinkDescription.class.php
Normal file
129
_rejestracja/core/_model/MfLinkDescription.class.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa jezykowa mfLinka
|
||||
*
|
||||
*/
|
||||
class MfLinkDescription extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_link_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_link_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*
|
||||
* id_mf_link description lang publication
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_link_description' => 'id',
|
||||
'id_mf_link' => 'idMfLink' ,
|
||||
'description' => 'description' ,
|
||||
'lang' => 'lang',
|
||||
'publication' => 'publication'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $idMfLink;
|
||||
private $description;
|
||||
private $lang;
|
||||
private $publication;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfLink() {
|
||||
return $this->idMfLink;
|
||||
}
|
||||
|
||||
public function SetIdMfLink($idMfLink) {
|
||||
$this->idMfLink = $idMfLink;
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
166
_rejestracja/core/_model/MfLinkDescriptionDAL.class.php
Normal file
166
_rejestracja/core/_model/MfLinkDescriptionDAL.class.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obsugi mf Linka
|
||||
*
|
||||
*/
|
||||
class MfLinkDescriptionDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function DeleteByParentId($id) {
|
||||
$sql = "DELETE FROM `mf_link_description` WHERE `id_mf_link`=:0";
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->Prepare($sql)
|
||||
->BindParam(0, $id)
|
||||
->Execute();
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new MfLinkDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_link_description' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." '". $value['value'] ."' " : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."' " : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
129
_rejestracja/core/_model/MfMetaTag.class.php
Normal file
129
_rejestracja/core/_model/MfMetaTag.class.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa sznurka
|
||||
*
|
||||
*/
|
||||
class MfMetaTag extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_meta_tag';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_meta_tag';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_meta_tag' =>'id',
|
||||
'source_type' =>'sourceType',
|
||||
'id_source' =>'idSource',
|
||||
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $sourceType;
|
||||
private $idSource;
|
||||
public $metaDescriptionObj;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetSourceType() {
|
||||
return $this->sourceType;
|
||||
}
|
||||
|
||||
public function SetSourceType($sourceType) {
|
||||
$this->sourceType = $sourceType;
|
||||
}
|
||||
|
||||
public function GetIdSource() {
|
||||
return $this->idSource;
|
||||
}
|
||||
|
||||
public function SetIdSource($idSource) {
|
||||
$this->idSource = $idSource;
|
||||
}
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->metaDescriptionObj)) {
|
||||
$metaDescriptionObj = MfMetaTagDescriptionDAL::GetResult(array('id_mf_meta_tag'=>$this->GetId()), array());
|
||||
//Utils::ArrayDisplay($articleDescriptionObj);
|
||||
if(isset($metaDescriptionObj[0]) && is_object($metaDescriptionObj[0])) {
|
||||
$this->SetDescriptionObj($metaDescriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().')');
|
||||
}
|
||||
}
|
||||
return $this->metaDescriptionObj;
|
||||
}
|
||||
|
||||
public function SetDescriptionObj($metaDescriptionObj) {
|
||||
$this->metaDescriptionObj = $metaDescriptionObj;
|
||||
}
|
||||
public function SetMfMetaTagDescription($metaDescriptionObj) {
|
||||
$this->metaDescriptionObj = $metaDescriptionObj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Eksperymentalne przeciazenie metod kierowane do podobiektu slownikowego
|
||||
*/
|
||||
// public function __call($name, $param) {
|
||||
//
|
||||
// $obj = $this->GetDescriptionObj();
|
||||
//
|
||||
// return $obj->$name($param);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
229
_rejestracja/core/_model/MfMetaTagDAL.class.php
Normal file
229
_rejestracja/core/_model/MfMetaTagDAL.class.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy linkow
|
||||
*
|
||||
*/
|
||||
class MfMetaTagDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::DefaultGetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetByIdSource($id, $sourceType, $lang) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array('id_source'=>$id, 'source_type' => $sourceType, 'lang' => $lang));
|
||||
$dalData->setLimit(1);
|
||||
$dalData->setJoin(array('MfMetaTagDescription' => ' LEFT JOIN mf_meta_tag_description ON mf_meta_tag.id_mf_meta_tag=mf_meta_tag_description.id_mf_meta_tag '));
|
||||
$result = self::DefaultGetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
$metaTag = new MfMetaTag();
|
||||
$metaTag->SetDescriptionObj(new MfMetaTagDescription());
|
||||
return $metaTag;
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfMetaTag(-1);
|
||||
$obj->SetMetaTagDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
136
_rejestracja/core/_model/MfMetaTagDescription.class.php
Normal file
136
_rejestracja/core/_model/MfMetaTagDescription.class.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa jezykowa prostych artykulow
|
||||
*
|
||||
*/
|
||||
class MfMetaTagDescription extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_meta_tag_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_meta_tag_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_meta_tag_description' => 'id',
|
||||
'id_mf_meta_tag' => 'idMfMetaTag' ,
|
||||
'description' => 'description' ,
|
||||
'keywords' => 'keywords',
|
||||
'lang' => 'lang',
|
||||
'statistic' => 'statistic'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $idMfMetaTag;
|
||||
private $description;
|
||||
private $keywords;
|
||||
private $lang;
|
||||
private $statistic;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfMetaTag() {
|
||||
return $this->idMfMetaTag;
|
||||
}
|
||||
|
||||
public function SetIdMfMetaTag($idMfMetaTag) {
|
||||
$this->idMfMetaTag = $idMfMetaTag;
|
||||
}
|
||||
|
||||
|
||||
public function GetDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function SetDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function GetStatistic() {
|
||||
return $this->statistic;
|
||||
}
|
||||
|
||||
public function SetStatistic($statistic) {
|
||||
$this->statistic = $statistic;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetKeywords() {
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
public function SetKeywords($keywords) {
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
226
_rejestracja/core/_model/MfMetaTagDescriptionDAL.class.php
Normal file
226
_rejestracja/core/_model/MfMetaTagDescriptionDAL.class.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obs<62>ugi prostych artykulow
|
||||
*
|
||||
*/
|
||||
class MfMetaTagDescriptionDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function DeleteByParentId($id) {
|
||||
$sql = "DELETE FROM `mf_meta_tag_description` WHERE `id_mf_meta_tag`=:0";
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->Prepare($sql)
|
||||
->BindParam(0, $id)
|
||||
->Execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new MfMetaTagDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_meta_tag_description' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." '". $value['value'] ."' " : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."' " : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
202
_rejestracja/core/_model/MfModule.class.php
Normal file
202
_rejestracja/core/_model/MfModule.class.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa modulow
|
||||
*
|
||||
*/
|
||||
class MfModule extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_module';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_module';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_module' =>'id',
|
||||
'module_title'=>'moduleTitle',
|
||||
'module_name'=>'moduleName',
|
||||
'method_title'=>'methodTitle',
|
||||
'method_name'=>'methodName',
|
||||
'method_admin_name'=>'methodAdminName',
|
||||
'options'=>'options',
|
||||
'controller'=>'controller',
|
||||
'version'=>'version',
|
||||
'table_name'=>'tableModuleName',
|
||||
'class_name'=>'classModuleName',
|
||||
'list'=>'list',
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $moduleTitle;
|
||||
private $moduleName;
|
||||
private $methodTitle;
|
||||
private $methodName;
|
||||
private $methodAdminName;
|
||||
private $options;
|
||||
private $controller;
|
||||
private $version;
|
||||
private $tableModuleName;
|
||||
private $classModuleName;
|
||||
private $catalog;
|
||||
private $list;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
public function GetList() {
|
||||
return $this->list;
|
||||
}
|
||||
|
||||
public function SetList($list) {
|
||||
$this->list = $list;
|
||||
}
|
||||
|
||||
public function GetModuleTitle() {
|
||||
return $this->moduleTitle;
|
||||
}
|
||||
|
||||
public function SetModuleTitle($moduleTitle) {
|
||||
$this->moduleTitle = $moduleTitle;
|
||||
}
|
||||
|
||||
public function GetModuleName() {
|
||||
return $this->moduleName;
|
||||
}
|
||||
|
||||
public function SetModuleName($moduleName) {
|
||||
$this->moduleName = $moduleName;
|
||||
}
|
||||
|
||||
public function GetMethodTitle() {
|
||||
return $this->methodTitle;
|
||||
}
|
||||
|
||||
public function SetMethodTitle($methodTitle) {
|
||||
$this->methodTitle = $methodTitle;
|
||||
}
|
||||
|
||||
public function GetMethodName() {
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
public function SetMethodName($methodName) {
|
||||
$this->methodName = $methodName;
|
||||
}
|
||||
|
||||
|
||||
public function GetMethodAdminName() {
|
||||
return $this->methodAdminName;
|
||||
}
|
||||
|
||||
public function SetMethodAdminName($methodAdminName) {
|
||||
$this->methodAdminName = $methodAdminName;
|
||||
}
|
||||
|
||||
public function GetOptions() {
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function GetArrayOptions() {
|
||||
return unserialize($this->options);
|
||||
}
|
||||
|
||||
public function SetOptions($options) {
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
|
||||
public function GetController() {
|
||||
return $this->controller;
|
||||
}
|
||||
|
||||
public function SetController($controller) {
|
||||
$this->controller = $controller;
|
||||
$array = explode('_', $this->controller);
|
||||
if (is_array($array)) {
|
||||
$this->catalog = $array[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function GetVersion() {
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function SetVersion($version) {
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public function GetClassModuleName() {
|
||||
return $this->classModuleName;
|
||||
}
|
||||
|
||||
public function SetClassModuleName($classModuleName) {
|
||||
$this->classModuleName = $classModuleName;
|
||||
}
|
||||
|
||||
public function GetTableModuleName() {
|
||||
return $this->tableModuleName;
|
||||
}
|
||||
|
||||
public function SetTableModuleName($tableModuleName) {
|
||||
$this->tableModuleName = $tableModuleName;
|
||||
}
|
||||
|
||||
public function GetCatalog() {
|
||||
return $this->catalog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
220
_rejestracja/core/_model/MfModuleDAL.class.php
Normal file
220
_rejestracja/core/_model/MfModuleDAL.class.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy slownika
|
||||
*
|
||||
*/
|
||||
class MfModuleDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function GetResult($dalData) {
|
||||
return self::DefaultGetResult($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetResultOLD($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public function GetModuleByName($name) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE module_name = '$name'";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
}
|
||||
|
||||
//TODO: pobrać tablię nazw do wyboru modułu
|
||||
public static function GetArrayModuleName() {
|
||||
$arrayModuleName = Utils::GetArrayList('mf_module', 'id_mf_module', 'method_title', '', ' AND publication = 1 ');
|
||||
return $arrayModuleName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
273
_rejestracja/core/_model/MfParameters.class.php
Normal file
273
_rejestracja/core/_model/MfParameters.class.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfParameters
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfParameters extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_parameters';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_parameters';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_parameters' => 'id',
|
||||
'name' => 'name',
|
||||
'opis' => 'opis',
|
||||
'list' => 'list',
|
||||
'price' => 'price',
|
||||
'price_prom' => 'priceProm',
|
||||
'type' => 'type',
|
||||
'price_type' => 'priceType',
|
||||
'link_id' => 'linkId',
|
||||
'price_progres' => 'priceProgres',
|
||||
'count_progres' => 'countProgres',
|
||||
'unit' => 'unit',
|
||||
'depend_id' => 'dependId',
|
||||
'publication' => 'publication',
|
||||
'revers' => 'revers',
|
||||
'sort' => 'sort'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $opis;
|
||||
private $list;
|
||||
private $price;
|
||||
private $priceProm;
|
||||
private $type;
|
||||
private $priceType;
|
||||
private $linkId;
|
||||
private $priceProgres;
|
||||
private $countProgres;
|
||||
private $unit;
|
||||
private $publication;
|
||||
private $sort;
|
||||
private $dependId;
|
||||
private $revers;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $name = null, $opis = null, $list = null, $price = null, $priceProm = null, $type = null, $priceType = null, $linkId = null, $priceProgres = null, $countProgres = null, $publication = null){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->opis = $opis;
|
||||
$this->list = $list;
|
||||
$this->price = $price;
|
||||
$this->priceProm = $priceProm;
|
||||
$this->type = $type;
|
||||
$this->priceType = $priceType;
|
||||
$this->linkId = $linkId;
|
||||
$this->priceProgres = $priceProgres;
|
||||
$this->countProgres = $countProgres;
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getNameText(){
|
||||
return Utils::TextToUrl($this->name);
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getOpis(){
|
||||
return $this->opis;
|
||||
}
|
||||
|
||||
public function setOpis($opis){
|
||||
$this->opis = $opis;
|
||||
}
|
||||
|
||||
|
||||
public function getList(){
|
||||
return $this->list;
|
||||
}
|
||||
|
||||
public function setList($list){
|
||||
$this->list = $list;
|
||||
}
|
||||
|
||||
|
||||
public function getPrice(){
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice($price){
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
public function getPriceProm(){
|
||||
return $this->priceProm;
|
||||
}
|
||||
|
||||
public function setPriceProm($price){
|
||||
$this->priceProm = $price;
|
||||
}
|
||||
|
||||
|
||||
public function getType(){
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type){
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
|
||||
public function getPriceType(){
|
||||
return $this->priceType;
|
||||
}
|
||||
|
||||
public function setPriceType($priceType){
|
||||
$this->priceType = $priceType;
|
||||
}
|
||||
|
||||
|
||||
public function getLinkId(){
|
||||
return $this->linkId;
|
||||
}
|
||||
|
||||
public function setLinkId($linkId){
|
||||
$this->linkId = $linkId;
|
||||
}
|
||||
|
||||
|
||||
public function getPriceProgres(){
|
||||
return $this->priceProgres;
|
||||
}
|
||||
|
||||
public function setPriceProgres($priceProgres){
|
||||
$this->priceProgres = $priceProgres;
|
||||
}
|
||||
|
||||
|
||||
public function getCountProgres(){
|
||||
return $this->countProgres;
|
||||
}
|
||||
|
||||
public function setCountProgres($countProgres){
|
||||
$this->countProgres = $countProgres;
|
||||
}
|
||||
|
||||
public function getUnit(){
|
||||
return $this->unit;
|
||||
}
|
||||
|
||||
public function setUnit($unit){
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function getDependId(){
|
||||
return $this->dependId;
|
||||
}
|
||||
|
||||
public function setDependId($depend_id){
|
||||
$this->dependId = $depend_id;
|
||||
}
|
||||
|
||||
public function getSort(){
|
||||
return $this->sort;
|
||||
}
|
||||
|
||||
public function setSort($s){
|
||||
$this->sort = $s;
|
||||
}
|
||||
|
||||
public function getRevers(){
|
||||
return $this->revers;
|
||||
}
|
||||
|
||||
public function setRevers($s){
|
||||
$this->revers = $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
154
_rejestracja/core/_model/MfParametersDAL.class.php
Normal file
154
_rejestracja/core/_model/MfParametersDAL.class.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_parameters
|
||||
*
|
||||
*/
|
||||
class MfParametersDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfParameters';
|
||||
protected static $objClassTable = 'mf_parameters';
|
||||
protected static $objClassTablePK = 'id_mf_parameters';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
//Utils::ArrayDisplay($dalData);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfParameters(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
557
_rejestracja/core/_model/MfParticipant.class.php
Normal file
557
_rejestracja/core/_model/MfParticipant.class.php
Normal file
@@ -0,0 +1,557 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfParticipant
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfParticipant extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_participant';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_participant';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'address' => 'address',
|
||||
'agree1' => 'agree1',
|
||||
'agree2' => 'agree2',
|
||||
'city' => 'city',
|
||||
'country' => 'country',
|
||||
'conference_fee' => 'conferenceFee',
|
||||
'degree' => 'degree',
|
||||
'email' => 'email',
|
||||
'fax' => 'fax',
|
||||
'fee_full' => 'feeFull',
|
||||
'fee_one_day' => 'feeOneDay',
|
||||
'id_mf_participant' => 'id',
|
||||
'institution' => 'institution',
|
||||
'message' => 'message',
|
||||
'message_long' => 'messageLong',
|
||||
'autor' => 'autor',
|
||||
'name' => 'name',
|
||||
'nip' => 'nip',
|
||||
'phone' => 'phone',
|
||||
'position' => 'position',
|
||||
'post_code' => 'postCode',
|
||||
'poster' => 'poster',
|
||||
'price' => 'price',
|
||||
'referat' => 'referat',
|
||||
'status' => 'status',
|
||||
'surname' => 'surname',
|
||||
'date_add' => 'dateAdd',
|
||||
'location' => 'location',
|
||||
'dinner' => 'dinner',
|
||||
'diet' => 'diet',
|
||||
'referat_lang' => 'referatLang',
|
||||
'poster_lang' => 'posterLang',
|
||||
'referat_file' => 'referatFile',
|
||||
'poster_file' => 'posterFile',
|
||||
'participation_option' => 'participationOption',
|
||||
'participation_days' => 'participationDays',
|
||||
'one_day_lodging' => 'oneDayLodging',
|
||||
'diet_special' => 'dietSpecial',
|
||||
'fee_room1' => 'feeRoom1',
|
||||
'fee_room_add_person' => 'feeRoomAddPerson'
|
||||
|
||||
);
|
||||
|
||||
|
||||
private $address;
|
||||
private $agree1;
|
||||
private $agree2;
|
||||
private $city;
|
||||
private $country;
|
||||
private $conferenceFee;
|
||||
private $degree;
|
||||
private $email;
|
||||
private $fax;
|
||||
private $feeFull;
|
||||
private $feeOneDay;
|
||||
protected $id;
|
||||
private $institution;
|
||||
private $message;
|
||||
private $messageLong;
|
||||
private $autor;
|
||||
private $name;
|
||||
private $nip;
|
||||
private $phone;
|
||||
private $position;
|
||||
private $postCode;
|
||||
private $poster;
|
||||
private $price;
|
||||
private $referat;
|
||||
private $status;
|
||||
private $surname;
|
||||
private $dateAdd;
|
||||
private $location;
|
||||
private $dinner;
|
||||
private $diet;
|
||||
private $referatFile;
|
||||
private $referatLang;
|
||||
private $posterFile;
|
||||
private $posterLang;
|
||||
private $participationOption;
|
||||
private $participationDays;
|
||||
private $oneDayLodging;
|
||||
private $dietSpecial;
|
||||
private $feeRoom1;
|
||||
private $feeRoomAddPerson;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $address = null, $agree1 = null, $agree2 = null, $city = null, $conferenceFee = null, $degree = null, $email = null, $fax = null, $feeFull = null, $feeOneDay = null, $id = -1 , $institution = null, $message = null, $messageLong =null, $autor = null, $name = null, $nip = null, $phone = null, $position = null, $postCode = null, $poster = null, $price = null, $referat = null, $status = null, $surname = null){
|
||||
$this->address = $address;
|
||||
$this->agree1 = $agree1;
|
||||
$this->agree2 = $agree2;
|
||||
$this->city = $city;
|
||||
$this->conferenceFee = $conferenceFee;
|
||||
$this->degree = $degree;
|
||||
$this->email = $email;
|
||||
$this->fax = $fax;
|
||||
$this->feeFull = $feeFull;
|
||||
$this->feeOneDay = $feeOneDay;
|
||||
$this->id = $id;
|
||||
$this->institution = $institution;
|
||||
$this->message = $message;
|
||||
$this->messageLong = $messageLong;
|
||||
$this->autor = $autor;
|
||||
$this->name = $name;
|
||||
$this->nip = $nip;
|
||||
$this->phone = $phone;
|
||||
$this->position = $position;
|
||||
$this->postCode = $postCode;
|
||||
$this->poster = $poster;
|
||||
$this->price = $price;
|
||||
$this->referat = $referat;
|
||||
$this->status = $status;
|
||||
$this->surname = $surname;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getAddress(){
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setAddress($address){
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
|
||||
public function getAgree1(){
|
||||
return $this->agree1;
|
||||
}
|
||||
|
||||
public function setAgree1($agree1){
|
||||
$this->agree1 = $agree1;
|
||||
}
|
||||
|
||||
|
||||
public function getAgree2(){
|
||||
return $this->agree2;
|
||||
}
|
||||
|
||||
public function setAgree2($agree2){
|
||||
$this->agree2 = $agree2;
|
||||
}
|
||||
|
||||
|
||||
public function getCity(){
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setCity($city){
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
public function getCountry(){
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function setCountry($country){
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
|
||||
public function getConferenceFee(){
|
||||
return $this->conferenceFee;
|
||||
}
|
||||
|
||||
public function setConferenceFee($conferenceFee){
|
||||
$this->conferenceFee = $conferenceFee;
|
||||
}
|
||||
|
||||
|
||||
public function getDegree(){
|
||||
return $this->degree;
|
||||
}
|
||||
|
||||
public function setDegree($degree){
|
||||
$this->degree = $degree;
|
||||
}
|
||||
|
||||
|
||||
public function getEmail(){
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail($email){
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
|
||||
public function getFax(){
|
||||
return $this->fax;
|
||||
}
|
||||
|
||||
public function setFax($fax){
|
||||
$this->fax = $fax;
|
||||
}
|
||||
|
||||
|
||||
public function getFeeFull(){
|
||||
return $this->feeFull;
|
||||
}
|
||||
|
||||
public function getFeeFullUnserialize(){
|
||||
return unserialize($this->feeFull);
|
||||
}
|
||||
|
||||
public function setFeeFull($feeFull){
|
||||
$this->feeFull = $feeFull;
|
||||
}
|
||||
|
||||
|
||||
public function getFeeOneDay(){
|
||||
return $this->feeOneDay;
|
||||
}
|
||||
|
||||
public function setFeeOneDay($feeOneDay){
|
||||
$this->feeOneDay = $feeOneDay;
|
||||
}
|
||||
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getInstitution(){
|
||||
return $this->institution;
|
||||
}
|
||||
|
||||
public function setInstitution($institution){
|
||||
$this->institution = $institution;
|
||||
}
|
||||
|
||||
|
||||
public function getMessageLong(){
|
||||
return $this->messageLong;
|
||||
}
|
||||
|
||||
public function setMessageLong($messageLong){
|
||||
$this->messageLong = $messageLong;
|
||||
}
|
||||
|
||||
public function getMessage(){
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage($message){
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
|
||||
public function getAutor(){
|
||||
return $this->autor;
|
||||
}
|
||||
|
||||
public function setAutor($s){
|
||||
$this->autor = $s;
|
||||
}
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getNip(){
|
||||
return $this->nip;
|
||||
}
|
||||
|
||||
public function setNip($nip){
|
||||
$this->nip = $nip;
|
||||
}
|
||||
|
||||
|
||||
public function getPhone(){
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone($phone){
|
||||
$this->phone = $phone;
|
||||
}
|
||||
|
||||
|
||||
public function getPosition(){
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition($position){
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
|
||||
public function getPostCode(){
|
||||
return $this->postCode;
|
||||
}
|
||||
|
||||
public function setPostCode($postCode){
|
||||
$this->postCode = $postCode;
|
||||
}
|
||||
|
||||
|
||||
public function getPoster(){
|
||||
return $this->poster;
|
||||
}
|
||||
|
||||
public function setPoster($poster){
|
||||
$this->poster = $poster;
|
||||
}
|
||||
|
||||
|
||||
public function getPrice(){
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice($price){
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
|
||||
public function getReferat(){
|
||||
return $this->referat;
|
||||
}
|
||||
|
||||
public function setReferat($referat){
|
||||
$this->referat = $referat;
|
||||
}
|
||||
|
||||
|
||||
public function getStatus(){
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus($status){
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
|
||||
public function getSurname(){
|
||||
return $this->surname;
|
||||
}
|
||||
|
||||
public function setSurname($surname){
|
||||
$this->surname = $surname;
|
||||
}
|
||||
public function getDateAdd(){
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function setDateAdd($date){
|
||||
$this->dateAdd = $date;
|
||||
}
|
||||
|
||||
public function getLocation(){
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function setLocation($location){
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
public function getDinner(){
|
||||
return $this->dinner;
|
||||
}
|
||||
|
||||
public function setDinner($dinner){
|
||||
$this->dinner = $dinner;
|
||||
}
|
||||
|
||||
public function getDiet(){
|
||||
return $this->diet;
|
||||
}
|
||||
|
||||
public function setDiet($diet){
|
||||
$this->diet = $diet;
|
||||
}
|
||||
|
||||
public function getReferatFile(){
|
||||
return $this->referatFile;
|
||||
}
|
||||
|
||||
public function setReferatFile($referatFile){
|
||||
$this->referatFile = $referatFile;
|
||||
}
|
||||
|
||||
public function getPosterFile(){
|
||||
return $this->posterFile;
|
||||
}
|
||||
|
||||
public function setPosterFile($posterFile){
|
||||
$this->posterFile = $posterFile;
|
||||
}
|
||||
|
||||
public function getPosterLang(){
|
||||
return $this->posterLang;
|
||||
}
|
||||
|
||||
public function setPosterLang($posterLang){
|
||||
$this->posterLang = $posterLang;
|
||||
}
|
||||
|
||||
public function getReferatLang(){
|
||||
return $this->referatLang;
|
||||
}
|
||||
|
||||
public function setReferatLang($referatLang){
|
||||
$this->referatLang = $referatLang;
|
||||
}
|
||||
|
||||
public function getParticipationOption(){
|
||||
return $this->participationOption;
|
||||
}
|
||||
|
||||
public function setParticipationOption($participationOption){
|
||||
$this->participationOption = $participationOption;
|
||||
}
|
||||
|
||||
public function getParticipationDays(){
|
||||
return $this->participationDays;
|
||||
}
|
||||
|
||||
public function setParticipationDays($participationDays){
|
||||
$this->participationDays = $participationDays;
|
||||
}
|
||||
|
||||
public function getOneDayLodging(){
|
||||
return $this->oneDayLodging;
|
||||
}
|
||||
|
||||
public function setOneDayLodging($oneDayLodging){
|
||||
$this->oneDayLodging = $oneDayLodging;
|
||||
}
|
||||
|
||||
public function getDietSpecial(){
|
||||
return $this->dietSpecial;
|
||||
}
|
||||
|
||||
public function setDietSpecial($dietSpecial){
|
||||
$this->dietSpecial = $dietSpecial;
|
||||
}
|
||||
|
||||
public function getFeeRoom1(){
|
||||
return $this->feeRoom1;
|
||||
}
|
||||
|
||||
public function setFeeRoom1($feeRoom1){
|
||||
$this->feeRoom1 = $feeRoom1;
|
||||
}
|
||||
|
||||
public function getFeeRoomAddPerson(){
|
||||
return $this->feeRoomAddPerson;
|
||||
}
|
||||
|
||||
public function setFeeRoomAddPerson($feeRoomAddPerson){
|
||||
$this->feeRoomAddPerson = $feeRoomAddPerson;
|
||||
}
|
||||
|
||||
public function GetPosterFileUrl() {
|
||||
if ($this->getPosterFile()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/File/' . $this->getPosterFile();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetReferatFileUrl() {
|
||||
if ($this->getReferatFile()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/File/' . $this->getReferatFile();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
146
_rejestracja/core/_model/MfParticipantDAL.class.php
Normal file
146
_rejestracja/core/_model/MfParticipantDAL.class.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_participant
|
||||
*
|
||||
*/
|
||||
class MfParticipantDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfParticipant';
|
||||
protected static $objClassTable = 'mf_participant';
|
||||
protected static $objClassTablePK = 'id_mf_participant';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
//Utils::ArrayDisplay($dalData);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfParticipant(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
213
_rejestracja/core/_model/MfProduct.class.php
Normal file
213
_rejestracja/core/_model/MfProduct.class.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProduct
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProduct extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product' => 'id',
|
||||
'publication' => 'publication',
|
||||
'weight' => 'weight',
|
||||
'date' => 'date',
|
||||
'id_mf_picture' => 'idMfPicture',
|
||||
'special' => 'special'
|
||||
//'id_structure' => 'idStructure'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $publication;
|
||||
private $weight;
|
||||
private $date;
|
||||
private $idMfPicture;
|
||||
private $special;
|
||||
private $idStructure;
|
||||
private $descriptionObj;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $publication = null, $weight = null, $date = null, $idMfPicture = null, $special = null, $idStructure = null){
|
||||
$this->id = $id;
|
||||
$this->publication = $publication;
|
||||
$this->weight = $weight;
|
||||
$this->date = $date;
|
||||
$this->idMfPicture = $idMfPicture;
|
||||
$this->special = $special;
|
||||
$this->idStructure = $idStructure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function getWeight(){
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight){
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
|
||||
public function getDate(){
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function GetDatePublicationWithoutTime() {
|
||||
return substr($this->date, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDatePublicationTime() {
|
||||
if (!$this->date) {
|
||||
return '00';
|
||||
} else {
|
||||
return substr($this->date, 11, -6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setDate($date){
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfPicture(){
|
||||
return $this->idMfPicture;
|
||||
}
|
||||
|
||||
public function setIdMfPicture($idMfPicture){
|
||||
$this->idMfPicture = $idMfPicture;
|
||||
}
|
||||
|
||||
|
||||
public function getSpecial(){
|
||||
return $this->special;
|
||||
}
|
||||
|
||||
public function setSpecial($special){
|
||||
$this->special = $special;
|
||||
}
|
||||
|
||||
|
||||
public function getIdStructure(){
|
||||
return $this->idStructure;
|
||||
}
|
||||
|
||||
public function setIdStructure($idStructure){
|
||||
$this->idStructure = $idStructure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->descriptionObj)) {
|
||||
$dalData = MfProductDescriptionDAL::GetDalDataObj();
|
||||
$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product'=>$this->GetId()));
|
||||
|
||||
$descriptionObj = MfProductDescriptionDAL::GetResult($dalData);
|
||||
if(isset($descriptionObj[0]) && is_object($descriptionObj[0])) {
|
||||
$this->SetDescriptionObj($descriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->descriptionObj;
|
||||
}
|
||||
|
||||
public function SetDescriptionObj($descriptionObj) {
|
||||
$this->descriptionObj = $descriptionObj;
|
||||
}
|
||||
public function SetMfProductDescription($descriptionObj) {
|
||||
$this->descriptionObj = $descriptionObj;
|
||||
}
|
||||
|
||||
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
208
_rejestracja/core/_model/MfProductAttribute.class.php
Normal file
208
_rejestracja/core/_model/MfProductAttribute.class.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductAttribute
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductAttribute extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_attribute';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_attribute';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_attribute' => 'id',
|
||||
'publication' => 'publication',
|
||||
'weight' => 'weight',
|
||||
'date' => 'date'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $publication;
|
||||
private $weight;
|
||||
private $date;
|
||||
private $descriptionObj;
|
||||
private $valueObj;
|
||||
private $lang;
|
||||
private $value;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $publication = null, $weight = null, $date = null){
|
||||
$this->id = $id;
|
||||
$this->publication = $publication;
|
||||
$this->weight = $weight;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function getWeight(){
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight){
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
|
||||
public function getDate(){
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate($date){
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function setValue($value){
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
public function getValue(){
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->descriptionObj)) {
|
||||
$dalData = MfProductAttributeDescriptionDAL::GetDalDataObj();
|
||||
$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product_attribute'=>$this->GetId()));
|
||||
|
||||
$descriptionObj = MfProductAttributeDescriptionDAL::GetResult($dalData);
|
||||
if(isset($descriptionObj[0]) && is_object($descriptionObj[0])) {
|
||||
$this->SetDescriptionObj($descriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->descriptionObj;
|
||||
}
|
||||
|
||||
public function SetDescriptionObj($descriptionObj) {
|
||||
$this->descriptionObj = $descriptionObj;
|
||||
}
|
||||
public function SetMfProductAttributeDescription($descriptionObj) {
|
||||
$this->descriptionObj = $descriptionObj;
|
||||
}
|
||||
|
||||
// public function SetMfProductAttributeValue($descriptionObj) {
|
||||
// $this->valueObj = $descriptionObj;
|
||||
// }
|
||||
//
|
||||
// public function SetValueObj($valueObj) {
|
||||
// $this->valueObj = $valueObj;
|
||||
// }
|
||||
//
|
||||
// public function GetValueObj() {
|
||||
// if(!is_object($this->valueObj)) {
|
||||
// $dalData = MfProductAttributeValueDAL::GetDalDataObj();
|
||||
// $dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product_attribute'=>$this->GetId()));
|
||||
//
|
||||
// $descriptionObj = MfProductAttributeDescriptionDAL::GetResult($dalData);
|
||||
// if(isset($descriptionObj[0]) && is_object($descriptionObj[0])) {
|
||||
// $this->SetDescriptionObj($descriptionObj[0]);
|
||||
// } else {
|
||||
// throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
// }
|
||||
// }
|
||||
// return $this->descriptionObj;
|
||||
// }
|
||||
|
||||
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
133
_rejestracja/core/_model/MfProductAttributeCategory.class.php
Normal file
133
_rejestracja/core/_model/MfProductAttributeCategory.class.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductAttributeCategory
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductAttributeCategory extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_attribute_category';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_attribute_category';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_attribute_category' => 'id',
|
||||
'publication' => 'publication',
|
||||
'weight' => 'weight',
|
||||
'id_parent' => 'idParent'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $publication;
|
||||
private $weight;
|
||||
private $idParent;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $publication = null, $weight = null, $idParent = null){
|
||||
$this->id = $id;
|
||||
$this->publication = $publication;
|
||||
$this->weight = $weight;
|
||||
$this->idParent = $idParent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function getWeight(){
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight){
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
|
||||
public function getIdParent(){
|
||||
return $this->idParent;
|
||||
}
|
||||
|
||||
public function setIdParent($idParent){
|
||||
$this->idParent = $idParent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
135
_rejestracja/core/_model/MfProductAttributeCategoryDAL.class.php
Normal file
135
_rejestracja/core/_model/MfProductAttributeCategoryDAL.class.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_attribute_category
|
||||
*
|
||||
*/
|
||||
class MfProductAttributeCategoryDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductAttributeCategory';
|
||||
protected static $objClassTable = 'mf_product_attribute_category';
|
||||
protected static $objClassTablePK = 'id_mf_product_attribute_category';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassName().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductAttributeCategoryDescription
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductAttributeCategoryDescription extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_attribute_category_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_attribute_category_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_attribute_category_description' => 'id',
|
||||
'name' => 'name',
|
||||
'publication' => 'publication',
|
||||
'lang' => 'lang',
|
||||
'id_mf_product_attribute_category' => 'idMfProductAttributeCategory'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $publication;
|
||||
private $lang;
|
||||
private $idMfProductAttributeCategory;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $name = null, $publication = null, $lang = null, $idMfProductAttributeCategory = null){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->publication = $publication;
|
||||
$this->lang = $lang;
|
||||
$this->idMfProductAttributeCategory = $idMfProductAttributeCategory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang){
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfProductAttributeCategory(){
|
||||
return $this->idMfProductAttributeCategory;
|
||||
}
|
||||
|
||||
public function setIdMfProductAttributeCategory($idMfProductAttributeCategory){
|
||||
$this->idMfProductAttributeCategory = $idMfProductAttributeCategory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_attribute_category_description
|
||||
*
|
||||
*/
|
||||
class MfProductAttributeCategoryDescriptionDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductAttributeCategoryDescription';
|
||||
protected static $objClassTable = 'mf_product_attribute_category_description';
|
||||
protected static $objClassTablePK = 'id_mf_product_attribute_category_description';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassName().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
160
_rejestracja/core/_model/MfProductAttributeDAL.class.php
Normal file
160
_rejestracja/core/_model/MfProductAttributeDAL.class.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_attribute
|
||||
*
|
||||
*/
|
||||
class MfProductAttributeDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductAttribute';
|
||||
protected static $objClassTable = 'mf_product_attribute';
|
||||
protected static $objClassTablePK = 'id_mf_product_attribute';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalObj = new DalData();
|
||||
$dalObj->setObjClassName(self::GetObjClassName());
|
||||
$dalObj->setObjClassTable(self::GetObjClassTable());
|
||||
$dalObj->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalObj->setObj($obj);
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
$dalObj = new DalData();
|
||||
$dalObj->setObjClassName(self::GetObjClassName());
|
||||
$dalObj->setObjClassTable(self::GetObjClassTable());
|
||||
$dalObj->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalObj->setObj($obj);
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTable().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfProductAttribute(-1);
|
||||
$obj->SetDescriptionObj(MfProductAttributeDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function CheakDescLang($id, $lang) {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
|
||||
return Utils::CheckDescLang($id, 'mf_product_attribute_description', $lang);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
133
_rejestracja/core/_model/MfProductAttributeDescription.class.php
Normal file
133
_rejestracja/core/_model/MfProductAttributeDescription.class.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductAttributeDescription
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductAttributeDescription extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_attribute_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_attribute_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_attribute_description' => 'id',
|
||||
'id_mf_product_attribute' => 'idMfProductAttribute',
|
||||
'description' => 'description',
|
||||
'lang' => 'lang'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $idMfProductAttribute;
|
||||
private $description;
|
||||
private $lang;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $idMfProductAttribute = null, $description = null, $lang = null){
|
||||
$this->id = $id;
|
||||
$this->idMfProductAttribute = $idMfProductAttribute;
|
||||
$this->description = $description;
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfProductAttribute(){
|
||||
return $this->idMfProductAttribute;
|
||||
}
|
||||
|
||||
public function setIdMfProductAttribute($idMfProductAttribute){
|
||||
$this->idMfProductAttribute = $idMfProductAttribute;
|
||||
}
|
||||
|
||||
|
||||
public function getDescription(){
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description){
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang){
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_attribute_description
|
||||
*
|
||||
*/
|
||||
class MfProductAttributeDescriptionDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductAttributeDescription';
|
||||
protected static $objClassTable = 'mf_product_attribute_description';
|
||||
protected static $objClassTablePK = 'id_mf_product_attribute_description';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalObj = new DalData();
|
||||
$dalObj->setObjClassName(self::GetObjClassName());
|
||||
$dalObj->setObjClassTable(self::GetObjClassTable());
|
||||
$dalObj->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalObj->setObj($obj);
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
$dalObj = new DalData();
|
||||
$dalObj->setObjClassName(self::GetObjClassName());
|
||||
$dalObj->setObjClassTable(self::GetObjClassTable());
|
||||
$dalObj->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalObj->setObj($obj);
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTable().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new MfProductAttributeDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
145
_rejestracja/core/_model/MfProductAttributeValue.class.php
Normal file
145
_rejestracja/core/_model/MfProductAttributeValue.class.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductAttributeValue
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductAttributeValue extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_attribute_value';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_attribute_value';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_attribute_value' => 'id',
|
||||
'value' => 'value',
|
||||
'id_mf_product' => 'idMfProduct',
|
||||
'id_mf_product_attribute' => 'idMfProductAttribute',
|
||||
'lang' => 'lang'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $value;
|
||||
private $idMfProduct;
|
||||
private $idMfProductAttribute;
|
||||
private $lang;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $value = null, $idMfProduct = null, $idMfProductAttribute = null, $lang = null){
|
||||
$this->id = $id;
|
||||
$this->value = $value;
|
||||
$this->idMfProduct = $idMfProduct;
|
||||
$this->idMfProductAttribute = $idMfProductAttribute;
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getValue(){
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value){
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfProduct(){
|
||||
return $this->idMfProduct;
|
||||
}
|
||||
|
||||
public function setIdMfProduct($idMfProduct){
|
||||
$this->idMfProduct = $idMfProduct;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfProductAttribute(){
|
||||
return $this->idMfProductAttribute;
|
||||
}
|
||||
|
||||
public function setIdMfProductAttribute($idMfProductAttribute){
|
||||
$this->idMfProductAttribute = $idMfProductAttribute;
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang){
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
142
_rejestracja/core/_model/MfProductAttributeValueDAL.class.php
Normal file
142
_rejestracja/core/_model/MfProductAttributeValueDAL.class.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_attribute_value
|
||||
*
|
||||
*/
|
||||
class MfProductAttributeValueDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductAttributeValue';
|
||||
protected static $objClassTable = 'mf_product_attribute_value';
|
||||
protected static $objClassTablePK = 'id_mf_product_attribute_value';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassName().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj, $showSql = null) {
|
||||
return self::DefaultGetResult($dalObj, $showSql);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
192
_rejestracja/core/_model/MfProductCategory.class.php
Normal file
192
_rejestracja/core/_model/MfProductCategory.class.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductCategory
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductCategory extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_category';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_category';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_category' => 'id',
|
||||
'weight' => 'weight',
|
||||
'id_parent' => 'idParent',
|
||||
'publication' => 'publication'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $weight;
|
||||
private $idParent;
|
||||
private $publication;
|
||||
private $descriptionObj;
|
||||
private $haveChildren;
|
||||
public $arrayChildren = array();
|
||||
private $checked;
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $weight = null, $idParent = null, $publication = null){
|
||||
$this->id = $id;
|
||||
$this->weight = $weight;
|
||||
$this->idParent = $idParent;
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getWeight(){
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight){
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
|
||||
public function getIdParent(){
|
||||
return $this->idParent;
|
||||
}
|
||||
|
||||
public function setIdParent($idParent){
|
||||
$this->idParent = $idParent;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->descriptionObj)) {
|
||||
$dalData = MfProductCategoryDescriptionDAL::GetDalDataObj();
|
||||
$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product_category'=>$this->GetId()));
|
||||
|
||||
$descriptionObj = MfProductCategoryDescriptionDAL::GetResult($dalData);
|
||||
if(isset($descriptionObj[0]) && is_object($descriptionObj[0])) {
|
||||
$this->SetDescriptionObj($descriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->descriptionObj;
|
||||
}
|
||||
|
||||
public function SetDescriptionObj($descriptionObj) {
|
||||
$this->descriptionObj = $descriptionObj;
|
||||
}
|
||||
public function SetMfProductCategoryDescription($descriptionObj) {
|
||||
$this->descriptionObj = $descriptionObj;
|
||||
}
|
||||
|
||||
public function GetHaveChildren() {
|
||||
return $this->haveChildren;
|
||||
}
|
||||
|
||||
public function SetHaveChildren($s) {
|
||||
$this->haveChildren = $s;
|
||||
}
|
||||
|
||||
public function SetArrayChildren($s) {
|
||||
$this->arrayChildren = $s;
|
||||
}
|
||||
|
||||
public function AddChildren($obj) {
|
||||
$this->arrayChildren = array_merge_recursive($this->arrayChildren, $obj);
|
||||
}
|
||||
public function GetArrayChildren() {
|
||||
return $this->arrayChildren;
|
||||
}
|
||||
|
||||
public function getChecked(){
|
||||
return $this->checked;
|
||||
}
|
||||
|
||||
public function setChecked($checked){
|
||||
$this->checked = $checked;
|
||||
}
|
||||
|
||||
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
211
_rejestracja/core/_model/MfProductCategoryDAL.class.php
Normal file
211
_rejestracja/core/_model/MfProductCategoryDAL.class.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_category
|
||||
*
|
||||
*/
|
||||
class MfProductCategoryDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductCategory';
|
||||
protected static $objClassTable = 'mf_product_category';
|
||||
protected static $objClassTablePK = 'id_mf_product_category';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTable().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
public static function CheakDescLang($id, $lang) {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
|
||||
return Utils::CheckDescLang($id, 'mf_product_category_description', $lang);
|
||||
}
|
||||
|
||||
public static function GetStructureProductCategory($lang = 'pl', $arrayLinked = array()) {
|
||||
$dalData = MfProductCategoryDAL::GetDalDataObj();
|
||||
$dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
|
||||
$dalData->setCondition(array('lang' => $lang));
|
||||
$arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
|
||||
|
||||
if (count($arrayLinked) > 0) {
|
||||
|
||||
$arrayObjProductSpecificationNew = array();
|
||||
foreach ($arrayObjProductCategory as $objProductSpecification) {
|
||||
if (key_exists($objProductSpecification->getId(), $arrayLinked)) {
|
||||
$objProductSpecification->setChecked(1);
|
||||
}
|
||||
$arrayObjProductSpecificationNew[] = $objProductSpecification;
|
||||
}
|
||||
|
||||
$arrayObjProductCategory = $arrayObjProductSpecificationNew;
|
||||
|
||||
}
|
||||
foreach ($arrayObjProductCategory as $item) {
|
||||
$menu[$item->GetId()] = $item;
|
||||
}
|
||||
foreach ($menu as $key => $obj) {
|
||||
|
||||
if ($obj->GetIdParent() != 0) {
|
||||
if (key_exists($obj->GetIdParent(), $menu)) {
|
||||
$menu[$obj->GetIdParent()]->SetHaveChildren(true);
|
||||
$menu[$obj->GetIdParent()]->AddChildren(array($obj->GetId() => $obj));
|
||||
} else {
|
||||
$arrayTree[$key] = $obj;
|
||||
}
|
||||
|
||||
}
|
||||
if ($obj->GetIdParent() == 0) {
|
||||
//Utils::ArrayDisplay('ones');
|
||||
$arrayTree[$key] = $obj;
|
||||
}
|
||||
}
|
||||
foreach ($menu as $key => $obj) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Utils::ArrayDisplay($arrayTree);
|
||||
|
||||
return $arrayTree;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfProductCategory(-1);
|
||||
$obj->SetDescriptionObj(MfProductCategoryDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
157
_rejestracja/core/_model/MfProductCategoryDescription.class.php
Normal file
157
_rejestracja/core/_model/MfProductCategoryDescription.class.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductCategoryDescription
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductCategoryDescription extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_category_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_category_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_category_description' => 'id',
|
||||
'name' => 'name',
|
||||
'publication' => 'publication',
|
||||
'id_mf_product_category' => 'idMfProductCategory',
|
||||
'lang' => 'lang',
|
||||
'date_publication' => 'datePublication'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $publication;
|
||||
private $idMfProductCategory;
|
||||
private $lang;
|
||||
private $datePublication;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $name = null, $publication = null, $idMfProductCategory = null, $lang = null, $datePublication = null){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->publication = $publication;
|
||||
$this->idMfProductCategory = $idMfProductCategory;
|
||||
$this->lang = $lang;
|
||||
$this->datePublication = $datePublication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfProductCategory(){
|
||||
return $this->idMfProductCategory;
|
||||
}
|
||||
|
||||
public function setIdMfProductCategory($idMfProductCategory){
|
||||
$this->idMfProductCategory = $idMfProductCategory;
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang){
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
public function getDatePublication(){
|
||||
return $this->datePublication;
|
||||
}
|
||||
|
||||
public function setDatePublication($datePublication){
|
||||
$this->datePublication = $datePublication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_category_description
|
||||
*
|
||||
*/
|
||||
class MfProductCategoryDescriptionDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductCategoryDescription';
|
||||
protected static $objClassTable = 'mf_product_category_description';
|
||||
protected static $objClassTablePK = 'id_mf_product_category_description';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalObj = new DalData();
|
||||
$dalObj->setObjClassName(self::GetObjClassName());
|
||||
$dalObj->setObjClassTable(self::GetObjClassTable());
|
||||
$dalObj->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalObj->setObj($obj);
|
||||
//Utils::ArrayDisplay($dalObj);
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
$dalObj = new DalData();
|
||||
$dalObj->setObjClassName(self::GetObjClassName());
|
||||
$dalObj->setObjClassTable(self::GetObjClassTable());
|
||||
$dalObj->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalObj->setObj($obj);
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassName().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new MfProductCategoryDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
165
_rejestracja/core/_model/MfProductDAL.class.php
Normal file
165
_rejestracja/core/_model/MfProductDAL.class.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product
|
||||
*
|
||||
*/
|
||||
class MfProductDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProduct';
|
||||
protected static $objClassTable = 'mf_product';
|
||||
protected static $objClassTablePK = 'id_mf_product';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
//Utils::ArrayDisplay($dalData);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl', $langNew = false) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTable().'.'.self::GetObjClassTablePK()=>$id));
|
||||
if (class_exists(self::GetObjClassName().'Description') && !$langNew) {
|
||||
$dalData->addCondition('lang', $lang);
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
if ($langNew) {
|
||||
$result[0]->setDescriptionObj(MfProductDescriptionDAL::GetEmptyObj());
|
||||
}
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function CheakDescLang($id, $lang) {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
|
||||
return Utils::CheckDescLang($id, 'mf_product_description', $lang);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfProduct(-1);
|
||||
$obj->SetDescriptionObj(MfProductDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
259
_rejestracja/core/_model/MfProductDescription.class.php
Normal file
259
_rejestracja/core/_model/MfProductDescription.class.php
Normal file
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductDescription
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductDescription extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_description' => 'id',
|
||||
'id_mf_product' => 'idMfProduct',
|
||||
'name' => 'name',
|
||||
'lang' => 'lang',
|
||||
'description' => 'description',
|
||||
'shortnote' => 'shortnote',
|
||||
'publication' => 'publication',
|
||||
'id_mf_picture' => 'idPicture',
|
||||
'id_mf_picture_mini' => 'idPictureMini',
|
||||
'id_mf_image_group' => 'idImageGroup'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $idMfProduct;
|
||||
private $name;
|
||||
private $lang;
|
||||
private $description;
|
||||
private $shortnote;
|
||||
private $publication;
|
||||
private $idPictureMini = 0;
|
||||
private $idPicture = 0;
|
||||
private $idStructure = 0;
|
||||
private $picture;
|
||||
private $pictureMini;
|
||||
private $idImageGroup;
|
||||
public $arrayImage;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $idMfProduct = null, $name = null, $lang = null, $description = null, $shortnote = null, $publication = null){
|
||||
$this->id = $id;
|
||||
$this->idMfProduct = $idMfProduct;
|
||||
$this->name = $name;
|
||||
$this->lang = $lang;
|
||||
$this->description = $description;
|
||||
$this->shortnote = $shortnote;
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getIdMfProduct(){
|
||||
return $this->idMfProduct;
|
||||
}
|
||||
|
||||
public function setIdMfProduct($idMfProduct){
|
||||
$this->idMfProduct = $idMfProduct;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang){
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
public function getDescription(){
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description){
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
|
||||
public function getShortnote(){
|
||||
return $this->shortnote;
|
||||
}
|
||||
|
||||
public function setShortnote($shortnote){
|
||||
$this->shortnote = $shortnote;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function SetIdPicture($idPicture) {
|
||||
$this->idPicture = $idPicture;
|
||||
}
|
||||
|
||||
public function GetIdPicture() {
|
||||
return $this->idPicture;
|
||||
}
|
||||
public function SetIdPictureMini($idPictureMini) {
|
||||
$this->idPictureMini = $idPictureMini;
|
||||
}
|
||||
|
||||
public function GetIdPictureMini() {
|
||||
return $this->idPictureMini;
|
||||
}
|
||||
|
||||
|
||||
public function SetPicture($picture) {
|
||||
$this->picture = $picture;
|
||||
}
|
||||
|
||||
public function GetPicture() {
|
||||
if (!$this->picture && (int)$this->idPicture > 0) {
|
||||
$this->picture = PictureDAL::GetById($this->GetIdPicture());
|
||||
}
|
||||
|
||||
return $this->picture;
|
||||
}
|
||||
|
||||
public function GetPictureUrl() {
|
||||
if ($this->GetPicture()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/Product/' . $this->GetPicture()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function SetPictureMini($pictureMini) {
|
||||
$this->pictureMini = $pictureMini;
|
||||
}
|
||||
|
||||
public function GetPictureMini() {
|
||||
if (!$this->pictureMini && (int)$this->idPictureMini > 0) {
|
||||
$this->pictureMini = PictureDAL::GetById($this->GetIdPictureMini());
|
||||
}
|
||||
|
||||
return $this->pictureMini;
|
||||
}
|
||||
|
||||
public function GetPictureMiniUrl() {
|
||||
if ($this->GetPictureMini()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/Product/' . $this->GetPictureMini()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function setArrayImage($arrayImage) {
|
||||
$this->arrayImage = $arrayImage;
|
||||
}
|
||||
|
||||
public function getArrayImage() {
|
||||
if (!$this->arrayImage && $this->idImageGroup > 0) {
|
||||
//$this->setArrayImage(ImageDAL::GetResultByLink('mf_article', $this->id));
|
||||
$this->setArrayImage(ImageDAL::GetResult(array('id_image_group' => $this->idImageGroup, 'size' => 2)));
|
||||
}
|
||||
return $this->arrayImage;
|
||||
}
|
||||
|
||||
public function setIdImageGroup($idImageGroup) {
|
||||
$this->idImageGroup = $idImageGroup;
|
||||
}
|
||||
|
||||
public function getIdImageGroup() {
|
||||
return $this->idImageGroup;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
150
_rejestracja/core/_model/MfProductDescriptionDAL.class.php
Normal file
150
_rejestracja/core/_model/MfProductDescriptionDAL.class.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_description
|
||||
*
|
||||
*/
|
||||
class MfProductDescriptionDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductDescription';
|
||||
protected static $objClassTable = 'mf_product_description';
|
||||
protected static $objClassTablePK = 'id_mf_product_description';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassName().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new MfProductDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
181
_rejestracja/core/_model/MfProductLink.class.php
Normal file
181
_rejestracja/core/_model/MfProductLink.class.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy MfProductLink
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class MfProductLink extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_product_link';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_product_link';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_product_link' => 'id',
|
||||
'source_type' => 'sourceType',
|
||||
'id_source' => 'idSource',
|
||||
'destination_type' => 'destinationType',
|
||||
'id_destination' => 'idDestination',
|
||||
'weight' => 'weight',
|
||||
'publication' => 'publication',
|
||||
'lang' => 'lang'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $sourceType;
|
||||
private $idSource;
|
||||
private $destinationType;
|
||||
private $idDestination;
|
||||
private $weight;
|
||||
private $publication;
|
||||
private $lang;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $sourceType = null, $idSource = null, $destinationType = null, $idDestination = null, $weight = null, $publication = null, $lang = null){
|
||||
$this->id = $id;
|
||||
$this->sourceType = $sourceType;
|
||||
$this->idSource = $idSource;
|
||||
$this->destinationType = $destinationType;
|
||||
$this->idDestination = $idDestination;
|
||||
$this->weight = $weight;
|
||||
$this->publication = $publication;
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getSourceType(){
|
||||
return $this->sourceType;
|
||||
}
|
||||
|
||||
public function setSourceType($sourceType){
|
||||
$this->sourceType = $sourceType;
|
||||
}
|
||||
|
||||
|
||||
public function getIdSource(){
|
||||
return $this->idSource;
|
||||
}
|
||||
|
||||
public function setIdSource($idSource){
|
||||
$this->idSource = $idSource;
|
||||
}
|
||||
|
||||
|
||||
public function getDestinationType(){
|
||||
return $this->destinationType;
|
||||
}
|
||||
|
||||
public function setDestinationType($destinationType){
|
||||
$this->destinationType = $destinationType;
|
||||
}
|
||||
|
||||
|
||||
public function getIdDestination(){
|
||||
return $this->idDestination;
|
||||
}
|
||||
|
||||
public function setIdDestination($idDestination){
|
||||
$this->idDestination = $idDestination;
|
||||
}
|
||||
|
||||
|
||||
public function getWeight(){
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight){
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
|
||||
public function getPublication(){
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function setPublication($publication){
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
public function getLang(){
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function setLang($lang){
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
318
_rejestracja/core/_model/MfProductLinkDAL.class.php
Normal file
318
_rejestracja/core/_model/MfProductLinkDAL.class.php
Normal file
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product_link
|
||||
*
|
||||
*/
|
||||
class MfProductLinkDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'MfProductLink';
|
||||
protected static $objClassTable = 'mf_product_link';
|
||||
protected static $objClassTablePK = 'id_mf_product_link';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassName().'.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function GetArrayId($source , $destination, $idDestination, $lang = 'pl') {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_source FROM `mf_product_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND `id_destination` = $idDestination AND lang = '$lang'";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_source'];
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
public function GetIdString($source , $destination, $idDestination, $lang = 'pl', $idDestinationNotIN = null) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_source FROM `mf_product_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND lang = '$lang'".
|
||||
($idDestination ? " AND `id_destination` = $idDestination " : "").
|
||||
($idDestinationNotIN ? " AND `id_destination` NOT IN ($idDestinationNotIN) " : "").
|
||||
" GROUP BY id_source ";
|
||||
$stmt=$db->prepare($sql)->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
if ($stmt->NumRows() > 0) {
|
||||
|
||||
}
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$ids = ' ';
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_source'];
|
||||
}
|
||||
if (count($returnArray) > 0) {
|
||||
$ids .= implode(',', $returnArray);
|
||||
} else {
|
||||
$ids .= '-1';
|
||||
}
|
||||
$ids .= ' ';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function GetArrayIdDestinaion($source , $destination, $idSource, $lang = 'pl') {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT `id_destination` FROM `mf_product_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND `id_source` = $idSource AND lang = '$lang'";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt=$db->prepare($sql)
|
||||
->execute();
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_destination'];
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
public function GetIdStringDestinaion($source , $destination, $idSource, $lang = 'pl', $idSourceNotIN = null) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT id_destination FROM `mf_product_link` WHERE `source_type` = '$source' AND `destination_type` = '$destination' AND lang = '$lang'".
|
||||
($idSource ? " AND `id_source` = $idSource " : "").
|
||||
($idSourceNotIN ? " AND `id_source` NOT IN ($idSourceNotIN) " : "").
|
||||
" GROUP BY id_destination ";
|
||||
$stmt=$db->prepare($sql)->execute();
|
||||
//Utils::ArrayDisplay($sql);
|
||||
if ($stmt->NumRows() > 0) {
|
||||
//$stmt->CacheStart($cacheTime);
|
||||
$ids = ' ';
|
||||
$returnArray = array();
|
||||
while(($row = $stmt->FetchArray())) {
|
||||
$returnArray[] = $row['id_destination'];
|
||||
}
|
||||
if (count($returnArray) > 0) {
|
||||
$ids .= implode(' ,', $returnArray);
|
||||
} else {
|
||||
$ids .= '-1';
|
||||
}
|
||||
$ids .= ' ';
|
||||
|
||||
return $ids;
|
||||
|
||||
} else {
|
||||
return '-1';
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function DeleteFromLink($idSource = null, $sourceType = null, $idDestination = null, $destinationType = null, $lang=null) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "DELETE FROM `mf_product_link` WHERE 1=1 ";
|
||||
|
||||
if($idSource!= null )
|
||||
$sql.= " AND id_source = :01 ";
|
||||
|
||||
if($sourceType!= null)
|
||||
$sql.= " AND source_type = :02 ";
|
||||
|
||||
if($idDestination!= null)
|
||||
$sql.= " AND id_destination = :03 ";
|
||||
|
||||
if($destinationType!= null)
|
||||
$sql.= " AND destination_type = :04 ";
|
||||
|
||||
if($lang!= null)
|
||||
$sql.= " AND lang = :05 ";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
|
||||
if($idSource!= null )
|
||||
$stmt->bindParam('01', $idSource);
|
||||
|
||||
if($sourceType!= null)
|
||||
$stmt->bindParam('02', $sourceType);
|
||||
|
||||
if($idDestination!= null)
|
||||
$stmt->bindParam('03', $idDestination);
|
||||
if($destinationType!= null)
|
||||
|
||||
$stmt->bindParam('04', $destinationType);
|
||||
if($lang!= null)
|
||||
|
||||
$stmt->bindParam('05', $lang);
|
||||
|
||||
$stmt->execute();
|
||||
//Utils::ArrayDisplay($stmt);
|
||||
}
|
||||
|
||||
public function IsLinked($idSource = null, $sourceType = null, $idDestination = null, $destinationType = null, $lang = null ,$published = '-1', $idSourceSql = '=') {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = "SELECT count(id_mf_product_link) as count FROM `mf_product_link` WHERE 1=1 AND publication NOT IN (".$published.") ";
|
||||
|
||||
if($idSource!= null )
|
||||
$sql.= " AND id_source ".$idSourceSql." $idSource ";
|
||||
|
||||
if($sourceType!= null)
|
||||
$sql.= " AND source_type = :02 ";
|
||||
|
||||
if($idDestination!= null)
|
||||
$sql.= " AND id_destination ".$idSourceSql." $idDestination ";
|
||||
|
||||
if($destinationType!= null)
|
||||
$sql.= " AND destination_type = :04 ";
|
||||
|
||||
if($lang!= null)
|
||||
$sql.= " AND lang = :05 ";
|
||||
|
||||
$stmt=$db->prepare($sql);
|
||||
|
||||
if($idSource!= null )
|
||||
$stmt->bindParam('01', $idSource);
|
||||
|
||||
if($sourceType!= null)
|
||||
$stmt->bindParam('02', $sourceType);
|
||||
|
||||
if($idDestination!= null)
|
||||
$stmt->bindParam('03', $idDestination);
|
||||
|
||||
if($destinationType!= null)
|
||||
$stmt->bindParam('04', $destinationType);
|
||||
|
||||
if($lang!= null)
|
||||
$stmt->bindParam('05', $lang);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
|
||||
return $array[0]['count'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
193
_rejestracja/core/_model/MfRouter.class.php
Normal file
193
_rejestracja/core/_model/MfRouter.class.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa routingu
|
||||
*
|
||||
*/
|
||||
class MfRouter extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_router';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_router';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_router' =>'id',
|
||||
'name' =>'name',
|
||||
'url' =>'url',
|
||||
'controller' =>'controller',
|
||||
'method' =>'method',
|
||||
'paramMatrix'=>'paramMatrix',
|
||||
'config'=>'config',
|
||||
'id_mf_module'=>'idMfModule',
|
||||
'param'=>'param',
|
||||
'label_url'=>'labelUrl',
|
||||
'location'=>'location',
|
||||
'lang'=>'lang'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $url;
|
||||
private $controller;
|
||||
private $method;
|
||||
private $paramMatrix;
|
||||
private $config;
|
||||
private $matchUri;
|
||||
private $param;
|
||||
private $idMfModule;
|
||||
private $labelUrl;
|
||||
private $location;
|
||||
private $lang;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function SetUrl($url) {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function GetController() {
|
||||
return $this->controller;
|
||||
}
|
||||
|
||||
public function SetController($controller) {
|
||||
$this->controller = $controller;
|
||||
}
|
||||
|
||||
public function GetMethod() {
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function SetMethod($method) {
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
public function GetParamMatrix() {
|
||||
return $this->paramMatrix;
|
||||
}
|
||||
|
||||
public function SetParamMatrix($paramMatrix) {
|
||||
$this->paramMatrix = $paramMatrix;
|
||||
}
|
||||
|
||||
public function GetConfig() {
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
public function SetConfig($config) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function GetMatchUri() {
|
||||
return $this->matchUri;
|
||||
}
|
||||
|
||||
public function SetMatchUri($matchUri) {
|
||||
$this->matchUri = $matchUri;
|
||||
}
|
||||
|
||||
public function GetParam() {
|
||||
return $this->param;
|
||||
}
|
||||
|
||||
public function SetParam($param) {
|
||||
$this->param = $param;
|
||||
}
|
||||
public function GetIdMfModule() {
|
||||
return $this->idMfModule;
|
||||
}
|
||||
|
||||
public function SetIdMfModule($idMfModule) {
|
||||
$this->idMfModule = $idMfModule;
|
||||
}
|
||||
|
||||
public function GetLabelUrl() {
|
||||
return $this->labelUrl;
|
||||
}
|
||||
|
||||
public function SetLabelUrl($labelUrl) {
|
||||
$this->labelUrl = $labelUrl;
|
||||
}
|
||||
|
||||
public function GetLocation() {
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function SetLocation($location) {
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
261
_rejestracja/core/_model/MfRouterDAL.class.php
Normal file
261
_rejestracja/core/_model/MfRouterDAL.class.php
Normal file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy organizacji/stowarzyszen
|
||||
*
|
||||
*/
|
||||
class MfRouterDAL extends DefaultDAL {
|
||||
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
return false;
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetResult($dalData) {
|
||||
return self::DefaultGetResult($dalData);
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$result = self::GetResult($dalData);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public static function GetResultOld($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function UpdateParamPush($idRouter, $arrayParam = array()) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT param FROM mf_router WHERE id_mf_router = $idRouter";
|
||||
$stmt = $db->execute($sql);
|
||||
|
||||
$array = array();
|
||||
if ($row = $stmt->FetchArray()) {
|
||||
//$param = $row['param'];
|
||||
$array = unserialize($row['param']);
|
||||
}
|
||||
|
||||
$arrayParam = array_merge($array, $arrayParam);
|
||||
|
||||
$serializeParam = serialize($arrayParam);
|
||||
|
||||
$sql = "UPDATE mf_router SET param = '$serializeParam' WHERE id_mf_router = $idRouter";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->execute($sql);
|
||||
}
|
||||
|
||||
|
||||
public function AddRouterByStructure($routerOld, $objStructure, $lang) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
|
||||
$router = new MfRouter();
|
||||
$router->SetController($routerOld->GetController());
|
||||
$router->SetMethod($routerOld->GetMethod());
|
||||
$router->SetUrl($routerOld->GetUrl());
|
||||
$router->SetLabelUrl($routerOld->GetLabelUrl());
|
||||
$router->SetParam($routerOld->GetParam());
|
||||
$router->SetConfig($routerOld->GetConfig());
|
||||
$router->SetIdMfModule($routerOld->GetIdMfModule());
|
||||
$router->SetLang($lang);
|
||||
|
||||
$dalData->setObj($router);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
$objStructure->SetIdRouter($id);
|
||||
StructureDAL::Update($objStructure);
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
193
_rejestracja/core/_model/News.class.php
Normal file
193
_rejestracja/core/_model/News.class.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy News
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class News extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'news';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_news';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_news' => 'id',
|
||||
'title' => 'title',
|
||||
'description' => 'description',
|
||||
'text' => 'text',
|
||||
'date_add' => 'dateAdd',
|
||||
'id_news_type' => 'idNewsType',
|
||||
'id_language' => 'idLanguage',
|
||||
'id_news_main' => 'idNewsMain',
|
||||
'description_main' => 'descriptionMain'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $title;
|
||||
private $description;
|
||||
private $text;
|
||||
private $dateAdd;
|
||||
private $idNewsType;
|
||||
private $idLanguage;
|
||||
private $idNewsMain;
|
||||
private $descriptionMain;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $title = null, $description = null, $text = null, $dateAdd = null, $idNewsType = null, $idLanguage = null, $idNewsMain = null, $descriptionMain = null){
|
||||
$this->id = $id;
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->text = $text;
|
||||
$this->dateAdd = $dateAdd;
|
||||
$this->idNewsType = $idNewsType;
|
||||
$this->idLanguage = $idLanguage;
|
||||
$this->idNewsMain = $idNewsMain;
|
||||
$this->descriptionMain = $descriptionMain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getTitle(){
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title){
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
|
||||
public function getDescription(){
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description){
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
|
||||
public function getText(){
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function setText($text){
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
|
||||
public function getDateAdd(){
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function setDateAdd($dateAdd){
|
||||
$this->dateAdd = $dateAdd;
|
||||
}
|
||||
|
||||
|
||||
public function getIdNewsType(){
|
||||
return $this->idNewsType;
|
||||
}
|
||||
|
||||
public function setIdNewsType($idNewsType){
|
||||
$this->idNewsType = $idNewsType;
|
||||
}
|
||||
|
||||
|
||||
public function getIdLanguage(){
|
||||
return $this->idLanguage;
|
||||
}
|
||||
|
||||
public function setIdLanguage($idLanguage){
|
||||
$this->idLanguage = $idLanguage;
|
||||
}
|
||||
|
||||
|
||||
public function getIdNewsMain(){
|
||||
return $this->idNewsMain;
|
||||
}
|
||||
|
||||
public function setIdNewsMain($idNewsMain){
|
||||
$this->idNewsMain = $idNewsMain;
|
||||
}
|
||||
|
||||
|
||||
public function getDescriptionMain(){
|
||||
return $this->descriptionMain;
|
||||
}
|
||||
|
||||
public function setDescriptionMain($descriptionMain){
|
||||
$this->descriptionMain = $descriptionMain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
153
_rejestracja/core/_model/NewsDAL.class.php
Normal file
153
_rejestracja/core/_model/NewsDAL.class.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy news
|
||||
*
|
||||
*/
|
||||
class NewsDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'News';
|
||||
protected static $objClassTable = 'news';
|
||||
protected static $objClassTablePK = 'id_news';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
//Utils::ArrayDisplay($dalData);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfNews(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
180
_rejestracja/core/_model/PhotoDAL.class.php
Normal file
180
_rejestracja/core/_model/PhotoDAL.class.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* $Id: PhotoDAL.class.php 1144 2008-08-19 08:10:12Z pawy $
|
||||
* Enter description here...
|
||||
*
|
||||
*/
|
||||
class PhotoDAL {
|
||||
|
||||
/**
|
||||
* Metoda tworzy katalogi
|
||||
*
|
||||
* @param string $dir sciezka katalog<6F>w
|
||||
* @param int $mode prawa zapisu
|
||||
* @param bool $recursive czy ma tworzy<7A> katalogi rekursywnie
|
||||
* @return bool
|
||||
*/
|
||||
public static function mkdirs($dir, $mode = 0777, $recursive = true) {
|
||||
if( is_null($dir) || $dir === "" ){
|
||||
return FALSE;
|
||||
}
|
||||
if( is_dir($dir) || $dir === DIRECTORY_SEPARATOR ){
|
||||
return TRUE;
|
||||
}
|
||||
if( PhotoDAL::mkdirs(dirname($dir), $mode, $recursive) ){
|
||||
return mkdir($dir, $mode);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public static function SimplePhotoUpload($sourceFileArray, $path, $dimnsionX = null, $dimensionY = null, $quality = 90) {
|
||||
|
||||
$directory = PATH_STATIC_CONTENT . $path;
|
||||
$url = $path . '/';
|
||||
|
||||
PhotoDAL::mkdirs($directory);
|
||||
|
||||
if(file_exists($directory . time() . $sourceFileArray['name'])) {
|
||||
unlink($directory . time() . $sourceFileArray['name']);
|
||||
}
|
||||
//$type = explode("/", $sourceFileArray['type'][$key]);
|
||||
//if($type[1] == "jpeg") $type[1] = "jpg";
|
||||
|
||||
$destinationFilePath = $directory . $sourceFileArray['name'];
|
||||
$destinationFileUrl = $url . $sourceFileArray['name'];
|
||||
|
||||
move_uploaded_file($sourceFileArray['tmp_name'], $destinationFilePath);
|
||||
|
||||
if($dimensionY!=null && $dimnsionX!=null) {
|
||||
$size = getimagesize($destinationFilePath);
|
||||
|
||||
$imgOryginal = new mImage($destinationFilePath);
|
||||
$imgOryginal->scaleProp($dimnsionX, $dimensionY, 'ffffff', false, 'c', 0);
|
||||
$imgOryginal->saveToFile($destinationFilePath, 'jpg', $quality, true);
|
||||
}
|
||||
|
||||
if (file_exists($destinationFilePath)) {
|
||||
return $destinationFileUrl;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Przenosi tymczasowo zapisane zdjęcie do zdjęć zapisanych na stałe,
|
||||
* przy okazji obcinając je wedle wskazań croppera, i resizując do
|
||||
* docelowego rozmiaru.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @param int $destWidth
|
||||
* @param int $destHeight
|
||||
*/
|
||||
public static function SaveTempFile($fileName, $destFile, $destDir, $x, $y, $width, $height, $destWidth, $destHeight) {
|
||||
$file = PATH_STATIC_CONTENT . DIRECTORY_SEPARATOR . $fileName;
|
||||
|
||||
$destDir = PATH_STATIC_CONTENT . DIRECTORY_SEPARATOR . $destDir;
|
||||
|
||||
//Utils::ArrayDisplay($destDir);
|
||||
PhotoDAL::mkdirs($destDir);
|
||||
|
||||
$destFileN = $destFile;
|
||||
$destFile = $destDir . DIRECTORY_SEPARATOR . $destFile;
|
||||
|
||||
$image = new mImage($file);
|
||||
$image->crop1($x, $y, $width, $height);
|
||||
$image->scaleProp($destWidth, $destHeight, 'ffffff', false, 'c', 0);
|
||||
$image->saveToFile($destFile . ".jpg", 'jpg', 90, true);
|
||||
|
||||
return $destFileN . ".jpg";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tworzy widok
|
||||
*/
|
||||
public static function MakeimgTitle($file, $string, $layout, $sizeImg) {
|
||||
|
||||
//$string = self::PLttf($string);
|
||||
//Utils::ArrayDisplay($string);
|
||||
|
||||
//header('Content-Type: text/html; charset=utf-8');
|
||||
$arrayLayout = array(
|
||||
1 => array('x' => '', 'y' => ''),
|
||||
2 => array('x' => 100, 'y' => 100),
|
||||
3 => array('x' => 120, 'y' => 100),
|
||||
4 => array('x' => 100, 'y' => 180),
|
||||
5 => array('x' => 100, 'y' => 20) );
|
||||
$im = imagecreate(400, 100);
|
||||
// White background and blue text
|
||||
$bg = imagecolorallocate($im, 255, 255, 255);
|
||||
$textcolor = imagecolorallocate($im, 0, 0, 0);
|
||||
if (is_file(PATH_STATIC_CONTENT.$file)) {
|
||||
$src = imagecreatefromjpeg(PATH_STATIC_CONTENT.$file);
|
||||
}
|
||||
//$string = iconv("utf-8", "utf-8", $string);
|
||||
$string = html_entity_decode($string);
|
||||
//Utils::ArrayDisplay($string);
|
||||
|
||||
|
||||
// Copy and merge
|
||||
//1
|
||||
if ($layout == 1) {
|
||||
imagecopymerge($im, $src, 25, 25, 0, 0, $sizeImg[0], $sizeImg[1], 90);
|
||||
}
|
||||
elseif ($layout == 2) {
|
||||
//imagecopymerge($im, $src, 25, 25, 0, 0, $sizeImg[0], $sizeImg[1], 90);
|
||||
//imagestring($im,8, 25, 45, $string ,$textcolor);
|
||||
imagettftext ( $im, 16, 0, 25, 55, $textcolor, PATH_CORE.'/plugins/arial.ttf', $string );
|
||||
}
|
||||
elseif ($layout == 3) {
|
||||
//3
|
||||
imagecopymerge($im, $src, 25, 25, 0, 0, $sizeImg[0], $sizeImg[1], 90);
|
||||
imagettftext ( $im, 16, 0, 25+$sizeImg[0]+20, 55, $textcolor, PATH_CORE.'/plugins/arial.ttf', $string );
|
||||
//imagestring($im,8, 25+$sizeImg[0]+20, 45, $string ,$textcolor);
|
||||
}
|
||||
elseif ($layout == 4) {
|
||||
imagecopymerge($im, $src, 25, 10, 0, 0, $sizeImg[0], $sizeImg[1], 90);
|
||||
imagettftext ( $im, 16, 0, 25, 85, $textcolor, PATH_CORE.'/plugins/arial.ttf', $string );
|
||||
//imagestring($im,8, 25, 65, $string ,$textcolor);
|
||||
}
|
||||
elseif ($layout == 5) {
|
||||
imagecopymerge($im, $src, 25, 40, 0, 0, $sizeImg[0], $sizeImg[1], 90);
|
||||
imagettftext ( $im, 16, 0, 25, 25, $textcolor, PATH_CORE.'/plugins/arial.ttf', $string );
|
||||
//imagestring($im,8, 25, 20, $string ,$textcolor);
|
||||
}
|
||||
|
||||
//imagestring($im,8, 25+$sizeImg[0]+20, 45, $string ,$textcolor);
|
||||
//2
|
||||
|
||||
|
||||
|
||||
//4
|
||||
|
||||
//5
|
||||
//imagettftext ( $im, 16, 0, 25+$sizeImg[0]+20, 45, $textcolor, PATH_CORE.'/plugins/arial.ttf', $string );
|
||||
$destName = md5('photo' . time()).".jpg";
|
||||
// Output and free from memory
|
||||
//header('Content-Type: image/jpeg');
|
||||
imagejpeg($im, PATH_STATIC_CONTENT.'creator/'.$destName );
|
||||
|
||||
imagedestroy($im);
|
||||
if (isset($src)) {
|
||||
imagedestroy($src);
|
||||
}
|
||||
return $destName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
105
_rejestracja/core/_model/Picture.class.php
Normal file
105
_rejestracja/core/_model/Picture.class.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Krku
|
||||
* @date 2009-05-15 10:31:12
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Pictureclass
|
||||
*/
|
||||
class Picture extends DataObject {
|
||||
|
||||
static $tableName = 'mf_picture';
|
||||
|
||||
static $className = __CLASS__;
|
||||
|
||||
static $classTablePK = 'id_mf_picture';
|
||||
|
||||
static $fields = array(
|
||||
'id_mf_picture' => 'id',
|
||||
'name' => 'name',
|
||||
'link' => 'link',
|
||||
'weight' => 'weight',
|
||||
'publication' => 'publication'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $link;
|
||||
private $weight;
|
||||
private $publication;
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetLink() {
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
public function SetLink($link) {
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
public function GetWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function SetWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
}
|
||||
?>
|
||||
108
_rejestracja/core/_model/PictureDAL.class.php
Normal file
108
_rejestracja/core/_model/PictureDAL.class.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Krku
|
||||
* @date 2009-05-15 10:30:31
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of PHPClass_1
|
||||
*/
|
||||
class PictureDAL extends DefaultDAL {
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
return self::GetResult(array());
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null, $cache = true) {
|
||||
return self::DefaultGetResult(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), $data, $queryFields, $limit, $sortBy, $count, $cache);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
|
||||
|
||||
|
||||
return self::DefaultGetById($dalData);
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
8
_rejestracja/core/_model/QueryCacheTemp.class.php
Normal file
8
_rejestracja/core/_model/QueryCacheTemp.class.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa przechowujaca wygenerowane zapytania
|
||||
*
|
||||
*/
|
||||
class QueryCacheTemp
|
||||
{
|
||||
static $cacheQuery = array("Spectacle_TsSpectacle_DefaultGetResult_d41d8cd98f00b204e9800998ecf8427e" => " SELECT ts_spectacle.id_ts_spectacle AS Spectacle_TsSpectacle_id_ts_spectacle, ts_spectacle.premiere_date AS Spectacle_TsSpectacle_premiere_date, ts_spectacle.id_admin AS Spectacle_TsSpectacle_id_admin, ts_spectacle.publication_date AS Spectacle_TsSpectacle_publication_date, ts_spectacle.expiration_date AS Spectacle_TsSpectacle_expiration_date, ts_spectacle.weight AS Spectacle_TsSpectacle_weight, ts_spectacle.creation_date AS Spectacle_TsSpectacle_creation_date, ts_spectacle.modification_date AS Spectacle_TsSpectacle_modification_date FROM ts_spectacle WHERE 1=1 ");}?>
|
||||
85
_rejestracja/core/_model/SetupDAL.class.php
Normal file
85
_rejestracja/core/_model/SetupDAL.class.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
class SetupDAL {
|
||||
/**
|
||||
* Zapisuje warto<74><6F> zmiennej w tabeli Setup
|
||||
*
|
||||
* @param String $zmienna
|
||||
* @param String $wartosc
|
||||
* @param String $opis
|
||||
*/
|
||||
public static function SaveVariable($zmienna, $wartosc, $opis) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "REPLACE INTO wp_setup (variable, value, description) values ( :1, :2, :3)";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $zmienna)
|
||||
->bindParam(2, $wartosc)
|
||||
->bindParam(3, $opis)
|
||||
->execute();
|
||||
|
||||
// return $stmt->GetInsertionId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera z tabeli setup zmienne oraz rejestruje je w Registry
|
||||
*
|
||||
* @param boolean $set_registry
|
||||
* @return Array
|
||||
*/
|
||||
public static function GetAllVariables($set_registry=true) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "select variable,value,description from wp_setup order by variable,value";
|
||||
//$cache = new DbCache($sql);
|
||||
|
||||
//if(!$cache->CacheCheck()) {
|
||||
$stmt=$db->execute($sql);
|
||||
$stmt->CacheStart(600);
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
//$cache->CacheWrite($array);
|
||||
//} else {
|
||||
// $array = $cache->CacheRead();
|
||||
//}
|
||||
//print_r($array);
|
||||
$returnArray = array();
|
||||
foreach ($array as $row) {
|
||||
|
||||
$row["value_str"] = $row["value"];
|
||||
if ($row["value"] == "false") {
|
||||
$row["value"] = false;
|
||||
}
|
||||
if ($row["value"] == "true") {
|
||||
$row["value"] = true;
|
||||
}
|
||||
|
||||
if ($set_registry) {
|
||||
Registry::Set($row["variable"], $row["value"]);
|
||||
}
|
||||
|
||||
$tmpArray["variable"] = $row["variable"];
|
||||
$tmpArray["value"] = $row["value_str"];
|
||||
$tmpArray["description"] = $row["description"];
|
||||
|
||||
$returnArray[] = $tmpArray;
|
||||
}
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ODczytuje z tabeli wp_setup zmienn<6E> o danej nazwie
|
||||
*
|
||||
* @param String $variable
|
||||
* @return String
|
||||
*/
|
||||
public static function GetVariableByName($variable) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = "select variable,value,description from wp_setup where variable=:1";
|
||||
$stmt=$db->prepare($sql)
|
||||
->bindParam(1, $variable)
|
||||
->execute();
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
return $array[0];
|
||||
}
|
||||
}
|
||||
?>
|
||||
492
_rejestracja/core/_model/SimpleArticle/MfArticle.class.php
Normal file
492
_rejestracja/core/_model/SimpleArticle/MfArticle.class.php
Normal file
@@ -0,0 +1,492 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticle extends DataObject {
|
||||
|
||||
static $TYPEART = 1;
|
||||
static $TYPENEWS = 2;
|
||||
static $TYPESTAGE = 3;
|
||||
static $TYPEGAL = 4;
|
||||
static $TYPEMAIN = 5;
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_article';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_article';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
static $types = array(
|
||||
1 =>'Artykuł',
|
||||
2 =>'Aktualość' ,
|
||||
3 =>'Scena' ,
|
||||
4 =>'Galeria' ,
|
||||
5 =>'Strona Główna'
|
||||
);
|
||||
|
||||
static $categoryName = array(
|
||||
1 =>'Narzędzia i oprzyrządowanie do smaru',
|
||||
2 =>'Narzędzia i oprzyrządowanie do oleju' ,
|
||||
3 =>'Narzędzia i oprzyrządowanie do płynów'
|
||||
);
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_article' =>'id',
|
||||
'date' =>'date' ,
|
||||
'publication' =>'publication' ,
|
||||
'weight' =>'weight' ,
|
||||
'url' =>'url',
|
||||
'special' =>'special',
|
||||
'id_mf_picture' => 'idPicture',
|
||||
'id_mf_picture_mini' => 'idPictureMini',
|
||||
'id_structure' => 'idStructure',
|
||||
'type' =>'type',
|
||||
'id_category' =>'idCategory',
|
||||
'date_shown'=>'dateShown',
|
||||
'date_publication'=> 'datePublication',
|
||||
'zz_date_add' => 'addDate',
|
||||
'zz_date_edit' => 'editDate',
|
||||
'id_mf_image_group' => 'idImageGroup'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $date;
|
||||
private $publication;
|
||||
private $weight;
|
||||
private $url;
|
||||
private $lang;
|
||||
private $articleDescriptionObj;
|
||||
private $idPicture = 0;
|
||||
private $idPictureMini = 0;
|
||||
private $idStructure = 0;
|
||||
private $picture;
|
||||
private $pictureMini;
|
||||
private $special = 0;
|
||||
private $type;
|
||||
private $idCategory;
|
||||
private $dateShown;
|
||||
private $datePublication;
|
||||
private $addDate;
|
||||
private $editDate;
|
||||
private $idImageGroup;
|
||||
public $tag;
|
||||
public $customer;
|
||||
public $structure;
|
||||
public $arrayImage;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetDate() {
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function SetDate($date) {
|
||||
$this->date = $date;
|
||||
}
|
||||
public function GetSpecial() {
|
||||
return $this->special;
|
||||
}
|
||||
|
||||
public function SetSpecial($special) {
|
||||
$this->special = $special;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function GetWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function SetWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
public function GetUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function SetUrl($url) {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
if($this->lang=='') {
|
||||
|
||||
$this->SetLang(Router::$curLang);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetIdPicture($idPicture) {
|
||||
$this->idPicture = $idPicture;
|
||||
}
|
||||
|
||||
public function GetIdPicture() {
|
||||
return $this->idPicture;
|
||||
}
|
||||
public function SetIdPictureMini($idPictureMini) {
|
||||
$this->idPictureMini = $idPictureMini;
|
||||
}
|
||||
|
||||
public function GetIdPictureMini() {
|
||||
return $this->idPictureMini;
|
||||
}
|
||||
public function SetIdStructure($idStructure) {
|
||||
$this->idStructure = $idStructure;
|
||||
}
|
||||
|
||||
public function GetIdStructure() {
|
||||
return $this->idStructure;
|
||||
}
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->articleDescriptionObj)) {
|
||||
$articleDescriptionObj = SimpleArticle_MfArticleDescriptionDAL::GetResult(array('publication' => 1, 'lang'=>$this->GetLang(), 'id_mf_article'=>$this->GetId()), array('title', 'browser_title', 'description', 'shortnote', 'publication'));
|
||||
if(isset($articleDescriptionObj[0]) && is_object($articleDescriptionObj[0])) {
|
||||
$this->SetArticleDescriptionObj($articleDescriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->articleDescriptionObj;
|
||||
}
|
||||
|
||||
public function SetArticleDescriptionObj($articleDescriptionObj) {
|
||||
$this->articleDescriptionObj = $articleDescriptionObj;
|
||||
}
|
||||
public function SetSimpleArticle_MfArticleDescription($articleDescriptionObj) {
|
||||
$this->articleDescriptionObj = $articleDescriptionObj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Eksperymentalne przeciazenie metod kierowane do podobiektu slownikowego
|
||||
*/
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
public function GetMfLinkDescription() {
|
||||
return $this->mfLinkDescription;
|
||||
}
|
||||
|
||||
public function SetMfLinkDescription($mfLinkDescription) {
|
||||
$this->mfLinkDescription = $mfLinkDescription;
|
||||
}
|
||||
|
||||
public function GetMfLinkWeight() {
|
||||
return $this->mfLinkWeight;
|
||||
}
|
||||
|
||||
public function SetMfLinkWeight($mfLinkWeight) {
|
||||
$this->mfLinkWeight = $mfLinkWeight;
|
||||
}
|
||||
|
||||
public function GetMfLinkType() {
|
||||
return $this->mfLinkType;
|
||||
}
|
||||
|
||||
public function SetMfLinkType($mfLinkType) {
|
||||
$this->mfLinkType = $mfLinkType;
|
||||
}
|
||||
|
||||
public function SetPicture($picture) {
|
||||
$this->picture = $picture;
|
||||
}
|
||||
|
||||
public function GetPicture() {
|
||||
if (!$this->picture && (int)$this->idPicture > 0) {
|
||||
$this->picture = PictureDAL::GetById($this->GetIdPicture());
|
||||
}
|
||||
|
||||
return $this->picture;
|
||||
}
|
||||
|
||||
public function GetPictureUrl() {
|
||||
if ($this->GetPicture()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/Article/' . $this->GetPicture()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetPicturePath() {
|
||||
if ($this->GetPicture()) {
|
||||
return Config::Get('PATH_STATIC_CONTENT') . 'upload/Article/' . $this->GetPicture()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function SetPictureMini($pictureMini) {
|
||||
$this->pictureMini = $pictureMini;
|
||||
}
|
||||
|
||||
public function GetPictureMini() {
|
||||
if (!$this->pictureMini && (int)$this->idPictureMini > 0) {
|
||||
$this->pictureMini = PictureDAL::GetById($this->GetIdPictureMini());
|
||||
}
|
||||
|
||||
return $this->pictureMini;
|
||||
}
|
||||
|
||||
public function GetPictureMiniUrl() {
|
||||
if ($this->GetPictureMini()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/Article/' . $this->GetPictureMini()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function GetDateShown() {
|
||||
return $this->dateShown;
|
||||
}
|
||||
|
||||
public function SetDateShown($date) {
|
||||
$this->dateShown = $date;
|
||||
}
|
||||
|
||||
public function GetDatePublication() {
|
||||
return $this->datePublication;
|
||||
}
|
||||
|
||||
public function GetDatePublicationWithoutTime() {
|
||||
return substr($this->datePublication, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDatePublicationTime() {
|
||||
if (!$this->datePublication) {
|
||||
return '00';
|
||||
} else {
|
||||
return substr($this->datePublication, 11, -6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function SetDatePublication($datePublication) {
|
||||
$this->datePublication = $datePublication;
|
||||
}
|
||||
|
||||
public function GetDateUpdate() {
|
||||
return $this->dateUpdate;
|
||||
}
|
||||
|
||||
public function GetDateUpdateWithoutTime() {
|
||||
return substr($this->dateUpdate, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDateUpdateTime() {
|
||||
return substr($this->dateUpdate, 11, -6);
|
||||
}
|
||||
|
||||
public function SetDateUpdate($dateUpdate) {
|
||||
$this->dateUpdate = $dateUpdate;
|
||||
}
|
||||
public function GetType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function SetType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
public function GetIdCategory() {
|
||||
return $this->idCategory;
|
||||
}
|
||||
|
||||
public function SetIdCategory($idCategory) {
|
||||
$this->idCategory = $idCategory;
|
||||
}
|
||||
|
||||
public function GetAddDate() {
|
||||
return $this->addDate;
|
||||
}
|
||||
|
||||
public function SetAddDate($add) {
|
||||
$this->addDate = $add;
|
||||
}
|
||||
|
||||
public function GetEditDate() {
|
||||
return $this->editDate;
|
||||
}
|
||||
|
||||
public function SetEditDate($edit) {
|
||||
$this->editDate = $edit;
|
||||
}
|
||||
|
||||
// public function getTags() {
|
||||
// if($this->tag=='') {
|
||||
// $this->setTags(TagDAL::GetResultByLink('mf_article', $this->GetId(), array()));
|
||||
// }
|
||||
// return $this->tag;
|
||||
// }
|
||||
//
|
||||
// public function setTags($tag) {
|
||||
// $this->tag = $tag;
|
||||
// }
|
||||
//
|
||||
// public function getTagsArrayId() {
|
||||
// $arrayObj = $this->getTags();
|
||||
// $arraySel = array();
|
||||
// foreach ($arrayObj as $obj) {
|
||||
// $arraySel[] = $obj->GetId();
|
||||
// }
|
||||
// return $arraySel;
|
||||
// }
|
||||
//
|
||||
// public function getCustomer() {
|
||||
// if($this->customer=='') {
|
||||
// $this->setCustomer(TagDAL::GetResultCustomerByLink('mf_article', $this->GetId(), array()));
|
||||
// }
|
||||
// return $this->customer;
|
||||
// }
|
||||
//
|
||||
// public function getCustomerArrayId() {
|
||||
// $arrayObj = $this->getCustomer();
|
||||
// $arraySel = array();
|
||||
// foreach ($arrayObj as $obj) {
|
||||
// $arraySel[] = $obj->GetId();
|
||||
// }
|
||||
// return $arraySel;
|
||||
// }
|
||||
//
|
||||
// public function setCustomer($c) {
|
||||
// $this->customer = $c;
|
||||
// }
|
||||
//
|
||||
// public function getStringTag($delimiter = ", ")
|
||||
// {
|
||||
// $stringTag = "";
|
||||
// if (is_array($this->getTags())) {
|
||||
//
|
||||
//
|
||||
// foreach($this->tag as $key => $value)
|
||||
// {
|
||||
// $stringTag .= $value->GetTag() . $delimiter;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return substr($stringTag,0,strlen($stringTag)-strlen($delimiter));
|
||||
// }
|
||||
|
||||
public function setStructure($s) {
|
||||
$this->structure = $s;
|
||||
}
|
||||
|
||||
public function getStructure()
|
||||
{
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
public function setArrayImage($arrayImage) {
|
||||
$this->arrayImage = $arrayImage;
|
||||
}
|
||||
|
||||
public function getArrayImage() {
|
||||
if (!$this->arrayImage && $this->idImageGroup > 0) {
|
||||
//$this->setArrayImage(ImageDAL::GetResultByLink('mf_article', $this->id));
|
||||
$this->setArrayImage(ImageDAL::GetResult(array('id_image_group' => $this->idImageGroup, 'size' => 2),null,'weight'));
|
||||
}
|
||||
return $this->arrayImage;
|
||||
}
|
||||
|
||||
public function setIdImageGroup($idImageGroup) {
|
||||
$this->idImageGroup = $idImageGroup;
|
||||
}
|
||||
|
||||
public function getIdImageGroup() {
|
||||
return $this->idImageGroup;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
public function GetTypes(){
|
||||
return self::$types;
|
||||
}
|
||||
|
||||
public function GetTypeName($type){
|
||||
return self::$fields[$type];
|
||||
}
|
||||
public function GetCategoryNameTest($type){
|
||||
return self::$categoryName[$type];
|
||||
}
|
||||
public static function GetCategory(){
|
||||
return self::$categoryName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa kategorii artukułow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleCategory extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_article_category';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_article_category';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
static $exts = array(
|
||||
'jpg',
|
||||
'gif',
|
||||
'jpeg',
|
||||
'bmp',
|
||||
'png'
|
||||
);
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_article_category' =>'id',
|
||||
'weight' =>'weight',
|
||||
'id_parent' =>'idParent',
|
||||
'publication' =>'publication'
|
||||
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $weight;
|
||||
private $publication;
|
||||
private $idParent;
|
||||
private $articleCategoryDescriptionObj;
|
||||
private $articleDescriptionObj;
|
||||
private $lang;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function SetIdParent($parent) {
|
||||
$this->idParent = $parent;
|
||||
}
|
||||
|
||||
public function GetIdParent() {
|
||||
return $this->idParent;
|
||||
}
|
||||
|
||||
public function GetWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function SetWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
public function GetUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function SetUrl($url) {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->articleDescriptionObj)) {
|
||||
$articleCategoryDescriptionObj = SimpleArticle_MfArticleCategoryDescriptionDAL::GetResult(array('lang'=>$this->GetLang(), 'id_mf_article_category'=>$this->GetId()), array('name', 'lang', 'publication', 'id_mf_article_category'));
|
||||
if(isset($articleCategoryDescriptionObj[0]) && is_object($articleCategoryDescriptionObj[0])) {
|
||||
$this->SetArticleCategoryDescriptionObj($articleCategoryDescriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->articleCategoryDescriptionObj;
|
||||
}
|
||||
|
||||
public function SetArticleCategoryDescriptionObj($articleCategoryDescriptionObj) {
|
||||
$this->articleCategoryDescriptionObj = $articleCategoryDescriptionObj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Eksperymentalne przeciazenie metod kierowane do podobiektu slownikowego
|
||||
*/
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
public function GetMfLinkCategoryDescription() {
|
||||
return $this->mfLinkCategoryDescription;
|
||||
}
|
||||
|
||||
public function SetMfLinkCategoryDescription($mfLinkCategoryDescription) {
|
||||
$this->mfLinkCategoryDescription = $mfLinkCategoryDescription;
|
||||
}
|
||||
|
||||
public function GetMfLinkWeight() {
|
||||
return $this->mfLinkWeight;
|
||||
}
|
||||
|
||||
public function SetMfLinkWeight($mfLinkWeight) {
|
||||
$this->mfLinkWeight = $mfLinkWeight;
|
||||
}
|
||||
|
||||
public function GetMfLinkType() {
|
||||
return $this->mfLinkType;
|
||||
}
|
||||
|
||||
public function SetMfLinkType($mfLinkType) {
|
||||
$this->mfLinkType = $mfLinkType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
public function GetIconUrl() {
|
||||
$return = null;
|
||||
foreach(self::$exts as $ext) {
|
||||
$path = PATH_STATIC_CONTENT."/image/Admin/Categories/Icons/".$this->id.".".$ext;
|
||||
$url = URL_STATIC_CONTENT."/image/Admin/Categories/Icons/".$this->id.".".$ext;
|
||||
if(file_exists($path)) {
|
||||
$return = $url;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obs<62>ugi prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleCategoryDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
|
||||
SimpleArticle_MfArticleCategoryDescriptionDAL::DeleteByParentId($id);
|
||||
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new SimpleArticle_MfArticleCategory(-1);
|
||||
$obj->SetArticleCategoryDescriptionObj(SimpleArticle_MfArticleCategoryDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pobiera listę kategorii sortując je po wadze (pole weight) rosnąco
|
||||
*/
|
||||
public static function GetArrayObjAll() {
|
||||
return self::GetResult(array(), array(), null, 'weight ASC');
|
||||
}
|
||||
|
||||
public static function GetResult($data, $queryFields = array(), $limit = 0, $sortBy = null, $count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__ . "_" . __FUNCTION__ . "_" . md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
} else {
|
||||
if($count == true) {
|
||||
$select = "count(`id_mf_article_category`) as count";
|
||||
} else {
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
}
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if($key == "id") {
|
||||
$key = 'id_mf_article';
|
||||
}
|
||||
|
||||
if(is_array($value)) {
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
} else {
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true) {
|
||||
return $array[0]['count'];
|
||||
}
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetList($limit = 20, $sortBy = 'id_mf_article') {
|
||||
return self::GetResult(array(), array('id_mf_article', 'date', 'url', 'weight'), $limit, $sortBy);
|
||||
}
|
||||
|
||||
public static function GetByLink($sourceType, $sourceId, $lang) {
|
||||
|
||||
$data = array('mf_link.source_type'=>'"'.$sourceType.'"', 'mf_link.id_source'=>$sourceId, 'mf_link.destination_type'=>'"'.self::GetObjClassTable().'"', 'mf_link.id_destination'=>self::GetObjClassTable().".".self::GetObjClassTablePK(), 'mf_link.id_mf_link'=>'mf_link_description.id_mf_link', 'mf_link_description.lang'=>'"'.$lang.'"');
|
||||
$sortBy = 'mf_link.link_type, mf_link.link_type';
|
||||
$queryFields = array();
|
||||
$limit = null;
|
||||
$count = null;
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
} else {
|
||||
if($count == true) {
|
||||
$select = "count(*) as count";
|
||||
} else {
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
}
|
||||
|
||||
$sql = " SELECT $select, mf_link_description.description as mf_link_description, mf_link.weight as mf_link_weight, mf_link.link_type as mf_link_type FROM " . self::GetObjClassTable() . ", mf_link, mf_link_description WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true) {
|
||||
return $array[0]['count'];
|
||||
}
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->SetMfLinkDescription($array[$i]['mf_link_description']);
|
||||
$obj->SetMfLinkWeight($array[$i]['mf_link_weight']);
|
||||
$obj->SetMfLinkType($array[$i]['mf_link_type']);
|
||||
$obj->SetLang($lang);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public function SaveFromPost($_POST) {
|
||||
//Utils::ArrayDisplay($_POST);
|
||||
if (isset($_POST['Article']['idArticleCategory']) && $_POST['Article']['idArticleCategory'] > 0) {
|
||||
|
||||
$objArticle = SimpleArticle_MfArticleCategoryDAL::GetById($_POST['Article']['idArticleCategory']);
|
||||
$objArticleDescription = SimpleArticle_MfArticleCategoryDescriptionDAL::GetResult(array('publication' => 1, 'lang' => $objArticle->GetLang(), 'id_mf_article' => $objArticle->GetId()), array('id_mf_article_description', 'title', 'description', 'shortnote'));
|
||||
$objArticleDescription = $objArticleDescription[0];
|
||||
} else {
|
||||
$objArticle = new SimpleArticle_MfArticle();
|
||||
$objArticleDescription = new SimpleArticle_MfArticleCategoryDescription();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// var_dump($objArticleDescription->GetId());
|
||||
|
||||
$objArticle->SetDate(date('Y-d-m'));
|
||||
$objArticle->SetWeight(10);
|
||||
//$objArticle->SetPublication(1);
|
||||
//Utils::ArrayDisplay($objArticle);
|
||||
$iid = SimpleArticle_MfArticleDAL::Save($objArticle);
|
||||
|
||||
$objArticleDescription->SetLang('pl');
|
||||
$objArticleDescription->SetDescription($_POST['Article']['tresc']);
|
||||
$objArticleDescription->SetShortnote($_POST['Article']['zajawka']);
|
||||
$objArticleDescription->SetTitle($_POST['tytul']);
|
||||
$objArticleDescription->SetBrowserTitle($_POST['Article']['tytulWPrzegladarce']);
|
||||
$objArticleDescription->SetPublication($_POST['publication']);
|
||||
$objArticleDescription->SetIdMfArticle($iid);
|
||||
|
||||
SimpleArticle_MfArticleDescriptionDAL::Save($objArticleDescription);
|
||||
|
||||
return $iid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function SaveSort($sortArray) {
|
||||
$array = self::GetArrayObjAll();
|
||||
foreach($array as $obj) {
|
||||
$obj->SetWeight($sortArray[$obj->GetId()]);
|
||||
self::Update($obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function GetCountAll() {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = " SELECT count(*) as ile ".
|
||||
" FROM ".self::GetObjClassTable();
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
return $array[0]["ile"];
|
||||
}
|
||||
|
||||
public static function CheckIsPublication($ids) {
|
||||
if(empty($ids)) {
|
||||
return false;
|
||||
}
|
||||
if(!is_array($ids)) {
|
||||
$ids = array($ids);
|
||||
}
|
||||
$sql = sprintf('SELECT count(publication) as count FROM mf_article_category WHERE id_mf_article_category IN (%s)', implode(',', $ids));
|
||||
$res = Registry::Get('db')->Prepare($sql)->Execute()->FetchAllAssoc();
|
||||
if($res[0]['count'] > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetCategoriesForArticles($type) {
|
||||
$sql = 'SELECT '.SQL::ToSelect('MfArticleCategory').' FROM mf_article_category where id_mf_Article_category in (
|
||||
SELECT distinct mf_link.id_destination FROM `mf_article`
|
||||
JOIN mf_link
|
||||
ON mf_link.source_type = \'mf_article\' AND
|
||||
mf_link.destination_type= \'mf_article_category\' AND
|
||||
mf_article.id_mf_article = id_source
|
||||
WHERE mf_article.type = '.$type.'
|
||||
AND mf_article.`publication` = 1
|
||||
) AND publication=1 ORDER BY weight';
|
||||
|
||||
$res = Registry::Get('db') -> prepare($sql) -> execute() -> FetchAllAssoc();
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach($res AS $row) {
|
||||
$obj = new MfArticleCategory();
|
||||
$obj -> FromArray($row,1);
|
||||
$return[] = $obj;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa jezykowa prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleCategoryDescription extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_article_category_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_article_category_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_article_category_description' => 'id',
|
||||
'name' => 'name',
|
||||
'lang' => 'lang',
|
||||
'publication' => 'publication',
|
||||
'id_mf_article_category' => 'idMfArticleCategory'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $lang;
|
||||
private $publication;
|
||||
private $idMfArticleCategory;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfArticleCategory() {
|
||||
return $this->idMfArticleCategory;
|
||||
}
|
||||
|
||||
public function SetIdMfArticleCategory($idMfArticleCategory) {
|
||||
$this->idMfArticleCategory = $idMfArticleCategory;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obs<62>ugi prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleCategoryDescriptionDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save($obj) {
|
||||
return self::DefaultSave(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Insert($obj) {
|
||||
return self::DefaultInsert(self::GetObjClassTable(), $obj);
|
||||
}
|
||||
|
||||
public static function Update($obj) {
|
||||
self::DefaultUpdate(self::GetObjClassTable(), self::GetObjClassTablePK(), $obj);
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
self::DefaultDelete(self::GetObjClassTable(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function DeleteByParentId($id) {
|
||||
$sql = "DELETE FROM `mf_article_category_description` WHERE `id_mf_article_category`=:0";
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->Prepare($sql)
|
||||
->BindParam(0, $id)
|
||||
->Execute();
|
||||
}
|
||||
|
||||
public static function GetById($id) {
|
||||
return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new SimpleArticle_MfArticleCategoryDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
return self::GetResult(array());
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_article_description' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." '". $value['value'] ."' " : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."' " : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetByLink($sourceType, $sourceId, $lang) {
|
||||
|
||||
$data = array('mf_link.source_type'=>'"'.$sourceType.'"', 'mf_link.id_source'=>$sourceId, 'mf_link.destination_type'=>'"'.self::GetObjClassTable().'"', 'mf_link.id_destination'=>self::GetObjClassTable().".".self::GetObjClassTablePK(), 'mf_link.id_mf_link'=>'mf_link_description.id_mf_link', 'mf_link_description.lang'=>'"'.$lang.'"');
|
||||
$sortBy = 'mf_link.link_type, mf_link.link_type';
|
||||
$queryFields = array();
|
||||
$limit = null;
|
||||
$count = null;
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select, mf_link_description.description as mf_link_description, mf_link.weight as mf_link_weight, mf_link.link_type as mf_link_type FROM " . self::GetObjClassTable() . ", mf_link, mf_link_description WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_article_description' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->SetMfLinkDescription($array[$i]['mf_link_description']);
|
||||
$obj->SetMfLinkWeight($array[$i]['mf_link_weight']);
|
||||
$obj->SetMfLinkType($array[$i]['mf_link_type']);
|
||||
$obj->SetLang($lang);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetIdByParentId($pid) {
|
||||
|
||||
$sql = "SELECT `id_mf_article_description` FROM `mf_article` WHERE `id_mf_article`=:0";
|
||||
|
||||
$res = $db = Registry::Get('db')
|
||||
->Prepare($sql)
|
||||
->BindParam(0, $pid)
|
||||
->Execute()
|
||||
->FetchAllAssoc();
|
||||
|
||||
return $res[0]['id_mf_article_description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
368
_rejestracja/core/_model/SimpleArticle/MfArticleDAL.class.php
Normal file
368
_rejestracja/core/_model/SimpleArticle/MfArticleDAL.class.php
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obs<62>ugi prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
if($obj->GetId()==-1) {
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
|
||||
SimpleArticle_MfArticleDescriptionDAL::DeleteByParentId($obj->GetId());
|
||||
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array('mf_article.'.self::GetObjClassTablePK()=>$id, 'lang' => $lang));
|
||||
$dalData->setJoin(array('SimpleArticle_MfArticleDescription' => ' LEFT JOIN mf_article_description ON mf_article.id_mf_article=mf_article_description.id_mf_article'));
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetResult($dalData, $showSql = null) {
|
||||
return self::DefaultGetResult($dalData, $showSql);
|
||||
}
|
||||
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new SimpleArticle_MfArticle(-1);
|
||||
$obj->SetArticleDescriptionObj(SimpleArticle_MfArticleDescriptionDAL::GetEmptyObj());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetResultOld($data, $queryFields = array(), $limit = 0, $sortBy = null, $count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__ . "_" . __FUNCTION__ . "_" . md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
} else {
|
||||
if($count == true) {
|
||||
$select = "count(`mf_article`.`id_mf_article`) as count";
|
||||
} else {
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
}
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . ", mf_article_description WHERE 1=1 AND mf_article.id_mf_article=mf_article_description.id_mf_article ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if($key == "id") {
|
||||
$key = 'id_mf_article';
|
||||
}
|
||||
|
||||
if(is_array($value)) {
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
} else {
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."'": "");
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true) {
|
||||
return $array[0]['count'];
|
||||
}
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++) {
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetList($data = array(), $limit = 20, $sortBy = 'id_mf_article') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setJoin(array('SimpleArticle_MfArticleDescription' => ' LEFT JOIN mf_article_description ON mf_article.id_mf_article=mf_article_description.id_mf_article ', 'Structure' => ' LEFT JOIN mf_structure ON mf_article.id_structure=mf_structure.id_mf_structure '));
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$result = self::GetResult($dalData);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public static function GetArrayIds($data = array(), $sortBy = 'id_mf_article') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setJoin(array('SimpleArticle_MfArticleDescription' => ' LEFT JOIN mf_article_description ON mf_article.id_mf_article=mf_article_description.id_mf_article '));
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields(array('id_mf_article'));
|
||||
$dalData->setSortBy($sortBy);
|
||||
$result = self::GetResult($dalData);
|
||||
$array = array();
|
||||
foreach ($result as $obj) {
|
||||
$array[] = $obj->GetId();
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
||||
public static function GetByLink($sourceType, $sourceId, $lang) {
|
||||
|
||||
$data = array('mf_link.source_type'=>'"'.$sourceType.'"', 'mf_link.id_source'=>$sourceId, 'mf_link.destination_type'=>'"'.self::GetObjClassTable().'"', 'mf_link.id_destination'=>self::GetObjClassTable().".".self::GetObjClassTablePK(), 'mf_link.id_mf_link'=>'mf_link_description.id_mf_link', 'mf_link_description.lang'=>'"'.$lang.'"');
|
||||
$sortBy = 'mf_link.link_type, mf_link.link_type';
|
||||
$queryFields = array();
|
||||
$limit = null;
|
||||
$count = null;
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName])) {
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
} else {
|
||||
if($count == true) {
|
||||
$select = "count(*) as count";
|
||||
} else {
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
}
|
||||
|
||||
$sql = " SELECT $select, mf_link_description.description as mf_link_description, mf_link.weight as mf_link_weight, mf_link.link_type as mf_link_type FROM " . self::GetObjClassTable() . ", mf_link, mf_link_description WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true) {
|
||||
return $array[0]['count'];
|
||||
}
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->SetMfLinkDescription($array[$i]['mf_link_description']);
|
||||
$obj->SetMfLinkWeight($array[$i]['mf_link_weight']);
|
||||
$obj->SetMfLinkType($array[$i]['mf_link_type']);
|
||||
$obj->SetLang($lang);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
// public function SaveFromPost($_POST, $className) {
|
||||
// //Utils::ArrayDisplay($_POST);
|
||||
// if (isset($_POST['Article']['idArticle']) && $_POST['Article']['idArticle'] > 0) {
|
||||
//
|
||||
// $objArticle = SimpleArticle_MfArticleDAL::GetById($_POST['Article']['idArticle']);
|
||||
// $objArticleDescription = SimpleArticle_MfArticleDescriptionDAL::GetResult(array('publication' => 1, 'lang' => $objArticle->GetLang(), 'id_mf_article' => $objArticle->GetId()), array('id_mf_article_description', 'title', 'description', 'shortnote'));
|
||||
// $objArticleDescription = $objArticleDescription[0];
|
||||
// } else {
|
||||
// $objArticle = new SimpleArticle_MfArticle();
|
||||
// $objArticleDescription = new SimpleArticle_MfArticleDescription();
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // var_dump($objArticleDescription->GetId());
|
||||
//
|
||||
// $objArticle->SetDate(date('Y-d-m'));
|
||||
// $objArticle->SetWeight(10);
|
||||
// //$objArticle->SetPublication(1);
|
||||
// //Utils::ArrayDisplay($objArticle);
|
||||
// $iid = SimpleArticle_MfArticleDAL::Save($objArticle);
|
||||
//
|
||||
// $objArticleDescription->SetLang('pl');
|
||||
// $objArticleDescription->SetDescription($_POST['Article']['tresc']);
|
||||
// $objArticleDescription->SetShortnote($_POST['Article']['zajawka']);
|
||||
// $objArticleDescription->SetTitle($_POST['tytul']);
|
||||
// $objArticleDescription->SetBrowserTitle($_POST['Article']['tytulWPrzegladarce']);
|
||||
// $objArticleDescription->SetPublication($_POST['publication']);
|
||||
// $objArticleDescription->SetIdMfArticle($iid);
|
||||
//
|
||||
// SimpleArticle_MfArticleDescriptionDAL::Save($objArticleDescription);
|
||||
//
|
||||
// return $iid;
|
||||
// }
|
||||
|
||||
public function Special($id = -1, $specjal) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
|
||||
$sql = "UPDATE mf_article SET special = $specjal
|
||||
WHERE id_mf_article = $id ";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa jezykowa prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleDescription extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_article_description';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_article_description';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_article_description' => 'id',
|
||||
'id_mf_article' => 'idMfArticle' ,
|
||||
'title' => 'title' ,
|
||||
'browser_title' => 'browserTitle',
|
||||
'description' => 'description' ,
|
||||
'description_add' => 'descriptionAdd' ,
|
||||
'shortnote' => 'shortnote',
|
||||
'lang' => 'lang',
|
||||
'publication' => 'publication',
|
||||
'autor' => 'autor'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $idMfArticle;
|
||||
private $title;
|
||||
private $browserTitle;
|
||||
private $description;
|
||||
private $descriptionAdd;
|
||||
private $shortnote;
|
||||
private $lang;
|
||||
private $publication;
|
||||
private $autor;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetIdMfArticle() {
|
||||
return $this->idMfArticle;
|
||||
}
|
||||
|
||||
public function SetIdMfArticle($idMfArticle) {
|
||||
$this->idMfArticle = $idMfArticle;
|
||||
}
|
||||
|
||||
public function GetTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function GetTitleInput() {
|
||||
return Utils::SaveInput($this->title);
|
||||
}
|
||||
|
||||
public function SetTitle($title) {
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function GetBrowserTitle() {
|
||||
return $this->browserTitle;
|
||||
}
|
||||
|
||||
public function SetBrowserTitle($browserTitle) {
|
||||
if ($browserTitle) {
|
||||
$this->browserTitle = $browserTitle;
|
||||
} else {
|
||||
$this->browserTitle = $this->title;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetDescription() {
|
||||
return str_replace('"2cms', '"'.URL_STATIC_CONTENT.'/upload/edytor/2cms', $this->description);
|
||||
}
|
||||
|
||||
public function SetDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function SetDescriptionAdd($descriptionAdd) {
|
||||
$this->descriptionAdd = $descriptionAdd;
|
||||
}
|
||||
|
||||
public function GetDescriptionAdd() {
|
||||
return $this->descriptionAdd;
|
||||
}
|
||||
|
||||
|
||||
public function GetShortnote() {
|
||||
return $this->shortnote;
|
||||
}
|
||||
|
||||
public function SetShortnote($shortnote) {
|
||||
$this->shortnote = $shortnote;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetAutor() {
|
||||
return $this->autor;
|
||||
}
|
||||
|
||||
public function SetAutor($s) {
|
||||
$this->autor = $s;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function GetDescriptionArray() {
|
||||
$array = explode('<div style="page-break-after: always;"><span style="display: none;"> </span></div>', stripslashes($this->description));
|
||||
//Utils::ArrayDisplay($array);
|
||||
$this->SetDescriptionArray($array);
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function SetDescriptionArray($descriptionArray) {
|
||||
$this->descriptionArray = $descriptionArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa do obs<62>ugi prostych artykulow
|
||||
*
|
||||
*/
|
||||
class SimpleArticle_MfArticleDescriptionDAL extends DefaultDAL {
|
||||
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
if($obj->GetId()==-1) {
|
||||
return self::Insert($obj);
|
||||
} else {
|
||||
return self::Update($obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id) {
|
||||
$result = self::GetResult(array(self::GetObjClassTablePK()=>$id), array(), 1);
|
||||
if(is_object($result[0])) {
|
||||
return $result[0];
|
||||
} else {
|
||||
throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null, $cache = true) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
return self::DefaultGetResult($dalData);
|
||||
|
||||
}
|
||||
|
||||
public static function DeleteByParentId($id) {
|
||||
$sql = "DELETE FROM `mf_article_description` WHERE `id_mf_article`=:0";
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$db->Prepare($sql)
|
||||
->BindParam(0, $id)
|
||||
->Execute();
|
||||
}
|
||||
|
||||
// public static function GetById($id) {
|
||||
// return self::DefaultGetById(self::GetOptClass(), self::GetObjClassTable(), self::GetObjClassName(), self::GetObjClassTablePK(), $id);
|
||||
// }
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
$obj = new SimpleArticle_MfArticleDescription(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
|
||||
}
|
||||
|
||||
// public static function GetResult($data,$queryFields = array(),$limit = 0, $sortBy = null,$count = null) {
|
||||
//
|
||||
// if(!is_array($data)){
|
||||
// $data = array();
|
||||
// }
|
||||
//
|
||||
// $db = Registry::Get('db');
|
||||
//
|
||||
// $queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
//
|
||||
// if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
// {
|
||||
// $sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if($count == true)
|
||||
// $select = "count(*) as count";
|
||||
// else
|
||||
// $select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
//
|
||||
// $sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
// $q = new QueryCache($queryCacheName,$sql);
|
||||
// }
|
||||
//
|
||||
// foreach ($data as $key => $value)
|
||||
// {
|
||||
// if($key == "id")
|
||||
// $key = 'id_mf_article_description' ;
|
||||
//
|
||||
// if(is_array($value))
|
||||
// $sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." '". $value['value'] ."' " : "");
|
||||
// else
|
||||
// $sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."' " : "");
|
||||
// }
|
||||
//
|
||||
// $sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
// ( $limit ? " LIMIT " . $limit : "").
|
||||
// " ";
|
||||
//
|
||||
// $stmt = $db->prepare($sql)
|
||||
// ->execute();
|
||||
//
|
||||
//
|
||||
// $array = $stmt->fetchAllAssoc();
|
||||
//
|
||||
// if($count == true)
|
||||
// return $array[0]['count'];
|
||||
//
|
||||
// $done = array();
|
||||
//
|
||||
// for($i=0;$i<count($array);$i++)
|
||||
// {
|
||||
// $className=self::GetObjClassName();
|
||||
// $obj = new $className();
|
||||
// $obj->FromArray($array[$i],1);
|
||||
// $done[] = $obj;
|
||||
// }
|
||||
// return $done;
|
||||
//
|
||||
// }
|
||||
|
||||
public static function GetByLink($sourceType, $sourceId, $lang) {
|
||||
|
||||
$data = array('mf_link.source_type'=>'"'.$sourceType.'"', 'mf_link.id_source'=>$sourceId, 'mf_link.destination_type'=>'"'.self::GetObjClassTable().'"', 'mf_link.id_destination'=>self::GetObjClassTable().".".self::GetObjClassTablePK(), 'mf_link.id_mf_link'=>'mf_link_description.id_mf_link', 'mf_link_description.lang'=>'"'.$lang.'"');
|
||||
$sortBy = 'mf_link.link_type, mf_link.link_type';
|
||||
$queryFields = array();
|
||||
$limit = null;
|
||||
$count = null;
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select, mf_link_description.description as mf_link_description, mf_link.weight as mf_link_weight, mf_link.link_type as mf_link_type FROM " . self::GetObjClassTable() . ", mf_link, mf_link_description WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = 'id_mf_article_description' ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = ". $value : "");
|
||||
}
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$obj->SetMfLinkDescription($array[$i]['mf_link_description']);
|
||||
$obj->SetMfLinkWeight($array[$i]['mf_link_weight']);
|
||||
$obj->SetMfLinkType($array[$i]['mf_link_type']);
|
||||
$obj->SetLang($lang);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
public static function GetIdByParentId($pid) {
|
||||
|
||||
$sql = "SELECT `id_mf_article_description` FROM `mf_article` WHERE `id_mf_article`=:0";
|
||||
|
||||
$res = $db = Registry::Get('db')
|
||||
->Prepare($sql)
|
||||
->BindParam(0, $pid)
|
||||
->Execute()
|
||||
->FetchAllAssoc();
|
||||
|
||||
return $res[0]['id_mf_article_description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
265
_rejestracja/core/_model/Site.class.php
Normal file
265
_rejestracja/core/_model/Site.class.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* Model dla klasy Site
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class Site extends DataObject{
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'site';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_site';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_site' => 'id',
|
||||
'name' => 'name',
|
||||
'date_add' => 'dateAdd',
|
||||
'id_site_parent' => 'idSiteParent',
|
||||
'id_language' => 'idLanguage',
|
||||
'content' => 'content',
|
||||
'site_order' => 'siteOrder',
|
||||
'site_location' => 'siteLocation',
|
||||
'type' => 'type',
|
||||
'id_site_main' => 'idSiteMain',
|
||||
'color' => 'color',
|
||||
'lower_name' => 'lowerName',
|
||||
'date_active_start' => 'dateActiveStart',
|
||||
'date_active_stop' => 'dateActiveStop',
|
||||
'active' => 'active'
|
||||
);
|
||||
|
||||
|
||||
protected $id;
|
||||
private $name;
|
||||
private $dateAdd;
|
||||
private $idSiteParent;
|
||||
private $idLanguage;
|
||||
private $content;
|
||||
private $siteOrder;
|
||||
private $siteLocation;
|
||||
private $type;
|
||||
private $idSiteMain;
|
||||
private $color;
|
||||
private $lowerName;
|
||||
private $dateActiveStart;
|
||||
private $dateActiveStop;
|
||||
private $active;
|
||||
|
||||
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct( $id = -1 , $name = null, $dateAdd = null, $idSiteParent = null, $idLanguage = null, $content = null, $siteOrder = null, $siteLocation = null, $type = null, $idSiteMain = null, $color = null, $lowerName = null, $dateActiveStart = null, $dateActiveStop = null, $active = null){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->dateAdd = $dateAdd;
|
||||
$this->idSiteParent = $idSiteParent;
|
||||
$this->idLanguage = $idLanguage;
|
||||
$this->content = $content;
|
||||
$this->siteOrder = $siteOrder;
|
||||
$this->siteLocation = $siteLocation;
|
||||
$this->type = $type;
|
||||
$this->idSiteMain = $idSiteMain;
|
||||
$this->color = $color;
|
||||
$this->lowerName = $lowerName;
|
||||
$this->dateActiveStart = $dateActiveStart;
|
||||
$this->dateActiveStop = $dateActiveStop;
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
public function getDateAdd(){
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function setDateAdd($dateAdd){
|
||||
$this->dateAdd = $dateAdd;
|
||||
}
|
||||
|
||||
|
||||
public function getIdSiteParent(){
|
||||
return $this->idSiteParent;
|
||||
}
|
||||
|
||||
public function setIdSiteParent($idSiteParent){
|
||||
$this->idSiteParent = $idSiteParent;
|
||||
}
|
||||
|
||||
|
||||
public function getIdLanguage(){
|
||||
return $this->idLanguage;
|
||||
}
|
||||
|
||||
public function setIdLanguage($idLanguage){
|
||||
$this->idLanguage = $idLanguage;
|
||||
}
|
||||
|
||||
|
||||
public function getContent(){
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent($content){
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
|
||||
public function getSiteOrder(){
|
||||
return $this->siteOrder;
|
||||
}
|
||||
|
||||
public function setSiteOrder($siteOrder){
|
||||
$this->siteOrder = $siteOrder;
|
||||
}
|
||||
|
||||
|
||||
public function getSiteLocation(){
|
||||
return $this->siteLocation;
|
||||
}
|
||||
|
||||
public function setSiteLocation($siteLocation){
|
||||
$this->siteLocation = $siteLocation;
|
||||
}
|
||||
|
||||
|
||||
public function getType(){
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type){
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
|
||||
public function getIdSiteMain(){
|
||||
return $this->idSiteMain;
|
||||
}
|
||||
|
||||
public function setIdSiteMain($idSiteMain){
|
||||
$this->idSiteMain = $idSiteMain;
|
||||
}
|
||||
|
||||
|
||||
public function getColor(){
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function setColor($color){
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
|
||||
public function getLowerName(){
|
||||
return $this->lowerName;
|
||||
}
|
||||
|
||||
public function setLowerName($lowerName){
|
||||
$this->lowerName = $lowerName;
|
||||
}
|
||||
|
||||
|
||||
public function getDateActiveStart(){
|
||||
return $this->dateActiveStart;
|
||||
}
|
||||
|
||||
public function setDateActiveStart($dateActiveStart){
|
||||
$this->dateActiveStart = $dateActiveStart;
|
||||
}
|
||||
|
||||
|
||||
public function getDateActiveStop(){
|
||||
return $this->dateActiveStop;
|
||||
}
|
||||
|
||||
public function setDateActiveStop($dateActiveStop){
|
||||
$this->dateActiveStop = $dateActiveStop;
|
||||
}
|
||||
|
||||
|
||||
public function getActive(){
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive($active){
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
153
_rejestracja/core/_model/SiteDAL.class.php
Normal file
153
_rejestracja/core/_model/SiteDAL.class.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy site
|
||||
*
|
||||
*/
|
||||
class SiteDAL extends DefaultDAL{
|
||||
|
||||
|
||||
protected static $objClassName = 'Site';
|
||||
protected static $objClassTable = 'site';
|
||||
protected static $objClassTablePK = 'id_site';
|
||||
private static $optClass;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function Save($obj) {
|
||||
if($obj->GetId()=='-1') {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultInsert($dalData);
|
||||
} else {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
//Utils::ArrayDisplay($dalData);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById($id, $lang = 'pl') {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
if (class_exists(self::GetObjClassName().'Description')) {
|
||||
$dalData->setJoin(array(self::GetObjClassName().'Description' => ' LEFT JOIN '.self::GetObjClassTable().'_description ON '.self::GetObjClassTable().'.id_'.self::GetObjClassTable().'='.self::GetObjClassTable().'_description.id_'.self::GetObjClassTable().''));
|
||||
}
|
||||
$dalData->setLimit(1);
|
||||
$result = self::GetResult($dalData);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
return self::GetEmptyObj();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
public static function GetEmptyObj() {
|
||||
//Utils::ArrayDisplay('tu jestem ');
|
||||
$obj = new MfSite(-1);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
450
_rejestracja/core/_model/Structure.class.php
Normal file
450
_rejestracja/core/_model/Structure.class.php
Normal file
@@ -0,0 +1,450 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Klasa struktury menu
|
||||
*
|
||||
*/
|
||||
class Structure extends DataObject {
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_structure';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_structure';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_structure' => 'id',
|
||||
'id_parent' => 'idParent',
|
||||
'id_content' => 'idContent',
|
||||
'id_main' => 'idMain',
|
||||
'id_router' => 'idRouter',
|
||||
'id_router_detail' => 'idRouterDetail',
|
||||
'id_router_page' => 'idRouterPage',
|
||||
'lang' => 'lang',
|
||||
'sort' => 'sort',
|
||||
'publication' => 'publication',
|
||||
'publication_menu' => 'publicationMenu',
|
||||
'type' => 'type',
|
||||
'name' => 'name',
|
||||
'subname' => 'subname',
|
||||
'element_name' => 'elementName',
|
||||
'menu_name' => 'menuName',
|
||||
'url' => 'url',
|
||||
'url_label' => 'urlLabel',
|
||||
'banner' => 'banner',
|
||||
'copy' => 'copy',
|
||||
'location' => 'location',
|
||||
'id_mf_picture' => 'idPicture',
|
||||
'id_mf_picture_mini' => 'idPictureMini',
|
||||
'url_redirect' => 'urlRedirect'
|
||||
);
|
||||
protected $id;
|
||||
private $idParent;
|
||||
private $idContent;
|
||||
private $idMain;
|
||||
private $idRouter;
|
||||
private $idRouterDetail;
|
||||
private $idRouterPage;
|
||||
private $lang;
|
||||
private $sort = 1;
|
||||
private $publication;
|
||||
private $publicationMenu;
|
||||
private $type;
|
||||
private $name;
|
||||
private $subname;
|
||||
private $elementName;
|
||||
private $menuName;
|
||||
private $url;
|
||||
private $urlLabel;
|
||||
private $banner;
|
||||
private $location;
|
||||
private $copy;
|
||||
private $idPicture = 0;
|
||||
private $idPictureMini = 0;
|
||||
private $urlRedirect = null;
|
||||
private $picture;
|
||||
private $pictureMini;
|
||||
private $haveChildren;
|
||||
public $arrayChildren = array();
|
||||
public $content;
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($s) {
|
||||
$this->name = $s;
|
||||
}
|
||||
|
||||
public function GetSubname() {
|
||||
return $this->subname;
|
||||
}
|
||||
|
||||
public function SetSubname($s) {
|
||||
$this->subname = $s;
|
||||
}
|
||||
|
||||
public function GetNameUpper() {
|
||||
return Utils::TextToUpper($this->name);
|
||||
}
|
||||
|
||||
public function GetArrayName($lang) {
|
||||
return Utils::TextToUpperArray($this->name, $lang);
|
||||
}
|
||||
|
||||
public function GetElementName() {
|
||||
if (!$this->elementName) {
|
||||
$this->elementName = $this->name;
|
||||
}
|
||||
return $this->elementName;
|
||||
}
|
||||
|
||||
public function SetElementName($s) {
|
||||
$this->elementName = $s;
|
||||
}
|
||||
|
||||
public function GetMenuName() {
|
||||
return $this->menuName;
|
||||
}
|
||||
|
||||
public function SetMenuName($s) {
|
||||
$this->menuName = $s;
|
||||
}
|
||||
|
||||
public function GetIdParent() {
|
||||
return $this->idParent;
|
||||
}
|
||||
|
||||
public function SetIdParent($s) {
|
||||
$this->idParent = $s;
|
||||
}
|
||||
|
||||
public function GetIdContent() {
|
||||
return $this->idContent;
|
||||
}
|
||||
|
||||
public function SetIdContent($s) {
|
||||
$this->idContent = $s;
|
||||
}
|
||||
|
||||
public function GetIdMain() {
|
||||
return $this->idMain;
|
||||
}
|
||||
|
||||
public function SetIdMain($s) {
|
||||
$this->idMain = $s;
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($s) {
|
||||
$this->lang = $s;
|
||||
}
|
||||
|
||||
public function GetIdRouter() {
|
||||
return $this->idRouter;
|
||||
}
|
||||
|
||||
public function SetIdRouter($s) {
|
||||
$this->idRouter = $s;
|
||||
}
|
||||
|
||||
public function GetIdRouterDetail() {
|
||||
return $this->idRouterDetail;
|
||||
}
|
||||
|
||||
public function SetIdRouterDetail($s) {
|
||||
$this->idRouterDetail = $s;
|
||||
}
|
||||
|
||||
public function GetIdRouterPage() {
|
||||
return $this->idRouterPage;
|
||||
}
|
||||
|
||||
public function SetIdRouterPage($s) {
|
||||
$this->idRouterPage = $s;
|
||||
}
|
||||
|
||||
public function GetSort() {
|
||||
return $this->sort;
|
||||
}
|
||||
|
||||
public function SetSort($s) {
|
||||
$this->sort = $s;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($s) {
|
||||
$this->publication = $s;
|
||||
}
|
||||
|
||||
public function GetPublicationMenu() {
|
||||
return $this->publicationMenu;
|
||||
}
|
||||
|
||||
public function SetPublicationMenu($s) {
|
||||
$this->publicationMenu = $s;
|
||||
}
|
||||
|
||||
public function GetUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function SetUrl($s) {
|
||||
$this->url = $s;
|
||||
}
|
||||
|
||||
public function GetUrlWithType() {
|
||||
return Router::GenerateUrl($this->urlLabel);
|
||||
}
|
||||
|
||||
public function GetType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function SetType($s) {
|
||||
$this->type = $s;
|
||||
}
|
||||
|
||||
public function GetUrlLabel() {
|
||||
return $this->urlLabel;
|
||||
}
|
||||
|
||||
public function GetUrlLabelDetail() {
|
||||
return $this->urlLabel . 'Detail';
|
||||
}
|
||||
|
||||
public function SetUrlLabel($s) {
|
||||
$this->urlLabel = $s;
|
||||
}
|
||||
|
||||
public function GetCopy() {
|
||||
return $this->copy;
|
||||
}
|
||||
|
||||
public function SetCopy($s) {
|
||||
$this->copy = $s;
|
||||
}
|
||||
|
||||
public function GetLocation() {
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function SetLocation($s) {
|
||||
$this->location = $s;
|
||||
}
|
||||
|
||||
public function GetBanner() {
|
||||
return $this->banner;
|
||||
}
|
||||
|
||||
public function SetBanner($s) {
|
||||
$this->banner = $s;
|
||||
}
|
||||
|
||||
public function GetBannerTh() {
|
||||
return str_replace('.jpg', '_th.jpg', $this->banner);
|
||||
}
|
||||
|
||||
public function GetHaveChildren() {
|
||||
return $this->haveChildren;
|
||||
}
|
||||
|
||||
public function SetHaveChildren($s) {
|
||||
$this->haveChildren = $s;
|
||||
}
|
||||
|
||||
public function SetArrayChildren($s) {
|
||||
$this->arrayChildren = $s;
|
||||
}
|
||||
|
||||
public function AddChildren($obj) {
|
||||
$this->arrayChildren = array_merge_recursive($this->arrayChildren, $obj);
|
||||
}
|
||||
|
||||
public function GetArrayChildren() {
|
||||
return $this->arrayChildren;
|
||||
}
|
||||
|
||||
public function GetMainFileName() {
|
||||
return Utils::ClearString($this->GetMenuName());
|
||||
}
|
||||
|
||||
public function GetBannerWhitUrl() {
|
||||
if (file_exists(PATH_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->banner)) {
|
||||
return URL_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->banner;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetBannerThWhitUrl() {
|
||||
if (file_exists(PATH_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->GetBannerTh())) {
|
||||
//Utils::ArrayDisplay();
|
||||
return URL_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->GetBannerTh();
|
||||
}
|
||||
}
|
||||
|
||||
public function setSimpleArticle_MfArticleDescription($content) {
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function getSimpleArticle_MfArticleDescription() {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function getContent() {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function SetIdPicture($idPicture) {
|
||||
$this->idPicture = $idPicture;
|
||||
}
|
||||
|
||||
public function GetIdPicture() {
|
||||
return $this->idPicture;
|
||||
}
|
||||
|
||||
public function SetIdPictureMini($idPictureMini) {
|
||||
$this->idPictureMini = $idPictureMini;
|
||||
}
|
||||
|
||||
public function GetIdPictureMini() {
|
||||
return $this->idPictureMini;
|
||||
}
|
||||
|
||||
public function SetUrlRedirect($urlRedirect) {
|
||||
$this->urlRedirect = $urlRedirect;
|
||||
}
|
||||
|
||||
public function GetUrlRedirect() {
|
||||
if ($this->urlRedirect) {
|
||||
$pos = strpos($this->urlRedirect, 'http://');
|
||||
//Utils::ArrayDisplay($pos);
|
||||
if ($pos === false) {
|
||||
//Utils::ArrayDisplay($this->urlRedirect);
|
||||
return 'http://' . $this->urlRedirect;
|
||||
} else {
|
||||
return $this->urlRedirect;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function SetPicture($picture) {
|
||||
$this->picture = $picture;
|
||||
}
|
||||
|
||||
public function GetPicture() {
|
||||
if (!$this->picture && (int) $this->idPicture > 0) {
|
||||
$this->picture = PictureDAL::GetById($this->GetIdPicture());
|
||||
}
|
||||
|
||||
return $this->picture;
|
||||
}
|
||||
|
||||
public function GetPictureUrl() {
|
||||
if ($this->GetPicture()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/Structure/' . $this->GetPicture()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function SetPictureMini($pictureMini) {
|
||||
$this->pictureMini = $pictureMini;
|
||||
}
|
||||
|
||||
public function GetPictureMini() {
|
||||
if (!$this->pictureMini && (int) $this->idPictureMini > 0) {
|
||||
$this->pictureMini = PictureDAL::GetById($this->GetIdPictureMini());
|
||||
}
|
||||
|
||||
return $this->pictureMini;
|
||||
}
|
||||
|
||||
public function GetPictureMiniUrl() {
|
||||
if ($this->GetPictureMini()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/Structure/' . $this->GetPictureMini()->GetLink();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id = -1, $idContent = '-1', $idParent = 0, $idMain = 0, $idRouter = '-1', $lang = 1, $sort = 0, $publication = 0, $name = null, $menuName = '', $url = null, $urlLabel = null) {
|
||||
$this->SetId($id);
|
||||
$this->SetIdContent($idContent);
|
||||
;
|
||||
$this->SetIdParent($idParent);
|
||||
;
|
||||
$this->SetIdMain($idMain);
|
||||
$this->SetLang($lang);
|
||||
$this->SetIdRouter($idRouter);
|
||||
$this->SetName($name);
|
||||
$this->SetMenuName($menuName);
|
||||
$this->SetPublication($publication);
|
||||
$this->SetUrl($url);
|
||||
$this->SetUrlLabel($urlLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName() {
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera taablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields() {
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName() {
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
398
_rejestracja/core/_model/StructureDAL.class.php
Normal file
398
_rejestracja/core/_model/StructureDAL.class.php
Normal file
@@ -0,0 +1,398 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa obsługi tablicy struktury menu
|
||||
*
|
||||
*/
|
||||
class StructureDAL extends DefaultDAL {
|
||||
protected static $objClassName;
|
||||
protected static $objClassTable;
|
||||
protected static $objClassTablePK;
|
||||
private static $optClass;
|
||||
|
||||
public static function Save( $obj) {
|
||||
$id = null;
|
||||
|
||||
if($obj->GetId()==-1 || $obj->GetId()=='NULL') {
|
||||
|
||||
$id = self::Insert($obj);
|
||||
} else {
|
||||
|
||||
self::Update($obj);
|
||||
$id = $obj->GetId();
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Feed $obj
|
||||
*
|
||||
*/
|
||||
public static function Insert($obj) {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObj($obj);
|
||||
$id = self::DefaultInsert($dalData);
|
||||
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* @param Text $obj
|
||||
*
|
||||
*/
|
||||
public static function Update($obj) {
|
||||
//Utils::ArrayDisplay($obj);
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultUpdate($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
*/
|
||||
public static function Delete($obj) {
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setObj($obj);
|
||||
return self::DefaultDelete($dalData);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function GetById($id, $getContent = false) {
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array(self::GetObjClassTablePK()=>$id));
|
||||
$dalData->setLimit(1);
|
||||
if ($getContent) {
|
||||
$dalData->setJoin(array('SimpleArticle_MfArticleDescription' => ' LEFT JOIN mf_article_description ON mf_article_description.id_mf_article=mf_structure.id_content'));
|
||||
}
|
||||
|
||||
$result = self::GetResult($dalData, false);
|
||||
if ((count($result) > 0) && (is_object($result[0]))) {
|
||||
return $result[0];
|
||||
} else {
|
||||
return false;
|
||||
//throw new Exception('Brak rekordu w tablicy '.self::GetObjClassTable().' o id <b>'.$id.'</b>!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetArrayObjAll() {
|
||||
return self::GetResult(array(), array());
|
||||
}
|
||||
|
||||
public static function GetIdAndName() {
|
||||
$data = self::GetResult(array());
|
||||
$done = array();
|
||||
foreach($data as $value) {
|
||||
$done[$value->GetId()] = $value->GetName();
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
public static function GetResult($dalData, $showSql = false) {
|
||||
return self::DefaultGetResult($dalData, $showSql);
|
||||
}
|
||||
|
||||
public static function GetResultOld($data,$queryFields = array(),$limit = 0, $sortBy = 'sort',$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."'" : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[] = $obj;
|
||||
}
|
||||
return $done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function GetTree($data,$queryFields = array(),$limit = 0, $sortBy = 'sort',$count = null) {
|
||||
|
||||
if(!is_array($data)){
|
||||
$data = array();
|
||||
}
|
||||
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$queryCacheName = __CLASS__. "_" .__FUNCTION__. "_" .md5(implode($queryFields));
|
||||
|
||||
if(isset(QueryCacheTemp::$cacheQuery[$queryCacheName]))
|
||||
{
|
||||
$sql = QueryCacheTemp::$cacheQuery[$queryCacheName];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count == true)
|
||||
$select = "count(*) as count";
|
||||
else
|
||||
$select =" " . SQL::ToSelect(self::GetOptClass(),$queryFields) . " ";
|
||||
|
||||
$sql = " SELECT $select FROM " . self::GetObjClassTable() . " WHERE 1=1 ";
|
||||
$q = new QueryCache($queryCacheName,$sql);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if($key == "id")
|
||||
$key = $objId ;
|
||||
|
||||
|
||||
if(is_array($value))
|
||||
$sql .= ( is_numeric($value['value']) || $value ? " AND ".$key." ".$value['condition']." ". $value['value'] : "");
|
||||
else
|
||||
$sql .= ( is_numeric($value) || $value ? " AND ".$key." = '". $value ."'" : "");
|
||||
}
|
||||
|
||||
$sql .= ( $sortBy ? " ORDER BY $sortBy " : "").
|
||||
( $limit ? " LIMIT " . $limit : "").
|
||||
" ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute();
|
||||
|
||||
//Utils::ArrayDisplay($sql);
|
||||
|
||||
$array = $stmt->fetchAllAssoc();
|
||||
|
||||
if($count == true)
|
||||
return $array[0]['count'];
|
||||
|
||||
$done = array();
|
||||
|
||||
for($i=0;$i<count($array);$i++)
|
||||
{
|
||||
$className=self::GetObjClassName();
|
||||
$obj = new $className();
|
||||
$obj->FromArray($array[$i],1);
|
||||
$done[$obj->GetId()] = $obj;
|
||||
}
|
||||
//
|
||||
// foreach ($done as $key => $obj) {
|
||||
// if ($obj->GetIdParent() == 0) {
|
||||
// $arrayObjParent[] = $obj;
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach ($done as $key => $obj) {
|
||||
|
||||
if ($obj->GetIdParent() != 0) {
|
||||
if (key_exists($obj->GetIdParent(), $done)) {
|
||||
$done[$obj->GetIdParent()]->SetHaveChildren(true);
|
||||
$done[$obj->GetIdParent()]->AddChildren(array($obj->GetId() => $obj));
|
||||
} else {
|
||||
$arrayTree[$key] = $obj;
|
||||
}
|
||||
|
||||
}
|
||||
if ($obj->GetIdParent() == 0) {
|
||||
//Utils::ArrayDisplay('ones');
|
||||
$arrayTree[$key] = $obj;
|
||||
}
|
||||
}
|
||||
foreach ($done as $key => $obj) {
|
||||
|
||||
}
|
||||
|
||||
if (isset($arrayTree)) {
|
||||
|
||||
return $arrayTree;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function CheckPublication($id) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT
|
||||
id_mf_structure
|
||||
FROM mf_structure WHERE id_mf_structure = $id AND publication = 1";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
if ($stmt->NumRows() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function CheckChildren($idParent) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT
|
||||
id_mf_structure
|
||||
FROM mf_structure WHERE id_parent = $idParent ";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
if ($stmt->NumRows() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetArrayRouter() {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT
|
||||
id_mf_router, name, url, controller, method, param, paramMatrix, matchUri, config
|
||||
FROM mf_router";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
while (($row = $stmt->FetchArray())) {
|
||||
|
||||
|
||||
$array[$row["id_mf_router"]] = array('name' =>$row["name"],
|
||||
'url' => $row["url"],
|
||||
'controller' => $row["controller"],
|
||||
'method' => $row["method"],
|
||||
'param' => $row["param"],
|
||||
'paramMatrix' => $row["paramMatrix"],
|
||||
'matchUri' => $row["matchUri"],
|
||||
'config' => $row["config"]
|
||||
);
|
||||
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function GetLabel($id) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "SELECT url_label FROM mf_structure WHERE id_mf_structure = $id";
|
||||
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
$row = $stmt->FetchArray();
|
||||
return $row['url_label'];
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = str_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj() {
|
||||
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
//$dalData->setDatabaseType('dbTemp');
|
||||
|
||||
return $dalData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
81
_rejestracja/core/class/Config.class.php
Normal file
81
_rejestracja/core/class/Config.class.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* $Id: Config.class.php 395 2008-05-28 19:41:06Z pawy $
|
||||
* Singleton dostepu do danych konfiguracyjnych serwisu
|
||||
*
|
||||
*/
|
||||
class Config {
|
||||
|
||||
static private $dbConfig;
|
||||
static private $internalConfig;
|
||||
static private $iniConfig;
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
*/
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Zapobiegacz klonowania
|
||||
*
|
||||
*/
|
||||
private function __clone() {}
|
||||
|
||||
/**
|
||||
* Ustawia konfiga z bazy
|
||||
*
|
||||
*/
|
||||
public static function SetDbConfig($dbConfig) {
|
||||
self::$dbConfig = $dbConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca wartosc lub wyjatek
|
||||
*
|
||||
*/
|
||||
public static function Get($value) {
|
||||
if(isset(self::$dbConfig[$value])) {
|
||||
$return = self::$dbConfig[$value];
|
||||
} else if(isset(self::$internalConfig[$value])) {
|
||||
$return = self::$internalConfig[$value];
|
||||
} else if(isset(self::$iniConfig[$value])) {
|
||||
$return = self::$iniConfig[$value];
|
||||
} else if(defined($value)) {
|
||||
$return = constant($value);
|
||||
} else {
|
||||
$return = false;
|
||||
throw new UserException("Niezdefiniowany parametr konfiguracji: '$value'",$value);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function Exists($value) {
|
||||
if(isset(self::$dbConfig[$value]) || isset(self::$internalConfig[$value]) || defined($value)) {
|
||||
return true;
|
||||
} else {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function Set($variable, $value) {
|
||||
self::$internalConfig[$variable] = $value;
|
||||
}
|
||||
|
||||
public static function LoadIniConfig($file, $sections = true) {
|
||||
if (!is_array(self::$iniConfig)) {
|
||||
self::$iniConfig = array();
|
||||
}
|
||||
|
||||
self::$iniConfig = array_merge(self::$iniConfig, parse_ini_file($file, $sections));
|
||||
}
|
||||
|
||||
public static function GetIniConfig() {
|
||||
return self::$iniConfig;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
753
_rejestracja/core/class/Controller.class.php
Normal file
753
_rejestracja/core/class/Controller.class.php
Normal file
@@ -0,0 +1,753 @@
|
||||
<?
|
||||
/**
|
||||
* $Id: Controller.mod.php 394 2008-05-28 19:28:03Z dakl $
|
||||
* Klasa kontrolera v 1.2.0
|
||||
*
|
||||
*/
|
||||
abstract class Controller {
|
||||
/**
|
||||
* Szablon dla metody
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $partialTemplate;
|
||||
/**
|
||||
* Sciezka szablonu dla metody
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $templatePath;
|
||||
/**
|
||||
* Wygenerowana przez metode tresc
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $content;
|
||||
/**
|
||||
* Czas cache dla metody
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $cacheTime;
|
||||
|
||||
/**
|
||||
* Obiekt Smarty
|
||||
*
|
||||
* @var Smarty
|
||||
*/
|
||||
protected $smarty;
|
||||
|
||||
/**
|
||||
* Obiekt request
|
||||
*
|
||||
* @Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
public $utf8;
|
||||
|
||||
/**
|
||||
* Zawiera url na ktory ma byc przekierowany user
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $redirect = array('url'=>'', 'time'=>'');
|
||||
/**
|
||||
* Wylacza obsluge smarty
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $disableTemplates = false;
|
||||
|
||||
public $actionRedirect = false;
|
||||
|
||||
private $breadCrumbs = array();
|
||||
|
||||
private $actionSet = array();
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
*/
|
||||
public final function __construct() {
|
||||
|
||||
}
|
||||
/**
|
||||
* Ustawia przekierowanie
|
||||
*
|
||||
* @param string $action (true/false/string: action)
|
||||
*
|
||||
*/
|
||||
public final function SetActionRedirect($action) {
|
||||
$this->actionRedirect = $action;
|
||||
}
|
||||
/**
|
||||
* Zwraca przekierowanie
|
||||
*
|
||||
*/
|
||||
public final function GetActionRedirect() {
|
||||
return $this->actionRedirect;
|
||||
}
|
||||
|
||||
public final function SetBreadCrumbs($array) {
|
||||
$this->breadCrumbs = $array;
|
||||
}
|
||||
|
||||
public function SetUtf8() {
|
||||
$this->utf8 = true;
|
||||
}
|
||||
|
||||
public final function GetBreadCrumbs() {
|
||||
return $this->breadCrumbs;
|
||||
}
|
||||
|
||||
public final function AddBreadCrumb($title, $url) {
|
||||
$this->breadCrumbs[] = array('title'=>$title, 'url'=>$url);
|
||||
// Utils::ArrayDisplay($this->breadCrumbs);
|
||||
}
|
||||
|
||||
public final function AddHeader($name, $value) {
|
||||
//TODO : New Feature - testme
|
||||
|
||||
$headers = Registry::Get('headers');
|
||||
$headers[$name][] = $value;
|
||||
Registry::Remove('headers');
|
||||
Registry::Set('headers', $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodawanie opisu
|
||||
*
|
||||
* @param unknown_type $desc
|
||||
*/
|
||||
public final function AddDescription($desc) {
|
||||
//Registry::Remove('description');
|
||||
//Registry::Set('description', $desc);
|
||||
$this->AddHeader('description', $desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodawanie opisu
|
||||
*
|
||||
* @param unknown_type $desc
|
||||
*/
|
||||
public final function AddKeywords($desc) {
|
||||
//Registry::Remove('description');
|
||||
//Registry::Set('description', $desc);
|
||||
$this->AddHeader('meta', array('name'=>'keywords', 'content'=>$desc));
|
||||
}
|
||||
|
||||
/**
|
||||
* Metoda przypisujaca obiekt smarty
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
*/
|
||||
public final function SetSmarty(Smarty $smarty) {
|
||||
$this->smarty = $smarty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodawanie elementu tytulu
|
||||
*
|
||||
* @param unknown_type $title
|
||||
*/
|
||||
public final function AddTitle($title) {
|
||||
/*$t = Registry::Get('title');
|
||||
$t[] = $title;
|
||||
Registry::Remove('title');
|
||||
Registry::Set('title', $t);*/
|
||||
$this->AddHeader('title', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Weryfikacja cache metody
|
||||
*
|
||||
* @param unknown_type $method
|
||||
* @param unknown_type $param
|
||||
* @return unknown
|
||||
*/
|
||||
public final function Init($method, $param) {
|
||||
|
||||
$this->SetReturnPath(array());
|
||||
|
||||
//logika werifikacji cache dla metod.
|
||||
$cacheTimeTmp = CacheParam::Get(get_class($this).$method);
|
||||
$cacheTimeTmp2 = CacheParam::Get(get_class($this));
|
||||
if(isset($cacheTimeTmp) && $cacheTimeTmp != '') {
|
||||
$cacheTime = $cacheTimeTmp;
|
||||
|
||||
} else if(isset($cacheTimeTmp2) && $cacheTimeTmp2 != '') {
|
||||
$cacheTime = $cacheTimeTmp2;
|
||||
} else {
|
||||
$cacheTime = CacheParam::Get('global');
|
||||
|
||||
}
|
||||
if($this->CheckLiveMethod($method, $param)) {
|
||||
$this->cacheTime = 0;
|
||||
} else {
|
||||
$this->cacheTime = $cacheTime;
|
||||
}
|
||||
|
||||
if(Core::GetAppSafeMode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(!$this->smarty->CacheControl($this->templatePath.$this->partialTemplate, array('cache_id'=> md5($method.$param), 'lifetime'=>$this->cacheTime))) {
|
||||
if(!Core::GetAppSafeMode()) {
|
||||
$this->smarty->CacheControl($this->templatePath.$this->partialTemplate, array('cache_id'=> md5($method.$param), 'write'=>true));
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
//echo ">>".$this->smarty->is_cached($this->templatePath.$this->partialTemplate, $method.substr($param,0, 100))."<<";
|
||||
//return $this->smarty->is_cached($this->templatePath.$this->partialTemplate, $method.substr($param,0, 100));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Czysci bufor strony
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $param
|
||||
*/
|
||||
public final function ClearCache($method, $param) {
|
||||
$cacheParam = implode('-', $param);
|
||||
$this->smarty->clear_cache($this->partialTemplate, $method.substr($cacheParam,0, 100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje skrypt do naglowka strony
|
||||
*
|
||||
* @param string $script
|
||||
* @param string $type (file/code)
|
||||
* @param string $position (top/bottom)
|
||||
* @param int $sort
|
||||
*/
|
||||
public final function AddScript($script, $type='file', $position='top', $sort=100) {
|
||||
|
||||
if($position == 'top') {
|
||||
$name = 'javascript';
|
||||
} else {
|
||||
$name = 'footerJavascript';
|
||||
}
|
||||
|
||||
$t = Registry::Get($name);
|
||||
if($type=='file') {
|
||||
$t[$sort][$script] = array('file'=>$script, 'code'=>'');
|
||||
} else {
|
||||
$t[$sort][$script] = array('code'=>$script, 'file'=>'');
|
||||
}
|
||||
|
||||
Registry::Remove($name);
|
||||
Registry::Set($name, $t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje CSS do naglowka strony
|
||||
*
|
||||
* @param string $script
|
||||
* @param string $type (file/code)
|
||||
* @param int $sort
|
||||
*/
|
||||
public final function AddCSS($script, $type='file', $sort=100) {
|
||||
|
||||
$name = 'headerCSS';
|
||||
|
||||
$t = Registry::Get($name);
|
||||
if($type=='file') {
|
||||
$t[$sort][$script] = array('file'=>$script, 'code'=>'');
|
||||
} else {
|
||||
$t[$sort][$script] = array('code'=>$script, 'file'=>'');
|
||||
}
|
||||
|
||||
Registry::Remove($name);
|
||||
Registry::Set($name, $t);
|
||||
}
|
||||
|
||||
public final function AddWpStatistics($key) {
|
||||
$this->AddScript("var pp_gemius_identifier ='$key';
|
||||
var pp_gemius_hitcollector = 'wp.hit.gemius.pl';",'code','top',0);
|
||||
$this->AddScript("WP.stat.dot('max15','','');", 'code', 'top', 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje skrypt przed </body>
|
||||
*
|
||||
* @param string $script
|
||||
* @param string $type
|
||||
*/
|
||||
public final function AddFooterScript($script, $type='file') {
|
||||
throw new ApiException('Metoda nieobslugiwana od wersji 1.1 Controllera. Uzyj AddScript z opcja bottom.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje przekierowanie
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $time
|
||||
*/
|
||||
public final function AddRedirect($url, $time, $code=302) {
|
||||
if(is_array($url)) {
|
||||
Core::RequireOnce('plugins/Smarty/function.url.php');
|
||||
$urlData = smarty_function_url($url, $this->smarty);
|
||||
} else {
|
||||
$urlData = $url;
|
||||
}
|
||||
if($this->redirect['url']=='') {
|
||||
$this->redirect['url']=$urlData;
|
||||
$this->redirect['time']=$time;
|
||||
$this->redirect['code']=$code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Usuwa przekierowanie
|
||||
*
|
||||
*/
|
||||
public final function ClearRedirect() {
|
||||
$this->redirect = array('url'=>'', 'time'=>'');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprawdza czy ustawione jest przekierowanie
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public final function IsRedirect() {
|
||||
if($this->redirect['url']!='') {
|
||||
$return = true;
|
||||
} else {
|
||||
$return = false;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca url do przekierowania
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public final function GetRedirect() {
|
||||
return $this->redirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wylacza wyswietlenie szablonow
|
||||
*
|
||||
*/
|
||||
public final function SetNoRender() {
|
||||
$this->disableTemplates = true;
|
||||
Profiler::$profiling = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uruchamianie obiektu klasy SharedController i wywolywanie pozadanej metody
|
||||
*
|
||||
* @param string $method
|
||||
*/
|
||||
public final function RunShared($method,$param) {
|
||||
//print_R($param);
|
||||
//echo $method."<br>";
|
||||
$this->smarty->assign('param', $param);
|
||||
$shared = new SharedController();
|
||||
|
||||
$shared->SetSmarty($this->smarty);
|
||||
$shared->templatePath = 'partial/Shared/';
|
||||
$shared->partialTemplate = $method.'.tpl';
|
||||
//$this->smarty->cache_lifetime = CacheParam::Get('shared'.$method);
|
||||
|
||||
|
||||
$cacheParam = Utils::MultiImplode('-', $param, '|').$shared->partialTemplate;
|
||||
if(FrontController::dispatchChecker($this->smarty, $shared->templatePath.$shared->partialTemplate, $cacheParam, CacheParam::Get('shared'.$method))) {
|
||||
//if(!$this->smarty->CacheControl($shared->templatePath.$shared->partialTemplate, array('cache_id'=> md5($cacheParam), 'lifetime'=>CacheParam::Get('shared'.$method)))) {
|
||||
//if(!Core::GetAppSafeMode()) {
|
||||
//$this->smarty->CacheControl($shared->templatePath.$shared->partialTemplate, array('cache_id'=> md5($cacheParam), 'write'=>true));
|
||||
//$this->smarty->assign($variable, $this->smarty->fetch($shared->templatePath.$shared->partialTemplate, md5($cacheParam), md5($cacheParam)));
|
||||
|
||||
//if(!$this->smarty->is_cached($shared->templatePath.$shared->partialTemplate, md5($cacheParam), md5($cacheParam)) && !Core::GetAppSafeMode()) {
|
||||
//echo $method."<br />".$this->smarty->is_cached($shared->templatePath.$shared->partialTemplate, md5($cacheParam));
|
||||
$shared->$method($param);
|
||||
//}
|
||||
//echo "<br />".$method."<br />";
|
||||
//echo $this->smarty->get_template_vars($variable);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(isset($param['runSharedVariable'])) {
|
||||
$variable = $param['runSharedVariable'];
|
||||
} else {
|
||||
$variable = strtolower(substr($method, 0, 1)) . substr($method, 1);
|
||||
}
|
||||
$this->smarty->assign($variable, $this->smarty->fetch($shared->templatePath.$shared->partialTemplate, md5($cacheParam), md5($cacheParam)));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Uruchamianie metody zewnetrzenego modulu
|
||||
*
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @param string $param = null
|
||||
* @param string $template = false - czy ma byc zaladowany template
|
||||
*
|
||||
*/
|
||||
|
||||
public final function RunModule($module,$method,$param,$template = false) {
|
||||
|
||||
if(isset($param) && is_array($param)) {
|
||||
$cparam = Utils::MultiImplode('-', $param, '|');
|
||||
} else {
|
||||
$cparam = null;
|
||||
}
|
||||
|
||||
$cacheParam = $module.$method.$template.$cparam;
|
||||
|
||||
$moduleControllerName = $module;
|
||||
$moduleControllerName .= "Controller";
|
||||
$moduleArray = explode('_', $moduleControllerName);
|
||||
if (count($moduleArray) > 1) {
|
||||
require_once "controller/".$moduleArray[0]."/".$moduleArray[1].".php";
|
||||
} else {
|
||||
require_once "controller/$moduleControllerName.php";
|
||||
}
|
||||
|
||||
|
||||
$moduleController = new $moduleControllerName();
|
||||
|
||||
if($template == true) {
|
||||
$moduleController->SetSmarty($this->smarty);
|
||||
if (count($moduleArray) > 1) {
|
||||
$moduleController->templatePath = "partial/".$moduleArray[0]."/".str_replace('Controller', '',$moduleArray[1]);
|
||||
// die($module.$moduleController->templatePath);
|
||||
$moduleController->partialTemplate = $method.'.tpl';
|
||||
} else {
|
||||
$moduleController->templatePath = "partial/$module/";
|
||||
// die($module.$moduleController->templatePath);
|
||||
$moduleController->partialTemplate = str_replace('Action', '', $method).'.tpl';
|
||||
//$this->smarty->cache_lifetime = CacheParam::Get($module.$method);
|
||||
|
||||
// if(!$this->smarty->is_cached($moduleController->partialTemplate) && !Core::GetAppSafeMode()) {
|
||||
// return $moduleController->$method($param);
|
||||
// }
|
||||
//Utils::ArrayDisplay($moduleController->partialTemplate);
|
||||
}
|
||||
|
||||
if(!$this->smarty->CacheControl($moduleController->templatePath.$moduleController->partialTemplate, array('cache_id'=> md5($cacheParam), 'lifetime'=>CacheParam::Get($module.$method)))) {
|
||||
|
||||
if(!Core::GetAppSafeMode()) {
|
||||
//Utils::ArrayDisplay($moduleController->$method($param));
|
||||
$this->smarty->CacheControl($moduleController->templatePath.$moduleController->partialTemplate, array('cache_id'=> md5($cacheParam), 'write'=>true));
|
||||
|
||||
return $moduleController->$method($param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
$moduleController->SetNoRender();
|
||||
return $moduleController->$method($param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Uruchamianie metody zewnetrzenego modulu
|
||||
*
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @param string $param = null
|
||||
* @param string $template = false - czy ma byc zaladowany template
|
||||
*
|
||||
*/
|
||||
|
||||
public final function RunModuleController($module,$method,$param,$template = false) {
|
||||
|
||||
$this->smarty->assign('param', $param);
|
||||
$moduleControllerName = $module;
|
||||
//$moduleControllerName .= "Controller";
|
||||
$moduleArray = explode('_', $moduleControllerName);
|
||||
if (count($moduleArray) > 1) {
|
||||
require_once "controller/".$moduleArray[0]."/".$moduleArray[1].".php";
|
||||
} else {
|
||||
require_once "controller/$moduleControllerName.php";
|
||||
}
|
||||
|
||||
//Utils::ArrayDisplay('sd: '.$moduleControllerName);
|
||||
|
||||
$moduleController = new $moduleControllerName();
|
||||
|
||||
$moduleController->SetSmarty($this->smarty);
|
||||
|
||||
if (count($moduleArray) > 1) {
|
||||
$moduleController->templatePath = "partial/".$moduleArray[0]."/".str_replace('Controller', '',$moduleArray[1]."/");
|
||||
// die($module.$moduleController->templatePath);
|
||||
$moduleController->partialTemplate = $method.'.tpl';
|
||||
//Utils::ArrayDisplay($method);
|
||||
} else {
|
||||
$moduleController->templatePath = "partial/".str_replace('Controller', '',$module)."/";
|
||||
// die($module.$moduleController->templatePath);
|
||||
$moduleController->partialTemplate = $method.'.tpl';
|
||||
|
||||
//$this->smarty->cache_lifetime = CacheParam::Get($module.$method);
|
||||
|
||||
// if(!$this->smarty->is_cached($moduleController->partialTemplate) && !Core::GetAppSafeMode()) {
|
||||
// return $moduleController->$method($param);
|
||||
// }
|
||||
//Utils::ArrayDisplay($moduleController->partialTemplate);
|
||||
}
|
||||
// $moduleController->templatePath = 'partial/Shared/';
|
||||
// $moduleController->partialTemplate = $method.'.tpl';
|
||||
//$this->smarty->cache_lifetime = CacheParam::Get('shared'.$method);
|
||||
|
||||
|
||||
$cacheParam = Utils::MultiImplode('-', $param, '|').$moduleController->partialTemplate;
|
||||
if(FrontController::dispatchChecker($this->smarty, $moduleController->templatePath.$moduleController->partialTemplate, $cacheParam, CacheParam::Get($module.$method))) {
|
||||
$methodToRun = $method.'Action';
|
||||
//Utils::ArrayDisplay($methodToRun);
|
||||
$moduleController->$methodToRun($param);
|
||||
}
|
||||
|
||||
|
||||
if(isset($param['runSharedVariable'])) {
|
||||
$variable = $param['runSharedVariable'];
|
||||
} else {
|
||||
$variable = strtolower(substr($method, 0, 1)) . substr($method, 1);
|
||||
}
|
||||
//Utils::ArrayDisplay($param['runSharedVariable']);
|
||||
$this->smarty->assign($variable, $this->smarty->fetch($moduleController->templatePath.$moduleController->partialTemplate, md5($cacheParam), md5($cacheParam)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final function SetRequest(Request $request) {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca obiekt Request
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public final function Request() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zmienia szablon glowny na pusty dla akcji ajaxowych
|
||||
*
|
||||
*/
|
||||
public final function SetAjaxRender($ajaxCallPath = false) {
|
||||
Router::DeleteThisUrl();
|
||||
if ($ajaxCallPath) {
|
||||
$prev = SessionProxy::GetValue(Router::$PREV_URL);
|
||||
if($prev != null)
|
||||
SessionProxy::SetValue('ajaxCallPath', $prev);
|
||||
}
|
||||
$template = 'clean.tpl';
|
||||
Registry::Remove('smartyTemplate');
|
||||
Registry::Set('smartyTemplate', $template);
|
||||
Profiler::$profiling = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia sciezke powrotna
|
||||
*
|
||||
* @param array $path
|
||||
*/
|
||||
public final function SetReturnPath($path) {
|
||||
Registry::Set('smartyReturnPath', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje element sciezki powrotnej
|
||||
*
|
||||
* array(title=>title, url=>url)
|
||||
*
|
||||
* @param array $item
|
||||
*/
|
||||
public final function AddReturnPathItem($item) {
|
||||
|
||||
if(Registry::Exists('smartyReturnPath')) {
|
||||
$data = Registry::Get('smartyReturnPath');
|
||||
Registry::Remove('smartyReturnPath');
|
||||
$data[]=$item;
|
||||
Registry::Set('smartyReturnPath', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwaraca sciezke powrotna
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public final function GetReturnPath() {
|
||||
return Registry::Get('smartyReturnPath');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca sformatowany url
|
||||
*
|
||||
* @param string $controller
|
||||
* @param string $action
|
||||
* @return string
|
||||
*/
|
||||
public final function GetMyUrl($controller,$action) {
|
||||
return ereg_replace('Action', '', $action).PATH_SEPARATOR.ereg_replace('Controller', '', $controller).APPLICATION_FILE_TYPE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sprawdza czy dana metoda ma byc zawsze uruchamiana (cache independent)
|
||||
*
|
||||
* @param string $method
|
||||
* @return bool
|
||||
*/
|
||||
public final function CheckLiveMethod($method, $param) {
|
||||
if(isset($this->$method) || preg_match('/^ajax/', $method) || (isset($param['liveMethod']) && $param['liveMethod']==true)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca oryginalne parametry z urla
|
||||
*
|
||||
* @param array $param
|
||||
* @return array
|
||||
*/
|
||||
public final function GetUrlParam($param) {
|
||||
if(is_array($param) && isset($param['urlParam'])) {
|
||||
return array_reverse(explode(",", $param['urlParam']));
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function SetActionSet($set) {
|
||||
|
||||
$this->actionSet = $set;
|
||||
}
|
||||
|
||||
public function LoadAdditionalModule($module, $controller) {
|
||||
if(is_file('controller/'.$module.'/'.str_replace($module.'_', '', ucfirst($controller)).'.php')) {
|
||||
Core::RequireOnce('controller/'.$module.'/'.str_replace($module.'_', '', ucfirst($controller)).'.php');
|
||||
MFLog::Debug('Loading module: '.$module.': '.$controller);
|
||||
} else {
|
||||
|
||||
MFLog::Debug('Unable to load module, Loading controller: '.$controller);
|
||||
throw new CoreException('Unable to load module, Loading controller: '.$controller);
|
||||
}
|
||||
}
|
||||
|
||||
public function LoadAdditionalController($controller) {
|
||||
|
||||
if(is_file('controller/'.ucfirst($controller).'.php')) {
|
||||
Core::RequireOnce('controller/'.ucfirst($controller).'.php');
|
||||
MFLog::Debug('Loading module: '.$controller);
|
||||
} else {
|
||||
|
||||
MFLog::Debug('Unable to load module, Loading controller: '.$controller);
|
||||
throw new CoreException('Unable to load module, Loading controller: '.$controller);
|
||||
}
|
||||
}
|
||||
|
||||
public function RunAdditionalModule($controller, $method) {
|
||||
|
||||
$controllerObj = null;
|
||||
|
||||
if(class_exists($controller) && class_parents($controller) == Array('MainController'=>'MainController', 'Controller'=>'Controller') && class_implements($controller) == Array('ControllerInterface'=>'ControllerInterface')) {
|
||||
$controllerObj = new $controller();
|
||||
|
||||
if(!method_exists($controllerObj, $method) && !method_exists($controllerObj, $method.'Action')) {
|
||||
MFLog::Debug('Method thoes not exists: '.$method);
|
||||
throw new CoreException('Method thoes not exists: '.$method);
|
||||
}
|
||||
} else {
|
||||
throw new CoreException('Brak klasy lub brak dziedziczenia!');
|
||||
}
|
||||
|
||||
return $controllerObj;
|
||||
}
|
||||
|
||||
public function DispatchAdditionalModule($controllerObj, $controller, $method, $module, $param, $liveMethod) {
|
||||
$controllerObj->SetSmarty($this->smarty);
|
||||
$controllerObj->partialTemplate = $method.'.tpl';
|
||||
|
||||
$controllerObj->templatePath = 'partial/'.str_replace('_', '/', str_replace('Controller', '', $controller)).'/';
|
||||
|
||||
|
||||
if((!$controllerObj->Init($method, md5(implode($param, '-'))) || $controllerObj->CheckLiveMethod($method, $param) || $liveMethod) && $controllerObj->GetActionRedirect()!=true) {
|
||||
|
||||
$methodAction = $method;
|
||||
$controllerObj->$methodAction($param);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(!isset($controllerObj->content) && !$liveMethod) {
|
||||
//$this->smarty->cache_lifetime = $controllerObj->cacheTime;
|
||||
|
||||
if(!$this->smarty->CacheControl($controllerObj->templatePath.$controllerObj->partialTemplate, array('cache_id'=> $method.substr(md5(implode($param, '-')),0,100), 'lifetime'=>$controllerObj->cacheTime)) && !Core::GetAppSafeMode()) {
|
||||
|
||||
$this->smarty->CacheControl($controllerObj->templatePath.$controllerObj->partialTemplate, array('cache_id'=> $method.substr(md5(implode($param, '-')),0,100), 'write'=>true));
|
||||
}
|
||||
|
||||
|
||||
$controllerObj->content = $this->smarty->fetch($controllerObj->templatePath.$controllerObj->partialTemplate, $method.substr(md5(implode($param, '-')),0,100));
|
||||
//echo $this->controllerObj->templatePath.$this->controllerObj->partialTemplate;
|
||||
|
||||
}
|
||||
|
||||
//Utils::ArrayDisplay($controllerObj->content);
|
||||
|
||||
$this->smarty->append('zoneContent', $controllerObj->content);
|
||||
$this->smarty->assign('zoneContent', $controllerObj->content);
|
||||
}
|
||||
|
||||
public function GetActionSet() {
|
||||
return $this->actionSet;
|
||||
}
|
||||
|
||||
public function ExecuteAdditionalActions($param) {
|
||||
$actionSetArray = $this->GetActionSet();
|
||||
$this->smarty->assign('zoneContent', '');
|
||||
|
||||
//Utils::ArrayDisplay($actionSetArray);
|
||||
foreach($actionSetArray as $actionSet) {
|
||||
if(isset($actionSet['liveMethod'])) {
|
||||
$liveMethod = true;
|
||||
} else {
|
||||
$liveMethod = false;
|
||||
|
||||
}
|
||||
try {
|
||||
$this->LoadAdditionalModule($actionSet['module'], $actionSet['controller']);
|
||||
} catch (CoreException $e) {
|
||||
|
||||
$this->LoadAdditionalController($actionSet['controller']);
|
||||
}
|
||||
$controllerObj = $this->RunAdditionalModule($actionSet['controller'], $actionSet['method']);
|
||||
$this->DispatchAdditionalModule($controllerObj, $actionSet['controller'], $actionSet['method'], $actionSet['module'], $param, $liveMethod);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
49
_rejestracja/core/class/ControllerDataExchange.class.php
Normal file
49
_rejestracja/core/class/ControllerDataExchange.class.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* Wymiana danych w kontrolerze modułowym
|
||||
*/
|
||||
|
||||
class ControllerDataExchange {
|
||||
|
||||
public static function Get($variable) {
|
||||
$index = self::Init();
|
||||
if(isset($index[$variable])) {
|
||||
return $index[$variable];
|
||||
} else {
|
||||
throw new UserException('Niezdefiniowana zmienna: '.$variable.' w indeksie ControllerDataExchange');
|
||||
}
|
||||
}
|
||||
|
||||
public static function Exists($variable) {
|
||||
$index = self::Init();
|
||||
if(isset($index[$variable])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function Set($variable, $value) {
|
||||
$index = self::Init();
|
||||
$index[$variable] = $value;
|
||||
self::Save($index);
|
||||
}
|
||||
|
||||
private static function Init() {
|
||||
if(Registry::Exists('ControllerDataExchange')) {
|
||||
return Registry::Get('ControllerDataExchange');
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
private static function Save($index) {
|
||||
if(Registry::Exists('ControllerDataExchange')) {
|
||||
return Registry::Remove('ControllerDataExchange');
|
||||
}
|
||||
|
||||
Registry::Set('ControllerDataExchange', $index);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
26
_rejestracja/core/class/ControllerInterface.class.php
Normal file
26
_rejestracja/core/class/ControllerInterface.class.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Obowiązkowy interfejs dla wszystkich kontrolerów
|
||||
*
|
||||
*/
|
||||
interface ControllerInterface {
|
||||
/**
|
||||
* metoda wywolywana przed metoda
|
||||
*
|
||||
*/
|
||||
public function PreDispatch($param);
|
||||
|
||||
/**
|
||||
* metoda wywolywana po metodzie
|
||||
*
|
||||
*/
|
||||
public function PostDispatch($param);
|
||||
|
||||
/**
|
||||
* metoda glowna
|
||||
*
|
||||
*/
|
||||
public function IndexAction($param);
|
||||
}
|
||||
|
||||
?>
|
||||
716
_rejestracja/core/class/DB.class.php
Normal file
716
_rejestracja/core/class/DB.class.php
Normal file
@@ -0,0 +1,716 @@
|
||||
<?
|
||||
|
||||
/**
|
||||
* $Id: DB.class.php 982 2008-07-31 15:25:34Z dakl $
|
||||
* Interfejs polaczenia z baza v2.2
|
||||
*
|
||||
*/
|
||||
interface DBConnection {
|
||||
|
||||
public function Prepare($query);
|
||||
|
||||
public function Execute($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interfejs danych w bazie
|
||||
*
|
||||
*/
|
||||
interface DBStatement {
|
||||
|
||||
public function Execute();
|
||||
|
||||
public function BindParam($key, $value);
|
||||
|
||||
public function FetchRow();
|
||||
|
||||
public function FetchAssoc();
|
||||
|
||||
public function FetchAllAssoc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Klasa do obslugi bazy mysql
|
||||
*
|
||||
*/
|
||||
class DBMysql implements DBConnection {
|
||||
|
||||
protected $user;
|
||||
protected $pass;
|
||||
protected $dbHost;
|
||||
protected $dbName;
|
||||
protected $dbh;
|
||||
private $query;
|
||||
protected $characterset = 'utf8';
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $pass
|
||||
* @param string $dbHost
|
||||
* @param string $dbName
|
||||
*/
|
||||
public function __construct($user, $pass, $dbHost, $dbName) {
|
||||
$this->user = $user;
|
||||
$this->pass = $pass;
|
||||
$this->dbHost = $dbhost;
|
||||
$this->dbName = $dbname;
|
||||
}
|
||||
|
||||
/* Nawiazywanie polaczenia z baza */
|
||||
|
||||
public function Connect($method = null) {
|
||||
|
||||
if (!Core::GetAppSafeMode()) {
|
||||
try { //echo $method;
|
||||
$this->DbConnect();
|
||||
//Utils::ArrayDisplay($this);
|
||||
$this->SelectDb();
|
||||
$this->SetCharacterset();
|
||||
} catch (Exception $e) {
|
||||
MFLog::Fatal("Line: " . $e->getLine() . " Message: " . $e->getMessage() . " Referer: " . getenv('HTTP_REFERER'));
|
||||
MFLog::Error("Switching app to safe mode");
|
||||
Core::SetAppSafeMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function DbConnect() {
|
||||
//echo"konekt";
|
||||
Profiler::log('mysqlStart', '', microtime());
|
||||
$this->dbh = new mysqli($this->dbHost, $this->user, $this->pass, $this->dbName);
|
||||
if ($this->dbh->connect_errno) {
|
||||
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
|
||||
}
|
||||
// echo $this->dbh->host_info . "\n";
|
||||
// $this->dbh = new mysqli($this->dbHost, $this->user, $this->pass);
|
||||
// //$this->dbh = mysqli_connect($this->dbHost, $this->user, $this->pass);
|
||||
// $this->dbh = new PDO('mysql:host='.$this->dbHost.';dbname='.$this->dbName.';charset='.$this->characterset, $this->user, $this->pass);
|
||||
//
|
||||
// if(empty($this->dbh)) {
|
||||
// throw new MysqlException('Cannot connect to database!');
|
||||
// }
|
||||
}
|
||||
|
||||
protected function SelectDb() {
|
||||
if (!mysqli_select_db($this->dbh, $this->dbName)) {
|
||||
throw new MysqlException('Cannot select database!');
|
||||
}
|
||||
}
|
||||
|
||||
protected function SetCharacterset() {
|
||||
mysqli_query($this->dbh, "SET CHARACTER SET " . $this->characterset);
|
||||
mysqli_query($this->dbh, "SET NAMES '" . $this->characterset . "'");
|
||||
mysqli_query($this->dbh, "SET CHARACTER_SET_CLIENT = " . $this->characterset);
|
||||
mysqli_query($this->dbh, "SET character_set_results = " . $this->characterset);
|
||||
mysqli_query($this->dbh, "SET character_set_connection = " . $this->characterset);
|
||||
}
|
||||
|
||||
public function Escape($string) {
|
||||
|
||||
// if(Enviroment::CheckMagicQuotes()) {
|
||||
// $return = mysqli_real_escape_string($string);
|
||||
// } else {
|
||||
// $return = $string;
|
||||
// }
|
||||
$return = mysqli_real_escape_string($this->dbh, $string);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/* Wykonanie zapytania */
|
||||
|
||||
public function Execute($query) {
|
||||
|
||||
if (!$this->dbh) {
|
||||
$this->Connect(__METHOD__);
|
||||
}
|
||||
MFLog::Debug($query);
|
||||
$ret = 'unexecuted';
|
||||
if ($this->dbh) {
|
||||
$startTime = microtime();
|
||||
$ret = $this->dbh->query($query);
|
||||
$endTime = microtime();
|
||||
$deltaTime = (int)$endTime - (int)$startTime;
|
||||
//Utils::ArrayDisplay( abs((int)$deltaTime));
|
||||
Profiler::log('mysql', $query, abs($deltaTime));
|
||||
}
|
||||
if (!$ret && $ret != 'unexecuted') {
|
||||
throw new MysqlException(mysqli_error($this->dbh) . $query);
|
||||
} else {
|
||||
$this->setQuery($query);
|
||||
$stmt = new DBMysqlStatement($this);
|
||||
$stmt->result = $ret;
|
||||
return $stmt;
|
||||
}
|
||||
}
|
||||
|
||||
/* Przygotowanie zapytania zwraca obiekt klasy DBMysqlStatement */
|
||||
|
||||
public function Prepare($query) {
|
||||
if (!$this->dbh) {
|
||||
//$this->Connect(__METHOD__);
|
||||
}
|
||||
$this->setQuery($query);
|
||||
return new DBMysqlStatement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rozpoczyna transakcje
|
||||
*
|
||||
*/
|
||||
public function BeginTransaction() {
|
||||
if (!$this->dbh) {
|
||||
$this->Connect(__METHOD__);
|
||||
}
|
||||
@mysqli_query($this->dbh, "START TRANSACTION ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Zartwierdza transakcje
|
||||
*
|
||||
*/
|
||||
public function CommitTransaction() {
|
||||
if (!$this->dbh) {
|
||||
$this->Connect(__METHOD__);
|
||||
}
|
||||
@mysqli_query($this->dbh,"COMMIT");
|
||||
}
|
||||
|
||||
/**
|
||||
* Wycofuje transakcje
|
||||
*
|
||||
*/
|
||||
public function Rollback() {
|
||||
if (!$this->dbh) {
|
||||
$this->Connect(__METHOD__);
|
||||
}
|
||||
@mysqli_query($this->dbh,"ROLLBACK");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruktor zamykajacy polaczenie
|
||||
*
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (isset($this->dbh) && is_resource($this->dbh)) {
|
||||
|
||||
Profiler::log('mysqlEnd', '', microtime());
|
||||
}
|
||||
}
|
||||
|
||||
public function GetDbh() {
|
||||
return $this->dbh;
|
||||
}
|
||||
|
||||
public function getQuery() {
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function setQuery($query) {
|
||||
$this->query = $query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Klasa implementujaca interfejs DBStatement dla mysqla
|
||||
*
|
||||
*/
|
||||
class DBMysqlStatement implements DBStatement {
|
||||
|
||||
public $result;
|
||||
public $binds;
|
||||
public $query;
|
||||
public $dbh;
|
||||
private $cacheTime = 30;
|
||||
private $cacheFile;
|
||||
private $cachePath = DBCACHE_PATH;
|
||||
private $cacheEnable = DBCACHE_ENABLE;
|
||||
private $cacheQuery = false;
|
||||
private $dbMysql;
|
||||
|
||||
/**
|
||||
* KOnstruktor klasy
|
||||
*
|
||||
* @param mysql $dbh
|
||||
* @param string $query
|
||||
*/
|
||||
public function __construct(DBMysql $dbMysql) {
|
||||
$this->query = $dbMysql->getQuery();
|
||||
$this->dbh = $dbMysql->GetDbh();
|
||||
$this->dbMysql = $dbMysql;
|
||||
if (!$this->dbh) {
|
||||
// $this->dbMysql->Connect();
|
||||
//throw new MysqlException("No db connection");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca tresc zapytania
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetQuery() {
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/* Zamienia zmienne w zapytaniu na podane wartosci */
|
||||
|
||||
public function BindParam($ph, $pv) {
|
||||
$this->binds[$ph] = $pv;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/* Wykonanie zapytania */
|
||||
|
||||
public function Execute($q = null) {
|
||||
//echo $q.":";
|
||||
//var_dump($this->CacheCheck());
|
||||
//var_dump(Core::GetAppSafeMode());
|
||||
if (!$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
//echo"qq";
|
||||
if (!$this->dbh) {
|
||||
$this->dbMysql->Connect(__METHOD__ . $this->query);
|
||||
}
|
||||
$binds = func_get_args();
|
||||
foreach ($binds as $index => $name) {
|
||||
$this->binds[$index + 1] = $name;
|
||||
}
|
||||
$cnt = count($binds);
|
||||
$query = $this->query;
|
||||
|
||||
|
||||
$binds = func_get_args();
|
||||
foreach ($binds as $index => $name) {
|
||||
$this->binds[$index + 1] = $name;
|
||||
}
|
||||
$cnt = count($binds);
|
||||
$query = $this->query;
|
||||
|
||||
//Utils::ArrayDisplay($query);
|
||||
|
||||
if(is_countable($this->binds)) {
|
||||
if (count($this->binds) > 0) {
|
||||
foreach ($this->binds as $ph => $pv) {
|
||||
// $query = str_replace(":$ph", "'".mysqli_escape_string($pv)."'", $query);
|
||||
|
||||
$query = str_replace(":$ph", '\'' . mysqli_real_escape_string($this->dbh, $pv) . '\'', $query);
|
||||
}
|
||||
}//echo ">>".$query;
|
||||
}
|
||||
MFLog::Debug(__FUNCTION__ . ' query: ' . $query);
|
||||
|
||||
|
||||
$startTime = microtime();
|
||||
$this->result = $this->dbh->query($query);
|
||||
$endTime = microtime();
|
||||
$deltaTime = (int)$endTime - (int)$startTime;
|
||||
Profiler::log('mysql', $query, abs($deltaTime));
|
||||
|
||||
|
||||
if (!$this->result) {
|
||||
throw new MysqlException($query . "<br /><br />" . mysqli_error($this->dbh));
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/* Zwraca wiersz */
|
||||
|
||||
public function FetchRow() {
|
||||
if (!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
$this->SetCacheFile($this->query . 'FetchRow');
|
||||
|
||||
if ($this->cacheQuery == false) {
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
|
||||
$result = mysqli_fetch_row($this->result);
|
||||
mysqli_free_result($this->result);
|
||||
}
|
||||
|
||||
else if ($this->cacheQuery == true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
|
||||
$result = mysqli_fetch_row($this->result);
|
||||
mysqli_free_result($this->result);
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Zwraca wiersz jako tablice asocjacyjna */
|
||||
|
||||
public function FetchAssoc() {
|
||||
$this->SetCacheFile($this->query . 'FetchAssoc');
|
||||
|
||||
if ($this->cacheQuery == false) {
|
||||
//$this->dbMysql->Connect();
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
//var_dump($this->result);
|
||||
//Utils::ArrayDisplay($this);
|
||||
$result = \mysqli_fetch_assoc($this->result);
|
||||
}
|
||||
|
||||
else if (($this->cacheQuery == true && !$this->CacheCheck() && !Core::GetAppSafeMode())) {
|
||||
|
||||
//$this->dbMysql->Connect(__METHOD__);
|
||||
$this->Execute();
|
||||
$result = mysqli_fetch_assoc($this->result);
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
//Utils::ArrayDisplay($this->dbh);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Zwraca ca<63>y wynik jako tablica asocjacyjna */
|
||||
|
||||
public function FetchAllAssoc() {
|
||||
$this->SetCacheFile($this->query . 'FetchAllAssoc');
|
||||
//Utils::ArrayDisplay($this);
|
||||
if ($this->cacheQuery == false) {
|
||||
$result = array();
|
||||
//$this->Execute();
|
||||
while ($row = $this->fetchAssoc()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
|
||||
} else if ($this->cacheQuery == true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = array();
|
||||
$this->cacheQuery = false;
|
||||
while ($row = $this->fetchAssoc()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
$this->SetCacheFile($this->query . 'FetchAllAssoc');
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Zwraca ca<63>y wynik jako tablica asocjacyjna */
|
||||
|
||||
public function FetchAllRow() {
|
||||
$this->SetCacheFile($this->query . 'FetchAllRow');
|
||||
|
||||
|
||||
|
||||
if ($this->cacheQuery == false) {
|
||||
$result = array();
|
||||
|
||||
while ($row = $this->fetchRow()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
} else if ($this->cacheQuery == true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = array();
|
||||
$this->cacheQuery = false;
|
||||
while ($row = $this->fetchRow()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
$this->SetCacheFile($this->query . 'FetchAllRow');
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Zwraca liczbe wierszy */
|
||||
|
||||
public function NumRows() {
|
||||
if (!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
$this->SetCacheFile($this->query . 'NumRows');
|
||||
|
||||
if ($this->cacheQuery == false) {
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
|
||||
$result = mysqli_num_rows($this->result);
|
||||
}
|
||||
|
||||
else if ($this->cacheQuery == true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
|
||||
$result = mysqli_num_rows($this->result);
|
||||
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Zwraca wiersz w postaci tablicy */
|
||||
|
||||
public function FetchArray() {
|
||||
if (!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
$this->SetCacheFile($this->query . 'FetchArray');
|
||||
|
||||
|
||||
|
||||
if ($this->cacheQuery == false) {
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
|
||||
$result = mysqli_fetch_array($this->result);
|
||||
}
|
||||
|
||||
else if ($this->cacheQuery == true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
|
||||
if (!$this->result)
|
||||
$this->Execute();
|
||||
|
||||
$result = mysqli_fetch_array($this->result);
|
||||
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca id ostatnio zmienionego rekordu
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function GetInsertionId() {
|
||||
if (!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
return mysqli_insert_id($this->dbh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca liczb<7A> zmienionych rekord<72>w w ostatnim zapytaniu modyfikuj<75>cym dane.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function GetAffectedRows() {
|
||||
if (!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
return mysqli_affected_rows($this->dbh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprawdza czy zaoytanie jest cacheowane
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function CacheCheck() {
|
||||
|
||||
if (($this->cacheEnable == true && (is_file($this->cachePath . $this->cacheFile) && filemtime($this->cachePath . $this->cacheFile) > (time() - $this->cacheTime)))) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (is_file($this->cachePath . $this->cacheFile)) {
|
||||
touch($this->cachePath . $this->cacheFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zapisuje cache do pliku
|
||||
*
|
||||
* @param obj $result
|
||||
*/
|
||||
public function CacheWrite($result) {
|
||||
if ($this->cacheEnable != false) {
|
||||
$records = serialize($result);
|
||||
$fp = fopen($this->cachePath . $this->cacheFile, "w");
|
||||
fputs($fp, $records);
|
||||
fclose($fp);
|
||||
$this->cacheQuery = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Odczytuje cache z pliku
|
||||
*
|
||||
* @return obj
|
||||
*/
|
||||
public function CacheRead() {
|
||||
if (is_file($this->cachePath . $this->cacheFile)) {
|
||||
$records = unserialize(file_get_contents($this->cachePath . $this->cacheFile));
|
||||
$this->cacheQuery = false;
|
||||
return $records;
|
||||
} else {
|
||||
throw new MysqlException('File does not exist: ' . $this->cachePath . $this->cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uruchamia cacheowanie
|
||||
*
|
||||
* @param integer $time
|
||||
*/
|
||||
public function CacheStart($time = null) {
|
||||
if ($time != null && $this->cacheEnable != false) {
|
||||
$this->cacheTime = $time;
|
||||
}
|
||||
if ($this->cacheEnable != false)
|
||||
$this->cacheQuery = true;
|
||||
else
|
||||
$this->cacheQuery = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustanawia nazw<7A> pliku cache
|
||||
*
|
||||
* @param unknown_type $fileName
|
||||
*/
|
||||
public function SetCacheFile($fileName) {
|
||||
$this->cacheFile = md5($fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Klasa obslugi wynikow zapytan
|
||||
*
|
||||
*/
|
||||
class DBResult {
|
||||
|
||||
protected $stmt;
|
||||
protected $result = array();
|
||||
private $rowIndex = 0;
|
||||
private $currIndex = 0;
|
||||
private $done = false;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
*
|
||||
* @param DBStatement $stmt
|
||||
*/
|
||||
public function __construct(DBStatement $stmt) {
|
||||
$this->stmt = $stmt;
|
||||
}
|
||||
|
||||
/* Zwraca pierwszy rekord */
|
||||
|
||||
public function First() {
|
||||
if (!$this->result) {
|
||||
$this->result[$this->rowIndex++] = $this->stmt->FetchAssoc();
|
||||
}
|
||||
$this->currIndex = 0;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/* Zwraca ostatni rekord */
|
||||
|
||||
public function Last() {
|
||||
if (!$this->done) {
|
||||
array_push($this->result, $this->stmt->FetchAllAssoc());
|
||||
}
|
||||
$this->done = true;
|
||||
$this->currIndex = $this->rowIndex = count($this->result) - 1;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/* Zwieksza index i zwraca kolejny rekord */
|
||||
|
||||
public function Next() {
|
||||
if ($this->done) {
|
||||
return false;
|
||||
}
|
||||
$offset = $this->currIndex + 1;
|
||||
if (!$this->result[$offset]) {
|
||||
$row = $this->stmt->FetchAssoc();
|
||||
if (!$row) {
|
||||
$this->done = true;
|
||||
return false;
|
||||
}
|
||||
$this->result[$offset] = $row;
|
||||
++$this->rowIndex;
|
||||
++$this->currIndex;
|
||||
return $this;
|
||||
} else {
|
||||
++$this->currIndex;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/* Zmniejsza index i zwraca poprzedni wiersz */
|
||||
|
||||
public function Prev() {
|
||||
if ($this->currIndex == 0) {
|
||||
return false;
|
||||
}
|
||||
--$this->currIndex;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter dla pobieranych danych
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function __get($value) {
|
||||
if (array_key_exists($value, $this->result[$this->currIndex])) {
|
||||
return $this->result[$this->currIndex][$value];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Klasa oslonowa naszej bazy danych
|
||||
*
|
||||
*/
|
||||
class DBProd extends DBMysql {
|
||||
|
||||
protected $user;
|
||||
protected $pass;
|
||||
protected $dbHost;
|
||||
protected $dbName;
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$db = Config::Get('db');
|
||||
$this->dbHost = $db['prodHost'];
|
||||
$this->dbName = $db['prodDb'];
|
||||
$this->user = $db['prodUser'];
|
||||
$this->pass = $db['prodPass'];
|
||||
}
|
||||
|
||||
public function GetDbh() {
|
||||
if (empty($this->dbh)) {
|
||||
//$this->Connect(__METHOD__);
|
||||
}
|
||||
return $this->dbh;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
489
_rejestracja/core/class/Daemon.class.php
Normal file
489
_rejestracja/core/class/Daemon.class.php
Normal file
@@ -0,0 +1,489 @@
|
||||
<?php
|
||||
|
||||
// Logowanie
|
||||
define('DLOG_TO_CONSOLE', 1);
|
||||
define('DLOG_NOTICE', 2);
|
||||
define('DLOG_WARNING', 4);
|
||||
define('DLOG_ERROR', 8);
|
||||
define('DLOG_CRITICAL', 16);
|
||||
|
||||
/**
|
||||
* Daemon
|
||||
*
|
||||
* Wymagania:
|
||||
* Unix
|
||||
* PHP 4 >= 4.3.0 or PHP 5
|
||||
* PHP z:
|
||||
* --enable-sigchild
|
||||
* --enable-pcntl
|
||||
*/
|
||||
class Daemon
|
||||
{
|
||||
|
||||
private $userID = 99;
|
||||
|
||||
public $x=0;
|
||||
|
||||
private $groupID = 99;
|
||||
|
||||
/**
|
||||
* Zakonczyc prace gdy nie da sie ustawic tozsamosci demona ?
|
||||
*/
|
||||
private $requireSetIdentity = false;
|
||||
|
||||
/**
|
||||
* sciezka do pida
|
||||
*
|
||||
*/
|
||||
private $pidFileLocation = '/home/users/turystyka/public_html/test/daemon.pid';
|
||||
|
||||
/**
|
||||
* sciezka home'a.. tylko po co?
|
||||
*
|
||||
*/
|
||||
private $homePath = '/home/users/turystyka/public_html/Server/Daemon';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* id procesu
|
||||
*
|
||||
*/
|
||||
protected $pid = 0;
|
||||
|
||||
/**
|
||||
* czy proces jest dzieckiem
|
||||
*
|
||||
*/
|
||||
private $isChildren = false;
|
||||
|
||||
/**
|
||||
* czy dzialamy czy nie :)
|
||||
*
|
||||
*/
|
||||
private $isRunning = false;
|
||||
|
||||
private $children = array();
|
||||
|
||||
private $maxProcesses = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
*/
|
||||
public function __construct($homePath, $pidFileLocation) {
|
||||
error_reporting(0);
|
||||
set_time_limit(0);
|
||||
ob_implicit_flush();
|
||||
|
||||
register_shutdown_function(array(&$this, 'releaseDaemon'));
|
||||
}
|
||||
|
||||
public function GetUserID() {
|
||||
return $this->userID;
|
||||
}
|
||||
|
||||
public function SetUserID($userID) {
|
||||
$this->userID = $userID;
|
||||
}
|
||||
|
||||
public function GetGroupID() {
|
||||
return $this->groupID;
|
||||
}
|
||||
|
||||
public function SetGroupID($groupID) {
|
||||
$this->groupID = $groupID;
|
||||
}
|
||||
|
||||
public function GetRequireSetIdentity() {
|
||||
return $this->requireSetIdentity;
|
||||
}
|
||||
|
||||
public function SetRequireSetIdentity($requireSetIdentity) {
|
||||
$this->requireSetIdentity = $requireSetIdentity;
|
||||
}
|
||||
|
||||
public function GetPidFileLocation() {
|
||||
return $this->pidFileLocation;
|
||||
}
|
||||
|
||||
public function SetPidFileLocation($pidFileLocation) {
|
||||
$this->pidFileLocation = $pidFileLocation;
|
||||
}
|
||||
|
||||
public function GetHomePath() {
|
||||
return $this->homePath;
|
||||
}
|
||||
|
||||
public function SetHomePath($homePath) {
|
||||
$this->homePath = $homePath;
|
||||
}
|
||||
|
||||
public function GetPid() {
|
||||
return $this->pid;
|
||||
}
|
||||
|
||||
public function SetPid($pid) {
|
||||
$this->pid = $pid;
|
||||
$fp = fopen($this->GetHomePath().'/'.$this->pid.'.pid', 'w');
|
||||
fwrite($fp, serialize($this));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public function GetIsChildren() {
|
||||
return $this->isChildren;
|
||||
}
|
||||
|
||||
public function SetIsChildren($isChildren) {
|
||||
$this->isChildren = $isChildren;
|
||||
}
|
||||
|
||||
public function GetIsRunning() {
|
||||
return $this->isRunning;
|
||||
}
|
||||
|
||||
public function SetIsRunning($isRunning) {
|
||||
$this->isRunning = $isRunning;
|
||||
}
|
||||
|
||||
public function GetChildren() {
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function AddChild($pid) {
|
||||
$this->children[$pid] = true;
|
||||
}
|
||||
|
||||
public function RemChild($pid) {
|
||||
if(isset($this->children[$pid])) {
|
||||
unset($this->childern[$pid]);
|
||||
}
|
||||
}
|
||||
|
||||
public function StartChild($child) {
|
||||
|
||||
$pid = Daemon::InitChild($chils, $this->GetPid());
|
||||
$this->AddChild($pid);
|
||||
MFLog::DbLog('Child process '.$pid.' started');
|
||||
if(!is_dir($filename)) {
|
||||
mkdir($this->GetHomePath().'/'.$this->GetPid(), 0777);
|
||||
}
|
||||
$fp = fopen($this->GetHomePath().'/'.$this->GetPid().'/'.$pid.'.pid', 'w');
|
||||
fwrite($fp, serialize($child));
|
||||
fclose($fp);
|
||||
$pidReturn = pcntl_waitpid($pid, $status);
|
||||
if(pcntl_wifexited($status)) {
|
||||
MFLog::DbLog('Child process '.$pid.' finished with status: '.$status);
|
||||
} else {
|
||||
MFLog::DbLog('child process '.$pid.' died');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static function InitChild($child, $masterPid) {
|
||||
$pid = pcntl_fork();
|
||||
if($pid == 0) {
|
||||
exit($child->Run($masterPid));
|
||||
} else {
|
||||
return $pid;
|
||||
}
|
||||
}
|
||||
|
||||
public function KillAll() {
|
||||
foreach($this->GetChildren() as $pid => $data) {
|
||||
MFLog::DbLog('Killing: '.$pid);
|
||||
posix_kill($pid, 0);
|
||||
if(is_file($this->GetHomePath().'/'.$this->GetPid().'/'.$pid.'.pid')) {
|
||||
unlink($this->GetHomePath().'/'.$this->GetPid().'/'.$pid.'.pid');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inicjowanie komponentow systemu
|
||||
*
|
||||
*/
|
||||
public function Init() {
|
||||
|
||||
//include('class/DB.class.php');
|
||||
//include('class/Registry.class.php');
|
||||
|
||||
|
||||
//include('ErrorHandler.php');
|
||||
$db = new DBProd();
|
||||
Registry::Remove('db');
|
||||
Registry::Set('db', $db);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Start daemona
|
||||
*
|
||||
*/
|
||||
public function Start() {
|
||||
$this->LogMessage('Starting daemon');
|
||||
|
||||
if (!$this->Daemonize())
|
||||
{
|
||||
$this->LogMessage('Could not start daemon', DLOG_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$this->LogMessage('Running...');
|
||||
|
||||
$this->IsRunning = true;
|
||||
|
||||
|
||||
while ($this->IsRunning)
|
||||
{
|
||||
$this->DoTask();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop daemona
|
||||
*
|
||||
*/
|
||||
public function Stop()
|
||||
{
|
||||
$this->LogMessage('Stoping daemon');
|
||||
|
||||
$this->KillAll();
|
||||
|
||||
if(is_file($this->GetHomePath().'/'.$this->pid.'.pid')) {
|
||||
unlink($this->GetHomePath().'/'.$this->pid.'.pid');
|
||||
}
|
||||
|
||||
$this->IsRunning = false;
|
||||
//posix_kill($this->GetPid(), 0);
|
||||
//exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Podaj lape :)
|
||||
*
|
||||
*/
|
||||
function DoTask()
|
||||
{
|
||||
|
||||
while(1) {
|
||||
if(is_dir($this->GetHomePath().'/todo')) {
|
||||
if($handle = opendir($this->GetHomePath().'/todo')) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if(count($this->GetChildren()) < $this->maxProcesses) {
|
||||
$taskFile = fopen($this->GetHomePath().'/todo/'.$file, 'r');
|
||||
$taskData = fread($taskFile, filesize($this->GetHomePath().'/todo/'.$file));
|
||||
fclose($taskFile);
|
||||
unlink($this->GetHomePath().'/todo/'.$file);
|
||||
$taskObj = unserialize($taskData);
|
||||
$this->InitChild($taskObj, $this->GetPid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hau hau
|
||||
//mail('pawy@formix.pl', 'demonizer', 'im running');
|
||||
// $fp = fopen('/home/users/turystyka/public_html/test/data'.$this->x.'.txt', 'w');
|
||||
// fwrite($fp, '1');
|
||||
// fwrite($fp, '23');
|
||||
// fclose($fp);
|
||||
// sleep(10);
|
||||
// //$fp = fopen('/home/users/turystyka/public_html/test/data2.txt', 'w');
|
||||
// $this->x++;
|
||||
// if($this->x < 5){
|
||||
// $this->DoTask();
|
||||
// } else {
|
||||
// $this->Stop();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Logujemy cos
|
||||
*
|
||||
*/
|
||||
public function LogMessage($msg, $level = DLOG_NOTICE)
|
||||
{
|
||||
// logowanie
|
||||
MFLog::DbLog($msg);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Nie taki diabel straszny..
|
||||
*
|
||||
*/
|
||||
private function Daemonize()
|
||||
{
|
||||
// ob_end_flush();
|
||||
|
||||
if ($this->IsDaemonRunning())
|
||||
{
|
||||
// Deamon dziala. Exiting
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->Fork())
|
||||
{
|
||||
// niesforkowalo sie. Exiting.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->SetIdentity() && $this->requireSetIdentity)
|
||||
{
|
||||
// nie udalo sie ustawic tozsamosci. Exiting
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!posix_setsid())
|
||||
{
|
||||
$this->LogMessage('Could not make the current process a session leader', DLOG_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$fp = @fopen($this->pidFileLocation, 'w'))
|
||||
{
|
||||
$this->LogMessage('Could not write to PID file', DLOG_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs($fp, $this->pid);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
@chdir($this->homePath);
|
||||
umask(0);
|
||||
|
||||
declare(ticks = 1);
|
||||
|
||||
pcntl_signal(SIGCHLD, array(&$this, 'sigHandler'));
|
||||
pcntl_signal(SIGTERM, array(&$this, 'sigHandler'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sprawdzamy czy dzialamy juz
|
||||
*
|
||||
*/
|
||||
private function IsDaemonRunning()
|
||||
{
|
||||
$oldPid = false;
|
||||
if(is_file($this->pidFileLocation)) {
|
||||
$oldPid = @file_get_contents($this->pidFileLocation);
|
||||
|
||||
}
|
||||
if ($oldPid !== false && posix_kill(trim($oldPid),0))
|
||||
{
|
||||
$this->LogMessage('Daemon already running with PID: '.$oldPid, (DLOG_TO_CONSOLE | DLOG_ERROR));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forkujemy proces
|
||||
*/
|
||||
private function Fork()
|
||||
{
|
||||
$this->LogMessage('Forking...');
|
||||
|
||||
$pid = pcntl_fork();
|
||||
|
||||
if ($pid == -1) // error
|
||||
{
|
||||
$this->LogMessage('Could not fork', DLOG_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if ($pid) // parent
|
||||
{
|
||||
$this->LogMessage('Killing parent');
|
||||
|
||||
exit();
|
||||
}
|
||||
else // children
|
||||
{
|
||||
|
||||
$this->IsChildren = true;
|
||||
$this->SetPid(posix_getpid());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawiamy tozsamosc diob³a i zwracamy wynik
|
||||
*
|
||||
*/
|
||||
private function SetIdentity()
|
||||
{
|
||||
if (!posix_setgid($this->groupID) || !posix_setuid($this->userID))
|
||||
{
|
||||
$this->LogMessage('Could not set identity', DLOG_WARNING);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsluga sig'ow
|
||||
*
|
||||
*/
|
||||
public function SigHandler($sigNo)
|
||||
{
|
||||
switch ($sigNo)
|
||||
{
|
||||
case SIGTERM: // Shutdown
|
||||
$this->LogMessage('Shutdown signal');
|
||||
$this->Stop();
|
||||
exit();
|
||||
break;
|
||||
|
||||
case SIGCHLD: // Halt
|
||||
$this->LogMessage('Halt signal');
|
||||
while (pcntl_waitpid(-1, $status, WNOHANG) > 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwalnia plik z pidem
|
||||
* Cos ala desktruktor
|
||||
*
|
||||
*/
|
||||
public function ReleaseDaemon()
|
||||
{
|
||||
if (file_exists($this->pidFileLocation))
|
||||
// if ($this->isChildren && file_exists($this->pidFileLocation))
|
||||
{
|
||||
$this->LogMessage('Releasing daemon');
|
||||
|
||||
unlink($this->pidFileLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
77
_rejestracja/core/class/DaemonTask.class.php
Normal file
77
_rejestracja/core/class/DaemonTask.class.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
class DaemonTask {
|
||||
|
||||
private $pid;
|
||||
|
||||
private $sheduleType = array('year'=>0, 'month'=>0, 'week'=>0, 'day'=>0, 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
|
||||
private $sheduleOffset;
|
||||
|
||||
private $masterPid;
|
||||
|
||||
|
||||
|
||||
public function getPid() {
|
||||
return $this->pid;
|
||||
}
|
||||
|
||||
public function SetPid($pid) {
|
||||
$this->pid = $pid;
|
||||
}
|
||||
|
||||
public function GetSheduleType() {
|
||||
return $this->sheduleType;
|
||||
}
|
||||
|
||||
public function SetSheduleType($sheduleType) {
|
||||
$this->sheduleType = $sheduleType;
|
||||
}
|
||||
|
||||
public function GetSheduleOffset() {
|
||||
return $this->sheduleOffset;
|
||||
}
|
||||
|
||||
public function SetSheduleOffset($sheduleOffset) {
|
||||
$this->sheduleOffset = $sheduleOffset;
|
||||
}
|
||||
|
||||
public function GetMasterPid() {
|
||||
return $this->masterPid;
|
||||
}
|
||||
|
||||
public function SetMasterPid($masterPid) {
|
||||
$this->masterPid = $masterPid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function Run($masterPid) {
|
||||
$this->SetMasterPid($masterPid);
|
||||
$this->Action();
|
||||
$this->ReShedule();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function Action() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function ReShedule() {
|
||||
$shedule = $this->GetSheduleType();
|
||||
if(isset($shedule['year']) && $shedule['year']>0) {
|
||||
//$next = mktime(0,0,0,date("m"), date("d"), date("Y")+$shedule['year']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
310
_rejestracja/core/class/DalData.class.php
Normal file
310
_rejestracja/core/class/DalData.class.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/*
|
||||
* Obiekt konfiguracyjny dla DALi
|
||||
*/
|
||||
class DalData {
|
||||
|
||||
/*
|
||||
* nazwa klasy
|
||||
*/
|
||||
private $objClassName;
|
||||
/*
|
||||
* tablica klasy
|
||||
*/
|
||||
private $objClassTable;
|
||||
/*
|
||||
* primary key
|
||||
*/
|
||||
private $objClassTablePK;
|
||||
/*
|
||||
* klasa opcjonalna
|
||||
*/
|
||||
private $optClass;
|
||||
/*
|
||||
* warunki
|
||||
*/
|
||||
private $condition = array(); //$data
|
||||
/*
|
||||
* lista pol do selecta
|
||||
*/
|
||||
private $queryFields = array();
|
||||
private $selectFields = array();
|
||||
/*
|
||||
* limit
|
||||
*/
|
||||
private $limit = 0;
|
||||
/*
|
||||
* order by
|
||||
*/
|
||||
private $sortBy = null;
|
||||
/*
|
||||
* group by
|
||||
*/
|
||||
private $groupBy = null;
|
||||
/*
|
||||
* count w wyniku
|
||||
*/
|
||||
private $count = null;
|
||||
/*
|
||||
* zapytanie cacheowane
|
||||
*/
|
||||
private $cache = true;
|
||||
/*
|
||||
* tablica do joina
|
||||
*/
|
||||
private $join = null;
|
||||
/*
|
||||
* czas cache
|
||||
*/
|
||||
private $cacheTime = 0;
|
||||
/*
|
||||
* cacheowanie obiektow wynikowych
|
||||
*/
|
||||
private $cacheObject = 0;
|
||||
/*
|
||||
* obiekt do przeslania do dal
|
||||
*/
|
||||
private $obj;
|
||||
private $updateFileldArray;
|
||||
private $id;
|
||||
private $fieldName;
|
||||
private $updateFieldId;
|
||||
/*
|
||||
* handler do bazy db/sqlite
|
||||
*/
|
||||
private $databaseType = 'db';
|
||||
private $dataArray = array();
|
||||
|
||||
|
||||
public function getUpdateFieldId() {
|
||||
return $this->updateFieldId;
|
||||
}
|
||||
|
||||
public function setUpdateFieldId($updateFieldId) {
|
||||
$this->updateFieldId = $updateFieldId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __construct($data = array()) {
|
||||
|
||||
if(is_array($data))
|
||||
{
|
||||
foreach($data as $key => $value)
|
||||
{
|
||||
eval ('self::set' . $key . '($value);');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getCacheTime() {
|
||||
return $this->cacheTime;
|
||||
}
|
||||
|
||||
public function setCacheTime($cacheTime) {
|
||||
$this->cacheTime = $cacheTime;
|
||||
}
|
||||
|
||||
public function getObjClassName() {
|
||||
return $this->objClassName;
|
||||
}
|
||||
|
||||
public function setObjClassName($objClassName) {
|
||||
$this->objClassName = $objClassName;
|
||||
}
|
||||
|
||||
public function getObjClassTable() {
|
||||
return $this->objClassTable;
|
||||
}
|
||||
|
||||
public function setObjClassTable($objClassTable) {
|
||||
$this->objClassTable = $objClassTable;
|
||||
}
|
||||
|
||||
public function getObjClassTablePK() {
|
||||
return $this->objClassTablePK;
|
||||
}
|
||||
|
||||
public function setObjClassTablePK($objClassTablePK) {
|
||||
$this->objClassTablePK = $objClassTablePK;
|
||||
}
|
||||
|
||||
public function getOptClass() {
|
||||
return $this->optClass;
|
||||
}
|
||||
|
||||
public function setOptClass($optClass) {
|
||||
$this->optClass = $optClass;
|
||||
}
|
||||
|
||||
public function getCondition() {
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
public function setCondition($condition) {
|
||||
$this->condition = $condition;
|
||||
}
|
||||
|
||||
public function addCondition($field, $value, $condition = null, $split = null) {
|
||||
if ($condition === null) {
|
||||
$this->condition[$field] = $value;
|
||||
} else {
|
||||
$this->condition[$field] = array('value' => $value, 'split' => $split, 'condition' => $condition);
|
||||
}
|
||||
}
|
||||
|
||||
public function getQueryFields() {
|
||||
return $this->queryFields;
|
||||
}
|
||||
|
||||
public function setQueryFields($queryFields) {
|
||||
$this->queryFields = $queryFields;
|
||||
}
|
||||
|
||||
public function getLimit() {
|
||||
return $this->limit;
|
||||
}
|
||||
|
||||
public function setLimit($limit) {
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
public function getSortBy() {
|
||||
return $this->sortBy;
|
||||
}
|
||||
|
||||
public function setSortBy($sortBy) {
|
||||
$this->sortBy = $sortBy;
|
||||
}
|
||||
|
||||
public function getCount() {
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
public function setCount($count) {
|
||||
$this->count = $count;
|
||||
}
|
||||
|
||||
public function getCache() {
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
public function setCache($cache) {
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
public function getJoin() {
|
||||
return $this->join;
|
||||
}
|
||||
|
||||
public function setJoin($join) {
|
||||
$this->join = $join;
|
||||
}
|
||||
|
||||
public function addJoin($name, $join) {
|
||||
$this->join[$name] = $join;
|
||||
}
|
||||
|
||||
public function getCacheObject() {
|
||||
return $this->cacheObject;
|
||||
}
|
||||
|
||||
public function setCacheObject($cacheObject) {
|
||||
$this->cacheObject = $cacheObject;
|
||||
}
|
||||
|
||||
public function getObj() {
|
||||
return $this->obj;
|
||||
}
|
||||
|
||||
public function setObj($obj) {
|
||||
$this->obj = $obj;
|
||||
}
|
||||
|
||||
public function getUpdateFileldArray() {
|
||||
return $this->updateFileldArray;
|
||||
}
|
||||
|
||||
public function setUpdateFileldArray($updateFileldArray) {
|
||||
$this->updateFileldArray = $updateFileldArray;
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getFieldName() {
|
||||
return $this->fieldName;
|
||||
}
|
||||
|
||||
public function setFieldName($fieldName) {
|
||||
$this->fieldName = $fieldName;
|
||||
}
|
||||
|
||||
public function getDatabaseType() {
|
||||
return $this->databaseType;
|
||||
}
|
||||
|
||||
public function setDatabaseType($databaseType) {
|
||||
$this->databaseType = $databaseType;
|
||||
}
|
||||
|
||||
public function getDataArray($key) {
|
||||
if(isset($this->dataArray[$key]))
|
||||
return $this->dataArray[$key];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setDataArray($key,$value) {
|
||||
$this->dataArray[$key] = $value;
|
||||
}
|
||||
|
||||
public function getSelectFields() {
|
||||
return $this->selectFields;
|
||||
}
|
||||
|
||||
public function getSelectFieldsQuery()
|
||||
{
|
||||
if(count($this->selectFields) > 0 )
|
||||
{
|
||||
$q = " , ";
|
||||
foreach($this->selectFields as $key => $value)
|
||||
{
|
||||
$q.= $value . " as " . $key . ",";
|
||||
}
|
||||
return substr($q, 0, strlen($q)-1);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addSelectFields($selectFields,$key) {
|
||||
if($key == null)
|
||||
$this->selectFields[] = $selectFields;
|
||||
else
|
||||
$this->selectFields[$key] = $selectFields;
|
||||
}
|
||||
|
||||
public function getGroupBy() {
|
||||
return $this->groupBy;
|
||||
}
|
||||
|
||||
public function setGroupBy($groupBy) {
|
||||
$this->groupBy = $groupBy;
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
if(!is_null($this->obj))return $this->obj->GetFields();
|
||||
else return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
202
_rejestracja/core/class/DataObject.class.php
Normal file
202
_rejestracja/core/class/DataObject.class.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description of DataObject
|
||||
*
|
||||
* @author mabi
|
||||
*/
|
||||
abstract class DataObject {
|
||||
|
||||
static $tableName;
|
||||
static $className = __CLASS__;
|
||||
static $fields = array();
|
||||
static $classTablePK;
|
||||
|
||||
protected $label;
|
||||
|
||||
public function GetLabel() {
|
||||
if (!$this->label) {
|
||||
throw new UserException("Object hasn't label.");
|
||||
}
|
||||
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* pola wystepujace tylko w obiekatch (nie sa zapisywane do BD)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $classFields = array();
|
||||
|
||||
protected $id;
|
||||
/** zdjecia **/
|
||||
|
||||
/**
|
||||
* Export danych do tablicy asocjacyjnej z pol klasy.
|
||||
*
|
||||
* @return array()
|
||||
*/
|
||||
public function ToArrayAssoc() {
|
||||
$fields = $this->GetFields();
|
||||
|
||||
$done = array();
|
||||
|
||||
foreach($fields as $index => $value) {
|
||||
$temp = 'Get'.$fields[$index];
|
||||
$done[$index] = $this->$temp();
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import danych z tablicy asocjacyjnej do p�l klasy.
|
||||
*
|
||||
* @param string $array tablica asocjacyjna zawieraj�ca rekordy pobrane z bazy
|
||||
* @param int $cut 1 - klucze musz� mie� posta� <KLASA>_<POLE>, 0 - <POLE>
|
||||
*/
|
||||
public function FromArray($array, $cut = false, $alias = null) {
|
||||
$fields = $this->GetFields();
|
||||
|
||||
// sprawdzenie czy istnieje metoda dla pol niebedacych w BD
|
||||
if(method_exists($this, 'GetClassFields')) {
|
||||
$fields = array_merge($fields, $this -> GetClassFields());
|
||||
}
|
||||
|
||||
$prfx = ((!empty($alias) && is_string($alias)) ? $alias .'_' : '' );
|
||||
|
||||
if (is_array($array))
|
||||
foreach ($array as $index => $var) {
|
||||
if($cut == true)
|
||||
$index = str_replace($prfx . $this->GetClassName() . "_", "", $index);
|
||||
if (array_key_exists($index, $fields)) {
|
||||
$temp = 'Set'.$fields[$index];
|
||||
$this->$temp($var);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Import danych z tablicy asocjacyjnej do p�l klasy.
|
||||
* Jedyn� r�nic� w por�wnaniu do @see FromArray jest zmiana postaci
|
||||
* klucza, kt�re teraz maja posta�: $prefix_<KLASA>_<POLE>
|
||||
*
|
||||
* @param string $array tablica asocjacyjna zawieraj�ca rekordy pobrane z bazy
|
||||
*/
|
||||
public function FromArrayPrefix($array, $prefix) {
|
||||
$fields = $this->GetFields();
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $index => $var) {
|
||||
$index = str_replace($prefix . "_" . $this->GetClassName() . "_", "", $index);
|
||||
|
||||
if (array_key_exists($index, $fields)) {
|
||||
$temp = 'Set'.$fields[$index];
|
||||
$this->$temp($var);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function GetType() {
|
||||
// //MAKL:!!
|
||||
// return array_search($this->GetClassName(),'Stars');
|
||||
// }
|
||||
|
||||
public abstract function GetId();
|
||||
public abstract function GetTableName();
|
||||
public abstract function GetFields();
|
||||
public abstract function GetClassName();
|
||||
public abstract function GetClassTablePK();
|
||||
|
||||
|
||||
public static function GetStaticVariable($variableName) {
|
||||
if(isset(self::$$variableName)) {
|
||||
return self::$$variableName;
|
||||
} else {
|
||||
throw new Exception('Klasa '.__CLASS__.' nie posiada stałej: '.$variableName.' !');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Metoda zwraca tablice id'k�w tablicy obiekt�w.
|
||||
* Wykorzystywana na potrzeby DefaultDAL::ToJavaScriptArray($array, $jsName)
|
||||
*
|
||||
* @param array $objArray
|
||||
*/
|
||||
public static function GetObjIDs($objArray) {
|
||||
$array = array();
|
||||
if(is_array($objArray)) {
|
||||
foreach($objArray as $obj) {
|
||||
$array[] = $obj->GetId();
|
||||
}
|
||||
} else {
|
||||
return $array;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Metoda zwraca tablice nazw
|
||||
* Wykorzystywana tylko w slownikach!
|
||||
*
|
||||
* @param unknown_type $objArray
|
||||
*/
|
||||
public static function ToArray($objArray) {
|
||||
|
||||
$done = array();
|
||||
foreach($objArray as $value) {
|
||||
$done[$value->GetId()] = $value->GetName();
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
public static function ToArrayUrl($objArray) {
|
||||
|
||||
$done = array();
|
||||
foreach($objArray as $value) {
|
||||
$done[$value->GetName()] = $value->GetUrlName();
|
||||
}
|
||||
return $done;
|
||||
}
|
||||
|
||||
|
||||
public function GetTitleAlt() {
|
||||
return strip_tags(Utils::cleanUrlSpaces($this->GetTitle()));
|
||||
}
|
||||
|
||||
public function GetTitleUrl() {
|
||||
return Utils::TextToUrl(strip_tags(Utils::cleanUrl($this->GetTitle())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Funkcja generuje url
|
||||
*
|
||||
* TODO: Dopisaæ dzia³anie matrixa.
|
||||
*
|
||||
* @param String $label Opcjonalnie, niestandardowy label
|
||||
*/
|
||||
public function GenerateUrl($label = null, $matrix = array()) {
|
||||
if (!$label) {
|
||||
$label = $this->GetLabel();
|
||||
}
|
||||
|
||||
$route = Router::$route[$label];
|
||||
|
||||
$dataArray = array();
|
||||
|
||||
foreach ($route['variables'] as $v) {
|
||||
$fun = 'Get' . ucfirst($v);
|
||||
$dataArray[$v] = Utils::TextToUrl($this->$fun());
|
||||
}
|
||||
|
||||
return Router::GenerateUrl($label, $dataArray);
|
||||
}
|
||||
|
||||
// abstract public function GetUrl();
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
43
_rejestracja/core/class/DbCache.class.php
Normal file
43
_rejestracja/core/class/DbCache.class.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class DbCache {
|
||||
private $query;
|
||||
private $cacheTime = 30;
|
||||
private $cacheFile;
|
||||
private $cachePath = DBCACHE_PATH;
|
||||
private $cacheEnable = DBCACHE_ENABLE;
|
||||
|
||||
public function __construct($query, $time=null) {
|
||||
$this->query = $query;
|
||||
$this->cacheFile = md5($query);
|
||||
if($time!=null) $this->cacheTime = $time;
|
||||
|
||||
}
|
||||
|
||||
public function CacheCheck() {
|
||||
if($this->cacheEnable == false || ($this->cacheEnable == true && is_file($this->cachePath.$this->cacheFile) && filemtime($this->cachePath.$this->cacheFile) > (time() - $this->cacheTime))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function CacheWrite($result) {
|
||||
if($this->cacheEnable != false) {
|
||||
$records = serialize($result);
|
||||
$fp = fopen($this->cachePath.$this->cacheFile, "w");
|
||||
fputs($fp, $records);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function CacheRead() {
|
||||
$records = unserialize(file_get_contents($this->cachePath.$this->cacheFile));
|
||||
return $records;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
476
_rejestracja/core/class/DbSqlLite.class.php
Normal file
476
_rejestracja/core/class/DbSqlLite.class.php
Normal file
@@ -0,0 +1,476 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Klasa do obslugi bazy mysql
|
||||
*
|
||||
*/
|
||||
class DbSqlLite implements DBConnection {
|
||||
protected $user;
|
||||
protected $pass;
|
||||
protected $dbHost;
|
||||
protected $dbName;
|
||||
protected $dbh;
|
||||
protected $fileName;
|
||||
protected $mode = '0666';
|
||||
protected $characterset = 'utf-8';
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $pass
|
||||
* @param string $dbHost
|
||||
* @param string $dbName
|
||||
*/
|
||||
public function __construct($file) {
|
||||
$this->fileName = $file;
|
||||
}
|
||||
/*Nawiazywanie polaczenia z baza*/
|
||||
protected function Connect() {
|
||||
|
||||
|
||||
try {
|
||||
$this->DbConnect();
|
||||
$this->SetCharacterset();
|
||||
} catch (Exception $e) {
|
||||
MFLog::Fatal("Line: ".$e->getLine()." Message: ".$e->getMessage()." Referer: ".getenv('HTTP_REFERER'));
|
||||
MFLog::Error("Switching app to safe mode");
|
||||
Core::SetAppSafeMode();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function DbConnect() {
|
||||
$this->dbh = sqlite_open($this->fileName, $this->mode, $errorMessage);
|
||||
if(empty($this->dbh)) {
|
||||
throw new CoreException('Cannot connect to database! '.$errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function SetCharacterset() {
|
||||
//sqlite_query($this->dbh, "SET CHARACTER SET ".$this->characterset);
|
||||
//sqlite_query($this->dbh, "SET NAMES '".$this->characterset."'");
|
||||
//sqlite_query($this->dbh, "SET CHARACTER_SET_CLIENT = ".$this->characterset);
|
||||
//sqlite_query($this->dbh, "SET character_set_results = ".$this->characterset);
|
||||
//sqlite_query($this->dbh, "SET character_set_connection = ".$this->characterset);
|
||||
}
|
||||
|
||||
public function Escape($string) {
|
||||
|
||||
if(Enviroment::CheckMagicQuotes()) {
|
||||
$return = $string;
|
||||
} else {
|
||||
$return = sqlite_escape_string($string);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*Wykonanie zapytania*/
|
||||
public function Execute($query) {
|
||||
|
||||
if(!$this->dbh) {
|
||||
$this->Connect();
|
||||
}
|
||||
MFLog::Debug($query);
|
||||
$ret = 'unexecuted';
|
||||
if($this->dbh) {
|
||||
$ret = sqlite_query($this->dbh, $query);
|
||||
}
|
||||
if(!$ret && $ret!='unexecuted') {
|
||||
throw new CoreException(sqlite_error_string(sqlite_last_error($this->dbh)).$query);
|
||||
}
|
||||
else {
|
||||
$stmt = new DbSqlLiteStatement($this->dbh, $query);
|
||||
$stmt->result = $ret;
|
||||
return $stmt;
|
||||
}
|
||||
}
|
||||
/*Przygotowanie zapytania zwraca obiekt klasy DBMysqlStatement*/
|
||||
public function Prepare($query) {
|
||||
if(!$this->dbh) {
|
||||
$this->Connect();
|
||||
}
|
||||
return new DbSqlLiteStatement($this->dbh, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rozpoczyna transakcje
|
||||
*
|
||||
*/
|
||||
public function BeginTransaction() {
|
||||
if(!$this->dbh) {
|
||||
$this->Connect();
|
||||
}
|
||||
@sqlite_query("START TRANSACTION ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Zartwierdza transakcje
|
||||
*
|
||||
*/
|
||||
public function CommitTransaction() {
|
||||
if(!$this->dbh) {
|
||||
$this->Connect();
|
||||
}
|
||||
@sqlite_query("COMMIT");
|
||||
}
|
||||
|
||||
/**
|
||||
* Wycofuje transakcje
|
||||
*
|
||||
*/
|
||||
public function Rollback() {
|
||||
if(!$this->dbh) {
|
||||
$this->Connect();
|
||||
}
|
||||
@sqlite_query("ROLLBACK");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruktor zamykajacy polaczenie
|
||||
*
|
||||
*/
|
||||
public function __destruct() {
|
||||
if(isset($this->dbh) && is_resource($this->dbh)) {
|
||||
sqlite_close($this->dbh);
|
||||
}
|
||||
}
|
||||
public function GetDbh() {
|
||||
return $this->dbh;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Klasa implementujaca interfejs DBStatement dla mysqla
|
||||
*
|
||||
*/
|
||||
class DbSqlLiteStatement implements DBStatement {
|
||||
public $result;
|
||||
public $binds;
|
||||
public $query;
|
||||
public $dbh;
|
||||
private $cacheTime = 30;
|
||||
private $cacheFile;
|
||||
private $cachePath = DBCACHE_PATH;
|
||||
private $cacheEnable = DBCACHE_ENABLE;
|
||||
private $cacheQuery = false;
|
||||
|
||||
/**
|
||||
* KOnstruktor klasy
|
||||
*
|
||||
* @param mysql $dbh
|
||||
* @param string $query
|
||||
*/
|
||||
public function __construct($dbh, $query) {
|
||||
$this->query = $query;
|
||||
$this->dbh = $dbh;
|
||||
if(!$dbh) {
|
||||
Core::SetAppSafeMode();
|
||||
//throw new MysqlException("No db connection");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca tresc zapytania
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
/*Zamienia zmienne w zapytaniu na podane wartosci*/
|
||||
public function BindParam($ph, $pv) {
|
||||
$this->binds[$ph] = $pv;
|
||||
return $this;
|
||||
}
|
||||
/*Wykonanie zapytania*/
|
||||
public function Execute() {
|
||||
|
||||
$binds = func_get_args();
|
||||
foreach($binds as $index => $name) {
|
||||
$this->binds[$index + 1] = $name;
|
||||
}
|
||||
$cnt = count($binds);
|
||||
$query = $this->query;
|
||||
|
||||
if (count($this->binds)>0) {
|
||||
foreach ($this->binds as $ph => $pv) {
|
||||
// $query = str_replace(":$ph", "'".mysql_escape_string($pv)."'", $query);
|
||||
$query = str_replace(":$ph", '\''.sqlite_escape_string($pv).'\'', $query);
|
||||
}
|
||||
}
|
||||
MFLog::Debug(__FUNCTION__.' query: '.$query);
|
||||
if($this->dbh) {
|
||||
$this->result = sqlite_query($this->dbh, $query);
|
||||
|
||||
if(!$this->result) {
|
||||
throw new MysqlException($query . "<br /><br />" . mysql_error());
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/*Zwraca wiersz*/
|
||||
public function FetchRow() {
|
||||
if(!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
$this->SetCacheFile($this->query.'FetchRow');
|
||||
|
||||
if($this->cacheQuery==false) {
|
||||
$result = sqlite_fetch_row($this->result);
|
||||
}
|
||||
|
||||
else if ($this->cacheQuery==true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = sqlite_fetch_row($this->result);
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*Zwraca wiersz jako tablice asocjacyjna*/
|
||||
public function FetchAssoc() {
|
||||
$this->SetCacheFile($this->query.'FetchAssoc');
|
||||
|
||||
if($this->cacheQuery==false) {
|
||||
$result = sqlite_fetch_assoc($this->result);
|
||||
}
|
||||
|
||||
else if(($this->cacheQuery==true && !$this->CacheCheck() && !Core::GetAppSafeMode())) {
|
||||
$result = sqlite_fetch_assoc($this->result);
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*Zwraca ca<63>y wynik jako tablica asocjacyjna*/
|
||||
public function FetchAllAssoc() {
|
||||
$this->SetCacheFile($this->query.'FetchAllAssoc');
|
||||
|
||||
if($this->cacheQuery==false) {
|
||||
$result = array();
|
||||
|
||||
while($row = $this->fetchAssoc()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
else if($this->cacheQuery==true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = array();
|
||||
$this->cacheQuery = false;
|
||||
while($row = $this->fetchAssoc()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
$this->SetCacheFile($this->query.'FetchAllAssoc');
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
/*Zwraca ca<63>y wynik jako tablica asocjacyjna*/
|
||||
public function FetchAllRow() {
|
||||
$this->SetCacheFile($this->query.'FetchAllRow');
|
||||
|
||||
|
||||
|
||||
if($this->cacheQuery==false) {
|
||||
$result = array();
|
||||
|
||||
while($row = $this->fetchRow()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
else if($this->cacheQuery==true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = array();
|
||||
$this->cacheQuery = false;
|
||||
while($row = $this->fetchRow()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
$this->SetCacheFile($this->query.'FetchAllRow');
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*Zwraca liczbe wierszy*/
|
||||
public function NumRows() {
|
||||
if(!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
$this->SetCacheFile($this->query.'NumRows');
|
||||
|
||||
if($this->cacheQuery==false) {
|
||||
$result = sqlite_num_rows($this->result);
|
||||
|
||||
}
|
||||
|
||||
else if($this->cacheQuery==true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = sqlite_num_rows($this->result);
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*Zwraca wiersz w postaci tablicy*/
|
||||
public function FetchArray() {
|
||||
if(!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
$this->SetCacheFile($this->query.'FetchArray');
|
||||
|
||||
|
||||
|
||||
if($this->cacheQuery==false) {
|
||||
$result = sqlite_fetch_array($this->result);
|
||||
|
||||
}
|
||||
|
||||
else if($this->cacheQuery==true && !$this->CacheCheck() && !Core::GetAppSafeMode()) {
|
||||
$result = sqlite_fetch_array($this->result);
|
||||
$this->CacheWrite($result);
|
||||
} else {
|
||||
$result = $this->CacheRead();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* Zwraca id ostatnio zmienionego rekordu
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function GetInsertionId() {
|
||||
if(!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
return sqlite_last_insert_rowid($this->dbh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca liczb<7A> zmienionych rekord<72>w w ostatnim zapytaniu modyfikuj<75>cym dane.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function GetAffectedRows()
|
||||
{
|
||||
if(!$this->result) {
|
||||
throw new MysqlException("Query failed");
|
||||
}
|
||||
return sqlite_affected_rows();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprawdza czy zaoytanie jest cacheowane
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function CacheCheck() {
|
||||
if($this->cacheEnable == false || ($this->cacheEnable == true && (is_file($this->cachePath.$this->cacheFile) && filemtime($this->cachePath.$this->cacheFile) > (time() - $this->cacheTime)))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zapisuje cache do pliku
|
||||
*
|
||||
* @param obj $result
|
||||
*/
|
||||
public function CacheWrite($result) {
|
||||
if($this->cacheEnable != false) {
|
||||
$records = serialize($result);
|
||||
$fp = fopen($this->cachePath.$this->cacheFile, "w");
|
||||
fputs($fp, $records);
|
||||
fclose($fp);
|
||||
$this->cacheQuery = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Odczytuje cache z pliku
|
||||
*
|
||||
* @return obj
|
||||
*/
|
||||
public function CacheRead() {
|
||||
if(is_file($this->cachePath.$this->cacheFile)) {
|
||||
$records = unserialize(file_get_contents($this->cachePath.$this->cacheFile));
|
||||
$this->cacheQuery = false;
|
||||
return $records;
|
||||
} else {
|
||||
throw new MysqlException('File does not exist: '.$this->cachePath.$this->cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uruchamia cacheowanie
|
||||
*
|
||||
* @param integer $time
|
||||
*/
|
||||
public function CacheStart($time=null) {
|
||||
if($time!=null && $this->cacheEnable != false) {
|
||||
$this->cacheTime = $time;
|
||||
}
|
||||
if($this->cacheEnable != false)
|
||||
$this->cacheQuery = true;
|
||||
else
|
||||
$this->cacheQuery = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustanawia nazw<7A> pliku cache
|
||||
*
|
||||
* @param unknown_type $fileName
|
||||
*/
|
||||
public function SetCacheFile($fileName) {
|
||||
$this->cacheFile=md5($fileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class DBTemp extends DbSqlLite {
|
||||
|
||||
/**
|
||||
* Pusty konstruktor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->fileName = '../SqlLite/sql';
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetDbh() {
|
||||
if(empty($this->dbh)) {
|
||||
$this->Connect();
|
||||
}
|
||||
return $this->dbh;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
77
_rejestracja/core/class/Dictionary.class.php
Normal file
77
_rejestracja/core/class/Dictionary.class.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/*
|
||||
* Singleton slownika
|
||||
*/
|
||||
|
||||
class Dictionary {
|
||||
|
||||
public static $rowSet = array();
|
||||
public static $lang;
|
||||
public static $allLangs = array();
|
||||
|
||||
public static function Init($lang) {
|
||||
if (!in_array($lang, Router::$arrayLang)) {
|
||||
throw new LangException('Incorrect language.');
|
||||
}
|
||||
|
||||
self::$rowSet = MfDictionaryDAL::GetAllVariables($lang, 0);
|
||||
self::$lang = $lang;
|
||||
|
||||
self::$allLangs == array();
|
||||
self::$allLangs[$lang] = self::$rowSet;
|
||||
|
||||
$langs = Router::$arrayLang;
|
||||
//$langs = array_filter($langs, create_function('$x', 'return $x != "' . $lang . '";'));
|
||||
$langs = array_filter($langs, function($x) {return $x != "' ".self::$lang.'"';});
|
||||
foreach ($langs as $lang) {
|
||||
self::$allLangs[$lang] = MfDictionaryDAL::GetAllVariables($lang, 0);
|
||||
}
|
||||
//Utils::ArrayDisplay(self::$allLangs);
|
||||
}
|
||||
|
||||
public static function Translate($keyword) {
|
||||
|
||||
self::CheckAndAdd($keyword);
|
||||
|
||||
if($keyword!='' && isset(self::$rowSet[$keyword])) {
|
||||
|
||||
return nl2br(self::$rowSet[$keyword]);
|
||||
//Utils::ArrayDisplay(self::$rowSet);
|
||||
} else {
|
||||
//Utils::ArrayDisplay(self::$rowSet);
|
||||
return nl2br($keyword);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CheckAndAdd($keyword) {
|
||||
// $lang = 'pl';
|
||||
$lang = Router::$curLang;
|
||||
|
||||
if (!key_exists($keyword, self::$rowSet)) {
|
||||
//Utils::ArrayDisplay(self::$rowSet);
|
||||
|
||||
$isVariables = MfDictionaryDAL::IsVariables($keyword, $lang);
|
||||
if (!$isVariables) {
|
||||
|
||||
$arrayLang = Router::GetArrayLang();
|
||||
foreach ($arrayLang as $langItem) {
|
||||
if ($langItem != 'pl') {
|
||||
$replacement = $langItem.'_'.$keyword;
|
||||
} else {
|
||||
$replacement = $keyword;
|
||||
}
|
||||
$objDictionary = new MfDictionary(-1);
|
||||
$objDictionary->SetId(-1);
|
||||
$objDictionary->SetKeyword($keyword);
|
||||
$objDictionary->SetReplacement($replacement);
|
||||
$objDictionary->SetLang($langItem);
|
||||
//Utils::ArrayDisplay($keyword);
|
||||
MfDictionaryDAL::Save($objDictionary);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
39
_rejestracja/core/class/Enviroment.class.php
Normal file
39
_rejestracja/core/class/Enviroment.class.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description of Enviromentclass
|
||||
*
|
||||
* @author Pawel
|
||||
*/
|
||||
class Enviroment {
|
||||
|
||||
public static function CheckMagicQuotes() {
|
||||
return get_magic_quotes_gpc();
|
||||
}
|
||||
|
||||
public static function CheckSoapClient() {
|
||||
if(class_exists('SoapClient')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function CheckGDSupport() {
|
||||
if (extension_loaded('gd') && function_exists('gd_info')){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function CheckMemcache() {
|
||||
if(class_exists('Memcache')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user