function art_get_post_icon($name){
return art_parse(art_option('metadata.'.$name), array('template_url' => get_bloginfo('template_url')));
}
if (!function_exists('get_the_date')) {
function get_the_date($format = 'F jS, Y') {
return get_the_time(__($format, THEME_NS));
}
}
function art_get_post_metadata($name) {
$list = art_option('metadata.'.$name);
$title = ($name == 'header' && art_option('metadata.title'));
if (!$title && $list == "") return;
$list_array = explode(",", $list);
$result = array();
for($i = 0; $i < count($list_array); $i++){
$icon = $list_array[$i];
switch($icon){
case 'date':
if(is_page()) break;
$result[] = art_get_post_icon($icon) . get_the_date();
break;
case 'author':
if(is_page()) break;
ob_start();
the_author_posts_link();
$result[] = art_get_post_icon($icon) . __('Author', THEME_NS) .' '. ob_get_clean();
break;
case 'category':
if(is_page()) break;
$result[] = art_get_post_icon($icon) .sprintf(__('Posted in %s', THEME_NS), get_the_category_list(', '));
break;
case 'tag':
if(is_page() || !get_the_tags()) break;
ob_start();
the_tags(__('Tags:', THEME_NS) . ' ', ', ', ' ');
$result[] = art_get_post_icon($icon) . ob_get_clean();
break;
case 'comments':
if(is_page() || is_single()) break;
ob_start();
comments_popup_link(__('No Comments »', THEME_NS), __('1 Comment »', THEME_NS), __('% Comments »', THEME_NS), '', __('Comments Closed', THEME_NS) );
$result[] = art_get_post_icon($icon) . ob_get_clean();
break;
case 'edit':
if (!current_user_can('edit_post', $post->ID)) break;
ob_start();
edit_post_link(__('Edit', THEME_NS), '');
$result[] = art_get_post_icon($icon) . ob_get_clean();
break;
}
}
if (!($title || count($result) > 0)) return '';
return art_parse_template("post_metadata".$name, array(
'post_title' => art_get_post_title(),
'post'.$name.'icons' => implode(art_option('metadata.separator'), $result))) ;
}
function art_post(){
the_post();
echo art_parse_template("post", array(
'post_class' => function_exists('get_post_class') ? implode(' ', get_post_class()) : '',
'post_id' => 'id="post-' . get_the_ID() . '"',
'post_thumbnail' => art_get_post_thumbnail(),
'post_title' => art_get_post_title(),
'post_metadataheader' => art_get_post_metadata('header'),
'post_content' => art_get_post_content(),
'post_metadatafooter' => art_get_post_metadata('footer')
));
}
function art_post_box($title, $content){
if ($title != "") {
$title = '<h2 class="art-postheader">'. $title . '</h2>';
}
if (art_option('metadata.title')) {
$content = $title . $content;
$title = '';
}
echo art_parse_template("post", array(
'post_class' => '',
'post_id' => '',
'post_thumbnail' => '',
'post_title' => $title,
'post_metadataheader' => '',
'post_content' => $content,
'post_metadatafooter' => ''));
}
function art_not_found_msg($caption = null, $content = null){
if ($caption === null){
$caption = __('Not Found', THEME_NS);
}
if($content === null){
$content = '<p class="center">' . __('Sorry, but you are looking for something that isn’t here.', THEME_NS) . '</p>'
. "\r\n" . art_get_search();
}
art_post_box($caption, $content);
}
function art_get_block($title, $content, $id = '', $class = '' , $name = "block"){
if (str_replace(array(' ', '', '\n', '\r', '\t'), '', $title) != ''){
$title = art_parse_template($name . '_header', array('caption' => $title));
}
if ($id != ''){
$id = 'id="' . $id . '"';
}
return art_parse_template($name, array(
'id' => $id,
'class' => $class,
'header' => $title,
'content' => $content,
));
}
function art_get_search() {
return art_parse_template("search",
array(
'url' => get_bloginfo('url'),
'button' => __('Search', THEME_NS),
'query' => get_search_query()
));
}
function art_page_navi($title = '', $comment = false) {
$prev_link = null;
$next_link = null;
if($comment){
$prev_link = get_previous_comments_link(__('Newer Entries »', THEME_NS));
$next_link = get_next_comments_link(__('« Older Entries', THEME_NS));
} elseif (is_single() || is_page()) {
$next_link = get_previous_post_link('« %link');
$prev_link = get_next_post_link('%link »');
} else {
$prev_link = get_previous_posts_link(__('Newer Entries »', THEME_NS));
$next_link = get_next_posts_link(__('« Older Entries', THEME_NS));
}
$content = '';
if ($prev_link || $next_link) {
$content = art_parse_template("pagination",
array(
'next_link' => $next_link,
'prev_link' => $prev_link
));
}
if (!$content && !$title) return;
art_post_box($title, $content);
}
if (!function_exists('get_previous_comments_link')) {
function get_previous_comments_link($label)
{
ob_start();
previous_comments_link($label);
return ob_get_clean();
}
}
if (!function_exists('get_next_comments_link')) {
function get_next_comments_link($label)
{
ob_start();
next_comments_link($label);
return ob_get_clean();
}
}
if (!function_exists('get_previous_posts_link')) {
function get_previous_posts_link($label)
{
ob_start();
previous_posts_link($label);
return ob_get_clean();
}
}
if (!function_exists('get_next_posts_link')) {
function get_next_posts_link($label)
{
ob_start();
next_posts_link($label);
return ob_get_clean();
}
}
if (!function_exists('get_previous_post_link')) {
function get_previous_post_link($label)
{
ob_start();
previous_post_link($label);
return ob_get_clean();
}
}
if (!function_exists('get_next_post_link')) {
function get_next_post_link($label)
{
ob_start();
next_post_link($label);
return ob_get_clean();
}
}
function art_get_comment_author_link(){
ob_start();
comment_author_link();
return ob_get_clean();
}
function art_get_edit_comment_link(){
ob_start();
edit_comment_link('('.__('Edit', THEME_NS).')',' ','');
return ob_get_clean();
}
function art_get_comment_text(){
ob_start();
comment_text();
return ob_get_clean();
}
function art_get_comment_reply_link($args, $depth){
ob_start();
comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'])));
return ob_get_clean();
}
function art_comment($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<?php art_post_box('', art_parse_template("comment", array(
'get_avatar' => get_avatar($comment, $size='48'),
'comment_author_link' => art_get_comment_author_link(),
'status' => $comment->comment_approved == '0' ? '<em>' . __('Your comment is awaiting moderation.', THEME_NS) . '</em><br />' : '',
'get_comment_link' => htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ,
'get_comment_date' => sprintf(__('%1$s at %2$s', THEME_NS), get_comment_date(), get_comment_time()),
'edit_comment_link' => art_get_edit_comment_link(),
'comment_text' => art_get_comment_text(),
'comment_reply_link' => art_get_comment_reply_link($args, $depth)))); ?>
</div>
<?php
}