Exemple #1
0
 function getPostByGroup($dbslug, $offset, $limit)
 {
     $bucket = array();
     /* limit for groups #1,2 and 3 */
     $limitMap = array(0 => 8, 1 => 4, 2 => 2);
     if (!Util::tryEmpty($dbslug)) {
         $slugs = explode(Constants::SPACE, $dbslug);
         $count = 0;
         foreach ($slugs as $slug) {
             if (Util::tryEmpty($slug)) {
                 continue;
             }
             /* fetch only one post beyond group #3 */
             $limit = $count <= 2 ? $limitMap[$count] : 1;
             $ids = $this->getMatch("post_groups", $slug, $offset, $limit);
             // @imp order matters for array_diff
             // bucket should always be second argument!
             $unique = Util::fast_array_diff($ids, $bucket);
             $bucket = array_merge($bucket, $unique);
             $count++;
         }
     }
     return $bucket;
 }