Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,58 +11,79 @@
|
||||
namespace IPS\core\modules\front\system;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use IPS\Content\Controller;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\DateTime;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Text\Parser;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnexpectedValueException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Embed iframe display
|
||||
*/
|
||||
class _embed extends \IPS\Content\Controller
|
||||
class embed extends Controller
|
||||
{
|
||||
/**
|
||||
* Embed iframe display
|
||||
*
|
||||
* @return void
|
||||
* @return mixed
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : mixed
|
||||
{
|
||||
/* Check cache */
|
||||
$cacheKey = 'embed_' . md5( \IPS\Request::i()->url );
|
||||
/* Check cache for the current scheme */
|
||||
$scheme = Theme::i()->getCurrentCSSScheme();
|
||||
$cacheKey = 'embed_' . md5( Request::i()->url ) . "_" . $scheme;
|
||||
try
|
||||
{
|
||||
$return = \IPS\Data\Cache::i()->getWithExpire( $cacheKey, TRUE );
|
||||
$return = Cache::i()->getWithExpire( $cacheKey, TRUE );
|
||||
}
|
||||
|
||||
/* Not in cache - fetch */
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
$return = \IPS\Text\Parser::embeddableMedia( \IPS\Http\Url::createFromString( \IPS\Request::i()->url, FALSE, TRUE ), TRUE );
|
||||
$return = Parser::embeddableMedia( Url::createFromString( Request::i()->url, FALSE, TRUE ), TRUE );
|
||||
}
|
||||
catch( \UnexpectedValueException $e )
|
||||
catch( UnexpectedValueException $e )
|
||||
{
|
||||
$return = '';
|
||||
}
|
||||
|
||||
/* And cache */
|
||||
\IPS\Data\Cache::i()->storeWithExpire( $cacheKey, $return, \IPS\DateTime::create()->add( new \DateInterval('P1D') ), TRUE );
|
||||
Cache::i()->storeWithExpire( $cacheKey, $return, DateTime::create()->add( new DateInterval('P1D') ), TRUE );
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$js = array(
|
||||
\IPS\Output::i()->js( 'js/commonEmbedHandler.js', 'core', 'interface' ),
|
||||
\IPS\Output::i()->js( 'js/externalEmbedHandler.js', 'core', 'interface' )
|
||||
Output::i()->js( 'js/commonEmbedHandler.js', 'core', 'interface' ),
|
||||
Output::i()->js( 'js/externalEmbedHandler.js', 'core', 'interface' )
|
||||
);
|
||||
|
||||
/* We don't want search engines indexing this */
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
|
||||
/* Intentionally replace the cssFiles array with a single file here, since we don't need the complete CSS framework in external embeds */
|
||||
\IPS\Output::i()->cssFiles = \IPS\Theme::i()->css( 'styles/embeds.css', 'core', 'front' );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->embedExternal( $return, $js ), 200 );
|
||||
Output::i()->cssFiles = array_merge(
|
||||
Theme::i()->css( 'styles/embeds.css', 'core', 'front' ),
|
||||
Theme::i()->css( "framework/1-2-settings.css", "core", "global" ),
|
||||
Theme::i()->css( "framework/1-3-variables.css", "core", "global" ),
|
||||
Theme::i()->css( "framework/1-4-colors.css", "core", "global" ),
|
||||
Theme::i()->css( "core.css", "core", "front" ),
|
||||
);
|
||||
|
||||
Output::i()->sendOutput( Theme::i()->getTemplate( 'global', 'core', 'front' )->embedExternal( $return, $js ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user