Skip to content

Commit

Permalink
Merge pull request #10841 from hypeJunction/cs
Browse files Browse the repository at this point in the history
New Coding Standards
  • Loading branch information
hypeJunction committed Mar 21, 2017
2 parents d1dc3f0 + 5a63b3c commit a51796a
Show file tree
Hide file tree
Showing 1,448 changed files with 6,707 additions and 6,665 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -61,6 +61,7 @@ tmtags
Thumbs.db
Desktop.ini
npm-debug.log
phpcbf-fixed.diff

# Codio.com
startup.sh
Expand Down
2 changes: 1 addition & 1 deletion actions/admin/delete_admin_notice.php
Expand Up @@ -10,4 +10,4 @@
register_error(elgg_echo("admin:notices:could_not_delete"));
}

forward(REFERER);
forward(REFERER);
8 changes: 4 additions & 4 deletions actions/admin/menu/save.php
Expand Up @@ -7,18 +7,18 @@
*/

// featured menu items
$featured_names = get_input('featured_menu_names', array());
$featured_names = get_input('featured_menu_names', []);
$featured_names = array_unique($featured_names);
if (in_array(' ', $featured_names)) {
unset($featured_names[array_search(' ', $featured_names)]);
}
elgg_save_config('site_featured_menu_names', $featured_names);

// custom menu items
$custom_menu_titles = get_input('custom_menu_titles', array());
$custom_menu_urls = get_input('custom_menu_urls', array());
$custom_menu_titles = get_input('custom_menu_titles', []);
$custom_menu_urls = get_input('custom_menu_urls', []);
$num_menu_items = count($custom_menu_titles);
$custom_menu_items = array();
$custom_menu_items = [];
for ($i = 0; $i < $num_menu_items; $i++) {
if (trim($custom_menu_urls[$i]) && trim($custom_menu_titles[$i])) {
$url = $custom_menu_urls[$i];
Expand Down
15 changes: 7 additions & 8 deletions actions/admin/plugins/activate.php
Expand Up @@ -14,33 +14,32 @@
$plugin_guids = get_input('plugin_guids');

if (!is_array($plugin_guids)) {
$plugin_guids = array($plugin_guids);
$plugin_guids = [$plugin_guids];
}

$activated_guids = array();
$activated_guids = [];
foreach ($plugin_guids as $guid) {
$plugin = get_entity($guid);

if (!($plugin instanceof ElggPlugin)) {
register_error(elgg_echo('admin:plugins:activate:no', array($guid)));
register_error(elgg_echo('admin:plugins:activate:no', [$guid]));
continue;
}

if ($plugin->activate()) {
$activated_guids[] = $guid;
$ids = array(
$ids = [
'cannot_start' . $plugin->getID(),
'invalid_and_deactivated_' . $plugin->getID()
);
];

foreach ($ids as $id) {
elgg_delete_admin_notice($id);
}

} else {
$msg = $plugin->getError();
$string = ($msg) ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
register_error(elgg_echo($string, [$plugin->getFriendlyName(), $plugin->getError()]));
}
}

Expand All @@ -50,7 +49,7 @@

if (count($activated_guids) === 1) {
$url = 'admin/plugins';
$query = (string)parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
$query = (string) parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
if ($query) {
$url .= "?$query";
}
Expand Down
8 changes: 4 additions & 4 deletions actions/admin/plugins/activate_all.php
Expand Up @@ -39,10 +39,10 @@
continue;
}

$ids = array(
$ids = [
'cannot_start' . $plugin->getID(),
'invalid_and_deactivated_' . $plugin->getID()
);
];

foreach ($ids as $id) {
elgg_delete_admin_notice($id);
Expand All @@ -63,12 +63,12 @@
foreach ($plugins as $plugin) {
$msg = $plugin->getError();
$string = ($msg) ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
register_error(elgg_echo($string, array($plugin->getFriendlyName(), $msg)));
register_error(elgg_echo($string, [$plugin->getFriendlyName(), $msg]));
}
}

// don't regenerate the simplecache because the plugin won't be
// loaded until next run. Just invalidate and let it regnerate as needed
elgg_flush_caches();

forward(REFERER);
forward(REFERER);
8 changes: 4 additions & 4 deletions actions/admin/plugins/deactivate.php
Expand Up @@ -14,14 +14,14 @@
$plugin_guids = get_input('plugin_guids');

if (!is_array($plugin_guids)) {
$plugin_guids = array($plugin_guids);
$plugin_guids = [$plugin_guids];
}

foreach ($plugin_guids as $guid) {
$plugin = get_entity($guid);

if (!($plugin instanceof ElggPlugin)) {
register_error(elgg_echo('admin:plugins:deactivate:no', array($guid)));
register_error(elgg_echo('admin:plugins:deactivate:no', [$guid]));
continue;
}

Expand All @@ -30,7 +30,7 @@
} else {
$msg = $plugin->getError();
$string = ($msg) ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
register_error(elgg_echo($string, [$plugin->getFriendlyName(), $plugin->getError()]));
}
}

Expand All @@ -40,7 +40,7 @@

if (count($plugin_guids) == 1) {
$url = 'admin/plugins';
$query = (string)parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
$query = (string) parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
if ($query) {
$url .= "?$query";
}
Expand Down
2 changes: 1 addition & 1 deletion actions/admin/plugins/deactivate_all.php
Expand Up @@ -34,7 +34,7 @@
if (!$plugin->deactivate()) {
$msg = $plugin->getError();
$string = ($msg) ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
register_error(elgg_echo($string, [$plugin->getFriendlyName(), $plugin->getError()]));
}
}

Expand Down
6 changes: 3 additions & 3 deletions actions/admin/plugins/set_priority.php
Expand Up @@ -19,7 +19,7 @@
$plugin = get_entity($plugin_guid);

if (!($plugin instanceof ElggPlugin)) {
register_error(elgg_echo('admin:plugins:set_priority:no', array($plugin_guid)));
register_error(elgg_echo('admin:plugins:set_priority:no', [$plugin_guid]));
forward(REFERER);
}

Expand All @@ -28,11 +28,11 @@
} else {
$msg = $plugin->getError();
$string = ($msg) ? 'admin:plugins:set_priority:no_with_msg' : 'admin:plugins:set_priority:no';
register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
register_error(elgg_echo($string, [$plugin->getFriendlyName(), $plugin->getError()]));
}

// don't regenerate the simplecache because the plugin won't be
// loaded until next run. Just invalidate and let it regnerate as needed
elgg_flush_caches();

forward(REFERER);
forward(REFERER);
2 changes: 1 addition & 1 deletion actions/admin/site/flush_cache.php
Expand Up @@ -7,4 +7,4 @@
_elgg_services()->autoloadManager->deleteCache();

system_message(elgg_echo('admin:cache:flushed'));
forward(REFERER);
forward(REFERER);
2 changes: 1 addition & 1 deletion actions/admin/site/set_maintenance_mode.php
Expand Up @@ -3,7 +3,7 @@
* Configure site maintenance mode
*/

$mode = (int)get_input('mode');
$mode = (int) get_input('mode');
$message = get_input('message');

$site = elgg_get_site_entity();
Expand Down
4 changes: 2 additions & 2 deletions actions/admin/site/update_advanced.php
Expand Up @@ -25,13 +25,13 @@
// check for relative paths
if (stripos(PHP_OS, 'win') === 0) {
if (strpos($dataroot, ':') !== 1) {
$msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot));
$msg = elgg_echo('admin:configuration:dataroot:relative_path', [$dataroot]);
register_error($msg);
forward(REFERER);
}
} else {
if (strpos($dataroot, '/') !== 0) {
$msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot));
$msg = elgg_echo('admin:configuration:dataroot:relative_path', [$dataroot]);
register_error($msg);
forward(REFERER);
}
Expand Down
2 changes: 1 addition & 1 deletion actions/admin/site/update_basic.php
Expand Up @@ -25,7 +25,7 @@

elgg_save_config('language', get_input('language'));

$default_limit = (int)get_input('default_limit');
$default_limit = (int) get_input('default_limit');
if ($default_limit < 1) {
register_error(elgg_echo('admin:configuration:default_limit'));
forward(REFERER);
Expand Down
2 changes: 1 addition & 1 deletion actions/admin/user/ban.php
Expand Up @@ -27,4 +27,4 @@
register_error(elgg_echo('admin:user:ban:no'));
}

forward(REFERER);
forward(REFERER);
4 changes: 2 additions & 2 deletions actions/admin/user/delete.php
Expand Up @@ -23,7 +23,7 @@

if (($user instanceof ElggUser) && ($user->canEdit())) {
if ($user->delete()) {
system_message(elgg_echo('admin:user:delete:yes', array($name)));
system_message(elgg_echo('admin:user:delete:yes', [$name]));
} else {
register_error(elgg_echo('admin:user:delete:no'));
}
Expand All @@ -33,7 +33,7 @@

// forward to user administration if on a user's page as it no longer exists
$forward = REFERER;
if (strpos($_SERVER['HTTP_REFERER'], $username) != FALSE) {
if (strpos($_SERVER['HTTP_REFERER'], $username) != false) {
$forward = "admin/users/newest";
}

Expand Down
8 changes: 4 additions & 4 deletions actions/admin/user/resetpassword.php
Expand Up @@ -25,13 +25,13 @@

notify_user($user->guid,
elgg_get_site_entity()->guid,
elgg_echo('email:resetpassword:subject', array(), $user->language),
elgg_echo('email:resetpassword:body', array($user->username, $password), $user->language),
array(
elgg_echo('email:resetpassword:subject', [], $user->language),
elgg_echo('email:resetpassword:body', [$user->username, $password], $user->language),
[
'object' => $user,
'action' => 'resetpassword',
'password' => $password,
),
],
'email');
} else {
register_error(elgg_echo('admin:user:resetpassword:no'));
Expand Down
6 changes: 3 additions & 3 deletions actions/avatar/crop.php
Expand Up @@ -32,13 +32,13 @@

system_message(elgg_echo('avatar:crop:success'));
$view = 'river/user/default/profileiconupdate';
_elgg_delete_river(array('subject_guid' => $owner->guid, 'view' => $view));
elgg_create_river_item(array(
_elgg_delete_river(['subject_guid' => $owner->guid, 'view' => $view]);
elgg_create_river_item([
'view' => $view,
'action_type' => 'update',
'subject_guid' => $owner->guid,
'object_guid' => $owner->guid,
));
]);


forward(REFERER);
6 changes: 3 additions & 3 deletions actions/avatar/upload.php
Expand Up @@ -26,13 +26,13 @@
system_message(elgg_echo("avatar:upload:success"));

$view = 'river/user/default/profileiconupdate';
_elgg_delete_river(array('subject_guid' => $owner->guid, 'view' => $view));
elgg_create_river_item(array(
_elgg_delete_river(['subject_guid' => $owner->guid, 'view' => $view]);
elgg_create_river_item([
'view' => $view,
'action_type' => 'update',
'subject_guid' => $owner->guid,
'object_guid' => $owner->guid,
));
]);
}

forward(REFERER);
2 changes: 1 addition & 1 deletion actions/comment/delete.php
Expand Up @@ -19,4 +19,4 @@
register_error(elgg_echo('generic_comment:notfound'));
}

forward(REFERER);
forward(REFERER);
8 changes: 4 additions & 4 deletions actions/comment/save.php
Expand Up @@ -34,11 +34,11 @@

if (elgg_is_xhr()) {
// @todo move to its own view object/comment/content in 1.x
echo elgg_view('output/longtext', array(
echo elgg_view('output/longtext', [
'value' => $comment->description,
'class' => 'elgg-inner',
'data-role' => 'comment-text',
));
]);
}
} else {
register_error(elgg_echo('generic_comment:failure'));
Expand Down Expand Up @@ -66,13 +66,13 @@
}

// Add to river
elgg_create_river_item(array(
elgg_create_river_item([
'view' => 'river/object/comment/create',
'action_type' => 'comment',
'subject_guid' => $user->guid,
'object_guid' => $guid,
'target_guid' => $entity_guid,
));
]);

system_message(elgg_echo('generic_comment:posted'));
}
Expand Down
8 changes: 4 additions & 4 deletions actions/entity/delete.php
Expand Up @@ -29,7 +29,7 @@
$container = $entity->getContainerEntity();

if (!$entity->delete()) {
register_error(elgg_echo('entity:delete:fail', array($display_name)));
register_error(elgg_echo('entity:delete:fail', [$display_name]));
forward(REFERRER);
}

Expand All @@ -51,15 +51,15 @@
}
}

$success_keys = array(
$success_keys = [
"entity:delete:$type:$subtype:success",
"entity:delete:$type:success",
"entity:delete:success",
);
];

foreach ($success_keys as $success_key) {
if (elgg_language_key_exists($success_key)) {
system_message(elgg_echo($success_key, array($display_name)));
system_message(elgg_echo($success_key, [$display_name]));
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions actions/friends/add.php
Expand Up @@ -16,9 +16,9 @@
}

if (!elgg_get_logged_in_user_entity()->addFriend($friend->guid, true)) {
register_error(elgg_echo("friends:add:failure", array($friend->name)));
register_error(elgg_echo("friends:add:failure", [$friend->name]));
forward(REFERER);
}

system_message(elgg_echo("friends:add:successful", array($friend->name)));
system_message(elgg_echo("friends:add:successful", [$friend->name]));
forward(REFERER);
4 changes: 2 additions & 2 deletions actions/friends/remove.php
Expand Up @@ -16,10 +16,10 @@
}

if (!elgg_get_logged_in_user_entity()->removeFriend($friend->guid)) {
register_error(elgg_echo("friends:remove:failure", array($friend->name)));
register_error(elgg_echo("friends:remove:failure", [$friend->name]));
forward(REFERER);
}

system_message(elgg_echo("friends:remove:successful", array($friend->name)));
system_message(elgg_echo("friends:remove:successful", [$friend->name]));
forward(REFERER);

0 comments on commit a51796a

Please sign in to comment.