From c9e1098dd2a38d36dd1cc2e083f7a2ea74f5f4c4 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 23 Oct 2019 21:38:51 +0200 Subject: [PATCH] Adapt naming convention --- mod/events.php | 8 ++++---- mod/item.php | 8 ++++---- mod/photos.php | 20 +++++++++----------- mod/settings.php | 8 ++++---- src/Model/Item.php | 6 +++--- src/Util/ACLFormatter.php | 6 +++--- tests/src/Util/ACLFormaterTest.php | 2 +- 7 files changed, 28 insertions(+), 30 deletions(-) diff --git a/mod/events.php b/mod/events.php index 75cbc6b431..11bb25f51b 100644 --- a/mod/events.php +++ b/mod/events.php @@ -152,10 +152,10 @@ function events_post(App $a) /** @var ACLFormatter $aclFormatter */ $aclFormatter = BaseObject::getClass(ACLFormatter::class); - $str_group_allow = $aclFormatter->aclToString($_POST['group_allow'] ?? ''); - $str_contact_allow = $aclFormatter->aclToString($_POST['contact_allow'] ?? ''); - $str_group_deny = $aclFormatter->aclToString($_POST['group_deny'] ?? ''); - $str_contact_deny = $aclFormatter->aclToString($_POST['contact_deny'] ?? ''); + $str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? ''); + $str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? ''); + $str_group_deny = $aclFormatter->toString($_POST['group_deny'] ?? ''); + $str_contact_deny = $aclFormatter->toString($_POST['contact_deny'] ?? ''); // Undo the pseudo-contact of self, since there are real contacts now if (strpos($str_contact_allow, '<' . $self . '>') !== false) { diff --git a/mod/item.php b/mod/item.php index 5539e28c67..a5875d258b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -275,10 +275,10 @@ function item_post(App $a) { /** @var ACLFormatter $aclFormatter */ $aclFormatter = BaseObject::getClass(ACLFormatter::class); - $str_group_allow = $aclFormatter->aclToString($_REQUEST['group_allow'] ?? ''); - $str_contact_allow = $aclFormatter->aclToString($_REQUEST['contact_allow'] ?? ''); - $str_group_deny = $aclFormatter->aclToString($_REQUEST['group_deny'] ?? ''); - $str_contact_deny = $aclFormatter->aclToString($_REQUEST['contact_deny'] ?? ''); + $str_group_allow = $aclFormatter->toString($_REQUEST['group_allow'] ?? ''); + $str_contact_allow = $aclFormatter->toString($_REQUEST['contact_allow'] ?? ''); + $str_group_deny = $aclFormatter->toString($_REQUEST['group_deny'] ?? ''); + $str_contact_deny = $aclFormatter->toString($_REQUEST['contact_deny'] ?? ''); } $title = Strings::escapeTags(trim($_REQUEST['title'] ?? '')); diff --git a/mod/photos.php b/mod/photos.php index 3a94813e54..d89cd04b0b 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -15,18 +15,16 @@ use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\System; use Friendica\Core\Session; +use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; -use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Object\Image; -use Friendica\Protocol\DFRN; use Friendica\Util\ACLFormatter; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; @@ -301,10 +299,10 @@ function photos_post(App $a) /** @var ACLFormatter $aclFormatter */ $aclFormatter = BaseObject::getClass(ACLFormatter::class); - $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->aclToString($_POST['group_allow']) : ''; - $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->aclToString($_POST['contact_allow']) : ''; - $str_group_deny = !empty($_POST['group_deny']) ? $aclFormatter->aclToString($_POST['group_deny']) : ''; - $str_contact_deny = !empty($_POST['contact_deny']) ? $aclFormatter->aclToString($_POST['contact_deny']) : ''; + $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : ''; + $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : ''; + $str_group_deny = !empty($_POST['group_deny']) ? $aclFormatter->toString($_POST['group_deny']) : ''; + $str_contact_deny = !empty($_POST['contact_deny']) ? $aclFormatter->toString($_POST['contact_deny']) : ''; $resource_id = $a->argv[3]; @@ -643,10 +641,10 @@ function photos_post(App $a) /** @var ACLFormatter $aclFormatter */ $aclFormatter = BaseObject::getClass(ACLFormatter::class); - $str_group_allow = $aclFormatter->aclToString(is_array($group_allow) ? $group_allow : explode(',', $group_allow)); - $str_contact_allow = $aclFormatter->aclToString(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow)); - $str_group_deny = $aclFormatter->aclToString(is_array($group_deny) ? $group_deny : explode(',', $group_deny)); - $str_contact_deny = $aclFormatter->aclToString(is_array($contact_deny) ? $contact_deny : explode(',', $contact_deny)); + $str_group_allow = $aclFormatter->toString(is_array($group_allow) ? $group_allow : explode(',', $group_allow)); + $str_contact_allow = $aclFormatter->toString(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow)); + $str_group_deny = $aclFormatter->toString(is_array($group_deny) ? $group_deny : explode(',', $group_deny)); + $str_contact_deny = $aclFormatter->toString(is_array($contact_deny) ? $contact_deny : explode(',', $contact_deny)); $ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => '']; diff --git a/mod/settings.php b/mod/settings.php index 3ab3d6212e..8c3ce66842 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -538,10 +538,10 @@ function settings_post(App $a) /** @var ACLFormatter $aclFormatter */ $aclFormatter = BaseObject::getClass(ACLFormatter::class); - $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->aclToString($_POST['group_allow']) : ''; - $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->aclToString($_POST['contact_allow']) : ''; - $str_group_deny = !empty($_POST['group_deny']) ? $aclFormatter->aclToString($_POST['group_deny']) : ''; - $str_contact_deny = !empty($_POST['contact_deny']) ? $aclFormatter->aclToString($_POST['contact_deny']) : ''; + $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : ''; + $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : ''; + $str_group_deny = !empty($_POST['group_deny']) ? $aclFormatter->toString($_POST['group_deny']) : ''; + $str_contact_deny = !empty($_POST['contact_deny']) ? $aclFormatter->toString($_POST['contact_deny']) : ''; $openidserver = $a->user['openidserver']; //$openid = Strings::normaliseOpenID($openid); diff --git a/src/Model/Item.php b/src/Model/Item.php index 6f84de427a..2c544a263b 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -17,8 +17,8 @@ use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\System; use Friendica\Core\Session; +use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Protocol\Activity; @@ -3350,7 +3350,7 @@ class Item extends BaseObject || $rendered_hash != hash("md5", $item["body"]) || Config::get("system", "ignore_cache") ) { - self::addRedirLinkToImageLinks($item); + self::addRedirToImageTags($item); $item["rendered-html"] = BBCode::convert($item["body"]); $item["rendered-hash"] = hash("md5", $item["body"]); @@ -3390,7 +3390,7 @@ class Item extends BaseObject * * @param array &$item The field array of an item row */ - private static function addRedirLinkToImageLinks(array &$item) + private static function addRedirToImageTags(array &$item) { $app = self::getApp(); diff --git a/src/Util/ACLFormatter.php b/src/Util/ACLFormatter.php index e724a89487..1fb7787610 100644 --- a/src/Util/ACLFormatter.php +++ b/src/Util/ACLFormatter.php @@ -30,7 +30,7 @@ final class ACLFormatter * * @param string $item The item to sanitise */ - private function sanitiseAcl(string &$item) { + private function sanitize(string &$item) { if (intval($item)) { $item = '<' . intval(Strings::escapeTags(trim($item))) . '>'; } elseif (in_array($item, [Group::FOLLOWERS, Group::MUTUALS])) { @@ -50,7 +50,7 @@ final class ACLFormatter * * @return string */ - function aclToString($permissions) { + function toString($permissions) { $return = ''; if (is_array($permissions)) { $item = $permissions; @@ -59,7 +59,7 @@ final class ACLFormatter } if (is_array($item)) { - array_walk($item, [$this, 'sanitiseAcl']); + array_walk($item, [$this, 'sanitize']); $return = implode('', $item); } return $return; diff --git a/tests/src/Util/ACLFormaterTest.php b/tests/src/Util/ACLFormaterTest.php index 19332f4953..76a566baaa 100644 --- a/tests/src/Util/ACLFormaterTest.php +++ b/tests/src/Util/ACLFormaterTest.php @@ -195,6 +195,6 @@ class ACLFormaterTest extends TestCase { $aclFormatter = new ACLFormatter(); - $this->assertEquals($assert, $aclFormatter->aclToString($input)); + $this->assertEquals($assert, $aclFormatter->toString($input)); } }