Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+25 -20
View File
@@ -12,43 +12,48 @@
namespace IPS\forums\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use IPS\forums\Topic;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Item;
use IPS\Theme;
use IPS\Widget;
use function defined;
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;
}
/**
* poll Widget
*/
class _poll extends \IPS\Widget
class poll extends Widget
{
/**
* @brief Widget Key
*/
public $key = 'poll';
public string $key = 'poll';
/**
* @brief App
*/
public $app = 'forums';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'forums';
/**
* Specify widget configuration
*
* @param null|\IPS\Helpers\Form $form Form object
* @return null|\IPS\Helpers\Form
* @param null|Form $form Form object
* @return Form
*/
public function configuration( &$form=null )
public function configuration( Form &$form=null ): Form
{
$form = parent::configuration( $form );
$form->add( new \IPS\Helpers\Form\Item( 'widget_poll_tid', ( isset( $this->configuration['widget_poll_tid'] ) ? $this->configuration['widget_poll_tid'] : NULL ), TRUE, array(
$form->add( new Item( 'widget_poll_tid', ( $this->configuration['widget_poll_tid'] ?? NULL ), TRUE, array(
'class' => '\IPS\forums\Topic',
'maxItems' => 1,
'where' => array( array( '(poll_state<>0 AND poll_state IS NOT NULL)' ) )
@@ -60,7 +65,7 @@ class _poll extends \IPS\Widget
if ( $poll === NULL )
{
/* poll_state is set to something other than 0 or NULL, but the poll doesn't exist, so let the user know. */
throw new \DomainException( 'poll_widget_no_poll' );
throw new DomainException( 'poll_widget_no_poll' );
}
}
} ) );
@@ -74,7 +79,7 @@ class _poll extends \IPS\Widget
* @param array $values Values from form
* @return array
*/
public function preConfig( $values )
public function preConfig( array $values ): array
{
$item = array_pop( $values['widget_poll_tid'] );
$values['widget_poll_tid'] = $item->tid;
@@ -86,7 +91,7 @@ class _poll extends \IPS\Widget
*
* @return string
*/
public function render()
public function render(): string
{
if ( empty( $this->configuration['widget_poll_tid'] ) )
{
@@ -95,12 +100,12 @@ class _poll extends \IPS\Widget
try
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( $this->configuration['widget_poll_tid'] );
$topic = Topic::loadAndCheckPerms( $this->configuration['widget_poll_tid'] );
$poll = $topic->getPoll();
if ( $poll )
{
$poll->displayTemplate = array( \IPS\Theme::i()->getTemplate( 'widgets', 'forums', 'front' ), 'pollWidget' );
$poll->displayTemplate = array( Theme::i()->getTemplate( 'widgets', 'forums', 'front' ), 'pollWidget' );
$poll->url = $topic->url();
return $this->output( $topic, $poll );
@@ -110,7 +115,7 @@ class _poll extends \IPS\Widget
return '';
}
}
catch( \Exception $ex )
catch( Exception $ex )
{
return '';
}