/** * Renders and returns output for given view filename with its * array of data. * * @param string $___viewFn Filename of the view * @param array $___dataForView Data to include in rendered view * @return string Rendered output * @access protected */ function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) { $loadedHelpers = array(); if ($this->helpers != false && $loadHelpers === true) { $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); foreach (array_keys($loadedHelpers) as $helper) { $camelBackedHelper = Inflector::variable($helper); ${$camelBackedHelper} =& $loadedHelpers[$helper]; $this->loaded[$camelBackedHelper] =& ${$camelBackedHelper}; $this->smarty->assign_by_ref($camelBackedHelper, ${$camelBackedHelper}); } $this->_triggerHelpers('beforeRender', 'beforeSmartyRender'); } foreach ($___dataForView as $data => $value) { if (!is_object($data)) { $this->smarty->assign($data, $value); } } $this->smarty->assign_by_ref('view', $this); ob_start(); echo $this->smarty->fetch($___viewFn); if ($loadHelpers === true) { $this->_triggerHelpers('afterRender', 'afterSmartyRender'); } $out = ob_get_clean(); $caching = isset($this->loaded['cache']) && $this->cacheAction != false && Configure::read('Cache.check') === true; if ($caching) { if (is_a($this->loaded['cache'], 'CacheHelper')) { $cache =& $this->loaded['cache']; $cache->base = $this->base; $cache->here = $this->here; $cache->helpers = $this->helpers; $cache->action = $this->action; $cache->controllerName = $this->name; $cache->layout = $this->layout; $cache->cacheAction = $this->cacheAction; $cache->cache($___viewFn, $out, $cached); } } return $out; }
/** * Build custom data view * @param object $form page object * @param array $groupTree associated array * @param boolean $returnCount true if customValue count needs to be returned */ static function buildCustomDataView(&$form, &$groupTree, $returnCount = false, $groupID = null, $prefix = null) { foreach ($groupTree as $key => $group) { if ($key === 'info') { continue; } foreach ($group['fields'] as $k => $properties) { $groupID = $group['id']; if (!empty($properties['customValue'])) { foreach ($properties['customValue'] as $values) { $details[$groupID][$values['id']]['title'] = CRM_Utils_Array::value('title', $group); $details[$groupID][$values['id']]['name'] = CRM_Utils_Array::value('name', $group); $details[$groupID][$values['id']]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); $details[$groupID][$values['id']]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][$values['id']]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][$values['id']]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); $details[$groupID][$values['id']]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties), 'field_type' => CRM_Utils_Array::value('html_type', $properties), 'field_value' => self::formatCustomValues($values, $properties), 'options_per_line' => CRM_Utils_Array::value('options_per_line', $properties)); } } else { $details[$groupID][0]['title'] = CRM_Utils_Array::value('title', $group); $details[$groupID][0]['name'] = CRM_Utils_Array::value('name', $group); $details[$groupID][0]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); $details[$groupID][0]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][0]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][0]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); $details[$groupID][0]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties)); } } } if ($returnCount) { return count($details[$groupID]); } else { $form->assign_by_ref("{$prefix}viewCustomData", $details); } }
/** * Build custom data view * @param object $form page object * @param array $groupTree associated array * @param boolean $returnCount true if customValue count needs to be returned */ static function buildCustomDataView(&$form, &$groupTree, $returnCount = false, $groupID = null, $prefix = null) { foreach ($groupTree as $key => $group) { if ($key === 'info') { continue; } foreach ($group['fields'] as $k => $properties) { $groupID = $group['id']; if (!empty($properties['customValue'])) { foreach ($properties['customValue'] as $values) { $details[$groupID][$values['id']]['title'] = CRM_Utils_Array::value('title', $group); $details[$groupID][$values['id']]['name'] = CRM_Utils_Array::value('name', $group); $details[$groupID][$values['id']]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); $details[$groupID][$values['id']]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][$values['id']]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][$values['id']]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); $details[$groupID][$values['id']]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties), 'field_type' => CRM_Utils_Array::value('html_type', $properties), 'field_data_type' => CRM_Utils_Array::value('data_type', $properties), 'field_value' => self::formatCustomValues($values, $properties), 'options_per_line' => CRM_Utils_Array::value('options_per_line', $properties)); // also return contact reference contact id if user has view all or edit all contacts perm if ((CRM_Core_Permission::check('view all contacts') || CRM_Core_Permission::check('edit all contacts')) && $details[$groupID][$values['id']]['fields'][$k]['field_data_type'] == 'ContactReference') { $details[$groupID][$values['id']]['fields'][$k]['contact_ref_id'] = CRM_Utils_Array::value('data', $values); } } } else { $details[$groupID][0]['title'] = CRM_Utils_Array::value('title', $group); $details[$groupID][0]['name'] = CRM_Utils_Array::value('name', $group); $details[$groupID][0]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); $details[$groupID][0]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][0]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][0]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); $details[$groupID][0]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties)); } } } if ($returnCount) { return count($details[$groupID]); } else { $form->assign_by_ref("{$prefix}viewCustomData", $details); return $details; } }
/** * Assigns values to template variables by reference * * @param string $tpl_var the template variable name * @param mixed $value the referenced value to assign FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always run through something like sm_encode_html_special_chars() (maybe even nl2br()?) * */ function assign_by_ref($tpl_var, &$value) { $this->smarty_template->assign_by_ref($tpl_var, $value); }