本文整理汇总了PHP中cmsCore::includeComments方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::includeComments方法的具体用法?PHP cmsCore::includeComments怎么用?PHP cmsCore::includeComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::includeComments方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_comments
function smarty_function_comments($params, &$smarty) {
if (!$params['target']) { return false; }
if (!$params['target_id']) { return false; }
cmsCore::includeComments();
comments($params['target'], $params['target_id'], (is_array($params['labels']) ? $params['labels'] : array()), (isset($params['can_delete']) ? $params['can_delete'] : false));
return;
}
示例2: cmsSmartyComments
/**
* Вспомогательные функции
*/
function cmsSmartyComments($params)
{
if (!$params['target']) {
return false;
}
if (!$params['target_id']) {
return false;
}
cmsCore::includeComments();
comments($params['target'], $params['target_id'], is_array($params['labels']) ? $params['labels'] : array());
return;
}
示例3: fenom_function_comments
function fenom_function_comments($params)
{
if (!$params['target']) {
return false;
}
if (!$params['target_id']) {
return false;
}
cmsCore::includeComments();
comments($params['target'], $params['target_id'], is_array($params['labels']) ? $params['labels'] : array(), isset($params['can_delete']) ? $params['can_delete'] : false);
return true;
}
示例4: blogs
//.........这里部分代码省略.........
}
cmsCore::c('page')->addPathway($blog['title'], cmsCore::m('blogs')->getBlogURL($blog['seolink']));
cmsCore::c('page')->addPathway($post['title']);
cmsCore::c('page')->setTitle($post['pagetitle'] ? $post['pagetitle'] : $post['title']);
cmsCore::c('page')->setDescription($post['meta_desc'] ? $post['meta_desc'] : crop($post['content_html']));
cmsCore::c('page')->setKeywords($post['meta_keys'] ? $post['meta_keys'] : $post['title']);
if ($post['cat_id']){
$cat = cmsCore::c('blog')->getBlogCategory($post['cat_id']);
}
$post['tags'] = cmsTagBar('blogpost', $post['id']);
$is_author = (cmsCore::c('user')->id && cmsCore::c('user')->id == $post['user_id']);
// увеличиваем кол-во просмотров
if (!$is_author) {
cmsCore::c('db')->setFlag('cms_blog_posts', $post['id'], 'hits', $post['hits']+1);
}
cmsPage::initTemplate('components', 'com_blog_view_post')->
assign('post', $post)->
assign('blog', $blog)->assign('cat', $cat)->
assign('is_author', $is_author)->
assign('is_writer', cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id))->
assign('myblog', (cmsCore::c('user')->id && cmsCore::c('user')->id == $blog['user_id']))->
assign('is_admin', cmsCore::c('user')->is_admin)->
assign('karma_form', cmsKarmaForm('blogpost', $post['id'], $post['rating'], $is_author))->
assign('navigation', cmsCore::c('blog')->getPostNavigation($post['id'], $blog['id'], cmsCore::m('blogs'), $blog['seolink']))->
display();
if ($inCore->isComponentEnable('comments') && $post['comments']) {
cmsCore::includeComments();
comments('blog', $post['id'], array(), $is_author);
}
}
///////////////////////// УДАЛЕНИЕ ПОСТА ///////////////////////////////////
if ($inCore->do == 'delpost'){
if(!cmsCore::c('user')->id) { cmsCore::error404(); }
if(!cmsCore::isAjax()) { cmsCore::error404(); }
$post = cmsCore::c('blog')->getPost($post_id);
if (!$post){ cmsCore::halt(); }
$blog = cmsCore::c('blog')->getBlog($post['blog_id']);
if (!$blog) { cmsCore::halt(); }
$myblog = (cmsCore::c('user')->id == $blog['user_id']); // автор блога
$is_writer = cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id);
// если не его блог, пользователь не писатель и не админ
if (!$myblog && !$is_writer && !cmsCore::c('user')->is_admin ) { cmsCore::halt(); }
// проверяем является ли пользователь автором
if (!cmsCore::c('user')->is_admin && !$myblog && $post['user_id'] != cmsCore::c('user')->id) { cmsCore::halt(); }
if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); }
cmsCore::c('blog')->deletePost($post['id']);
if (cmsCore::c('user')->id != $post['user_id']){
cmsUser::sendMessage(USER_UPDATER, $post['user_id'], $_LANG['YOUR_POST'].' <b>«'.$post['title'].'»</b> '.$_LANG['WAS_DELETED_FROM_BLOG'].' <b>«<a href="'.cmsCore::m('blogs')->getBlogURL($blog['seolink']).'">'.$blog['title'].'</a>»</b>');
}
示例5: wishes
function wishes()
{
$inCore = cmsCore::getInstance();
$inPage = cmsPage::getInstance();
$inDB = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();
$user_id = $inUser->id;
//$inPage->addHeadJS('');
//$inPage->addHeadJS('');
global $_LANG;
$inCore->loadModel('wishes');
$model = new cms_model_wishes();
//Загрузка настроек встреч
$cfg = $inCore->loadComponentConfig('wishes');
// Проверяем включени ли компонент
if (!$cfg['component_enabled']) {
cmsCore::error404();
}
if (!isset($cfg['perpage'])) {
$cfg['perpage'] = 10;
}
if (!isset($cfg['on_main'])) {
$cfg['on_main'] = 5;
}
//Получаем параметры
$id = $inCore->request('id', 'int', 0);
$do = $inCore->request('do', 'str', 'view');
$page = $inCore->request('page', 'int', 1);
$pagetitle = "Потрібно - Допоможу";
$inPage->addPathway($pagetitle, '/wishes/all.html');
$types = array();
$sql = "select * from `cms_wishes_cat`";
$result = $inDB->query($sql);
$j = 1;
while ($tinfo = $inDB->fetch_assoc($result)) {
$types[$j]["1"] = $tinfo['class'];
$types[$j]["2"] = $tinfo['title'];
$j++;
}
$inPage->addHead('<link rel="stylesheet" href="/components/wishes/css/style.css">');
/***********************************************************/
if ($do == 'load') {
$n = $inCore->request('n', 'int', 1);
$page = $inCore->request('page', 'int', 1);
//echo $page." ".$n." дозагрузка данных<br/>";
$t = $types[$n];
$inf = $model->wish_type($n, $t, $user_id, $page, $active = 0, $types = array(), $cfg['on_main']);
echo $inf;
exit;
}
if ($do == 'delete') {
if ($model->is_author($user_id, $id) or $inUser->is_admin) {
$sql = "DELETE FROM `cms_wishes` WHERE `id` = " . $id . ";";
$result = $inDB->query($sql);
cmsCore::addSessionMessage("Успішно видалено!", 'success');
}
cmsCore::redirect('/wishes/');
}
if ($do == 'wish_item') {
$sql = "select * from `cms_wishes` where `published`='1' and `id`='" . $id . "' ";
//echo $sql;
$result = $inDB->query($sql);
$sinfo = $inDB->fetch_assoc($result);
$us = $inUser->loadUser($sinfo['user_id']);
$t = $types[$sinfo['type']];
$inPage->addPathway($t[2], '/wishes/type' . $sinfo['type'] . '.html');
$inPage->addPathway($sinfo['title'], '');
$inPage->setTitle($sinfo['title']);
echo "<h2><a href='/wishes/type" . $sinfo['type'] . ".html'>" . $t[2] . "</a> » " . $sinfo['title'] . "</h2>";
echo "<div style='font-size:11px;'><a href='/users/" . $us['login'] . "'>" . $us['nickname'] . "</a> | " . $inCore->dateformat($sinfo['datetime']) . "</div>";
if ($model->is_author($user_id, $id) or $inUser->is_admin) {
echo "<div style='float:right;'><a href='/wishes/delete" . $id . ".html'>Видалити</a></div>";
}
echo "\n\t\t\t<table width='100%'><tr><td valign='top' width='10%'>\n\t\t\t<a href='/users/" . $us['login'] . "'><img src='" . $us['imageurl'] . "' style='float:left;border-radius:10px;margin:0px 10px 10px 0px;' border='0' /></a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t<div style='padding:10px;margin-bottom:50px; background-color:#f2f0f0; border-bottom: 1px solid #DDDDDD;border-top: 1px solid #DDDDDD;'>\n\t\t\t" . $sinfo['info'] . "</div>\n\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t";
if ($inCore->isComponentInstalled('comments')) {
cmsCore::includeComments();
comments('wishes', $sinfo['id']);
}
}
/***********************************************************/
if ($do == 'add_item') {
$title = $inCore->request('title', 'str', '');
$info = $inCore->request('info', 'str', '');
$send = $inCore->request('send', 'str', '');
$type = $id;
$guest_info = $inUser->getGuestInfo();
$user_access = $inUser->id;
if ($user_access > 0) {
/**/
/**/
/**/
/**/
$inf = "0";
$success = "0";
$tr = strlen($title);
if ($send == "ok") {
if ($tr > 0) {
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$sql = "INSERT INTO `cms_wishes` (`id` ,\n`title` ,\n`info` ,\n`published` ,\n`datetime` ,\n`user_id` ,\n`rate` ,\n`type` ,\n`ip` ,\n`browser` \n)\nVALUES (NULL , '" . $title . "', '" . $info . "', '1', NOW(), '" . $user_id . "', '0', '" . $type . "', '" . $ip . "', '" . $browser . "'\n);";
//.........这里部分代码省略.........
示例6: clubs
//.........这里部分代码省略.........
if ($photo['description']) {
$inPage->setDescription(crop($photo['description']));
} else {
$inPage->setDescription($photo['title']);
}
} else {
$inPage->setDescription($photo['meta_desc']);
}
// ссылки вперед назад
$photo['nextid'] = $inDB->get_fields('cms_photo_files', 'id<'.$photo['id'].' AND album_id = '.$photo['album_id'], 'id, file, title', 'id DESC');
$photo['previd'] = $inDB->get_fields('cms_photo_files', 'id>'.$photo['id'].' AND album_id = '.$photo['album_id'], 'id, file, title', 'id ASC');
// кнопки голосования
$photo['karma_buttons'] = cmsKarmaButtons('club_photo', $photo['id'], $photo['rating'], $is_author);
// Обновляем кол-во просмотров
if(!$is_author){
$inDB->setFlag('cms_photo_files', $photo['id'], 'hits', $photo['hits']+1);
}
// выводим в шаблон
cmsPage::initTemplate('components', 'com_clubs_view_photo')->
assign('club', $club)->
assign('photo', $photo)->
assign('is_admin', $is_admin)->
assign('is_moder', $is_moder)->
assign('is_exists_original', (file_exists(PATH.'/images/photos/'. $photo['file'])))->
assign('is_author', $is_author)->
display();
//если есть, выводим комментарии
if ($photo['comments'] && $inCore->isComponentEnable('comments')) {
cmsCore::includeComments();
comments('club_photo', $photo['id'], array(), $is_author);
}
}
////////////////////////////// УДАЛИТЬ ФОТО ////////////////////////////////////
if ($do=='delete_photo'){
if(!$inUser->id) { return false; }
if(!cmsCore::isAjax()) { return false; }
if(!cmsUser::checkCsrfToken()) { return false; }
$photo = $inPhoto->getPhoto(cmsCore::request('photo_id', 'int', 0));
if (!$photo) { cmsCore::halt(); }
// получаем клуб
$club = $model->getClub($photo['auser_id']);
if(!$club) { cmsCore::halt(); }
// Инициализируем участников клуба
$model->initClubMembers($club['id']);
// права доступа
$is_admin = $inUser->is_admin || ($inUser->id == $club['admin_id']);
$is_moder = $model->checkUserRightsInClub('moderator');
// удалять могут только модераторы и администраторы
if(!$is_admin && !$is_moder) { cmsCore::halt(); }
$inPhoto->deletePhoto($photo, $model->initUploadClass());
cmsCore::addSessionMessage($_LANG['PHOTO_DELETED'], 'success');
示例7: round
$inPage->addPathway($photo['title']);
$photo['pubdate'] = cmsCore::dateFormat($photo['pubdate'], true, false, false);
$photo['genderlink'] = cmsUser::getGenderLink($usr['id'], $usr['nickname'], $photo['gender'], $usr['login']);
$photo['filesize'] = round(filesize(PATH . '/images/users/photos/medium/' . $photo['imageurl']) / 1024, 2);
//ссылки на предыдущую и следующую фотографии
$previd = $inDB->get_fields('cms_user_photos', "id>'{$photo['id']}' AND user_id = '{$usr['id']}' AND album_id='{$photo['album_id']}'", 'id, title, pubdate', 'id ASC');
$nextid = $inDB->get_fields('cms_user_photos', "id<'{$photo['id']}' AND user_id = '{$usr['id']}' AND album_id='{$photo['album_id']}'", 'id, title, pubdate', 'id DESC');
// Проверяем права доступа
$is_allow = cmsUser::checkUserContentAccess($photo['allow_who'], $id);
// Если видим фото, обновляем просмотры
if ($is_allow) {
$inDB->query("UPDATE cms_user_photos SET hits = hits + 1 WHERE id = " . $photo['id']);
}
cmsPage::initTemplate('components', 'com_users_photos_view')->assign('photo', $photo)->assign('bbcode', '[IMG]' . HOST . '/images/users/photos/medium/' . $photo['imageurl'] . '[/IMG]')->assign('previd', $previd)->assign('nextid', $nextid)->assign('usr', $usr)->assign('myprofile', $myprofile)->assign('is_admin', cmsUser::userIsAdmin($inUser->id))->assign('is_allow', $is_allow)->assign('tagbar', $is_allow ? cmsTagBar('userphoto', $photo['id']) : '')->display('com_users_photos_view.tpl');
if ($inCore->isComponentInstalled('comments') && $is_allow) {
cmsCore::includeComments();
comments('userphoto', $photo['id']);
}
}
//============================================================================//
//============================ Один фотоальбом ===============================//
//============================================================================//
if ($pdo == 'viewalbum') {
if (!$inUser->id && !$model->config['sw_guest']) {
cmsUser::goToLogin();
}
$usr = cmsUser::getShortUserData($login);
if (!$usr) {
cmsCore::error404();
}
$album_type = cmsCore::request('album_type', 'str', 'private');
示例8: content
//.........这里部分代码省略.........
}
}
$inPage->addPathway($article['title']);
// Мета теги KEYWORDS и DESCRIPTION
if ($article['meta_keys']) {
$inPage->setKeywords($article['meta_keys']);
} else {
if (mb_strlen($article['content']) > 30) {
$inPage->setKeywords(cmsCore::getKeywords(cmsCore::strClear($article['content'])));
}
}
if (mb_strlen($article['meta_desc'])) {
$inPage->setDescription($article['meta_desc']);
}
// Выполняем фильтры
$article['content'] = cmsCore::processFilters($article['content']);
// Разбивка статей на страницы
$pt_pages = array();
if (!empty($GLOBALS['pt'])) {
foreach ($GLOBALS['pt'] as $num => $page_title) {
$pt_pages[$num]['title'] = $page_title;
$pt_pages[$num]['url'] = $model->getArticleURL(null, $article['seolink'], $num + 1);
}
}
// Рейтинг статьи
if ($model->config['rating'] && $article['canrate']) {
$karma = cmsKarma('content', $article['id']);
$karma_points = cmsKarmaFormatSmall($karma['points']);
$btns = cmsKarmaButtonsText('content', $article['id'], $karma['points'], $is_author);
}
cmsPage::initTemplate('components', $article['tpl'])->assign('article', $article)->assign('cfg', $model->config)->assign('page', $page)->assign('is_pages', !empty($GLOBALS['pt']))->assign('pt_pages', $pt_pages)->assign('is_admin', $is_admin)->assign('is_editor', $is_editor)->assign('is_author', $is_author)->assign('is_author_del', $is_author_del)->assign('tagbar', cmsTagBar('content', $article['id']))->assign('karma_points', @$karma_points)->assign('karma_votes', @$karma['votes'])->assign('karma_buttons', @$btns)->display($article['tpl']);
// Комментарии статьи
if ($article['published'] && $article['comments'] && $inCore->isComponentInstalled('comments')) {
cmsCore::includeComments();
comments('article', $article['id'], array(), $is_author);
}
}
///////////////////////////////////// ADD ARTICLE //////////////////////////////////////////////////////////////////////////////////
if ($do == 'addarticle' || $do == 'editarticle') {
$is_add = cmsUser::isUserCan('content/add');
// может добавлять статьи
$is_auto_add = cmsUser::isUserCan('content/autoadd');
// добавлять статьи без модерации
if (!$is_add && !$is_auto_add) {
cmsCore::error404();
}
// Для редактирования получаем статью и проверяем доступ
if ($do == 'editarticle') {
// Получаем статью
$item = $model->getArticle($id);
if (!$item) {
cmsCore::error404();
}
$pubcats = array();
// доступ к редактированию админам, авторам и редакторам
if (!$inUser->is_admin && $item['user_id'] != $inUser->id && !($item['modgrp_id'] == $inUser->group_id && cmsUser::isUserCan('content/autoadd'))) {
cmsCore::error404();
}
}
// Для добавления проверяем не вводили ли мы данные ранее
if ($do == 'addarticle') {
$item = cmsUser::sessionGet('article');
if ($item) {
cmsUser::sessionDel('article');
}
// Категории, в которые разрешено публиковать
示例9: photos
function photos()
{
$inCore = cmsCore::getInstance();
$inPage = cmsPage::getInstance();
$inDB = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();
cmsCore::loadClass('photo');
$inPhoto = cmsPhoto::getInstance();
global $_LANG;
$model = new cms_model_photos();
$pagetitle = $inCore->menuTitle();
$root_album_id = $inDB->getNsRootCatId('cms_photo_albums');
$id = cmsCore::request('id', 'int', $root_album_id);
$do = $inCore->do;
$page = cmsCore::request('page', 'int', 1);
$inPage->addPathway($inCore->getComponentTitle(), '/photos');
// только авторизованные пользуются js
if ($inUser->id) {
$inPage->addHeadJS('components/photos/js/photos.js');
$inPage->addHeadJsLang(array('NO_PUBLISH', 'EDIT_PHOTO', 'YOU_REALLY_DELETE_PHOTO', 'MOVE_PHOTO'));
}
$inPage->setDescription($model->config['meta_desc'] ? $model->config['meta_desc'] : $pagetitle);
$inPage->setKeywords($model->config['meta_keys'] ? $model->config['meta_keys'] : $pagetitle);
/////////////////////////////// Просмотр альбома ///////////////////////////////////////////////////////////////////////////////////////////
if ($do == 'view') {
$album = $inDB->getNsCategory('cms_photo_albums', $id, null);
if (!$album && $inCore->menuId() !== 1) {
cmsCore::error404();
}
// Неопубликованные альбомы показываем только админам
if (!$album['published'] && !$inUser->is_admin) {
cmsCore::error404();
}
$album = cmsCore::callEvent('GET_PHOTO_ALBUM', $album);
// если не корневой альбом
if ($album['id'] != $root_album_id) {
$path_list = $inDB->getNsCategoryPath('cms_photo_albums', $album['NSLeft'], $album['NSRight'], 'id, title, NSLevel');
if ($path_list) {
foreach ($path_list as $pcat) {
$inPage->addPathway($pcat['title'], '/photos/' . $pcat['id']);
}
}
$pagetitle = $pagetitle && $inCore->isMenuIdStrict() ? $pagetitle : $album['title'] . ' - ' . $_LANG['PHOTOGALLERY'];
$inPage->setTitle($album['pagetitle'] ? $album['pagetitle'] : $pagetitle);
} else {
$pagetitle = $pagetitle && $inCore->isMenuIdStrict() ? $pagetitle : $_LANG['PHOTOGALLERY'];
$inPage->setTitle($pagetitle);
$album['title'] = $pagetitle;
}
//Формируем подкатегории альбома
$inDB->orderBy('f.' . $model->config['orderby'], $model->config['orderto']);
$subcats = $inPhoto->getAlbums($album['id']);
// Сортировка фотографий
$orderby = cmsCore::getSearchVar('orderby', $album['orderby']);
$orderto = cmsCore::getSearchVar('orderto', $album['orderto']);
if (!in_array($orderby, array('title', 'pubdate', 'rating', 'hits'))) {
$orderby = $album['orderby'];
}
if (!in_array($orderto, array('desc', 'asc'))) {
$orderto = $album['orderto'];
}
// Устанавливаем альбом
$inPhoto->whereAlbumIs($album['id']);
// Общее количество фото по заданным выше условиям
$total = $inPhoto->getPhotosCount($inUser->is_admin);
//устанавливаем сортировку
$inDB->orderBy('f.' . $orderby, $orderto);
//устанавливаем номер текущей страницы и кол-во фото на странице
$inDB->limitPage($page, $album['perpage']);
$photos = $inPhoto->getPhotos($inUser->is_admin, $album['showdate']);
if (!$photos && $page > 1) {
cmsCore::error404();
}
if ($album['id'] != $root_album_id) {
// meta description
if ($album['meta_desc']) {
$meta_desc = $album['meta_desc'];
} elseif (mb_strlen(strip_tags($album['description'])) >= 250) {
$meta_desc = crop($album['description']);
} else {
$meta_desc = $album['title'];
}
$inPage->setDescription($meta_desc);
// meta keywords
if ($album['meta_keys']) {
$meta_keys = $album['meta_keys'];
} elseif ($photos) {
foreach ($photos as $p) {
$k[] = $p['title'];
}
$meta_keys = implode(', ', $k);
} else {
$meta_keys = $album['title'];
}
$inPage->setKeywords($meta_keys);
}
cmsPage::initTemplate('components', 'com_photos_view')->assign('root_album_id', $root_album_id)->assign('cfg', $model->config)->assign('album', $album)->assign('can_add_photo', $album['public'] && $inUser->id || $inUser->is_admin)->assign('subcats', $subcats)->assign('photos', $photos)->assign('pagebar', cmsPage::getPagebar($total, $page, $album['perpage'], '/photos/' . $album['id'] . '-%page%'))->assign('total', $total)->assign('orderby', $orderby)->assign('orderto', $orderto)->display('com_photos_view.tpl');
// если есть фотограйии в альбоме и включены комментарии в альбоме, то показываем их
if ($album['is_comments'] && $photos && $inCore->isComponentInstalled('comments')) {
cmsCore::includeComments();
//.........这里部分代码省略.........
示例10: catalog
//.........这里部分代码省略.........
} else {
if ($makelink) {
$field = $model->getUCSearchLink($cat['id'], $field);
}
}
}
$fields[stripslashes($value)] = stripslashes($field);
}
}
}
if ($cat['view_type']=='shop'){
$item['price'] = number_format(shopDiscountPrice($item['id'], $item['category_id'], $item['price']), 2, '.', ' ');
}
$user = $inDB->get_fields('cms_users', "id='{$item['user_id']}'", 'login, nickname');
$getProfileLink = cmsUser::getProfileLink($user['login'], $user['nickname']);
if ($cat['is_ratings']){
$ratingForm = ratingForm($ratingdata, $item['id']);
}
cmsPage::initTemplate('components', 'com_catalog_item')->
assign('shopCartLink', (isset($shopCartLink) ? $shopCartLink : ''))->
assign('getProfileLink', $getProfileLink)->
assign('tagline', tagLine($item['tags'], $cat['id']))->
assign('item', $item)->
assign('cat', $cat)->
assign('fields', $fields)->
assign('ratingForm', (isset($ratingForm) ? $ratingForm : ''))->
display('com_catalog_item.tpl');
if ($item['is_comments'] && $inCore->isComponentEnable('comments')) {
cmsCore::includeComments();
comments('catalog', $item['id'], array(), ($inUser->id == $item['user_id']));
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// S H O P /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// ADD TO CART /////////////////////////////////////////////////////////////////////////////
if ($do == 'addcart'){
shopAddToCart($id, 1);
$inCore->redirect('/catalog/viewcart.html');
}
///////////////////////// VIEW CART /////////////////////////////////////////////////////////////////////////////
if ($do == 'viewcart'){
shopCart();
}
///////////////////////// DELETE FROM CART /////////////////////////////////////////////////////////////////////////////
if ($do == 'cartremove'){
shopRemoveFromCart($id);
$inCore->redirectBack();
}
///////////////////////// CLEAR CART /////////////////////////////////////////////////////////////////////////////
if ($do == 'clearcart'){
shopClearCart();
$inCore->redirectBack();
}
///////////////////////// CLEAR CART /////////////////////////////////////////////////////////////////////////////
示例11: blog
//.........这里部分代码省略.........
// право просмотра блога
if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])) {
cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'] . '<br>' . $_LANG['CLOSED_BLOG_TEXT'], 'error');
cmsCore::redirect('/blog');
}
// право просмотра самого поста
if (!cmsUser::checkUserContentAccess($post['allow_who'], $post['user_id'])) {
cmsCore::addSessionMessage($_LANG['CLOSED_POST'] . '<br>' . $_LANG['CLOSED_POST_TEXT'], 'error');
cmsCore::redirect($model->getBlogURL());
}
if ($inUser->id) {
$inPage->addHeadJS('components/blog/js/blog.js');
}
$inPage->addPathway($blog['title'], $model->getBlogURL());
$inPage->setTitle($post['title']);
$inPage->addPathway($post['title']);
$inPage->setDescription($post['title']);
if ($post['cat_id']) {
$cat = $inBlog->getBlogCategory($post['cat_id']);
}
$post['tags'] = cmsTagBar('blogpost', $post['id']);
$is_author = $inUser->id && $inUser->id == $post['user_id'];
$smarty = $inCore->initSmarty('components', 'com_blog_view_post.tpl');
$smarty->assign('post', $post);
$smarty->assign('blog', $blog);
$smarty->assign('cat', $cat);
$smarty->assign('is_author', $is_author);
$smarty->assign('myblog', $inUser->id && $inUser->id == $blog['user_id']);
$smarty->assign('is_admin', $inUser->is_admin);
$smarty->assign('karma_form', cmsKarmaForm('blogpost', $post['id'], $post['rating'], $is_author));
$smarty->assign('navigation', $inBlog->getPostNavigation($post['id'], $blog['id'], $model, $blog['seolink']));
$smarty->display('com_blog_view_post.tpl');
if ($inCore->isComponentInstalled('comments') && $post['comments']) {
cmsCore::includeComments();
comments('blog', $post['id']);
}
}
///////////////////////// УДАЛЕНИЕ ПОСТА /////////////////////////////////////////////////////////////////////////////
if ($do == 'delpost') {
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
cmsCore::halt();
}
if (!$inUser->id) {
cmsCore::halt();
}
$post = $inBlog->getPost($post_id);
if (!$post) {
cmsCore::halt();
}
$blog = $inBlog->getBlog($post['blog_id']);
if (!$blog) {
cmsCore::halt();
}
// удалять могут авторы, авторы блога, админы
if ($blog['user_id'] != $inUser->id && !$inUser->is_admin && $inUser->id != $post['user_id']) {
cmsCore::halt();
}
if (!cmsCore::validateForm()) {
cmsCore::halt();
}
$inBlog->deletePost($post['id']);
if ($inUser->id != $post['user_id']) {
cmsUser::sendMessage(USER_UPDATER, $post['user_id'], $_LANG['YOUR_POST'] . ' <b>«' . $post['title'] . '»</b> ' . $_LANG['WAS_DELETED_FROM_BLOG'] . ' <b>«<a href="' . $model->getBlogURL() . '">' . $blog['title'] . '</a>»</b>');
}
cmsCore::addSessionMessage($_LANG['POST_IS_DELETED'], 'success');
cmsUser::clearCsrfToken();