<?php
/**
* Copyright (C) 2021 Rhyme Digital, LLC.
*
* @author Blair Winans <blair@rhyme.digital>
* @author Adam Fisher <adam@rhyme.digital>
* @link https://rhyme.digital
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
namespace Rhyme\WMassArtsHub\Hooks\GetPageLayout;
use Contao\ArrayUtil;
use Contao\LayoutModel;
use Contao\PageModel;
use Contao\PageRegular;
use Contao\FrontendTemplate;
use Contao\Template;
/**
* Class AddScripts
* Runs hook for \Contao\PageRegular\getPageLayout
*/
class AddScripts extends \Controller
{
/**
* Modify the page or layout object - Add in custom MRM Scripts
* @param PageModel
* @param LayoutModel
* @param PageRegular
* @return void
*/
public function run($objPage, &$objLayout, $objPageRegular)
{
if (TL_MODE === 'FE')
{
// CSS - Todo: split these up on a per-page basis
ArrayUtil::arrayInsert($GLOBALS['TL_CSS'], 0, array
(
"web/bundles/rhymewmassartshub/assets/js/vendor/mobiscroll/css/mobiscroll.jquery.min.css|static",
"web/bundles/rhymewmassartshub/assets/js/vendor/uploader/dist/css/jquery.dm-uploader.min.css|static",
"vendor/select2/select2/dist/css/select2.min.css|static",
));
$GLOBALS['TL_BODY']['historyjs'] = '<script src="https://cdnjs.cloudflare.com/ajax/libs/history.js/1.8/native.history.min.js" integrity="sha512-LW9lY12yhdxezhOnfueR/bF7GdraV3ZCZpdTTUqrq6ifCsp4wmnlBbw8/qTjs+9jqLXZn+cBVYN9rlQz52UVkA==" crossorigin="anonymous"></script>';
// Javascript - Todo: split these up on a per-page basis
ArrayUtil::arrayInsert($GLOBALS['TL_JAVASCRIPT'], 9999999, array
(
"web/bundles/rhymewmassartshub/assets/js/vendor/modernizr.min.js|static",
"web/bundles/rhymewmassartshub/assets/js/vendor/readmore/readmore.min.js|static",
"web/bundles/rhymewmassartshub/assets/js/vendor/snap-svg/dist/snap.svg-min.js|static",
"web/bundles/rhymewmassartshub/assets/js/vendor/mobiscroll/js/mobiscroll.jquery.min.js|static",
"web/bundles/rhymewmassartshub/assets/js/vendor/uploader/dist/js/jquery.dm-uploader.min.js|static",
"vendor/select2/select2/dist/js/select2.min.js|static",
"web/bundles/rhymewmassartshub/assets/js/util.js|static",
"web/bundles/rhymewmassartshub/assets/js/events.js|static",
"web/bundles/rhymewmassartshub/assets/js/analytics.js|static",
"web/bundles/rhymewmassartshub/assets/js/general.js|static",
"web/bundles/rhymewmassartshub/assets/js/modal.js|static",
"web/bundles/rhymewmassartshub/assets/js/menus.js|static",
"web/bundles/rhymewmassartshub/assets/js/forms.js|static",
"web/bundles/rhymewmassartshub/assets/js/video.js|static",
));
// Also add modal HTML
$objTemplate = new FrontendTemplate('modal_artshub_default');
$GLOBALS['TL_BODY']['modal_artshub_default'] = $objTemplate->parse();
// Add modal template - Todo: split these up on a per-page basis
$objModalTpl = new FrontendTemplate('modal_artshub_combinedlister');
$GLOBALS['TL_BODY']['modal_artshub_combinedlister'] = $objModalTpl->parse();
// Add modal template - Todo: split these up on a per-page basis
$objModalTpl = new FrontendTemplate('modal_artshub_profileItemList');
$GLOBALS['TL_BODY']['modal_artshub_profileItemList'] = $objModalTpl->parse();
//Add Photoswipe code
$objTemplatePS = new FrontendTemplate('photoswipe_default');
$GLOBALS['TL_BODY']['photoswipe'] = $objTemplatePS->parse();
}
}
}