function page__getajax() { $out = aikiGetForm($_GET["form"], $_GET["mode"]); if (!is_object($out)) { $out = aikiGetForm($_GET["form"], "show"); } $Item = aikiReadItem($_GET["form"], $_GET["item"]); $out = aikiFromString(page__show($out, $Item)); if (is_callable("pageChangeHtml")) { pageChangeHtml($out, $Item); } return $out->outerHtml(); }
if (!isset($_GET["mode"])) { $_GET["mode"] = ""; } if (!isset($_GET["item"])) { $_GET["item"] = ""; } $_SESSION["engine_path"] = "{$_SERVER['DOCUMENT_ROOT']}/engine"; $_ENV["cache"] = array("_readitem" => array(), "_fileds" => array()); $tmp = explode("?", $_SERVER["REQUEST_URI"]); if (isset($tmp[1])) { parse_str($tmp[1], $get); $_GET = (array) $_GET + (array) $get; unset($tmp, $get); } include_once "{$_SESSION["engine_path"]}/functions.php"; $__page = aikiFromString(""); $Item = array(); $form = ""; $mode = ""; $id = ""; $error = null; $tpl = ""; comSession(); comPathCheck(); aikiSettingsRead(); aikiDatabaseConnect(); aikiLogin(); if (is_file("{$_SESSION["app_path"]}/functions.php")) { include_once "{$_SESSION["app_path"]}/functions.php"; } if ($_SERVER['SCRIPT_NAME'] == "/index.php") {
function tagDataPagesAjax($size = 10, $page = 1, $pages = 1, $cacheId, $count = 0, $find = "") { $this->attr("data-pages", $pages); $tplId = $this->attr("data-template"); $class = "ajax-" . $tplId; if (is_object($this->parent("table")) && $this->parent("table")->find("thead th[data-sort]")->length) { $this->parent("table")->find("thead")->attr("data-cache", $cacheId); $this->parent("table")->find("thead")->attr("data-size", $size); $this->parent("table")->find("thead")->attr("data", $class); } if ($pages > 0) { $find = urlencode($find); $pag = aikiFromString("<div><ul id='{$class}' class='pagination' data-size='{$size}' data-count='{$count}' data-cache='{$cacheId}' data-find='{$find}'></ul></div>"); $step = 1; $flag = floor($page / 10); if ($flag <= 1) { $flag = 0; } else { $flag *= 10; } $inner = ""; for ($i = 1; $i <= $pages; $i += $step) { $inner .= "<li data-page='{$i}'><a flag='{$flag}' href='#' data='{$class}-{$i}'>{$i}</a></li>"; if ($i >= 10) { $step = 10; } if ($page >= 10 && $i < 10) { $i = 10 - 1; $step = 1; } if ($flag > 0 && $i >= $flag && $i <= $flag + 9) { $step = 1; } if ($page >= 10 && $page < 20 && $i < 20) { $step = 1; } } $pag->find("ul")->append($inner); $pag->find("li[data-page={$page}]")->addClass("active"); if ($pages == 1) { $style = $pag->find("ul")->attr("style"); $pag->find("ul")->attr("style", $style . ";display:none;"); } $this->after($pag->innerHtml()); } $this->removeAttr("data-pagination"); }
function aikiTableProcessor($out) { $data = array(); $grps = array(); $total = array(); $grand = array(); $tmp = $out->attr("data-group"); if ($tmp > "") { $groups = attrToArray($tmp); } else { $groups = array(null); } $tmp = $out->attr("data-total"); if ($tmp > "") { $totals = attrToArray($tmp); $total = array(); } if ($out->is("[data-suppress]")) { $sup = true; } else { $sup = false; } $lines = $out->find("tr"); $index = 0; foreach ($lines as $tr) { unset($grp_id, $grpidx); $fields = $tr->find("td[data-fld]:not([data-eval])"); $Item = array(); foreach ($fields as $field) { $Item[$field->attr("data-fld")] = $field->text(); } $fields = $tr->find("[data-eval]"); foreach ($fields as $field) { $evalStr = contentSetValuesStr($field, $Item); eval("\$tmp = " . $field->text() . ";"); $field->text($tmp); } foreach ($groups as $group) { $grp_text = $tr->find("[data-fld={$group}]")->text(); if (!isset($grp_id)) { $grp_id = $grp_text; } else { $grp_id .= "|" . $grp_text; } if (!isset($grpidx)) { $grpidx = $group; } else { $grpidx .= "|" . $group; } if (!isset($grps[$grp_id])) { $grps[$grp_id] = array("data" => array(), "total" => array()); } $grps[$grp_id]["grpidx"] = $grpidx; $grps[$grp_id]["data"][] = $index; if (isset($totals)) { foreach ($totals as $totfld) { $totval = $tr->find("[data-fld={$totfld}]")->text() * 1; if (!isset($grps[$grp_id]["total"][$totfld])) { $grps[$grp_id]["total"][$totfld] = 0; } $grps[$grp_id]["total"][$totfld] += $totval; if (!isset($grand[$totfld])) { $grand[$totfld] = 0; } if ($group == $groups[0]) { $grand[$totfld] += $totval; } } } } $index++; } ksort($grps); $grps = array_reverse($grps, true); $tbody = aikiFromString("<tbody type='result'></tbody>"); $ready = array(); foreach ($grps as $grpid => $grp) { $inner = ""; $count = count($grp["data"]) - 1; foreach ($grp["data"] as $key => $idx) { if (!in_array($idx, $ready)) { $tpl = $out->find("tr:eq({$idx})")->outerHtml(); if ($sup == false) { $tbody->append($tpl); } } if ($key == $count and count($grp["total"]) > 0) { // выводим тоталы группы $trtot = aikiFromString("<tr>" . $out->find("tr:eq({$idx})")->html() . "</tr>"); $totchk = array(); foreach ($grp["total"] as $fld => $total) { $trtot->find("td[data-fld={$fld}]")->html($total); $totchk[] = $fld; } $trtot->find("tr")->attr("data-group", $grp["grpidx"]); $trtot->find("tr")->attr("data-group-value", $grpid); $trtot->find("tr")->addClass("data-total success"); $grpchk = explode("|", $grp["grpidx"]); $tmp = $trtot->find("td:not([data-fld])"); foreach ($tmp as $temp) { $temp->html(""); } $tdflds = $trtot->find("td[data-fld]"); foreach ($tdflds as $tdfld) { $data_fld = $tdfld->attr("data-fld"); if (!in_array($data_fld, $grpchk) && !in_array($data_fld, $totchk)) { $tdfld->html(""); } if (in_array($data_fld, $grpchk)) { $tdfld->addClass("data-group"); } if (in_array($data_fld, $totchk)) { $tdfld->addClass("data-total"); } } $inner .= $trtot->outerHtml(); } $ready[] = $idx; } $tbody->append($inner); } // выводим общий итог if (isset($grp["total"]) && count($grp["total"]) > 0) { $grtot = aikiFromString("<tr>" . $out->find("tr:eq({$idx})")->html() . "</tr>"); $grtot->find("tr")->addClass("data-grand-total info"); $tmp = $grtot->find("td"); foreach ($tmp as $temp) { $temp->html(""); } $grflds = $grtot->find("td[data-fld]"); foreach ($grflds as $grfld) { $data_fld = $grfld->attr("data-fld"); if (in_array($data_fld, $totchk)) { $grfld->html($grand[$data_fld]); $grfld->addClass("data-total"); } } $tbody->append($grtot); } $out->html($tbody->innerHtml()); }