getCalendarViewArray()

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2012-10-25

@param  HarvestCloud\CoreBundle\Entity\Profile $hub
977886
public function getCalendarViewArray(OrderCollection $orderCollection)
    {
        $windows  = $this->findForSelectWindowForOrderCollection($orderCollection);
        $slots     = HubWindow::getSlots();

        foreach ($windows as $window)
        {
            $hour = $window->getStartTime()->format('H:i');
            $date = $window->getStartTime()->format('Y-m-d');

            if (array_key_exists($hour, $slots) && array_key_exists($date, $slots[$hour]))
            {
                $slots[$hour][$date] = $window; //->getStartTime()->format(\DateTime::ATOM);
            }
        }

        // \HarvestCloud\CoreBundle\Util\Debug::show($slots);

        return $slots;
    }
1134986
public function setCalendarEventData(array $data = [], ?EntityInterface $calendar = null): array
    {
        $result = [
            'CalendarEvents' => [],
        ];

        $result['CalendarEvents'] = $data;
        if (!empty($data['recurrence'])) {
            $recurrence = $this->setRRuleConfiguration($data['recurrence']);
            $result['CalendarEvents']['is_recurring'] = true;
            $result['CalendarEvents']['recurrence'] = $recurrence;
        }

        if (!empty($data['attendees_ids'])) {
            $result['calendar_attendees']['_ids'] = $data['attendees_ids'];
            unset($result['CalendarEvents']['attendees_ids']);
        }

        if (empty($data['title']) && $calendar instanceof EntityInterface) {
            $result['CalendarEvents']['title'] = $this->setEventTitle($data, $calendar);
        }

        return $result;
    }
256040
public function getContentArray($type = DOC_TYPE_ARRAY)
  {
    if ($type == DOC_TYPE_SIMPLEXML) {
      $cpsChildren = $this->_simpleXml->children('www.clusterpoint.com');
      if (isset($cpsChildren->content)) {
        return $cpsChildren->content;
      } else {
        return NULL;
      }
    } else if ($type == DOC_TYPE_ARRAY) {
      return $this->_contentArray;
    }
  }
1033008
protected function getVisitsViewsUsersForPeriod(
        DateTime $startDate,
        DateTime $endDate
    ) {
        $cacheName = md5(serialize('visits-views-users'
            .$startDate->format('Y-m-d').$endDate->format('Y-m-d')));

        $urlParams = [
            'ids'        => $this->counter_id,
            'date1'      => $startDate->format('Y-m-d'),
            'date2'      => $endDate->format('Y-m-d'),
            'metrics'    => 'ym:s:visits,ym:s:pageviews,ym:s:users',
            'dimensions' => 'ym:s:date',
            'sort'       => 'ym:s:date',
        ];

        $this->data = $this->request($urlParams, $cacheName);
    }
510172
public function getVisitsByDate($parameters = [], $parseResult = true)
    {
        $this->setParams([
            'metrics'    => 'ga:visits',
            'dimensions' => 'ga:date',
        ]);

        return $this->execute($parameters, $parseResult);
    }
469069
public function setProfile(\HarvestCloud\CoreBundle\Entity\Profile $profile = null)
    {
        $this->profile = $profile;

        return $this;
    }
866583
public function getSocialMediaProfiles()
    {
        $socialMediaProfiles = [];
        if ($this->entity->getSocialMediaProfiles()) {
            foreach ($this->entity->getSocialMediaProfiles() as $socialMediaProfile) {
                $socialMediaProfiles[] = $socialMediaProfile;
            }
        }

        return $socialMediaProfiles;
    }
626947
public function indexAction(Profile $profile, $week)
    {
        $startDate = DateTime::getForStartOfWeek();
        $endDate   = DateTime::getForEndOfWeek();

        if ('next-week' == $week)
        {
            $startDate->add(new \DateInterval('P7D'));
            $endDate->add(new \DateInterval('P7D'));
        }

        $weekView = $this->getRepo('HubWindow')
            ->getWeekViewForHub($profile, $startDate, $endDate);

        return $this->render('HarvestCloudCoreBundle:Hub/Window:index.html.twig', array(
            'weekView'  => $weekView,
            'profile'   => $profile,
            'startDate' => $startDate,
            'endDate'   => $endDate,
        ));
    }
976209
private function parseForecastResponseHeaders($headers)
    {
        $responseHeaders = [
            'cache' => [
                'maxAge' => null,
                'expires' => null
            ],
            'responseTime' => null,
            'apiCalls' => null
        ];
        foreach ($headers as $header) {
            switch (true) {
                case (substr($header, 0, 14) === 'Cache-Control:'):
                    $responseHeaders['cache']['maxAge'] = trim(substr($header, strrpos($header, '=') + 1));
                    break;
                case (substr($header, 0, 8) === 'Expires:'):
                    $responseHeaders['cache']['expires'] = trim(substr($header, 8));
                    break;
                case (substr($header, 0, 21) === 'X-Forecast-API-Calls:'):
                    $responseHeaders['apiCalls'] = trim(substr($header, 21));
                    break;
                case (substr($header, 0, 16) === 'X-Response-Time:'):
                    $responseHeaders['responseTime'] = (int)trim(substr($header, 16));
                    break;
                default:
                    break;
            }
        }
        return $responseHeaders;
    }
483502
public function calendar($referenceTime = null, array $formats = [])
    {
        /** @var CarbonInterface $current */
        $current = $this->copy()->startOfDay();
        /** @var CarbonInterface $other */
        $other = $this->resolveCarbon($referenceTime)->copy()->setTimezone($this->getTimezone())->startOfDay();
        $diff = $other->diffInDays($current, false);
        $format = $diff < -6 ? 'sameElse' : (
            $diff < -1 ? 'lastWeek' : (
                $diff < 0 ? 'lastDay' : (
                    $diff < 1 ? 'sameDay' : (
                        $diff < 2 ? 'nextDay' : (
                            $diff < 7 ? 'nextWeek' : 'sameElse'
                        )
                    )
                )
            )
        );
        $format = array_merge($this->getCalendarFormats(), $formats)[$format];
        if ($format instanceof Closure) {
            $format = $format($current, $other) ?? '';
        }

        return $this->isoFormat(strval($format));
    }
990676
public function getVisitorsAndPageViews()
    {
        $period = $this->analyticsDuration();
        $data = Analytics::fetchTotalVisitorsAndPageViews($period);

        $totalViews = ['labels' => []];
        $visitors = [];
        $pageviews = [];
        foreach ($data as $k => $item) {
            array_push($totalViews['labels'], $item['date']->format('d M'));

            array_push($visitors, $item['visitors']);
            array_push($pageviews, $item['pageViews']);
        }

        $totalViews['datasets'][] = $this->getDataSet('Page Views', $pageviews, 0);
        $totalViews['datasets'][] = $this->getDataSet('Visitors', $visitors, 1);

        return json_encode($totalViews);
    }
712691
protected function getSitemapEntries(ProfileInterface $profile)
    {
        $now = new \DateTime();
        $urlEntries = $profile->getUrlEntries();
        $numberOfSitemap = $this->getNumberOfSitemap($urlEntries);

        if (1 === $numberOfSitemap) {
            $this->writeFile(
                $this->helper->getSitemapEntryFilePath($this->getFilename($profile)),
                $this->render->renderSitemap($urlEntries)
            );

            return array(new SitemapEntry($this->helper->getSitemapEntryFileUrl($this->getFilename($profile)), $now));
        }


        $sitemapEntries = array();

        for ($number = 0; $number < $numberOfSitemap; $number++) {
            $filename = $this->getFilename($profile, $number);
            $entries = array_slice($urlEntries, $number * $this->maxPerSitemap, $this->maxPerSitemap);

            $this->writeFile($this->helper->getSitemapEntryFilePath($filename), $this->render->renderSitemap($entries));

            $sitemapEntries[] = new SitemapEntry($this->helper->getSitemapEntryFileUrl($filename), $now);
        }

        return $sitemapEntries;
    }
1202039
public static function getMaskList($classMetadata, $hub)
    {
        $path = self::PATH_MASK_BY_HUB;

        return (!empty($classMetadata->$path[$hub]) ? $classMetadata->$path[$hub] : []);
    }
1157546
public function getEntryPageTitles($idSite, $period, $date, $segment = false, $expanded = false,
                                       $idSubtable = false, $flat = false)
    {
        Piwik::checkUserHasViewAccess($idSite);

        $dataTable = $this->getPageTitles($idSite, $period, $date, $segment, $expanded, $idSubtable, $flat);
        $this->filterNonEntryActions($dataTable);
        return $dataTable;
    }
337049
public function findOpenForSeller(Profile $seller)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        $qb->from('HarvestCloudCoreBundle:Order', 'o')
            ->select('o')
            ->join('o.seller', 's')
            ->orderBy('o.id', 'DESC')
            ->where($qb->expr()->in('o.status_code', Order::getOpenStatusCodes()))
            ->andWhere('s.id = :seller_id')
            ->setParameter('seller_id', $seller->getId())
        ;

        $q = $qb->getQuery();

        return $q->execute();
    }
290615
public function getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment = false, $_leavePriceViewedColumn = false)
    {
        Piwik::checkUserHasViewAccess($idSite);

        $dataTable = $this->getDataTable($idSite, $period, $date, $segment, $expanded = false, $flat = false, $idSubtable);

        if (!$_leavePriceViewedColumn) {
            $dataTable->deleteColumn('price_viewed');
        } else {
            // Hack Ecommerce product price tracking to display correctly
            $dataTable->renameColumn('price_viewed', 'price');
        }

        $dataTable->filter('Piwik\Plugins\CustomVariables\DataTable\Filter\CustomVariablesValuesFromNameId');

        return $dataTable;
    }
1307668
public function findUpcomingForSeller(Profile $seller)
    {
        $em = $this->getEntityManager();

        $q  = $em->createQuery('
                SELECT w
                FROM HarvestCloudCoreBundle:SellerWindow w
                LEFT JOIN w.sellerHubRef shr
                LEFT JOIN shr.hub h
                WHERE shr.seller = :seller
                AND w.end_time >= :now
            ')
            ->setParameter('seller', $seller)
            ->setParameter('now', date('Y-m-d H:i:s'))
        ;

        return $q->getResult();
    }