function tagpatch_u($p, $o, $res = '') { //$p='type'; $p = utf8_decode($p); $r = sql('ib,msg', 'qdd', 'kv', 'val="' . $p . '"'); //id>'.$p.' limit 10000 foreach ($r as $k => $v) { $r[$k] = tri_tag($v); foreach ($r[$k] as $ka => $va) { if ($va) { $ra[$va] += 1; $rb[$k][] = $va; } } } //p($rb); foreach ($ra as $k => $v) { $idtag = sql('id', 'qdt', 'v', 'cat="' . $p . '" and tag="' . $k . '"'); if (!$idtag) { $idtag = insert('qdt', '("","' . $p . '","' . $k . '")'); } $rtag[$k] = $idtag; } foreach ($rb as $k => $v) { foreach ($v as $ka => $va) { $idtag = $rtag[$va]; $ex = sql('id', 'qdta', 'v', 'idart="' . $k . '" and idtag="' . $idtag . '"'); if (!$ex) { insert('qdta', '("","' . $k . '","' . $idtag . '")'); } } } $ret = $p . ':' . sql('count(id)', 'qdt', 'v', '') . '-' . sql('count(id)', 'qdta', 'v', ''); return $ret; }
function plug_slct() { $r = msql_read('system', 'program_plugs', '', 1); //p($r); //ksort($r); foreach ($r as $k => $v) { if ($v[2] == '1' && !$v[3] && !$v[5] && $v[1]) { $rb = tri_tag(str_replace(' ', ',', $v[1])); } if ($rb) { foreach ($rb as $kb => $vb) { $ret[$vb][] = lkc('', '/plug/' . $k, $k); } } } return divc('', make_tabs($ret)); }
function tri_tags($r) { if (is_array($r)) { foreach ($r as $k => $v) { $rb = tri_tag($k); foreach ($rb as $ka => $va) { if ($va) { $ret[$va] += $v; } } } } return $ret; }