| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 6 | | This work is published under the GNU AGPLv3 license with some | |
| 7 | | permitted exceptions and without any warranty. For full license | |
| 8 | | and copyright information, see https://civicrm.org/licensing | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * This interface defines the set of functions a class needs to implement |
| 14 | * to use the CRM/Selector object. |
| 15 | * |
| 16 | * Using this interface allows us to standardize on multiple things including |
| 17 | * list display, pagination, sorting and export in multiple formats (CSV is |
| 18 | * supported right now, XML support will be added as and when needed |
| 19 | * |
| 20 | * @package CRM |
| 21 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 22 | */ |
| 23 | interface CRM_Core_Selector_API { |
| 24 | |
| 25 | /** |
| 26 | * Get pager parameters. |
| 27 | * |
| 28 | * Based on the action, the GET variables and the session state |
| 29 | * it adds various key => value pairs to the params array including |
| 30 | * |
| 31 | * status - the status message to display. Modifiers will be defined |
| 32 | * to integrate the total count and the current state of the |
| 33 | * page: e.g. Displaying Page 3 of 5 |
| 34 | * csvString - The html string to display for export as csv |
| 35 | * rowCount - the number of rows to be included |
| 36 | * |
| 37 | * @param string $action |
| 38 | * The action being performed. |
| 39 | * @param array $params |
| 40 | * The array that the pagerParams will be inserted into. |
| 41 | */ |
| 42 | public function getPagerParams($action, &$params); |
| 43 | |
| 44 | /** |
| 45 | * Returns the sort order array for the given action. |
| 46 | * |
| 47 | * @param string $action |
| 48 | * The action being performed. |
| 49 | * |
| 50 | * @return array |
| 51 | * the elements that can be sorted along with their properties |
| 52 | */ |
| 53 | public function &getSortOrder($action); |
| 54 | |
| 55 | /** |
| 56 | * Returns the column headers as an array of tuples. |
| 57 | * |
| 58 | * (name, sortName (key to the sort array)) |
| 59 | * |
| 60 | * @param string $action |
| 61 | * The action being performed. |
| 62 | * @param string $type |
| 63 | * What should the result set include (web/email/csv). |
| 64 | * |
| 65 | * @return array |
| 66 | * the column headers that need to be displayed |
| 67 | */ |
| 68 | public function &getColumnHeaders($action = NULL, $type = NULL); |
| 69 | |
| 70 | /** |
| 71 | * Returns the number of rows for this action. |
| 72 | * |
| 73 | * @param string $action |
| 74 | * The action being performed. |
| 75 | * |
| 76 | * @return int |
| 77 | * the total number of rows for this action |
| 78 | */ |
| 79 | public function getTotalCount($action); |
| 80 | |
| 81 | /** |
| 82 | * Returns all the rows in the given offset and rowCount. |
| 83 | * |
| 84 | * @param string $action |
| 85 | * The action being performed. |
| 86 | * @param int $offset |
| 87 | * The row number to start from. |
| 88 | * @param int $rowCount |
| 89 | * The number of rows to return. |
| 90 | * @param string $sort |
| 91 | * The sql string that describes the sort order. |
| 92 | * @param string $type |
| 93 | * What should the result set include (web/email/csv). |
| 94 | * |
| 95 | * @return int |
| 96 | * the total number of rows for this action |
| 97 | */ |
| 98 | public function &getRows($action, $offset, $rowCount, $sort, $type = NULL); |
| 99 | |
| 100 | /** |
| 101 | * Return the template (.tpl) filename. |
| 102 | * |
| 103 | * @param string $action |
| 104 | * The action being performed. |
| 105 | * |
| 106 | * @return string |
| 107 | */ |
| 108 | public function getTemplateFileName($action = NULL); |
| 109 | |
| 110 | /** |
| 111 | * Return the filename for the exported CSV. |
| 112 | * |
| 113 | * @param string $type |
| 114 | * The type of export required: csv/xml/foaf etc. |
| 115 | * |
| 116 | * @return string |
| 117 | * the fileName which we will munge to skip spaces and |
| 118 | * special characters to avoid various browser issues |
| 119 | */ |
| 120 | public function getExportFileName($type = 'csv'); |
| 121 | |
| 122 | } |