function getSubCatFAs() { global $wgOut, $wgCategoryMagicGallery, $wgCategoryPagingLimit, $wgTitle; $children = $this->children; $fas = count($this->articles_fa); $fas_needed = 10 - count($this->articles_fa); $randomFAs = array(); if ($fas < 10) { $allSubCats = $this->shortListRD($this->children, $this->children_start_char, true); $used = array(); $fas2 = array(); $count = 0; while (count($used) < count($allSubCats)) { $j = rand(0, count($allSubCats)); if (!in_array($j, $used)) { $t = Title::newFromText("Category:" . $allSubCats[$j]); if (isset($t) && $t->getArticleID() > 0) { $cat = new self($t); $fas2 = $cat->getFAs(); $randomFAs = array_merge((array) $fas2, (array) $randomFAs); } if (count($randomFAs) >= $fas_needed) { return $randomFAs; } $used[] = $j; } $count++; if ($count >= 30) { return $randomFAs; } } } return $randomFAs; }