',PHP_EOL;
$posts = array_slice($posts, 0, $NMRECENTPOSTS, true);
foreach ($posts as $post) {
$url = nm_get_url('post') . $post->slug;
$title = stripslashes($post->title);
echo '
',$title,'',PHP_EOL;
}
echo '',PHP_EOL;
}
}
/*******************************************************
* @function nm_list_archives
* @action print a list of archives ordered by month or year
* @param $fmt optional custom format (strftime), default '%B %Y' or '%Y'
*/
function nm_list_archives($fmt='') {
global $NMARCHIVESBY;
$archives = array_keys(nm_get_archives($NMARCHIVESBY));
if (!empty($archives)) {
echo '',PHP_EOL;
if ($NMARCHIVESBY == 'y') {
# annual
if (!$fmt) $fmt = '%Y';
foreach ($archives as $archive) {
$y = $archive;
$title = nm_get_date($fmt, mktime(0, 0, 0, 1, 1, $y));
$url = nm_get_url('archive') . $archive;
echo '- ',$title,'
',PHP_EOL;
}
} else {
# monthly
if (!$fmt) $fmt = '%B %Y';
foreach ($archives as $archive) {
list($y, $m) = str_split($archive, 4);
$title = nm_get_date($fmt, mktime(0, 0, 0, $m, 1, $y));
$url = nm_get_url('archive') . $archive;
echo '- ',$title,'
',PHP_EOL;
}
}
echo '
',PHP_EOL;
}
}
/*******************************************************
* @function nm_list_tags
* @action print unique tags, popular tags are bigger.
*/
function nm_list_tags() {
$tags = array();
foreach (nm_get_tags() as $tag=>$posts)
if (substr($tag, 0, 1) != '_')
$tags[$tag] = count($posts);
if (!empty($tags)) {
$min = min($tags);
$max = max($tags);
foreach ($tags as $tag=>$count) {
$url = nm_get_url('tag') . $tag;
if ($min < $max && $count/$max > 0.5)
echo '',$tag,' ';
else
echo '',$tag,' ';
}
}
}
/*******************************************************
* @function nm_search
* @action provide form to search posts by keyword(s)
*/
function nm_search() {
global $i18n;
$placeholder = (isset($i18n['news_manager/SEARCH_PLACEHOLDER'])) ? $i18n['news_manager/SEARCH_PLACEHOLDER'] : '';
$url = nm_get_url();
?>