Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+51
-28
@@ -76,7 +76,12 @@ class _Reaction extends \IPS\Node\Model
|
||||
* @brief [Node] Enabled/Disabled Column
|
||||
*/
|
||||
public static $databaseColumnEnabledDisabled = 'enabled';
|
||||
|
||||
|
||||
/**
|
||||
* @brief Icon Cache
|
||||
*/
|
||||
public static $icons = array();
|
||||
|
||||
/**
|
||||
* Form
|
||||
*
|
||||
@@ -131,7 +136,12 @@ class _Reaction extends \IPS\Node\Model
|
||||
*/
|
||||
public function get__icon()
|
||||
{
|
||||
return \IPS\File::get( 'core_Reaction', $this->_data['icon'] );
|
||||
if ( !isset( static::$icons[ $this->id ] ) )
|
||||
{
|
||||
static::$icons[ $this->id ] = \IPS\File::get( 'core_Reaction', $this->_data['icon'] );
|
||||
}
|
||||
|
||||
return static::$icons[ $this->id ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,13 +177,20 @@ class _Reaction extends \IPS\Node\Model
|
||||
{
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
$return = array();
|
||||
$cacheKey = md5( get_called_class() . $permissionCheck );
|
||||
|
||||
if( isset( static::$rootsResult[ $cacheKey ] ) )
|
||||
{
|
||||
return static::$rootsResult[ $cacheKey ];
|
||||
}
|
||||
|
||||
static::$rootsResult[ $cacheKey ] = array();
|
||||
foreach( static::reactionStore() AS $reaction )
|
||||
{
|
||||
$return[ $reaction['reaction_id'] ] = static::constructFromData( $reaction );
|
||||
static::$rootsResult[ $cacheKey ][ $reaction['reaction_id'] ] = static::constructFromData( $reaction );
|
||||
}
|
||||
|
||||
return $return;
|
||||
return static::$rootsResult[ $cacheKey ];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,19 +213,7 @@ class _Reaction extends \IPS\Node\Model
|
||||
|
||||
return parent::get__enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Enabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set__enabled( $enabled )
|
||||
{
|
||||
parent::set__enabled( $enabled );
|
||||
|
||||
unset( \IPS\Data\Store::i()->reactions );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reaction Store
|
||||
*
|
||||
@@ -231,16 +236,7 @@ class _Reaction extends \IPS\Node\Model
|
||||
*/
|
||||
public static function isLikeMode()
|
||||
{
|
||||
$i = 0;
|
||||
foreach( static::roots() AS $row )
|
||||
{
|
||||
if ( $row->_enabled !== FALSE )
|
||||
{
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return ( $i == 1 );
|
||||
return (bool) \IPS\Settings::i()->reaction_is_likemode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,6 +278,7 @@ class _Reaction extends \IPS\Node\Model
|
||||
parent::delete();
|
||||
|
||||
unset( \IPS\Data\Store::i()->reactions );
|
||||
static::updateLikeModeSetting();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,6 +291,7 @@ class _Reaction extends \IPS\Node\Model
|
||||
parent::save();
|
||||
|
||||
unset( \IPS\Data\Store::i()->reactions );
|
||||
static::updateLikeModeSetting();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -331,4 +329,29 @@ class _Reaction extends \IPS\Node\Model
|
||||
}
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the setting which stores if likemode is enabled ( = only one reaction is being used )
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function updateLikeModeSetting()
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'reaction_is_likemode' => intval( count( static::enabledReactions() ) == 1 ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return enabled reactions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function enabledReactions()
|
||||
{
|
||||
return array_filter(
|
||||
static::roots(),
|
||||
function( $reaction ){
|
||||
return ( $reaction->_enabled !== FALSE );
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user