Skip to content

Commit

Permalink
user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Shemona Singh authored and Shemona Singh committed Dec 5, 2017
2 parents 680bbb1 + a024e26 commit 5061312
Show file tree
Hide file tree
Showing 16 changed files with 208 additions and 128 deletions.
2 changes: 1 addition & 1 deletion www/application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://twitter-clone.lndo.site/';
$config['base_url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/';

/*
|--------------------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions www/application/controllers/All_Tweets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ function __Construct(){
parent::__Construct ();
$this->load->database(); // load database
$this->load->model('All_Tweets_Model'); // load model
$this->output->enable_profiler(TRUE);
//$this->output->enable_profiler(TRUE);
}

public function index() {
$this->data['posts'] = $this->All_Tweets_Model->getPosts(); // calling Post model method getPosts()

$this->load->view('templates/header', NULL);
$this->load->view('templates/nav', NULL);
$this->load->view('home', $this->data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer', NULL);
}
Expand All @@ -22,9 +23,10 @@ function search_keyword(){
$keyword = $this->input->post('keyword');
$data['results'] = $this->All_Tweets_Model->search($keyword);

$this->load->view('templates/header');
$this->load->view('templates/header', NULL);
$this->load->view('templates/nav', NULL);
$this->load->view('home', $data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer');
$this->load->view('templates/footer', NULL);
}

}
11 changes: 9 additions & 2 deletions www/application/controllers/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ public function index(){

$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('', '');

$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');

if ($this->form_validation->run() == FALSE)
if ($this->form_validation->run() == FALSE){
$this->load->view('templates/header');
$this->load->view('login');
}


// load the homepage if login successful
// https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods
Expand All @@ -35,7 +39,10 @@ public function index(){
redirect('/User_Tweets');
}
// if no, refresh login
else $this->load->view('login', $data);
else {
$this->load->view('templates/header');
$this->load->view('login', $data);
}

}
}
Expand Down
8 changes: 5 additions & 3 deletions www/application/controllers/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function __Construct(){
parent::__Construct();
$this->load->database(); // load database
$this->load->model('User_Info_Model'); // load model
$this->output->enable_profiler(TRUE);
//$this->output->enable_profiler(TRUE);
}

public function index(){
Expand All @@ -22,8 +22,10 @@ public function index(){
array('required' => 'You must provide a %s.'));
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');

if ($this->form_validation->run() == FALSE)
$this->load->view('register');
if ($this->form_validation->run() == FALSE){
$this->load->view('templates/header');
$this->load->view('register');
}

// load the homepage once properly submitted
// https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods
Expand Down
29 changes: 0 additions & 29 deletions www/application/controllers/Tweet.php

This file was deleted.

5 changes: 4 additions & 1 deletion www/application/controllers/User_Tweets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ function __Construct(){
parent::__Construct();
$this->load->database(); // load database
$this->load->model('User_Tweets_Model'); // load model
$this->output->enable_profiler(TRUE);
//$this->output->enable_profiler(TRUE);
}

public function index() {
// get posts based on user ID
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts()
$this->load->view('templates/header', NULL);
$this->load->view('templates/nav', NULL);
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer', NULL);
}
Expand All @@ -26,6 +28,7 @@ public function create(){
{
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts()
$this->load->view('templates/header', NULL);
$this->load->view('templates/nav');
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer', NULL);
}
Expand Down
36 changes: 26 additions & 10 deletions www/application/views/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,30 @@
<h1>All Tweets</h1>
<?php echo $id; ?>
<?php $this->load->library('form_validation'); ?>
<?php echo validation_errors(); ?>
<?php echo form_open('all_tweets/search_keyword'); ?>
<input type="text" name = "keyword" />
<input type="submit" value = "Search" />
<form class="form" action="/index.php/all_tweets/search_keyword" method="post">
<div class="form-group">
<input type="text" name="keyword" class="form-control" placeholder="What would you like to find?">
</div>
<button class="btn btn-primary" type="submit" value="Search">Search</button>
</form>

<?php foreach($results as $row){ ?>
<div class="tweet-container">
<div class="row">
<div class="col-md-6">
<?php echo "<h3>" . $row['first_name'] . " " . $row['last_name'] . "</h3>"; ?>
<?php echo "<h4>" . "@" . $row['username'] . "</h4>";?>
<?php echo "<h3>" . $row['first_name'] . " " . $row['last_name'] . " " . "<span class=\"handle\">" . "@" . $row['username'] . "</span>" . "</h3>"; ?>

</div>
<div class="col-md-3 date">
<?php echo $row['date_time'];?>
<?php
$startDate = $row['date_time'];
$start = new DateTime($startDate);
$timestring = $start->format('m/d/y h:s A');
$time_arr = str_split($timestring);
if($time_arr[count($time_arr) - 8] === '0')
unset($time_arr[count($time_arr) - 8]);
echo implode("",$time_arr);
?>
</div>
</div>
<div class="row tweet italic">
Expand All @@ -42,11 +51,18 @@
<div class="tweet-container">
<div class="row">
<div class="col-md-6">
<?php echo "<h3>" . $post['first_name'] . " " . $post['last_name'] . "</h3>"; ?>
<?php echo "<h4>" . "@" . $post['username'] . "</h4>";?>
<?php echo "<h3>" . $post['first_name'] . " " . $post['last_name'] . " " . "<span class=\"handle\">" . "@" . $post['username'] . "</span>" . "</h3>"; ?>
</div>
<div class="col-md-3 date">
<?php echo $post['date_time'];?>
<?php
$startDate = $post['date_time'];
$start = new DateTime($startDate);
$timestring = $start->format('m/d/y h:s A');
$time_arr = str_split($timestring);
if($time_arr[count($time_arr) - 8] === '0')
unset($time_arr[count($time_arr) - 8]);
echo implode("",$time_arr);
?>
</div>
</div>
<div class="row tweet italic">
Expand Down
35 changes: 23 additions & 12 deletions www/application/views/login.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
<?php
$this->load->library('form_validation');
<<<<<<< HEAD
echo validation_errors();
echo form_open('login'); ?>
<?php
var_dump($username); //var_dump($sesh);
=======
echo form_open('login');
>>>>>>> a024e265e94e8addb4b7953ae90dbdb94e25e7af
?>
<div class="login container">
<img class="icon" src="../img/twitter.png" alt="Twitter">
<div class="form-group">
<label for="username">Username</label>
<input class="form-control" type="text" name="username" value="<?php echo set_value('username'); ?>" placeholder="Enter username"/>
<?php echo form_error('username'); ?>
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" type="password" name="password" value="<?php echo set_value('password'); ?>" placeholder="Enter password"/>
<?php echo form_error('password'); ?>
</div>
<button type="submit" class="btn btn-primary">Login</button><span> or <a href="register">Create an account</a></span>

<h1>Twitter</h1>
<!--<img src="../img/twitter.png" alt="Twitter icon.">-->
<h5>Username</h5>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<?php echo form_error('username'); ?>
</form>

<h5>Password</h5>
<input type="password" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<?php echo form_error('password'); ?>

<br><br>
<div><input type="submit" value="Submit"/></div>
</form>
</div>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</body>
</html>
69 changes: 40 additions & 29 deletions www/application/views/register.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
<?php
$this->load->library('form_validation');
echo validation_errors();
echo form_open('register'); ?>
<h1>Register</h1>
<h5>First Name</h5>
<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" size="50" />
<?php echo form_error('firstname'); ?>

<h5>Last Name</h5>
<input type="text" name="lastname" value="<?php echo set_value('lastname'); ?>" size="50" />
<?php echo form_error('lastname'); ?>

<h5>Email Address</h5>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
<?php echo form_error('email'); ?>

<h5>Location</h5>
<input type="text" name="location" value="<?php echo set_value('location'); ?>" size="50" />
<?php echo form_error('location'); ?>

<h5>Username</h5>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<?php echo form_error('username'); ?>

<h5>Password</h5>
<input type="password" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<?php echo form_error('password'); ?>

<br><br>
<div><input type="submit" value="Submit"/></div>

<div class="login register container">
<img class="icon reg" src="../img/twitter.png" alt="Twitter">
<h1>Register</h1>
<div class="form-group">
<label for="firstname">First Name</label>
<input class="form-control" type="text" name="firstname" value="<?php echo set_value('firstname'); ?>"/>
<?php echo form_error('firstname'); ?>
</div>
<div class="form-group">
<label for="lastname">Last Name</label>
<input class="form-control" type="text" name="lastname" value="<?php echo set_value('lastname'); ?>"/>
<?php echo form_error('lastname'); ?>
</div>
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" type="email" name="email" value="<?php echo set_value('email'); ?>"/>
<?php echo form_error('email'); ?>
</div>
<div class="form-group">
<label for="location">Location</label>
<input class="form-control" type="text" name="location" value="<?php echo set_value('location'); ?>"/>
<?php echo form_error('location'); ?>
</div>
<div class="form-group">
<label for="username">Username</label>
<input class="form-control" type="text" name="username" value="<?php echo set_value('username'); ?>"/>
<?php echo form_error('username'); ?>
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" type="password" name="password" value="<?php echo set_value('password'); ?>"/>
<?php echo form_error('password'); ?>
</div>
<button type="submit" class="btn btn-primary">Sign Up</button>
</form>
</div>

<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</body>
</html>
4 changes: 3 additions & 1 deletion www/application/views/templates/footer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<em>&copy; 2017 Singh and Stumper Studios</em>
<br><br>
<em class="footer">&copy; 2017 Stingh Design</em>
<br><br>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</body>
Expand Down
2 changes: 2 additions & 0 deletions www/application/views/templates/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/styles.css">
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet">
</head>
<body>
12 changes: 12 additions & 0 deletions www/application/views/templates/nav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="/index.php/all_tweets">
<img class="home-icon" alt="Brand" src="../../img/twitter.png">
</a>
</div>
<ul class="nav navbar-nav">
<li><a href="/index.php/all_tweets">Home</a></li>
<li><a href="/index.php/user_tweets">Profile</a></li>
</div>
</nav>
9 changes: 0 additions & 9 deletions www/application/views/tweet.php

This file was deleted.

Loading

0 comments on commit 5061312

Please sign in to comment.