public function getMetaRecordset($str, $type) { $meta = $this->getMetaArray($str); $data = array(); if (isset($meta[$type])) { foreach ($meta[$type] as $v) { $data[] = array('meta_id' => $v, 'meta_type' => $type, 'meta_id_lower' => mb_strtolower($v), 'count' => 0, 'percent' => 0, 'roundpercent' => 0); } } return staticRecord::newFromArray($data); }
/** Retrieves categories. <var>$params</var> is an associative array which can take the following parameters: - post_type: Get only entries with given type (default "post") - cat_url: filter on cat_url field - cat_id: filter on cat_id field - start: start with a given category - level: categories level to retrieve @param params <b>array</b> Parameters @return <b>record</b> */ public function getCategories($params = array()) { $c_params = array(); if (isset($params['post_type'])) { $c_params['post_type'] = $params['post_type']; unset($params['post_type']); } $counter = $this->getCategoriesCounter($c_params); if (isset($params['without_empty']) && $params['without_empty'] == false) { $without_empty = false; } else { $without_empty = $this->core->auth->userID() == false; # Get all categories if in admin display } $start = isset($params['start']) ? (int) $params['start'] : 0; $l = isset($params['level']) ? (int) $params['level'] : 0; $rs = $this->categories()->getChildren($start, null, 'desc'); # Get each categories total posts count $data = array(); $stack = array(); $level = 0; $cols = $rs->columns(); while ($rs->fetch()) { $nb_post = isset($counter[$rs->cat_id]) ? (int) $counter[$rs->cat_id] : 0; if ($rs->level > $level) { $nb_total = $nb_post; $stack[$rs->level] = (int) $nb_post; } elseif ($rs->level == $level) { $nb_total = $nb_post; $stack[$rs->level] += $nb_post; } else { $nb_total = $stack[$rs->level + 1] + $nb_post; if (isset($stack[$rs->level])) { $stack[$rs->level] += $nb_total; } else { $stack[$rs->level] = $nb_total; } unset($stack[$rs->level + 1]); } if ($nb_total == 0 && $without_empty) { continue; } $level = $rs->level; $t = array(); foreach ($cols as $c) { $t[$c] = $rs->f($c); } $t['nb_post'] = $nb_post; $t['nb_total'] = $nb_total; if ($l == 0 || $l > 0 && $l == $rs->level) { array_unshift($data, $t); } } # We need to apply filter after counting if (isset($params['cat_id']) && $params['cat_id'] !== '') { $found = false; foreach ($data as $v) { if ($v['cat_id'] == $params['cat_id']) { $found = true; $data = array($v); break; } } if (!$found) { $data = array(); } } if (isset($params['cat_url']) && $params['cat_url'] !== '' && !isset($params['cat_id'])) { $found = false; foreach ($data as $v) { if ($v['cat_url'] == $params['cat_url']) { $found = true; $data = array($v); break; } } if (!$found) { $data = array(); } } return staticRecord::newFromArray($data); }