mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
- Changed helper and language autoload
- Changed language config - Removed never used constants - Changed rest_language in rest config file - Adapted models that where extending FHC_Model - Adapted code to load hlp_return_object - Adapted code to use exit status codes constants
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class DB_Model extends FHC_Model
|
||||
class DB_Model extends CI_Model
|
||||
{
|
||||
// Default schema used by the models
|
||||
const DEFAULT_SCHEMA = 'public';
|
||||
@@ -64,7 +64,7 @@ class DB_Model extends FHC_Model
|
||||
public function insert($data)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate;
|
||||
@@ -100,7 +100,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ class DB_Model extends FHC_Model
|
||||
public function update($id, $data)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate;
|
||||
@@ -148,7 +148,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ class DB_Model extends FHC_Model
|
||||
public function delete($id)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK);
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
@@ -190,7 +190,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,8 +203,8 @@ class DB_Model extends FHC_Model
|
||||
public function load($id = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
@@ -232,7 +232,7 @@ class DB_Model extends FHC_Model
|
||||
public function loadWhere($where = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// Execute query
|
||||
$result = $this->db->get_where($this->dbTable, $where);
|
||||
@@ -245,7 +245,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ class DB_Model extends FHC_Model
|
||||
public function loadTree($mainTable, $sideTables, $where = null, $sideTablesAliases = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// List of tables on which it will work
|
||||
$tables = array_merge(array($mainTable), $sideTables);
|
||||
@@ -405,7 +405,7 @@ class DB_Model extends FHC_Model
|
||||
|| is_null($cond)
|
||||
|| !in_array($type, array('', 'LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER')))
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_MODEL);
|
||||
}
|
||||
|
||||
$this->db->join($joinTable, $cond, $type);
|
||||
@@ -421,7 +421,7 @@ class DB_Model extends FHC_Model
|
||||
public function addOrder($field = null, $type = 'ASC')
|
||||
{
|
||||
// Check class properties and parameters
|
||||
if (is_null($field) || !in_array($type, array('ASC', 'DESC'))) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (is_null($field) || !in_array($type, array('ASC', 'DESC'))) return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
$this->db->order_by($field, $type);
|
||||
|
||||
@@ -436,7 +436,7 @@ class DB_Model extends FHC_Model
|
||||
public function addSelect($select, $escape = true)
|
||||
{
|
||||
// Check class properties and parameters
|
||||
if (is_null($select) || $select == '') return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (is_null($select) || $select == '') return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
$this->db->select($select, $escape);
|
||||
|
||||
@@ -461,7 +461,7 @@ class DB_Model extends FHC_Model
|
||||
public function addLimit($start = null, $end = null)
|
||||
{
|
||||
// Check class properties and parameters
|
||||
if (!is_numeric($start) || (is_numeric($start) && $start <= 0)) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (!is_numeric($start) || (is_numeric($start) && $start <= 0)) return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
if (is_numeric($end) && $end > $start)
|
||||
{
|
||||
@@ -485,7 +485,7 @@ class DB_Model extends FHC_Model
|
||||
$tmpTable = trim($table);
|
||||
|
||||
// Check parameters
|
||||
if (isEmptyString($tmpTable)) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (isEmptyString($tmpTable)) return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
if (!isEmptyString($alias))
|
||||
{
|
||||
@@ -509,7 +509,7 @@ class DB_Model extends FHC_Model
|
||||
|| (is_array($fields) && count($fields) == 0)
|
||||
|| (is_string($fields) && $fields == ''))
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_MODEL);
|
||||
}
|
||||
|
||||
$this->db->group_by($fields);
|
||||
@@ -772,7 +772,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = error($this->db->error(), FHC_DB_ERROR);
|
||||
$result = error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class FHC_Controller extends CI_Controller
|
||||
$this->_controllerId = null; // set _controllerId as null by default
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
$this->load->helper('hlp_message');
|
||||
$this->load->helper('hlp_return_object');
|
||||
|
||||
// Loads helper with generic utility function
|
||||
$this->load->helper('hlp_common');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class FS_Model extends FHC_Model
|
||||
class FS_Model extends CI_Model
|
||||
{
|
||||
protected $filepath; // Path of the file
|
||||
|
||||
@@ -25,10 +25,10 @@ class FS_Model extends FHC_Model
|
||||
public function read($filename)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename)))
|
||||
{
|
||||
@@ -36,7 +36,7 @@ class FS_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,19 +49,19 @@ class FS_Model extends FHC_Model
|
||||
public function write($filename, $content)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($content)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
if (is_null($content)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
if ($this->filesystemlib->write($this->filepath, $filename, base64_decode($content)) === true)
|
||||
{
|
||||
return success(FHC_SUCCESS);
|
||||
return success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,19 +74,19 @@ class FS_Model extends FHC_Model
|
||||
public function append($filename, $content)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($content)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($content)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
if ($this->filesystemlib->append($this->filepath, $filename, base64_decode($content)) === true)
|
||||
{
|
||||
return success(FHC_SUCCESS);
|
||||
return success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,18 +99,18 @@ class FS_Model extends FHC_Model
|
||||
public function remove($filename)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
if ($this->filesystemlib->remove($this->filepath, $filename) === true)
|
||||
{
|
||||
return success(FHC_SUCCESS);
|
||||
return success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,19 +123,19 @@ class FS_Model extends FHC_Model
|
||||
public function rename($filename, $newFilename)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($newFilename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
if (is_null($newFilename)) return error(EXIT_MODEL, EXIT_ERROR);
|
||||
|
||||
if ($this->filesystemlib->rename($this->filepath, $filename, $this->filepath, $newFilename) === true)
|
||||
{
|
||||
return success(FHC_SUCCESS);
|
||||
return success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ abstract class REST_Controller extends CI_Controller {
|
||||
protected function early_checks()
|
||||
{
|
||||
// Loads helper message to manage returning messages
|
||||
$this->load->helper('hlp_message');
|
||||
$this->load->helper('hlp_return_object');
|
||||
|
||||
// Loads helper with generic utility function
|
||||
$this->load->helper('hlp_common');
|
||||
|
||||
Reference in New Issue
Block a user