本文整理汇总了PHP中cmsDatabase类的典型用法代码示例。如果您正苦于以下问题:PHP cmsDatabase类的具体用法?PHP cmsDatabase怎么用?PHP cmsDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cmsDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mod_cart
function mod_cart($module_id, $cfg)
{
$inDB = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();
cmsCore::includeFile('components/catalog/includes/shopcore.php');
$sid = session_id();
$items = array();
$total_summ = 0;
$user_sql = $inUser->id ? "c.user_id='{$inUser->id}'" : "c.session_id='{$sid}'";
$sql = "SELECT i.title, i.price, i.category_id, i.id, c.itemscount\n FROM cms_uc_cart c\n INNER JOIN cms_uc_items i ON i.id = c.item_id\n WHERE {$user_sql}";
$result = $inDB->query($sql);
$items_count = $inDB->num_rows($result);
if ($items_count) {
while ($con = $inDB->fetch_assoc($result)) {
$price = shopDiscountPrice($con['id'], $con['category_id'], $con['price']);
$totalcost = $con['itemscount'] * $price;
$total_summ += $totalcost;
$con['price'] = number_format($price, 2, '.', ' ');
$con['totalcost'] = number_format($totalcost, 2, '.', ' ');
$items[] = $con;
}
}
cmsPage::initTemplate('modules', 'mod_cart')->assign('cfg', $cfg)->assign('items_count', $items_count)->assign('total_summ', number_format($total_summ, 2, '.', ' '))->assign('items', $items)->display('mod_cart.tpl');
return true;
}
示例2: mod_dt_newsslider
function mod_dt_newsslider($module_id, $cfg)
{
$inDB = cmsDatabase::getInstance();
cmsCore::loadModel('content');
$model = new cms_model_content();
if (!isset($cfg['cat_id'])) {
$cfg['cat_id'] = 1;
}
if ($cfg['cat_id']) {
if (!$cfg['subs']) {
$model->whereCatIs($cfg['cat_id']);
} else {
$rootcat = $inDB->getNsCategory('cms_category', $cfg['cat_id']);
if (!$rootcat) {
return false;
}
$model->whereThisAndNestedCats($rootcat['NSLeft'], $rootcat['NSRight']);
}
}
$inDB->orderBy('con.ordering', 'ASC');
$inDB->limit($cfg['newscount']);
$slider_list = $model->getArticlesList();
if (!$slider_list) {
return false;
}
cmsPage::initTemplate('modules', 'mod_dt_newsslider')->assign('slider', $slider_list)->assign('cfg', $cfg)->assign('module_id', $module_id)->display('mod_dt_newsslider.tpl');
return true;
}
示例3: mod_latest_faq
function mod_latest_faq($module_id, $cfg)
{
$inDB = cmsDatabase::getInstance();
if (!isset($cfg['newscount'])) {
$cfg['newscount'] = 2;
}
if (!isset($cfg['cat_id'])) {
$cfg['cat_id'] = 0;
}
if (!isset($cfg['maxlen'])) {
$cfg['maxlen'] = 120;
}
if ($cfg['cat_id']) {
$catsql = 'AND category_id = ' . $cfg['cat_id'];
} else {
$catsql = '';
}
$sql = "SELECT *\n FROM cms_faq_quests\n WHERE published = 1 " . $catsql . "\n ORDER BY pubdate DESC\n LIMIT " . $cfg['newscount'];
$result = $inDB->query($sql);
$faq = array();
if ($inDB->num_rows($result)) {
while ($con = $inDB->fetch_assoc($result)) {
$con['date'] = cmsCore::dateFormat($con['pubdate']);
$con['href'] = '/faq/quest' . $con['id'] . '.html';
$faq[] = $con;
}
}
cmsPage::initTemplate('modules', 'mod_latest_faq')->assign('faq', $faq)->assign('cfg', $cfg)->display('mod_latest_faq.tpl');
return true;
}
示例4: mod_calendar_eventview
function mod_calendar_eventview($module_id)
{
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$DB = cmsDatabase::getInstance();
$cfg = $inCore->loadComponentConfig('calendar');
if ($inUser->id != 0 and $cfg['calendar_module'] == "user") {
//Запрос к БД
$sql = "\r\n\tSELECT cms_events.* ,\r\n\tcms_events_category.tx,\r\n\tcms_events_category.bg\r\n\tFROM cms_events \r\n\tLEFT JOIN cms_events_signup ON cms_events.id=cms_events_signup.event_id \r\n\tLEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\r\n\tWHERE \r\n\tcms_events.start_time > " . time() . " AND \r\n\tcms_events.author_id = " . $inUser->id . " OR \r\n\tcms_events_signup.user_id = " . $inUser->id . " AND \r\n\tcms_events.author_id <> " . $inUser->id . " AND \r\n\tcms_events.start_time > " . time() . " \r\n\tGROUP BY cms_events.id ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count'];
} else {
$sql = "SELECT cms_events.*,\r\n\t cms_events_category.tx,\r\n\t cms_events_category.bg\r\n\t FROM cms_events\r\n\t LEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\t \r\n\t WHERE cms_events.`type` = 'public' \r\n\t AND cms_events.start_time > " . time() . " \r\n\t ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count'];
}
$result = $DB->query($sql);
if ($DB->error()) {
return false;
}
$events = array();
while ($event = $DB->fetch_assoc($result)) {
if ($event['author_id'] == $inUser->id) {
$event['time'] == "";
}
if ($event['category_id'] == 0) {
$event['bg'] = '#C3BCB9';
$event['tx'] = '#000000';
}
$events[] = $event;
}
$smarty = $inCore->initSmarty('modules', 'mod_calendar_eventview.tpl');
$smarty->assign('events', $events);
$smarty->display('mod_calendar_eventview.tpl');
return true;
}
示例5: mod_forum
function mod_forum($mod, $cfg)
{
$inDB = cmsDatabase::getInstance();
$default_cfg = array('shownum' => 4, 'cat_id' => 0, 'forum_id' => 0, 'subs' => 0, 'show_hidden' => 0, 'show_pinned' => 0, 'showtext' => 1, 'showforum' => 0, 'order' => 'pubdate');
$cfg = array_merge($default_cfg, $cfg);
cmsCore::loadModel('forum');
$model = new cms_model_forum();
$inDB->addJoin('INNER JOIN cms_forums f ON f.id = t.forum_id');
$inDB->addSelect('f.title as forum_title');
if ($cfg['cat_id']) {
$model->whereForumCatIs($cfg['cat_id']);
}
if ($cfg['forum_id']) {
if ($cfg['subs']) {
$forum = $model->getForum($cfg['forum_id']);
if (!$forum) {
return false;
}
$model->whereThisAndNestedForum($forum['NSLeft'], $forum['NSRight']);
} else {
$model->whereForumIs($cfg['forum_id']);
}
}
if (!$cfg['show_hidden']) {
$model->wherePublicThreads();
}
if ($cfg['show_pinned']) {
$model->wherePinnedThreads();
}
$inDB->orderBy('t.' . $cfg['order'], 'DESC');
$inDB->limit($cfg['shownum']);
$threads = $model->getThreads();
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('threads', $threads)->assign('cfg', $cfg)->display($cfg['tpl']);
return true;
}
示例6: mod_bestcontent
function mod_bestcontent($mod, $cfg)
{
$inDB = cmsDatabase::getInstance();
cmsCore::loadModel('content');
$model = new cms_model_content();
if (!isset($cfg['shownum'])) {
$cfg['shownum'] = 5;
}
if (!isset($cfg['subs'])) {
$cfg['subs'] = 1;
}
if (!isset($cfg['cat_id'])) {
$cfg['cat_id'] = 1;
}
$inDB->where("con.canrate = 1");
if ($cfg['cat_id']) {
if (!$cfg['subs']) {
//выбираем из категории
$model->whereCatIs($cfg['cat_id']);
} else {
//выбираем из категории и подкатегорий
$rootcat = $inDB->getNsCategory('cms_category', $cfg['cat_id']);
if (!$rootcat) {
return false;
}
$model->whereThisAndNestedCats($rootcat['NSLeft'], $rootcat['NSRight']);
}
}
$inDB->orderBy('con.rating', 'DESC');
$inDB->limitPage(1, $cfg['shownum']);
$content_list = $model->getArticlesList();
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('articles', $content_list)->assign('cfg', $cfg)->display($cfg['tpl']);
return true;
}
示例7: mod_actions
function mod_actions(array $mod, $cfg)
{
$inDB = cmsDatabase::getInstance();
$inActions = cmsActions::getInstance();
global $_LANG;
if (!isset($cfg['show_target'])) {
$cfg['show_target'] = 1;
}
if (!isset($cfg['limit'])) {
$cfg['limit'] = 15;
}
if (!isset($cfg['show_link'])) {
$cfg['show_link'] = 1;
}
if (!isset($cfg['action_types'])) {
echo $_LANG['MODULE_NOT_CONFIGURED'];
return true;
}
if (!$cfg['show_target']) {
$inActions->showTargets(false);
}
$inActions->onlySelectedTypes($cfg['action_types']);
$inDB->limitIs($cfg['limit']);
$actions = $inActions->getActionsLog();
if (!$actions) {
return false;
}
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('actions', $actions)->assign('cfg', $cfg)->assign('user_id', cmsUser::getInstance()->id)->display($cfg['tpl']);
return true;
}
示例8: __construct
function __construct()
{
$this->inDB = cmsDatabase::getInstance();
$inCore = cmsCore::getInstance();
$cfg = $inCore->loadComponentConfig('pogoda');
$this->city_id = $cfg['city_id'];
}
示例9: __construct
function __construct(){
$this->inDB = cmsDatabase::getInstance();
$this->inCore = cmsCore::getInstance();
$this->config = $this->inCore->loadComponentConfig('users');
cmsCore::loadLanguage('components/users');
cmsCore::loadClass('form');
}
示例10: mod_category
function mod_category($mod, $cfg)
{
$inDB = cmsDatabase::getInstance();
cmsCore::loadModel('content');
$model = new cms_model_content();
if (!isset($cfg['category_id'])) {
$cfg['category_id'] = 0;
}
if (!isset($cfg['show_subcats'])) {
$cfg['show_subcats'] = 1;
}
if (!isset($cfg['expand_all'])) {
$cfg['expand_all'] = 1;
}
$rootcat = $inDB->getNsCategory('cms_category', $cfg['category_id']);
if (!$rootcat) {
return false;
}
$subcats_list = $model->getSubCats($rootcat['id'], $cfg['show_subcats'], $rootcat['NSLeft'], $rootcat['NSRight']);
if (!$subcats_list) {
return false;
}
$current_seolink = urldecode(cmsCore::request('seolink', 'str', ''));
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('cfg', $cfg)->assign('current_seolink', $current_seolink)->assign('subcats_list', $subcats_list)->display($cfg['tpl']);
return true;
}
示例11: upgrade_component_calendar
function upgrade_component_calendar()
{
$inCore = cmsCore::getInstance();
$inDB = cmsDatabase::getInstance();
$inDB->query("ALTER TABLE `cms_events` ADD `hide` INT NOT NULL ;");
return true;
}
示例12: __construct
public function __construct()
{
$this->inDB = cmsDatabase::getInstance();
$this->config = cmsCore::getInstance()->loadComponentConfig('clubs');
cmsCore::loadLanguage('components/clubs');
cmsCore::loadLib('karma');
}
示例13: mod_clubs
function mod_clubs($module_id, $cfg)
{
$inDB = cmsDatabase::getInstance();
if (!isset($cfg['count'])) {
$cfg['count'] = 5;
}
if (!isset($cfg['type'])) {
$cfg['type'] = 'id';
}
if (!isset($cfg['vip_on_top'])) {
$cfg['vip_on_top'] = 1;
}
cmsCore::loadModel('clubs');
$model = new cms_model_clubs();
if ($cfg['vip_on_top']) {
$inDB->orderBy('is_vip', 'DESC, c.' . $cfg['type'] . ' DESC');
} else {
$inDB->orderBy('c.' . $cfg['type'], 'DESC');
}
$inDB->limit($cfg['count']);
$clubs = $model->getClubs();
if (!$clubs) {
return false;
}
cmsPage::initTemplate('modules', 'mod_clubs')->assign('clubs', $clubs)->display('mod_clubs.tpl');
return true;
}
示例14: mod_user_friend
function mod_user_friend($mod, $cfg)
{
$inDB = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();
if (!$inUser->id) {
return false;
}
if ($cfg['view_type'] == 'table') {
$sql = "SELECT\r\n CASE\r\n WHEN f.from_id = {$inUser->id}\r\n THEN f.to_id\r\n WHEN f.to_id = {$inUser->id}\r\n THEN f.from_id\r\n END AS user_id, u.login, u.nickname, u.is_deleted, p.imageurl\r\n FROM cms_user_friends f\r\n INNER JOIN cms_online o ON o.user_id = CASE WHEN f.from_id = {$inUser->id} THEN f.to_id WHEN f.to_id = {$inUser->id} THEN f.from_id END\r\n LEFT JOIN cms_users u ON u.id = o.user_id\r\n LEFT JOIN cms_user_profiles p ON p.user_id = u.id\r\n WHERE (from_id = {$inUser->id} OR to_id = {$inUser->id}) AND is_accepted =1 LIMIT " . $cfg['limit'];
} else {
$sql = "SELECT\r\n CASE\r\n WHEN f.from_id = {$inUser->id}\r\n THEN f.to_id\r\n WHEN f.to_id = {$inUser->id}\r\n THEN f.from_id\r\n END AS user_id, u.login, u.nickname\r\n FROM cms_user_friends f\r\n INNER JOIN cms_online o ON o.user_id = CASE WHEN f.from_id = {$inUser->id} THEN f.to_id WHEN f.to_id = {$inUser->id} THEN f.from_id END\r\n LEFT JOIN cms_users u ON u.id = o.user_id\r\n WHERE (from_id = {$inUser->id} OR to_id = {$inUser->id}) AND is_accepted =1 LIMIT " . $cfg['limit'];
}
$result = $inDB->query($sql);
$total = $inDB->num_rows($result);
if ($total) {
$friends = array();
while ($friend = $inDB->fetch_assoc($result)) {
$friend['avatar'] = $cfg['view_type'] == 'table' ? cmsUser::getUserAvatarUrl($friend['user_id'], 'small', $friend['imageurl'], $friend['is_deleted']) : false;
$friend['user_link'] = cmsUser::getProfileLink($friend['login'], $friend['nickname']);
$friends[$friend['user_id']] = $friend;
}
}
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('friends', $friends)->assign('total', $total)->assign('cfg', $cfg)->display($cfg['tpl']);
return true;
}
示例15: search_blogs
function search_blogs($query, $look)
{
$inDB = cmsDatabase::getInstance();
$searchModel = cms_model_search::initModel();
global $_LANG;
$sql = "SELECT con.*, cat.title cat_title, cat.id cat_id, cat.owner owner, cat.user_id user_id, cat.seolink as bloglink\n\t\t\tFROM cms_blog_posts con\n\t\t\tINNER JOIN cms_blogs cat ON cat.id = con.blog_id AND cat.allow_who = 'all' AND cat.owner = 'user'\n\t\t\tWHERE MATCH(con.title, con.content) AGAINST ('{$query}' IN BOOLEAN MODE) AND con.published = 1 LIMIT 100";
$result = $inDB->query($sql);
if ($inDB->num_rows($result)) {
cmsCore::loadLanguage('components/blogs');
cmsCore::loadModel('blogs');
$model = new cms_model_blogs();
while ($item = $inDB->fetch_assoc($result)) {
$result_array = array();
$result_array['link'] = $model->getPostURL($item['bloglink'], $item['seolink']);
$result_array['place'] = $_LANG['BLOG'] . ' «' . $item['cat_title'] . '»';
$result_array['placelink'] = $model->getBlogURL($item['bloglink']);
$result_array['description'] = $searchModel->getProposalWithSearchWord($item['content_html']);
$result_array['title'] = $item['title'];
$result_array['pubdate'] = $item['pubdate'];
$result_array['session_id'] = session_id();
$searchModel->addResult($result_array);
}
}
return;
}