本文整理汇总了PHP中View::InitView方法的典型用法代码示例。如果您正苦于以下问题:PHP View::InitView方法的具体用法?PHP View::InitView怎么用?PHP View::InitView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::InitView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Get
/**
* Extract values from database and set them to object properties
* @param integer $id ID of record to be instantiated
* @return void DB record's fields are loaded into object properties
*/
private function Get($id)
{
$query = 'SELECT * FROM ' . DB_PREFIX . self::$table . ' WHERE ' . self::$id_name . "= {$id}";
$result = $this->db->Query($query);
$row = $this->db->FetchAssoc($result);
foreach ($row as $key => $value) {
$this->{$key} = $value;
}
// User specific values
View::InitView();
$this->role = empty($this->role) ? 'user' : $this->role;
$this->avatar_url = empty($this->avatar) ? View::GetFallbackUrl('images/avatar.gif') : HOST . "/cc-content/uploads/avatars/{$this->avatar}";
$this->date_created = Functions::GmtToLocal($this->date_created);
$this->last_login = Functions::GmtToLocal($this->last_login);
$this->video_count = $this->GetVideoCount();
Plugin::Trigger('user.get');
}
示例2: Get
/**
* Extract values from database and set them to object properties
* @param integer $id ID of record to be instantiated
* @return void
*/
private function Get($id)
{
$query = 'SELECT * FROM ' . DB_PREFIX . self::$table . ' WHERE ' . self::$id_name . "= {$id}";
$result = $this->db->Query($query);
$row = $this->db->FetchAssoc($result);
foreach ($row as $key => $value) {
$this->{$key} = $value;
}
// Custom Vars
$this->date_created = Functions::GmtToLocal($this->date_created);
$this->comments_display = nl2br($row['comments']);
if ($this->user_id != 0) {
$user = new User($this->user_id);
$this->name = $user->username;
$this->email = $user->email;
$this->website = HOST . '/members/' . $user->username . '/';
$this->avatar_url = $user->avatar_url;
} else {
View::InitView();
$this->avatar_url = View::GetFallbackUrl('images/avatar.gif');
}
Plugin::Trigger('comment.get');
}
示例3: dirname
<?php
// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('activate');
Plugin::Trigger('activate.start');
View::$vars->logged_in = User::LoginCheck();
Functions::RedirectIf(!View::$vars->logged_in, HOST . '/myaccount/');
View::$vars->message = null;
### Verify token was provided
if (isset($_GET['token'])) {
$token = $_GET['token'];
$id = User::Exist(array('confirm_code' => $token, 'status' => 'new'));
if ($id) {
$user = new User($id);
$user->Approve('activate');
if (Settings::Get('auto_approve_users') == 1) {
View::$vars->message = Language::GetText('activate_success', array('host' => HOST));
$_SESSION['user_id'] = $user->user_id;
} else {
View::$vars->message = Language::GetText('activate_approve');
}
View::$vars->message_type = 'success';
Plugin::Trigger('activate.activate');
} else {
View::$vars->message = Language::GetText('activate_error', array('host' => HOST));
View::$vars->message_type = 'error';
}
} else {
示例4: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Message');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
View::InitView('message_inbox');
Plugin::Trigger('message_inbox.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 20;
$url = HOST . '/myaccount/message/inbox';
View::$vars->message = null;
/***********************
Handle form if submitted
***********************/
// Delete message (Request came from this page)
if (isset($_POST['submitted'])) {
// Verify messages were chosen
if (!empty($_POST['delete']) && is_array($_POST['delete'])) {
foreach ($_POST['delete'] as $value) {
$data = array('recipient' => View::$vars->user->user_id, 'message_id' => $value);
$message_id = Message::Exist($data);
if ($message_id) {
Message::Delete($message_id);
Plugin::Trigger('message_inbox.purge_single_message');
}
}
View::$vars->message = Language::GetText('success_messages_purged');
示例5: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Pagination');
App::LoadClass('Rating');
App::LoadClass('Favorite');
// Establish page variables, objects, arrays, etc
View::InitView('myfavorites');
Plugin::Trigger('myfavorites.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/myfavorites';
View::$vars->message = null;
/***********************
Handle Form if submitted
***********************/
if (isset($_GET['vid']) && is_numeric($_GET['vid']) && $_GET['vid'] != 0) {
$data = array('user_id' => View::$vars->user->user_id, 'video_id' => $_GET['vid']);
$id = Favorite::Exist($data);
if ($id) {
Favorite::Delete($id);
View::$vars->message = Language::GetText('success_favorite_removed');
View::$vars->message_type = 'success';
Plugin::Trigger('myfavorites.remove_favorite');
}
}
// Retrieve total count
示例6: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Privacy');
// Establish page variables, objects, arrays, etc
View::InitView('privacy_settings');
Plugin::Trigger('privacy_settings.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
View::$vars->privacy = Privacy::LoadByUser(View::$vars->user->user_id);
View::$vars->data = array();
View::$vars->errors = array();
View::$vars->message = null;
/**************************
* Handle Form if submitted
*************************/
if (isset($_POST['submitted'])) {
// Validate Video Comments
if (isset($_POST['video_comment']) && in_array($_POST['video_comment'], array('0', '1'))) {
View::$vars->data['video_comment'] = $_POST['video_comment'];
} else {
View::$vars->errors['video_comment'] = TRUE;
}
// Validate Private Message
if (isset($_POST['new_message']) && in_array($_POST['new_message'], array('0', '1'))) {
View::$vars->data['new_message'] = $_POST['new_message'];
} else {
View::$vars->errors['new_message'] = TRUE;
}
示例7: dirname
<?php
// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Page');
// Establish page variables, objects, arrays, etc
View::InitView();
Plugin::Trigger('page.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
View::$vars->user = new User(View::$vars->logged_in);
}
$page_id = null;
// Parse preview request
if (!empty($_GET['preview']) && is_numeric($_GET['preview'])) {
$page_id = Page::Exist(array('page_id' => $_GET['preview']));
// Parse the URI request
} else {
$request = preg_replace('/^\\/?(.*?)\\/?$/', '$1', basename($_SERVER['REQUEST_URI']));
$page_id = Page::Exist(array('slug' => $request, 'status' => 'published'));
}
### Validate requested page
if ($page_id) {
// Retrieve custom page
$page = new Page($page_id);
$page_name = 'page_' . $page->slug;
// Set view settings for custom page
View::$vars->page = $page;
View::$options->page = $page_name;
View::$vars->meta = Language::GetMeta($page_name);
示例8: dirname
<?php
// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Rating');
App::LoadClass('Subscription');
App::LoadClass('Flag');
App::LoadClass('Post');
// Establish page variables, objects, arrays, etc
View::InitView('profile');
Plugin::Trigger('profile.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
View::$vars->user = new User(View::$vars->logged_in);
}
$success = NULL;
$errors = NULL;
$sub_id = NULL;
$post_count = 5;
// Verify Member was supplied
if (isset($_GET['username'])) {
$data = array('username' => $_GET['username'], 'status' => 'Active');
$user_id = User::Exist($data);
} else {
App::Throw404();
}
// Verify Member exists
if ($user_id) {
View::$vars->member = new User($user_id);
示例9: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Subscription');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
View::InitView('subscribers');
Plugin::Trigger('subscribers.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/subscribers';
// Retrieve total count
$query = "SELECT user_id FROM " . DB_PREFIX . "subscriptions WHERE member = " . View::$vars->user->user_id;
$result_count = $db->Query($query);
$total = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, $total, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
View::$vars->result = $db->Query($query);
// Output page
Plugin::Trigger('subscribers.before_render');
View::Render('myaccount/subscribers.tpl');
示例10: dirname
<?php
// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
View::InitView('members');
Plugin::Trigger('members.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
View::$vars->user = new User(View::$vars->logged_in);
}
$records_per_page = 12;
$url = HOST . '/members';
// Retrieve total count
$query = "SELECT user_id FROM " . DB_PREFIX . "users WHERE status = 'Active'";
$result_count = $db->Query($query);
$total = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, $total, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
View::$vars->result = $db->Query($query);
// Output Page
Plugin::Trigger('members.before_render');
View::Render('members.tpl');
示例11: dirname
<?php
// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Privacy');
// Establish page variables, objects, arrays, etc
View::InitView('opt_out');
Plugin::Trigger('opt_out.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
View::$vars->user = new User(View::$vars->logged_in);
}
### Verify user actually unsubscribed
if (isset($_GET['email'])) {
$data = array('email' => $_GET['email']);
$id = User::Exist($data);
if ($id) {
$privacy = Privacy::LoadByUser($id);
$data = array('new_video' => 'no', 'new_message' => 'no', 'video_comment' => 'no');
Plugin::Trigger('opt_out.opt_out');
$privacy->Update($data);
} else {
App::Throw404();
}
} else {
App::Throw404();
}
// Output Page
Plugin::Trigger('opt_out.before_render');
View::Render('opt_out.tpl');
示例12: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Subscription');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
View::InitView('subscriptions');
Plugin::Trigger('subscriptions.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/subscriptions';
View::$vars->message = null;
/***********************
Handle Form if submitted
***********************/
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$data = array('user_id' => View::$vars->user->user_id, 'member' => $_GET['id']);
$id = Subscription::Exist($data);
if ($id) {
$subscribed_user = new User($_GET['id']);
Subscription::Delete($id);
View::$vars->message = Language::GetText('success_unsubscribed', array('username' => $subscribed_user->username));
View::$vars->message_type = 'success';
Plugin::Trigger('subscriptions.unsubscribe');
}
}
/******************
Prepare page to run
示例13: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('myaccount');
Plugin::Trigger('myaccount.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
View::$vars->new_messages = NULL;
View::$vars->meta->title = Functions::Replace(View::$vars->meta->title, array('username' => View::$vars->user->username));
// Check for unread messages
$query = "SELECT message_id FROM " . DB_PREFIX . "messages WHERE recipient = " . View::$vars->user->user_id . " AND status = 'unread'";
$result = $db->Query($query);
if ($db->Count($result) > 0) {
View::$vars->new_messages = ' <strong>*(new messages)</strong>';
}
// Output Page
Plugin::Trigger('myaccount.before_render');
View::Render('myaccount/myaccount.tpl');
示例14: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Pagination');
App::LoadClass('Rating');
// Establish page variables, objects, arrays, etc
View::InitView('myvideos');
Plugin::Trigger('myvideos.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/myvideos';
View::$vars->message = null;
/***********************
Handle Form if submitted
***********************/
if (isset($_GET['vid']) && is_numeric($_GET['vid'])) {
$data = array('user_id' => View::$vars->user->user_id, 'video_id' => $_GET['vid']);
$video_id = Video::Exist($data);
if ($video_id) {
Video::Delete($video_id);
View::$vars->message = Language::GetText('success_video_deleted');
View::$vars->message_type = 'success';
Plugin::Trigger('myvideos.delete_video');
}
}
// Retrieve total count
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE user_id = " . View::$vars->user->user_id . " AND status = 'approved'";
示例15: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('Video');
// Establish page variables, objects, arrays, etc
View::InitView('mobile_index');
Plugin::Trigger('mobile_index.start');
// Retrieve updated page title
View::$vars->meta->title = Language::GetText('mobile_heading', array('sitename' => $config->sitename));
// Retrieve Featured Video
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND featured = 1 AND private = '0' AND gated = '0'";
View::$vars->featured_video = array();
$result_featured = $db->Query($query);
while ($video = $db->FetchObj($result_featured)) {
View::$vars->featured_video[] = $video->video_id;
}
// Retrieve Recent Videos
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND gated = '0' ORDER BY video_id DESC LIMIT 3";
View::$vars->recent_videos = array();
$result_recent = $db->Query($query);
while ($video = $db->FetchObj($result_recent)) {
View::$vars->recent_videos[] = $video->video_id;
}
// Output Page
Plugin::Trigger('mobile_index.before_render');
View::Render('index.tpl');