original_string: public function getReferrerType($idSite, $period, $date, $segment = false, $typeReferrer = false,
                                      $idSubtable = false, $expanded = false)
      {
          Piwik::checkUserHasViewAccess($idSite);
  
          $this->checkSingleSite($idSite, 'getReferrerType');
  
          // if idSubtable is supplied, interpret idSubtable as referrer type and return correct report
          if ($idSubtable !== false) {
              $result = false;
              switch ($idSubtable) {
                  case Common::REFERRER_TYPE_SEARCH_ENGINE:
                      $result = $this->getKeywords($idSite, $period, $date, $segment);
                      break;
                  case Common::REFERRER_TYPE_SOCIAL_NETWORK:
                      $result = $this->getSocials($idSite, $period, $date, $segment);
                      break;
                  case Common::REFERRER_TYPE_WEBSITE:
                      $result = $this->getWebsites($idSite, $period, $date, $segment);
                      break;
                  case Common::REFERRER_TYPE_CAMPAIGN:
                      $result = $this->getCampaigns($idSite, $period, $date, $segment);
                      break;
                  default: // invalid idSubtable, return whole report
                      break;
              }
  
              if ($result) {
                  $result->filter('ColumnCallbackDeleteMetadata', array('segment'));
                  $result->filter('ColumnCallbackDeleteMetadata', array('segmentValue'));
  
                  return $this->removeSubtableIds($result); // this report won't return subtables of individual reports
              }
          }
  
          // get visits by referrer type
          $dataTable = $this->getDataTable(Archiver::REFERRER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
  
          if ($typeReferrer !== false) // filter for a specific referrer type
          {
              $dataTable->filter('Pattern', array('label', $typeReferrer));
          }
  
          // set subtable IDs for each row to the label (which holds the int referrer type)
          $dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\SetGetReferrerTypeSubtables', array($idSite, $period, $date, $segment, $expanded));
  
          $dataTable->filter('AddSegmentByLabelMapping', array(
              'referrerType',
              array(
                  Common::REFERRER_TYPE_DIRECT_ENTRY   => 'direct',
                  Common::REFERRER_TYPE_CAMPAIGN       => 'campaign',
                  Common::REFERRER_TYPE_SEARCH_ENGINE  => 'search',
                  Common::REFERRER_TYPE_SOCIAL_NETWORK => 'social',
                  Common::REFERRER_TYPE_WEBSITE        => 'website',
              )
          ));
          // set referrer type column to readable value
          $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getReferrerTypeLabel'));
  
          return $dataTable;
      }
code: public function getReferrerType($idSite, $period, $date, $segment = false, $typeReferrer = false,
                                      $idSubtable = false, $expanded = false)
      {
          Piwik::checkUserHasViewAccess($idSite);
  
          $this->checkSingleSite($idSite, 'getReferrerType');
  
          // if idSubtable is supplied, interpret idSubtable as referrer type and return correct report
          if ($idSubtable !== false) {
              $result = false;
              switch ($idSubtable) {
                  case Common::REFERRER_TYPE_SEARCH_ENGINE:
                      $result = $this->getKeywords($idSite, $period, $date, $segment);
                      break;
                  case Common::REFERRER_TYPE_SOCIAL_NETWORK:
                      $result = $this->getSocials($idSite, $period, $date, $segment);
                      break;
                  case Common::REFERRER_TYPE_WEBSITE:
                      $result = $this->getWebsites($idSite, $period, $date, $segment);
                      break;
                  case Common::REFERRER_TYPE_CAMPAIGN:
                      $result = $this->getCampaigns($idSite, $period, $date, $segment);
                      break;
                  default: // invalid idSubtable, return whole report
                      break;
              }
  
              if ($result) {
                  $result->filter('ColumnCallbackDeleteMetadata', array('segment'));
                  $result->filter('ColumnCallbackDeleteMetadata', array('segmentValue'));
  
                  return $this->removeSubtableIds($result); // this report won't return subtables of individual reports
              }
          }
  
          // get visits by referrer type
          $dataTable = $this->getDataTable(Archiver::REFERRER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
  
          if ($typeReferrer !== false) // filter for a specific referrer type
          {
              $dataTable->filter('Pattern', array('label', $typeReferrer));
          }
  
          // set subtable IDs for each row to the label (which holds the int referrer type)
          $dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\SetGetReferrerTypeSubtables', array($idSite, $period, $date, $segment, $expanded));
  
          $dataTable->filter('AddSegmentByLabelMapping', array(
              'referrerType',
              array(
                  Common::REFERRER_TYPE_DIRECT_ENTRY   => 'direct',
                  Common::REFERRER_TYPE_CAMPAIGN       => 'campaign',
                  Common::REFERRER_TYPE_SEARCH_ENGINE  => 'search',
                  Common::REFERRER_TYPE_SOCIAL_NETWORK => 'social',
                  Common::REFERRER_TYPE_WEBSITE        => 'website',
              )
          ));
          // set referrer type column to readable value
          $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getReferrerTypeLabel'));
  
          return $dataTable;
      }
code_tokens: public function getReferrerType ( $ idSite , $ period , $ date , $ segment = false , $ typeReferrer = false , $ idSubtable = false , $ expanded = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ this -> checkSingleSite ( $ idSite , 'getReferrerType' ) ; // if idSubtable is supplied, interpret idSubtable as referrer type and return correct report if ( $ idSubtable !== false ) { $ result = false ; switch ( $ idSubtable ) { case Common :: REFERRER_TYPE_SEARCH_ENGINE : $ result = $ this -> getKeywords ( $ idSite , $ period , $ date , $ segment ) ; break ; case Common :: REFERRER_TYPE_SOCIAL_NETWORK : $ result = $ this -> getSocials ( $ idSite , $ period , $ date , $ segment ) ; break ; case Common :: REFERRER_TYPE_WEBSITE : $ result = $ this -> getWebsites ( $ idSite , $ period , $ date , $ segment ) ; break ; case Common :: REFERRER_TYPE_CAMPAIGN : $ result = $ this -> getCampaigns ( $ idSite , $ period , $ date , $ segment ) ; break ; default : // invalid idSubtable, return whole report break ; } if ( $ result ) { $ result -> filter ( 'ColumnCallbackDeleteMetadata' , array ( 'segment' ) ) ; $ result -> filter ( 'ColumnCallbackDeleteMetadata' , array ( 'segmentValue' ) ) ; return $ this -> removeSubtableIds ( $ result ) ; // this report won't return subtables of individual reports } } // get visits by referrer type $ dataTable = $ this -> getDataTable ( Archiver :: REFERRER_TYPE_RECORD_NAME , $ idSite , $ period , $ date , $ segment ) ; if ( $ typeReferrer !== false ) // filter for a specific referrer type { $ dataTable -> filter ( 'Pattern' , array ( 'label' , $ typeReferrer ) ) ; } // set subtable IDs for each row to the label (which holds the int referrer type) $ dataTable -> filter ( 'Piwik\Plugins\Referrers\DataTable\Filter\SetGetReferrerTypeSubtables' , array ( $ idSite , $ period , $ date , $ segment , $ expanded ) ) ; $ dataTable -> filter ( 'AddSegmentByLabelMapping' , array ( 'referrerType' , array ( Common :: REFERRER_TYPE_DIRECT_ENTRY => 'direct' , Common :: REFERRER_TYPE_CAMPAIGN => 'campaign' , Common :: REFERRER_TYPE_SEARCH_ENGINE => 'search' , Common :: REFERRER_TYPE_SOCIAL_NETWORK => 'social' , Common :: REFERRER_TYPE_WEBSITE => 'website' , ) ) ) ; // set referrer type column to readable value $ dataTable -> queueFilter ( 'ColumnCallbackReplace' , array ( 'label' , __NAMESPACE__ . '\getReferrerTypeLabel' ) ) ; return $ dataTable ; }
docstring: Returns a report describing visit information for each possible referrer type. The
  result is a datatable whose subtables are the reports for each parent row's referrer type.
  
  The subtable reports are: 'getKeywords' (for search engine referrer type), 'getWebsites',
  and 'getCampaigns'.
  
  @param string $idSite The site ID.
  @param string $period The period to get data for, either 'day', 'week', 'month', 'year',
  or 'range'.
  @param string $date The date of the period.
  @param bool|string $segment The segment to use.
  @param bool|int $typeReferrer (deprecated) If you want to get data only for a specific referrer
  type, supply a type for this parameter.
  @param bool|int $idSubtable For this report this value is a referrer type ID and not an actual
  subtable ID. The result when using this parameter will be the
  specific report for the given referrer type.
  @param bool $expanded Whether to get report w/ subtables loaded or not.
  @return DataTable
docstring_tokens: Returns a report describing visit information for each possible referrer type . The result is a datatable whose subtables are the reports for each parent row s referrer type .