Get visible grouped components.

@param bool $displayMetrics

@return \Illuminate\Support\Collection|void
163759
protected function getVisibleMetrics($displayMetrics)
    {
        if (!$displayMetrics) {
            return;
        }

        $metrics = Metric::displayable();

        if (!$this->guard->check()) {
            $metrics->visible();
        }

        return $metrics->orderBy('order')->orderBy('id')->get();
    }
1008727
public function index()
    {
        $groups = ComponentGroup::query();
        if (!$this->guard->check()) {
            $groups = ComponentGroup::visible();
        }

        $groups->search(Binput::except(['sort', 'order', 'per_page']));

        if ($sortBy = Binput::get('sort')) {
            $direction = Binput::get('order', 'asc');

            $groups->sort($sortBy, $direction);
        }

        $groups = $groups->paginate(Binput::get('per_page', 20));

        return $this->paginator($groups, Request::instance());
    }
736763
public function get_viewable_roles() {
        if ($this->_visibleroles === null) {
            $this->_visibleroles = get_viewable_roles($this->context);
        }
        return $this->_visibleroles;
    }
1079650
public function getGroups()
    {
        if ($this->groups === null) {
            $this->setGroups($this->groupRepository->getAllByRevision($this));
        }
        return $this->groups;
    }
1080354
@Override
    protected void collectMetrics(final Metrics metrics) {
        for (final JvmMetricsCollector collector : _collectorsEnabled) {
            collector.collect(metrics, _managementFactory);
        }
    }
227562
public function postAddComponentGroup()
    {
        try {
            $group = execute(new CreateComponentGroupCommand(
                Binput::get('name'),
                Binput::get('order', 0),
                Binput::get('collapsed'),
                Binput::get('visible')
            ));
        } catch (ValidationException $e) {
            return cachet_redirect('dashboard.components.groups.create')
                ->withInput(Binput::all())
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
                ->withErrors($e->getMessageBag());
        }

        return cachet_redirect('dashboard.components.groups')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
    }
975658
public function setDisplayCategories($displayCategories) {
		$this->displayCategories = [];

		foreach ($displayCategories as $displayCategory) {
			$this->addDisplayCategory($displayCategory);
		}

		return $this;
	}
927144
public function compose(View $view)
    {
        $componentGroups = $this->getVisibleGroupedComponents();
        $ungroupedComponents = Component::ungrouped()->orderBy('status', 'desc')->get();

        $view->withComponentGroups($componentGroups)
            ->withUngroupedComponents($ungroupedComponents);
    }
1242794
protected function get_components() {
		$components = ( new \ReflectionClass( $this ) )->getProperties();
		$components = array_map(
		/**
		 * @param \ReflectionProperty $property
		 *
		 * @return string
		 */
			function ( $property ) {
				return $property->name;
			}, $components );
		$components = array_filter( $components, [ $this, 'is_component' ] );
		$components = array_map(
		/**
		 * @param \ReflectionProperty $component
		 *
		 * @return Component
		 */
			function ( $component ) {
				$getter = "get_{$component}";

				return $this->$getter();
			}, $components );

		return $components;
	}
1261393
protected function getSRGBComponents($RGBComponents)
	    {
	        return [
	            $this->getSRGBComponent($RGBComponents[0]),
	            $this->getSRGBComponent($RGBComponents[1]),
	            $this->getSRGBComponent($RGBComponents[2])
	        ];
	    }
217327
public function getValidDisplayCount(
        $items,
        $validCounts
    ) {
        sort($validCounts);

        $displayCount = 0;

        /**
         * @var mixed $key
         * @var \Rcm\Entity\DisplayInterface $item
         */
        foreach ($items as $key => $item) {
            if ($item->canDisplay()) {
                $displayCount++;
            }
        }

        if (in_array($displayCount, $validCounts)) {
            return $displayCount;
        }

        $min = $validCounts[0];

        if ($displayCount < $min) {
            return $min;
        }

        $max = $this->getRequiredCount($validCounts);

        if ($displayCount > $max) {
            return $max;
        }

        // figure out where it is in the list
        $prevCount = $min;

        foreach ($validCounts as $currCount) {
            if ($displayCount > $prevCount && $displayCount < $currCount) {
                return $prevCount;
            }

            $prevCount = $currCount;
        }

        // fall back - not reachable
        return $displayCount;
    }
674820
protected function getMetricsToggles()
    {
        $i = 0;
        $metrics = array();
        foreach ($this->availableMetrics as $metric => $metricData) {
            $unit = Metrics::getUnit($metric, $this->idSite);
            $change = isset($metricData['change']) ? $metricData['change'] : false;

            list($first, $last) = $this->getFirstAndLastDataPointsForMetric($metric);
            $fractionDigits = max($this->getFractionDigits($first), $this->getFractionDigits($last));

            $details = Piwik::translate('RowEvolution_MetricBetweenText', array(
                NumberFormatter::getInstance()->format($first, $fractionDigits, $fractionDigits) . $unit,
                NumberFormatter::getInstance()->format($last, $fractionDigits, $fractionDigits) . $unit,
            ));

            if ($change !== false) {
                $lowerIsBetter = Metrics::isLowerValueBetter($metric);
                if (substr($change, 0, 1) == '+') {
                    $changeClass = $lowerIsBetter ? 'bad' : 'good';
                    $changeImage = $lowerIsBetter ? 'arrow_up_red' : 'arrow_up';
                } else if (substr($change, 0, 1) == '-') {
                    $changeClass = $lowerIsBetter ? 'good' : 'bad';
                    $changeImage = $lowerIsBetter ? 'arrow_down_green' : 'arrow_down';
                } else {
                    $changeClass = 'neutral';
                    $changeImage = false;
                }

                $change = '<span class="' . $changeClass . '">'
                    . ($changeImage ? '<img src="plugins/MultiSites/images/' . $changeImage . '.png" /> ' : '')
                    . $change . '</span>';

                $details .= ', ' . Piwik::translate('RowEvolution_MetricChangeText', $change);
            }

            // set metric min/max text (used as tooltip for details)
            $max = isset($metricData['max']) ? $metricData['max'] : 0;
            $min = isset($metricData['min']) ? $metricData['min'] : 0;
            $minmax = Piwik::translate('RowEvolution_MetricMinMax', array(
                $metricData['name'],
                NumberFormatter::getInstance()->formatNumber($min, $fractionDigits, $fractionDigits) . $unit,
                NumberFormatter::getInstance()->formatNumber($max, $fractionDigits, $fractionDigits) . $unit,
            ));

            $newMetric = array(
                'label'     => $metricData['name'],
                'details'   => $details,
                'minmax'    => $minmax,
                'sparkline' => $this->getSparkline($metric),
            );
            // Multi Rows, each metric can be for a particular row and display an icon
            if (!empty($metricData['logo'])) {
                $newMetric['logo'] = $metricData['logo'];
            }

            // TODO: this check should be determined by metric metadata, not hardcoded here
            if ($metric == 'nb_users'
                && $first == 0
                && $last == 0
            ) {
                $newMetric['hide'] = true;
            }

            $metrics[] = $newMetric;
            $i++;
        }

        return $metrics;
    }
577146
public static function fromArray(array $displayNames)
    {
        $path = new self();
        foreach ($displayNames as $v) {
            $path->push(new ResourceField(new ResourceDefinition(null), $v));
        }
        return $path;
    }
206894
public function groups(callable $groupCallback = null)
    {
        $groups = $this->groups;
        uasort($groups, [ $this, 'sortItemsByPriority' ]);

        $groupCallback = (isset($groupCallback) ? $groupCallback : $this->groupCallback);

        $groups = $this->finalizeFormGroups($groups);

        $i = 1;
        foreach ($groups as $group) {
            if ($groupCallback) {
                $groupCallback($group);
            }

            $GLOBALS['widget_template'] = $group->template();

            if (!$this->selectedFormGroup() && $this->isTabbable()) {
                $group->setIsHidden(false);
                if ($i > 1) {
                    $group->setIsHidden(true);
                }
            }
            $i++;

            yield $group;

            $GLOBALS['widget_template'] = '';
        }
    }
1090698
private function getHeaderLine($columnMetrics)
    {
        foreach ($columnMetrics as $index => $value) {
            if (in_array($value, $this->unsupportedColumns)) {
                unset($columnMetrics[$index]);
            }
        }

        if ($this->translateColumnNames) {
            $columnMetrics = $this->translateColumnNames($columnMetrics);
        }

        foreach ($columnMetrics as &$value) {
            $value = $this->formatValue($value);
        }

        return implode($this->separator, $columnMetrics);
    }
788220
public function getReportMetadata(
        array $idSites,
        $hideMetricsDoc = '',
        $showSubtableReports = '',
        array $optional = []
    )
    {
        return $this->_request('API.getReportMetadata', [
            'idSites' => $idSites,
            'hideMetricsDoc' => $hideMetricsDoc,
            'showSubtableReports' => $showSubtableReports,
        ], $optional);
    }
680641
protected function getVisibleItems()
    {
        if (count($this->data) <= $this->visibleCount) {
            return $this->data;
        }
        $visible = [];
        $iterator = (new ArrayObject($this->data))->getIterator();
        while (count($visible) < $this->visibleCount && $iterator->valid()) {
            $visible[] = $iterator->current();
            $iterator->next();
        }

        return $visible;
    }