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
23 class CRM_Core_Selector_Base
{
26 * The sort order which is computed from the columnHeaders
33 * The permission mask for this selector
37 protected $_permission = NULL;
40 * The qfKey of the underlying search
47 * This function gets the attribute for the action that.
50 * @param string $match the action to match against
51 * @param string $attribute the attribute to return ( name, link, title )
54 * the attribute that matches the action if any
56 public function getActionAttribute($match, $attribute = 'name') {
57 $links = &$this->links();
59 foreach ($link as $action => $item) {
60 if ($match & $action) {
61 return $item[$attribute];
68 * This is a static virtual function returning reference on links array. Each
69 * inherited class must redefine this function
71 * links is an array of associative arrays. Each element of the array
72 * has at least 3 fields
74 * name : the name of the link
75 * url : the URI to be used for this link
76 * qs : the parameters to the above url along with any dynamic substitutions
77 * title : A more descriptive name, typically used in breadcrumbs / navigation
79 public static function &links() {
84 * Compose the template file name from the class name.
86 * @param string $action
87 * The action being performed.
92 public function getTemplateFileName($action = NULL) {
93 return (str_replace('_', DIRECTORY_SEPARATOR
, CRM_Utils_System
::getClassName($this)) . ".tpl");
97 * Getter for the sorting direction for the fields which will be displayed on the form.
99 * @param string $action the action being performed
102 * the elements that can be sorted along with their properties
104 public function &getSortOrder($action) {
105 $columnHeaders = &$this->getColumnHeaders(NULL);
107 if (!isset($this->_order
)) {
110 $firstElementNotFound = TRUE;
111 if (!empty($columnHeaders)) {
112 foreach ($columnHeaders as $k => $header) {
113 $header = &$columnHeaders[$k];
114 if (array_key_exists('sort', $header)) {
115 if ($firstElementNotFound && $header['direction'] != CRM_Utils_Sort
::DONTCARE
) {
116 $this->_order
[1] = &$header;
117 $firstElementNotFound = FALSE;
120 $this->_order
[$start++
] = &$header;
126 if ($firstElementNotFound) {
127 // CRM_Core_Error::fatal( "Could not find a valid sort directional element" );
130 return $this->_order
;
134 * Setter for permission.
138 public function setPermission($permission) {
139 $this->_permission
= $permission;
143 * Get the display text in plain language for the search
144 * to display on the results page
146 * FIXME: the current internationalisation is bad, but should more or less work
147 * on most of "European" languages
152 public function getQill() {
159 public function getSummary() {
166 public function setKey($key) {
173 public function getKey() {