/** * Get the html node for this element * * @param \AppShed\Remote\XML\DOMDocument $xml * @param \DOMElement $node * @param \AppShed\Remote\HTML\Settings $settings */ protected function applyLinkToNode(DOMDocument $xml, \DOMElement $node, Settings $settings) { switch ($this->linktype) { case LinkConstants::LINK_JAVASCRIPT: $node->setAttribute('data-linktype', LinkConstants::LINK_JAVASCRIPT); $node->setAttribute('data-href', $this->getIdType() . $settings->getPrefix() . $this->getId()); break; case LinkConstants::LINK_APP: $node->setAttribute('data-linktype', LinkConstants::LINK_APP); if ($this->screen instanceof App) { $this->app->getHTMLNode($xml, $settings); $node->setAttribute('data-href', $settings->getPrefix() . $this->app->getId()); } else { $node->setAttribute('data-href', $settings->getPrefix() . $this->app); } break; case LinkConstants::LINK_SCREEN: $node->setAttribute('data-linktype', LinkConstants::LINK_SCREEN); if ($this->screen instanceof Screen) { $this->screen->getHTMLNode($xml, $settings); $node->setAttribute('data-href', $settings->getPrefix() . $this->screen->getId()); } elseif ($this->appshedLink) { $node->setAttribute('data-href', $this->screen); $node->setAttribute('data-appshed', 'appshed'); } else { $node->setAttribute('data-href', $settings->getPrefix() . $this->screen); } if (!empty($this->elementId)) { $node->setAttribute('data-element', $this->elementId); } break; case LinkConstants::LINK_TAB: $node->setAttribute('data-linktype', LinkConstants::LINK_TAB); if ($this->tab instanceof Tab) { $node->setAttribute('data-href', $settings->getPrefix() . $this->tab->getId()); } elseif ($this->appshedLink) { $node->setAttribute('data-href', $this->tab); $node->setAttribute('data-appshed', 'appshed'); } else { $node->setAttribute('data-href', $settings->getPrefix() . $this->tab); } break; case LinkConstants::LINK_FILE: $node->setAttribute('data-linktype', LinkConstants::LINK_FILE); $node->setAttribute('data-href', $this->fileUrl); if ($this->fileName) { $node->setAttribute('data-filename', $this->fileName); } break; case LinkConstants::LINK_SOUND: $node->setAttribute('data-linktype', LinkConstants::LINK_SOUND); $node->setAttribute('data-href', $this->soundUrl); if ($this->soundName) { $node->setAttribute('data-filename', $this->soundName); } break; case LinkConstants::LINK_WEB: $node->setAttribute('data-linktype', LinkConstants::LINK_WEB); $node->setAttribute('data-href', $this->applyVariablesToUrl($this->webUrl)); $node->setAttribute('data-weblinktype', $this->webType); break; case LinkConstants::LINK_REMOTE: $node->setAttribute('data-linktype', LinkConstants::LINK_REMOTE); $node->setAttribute('data-href', $this->applyVariablesToUrl($this->remoteUrl)); $node->setAttribute('data-direct', 'direct'); break; case LinkConstants::LINK_LOGIN: $node->setAttribute('data-linktype', LinkConstants::LINK_LOGIN); $node->setAttribute('data-href', $this->loginId); break; case LinkConstants::LINK_REGISTER: $node->setAttribute('data-linktype', LinkConstants::LINK_REGISTER); $node->setAttribute('data-href', $this->registerId); break; case LinkConstants::LINK_YOUTUBE: $node->setAttribute('data-linktype', LinkConstants::LINK_YOUTUBE); $node->setAttribute('data-href', $this->youTubeUrl); break; case LinkConstants::LINK_VIMEO: $node->setAttribute('data-linktype', LinkConstants::LINK_VIMEO); $node->setAttribute('data-href', $this->vimeoUrl); break; case LinkConstants::LINK_VIDEO: $node->setAttribute('data-linktype', LinkConstants::LINK_VIDEO); $node->setAttribute('data-href', $this->videoUrl); break; case LinkConstants::LINK_FACEBOOK: $node->setAttribute('data-linktype', LinkConstants::LINK_FACEBOOK); $node->setAttribute('data-href', $this->facebookUrl); break; case LinkConstants::LINK_TWITTER: $node->setAttribute('data-linktype', LinkConstants::LINK_TWITTER); $node->setAttribute('data-href', $this->twitterScreenName); break; case LinkConstants::LINK_BBM: $node->setAttribute('data-linktype', LinkConstants::LINK_BBM); break; case LinkConstants::LINK_REFRESH: $node->setAttribute('data-linktype', LinkConstants::LINK_REFRESH); break; case LinkConstants::LINK_EMAIL: if ($settings->getEmailPreview()) { $screen = new Screen('Email'); $screen->setId('email' . $this->getId()); $screen->setEditable(false); $screen->setBack($settings->getCurrentScreen()); $screen->addChild(new Input('email_to', 'To', $this->emailTo)); $screen->addChild(new Input('email_subject', 'Subject', $this->emailSubject)); $screen->addChild(new TextArea('email_body', 'Message', $this->emailBody)); $send = new Button('Send'); $send->setWebLink('mailto:{email_to}?subject={email_subject}&body={email_body}', LinkConstants::WEBLINK_EXTERNAL); $screen->addChild($send); $screen->getHTMLNode($xml, $settings); $node->setAttribute('data-linktype', LinkConstants::LINK_SCREEN); $node->setAttribute('data-href', $settings->getPrefix() . $screen->getId()); } else { $node->setAttribute('data-linktype', LinkConstants::LINK_WEB); $node->setAttribute('data-href', 'mailto:' . $this->emailTo . '?' . http_build_query(['subject' => $this->emailSubject, 'body' => $this->emailBody])); $node->setAttribute('data-weblinktype', LinkConstants::WEBLINK_EXTERNAL); } break; case LinkConstants::LINK_PHONE: if ($settings->getPhonePreview()) { $screen = new Screen('Phone'); $screen->setId('phone' . $this->getId()); $screen->setScroll(false); $screen->setEditable(false); $screen->setBack($settings->getCurrentScreen()); $screen->addClass('phone-screen'); $screen->setHeader(false); $screen->setTabs(false); $top = new LinkElement($this->phoneNumber); $top->addClass('top'); $screen->addChild($top); $end = new LinkElement('End'); $end->addClass('bottom'); $end->setBackLink(); $screen->addChild($end); $screen->getHTMLNode($xml, $settings); $node->setAttribute('data-linktype', LinkConstants::LINK_SCREEN); $node->setAttribute('data-href', $settings->getPrefix() . $screen->getId()); } else { $node->setAttribute('data-linktype', 'web'); $node->setAttribute('data-href', 'tel:' . $this->phoneNumber); $node->setAttribute('data-weblinktype', LinkConstants::WEBLINK_CONFIRM); $node->setAttribute('data-confirm-message', 'Click to make a call to ' . $this->phoneNumber); $node->setAttribute('data-okbtn', 'Call'); } break; case LinkConstants::LINK_BACK: $node->setAttribute('data-linktype', LinkConstants::LINK_BACK); if ($this->backScreenId) { $node->setAttribute('data-href', $this->backScreenId); } break; case LinkConstants::LINK_IOT: $node->setAttribute('data-linktype', LinkConstants::LINK_IOT); $node->setAttribute('data-href', $this->iotPinName); $node->setAttribute('data-value', $this->iotValue); break; } if ($node->hasAttribute('data-linktype')) { $xml->addClass($node, 'link'); if ($this->linkArrow === true) { $node->appendChild($xml->createElement('div', 'link-arrow')); } else { if ($this->linkArrow === false) { $xml->addClass($node, 'link-no-arrow'); } } $node->setAttribute('x-blackberry-focusable', 'true'); } }