From 700eca70a9e8ac866419eeac4a1a661cdb62caa3 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 15 Jan 2018 10:08:47 -0500 Subject: [PATCH 1/4] Functions to ContactSelector put function in ContactSelector class --- src/Content/ContactSelector.php | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index eac7debce7..7b7cff4c98 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -112,4 +112,58 @@ class ContactSelector return $networkname; } + + function gender_selector($current="",$suffix="") { + $o = ''; + $select = array('', t('Male'), t('Female'), t('Currently Male'), t('Currently Female'), t('Mostly Male'), t('Mostly Female'), t('Transgender'), t('Intersex'), t('Transsexual'), t('Hermaphrodite'), t('Neuter'), t('Non-specific'), t('Other'), t('Undecided')); + + call_hooks('gender_selector', $select); + + $o .= "'; + return $o; + } + + function sexpref_selector($current="",$suffix="") { + $o = ''; + $select = array('', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')); + + + call_hooks('sexpref_selector', $select); + + $o .= "'; + return $o; + } + + + function marital_selector($current = "") + { + $o = ''; + $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me')); + + call_hooks('marital_selector', $select); + + $o .= ''; + return $o; + } } From f53e54c70589c3f7a137c29d4a1db6482857bc0c Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 15 Jan 2018 10:15:00 -0500 Subject: [PATCH 2/4] Update functions and calls Update function name and calls. --- mod/profiles.php | 12 +++++------- src/Content/ContactSelector.php | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/mod/profiles.php b/mod/profiles.php index 279a198aa5..5fcd2d8f17 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -3,6 +3,7 @@ * @file mod/profiles.php */ use Friendica\App; +use Friendica\Content\ContactSelector; use Friendica\Content\Feature; use Friendica\Core\Config; use Friendica\Core\PConfig; @@ -623,10 +624,7 @@ function profiles_content(App $a) { notice( t('Profile not found.') . EOL); return; } - - require_once 'include/profile_selectors.php'; - - + $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( '$baseurl' => System::baseUrl(true), )); @@ -718,11 +716,11 @@ function profiles_content(App $a) { '$postal_code' => array('postal_code', t('Postal/Zip Code:'), $r[0]['postal-code']), '$country_name' => array('country_name', t('Country:'), $r[0]['country-name']), '$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''), - '$gender' => gender_selector($r[0]['gender']), - '$marital' => marital_selector($r[0]['marital']), + '$gender' => ContactSelector::gender($r[0]['gender']), + '$marital' => ContactSelector::maritalStatus($r[0]['marital']), '$with' => array('with', t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), t('Examples: cathy123, Cathy Williams, cathy@example.com')), '$howlong' => array('howlong', t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))), - '$sexual' => sexpref_selector($r[0]['sexual']), + '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']), '$about' => array('about', t('Tell us about yourself...'), $r[0]['about']), '$xmpp' => array('xmpp', t('XMPP (Jabber) address:'), $r[0]['xmpp'], t("The XMPP address will be propagated to your contacts so that they can follow you.")), '$homepage' => array('homepage', t('Homepage URL:'), $r[0]['homepage']), diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index 7b7cff4c98..35f4fac33b 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -113,7 +113,12 @@ class ContactSelector return $networkname; } - function gender_selector($current="",$suffix="") { + /** + * @param string $current optional, default empty + * @param string $suffix optionsl, default empty + */ + public static function gender($current = "", $suffix = "") + { $o = ''; $select = array('', t('Male'), t('Female'), t('Currently Male'), t('Currently Female'), t('Mostly Male'), t('Mostly Female'), t('Transgender'), t('Intersex'), t('Transsexual'), t('Hermaphrodite'), t('Neuter'), t('Non-specific'), t('Other'), t('Undecided')); @@ -130,7 +135,12 @@ class ContactSelector return $o; } - function sexpref_selector($current="",$suffix="") { + /** + * @param string $current optional, default empty + * @param string $suffix optionsl, default empty + */ + public static function sexualPreference($current = "", $suffix = "") + { $o = ''; $select = array('', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')); @@ -148,8 +158,10 @@ class ContactSelector return $o; } - - function marital_selector($current = "") + /** + * @param string $current optional, default empty + */ + public static function maritalStatus($current = "") { $o = ''; $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me')); From 494f61a78f44bd8bce3adaf710c2991f24b9224c Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 15 Jan 2018 10:16:21 -0500 Subject: [PATCH 3/4] Remove old file remove include/profile_selectors.php --- include/profile_selectors.php | 56 ----------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 include/profile_selectors.php diff --git a/include/profile_selectors.php b/include/profile_selectors.php deleted file mode 100644 index 9e9dee0253..0000000000 --- a/include/profile_selectors.php +++ /dev/null @@ -1,56 +0,0 @@ -"; - foreach ($select as $selection) { - if ($selection !== 'NOTRANSLATION') { - $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= ""; - } - } - $o .= ''; - return $o; -} - -function sexpref_selector($current="",$suffix="") { - $o = ''; - $select = array('', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')); - - - call_hooks('sexpref_selector', $select); - - $o .= "'; - return $o; -} - - -function marital_selector($current = "") -{ - $o = ''; - $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me')); - - call_hooks('marital_selector', $select); - - $o .= ''; - return $o; -} From 309ea7e7a4a4a614db647eaa744ac2efb24ed65b Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 15 Jan 2018 11:33:02 -0500 Subject: [PATCH 4/4] Review updates update array to short form syntax --- src/Content/ContactSelector.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index 35f4fac33b..368ec98575 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -120,7 +120,7 @@ class ContactSelector public static function gender($current = "", $suffix = "") { $o = ''; - $select = array('', t('Male'), t('Female'), t('Currently Male'), t('Currently Female'), t('Mostly Male'), t('Mostly Female'), t('Transgender'), t('Intersex'), t('Transsexual'), t('Hermaphrodite'), t('Neuter'), t('Non-specific'), t('Other'), t('Undecided')); + $select = ['', t('Male'), t('Female'), t('Currently Male'), t('Currently Female'), t('Mostly Male'), t('Mostly Female'), t('Transgender'), t('Intersex'), t('Transsexual'), t('Hermaphrodite'), t('Neuter'), t('Non-specific'), t('Other'), t('Undecided')]; call_hooks('gender_selector', $select); @@ -142,7 +142,7 @@ class ContactSelector public static function sexualPreference($current = "", $suffix = "") { $o = ''; - $select = array('', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')); + $select = ['', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')]; call_hooks('sexpref_selector', $select); @@ -164,7 +164,7 @@ class ContactSelector public static function maritalStatus($current = "") { $o = ''; - $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me')); + $select = ['', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me')]; call_hooks('marital_selector', $select);