- //Init links
- $links = null;
-
- //Merge array
- if (!empty($session['i_type']) && !empty($session['i_url'])) {
- //Extract links type
- $session['i_type'] = explode("\n", $session['i_type']);
-
- //Extract links url
- $session['i_url'] = explode("\n", $session['i_url']);
-
- //Set links array
- $links = [];
-
- //Iterate on links type
- foreach($session['i_type'] as $i => $type) {
- //Type is contact, donate or link
- if (in_array($type, [Link::TYPE_CONTACT, Link::TYPE_DONATE, Link::TYPE_LINK])) {
- //Set title
- $linkTitle = $this->translator->trans(ucfirst($type));
- }
-
- //Type is contact
- if ($type == Link::TYPE_CONTACT) {
- //Set description
- $description = $this->translator->trans('Send a message to %pseudonym%', [ '%pseudonym%' => $session['au_pseudonym'] ]);
- //Type is donate
- } elseif ($type == Link::TYPE_DONATE) {
- //Set description
- $description = $this->translator->trans('Donate to %pseudonym%', [ '%pseudonym%' => $session['au_pseudonym'] ]);
- //Type is link
- } elseif ($type == Link::TYPE_LINK) {
- //Set description
- $description = $this->translator->trans('Link to %pseudonym%', [ '%pseudonym%' => $session['au_pseudonym'] ]);
- //Type is social
- } elseif ($type == Link::TYPE_SOCIAL) {
- //Set description
- $description = $this->translator->trans('Consult %pseudonym% social profile', [ '%pseudonym%' => $session['au_pseudonym'] ]);
-
- //Set title
- $linkTitle = $this->translator->trans('Social network');
- //Unknown type
- } else {
- //Throw explode
- throw new \InvalidArgumentException('Invalid type');
- }
-
- //Set link entry
- $links[$i] = [
- 'description' => $description,
- 'title' => $linkTitle,
- 'type' => $type,
- 'url' => $session['i_url'][$i]
- ];
- }
- }