/** * Smarty block plugin, for generating page menu item * This block must always be called in pageMenu block context * * @param array $params * @param Smarty $smarty * @param $repeat * * <code> * {pageMenu id="menu"} * {menuItem} * {menuCaption}Click Me{/menuCaption} * {menuAction}http://click.me.com{/menuAction} * {/menuItem} * {menuItem} * {menuCaption}Another menu item{/menuCaption} * {pageAction}alert('Somebody clicked on me too!'){/menuAction} * {/menuItem} * {/pageMenu} * </code> * * @package application.helper.smarty * @author Integry Systems */ function smarty_block_menuItem($params, $content, Smarty_Internal_Template $smarty, &$repeat) { if ($repeat) { $smarty->clear_assign('menuCaption'); $smarty->clear_assign('menuAction'); $smarty->clear_assign('menuPageAction'); } else { $item = new HtmlElement('a'); if ($smarty->getTemplateVars('menuAction')) { $href = $smarty->getTemplateVars('menuAction'); } else { if ($smarty->getTemplateVars('menuPageAction')) { $onClick = $smarty->getTemplateVars('menuPageAction'); $href = '#'; $item->setAttribute('onClick', $onClick . '; return false;'); } } $item->setAttribute('href', $href); // EXPERIMENTAL - set access key for menu item $caption = $smarty->getTemplateVars('menuCaption'); if (FALSE != strpos($caption, '&&')) { $p = strpos($caption, '&&'); $accessKey = substr($caption, $p + 2, 1); $item->setAttribute('accessKey', $accessKey); $caption = substr($caption, 0, $p + 3) . '</span>' . substr($caption, $p + 3); $caption = substr($caption, 0, $p) . '<span class="accessKey">' . substr($caption, $p + 2); } $item->setContent($caption); $smarty->append('pageMenuItems', $item->render()); } }
/** * @param array $params * @param string $content * @param Smarty_Internal_Template $smarty * @param boolean $repeat * * @throws SmartyException * @return string * * @author Kovács Vince */ function smarty_block_datatable($params, $content, Smarty_Internal_Template &$smarty, &$repeat) { if (!class_exists('Datatable')) { throw new SmartyException('chumper/datatable not installed'); } if ($repeat) { $options = array('language' => \Lang::get('datatable', array()), 'processing' => true, 'bProcessing' => true, 'stateSave' => true, 'autoWidth' => false, 'columns' => array()); $table = Datatable::table(); if (isset($params['id'])) { $table->setId($params['id']); unset($params['id']); } if (isset($params['url'])) { $table->setUrl($params['url']); unset($params['url']); } elseif (isset($params['action'])) { $table->setUrl(URL::action($params['action'])); unset($params['action']); } if (isset($params['searching'])) { $options['searching'] = $params['searching']; } if (isset($params['lengthChange'])) { $options['lengthChange'] = $params['lengthChange']; } if (isset($params['class'])) { $table->setClass($params['class']); } $table->setOptions($options); $smarty->append('datatables', $table); } else { $tables = $smarty->getVariable('datatables')->value; $table = array_pop($tables); $smarty->assign('datatables', $tables); if (isset($params['view'])) { return $table->render($params['view']); } return $table->render('datatable'); } return ''; }
/** * Close capture section * * @param \Smarty_Internal_Template $_template * * @throws \SmartyException */ public function close(Smarty_Internal_Template $_template) { if ($this->captureCount) { list($buffer, $assign, $append) = array_pop($this->captureStack); $this->captureCount--; if (isset($assign)) { $_template->assign($assign, ob_get_contents()); } if (isset($append)) { $_template->append($append, ob_get_contents()); } $_template->_cache['capture'][$buffer] = ob_get_clean(); } else { $this->error($_template); } }