public function render() { $this->sendHeader(); $html = new Tag('html'); $sections = $this->get('section'); foreach ($sections as $section => $tagSection) { if ($sectionContent = $this->get($section)) { foreach ($sectionContent as $key => $elems) { foreach ($elems as $elem) { if (empty($elem)) { continue; } switch ($key) { case 'jsfile': $tagSection->add(new Tag('script'))->att('src', $elem); break; case 'jscode': $elem = trim($elem); if ($elem[0] == '<') { $tagSection->add(PHP_EOL . $elem); break; } $script = $tagSection->add(new Tag('script')); $script->add($elem); break; case 'css': $tagSection->add(new Tag('link'))->att(array('href' => $elem, 'rel' => 'stylesheet')); break; case 'error': $tagSection->add(new Tag('div'))->att('class', 'hidden')->att('id', 'error')->add(implode('<br>', $elem)); break; } } } } $html->add($tagSection); } return '<!DOCTYPE ' . $this->get('doctype') . '>' . PHP_EOL . $html; }
public function buildAjax() { $form_pkey = array(); if ($form = $this->get_par('form-related')) { $form_par = $this->getFormParam($form, true); $form_pkey = $form_par['pkey']; } $tbl = new Tag('div'); $sql = $this->replacePlaceholder($this->get_par('datasource-sql')); $rs = $this->db->exec_query("SELECT * FROM (" . $sql . ") a", null, 'ASSOC'); $cols = $this->db->get_columns(); foreach ($cols as $col) { if ($col['name'] == '_group') { $rs = $this->groupRs($rs); } } $__g = ''; foreach ($rs as $rec) { $tr = tag::create('div')->att('class', 'row'); $__k = array(); $_oid = array(); foreach ($rec as $key => $fld) { $val = $fld; if (in_array($key, $form_pkey)) { $__k[] = 'pkey[' . $key . ']=' . $val; $_oid[] = $val; continue; } $print = true; if ($key[0] == '_') { $print = false; switch ($key) { case '_id': $tr->att('data-oid', $val); $print = false; break; case '_label': $tr->att('data-label', $val); $print = false; break; case '_group': if ($val != $__g) { $__g = $val; } else { $val = ' '; } $val = '<span class="osy-textsearch-inline-group">' . $val . '</span>'; $print = true; break; case '_img64x2': $dimcls = 'osy-image-med'; //no-break //no-break case '_img64': $val = '<span class="' . (empty($dimcls) ? 'osy-image-min' : $dimcls) . '">' . (empty($fld) ? '<span class="fa fa-ban"></span>' : '<img src="data:image/png;base64,' . base64_encode($fld) . '">') . '</span>'; $print = true; break; case '_label': $tr->att('data-label', $val); break; } } if ($print) { $tr->add(tag::create('div'))->add($val); } } //$tr->add('<br class="clear">'); $tbl->add($tr); if (!empty($__k)) { $tr->att('data-pkey', implode('&', $__k)); $tr->att('data-oid', implode('&', $_oid)); } } return $tbl; }
public function getFormIconify() { $usr = $this->getCurrentUser(); $sql = "SELECT f.o_id as form_id,f.o_nam as form_name,ic.p_vl as icon,coalesce(fw.p_vl,'640') as form_width,coalesce(fh.p_vl,'480') as form_height " . "FROM osy_obj_rel a " . "INNER JOIN osy_obj f ON (a.o_2 = f.o_own AND f.o_typ = 'form') " . "INNER JOIN osy_obj_prp i ON (f.o_id = i.o_id AND i.p_id = 'iconify' AND i.p_vl = '1') " . "LEFT JOIN osy_obj_prp ic ON (f.o_id = ic.o_id AND ic.p_id = 'iconify-icon') " . "LEFT JOIN osy_obj_prp fw ON (f.o_id = fw.o_id AND fw.p_id = 'width') " . "LEFT JOIN osy_obj_prp fh ON (f.o_id = fh.o_id AND fh.p_id = 'height') " . "WHERE a.o_1 = CONCAT('instance://',?,'/') AND a.r_typ = 'instance+application'"; //echo $sql; $res = $this->model->dbo->exec_query($sql, array($this->request->get('instance.id'))); $iconify = new Tag('span'); $iconify->add(print_r($this->request->get('input'), true)); if (!empty($res)) { $iconify = new Tag('ul'); foreach ($res as $rec) { $item = new Tag('span'); $item->att('id', $rec['form_name'])->att('data-fid', $rec['form_id'])->att('data-form-width', $rec['form_width'])->att('data-form-height', $rec['form_height'])->add(str_replace('CURRENT_USER', $usr, $rec['icon'])); $iconify->add(tag::create('li'))->add($item); } } return $iconify->att('id', 'iconify-forms')->att('style', 'display:none;'); }