public function getChildren($p) { $p['showFoldersContent'] = true; if (@$p['from'] == 'calendar') { $p['fl'] = 'id,cid,date,date_end,status,template_id,name,cls'; } /* set default folder to root on fulltext search, otherwise facets will not be displayed for empty path */ if (!empty($p['query']) && (empty($p['path']) || $p['path'] == '/')) { $p['path'] = '/' . $this->getRootFolderId(); } /**/ $rez = parent::getChildren($p); return $rez; }
public function getChildren($p) { $p['from'] = 'tree'; $rez = parent::getChildren($p); $sql = 'SELECT count(*) `has_childs` FROM tree WHERE pid = $1 AND dstatus = 0' . (empty($p['showFoldersContent']) ? ' AND `template_id` IN (0' . implode(',', Config::get('folder_templates')) . ')' : ''); foreach ($rez['data'] as &$d) { if (!isset($d['loaded'])) { if (is_numeric($d['nid'])) { $res = DB\dbQuery($sql, $d['nid']) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $d['has_childs'] = !empty($r['has_childs']); } $res->close(); } $d['loaded'] = empty($d['has_childs']); } } return $rez['data']; }