Retrieves a feed of the most viewed videos.

@param mixed $location (optional) The URL to query or a
Zend_Gdata_Query object from which a URL can be determined
@return Zend_Gdata_YouTube_VideoFeed The feed of videos found at the
specified URL.
347070
public function getMostViewedVideoFeed($location = null)
    {
        $standardFeedUri = self::STANDARD_MOST_VIEWED_URI;

        if ($this->getMajorProtocolVersion() == 2) {
            $standardFeedUri = self::STANDARD_MOST_VIEWED_URI_V2;
        }

        if ($location == null) {
            $uri = $standardFeedUri;
        } else if ($location instanceof Zend_Gdata_Query) {
            if ($location instanceof Zend_Gdata_YouTube_VideoQuery) {
                if (!isset($location->url)) {
                    $location->setFeedType('most viewed');
                }
            }
            $uri = $location->getQueryUrl($this->getMajorProtocolVersion());
        } else {
            $uri = $location;
        }
        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');
    }
473902
public function findByLocation(Location $location, array $orderBy = [],
        ?int $limit = null): array
    {
        $qb = $this->createQueryBuilder('su');
        $this->filterByLocation($qb, $location);
        $this->addOrderBy($qb, $orderBy);
        $this->addLimit($qb, $limit);

        return $qb->getQuery()->getResult();
    }
1236226
public function rawWhich($location)
    {
        $location = $this->modulable->runSilently('which '.$location);
        if (mb_strpos($location, 'not found') !== false || mb_strpos($location, 'in (') !== false) {
            return false;
        }

        return $location;
    }
860887
public function load($location)
	{
		if($this->isTesting())
		{
			$location = 'local';
		}

		if (file_exists($path = $this->getFile($location)))
		{
            return require_once($path);
		}

		return array();
	}
243268
public function findFeeds($uri)
    {
        $client = new Zend_Http_Client($uri);
        $response = $client->request();
        if ($response->getStatus() != 200) {
            throw new Kwf_Exception("invalid status response");
        }
        $contents = $response->getBody();
        // Parse the contents for appropriate <link ... /> tags
        @ini_set('track_errors', 1);
        $pattern = '~(<link[^>]+)/?>~i';
        $result = @preg_match_all($pattern, $contents, $matches);
        @ini_restore('track_errors');
        if ($result === false) {
            throw new Zend_Feed_Exception("Internal error: $php_errormsg");
        }
        // Try to fetch a feed for each link tag that appears to refer to a feed
        $feeds = array();
        if (isset($matches[1]) && count($matches[1]) > 0) {
            foreach ($matches[1] as $link) {
                // force string to be an utf-8 one
                if (!mb_check_encoding($link, 'UTF-8')) {
                    $link = mb_convert_encoding($link, 'UTF-8');
                }
                $link = html_entity_decode($link, ENT_QUOTES, "utf-8");
                $entityLoaderWasDisabled = libxml_disable_entity_loader(true);
                $xml = @simplexml_load_string(rtrim($link, ' /') . ' />');
                libxml_disable_entity_loader($entityLoaderWasDisabled);
                if ($xml === false) {
                    $link = preg_replace('#&(?=[a-z_0-9]+=)#', '&amp;', $link);
                    $link = str_replace('& ', '&amp; ', $link);
                    $entityLoaderWasDisabled = libxml_disable_entity_loader(true);
                    $xml = @simplexml_load_string(rtrim($link, ' /') . ' />');
                    libxml_disable_entity_loader($entityLoaderWasDisabled);
                    if ($xml === false) {
                        continue;
                    }
                }
                $attributes = $xml->attributes();
                if (!isset($attributes['rel']) || !@preg_match('~^(?:alternate|service\.feed)~i', $attributes['rel'])) {
                    continue;
                }
                
                $type = false;
                if (isset($attributes['type'])) {
                    $type = $attributes['type'];
                } else if (isset($attributes['TYPE'])) {
                    $type = $attributes['TYPE'];
                }
                if (!$type ||
                        !@preg_match('~^application/(?:atom|rss|rdf)\+xml~', $type)) {
                    continue;
                }
                if (!isset($attributes['href'])) {
                    continue;
                }
                try {
                    // checks if we need to canonize the given uri
                    try {
                        $uri = Zend_Uri::factory((string) $attributes['href']);
                    } catch (Zend_Uri_Exception $e) {
                        // canonize the uri
                        $pageUri = Zend_Uri::factory($uri);
                        $path = (string) $attributes['href'];
                        $query = $fragment = '';
                        if (substr($path, 0, 1) != '/') {
                            // add the current root path to this one
                            $path = rtrim($pageUri->getPath(), '/') . '/' . $path;
                        }
                        if (strpos($path, '?') !== false) {
                            list($path, $query) = explode('?', $path, 2);
                        }
                        if (strpos($query, '#') !== false) {
                            list($query, $fragment) = explode('#', $query, 2);
                        }
                        $uri = Zend_Uri::factory($pageUri->__toString());
                        $uri->setPath($path);
                        $uri->setQuery($query);
                        $uri->setFragment($fragment);
                    }
                } catch (Exception $e) {
                    continue;
                }
                $title = '';
                if (isset($attributes['title'])) {
                    $title = (string)$attributes['title'];
                }
                $feeds[(string)$uri] = $title;
            }
        }
        // Return the fetched feeds
        return $feeds;
    }
22721
public function findNearbyHubs(Geolocatable $location)
    {
        $qb = $this->getEntityManager()->createQueryBuilder()
            ->select('pf')
            ->from('HarvestCloudCoreBundle:Profile', 'pf')
            ->addSelect('GEO(pf.latitude = :latitude, pf.longitude = :longitude) AS distance')
            ->where('pf.hub_status = :hub_status')
            ->andWhere('pf.system_hub_status = :system_hub_status')
            ->andWhere('GEO(pf.latitude = :latitude, pf.longitude = :longitude) < 50')
            ->setParameter('latitude', $location->getLatitude())
            ->setParameter('longitude', $location->getLongitude())
            ->setParameter('hub_status', Profile::STATUS_ACTIVE)
            ->setParameter('system_hub_status', Profile::STATUS_ENABLED)
            ->orderBy('distance')
        ;

        return $qb->getQuery()->execute();
    }
103111
public function getAccountFeed($uri = self::ANALYTICS_ACCOUNT_FEED_URI)
    {
        if ($uri instanceof Query) {
            $uri = $uri->getQueryUrl();
        }
        return parent::getFeed($uri, 'Zend_Gdata_Analytics_AccountFeed');
    }
662616
public static function convertLocationCoordinates(Location $location)
    {
        $coordinates = $location->getCoordinates()->getCoordinates();
        $coordinate = doubleval($coordinates[1]) . '%' . doubleval($coordinates[0]);
        $coordinate = strtr($coordinate, [
            '%'=>',',
            ','=>'.'
        ]);
        return $coordinate;
    }
912770
public function addLocation(Location $location)
    {
        $this->locations->add($location);

        unset( $this->viewPathCache );
        $this->viewPathCache = [];

        return $this;
    }
941449
public function viewParentExtraInfoAction(Location $location)
    {
        $repository = $this->getRepository();
        $parentLocation = $repository->getLocationService()->loadLocation($location->parentLocationId);

        // TODO once the keyword service is available replace part this subrequest by a full symfony one

        return $this->render(
            'eZDemoBundle:parts/blog:extra_info.html.twig',
            array('location' => $parentLocation)
        );
    }
236019
public function baqiFromLocation($location = null, $time = null)
    {
        $this->guardAgainstEmptyArgument($location, 'location');

        $baqi = $this->getClient()->get("{$this->endpoint}/baqi/?location={$location}&datetime={$time}&key={$this->apiKey}");

        return $baqi->json();
    }
143953
public function getDocumentListEntry($location = null)
    {
        if ($location === null) {
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
            throw new Zend_Gdata_App_InvalidArgumentException(
                    'Location must not be null'
            );
        } else if ($location instanceof Zend_Gdata_Query) {
            $uri = $location->getQueryUrl();
        } else {
            $uri = $location;
        }
        return parent::getEntry($uri, 'Zend_Gdata_Docs_DocumentListEntry');
    }
1272607
private function getLocationCounter($location)
    {
        $locationHash = md5(implode(',', $location));
        if (!isset($this->seenCounter[$locationHash])) {
            $this->seenCounter[$locationHash] = 0;
        } else {
            $this->seenCounter[$locationHash]++;
        }
        return $this->seenCounter[$locationHash];
    }
1168860
protected function searchSubGroups(Location $location, $offset = 0, $limit = 25)
    {
        $searchQuery = new LocationQuery();

        $searchQuery->offset = $offset;
        $searchQuery->limit = $limit;

        $searchQuery->filter = new CriterionLogicalAnd([
            new CriterionContentTypeId($this->settings['userGroupClassID']),
            new CriterionParentLocationId($location->id),
        ]);

        $searchQuery->sortClauses = $location->getSortClauses();

        return $this->repository->getSearchService()->findLocations($searchQuery, array(), false);
    }
879543
public function addVideo($location, $title = null, $description = null, $thumbnailLocation = null)
    {
        $video = $location instanceof VideoTag ? $location : new VideoTag($location, $title, $description, $thumbnailLocation);

        $this->videos[] = $video;
    }
953513
public function loadPathLocations(Location $location)
    {
        $locationQuery = new LocationQuery([
            'filter' => new Ancestor($location->pathString),
            'sortClauses' => [new Path()],
        ]);

        $searchResult = $this->searchService->findLocations($locationQuery);

        return array_map(function (SearchHit $searchHit) {
            return $searchHit->valueObject;
        }, $searchResult->searchHits);
    }
81835
public function getWorksheetFeed($location)
    {
        if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) {
            if ($location->getDocumentType() == null) {
                $location->setDocumentType('worksheets');
            }
            $uri = $location->getQueryUrl();
        } else if ($location instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry) {
            $uri = $location->getLink(self::WORKSHEETS_FEED_LINK_URI)->href;
        } else {
            $uri = $location;
        }

        return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_WorksheetFeed');
    }