Google analytics

@param  array $gaConf     Google Analytics configuration

@return string
764365
public function serviceGoogleAnalyticsTrackDownloads(array $gaConf)
    {
        $jsFile = Typo3GeneralUtility::getFileAbsFileName($gaConf['trackDownloadsScript']);
        $jsfile = preg_replace('/^' . preg_quote(PATH_site, '/') . '/i', '', $jsFile);

        $ret = '<script type="text/javascript" src="' . htmlspecialchars($jsfile) . '"></script>';

        return $ret;
    }
1280624
public function main($content = '', $conf = [])
    {
        // first we have to take care of possible flexform values containing additional information
        // that is not available via DB relations. It will be added as "virtual" key to the existing data Array
        // so that you can easily get the values with TypoScript
        $this->initPluginFlexForm();
        $this->getPluginFlexFormData();

        $this->languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');

        // now we have to find the children of this grid container regardless of their column
        // so we can get them within a single DB query instead of doing a query per column
        // but we will only fetch those columns that are used by the current grid layout
        if ($this->languageAspect->getLegacyOverlayType() && $this->cObj->data['l18n_parent']) {
            $element = $this->cObj->data['l18n_parent'];
        } else {
            $element = $this->cObj->data['uid'];
        }
        $pid = $this->cObj->data['pid'];
        $layout = $this->cObj->data['tx_gridelements_backend_layout'];

        /** @var LayoutSetup $layoutSetup */
        $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class);
        $layoutSetup->init($this->cObj->data['pid'], $conf);

        $availableColumns = $layoutSetup->getLayoutColumns($layout);
        $csvColumns = ltrim(str_replace('-2,-1', '', $availableColumns['CSV']), ',');
        $this->getChildren($element, $pid, $csvColumns);

        // and we have to determine the frontend setup related to the backend layout record which is assigned to this container
        $typoScriptSetup = $layoutSetup->getTypoScriptSetup($layout);

        // we need a sorting columns array to make sure that the columns are rendered in the order
        // that they have been created in the grid wizard but still be able to get all children
        // within just one SELECT query
        $sortColumns = explode(',', $csvColumns);

        $this->renderChildrenIntoParentColumns($typoScriptSetup, $sortColumns);
        unset($children);
        unset($sortColumns);

        // if there are any columns available, we can go on with the render process
        if (!empty($this->cObj->data['tx_gridelements_view_columns'])) {
            $content = $this->renderColumnsIntoParentGrid($typoScriptSetup);
        }

        unset($availableColumns);
        unset($csvColumns);

        if (isset($typoScriptSetup['jsFooterInline']) || isset($typoScriptSetup['jsFooterInline.'])) {
            $jsFooterInline = isset($typoScriptSetup['jsFooterInline.']) ? $this->cObj->stdWrap(
                $typoScriptSetup['jsFooterInline'],
                $typoScriptSetup['jsFooterInline.']
            ) : $typoScriptSetup['jsFooterInline'];

            $this->getPageRenderer()->addJsFooterInlineCode('gridelements' . $element, $jsFooterInline);
            unset($typoScriptSetup['jsFooterInline']);
            unset($typoScriptSetup['jsFooterInline.']);
        }

        // finally we can unset the columns setup as well and apply stdWrap operations to the overall result
        // before returning the content
        unset($typoScriptSetup['columns.']);

        return !empty($typoScriptSetup) ? $this->cObj->stdWrap($content, $typoScriptSetup) : $content;
    }
1235723
public function getTextSettings()
    {
        $options = $this->util->getTranslated()->getEmptyDropdownArray() +
                $this->util->getDbLookup()->getOrganizations();

        foreach (['gaf_filter_text1', 'gaf_filter_text2', 'gaf_filter_text3', 'gaf_filter_text4'] as $i => $field) {
            $output[$field] = [
                'label'        => $this->_('Organization') . ' ' . ($i + 1),
                'multiOptions' => $options,
                'required'     => false,
                ];
        }


        return $output;
    }
838757
protected function parseLinkConf(array $conf)
    {
        $uid  = null;
        $type = null;

        // Check link type
        switch ($conf['finalTagParts']['TYPE']) {
            // ##############
            // Page URL
            // ##############
            case 'page':
                if (is_numeric($conf['conf']['parameter'])) {
                    $uid = $conf['conf']['parameter'];
                }

                $type = SitemapUtility::SITEMAP_TYPE_PAGE;
                break;

            // ##############
            // File URL
            // ##############
            case 'file':
                $fileUrl = $conf['finalTagParts']['url'];

                if ($this->checkIfFileIsWhitelisted($fileUrl)) {
                    // File will be registered from the root page
                    // to prevent duplicate urls
                    $uid  = GeneralUtility::getRootPid();
                    $type = SitemapUtility::SITEMAP_TYPE_FILE;
                }
                break;
        }

        return array($uid, $type);
    }
944956
public function getTemplateConfig($framework)
    {
        $templates = __DIR__.'/../Templates/'.$framework;

        $templates = app('config')->get('crudmaker.template_source', $templates);

        return $templates;
    }
590715
public function setup(array $conf = [])
    {
        if (empty($conf['filesystem'])) {
            throw new Exception('no filesystem configured');
        }
        $this->filesystem = $conf['filesystem'];
        $this->path       = !empty($conf['path']) ? $conf['path'] : '';
    }
1320876
public function config(string $conf)
    {
        if (!isset($this->configs[$conf])) {
            $file = $this->getDirectory()."configs/$conf.php";
            $this->configs[$conf] = require $file;
        }

        return $this->configs[$conf];
    }
523488
protected function getContentObjectVariables(array $conf = array())
    {
        // Call Parent Function to maintain core functions
        $variables = parent::getContentObjectVariables($conf);

        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
        $this->inlineHelper = $objectManager->get(InlineHelper::class);

        // Make some enhancements to data
        $data = $variables['data'];
        $this->inlineHelper->addFilesToData($data, "pages");
        $this->inlineHelper->addIrreToData($data, "pages");
        $variables['data'] = $data;

        return $variables;
    }
300607
protected function makeGoogleCloudAdapter(array $config)
    {
        $clientConfig = [
            'projectId' => $config['project_id'],
            'keyFilePath' => $config['key_file'],
        ];
        if (isset($config['auth_cache'])) {
            $clientConfig['authCache'] = $this->container->make($config['auth_cache']);
        }

        $client = $this->container->make('pubsub.gcloud.pub_sub_client', ['config' => $clientConfig]);

        $clientIdentifier = array_get($config, 'client_identifier');
        $autoCreateTopics = array_get($config, 'auto_create_topics', true);
        $autoCreateSubscriptions = array_get($config, 'auto_create_subscriptions', true);
        $backgroundBatching = array_get($config, 'background_batching', false);
        $backgroundDaemon = array_get($config, 'background_daemon', false);
        $maxMessages = array_get($config, 'max_messages', 1000);
        $returnImmediately = array_get($config, 'return_immediately', null);
        $returnImmediatelyPause = array_get($config, 'return_immediately_pause', null);

        if ($backgroundDaemon) {
            putenv('IS_BATCH_DAEMON_RUNNING=true');
        }

        return new GoogleCloudPubSubAdapter(
            $client,
            $clientIdentifier,
            $autoCreateTopics,
            $autoCreateSubscriptions,
            $backgroundBatching,
            $maxMessages,
            $returnImmediately,
            $returnImmediatelyPause
        );
    }
620197
public static function getCampaignParameters()
    {
        $return = array(
            Config::getInstance()->Tracker['campaign_var_name'],
            Config::getInstance()->Tracker['campaign_keyword_var_name'],
        );

        foreach ($return as &$list) {
            if (strpos($list, ',') !== false) {
                $list = explode(',', $list);
            } else {
                $list = array($list);
            }
            $list = array_map('trim', $list);
        }

        return $return;
    }
1207698
public function addConfig(array $conf = array())
    {
        $appConfig =& $this->config;

        // Iterate through new top-level keys
        foreach ($conf as $key => $value) {

            // If doesnt exist yet, create it
            if (!isset($appConfig[$key])) {
                $appConfig[$key] = $value;
                continue;
            }

            // If it exists, and is already an array
            if (is_array($appConfig[$key])) {
                $mergedArray = array_merge_recursive($appConfig[$key], $value);
                $appConfig[$key] = $mergedArray;
                continue;
            }

            //@TODO check for iterators?

            // Just set the value already!
            $appConfig[$key] = $value;
        }
    }
913064
public function getGoogleTracking()
    {
        /** @var \Ekyna\Bundle\GoogleBundle\Model\TrackingCode $trackingCode */
        $trackingCode = $this->settingManager->getParameter('google.tracking_code');
        if (!$this->debug && 0 < strlen($trackingCode->getPropertyId())) {
            $domain = $trackingCode->getDomain();
            if (0 === strlen($domain)) {
                $domain = 'auto';
            }
            if (in_array($trackingCode->getDomain(), ['none', 'auto'])) {
                $domain = sprintf("'%s'", $domain);
            } else {
                $domain = sprintf("{'cookieDomain': '%s'}", $domain);
            }
            return sprintf(self::GA_TRACKING_CODE, $trackingCode->getPropertyId(), $domain);
        }
        return '';
    }
514470
private function getOverviewsOfConfig($configId)
    {
        // get specified config
        $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig');
        $config = $configRepository->find($configId);

        if (!$config) {
            throw new \Exception('Unkown config ID');
        }

        // get the overviews
        return $config->getOverviews();
    }
1162774
public function main($content, $conf)
    {
        $this->ms = GeneralUtility::milliseconds();

        $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
        $this->conf = $typoScriptService->convertTypoScriptArrayToPlainArray($conf);
        $this->pi_setPiVarDefaults();

        // use pi1 locallang values, since all the frontend locallang values for
        // pi1, pi2 are set in pi1 language file
        $this->pi_loadLL('EXT:ke_search/Resources/Private/Language/locallang_searchbox.xml');

        // Configuring so caching is not expected. This value means that no cHash params are ever set.
        // We do this, because it's a USER_INT object!
        $this->pi_USER_INT_obj = 1;

        // initializes plugin configuration
        $this->init();

        if ($this->conf['resultPage'] != $GLOBALS['TSFE']->id) {
            $content = '<div id="textmessage">' . $this->pi_getLL('error_resultPage') . '</div>';
            return $this->pi_wrapInBaseClass($content);
        }

        // init template
        $this->initFluidTemplate();

        // hook for initials
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] as $_classRef) {
                $_procObj = &GeneralUtility::makeInstance($_classRef);
                $_procObj->addInitials($this);
            }
        }

        // assign isEmptySearch to fluid templates
        $this->fluidTemplateVariables['isEmptySearch'] = $this->isEmptySearch;

        // render "no results"-message, "too short words"-message and finally the result list
        $this->getSearchResults();

        // number of results
        $this->fluidTemplateVariables['numberofresults'] = $this->numberOfResults;

        // render links for sorting, fluid template variables are filled in class Sorting
        $this->renderOrdering();

        // process query time
        $queryTime = (GeneralUtility::milliseconds() - $GLOBALS['TSFE']->register['ke_search_queryStartTime']);
        $this->fluidTemplateVariables['queryTime'] = $queryTime;
        $this->fluidTemplateVariables['queryTimeText'] = sprintf($this->pi_getLL('query_time'), $queryTime);

        // render pagebrowser
        if ($GLOBALS['TSFE']->id == $this->conf['resultPage']) {
            if ($this->conf['pagebrowserOnTop'] || $this->conf['pagebrowserAtBottom']) {
                $this->renderPagebrowser();
            }
        }

        // hook: modifyResultList
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyResultList'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyResultList'] as $_classRef) {
                $_procObj = &GeneralUtility::makeInstance($_classRef);
                $_procObj->modifyResultList($this->fluidTemplateVariables, $this);
            }
        }

        // generate HTML output
        $this->resultListView->assignMultiple($this->fluidTemplateVariables);
        $htmlOutput = $this->resultListView->render();

        return $htmlOutput;
    }
635985
public function saveConfigName($configName, $configId = false)
    {
        $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveConfigName($configName, $configId);
    }
944326
private function getAnalyticsProviders()
    {
        $providers = Yii::app()->cache->get('analyticsjs_providers');

        if ($providers === false)
        {
            $analytics = new AnalyticsSettings;
            $rules = $analytics->rules();
            unset($analytics);

            // Init the array
            $providers = array();

            // Retrieve all the providors that are enabled
            $response = Yii::app()->db->createCommand('SELECT REPLACE(`key`, "analyticsjs_", "") AS `key`, value FROM `configuration` WHERE `key` LIKE "analyticsjs_%_enabled" AND value = 1')->queryAll();
            foreach ($response as $element)
            {
                $k = $element['key'];
                $provider = explode('_', str_replace("__", " " ,str_replace("___", ".", $k)));
                $provider = reset($provider);

                $sqlProvider = str_replace(" ", "__" ,str_replace(".", "___", $provider));
                $data = Yii::app()->db->createCommand('SELECT REPLACE(`key`, "analyticsjs_", "") AS `key`, value FROM `configuration` WHERE `key` LIKE "analyticsjs_' . $sqlProvider .'%" AND `key` != "analyticsjs_' . $sqlProvider .'_enabled"')->queryAll();

                foreach ($data as $el)
                {
                    $k = $el['key'];

                    $v = $el['value'];
                    $p = explode('_', str_replace("__", " " ,str_replace("___", ".", $k)));
                    if ($v !== "")
                    {
                        $thisRule = 'string';
                        foreach ($rules as $rule)
                        {
                            if (strpos($rule[0], 'analyticsjs_' . $k) !== false)
                                $thisRule = $rule[1];
                        }

                        if ($thisRule == 'boolean')
                        {
                            if ($v == "0")
                                $providers[$provider][$p[1]] = (bool)false;
                            else if ($v == "1")
                                $providers[$provider][$p[1]] = (bool)true;
                            else
                                $providers[$provider][$p[1]] = 'null';
                        }
                        else
                        {
                            if ($v == "" || $v == null || $v == "null")
                                $providers[$provider][$p[1]] = null;
                            else
                                $providers[$provider][$p[1]] = $v;
                        }

                    }
                }
            }
            
	    Yii::app()->cache->set('analyticsjs_providers', $providers);
        }
        
        return $providers;
    }
1200865
private function _getConfigArray()
    {
        $keyId = Craft::parseEnv($this->keyId);
        $secret = Craft::parseEnv($this->secret);
        $region = Craft::parseEnv($this->region);

        return self::_buildConfigArray($keyId, $secret, $region);
    }