From 7f67a0e0e15adb751b133ebd2a238b1e62382341 Mon Sep 17 00:00:00 2001 From: nguyenanhung Date: Wed, 6 Mar 2024 05:06:01 +0700 Subject: [PATCH] Update at 2024-03-06 05:06:01 on Mac-mini-M1--Home --- ...HungNG_CI_Base_Controller_Default_Page.php | 36 ++--- custom/HungNG_CI_Base_Hooks_Log_Query.php | 6 +- hungng/HungNG_CI_Base_Lib_ElasticSearch.php | 48 +++---- hungng/HungNG_CI_Base_Lib_Hmvc_Migration.php | 96 ++++++------- hungng/HungNG_CI_Base_Lib_MongoDB.php | 66 ++++----- hungng/HungNG_CI_Base_Queue_Worker.php | 90 ++++++------ hungng/HungNG_CI_Base_REST.php | 46 +++---- hungng/HungNG_Custom_Based_model.php | 118 ++++++++-------- hungng/HungNG_Lang.php | 14 +- hungng/HungNG_Model.php | 128 +++++++++--------- hungng/HungNG_ORM_Model.php | 82 +++++------ hungng/StatusCodes.php | 22 +-- 12 files changed, 376 insertions(+), 376 deletions(-) diff --git a/custom/HungNG_CI_Base_Controller_Default_Page.php b/custom/HungNG_CI_Base_Controller_Default_Page.php index 8be0b81..4371ff8 100644 --- a/custom/HungNG_CI_Base_Controller_Default_Page.php +++ b/custom/HungNG_CI_Base_Controller_Default_Page.php @@ -69,15 +69,15 @@ public function maintenance() public function under_construction() { $data = array( - 'title' => 'Coming Soon', - 'heading' => 'I\'ll be back', - 'site_name' => config_item('cms_site_name'), - 'site_author' => POWERED_HUNGNG_NAME . ' - ' . POWERED_HUNGNG_EMAIL, - 'url_assets' => assets_themes('Clouds'), - 'url_facebook' => site_url(), - 'url_twitter' => site_url(), + 'title' => 'Coming Soon', + 'heading' => 'I\'ll be back', + 'site_name' => config_item('cms_site_name'), + 'site_author' => POWERED_HUNGNG_NAME . ' - ' . POWERED_HUNGNG_EMAIL, + 'url_assets' => assets_themes('Clouds'), + 'url_facebook' => site_url(), + 'url_twitter' => site_url(), 'url_briefcase' => site_url(), - 'url_transit' => site_url() + 'url_transit' => site_url() ); $this->parser->parse($this->template . 'Clouds_under_construction', $data); } @@ -92,17 +92,17 @@ public function under_construction() public function error404() { $data = array( - 'name' => '404', - 'title' => 'PAGE NOT FOUND', - 'heading' => 'The page you requested was not found.', - 'site_name' => config_item('cms_site_name'), - 'site_author' => POWERED_HUNGNG_NAME . ' - ' . POWERED_HUNGNG_EMAIL, - 'site_link' => config_item('base_url'), - 'url_assets' => assets_themes('Sailors'), - 'url_facebook' => site_url(), - 'url_twitter' => site_url(), + 'name' => '404', + 'title' => 'PAGE NOT FOUND', + 'heading' => 'The page you requested was not found.', + 'site_name' => config_item('cms_site_name'), + 'site_author' => POWERED_HUNGNG_NAME . ' - ' . POWERED_HUNGNG_EMAIL, + 'site_link' => config_item('base_url'), + 'url_assets' => assets_themes('Sailors'), + 'url_facebook' => site_url(), + 'url_twitter' => site_url(), 'url_briefcase' => site_url(), - 'url_transit' => site_url() + 'url_transit' => site_url() ); $this->parser->parse($this->template . 'Sailor_error', $data); } diff --git a/custom/HungNG_CI_Base_Hooks_Log_Query.php b/custom/HungNG_CI_Base_Hooks_Log_Query.php index 1bdeb39..b8c6f62 100644 --- a/custom/HungNG_CI_Base_Hooks_Log_Query.php +++ b/custom/HungNG_CI_Base_Hooks_Log_Query.php @@ -43,7 +43,7 @@ public function __construct() } if (is_numeric($config['log_threshold'])) { - $this->_threshold = (int) $config['log_threshold']; + $this->_threshold = (int)$config['log_threshold']; } elseif (is_array($config['log_threshold'])) { $this->_threshold = 0; $this->_threshold_array = array_flip($config['log_threshold']); @@ -143,8 +143,8 @@ protected static function strlen($str) * Byte-safe substr() * * @param string $str - * @param int $start - * @param int $length + * @param int $start + * @param int $length * * @return string */ diff --git a/hungng/HungNG_CI_Base_Lib_ElasticSearch.php b/hungng/HungNG_CI_Base_Lib_ElasticSearch.php index dbf8286..81da6cd 100644 --- a/hungng/HungNG_CI_Base_Lib_ElasticSearch.php +++ b/hungng/HungNG_CI_Base_Lib_ElasticSearch.php @@ -17,7 +17,7 @@ */ class HungNG_CI_Base_Lib_ElasticSearch { - private $client; + private $client; protected $esHost; protected $CI; @@ -88,8 +88,8 @@ public function get_found_document($index, $type, $id) //db - collection - id $params = array( 'index' => $index, - 'type' => $type, - 'id' => $id + 'type' => $type, + 'id' => $id ); $results = $this->client->get($params); @@ -100,8 +100,8 @@ public function exists_document($index, $type, $id) { $params = array( 'index' => $index, - 'type' => $type, - 'id' => $id + 'type' => $type, + 'id' => $id ); return $this->client->exists($params); @@ -111,9 +111,9 @@ public function create_document($index, $type, $id, $body) { $params = array( 'index' => $index, - 'type' => $type, - 'id' => $id, - 'body' => $body + 'type' => $type, + 'id' => $id, + 'body' => $body ); return $this->client->index($params); @@ -123,9 +123,9 @@ public function update_document($index, $type, $id, $body) { $params = array( 'index' => $index, - 'type' => $type, - 'id' => $id, - 'body' => $body + 'type' => $type, + 'id' => $id, + 'body' => $body ); return $this->client->update($params); @@ -134,10 +134,10 @@ public function update_document($index, $type, $id, $body) public function delete_document($index, $type, $id) { $params = array( - 'index' => $index, - 'type' => $type, + 'index' => $index, + 'type' => $type, 'refresh' => 'wait_for', //or true - 'id' => $id + 'id' => $id ); return $this->client->delete($params); @@ -147,20 +147,20 @@ public function search_document($index, $type, $from, $size, $query, $all) { $params = array( 'index' => $index, - 'type' => $type, - 'body' => array( - 'from' => $from, - 'size' => $size, + 'type' => $type, + 'body' => array( + 'from' => $from, + 'size' => $size, 'query' => $query ) ); if ($all) { $params = array( 'index' => $index, - 'type' => $type, - 'from' => $from, - 'size' => $size, - 'body' => array('query' => $query) + 'type' => $type, + 'from' => $from, + 'size' => $size, + 'body' => array('query' => $query) ); } @@ -173,8 +173,8 @@ public function count_documents($index, $type, $query) if ($exists_index === 200) { $params = array( 'index' => $index, - 'type' => $type, - 'body' => array('query' => $query) + 'type' => $type, + 'body' => array('query' => $query) ); $response = $this->client->count($params); } else { diff --git a/hungng/HungNG_CI_Base_Lib_Hmvc_Migration.php b/hungng/HungNG_CI_Base_Lib_Hmvc_Migration.php index fe10bc4..f167c63 100644 --- a/hungng/HungNG_CI_Base_Lib_Hmvc_Migration.php +++ b/hungng/HungNG_CI_Base_Lib_Hmvc_Migration.php @@ -28,50 +28,50 @@ * * @author Michel Roca * - * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them. Memory consumption can also be displayed. - * @property CI_Calendar $calendar This class enables the creation of calendars - * @property CI_Cache $cache Caching Class - * @property CI_Cart $cart Shopping Cart Class - * @property CI_Config $config This class contains functions that enable config files to be managed - * @property CI_Controller $controller This class object is the super class that every library in CodeIgniter will be assigned to - * @property CI_DB_forge $dbforge Database Forge Class + * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them. Memory consumption can also be displayed. + * @property CI_Calendar $calendar This class enables the creation of calendars + * @property CI_Cache $cache Caching Class + * @property CI_Cart $cart Shopping Cart Class + * @property CI_Config $config This class contains functions that enable config files to be managed + * @property CI_Controller $controller This class object is the super class that every library in CodeIgniter will be assigned to + * @property CI_DB_forge $dbforge Database Forge Class * @property CI_DB_pdo_driver|CI_DB_query_builder|CI_DB_driver $db This is the platform-independent base Query Builder implementation class - * @property CI_DB_utility $dbutil Database Utility Class - * @property CI_Driver_Library $driver Driver Library Class - * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP - * @property CI_Encrypt $encrypt Provides two-way keyed encoding using Mcrypt - * @property CI_Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions - * @property CI_Exceptions $exceptions Exceptions Class - * @property CI_Form_validation $form_validation Form Validation Class - * @property CI_FTP $ftp FTP Class - * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking - * @property CI_Image_lib $image_lib Image Manipulation class - * @property CI_Input $input Pre-processes global input data for security - * @property CI_Javascript $javascript Javascript Class - * @property CI_Jquery $jquery Jquery Class - * @property CI_Lang $lang Language Class - * @property CI_Loader $load Loads framework components - * @property CI_Log $log Logging Class - * @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global - * @property CI_Model $model CodeIgniter Model Class - * @property CI_Output $output Responsible for sending final output to the browser - * @property CI_Pagination $pagination Pagination Class - * @property CI_Parser $parser Parser Class - * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data in order to help with debugging and optimization. - * @property CI_Router $router Parses URIs and determines routing - * @property CI_Security $security Security Class - * @property CI_Session $session Session Class - * @property CI_Table $table Lets you create tables manually or from database result objects, or arrays - * @property CI_Trackback $trackback Trackback Sending/Receiving Class - * @property CI_Typography $typography Typography Class - * @property CI_Unit_test $unit Simple testing class - * @property CI_Upload $upload File Uploading Class - * @property CI_URI $uri Parses URIs and determines routing - * @property CI_User_agent $agent Identifies the platform, browser, robot, or mobile device of the browsing agent - * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class - * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class - * @property CI_Zip $zip Zip Compression Class - * @property CI_Utf8 $utf8 Provides support for UTF-8 environments + * @property CI_DB_utility $dbutil Database Utility Class + * @property CI_Driver_Library $driver Driver Library Class + * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP + * @property CI_Encrypt $encrypt Provides two-way keyed encoding using Mcrypt + * @property CI_Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions + * @property CI_Exceptions $exceptions Exceptions Class + * @property CI_Form_validation $form_validation Form Validation Class + * @property CI_FTP $ftp FTP Class + * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking + * @property CI_Image_lib $image_lib Image Manipulation class + * @property CI_Input $input Pre-processes global input data for security + * @property CI_Javascript $javascript Javascript Class + * @property CI_Jquery $jquery Jquery Class + * @property CI_Lang $lang Language Class + * @property CI_Loader $load Loads framework components + * @property CI_Log $log Logging Class + * @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global + * @property CI_Model $model CodeIgniter Model Class + * @property CI_Output $output Responsible for sending final output to the browser + * @property CI_Pagination $pagination Pagination Class + * @property CI_Parser $parser Parser Class + * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data in order to help with debugging and optimization. + * @property CI_Router $router Parses URIs and determines routing + * @property CI_Security $security Security Class + * @property CI_Session $session Session Class + * @property CI_Table $table Lets you create tables manually or from database result objects, or arrays + * @property CI_Trackback $trackback Trackback Sending/Receiving Class + * @property CI_Typography $typography Typography Class + * @property CI_Unit_test $unit Simple testing class + * @property CI_Upload $upload File Uploading Class + * @property CI_URI $uri Parses URIs and determines routing + * @property CI_User_agent $agent Identifies the platform, browser, robot, or mobile device of the browsing agent + * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class + * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class + * @property CI_Zip $zip Zip Compression Class + * @property CI_Utf8 $utf8 Provides support for UTF-8 environments */ class HungNG_CI_Base_Lib_Hmvc_Migration { @@ -114,9 +114,9 @@ public function __construct($config = array()) // If the migrations table is missing, make it if (!$this->db->table_exists('migrations')) { $this->dbforge->add_field(array( - 'module' => array('type' => 'VARCHAR', 'constraint' => 20), - 'version' => array('type' => 'INT', 'constraint' => 3), - )); + 'module' => array('type' => 'VARCHAR', 'constraint' => 20), + 'version' => array('type' => 'INT', 'constraint' => 3), + )); $this->dbforge->create_table('migrations', true); @@ -360,7 +360,7 @@ public function latest() // Calculate the last migration step from existing migration // filenames and procceed to the standard version migration - return $this->version((int) substr($last_migration, 0, 3)); + return $this->version((int)substr($last_migration, 0, 3)); } // -------------------------------------------------------------------- @@ -435,7 +435,7 @@ protected function _get_version($module = '') /** * Stores the current schema version * - * @param int $migrations Migration reached + * @param int $migrations Migration reached * @param string $module * * @return bool diff --git a/hungng/HungNG_CI_Base_Lib_MongoDB.php b/hungng/HungNG_CI_Base_Lib_MongoDB.php index d1a49c8..189a97b 100644 --- a/hungng/HungNG_CI_Base_Lib_MongoDB.php +++ b/hungng/HungNG_CI_Base_Lib_MongoDB.php @@ -25,8 +25,8 @@ class HungNG_CI_Base_Lib_MongoDB { private $CI; - private $config = array(); - private $param = array(); + private $config = array(); + private $param = array(); private $activate; private $connect; private $db; @@ -41,14 +41,14 @@ class HungNG_CI_Base_Lib_MongoDB private $read_concern; private $read_preference; private $journal; - private $selects = array(); - private $updates = array(); - private $wheres = array(); - private $limit = 999999; - private $offset = 0; - private $sorts = array(); + private $selects = array(); + private $updates = array(); + private $wheres = array(); + private $limit = 999999; + private $offset = 0; + private $sorts = array(); private $return_as = 'array'; - public $benchmark = array(); + public $benchmark = array(); /** * -------------------------------------------------------------------------------- @@ -719,9 +719,9 @@ public function like($field = "", $value = "", $flags = "i", $enable_start_wildc show_error("Mongo field's value is require to like query.", 500); } - $field = (string) trim($field); + $field = (string)trim($field); $this->_w($field); - $value = (string) trim($value); + $value = (string)trim($value); $value = quotemeta($value); if ($enable_start_wildcard !== true) { $value = "^" . $value; @@ -758,8 +758,8 @@ public function get($collection = "") $options = array(); $options['projection'] = $this->selects; $options['sort'] = $this->sorts; - $options['skip'] = (int) $this->offset; - $options['limit'] = (int) $this->limit; + $options['skip'] = (int)$this->offset; + $options['limit'] = (int)$this->limit; $options['readConcern'] = $read_concern; $query = new MongoDB\Driver\Query($this->wheres, $options); @@ -773,18 +773,18 @@ public function get($collection = "") $it = new \IteratorIterator($cursor); $it->rewind(); - while ($doc = (array) $it->current()) { + while ($doc = (array)$it->current()) { if ($this->return_as == 'object') { - $returns[] = (object) $this->convert_document_id($doc); + $returns[] = (object)$this->convert_document_id($doc); } else { - $returns[] = (array) $this->convert_document_id($doc); + $returns[] = (array)$this->convert_document_id($doc); } $it->next(); } } if ($this->return_as == 'object') { - return (object) $returns; + return (object)$returns; } else { return $returns; } @@ -810,7 +810,7 @@ public function get_where($collection = "", $where = array()) { if (is_array($where) && count($where) > 0) { return $this->where($where) - ->get($collection); + ->get($collection); } else { show_error("Nothing passed to perform search or value is empty.", 500); } @@ -840,8 +840,8 @@ public function find_one($collection = "") $options = array(); $options['projection'] = $this->selects; $options['sort'] = $this->sorts; - $options['skip'] = (int) $this->offset; - $options['limit'] = (int) 1; + $options['skip'] = (int)$this->offset; + $options['limit'] = (int)1; $options['readConcern'] = $read_concern; $query = new MongoDB\Driver\Query($this->wheres, $options); @@ -855,18 +855,18 @@ public function find_one($collection = "") $it = new \IteratorIterator($cursor); $it->rewind(); - while ($doc = (array) $it->current()) { + while ($doc = (array)$it->current()) { if ($this->return_as == 'object') { - $returns[] = (object) $this->convert_document_id($doc); + $returns[] = (object)$this->convert_document_id($doc); } else { - $returns[] = (array) $this->convert_document_id($doc); + $returns[] = (array)$this->convert_document_id($doc); } $it->next(); } } if ($this->return_as == 'object') { - return (object) $returns; + return (object)$returns; } else { return $returns; } @@ -902,8 +902,8 @@ public function count($collection = "") $options = array(); $options['projection'] = array('_id' => 1); $options['sort'] = $this->sorts; - $options['skip'] = (int) $this->offset; - $options['limit'] = (int) $this->limit; + $options['skip'] = (int)$this->offset; + $options['limit'] = (int)$this->limit; $options['readConcern'] = $read_concern; $query = new MongoDB\Driver\Query($this->wheres, $options); @@ -1203,7 +1203,7 @@ public function distinct($collection = "", $field = "") $documents = $this->db->{$collection}->distinct($field, $this->wheres); $this->_clear(); if ($this->return_as == 'object') { - return (object) $documents; + return (object)$documents; } else { return $documents; } @@ -1490,7 +1490,7 @@ public function date($stamp = false) public function limit($x = 99999) { if ($x !== null && is_numeric($x) && $x >= 1) { - $this->limit = (int) $x; + $this->limit = (int)$x; } return ($this); @@ -1508,7 +1508,7 @@ public function limit($x = 99999) public function offset($x = 0) { if ($x !== null && is_numeric($x) && $x >= 1) { - $this->offset = (int) $x; + $this->offset = (int)$x; } return ($this); @@ -1559,18 +1559,18 @@ public function command($command = array()) $it = new \IteratorIterator($cursor); $it->rewind(); - while ($doc = (array) $it->current()) { + while ($doc = (array)$it->current()) { if ($this->return_as == 'object') { - $returns[] = (object) $this->convert_document_id($doc); + $returns[] = (object)$this->convert_document_id($doc); } else { - $returns[] = (array) $this->convert_document_id($doc); + $returns[] = (array)$this->convert_document_id($doc); } $it->next(); } } if ($this->return_as == 'object') { - return (object) $returns; + return (object)$returns; } else { return $returns; } diff --git a/hungng/HungNG_CI_Base_Queue_Worker.php b/hungng/HungNG_CI_Base_Queue_Worker.php index 0ebf5f8..612730b 100644 --- a/hungng/HungNG_CI_Base_Queue_Worker.php +++ b/hungng/HungNG_CI_Base_Queue_Worker.php @@ -15,50 +15,50 @@ * @author 713uk13m * @copyright 713uk13m * - * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them. Memory consumption can also be displayed. - * @property CI_Calendar $calendar This class enables the creation of calendars - * @property CI_Cache $cache Caching Class - * @property CI_Cart $cart Shopping Cart Class - * @property CI_Config $config This class contains functions that enable config files to be managed - * @property CI_Controller $controller This class object is the super class that every library in CodeIgniter will be assigned to - * @property CI_DB_forge $dbforge Database Forge Class + * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them. Memory consumption can also be displayed. + * @property CI_Calendar $calendar This class enables the creation of calendars + * @property CI_Cache $cache Caching Class + * @property CI_Cart $cart Shopping Cart Class + * @property CI_Config $config This class contains functions that enable config files to be managed + * @property CI_Controller $controller This class object is the super class that every library in CodeIgniter will be assigned to + * @property CI_DB_forge $dbforge Database Forge Class * @property CI_DB_pdo_driver|CI_DB_query_builder|CI_DB_driver $db This is the platform-independent base Query Builder implementation class - * @property CI_DB_utility $dbutil Database Utility Class - * @property CI_Driver_Library $driver Driver Library Class - * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP - * @property CI_Encrypt $encrypt Provides two-way keyed encoding using Mcrypt - * @property CI_Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions - * @property CI_Exceptions $exceptions Exceptions Class - * @property CI_Form_validation $form_validation Form Validation Class - * @property CI_FTP $ftp FTP Class - * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking - * @property CI_Image_lib $image_lib Image Manipulation class - * @property CI_Input $input Pre-processes global input data for security - * @property CI_Javascript $javascript Javascript Class - * @property CI_Jquery $jquery Jquery Class - * @property CI_Lang $lang Language Class - * @property CI_Loader $load Loads framework components - * @property CI_Log $log Logging Class - * @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global - * @property CI_Model $model CodeIgniter Model Class - * @property CI_Output $output Responsible for sending final output to the browser - * @property CI_Pagination $pagination Pagination Class - * @property CI_Parser $parser Parser Class - * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data in order to help with debugging and optimization. - * @property CI_Router $router Parses URIs and determines routing - * @property CI_Security $security Security Class - * @property CI_Session $session Session Class - * @property CI_Table $table Lets you create tables manually or from database result objects, or arrays - * @property CI_Trackback $trackback Trackback Sending/Receiving Class - * @property CI_Typography $typography Typography Class - * @property CI_Unit_test $unit Simple testing class - * @property CI_Upload $upload File Uploading Class - * @property CI_URI $uri Parses URIs and determines routing - * @property CI_User_agent $agent Identifies the platform, browser, robot, or mobile device of the browsing agent - * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class - * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class - * @property CI_Zip $zip Zip Compression Class - * @property CI_Utf8 $utf8 Provides support for UTF-8 environments + * @property CI_DB_utility $dbutil Database Utility Class + * @property CI_Driver_Library $driver Driver Library Class + * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP + * @property CI_Encrypt $encrypt Provides two-way keyed encoding using Mcrypt + * @property CI_Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions + * @property CI_Exceptions $exceptions Exceptions Class + * @property CI_Form_validation $form_validation Form Validation Class + * @property CI_FTP $ftp FTP Class + * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking + * @property CI_Image_lib $image_lib Image Manipulation class + * @property CI_Input $input Pre-processes global input data for security + * @property CI_Javascript $javascript Javascript Class + * @property CI_Jquery $jquery Jquery Class + * @property CI_Lang $lang Language Class + * @property CI_Loader $load Loads framework components + * @property CI_Log $log Logging Class + * @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global + * @property CI_Model $model CodeIgniter Model Class + * @property CI_Output $output Responsible for sending final output to the browser + * @property CI_Pagination $pagination Pagination Class + * @property CI_Parser $parser Parser Class + * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data in order to help with debugging and optimization. + * @property CI_Router $router Parses URIs and determines routing + * @property CI_Security $security Security Class + * @property CI_Session $session Session Class + * @property CI_Table $table Lets you create tables manually or from database result objects, or arrays + * @property CI_Trackback $trackback Trackback Sending/Receiving Class + * @property CI_Typography $typography Typography Class + * @property CI_Unit_test $unit Simple testing class + * @property CI_Upload $upload File Uploading Class + * @property CI_URI $uri Parses URIs and determines routing + * @property CI_User_agent $agent Identifies the platform, browser, robot, or mobile device of the browsing agent + * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class + * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class + * @property CI_Zip $zip Zip Compression Class + * @property CI_Utf8 $utf8 Provides support for UTF-8 environments */ class HungNG_CI_Base_Queue_Worker extends HungNG_CI_Base_Controllers { @@ -544,7 +544,7 @@ protected function setStaticSingle($object) public function _singleUpdateLock($lockFile) { $lockData = [ - 'pid' => getmypid(), + 'pid' => getmypid(), 'expires_at' => time() + $this->singleSleep + $this->singleLockTimeout, ]; @@ -554,7 +554,7 @@ public function _singleUpdateLock($lockFile) /** * Command for creating a worker * - * @param string $workerCmd + * @param string $workerCmd * @param integer $workerCount * * @return string Command result diff --git a/hungng/HungNG_CI_Base_REST.php b/hungng/HungNG_CI_Base_REST.php index b9b3fc3..369c45e 100644 --- a/hungng/HungNG_CI_Base_REST.php +++ b/hungng/HungNG_CI_Base_REST.php @@ -48,9 +48,9 @@ class HungNG_CI_Base_REST extends HungNG_CI_Base_Controllers * @var array RESTful API table of routes & actions */ protected $routes = array( - 'index' => 'index', - 'store' => 'store', - 'show' => 'show', + 'index' => 'index', + 'store' => 'store', + 'show' => 'show', 'update' => 'update', 'delete' => 'delete', ); @@ -61,9 +61,9 @@ class HungNG_CI_Base_REST extends HungNG_CI_Base_Controllers * @var array */ private $behaviors = array( - 'index' => null, - 'store' => null, - 'show' => null, + 'index' => null, + 'store' => null, + 'show' => null, 'update' => null, 'delete' => null, ); @@ -168,18 +168,18 @@ public function ajax($resourceID = null) /** * Output by JSON format with optinal body format * - * @deprecated 1.3.0 - * - * @param array|mixed $data Callback data body, false will remove body key - * @param bool $bodyFormat Enable body format - * @param int $statusCode HTTP Status Code - * @param string $message Callback message + * @param array|mixed $data Callback data body, false will remove body key + * @param bool $bodyFormat Enable body format + * @param int $statusCode HTTP Status Code + * @param string $message Callback message * * @return string Response body data * + * @throws \Exception * @example * json(false, true, 401, 'Login Required', 'Unauthorized'); - * @throws \Exception + * @deprecated 1.3.0 + * */ protected function json($data = array(), $bodyFormat = null, $statusCode = null, $message = null) { @@ -200,19 +200,19 @@ protected function json($data = array(), $bodyFormat = null, $statusCode = null, /** * Format Response Data * - * @deprecated 1.3.0 - * - * @param int $statusCode Callback status code - * @param string $message Callback status text - * @param array|mixed|bool $body Callback data body, false will remove body key + * @param int $statusCode Callback status code + * @param string $message Callback status text + * @param array|mixed|bool $body Callback data body, false will remove body key * * @return array Formatted array data + * @deprecated 1.3.0 + * */ protected function _format($statusCode = null, $message = null, $body = false) { $format = array(); // Status Code field is necessary - $format['code'] = ($statusCode) ? : $this->response->getStatusCode(); + $format['code'] = ($statusCode) ?: $this->response->getStatusCode(); // Message field if ($message) { $format['message'] = $message; @@ -230,9 +230,9 @@ protected function _format($statusCode = null, $message = null, $body = false) * * You could override this method for your application standard * - * @param array|mixed $data Original data - * @param int $statusCode HTTP Status Code - * @param string $message Callback message + * @param array|mixed $data Original data + * @param int $statusCode HTTP Status Code + * @param string $message Callback message * * @return array Packed data * @example @@ -276,7 +276,7 @@ protected function _defaultAction() /** * Set behavior to a action before route * - * @param String $action + * @param String $action * @param Callable $function * * @return boolean Result diff --git a/hungng/HungNG_Custom_Based_model.php b/hungng/HungNG_Custom_Based_model.php index 0c3615e..a8cc821 100644 --- a/hungng/HungNG_Custom_Based_model.php +++ b/hungng/HungNG_Custom_Based_model.php @@ -15,50 +15,50 @@ * @author 713uk13m * @copyright 713uk13m * - * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them. Memory consumption can also be displayed. - * @property CI_Calendar $calendar This class enables the creation of calendars - * @property CI_Cache $cache Caching Class - * @property CI_Cart $cart Shopping Cart Class - * @property CI_Config $config This class contains functions that enable config files to be managed - * @property CI_Controller $controller This class object is the super class that every library in CodeIgniter will be assigned to - * @property CI_DB_forge $dbforge Database Forge Class + * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them. Memory consumption can also be displayed. + * @property CI_Calendar $calendar This class enables the creation of calendars + * @property CI_Cache $cache Caching Class + * @property CI_Cart $cart Shopping Cart Class + * @property CI_Config $config This class contains functions that enable config files to be managed + * @property CI_Controller $controller This class object is the super class that every library in CodeIgniter will be assigned to + * @property CI_DB_forge $dbforge Database Forge Class * @property CI_DB_pdo_driver|CI_DB_query_builder|CI_DB_driver $db This is the platform-independent base Query Builder implementation class - * @property CI_DB_utility $dbutil Database Utility Class - * @property CI_Driver_Library $driver Driver Library Class - * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP - * @property CI_Encrypt $encrypt Provides two-way keyed encoding using Mcrypt - * @property CI_Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions - * @property CI_Exceptions $exceptions Exceptions Class - * @property CI_Form_validation $form_validation Form Validation Class - * @property CI_FTP $ftp FTP Class - * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking - * @property CI_Image_lib $image_lib Image Manipulation class - * @property CI_Input $input Pre-processes global input data for security - * @property CI_Javascript $javascript Javascript Class - * @property CI_Jquery $jquery Jquery Class - * @property CI_Lang $lang Language Class - * @property CI_Loader $load Loads framework components - * @property CI_Log $log Logging Class - * @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global - * @property CI_Model $model CodeIgniter Model Class - * @property CI_Output $output Responsible for sending final output to the browser - * @property CI_Pagination $pagination Pagination Class - * @property CI_Parser $parser Parser Class - * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data in order to help with debugging and optimization. - * @property CI_Router $router Parses URIs and determines routing - * @property CI_Security $security Security Class - * @property CI_Session $session Session Class - * @property CI_Table $table Lets you create tables manually or from database result objects, or arrays - * @property CI_Trackback $trackback Trackback Sending/Receiving Class - * @property CI_Typography $typography Typography Class - * @property CI_Unit_test $unit Simple testing class - * @property CI_Upload $upload File Uploading Class - * @property CI_URI $uri Parses URIs and determines routing - * @property CI_User_agent $agent Identifies the platform, browser, robot, or mobile device of the browsing agent - * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class - * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class - * @property CI_Zip $zip Zip Compression Class - * @property CI_Utf8 $utf8 Provides support for UTF-8 environments + * @property CI_DB_utility $dbutil Database Utility Class + * @property CI_Driver_Library $driver Driver Library Class + * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP + * @property CI_Encrypt $encrypt Provides two-way keyed encoding using Mcrypt + * @property CI_Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions + * @property CI_Exceptions $exceptions Exceptions Class + * @property CI_Form_validation $form_validation Form Validation Class + * @property CI_FTP $ftp FTP Class + * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking + * @property CI_Image_lib $image_lib Image Manipulation class + * @property CI_Input $input Pre-processes global input data for security + * @property CI_Javascript $javascript Javascript Class + * @property CI_Jquery $jquery Jquery Class + * @property CI_Lang $lang Language Class + * @property CI_Loader $load Loads framework components + * @property CI_Log $log Logging Class + * @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global + * @property CI_Model $model CodeIgniter Model Class + * @property CI_Output $output Responsible for sending final output to the browser + * @property CI_Pagination $pagination Pagination Class + * @property CI_Parser $parser Parser Class + * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data in order to help with debugging and optimization. + * @property CI_Router $router Parses URIs and determines routing + * @property CI_Security $security Security Class + * @property CI_Session $session Session Class + * @property CI_Table $table Lets you create tables manually or from database result objects, or arrays + * @property CI_Trackback $trackback Trackback Sending/Receiving Class + * @property CI_Typography $typography Typography Class + * @property CI_Unit_test $unit Simple testing class + * @property CI_Upload $upload File Uploading Class + * @property CI_URI $uri Parses URIs and determines routing + * @property CI_User_agent $agent Identifies the platform, browser, robot, or mobile device of the browsing agent + * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class + * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class + * @property CI_Zip $zip Zip Compression Class + * @property CI_Utf8 $utf8 Provides support for UTF-8 environments */ class HungNG_Custom_Based_model extends CI_Model { @@ -260,8 +260,8 @@ public function close() */ public function get_off_set($size = 500, $page = 0) { - $size = (int) $size; - $page = (int) $page; + $size = (int)$size; + $page = (int)$page; if ($page !== 0) { if ($page <= 0 || empty($page)) { $page = 1; @@ -271,7 +271,7 @@ public function get_off_set($size = 500, $page = 0) $start = $page; } - return (int) $start; + return (int)$start; } /** @@ -302,8 +302,8 @@ public function page_limit($size = 500, $page = 0) * @param int $size * @param int $page * - * @deprecated use page_limit method * @return \CI_DB_query_builder + * @deprecated use page_limit method * @author : 713uk13m * @copyright : 713uk13m * @time : 08/16/2021 30:54 @@ -380,7 +380,7 @@ public function build_order_result($order_by_field, $direction = 'desc', $field * Function build_list_id_with_parent_id - Tạo 1 list các ID, trong đó chứa các tập con phụ thuộc của ID đ * * @param array|object|mixed $allSubId - * @param string|int $parentId + * @param string|int $parentId * * @return array|string|int * @author : 713uk13m @@ -878,7 +878,7 @@ public function list_all_field_data($table) * Function check_exists * * @param string $value - * @param mixed $field + * @param mixed $field * * @return int * @author : 713uk13m @@ -1109,10 +1109,10 @@ public function get_list_distinct($field = '*') /** * Function get_data_simple_result * - * @param string $select - * @param array $wheres - * @param int $size - * @param int $page + * @param string $select + * @param array $wheres + * @param int $size + * @param int $page * @param string[] $orderBy * * @return array|array[]|object|object[] @@ -1172,8 +1172,8 @@ public function get_all_data_simple_result($options = null) * Function get_info * * @param string $value - * @param mixed $field - * @param bool $array + * @param mixed $field + * @param bool $array * * @return array|mixed|object|null * @author : 713uk13m @@ -1199,8 +1199,8 @@ public function get_info($value = '', $field = null, $array = false) * Function get_value * * @param string $value_input - * @param mixed $field_input - * @param mixed $field_output + * @param mixed $field_input + * @param mixed $field_output * * @return array|mixed|object|null * @author : 713uk13m @@ -1268,7 +1268,7 @@ public function insert_batch($data = array()) * Function update * * @param string $id - * @param array $data + * @param array $data * * @return int * @author : 713uk13m @@ -1386,7 +1386,7 @@ public function request_builder($search, $table = '') } } if ($field === 'sort') { - $sort = (strpos($value, '-') === false) ? 'DESC' : 'ASC'; + $sort = strpos($value, '-') === false ? 'DESC' : 'ASC'; $column = (strpos($value, '-') === false) ? $value : substr($value, 1); if ($this->db->field_exists($column, $tableName)) { $this->db->order_by($tableName . '.' . $column, $sort); diff --git a/hungng/HungNG_Lang.php b/hungng/HungNG_Lang.php index 9dee24d..3972052 100644 --- a/hungng/HungNG_Lang.php +++ b/hungng/HungNG_Lang.php @@ -85,11 +85,11 @@ public function __construct() /** * Load a language file, with fallback to english. * - * @param mixed $langfile Language file name - * @param string $idiom Language name (english, etc.) - * @param bool $return Whether to return the loaded array of translations - * @param bool $add_suffix Whether to add suffix to $langfile - * @param string $alt_path Alternative path to look for the language file + * @param mixed $langfile Language file name + * @param string $idiom Language name (english, etc.) + * @param bool $return Whether to return the loaded array of translations + * @param bool $add_suffix Whether to add suffix to $langfile + * @param string $alt_path Alternative path to look for the language file * * @return void|string[] Array containing translations, if $return is set to TRUE */ @@ -110,7 +110,7 @@ public function load($langfile, $idiom = '', $return = false, $add_suffix = true $langfile .= '.php'; if (empty($idiom) || !preg_match('/^[a-z_-]+$/i', $idiom)) { $config =& get_config(); - $idiom = empty($config['language']) ? $this->base_language : $config['language']; + $idiom = empty($config['language']) ? $this->base_language : $config['language']; } if ($return === false && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { return; @@ -158,7 +158,7 @@ public function load($langfile, $idiom = '', $return = false, $add_suffix = true return $lang; } $this->is_loaded[$langfile] = $idiom; - $this->language = array_merge($this->language, $lang); + $this->language = array_merge($this->language, $lang); log_message('info', 'Language file loaded: language/' . $idiom . '/' . $langfile); return true; diff --git a/hungng/HungNG_Model.php b/hungng/HungNG_Model.php index 458e7b2..91bdf2b 100644 --- a/hungng/HungNG_Model.php +++ b/hungng/HungNG_Model.php @@ -88,7 +88,7 @@ * } * } * - * @property \CI_Loader load + * @property \CI_Loader load * @property \CI_Form_validation form_validation **/ class HungNG_Model extends CI_Model @@ -125,12 +125,12 @@ class HungNG_Model extends CI_Model * @var array * Sets protected fields */ - public $protected = array(); + public $protected = array(); private $_can_be_filled = null; /** @var bool | array * Enables created_at and updated_at fields */ - protected $timestamps = true; + protected $timestamps = true; protected $timestamps_format = 'Y-m-d H:i:s'; protected $_created_at_field; protected $_updated_at_field; @@ -140,18 +140,18 @@ class HungNG_Model extends CI_Model */ protected $soft_deletes = false; /** relationships variables */ - private $_relationships = array(); - public $has_one = array(); - public $has_many = array(); - public $has_many_pivot = array(); - public $separate_subqueries = true; - private $_requested = array(); + private $_relationships = array(); + public $has_one = array(); + public $has_many = array(); + public $has_many_pivot = array(); + public $separate_subqueries = true; + private $_requested = array(); /** end relationships variables */ /*caching*/ - public $cache_driver = 'file'; - public $cache_prefix = 'mm'; - protected $_cache = array(); - public $delete_cache_on_save = false; + public $cache_driver = 'file'; + public $cache_prefix = 'mm'; + protected $_cache = array(); + public $delete_cache_on_save = false; /*pagination*/ public $next_page; public $previous_page; @@ -159,28 +159,28 @@ class HungNG_Model extends CI_Model public $pagination_delimiters; public $pagination_arrows; /* validation */ - private $validated = true; + private $validated = true; private $row_fields_to_update = array(); /** * The various callbacks available to the model. Each are * simple lists of method names (methods will be run on $this). */ - protected $before_create = array(); - protected $after_create = array(); - protected $before_update = array(); - protected $after_update = array(); - protected $before_get = array(); - protected $after_get = array(); - protected $before_delete = array(); - protected $after_delete = array(); - protected $before_soft_delete = array(); - protected $after_soft_delete = array(); + protected $before_create = array(); + protected $after_create = array(); + protected $before_update = array(); + protected $after_update = array(); + protected $before_get = array(); + protected $after_get = array(); + protected $before_delete = array(); + protected $after_delete = array(); + protected $before_soft_delete = array(); + protected $after_soft_delete = array(); protected $callback_parameters = array(); - protected $return_as = 'object'; - protected $return_as_dropdown = null; - protected $_dropdown_field = ''; - private $_trashed = 'without'; - private $_select = '*'; + protected $return_as = 'object'; + protected $return_as_dropdown = null; + protected $_dropdown_field = ''; + private $_trashed = 'without'; + private $_select = '*'; public function __construct() { @@ -193,9 +193,9 @@ public function __construct() $this->_set_timestamps(); $this->_fetch_table(); $this->pagination_delimiters = (isset($this->pagination_delimiters)) ? $this->pagination_delimiters : array('', - ''); + ''); $this->pagination_arrows = (isset($this->pagination_arrows)) ? $this->pagination_arrows : array('<', - '>'); + '>'); /* These below are implementation examples for before_create and before_update triggers. Their respective functions - add_creator() and add_updater() - can be found at the end of the model. They add user id on create and update. If you comment this out don't forget to do the same for the methods() @@ -245,7 +245,7 @@ public function _prep_before_write($data) // We make sure we have the fields that can be filled $can_fill = $this->_can_be_filled; // Let's make sure we receive an array... - $data_as_array = (is_object($data)) ? (array) $data : $data; + $data_as_array = (is_object($data)) ? (array)$data : $data; $new_data = array(); $multi = $this->is_multidimensional($data); if ($multi === false) { @@ -315,9 +315,9 @@ public function _prep_after_read($data, $multi = true) * public function from_form($rules = NULL,$additional_values = array(), $row_fields_to_update = array()) * Gets data from form, after validating it and waits for an insert() or update() method in the query chain * - * @param null $rules Gets the validation rules. If nothing is passed (NULL), will look for the + * @param null $rules Gets the validation rules. If nothing is passed (NULL), will look for the * validation rules inside the model $rules public property - * @param array $additional_values Accepts additional fields to be filled, fields that are not to be found + * @param array $additional_values Accepts additional fields to be filled, fields that are not to be found * inside * the form. The values are inserted as an array with "field_name" => * "field_value" @@ -456,9 +456,9 @@ public function is_multidimensional($array) * Updates data into table. Can receive an array or a multidimensional array depending on what kind of update we're * talking about. * - * @param array $data + * @param array $data * @param array|int $column_name_where - * @param bool $escape should the values be escaped or not - defaults to true + * @param bool $escape should the values be escaped or not - defaults to true * * @return str/array Returns id/ids of inserted rows */ @@ -553,13 +553,13 @@ public function update($data = null, $column_name_where = null, $escape = true) * public function where($field_or_array = NULL, $operator_or_value = NULL, $value = NULL, $with_or = FALSE, * $with_not = FALSE, $custom_string = FALSE) Sets a where method for the $this object * - * @param null $field_or_array - can receive a field name or an array with more wheres... + * @param null $field_or_array - can receive a field name or an array with more wheres... * @param null $operator_or_value - can receive a database operator or, if it has a field, the value to equal with - * @param null $value - a value if it received a field name and an operator - * @param bool $with_or - if set to true will create a or_where query type pr a or_like query type, + * @param null $value - a value if it received a field name and an operator + * @param bool $with_or - if set to true will create a or_where query type pr a or_like query type, * depending on the operator - * @param bool $with_not - if set to true will also add "NOT" in the where - * @param bool $custom_string - if set to true, will simply assume that $field_or_array is actually a string + * @param bool $with_not - if set to true will also add "NOT" in the where + * @param bool $custom_string - if set to true, will simply assume that $field_or_array is actually a string * and pass it to the where query * * @return $this @@ -942,7 +942,7 @@ public function count_rows($where = null) * the constructor * * @param string $request - * @param array $arguments + * @param array $arguments * * @return $this */ @@ -1027,10 +1027,10 @@ protected function join_temporary_results($data) $order = explode(' ', $element); if (sizeof($order) == 2) { $order_inside_array[] = array(trim($order[0]), - trim($order[1])); + trim($order[1])); } else { $order_inside_array[] = array(trim($order[0]), - 'desc'); + 'desc'); } } } @@ -1132,7 +1132,7 @@ protected function join_temporary_results($data) if (isset($sub_results) && !empty($sub_results)) { $subs = array(); foreach ($sub_results as $result) { - $result_array = (array) $result; + $result_array = (array)$result; $the_foreign_key = $result_array[$foreign_key]; if (isset($pivot_table)) { $the_local_key = $result_array[$pivot_local_key]; @@ -1166,10 +1166,10 @@ protected function join_temporary_results($data) $elements = explode(',', $request['parameters']['order_by']); if (sizeof($elements) == 2) { $order_by[$relation_key] = array(trim($elements[0]), - trim($elements[1])); + trim($elements[1])); } else { $order_by[$relation_key] = array(trim($elements[0]), - 'desc'); + 'desc'); } } unset($this->_requested[$requested_key]); @@ -1210,8 +1210,8 @@ private function _set_relationships() { if (empty($this->_relationships)) { $options = array('has_one', - 'has_many', - 'has_many_pivot'); + 'has_many', + 'has_many_pivot'); foreach ($options as $option) { if (isset($this->{$option}) && !empty($this->{$option})) { foreach ($this->{$option} as $key => $relation) { @@ -1270,17 +1270,17 @@ private function _set_relationships() } if ($option == 'has_many_pivot' && !isset($pivot_table)) { $tables = array($this->table, - $foreign_table); + $foreign_table); sort($tables); $pivot_table = $tables[0] . '_' . $tables[1]; } - $this->_relationships[$key] = array('relation' => $option, - 'relation_key' => $key, - 'foreign_model' => bear_str_to_lower($foreign_model), - 'foreign_model_name' => bear_str_to_lower($foreign_model_name), - 'foreign_table' => $foreign_table, - 'foreign_key' => $foreign_key, - 'local_key' => $local_key); + $this->_relationships[$key] = array('relation' => $option, + 'relation_key' => $key, + 'foreign_model' => bear_str_to_lower($foreign_model), + 'foreign_model_name' => bear_str_to_lower($foreign_model_name), + 'foreign_table' => $foreign_table, + 'foreign_key' => $foreign_key, + 'local_key' => $local_key); if ($option == 'has_many_pivot') { $this->_relationships[$key]['pivot_table'] = $pivot_table; $this->_relationships[$key]['pivot_local_key'] = $pivot_local_key; @@ -1346,8 +1346,8 @@ public function trigger($event, $data = array(), $last = true) $this->callback_parameters = explode(',', $matches[3]); } $data = call_user_func_array(array($this, - $method), array($data, - $last)); + $method), array($data, + $last)); } } @@ -1500,7 +1500,7 @@ public function as_dropdown($field = null) $this->return_as_dropdown = 'dropdown'; $this->_dropdown_field = $field; $this->_select = array($this->primary_key, - $field); + $field); return $this; } @@ -1538,7 +1538,7 @@ public function set_cache($string, $seconds = 86400) $prefix = (bear_str_length($this->cache_prefix) > 0) ? $this->cache_prefix . '_' : ''; $prefix .= $this->table . '_'; $this->_cache = array('cache_name' => $prefix . $string, - 'seconds' => $seconds); + 'seconds' => $seconds); return $this; } @@ -1759,7 +1759,7 @@ public function __call($method, $arguments) } if (method_exists($this->_database, $method)) { call_user_func_array(array($this->_database, - $method), $arguments); + $method), $arguments); return $this; } @@ -1792,7 +1792,7 @@ public function object_to_array($object) } return array_map(array($this, - 'object_to_array'), $object); + 'object_to_array'), $object); } /** @@ -1804,7 +1804,7 @@ public function object_to_array($object) */ protected function is_assoc(array $array) { - return (bool) count(array_filter(array_keys($array), 'is_string')); + return (bool)count(array_filter(array_keys($array), 'is_string')); } /** diff --git a/hungng/HungNG_ORM_Model.php b/hungng/HungNG_ORM_Model.php index f63e948..e0a630b 100644 --- a/hungng/HungNG_ORM_Model.php +++ b/hungng/HungNG_ORM_Model.php @@ -362,7 +362,7 @@ public function validate($attributes = array(), $returnData = false) if ($this->_selfCondition) { $newRules = array(); - foreach ((array) $rules as $key => $rule) { + foreach ((array)$rules as $key => $rule) { if (isset($this->_writeProperties[$rule['field']])) { // Add into new rules for updating $newRules[] = $rule; @@ -554,13 +554,13 @@ public function forceFind() * @param mixed $condition Refer to _findByCondition() for the explanation of this parameter * * @return object ActiveRecord(Model) - * @example - * $post = $this->Model->findOne(123); + * @throws \Exception * @example * // Query builder ORM usage * $this->Model->find()->where('id', 123); * $this->Model->findOne(); - * @throws \Exception + * @example + * $post = $this->Model->findOne(123); */ public static function findOne($condition) { @@ -571,8 +571,8 @@ public static function findOne($condition) } $record = $instance->_findByCondition($condition) - ->limit(1) - ->get()->row_array(); + ->limit(1) + ->get()->row_array(); // Record check if (!$record) { @@ -585,17 +585,17 @@ public static function findOne($condition) /** * Returns a list of active record models that match the specified primary key value(s) or a set of column values. * - * @param mixed $condition Refer to _findByCondition() for the explanation - * @param integer|array $limit Limit or [offset, limit] + * @param mixed $condition Refer to _findByCondition() for the explanation + * @param integer|array $limit Limit or [offset, limit] * * @return array Set of ActiveRecord(Model)s - * @example - * $post = $this->PostModel->findAll([3,21,135]); + * @throws \Exception * @example * // Query builder ORM usage * $this->Model->find()->where_in('id', [3,21,135]); * $this->Model->findAll(); - * @throws \Exception + * @example + * $post = $this->PostModel->findAll([3,21,135]); */ public static function findAll($condition = array(), $limit = null) { @@ -627,7 +627,7 @@ public static function findAll($condition = array(), $limit = null) $set = array(); // Each ActiveRecord - foreach ((array) $records as $key => $record) { + foreach ((array)$records as $key => $record) { // Check primary key setting if (!isset($record[$instance->primaryKey])) { throw new Exception("Model's primary key not set", 500); @@ -658,7 +658,7 @@ public function reset() /** * Insert a row with Timestamps feature into the associated database table using the attribute values of this record. * - * @param array $attributes + * @param array $attributes * @param boolean $runValidation Whether to perform validation (calling validate()) before manipulate the record. * * @return boolean Result @@ -684,7 +684,7 @@ public function insert($attributes, $runValidation = true) /** * Insert a batch of rows with Timestamps feature into the associated database table using the attribute values of this record. * - * @param array $data The rows to be batch inserted + * @param array $data The rows to be batch inserted * @param boolean $runValidation Whether to perform validation (calling validate()) before manipulate the record. * * @return int Number of rows inserted or FALSE on failure @@ -723,7 +723,7 @@ public function getLastInsertID($name = null) /** * Replace a row with Timestamps feature into the associated database table using the attribute values of this record. * - * @param array $attributes + * @param array $attributes * @param boolean $runValidation Whether to perform validation (calling validate()) before manipulate the record. * * @return bool Result @@ -748,8 +748,8 @@ public function replace($attributes, $runValidation = true) /** * Save the changes with Timestamps feature to the selected record(s) into the associated database table. * - * @param array $attributes - * @param mixed $condition Refer to _findByCondition() for the explanation + * @param array $attributes + * @param mixed $condition Refer to _findByCondition() for the explanation * @param boolean $runValidation Whether to perform validation (calling validate()) before manipulate the record. * * @return bool Result @@ -784,9 +784,9 @@ public function update($attributes, $condition = null, $runValidation = true) /** * Update a batch of update queries into combined query strings. * - * @param array $dataSet [[[Attributes], [Condition]], ] - * @param boolean $withAll withAll() switch helper - * @param integer $maxLenth MySQL max_allowed_packet + * @param array $dataSet [[[Attributes], [Condition]], ] + * @param boolean $withAll withAll() switch helper + * @param integer $maxLenth MySQL max_allowed_packet * @param boolean $runValidation Whether to perform validation (calling validate()) before manipulate the record. * * @return integer Count of successful query pack(s) @@ -798,7 +798,7 @@ public function update($attributes, $condition = null, $runValidation = true) */ public function batchUpdate(array $dataSet, $withAll = false, $maxLength = null, $runValidation = true) { - $maxLength = $maxLength ? : 4 * 1024 * 1024; + $maxLength = $maxLength ?: 4 * 1024 * 1024; $count = 0; $sqlBatch = ''; @@ -853,9 +853,9 @@ public function batchUpdate(array $dataSet, $withAll = false, $maxLength = null, /** * Delete the selected record(s) with Timestamps feature into the associated database table. * - * @param mixed $condition Refer to _findByCondition() for the explanation + * @param mixed $condition Refer to _findByCondition() for the explanation * @param boolean $forceDelete Force to hard delete - * @param array $attributes Extended attributes for Soft Delete Mode + * @param array $attributes Extended attributes for Soft Delete Mode * * @return bool Result * @@ -988,9 +988,7 @@ public function count($resetQuery = true) * * sharedLock locks only for write, lockForUpdate also prevents them from being selected * - * @example - * $this->Model->find()->where('id', 123) - * $result = $this->Model->lockForUpdate()->row_array(); + * @return object CI_DB_result * @example * // This transaction block will lock selected rows for next same selected * // rows with `FOR UPDATE` lock: @@ -999,7 +997,9 @@ public function count($resetQuery = true) * $result = $this->Model->lockForUpdate()->row_array(); * $this->Model->getDB()->trans_complete(); * - * @return object CI_DB_result + * @example + * $this->Model->find()->where('id', 123) + * $result = $this->Model->lockForUpdate()->row_array(); */ public function lockForUpdate() { @@ -1013,11 +1013,11 @@ public function lockForUpdate() /** * Share lock the selected rows in the table. * + * @return object CI_DB_result * @example * $this->Model->find()->where('id', 123) * $result = $this->Model->sharedLock()->row_array();' * - * @return object CI_DB_result */ public function sharedLock() { @@ -1170,7 +1170,7 @@ public function beforeSave($insert) /** * This method is called at the end of inserting or updating a active record * - * @param bool $insert whether this method called while inserting a record. + * @param bool $insert whether this method called while inserting a record. * If `false`, it means the method is called while updating a record. * @param array $changedAttributes The old values of attributes that had changed and were saved. * You can use this parameter to take action based on the changes made for example send an email @@ -1253,7 +1253,7 @@ protected function _relationship($modelName, $relationship, $foreignKey = null, $localKey = ($localKey) ? $localKey : $this->primaryKey; $query = $model->find() - ->where($foreignKey, $this->$localKey); + ->where($foreignKey, $this->$localKey); // Inject Model name into query builder for ORM relationships $query->modelName = $modelName; @@ -1335,7 +1335,7 @@ public function getTableSchema() if (!isset(self::$_ormCaches[$class])) { $columns = $this->_dbr->query("SHOW COLUMNS FROM `{$this->table}`;") - ->result_array(); + ->result_array(); // Cache self::$_ormCaches[$class] = $columns; @@ -1347,9 +1347,9 @@ public function getTableSchema() /** * Index by Key * - * @param array $array Array data for handling - * @param string $key Array key for index key - * @param bool $obj2Array Object converts to array if is object + * @param array $array Array data for handling + * @param string $key Array key for index key + * @param bool $obj2Array Object converts to array if is object * * @return array Result with indexBy Key * @example @@ -1359,14 +1359,14 @@ public function getTableSchema() public static function indexBy(array &$array, $key = null, $obj2Array = false) { // Use model instance's primary key while no given key - $key = ($key) ? : (new static())->primaryKey; + $key = ($key) ?: (new static())->primaryKey; $tmp = array(); foreach ($array as $row) { // Array & Object types support if (is_object($row) && isset($row->$key)) { - $tmp[$row->$key] = ($obj2Array) ? (array) $row : $row; + $tmp[$row->$key] = ($obj2Array) ? (array)$row : $row; } elseif (is_array($row) && isset($row[$key])) { $tmp[$row[$key]] = $row; @@ -1381,8 +1381,8 @@ public static function indexBy(array &$array, $key = null, $obj2Array = false) * * The [[$this->config->item('charset')]] will be used for encoding. * - * @param string $content the content to be encoded - * @param bool $doubleEncode whether to encode HTML entities in `$content`. If false, + * @param string $content the content to be encoded + * @param bool $doubleEncode whether to encode HTML entities in `$content`. If false, * HTML entities in `$content` will not be further encoded. * * @return string the encoded content @@ -1586,7 +1586,7 @@ protected function _addSoftDeletedCondition() } elseif (static::SOFT_DELETED && isset($this->softDeletedFalseValue)) { // Add condition $this->_dbr->where($this->_field(static::SOFT_DELETED), - $this->softDeletedFalseValue); + $this->softDeletedFalseValue); } return true; @@ -1649,7 +1649,7 @@ private function _getDefaultDB() * ORM set property * * @param string $name Property key name - * @param mixed $value + * @param mixed $value */ public function __set($name, $value) { @@ -1764,7 +1764,7 @@ public function __unset($name) * ArrayAccess offsetSet * * @param string $offset - * @param mixed $value + * @param mixed $value * * @return void */ diff --git a/hungng/StatusCodes.php b/hungng/StatusCodes.php index cce283d..47ba752 100644 --- a/hungng/StatusCodes.php +++ b/hungng/StatusCodes.php @@ -79,18 +79,18 @@ class StatusCodes * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */ public static $HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES = array( - 'must_revalidate' => false, - 'no_cache' => false, - 'no_store' => false, - 'no_transform' => false, - 'public' => false, - 'private' => false, + 'must_revalidate' => false, + 'no_cache' => false, + 'no_store' => false, + 'no_transform' => false, + 'public' => false, + 'private' => false, 'proxy_revalidate' => false, - 'max_age' => true, - 's_maxage' => true, - 'immutable' => false, - 'last_modified' => true, - 'etag' => true, + 'max_age' => true, + 's_maxage' => true, + 'immutable' => false, + 'last_modified' => true, + 'etag' => true, ); public static $statusTexts = array( 100 => 'Continue',