original_string: public function getSuggestedValuesForSegment($segmentName, $idSite)
      {
          if (empty(Config::getInstance()->General['enable_segment_suggested_values'])) {
              return array();
          }
  
          Piwik::checkUserHasViewAccess($idSite);
  
          $maxSuggestionsToReturn = 30;
          $segment = $this->findSegment($segmentName, $idSite);
  
          // if segment has suggested values callback then return result from it instead
          $suggestedValuesCallbackRequiresTable = false;
          if (isset($segment['suggestedValuesCallback'])) {
              $suggestedValuesCallbackRequiresTable = $this->doesSuggestedValuesCallbackNeedData(
                  $segment['suggestedValuesCallback']);
  
              if (!$suggestedValuesCallbackRequiresTable) {
                  return call_user_func($segment['suggestedValuesCallback'], $idSite, $maxSuggestionsToReturn);
              }
          }
  
          // if period=range is disabled, do not proceed
          if (!Period\Factory::isPeriodEnabledForAPI('range')) {
              return array();
          }
  
          if (!empty($segment['unionOfSegments'])) {
              $values = array();
              foreach ($segment['unionOfSegments'] as $unionSegmentName) {
                  $unionSegment = $this->findSegment($unionSegmentName, $idSite);
  
                  try {
                      $result = $this->getSuggestedValuesForSegmentName($idSite, $unionSegment, $maxSuggestionsToReturn);
                      if (!empty($result)) {
                          $values = array_merge($result, $values);
                      }
                  } catch (\Exception $e) {
                      // we ignore if there was no data found for $unionSegmentName
                  }
              }
  
              if (empty($values)) {
                  throw new \Exception("There was no data to suggest for $segmentName");
              }
  
          } else {
              $values = $this->getSuggestedValuesForSegmentName($idSite, $segment, $maxSuggestionsToReturn);
          }
  
          $values = $this->getMostFrequentValues($values);
          $values = array_slice($values, 0, $maxSuggestionsToReturn);
          $values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);
  
          return $values;
      }
code: public function getSuggestedValuesForSegment($segmentName, $idSite)
      {
          if (empty(Config::getInstance()->General['enable_segment_suggested_values'])) {
              return array();
          }
  
          Piwik::checkUserHasViewAccess($idSite);
  
          $maxSuggestionsToReturn = 30;
          $segment = $this->findSegment($segmentName, $idSite);
  
          // if segment has suggested values callback then return result from it instead
          $suggestedValuesCallbackRequiresTable = false;
          if (isset($segment['suggestedValuesCallback'])) {
              $suggestedValuesCallbackRequiresTable = $this->doesSuggestedValuesCallbackNeedData(
                  $segment['suggestedValuesCallback']);
  
              if (!$suggestedValuesCallbackRequiresTable) {
                  return call_user_func($segment['suggestedValuesCallback'], $idSite, $maxSuggestionsToReturn);
              }
          }
  
          // if period=range is disabled, do not proceed
          if (!Period\Factory::isPeriodEnabledForAPI('range')) {
              return array();
          }
  
          if (!empty($segment['unionOfSegments'])) {
              $values = array();
              foreach ($segment['unionOfSegments'] as $unionSegmentName) {
                  $unionSegment = $this->findSegment($unionSegmentName, $idSite);
  
                  try {
                      $result = $this->getSuggestedValuesForSegmentName($idSite, $unionSegment, $maxSuggestionsToReturn);
                      if (!empty($result)) {
                          $values = array_merge($result, $values);
                      }
                  } catch (\Exception $e) {
                      // we ignore if there was no data found for $unionSegmentName
                  }
              }
  
              if (empty($values)) {
                  throw new \Exception("There was no data to suggest for $segmentName");
              }
  
          } else {
              $values = $this->getSuggestedValuesForSegmentName($idSite, $segment, $maxSuggestionsToReturn);
          }
  
          $values = $this->getMostFrequentValues($values);
          $values = array_slice($values, 0, $maxSuggestionsToReturn);
          $values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);
  
          return $values;
      }
code_tokens: public function getSuggestedValuesForSegment ( $ segmentName , $ idSite ) { if ( empty ( Config :: getInstance ( ) -> General [ 'enable_segment_suggested_values' ] ) ) { return array ( ) ; } Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ maxSuggestionsToReturn = 30 ; $ segment = $ this -> findSegment ( $ segmentName , $ idSite ) ; // if segment has suggested values callback then return result from it instead $ suggestedValuesCallbackRequiresTable = false ; if ( isset ( $ segment [ 'suggestedValuesCallback' ] ) ) { $ suggestedValuesCallbackRequiresTable = $ this -> doesSuggestedValuesCallbackNeedData ( $ segment [ 'suggestedValuesCallback' ] ) ; if ( ! $ suggestedValuesCallbackRequiresTable ) { return call_user_func ( $ segment [ 'suggestedValuesCallback' ] , $ idSite , $ maxSuggestionsToReturn ) ; } } // if period=range is disabled, do not proceed if ( ! Period \ Factory :: isPeriodEnabledForAPI ( 'range' ) ) { return array ( ) ; } if ( ! empty ( $ segment [ 'unionOfSegments' ] ) ) { $ values = array ( ) ; foreach ( $ segment [ 'unionOfSegments' ] as $ unionSegmentName ) { $ unionSegment = $ this -> findSegment ( $ unionSegmentName , $ idSite ) ; try { $ result = $ this -> getSuggestedValuesForSegmentName ( $ idSite , $ unionSegment , $ maxSuggestionsToReturn ) ; if ( ! empty ( $ result ) ) { $ values = array_merge ( $ result , $ values ) ; } } catch ( \ Exception $ e ) { // we ignore if there was no data found for $unionSegmentName } } if ( empty ( $ values ) ) { throw new \ Exception ( "There was no data to suggest for $segmentName" ) ; } } else { $ values = $ this -> getSuggestedValuesForSegmentName ( $ idSite , $ segment , $ maxSuggestionsToReturn ) ; } $ values = $ this -> getMostFrequentValues ( $ values ) ; $ values = array_slice ( $ values , 0 , $ maxSuggestionsToReturn ) ; $ values = array_map ( array ( 'Piwik\Common' , 'unsanitizeInputValue' ) , $ values ) ; return $ values ; }
docstring: Given a segment, will return a list of the most used values for this particular segment.
  @param $segmentName
  @param $idSite
  @throws \Exception
  @return array
docstring_tokens: Given a segment will return a list of the most used values for this particular segment .