Permalink
Browse files

various coding standard issues resolved thanks to lithium_qa

  • Loading branch information...
1 parent 1708d37 commit e7aa1199981ef2b64cab4c34d674ab06569558cf @daetal-us committed Aug 12, 2011
@@ -18,7 +18,6 @@
*/
use lithium\core\Libraries;
-use lithium\net\http\Router;
use lithium\core\Environment;
use lithium\action\Dispatcher;
@@ -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,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}');
-?>
+?>
@@ -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 {
@@ -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;
}
-
}
+
+?>
@@ -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;
}
-
}
?>
@@ -35,7 +35,6 @@ public function classify($string = null, $options = array()) {
);
return $string;
}
-
}
?>
View
@@ -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()) {
@@ -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,15 +46,16 @@ 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>';
}
}
$out .= '</div>';
return $out;
}
-
}
?>
@@ -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);
}
-
}
?>
Oops, something went wrong.

0 comments on commit e7aa119

Please sign in to comment.