Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+22 -2
View File
@@ -55,7 +55,7 @@ class advertisements extends Widget
$form = parent::configuration( $form );
$ads = [];
foreach( Db::i()->select( 'ad_id', 'core_advertisements', [ 'ad_type!=?', Advertisement::AD_EMAIL ] ) as $adId )
foreach( Db::i()->select( 'ad_id', 'core_advertisements', [ 'ad_type!=? and ad_active=?', Advertisement::AD_EMAIL, 1 ] ) as $adId )
{
$ads[$adId] = 'core_advert_' . $adId;
}
@@ -104,6 +104,20 @@ class advertisements extends Widget
return $values;
}
/**
* Return any extra classes that should be added to the widget wrapper
* Placeholder method in case an override is necessary for individual widgets.
*
* @return array
*/
public function getWrapperClasses() : array
{
return [
'ipsWidget--transparent'
];
}
/**
* Render a widget
*
@@ -125,6 +139,12 @@ class advertisements extends Widget
}
}
return $this->output( Advertisement::loadForWidget( array(), ( count( $ids ) ? $ids : null ), ( $this->configuration['widget_ad_limit'] ?? null ) ) );
$ads = Advertisement::loadForWidget( array(), ( count( $ids ) ? $ids : null ) );
if( $ads === null )
{
return "";
}
return $this->output( $ads, ( $this->configuration['widget_ad_limit'] ?? null ) );
}
}
@@ -119,6 +119,20 @@ class relatedContent extends PermissionCache implements Customizable
return $form;
}
/**
* Can this widget be used on this page?
*
* @param string $app
* @param string $module
* @param string $controller
* @return bool
*/
public function isExecutableByPage( string $app, string $module, string $controller ) : bool
{
$class = 'IPS\\' . $app . '\\modules\\front\\' . $module . '\\' . $controller;
return is_subclass_of( $class, Controller::class );
}
/**
* Render a widget
+20 -7
View File
@@ -25,6 +25,7 @@ use Throwable;
use UnderflowException;
use IPS\Widget\StaticCache;
use IPS\Widget;
use IPS\cms\Databases\Dispatcher as DatabaseDispatcher;
use function defined;
/* To prevent PHP errors (extending class does not exist) revealing path */
@@ -103,12 +104,8 @@ class tableofcontents extends StaticCache
{
parent::__construct( $uniqueKey, $configuration, $access, $orientation, $layout );
$data = Dispatcher::i()->getLocationData();
if ( @$data['app'] === 'cms' and @$data['module'] === 'pages' and @$data['controller'] === 'page' and $page = page::getPage() )
{
@$data['id'] = $page->id;
}
$location = static::getLocationHash( @$data['app'], @$data['module'], @$data['controller'], @$data['id'] );
$data = $this->getLocationData();
$location = static::getLocationHash( @$data['app'], @$data['module'], @$data['controller'], @$data['key'] );
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( Member::loggedIn()->language()->id . "_" . $orientation) . ( $this->canEdit() ? '_canEdit_' : '_cannotEdit_' ) . '_' . $location;
}
@@ -231,7 +228,23 @@ class tableofcontents extends StaticCache
}
}
$data = Dispatcher::i()->getLocationData();
if ( $data['app'] === 'cms' and $data['module'] === 'pages' and $data['controller'] === 'page' and $page = page::getPage() )
$recordId = null;
try
{
if ( DatabaseDispatcher::i() instanceof DatabaseDispatcher and DatabaseDispatcher::i()->recordId and DatabaseDispatcher::i()->databaseId )
{
$recordId = DatabaseDispatcher::i()->recordId;
}
}
catch ( OutOfRangeException | OutOfBoundsException ){}
if ( $recordId )
{
$data['key'] = "IPS\\cms\\Records" . DatabaseDispatcher::i()->databaseId . '_' . $recordId;
}
else if ( $data['app'] === 'cms' and $data['module'] === 'pages' and $data['controller'] === 'page' and $page = page::getPage() )
{
$data['key'] = (string) $page->id;
}
+34 -43
View File
@@ -11,6 +11,10 @@
namespace IPS\core\widgets;
use IPS\Content\Comment;
use IPS\Content\Search\ContentFilter;
use IPS\Content\Search\Query;
use IPS\Content\Search\Result\Content as SearchResultContent;
use IPS\Content\Tag;
use IPS\Db;
use IPS\Helpers\Form;
@@ -18,7 +22,6 @@ use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Text;
use IPS\Member;
use IPS\Settings;
use IPS\Widget\Customizable;
use IPS\Widget\PermissionCache;
use OutOfRangeException;
@@ -74,26 +77,6 @@ class tags extends PermissionCache implements Customizable
return $form;
}
/**
* @return string[]
*/
public function getSupportedLayouts() : array
{
$layouts = parent::getSupportedLayouts();
/* Remove support for carousels; if we have tabs, there is way too much going on here */
$return = [];
foreach( $layouts as $k => $v )
{
if( !str_ends_with( $v, '-carousel' ) )
{
$return[] = $v;
}
}
return $return;
}
/**
* Render a widget
*
@@ -103,7 +86,12 @@ class tags extends PermissionCache implements Customizable
{
$data = [];
$limit = $this->configuration['tag_block_limit'] ?? 5;
$contentTypes = Tag::getTaggableContentTypes();
$filters = [];
foreach( Tag::getTaggableContentTypes() as $type )
{
$filters[] = ContentFilter::init( $type );
}
foreach( ( $this->configuration['tag_block_tags'] ?? [] ) as $tag )
{
@@ -116,27 +104,30 @@ class tags extends PermissionCache implements Customizable
continue;
}
$items = [];
foreach( Db::i()->select( '*', [ 'core_tags', 't' ], [
[ 't.tag_text=?', $tag->text ],
[ 'p.tag_perm_visible=?', 1 ],
[ '(p.tag_perm_text=? or ' . Db::i()->findInSet( 'p.tag_perm_text', Member::loggedIn()->groups ) . ')', '*' ]
], 't.tag_added desc', $limit )
->join( [ 'core_tags_perms', 'p' ], 't.tag_aai_lookup=p.tag_perm_aai_lookup and t.tag_aap_lookup=p.tag_perm_aap_lookup' ) as $row )
{
foreach( $contentTypes as $k => $itemClass )
{
if( $itemClass::$application == $row['tag_meta_app'] and $itemClass::$module == $row['tag_meta_area'] )
{
try
{
$items[] = $itemClass::load( $row['tag_meta_id'] );
}
catch( OutOfRangeException ){}
break;
}
}
}
$query = Query::init();
$query->setLimit( $limit );
$query->filterByContent( $filters );
$query->setOrder( Query::ORDER_NEWEST_CREATED );
$items = [];
foreach( $query->search( null, [ $tag->text ], Query::TAGS_MATCH_ITEMS_ONLY ) as $result )
{
/* @var SearchResultContent $result */
$result = $result->asArray();
try
{
$itemClass = $result['indexData']['index_class'];
$id = $result['indexData']['index_object_id'];
if( is_subclass_of( $itemClass, Comment::class ) )
{
$itemClass = $itemClass::$itemClass;
$id = $result['indexData']['index_item_id'];
}
$items[] = $itemClass::load( $id );
}
catch( OutOfRangeException ){}
}
if( count( $items ) )
{