Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,41 +12,50 @@
|
||||
namespace IPS\cms\Records;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\cms\Fields;
|
||||
use IPS\cms\Records;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Records Model
|
||||
*/
|
||||
class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
class Revisions extends ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons = array();
|
||||
protected static array $multitons = array();
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'cms_database_revisions';
|
||||
public static ?string $databaseTable = 'cms_database_revisions';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Column
|
||||
*/
|
||||
public static $databaseColumnId = 'id';
|
||||
public static string $databaseColumnId = 'id';
|
||||
|
||||
/**
|
||||
* @brief Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'revision_';
|
||||
public static string $databasePrefix = 'revision_';
|
||||
|
||||
/**
|
||||
* @brief Unpacked data
|
||||
*/
|
||||
protected $_dataJson = NULL;
|
||||
protected ?array $_dataJson = NULL;
|
||||
|
||||
/**
|
||||
* Constructor - Create a blank object with default values
|
||||
@@ -59,7 +68,7 @@ class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
if ( $this->_new )
|
||||
{
|
||||
$this->member_id = \IPS\Member::loggedIn()->member_id;
|
||||
$this->member_id = Member::loggedIn()->member_id;
|
||||
$this->date = time();
|
||||
}
|
||||
}
|
||||
@@ -70,7 +79,7 @@ class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
* @param string $key Key of value to return
|
||||
* @return mixed
|
||||
*/
|
||||
public function get( $key )
|
||||
public function get( string $key ) : mixed
|
||||
{
|
||||
if ( $this->_dataJson === NULL )
|
||||
{
|
||||
@@ -88,14 +97,15 @@ class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Compute differences
|
||||
*
|
||||
* @param int $databaseId Database ID
|
||||
* @param \IPS\cms\Records $record Record
|
||||
* @param boolean $justChanged Get changed only
|
||||
* @param int $databaseId Database ID
|
||||
* @param Records $record Record
|
||||
* @param boolean $justChanged Get changed only
|
||||
* @return array
|
||||
*/
|
||||
public function getDiffHtmlTables( $databaseId, $record, $justChanged=FALSE )
|
||||
public function getDiffHtmlTables( int $databaseId, Records $record, bool $justChanged=FALSE ): array
|
||||
{
|
||||
$fieldsClass = 'IPS\cms\Fields' . $databaseId;
|
||||
/* @var $fieldsClass Fields */
|
||||
$customFields = $fieldsClass::data( 'view' );
|
||||
$conflicts = array();
|
||||
|
||||
@@ -104,7 +114,7 @@ class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
$key = 'field_' . $field->id;
|
||||
|
||||
if( $justChanged === FALSE OR !\IPS\Login::compareHashes( md5( $record->$key ), md5( $this->get( $key ) ) ) )
|
||||
if( $justChanged === FALSE OR !Login::compareHashes( md5( $record->$key ), md5( $this->get( $key ) ) ) )
|
||||
{
|
||||
$conflicts[] = array( 'original' => $this->get( $key ), 'current' => $record->$key, 'field' => $field );
|
||||
}
|
||||
@@ -119,9 +129,9 @@ class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
* @param string|array $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_data( $value )
|
||||
public function set_data( string|array $value ) : void
|
||||
{
|
||||
$this->_data['data'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
|
||||
$this->_data['data'] = ( is_array( $value ) ? json_encode( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +139,7 @@ class _Revisions extends \IPS\Patterns\ActiveRecord
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_data()
|
||||
public function get_data() : array
|
||||
{
|
||||
return json_decode( $this->_data['data'], TRUE );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user