Piwik\Plugins\Referrers\API::getUrlsForSocial PHP Method

getUrlsForSocial() public method

Returns report containing individual referrer URLs for a specific social networking site.
public getUrlsForSocial ( string $idSite, string $period, string $date, boolean | string $segment = false, boolean | integer $idSubtable = false ) : DataTable
$idSite string
$period string
$date string
$segment boolean | string
$idSubtable boolean | integer This ID does not reference a real DataTable record. Instead, it is the array index of an item in the Socials list file. The urls are filtered by the social network at this index. If false, no filtering is done and every social URL is returned.
return Piwik\DataTable
    public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idSubtable = false)
    {
        $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
        // get the social network domain referred to by $idSubtable
        $socialNetworks = Social::getInstance()->getDefinitions();
        $social = false;
        if ($idSubtable !== false) {
            --$idSubtable;
            reset($socialNetworks);
            for ($i = 0; $i != (int) $idSubtable; ++$i) {
                next($socialNetworks);
            }
            $social = current($socialNetworks);
        }
        // filter out everything but social network indicated by $idSubtable
        $dataTable->filter('ColumnCallbackDeleteRow', array('label', function ($url) use($social) {
            return !Social::getInstance()->isSocialUrl($url, $social);
        }));
        // merge the datatable's subtables which contain the individual URLs
        $dataTable = $dataTable->mergeSubtables();
        $dataTable->filter('AddSegmentByLabel', array('referrerUrl'));
        $dataTable->filter('Piwik\\Plugins\\Referrers\\DataTable\\Filter\\UrlsForSocial', array($expanded));
        return $dataTable;
    }