Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -13,7 +13,11 @@ namespace IPS\gallery\extensions\core\AdvertisementLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\core\Advertisement;
|
||||
use IPS\Extensions\AdvertisementLocationsAbstract;
|
||||
use IPS\gallery\Image;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
@@ -35,7 +39,7 @@ class ImageLightbox extends AdvertisementLocationsAbstract
|
||||
*/
|
||||
public function getSettings( array $settings ): array
|
||||
{
|
||||
return array( 'locations' => array( 'ad_image_lightbox' => array() ), 'settings' => array() );
|
||||
return array( 'locations' => array( 'ad_image_lightbox' => array( 'IPS_gallery_Category' ) ), 'settings' => array() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,4 +52,28 @@ class ImageLightbox extends AdvertisementLocationsAbstract
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the advertisement can be displayed, based on settings
|
||||
*
|
||||
* @param Advertisement $advertisement
|
||||
* @param string $location
|
||||
* @return bool
|
||||
*/
|
||||
public function canShow( Advertisement $advertisement, string $location ) : bool
|
||||
{
|
||||
if( isset( $advertisement->_additional_settings['IPS_gallery_Category'] ) and is_array( $advertisement->_additional_settings['IPS_gallery_Category'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
return in_array( Image::load( Request::i()->id )->category_id, $advertisement->_additional_settings['IPS_gallery_Category'] );
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user