12345678910111213141516171819202122232425262728293031323334 |
- <?php
- class UI_AjaxContent implements UITagInterface {
- /**
- * @param string $tagName = 'p5:AjaxContent'
- * @param array $props
- * @param array $childrens
- *
- * @return string html code
- */
- static function h($tagName, $props = [], $childrens = []) {
- // if (empty($props['url'])) throw new Exception("Missing url!");
- // if (empty($props['url'])) throw new Exception("Missing url!");
- $idHtmlNode = self::generateUniqueID();
- $loading = V::get('loading', "Wczytywanie danych ...", $props);
- return UI::h(null, [], [
- UI::h('div', [ 'id' => $idHtmlNode ], $loading),
- UI::hScript($jsFile = __FILE__ . '.script.js', $jsonVars = [
- 'ID_HTML_NODE' => $idHtmlNode,
- 'URL_FETCH_CONTENT' => $props['url'],
- 'LOADING' => $loading,
- ]),
- ]);
- }
- static function generateUniqueID() {
- static $_counter = 0;
- $_counter += 1;
- return "p5_ajax_content_{$_counter}";
- }
- }
|