function list_children($from, MCSession $curusr, $filter = null) { $path_parts = explode("/", $from); $names = array(); foreach ($path_parts as $name) { if (!empty($name)) { $names[] = storagenamedecode($name); } } $cid = find_cid($names); $con = new DataBaseTable('content', true, DATACONF); $types = new DataBaseTable('types', true, DATACONF); $cq = $con->getData("pid:`= {$cid}`", null, null, $curusr->items_per_page, $_GET['offset']); $cols = $curusr->items_per_page / $curusr->rows_per_page; $grid = con_list_to_grid($cq); $list = "<div id=\"Grid-{$cid}\" class=\"grid grid-col-{$cols}\">" . $grid . "</div>\n"; if (empty($grid)) { $self = $con->getData("cid:`= {$cid}`"); $self = $self->fetch(); $type = $types->getData("ttid:`= {$self['ttid']}`"); $type = $type->fetch(); if ($type['ctype'] == 'page') { require_once dirname(__FILE__) . "/page.mod.php"; $list = load_page($self, $curusr); } else { $list = "<div id=\"Message-{$cid}\" class=\"alert alert-warning\">No Children detected for this content!</div>\n"; } } return $list; }
function list_projects(MCSession $curusr, $filter = null) { $table = new DataBaseTable('content', true, DATACONF); $q = "pid:`= 0`"; if (!empty($filter)) { $q .= " " . $filter; } $q = $table->getData($q, null, null, $curusr->items_per_page, $_GET['offset']); $cols = $curusr->items_per_page / $curusr->rows_per_page; if ($q instanceof PDOStatement) { $grid = con_list_to_grid($q); $list = "<div id=\"ConList\" class=\"grid grid-col-{$cols}\">\n"; } if (empty($grid)) { if (empty($curusr) || $curusr->level >= 3) { $html = "<div class=\"alert alert-warning\">No Content Posted! Please <a href=\"" . SITEROOT . "/?modal=login\">login</a> and post some stuff!!</div>"; } else { $html = "<div class=\"alert alert-warning\">No Content Posted! Please open the <a href=\"" . SITEROOT . "dash/?section=projects\" data-toggle=\"modal\" data-target=\"#AJAXModal\">project manager</a> to add new content!</div>"; } } else { $html = $list; } return $html; }
function random_search() { $cdb = new DataBaseTable('content', true, DATACONF); $aq = $cdb->getData("pid:`= 0`", array('cid')); $ac = $aq->fetch(PDO::FETCH_OBJ, PDO::FETCH_ORI_LAST); if ($ac->cid > 0) { $rid = mt_rand(1, $ac->cid); } else { $rid = 1; } if ($rq = $cdb->getData("cid:`= {$rid}`")) { $grid = con_list_to_grid($rq, true); if (!empty($grid)) { return "<div class=\"grid grid-col-4\">\n" . $grid . "\n</div>\n"; } else { return random_search(); //result empty try a different random ID } } else { return "<div class=\"alert alert-danger\">Cannot retrieve random series! Unknown server error.</div>\n"; } }