function getArchives($blogid, $option = 'yearmonth') { global $database; $archives = array(); $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid); $skinSetting = getSkinSettings($blogid); $archivesOnPage = $skinSetting['archivesOnPage']; switch (POD::dbms()) { case 'PostgreSQL': if ($option == 'year') { $format = 'year'; } else { if ($option == 'month') { $format = 'month'; } else { $format = 'year, month'; } } $sql = "SELECT EXTRACT(YEAR FROM FROM_UNIXTIME(e.published)) AS year, EXTRACT(MONTH FROM FROM_UNIXTIME(e.published)) AS month, COUNT(*) AS count \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY {$format} \n\t\t\t\tORDER BY {$format}\n\t\t\t\tDESC LIMIT {$archivesOnPage}"; $result = POD::queryAllWithDBCache($sql, 'entry'); if ($result) { foreach ($result as $archive) { switch ($option) { case 'year': $archive['period'] = $archive['year']; break; case 'month': $archive['period'] = sprintf("%02d", $archive['month']); break; case 'yearmonth': default: $archive['period'] = $archive['year'] . sprintf("%02d", $archive['month']); break; } array_push($archives, $archive); } } break; case 'Cubrid': if ($option == 'year') { $format = 'YYYY'; } else { if ($option == 'month') { $format = 'MM'; } else { $format = 'YYYYMM'; } } $sql = "SELECT TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, '{$format}') period, \n\t\t\t\tCOUNT(*) \"count\"\n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYYMM') \n\t\t\t\tORDER BY period\n\t\t\t\tDESC FOR ORDERBY_NUM() BETWEEN 1 AND {$archivesOnPage}"; $result = POD::queryAllWithDBCache($sql, 'entry'); if ($result) { foreach ($result as $archive) { array_push($archives, $archive); } } break; case 'MySQL': case 'MySQLi': default: if ($option == 'year') { $format = 'year'; } else { if ($option == 'month') { $format = 'month'; } else { $format = 'year_month'; } } $sql = "SELECT EXTRACT({$format} FROM FROM_UNIXTIME(e.published)) period, COUNT(*) count \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY period \n\t\t\t\tORDER BY period \n\t\t\t\tDESC LIMIT {$archivesOnPage}"; $result = POD::queryAllWithDBCache($sql, 'entry'); if ($result) { foreach ($result as $archive) { array_push($archives, $archive); } } break; } return $archives; }
function getCategoriesSkin() { global $service; $setting = getSkinSettings(getBlogId()); $skin = array('name' => "{$setting['skin']}", 'url' => $service['path'] . "/skin/tree/{$setting['tree']}", 'labelLength' => $setting['labelLengthOnTree'], 'showValue' => $setting['showValueOnTree'], 'itemColor' => "{$setting['colorOnTree']}", 'itemBgColor' => "{$setting['bgColorOnTree']}", 'activeItemColor' => "{$setting['activeColorOnTree']}", 'activeItemBgColor' => "{$setting['activeBgColorOnTree']}"); return $skin; }