3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
30 * A simple base class for objects that need to implement the selector api
31 * interface. This class provides common functionality with regard to actions
35 * @copyright CiviCRM LLC (c) 2004-2014
39 class CRM_Core_Selector_Base
{
42 * The sort order which is computed from the columnHeaders
49 * The permission mask for this selector
53 protected $_permission = NULL;
56 * The qfKey of the underlying search
63 * This function gets the attribute for the action that
66 * @param string match the action to match against
67 * @param string attribute the attribute to return ( name, link, title )
69 * @return string the attribute that matches the action if any
74 function getActionAttribute($match, $attribute = 'name') {
75 $links = &$this->links();
77 foreach ($link as $action => $item) {
78 if ($match & $action) {
79 return $item[$attribute];
86 * This is a static virtual function returning reference on links array. Each
87 * inherited class must redefine this function
89 * links is an array of associative arrays. Each element of the array
90 * has at least 3 fields
92 * name : the name of the link
93 * url : the URI to be used for this link
94 * qs : the parameters to the above url along with any dynamic substitutions
95 * title : A more descriptive name, typically used in breadcrumbs / navigation
97 static function &links() {
102 * Compose the template file name from the class name
104 * @param string $action the action being performed
106 * @return string template file name
109 function getTemplateFileName($action = NULL) {
110 return (str_replace('_', DIRECTORY_SEPARATOR
, CRM_Utils_System
::getClassName($this)) . ".tpl");
114 * Getter for the sorting direction for the fields which will be displayed on the form.
116 * @param string action the action being performed
118 * @return array the elements that can be sorted along with their properties
121 function &getSortOrder($action) {
122 $columnHeaders = &$this->getColumnHeaders(NULL);
124 if (!isset($this->_order
)) {
125 $this->_order
= array();
127 $firstElementNotFound = TRUE;
128 if (!empty($columnHeaders)) {
129 foreach ($columnHeaders as $k => $header) {
130 $header = &$columnHeaders[$k];
131 if (array_key_exists('sort', $header)) {
132 if ($firstElementNotFound && $header['direction'] != CRM_Utils_Sort
::DONTCARE
) {
133 $this->_order
[1] = &$header;
134 $firstElementNotFound = FALSE;
137 $this->_order
[$start++
] = &$header;
143 if ($firstElementNotFound) {
144 // CRM_Core_Error::fatal( "Could not find a valid sort directional element" );
147 return $this->_order
;
151 * Setter for permission
156 public function setPermission($permission) {
157 $this->_permission
= $permission;
161 * Get the display text in plain language for the search
162 * to display on the results page
167 public function getQill() {
174 public function getSummary() {
181 public function setKey($key) {
188 public function getKey() {