public function index($room_id) { $room = $this->Room->getRoomById($room_id); $this->set('room', $room); if (!empty($room)) { $last_update = time(); $idafter = 0; $messages = $this->Message->getMessages($room_id); if (!empty($messages)) { $messages = array_reverse($messages); $idafter = $messages[count($messages) - 1]['Message']['message_id']; } // Render message list $view = new View($this, false); $view->layout = false; $view->set(compact('messages', $messages)); $view->viewPath = 'Message'; $message_list = $view->render('message_list'); $this->set('message_list', $message_list); $this->set('idafter', $idafter); $this->set('last_update', $last_update); $this->set('title', $room['Room']['name']); } else { $this->set('title', 'Room not found!'); } }
public function index($feedtype = 'rss2') { if (!Kohana::config('settings.allow_feed')) { throw new Kohana_404_Exception(); } if ($feedtype != 'atom' and $feedtype != 'rss2') { throw new Kohana_404_Exception(); } // How Many Items Should We Retrieve? $limit = (isset($_GET['l']) and !empty($_GET['l']) and (int) $_GET['l'] <= 200) ? (int) $_GET['l'] : 20; // Start at which page? $page = (isset($_GET['p']) and !empty($_GET['p']) and (int) $_GET['p'] >= 1) ? (int) $_GET['p'] : 1; $page_position = $page == 1 ? 0 : $page * $limit; // Query position $site_url = url::base(); // Cache the Feed with subdomain in the cache name if mhi is set $subdomain = ''; if (substr_count($_SERVER["HTTP_HOST"], '.') > 1 and Kohana::config('config.enable_mhi') == TRUE) { $subdomain = substr($_SERVER["HTTP_HOST"], 0, strpos($_SERVER["HTTP_HOST"], '.')); } $cache = Cache::instance(); $feed_items = $cache->get($subdomain . '_feed_' . $limit . '_' . $page); if ($feed_items == NULL) { // Cache is Empty so Re-Cache $incidents = ORM::factory('incident')->where('incident_active', '1')->orderby('incident_date', 'desc')->limit($limit, $page_position)->find_all(); $items = array(); foreach ($incidents as $incident) { $categories = array(); foreach ($incident->category as $category) { $categories[] = (string) $category->category_title; } $item = array(); $item['id'] = $incident->id; $item['title'] = $incident->incident_title; $item['link'] = $site_url . 'reports/view/' . $incident->id; $item['description'] = $incident->incident_description; $item['date'] = $incident->incident_date; $item['categories'] = $categories; if ($incident->location_id != 0 and $incident->location->longitude and $incident->location->latitude) { $item['point'] = array($incident->location->latitude, $incident->location->longitude); $items[] = $item; } } $cache->set($subdomain . '_feed_' . $limit . '_' . $page, $items, array('feed'), 3600); // 1 Hour $feed_items = $items; } $feedpath = $feedtype == 'atom' ? 'feed/atom/' : 'feed/'; header('Content-Type: application/' . ($feedtype == 'atom' ? 'atom' : 'rss') . '+xml; charset=utf-8'); $view = new View('feed/' . $feedtype); $view->feed_title = Kohana::config('settings.site_name'); $view->site_url = $site_url; $view->georss = 1; // this adds georss namespace in the feed $view->feed_url = $site_url . $feedpath; $view->feed_date = gmdate("D, d M Y H:i:s T", time()); $view->feed_description = Kohana::lang('ui_admin.incident_feed') . ' ' . Kohana::config('settings.site_name'); $view->items = $feed_items; $view->render(TRUE); }
/** * generate xml for a form from a table * * @param object $setup * @return string * @author Andy Bennett */ function get_form_xml($setup) { $file_name = $setup->form_name; $dir = DATAPATH . '/xml/forms/'; $path = $dir . $file_name . '.xml'; if (file_exists($path)) { return file_get_contents($path); } if (!isset($setup->model) || !is_object($setup->model)) { $config = Kohana::config('controls.controllers'); $name = Kohana::instance()->uri->segment(1); if (!isset($config->{$name})) { throw new Exception("No controller set up"); } $this->set_table($config->{$name}['table']); } else { $this->set_table($setup->model->get_table()); $name = $setup->form_name; } $field_data = $this->db->field_data($this->table); // print_r($field_data); $view = new View('xml/form'); $view->field_data = $field_data; $view->name = Kohana::instance()->uri->segment(1); $view->action = Kohana::instance()->uri->segment(2); $data = $view->render(); if (file_exists($dir)) { file_put_contents($path, $data); } return $data; }
public function __construct($id = false) { parent::__construct(); $this->add("products"); $this->name = "form_slider"; $this->enctype = "multipart/form-data"; $this->action = URL::current(); $this->products = ProductDB::getAdminShow(); if (!$id) { $this->text("title", "Название:"); $this->textarea("description", "Описание:"); $this->submit("insert_slider", "Сохранить"); } else { $this->add("img"); $this->add("product_id"); $this->hidden("id", $id); $obj = new SliderDB(); $obj->load($id); $this->text("title", "Название:", $obj->title); $img = ProductDB::getCellOnID($obj->product_id, "img"); $view = new View(Config::DIR_TMPL); $this->img = $view->render("img", array("src" => Config::DIR_IMG_PRODUCT . $img), true); $this->textarea("description", "Описание:", $obj->description); $this->submit("update_slider", "Сохранить"); $this->product_id = $obj->product_id; } }
function __construct($path) { $chanbar = ' <ul> <li id="settings" class="option"><a href="#" class="button">settings</a></li> <li id="files" class="option"><a href="#" class="button">files</a></li> <li id="people" class="option"><a href="#" class="button">people</a></li> </ul> '; $user = Auth::user(); $curchan = DB::get()->val('SELECT name from channels where user_id = :user_id AND active = 1', array('user_id' => $user->id)); if ($curchan == '') { $curchan = 'bar'; } $widgets = Widgets::get_widgets(); $components = array('title' => 'Barchat Home', 'path' => $path, 'chanbar' => $chanbar, 'user_id' => Auth::user_id(), 'username' => $user->username, 'nickname' => $user->nickname, 'session_key' => $user->session_key, 'cur_chan' => addslashes($curchan), 'widgets' => $widgets); $v = new View($components); Plugin::call('reload', $user); //check for user agent $useragent = $_SERVER['HTTP_USER_AGENT']; // if (preg_match('/ip(hone|od|ad)/i', $useragent)) { $v->render('template-ios'); } else { $v->render('template'); } }
/** * Generates a model for a given schema * * @usage ./metal model/create --database=default --schema=public --table=user --related * @switch database The name of the database in the conf file * @switch schema The name of the schema, default is 'public' * @switch table The name of the table to generate the model for * @switch related Boolean determines if any related models should be generated. */ public function create() { $db = Database::Get($this->request->input->database); $schemaName = $this->request->input->schema ? $this->request->input->schema : 'public'; $schema = $db->table($schemaName, $this->request->input->table, $this->request->input->related); $rel_classname = ''; $names = explode('_', $this->request->input->table); foreach ($names as $n) { $rel_classname .= ucfirst($n); } $view = new View('index.html', $this, PATH_SYS . 'shell/view/model/'); $model = $view->render(array('classname' => $rel_classname, 'schema' => $schema, 'database' => $this->request->input->database)); $path = PATH_APP . 'model/' . $schemaName; if (!file_exists($path)) { mkdir($path); } file_put_contents($path . '/' . $schema->tablename . EXT, $model); foreach ($schema->related as $table) { $rel_classname = ''; $names = explode('_', $table->tablename); foreach ($names as $n) { $rel_classname .= ucfirst($n); } $model = $view->render(array('classname' => $rel_classname, 'schema' => $table, 'database' => $this->request->input->database)); $path = PATH_APP . 'model/' . $table->schema; if (!file_exists($path)) { mkdir($path); } file_put_contents($path . '/' . $table->tablename . EXT, $model); } die; }
/** * This method gets called after the action is called. * * @param mixed $response Value returned from the action method. * * @return Response $response */ public function after($response) { // Return if passed a response. if ($response instanceof Response) { return parent::after($response); } if ($this->autorender) { try { $this->view->set_filename(Str::lower(str_replace('_', '/', Inflector::denamespace(str_replace('controller_', '', Str::lower($this->request->controller)))) . DS . str_replace('_', '/', $this->request->action))); } catch (FuelException $e) { } } // Inject view into the layout if the main request. if ($this->layout instanceof View) { if ($this->autorender) { try { // Throws exception if there is no view template found. $this->layout->content = $this->view->render(); } catch (FuelException $e) { } } $this->layout->content_data = $this->view->get(); $this->response->body($this->layout); } else { $this->response->body($this->view); } return parent::after($this->response); }
/** * Assigns the template [View] as the request response. */ public function after() { if ($this->auto_render === TRUE) { $this->response->body($this->template->render()); } parent::after(); }
public function testRenderLayout() { $this->view->setLayout('layout'); $output = $this->view->render('page', true); $this->assertContains('Page text', $output); $this->assertContains('Layout start', $output); $this->assertContains('Layout end', $output); }
public static function render($print = false) { Benchmark::start(self::$benchmark_name); $template = new View('toolbar'); if (Kohana::config('debug_toolbar.panels.database')) { $template->set('queries', self::queries()); } if (Kohana::config('debug_toolbar.panels.logs')) { $template->set('logs', self::logs()); } if (Kohana::config('debug_toolbar.panels.vars_and_config')) { $template->set('configs', self::configs()); } if (Kohana::config('debug_toolbar.panels.files')) { $template->set('files', self::files()); } if (Kohana::config('debug_toolbar.firephp_enabled')) { self::firephp(); } switch (Kohana::config('debug_toolbar.align')) { case 'right': case 'center': case 'left': $template->set('align', Kohana::config('debug_toolbar.align')); break; default: $template->set('align', 'left'); } $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', true, 'js'))); Benchmark::stop(self::$benchmark_name); if (Kohana::config('debug_toolbar.panels.benchmarks')) { $template->set('benchmarks', self::benchmarks()); } if (Event::$data) { if (Kohana::config('debug_toolbar.auto_render') or Kohana::config('debug_toolbar.secret_key') !== FALSE and isset($_GET[Kohana::config('debug_toolbar.secret_key')])) { // try to add css to <head>, otherwise, send to template $styles = file_get_contents(Kohana::find_file('views', 'toolbar', false, 'css')); if (stripos(Event::$data, '</head>') !== FALSE) { Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data); } else { $template->set('styles', $styles); } // try to add js and HTML just before the </body> tag, // otherwise just append it to the output if (stripos(Event::$data, '</body>') !== FALSE) { Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data); } else { Event::$data .= $template->render(); } } } else { if ($print) { $template->render(TRUE); } else { return $template->render(); } } }
/** * Assigns the template [View] as the request response. */ public function after() { //send request headers parent::after(); if ($this->auto_render === TRUE) { $this->template->content = $this->view; $this->response->body($this->template->render()); } }
public function indexAction() { $container = new Container(); $collectorLocator = new CollectorLocator(new Request()); $topCatCollector = $collectorLocator->createBannersCollector(); $topCatCollector->collectTo($container); $this->assignContainerToView($container); echo $this->view->render(); }
public function render($action = null) { static $is_rendered = false; if ($is_rendered) { return; } $this->beforeRender(); $this->view->render($action); $is_rendered = true; }
function setTemplate($name, $data = array()) { if ($this->subject === '') { throw new Exception('You must define the subject before using a template'); } require_once APPPATH . 'models/objects/view.php'; $this->setHTMLOn(); $view = new View(); $layout_data = array('content' => $view->render(APPPATH . 'views/emails/' . $name . '.php', $data), 'subject' => $this->subject); $this->body = $view->render(APPPATH . 'views/layouts/email.php', $layout_data); }
private function _render($file) { $view = new View(); $body = NULL; if ($this->_includeTemplate) { $body = $view->render(FrontController::$dirname . '/views/header.phtml', $this->_response->getVars()); } $body .= $view->render(FrontController::$dirname . '/views/' . $file . '.phtml', $this->_response->getVars()); if ($this->_includeTemplate) { $body .= $view->render(FrontController::$dirname . '/views/footer.phtml', $this->_response->getVars()); } $this->_response->setBody($body); }
public function postDispatch() { $o_view = new View($this->getRequest(), $this->getRequest()->config->get('views_directory')); $o_notification = new NotificationManager($this->getRequest()); if ($o_notification->numNotifications()) { $o_view->setVar('notifications', $o_notification->getNotifications($this->getResponse()->isRedirect())); $this->getResponse()->prependContent($o_view->render('pageFormat/notifications.php'), 'notifications'); } //$nav = new AppNavigation($this->getRequest(), $this->getResponse()); $o_view->setVar('nav', $nav); //$this->getResponse()->prependContent($o_view->render('pageFormat/menuBar.php'), 'menubar'); $this->getResponse()->prependContent($o_view->render('pageFormat/pageHeader.php'), 'head'); $this->getResponse()->appendContent($o_view->render('pageFormat/pageFooter.php'), 'footer'); }
/** * Execute and dispatch action * @param $name * @throws BitException */ public function execute($name) { try { $name = !$name ? 'index' : $name; $action = Inflector::camelcase($name . '_action', true); $method = new \ReflectionMethod($this, $action); if (!$method->isPublic()) { throw new BitException(sprintf('Access to method %s::%s is not allowed', get_class($this), $method->getName())); } $this->view->render($name); $method->invoke($this); } catch (\Exception $e) { throw new BitException($e->getMessage()); } }
public function nuevoArticulo() { HelperFunctions::comprobarSesion(); if (!$_POST) { View::render('articulo/nuevoArticulo', array('titulo' => 'Nuevo Articulo')); } else { $_POST = HelperFunctions::sanear($_POST); $errores = []; if (!isset($_POST['titulo']) || empty($_POST['titulo'])) { $errores['titulo'] = ['titulo' => 'Debes introducir un título']; } if (!isset($_POST['cuerpo']) || empty($_POST['cuerpo'])) { $errores['cuerpo'] = ['cuerpo' => 'Debes introducir un cuerpo']; } if ($errores) { View::render('articulo/nuevoArticulo', array('titulo' => 'Nuevo Articulo', 'errores' => $errores)); } else { if (isset($_POST['publicar']) && ($_POST['publicar'] = 'on')) { $_POST['publicar'] = 1; } else { $_POST['publicar'] = 0; } $datos = $_POST; $titulo = $_POST['titulo']; $url = HelperFunctions::generarUrl($titulo); ArticuloModel::nuevoArticulo($datos); View::render('articulo/articuloGuardado', array('titulo' => 'Articulo Guardado', 'url' => $url)); } } }
public function render() { $content = parent::render(); Yii::app()->clientScript->scriptMap = array('jquery-ui.min.js' => false); Yii::app()->getClientScript()->render($content); return $content; }
function build() { $result=''; $rendered=''; $resultfilter = new $this->filter_class(); $resultfilter->controller = $this->controller; $resultfilter->datasource = $this->datasource; foreach($this->controller->appmeta->filter as $field => $filter) { if ($filter->hidden != 'true') { $resultfilter->clear(); $resultfilter->field = $field; $resultfilter->datasource = $this->datasource; $resultfilter->init(); $rendered .= $resultfilter->build(); } } if (!empty($this->container_template)) { $view=new View($this->container_template,$this->controller); $result=$view->render(array('meta'=>$this->controller->appmeta, 'control' => $this, 'content' => $rendered)); } else { $result=$rendered; } return $result; }
/** * index method */ public function index() { if ($this->param['method'] == 'POST') { $result = null; switch ($this->param['action']) { case 'create': $result = $this->transaction('create', $_POST); break; case 'modify': $result = $this->transaction('modify', $_POST); break; case 'remove': $result = $this->transaction('remove', $_POST); break; case 'sort': $result = $this->transaction('sort', $_POST); break; } if ($result) { Module::afterAction($result); } Goose::end(); } else { require_once __GOOSE_PWD__ . $this->path . 'view.class.php'; $view = new View($this); $view->render(); } }
public function index($feedtype = 'rss2') { if (!Kohana::config('settings.allow_feed')) { throw new Kohana_404_Exception(); } if ($feedtype != 'atom' and $feedtype != 'rss2') { throw new Kohana_404_Exception(); } $feedpath = $feedtype == 'atom' ? 'feed/atom/' : 'feed/'; $site_url = url::base(); $incidents = ORM::factory('incident')->where('incident_active', '1')->orderby('incident_date', 'desc')->limit(20)->find_all(); $items = array(); foreach ($incidents as $incident) { $item = array(); $item['title'] = $incident->incident_title; $item['link'] = $site_url . 'reports/view/' . $incident->id; $item['description'] = $incident->incident_description; $item['date'] = $incident->incident_date; if ($incident->location_id != 0 and $incident->location->longitude and $incident->location->latitude) { $item['point'] = array($incident->location->latitude, $incident->location->longitude); $items[] = $item; } } header("Content-Type: text/xml; charset=utf-8"); $view = new View('feed_' . $feedtype); $view->feed_title = htmlspecialchars(Kohana::config('settings.site_name')); $view->site_url = $site_url; $view->georss = 1; // this adds georss namespace in the feed $view->feed_url = $site_url . $feedpath; $view->feed_date = gmdate("D, d M Y H:i:s T", time()); $view->feed_description = 'Incident feed for ' . Kohana::config('settings.site_name'); $view->items = $items; $view->render(TRUE); }
/** * This little guy will add the UI to the /reports page so we can switch between AND and OR */ public function _add_report_filter_ui() { $operator = $this->_get_logical_operator(); $view = new View('adminmap/report_filter_ui'); $view->operator = $operator; $view->render(true); }
private function _send_reset() { $form = $this->_reset_form(); $valid = $form->validate(); if ($valid) { $user = user::lookup_by_name($form->reset->inputs["name"]->value); if (!$user->loaded || empty($user->email)) { $form->reset->inputs["name"]->add_error("no_email", 1); $valid = false; } } if ($valid) { $user->hash = md5(rand()); $user->save(); $message = new View("reset_password.html"); $message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}"); $message->user = $user; Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send(); log::success("user", t("Password reset email sent for user %name", array("name" => $user->name))); } else { // Don't include the username here until you're sure that it's XSS safe log::warning("user", "Password reset email requested for bogus user"); } message::success(t("Password reset email sent")); print json_encode(array("result" => "success")); }
function render() { if ($_GET['changed_contact_id']) { $contact = $this->add('xepan\\base\\Model_Contact'); $contact->load($_GET['changed_contact_id']); $js = []; // billing address $js[] = $this->js()->_selector('.billing_address')->find('input')->val($contact['billing_address'] ?: $contact['address']); $js[] = $this->js()->_selector('.billing_country_id')->find('select')->val($contact['billing_country_id'] ?: $contact['country_id']); $js[] = $this->js()->_selector('.billing_state_id')->find('select')->val($contact['billing_state_id'] ?: $contact['state_id']); $js[] = $this->js()->_selector('.billing_city')->find('input')->val($contact['billing_city'] ?: $contact['city']); $js[] = $this->js()->_selector('.billing_pincode')->find('input')->val($contact['billing_city'] ?: $contact['pin_code']); // shipping address $js[] = $this->js()->_selector('.shipping_address')->find('input')->val($contact['shipping_address'] ?: $contact['address']); $js[] = $this->js()->_selector('.shipping_country_id')->find('select')->val($contact['shipping_country_id'] ?: $contact['country_id']); $js[] = $this->js()->_selector('.shipping_state_id')->find('select')->val($contact['shipping_state_id'] ?: $contact['state_id']); $js[] = $this->js()->_selector('.shipping_city')->find('input')->val($contact['shipping_city'] ?: $contact['city']); $js[] = $this->js()->_selector('.shipping_pincode')->find('input')->val($contact['shipping_city'] ?: $contact['pin_code']); if (in_array($contact['type'], ['Customer', 'Supplier'])) { $tmp = $this->add('xepan\\commerce\\Model_' . $contact['type']); $tmp->load($_GET['changed_contact_id']); $js[] = $this->js()->_selector('.currency')->find('select')->select2("val", $tmp['currency_id'] ?: $tmp['currency_id']); } $this->js(true, $js); } parent::render(); }
function showedit() { $model = new Forum(); $data = $model->getEdit(); $data['formpath'] = 'edit'; View::render('forum/add', $data); }
/** * Chama a classe View e executa o o html */ public function render() { if ($this->view) { $this->beforeRender(); $this->View->render(); } }
public function delete() { if (!$this->request->is('post')) { $response['success'] = false; $response['error'] = __('Sorry, an error has occured.<br />Please try again.'); } else { $conditions = array('Subscription.feed_id' => $this->request->query['id'], 'Subscription.user_id' => $this->request->query['user']); $subscription = $this->Subscription->find('first', array('conditions' => $conditions)); if (!$subscription) { $response['success'] = false; $response['error'] = __('Sorry, an error has occured.<br />Please try again.'); } else { $this->Subscription->id = $subscription['Subscription']['id']; if ($this->Subscription->delete()) { $response['success'] = true; } else { $response['success'] = false; $response['error'] = __('Sorry, an error has occured.<br />Please try again.'); } } } $view = new View($this->controller, false); $view->layout = 'ajax'; $view->set('data', $response); $html = $view->render('/Shared/json/data'); echo $html; die; }
/** * Demonstrates how to use views inside of views. */ function template() { $data = array('title' => 'View-in-View Example', 'content' => 'This is my view-in-view page content.', 'copyright' => '© 2007 Kohana Team'); $view = new View('viewinview/container', $data); $view->header = new View('viewinview/header', $data); $view->render(TRUE); }
/** * Methode : page envoyer le mailing */ public function envoyer() { if ($_POST) { $texte = $this->input->post('texte'); $format = $this->input->post('format'); $sujet = $this->input->post('sujet'); $format = $format == 1 ? TRUE : FALSE; $users = $this->user->select(); $nbr_envois = 0; foreach ($users as $user) { if ($format) { $view = new View('mailing/template'); $view->name = ucfirst(mb_strtolower($user->username)); $view->content = $texte; $message = $view->render(); } else { $message = $texte; } if (email::send($user->email, Kohana::config('email.from'), $sujet, $message, $format)) { $nbr_envois++; } } return url::redirect('mailing?msg=' . urlencode(Kohana::lang('mailing.send_valide', number_format($nbr_envois)))); } else { return parent::redirect_erreur('mailing'); } }