Skip to content

Commit

Permalink
Clearer concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
DHS committed Jun 24, 2012
1 parent fbe1666 commit 15e3f5e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion controllers/admin_controller.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function invite() {
} }


$to = $email; $to = $email;
$link = $this->config->url . 'users/add/' . $id . '/?email='.urlencode($email); $link = $this->config->url . 'users/add/' . $id . '/?email=' . urlencode($email);


// Load template into $body variable // Load template into $body variable
$to = array('email' => $email); $to = array('email' => $email);
Expand Down
2 changes: 1 addition & 1 deletion controllers/items_controller.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function remove($item_id) {
} }


// Set message // Set message
Application::flash('success', ucfirst($this->config->items['name']).' removed!'); Application::flash('success', ucfirst($this->config->items['name']) . ' removed!');


// Return from whence you came // Return from whence you came
header('Location: ' . $_SERVER['HTTP_REFERER']); header('Location: ' . $_SERVER['HTTP_REFERER']);
Expand Down
12 changes: 6 additions & 6 deletions controllers/pages_controller.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ function show($name) {
foreach ($this->config->admin_users as $value) { foreach ($this->config->admin_users as $value) {
$author = User::get_by_id($value); $author = User::get_by_id($value);
if ($this->config->private != TRUE || isset($_SESSION['user_id'])) { if ($this->config->private != TRUE || isset($_SESSION['user_id'])) {
$authors .= $this->get_link_to($author->username, 'users', 'show', $author->id).', '; $authors .= $this->get_link_to($author->username, 'users', 'show', $author->id) . ', ';
} else { } else {
$authors .= $author->username . ', '; $authors .= $author->username . ', ';
} }


} }
$authors = substr($authors, 0, -2); $authors = substr($authors, 0, -2);


$content = '<p>' . $this->config->name . ' is a web app created by ' . $authors.' based on the <a href="http://github.com/DHS/rat">rat</a> framework. '; $content = '<p>' . $this->config->name . ' is a web app created by ' . $authors . ' based on the <a href="http://github.com/DHS/rat">rat</a> framework. ';


if ($this->config->beta == TRUE) { if ($this->config->beta == TRUE) {
$content .= 'It is currently in beta.'; $content .= 'It is currently in beta.';
Expand All @@ -31,23 +31,23 @@ function show($name) {
$content .= '<p>It lets you create ' . $this->config->items['name_plural']; $content .= '<p>It lets you create ' . $this->config->items['name_plural'];


if ($this->config->items['titles']['enabled'] == TRUE) { if ($this->config->items['titles']['enabled'] == TRUE) {
$content .= ' with '.strtolower($this->config->items['titles']['name_plural']); $content .= ' with ' . strtolower($this->config->items['titles']['name_plural']);
} }


if ($this->config->items['comments']['enabled'] == TRUE || $this->config->items['likes']['enabled'] == TRUE) { if ($this->config->items['comments']['enabled'] == TRUE || $this->config->items['likes']['enabled'] == TRUE) {


$content .= ' and then '; $content .= ' and then ';


if ($this->config->items['comments']['enabled'] == TRUE) { if ($this->config->items['comments']['enabled'] == TRUE) {
$content .= ' add '.strtolower($this->config->items['comments']['name_plural']).' '; $content .= ' add ' . strtolower($this->config->items['comments']['name_plural']) . ' ';
} }


if ($this->config->items['comments']['enabled'] == TRUE && $this->config->items['likes']['enabled'] == TRUE) { if ($this->config->items['comments']['enabled'] == TRUE && $this->config->items['likes']['enabled'] == TRUE) {
$content .= ' and '; $content .= ' and ';
} }


if ($this->config->items['likes']['enabled'] == TRUE) { if ($this->config->items['likes']['enabled'] == TRUE) {
$content .= ' \''.strtolower($this->config->items['likes']['name']).'\' '; $content .= " '" . strtolower($this->config->items['likes']['name']) . "' ";
} }


$content .= 'them'; $content .= 'them';
Expand All @@ -73,7 +73,7 @@ function show($name) {
} }


if (isset($this->plugins->gravatar)) { if (isset($this->plugins->gravatar)) {
$content .= '<p>' . $this->config->name . ' is <a href="http://gravatar.com/">Gravatar</a>-enabled.</p>'."\n"; $content .= '<p>' . $this->config->name . ' is <a href="http://gravatar.com/">Gravatar</a>-enabled.</p>' . "\n";
} }


} }
Expand Down
2 changes: 1 addition & 1 deletion controllers/sessions_controller.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function add() {


} else { } else {


Application::flash('error', 'You are already logged in! ' . $this->get_link_to('Click here', 'sessions', 'remove').' to logout.'); Application::flash('error', 'You are already logged in! ' . $this->get_link_to('Click here', 'sessions', 'remove') . ' to logout.');
$this->loadView(); $this->loadView();


} }
Expand Down
8 changes: 4 additions & 4 deletions lib/application.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function initialise() {


$uri = Routing::fetch_uri($config); $uri = Routing::fetch_uri($config);


$controller = ucfirst($uri['controller']).'Controller'; $controller = ucfirst($uri['controller']) . 'Controller';
@include "controllers/{$uri['controller']}_controller.php"; @include "controllers/{$uri['controller']}_controller.php";


if (substr($uri['action'], 0, 1) == '?') { if (substr($uri['action'], 0, 1) == '?') {
Expand All @@ -43,7 +43,7 @@ public static function initialise() {


$uri = Routing::route(); $uri = Routing::route();


$controller = ucfirst($uri['controller']).'Controller'; $controller = ucfirst($uri['controller']) . 'Controller';
@include "controllers/{$uri['controller']}_controller.php"; @include "controllers/{$uri['controller']}_controller.php";


$app = new $controller; $app = new $controller;
Expand Down Expand Up @@ -286,11 +286,11 @@ public function url_for_route($route, array $params) {
} }


public function link_to($link_text, $controller, $action = '', $id = '', $params = array()) { public function link_to($link_text, $controller, $action = '', $id = '', $params = array()) {
echo '<a href="' . $this->url_for($controller, $action, $id, $params).'">' . $link_text.'</a>'; echo '<a href="' . $this->url_for($controller, $action, $id, $params) . '">' . $link_text . '</a>';
} }


public function get_link_to($link_text, $controller, $action = '', $id = '', $params = array()) { public function get_link_to($link_text, $controller, $action = '', $id = '', $params = array()) {
return '<a href="' . $this->url_for($controller, $action, $id, $params).'">' . $link_text.'</a>'; return '<a href="' . $this->url_for($controller, $action, $id, $params) . '">' . $link_text . '</a>';
} }


public function redirect_to($controller, $action = '', $id = '', $params = array()) { public function redirect_to($controller, $action = '', $id = '', $params = array()) {
Expand Down
2 changes: 1 addition & 1 deletion models/admin.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function list_users() {
if ($last_login == 0) { if ($last_login == 0) {
$last_login = 'Today!'; $last_login = 'Today!';
} else { } else {
$last_login = $last_login.' days ago'; $last_login = $last_login . ' days ago';
} }


} else { } else {
Expand Down
6 changes: 3 additions & 3 deletions plugins/gravatar.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ function show($email, $params = array()) {


// if style is set, add it in // if style is set, add it in
if (isset($params['style'])) { if (isset($params['style'])) {
$return .= ' style="' . $params['style'].'"'; $return .= ' style="' . $params['style'] . '"';
} }


$return .= ' />'; $return .= ' />';


// if user_id is set, make it a link // if user_id is set, make it a link
if (isset($params['link'])) { if (isset($params['link'])) {
$return = '<a href="' . $params['link'].'">' . $return.'</a>'; $return = '<a href="' . $params['link'] . '">' . $return . '</a>';
} }


return $return; return $return;
Expand All @@ -58,7 +58,7 @@ function show($email, $params = array()) {
function show_settings($email) { function show_settings($email) {


echo '<h2>Picture</h2> echo '<h2>Picture</h2>
' . $this->show($email).' ' . $this->show($email) . '
<p>Visit <a href="http://gravatar.com/">Gravatar.com</a> to change your picture.</p>'; <p>Visit <a href="http://gravatar.com/">Gravatar.com</a> to change your picture.</p>';


} }
Expand Down
2 changes: 1 addition & 1 deletion plugins/log.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function view() {
$return .= $entry['params']; $return .= $entry['params'];
} }


$return .= '</td><td>' . $entry['date'].'</td></tr>'; $return .= '</td><td>' . $entry['date'] . '</td></tr>';


} }


Expand Down
12 changes: 6 additions & 6 deletions plugins/points.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* To display users's points: * To display users's points:
* *
* if (isset($this->plugins->points)) { * if (isset($this->plugins->points)) {
* echo 'You have ' . $user->points.' ' . $this->plugins->points['name']; * echo 'You have ' . $user->points . ' ' . $this->plugins->points['name'];
* } * }
* *
*/ */
Expand Down Expand Up @@ -46,12 +46,12 @@ function update($user_id, $points) {
function view() { function view() {


if ($id == $_SESSION['user_id']) { if ($id == $_SESSION['user_id']) {
echo '<p>You have ' . $user['points'].' ' . $this->plugins->points['name'].'!</p>'; echo '<p>You have ' . $user['points'] . ' ' . $this->plugins->points['name'] . '!</p>';
if ($this->plugins->points['leaderboard'] == TRUE) { if ($this->plugins->points['leaderboard'] == TRUE) {
echo '<p class="small">Where do you rank on the <a href="leaderboard.php">leaderboard</a>?</p>'; echo '<p class="small">Where do you rank on the <a href="leaderboard.php">leaderboard</a>?</p>';
} }
} else { } else {
echo '<p>' . $user['username'].' has ' . $user['points'].' ' . $this->plugins->points['name'].'!</p>'; echo '<p>' . $user['username'] . ' has ' . $user['points'] . ' ' . $this->plugins->points['name'] . '!</p>';
if ($this->plugins->points['leaderboard'] == TRUE) { if ($this->plugins->points['leaderboard'] == TRUE) {
echo '<p class="small">See where they rank on the <a href="leaderboard.php">leaderboard</a>.</p>'; echo '<p class="small">See where they rank on the <a href="leaderboard.php">leaderboard</a>.</p>';
} }
Expand Down Expand Up @@ -79,9 +79,9 @@ function view_leaderboard($limit = 10) {
foreach ($this->page['leaderboard'] as $row) { foreach ($this->page['leaderboard'] as $row) {


echo '<tr> echo '<tr>
<td>' . $i.'.</td> <td>' . $i . '.</td>
<td><a href="/' . $row['username'].'">' . $row['username'].'</a></td> <td><a href="/' . $row['username'] . '">' . $row['username'] . '</a></td>
<td>' . $row['points'].'</td> <td>' . $row['points'] . '</td>
</tr>'; </tr>';


$i++; $i++;
Expand Down

0 comments on commit 15e3f5e

Please sign in to comment.