/** * Get the html object for a screen * @param AppBuilderAPIElement $screen * @return array * @internal used by appbuilder */ public static function getElementAsHTMLObj($screen, $settings = null, $objs = null) { if (!$settings) { $settings = array(); } if (!isset($settings['emailPreview'])) { $settings['emailPreview'] = isset($_REQUEST['emailPreview']) ? $_REQUEST['emailPreview'] === 'true' : false; } if (!isset($settings['telPreview'])) { $settings['telPreview'] = isset($_REQUEST['telPreview']) ? $_REQUEST['telPreview'] === 'true' : false; } $settings['fetchscreen'] = $screen; $data['settings'] = $settings; $xml = self::getNewXMLDocument(); $s = $screen->getHTMLNode($xml, $data); if (isset($objs)) { foreach ($objs as $obj) { $obj->getHTMLNode($xml, $data); } } $data['settings']['main'] = (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $screen->getId(); $data['settings']['maintype'] = $screen instanceof AppBuilderAPIApp ? 'app' : 'screen'; unset($data['settings']['fetchscreen']); unset($data['settings']['emailPreview']); unset($data['settings']['telPreview']); return $data; }
protected function getHTMLNodeBase($xml, &$data, $css, &$javascripts = array()) { $this->node = parent::getHTMLNode($xml, $data); $this->node->setAttribute('data-screentype', static::TYPE); if ($this->secured) { $xml->addClass($this->node, 'secured'); } $this->getCSS($css, $data); if ($this->tabs === 'float') { $this->node->setAttribute('data-tabs', 'float'); } else { if (!$this->tabs) { $this->node->setAttribute('data-tabs', 'hide'); } } if ($this->header === 'float') { $xml->addClass($this->node, 'float-header'); } else { if (!$this->header) { $xml->addClass($this->node, 'hide-header'); } } if ($this->status === 'float') { $this->node->setAttribute('data-status', 'float'); } else { if ($this->status === 'black') { $this->node->setAttribute('data-status', 'black'); } } if ($this->tab) { $this->node->setAttribute('data-tab', $this->tab); } if ($this->fetchId) { $this->node->setAttribute('data-fetch-id', (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->fetchId); } if ($this->fetchUrl) { $this->node->setAttribute('data-fetch-url', $this->fetchUrl); } $this->node->appendChild($navbar = $xml->createElement('div', 'header')); $navbar->setAttribute('x-blackberry-focusable', 'true'); $navbar->appendChild($xml->createElement('div', 'background')); if ($this->back || $this->back === 0) { $navbar->appendChild($back = $xml->createElement('div', array('class' => 'back', 'data-linktype' => 'back', 'text' => 'Back'))); if ($this->back instanceof AppBuilderAPIScreen) { $this->back->getHTMLNode($xml, $data, true); $back->setAttribute('data-href', (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->back->getId()); } else { if ($this->back !== true) { $back->setAttribute('data-href', (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->back); } } $back->setAttribute('x-blackberry-focusable', 'true'); } $navbar->appendChild($title = $xml->createElement('div', 'title')); $title->appendChild($xml->createElement('span', array('text' => $this->title))); $items = $xml->createElement('div', 'items' . ($this->scrolling ? ' scrolling' : '')); $this->node->appendChild($items); $headButtons = $this->addHTMLChildren($items, $xml, $data, $css, $javascripts); if (is_array($headButtons)) { foreach ($headButtons as $b) { $c = $b->getHTMLNode($xml, $data); if ($c) { $navbar->appendChild($c); } } } return $this->node; }
/** * Get the html node for this element * @param AppBuilderAPIDOMDocument $xml * @param array $data * @return DOMElement */ public function getHTMLNode($xml, &$data, $link = false) { if (!$this->node && !$link) { $css = new AppBuilderAPICSSDocument(); if ($this->css) { $idselector = $css->getIdSelector($this->getIdType() . (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId()); $css->addCSS($this->css, $idselector); } $this->getCSS($css, $data); $this->node = parent::getHTMLNode($xml, $data); if ($this->name) { $this->node->setAttribute('data-name', $this->name); } if ($this->description) { $this->node->setAttribute('data-description', $this->description); } if ($this->flag) { $this->node->setAttribute('data-flag', $this->flag); } if ($this->previewUrl) { $this->node->setAttribute('data-preview-url', $this->previewUrl); } if ($this->webviewUrl) { $this->node->setAttribute('data-webview-url', $this->webviewUrl); } if ($this->icon) { $this->node->setAttribute('data-icon', $this->icon); $idselector = $css->getIdSelector($this->getIdType() . (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId()); $css->addRule(array(".android .phone-navigator {$idselector}.app .app-navigator .screen .header .back"), 'background-image', $css->getURLValue($this->icon)); $css->addRule(array(".blackberry .phone-navigator {$idselector}.app .app-navigator .screen .header"), 'background-image', $css->getURLValue($this->icon)); } if ($this->fetchUrl) { $this->node->setAttribute('data-fetch-url', $this->fetchUrl); } $this->node->appendChild($navigator = $xml->createElement('div', 'app-navigator')); $navigator->appendChild($navinner = $xml->createElement('div', 'app-navigator-inner')); $navinner->appendChild($xml->createElement('div', 'app-navigator-inner-sides')); $navinner->appendChild($xml->createElement('div', 'app-navigator-inner-sides')); if ($this->ads) { $xml->addClass($navigator, 'ads'); $this->node->appendChild($xml->createElement('div', 'ad-holder')); } $this->node->appendChild($tabbarOuter = $xml->createElement('div', 'tab-bar')); $tabbarOuter->appendChild($tabbar = $xml->createElement('table')); $tabbar->appendChild($tabbarinner = $xml->createElement('tr', 'tar-bar-inner')); //take the first tab and insert its screen directly into the navigator /* $firstTab = array_shift($this->tabs); $tabbar->appendChild($tabNode = $firstTab->getHTMLNode($xml, &$data)); $xml->addClass($tabNode, 'selected'); if($firstTab->hasScreenLink()) { $navigator->appendChild($firstTab->getScreen()->getHTMLNode($xml, &$data)); } */ foreach ($this->tabs as $tab) { $tabbarinner->appendChild($tab->getHTMLNode($xml, $data)); $tab->getCSS($css, $data); } //put that tab back on the beginning //array_unshift($this->tabs, $firstTab); $data['app'][(isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId()] = array('html' => "<style scoped>" . $css->toString() . "</style>" . $xml->saveXML($this->node), 'splashhtml' => $this->hasSplash ? "<style scoped>" . $css->toSplashString() . "</style><div class=\"splash\" id=\"app" . $this->getId() . "\"></div>" : null, 'updated' => $this->updated === true ? time() : $this->updated, 'secure' => array('login' => $this->login, 'register' => $this->register), 'css' => '', 'javascript' => $this->js); } return $this->node; }