/** * Generate number pages (subitems) in a certain range with a specified interval. * * @param int $from Index of the first page. * @param int $to Index of the last page. * @param int $interval Interval between pages. * @return array $new_subitems Generated items. */ public function generate_pages_with_interval($from, $to, $interval = 1) { $collection = $this->get_collection(); $new_subitems = array(); for ($i = $from; $i < $to; $i += $interval) { $page_item = new Carbon_Pagination_Item_Page($collection); $page_item->set_page_number($i); $new_subitems[] = $page_item; } return $new_subitems; }
/** * Create a new subitems collection with a single subitem * for the specified collection with the specified HTML and page number. * * @static * @param Carbon_Pagination_Collection $collection Collection of the original item. * @param string $html HTML of the new subitem. * @param int $page_number The number of the page to link the subitem to. * @return Carbon_Pagination_Collection $subitems_collection The new subitems collection. */ public static function generate_single_subitem_collection($collection, $html, $page_number) { $page_item = new Carbon_Pagination_Item_Page($collection); $page_item->set_html($html); $page_item->set_page_number($page_number); // create and assign the subitems collection $subitems_collection = new Carbon_Pagination_Collection($collection->get_pagination(), false); $subitems_collection->set_items(array($page_item)); return $subitems_collection; }