public function onLoad() { parent::onLoad(); // get user details $account = $this->getHandler('AmunService\\User\\Account')->getOneById($this->user->getId(), array('id', 'status', 'name', 'gender', 'thumbnailUrl', 'timezone', 'updated', 'date', 'countryTitle'), Sql::FETCH_OBJECT); $this->template->assign('account', $account); // check whether remote profile if ($account->status == Account\Record::REMOTE) { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $account->profileUrl); exit; } // get acctivites $activities = $this->getActivities(); $this->template->assign('activities', $activities); // load groups $groups = $this->getHandler('AmunService\\User\\Friend\\Group')->getAll(array(), 0, 16, 'id', Sql::SORT_DESC, new Condition(array('userId', '=', $this->user->getId()))); $this->template->assign('groups', $groups); // form url $activityUrl = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/activity'; $receiverUrl = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/activity/receiver'; $this->template->assign('activityUrl', $activityUrl); $this->template->assign('receiverUrl', $receiverUrl); // template $this->htmlCss->add('my'); $this->htmlJs->add('amun'); $this->htmlJs->add('my'); $this->htmlContent->add(Html\Content::META, Atom\Writer::link($this->page->getTitle(), $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $this->user->getName() . '?format=atom')); }
public function onLoad() { parent::onLoad(); // add path $this->path->add('Friends', $this->page->getUrl() . '/friends'); // get friends $friends = $this->getFriends(); $this->template->assign('friends', $friends); // form url $url = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/friend'; $this->template->assign('friendUrl', $url); // template $this->htmlCss->add('my'); $this->htmlJs->add('amun'); $this->htmlJs->add('my'); $this->htmlContent->add(Html\Content::META, Atom\Writer::link($this->page->getTitle(), $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/friend?format=atom&filterBy=authorId&filterOp=equals&filterValue=' . $this->user->getId())); }
/** * @httpMethod GET * @path / */ public function doIndex() { if ($this->user->hasRight('forum_view')) { // load forum $resultForum = $this->getForum(); $this->template->assign('resultForum', $resultForum); // options $url = $this->service->getApiEndpoint() . '/form?format=json&method=create&pageId=' . $this->page->getId(); $this->setOptions(array(array('forum_add', 'Add', 'javascript:amun.services.forum.showForm(\'' . $url . '\')'))); // template $this->htmlCss->add('forum'); $this->htmlJs->add('forum'); $this->htmlJs->add('ace-html'); $this->htmlJs->add('bootstrap'); $this->htmlJs->add('prettify'); $this->htmlContent->add(Html\Content::META, Atom\Writer::link($this->page->getTitle(), $this->service->getApiEndpoint() . '?format=atom&filterBy=pageId&filterOp=equals&filterValue=' . $this->page->getId())); } else { throw new Exception('Access not allowed'); } }
/** * @httpMethod GET * @path /{userName} */ public function doProfile() { if ($this->user->hasRight('profile_view')) { $account = $this->getAccount(); if (!$account instanceof Account\Record) { throw new Exception('Invalid user'); } $this->template->assign('account', $account); // check whether remote profile if ($account->status == Account\Record::REMOTE) { Base::setResponseCode(301); header('Location: ' . $account->profileUrl); exit; } // add path $this->path->add($account->name, $this->page->getUrl() . '/' . $account->name); // get activities $activities = $this->getActivities($account); $this->template->assign('activities', $activities); // options $url = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/friend'; $options = new Option(__CLASS__, $this->registry, $this->user, $this->page); if (!$this->user->isAnonymous() && !$this->user->hasFriend($account)) { $options->add('profile_view', 'Add as friend', 'javascript:amun.services.profile.friendshipRequest(' . $this->user->getId() . ', ' . $account->id . ', \'' . $url . '\', this)'); } $options->load(array($this->page, $account)); $this->template->assign('options', $options); // template $this->htmlCss->add('profile'); $this->htmlJs->add('amun'); $this->htmlJs->add('profile'); $this->htmlContent->add(Html\Content::META, Atom\Writer::link('Activity', $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=atom')); $this->htmlContent->add(Html\Content::META, '<link rel="alternate" type="application/stream+json" href="' . $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/activity/' . $account->id . '?format=jas" />'); $this->htmlContent->add(Html\Content::META, '<link rel="meta" type="application/rdf+xml" title="FOAF" href="' . $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/foaf/' . $account->name . '" />'); $this->htmlContent->add(Html\Content::META, '<link rel="profile" type="html/text" href="' . $account->profileUrl . '" />'); } else { throw new Exception('Access not allowed'); } }
public function setTitle($title, $type = null) { Atom::textConstruct($this->writer, 'title', $title, $type); }
public function testLink() { $html = Writer::link('foo > bar', 'http://foo.com'); $this->assertEquals('<link rel="alternate" type="application/atom+xml" title="foo > bar" href="http://foo.com" />', $html); }