Source of file GoogleDfpController.php
Size: 1,834 Bytes - Last Modified: 2021-12-24T06:48:06+00:00
/var/www/docs.ssmods.com/process/src/src/GoogleDfpController.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | <?php namespace Fractas\GoogleDfp; use SilverStripe\Core\Extension; use SilverStripe\View\Requirements; use Fractas\GoogleDfp\GoogleDfpSlotHelper; /** * Google DFP Controller class. * * * @package SilverStripe-Google-DFP * @copyright 2017 Fractas Labs * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/fractaslabs/silverstripe-google-dfp */ class GoogleDfpController extends Extension { /** * Renders a banners HTML to template using $id as identifier * * * @param $id */ public function GoogleDfpSlotByID($id = false) { $data = GoogleDfpSlotHelper::slot_by_id($id); return $data ? $data->renderWith('GoogleDfpSlot') : false; } /** * Renders a banners HTML to template using $alias as identifier * * * @param $alias */ public function GoogleDfpSlotByAlias($alias = false) { $data = GoogleDfpSlotHelper::slot_by_alias($alias); return $data ? $data->renderWith('GoogleDfpSlot') : false; } /** * Fills a javascript with data array needed to initialize a banner show * */ public function GoogleDfpSlotList() { return GoogleDfpSlotHelper::slot_list()->filter(array('Layout' => Controller::curr()->ClassName)); } /** * Check method if is module enabled, used in GoogleDfpSlot.ss * * @return bool */ public function GoogleDfpEnabled() { return GoogleDfpSlotHelper::enabled(); } /** * Renders a javascript needed to initialize a banner show * */ public function onAfterInit() { if (GoogleDfpSlotHelper::enabled() !== false) { Requirements::insertHeadTags($this->owner->renderWith('GoogleDfpHead'), 'GoogleDfpHead'); } } } |