| @@ 5-48 (lines=44) @@ | ||
| 2 | /** |
|
| 3 | * Lists tags that are associated with add-ons. |
|
| 4 | */ |
|
| 5 | class TagsController extends SiteController |
|
| 6 | { |
|
| 7 | ||
| 8 | public static $allowed_actions = array( |
|
| 9 | 'index' |
|
| 10 | ); |
|
| 11 | ||
| 12 | public function index() |
|
| 13 | { |
|
| 14 | return $this->renderWith(array('Tags', 'Page')); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function Title() |
|
| 18 | { |
|
| 19 | return 'Tags'; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function Link() |
|
| 23 | { |
|
| 24 | return Controller::join_links(Director::baseURL(), 'tags'); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function Tags() |
|
| 28 | { |
|
| 29 | $query = new SQLQuery(); |
|
| 30 | $result = new ArrayList(); |
|
| 31 | ||
| 32 | $query |
|
| 33 | ->setSelect('"AddonKeyword"."ID", "Name"') |
|
| 34 | ->selectField('COUNT("AddonKeywordID")', 'Count') |
|
| 35 | ->setFrom('AddonKeyword') |
|
| 36 | ->addLeftJoin('Addon_Keywords', '"AddonKeywordID" = "AddonKeyword"."ID"') |
|
| 37 | ->setGroupBy('"ID"') |
|
| 38 | ->setOrderBy(array('"Count"' => 'DESC', '"Name"' => 'ASC')); |
|
| 39 | ||
| 40 | foreach ($query->execute() as $row) { |
|
| 41 | $link = Controller::join_links( |
|
| 42 | Director::baseURL(), |
|
| 43 | 'add-ons', |
|
| 44 | '?' . http_build_query(array( |
|
| 45 | 'tags[]' => $row['Name'] |
|
| 46 | )) |
|
| 47 | ); |
|
| 48 | ||
| 49 | $result->push(new ArrayData($row + array('Link' => $link))); |
|
| 50 | } |
|
| 51 | ||
| @@ 5-46 (lines=42) @@ | ||
| 2 | /** |
|
| 3 | * Handles listing package vendors. |
|
| 4 | */ |
|
| 5 | class VendorsController extends SiteController |
|
| 6 | { |
|
| 7 | ||
| 8 | public static $allowed_actions = array( |
|
| 9 | 'index' |
|
| 10 | ); |
|
| 11 | ||
| 12 | public function index() |
|
| 13 | { |
|
| 14 | return $this->renderWith(array('Vendors', 'Page')); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function Title() |
|
| 18 | { |
|
| 19 | return 'Vendors'; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function Link() |
|
| 23 | { |
|
| 24 | return Controller::join_links(Director::baseURL(), 'vendors'); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function Vendors() |
|
| 28 | { |
|
| 29 | $query = new SQLQuery(); |
|
| 30 | $result = new ArrayList(); |
|
| 31 | ||
| 32 | $query |
|
| 33 | ->setSelect('"AddonVendor"."Name"') |
|
| 34 | ->selectField('COUNT("Addon"."ID")'. 'Count') |
|
| 35 | ->setFrom('"AddonVendor"') |
|
| 36 | ->addLeftJoin('Addon', '"Addon"."VendorID" = "AddonVendor"."ID"') |
|
| 37 | ->setGroupBy('"AddonVendor"."ID"') |
|
| 38 | ->setOrderBy(array('"Count"' => 'DESC', '"Name"' => 'ASC')); |
|
| 39 | ||
| 40 | foreach ($query->execute() as $row) { |
|
| 41 | $link = Controller::join_links( |
|
| 42 | Director::baseURL(), |
|
| 43 | 'add-ons', |
|
| 44 | $row['Name'] |
|
| 45 | ); |
|
| 46 | ||
| 47 | $result->push(new ArrayData($row + array('Link' => $link))); |
|
| 48 | } |
|
| 49 | ||