Example #1
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');
     }
 }
 /**
  * @Route("/read", name="read")
  * @Method({"GET", "POST", "OPTIONS"})
  */
 public function appshedAction(Request $request)
 {
     $view = $this->getView($request);
     if (!$view->getId()) {
         $screen = new Screen("Error");
         $screen->addChild(new Text("You must setup the view first"));
         return (new Remote($screen))->getSymfonyResponse();
     }
     $rootScreen = new Screen($view->getTitle() ?: "Results");
     if ($view->getMessage()) {
         $rootScreen->addChild(new Text($view->getMessage()));
     }
     $datas = $this->getDoctrine()->getRepository('AppShedExtensionsStorageBundle:Data')->getDataForView($view);
     /** @var Data $dataO */
     foreach ($datas as $dataO) {
         $data = $dataO->getData();
         if (count($data)) {
             if (array_key_exists('title', $data)) {
                 $title = $data['title'];
                 unset($data['title']);
             } else {
                 $title = current($data);
             }
             $dataScreen = new Screen($title);
             foreach ($data as $key => $value) {
                 $dataScreen->addChild(new Thumb($key, $value));
             }
             $link = new Link($title);
             $link->setScreenLink($dataScreen);
             $rootScreen->addChild($link);
         }
     }
     return (new Remote($rootScreen))->getSymfonyResponse();
 }