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($message = "") { $view = new View('admin/instances'); $form_error = ""; $form_saved = ""; $form_action = ""; if (!empty($_GET['status'])) { $status = $_GET['status']; if (strtolower($status) == 'a') { $filter = 'is_approved = 0'; } } else { $status = "0"; $filter = "1=1"; } $db = Database::instance(); $sites = $db->query("SELECT B.username,B.email,A.id,is_approved,sitename,subdomain,tagline,description,keywords FROM sites AS A JOIN users AS B ON (A.user_id = B.id) WHERE {$filter} ORDER BY is_approved DESC"); $view->set("sites", $sites); $view->set("message", $message); $this->template->content = $view; $this->template->content->title = 'Instances'; $this->template->content->form_error = $form_error; $this->template->content->form_saved = $form_saved; $this->template->content->form_action = $form_action; $this->template->content->total_items = count($sites); $this->template->content->status = $status; $this->template->js = new View('admin/reports_js'); }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $Id = $_GET[0]; $View = new View(); new ControllerHelper($View, 'page-hard-article'); $Article = $this->Manhattan->GetModel()->prepare('SELECT * FROM sulake_news WHERE id = ?')->bind(array($Id))->execute(); if ($Article->num_rows() == 0) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'me', true); } while ($A = $Article->fetch_array()) { $View->set(array('article_title' => $A['title'], 'article_author' => $A['author'], 'article_date' => $A['date'], 'article_story' => nl2br($A['story']), 'article_image' => $A['image'], 'article_id' => $Id, 'page-tagline' => $A['title'])); } foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'site_title' => $this->Manhattan->Config['Site']['Title'], 'users_online' => 0, 'query_count' => $this->Manhattan->GetModel()->_count, 'exec_time' => round(microtime(true) - $this->Manhattan->Start, 3))); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $Exists = file_get_contents('Storage/Cache/Looks/' . $_SESSION['habbo']['look'] . '.png'); $HabboLook = file_get_contents('http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $_SESSION['habbo']['look'] . '.gif'); if ($Exists && $HabboLook && $Exists != $HabboLook) { file_put_contents('Storage/Cache/Looks/' . $_SESSION['habbo']['look'] . '.png', file_get_contents('http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $_SESSION['habbo']['look'] . '.gif')); } $View = new View(); new ControllerHelper($View, 'page-me'); foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'page-tagline' => $_SESSION['habbo']['username'], 'site_title' => $this->Manhattan->Config['Site']['Title'], 'users_online' => 0, 'query_count' => $this->Manhattan->GetModel()->_count, 'exec_time' => round(microtime(true) - $this->Manhattan->Start, 3))); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
function run($action = 'main', $layout = 'layout') { $db = new Db(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); if(substr($action, -1) == '/') { // remove last slash if exists $action = substr($action, 0, -1); } $action = str_replace('/', '_', $action); $controller = WWW_ROOT . '/controllers/' . $action . '.php'; if(strcmp(realpath($controller), $_SERVER['DOCUMENT_WWW_ROOT'])) { $view = new View($action, $layout); if(isset($_SESSION['user'])) { $user = $_SESSION['user']; $view->set('user', $user); } if(is_file($controller)) { include($controller); } else { $view->changeAction('404'); } $view->set('user', $user); $view->display(); } else { trigger_error('Hacker attack from IP:' . $_SERVER['REMOTE_ADDR']); die(); } }
public function browse($order = 'browse', $page = 1) { if (isset($_POST['rating'])) { $this->_rate(); } if (isset($_POST['submit_quote'])) { $this->_submit(); } if (request::is_ajax()) { die; } //Done with possible ajax calls $pagination = new Pagination(array('base_url' => "quotes/{$order}/page", 'uri_segment' => 'page', 'total_items' => ORM::factory('quote')->count_all(), 'items_per_page' => self::num_per_page)); switch ($order) { case 'latest': $quotes = ORM::factory('quote')->orderby('id', 'DESC')->find_all(self::num_per_page, $pagination->sql_offset); break; case 'rating': $quotes = ORM::factory('quote')->orderby('rating', 'DESC')->find_all(self::num_per_page, $pagination->sql_offset); break; default: $quotes = ORM::factory('quote')->find_all(self::num_per_page, $pagination->sql_offset); } $t = new View('quotes'); $t->set('quotes', $quotes); $t->set('pagination', $pagination); $t->render(TRUE); }
public function users($id = 0) { if (!$this->auth->logged_in('admin')) { throw new Kohana_404_Exception(); } if ($id == 0) { $t = new View('login/users'); $t->set('users', ORM::factory('user')->find_all()); return $t->render(TRUE); } $user = ORM::factory('user', $id); if (isset($_POST['reset'])) { $this->_reset_password($user); } if (isset($_POST['delete'])) { $this->_delete_user($user); } if (isset($_POST['save_roles'])) { $this->_update_roles($user); } $roles = array(); foreach ($user->roles as $role) { $roles[] = $role->id; } $t = new View('login/users_view'); $t->set('user', $user); $t->set('user_roles', $roles); $t->set('roles', ORM::factory('role')->find_all()); return $t->render(TRUE); }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $View = new View('page-client'); $View->javascript('swfobject'); $this->Manhattan->GetModel()->prepare('UPDATE users SET auth_ticket = ? WHERE id = ?')->bind(array('sulake.' . $_SESSION['habbo']['username'], $_SESSION['habbo']['id']))->execute(); $_SESSION['habbo']['auth_ticket'] = 'sulake.' . $_SESSION['habbo']['username']; $this->Manhattan->GetModel()->prepare('UPDATE users SET ip_last = ?, ip_reg = ? WHERE id = ?')->bind(array(IP_ADDRESS, IP_ADDRESS, $_SESSION['habbo']['id']))->execute(); foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'page-tagline' => 'Index')); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
public function action_news() { $slug = $this->request->param('slug'); $pageData = $this->newsModel->findNews(null, null, $slug == 'all' ? null : $slug, 'all'); $content = $this->contentModel->getContent('news', $pageData); $footer = View::factory('footer')->set('pagesImgs', []); $this->template->set('content', $content)->set('footer', $footer); $this->response->body($this->template); }
protected function _setLayoutVars() { $this->layout->set('months', $this->_getMonths()); $this->layout->set('days', $this->_getDays()); $this->layout->set_global('active_month', "{$this->_year}/{$this->_month}"); $this->layout->set_global('active_day', $this->_day); $this->layout->set_global('active_report', "{$this->_day}.php"); $this->layout->set_global('log_level', $this->_level); }
public function _get() { //create the form $form = new Form_Table('tests/loading/'); $name_el = $form->add_textbox('nickname', 'Nickname'); $name_el->setting('value', $this->args->nickname); $birth_el = $form->add_textbox('birth', 'Date'); $birth_el->setting('value', $this->args->birth); $penguins_el = $form->add_select('penguins', 'Penguins'); for ($i = 0; $i < 10; $i++) { $penguins_el->add_item($i, "{$i} penguins"); } $penguins_el->setting('selected', $this->args->penguins); $pies_el = $form->add_textbox('pies', 'Pies'); $pies_el->setting('value', $this->args->pies); $awesome_el = $form->add_checkbox('awesome', 'Awesome?'); $awesome_el->setting('checked', $this->args->awesome); //create the table $table = new Table_Basic(); $caption = $table->add_caption('A Table of information'); $header = $table->add_header(); $header->add_cell('Question'); $header->add_cell('Answer'); $new_row = $table->add_row(); $new_row->add_cell('Who Are You?'); $new_row->add_cell($this->args->nickname); $new_row = $table->add_row(); $new_row->add_cell('Your Birthday Is?'); $new_row->add_cell($this->args->birth); $new_row = $table->add_row(); $new_row->add_cell('How many Penguins do you own?'); $new_row->add_cell($this->args->penguins); $new_row = $table->add_row(); $new_row->add_cell('How many Pies did you eat?'); $new_row->add_cell($this->args->pies); $new_row = $table->add_row(); $new_row->add_cell('Is this Awesome?'); if ($this->args->awesome) { $new_row->add_cell('Hell Yeah'); } else { $new_row->add_cell('Not Really'); } // get the views $page = new View('main', 'layouts', VPATH); $sidebar = new View('sidebar', 'layouts', VPATH); $content = new View('content', 'classtest', VPATH); $header = new View('header', 'classtest', VPATH); //insert data into views $content->set("table_html", $table->render()); $content->set("form_html", $form->render()); $page->set("sidebar", $sidebar->package()); $page->set("header", $header->package()); $page->set("content", $content->package()); //render final view $page->render(); }
public function action_project() { $slug = $this->request->param('id'); $pageData = Arr::get($this->contentModel->findPortfolioProject(null, null, $slug), 0, []); $view = 'page'; $content = $this->contentModel->getContent($view, $pageData)->set('projectGalleryImgs', $this->contentModel->findProjectImgs(Arr::get($pageData, 'id'), null, null, 1)); $footer = ''; $this->template->set('content', $content)->set('footer', $footer); $this->response->body($this->template); }
/** * Execute custom widget action. * * @access public * @param View $view * @return string * @throws Exception\Fatal * @since 1.0.0-alpha * @version 1.0.0-alpha */ public static function execute(View $view) { $aDbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $sCaller = isset($aDbt[1]['function']) ? $aDbt[1]['function'] : NULL; if (static::$oMainView === NULL) { static::$oMainView = View::factory(static::$sMainView); } $sClass1 = strtolower(str_replace('\\', '_', get_called_class())); $sClass2 = $sClass1 . '_' . strtolower(str_replace('action', '', $sCaller)); return static::$oMainView->set('sClasses', $sClass1 . ' ' . $sClass2)->set('oContent', $view)->render(); }
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(); } } }
public function sendConfirmation($userAttr) { $mail = Mail::getInstance(); $mail->setTo($userAttr['email']); $mail->setFrom(); $mail->setSubject('Your account is created succussful'); $view = new View(HOME . DS . 'views' . DS . 'confirm.tpl'); $view->set('user', $userAttr); $view->set('url', APP_URL . '/activate.php?token=' . $userAttr['confirmation_code']); $mail->setTemplate($view->content()); return $mail->send(); }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); $this->_View = new BcAppView(); $SiteConfig = ClassRegistry::init('SiteConfig'); $siteConfig = $SiteConfig->findExpanded(); $this->_View->set('widgetArea', $siteConfig['widget_area']); $this->_View->set('siteConfig', $siteConfig); $this->_View->helpers = array('BcBaser'); $this->_View->loadHelpers(); $this->BcBaser = $this->_View->BcBaser; }
public static function response(Exception $e) { // handle error if (Kohana::$environment >= Kohana::DEVELOPMENT) { return parent::response($e); } else { $view = new View('templates/errors/default'); $view->set('title', "500 Internal Server Error"); $view->set('message', "{$e->getMessage()}"); $response = Response::factory()->status(500)->body($view->render()); return $response; } }
/** * Render the partials and the theme template * * @return string|View * @throws \ThemeException */ public function render() { // make sure the template to be rendered is defined if (empty($this->template)) { throw new \ThemeException('No valid template could be found. Use set_template() to define a page template.'); } // pre-process all defined partials foreach ($this->partials as $key => $partials) { $output = ''; foreach ($partials as $index => $partial) { // render the partial $output .= $partial->render(); } // store the rendered output if (!empty($output) and array_key_exists($key, $this->chrome)) { // encapsulate the partial in the chrome template $this->partials[$key] = $this->chrome[$key]->set($this->chrome['var'], $output, false); } else { // store the partial output $this->partials[$key] = $output; } } // assign the partials to the template $this->template->set('partials', $this->partials, false); // return the template return $this->template; }
/** * Default action * @param $args array */ public function index(array $args = array()) { $hooks = array(); \View::set('registerLayoutHooks', $hooks); \View::set('username', isset($_POST['username']) ? $_POST['username'] : ''); \View::set('email', isset($_POST['email']) ? $_POST['email'] : ''); \View::set('password', isset($_POST['password']) ? $_POST['password'] : ''); \View::set('pageTitle', 'Register'); $auth = $this->app->getModel('player'); if (isset($_POST['register'])) { $insert = array(); $insert['username'] = $_POST['username']; $insert['email'] = $_POST['email']; $insert['password'] = $_POST['password']; $insert['confirm_password'] = $_POST['password2']; try { /* Attempt to register the account */ $register = $auth->create($insert); } catch (\Exception $e) { $message = '<strong>You could not be registered:</strong><ul>'; foreach (unserialize($e->getMessage()) as $prev) { $message .= '<li>' . $prev->getMessage() . '</li>'; } $message .= '</ul>'; \View::setMessage($message, 'warn'); } /* If the account is active, redirect the user to the login page */ if (isset($register['active']) && $register['active'] == '1') { \View::setMessage('Your accounts was successfully created. You may now log in.', 'success'); } elseif (isset($register['active']) && $register['active'] == '0') { \View::setMessage('Your account has been created, but requires activation.', 'success'); \View::setTemplate('Index.twig'); } } }
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; }
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('Like.foreign_key' => $this->request->query['id'], 'Like.model' => $this->request->query['model'], 'Like.user_id' => $this->request->query['user']); $like = $this->Like->find('first', array('conditions' => $conditions)); if (!$like) { $response['success'] = false; $response['error'] = __('Sorry, an error has occured.<br />Please try again.'); } else { $this->Like->id = $like['Like']['id']; if ($this->Like->delete()) { $response['success'] = true; $response['msgText'] = __($this->request->query['model'] . " removed from likes."); } else { $response['success'] = false; $response['error'] = __('Sorry, an error has occured.<br />Please try again.'); } } } $view = new View($this->controller, false); $view->layout = 'LikeableContent.ajax'; $view->set('data', $response); $html = $view->render('/Shared/Admin/json/data'); echo $html; die; }
public function testViewCanRenderVar() { View::set('varname', 'varname'); $this->assertEquals('varname', View::render('testvar.phtml')); $this->assertEquals('varname', View::render('getvar.phtml')); $this->assertEquals('string(7) "varname"', trim(View::render('dumpvar.phtml'))); }
/** * Default action. * * @param $args array */ public function index(array $args = array()) { $error = null; $playerModel = \App::getModel('Player'); $session = \App::getModel('Session'); if (empty($_POST['username']) || empty($_POST['password'])) { $error = 'Please enter your username and password!'; } else { try { $player = $playerModel->authenticate($_POST['username'], $_POST['password']); } catch (\Exception $e) { $error = 'Invalid username and/or password.'; if (\Config::get('security.login.showInvalidLoginReason')) { $error = $e->getMessage(); } } } if (isset($error)) { $session->clear(); $error = '<strong>Sorry, you could not be logged in...</strong><br />' . $error; \View::setMessage($error, 'fail'); /* Changed from a header to just grabbing the view itself */ \View::setTemplate('Index.twig'); \View::set('credentials', array('username' => \Config::get('security.login.returnUsernameOnFailure') ? isset($_POST['username']) ? $_POST['username'] : '' : '')); } }
public function getMessage() { $room_id = $this->request->data('room_id'); $idafter = $this->request->data('idafter'); $this->autoRender = false; $response = array('status' => 'success', 'data' => '', 'error' => ''); $room_id = intval($room_id); $idafter = intval($idafter); $last_update = time(); $messages = $this->Message->getMessages($room_id, null, $idafter); // Render message list $view = new View($this, false); $view->layout = false; $view->set(compact('messages', $messages)); $view->viewPath = 'Message'; $message_list_html = $view->render('message_list'); // Set response data $response['data']['message_list'] = $message_list_html; $response['data']['new_message_count'] = count($messages); $response['data']['idafter'] = $idafter; $response['data']['last_update'] = time(); if (!empty($messages)) { $response['data']['idafter'] = $messages[count($messages) - 1]['Message']['message_id']; } // Update list $last_update = $this->request->data('last_update'); $messages = $this->Message->getUpdatedList($last_update); $response['data']['update_list'] = $messages; header('Content-Type: application/json'); echo json_encode($response); }
public function _get() { $test = new Test('test 1'); $test->add_var()->add_var(); $test->set('var3', 200); $var_list = $test->get_var_data(); $page = new View('main', 'layouts', VPATH); $sidebar = new View('sidebar', 'layouts', VPATH); $content = new View('content', 'loading', VPATH); $header = new View('header', 'loading', VPATH); $content->merge($test->get_var_data()); $page->set("sidebar", $sidebar->package()); $page->set("header", $header->package()); $page->set("content", $content->package()); $page->render(); }
/** * * @return string */ public function render() { $this->content(); if ($this->_template instanceof View) { $this->_content = $this->_template->set(array('attributes' => $this->attributes(), 'element' => $this, 'content' => $this->_content, 'data' => $this->data()))->render(); } return (string) $this->_content; }
public function doView() { $areaService = new AreaService(); $areaId = intval(Request::get("view_area_id")); $areaVo = $areaService->getByPrimary($areaId); View::set("AreaViewValue", $areaVo); View::display("View"); }
public function edit($id) { $view = new View("product/edit.php"); $modelProduct = new Product(); $product = $modelProduct->getProduct($id); $view->set('product', $product); $view->output(); }
public function new_comment($to, $comment) { $subject = __('New comment'); $template = new View('emails/new_comment'); $template->set("comment", $comment); $message = $this->build_html_message($template); Email::send($to, $this->from, $subject, $message, $this->html); }
protected function renderElement($element, $data = array()) { $view = new View(ClassRegistry::getObject('EventController'), false); $view->set('data', $data); $html = $view->element($element, $this->params, true); $view = null; unset($view); return $html; }