These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @title User Design Core Model Class |
||
4 | * |
||
5 | * @author Pierre-Henry Soria <[email protected]> |
||
6 | * @copyright (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved. |
||
7 | * @license GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. |
||
8 | * @package PH7 / App / System / Core / Model / Design |
||
9 | */ |
||
10 | namespace PH7; |
||
11 | |||
12 | use |
||
13 | PH7\Framework\Mvc\Router\Uri, |
||
14 | PH7\Framework\Url\Url; |
||
15 | |||
16 | class UserDesignCoreModel extends Framework\Mvc\Model\Design |
||
17 | { |
||
18 | const |
||
19 | GEO_PROFILE_LIMIT = 14, |
||
20 | CAROUSEL_PROFILE_LIMIT = 25, |
||
21 | PROFILE_BLOCK_LIMIT = 8, |
||
22 | PROFILE_LIMIT = 44, |
||
23 | GEO_PROFILE_AVATAR_SIZE = 150, |
||
24 | CAROUSEL_PROFILE_AVATAR_SIZE = 150, |
||
25 | PROFILE_BLOCK_AVATAR_SIZE = 150, |
||
26 | PROFILE_AVATAR_SIZE = 64; |
||
27 | |||
28 | protected $oUser, $oUserModel; |
||
29 | |||
30 | public function __construct() |
||
31 | { |
||
32 | parent::__construct(); |
||
33 | |||
34 | $this->oUser = new UserCore; |
||
35 | $this->oUserModel = new UserCoreModel; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get profile avatars from the geolocation. |
||
40 | * |
||
41 | * @param string $sCountryCode Optional The country code (e.g., GB, RU, FR, ES, ...). Default '' |
||
42 | * @param string $sCity Optional. The city name. Default '' |
||
43 | * @param integer $iOffset Optional. Default 0 |
||
44 | * @param integer $iLimit Optional. Default 14 |
||
45 | * @return void HTML output. |
||
46 | */ |
||
47 | public function geoProfiles($sCountryCode = '', $sCity = '', $iOffset = 0, $iLimit = self::GEO_PROFILE_LIMIT) |
||
48 | { |
||
49 | $oUserGeo = $this->oUserModel->getGeoProfiles($sCountryCode, $sCity, false, SearchCoreModel::LAST_ACTIVITY, $iOffset, $iLimit); |
||
50 | if (empty($oUserGeo)) return; |
||
51 | |||
52 | foreach ($oUserGeo as $oRow) |
||
53 | { |
||
54 | $sFirstName = $this->oStr->upperFirst($oRow->firstName); |
||
55 | $sCity = $this->oStr->upperFirst($oRow->city); |
||
56 | |||
57 | echo '<div class="carouselTooltip vs_marg pic thumb"><p><strong>'; |
||
58 | |||
59 | if (!UserCore::auth() && !AdminCore::auth()) |
||
60 | { |
||
61 | // Build GET parameters for tracking references |
||
62 | $aHttpParams = [ |
||
63 | 'ref' => $this->oHttpRequest->currentController(), |
||
64 | 'a' => 'carousel', |
||
65 | 'u' => $oRow->username, |
||
66 | 'f_n' => $sFirstName, |
||
67 | 's' => $oRow->sex |
||
68 | ]; |
||
69 | |||
70 | echo t('Meet %0% on %site_name%!', '<a href="' . $this->oUser->getProfileLink($oRow->username) . '">'. $sFirstName . '</a>'), '</strong><br /><em>', t('I am a %0% and I am looking %1%.', $oRow->sex, $oRow->matchSex), '<br />', t('I from %0%, %1%.', t($oRow->country), $sCity), '</em></p><a rel="nofollow" href="', Uri::get('user', 'signup', 'step1', '?' . Url::httpBuildQuery($aHttpParams), false), '"><img src="', $this->getUserAvatar($oRow->username, $oRow->sex, self::GEO_PROFILE_AVATAR_SIZE, 'Members'), '" alt="', t('Meet %0% on %site_name%', $oRow->username), '" /></a>'; |
||
0 ignored issues
–
show
|
|||
71 | } |
||
72 | else |
||
73 | { |
||
74 | echo t('Meet %0% on %site_name%!', $sFirstName), '</strong><br /><em>', t('I am a %0% and I am looking %1%.', $oRow->sex, $oRow->matchSex), '<br />', t('I from %0%, %1%.', t($oRow->country), $sCity), '</em></p><a href="', $this->oUser->getProfileLink($oRow->username), '"><img src="', $this->getUserAvatar($oRow->username, $oRow->sex, self::GEO_PROFILE_AVATAR_SIZE, 'Members'), '" alt="', t('Meet %0% on %site_name%', $oRow->username), '" /></a>'; |
||
0 ignored issues
–
show
The call to
UserDesignCoreModel::getUserAvatar() has too many arguments starting with 'Members' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
75 | } |
||
76 | |||
77 | echo '</div>'; |
||
78 | } |
||
79 | } |
||
80 | |||
81 | public function carouselProfiles($iOffset = 0, $iLimit = self::CAROUSEL_PROFILE_LIMIT) |
||
82 | { |
||
83 | $oUsers = $this->oUserModel->getProfiles(SearchCoreModel::LATEST, $iOffset, $iLimit); |
||
84 | if (empty($oUsers)) return; |
||
85 | |||
86 | echo '<script>$(function(){$("#foo").carouFredSel()});</script> |
||
87 | <div class="transparent p1"><div class="img_carousel"><div id="foo">'; |
||
88 | |||
89 | foreach ($oUsers as $oUser) |
||
90 | { |
||
91 | $sFirstName = $this->oStr->upperFirst($oUser->firstName); |
||
92 | $sCity = $this->oStr->upperFirst($oUser->city); |
||
93 | |||
94 | echo '<div class="carouselTooltip"><p><strong>'; |
||
95 | |||
96 | if (!UserCore::auth() && !AdminCore::auth()) |
||
97 | { |
||
98 | // Build GET parameters for tracking references |
||
99 | $aHttpParams = [ |
||
100 | 'ref' => $this->oHttpRequest->currentController(), |
||
101 | 'a' => 'carousel', |
||
102 | 'u' => $oUser->username, |
||
103 | 'f_n' => $sFirstName, |
||
104 | 's' => $oUser->sex |
||
105 | ]; |
||
106 | |||
107 | echo t('Meet %0% on %site_name%!', '<a href="' . $this->oUser->getProfileLink($oUser->username) . '">' . $sFirstName . '</a>'), '</strong><br /><em>', t('I am a %0% and I am looking %1%.', $oUser->sex, $oUser->matchSex), '<br />', t('I from %0%, %1%.', t($oUser->country), $sCity), '</em></p><a rel="nofollow" href="', Uri::get('user', 'signup', 'step1', '?' . Url::httpBuildQuery($aHttpParams), false), '"><img src="', $this->getUserAvatar($oUser->username, $oUser->sex, self::CAROUSEL_PROFILE_AVATAR_SIZE, 'Members'), '" alt="',t('Meet %0% on %site_name%', $oUser->username), '" class="splash_avatar" /></a>'; |
||
0 ignored issues
–
show
The call to
UserDesignCoreModel::getUserAvatar() has too many arguments starting with 'Members' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
108 | } |
||
109 | else |
||
110 | { |
||
111 | echo t('Meet %0% on %site_name%!', $sFirstName), '</strong><br /><em>', t('I am a %0% and I am looking %1%.', $oUser->sex, $oUser->matchSex), '<br />', t('I from %0%, %1%.', t($oUser->country), $sCity), '</em></p><a href="', $this->oUser->getProfileLink($oUser->username), '"><img src="', $this->getUserAvatar($oUser->username, $oUser->sex, self::CAROUSEL_PROFILE_AVATAR_SIZE, 'Members'), '" alt="',t('Meet %0% on %site_name%', $oUser->username), '" class="splash_avatar" /></a>'; |
||
0 ignored issues
–
show
The call to
UserDesignCoreModel::getUserAvatar() has too many arguments starting with 'Members' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
112 | } |
||
113 | |||
114 | echo '</div>'; |
||
115 | } |
||
116 | |||
117 | echo '</div><div class="clearfix"></div></div></div>'; |
||
118 | } |
||
119 | |||
120 | public function profilesBlock($iOffset = 0, $iLimit = self::PROFILE_BLOCK_LIMIT) |
||
121 | { |
||
122 | $oUsers = $this->oUserModel->getProfiles(SearchCoreModel::LATEST, $iOffset, $iLimit); |
||
123 | if (empty($oUsers)) return; |
||
124 | |||
125 | echo '<ul class="zoomer_pic">'; |
||
126 | |||
127 | foreach ($oUsers as $oUser) |
||
128 | { |
||
129 | $sFirstName = $this->oStr->upperFirst($oUser->firstName); |
||
130 | $sCity = $this->oStr->upperFirst($oUser->city); |
||
131 | |||
132 | echo '<li><a rel="nofollow" href="', $this->oUser->getProfileSignupLink($oUser->username, $sFirstName, $oUser->sex), '"><img src="', $this->getUserAvatar($oUser->username, $oUser->sex, self::PROFILE_BLOCK_AVATAR_SIZE, 'Members'), '" alt="',t('Meet %0% on %site_name%', $oUser->username), '" /></a></li>'; |
||
0 ignored issues
–
show
The call to
UserDesignCoreModel::getUserAvatar() has too many arguments starting with 'Members' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
133 | } |
||
134 | |||
135 | echo '</ul>'; |
||
136 | } |
||
137 | |||
138 | public function profiles($iOffset = 0, $iLimit = self::PROFILE_LIMIT) |
||
139 | { |
||
140 | $oUsers = $this->oUserModel->getProfiles(SearchCoreModel::LAST_ACTIVITY, $iOffset, $iLimit); |
||
141 | if (empty($oUsers)) return; |
||
142 | |||
143 | foreach ($oUsers as $oUser) |
||
144 | (new AvatarDesignCore)->get($oUser->username, $oUser->firstName, $oUser->sex, self::PROFILE_AVATAR_SIZE); |
||
145 | } |
||
146 | |||
147 | public static function userStatus($iProfileId) |
||
148 | { |
||
149 | $oUserModel = new \PH7\UserCoreModel; |
||
150 | |||
151 | echo '<div class="user_status">'; |
||
152 | if ($oUserModel->isOnline($iProfileId, Framework\Mvc\Model\DbConfig::getSetting('userTimeout'))) |
||
153 | { |
||
154 | echo '<img src="', PH7_URL_TPL, PH7_TPL_NAME, PH7_SH, PH7_IMG, 'icon/online.png" alt="', t('Online'), '" title="', t('Is Online!'), '" />'; |
||
155 | } |
||
156 | else |
||
157 | { |
||
158 | $iStatus = $oUserModel->getUserStatus($iProfileId); |
||
159 | $sImgName = ($iStatus == 2 ? 'busy' : ($iStatus == 3 ? 'away' : 'offline')); |
||
160 | $sTxt = ($iStatus == 2 ? t('Busy') : ($iStatus == 3 ? t('Away') : t('Offline'))); |
||
161 | |||
162 | echo '<img src="', PH7_URL_TPL, PH7_TPL_NAME, PH7_SH, PH7_IMG, 'icon/', $sImgName, '.png" alt="', $sTxt, '" title="', $sTxt, '" />'; |
||
163 | } |
||
164 | echo '</div>'; |
||
165 | |||
166 | unset($oUserModel); |
||
167 | } |
||
168 | } |
||
169 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.