/** * Smarty {form} block plugin * * Type: block<br> * Name: form<br> * Purpose: Set up a form block * * @param $params * @param $content * @param \Smarty $smarty * @param $repeat */ function smarty_block_form($params, $content, &$smarty, &$repeat) { if (empty($content)) { $name = isset($params['name']) ? $params['name'] : 'form'; $id = empty($params['id']) ? $name : $params['id']; $module = isset($params['module']) ? $params['module'] : $smarty->getTemplateVars('__loc')->mod; $controller = isset($params['controller']) ? $params['controller'] : $smarty->getTemplateVars('__loc')->con; $method = isset($params['method']) ? $params['method'] : "POST"; $enctype = isset($params['enctype']) ? $params['enctype'] : 'multipart/form-data'; echo "<!-- Form Object 'form' -->\r\n"; echo '<script type="text/javascript" src="' . PATH_RELATIVE . 'framework/core/subsystems/forms/js/inputfilters.js.php"></script>' . "\r\n"; // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/subsystems/forms/controls/listbuildercontrol.js"></script>'."\r\n"; // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/subsystems/forms/js/required.js"></script>'."\r\n"; // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/calendar.js"></script>'."\r\n"; // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/lang/calendar-en.js"></script>'."\r\n"; // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/calendar-setup.js"></script>'."\r\n"; // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'js/PopupDateTimeControl.js"></script>'."\r\n"; expCSS::pushToHead(array("corecss" => "forms")); echo '<form id="' . $id . '" name="' . $name . '" class="' . $params['class'] . '" method="' . $method . '" action="' . URL_FULL . 'index.php" enctype="' . $enctype . '">' . "\r\n"; if (!empty($controller)) { echo '<input type="hidden" name="controller" id="controller" value="' . $controller . '" />' . "\r\n"; } else { echo '<input type="hidden" name="module" id="module" value="' . $module . '" />' . "\r\n"; } echo '<input type="hidden" name="src" id="src" value="' . $smarty->getTemplateVars('__loc')->src . '" />' . "\r\n"; echo '<input type="hidden" name="int" id="int" value="' . $smarty->getTemplateVars('__loc')->int . '" />' . "\r\n"; if (isset($params['action'])) { echo '<input type="hidden" name="action" id="action" value="' . $params['action'] . '" />' . "\r\n"; } //echo the innards } else { echo $content; echo '</form>'; } }
/** * Get the evaluated contents of the view. * * @param string $path * @param array $data * @return string */ public function get($path, array $data = array()) { $template = $this->smarty->createTemplate($path); $template->assign($this->smarty->getTemplateVars()); $template->assign($data); return $template->fetch(); }
/** * print an url * @param unknown_type $params * @param Smarty $smarty * @param unknown_type $template * @return string */ function smarty_function_url($params, $smarty, $template) { $action = isset($params['action']) ? $params['action'] : $smarty->getTemplateVars('action'); $controller = isset($params['controller']) ? $params['controller'] : $smarty->getTemplateVars('controller'); unset($params['action']); unset($params['controller']); $extra = ''; foreach ($params as $key => $param) { $extra .= '/' . $key . '/' . $param; } return "{$smarty->getTemplateVars('baseUrl')}/{$controller}/{$action}{$extra}"; }
/** * Smarty {uniqueid} function plugin * * Type: function<br> * Name: uniquieid<br> * Purpose: create a unique id * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_uniqueid($params, &$smarty) { $badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}"); $randstr = 'exp'; $randstr .= empty($smarty->getTemplateVars('__loc')->src) ? mt_rand(1, 9999) : str_replace($badvals, "", $smarty->getTemplateVars('__loc')->src); $id = $randstr . $params['id']; if (!empty($params['prepend'])) { $id = $params['prepend'] . $id; } if (isset($params['assign'])) { $smarty->assign($params['assign'], $id); } else { echo $id; } }
/** * ... * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty.form * @author Integry Systems */ function smarty_function_textarea($params, $smarty) { if (empty($params['name'])) { $params['name'] = $smarty->getTemplateVars('input_name'); } // @todo: can be removed when all TinyMCE editors are instantiated via Angular if (empty($params['id']) && empty($params['tinymce'])) { $params['id'] = uniqid(); } $formParams = $smarty->_tag_stack[0][1]; $formHandler = $formParams['handle']; $fieldName = $params['name']; if (empty($params['ng_model']) && !empty($formParams['model'])) { $params['ng-model'] = $formParams['model'] . '.' . $params['name']; unset($params['ng_model']); } $params = $smarty->applyFieldValidation($params, $formHandler); if (!empty($params['tinymce'])) { if (is_bool($params['tinymce'])) { $params['tinymce'] = 'getTinyMceOpts()'; } $params['ui-tinymce'] = $params['tinymce']; unset($params['tinymce']); } // Check permissions if ($formParams['readonly']) { $params['readonly'] = 'readonly'; } $content = '<textarea'; $content = $smarty->appendParams($content, $params); $content .= '>' . htmlspecialchars($formHandler->get($fieldName), ENT_QUOTES, 'UTF-8') . '</textarea>'; $content = $smarty->formatControl($content, $params); return $content; }
/** * Smarty {optiondisplayer} function plugin * * Type: function<br> * Name: optiondisplayer<br> * Purpose: display option dropdown list * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_optiondisplayer($params, &$smarty) { global $db; $groupname = $params['options']; $product = $params['product']; $display_price_as = isset($params['display_price_as']) ? $params['display_price_as'] : 'diff'; // get the option group $og = new optiongroup(); //$group = $og->find('bytitle', $groupname); $group = $og->find('first', 'product_id=' . $product->id . ' AND title="' . $groupname . '"'); //grab the options configured for this product $options = $product->optionDropdown($group->title, $display_price_as); // if there are no options we can return now if (empty($options)) { return false; } // find the default option if there is one. $default = $db->selectValue('option', 'id', 'optiongroup_id=' . $group->id . ' AND is_default=1'); $view = $params['view']; //if((isset() || $og->required == false) $includeblank = $params['includeblank'] ; //elseif((isset($params['includeblank']) && $params['includeblank'] == false) || $og->required == true) $includeblank = false; $includeblank = $og->required == false && !isset($params['includeblank']) ? gt('-- Please Select an Option --') : $params['includeblank']; $template = get_common_template($view, $smarty->getTemplateVars('__loc'), 'options'); $template->assign('product', $product); $template->assign('options', $options); $template->assign('group', $group); $template->assign('params', $params); $template->assign('default', $default); $template->assign('includeblank', $includeblank); $template->assign('required', $params['required']); $template->assign('selected', $params['selected']); echo $template->render(); }
/** * Smarty {securelink} function plugin * * Type: function<br> * Name: securelink<br> * Purpose: create a secure link * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_securelink($params, &$smarty) { /*$loc = $smarty->getTemplateVars('__loc'); if (!isset($params['module'])) $params['module'] = $loc->mod; if (!isset($params['src'])) $params['src'] = $loc->src; if (!isset($params['int'])) $params['int'] = $loc->int; $params['expid'] = session_id(); */ $loc = $smarty->getTemplateVars('__loc'); if (!isset($params['module'])) { $params['module'] = empty($params['controller']) ? $loc->mod : $params['controller']; } if (!isset($params['src'])) { if (expModules::controllerExists($params['module'])) { $params['src'] = $loc->src; } elseif (@call_user_func(array($loc->mod, 'hasSources'))) { $params['src'] = $loc->src; } } if (!isset($params['int'])) { $params['int'] = $loc->int; } echo expCore::makeSecureLink($params); }
/** * ... * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty.form * @author Integry Systems */ function smarty_function_hidden($params, $smarty) { if (empty($params['name'])) { $params['name'] = $smarty->getTemplateVars('input_name'); } $formParams = $smarty->_tag_stack[0][1]; $formHandler = $formParams['handle']; $fieldName = $params['name']; if (!$formHandler instanceof Form) { throw new HelperException('Element must be placed in {form} block'); } if (!empty($formParams['model'])) { $params['ng-model'] = $formParams['model'] . '.' . $params['name']; } $fieldName = $params['name']; $output = '<input type="hidden"'; if (!isset($params['value'])) { $params['value'] = $formHandler->get($fieldName); } foreach ($params as $name => $value) { $output .= ' ' . $name . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; } $output .= " />"; return $output; }
/** * Display radio button * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty.form * @author Integry Systems <http://integry.com> */ function smarty_function_radio($params, $smarty) { if (empty($params['name'])) { $params['name'] = $smarty->getTemplateVars('input_name'); } $formParams = $smarty->_tag_stack[0][1]; $formHandler = $formParams['handle']; if (!$formHandler instanceof Form) { throw new HelperException('Element must be placed in {form} block'); } $fieldName = $params['name']; if (!empty($formParams['model'])) { $params['ng-model'] = $formParams['model'] . '.' . $params['name']; } // Check permissions if ($formParams['readonly']) { $params['disabled'] = 'disabled'; } // get checked state $formValue = $formHandler->get($fieldName); if ($formValue == $params['value'] || empty($formValue) && $params['checked']) { $params['checked'] = 'checked'; } $output = '<input type="radio"'; foreach ($params as $name => $value) { $output .= ' ' . $name . '="' . $value . '"'; } $output .= "/>"; return $output; }
/** * Smarty {yuimenu} function plugin * * Type: function<br> * Name: yuimenu<br> * Purpose: display a yui menu * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_yuimenu($params, &$smarty) { $menu = ' function buildmenu () { var oMenuSidenavJs = new YAHOO.widget.Menu("' . $params['buildon'] . '", { position: "static", hidedelay: 100, lazyload: true }); var aSubmenuData = ' . navigationmodule::navtojson() . '; oMenuSidenavJs.subscribe("beforeRender", function () { if (this.getRoot() == this) { for (i=0; i<=this.getItems().length; i++){ var j=i; // console.debug(aSubmenuData[j].itemdata.length); if (aSubmenuData[j].itemdata.length>0){ this.getItem(i).cfg.setProperty("submenu", aSubmenuData[j]); } } } }); oMenuSidenavJs.render(); } YAHOO.util.Event.onDOMReady(buildmenu); '; expJavascript::pushToFoot(array("unique" => "yuimenubar-" . $params['buildon'], "yui2mods" => "menu", "yui3mods" => $smarty->getTemplateVars('__name'), "content" => $menu, "src" => "")); }
function smarty_compiler_translateStatic($params, Smarty $smarty) { /** @var CM_Frontend_Render $render */ $render = $smarty->getTemplateVars('render'); $key = eval('return ' . $params['key'] . ';'); return $render->getTranslation($key); }
/** * Simple smarty function to disable View caching of the current page * * @param array $params Associative (and/or indexed) array of smarty parameters passed in from the template * @param Smarty $smarty Parent Smarty template object * * @return string */ function smarty_function_disable_view_cache($params, $smarty){ $tmpl = $smarty->getTemplateVars('__core_template'); $view = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view(); $view->disableCache(); }
/** * @param \Smarty $smarty * @return \MistyForms\FormBlock */ public static function fromSmarty($smarty) { $vars = $smarty->getTemplateVars(); if (!isset($vars[self::VIEW_KEY])) { throw new ConfigurationException('The form is missing. This is probably a bug'); } return $vars[self::VIEW_KEY]; }
/** * @todo Finish documentation of smarty_function_head * @param array $params Associative (and/or indexed) array of smarty parameters passed in from the template * @param Smarty $smarty Parent Smarty template object * * @return string */ function smarty_function_head($params, $smarty){ $tmpl = $smarty->getTemplateVars('__core_template'); $view = ($tmpl instanceof \Core\Templates\TemplateInterface) ? $tmpl->getView() : \Core\view(); // Load any head elements currently in the CurrentPage cache return $view->getHeadContent(); }
/** * Smarty {getchromemenu} function plugin * * Type: function<br> * Name: getchromemenu<br> * Purpose: display the chrome menu * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_getchromemenu($params, &$smarty) { global $router, $user; $cloc = $smarty->getTemplateVars('__loc'); $module = $params['module']; $list = '<ul class="container-menu">'; $list .= '<li class="container-info">' . $module->action . ' / ' . str_replace($module->action . '_', '', $module->view) . '</li>'; if (!empty($params['rank']) && expPermissions::check('order_modules', $cloc)) { $uplink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 2, 'b' => $params['rank'] - 1)); $downlink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 1, 'b' => $params['rank'])); if ($params['rank'] != 1) { //dont show this up arrow if it's the first module in a container $list .= '<li><a href="' . $uplink . '" class="mod-up">' . gt("Move Module Up") . '</a></li>'; } if (!$params['last']) { //if this is the last module in a container don't show down arrow. $list .= '<li><a href="' . $downlink . '" class="mod-down">' . gt("Move Module Down") . '</a></li>'; } } $rerank = $params['rerank']; if ($rerank == 'false') { $rerank = 0; } else { $rerank = 1; } if ($user->isAdmin()) { $userlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'userperms', '_common' => 1)); $grouplink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'groupperms', '_common' => 1)); $list .= '<li><a href="' . $userlink . '" class="user">' . gt("User Permissions") . '</a></li>'; $list .= '<li><a href="' . $grouplink . '" class="group">' . gt("Group Permissions") . '</a></li>'; } if (!empty($module->id) && expPermissions::check('edit_module', $cloc) && $module->permissions['administrate'] == 1) { $editlink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'edit', 'src' => $module->info['source'])); $list .= '<li><a href="' . $editlink . '" class="config-view">' . gt("Configure Action") . " & " . gt("View") . '</a></li>'; } if ($module->permissions['configure'] == 1) { if (expModules::controllerExists($module->info['class'])) { $configlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'configure', 'hcview' => $module->view)); $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>'; } elseif ($module->info['hasConfig']) { $configlink = $router->makeLink(array('module' => $module->info['class'], 'src' => $module->info['source'], 'action' => 'configure', '_common' => 1)); $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>'; } } if (!empty($module->id) && expPermissions::check('delete_module', $cloc)) { $deletelink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'delete', 'rerank' => $rerank)); $list .= '<li><a href="' . $deletelink . '" class="delete" onclick="alert(\'' . gt("This content is being sent to the Recycle Bin to be recovered later if you wish.") . '\')">' . gt("Remove Module") . '</a></li>'; } if (HELP_ACTIVE) { $helplink = help::makeHelpLink(expModules::getControllerName($module->info['class'])); $list .= '<li><a href="' . $helplink . '" class="helplink" target="_blank">' . gt("Get Help") . '</a></li>'; } $list .= '</ul>'; expCSS::pushToHead(array("unique" => "container-chrome", "link" => PATH_RELATIVE . "framework/modules/container/assets/css/admin-container.css")); expJavascript::pushToFoot(array("unique" => 'container-chrome', "yui3mods" => 'node', "src" => PATH_RELATIVE . "framework/core/assets/js/exp-container.js")); echo $list; }
/** * Smarty {chain} function plugin * * Type: function<br> * Name: chain<br> * Purpose: chain/append templates * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_chain($params, &$smarty) { if (empty($params['module']) && empty($params['controller'])) { return false; } if (isset($params['source'])) { $params['src'] = $params['source']; } $src = isset($params['src']) ? $params['src'] : $smarty->getTemplateVars('__loc')->src; if (isset($params['module'])) { // $chrome = $params['chrome'] == "none" ? true : false; $chrome = empty($params['chrome']) ? true : false; $title = isset($params['title']) ? $params['title'] : ''; $view = isset($params['view']) ? $params['view'] : 'Default'; $action = isset($params['action']) ? $params['action'] : null; $parms = isset($params['params']) ? $params['params'] : null; if (!$parms) { //return; } else { eval('$new_parms = ' . $parms . ';'); $parms = $new_parms; } if (empty($action)) { echo expTheme::showModule($params['module'], $view, $title, $src, false, null, $chrome); } else { echo expTheme::showAction($params['module'], $action, $src, $parms); } } elseif (isset($params['controller'])) { $view = isset($params['view']) ? $params['view'] : $params['action']; $action = isset($params['action']) ? $params['action'] : 'index'; $scope = isset($params['scope']) ? $params['scope'] : 'global'; //$chrome = isset($params['chrome']) ? '"chrome"=>true' : ''; $source = isset($params['source']) ? $params['source'] : $smarty->getTemplateVars('__loc')->src; $cfg = array("controller" => $params['controller'], "action" => $action, "view" => $view, "source" => $source, "scope" => $scope); //because of the silly way we have to toggle chrome if (!empty($params['chrome'])) { $cfg['chrome'] = true; } else { $cfg['chrome'] = false; } //eDebug($cfg); expTheme::module($cfg); } }
/** * ... * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty.form * @author Integry Systems */ function smarty_function_checkbox($params, $smarty) { if (empty($params['name'])) { $params['name'] = $smarty->getTemplateVars('input_name'); } if (empty($params['id'])) { $params['id'] = uniqid(); } $smarty->assign('last_fieldType', 'checkbox'); $smarty->assign('last_fieldID', $params['id']); if (empty($params['class'])) { $params['class'] = 'checkbox'; } else { $params['class'] .= ' checkbox'; } $formParams = $smarty->_tag_stack[0][1]; $formHandler = $formParams['handle']; if (!$formHandler instanceof Form) { throw new HelperException('Element must be placed in {form} block'); } $fieldName = $params['name']; if (!isset($params['value'])) { $params['value'] = 1; } if (!empty($formParams['model'])) { $params['ng-model'] = $formParams['model'] . '.' . $params['name']; } // Check permissions if ($formParams['readonly']) { $params['disabled'] = 'disabled'; } $formValue = $formHandler->get($fieldName); // get checkbox state if the form has been submitted if (1 == $formHandler->get('checkbox_' . $fieldName)) { if ($formValue == $params['value'] || 'on' == $params['value'] && 1 == $formValue) { $params['checked'] = 'checked'; } else { unset($params['checked']); } } else { if ($params['value'] == $formValue) { $params['checked'] = 'checked'; } } if (empty($params['checked'])) { unset($params['checked']); } $params['ng-true-value'] = 1; $params['ng-false-value'] = 0; $output = '<input type="checkbox"'; foreach ($params as $name => $value) { $output .= ' ' . $name . '="' . $value . '"'; } $output .= '/><input type="hidden" name="checkbox_' . $params['name'] . '" value="1" />'; return $output; }
/** * Smarty Help Tag * Displays help text of this module. * * Examples: * <pre> * {help} * </pre> * * Type: function<br> * Name: help<br> * Purpose: displays help.tpl for a module, if existing<br> * * @param array $params * @param Smarty $smarty * * @return string */ function Smarty_function_help($params, $smarty) { $modulename = $smarty->getTemplateVars('template_of_module'); $tpl = $modulename . '/view/smarty/help.tpl'; // load the help template from the module path -> app/modules/modulename/view/help.tpl if ($smarty->templateExists($tpl)) { return $smarty->fetch($tpl); } return 'Help Template not found.'; }
/** * Handle a notification. * * @return boolean */ public function handle(NotificationInterface $notification, $level) { if ($notification instanceof AttributeAwareInterface) { $options = $notification->attributes(); } else { $options = []; } if ($notification instanceof TitleAwareInterface) { $options['header'] = $notification->title(); } $variable = ['message' => $notification->message(), 'type' => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD, 'options' => $options]; $current = $this->smarty->getTemplateVars($this->var); if (!$current) { $this->smarty->assign($this->var, [$variable]); } else { $this->smarty->append($this->var, $variable); } return true; }
/** * Add a new message to the stack * * @param OSS_Message An instance of the OSS_Message class * @return bool */ public function ossAddMessage(OSS_Message &$message) { $OSS_Messages = $this->_smarty->getTemplateVars('OSS_Messages'); if ($OSS_Messages == null) { $OSS_Messages = array(); } $OSS_Messages[] = $message; $this->_smarty->assign('OSS_Messages', $OSS_Messages); return true; }
/** * Add a new message to the stack * * @param ViMbAdmin_Message An instance of the ViMbAdmin_Message class * @return boolean */ public function vimbadminAddMessage(vimbadmin_Message &$message) { $ViMbAdmin_Messages = $this->_smarty->getTemplateVars('ViMbAdmin_Messages'); if ($ViMbAdmin_Messages == null) { $ViMbAdmin_Messages = array(); } $ViMbAdmin_Messages[] = $message; $this->_smarty->assign('ViMbAdmin_Messages', $ViMbAdmin_Messages); return true; }
/** * Smarty {includemiscfiles} postfilter plugin * * Type: postfilter<br> * Name: includemiscfiles<br> * Purpose: This function creates html loaders for - currently - JS and CSS Files * Please note it will only work for newtype __names (SomeModule, SomeForm, SomeTheme, SomeControl...) * * @param $compiledsource * @param \Smarty $smarty * * @return bool */ function smarty_postfilter_includemiscfiles($compiledsource, &$smarty) { ob_start(); //CSS $myCSS = expCore::resolveFilePaths("guess", $smarty->getTemplateVars('__name'), "css", $smarty->getTemplateVars('__view') . "*"); if ($myCSS != false) { foreach ($myCSS as $myCSSFile) { echo "<link rel='stylesheet' type='text/css' href='" . expCore::abs2rel($myCSSFile) . "'></link>\n"; } } //JavaScript $myJS = expCore::resolveFilePaths("guess", $smarty->getTemplateVars('__name'), "js", $smarty->getTemplateVars('__view') . "*"); if ($myJS != false) { foreach ($myJS as $myJSFile) { echo "<script type='text/javascript' src='" . expCore::abs2rel($myJSFile) . "'></script>\n"; } } $html = ob_get_contents(); ob_end_clean(); return $html . $compiledsource; }
public function VarAssign() { $this->_extSortBlocks(); parent::VarAssign(); $aPlugins = $this->Plugin_GetActivePlugins(); $plugins = array(); foreach ($aPlugins as $sPlugin) { $plugins[$sPlugin] = array('skin' => array('name' => HelperPlugin::GetPluginSkin($sPlugin), 'path' => HelperPlugin::GetPluginSkinPath($sPlugin), 'url' => HelperPlugin::GetPluginSkinUrl($sPlugin)), 'config' => Config::Get('plugin.' . $sPlugin)); } $ls = array('site' => array('skin' => array('name' => Config::Get($this->sPlugin . '.saved.view.skin') ? Config::Get($this->sPlugin . '.saved.view.skin') : Config::Get('view.skin'), 'path' => Config::Get($this->sPlugin . '.saved.path.smarty.template') ? Config::Get($this->sPlugin . '.saved.path.smarty.template') : Config::Get('path.smarty.template'), 'url' => Config::Get($this->sPlugin . '.saved.path.static.skin') ? Config::Get($this->sPlugin . '.saved.path.static.skin') : Config::Get('path.static.skin'))), 'js' => array('lib' => Config::Get('js.lib'), 'jquery' => Config::Get('js.jquery'), 'mootools' => Config::Get('js.mootools')), 'router' => array('action' => Router::GetAction(), 'event' => Router::GetActionEvent(), 'param' => Router::GetParams()), 'url' => $this->oSmarty->getTemplateVars('aRouter'), 'plugin' => $plugins); $this->AssignArray('ls', $ls); }
/** * Static function to retrieve the handler from the view * * @param \Smarty $smarty * @return \MistyForms\Handler */ public static function fromSmarty($smarty) { $vars = $smarty->getTemplateVars(); if (!isset($vars[self::VIEW_KEY])) { throw new ConfigurationException('The form handler is missing. Did you call Form::setupForm()?'); } $handler = $vars[self::VIEW_KEY]; if (!$handler instanceof Handler) { throw new ConfigurationException('The handler is not of type MistyForms\\Handler'); } return $handler; }
/** * Smarty {fill_form_values}...{/fill_form_values} extension. * Fills in form fields between the tags based on values in Smarty template * variables, and shows form errors stored in the template variable * "formErrors". * * @param array $params Params from smarty template (unused) * @param string $content HTML to filter (it's {...}THIS STUFF{/...} * @param Smarty $smarty * @return string $content with form vars set properly. */ function smarty_fill_form_values($params, $content, &$smarty) { if ($content === null) { return ""; } $vars = $smarty->getTemplateVars(); $errors = array(); if (array_key_exists('formErrors', $vars)) { $errors = $vars['formErrors']; } return fillInFormValues($content, $vars, $errors); }
/** * Smarty {filedisplayer} function plugin * * Type: function<br> * Name: filedisplayer<br> * Purpose: display files * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_filedisplayer($params, &$smarty) { $config = $smarty->getTemplateVars('config'); // make sure we have a view, and files..otherwise return nada. if (empty($params['view']) || empty($params['files'])) { return ""; } // get the view, pass params and render & return it. $view = isset($params['view']) ? $params['view'] : 'Downloadable Files'; $title = isset($params['title']) ? $params['title'] : ''; $badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}"); $config['uniqueid'] = str_replace($badvals, "", $smarty->getTemplateVars('__loc')->src) . $params['record']->id; if ($config['pio'] && $params['is_listing']) { $tmp = reset($params['files']); unset($params['files']); $params['files'][] = $tmp; } $float = $config['ffloat'] == "No Float" ? "" : "float:" . strtolower($config['ffloat']) . ";"; $width = !empty($config['fwidth']) ? $config['fwidth'] : "200"; switch ($config['ffloat']) { case 'Left': $margin = "margin-right:" . $config['fmargin'] . "px;"; break; case 'Right': $margin = "margin-left:" . $config['fmargin'] . "px;"; break; default: $margin = ""; break; } $html = '<div class="display-files" style="' . $float . 'width:' . $width . 'px;' . $margin . '">'; $template = get_common_template($view, $smarty->getTemplateVars('__loc'), 'file'); $template->assign('files', $params['files']); $template->assign('style', $params['style']); $template->assign('config', $config); $template->assign('params', $params); $html .= $template->render(); $html .= "</div>"; echo $html; }
/** * ... * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty.form * @author Integry Systems */ function smarty_function_selectfield($params, $smarty) { if (empty($params['name'])) { $params['name'] = $smarty->getTemplateVars('input_name'); } $formParams = $smarty->_tag_stack[0][1]; $formHandler = $formParams['handle']; if (!empty($formParams['model']) && !empty($formParams['name'])) { $params['ng-model'] = $formParams['model'] . '.' . $params['name']; } $options = $params['options']; if (empty($options)) { $options = array(); } unset($params['options']); $before = isset($params['before']) ? $params['before'] : ''; $after = isset($params['after']) ? $params['after'] : ''; $defaultValue = isset($params['value']) ? $params['value'] : ''; unset($params['value'], $params['before'], $params['after']); // Check permissions if ($formParams['readonly']) { $params['disabled'] = 'disabled'; } if ($formHandler) { $fieldValue = $formHandler->get($params['name']); if (is_null($fieldValue)) { $fieldValue = $defaultValue; } //$params['initialValue'] = $fieldValue; } $content = '<select'; $content = $smarty->appendParams($content, $params); $content .= ">\n"; if (isset($params['blank'])) { $content .= '<option></option>'; } $content .= $before; foreach ($options as $value => $title) { if (preg_match('/optgroup_\\d+/', $value)) { $content .= "\t" . '<optgroup label="' . htmlspecialchars($title) . '" />' . "\n"; } else { if (is_array($fieldValue) && in_array($value, $fieldValue) || !is_array($fieldValue) && $fieldValue == $value && strlen($fieldValue) == strlen($value)) { $content .= "\t" . '<option value="' . $value . '" selected="selected">' . htmlspecialchars($title) . '</option>' . "\n"; } else { $content .= "\t" . '<option value="' . $value . '">' . htmlspecialchars($title) . '</option>' . "\n"; } } } $content .= $after . '</select>'; $content = $smarty->formatControl($content, $params); return $content; }
/** * print an icon * @param unknown_type $params * @param Smarty $smarty * @param unknown_type $template * @return string */ function smarty_function_icon($params, $smarty, $template) { $extra = ''; $icon_path = 'images/template/icons'; $name = $params['src']; $type = isset($params['type']) ? $params['type'] : 'png'; unset($params['src']); unset($params['type']); foreach ($params as $key => $value) { $extra .= $key . "='{$value}' "; } return "<img src='{$smarty->getTemplateVars('baseUrl')}/{$icon_path}/{$name}.{$type}' alt='icon' {$extra} />"; }
private function addMessage($type, $message, array $format = array()) { $messages = $this->smarty->getTemplateVars($type); if ($messages === null) { $messages = array(); } $message = $this->translator->translate($message); foreach ($format as $key => $value) { $message = str_replace('%' . $key . '%', $value, $message); } $messages[] = $message; $this->smarty->assign($type, $messages); }
/** * Set profile in smarty var * * @param Smarty $smarty */ public static function setProfile(Smarty $smarty) { $profileRequest = new Request(array("username" => array_key_exists("username", $_REQUEST) ? $_REQUEST["username"] : null, "auth_token" => $smarty->getTemplateVars('CURRENT_USER_AUTH_TOKEN'))); $profileRequest->method = "UserController::apiProfile"; $response = ApiCaller::call($profileRequest); if ($response["status"] === "ok") { $response["userinfo"]["graduation_date"] = is_null($response["userinfo"]["graduation_date"]) ? null : gmdate('d/m/Y', $response["userinfo"]["graduation_date"]); $response["userinfo"]["birth_date"] = is_null($response["userinfo"]["birth_date"]) ? null : gmdate('d/m/Y', $response["userinfo"]["birth_date"]); $smarty->assign('profile', $response); } else { $smarty->assign('STATUS_ERROR', $response["error"]); } }