original_string: public static function getUsage(array $archives = [], $category = null, $includeSubcategories = false, array $cumulativeCategories = [])
      {
          $t = NewsModel::getTable();
  
          // Include the subcategories
          if (null !== $category && $includeSubcategories) {
              $category = static::getAllSubcategoriesIds($category);
          }
  
          $ids = Model::getReferenceValues($t, 'categories', $category);
  
          // Also filter by cumulative categories
          if (count($cumulativeCategories) > 0) {
              $cumulativeIds = null;
  
              foreach ($cumulativeCategories as $cumulativeCategory) {
                  $tmp = Model::getReferenceValues($t, 'categories', $cumulativeCategory);
  
                  // Include the subcategories
                  if ($includeSubcategories) {
                      $tmp = static::getAllSubcategoriesIds($tmp);
                  }
  
                  if ($cumulativeIds === null) {
                      $cumulativeIds = $tmp;
                  } else {
                      $cumulativeIds = array_intersect($cumulativeIds, $tmp);
                  }
              }
  
              $ids = array_intersect($ids, $cumulativeIds);
          }
  
          if (0 === \count($ids)) {
              return 0;
          }
  
          $columns = ["$t.id IN (".\implode(',', \array_unique($ids)).')'];
          $values = [];
  
          // Filter by archives
          if (\count($archives)) {
              $columns[] = "$t.pid IN (".\implode(',', \array_map('intval', $archives)).')';
          }
  
          if (!BE_USER_LOGGED_IN) {
              $time = Date::floorToMinute();
              $columns[] = "($t.start=? OR $t.start<=?) AND ($t.stop=? OR $t.stop>?) AND $t.published=?";
              $values = \array_merge($values, ['', $time, '', $time + 60, 1]);
          }
  
          return NewsModel::countBy($columns, $values);
      }
code: public static function getUsage(array $archives = [], $category = null, $includeSubcategories = false, array $cumulativeCategories = [])
      {
          $t = NewsModel::getTable();
  
          // Include the subcategories
          if (null !== $category && $includeSubcategories) {
              $category = static::getAllSubcategoriesIds($category);
          }
  
          $ids = Model::getReferenceValues($t, 'categories', $category);
  
          // Also filter by cumulative categories
          if (count($cumulativeCategories) > 0) {
              $cumulativeIds = null;
  
              foreach ($cumulativeCategories as $cumulativeCategory) {
                  $tmp = Model::getReferenceValues($t, 'categories', $cumulativeCategory);
  
                  // Include the subcategories
                  if ($includeSubcategories) {
                      $tmp = static::getAllSubcategoriesIds($tmp);
                  }
  
                  if ($cumulativeIds === null) {
                      $cumulativeIds = $tmp;
                  } else {
                      $cumulativeIds = array_intersect($cumulativeIds, $tmp);
                  }
              }
  
              $ids = array_intersect($ids, $cumulativeIds);
          }
  
          if (0 === \count($ids)) {
              return 0;
          }
  
          $columns = ["$t.id IN (".\implode(',', \array_unique($ids)).')'];
          $values = [];
  
          // Filter by archives
          if (\count($archives)) {
              $columns[] = "$t.pid IN (".\implode(',', \array_map('intval', $archives)).')';
          }
  
          if (!BE_USER_LOGGED_IN) {
              $time = Date::floorToMinute();
              $columns[] = "($t.start=? OR $t.start<=?) AND ($t.stop=? OR $t.stop>?) AND $t.published=?";
              $values = \array_merge($values, ['', $time, '', $time + 60, 1]);
          }
  
          return NewsModel::countBy($columns, $values);
      }
code_tokens: public static function getUsage ( array $ archives = [ ] , $ category = null , $ includeSubcategories = false , array $ cumulativeCategories = [ ] ) { $ t = NewsModel :: getTable ( ) ; // Include the subcategories if ( null !== $ category && $ includeSubcategories ) { $ category = static :: getAllSubcategoriesIds ( $ category ) ; } $ ids = Model :: getReferenceValues ( $ t , 'categories' , $ category ) ; // Also filter by cumulative categories if ( count ( $ cumulativeCategories ) > 0 ) { $ cumulativeIds = null ; foreach ( $ cumulativeCategories as $ cumulativeCategory ) { $ tmp = Model :: getReferenceValues ( $ t , 'categories' , $ cumulativeCategory ) ; // Include the subcategories if ( $ includeSubcategories ) { $ tmp = static :: getAllSubcategoriesIds ( $ tmp ) ; } if ( $ cumulativeIds === null ) { $ cumulativeIds = $ tmp ; } else { $ cumulativeIds = array_intersect ( $ cumulativeIds , $ tmp ) ; } } $ ids = array_intersect ( $ ids , $ cumulativeIds ) ; } if ( 0 === \ count ( $ ids ) ) { return 0 ; } $ columns = [ "$t.id IN (" . \ implode ( ',' , \ array_unique ( $ ids ) ) . ')' ] ; $ values = [ ] ; // Filter by archives if ( \ count ( $ archives ) ) { $ columns [ ] = "$t.pid IN (" . \ implode ( ',' , \ array_map ( 'intval' , $ archives ) ) . ')' ; } if ( ! BE_USER_LOGGED_IN ) { $ time = Date :: floorToMinute ( ) ; $ columns [ ] = "($t.start=? OR $t.start<=?) AND ($t.stop=? OR $t.stop>?) AND $t.published=?" ; $ values = \ array_merge ( $ values , [ '' , $ time , '' , $ time + 60 , 1 ] ) ; } return NewsModel :: countBy ( $ columns , $ values ) ; }
docstring: Count the published news by archives.
  
  @param array    $archives
  @param int|null $category
  @param bool     $includeSubcategories
  @param array    $cumulativeCategories
  
  @return int
docstring_tokens: Count the published news by archives .