Ver Fonte

Merge branch 'master' of bn.git:plabudda/se

Piotr Labudda há 7 anos atrás
pai
commit
79f8eac24e

+ 9 - 1
SE/se-lib/Core/Pdo.php

@@ -38,11 +38,19 @@ class Core_Pdo extends PDO {
 	public function identifierQuote($identifier) {
 	public function identifierQuote($identifier) {
 		switch (strtolower($this->_type)) {
 		switch (strtolower($this->_type)) {
 			// case 'pgsql': return $identifier;
 			// case 'pgsql': return $identifier;
-			case 'pgsql': return "\"{$identifier}\""; // https://www.postgresql.org/docs/9.1/sql-syntax-lexical.html
+			case 'pgsql': return $this->pgsqlIdentifierQuote($identifier);
 			case 'mysql': return "`{$identifier}`";
 			case 'mysql': return "`{$identifier}`";
 		}
 		}
 		return $identifier;
 		return $identifier;
 	}
 	}
+	function pgsqlIdentifierQuote($identifier) {
+		if (false !== strpos($identifier, '.')) {
+			return implode('.', array_map(function ($token) {
+				return "\"{$token}\"";
+			}, explode('.', $identifier)));
+		}
+		return "\"{$identifier}\""; // https://www.postgresql.org/docs/9.1/sql-syntax-lexical.html
+	}
 
 
 	public function tableNameQuote($tableName) {
 	public function tableNameQuote($tableName) {
 		switch (strtolower($this->_type)) {
 		switch (strtolower($this->_type)) {

+ 11 - 15
SE/se-lib/Data_Source.php

@@ -730,7 +730,7 @@ class Data_Source {
 
 
 	public function getHistItems($id, $params = array()) {
 	public function getHistItems($id, $params = array()) {
 		$ret = array();
 		$ret = array();
-		DBG::_('DBG_DS', '>1', "params", $params, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::log($params, 'array', "getHistItems({$id}, \$params)");
 		$sql_tbl = $this->_tbl . "_HIST";
 		$sql_tbl = $this->_tbl . "_HIST";
 		$sql_cols = $this->_getSqlCols();
 		$sql_cols = $this->_getSqlCols();
 		$sql_where = "t.`ID_USERS2`='{$id}'";
 		$sql_where = "t.`ID_USERS2`='{$id}'";
@@ -755,23 +755,19 @@ class Data_Source {
 			where {$sql_where}
 			where {$sql_where}
 			order by ID DESC
 			order by ID DESC
 		";
 		";
-		DBG::_('DBG_DS', '>1', "sql", $sql, __CLASS__, __FUNCTION__, __LINE__);
-		$res = $this->getDB()->query($sql);
-		while ($r = $this->getDB()->fetch($res)) {
-			$r->_author = $r->A_RECORD_UPDATE_AUTHOR;
-			$r->_created = $r->A_RECORD_UPDATE_DATE;
+		return array_map(function ($histRow) {
+			$histItem = (object)$histRow;
+			$histItem->_author = $histItem->A_RECORD_UPDATE_AUTHOR;
+			$histItem->_created = $histItem->A_RECORD_UPDATE_DATE;
 
 
-			if (!$r->_author || $r->_author == 'N/S;') {
-				$r->_author = $r->A_RECORD_CREATE_AUTHOR;
+			if (!$histItem->_author || $histItem->_author == 'N/S;') {
+				$histItem->_author = $histItem->A_RECORD_CREATE_AUTHOR;
 			}
 			}
-			if (!$r->_created || $r->_created == 'N/S;') {
-				$r->_created = $r->A_RECORD_CREATE_DATE;
+			if (!$histItem->_created || $histItem->_created == 'N/S;') {
+				$histItem->_created = $histItem->A_RECORD_CREATE_DATE;
 			}
 			}
-
-			$ret[$r->ID] = $r;
-		}
-		DBG::_('DBG_DS', '>2', "ret", $ret, __CLASS__, __FUNCTION__, __LINE__);
-		return $ret;
+			return $histItem;
+		}, DB::getPDO()->fetchAllByKey($sql, $key = 'ID'));
 	}
 	}
 
 
 	function get_total($params = array()) {// TODO: RMME
 	function get_total($params = array()) {// TODO: RMME

+ 8 - 0
SE/se-lib/FileUploader.php

@@ -842,4 +842,12 @@ class FileUploader {
 		return file_exists($dest_folder);
 		return file_exists($dest_folder);
 	}
 	}
 
 
+	public function makeDestFolder() {
+		$destFolderPath = $this->getDestLocalPath(true);
+		$folderCreated = $this->tryCreateDestFolder($destFolderPath);
+		if (!$folderCreated) throw new Exception("Nie udało się utworzyć katalogu");
+		$this->findFolder();
+		return $this->getDestFolder();
+	}
+
 }
 }

+ 3 - 1
SE/se-lib/Route/ViewTableAjax.php

@@ -1383,6 +1383,8 @@ class Route_ViewTableAjax extends RouteBase {
 	}
 	}
 	public function uploadFilesAjax($args) {
 	public function uploadFilesAjax($args) {
 		DBG::log($_FILES, 'array', "\$_FILES");
 		DBG::log($_FILES, 'array', "\$_FILES");
+		DBG::log(ini_get("upload_max_filesize"), 'array', "ini_get('upload_max_filesize')");
+		DBG::log(ini_get("post_max_size"), 'array', "ini_get('post_max_size')");
 		DBG::log($args, 'array', "\$args");
 		DBG::log($args, 'array', "\$args");
 
 
 		$namespace = V::get('namespace', '', $args, 'word');
 		$namespace = V::get('namespace', '', $args, 'word');
@@ -1445,7 +1447,7 @@ class Route_ViewTableAjax extends RouteBase {
 		$moveActions = array_map(function ($file) use ($destPath, $generateSafeFileName) {
 		$moveActions = array_map(function ($file) use ($destPath, $generateSafeFileName) {
 			$safeName = $generateSafeFileName($destPath, $file['name']);
 			$safeName = $generateSafeFileName($destPath, $file['name']);
 			return [
 			return [
-				$file['tmp_name'],
+				$file['tmp_name'], // TODO: BUG when empty? file size limit!
 				"{$destPath}/{$safeName}",
 				"{$destPath}/{$safeName}",
 				$safeName,
 				$safeName,
 			];
 			];

+ 10 - 0
SE/se-lib/V.php

@@ -561,6 +561,16 @@ EOF';
 			return V::get($fieldName, $default, $item, $type);
 			return V::get($fieldName, $default, $item, $type);
 		};
 		};
 	}
 	}
+	public static function makeSplit($splitChar, $total) {
+		return function ($string) use ($splitChar, $total) {
+			return ($total) ? explode($splitChar, $string, $total) : explode($splitChar, $string);
+		};
+	}
+	public static function makeJoin($joinChar) {
+		return function ($string) use ($joinChar) {
+			return implode($joinChar, $string);
+		};
+	}
 
 
 	public static function pickSimgleValue($items, $fieldName) {
 	public static function pickSimgleValue($items, $fieldName) {
 		return array_map(
 		return array_map(