/** * Get module contents * * @return void */ public function run() { include_once Component::path('com_whatsnew') . DS . 'helpers' . DS . 'period.php'; $live_site = rtrim(Request::base(), '/'); // Get some initial parameters $count = intval($this->params->get('limit', 5)); $this->feed = $this->params->get('feed'); $this->cssId = $this->params->get('cssId'); $this->period = $this->params->get('period', 'resources:month'); $this->tagged = intval($this->params->get('tagged', 0)); $database = \App::get('db'); // Build the feed link if necessary if ($this->feed) { $this->feedlink = Route::url('index.php?option=com_whatsnew&task=feed.rss&period=' . $this->period); $this->feedlink = DS . trim($this->feedlink, DS); $this->feedlink = $live_site . $this->feedlink; if (substr($this->feedlink, 0, 5) == 'https') { $this->feedlink = ltrim($this->feedlink, 'https'); $this->feedlink = 'http' . $this->feedlink; } } // Get categories $areas = $this->_getAreas(); $area = ''; // Check the search string for a category prefix if ($this->period != NULL) { $searchstring = strtolower($this->period); foreach ($areas as $c => $t) { $regexp = "/" . $c . ":/"; if (strpos($searchstring, $c . ":") !== false) { // We found an active category // NOTE: this will override any category sent in the querystring $area = $c; // Strip it off the search string $searchstring = preg_replace($regexp, '', $searchstring); break; } // Does the category contain sub-categories? if (is_array($t) && !empty($t)) { // It does - loop through them and perform the same check foreach ($t as $sc => $st) { $regexp = "/" . $sc . ":/"; if (strpos($searchstring, $sc . ':') !== false) { // We found an active category // NOTE: this will override any category sent in the querystring $area = $sc; // Strip it off the search string $searchstring = preg_replace($regexp, '', $searchstring); break; } } } } $this->period = trim($searchstring); } $this->area = $area; // Get the active category $activeareas = array(); if ($area) { $activeareas[] = $area; } // Process the keyword for exact time period $p = new Period($this->period); // Get the search results $results = Event::trigger('whatsnew.onWhatsnew', array($p, $count, 0, $activeareas, array())); $rows = array(); if ($results) { foreach ($results as $result) { if (is_array($result) && !empty($result)) { $rows = $result; break; } } } $this->rows = $rows; $this->rows2 = null; if ($this->tagged) { include_once Component::path('com_members') . DS . 'models' . DS . 'tags.php'; $mt = new \Components\Members\Models\Tags(User::get('id')); $tags = $mt->tags(); $this->tags = $tags; if (count($tags) > 0) { $tagids = array(); foreach ($tags as $tag) { $tagids[] = $tag->get('id'); } // Get the search results $results2 = Event::trigger('onWhatsnew', array($p, $count, 0, $activeareas, $tagids)); $rows2 = array(); if ($results2) { foreach ($results2 as $result2) { if (is_array($result2) && !empty($result2)) { $rows2 = $result2; break; } } } $this->rows2 = $rows2; } } require $this->getLayoutPath($this->params->get('layout', 'default')); }
/** * Get user profile info * * @apiMethod GET * @apiUri /members/{id} * @apiParameter { * "name": "id", * "description": "Member identifier", * "type": "integer", * "required": true, * "default": null * } * @return void */ public function readTask() { $userid = Request::getInt('id', 0); $result = Member::oneOrFail($userid); if (!$result || !$result->get('id')) { throw new Exception(Lang::txt('COM_MEMBERS_ERROR_USER_NOT_FOUND'), 404); } // Get any request vars $base = rtrim(Request::base(), '/'); $profile = array('id' => $result->get('id'), 'username' => $result->get('username'), 'name' => $result->get('name'), 'first_name' => $result->get('givenName'), 'middle_name' => $result->get('middleName'), 'last_name' => $result->get('surname'), 'email' => $result->get('email'), 'member_since' => $result->get('registerDate'), 'picture' => array('thumb' => $result->picture(0, true), 'full' => $result->picture(0, false)), 'interests' => array(), 'url' => str_replace('/api', '', $base . '/' . ltrim(Route::url($result->link()), '/'))); // Get custom fields $attribs = Field::all()->ordered()->rows(); foreach ($attribs as $attrib) { $key = $attrib->get('name'); if ($attrib->get('type') == 'tags') { $val = $result->tags('string'); } else { $val = $result->get($key); } if (is_array($val)) { $val = implode(';', $val); } $profile[$key] = $val; } require_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'tags.php'; $cloud = new \Components\Members\Models\Tags($userid); foreach ($cloud->tags('list') as $i => $tag) { $obj = new stdClass(); $obj->id = $tag->get('id'); $obj->raw_tag = $tag->get('raw_tag'); $obj->tag = $tag->get('tag'); $obj->uri = str_replace('/api', '', $base . '/' . ltrim(Route::url($tag->link()), '/')); $obj->substitutes_count = $tag->get('substitutes'); $obj->objects_count = $tag->get('total'); $profile['interests'][] = $obj; } // Corrects image path, API application breaks Route::url() in the Helper::getMemberPhoto() method. $profile['picture']['thumb'] = str_replace('/api', '', $base . '/' . $profile['picture']['thumb']); $profile['picture']['full'] = str_replace('/api', '', $base . '/' . $profile['picture']['full']); // Encode and return result $object = new stdClass(); $object->profile = $profile; $this->send($object); }