Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -3,9 +3,9 @@
|
||||
* @brief Widget PermissionCache Class: Used for widgets whose output depends on
|
||||
* the permissions of the user viewing
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 15 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Widget StaticCache Class: Used for when output does not regularly change
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 15 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
+47
-15
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Sidebar Widget Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 15 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -205,10 +205,7 @@ abstract class _Widget
|
||||
}
|
||||
else
|
||||
{
|
||||
$bits = explode( '\\', $class );
|
||||
list( $class, $app, $location, $group ) = explode( '_', $bits[2] );
|
||||
|
||||
$params = array( 'app' => $app, 'location' => $location, 'group' => $group );
|
||||
$params = array( 'app' => $this->template[0]->template->app, 'location' => $this->template[0]->template->templateLocation, 'group' => $this->template[0]->template->templateName );
|
||||
}
|
||||
|
||||
return array_merge( $params, array( 'name' => $this->template[1] ) );
|
||||
@@ -264,7 +261,7 @@ abstract class _Widget
|
||||
public static function load( $parent, $widgetKey, $uniqueKey, $configuration=array(), $access=null, $orientation=null )
|
||||
{
|
||||
/* If our parent is not enabled, do not attempt to use this widget - both \IPS\Application and \IPS\Plugin have get__enabled() methods, so this covers both */
|
||||
if ( $parent->_enabled === FALSE )
|
||||
if ( $parent->_enabled == FALSE )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
@@ -300,11 +297,10 @@ abstract class _Widget
|
||||
* @param string $widgetDirectory Directory where PHP files are stored
|
||||
* @param string $subpackage The value to use for the subpackage in the widget file's header
|
||||
* @param string $namespace The namespace for the widget file
|
||||
* @param int $version The application/plugin's current version
|
||||
* @param int|string $appKeyOrPluginId If widget belongs to an application, it's key, or if a plugin, it's ID
|
||||
* @return string
|
||||
*/
|
||||
public static function devTable( $json, $url, $widgetDirectory, $subpackage, $namespace, $version, $appKeyOrPluginId )
|
||||
public static function devTable( $json, $url, $widgetDirectory, $subpackage, $namespace, $appKeyOrPluginId )
|
||||
{
|
||||
if ( !file_exists( $json ) )
|
||||
{
|
||||
@@ -336,7 +332,7 @@ abstract class _Widget
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'dev_widget_key', $current ? $current['dev_widget_key'] : NULL, TRUE, array( 'maxLength' => 255 ), function( $val ) use ( $current )
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'dev_widget_key', $current ? $current['dev_widget_key'] : NULL, TRUE, array( 'maxLength' => 255, 'regex' => '/^[a-z][a-z0-9]*$/i' ), function( $val ) use ( $current )
|
||||
{
|
||||
if( mb_strpos( $val, "_" ) !== FALSE )
|
||||
{
|
||||
@@ -416,7 +412,6 @@ abstract class _Widget
|
||||
"{subpackage}\n",
|
||||
'{date}',
|
||||
'{namespace}',
|
||||
'{version_long}',
|
||||
'{class}',
|
||||
'{appkey}',
|
||||
'{pluginid}'
|
||||
@@ -426,13 +421,13 @@ abstract class _Widget
|
||||
( $subpackage != 'core' ) ? ( " * @subpackage\t" . $subpackage . "\n" ) : '',
|
||||
date( 'd M Y' ),
|
||||
$namespace,
|
||||
$version,
|
||||
$values['dev_widget_class'],
|
||||
is_string( $appKeyOrPluginId ) ? $appKeyOrPluginId : NULL,
|
||||
is_numeric( $appKeyOrPluginId ) ? $appKeyOrPluginId : NULL,
|
||||
),
|
||||
file_get_contents( \IPS\ROOT_PATH . "/applications/core/data/defaults/Widget.txt" )
|
||||
) );
|
||||
chmod( $widgetFile, \IPS\IPS_FILE_PERMISSION );
|
||||
}
|
||||
|
||||
/* Add to DB */
|
||||
@@ -793,8 +788,7 @@ abstract class _Widget
|
||||
/* If we still don't have anything, go ahead and render */
|
||||
if( $this->cachedOutput === NULL )
|
||||
{
|
||||
$this->cachedOutput = $this->render();
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $this->cachedOutput );
|
||||
$this->cachedOutput = $this->render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,6 +799,10 @@ abstract class _Widget
|
||||
{
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
{
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -859,16 +857,23 @@ abstract class _Widget
|
||||
*/
|
||||
public static function emptyTrash( $seconds=86400 )
|
||||
{
|
||||
$uniqueIds = static::getUniqueIds();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_widget_trash', array( array( 'date < ?', time() - $seconds ) ) ) as $row )
|
||||
{
|
||||
$data = json_decode( $row['data'], TRUE );
|
||||
|
||||
if ( ! empty( $data['app'] ) and ! empty( $data['key'] ) and ! empty( $data['unique'] ) )
|
||||
{
|
||||
$widget = static::load( \IPS\Application::load( $data['app'] ), $data['key'], $data['unique'], isset( $data['configuration'] ) ? $data['configuration'] : NULL );
|
||||
/* Is this unique ID actually used elsewhere? Sometimes moving blocks around can add a row in the trash table with the same unique ID */
|
||||
if ( in_array( $data['unique'], $uniqueIds ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$widget = static::load( \IPS\Application::load( $data['app'] ), $data['key'], $data['unique'], isset( $data['configuration'] ) ? $data['configuration'] : NULL );
|
||||
$widget->delete();
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
@@ -878,6 +883,33 @@ abstract class _Widget
|
||||
\IPS\Db::i()->delete( 'core_widget_trash', array( 'date < ?', time() - $seconds ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unique IDs in use
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getUniqueIds()
|
||||
{
|
||||
$uniqueIds = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_widget_areas' ) as $row )
|
||||
{
|
||||
$data = json_decode( $row['widgets'], TRUE );
|
||||
|
||||
if ( count( $data ) )
|
||||
{
|
||||
foreach( $data as $widget )
|
||||
{
|
||||
if ( isset( $widget['unique'] ) )
|
||||
{
|
||||
$uniqueIds[] = $widget['unique'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $uniqueIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the where clause based on key, app, plugin
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user