original_string: public function getAnnotationCountForDates($idSite, $date, $period, $lastN = false, $getAnnotationText = false)
      {
          Piwik::checkUserHasViewAccess($idSite);
  
          // get start & end date for request. lastN is ignored if $period == 'range'
          list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
          if ($period == 'range') {
              $period = 'day';
          }
  
          // create list of dates
          $dates = array();
          for (; $startDate->getTimestamp() <= $endDate->getTimestamp(); $startDate = $startDate->addPeriod(1, $period)) {
              $dates[] = $startDate;
          }
          // we add one for the end of the last period (used in for loop below to bound annotation dates)
          $dates[] = $startDate;
  
          // get annotations for the site
          $annotations = new AnnotationList($idSite);
  
          // create result w/ 0-counts
          $result = array();
          for ($i = 0; $i != count($dates) - 1; ++$i) {
              $date = $dates[$i];
              $nextDate = $dates[$i + 1];
              $strDate = $date->toString();
  
              foreach ($annotations->getIdSites() as $idSite) {
                  $result[$idSite][$strDate] = $annotations->count($idSite, $date, $nextDate);
  
                  // if only one annotation, return the one annotation's text w/ the counts
                  if ($getAnnotationText
                      && $result[$idSite][$strDate]['count'] == 1
                  ) {
                      $annotationsForSite = $annotations->search(
                          $date, Date::factory($nextDate->getTimestamp() - 1), $idSite);
                      $annotation = reset($annotationsForSite[$idSite]);
  
                      $result[$idSite][$strDate]['note'] = $annotation['note'];
                  }
              }
          }
  
          // convert associative array into array of pairs (so it can be traversed by index)
          $pairResult = array();
          foreach ($result as $idSite => $counts) {
              foreach ($counts as $date => $count) {
                  $pairResult[$idSite][] = array($date, $count);
              }
          }
          return $pairResult;
      }
code: public function getAnnotationCountForDates($idSite, $date, $period, $lastN = false, $getAnnotationText = false)
      {
          Piwik::checkUserHasViewAccess($idSite);
  
          // get start & end date for request. lastN is ignored if $period == 'range'
          list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
          if ($period == 'range') {
              $period = 'day';
          }
  
          // create list of dates
          $dates = array();
          for (; $startDate->getTimestamp() <= $endDate->getTimestamp(); $startDate = $startDate->addPeriod(1, $period)) {
              $dates[] = $startDate;
          }
          // we add one for the end of the last period (used in for loop below to bound annotation dates)
          $dates[] = $startDate;
  
          // get annotations for the site
          $annotations = new AnnotationList($idSite);
  
          // create result w/ 0-counts
          $result = array();
          for ($i = 0; $i != count($dates) - 1; ++$i) {
              $date = $dates[$i];
              $nextDate = $dates[$i + 1];
              $strDate = $date->toString();
  
              foreach ($annotations->getIdSites() as $idSite) {
                  $result[$idSite][$strDate] = $annotations->count($idSite, $date, $nextDate);
  
                  // if only one annotation, return the one annotation's text w/ the counts
                  if ($getAnnotationText
                      && $result[$idSite][$strDate]['count'] == 1
                  ) {
                      $annotationsForSite = $annotations->search(
                          $date, Date::factory($nextDate->getTimestamp() - 1), $idSite);
                      $annotation = reset($annotationsForSite[$idSite]);
  
                      $result[$idSite][$strDate]['note'] = $annotation['note'];
                  }
              }
          }
  
          // convert associative array into array of pairs (so it can be traversed by index)
          $pairResult = array();
          foreach ($result as $idSite => $counts) {
              foreach ($counts as $date => $count) {
                  $pairResult[$idSite][] = array($date, $count);
              }
          }
          return $pairResult;
      }
code_tokens: public function getAnnotationCountForDates ( $ idSite , $ date , $ period , $ lastN = false , $ getAnnotationText = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; // get start & end date for request. lastN is ignored if $period == 'range' list ( $ startDate , $ endDate ) = self :: getDateRangeForPeriod ( $ date , $ period , $ lastN ) ; if ( $ period == 'range' ) { $ period = 'day' ; } // create list of dates $ dates = array ( ) ; for ( ; $ startDate -> getTimestamp ( ) <= $ endDate -> getTimestamp ( ) ; $ startDate = $ startDate -> addPeriod ( 1 , $ period ) ) { $ dates [ ] = $ startDate ; } // we add one for the end of the last period (used in for loop below to bound annotation dates) $ dates [ ] = $ startDate ; // get annotations for the site $ annotations = new AnnotationList ( $ idSite ) ; // create result w/ 0-counts $ result = array ( ) ; for ( $ i = 0 ; $ i != count ( $ dates ) - 1 ; ++ $ i ) { $ date = $ dates [ $ i ] ; $ nextDate = $ dates [ $ i + 1 ] ; $ strDate = $ date -> toString ( ) ; foreach ( $ annotations -> getIdSites ( ) as $ idSite ) { $ result [ $ idSite ] [ $ strDate ] = $ annotations -> count ( $ idSite , $ date , $ nextDate ) ; // if only one annotation, return the one annotation's text w/ the counts if ( $ getAnnotationText && $ result [ $ idSite ] [ $ strDate ] [ 'count' ] == 1 ) { $ annotationsForSite = $ annotations -> search ( $ date , Date :: factory ( $ nextDate -> getTimestamp ( ) - 1 ) , $ idSite ) ; $ annotation = reset ( $ annotationsForSite [ $ idSite ] ) ; $ result [ $ idSite ] [ $ strDate ] [ 'note' ] = $ annotation [ 'note' ] ; } } } // convert associative array into array of pairs (so it can be traversed by index) $ pairResult = array ( ) ; foreach ( $ result as $ idSite => $ counts ) { foreach ( $ counts as $ date => $ count ) { $ pairResult [ $ idSite ] [ ] = array ( $ date , $ count ) ; } } return $ pairResult ; }
docstring: Returns the count of annotations for a list of periods, including the count of
  starred annotations.
  
  @param string $idSite The site ID to add the annotation to.
  @param string|bool $date The date of the period.
  @param string $period The period type.
  @param int|bool $lastN Whether to get counts for the last N number of periods or not.
  @param bool $getAnnotationText
  @return array An array mapping site IDs to arrays holding dates & the count of
  annotations made for those dates. eg,
  array(
  5 => array(
  array('2012-01-02', array('count' => 4, 'starred' => 2)),
  array('2012-01-03', array('count' => 0, 'starred' => 0)),
  array('2012-01-04', array('count' => 2, 'starred' => 0)),
  ),
  6 => array(
  array('2012-01-02', array('count' => 1, 'starred' => 0)),
  array('2012-01-03', array('count' => 4, 'starred' => 3)),
  array('2012-01-04', array('count' => 2, 'starred' => 0)),
  ),
  ...
  )
docstring_tokens: Returns the count of annotations for a list of periods including the count of starred annotations .