BxDolGrid.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentCore Trident Core
  7. * @{
  8. */
  9. /**
  10. * @page objects
  11. * @section grid Grid
  12. * @ref BxDolGrid
  13. */
  14. /**
  15. * Grid for any content.
  16. *
  17. * It allows to display some data as grid with ready to use features:
  18. * - paginate
  19. * - reordering
  20. * - sorting
  21. * - search
  22. * - actions
  23. *
  24. * The advantages of the this system:
  25. * - Less code to write - so you can concentrate on the main functionality.
  26. * - Flexibility - you can turn on/off ready features or override it for the custom behavior.
  27. *
  28. * Grid is working together with Paginate to look through the data in the grid. @see BxDolPaginate
  29. *
  30. * @section grid_create Creating the new Grid object:
  31. *
  32. * 1. add record to 'sys_objects_grid' table:
  33. *
  34. * - object: name of the grid object, in the format: vendor prefix, underscore, module prefix, underscore, internal identifier or nothing; for example: bx_profiles_admin - to display profiles in admin panel.
  35. * - source_type: type of the source data:
  36. * - Sql: the source is SQL query.
  37. * - Array: the source is serialized array.
  38. * - source: the source data, different for each 'source_type':
  39. * - Sql: the SQL query string, without ORDER BY and LIMIT clauses, these clauses are added automatically for sorting, pagination and filtering.
  40. * - Array: 2 dimentional serialized array string.
  41. * - table: table name (if 'source_type' is 'Sql'), to automatically update order field and delete records.
  42. * - field_id: name of the ID field.
  43. * - field_order: name of the order field.
  44. * - field_active: name of the field which determines if the row is active or disabled. This field is used to display row as disabled (ususally as grayed out).
  45. * The following functions can be overrided for custom behavior:
  46. * - '_switcherChecked2State' and '_switcherState2Checked': override these functions if value of 'field_active' field is different from '0' and '1'
  47. * - '_enable': for custom behavior upon activation/deactivation
  48. * - '_isRowDisabled' and '_isCheckboxDisabled': for displaying disabled rows which is not related to 'field_active' field.
  49. * - '_isSwitcherOn': to display rows which are active/disabled by default.
  50. * - paginate_url: URL of the page for the grid, set it empty for AJAX paginate, or specify the url for regular page reloading in paginate, with the following markers:
  51. * - {start}: starting record to show data from.
  52. * - {per_page}: number of records per one page.
  53. * - paginate_per_page: number of records per one page.
  54. * - paginate_simple: show full or simple paginate, the following values are supported:
  55. * - NULL: show full(big) paginate.
  56. * - ''(empty string): show simple(small) paginate.
  57. * - 'some url': show simple(small) paginate with "View All" link to the specified URL.
  58. * - paginate_get_start: GET variable name for 'start'.
  59. * - paginate_get_per_page: GET variable name for 'per_page'.
  60. * - filter_fields: comma separated list of field names to search in; if field contains language key then it is better to specify it in 'filter_fields_translatable'.
  61. * - filter_fields_translatable: comma separated list of field names to search in its translations; enter field name here if field contains language key.
  62. * - filter_mode: search mode:
  63. * - like: use SQL LIKE expression for search, if 'source_type' is not 'Sql' it doesn't matter.
  64. * - fulltext: use MATCH ... AGAINST expression for search, if 'source_type' is not 'Sql' it doesn't matter.
  65. * - auto: use 'like' or 'fulltext', depending on 'useLikeOperator' setting option.
  66. * - sorting_fields: comma separated field names, which will be allowed for sorting, if field contains language keys, specify it in 'sorting_fields_translatable' field instead.
  67. * - sorting_fields_translatable: comma separated field names which need to be sorted by translations, enter field name here if field contains language key.
  68. * - visible_for_levels: bit field with set of member level ids. To use member level id in bit field - the level id minus 1 as power of 2 is used, for example:
  69. * - user level id = 1 -> 2^(1-1) = 1
  70. * - user level id = 2 -> 2^(2-1) = 2
  71. * - user level id = 3 -> 2^(3-1) = 4
  72. * - user level id = 4 -> 2^(4-1) = 8
  73. * - override_class_name: user defined class name which is derived from BxTemplGrid.
  74. * - override_class_file: the location of the user defined class, leave it empty if class is located in system folders.
  75. *
  76. * 2. Specify field names (columns in the grid) in sys_grid_fields table:
  77. *
  78. * - object: name of the Grid object.
  79. * - name: name of the field, it must refer to the SQL field name in the case of 'Sql' 'source_type' or index of the 2 dimentional array in the case of 'Array' 'source_type'.
  80. * - title: title of the field, the language key.
  81. * - width: width of the column in % or px, pt, etc.
  82. * - translatable: if field contains language key and it is needed to display translation for this key - set it to 1, by default 0.
  83. * - params: searialized array of additional params:
  84. * - display: display function from BxDolFormCheckerHelper class, for example to convert unix timestamp to the regular date/time string.
  85. * - attr_cell: tag attributes for the data cell.
  86. * - attr_head: tag attributes for the header cell.
  87. * - order: order of the field.
  88. *
  89. * There are some fields which are always available, additionally to the provided set of fields:
  90. *
  91. * - order: display column as dragable handle, it makes sense if you have data ordered by some field
  92. * and it is specified in field_order, field_id and table fields; reordering is not correctly
  93. * working with paginate, so make sure that paginate_per_page number is big enough to show all records;
  94. * reordering is working with Sql source_type.
  95. * - checkbox: display column with checkboxes, so several records can be selected for bulk action;
  96. * you need to specify 'field_id' field, so every checkbox have unique row id;
  97. * you need to specify bulk actions separately in 'sys_grid_actions' table;
  98. * you can override '_isCheckboxSelected' function to display checkbox as checked by default.
  99. * - actions: display column with single actions, displayed as buttons; you need to specify field_id field,
  100. * so every action is provided with unique row id; you need to specify single actions separately in sys_grid_actions table.
  101. *
  102. * 3. Add actions to sys_grid_actions table:
  103. *
  104. * - object: name of the Grid object.
  105. * - type: action type, one of the following:
  106. * - bulk: bulk action, to perform on the set of records, the action is usually displaed below the grid.
  107. * - single: simple action, to perform on one record, the action is usually displayed in the grid row.
  108. * - independent: independent actionm which is not related to any rowm the action is usually displayed above the grid.
  109. * - name: action name.
  110. * - title: title of the action, the language key.
  111. * - icon: display action as icon, title need to be empty in this case.
  112. * - confirm: ask confirmation before performing the action, 0 or 1.
  113. * - order: order of the action in particular actions set by type.
  114. *
  115. * Usually you need to handle actions manually, but there are several actions which are available by default:
  116. *
  117. * - delete: delete the record, it works automatically when 'source_type' is 'Sql' and 'field_id', 'table' fields are specified.
  118. *
  119. *
  120. *
  121. * @section grid_display_custom_cell Displaying custom cell
  122. *
  123. * Cell is displayed with default design. It is possible to easily customize its design by specifying custom attributes as 'attr_cell' in params field in sys_grid_fields table.
  124. *
  125. * If it is not enough, you can customize it even more by adding the method to your custom class with the following format:
  126. * _getCell[field name]
  127. * where [field name] is the name of the field you want to have custom look with the capital first letter.
  128. *
  129. * For example:
  130. *
  131. * @code
  132. * protected function _getCellStatus ($mixedValue, $sKey, $aField, $aRow) {
  133. *
  134. * $sAttr = $this->_convertAttrs(
  135. * $aField, 'attr_cell',
  136. * false,
  137. * isset($aField['width']) ? 'width:' . $aField['width'] : false // add default styles
  138. * );
  139. * return '<td ' . $sAttr . '><span style="background-color:' . ('Active' == $mixedValue ? '#cfc' : '#fcc') . '">' . $mixedValue . '</span></td>';
  140. * }
  141. * @endcode
  142. *
  143. * Above example is displaying user's status using different colors depending on the status value. Please note that you need to convert attributes by adding some default classes or styles if you need.
  144. *
  145. *
  146. *
  147. * @section grid_display_custom_header Displaying custom column header
  148. *
  149. * This is working similar to displaying custom cell. It easily customize its design by specifying custom attributes as 'attr_head' in params field in sys_grid_fields table.
  150. * If it is not enough, you can customize it even more by adding the method to your custom class with the following format:
  151. * _getCellHeader[field name]
  152. * where [field name] is the name of the field you want to have custom look with the capital first letter.
  153. *
  154. * For example:
  155. *
  156. * @code
  157. * protected function _getCellHeaderStatus ($sKey, $aField) {
  158. * $s = parent::_getCellHeaderDefault($sKey, $aField);
  159. * return preg_replace ('/<th(.*?)>(.*?)<\/th>/', '<th$1><img src="' . BxDolTemplate::getInstance()->getIconUrl('user.png') . '"></th>', $s);
  160. * }
  161. * @endcode
  162. *
  163. * The above example replaces column header text with the image.
  164. *
  165. *
  166. *
  167. * @section grid_display_custom_action Displaying custom action
  168. *
  169. * All actions are displayed as buttons. Bulk and independent actions are displaed as big buttons and single actions are displayed as small buttons.
  170. *
  171. * It is possible to completely customize it by adding the following method to your custom class:
  172. * _getAction[action name]
  173. * where [action name] is the action name with the capital first letter.
  174. *
  175. * For example:
  176. *
  177. * @code
  178. * protected function _getActionCustom1 ($sType, $sKey, $a, $isSmall = false) {
  179. * $sAttr = $this->_convertAttrs(
  180. * $a, 'attr',
  181. * 'bx-btn bx-def-margin-sec-left' . ($isSmall ? ' bx-btn-small' : '') // add default classes
  182. * );
  183. * return '<button ' . $sAttr . ' onclick="$(this).off(); alert(\'default behaviour is overrided, so the action is not performed\');">' . $a['title'] . '</button>';
  184. * }
  185. * @endcode
  186. *
  187. * The above example disables default onclick event and just displays an alert. Please note that you need to convert attributes by adding some default classes or styles if you need.
  188. *
  189. *
  190. *
  191. * @section grid_add_action_handler Add action handler
  192. *
  193. * As it was mentioned earlier only several actions can be handled automatically, all other actions must be processed manually.
  194. * To add action handler you need to add method to your custom class with the following format:
  195. * performAction[action name]
  196. * where [action name] is the action name with the capital first letter.
  197. *
  198. * For example:
  199. *
  200. * @code
  201. * public function performActionApprove() {
  202. *
  203. * $iAffected = 0;
  204. * $aIds = bx_get('ids');
  205. * if (!$aIds || !is_array($aIds)) {
  206. * $this->_echoResultJson(array());
  207. * exit;
  208. * }
  209. *
  210. * $aIdsAffected = array ();
  211. * foreach ($aIds as $mixedId) {
  212. * if (!$this->_approve($mixedId))
  213. * continue;
  214. * $aIdsAffected[] = $mixedId;
  215. * $iAffected++;
  216. * }
  217. *
  218. * $this->_echoResultJson(array(
  219. * 'msg' => $iAffected > 0 ? sprintf("%d profiles successfully activated", $iAffected) : "Profile(s) activation failed",
  220. * 'grid' => $this->getCode(false),
  221. * 'blink' => $aIdsAffected,
  222. * ));
  223. * }
  224. *
  225. * protected function _approve ($mixedId) {
  226. * $oDb = BxDolDb::getInstance();
  227. * $sTable = $this->_aOptions['table'];
  228. * $sFieldId = $this->_aOptions['field_id'];
  229. * $sQuery = $oDb->prepare("UPDATE `{$sTable}` SET `Status` = 'Active' WHERE `{$sFieldId}` = ?", $mixedId);
  230. * return $oDb->query($sQuery);
  231. * }
  232. * @endcode
  233. *
  234. * The action can be used as 'single' or 'bulk', in the case of 'single' action 'ids' array always has one element.
  235. *
  236. * As the result, action must outputs JSON array, which is done by _echoResultJson function.
  237. * The defined indexes in the array determines behavior after action is performed, the following behaviors are supported:
  238. *
  239. * - msg: display javascript alert message.
  240. * - grid: reload grid data with the provided HTML code.
  241. * - popup: display popup with the provided HTML code.
  242. * - blink: highlight(blink effect) the specified rows, by the ids.
  243. *
  244. */
  245. class BxDolGrid extends BxDol implements iBxDolFactoryObject, iBxDolReplaceable
  246. {
  247. protected $_aMarkers = array ();
  248. protected $_sObject;
  249. protected $_aOptions;
  250. protected $_sDefaultSortingOrder = 'ASC';
  251. /**
  252. * Constructor
  253. * @param $aOptions array of grid options
  254. */
  255. public function __construct($aOptions)
  256. {
  257. parent::__construct();
  258. $this->_sObject = $aOptions['object'];
  259. $this->_aOptions = $aOptions;
  260. }
  261. /**
  262. * Get grid object instance by object name
  263. * @param $sObject object name
  264. * @return object instance or false on error
  265. */
  266. public static function getObjectInstance($sObject)
  267. {
  268. if (isset($GLOBALS['bxDolClasses']['BxDolGrid!'.$sObject]))
  269. return $GLOBALS['bxDolClasses']['BxDolGrid!'.$sObject];
  270. $aObject = BxDolGridQuery::getGridObject($sObject);
  271. if (!$aObject || !is_array($aObject))
  272. return false;
  273. $sClass = 'BxTemplGrid';
  274. if (!empty($aObject['override_class_name'])) {
  275. $sClass = $aObject['override_class_name'];
  276. if (!empty($aObject['override_class_file']))
  277. require_once(BX_DIRECTORY_PATH_ROOT . $aObject['override_class_file']);
  278. }
  279. $o = new $sClass($aObject);
  280. if (!$o->_isVisibleGrid($aObject))
  281. return false;
  282. return ($GLOBALS['bxDolClasses']['BxDolGrid!'.$sObject] = $o);
  283. }
  284. public function getObject()
  285. {
  286. return $this->_sObject;
  287. }
  288. /**
  289. * Add replace markers. Curently markers are replaced in 'source' field
  290. * @param $a array of markers as key => value
  291. * @return true on success or false on error
  292. */
  293. public function addMarkers ($a)
  294. {
  295. if (empty($a) || !is_array($a))
  296. return false;
  297. $this->_aMarkers = array_merge ($this->_aMarkers, $a);
  298. return true;
  299. }
  300. /**
  301. * Replace provided markers in form array
  302. * @param $a form description array
  303. * @return array where markes are replaced with real values
  304. */
  305. protected function _replaceMarkers ()
  306. {
  307. $this->_aOptions['source'] = bx_replace_markers($this->_aOptions['source'], $this->_aMarkers);
  308. }
  309. protected function _getData ($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  310. {
  311. $sFunc = '_getData' . $this->_aOptions['source_type'];
  312. return $this->$sFunc($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  313. }
  314. protected function _getDataArray ($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  315. {
  316. if ($this->_aOptions['source'] && !is_array($this->_aOptions['source'])) {
  317. $this->_aOptions['source'] = unserialize($this->_aOptions['source']);
  318. }
  319. // apply filter
  320. if ($sFilter && (!empty($this->_aOptions['filter_fields']) || !empty($this->_aOptions['filter_fields_translatable']))) {
  321. $aSource = array();
  322. foreach ($this->_aOptions['source'] as $aRow) {
  323. $bFound = false;
  324. if (!empty($this->_aOptions['filter_fields'])) {
  325. foreach ($this->_aOptions['filter_fields'] as $sField) {
  326. if (empty($aRow[$sField]) || false === stripos($aRow[$sField], $sFilter))
  327. continue;
  328. $aSource[] = $aRow;
  329. $bFound = true;
  330. break;
  331. }
  332. }
  333. if (!$bFound && !empty($this->_aOptions['filter_fields_translatable'])) {
  334. foreach ($this->_aOptions['filter_fields_translatable'] as $sField) {
  335. if (empty($aRow[$sField]) || false === stripos(_t($aRow[$sField]), $sFilter))
  336. continue;
  337. $aSource[] = $aRow;
  338. $bFound = true;
  339. break;
  340. }
  341. }
  342. }
  343. } else {
  344. $aSource = &$this->_aOptions['source'];
  345. }
  346. // sort
  347. $sSortField = false;
  348. $iSortDir = 1;
  349. if ($sOrderField && !empty($this->_aOptions['sorting_fields']) && is_array($this->_aOptions['sorting_fields']) && in_array($sOrderField, $this->_aOptions['sorting_fields'])) { // explicit order
  350. $sSortField = $sOrderField;
  351. $iSortDir = 0 == strcasecmp($sOrderDir, 'desc') ? -1 : 1;
  352. } elseif (!empty($this->_aOptions['field_order'])) { // order by "order" field
  353. $sSortField = $this->_aOptions['field_order'];
  354. }
  355. if ($sSortField) {
  356. $aSourceOrdered = $aSource;
  357. $this->_tmpOrderField = $sSortField;
  358. $this->_tmpOrderDir = $iSortDir;
  359. usort($aSourceOrdered, array($this, '_cmp'));
  360. } else {
  361. $aSourceOrdered = &$aSource;
  362. }
  363. return array_slice($aSourceOrdered, $iStart, $iPerPage, true);
  364. }
  365. protected function _getDataSql ($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  366. {
  367. $oDb = BxDolDb::getInstance();
  368. $sQuery = $this->_aOptions['source'];
  369. if (false === stripos($sQuery, ' WHERE '))
  370. $sQuery .= " WHERE 1 ";
  371. // add filter condition
  372. $sOrderByFilter = '';
  373. if ($sFilter && (!empty($this->_aOptions['filter_fields']) || !empty($this->_aOptions['filter_fields_translatable']))) {
  374. $sMode = $this->_aOptions['filter_mode'];
  375. if ($sMode != 'like' && $sMode != 'fulltext')
  376. $sMode = getParam('useLikeOperator') ? 'like' : 'fulltext';
  377. $sCond = '';
  378. if ('like' == $sMode) { // LIKE search
  379. // condition for regular fields
  380. if (!empty($this->_aOptions['filter_fields']))
  381. foreach ($this->_aOptions['filter_fields'] as $sField)
  382. $sCond .= $oDb->prepare("`{$sField}` LIKE ? OR ", '%' . $sFilter . '%');
  383. // condition for translatable fields
  384. if (!empty($this->_aOptions['filter_fields_translatable'])) {
  385. $sCondFields = '';
  386. foreach ($this->_aOptions['filter_fields_translatable'] as $sField)
  387. $sCondFields .= "`k`.`Key` = `{$sField}` OR ";
  388. $sCondFields = rtrim($sCondFields, ' OR ');
  389. if ($sCondFields)
  390. $sCond .= $oDb->prepare("(SELECT 1 FROM `sys_localization_strings` AS `s` INNER JOIN `sys_localization_keys` AS `k` ON (`k`.`ID` = `s`.`IDKey`) WHERE `s`.`string` LIKE ? AND ($sCondFields) LIMIT 1) OR ", '%' . $sFilter . '%');
  391. }
  392. $sCond = rtrim($sCond, ' OR ');
  393. } else { // FULLTEXT search
  394. // condition for regular fields
  395. if (!empty($this->_aOptions['filter_fields'])) {
  396. $sCondFields = '';
  397. foreach ($this->_aOptions['filter_fields'] as $sField)
  398. $sCondFields .= "`{$sField}`,";
  399. $sCondFields = rtrim($sCondFields, ',');
  400. if ($sCondFields) {
  401. $sCond = $oDb->prepare(" MATCH ($sCondFields) AGAINST (?) ", $sFilter);
  402. $sOrderByFilter = $sCond;
  403. $sCond .= ' > 1 OR ';
  404. }
  405. }
  406. // condition for translatable fields
  407. if (!empty($this->_aOptions['filter_fields_translatable'])) {
  408. $sCondFields = '';
  409. foreach ($this->_aOptions['filter_fields_translatable'] as $sField)
  410. $sCondFields .= "`k`.`Key` = `{$sField}` OR ";
  411. $sCondFields = rtrim($sCondFields, ' OR ');
  412. if ($sCondFields)
  413. $sCond .= $oDb->prepare("(SELECT 1 FROM `sys_localization_strings` AS `s` INNER JOIN `sys_localization_keys` AS `k` ON (`k`.`ID` = `s`.`IDKey`) WHERE MATCH (`s`.`string`) AGAINST (?) AND ($sCondFields) LIMIT 1) OR ", $sFilter);
  414. }
  415. $sCond = rtrim($sCond, ' OR ');
  416. }
  417. if ($sCond)
  418. $sQuery .= ' AND (' . $sCond . ')';
  419. }
  420. // add order
  421. $sQuery .= $this->_getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir);
  422. $sQuery = $sQuery . $oDb->prepare(' LIMIT ?, ?', $iStart, $iPerPage);
  423. return $oDb->getAll($sQuery);
  424. }
  425. protected function _getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir)
  426. {
  427. $sOrderClause = '';
  428. if ($sOrderField && is_array($this->_aOptions['sorting_fields']) && in_array($sOrderField, $this->_aOptions['sorting_fields'])) { // explicit order
  429. $sDir = (0 == strcasecmp($sOrderDir, 'desc') ? 'DESC' : 'ASC');
  430. if (is_array($this->_aOptions['sorting_fields_translatable']) && in_array($sOrderField, $this->_aOptions['sorting_fields_translatable'])) {
  431. // translatable fields
  432. $iLang = BxDolLanguages::getInstance()->getCurrentLangId();
  433. $oDb = BxDolDb::getInstance();
  434. $sOrderClause = $oDb->prepare("ORDER BY (SELECT `s`.`string` FROM `sys_localization_strings` AS `s` INNER JOIN `sys_localization_keys` AS `k` ON (`k`.`ID` = `s`.`IDKey`) WHERE `k`.`KEY` = `$sOrderField` AND `s`.`IDLanguage` = ? LIMIT 1) ", $iLang) . $sDir;
  435. } else {
  436. // regular fields
  437. $sOrderClause = " ORDER BY `$sOrderField` $sDir";
  438. }
  439. } elseif ($sOrderByFilter) { // order by filter
  440. $sOrderClause = " ORDER BY $sOrderByFilter DESC";
  441. } elseif (!empty($this->_aOptions['field_order'])) { // order by "order" field
  442. if (false == strpos($this->_aOptions['field_order'], ',')) {
  443. $sOrderClause = " ORDER BY `" . $this->_aOptions['field_order'] . "` " . $this->_sDefaultSortingOrder;
  444. } else {
  445. $a = explode(',', $this->_aOptions['field_order']);
  446. foreach ($a as $sField)
  447. $sOrderClause .= "`" . trim($sField) . "` " . $this->_sDefaultSortingOrder . ", ";
  448. if ($sOrderClause)
  449. $sOrderClause = " ORDER BY " . trim($sOrderClause, ', ');
  450. }
  451. }
  452. return $sOrderClause;
  453. }
  454. protected function _getCellData($sKey, $aField, $aRow)
  455. {
  456. if (isset($aRow[$sKey])) {
  457. if (!empty($aField['display'])) {
  458. bx_import('BxDolForm');
  459. $sDisplayFunc = 'display' . $aField['display'];
  460. $oDisplay = new BxDolFormCheckerHelper();
  461. return $oDisplay->$sDisplayFunc($aRow[$sKey]);
  462. } else {
  463. return bx_process_output($aRow[$sKey]);
  464. }
  465. } else {
  466. return _t('_undefined');
  467. }
  468. }
  469. protected function _cmp ($r1, $r2)
  470. {
  471. $iRet = strcasecmp($r1[$this->_tmpOrderField], $r2[$this->_tmpOrderField]);
  472. return $iRet ? $this->_tmpOrderDir * $iRet : 0;
  473. }
  474. protected function _genMethodName ($s)
  475. {
  476. return bx_gen_method_name($s);
  477. }
  478. protected function _isVisibleGrid ($a)
  479. {
  480. if (!isset($a['visible_for_levels']))
  481. return true;
  482. return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
  483. }
  484. }
  485. /** @} */