X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ffeatured.php;h=63ba8a07166956f21a476879345f00122d78ee48;hb=ed440c734e45de01183d885e8750c173fc20a726;hp=01071912d66168ea38731a791d2a1bcc47922f59;hpb=727c4060a590d12595a0378e5d83b57423d920f5;p=quix0rs-gnu-social.git diff --git a/actions/featured.php b/actions/featured.php index 01071912d6..63ba8a0716 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -10,16 +10,17 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/stream.php'); +require_once(INSTALLDIR.'/lib/profilelist.php'); class FeaturedAction extends StreamAction { @@ -38,64 +39,66 @@ class FeaturedAction extends StreamAction { } function show_top() { - if (common_logged_in()) { - common_notice_form('public'); - } - + $instr = $this->get_instructions(); + $output = common_markup_to_html($instr); + common_element_start('div', 'instructions'); + common_raw($output); + common_element_end('div'); $this->public_views_menu(); } function show_header() { + } - // XXX need to make the RSS feed for this - - //common_element('link', array('rel' => 'alternate', - // 'href' => common_local_url('featuredrss'), - // 'type' => 'application/rss+xml', - // 'title' => _('Featured Stream Feed'))); - + function get_instructions() { + return _('Featured users'); } function show_notices($page) { - $featured = common_config('nickname', 'featured'); + // XXX: Note I'm doing it this two-stage way because a raw query + // with a JOIN was *not* working. --Zach - if (count($featured) > 0) { + $featured_nicks = common_config('nickname', 'featured'); - $id_list = array(); + if (count($featured_nicks) > 0) { - foreach($featured as $featuree) { - $profile = Profile::staticGet('nickname', trim($featuree)); - array_push($id_list, $profile->id); + $quoted = array(); + + foreach ($featured_nicks as $nick) { + $quoted[] = "'$nick'"; } - // XXX: Show a list of users (people list) instead of shit crap + $user = new User; + $user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted))); + $user->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1); + $user->orderBy('user.nickname ASC'); + + $user->find(); + + $profile_ids = array(); + + while ($user->fetch()) { + $profile_ids[] = $user->id; + common_debug("id = $user->id"); + } - $qry = - 'SELECT * ' . - 'FROM notice ' . - 'WHERE profile_id IN (%s) '; + $profile = new Profile; + $profile->whereAdd(sprintf('profile.id IN (%s)', implode(',', $profile_ids))); + $profile->orderBy('nickname ASC'); - $cnt = 0; + $cnt = $profile->find(); - $notice = Notice::getStream(sprintf($qry, implode($id_list, ',')), - 'featured_stream', ($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + common_debug("count = $cnt"); - if ($notice) { - common_element_start('ul', array('id' => 'notices')); - while ($notice->fetch()) { - $cnt++; - if ($cnt > NOTICES_PER_PAGE) { - break; - } - $this->show_notice($notice); - } - common_element_end('ul'); + if ($cnt > 0) { + $featured = new ProfileList($profile); + $featured->show_list(); } - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'featured'); + $profile->free(); + common_pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'featured'); } }