Exemplo n.º 1
0
function prod__list()
{
    $out = aikiGetForm($_GET["form"], $_GET["mode"]);
    $flag = "";
    $where = "";
    if (isset($_GET["division"]) && $_GET["division"] > "") {
        $where = aikiWhereFromTree("prod_division", $_GET["division"], "division");
        $flag = "division";
    }
    $Item = aikiListItems($_GET["form"], $where);
    $Item["result"] = array_sort($Item["result"], "id");
    $Item["form"] = $_GET["form"];
    $out->contentSetData($Item);
    $out->contentSetValues($Item);
    $modal = $out->find("div.modal");
    foreach ($modal as $m) {
        if ($m->attr("id") == "") {
            $m->attr("id", "{$_GET["form"]}Edit");
        }
        $m->attr("data-backdrop", "static");
        if ($m->find("[data-formsave]")->length && $m->find("[data-formsave]")->attr("data-formsave") == "") {
            $m->find("[data-formsave]")->attr("data-formsave", "#{$_GET["form"]}EditForm");
        }
        if ($m->find(".modal-title")->html() == "") {
            $m->find(".modal-title")->html("Редактирование");
        }
    }
    if ($flag == "division") {
        $out = $out->find("#prodList .list")->html();
        return $out;
    }
    if ($flag == "") {
        return $out->outerHtml();
    }
}
Exemplo n.º 2
0
function page__list()
{
    $out = aikiGetForm($_GET["form"], $_GET["mode"]);
    $Item = aikiListItems("page");
    $Item["result"] = array_sort($Item["result"], "id");
    $out->contentSetData($Item);
    $out->find("div.modal")->attr("id", "pageEdit");
    $out->find("div.modal")->attr("data-backdrop", "static");
    $out->find("[data-formsave]")->attr("data-formsave", "#pageEditForm");
    $out->find(".modal-title")->html("Редактирование страницы");
    return $out->outerHtml();
}
Exemplo n.º 3
0
function dict__list()
{
    $form = $_GET["form"];
    $out = aikifromFile("http://{$_SERVER["HTTP_HOST"]}/engine/forms/{$form}/{$form}_list.php");
    $Item = aikiListItems("comments");
    $Item["result"] = array_sort($Item["result"], "date", SORT_DESC);
    $out->contentSetData($Item);
    $out->find("div.modal")->attr("id", "{$form}Edit");
    $out->find("div.modal")->attr("data-backdrop", "static");
    $out->find("[data-formsave]")->attr("data-formsave", "#{$form}EditForm");
    $out->find(".modal-title")->html("Редактирование справочника");
    return $out->outerHtml();
}
Exemplo n.º 4
0
function news__list()
{
    $out = aikiGetForm($_GET["form"], $_GET["mode"]);
    $Item = aikiListItems("news");
    foreach ($Item["result"] as $key => $item) {
        $Item["result"][$key] = _newsBeforeShowItem($item);
    }
    $out->contentSetData($Item);
    $out->find("div.modal")->attr("id", "newsEdit");
    $out->find("div.modal")->attr("data-backdrop", "static");
    $out->find("[data-formsave]")->attr("data-formsave", "#newsEditForm");
    $out->find(".modal-title")->html("Редактирование новости");
    return $out->htmlOuter();
}
Exemplo n.º 5
0
function users__reg_check()
{
    $res = "ok";
    $type = $_SESSION["settings"]["elogin"];
    ${$type} = $_POST[$type];
    $where = " {$type} = '{${$type}}' ";
    $list = aikiListItems("users", $where);
    $list = $list["result"];
    foreach ($list as $key => $user) {
        if ($user[$type] == ${$type}) {
            $res = $type;
        }
    }
    return $res;
}
Exemplo n.º 6
0
function common__list()
{
    $out = aikiGetForm($_GET["form"], $_GET["mode"]);
    $Item = aikiListItems($_GET["form"]);
    $Item["form"] = $_GET["form"];
    $out->contentSetData($Item);
    if ($out->find("div.modal")->attr("id") == "") {
        $out->find("div.modal")->attr("id", "{$_GET["form"]}Edit");
    }
    $out->find("div.modal")->attr("data-backdrop", "static");
    if ($out->find("[data-formsave]")->length && $out->find("[data-formsave]")->attr("data-formsave") == "") {
        $out->find("[data-formsave]")->attr("data-formsave", "#{$_GET["form"]}EditForm");
    }
    $out->find(".modal-title")->html("Редактирование");
    return $out->outerHtml();
}
Exemplo n.º 7
0
 function tagForeach($Item = array())
 {
     if (!$this->is("[data-template]")) {
         $this->addTemplate();
     }
     $srcItem = $Item;
     $pagination = "";
     $sort = $this->attr("sort");
     $dsort = $this->attr("data-sort");
     $pagination = "ajax";
     if ($this->attr("data-pagination") > "") {
         $size = $this->attr("data-pagination");
         $pagination = "js";
     }
     if ($this->attr("data-size") > "") {
         $size = $this->attr("data-size");
         $pagination = "ajax";
     } else {
         $size = "false";
     }
     $mode = $this->attr("mode");
     $dmode = $this->attr("data-mode");
     if ($dmode == "") {
         $dmode = "list";
     }
     $desc = $this->attr("desc");
     $ddesc = $this->attr("data-desc");
     $rand = $this->attr("rand");
     $step = $this->attr("step");
     $page = $this->attr("data-page");
     if ($page == "") {
         $page = 1;
     }
     $cache = $this->attr("data-cache");
     $dList = $this->attr("data-list");
     if ($dList == "") {
         $dList = false;
     } else {
         $dList = aikiReadList($dList);
     }
     $limit = $this->attr("limit");
     $call = $this->attr("call");
     $oconv = $this->attr("oconv");
     $item = $this->attr("item");
     $where = $this->attr("where");
     if ($where == "") {
         $where = NULL;
     }
     $field = $this->attr("field");
     $from = $this->attr("from");
     $find = $this->attr("data-find");
     // контекстный поиск
     $tplid = $this->attr("data-template");
     $beforeShow = $this->attr("data-before-show");
     if ($from > "" && !isset($Item[$from])) {
         $tmp = "";
         eval('$tmp=$Item' . $from . ";");
         if ($tmp > "") {
             $Item[$from] = $tmp;
         }
     }
     if ($from > "" && isset($Item[$from]) && $this->hasRole("foreach") && $cache == "") {
         if ($this->attr("form") == "" && isset($Item["form"])) {
             $form = $Item["form"];
         } else {
             $form = "";
         }
         if ($this->attr("item") == "" && isset($Item["id"])) {
             $item = $Item["id"];
         } else {
             $item = "";
         }
         $Item = $Item[$from];
         if (!is_array($Item)) {
             $Item = json_decode($Item, true);
         }
         if ($field > "") {
             $Item = $Item[$field];
         }
         if (!is_array($Item)) {
             $Item = json_decode($Item, true);
         }
         if ($where > "") {
             $Item = aikiWhere($Item);
         }
     } else {
         $Item = array();
     }
     $vars = $this->attr("vars");
     if ($vars > "") {
         $Item = attrAddData($vars, $Item);
     }
     $json = $this->attr("json");
     if ($json > "") {
         $Item = json_decode($json, true);
     }
     $index = $this->attr("index");
     if (($this->attr("form") > "" or $this->attr("data-form") > "") && $from == "" && $cache == "") {
         $form = $this->attr("form");
         if ($form == "") {
             $form = $this->attr("data-form");
         }
         $type = $this->attr("data-type");
         if ($type > "") {
             $_SESSION[$form]["data-type-tmp"] = $type;
         }
         formCurrentInclude($form);
         $datatype = "file";
         $func = $form . "DataType";
         if (is_callable($func)) {
             $datatype = $func();
         }
         if ($item > "") {
             $Item[0] = aikiReadItem($form, $item);
             if ($field > "") {
                 $Item = $Item[0][$field];
                 if (is_string($Item)) {
                     $Item = json_decode($Item, true);
                 }
                 if (isset($Item[0]["img"]) && isset($Item[0]["visible"])) {
                     $Item = array_filter_value($Item, "visible", "1");
                 }
             }
         } else {
             $list = aikiListItems($form, $where);
             $Item = array();
             $Item = $list["result"];
         }
     }
     if (is_string($Item)) {
         $Item = json_decode($Item, true);
     }
     if (!is_array($Item)) {
         $Item = array($Item);
     }
     if ($cache > "" && isset($_SESSION["data"]["foreach"][$cache])) {
         $Item = $_SESSION["data"]["foreach"][$cache];
         $first = array_shift($Item);
         array_unshift($Item, $first);
         if (isset($first["form"])) {
             $form = $first["form"];
             formCurrentInclude($form);
         }
     }
     if ($sort > "") {
         // старый формат
         if ($desc == "true") {
             $stype = SORT_DESC;
         } else {
             $stype = SORT_ASC;
         }
         $Item = array_sort($Item, $sort, $stype);
     }
     if ($dsort > "") {
         $Item = array_sort_multi($Item, $dsort);
         if ($cache !== "") {
             $_SESSION["data"]["foreach"][$cache] = $Item;
         }
     }
     if ($ddesc == "true") {
         $Item = array_reverse($Item);
     }
     if ($rand == "true") {
         shuffle($Item);
     }
     if (is_callable($call)) {
         $Item = $call($Item);
     }
     $tpl = $this->innerHtml();
     $inner = "";
     $this->html("");
     if ($step > 0) {
         $steptpl = $this->clone();
         $stepcount = 0;
     }
     if ($tplid == "") {
         $tplid = "tpl" . newIdRnd();
     }
     $ndx = 0;
     $fdx = 0;
     $n = 0;
     $count = count($Item);
     if ($size == "false") {
         $pagination = "js";
     }
     if ($this->tag() !== "select" && $size == "" && $count > 200) {
         $pagination = "ajax";
         $size = 10;
         $page = 1;
         $this->attr("data-size", $size);
     }
     if ($count && $Item !== array(0 => "")) {
         $cacheList = array();
         $inner = "";
         $srcVal = array();
         foreach ($srcItem as $k => $v) {
             $srcVal["%{$k}"] = $v;
         }
         unset($v);
         $ndx = 0;
         $n = 0;
         $f = 0;
         $tmptpl = aikiFromString($tpl);
         foreach ($Item as $key => $val) {
             if (!isset($val["id"])) {
                 $lid = $key;
             } else {
                 $lid = $val["id"];
             }
             if ($dList == false or in_array($lid, $dList)) {
                 $n++;
                 $cacheVal = $val;
                 if ($limit == "" or $limit * 1 > $ndx * 1) {
                     if (!is_array($val)) {
                         $tmp = json_decode($val, true);
                         if ($tmp) {
                             $val = $tmp;
                         } else {
                             $val = array($val);
                         }
                     }
                     // именно так и никак иначе
                     if ($vars > "") {
                         $val = attrAddData($vars, $val);
                     }
                     if ($val !== NULL && ($where == NULL or aikiWhereItem($val, $where))) {
                         // если не обнулено в вызываемой ранее функцией (например, если стоит флаг скрытия в списке)
                         if ($cache == "" && $size !== "false" && $size !== "") {
                             $cacheList[$key] = $cacheVal;
                         }
                         if ($pagination == "ajax" && ($size == "false" or $size == "")) {
                             $size = 999999999;
                         }
                         if ($pagination == "ajax" and ($size > "" && $cache > "" && ($n > $page * $size - $size && $n <= $page * $size) or $size > "" && $cache == "" && $ndx < $size or $find > "") or $size == "" or $pagination == "js") {
                             $itemform = "";
                             if (isset($val["form"])) {
                                 $itemform = $val["form"];
                             } else {
                                 $itemform = $_GET["form"];
                             }
                             $text = $tmptpl->clone();
                             $val = (array) $srcVal + (array) $val;
                             // сливаем массивы
                             if ($beforeShow !== "false") {
                                 $val = aikiBeforeShowItem($val, $dmode, $itemform);
                             }
                             if (is_callable($oconv)) {
                                 $val = $oconv($val);
                             }
                             $text->find(":first")->attr("idx", $key);
                             $val["_idx"] = $_SESSION["foreach_idx"] = $key;
                             $val["_ndx"] = $_SESSION["foreach_ndx"] = $ndx;
                             $val["_num"] = $_SESSION["foreach_num"] = $ndx + 1;
                             $text->contentSetData($val);
                             if ($find == "") {
                                 $flag = true;
                             } else {
                                 $flag = aikiInString(strip_tags($text->innerHtml()), $find);
                                 if ($flag) {
                                     $f++;
                                 }
                             }
                             if ($find == "" or $size == "false" or $size == "" or $find > "" && ($f > $page * $size - $size && $f <= $page * $size)) {
                                 $tmp;
                             } else {
                                 $flag = false;
                             }
                             if ($flag == true) {
                                 $ndx++;
                                 if ($step > 0) {
                                     // если степ, то работаем с объектом
                                     if ($stepcount == 0) {
                                         $t_step = $steptpl->clone();
                                         $t_step->addClass($tplid);
                                         $this->append($t_step);
                                     }
                                     $this->find(".{$tplid}:last")->append(clearValueTags($text->outerHtml()));
                                     $stepcount++;
                                     //$stepcount=$this->find(".{$tplid}:last")->children()->length;
                                     if ($stepcount == $step) {
                                         $stepcount = 0;
                                     }
                                 } else {
                                     // иначе строим строку
                                     $inner .= clearValueTags($text->outerHtml());
                                 }
                             } else {
                                 $n--;
                             }
                             $text->remove();
                         }
                     }
                 }
             }
         }
         if ($step > 0) {
             foreach ($this->find(".{$tplid}") as $tid) {
                 $tid->removeClass($tplid);
             }
             unset($tid);
         } else {
             $this->html($inner);
         }
         unset($val, $ndx, $t_step, $string, $text, $func, $inner, $tmptpl);
     }
     if ($this->tag() == "select") {
         if (!is_array($result)) {
             $this->outerHtml("");
         }
         $plhr = $this->attr("placeholder");
         if ($plhr > "") {
             $this->prepend("<option value=''>{$plhr}</option>");
         }
     } else {
         $data_group = $this->attr("data-group");
         $data_total = $this->attr("data-total");
         if ($data_total > "" or $data_group > "") {
             aikiTableProcessor($this);
             $size = "";
         }
         if ($size > "" && $size !== "false" && $pagination == "js") {
             $this->tagDataPagination($size);
         }
         if ($size > "" && $size !== "false" && $pagination == "ajax") {
             if ($cache > "") {
                 $cacheId = $cache;
             } else {
                 $cacheId = md5($from . $form . $where . $tplid . $sort . $rand . $dsort . $limit . $item . $field . $call . $oconv . $vars . $json . implode("-", $_GET));
             }
             if ($cache == "" && isset($cacheList)) {
                 $_SESSION["data"]["foreach"][$cacheId] = $cacheList;
             }
             unset($cacheList);
             if ($find > "") {
                 $count = $f;
             } else {
                 $count = count($_SESSION["data"]["foreach"][$cacheId]);
             }
             $pages = ceil($count / $size);
             //if (round($pages)<$pages) {$pages=round($pages)+1;}
             $this->tagDataPagesAjax($size, $page, $pages, $cacheId, $count, $find);
         }
     }
     unset($Item, $tpl);
     gc_collect_cycles();
 }
Exemplo n.º 8
0
function sitemapGeneration()
{
    $host = "http://{$_SESSION['HTTP_HOST']}";
    $sitemap = ki::fromString('
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<url>
		<loc>' . $host . '/</loc>
		<lastmod>' . date("Y-m-d") . '</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.8</priority>
	</url>
</urlset>
	');
    $forms = array("page", "news");
    foreach ($forms as $form) {
        $list = aikiListItems($form);
        sitemapGenerationUrl($sitemap, $form, $list);
    }
    unset($form);
    fileSaveItem("{$_SESSION['prj_path']}/sitemap.xml", $sitemap, true);
    return true;
}