Constructor

@param AnalyticsOverview $overview

@return array
514043
protected function getTimestamps(AnalyticsOverview &$overview)
    {
        // if yearoverview set the begin time to the first day of this year
        $profileStartDate = explode('T', $this->configHelper->getActiveProfile()['created'])[0];
        if ($overview->getUseYear()) {
            $begin_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, date('Y')));
            $begin = strtotime($profileStartDate) > strtotime($begin_date) ? date('Y-m-d', strtotime($profileStartDate)) : $begin_date;
        } else {
            // check if timespan is't more than existence of the profile; if so, use the creation time in stead of the timespan time
            $begin = strtotime($profileStartDate) > strtotime('-' . $overview->getTimespan() . ' days') ? date('Y-m-d', strtotime($profileStartDate)) : date('Y-m-d', strtotime('-' . $overview->getTimespan() . ' days'));
        }
        // set the end time
        $end = date('Y-m-d', strtotime('-' . $overview->getStartOffset() . ' days'));

        return array('begin' => $begin, 'end' => $end);
    }
374978
public static function load()
    {
        if (!extension_loaded('opencensus')) {
            trigger_error('opencensus extension required to load Eloquent integrations.', E_USER_WARNING);
            return;
        }

        // public function getModels($columns = ['*'])
        opencensus_trace_method(Builder::class, 'getModels', function ($builder) {
            return [
                'name' => 'eloquent/get',
                'attributes' => [
                    'query' => $builder->toBase()->toSql()
                ],
                'kind' => Span::KIND_CLIENT
            ];
        });

        // protected function performInsert(Builder $query)
        opencensus_trace_method(Model::class, 'performInsert', function ($model, $query) {
            return [
                'name' => 'eloquent/insert',
                'attributes' => [
                    'query' => $query->toBase()->toSql()
                ],
                'kind' => Span::KIND_CLIENT
            ];
        });

        // protected function performUpdate(Builder $query)
        opencensus_trace_method(Model::class, 'performUpdate', function ($model, $query) {
            return [
                'name' => 'eloquent/update',
                'attributes' => [
                    'query' => $query->toBase()->toSql()
                ],
                'kind' => Span::KIND_CLIENT
            ];
        });

        // public function delete()
        opencensus_trace_method(Model::class, 'delete', function ($model) {
            return [
                'name' => 'eloquent/delete',
                'kind' => Span::KIND_CLIENT
            ];
        });
    }
744296
private function generateAllOverviews()
    {
        $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig');
        $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
        $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment');
        $configs = $configRepository->findAll();

        foreach ($configs as $config) {
            // add overviews if none exist yet
            if (!count($configRepository->findDefaultOverviews($config))) {
                $overviewRepository->addOverviews($config);
            }

            // init all the segments for this config
            $segments = $config->getSegments();
            foreach ($segments as $segment) {
                $segmentRepository->initSegment($segment);
            }
        }
    }
179570
public function overviewAction()
    {
        if ($this->overviewSnippets) {
            $params = $this->_processParameters($this->overviewParameters);

            $this->addSnippets($this->overviewSnippets, $params);
        }
    }
1114190
private function _dataForView()
    {
        return [
            'collection_generator' => $this->_config['collection_generator'],
            'columns'              => $this->_getColumns(),
            'collection'           => $this->_collection,
            'paginator'            => $this->_config['paginator_presenter'],
            'table'                => $this,
            'extra'                => $this->_config['extra'],
        ];
    }
1308865
public function analytics($id)
    {
        return $this->getView()->getRequest()->is('localhost') ? null : $this->Html->scriptBlock(
            sprintf('!function(e,a,t,n,c,o,s){e.GoogleAnalyticsObject=c,e[c]=e[c]||function(){(e[c].q=e[c].q||[]).push(arguments)},e[c].l=1*new Date,o=a.createElement(t),s=a.getElementsByTagName(t)[0],o.async=1,o.src=n,s.parentNode.insertBefore(o,s)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create","%s","auto"),ga("send","pageview");', $id),
            ['block' => 'script_bottom']
        );
    }
1058540
public function compose(View $view)
    {
        $view->withAboutApp(Markdown::convertToHtml($this->config->get('setting.app_about')));
        $view->withAppAnalytics($this->config->get('setting.app_analytics'));
        $view->withAppAnalyticsGoSquared($this->config->get('setting.app_analytics_gs'));
        $view->withAppAnalyticsPiwikUrl($this->config->get('setting.app_analytics_piwik_url'));
        $view->withAppAnalyticsPiwikSiteId($this->config->get('setting.app_analytics_piwik_site_id'));
        $view->withAppBanner($this->config->get('setting.app_banner'));
        $view->withAppBannerStyleFullWidth($this->config->get('setting.style_fullwidth_header'));
        $view->withAppBannerType($this->config->get('setting.app_banner_type'));
        $view->withAppDomain($this->config->get('setting.app_domain'));
        $view->withAppGraphs($this->config->get('setting.display_graphs'));
        $view->withAppLocale($this->config->get('setting.app_locale'));
        $view->withAppStylesheet($this->config->get('setting.stylesheet'));
        $view->withAppUrl($this->config->get('app.url'));
        $view->withAppHeader($this->config->get('setting.header'));
        $view->withAppFooter($this->config->get('setting.footer'));
        $view->withAppName($this->config->get('setting.app_name'));
        $view->withShowSupport($this->config->get('setting.show_support'));
        $view->withAutomaticLocalization($this->config->get('setting.automatic_localization'));
        $view->withEnableExternalDependencies($this->config->get('setting.enable_external_dependencies'));
        $view->withShowTimezone($this->config->get('setting.show_timezone'));
        $view->withAppRefreshRate($this->config->get('setting.app_refresh_rate'));
        $view->withTimezone($this->dates->getTimezone());
        $view->withSiteTitle($this->config->get('setting.app_name'));
        $view->withFontSubset($this->config->get('langs.'.$this->config->get('app.locale').'.subset', 'latin'));
        $view->withOnlyDisruptedDays($this->config->get('setting.only_disrupted_days'));
        $view->withDashboardLink($this->config->get('setting.dashboard_login_link'));
        $view->withEnableSubscribers($this->config->get('setting.enable_subscribers'));
    }
213785
public function showMetrics()
    {
        $metrics = Metric::orderBy('order')->orderBy('id')->get();

        return View::make('dashboard.metrics.index')
            ->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'))
            ->withMetrics($metrics);
    }
301056
public static function get_all_models($enabled = false, $trained = false, $predictioncontext = false) {
        global $DB;

        $params = array();

        $sql = "SELECT am.* FROM {analytics_models} am";

        if ($enabled || $trained || $predictioncontext) {
            $conditions = [];
            if ($enabled) {
                $conditions[] = 'am.enabled = :enabled';
                $params['enabled'] = 1;
            }
            if ($trained) {
                $conditions[] = 'am.trained = :trained';
                $params['trained'] = 1;
            }
            if ($predictioncontext) {
                $conditions[] = "EXISTS (SELECT 'x'
                                           FROM {analytics_predictions} ap
                                          WHERE ap.modelid = am.id AND ap.contextid = :contextid)";
                $params['contextid'] = $predictioncontext->id;
            }
            $sql .= ' WHERE ' . implode(' AND ', $conditions);
        }
        $sql .= ' ORDER BY am.enabled DESC, am.timemodified DESC';

        $modelobjs = $DB->get_records_sql($sql, $params);

        $models = array();
        foreach ($modelobjs as $modelobj) {
            $model = new \core_analytics\model($modelobj);
            if ($model->is_available()) {
                $models[$modelobj->id] = $model;
            }
        }
        return $models;
    }
762108
protected function getCreateAnalyzerClosure()
    {
        return function ($app) {
            /** @var AnalysisStrategyInterface $strategy */
            $strategy = $app[AnalysisStrategyInterface::class];
            $analyzer = Analyzer::instance($strategy);

            $logger = $this->getLoggerIfEnabled($app);
            $logger === null ?: $analyzer->setLogger($logger);

            return $analyzer;
        };
    }
1266184
public function get_analyser($options = array()) {
        if ($this->analyser !== null) {
            return $this->analyser;
        }

        $this->init_analyser($options);

        return $this->analyser;
    }
1243897
public function overviewAction()
    {
        $roles = array();

        foreach ($this->acl->getRolePrivileges() as $role => $privileges) {
            $roles[$role][$this->_('Role')]    = $role;
            $roles[$role][$this->_('Parents')] = $privileges[\MUtil_Acl::PARENTS]   ? implode(', ', $privileges[\MUtil_Acl::PARENTS])   : null;
            $roles[$role][$this->_('Allowed')] = $privileges[\Zend_Acl::TYPE_ALLOW] ? implode(', ', $privileges[\Zend_Acl::TYPE_ALLOW]) : null;
            //$roles[$role][$this->_('Denied')]  = $privileges[\Zend_Acl::TYPE_DENY]  ? implode(', ', $privileges[\Zend_Acl::TYPE_DENY])  : null;
            $roles[$role][$this->_('Inherited')] = $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_ALLOW] ? implode(', ', $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_ALLOW]) : null;
            //$roles[$role][$this->_('Parent denied')]  = $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_DENY]  ? implode(', ', $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_DENY])  : null;
        }
        ksort($roles);

        $this->html->h2($this->_('Project role overview'));

        $this->_showTable($this->_('Roles'), $roles, true);
    }
543881
protected function expandAggregateInspectionData(InspectionInterface $inspection)
    {
        if ($inspection instanceof AggregateInspection) {
            return array_map(
                function (InspectionInterface $inspection) {
                    return [
                        static::PARAM_INSPECTION       => $inspection,
                        static::PARAM_INSPECTION_DATA  => $this->expandAggregateInspectionData($inspection),
                        static::PARAM_INSPECTION_CLASS => get_class($inspection),
                    ];
                },
                $inspection->getInspectionData()
            );
        }

        return $inspection->getInspectionData();
    }
1079561
public function variantsAction(string $assetSourceIdentifier, string $assetProxyIdentifier, string $overviewAction): void
    {
        if (!isset($this->assetSources[$assetSourceIdentifier])) {
            throw new \RuntimeException('Given asset source is not configured.', 1509632166);
        }

        $assetSource = $this->assetSources[$assetSourceIdentifier];
        $assetProxyRepository = $assetSource->getAssetProxyRepository();

        try {
            $assetProxy = $assetProxyRepository->getAssetProxy($assetProxyIdentifier);
            $asset = $this->persistenceManager->getObjectByIdentifier($assetProxy->getLocalAssetIdentifier(), Asset::class);

            /** @var VariantSupportInterface $originalAsset */
            $originalAsset = ($asset instanceof AssetVariantInterface ? $asset->getOriginalAsset() : $asset);

            $variantInformation = array_map(static function (AssetVariantInterface $imageVariant) {
                return (new ImageMapper($imageVariant))->getMappingResult();
            }, $originalAsset->getVariants());

            $this->view->assignMultiple([
                'assetProxy' => $assetProxy,
                'asset' => $originalAsset,
                'assetSource' => $assetSource,
                'imageProfiles' => $this->imageProfilesConfiguration,
                'overviewAction' => $overviewAction,
                'originalInformation' => (new ImageMapper($asset))->getMappingResult(),
                'variantsInformation' => $variantInformation
            ]);
        } catch (AssetNotFoundExceptionInterface $e) {
            $this->throwStatus(404, 'Original asset not found');
        } catch (AssetSourceConnectionExceptionInterface $e) {
            $this->view->assign('connectionError', $e);
        }
    }
785771
private function loadAdvisorsList(AspectContainer $aspectContainer): array
    {
        /** @var AspectLoader $aspectLoader */
        $aspectLoader   = $aspectContainer->get('aspect.cached.loader');
        $aspects        = $aspectLoader->getUnloadedAspects();
        foreach ($aspects as $aspect) {
            $aspectLoader->loadAndRegister($aspect);
        }
        $advisors = $aspectContainer->getByTag('advisor');

        return $advisors;
    }
1262082
public function getRowEvolutionGraph($graphType = false, $metrics = false)
    {
        // set up the view data table
        $view = Factory::build($graphType ? : $this->graphType, $this->apiMethod,
            $controllerAction = 'CoreHome.getRowEvolutionGraph', $forceDefault = true);
        $view->setDataTable($this->dataTable);

        if (!empty($this->graphMetrics)) { // In row Evolution popover, this is empty
            $view->config->columns_to_display = array_keys($metrics ? : $this->graphMetrics);
        }

        $view->requestConfig->request_parameters_to_modify['label'] = '';
        $view->config->show_goals = false;
        $view->config->show_search = false;
        $view->config->show_all_views_icons = false;
        $view->config->show_related_reports  = false;
        $view->config->show_series_picker    = false;
        $view->config->show_footer_message   = false;

        foreach ($this->availableMetrics as $metric => $metadata) {
            $view->config->translations[$metric] = $metadata['name'];
        }

        $view->config->external_series_toggle = 'RowEvolutionSeriesToggle';
        $view->config->external_series_toggle_show_all = $this->initiallyShowAllMetrics;

        return $view;
    }
1302055
public function buildSummary(array $orders = []) {
    if (empty($orders)) {
      return [
        '#markup' => $this->t('You have no orders'),
      ];
    }

    $build = [];

    foreach ($orders as $order) {
      $build[] = [
        '#theme' => 'user_order',
        '#order' => $order,
        '#order_details_path' => Url::fromRoute('acm_customer.view_page', [
          'page' => $this->getPageId(),
          'action' => 'edit',
          'id' => $order['order_id'],
        ])->toString(),
      ];
    }

    return $build;
  }