/**
  * Get the html node for this element
  *
  * @param \DOMElement $node
  * @param \AppShed\Remote\XML\DOMDocument $xml
  * @param \AppShed\Remote\HTML\Settings $settings
  * @param CSSDocument $css
  * @param array $javascripts
  */
 protected function getHTMLNodeBase($node, $xml, $settings, $css, &$javascripts)
 {
     $node->setAttribute('data-screentype', static::TYPE);
     if ($this->secure) {
         $xml->addClass($node, 'secured');
     }
     $this->getCSS($css, $settings);
     if ($this->tabs === 'float') {
         $node->setAttribute('data-tabs', 'float');
     } else {
         if (!$this->tabs) {
             $node->setAttribute('data-tabs', 'hide');
         }
     }
     if ($this->header === 'float') {
         $xml->addClass($node, 'float-header');
     } else {
         if (!$this->header) {
             $xml->addClass($node, 'hide-header');
         }
     }
     if ($this->statusBarStyle === 'float') {
         $node->setAttribute('data-status', 'float');
     } else {
         if ($this->statusBarStyle === 'black') {
             $node->setAttribute('data-status', 'black');
         }
     }
     if ($this->tab) {
         $node->setAttribute('data-tab', $this->tab);
     }
     if ($settings->getFetchId()) {
         $node->setAttribute('data-fetch-id', $settings->getPrefix() . $settings->getFetchId());
     }
     if ($settings->getFetchUrl()) {
         $node->setAttribute('data-fetch-url', $settings->getFetchUrl());
     }
     if ($settings->getDirect()) {
         $node->setAttribute('data-fetch-direct', 'direct');
     }
     $node->appendChild($navbar = $xml->createElement('div', 'header'));
     $navbar->setAttribute('x-blackberry-focusable', 'true');
     $navbar->appendChild($xml->createElement('div', 'background'));
     if ($this->back !== false) {
         $navbar->appendChild($back = $xml->createElement('div', ['class' => 'back', 'data-linktype' => 'back', 'text' => 'Back']));
         if ($this->back instanceof Screen) {
             $this->back->getHTMLNode($xml, $settings);
             $back->setAttribute('data-href', $settings->getPrefix() . $this->back->getId());
         } else {
             if ($this->back !== true) {
                 $back->setAttribute('data-href', $settings->getPrefix() . $this->back);
             }
         }
         $back->setAttribute('x-blackberry-focusable', 'true');
     }
     $navbar->appendChild($title = $xml->createElement('div', 'title'));
     $title->appendChild($xml->createElement('span', ['text' => $this->title]));
     $items = $xml->createElement('div', 'items' . ($this->scroll ? ' scrolling' : ''));
     $node->appendChild($items);
     $headButtons = $this->addHTMLChildren($items, $xml, $settings, $css, $javascripts);
     foreach ($headButtons as $b) {
         $c = $b->getHTMLNode($xml, $settings);
         if ($c) {
             $navbar->appendChild($c);
         }
     }
 }
Exemple #2
0
 /**
  * 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');
     }
 }