original_string: public function search($startDate, $endDate, $idSite = false)
      {
          if ($idSite) {
              $idSites = Site::getIdSitesFromIdSitesString($idSite);
          } else {
              $idSites = array_keys($this->annotations);
          }
  
          // collect annotations that are within the right date range & belong to the right
          // site
          $result = array();
          foreach ($idSites as $idSite) {
              if (!isset($this->annotations[$idSite])) {
                  continue;
              }
  
              foreach ($this->annotations[$idSite] as $idNote => $annotation) {
                  if ($startDate !== false) {
                      $annotationDate = Date::factory($annotation['date']);
                      if ($annotationDate->getTimestamp() < $startDate->getTimestamp()
                          || $annotationDate->getTimestamp() > $endDate->getTimestamp()
                      ) {
                          continue;
                      }
                  }
  
                  $this->augmentAnnotationData($idSite, $idNote, $annotation);
                  $result[$idSite][] = $annotation;
              }
  
              // sort by annotation date
              if (!empty($result[$idSite])) {
                  uasort($result[$idSite], array($this, 'compareAnnotationDate'));
              }
          }
          return $result;
      }
code: public function search($startDate, $endDate, $idSite = false)
      {
          if ($idSite) {
              $idSites = Site::getIdSitesFromIdSitesString($idSite);
          } else {
              $idSites = array_keys($this->annotations);
          }
  
          // collect annotations that are within the right date range & belong to the right
          // site
          $result = array();
          foreach ($idSites as $idSite) {
              if (!isset($this->annotations[$idSite])) {
                  continue;
              }
  
              foreach ($this->annotations[$idSite] as $idNote => $annotation) {
                  if ($startDate !== false) {
                      $annotationDate = Date::factory($annotation['date']);
                      if ($annotationDate->getTimestamp() < $startDate->getTimestamp()
                          || $annotationDate->getTimestamp() > $endDate->getTimestamp()
                      ) {
                          continue;
                      }
                  }
  
                  $this->augmentAnnotationData($idSite, $idNote, $annotation);
                  $result[$idSite][] = $annotation;
              }
  
              // sort by annotation date
              if (!empty($result[$idSite])) {
                  uasort($result[$idSite], array($this, 'compareAnnotationDate'));
              }
          }
          return $result;
      }
code_tokens: public function search ( $ startDate , $ endDate , $ idSite = false ) { if ( $ idSite ) { $ idSites = Site :: getIdSitesFromIdSitesString ( $ idSite ) ; } else { $ idSites = array_keys ( $ this -> annotations ) ; } // collect annotations that are within the right date range & belong to the right // site $ result = array ( ) ; foreach ( $ idSites as $ idSite ) { if ( ! isset ( $ this -> annotations [ $ idSite ] ) ) { continue ; } foreach ( $ this -> annotations [ $ idSite ] as $ idNote => $ annotation ) { if ( $ startDate !== false ) { $ annotationDate = Date :: factory ( $ annotation [ 'date' ] ) ; if ( $ annotationDate -> getTimestamp ( ) < $ startDate -> getTimestamp ( ) || $ annotationDate -> getTimestamp ( ) > $ endDate -> getTimestamp ( ) ) { continue ; } } $ this -> augmentAnnotationData ( $ idSite , $ idNote , $ annotation ) ; $ result [ $ idSite ] [ ] = $ annotation ; } // sort by annotation date if ( ! empty ( $ result [ $ idSite ] ) ) { uasort ( $ result [ $ idSite ] , array ( $ this , 'compareAnnotationDate' ) ) ; } } return $ result ; }
docstring: Returns all annotations within a specific date range. The result is
  an array that maps site IDs with arrays of annotations within the range.
  
  Note: The date range is inclusive.
  
  @see self::get for info on what attributes stored within annotations.
  
  @param Date|bool $startDate The start of the date range.
  @param Date|bool $endDate The end of the date range.
  @param array|bool|int|string $idSite IDs of the sites whose annotations to
  search through.
  @return array Array mapping site IDs with arrays of annotations, eg:
  array(
  '5' => array(
  array(...), // annotation
  array(...), // annotation
  ...
  ),
  '6' => array(
  array(...), // annotation
  array(...), // annotation
  ...
  ),
  )
docstring_tokens: Returns all annotations within a specific date range . The result is an array that maps site IDs with arrays of annotations within the range .