public function result($xmlData, $intLevel = 0) { if (!$this->hasAttribute('src')) { return; } return Bean::create(file_get_contents($this->attribute('src')))->run($xmlData); }
/** * Fetches an external dataset. * * @param string $strURL The URL or directory of the file * @param string $strType Declares the type of data (plain*, xml, bean, json) * @param string $strMethod Loading method for the external resource: open*, get, post * @return object|string */ private function xdrRetriveExternal($strURL, $strType = 'plain', $strMethod = 'open') { // TESTING: $this->probe('xdrRetriveExternal', 'Trying to load the external resource now: '.$strURL.'; Method: '.$strMethod.'; Type: '.$strType, 4); $strData = null; $strMethod = strtolower($strMethod); switch ($strMethod) { case 'get': if (class_exists('\\REST\\Client')) { $req = new \REST\Client($strURL); $strData = $req->post(); } else { // If the REST library is not present, simply use file_get_contents $strData = file_get_contents($strURL); } break; case 'post': if (!class_exists('\\REST\\Client')) { throw new Exception('Class REST\\Client not found. Please include the library from https://github.com/zeyon/rest'); } $req = new \REST\Client($strURL); $strData = $req->post(); break; default: $strData = is_readable(self::$basepath . $strURL) ? file_get_contents(self::$basepath . $strURL) : false; break; } if (!$strData) { return; } if ($strType == 'xml') { return Xml::create($strData); } elseif ($strType == 'bean') { return Bean::create($strData); } elseif ($strType == 'json') { return json_decode($strData, 1); } else { return $strData; } }
/** * Fetches an external dataset. * * @param string $strURL The URL or directory of the file * @param string strType Declares the type of data (plain*, xml, bean, json) * @param string $strMethod Loading method for the external resource: open*, get, post * @return object|string */ private function xdr_external($strURL, $strType = 'plain', $strMethod = 'open') { // TESTING: $this->probe('xdr_external', 'Trying to load the external resource now: '.$strURL.'; Method: '.$strMethod.'; Type: '.$strType, 4); $strData = null; $strMethod = strtolower($strMethod); switch ($strMethod) { case 'get': case 'post': if (class_exists('\\REST\\Client')) { $req = new \REST\Client($strURL); $strData = $strMethod == 'get' ? $req->get() : $req->post(); } break; default: $strData = is_readable(self::$basepath . $strURL) ? file_get_contents(self::$basepath . $strURL) : false; break; } if (!$strData) { return; } if ($strType == 'xml') { return Xml::create($strData); } elseif ($strType == 'bean') { return Bean::create($strData); } elseif ($strType == 'json') { return json_decode($strData, 1); } else { return $strData; } }
} $elem .= '</select>'; } elseif ($this->attribute('type') == 'multi') { $elem .= '<textarea class="form-control" name="' . $id . '" name="' . $name . '" rows="' . ($this->hasAttribute('rows') ? $this->attribute('rows') : 3) . '"></textarea>'; } else { $elem .= '<input type="' . ($this->hasAttribute('type') ? $this->attribute('type') : 'text') . '"' . ($this->hasAttribute('placeholder') ? ' placeholder="' . $this->attribute('placeholder') . '"' : '') . ' class="form-control" name="' . $id . '" name="' . $name . '" />'; } return $elem . '</div></div>'; } } $xlyDoc = Bean::create('<?xml version="1.0" encoding="UTF-8"?> <html> <form:frame width="2"> <form:field name="Firstname" label="First name" required="true" /> <form:field name="Lastname" label="Last name" required="true" /> <form:field name="Email" label="E-mail" type="email" /> <form:field name="region" label="Region?" placeholder="- Please Select -"> <option>North America</option> <option>Central America</option> <option>South America</option> <option>European Union</option> <option>Eastern Europe</option> <option>Africa</option> <option>Middle East</option> <option>Asia</option> <option>Oceania</option> <option>The Caribbean</option> </form:field> </form:frame> </html>'); echo $xlyDoc->run();