3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
14 * A simple base class for objects that need to implement the selector api
15 * interface. This class provides common functionality with regard to actions
19 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 class CRM_Core_Selector_Base
{
24 * The sort order which is computed from the columnHeaders
31 * The permission mask for this selector
35 protected $_permission = NULL;
38 * The qfKey of the underlying search
45 * This function gets the attribute for the action that.
48 * @param string $match the action to match against
49 * @param string $attribute the attribute to return ( name, link, title )
52 * the attribute that matches the action if any
54 public function getActionAttribute($match, $attribute = 'name') {
55 $links = &$this->links();
57 foreach ($link as $action => $item) {
58 if ($match & $action) {
59 return $item[$attribute];
66 * This is a static virtual function returning reference on links array. Each
67 * inherited class must redefine this function
69 * links is an array of associative arrays. Each element of the array
70 * has at least 3 fields
72 * name : the name of the link
73 * url : the URI to be used for this link
74 * qs : the parameters to the above url along with any dynamic substitutions
75 * title : A more descriptive name, typically used in breadcrumbs / navigation
77 public static function &links() {
82 * Compose the template file name from the class name.
84 * @param string $action
85 * The action being performed.
90 public function getTemplateFileName($action = NULL) {
91 return (str_replace('_', DIRECTORY_SEPARATOR
, CRM_Utils_System
::getClassName($this)) . ".tpl");
95 * Getter for the sorting direction for the fields which will be displayed on the form.
97 * @param string $action the action being performed
100 * the elements that can be sorted along with their properties
102 public function &getSortOrder($action) {
103 $columnHeaders = &$this->getColumnHeaders(NULL);
105 if (!isset($this->_order
)) {
108 $firstElementNotFound = TRUE;
109 if (!empty($columnHeaders)) {
110 foreach ($columnHeaders as $k => $header) {
111 $header = &$columnHeaders[$k];
112 if (array_key_exists('sort', $header)) {
113 if ($firstElementNotFound && $header['direction'] != CRM_Utils_Sort
::DONTCARE
) {
114 $this->_order
[1] = &$header;
115 $firstElementNotFound = FALSE;
118 $this->_order
[$start++
] = &$header;
125 return $this->_order
;
129 * Setter for permission.
133 public function setPermission($permission) {
134 $this->_permission
= $permission;
138 * Get the display text in plain language for the search
139 * to display on the results page
141 * FIXME: the current internationalisation is bad, but should more or less work
142 * on most of "European" languages
147 public function getQill() {
154 public function getSummary() {
161 public function setKey($key) {
168 public function getKey() {