Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

various coding standard issues resolved thanks to lithium_qa

  • Loading branch information...
commit e7aa1199981ef2b64cab4c34d674ab06569558cf 1 parent 1708d37
@pointlessjon authored
View
1  config/bootstrap/action.php
@@ -18,7 +18,6 @@
*/
use lithium\core\Libraries;
-use lithium\net\http\Router;
use lithium\core\Environment;
use lithium\action\Dispatcher;
View
6 config/bootstrap/connections.php
@@ -6,18 +6,18 @@
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
-use \lithium\data\Connections;
+use lithium\data\Connections;
Connections::add('default', array(
'adapter' => 'MongoDb',
'host' => 'localhost',
- 'database' => 'lithosphere',
+ 'database' => 'lithosphere'
));
Connections::add('test', array(
'adapter' => 'MongoDb',
'host' => 'localhost',
- 'database' => 'lithosphere_test',
+ 'database' => 'lithosphere_test'
));
?>
View
6 config/routes.php
@@ -6,8 +6,8 @@
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
-use \lithium\net\http\Router;
-use \lithium\core\Environment;
+use lithium\net\http\Router;
+use lithium\core\Environment;
/**
* Uncomment the line below to enable routing for admin actions.
@@ -144,4 +144,4 @@
// Router::connect('/{:controller}/{:action}/{:_id:[0-9]+}');
Router::connect('/{:controller}/{:action}/{:args}');
-?>
+?>
View
5 controllers/PostsController.php
@@ -2,9 +2,8 @@
namespace app\controllers;
-use \app\models\Post;
-use \lithium\util\Set;
-use \lithium\storage\Session;
+use app\models\Post;
+use lithium\storage\Session;
class PostsController extends \lithium\action\Controller {
View
11 controllers/SearchController.php
@@ -2,9 +2,7 @@
namespace app\controllers;
-use \app\models\Post;
-use \lithium\util\Set;
-use \lithium\storage\Session;
+use app\models\Post;
class SearchController extends \lithium\action\Controller {
@@ -63,7 +61,7 @@ public function filter() {
'order' => array(
'rating' => -1,
'created' => -1
- ),
+ )
);
extract($this->request->params + $defaults);
@@ -182,12 +180,13 @@ protected function _queryToConditions($query) {
'$or' => array(
array('tags' => $query),
array('_title' => $query),
- array('user_id' => $query),
+ array('user_id' => $query)
)
);
}
}
return $conditions;
}
-
}
+
+?>
View
3  extensions/helper/Gravatar.php
@@ -25,7 +25,7 @@ class Gravatar extends \lithium\template\Helper {
/**
* Generate a gravatar image url
*
- * @param array options
+ * @param array $options
* @return string
*/
public function url($options = array()) {
@@ -53,7 +53,6 @@ public function url($options = array()) {
return $this->_base . md5($email) . '?' . http_build_query($params) . $ext;
}
-
}
?>
View
1  extensions/helper/Oembed.php
@@ -35,7 +35,6 @@ public function classify($string = null, $options = array()) {
);
return $string;
}
-
}
?>
View
49 extensions/helper/Post.php
@@ -2,8 +2,8 @@
namespace app\extensions\helper;
-use \lithium\net\http\Router;
-use \lithium\util\String;
+use lithium\net\http\Router;
+use lithium\util\String;
/**
* This helper provides tools to uniformly render posts across views.
@@ -15,7 +15,7 @@ public function rows($posts = null, $options = array()) {
return null;
}
$defaults = array(
- 'class' => 'posts',
+ 'class' => 'posts'
);
$options += $defaults;
extract($options);
@@ -35,15 +35,9 @@ public function row($post, $options = array()) {
$html = $this->_context->helper('html');
$gravatar = $this->_context->helper('gravatar');
- $ratingClass = ($post->rating == 0 ? ' empty' : null);
- $rating = '<span class="post-rating' . $ratingClass .'">' .
- '<span>' . $post->rating . '</span>' .
- '</span>';
-
- // $image = $html->image($gravatar->url($post->user()->email), array('class' => 'gravatar'));
- // $image = $html->link($image, array(
- // 'controller' => 'posts', 'action' => 'comment', '_id' => $post->_id
- // ), array('escape' => false));
+ $class = ($post->rating == 0 ? ' empty' : null);
+ $rating = '<span>' . $post->rating . '</span>';
+ $rating = '<span class="post-rating' . $class . '">' . $rating . '</span>';
$category = null;
if (!empty($post->tags)) {
@@ -56,9 +50,13 @@ public function row($post, $options = array()) {
}
}
- $heading = '<h2 class="'.$category.'">' . $html->link($post->title, array(
- 'controller' => 'posts', 'action' => 'comment', '_id' => $post->_id
- )) . '</h2>';
+ $heading = $html->link(
+ $post->title,
+ array(
+ 'controller' => 'posts', 'action' => 'comment', '_id' => $post->_id
+ )
+ );
+ $heading = '<h2 class="' . $category . '">' . $heading . '</h2>';
$author = $html->link($post->user()->_id, array(
'controller' => 'search',
@@ -74,21 +72,23 @@ public function row($post, $options = array()) {
$timestamp = $post->created->sec;
$date = $date = date("F j, Y, g:i a T", $timestamp);
- $time = "<span class=\"post-created pretty-date\" title=\"{$date}\">{$date}" .
- "<span class=\"timestamp\">{$timestamp}</span></span>";
+ $time = "<span class=\"post-created pretty-date\" title=\"{$date}\">{$date}";
+ $time .= "<span class=\"timestamp\">{$timestamp}</span></span>";
$count = (empty($post->comment_count) ? 0 : $post->comment_count);
- $commentsClass = ($count > 0) ? (($count > 1) ? 'many' : 'one') : 'none';
- $commentsText = (($count < 1) ? 'no' : $count)
- . ' comment' . (($count !== 1) ? 's' : '');
- $comments = $html->link($commentsText,
+ $class = ($count > 0) ? (($count > 1) ? 'many' : 'one') : 'none';
+ $text = (($count < 1) ? 'no' : $count);
+ $text .= ' comment' . (($count !== 1) ? 's' : '');
+ $comments = $html->link(
+ $text,
array(
- 'controller' => 'posts', 'action' => 'comment', '_id' => $post->_id,
+ 'controller' => 'posts', 'action' => 'comment', '_id' => $post->_id
),
- array('class' => 'comments ' . $commentsClass)
+ array('class' => 'comments ' . $class)
);
- $meta = "<div class=\"meta\">".implode('', compact('comments','author','time'))."</div>";
+ $meta = implode('', compact('comments','author','time'));
+ $meta = "<div class=\"meta\">{$meta}</div>";
$content = implode('', compact('heading','meta'));
@@ -99,6 +99,7 @@ public function row($post, $options = array()) {
* Generate a link to tags
*
* @param string $tag
+ * @param array $options
* @return string
*/
public function tag($tag, $options = array()) {
View
15 extensions/helper/Search.php
@@ -22,7 +22,9 @@ public function pagination($results, $options = array()) {
$last = ($limit * $page > $count) ? $count : $limit * $page;
$pages = ceil($count / $limit);
- $out .= "<div class=\"total\">displaying {$current}-{$last} of {$count} result(s)</div>";
+ $out .= "<div class=\"total\">"
+ . "displaying {$current}-{$last} of {$count} result(s)"
+ . "</div>";
if (empty($url)) {
$url = array('controller' => 'search', 'action' => 'index', 'q' => $results->q);
@@ -31,9 +33,11 @@ public function pagination($results, $options = array()) {
if ($pages > 1) {
$links = array();
if ($pages > 5) {
- $links[] = $html->link('first', array('page' => 1) + $url, array('class' => 'first'));
+ $links[] = $html->link(
+ 'first', array('page' => 1) + $url, array('class' => 'first')
+ );
}
- for ($page=1;$page<=$pages;$page++) {
+ for ($page = 1; $page <= $pages; $page++) {
$class = 'page';
if ($page == $current_page) {
$class .= " active";
@@ -42,7 +46,9 @@ public function pagination($results, $options = array()) {
}
if ($pages > 5) {
- $links[] = $html->link('last', array('page' => $pages) + $url, array('class' => 'last'));
+ $links[] = $html->link(
+ 'last', array('page' => $pages) + $url, array('class' => 'last')
+ );
}
$out .= '<div class="pages">' . implode($links, " \n") . '</div>';
}
@@ -50,7 +56,6 @@ public function pagination($results, $options = array()) {
$out .= '</div>';
return $out;
}
-
}
?>
View
7 extensions/helper/Sphere.php
@@ -2,12 +2,14 @@
namespace app\extensions\helper;
-use \lithium\util\String;
-
class Sphere extends \lithium\template\Helper {
/**
* A convenience method to output common site links
+ *
+ * @param mixed $text
+ * @param array $data
+ * @param array $options
*/
public function link($text, $data = array(), $options = array()) {
$defaults = array(
@@ -27,7 +29,6 @@ public function link($text, $data = array(), $options = array()) {
$html = $this->_context->helper('html');
return $html->link($text, $link, $options);
}
-
}
?>
View
70 extensions/helper/Thread.php
@@ -2,9 +2,9 @@
namespace app\extensions\helper;
-use \lithium\storage\Session;
-use \lithium\net\http\Router;
-use \markdown\Markdown;
+use lithium\storage\Session;
+use lithium\net\http\Router;
+use markdown\Markdown;
class Thread extends \lithium\template\Helper {
@@ -93,16 +93,21 @@ public function comments($data, $options = array(), $parent = array()) {
'escape' => false
)
);
+
if (!empty($user)) {
- if (
- ($comment['user']['_id'] == $user['_id']) ||
- (!empty($comment['endorsements']) && in_array($user['_id'], $comment['endorsements']))
- ) {
+ $author = $comment['user']['_id'] == $user['_id'];
+ $endorsed = !empty($comment['endorsements'])
+ && in_array($user['_id'], $comment['endorsements']);
+
+ if ($author || $endorsed) {
$endorsement = null;
}
}
- $comment['content'] = $oembed->classify($html->escape($comment['content']), array('markdown' => true));
+ $comment['content'] = $oembed->classify(
+ $html->escape($comment['content']), array('markdown' => true)
+ );
+
$comment['content'] = Markdown::parse($comment['content']);
$replies = null;
@@ -120,19 +125,20 @@ public function comments($data, $options = array(), $parent = array()) {
$timestamp = $comment['created'];
$date = date("F j, Y, g:i a T", $timestamp);
- $time = "<span class=\"post-comment-created pretty-date\" title=\"{$date}\">{$date}" .
- "<span class=\"timestamp\">{$timestamp}</span></span>";
+ $time = "<span class=\"post-comment-created pretty-date\" title=\"{$date}\">";
+ $time .= "{$date}<span class=\"timestamp\">{$timestamp}</span></span>";
$size = $this->threadedIconSize(count($args));
- $style = 'style="padding:' . $size . 'px 0 0 0; width:' . $size . 'px; background-image:url('.$gravatar->url(array(
+ $avatar = $gravatar->url(array(
'email' => $comment['user']['email'], 'params' => compact('size')
- )).');"';
- $author = "<span $style title=" . $html->escape($comment['user']['_id']) . "></span>";
+ ));
+ $style = 'style="padding:' . $size . 'px 0 0 0; width:' . $size . 'px; ';
+ $style .= 'background-image:url(' . $avatar . ');"';
+ $author = "<span {$style} title=" . $html->escape($comment['user']['_id']) . "></span>";
- $ratingClass = ($comment['rating'] == 0 ? ' empty' : null);
- $rating = '<span class="post-comment-rating' . $ratingClass .'">' .
- $comment['rating'] .
- '</span>';
+ $class = ($comment['rating'] == 0 ? ' empty' : null);
+ $rating = '<span class="post-comment-rating' . $class . '">';
+ $rating .= $comment['rating'] . '</span>';
if ($comment['rating']) {
$rating = "<div class=\"meta aside\"><aside>{$rating}<aside></div>";
@@ -140,18 +146,25 @@ public function comments($data, $options = array(), $parent = array()) {
$rating = null;
}
- $row = "{$rating} {$reply} {$endorsement}" .
- "<div class=\"post-comment-author-icon\">{$author} </div>" .
- "<div class=\"post-comment-author-content\" ><div class=\"post-comment-author\">" .
- $html->link($comment['user']['_id'], array('controller' => 'search', 'action' => 'filter', '_id' => $comment['user']['_id']), array('title' => 'Search for more posts by this author')) .
- " {$time}</div>" .
- "<div class=\"post-comment-content\">{$comment['content']}</div></div> {$replies}";
-
- // if (isset($options['args']) && $options['args'] == $args) {
- // $next = (!empty($comment->comments) ? count($comment->comments) : 0);
- // $row .= $this->form(array_merge($args, array($next)));
- // }
+ $row = "{$rating} {$reply} {$endorsement}" ;
+ $row .= "<div class=\"post-comment-author-icon\">{$author} </div>";
+ $row .= "<div class=\"post-comment-author-content\">";
+ $row .= "<div class=\"post-comment-author\">";
+ $row .= $html->link(
+ $comment['user']['_id'],
+ array(
+ 'controller' => 'search',
+ 'action' => 'filter',
+ '_id' => $comment['user']['_id']
+ ), array(
+ 'title' => 'Search for more posts by this author'
+ )
+ );
+ $row .= " {$time}</div>";
+ $row .= "<div class=\"post-comment-content\">{$comment['content']}</div>";
+ $row .= "</div> {$replies}";
$row .= $this->comments($comment, $options, $args);
+
$_id = implode('-', $args);
$parts[] = "<li class=\"comment\" id=\"comment-{$_id}\">{$row}</li>";
}
@@ -170,4 +183,5 @@ protected function threadedIconSize($factor) {
return ($result > 16) ? $result : 16;
}
}
+
?>
View
4 libraries/li3_users/config/bootstrap/connections.php
@@ -6,12 +6,12 @@
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
-use \lithium\data\Connections;
+use lithium\data\Connections;
Connections::add('li3_users', array(
'adapter' => 'MongoDb',
'host' => 'localhost',
- 'database' => 'li3_users',
+ 'database' => 'li3_users'
));
?>
View
12 libraries/li3_users/controllers/UsersController.php
@@ -8,9 +8,9 @@
namespace li3_users\controllers;
-use \li3_users\models\User;
-use \lithium\security\Auth;
-use \lithium\storage\Session;
+use li3_users\models\User;
+use lithium\security\Auth;
+use lithium\storage\Session;
class UsersController extends \lithium\action\Controller {
@@ -30,11 +30,11 @@ public function login() {
$return = $this->request->params['return'];
}
$errors = $disabled = false;
- $attempts = (int) Session::read('attempts');
+ $attempts = (integer) Session::read('attempts');
if (!empty($this->request->data)) {
$attempts++;
}
- switch(true) {
+ switch (true) {
case $attempts == $this->_cooldown:
$attempts = strtotime('+10 minutes');
case $attempts > $this->_cooldown && $attempts > time():
@@ -48,7 +48,7 @@ public function login() {
if (!empty($user)) {
$attempts = 0;
if (!empty($return)) {
- Session:write('attempts', $attempts);
+ Session::write('attempts', $attempts);
return $this->redirect(base64_decode($return));
}
} else {
View
6 libraries/li3_users/models/User.php
@@ -8,14 +8,14 @@
namespace li3_users\models;
-use \lithium\util\String;
-use \lithium\util\Validator;
+use lithium\util\String;
+use lithium\util\Validator;
Validator::add('uniqueUserValue', function ($value, $format, $options) {
$conditions = array();
if (!empty($value)) {
$conditions[$options['field']] = $value;
- return !(bool) User::find('count', compact('conditions'));
+ return !(boolean) User::find('count', compact('conditions'));
}
return false;
});
View
3  libraries/li3_users/tests/cases/extensions/helper/UserTest.php
@@ -8,7 +8,7 @@
namespace li3_users\tests\cases\extensions\helper;
-use li3_users\extensions\helper\User;
+//use li3_users\extensions\helper\User;
class UserTest extends \lithium\test\Unit {
@@ -19,7 +19,6 @@ public function setUp() {
public function tearDown() {
//
}
-
}
?>
View
5 libraries/li3_users/tests/cases/models/UserTest.php
@@ -8,8 +8,8 @@
namespace li3_users\tests\cases\models;
-use \lithium\data\Connections;
-use \lithium\data\model\Query;
+use lithium\data\Connections;
+use lithium\data\model\Query;
define('LI3_USERS_TEST', 'li3_users_test');
@@ -61,7 +61,6 @@ public function tearDown() {
public function testClassInstanceAndConnection() {
$user = new User();
}
-
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.