/** * @return string The html code for the radio input. */ public function display() { $tpl_src = '<div class="form-field-radio"><input id="${escape(ID)}" type="radio" name="${escape(NAME)}" value="${escape(VALUE)}" # IF C_CHECKED # checked="checked" # ENDIF # # IF C_DISABLE # disabled="disabled" # ENDIF #><label for="${escape(ID)}"></label></div><span class="form-field-radio-span"> {LABEL}</span>'; $tpl = new StringTemplate($tpl_src); $tpl->put_all(array('ID' => $this->get_option_id(), 'NAME' => $this->get_field_id(), 'VALUE' => $this->get_raw_value(), 'C_CHECKED' => $this->is_active(), 'C_DISABLE' => $this->is_disable(), 'LABEL' => $this->get_label())); return $tpl; }
public function execute(HTTPRequestCustom $request) { $this->load_lang(); $id_theme = $request->get_value('id_theme', ''); $id_module = ''; $file_selected = $request->get_value('file_name', ''); if (preg_match('`/`', $file_selected)) { $split = explode('/', $file_selected); $id_module = $split[0]; $file_name = $split[1] . '.tpl'; } else { $file_name = $file_selected . '.tpl'; } $this->build_form($id_theme, $id_module, $file_name, $file_selected); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if (!empty($id_theme) && !empty($file_selected)) { if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.success', 'status-messages-common'), MessageHelper::SUCCESS, 4)); } } $tpl->put('FORM', $this->form->display()); return new AdminCustomizationDisplayResponse($tpl, $this->lang['customization.editor.tpl-files']); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $this->form->get_field_by_id('admin_alerts_levels')->set_hidden(!$this->config->are_admin_alerts_enabled()); $this->form->get_field_by_id('admin_alerts_fix_action')->set_hidden(!$this->config->are_admin_alerts_enabled()); foreach ($this->config->get_status_list() as $key => $value) { $this->form->get_field_by_id($key)->set_hidden(!$this->config->is_progress_bar_displayed()); } $this->form->get_field_by_id('stats_top_posters_enabled')->set_hidden(!$this->config->are_stats_enabled()); $this->form->get_field_by_id('stats_top_posters_number')->set_hidden(!$this->config->are_stats_top_posters_enabled()); $this->form->get_field_by_id('pm_edit_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_delete_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_comment_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_in_progress_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_pending_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_assign_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_fix_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_reject_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('pm_reopen_enabled')->set_hidden(!$this->config->are_pm_enabled()); $this->form->get_field_by_id('types_table')->set_value($this->build_types_table()->render()); $this->form->get_field_by_id('categories_table')->set_value($this->build_categories_table()->render()); $this->form->get_field_by_id('severities_table')->set_value($this->build_severities_table()->render()); $this->form->get_field_by_id('priorities_table')->set_value($this->build_priorities_table()->render()); $this->form->get_field_by_id('versions_table')->set_value($this->build_versions_table()->render()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } $tpl->put('FORM', $this->form->display()); return new AdminBugtrackerDisplayResponse($tpl, $this->lang['titles.admin.module_config']); }
public function execute(HTTPRequestCustom $request) { $this->load_lang(); $this->load_config(); $theme = $request->get_value('theme', 'all'); if ($theme !== 'all' && !ThemesManager::get_theme_existed($theme)) { AppContext::get_response()->redirect(AdminCustomizeUrlBuilder::customize_interface()); } $this->build_form($theme); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $header_logo = $this->form->get_value('header_logo', null); if ($header_logo !== null) { $file_type = new FileType(new File($header_logo->get_name())); if ($file_type->is_picture()) { $this->save($header_logo, $theme); AppContext::get_response()->redirect(AdminCustomizeUrlBuilder::customize_interface()); } else { $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.error', 'status-messages-common'), MessageHelper::ERROR, 4)); } } elseif ($this->form->get_value('use_default_logo')) { $this->delete_pictures_saved($theme); AppContext::get_response()->redirect(AdminCustomizeUrlBuilder::customize_interface()); } else { $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.error', 'status-messages-common'), MessageHelper::ERROR, 4)); } } $tpl->put('FORM', $this->form->display()); return new AdminCustomizationDisplayResponse($tpl, $this->lang['customization.interface']); }
/** * Test adding templates through the constructor. * * @return void */ public function testConstructorAdd() { $templates = array('link' => '<a href="{{url}}">{{text}}</a>'); $template = new StringTemplate($templates); debug($template->config('link')); $this->assertEquals($templates['link'], $template->config('link')); }
/** * @return string The html code for the select. */ public function display() { $tpl_src = '<option value="${escape(VALUE)}" # IF C_SELECTED # selected="selected" # ENDIF # # IF C_DISABLE # disabled="disabled" # ENDIF #>{LABEL}</option>'; $tpl = new StringTemplate($tpl_src); $tpl->put_all(array('VALUE' => $this->get_raw_value(), 'C_SELECTED' => $this->is_active(), 'C_DISABLE' => $this->is_disable(), 'LABEL' => $this->get_label())); return $tpl; }
/** * @return Template The html code for the file input. */ function display() { $template = $this->get_template_to_use(); $file_field_tpl = new StringTemplate(self::$tpl_src); $file_field_tpl->put_all(array('MAX_FILE_SIZE' => $this->get_max_file_size(), 'NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled())); $this->assign_common_template_variables($template); $template->assign_block_vars('fieldelements', array('ELEMENT' => $file_field_tpl->render())); return $template; }
/** * @return string The html code for the input. */ public function display() { $template = $this->get_template_to_use(); $field = new StringTemplate(self::$tpl_src); $field->put_all(array('SIZE' => $this->size, 'MAX_LENGTH' => $this->maxlength, 'NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'TYPE' => $this->type, 'VALUE' => $this->get_value(), 'CLASS' => $this->get_css_class(), 'C_DISABLED' => $this->is_disabled(), 'C_READONLY' => $this->is_readonly(), 'C_MULTIPLE' => $this->is_multiple())); $this->assign_common_template_variables($template); $template->assign_block_vars('fieldelements', array('ELEMENT' => $field->render())); return $template; }
/** * @return string The html code for the input. */ public function display() { $template = $this->get_template_to_use(); $field = new StringTemplate(self::$tpl_src); $field->put_all(array('ROWS' => $this->rows, 'COLS' => $this->cols, 'WIDTH' => $this->width > 0 ? 'width: ' . $this->width . '%;' : '', 'NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'VALUE' => $this->get_value(), 'CLASS' => $this->get_css_class(), 'C_DISABLED' => $this->is_disabled(), 'C_READONLY' => $this->is_readonly())); $this->assign_common_template_variables($template); $template->assign_block_vars('fieldelements', array('ELEMENT' => $field->render())); return $template; }
public function display() { $tpl = new StringTemplate('<span # IF C_HAS_CSS_CLASSES #class="{CSS_CLASSES}"# ENDIF ## START attributs # {attributs.TYPE}="{attributs.VALUE}"# END attributs #>{CONTENT}</span>'); $tpl->put_all(array('C_HAS_CSS_CLASSES' => $this->has_css_class(), 'CSS_CLASSES' => $this->get_css_class(), 'CONTENT' => $this->content)); foreach ($this->attributs as $type => $value) { $tpl->assign_block_vars('attributs', array('TYPE' => $type, 'VALUE' => $value)); } return $tpl->render(); }
/** * @return string The html code for the input. */ public function display() { $template = $this->get_template_to_use(); $field = new StringTemplate(self::$tpl_src); $field->put_all(array('C_MIN' => $this->min !== null, 'MIN' => $this->min, 'C_MAX' => $this->max != 0, 'MAX' => $this->max, 'C_STEP' => $this->step > 0, 'STEP' => $this->step, 'NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'TYPE' => $this->type, 'VALUE' => $this->get_value(), 'CLASS' => $this->get_css_class(), 'C_DISABLED' => $this->is_disabled(), 'C_READONLY' => $this->is_readonly(), 'C_DISABLED' => $this->is_disabled(), 'C_PATTERN' => $this->has_pattern(), 'PATTERN' => $this->pattern, 'C_VERTICAL' => $this->is_vertical())); $this->assign_common_template_variables($template); $template->assign_block_vars('fieldelements', array('ELEMENT' => $field->render())); return $template; }
public function display() { $tpl = new StringTemplate('<img src="{URL}" # START attributs # {attributs.TYPE}="{attributs.VALUE}"# END attributs ## IF C_HAS_CSS_CLASSES #class="{CSS_CLASSES}"# ENDIF #>'); $tpl->put_all(array('C_HAS_CSS_CLASSES' => $this->has_css_class(), 'CSS_CLASSES' => $this->get_css_class(), 'URL' => $this->url)); foreach ($this->attributs as $type => $value) { $tpl->assign_block_vars('attributs', array('TYPE' => $type, 'VALUE' => $value)); } return $tpl->render(); }
private function get_html_code() { $tpl_src = '<select name="${escape(NAME)}" id="${escape(HTML_ID)}" class="${escape(CSS_CLASS)}" # IF C_DISABLED # disabled="disabled" # ENDIF # >' . '# START options # # INCLUDE options.OPTION # # END options #' . '</select>'; $tpl = new StringTemplate($tpl_src); $tpl->put_all(array('NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'CSS_CLASS' => $this->get_css_class(), 'C_DISABLED' => $this->is_disabled())); foreach ($this->get_options() as $option) { $tpl->assign_block_vars('options', array(), array('OPTION' => $option->display())); } return $tpl; }
public function display() { $tpl_src = '<optgroup label="${escape(LABEL)}"> # START options # # INCLUDE options.OPTION # # END options # </optgroup>'; $tpl = new StringTemplate($tpl_src); $tpl->put_all(array('LABEL' => $this->get_label())); foreach ($this->options as $option) { $tpl->assign_block_vars('options', array(), array('OPTION' => $option->display())); } return $tpl; }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->check_authorizations(); $this->build_form($request); $tpl = new StringTemplate('# INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); } $tpl->put('FORM', $this->form->display()); return $this->generate_response($tpl); }
public function execute(HTTPRequestCustom $request) { ob_start(); phpinfo(); $phpinfo = ob_get_contents(); $phpinfo = preg_replace('`^.*<body>`is', '', $phpinfo); $phpinfo = str_replace(array('class="e"', 'class="v"', '<table border="0" cellpadding="3" width="600">', '</body></html>'), array('', 'style="overflow:auto;"', '<table style="table-layout:fixed;">', ''), $phpinfo); ob_end_clean(); ob_start(); $tpl = new StringTemplate('{PHPINFO}'); $tpl->put('PHPINFO', $phpinfo); return new AdminServerDisplayResponse($tpl, LangLoader::get_message('phpinfo', 'admin')); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form($request); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $display_name = $this->save(); AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : AdminMembersUrlBuilder::management(), StringVars::replace_vars($this->lang['user.message.success.add'], array('name' => $display_name))); } $tpl->put('FORM', $this->form->display()); return new AdminMembersDisplayResponse($tpl, LangLoader::get_message('members.add-member', 'admin-user-common')); }
public function execute(HTTPRequestCustom $request) { $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->handle_form(); $this->form->get_field_by_id('file_life_time')->set_hidden(!SitemapXMLFileService::is_xml_file_generation_enabled()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } $tpl->put('FORM', $this->form->display()); return $this->build_response($tpl); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG ## INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.success', 'status-messages-common'), MessageHelper::SUCCESS, 4)); } $tpl->put('FORM', $this->form->display()); return $this->build_response($tpl); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $this->form->get_field_by_id('database_tables_optimization_day')->set_hidden(!$this->config->is_database_tables_optimization_enabled()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } $tpl->put('FORM', $this->form->display()); return new AdminDatabaseDisplayResponse($tpl, $this->lang['module_config_title']); }
public function render(array $variables = array()) { $variables = $variables ?: $this->array; $callback = function ($item) use($variables) { if ($item instanceof Renderizable) { return $item->render($variables); } elseif (is_string($item)) { $string = new StringTemplate($item); return $string->render($variables); } return $item; }; return array_map($callback, $this->array); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $this->form->get_field_by_id('forbidden_tags')->set_selected_options($this->content_formatting_config->get_forbidden_tags()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } $tpl->put('FORM', $this->form->display()); return new AdminContentDisplayResponse($tpl, $this->lang['content.config']); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $this->form->get_field_by_id('display_descriptions_to_guests')->set_hidden($this->config->get_category_display_type() == DownloadConfig::DISPLAY_ALL_CONTENT); $this->form->get_field_by_id('notation_scale')->set_hidden(!$this->config->is_notation_enabled()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } $tpl->put('FORM', $this->form->display()); return new AdminDownloadDisplayResponse($tpl, $this->lang['module_config_title']); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $this->form->get_field_by_id('birthday_color')->set_hidden(!$this->config->is_members_birthday_enabled()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } //Display the form on the template $tpl->put('FORM', $this->form->display()); //Display the generated page return new AdminCalendarDisplayResponse($tpl, $this->lang['module_config_title']); }
public function execute(HTTPRequestCustom $request) { $this->load_lang(); $this->load_config(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $this->form->get_field_by_id('debug_mode_type')->set_hidden(!Debug::is_debug_mode_enabled()); $this->form->get_field_by_id('display_database_query_enabled')->set_hidden(!Debug::is_debug_mode_enabled()); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } $tpl->put('FORM', $this->form->display()); return new AdminConfigDisplayResponse($tpl, $this->lang['advanced-config']); }
public function execute(HTTPRequestCustom $request) { $this->check_authorizations(); $this->init(); $this->build_form(); $tpl = new StringTemplate('# INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $type = $request->get_value('type', ''); if ($type !== '' && ($type == 'html' || $type == 'bbcode' || $type == 'text')) { AppContext::get_response()->redirect(NewsletterUrlBuilder::add_newsletter($type)); } } $tpl->put('FORM', $this->form->display()); return $this->build_response($tpl); }
public function execute(HTTPRequestCustom $request) { $this->init(); $this->build_form($request); $tpl = new StringTemplate('# INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->set_properties(); $this->save(); if ($this->is_new_category) { AppContext::get_response()->redirect($this->get_categories_management_url(), StringVars::replace_vars($this->get_success_message(), array('name' => $this->get_category()->get_name()))); } else { AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : $this->get_categories_management_url(), StringVars::replace_vars($this->get_success_message(), array('name' => $this->get_category()->get_name()))); } } $tpl->put('FORM', $this->form->display()); return $this->generate_response($tpl); }
/** * znova spracovava retazec s latte syntaxou s vyuzitim StringTemplate * * @param string $s * @return string */ public static function latte($s) { // kedze HTML Purifier aj CKEditor escape-uju entity, tak by mi nefungovali nette linky -> robim replace $search = array('->', '=>'); $replace = array('->', '=>'); $s = str_replace($search, $replace, $s); $tpl = new StringTemplate(); $tpl->presenter = Environment::getApplication()->getPresenter(); // nutné např. pro rozchození linků $tpl->registerFilter(new LatteFilter()); $tpl->content = $s; // obsah šablony (řetězec) $tpl->control = $tpl->presenter; // vrátíme vygenerovanou šablonu return $tpl->__toString(); // nebo ji vypíšeme na výstup // $tpl->render(); }
public function execute(HTTPRequestCustom $request) { $this->init(); //Form building $this->build_form(); //Creation of the template $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #'); $tpl->add_lang($this->lang); //Saving of the configuration if the submit button has been submitted if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save(); $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.config', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } //Display the form on the template $tpl->put('FORM', $this->form->display()); //Display the generated page return new AdminBugtrackerDisplayResponse($tpl, $this->lang['titles.admin.module_authorizations']); }
public function execute(HTTPRequestCustom $request) { AppContext::get_session()->csrf_get_protect(); $this->init(); $this->get_event($request); $this->check_authorizations(); $tpl = new StringTemplate('# INCLUDE FORM #'); $tpl->add_lang($this->lang); if ($this->event->belongs_to_a_serie()) { $this->build_form($request); } if ($this->event->belongs_to_a_serie() && $this->submit_button->has_been_submited() && $this->form->validate() || !$this->event->belongs_to_a_serie()) { $this->delete_event($this->event->belongs_to_a_serie() ? $this->form->get_value('delete_serie')->get_raw_value() : false); $this->redirect($request); } $tpl->put('FORM', $this->form->display()); return $this->generate_response($tpl); }