PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/include/Smarty/plugins/function.sugar_evalcolumn.php

https://github.com/mikmagic/sugarcrm_dev
PHP | 108 lines | 38 code | 12 blank | 58 comment | 10 complexity | 59740a8d35e31740068ffd7e82067e4c MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause, AGPL-3.0
  1. <?php
  2. /*
  3. Modification information for LGPL compliance
  4. r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
  5. r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
  6. r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
  7. r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
  8. r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
  9. r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
  10. r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
  11. r42645 - 2008-12-18 13:41:08 -0800 (Thu, 18 Dec 2008) - awu - merging maint_5_2_0 rev41336:HEAD to trunk
  12. r23498 - 2007-06-08 14:05:19 -0700 (Fri, 08 Jun 2007) - clee - Added support for auto generated tabindex.
  13. r22745 - 2007-05-11 18:35:10 -0700 (Fri, 11 May 2007) - majed - fixes compiling issue
  14. r22717 - 2007-05-11 15:02:12 -0700 (Fri, 11 May 2007) - clee - better meta data driven ui support
  15. r22570 - 2007-05-08 16:35:23 -0700 (Tue, 08 May 2007) - clee - Latest revisions.
  16. r22438 - 2007-05-01 18:02:10 -0700 (Tue, 01 May 2007) - clee - Updates for SDUC and developer's build.
  17. r17559 - 2006-11-10 16:01:13 -0800 (Fri, 10 Nov 2006) - wayne - remove extra &
  18. r17518 - 2006-11-07 14:58:53 -0800 (Tue, 07 Nov 2006) - wayne - removed extra &
  19. r17486 - 2006-11-06 15:13:23 -0800 (Mon, 06 Nov 2006) - wayne - added array and tojson support
  20. r17329 - 2006-10-26 15:39:17 -0700 (Thu, 26 Oct 2006) - wayne - defensive code
  21. r12955 - 2006-04-26 18:32:25 -0700 (Wed, 26 Apr 2006) - wayne - custom code in listview smarty stuff
  22. */
  23. /**
  24. * Smarty plugin
  25. * @package Smarty
  26. * @subpackage plugins
  27. */
  28. /**
  29. * Smarty {sugar_evalcolumn} function plugin
  30. *
  31. * Type: function<br>
  32. * Name: sugar_evalcolumn<br>
  33. * Purpose: evaluate a string by substituting values in the rowData parameter. Used for ListViews<br>
  34. *
  35. * @author Wayne Pan {wayne at sugarcrm.com
  36. * @param array
  37. * @param Smarty
  38. */
  39. function smarty_function_sugar_evalcolumn($params, &$smarty)
  40. {
  41. if (!isset($params['colData']['field']) ) {
  42. if(empty($params['colData']))
  43. $smarty->trigger_error("evalcolumn: missing 'colData' parameter");
  44. if(!isset($params['colData']['field']))
  45. $smarty->trigger_error("evalcolumn: missing 'colData.field' parameter");
  46. return;
  47. }
  48. if(empty($params['colData']['field'])) {
  49. return;
  50. }
  51. $params['var'] = $params['colData']['field'];
  52. if(isset($params['toJSON'])) {
  53. $json = getJSONobj();
  54. $params['var'] = $json->encode($params['var']);
  55. }
  56. if (!empty($params['var']['assign'])) {
  57. return '{$' . $params['colData']['field']['name'] . '}';
  58. } else {
  59. $code = $params['var']['customCode'];
  60. if(isset($params['tabindex']) && preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $code, $matches, PREG_PATTERN_ORDER)) {
  61. $str_replace = array();
  62. $tabindex = ' tabindex="' . $params['tabindex'] . '" ';
  63. foreach($matches[3] as $match) {
  64. $str_replace[$match] = $tabindex . $match;
  65. }
  66. $code = str_replace(array_keys($str_replace), array_values($str_replace), $code);
  67. }
  68. if(!empty($params['var']['displayParams']['enableConnectors'])) {
  69. require_once('include/connectors/utils/ConnectorUtils.php');
  70. $code .= '&nbsp;' . ConnectorUtils::getConnectorButtonScript($params['var']['displayParams'], $smarty);
  71. }
  72. return $code;
  73. }
  74. }
  75. ?>