original_string: public function getByDayOfWeek($idSite, $period, $date, $segment = false)
      {
  
          Piwik::checkUserHasViewAccess($idSite);
  
          // metrics to query
          $metrics = Metrics::getVisitsMetricNames();
          unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
  
          // disabled for multiple dates
          if (Period::isMultiplePeriod($date, $period)) {
              throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
          }
  
          // get metric data for every day within the supplied period
          $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
          $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
          $archive = Archive::build($idSite, 'day', $dateRange, $segment);
  
          // disabled for multiple sites
          if (count($archive->getParams()->getIdSites()) > 1) {
              throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
          }
  
          $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
  
          // if there's no data for this report, don't bother w/ anything else
          if ($dataTable->getRowsCount() == 0) {
              return $dataTable;
          }
  
          // group by the day of the week (see below for dayOfWeekFromDate function)
          $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate'));
  
          // create new datatable w/ empty rows, then add calculated datatable
          $rows = array();
          foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
              $rows[] = array('label' => $day, 'nb_visits' => 0);
          }
          $result = new DataTable();
          $result->addRowsFromSimpleArray($rows);
          $result->addDataTable($dataTable);
  
          // set day of week integer as metadata
          $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
  
          // translate labels
          $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek'));
  
          // set datatable metadata for period start & finish
          $result->setMetadata('date_start', $oPeriod->getDateStart());
          $result->setMetadata('date_end', $oPeriod->getDateEnd());
  
          return $result;
      }
code: public function getByDayOfWeek($idSite, $period, $date, $segment = false)
      {
  
          Piwik::checkUserHasViewAccess($idSite);
  
          // metrics to query
          $metrics = Metrics::getVisitsMetricNames();
          unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
  
          // disabled for multiple dates
          if (Period::isMultiplePeriod($date, $period)) {
              throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
          }
  
          // get metric data for every day within the supplied period
          $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
          $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
          $archive = Archive::build($idSite, 'day', $dateRange, $segment);
  
          // disabled for multiple sites
          if (count($archive->getParams()->getIdSites()) > 1) {
              throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
          }
  
          $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
  
          // if there's no data for this report, don't bother w/ anything else
          if ($dataTable->getRowsCount() == 0) {
              return $dataTable;
          }
  
          // group by the day of the week (see below for dayOfWeekFromDate function)
          $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate'));
  
          // create new datatable w/ empty rows, then add calculated datatable
          $rows = array();
          foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
              $rows[] = array('label' => $day, 'nb_visits' => 0);
          }
          $result = new DataTable();
          $result->addRowsFromSimpleArray($rows);
          $result->addDataTable($dataTable);
  
          // set day of week integer as metadata
          $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
  
          // translate labels
          $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek'));
  
          // set datatable metadata for period start & finish
          $result->setMetadata('date_start', $oPeriod->getDateStart());
          $result->setMetadata('date_end', $oPeriod->getDateEnd());
  
          return $result;
      }
code_tokens: public function getByDayOfWeek ( $ idSite , $ period , $ date , $ segment = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; // metrics to query $ metrics = Metrics :: getVisitsMetricNames ( ) ; unset ( $ metrics [ Metrics :: INDEX_MAX_ACTIONS ] ) ; // disabled for multiple dates if ( Period :: isMultiplePeriod ( $ date , $ period ) ) { throw new Exception ( "VisitTime.getByDayOfWeek does not support multiple dates." ) ; } // get metric data for every day within the supplied period $ oPeriod = Period \ Factory :: makePeriodFromQueryParams ( Site :: getTimezoneFor ( $ idSite ) , $ period , $ date ) ; $ dateRange = $ oPeriod -> getDateStart ( ) -> toString ( ) . ',' . $ oPeriod -> getDateEnd ( ) -> toString ( ) ; $ archive = Archive :: build ( $ idSite , 'day' , $ dateRange , $ segment ) ; // disabled for multiple sites if ( count ( $ archive -> getParams ( ) -> getIdSites ( ) ) > 1 ) { throw new Exception ( "VisitTime.getByDayOfWeek does not support multiple sites." ) ; } $ dataTable = $ archive -> getDataTableFromNumeric ( $ metrics ) -> mergeChildren ( ) ; // if there's no data for this report, don't bother w/ anything else if ( $ dataTable -> getRowsCount ( ) == 0 ) { return $ dataTable ; } // group by the day of the week (see below for dayOfWeekFromDate function) $ dataTable -> filter ( 'GroupBy' , array ( 'label' , __NAMESPACE__ . '\dayOfWeekFromDate' ) ) ; // create new datatable w/ empty rows, then add calculated datatable $ rows = array ( ) ; foreach ( array ( 1 , 2 , 3 , 4 , 5 , 6 , 7 ) as $ day ) { $ rows [ ] = array ( 'label' => $ day , 'nb_visits' => 0 ) ; } $ result = new DataTable ( ) ; $ result -> addRowsFromSimpleArray ( $ rows ) ; $ result -> addDataTable ( $ dataTable ) ; // set day of week integer as metadata $ result -> filter ( 'ColumnCallbackAddMetadata' , array ( 'label' , 'day_of_week' ) ) ; // translate labels $ result -> filter ( 'ColumnCallbackReplace' , array ( 'label' , __NAMESPACE__ . '\translateDayOfWeek' ) ) ; // set datatable metadata for period start & finish $ result -> setMetadata ( 'date_start' , $ oPeriod -> getDateStart ( ) ) ; $ result -> setMetadata ( 'date_end' , $ oPeriod -> getDateEnd ( ) ) ; return $ result ; }
docstring: Returns datatable describing the number of visits for each day of the week.
  
  @param string $idSite The site ID. Cannot refer to multiple sites.
  @param string $period The period type: day, week, year, range...
  @param string $date The start date of the period. Cannot refer to multiple dates.
  @param bool|string $segment The segment.
  @throws Exception
  @return DataTable
docstring_tokens: Returns datatable describing the number of visits for each day of the week .