Example #1
0
require_once getinfo('common_dir') . 'comments.php';
// функции комментариев
// если был отправлен новый коммент, то обрабатываем его и выводим сообщение в случае ошибки
if ($out = mso_get_new_comment(array('page_title' => $page_title))) {
    $out .= mso_load_jquery('jquery.scrollto.js');
    $out .= '<script>$(document).ready(function(){$.scrollTo("#comments", 500);})</script>';
    echo $out;
}
// получаем все разрешенные комментарии
$comments = mso_get_comments($page_id);
// в сессии проверяем может быть только что отправленный комментарий
if (isset($MSO->data['session']['comments']) and $MSO->data['session']['comments']) {
    $anon_comm = $MSO->data['session']['comments'];
    // массив: id-коммент
    // получаем комментарии для этого юзера
    $an_comments = mso_get_comments($page_id, array('anonim_comments' => $anon_comm));
    // добавляем в вывод
    if ($an_comments) {
        $comments = array_merge($comments, $an_comments);
    }
}
if (is_login()) {
    $edit_link = getinfo('siteurl') . 'admin/comments/edit/';
} else {
    $edit_link = '';
}
if ($comments or $page_comment_allow) {
    echo NR . '<div class="type type_page_comments">' . NR;
}
if ($page_text_ok and $comments) {
    if ($f = mso_page_foreach('page-comments-do')) {
Example #2
0
function last_comments_widget_custom($options = array(), $num = 1)
{
    if (!isset($options['count'])) {
        $options['count'] = 5;
    }
    if (!isset($options['words'])) {
        $options['words'] = 20;
    }
    if (!isset($options['maxchars'])) {
        $options['maxchars'] = 20;
    }
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    $options['count'] = (int) $options['count'];
    if ($options['count'] < 1) {
        $options['count'] = 5;
    }
    $options['words'] = (int) $options['words'];
    if ($options['words'] < 1) {
        $options['words'] = 20;
    }
    $options['maxchars'] = (int) $options['maxchars'];
    if ($options['maxchars'] < 1) {
        $options['maxchars'] = 20;
    }
    $cache_key = 'last_comments_widget_' . $num . mso_md5(serialize($options));
    $k = mso_get_cache($cache_key, true);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    require_once getinfo('common_dir') . 'comments.php';
    // функции комментариев
    $comments = mso_get_comments(false, array('limit' => $options['count'], 'order' => 'desc'));
    $out = '';
    if ($comments) {
        // сгруппируем все комментарии по записям
        $arr_com_page = array();
        $arr_com_page_title = array();
        foreach ($comments as $comment) {
            $arr_com_page[$comment['page_id']][$comment['comments_id']] = $comment;
            $arr_com_page_title[$comment['page_id']] = $comment['page_title'];
        }
        // выводим по странично
        foreach ($arr_com_page as $key => $comments) {
            $out .= '<h5>' . $arr_com_page_title[$key] . '</h5>';
            $comments = array_reverse($comments);
            // чтобы комментарии были в привычном порядке сверху вниз
            $out .= '<ul class="mso-widget-list">';
            foreach ($comments as $comment) {
                extract($comment);
                if ($comment['comments_users_id']) {
                    $css_style_add = 'last_comment_users ' . ' mso-last-comment-users-' . $comment['comments_users_id'];
                } elseif ($comment['comments_comusers_id']) {
                    $css_style_add = 'last_comment_comusers ' . ' mso-last-comment-comusers-' . $comment['comments_comusers_id'];
                } else {
                    $css_style_add = 'last_comment_anonim';
                }
                $out .= '<li class="' . $css_style_add . '"><a href="' . getinfo('siteurl') . 'page/' . mso_slug($page_slug) . '#comment-' . $comments_id . '"><b>';
                if ($comments_users_id) {
                    $out .= $users_nik;
                } elseif ($comments_comusers_id) {
                    if ($comusers_nik) {
                        $out .= $comusers_nik;
                    } else {
                        $out .= t('Комментатор') . ' ' . $comusers_id;
                    }
                } elseif ($comments_author_name) {
                    $out .= $comments_author_name;
                } else {
                    $out .= ' ' . t('Аноним');
                }
                $comments_content_1 = strip_tags($comments_content);
                // удалим тэги
                $comments_content = mso_str_word($comments_content_1, $options['words']);
                // ограничение на количество слов
                // если старый и новый текст после обрезки разные, значит добавим в конце ...
                if ($comments_content_1 != $comments_content) {
                    $comments_content .= '...';
                }
                // каждое слово нужно проверить на длину и если оно больше maxchars, то добавить пробел в wordwrap
                $words = explode(' ', $comments_content);
                foreach ($words as $key => $word) {
                    $words[$key] = mso_wordwrap($word, $options['maxchars'], ' ');
                }
                $comments_content = implode(' ', $words);
                $out .= ' »</b>  ' . strip_tags($comments_content) . '</a>';
                $out .= '</li>' . NR;
            }
            $out .= '</ul>';
        }
        if ($options['header']) {
            $out = $options['header'] . $out;
        }
    }
    mso_add_cache($cache_key, $out, false, true);
    // сразу в кэш добавим
    return trim($out);
}
Example #3
0
$time_zone = str_replace('.', '', $time_zone);
$description = mso_head_meta('description');
$feed_url = getinfo('siteurl');
$language = 'en-ru';
$generator = 'MaxSite CMS (http://max-3000.com/)';
$par = array('limit' => 1, 'cut' => tf('Читать полностью') . ' »', 'type' => false);
$pages = mso_get_pages($par, $pagination);
if ($pages) {
    $pubdate = date('D, d M Y H:i:s ' . $time_zone, strtotime(mso_date_convert('Y-m-d H:i:s', $pages[0]['page_date_publish'])));
    echo '<' . '?xml version="1.0" encoding="utf-8"?' . '>';
    # получаем комментарии к странице
    $page = $pages[0];
    extract($page);
    // $feed_name = mso_meta_title($page_title) . ' ('. tf('Комментарии к странице'). ')';
    $feed_name = mso_head_meta('title', $pages, '%page_title%', '', true) . ' (' . tf('комментарии к странице') . ')';
    $comments = mso_get_comments($page_id);
    ?>

<rss version="2.0">
	<channel>
		<title><?php 
    echo $feed_name;
    ?>
</title>
		<link><?php 
    echo $feed_url;
    ?>
</link>
		<description><?php 
    echo $description;
    ?>
Example #4
0
    if ($f = mso_page_foreach('comments-do-last-comments-widget')) {
        require $f;
    } else {
        echo '<h1 class="comments">' . tf('Последние комментарии') . '</h1>';
        echo '<p class="info"><a href="' . getinfo('siteurl') . 'comments/feed">' . tf('Подписаться по RSS') . '</a>';
        echo '<br><a href="' . getinfo('siteurl') . 'users">' . tf('Список комментаторов') . '</a></p>';
        echo '<div class="comments">';
        echo last_comments_widget_custom(array('count' => 40), '999');
        echo '</div>';
    }
} else {
    // нет функции last_comments_widget_custom - выводим комменты как обычно
    require_once getinfo('common_dir') . 'comments.php';
    // функции комментариев
    // получаем список комментариев текущей страницы
    $comments = mso_get_comments(false, array('limit' => mso_get_option('comments_count', 'templates', '10'), 'order' => 'desc'));
    mso_head_meta('title', tf('Последние комментарии') . ' — ' . getinfo('title'));
    //  meta title страницы
    require getinfo('template_dir') . 'main-start.php';
    echo NR . '<div class="type type_comments">' . NR;
    if ($f = mso_page_foreach('comments-do')) {
        require $f;
    } else {
        echo '<h1 class="comments">' . tf('Последние комментарии') . '</h1>';
        echo '<p class="info"><a href="' . getinfo('siteurl') . 'comments/feed">' . tf('Подписаться по RSS') . '</a>';
        echo '<br><a href="' . getinfo('siteurl') . 'users">' . tf('Список комментаторов') . '</a></p>';
    }
    echo '<div class="comments">';
    if ($comments) {
        echo '<ul>';
        foreach ($comments as $comment) {
Example #5
0
// 3.00
if ($time_zone < 10 and $time_zone > 0) {
    $time_zone = '+0' . $time_zone;
} elseif ($time_zone > -10 and $time_zone < 0) {
    $time_zone = '0' . $time_zone;
    $time_zone = str_replace('0-', '-0', $time_zone);
} else {
    $time_zone = '+00.00';
}
$time_zone = str_replace('.', '', $time_zone);
$feed_name = mso_head_meta('title') . ' (' . tf('Последние комментарии') . ')';
$description = mso_head_meta('description');
$feed_url = getinfo('siteurl');
$language = 'en-ru';
$generator = 'MaxSite CMS (http://max-3000.com/)';
$comments = mso_get_comments(false, array('limit' => '20', 'order' => 'desc'));
if ($comments) {
    $pubdate = date('D, d M Y H:i:s ' . $time_zone, strtotime(mso_date_convert('Y-m-d H:i:s', $comments[0]['comments_date'])));
    echo '<' . '?xml version="1.0" encoding="utf-8"?' . '>';
    ?>

<rss version="2.0">
	<channel>
		<title><?php 
    echo $feed_name;
    ?>
</title>
		<link><?php 
    echo $feed_url;
    ?>
</link>