Skip to content

Commit 1e7bf70

Browse files
committed
Normalized spaces before/after parenthesis and other symbols.
1 parent e65de49 commit 1e7bf70

19 files changed

+168
-159
lines changed

CommentingPlugin.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public function hookInitialize()
7171
public function setUp()
7272
{
7373

74-
if(plugin_is_active('SimplePages')) {
74+
if (plugin_is_active('SimplePages')) {
7575
$this->_filters[] = 'api_extend_simple_pages';
7676
}
77-
if(plugin_is_active('ExhibitBuilder')) {
77+
if (plugin_is_active('ExhibitBuilder')) {
7878
$this->_filters[] = 'api_extend_exhibit_pages';
7979
}
8080
parent::setUp();
@@ -130,32 +130,32 @@ public function hookUpgrade($args)
130130
$old = $args['old_version'];
131131
$new = $args['new_version'];
132132

133-
if(version_compare($old, '1.0', '<')) {
134-
if(!get_option('commenting_comment_roles')) {
133+
if (version_compare($old, '1.0', '<')) {
134+
if (!get_option('commenting_comment_roles')) {
135135
$commentRoles = array('super');
136136
set_option('commenting_comment_roles', serialize($commentRoles));
137137
}
138138

139-
if(!get_option('commenting_moderate_roles')) {
139+
if (!get_option('commenting_moderate_roles')) {
140140
$moderateRoles = array('super');
141141
set_option('commenting_moderate_roles', serialize($moderateRoles));
142142
}
143143

144-
if(!get_option('commenting_noapp_comment_roles')) {
144+
if (!get_option('commenting_noapp_comment_roles')) {
145145
set_option('commenting_noapp_comment_roles', serialize(array()));
146146
}
147147

148-
if(!get_option('commenting_view_roles')) {
148+
if (!get_option('commenting_view_roles')) {
149149
set_option('commenting_view_roles', serialize(array()));
150150
}
151151
}
152152

153-
if(version_compare($old, '2.0', '<')) {
153+
if (version_compare($old, '2.0', '<')) {
154154
$sql = "ALTER TABLE `$db->Comment` ADD `flagged` BOOLEAN NOT NULL DEFAULT '0' AFTER `approved` ";
155155
$db->query($sql);
156156
}
157157

158-
if(version_compare($old, '2.1', '<')) {
158+
if (version_compare($old, '2.1', '<')) {
159159
delete_option('commenting_noapp_comment_roles');
160160
set_option('commenting_reqapp_comment_roles', serialize(array()));
161161
$sql = "ALTER TABLE `$db->Comment` CHANGE `flagged` `flagged` TINYINT( 1 ) NOT NULL DEFAULT '0'";
@@ -197,8 +197,8 @@ public function hookAfterDeleteRecord($args)
197197
{
198198
$record = $args['record'];
199199
$type = get_class($record);
200-
$comments = get_db()->getTable('Comment')->findBy(array('record_type'=>$type, 'record_id'=>$record->id));
201-
foreach($comments as $comment) {
200+
$comments = get_db()->getTable('Comment')->findBy(array('record_type' => $type, 'record_id' => $record->id));
201+
foreach ($comments as $comment) {
202202
$comment->delete();
203203
}
204204
}
@@ -210,7 +210,7 @@ public static function showComments($args = array())
210210
{
211211
$view = isset($args['view']) ? $args['view'] : get_view();
212212
echo "<div id='comments-container'>";
213-
if( (get_option('commenting_allow_public') == 1)
213+
if ((get_option('commenting_allow_public') == 1)
214214
|| (get_option('commenting_allow_public_view') == 1)
215215
|| is_allowed('Commenting_Comment', 'show')
216216
) {
@@ -226,8 +226,8 @@ public static function showComments($args = array())
226226
));
227227
}
228228

229-
if( (get_option('commenting_allow_public') == 1)
230-
|| is_allowed('Commenting_Comment', 'add') ) {
229+
if ((get_option('commenting_allow_public') == 1)
230+
|| is_allowed('Commenting_Comment', 'add')) {
231231
echo "<div id='comment-main-container'>";
232232
echo $view->getCommentForm();
233233
echo "</div>";
@@ -278,22 +278,22 @@ public function hookDefineAcl($args)
278278
$moderateRoles = unserialize(get_option('commenting_moderate_roles'));
279279
$viewRoles = unserialize(get_option('commenting_view_roles'));
280280
$acl->allow(null, 'Commenting_Comment', array('flag'));
281-
if($viewRoles !== false) {
282-
foreach($viewRoles as $role) {
281+
if ($viewRoles !== false) {
282+
foreach ($viewRoles as $role) {
283283
//check that all the roles exist, in case a plugin-added role has been removed (e.g. GuestUser)
284-
if($acl->hasRole($role)) {
284+
if ($acl->hasRole($role)) {
285285
$acl->allow($role, 'Commenting_Comment', 'show');
286286
}
287287
}
288288

289-
foreach($commentRoles as $role) {
290-
if($acl->hasRole($role)) {
289+
foreach ($commentRoles as $role) {
290+
if ($acl->hasRole($role)) {
291291
$acl->allow($role, 'Commenting_Comment', 'add');
292292
}
293293
}
294294

295-
foreach($moderateRoles as $role) {
296-
if($acl->hasRole($role)) {
295+
foreach ($moderateRoles as $role) {
296+
if ($acl->hasRole($role)) {
297297
$acl->allow($role, 'Commenting_Comment', array(
298298
'update-approved',
299299
'update-spam',
@@ -305,16 +305,16 @@ public function hookDefineAcl($args)
305305
}
306306
}
307307

308-
if(get_option('commenting_allow_public')) {
308+
if (get_option('commenting_allow_public')) {
309309
$acl->allow(null, 'Commenting_Comment', array('show', 'add'));
310310
}
311311
}
312312
}
313313

314314
public function filterAdminNavigationMain($tabs)
315315
{
316-
if(is_allowed('Commenting_Comment', 'update-approved') ) {
317-
$tabs[] = array('uri'=> url('commenting/comment/browse'), 'label'=>__('Comments') );
316+
if (is_allowed('Commenting_Comment', 'update-approved')) {
317+
$tabs[] = array('uri' => url('commenting/comment/browse'), 'label' => __('Comments'));
318318
}
319319

320320
return $tabs;

controllers/CommentController.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public function init()
1414

1515
public function browseAction()
1616
{
17-
if(!$this->_hasParam('sort_field')) {
17+
if (!$this->_hasParam('sort_field')) {
1818
$this->_setParam('sort_field', 'added');
1919
}
2020

21-
if(!$this->_hasParam('sort_dir')) {
21+
if (!$this->_hasParam('sort_dir')) {
2222
$this->_setParam('sort_dir', 'd');
2323
}
2424
parent::browseAction();
@@ -27,11 +27,11 @@ public function browseAction()
2727
public function batchDeleteAction()
2828
{
2929
$ids = $_POST['ids'];
30-
foreach($ids as $id) {
30+
foreach ($ids as $id) {
3131
$record = $this->_helper->db->findById($id);
3232
$record->delete();
3333
}
34-
$response = array('status'=>'ok');
34+
$response = array('status' => 'ok');
3535
$this->_helper->json($response);
3636
}
3737

@@ -41,19 +41,19 @@ public function addAction()
4141
$module = isset($_POST['module']) ? Inflector::camelize($_POST['module']) : '';
4242
$destArray = array(
4343
'module' => $module,
44-
'controller'=> strtolower(Inflector::pluralize($_POST['record_type'])),
44+
'controller' => strtolower(Inflector::pluralize($_POST['record_type'])),
4545
'action' => 'show',
4646
'id' => $_POST['record_id']
4747
);
4848

4949
$comment = new Comment();
50-
if($user = current_user()) {
50+
if ($user = current_user()) {
5151
$comment->user_id = $user->id;
5252
}
5353
$comment->flagged = 0;
5454
$form = $this->_getForm();
5555
$valid = $form->isValid($this->getRequest()->getPost());
56-
if(!$valid) {
56+
if (!$valid) {
5757
$destination .= "#comment-form";
5858
$commentSession = new Zend_Session_Namespace('commenting');
5959
$commentSession->post = serialize($_POST);
@@ -67,7 +67,7 @@ public function addAction()
6767
$reqAppPublicComment = (bool) get_option('commenting_require_public_moderation');
6868
$requiresApproval = $requiresApproval || (!is_object(current_user()) && $reqAppPublicComment);
6969
//end Daniel Lind contribution
70-
if($requiresApproval) {
70+
if ($requiresApproval) {
7171
$this->_helper->flashMessenger(__("Your comment is awaiting moderation"), 'success');
7272
}
7373

@@ -91,11 +91,11 @@ public function updateSpamAction()
9191
$table = $this->_helper->db->getTable();
9292
$wordPressAPIKey = get_option('commenting_wpapi_key');
9393
$ak = new Zend_Service_Akismet($wordPressAPIKey, WEB_ROOT );
94-
$response = array('errors'=> array());
95-
foreach($commentIds as $commentId) {
94+
$response = array('errors' => array());
95+
foreach ($commentIds as $commentId) {
9696
$comment = $table->find($commentId);
9797
$data = $comment->getAkismetData();
98-
if($spam) {
98+
if ($spam) {
9999
$submitMethod = 'submitSpam';
100100
} else {
101101
$submitMethod = 'submitHam';
@@ -108,7 +108,7 @@ public function updateSpamAction()
108108
$response['status'] = 'ok';
109109
} catch (Exception $e){
110110
$response['status'] = 'fail';
111-
$response['errors'][] = array('id'=>$comment->id);
111+
$response['errors'][] = array('id' => $comment->id);
112112
$response['message'] = $e->getMessage();
113113
_log($e);
114114
}
@@ -122,32 +122,32 @@ public function updateApprovedAction()
122122
$commentIds = $_POST['ids'];
123123
$status = $_POST['approved'];
124124
$table = $this->_helper->db->getTable();
125-
if(! $commentIds) {
125+
if (! $commentIds) {
126126
return;
127127
}
128-
foreach($commentIds as $commentId) {
128+
foreach ($commentIds as $commentId) {
129129
$comment = $table->find($commentId);
130130
$comment->approved = $status;
131131
//if approved, it isn't spam
132-
if( ($status == 1) && ($comment->is_spam == 1) ) {
132+
if (($status == 1) && ($comment->is_spam == 1)) {
133133
$comment->is_spam = 0;
134134
$ak = new Zend_Service_Akismet($wordPressAPIKey, WEB_ROOT );
135135
$data = $comment->getAkismetData();
136136
try {
137137
$ak->submitHam($data);
138-
$response = array('status'=>'ok');
138+
$response = array('status' => 'ok');
139139
$comment->save();
140140
} catch (Exception $e) {
141141
_log($e->getMessage());
142-
$response = array('status'=>'fail', 'message'=>$e->getMessage());
142+
$response = array('status' => 'fail', 'message' => $e->getMessage());
143143
}
144144

145145
} else {
146146
try {
147147
$comment->save();
148-
$response = array('status'=>'ok');
148+
$response = array('status' => 'ok');
149149
} catch(Exception $e) {
150-
$response = array('status'=>'fail', 'message'=>$e->getMessage());
150+
$response = array('status' => 'fail', 'message' => $e->getMessage());
151151
_log($e->getMessage());
152152
}
153153
}
@@ -162,21 +162,21 @@ public function updateFlaggedAction()
162162
$commentIds = $_POST['ids'];
163163
$flagged = $_POST['flagged'];
164164

165-
if($commentIds) {
166-
foreach($commentIds as $id) {
165+
if ($commentIds) {
166+
foreach ($commentIds as $id) {
167167
$comment = $this->_helper->db->getTable('Comment')->find($id);
168168
$comment->flagged = $flagged;
169169
$comment->save();
170170
}
171171
} else {
172-
$response = array('status'=>'empty', 'message'=>'No Comments Found');
172+
$response = array('status' => 'empty', 'message' => 'No Comments Found');
173173
}
174-
if($flagged) {
174+
if ($flagged) {
175175
$action = 'flagged';
176176
} else {
177177
$action = 'unflagged';
178178
}
179-
$response = array('status'=>'ok', 'action'=>$action, 'ids'=>$commentIds);
179+
$response = array('status' => 'ok', 'action' => $action, 'ids' => $commentIds);
180180
$this->_helper->json($response);
181181
}
182182

@@ -187,7 +187,7 @@ public function flagAction()
187187
$comment->flagged = true;
188188
$comment->save();
189189
$this->emailFlagged($comment);
190-
$response = array('status'=>'ok', 'id'=>$commentId, 'action'=>'flagged');
190+
$response = array('status' => 'ok', 'id' => $commentId, 'action' => 'flagged');
191191
$this->_helper->json($response);
192192
}
193193

@@ -197,7 +197,7 @@ public function unflagAction()
197197
$comment = $this->_helper->db->getTable('Comment')->find($commentId);
198198
$comment->flagged = 0;
199199
$comment->save();
200-
$response = array('status'=>'ok', 'id'=>$commentId, 'action'=>'unflagged');
200+
$response = array('status' => 'ok', 'id' => $commentId, 'action' => 'unflagged');
201201
$this->_helper->json($response);
202202
}
203203

0 commit comments

Comments
 (0)