if (!isset($snippet['name'])) {
$snippet['name'] = count($this->_snippets);
}
+
$this->_snippets[$snippet['name']] = $snippet;
$this->_isSorted = FALSE;
return $snippet;
}
/**
+ * Get snippet.
+ *
* @param string $name
*
* @return mixed
*/
- public function &get($name) {
- return @$this->_snippets[$name];
+ public function get($name) {
+ return !empty($this->_snippets[$name]) ? $this->_snippets[$name] : NULL;
}
/**
$smarty = CRM_Core_Smarty::singleton();
$html = '';
foreach ($this->_snippets as $snippet) {
- $placement = empty($snippet['placement']) ? 'after' : $snippet['placement'];
if ($snippet['disabled']) {
continue;
}
switch ($snippet['type']) {
case 'markup':
- if ($placement == 'before') {
- $html = $snippet['markup'] . $html;
- }
- else {
- $html .= $snippet['markup'];
- }
+ $html .= $snippet['markup'];
break;
case 'template':
$tmp = $smarty->get_template_vars('snippet');
$smarty->assign('snippet', $snippet);
- if ($placement == 'before') {
- $html = $smarty->fetch($snippet['template']) . $html;
- }
- else {
- $html .= $smarty->fetch($snippet['template']);
- }
+ $html .= $smarty->fetch($snippet['template']);
$smarty->assign('snippet', $tmp);
break;