/** * Display a template * @param string $name The Template Name * @param mixed $data Array/Object with data to merge * * @return string */ public function displayTemplate($name, $data = array()) { if ($this->debug) { $data = array_merge($data, array('debug' => true)); } return $this->twig->render($name, $data); }
/** * Generates the administration form for the widget * * @param array $instance The array of keys and * values for the widget */ public function form($instance) { // Reset the names so that the form's update function works properly foreach ($this->config->fields as $field) { $field->name = $field->init_name; } // Update values $this->form->updater->set_new_instance($instance); $this->form->updater->update(); // Set the widget specific field names and ids foreach ($this->config->fields as $field) { $field->id = $this->get_field_id($field->init_name); $field->name = $this->get_field_name($field->init_name); } // Print the form $this->form->render(true); }
/** * Prepare fields for table * * @param type $user * @return type */ public function prepareFields($user, $key) { switch ($key) { case 'login': return $user->render('list', 'avatar.small'); break; case 'reg_date': return df($user->reg_date, 'd M Y'); break; case 'posts': return '<a href="' . $user->getLink() . '/posts/" class="badge' . ($user->posts > 0 ? ' badge-info' : '') . '">' . $user->posts . '</a>'; break; case 'comments': return '<a href="' . $user->getLink() . '/comments/" class="badge' . ($user->comments > 0 ? ' badge-warning' : '') . '">' . $user->comments . '</a>'; break; } }
/** * Render the menu * @param array $menu_items * @param array $attributes * @param int $level * @return type */ private function _render($menu_items, $attributes, $level = null, $group = null, $currentDepth = 0) { if ($level !== null && $level-- <= 0) { return; } $items = array(); foreach ($menu_items as $item) { if (isset($group, $item['group']) && !in_array($group, explode(',', $item['group']))) { continue; } isset($item['list_attributes']) or $item['list_attributes'] = array(); if ($this->is_active($item) || $this->has_active_children($item)) { isset($item['list_attributes']['class']) or $item['list_attributes']['class'] = ''; $item['list_attributes']['class'] .= 'active'; } $item['pages'] = isset($item['pages']) ? $this->_render($item['pages'], array(), $level, $group, $currentDepth + 1) : ''; $items[] = $this->renderer->render_item($this, $item); } $str_items = implode(PHP_EOL, $items); return $this->renderer->render($this, $str_items, $attributes, $currentDepth); }
/** * Renders main layout. */ protected function renderMainLayout($content, $pageTitle, $dirPrefix = '', $langCode = 'en') { $vars = ['bookTitle' => $this->bookProps['book_title'], 'bookSubtitle' => $this->bookProps['book_subtitle'], 'keywords' => implode(',', $this->bookProps['keywords']), 'pageTitle' => $pageTitle, 'copyright' => $this->bookProps['copyright'], 'links' => $this->bookProps['links'], 'content' => $content, 'dirPrefix' => $dirPrefix, 'bookProps' => $this->bookProps, 'langCode' => $langCode]; $html = $this->phpRenderer->render("data/theme/default/layout/main.php", $vars); return $html; }
/** * render * * render function displays the view. * Question Time: What if I use desctructor to render the view? * @return void */ protected function render() { $this->view->render(); }