本文整理汇总了PHP中HomeView::show方法的典型用法代码示例。如果您正苦于以下问题:PHP HomeView::show方法的具体用法?PHP HomeView::show怎么用?PHP HomeView::show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HomeView
的用法示例。
在下文中一共展示了HomeView::show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUser
public static function updateUser()
{
// Process updating of user information
$users = UsersDB::getUsersBy('userId', $_SESSION['arguments']);
if (empty($users)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['users'] = $users;
UserView::showUpdate();
} else {
$parms = $users[0]->getParameters();
$parms['userName'] = array_key_exists('userName', $_POST) ? $_POST['userName'] : "";
$parms['password'] = array_key_exists('password', $_POST) ? $_POST['password'] : "";
$newUser = new User($parms);
$newUser->setUserId($users[0]->getUserId());
$user = UsersDB::updateUser($newUser);
if ($user->getErrorCount() != 0) {
$_SESSION['users'] = array($newUser);
return;
UserView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
示例2: updateSensor
private function updateSensor()
{
$sensor = $_SESSION['sensor'];
if (empty($sensor)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
SensorView::showUpdate();
} else {
$params = $sensor->getParameters();
$params['sensor_name'] = array_key_exists('sensor_name', $_POST) ? $_POST['sensor_name'] : '';
$params['description'] = array_key_exists('description', $_POST) ? $_POST['description'] : '';
$updatedSensor = new Sensor($params);
$updatedSensor->setSensorId($sensor->getSensorId());
$returnedSensor = SensorsDB::updateSensor($updatedSensor);
if ($returnedSensor->getErrorCount() == 0) {
// Show the Sensor View which should display the updated params
SensorView::show();
header('Location: /' . $_SESSION['base'] . '/sensor/show/' . $sensor->getSensorId());
} else {
// Carry over the measurements, if any
$updatedSensor->setMeasurements($sensor->getMeasurements());
$_SESSION['sensor'] = $updatedSensor;
SensorView::showUpdate();
}
}
}
示例3: updateSubmission
public static function updateSubmission()
{
// Process updating submissions
$submissions = SubmissionsDB::getSubmissionsBy('submissionId', $_SESSION['arguments']);
if (empty($submissions)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['submissions'] = $submissions;
SubmissionView::showUpdate();
} else {
$parms = $submissions[0]->getParameters();
$parms['submissionFile'] = array_key_exists('submissionFile', $_POST) ? $_POST['submissionFile'] : "";
$newSubmission = new Submission($parms);
$newSubmission->setSubmissionId($submissions[0]->getSubmissionId());
$submission = SubmissionsDB::updateSubmission($newSubmission);
if ($submission->getErrorCount() != 0) {
$_SESSION['submissions'] = array($newSubmission);
SubmissionView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
示例4: show
private function show()
{
$arguments = array_key_exists('arguments', $_SESSION) ? $_SESSION['arguments'] : 0;
// Identify the target user
$users = UsersDB::getUsersBy('user_id', $arguments);
$user = $users[0];
if (!is_null($user)) {
// Prepare all data to be displayed in the target user's ProfileView
// --all of their datasets
// --all of the sensors for each dataset
// TODO: add 'member since'
$datasets = DatasetsDB::getDatasetsBy('user_id', $user->getUserId());
foreach ($datasets as $dataset) {
$sensors = SensorsDB::getSensorsBy('dataset_id', $dataset->getDatasetId());
$dataset->setSensors($sensors);
}
$_SESSION['user'] = $user;
$_SESSION['datasets'] = $datasets;
ProfileView::show();
} else {
$_SESSION['user'] = null;
// TODO:: Consider showing a 'Specified user does not exist' page
HomeView::show();
}
}
示例5: updateUser
public static function updateUser()
{
$users = UsersDB::getUsersBy('userID', $_SESSION['arguments']);
if (empty($users)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['users'] = $users;
UserView::showUpdate();
} else {
$parms = $users[0]->getParameters();
$parms['userName'] = array_key_exists('userName', $_POST) ? $_POST['userName'] : $users[0]->getUsername();
$parms['rank'] = array_key_exists('rank', $_POST) ? $_POST['rank'] : $users[0]->getRank();
$newUser = new User($parms);
$newUser->setUserID($users[0]->getUserID());
$user = UsersDB::updateUser($newUser);
if ($user->getErrorCount() != 0) {
$_SESSION['user'] = $newUser;
UserView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
示例6: updateUser
private function updateUser($userId)
{
$users = UsersDB::getUsersBy('user_id', $userId);
if (empty($users)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} else {
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$_SESSION['user'] = $users[0];
UserView::showUpdate();
} else {
$params = $users[0]->getParameters();
$params['username'] = array_key_exists('username', $_POST) ? $_POST['username'] : "";
$params['password'] = array_key_exists('password', $_POST) ? $_POST['password'] : "";
$updatedUser = new User($params);
$updatedUser->setUserId($users[0]->getUserId());
$plaintextPassword = $updatedUser->getPassword();
$hashedPassword = password_hash($plaintextPassword, PASSWORD_DEFAULT);
$updatedUser->setPassword($hashedPassword);
$returnedUser = UsersDB::updateUser($updatedUser);
if ($returnedUser->getErrorCount() == 0) {
// TODO: Log out the current user before diplaying the HomeView; LogoutController::LogoutCurrentUser()
HomeView::show();
header('Location: /' . $_SESSION['base']);
} else {
$_SESSION['user'] = $updatedUser;
UserView::showUpdate();
}
}
}
}
示例7: run
public static function run()
{
$action = $_SESSION['action'];
$arguments = $_SESSION['arguments'];
switch ($action) {
case "show":
$users = UsersDB::getUsersBy('userId', $arguments);
if (count($users) > 0) {
$user = $users[0];
if (self::setProfileDataForUser($user->getUserId()) == true) {
ProfileView::show();
} else {
HomeView::show();
}
}
// $user = null;
// $userData = null;
// $users = UsersDB::getUsersBy('userId', $arguments);
// if (count($users) > 0) {
// $user = $users[0];
// $userDataArray = UserDataDB::getUserDataBy('userId', $user->getUserId());
// if (count($userDataArray) > 0)
// $userData = $userDataArray[0];
// }
// $_SESSION['user'] = $user;
// $_SESSION['userData'] = $userData;
// ProfileView::show();
break;
case "update":
break;
default:
}
}
示例8: updateReview
public static function updateReview()
{
// Process updating review
$reviews = ReviewsDB::getReviewsBy('reviewId', $_SESSION['arguments']);
if (empty($reviews)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['reviews'] = $reviews;
ReviewView::showUpdate();
} else {
$parms = $reviews[0]->getParameters();
$parms['score'] = array_key_exists('score', $_POST) ? $_POST['score'] : $reviews[0]->getScore();
$parms['review'] = array_key_exists('review', $_POST) ? $_POST['review'] : $reviews[0]->getReview();
$newReview = new Review($parms);
$newReview->setReviewId($reviews[0]->getReviewId());
$review = ReviewsDB::updateReview($newReview);
if ($review->getErrorCount() != 0) {
$_SESSION['reviews'] = array($newReview);
ReviewView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
示例9: run
public static function run()
{
$user = null;
$userIsLegit = false;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$user = new User($_POST);
if ($user->getErrorCount() == 0) {
$checkUserArray = UsersDB::getUsersBy('username', $user->getUserName());
if (count($checkUserArray) > 0) {
$checkUser = $checkUserArray[0];
$user->setUserId($checkUser->getUserId());
$userIsLegit = password_verify($_POST['password'], $checkUser->getPassword());
}
}
} else {
LoginView::show();
return;
}
if ($userIsLegit) {
$_SESSION['authenticatedUser'] = $user;
$_SESSION['authenticated'] = true;
HomeView::show();
} else {
$user->setError('username', 'USERNAME_PASSWORD_COMBO_INVALID');
$_SESSION['user'] = $user;
LoginView::show();
}
}
示例10: testShowHomeViewWithNullUser
public function testShowHomeViewWithNullUser()
{
ob_start();
$return = HomeView::show(null);
$output = ob_get_clean();
$this->assertFalse(empty($output), "It should show a Home view when passed a null user");
}
示例11: updateTournament
public static function updateTournament()
{
$tournaments = TournamentsDB::getTournamentsBy('tournamentID', $_SESSION['arguments']);
if (empty($tournaments)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['tournament'] = $tournaments[0];
TournamentView::showUpdate();
} else {
$parms = $tournaments[0]->getParameters();
$parms['name'] = array_key_exists('name', $_POST) ? $_POST['name'] : $tournaments[0]->getName();
$parms['startDate'] = array_key_exists('startDate', $_POST) ? $_POST['startDate'] : $tournaments[0]->getDate();
$parms['startTime'] = array_key_exists('startTime', $_POST) ? $_POST['startTime'] : $tournaments[0]->getTime();
$parms['numParticipants'] = array_key_exists('numParticipants', $_POST) ? $_POST['numParticipants'] : $tournaments[0]->getName();
$newTournament = new Tournament($parms);
$newTournament->setTournamentID($tournaments[0]->getTournamentID());
$tournament = TournamentsDB::updateTournament($newTournament);
if ($tournament->getErrorCount() != 0) {
$_SESSION['tournament'] = $newTournament;
TournamentView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
示例12: updateDataset
private function updateDataset()
{
$dataset = $_SESSION['dataset'];
if (empty($dataset)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
DatasetView::showUpdate();
} else {
$params = $dataset->getParameters();
$params['dataset_name'] = array_key_exists('dataset_name', $_POST) ? $_POST['dataset_name'] : '';
$params['description'] = array_key_exists('description', $_POST) ? $_POST['description'] : '';
$updatedDataset = new Dataset($params);
$updatedDataset->setDatasetId($dataset->getDatasetId());
$returnedDataset = DatasetsDB::updateDataset($updatedDataset);
if ($returnedDataset->getErrorCount() == 0) {
// Show the Dataset view which should display the updated params
DatasetView::show();
header('Location: /' . $_SESSION['base'] . '/dataset/show/' . $dataset->getDatasetId());
} else {
// Carry over the sensors, if any
$updatedDataset->setSensors($dataset->getSensors());
$_SESSION['dataset'] = $updatedDataset;
DatasetView::showUpdate();
}
}
}
示例13: testShowHomeViewWithNullUser
public function testShowHomeViewWithNullUser()
{
ob_start();
$_SESSION = array('user' => null, 'base' => 'mvcdbcrud');
$return = HomeView::show();
$output = ob_get_clean();
$this->assertFalse(empty($output), "It should show a Home view when passed a null user");
}
示例14: run
public static function run()
{
if (isset($_COOKIE["user"])) {
ProfileView::show();
} else {
HomeView::show();
}
}
示例15: run
public static function run()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
HomeView::show();
} else {
// Initial link
ReviewView::show();
}
}