本文整理汇总了PHP中View::set方法的典型用法代码示例。如果您正苦于以下问题:PHP View::set方法的具体用法?PHP View::set怎么用?PHP View::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
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!');
}
}
示例2: index
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');
}
示例3: action
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');
}
}
示例4: action
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');
}
}
示例5: run
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();
}
}
示例6: browse
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);
}
示例7: users
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);
}
示例8: action
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');
}
}
示例9: action_news
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);
}
示例10: _setLayoutVars
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);
}
示例11: _get
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();
}
示例12: action_project
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);
}
示例13: execute
/**
* 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();
}
示例14: 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();
}
}
}
示例15: sendConfirmation
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();
}