/** * Возвращает прямую ссылку на пункт меню по его типу и опции * @param string $linktype * @param string $linkid * @return string */ public function getMenuLink($linktype, $linkid) { $inDB = cmsDatabase::getInstance(); $menulink = ''; if ($linktype == 'component') { $menulink = '/' . $linkid; } if ($linktype == 'link') { $menulink = $linkid; } if ($linktype == 'category' || $linktype == 'content') { $this->loadModel('content'); $model = new cms_model_content(); switch ($linktype) { case 'category': $menulink = $model->getCategoryURL(null, $inDB->get_field('cms_category', "id='{$linkid}'", 'seolink')); break; case 'content': $menulink = $model->getArticleURL(null, $inDB->get_field('cms_content', "id='{$linkid}'", 'seolink')); break; } } if ($linktype == 'blog') { $this->loadModel('blogs'); $model = new cms_model_blogs(); $menulink = $model->getBlogURL($inDB->get_field('cms_blogs', "id='{$linkid}'", 'seolink')); } if ($linktype == 'video_cat') { $this->loadModel('video'); $model = cms_model_video::initModel(); $cat = $inDB->get_fields('cms_video_category', "id='{$linkid}'", 'id, seolink'); $menulink = $model->getCatLink($cat['seolink'], $cat['id']); } if ($linktype == 'uccat') { $menulink = '/catalog/' . $linkid; } if ($linktype == 'photoalbum') { $menulink = '/photos/' . $linkid; } return $menulink; }
function cmsTagItemLink($target, $item_id){ $inCore = cmsCore::getInstance(); $link = ''; switch ($target){ case 'content': $today = date("Y-m-d H:i:s"); $sql = "SELECT i.title as title, c.title as cat, i.seolink as seolink, c.seolink as cat_seolink FROM cms_content i INNER JOIN cms_category c ON c.id = i.category_id WHERE i.id = '$item_id' AND i.published = 1 AND i.is_arhive = 0 AND i.pubdate <= '$today' AND (i.is_end=0 OR (i.is_end=1 AND i.enddate >= '$today')) LIMIT 1"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="/'.$item['cat_seolink'].'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/'.$item['seolink'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'blogpost': $sql = "SELECT i.title as title, i.id as item_id, c.title as cat, c.id as cat_id, c.owner as owner, c.user_id user_id, i.seolink as seolink, c.seolink as bloglink FROM cms_blog_posts i LEFT JOIN cms_blogs c ON c.id = i.blog_id WHERE i.id = '$item_id' AND i.published = 1"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); if ($item['owner'] == 'club') { $item['cat'] = cmsCore::c('db')->get_field('cms_clubs','id='.$item['user_id'],'title'); } $link = '<a href="/blogs/'.$item['bloglink'].'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/blogs/'.$item['bloglink'].'/'.$item['seolink'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'photo': $sql = "SELECT i.title as title, i.id as item_id, c.title as cat, c.id as cat_id FROM cms_photo_files i LEFT JOIN cms_photo_albums c ON c.id = i.album_id WHERE i.id = '$item_id' AND i.published = 1"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="/photos/'.$item['cat_id'].'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/photos/photo'.$item['item_id'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'userphoto': $sql = "SELECT i.title as title, i.id as item_id, c.nickname as cat, c.id as cat_id, c.login as login FROM cms_user_photos i LEFT JOIN cms_users c ON c.id = i.user_id WHERE i.id = '$item_id'"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="'.cmsUser::getProfileURL($item['login']).'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/users/'.$item['cat_id'].'/photo'.$item['item_id'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'catalog': $sql = "SELECT i.title as title, i.id as item_id, c.title as cat, c.id as cat_id FROM cms_uc_items i LEFT JOIN cms_uc_cats c ON c.id = i.category_id WHERE i.id = '$item_id' AND i.published = 1"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="/catalog/'.$item['cat_id'].'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/catalog/item'.$item['item_id'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'video': $inCore->loadModel('video'); $model = cms_model_video::initModel(); $sql = "SELECT i.title as title, i.id as item_id, i.seolink as movie_seolink, c.title as cat_title, c.id as cat_id, c.seolink as cat_seolink FROM cms_video_movie i INNER JOIN cms_video_category c ON c.id = i.cat_id WHERE i.id = '$item_id'"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="'.$model->getCatLink($item['cat_seolink'], $item['cat_id']).'" class="tag_searchcat">'.$item['cat_title'].'</a> → '; $link .= '<a href="'.$model->getMovieLink($item['cat_seolink'].'/'.$item['movie_seolink'], $item['item_id']).'" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'shop': $sql = "SELECT i.title as title, i.seolink as seolink, c.title as cat, c.seolink as cat_seolink FROM cms_shop_items i LEFT JOIN cms_shop_cats c ON c.id = i.category_id WHERE i.id = '$item_id'"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="/shop/'.$item['cat_seolink'].'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/shop/'.$item['seolink'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; case 'maps': $sql = "SELECT i.title as title, i.seolink as seolink, c.title as cat, c.seolink as cat_seolink FROM cms_map_items i LEFT JOIN cms_map_cats c ON c.id = i.category_id WHERE i.id = '$item_id'"; $rs = cmsCore::c('db')->query($sql) ; if (cmsCore::c('db')->num_rows($rs)){ $item = cmsCore::c('db')->fetch_assoc($rs); $link = '<a href="/maps/'.$item['cat_seolink'].'" class="tag_searchcat">'.$item['cat'].'</a> → '; $link .= '<a href="/maps/'.$item['seolink'].'.html" class="tag_searchitem">'.$item['title'].'</a>'; } break; } return $link; }