Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
twitter-clone/www/application/views/home.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
106 lines (98 sloc)
3.64 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
error_reporting(0); | |
// shouldn't need the title and links below | |
?> | |
<!-- header used to be here --> | |
<div class="home container"> | |
<h1>My Feed</h1> | |
<?php $this->load->library('form_validation'); ?> | |
<form class="form" action="<?php echo base_url("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> | |
<!-- DISPLAY ERROR IF NO SEARCH RESULTS FOUND --> | |
<?php | |
if($results === []){ ?> | |
<div class="tweet-container"> | |
<div class="row"> | |
<div class="col-md-6"> | |
<?php echo "<h3>No tweets found</h3>"; ?> | |
</div> | |
</div> | |
<div class="row tweet"> | |
<div class="col-md-12"> | |
<?php echo "There are no tweets that match your query, please try another search.";?> | |
</div> | |
</div> | |
</div> | |
<?php }?> | |
<!-- OUTPUT SEARCH RESULTS --> | |
<?php foreach($results as $row){ ?> | |
<div class="tweet-container"> | |
<?php | |
if($row['username'] === "mona") echo "<img class=\"profile-icon\" alt=\"user\" src=" . base_url("img/mona.png") . ">"; | |
else if($row['username'] === "chris") echo "<img class=\"profile-icon\" alt=\"user\" src=" . base_url("img/chris.png") .">"; | |
else echo "<img class=\"profile-icon\" alt=\"user\" src=" . base_url("img/anon.png") .">"; | |
?> | |
<div class="tweet-data"> | |
<div class="row"> | |
<div class="col-md-6"> | |
<?php echo "<h3>" . $row['first_name'] . " " . $row['last_name'] . " " . "<span class=\"handle\">" . "@" . $row['username'] . "</span>" . "</h3>"; ?> | |
</div> | |
<div class="col-md-3 date"> | |
<?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"> | |
<div class="col-md-6"> | |
<?php echo "\"" . $row['tweet'] . "\"";?> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php } ?> | |
<!-- OUTPUT ALL TWEETS IF NOT ON SEARCH RESULT PAGE --> | |
<?php foreach($posts as $post){ ?> | |
<div class="tweet-container"> | |
<!-- LOAD USER ICON --> | |
<?php | |
if($post['username'] === "mona") echo "<img class=\"profile-icon\" alt=\"user\" src=" . base_url("img/mona.png") . ">"; | |
else if($post['username'] === "chris") echo "<img class=\"profile-icon\" alt=\"user\" src=" . base_url("img/chris.png") .">"; | |
else echo "<img class=\"profile-icon\" alt=\"user\" src=" . base_url("img/anon.png") .">"; | |
?> | |
<div class="tweet-data"> | |
<div class="row"> | |
<div class="col-md-6"> | |
<?php echo "<h3>" . $post['first_name'] . " " . $post['last_name'] . " " . "<span class=\"handle\">" . "@" . $post['username'] . "</span>" . "</h3>"; ?> | |
</div> | |
<div class="col-md-3 date"> | |
<?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"> | |
<div class="col-md-6"> | |
<?php echo "\"" . $post['tweet'] . "\"";?> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php }?> | |
</div> |