本文整理汇总了PHP中EasyBlogHelper::accessNestedCategoriesId方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyBlogHelper::accessNestedCategoriesId方法的具体用法?PHP EasyBlogHelper::accessNestedCategoriesId怎么用?PHP EasyBlogHelper::accessNestedCategoriesId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyBlogHelper
的用法示例。
在下文中一共展示了EasyBlogHelper::accessNestedCategoriesId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tmpl = null)
{
$config = EasyBlogHelper::getConfig();
$id = JRequest::getCmd('id', '0');
$category = EasyBlogHelper::getTable('Category', 'Table');
$category->load($id);
// private category shouldn't allow to access.
$privacy = $category->checkPrivacy();
if (!$privacy->allowed) {
return;
}
$catIds = array();
$catIds[] = $category->id;
EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
$model = $this->getModel('Blog');
$posts = $model->getBlogsBy('category', $catIds);
$weever = EasyBlogHelper::getHelper('Weever')->getMainFeed();
$weever->set('description', JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->title)));
$weever->set('url', EasyBlogRouter::getRoutedUrl('index.php?option=com_easyblog&view=categories&id=' . $id . '&format=weever', false, true));
$weever->set('thisPage', 1);
$weever->set('lastPage', 1);
if ($posts) {
foreach ($posts as $post) {
$blog = EasyBlogHelper::getTable('Blog');
$blog->load($post->id);
$weever->addChild($blog);
}
}
$weever->toJSON(true, JRequest::getVar('callback'));
}
示例2: get
public function get()
{
$input = JFactory::getApplication()->input;
$model = EasyBlogHelper::getModel('Blog');
$category = EasyBlogHelper::getTable('Category', 'Table');
$id = $input->get('id', null, 'INT');
$search = $input->get('search', null, 'STRING');
$posts = array();
if (!isset($id)) {
$categoriesmodel = EasyBlogHelper::getModel('Categories');
$categories = $categoriesmodel->getCategoryTree('ordering');
$this->plugin->setResponse($categories);
return;
}
$category->load($id);
// private category shouldn't allow to access.
$privacy = $category->checkPrivacy();
if (!$category->id || !$privacy->allowed) {
$this->plugin->setResponse($this->getErrorResponse(404, 'Category not found'));
return;
}
$catIds = array();
$catIds[] = $category->id;
EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
$sorting = $this->plugin->params->get('sorting', 'latest');
$rows = $model->getBlogsBy('category', $catIds, $sorting, 0, EBLOG_FILTER_PUBLISHED, $search);
foreach ($rows as $k => $v) {
$item = EasyBlogHelper::getHelper('SimpleSchema')->mapPost($v, '', 100, array('text'));
$item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
$posts[] = $item;
}
$this->plugin->setResponse($posts);
}
示例3: _getParentIdsWithPost
function _getParentIdsWithPost($accessibleCatsIds = array())
{
$db = EasyBlogHelper::db();
$my = JFactory::getUser();
$query = 'select * from `#__easyblog_category`';
$query .= ' where `published` = 1';
$query .= ' and `parent_id` = 0';
if (!empty($accessibleCatsIds)) {
$catAccessQuery = ' `id` IN(';
if (!is_array($accessibleCatsIds)) {
$accessibleCatsIds = array($accessibleCatsIds);
}
for ($i = 0; $i < count($accessibleCatsIds); $i++) {
$catAccessQuery .= $db->Quote($accessibleCatsIds[$i]->id);
if (next($accessibleCatsIds) !== false) {
$catAccessQuery .= ',';
}
}
$catAccessQuery .= ')';
$query .= ' and ' . $catAccessQuery;
}
$db->setQuery($query);
$result = $db->loadObjectList();
$validCat = array();
if (count($result) > 0) {
for ($i = 0; $i < count($result); $i++) {
$item =& $result[$i];
$item->childs = null;
EasyBlogHelper::buildNestedCategories($item->id, $item);
$catIds = array();
$catIds[] = $item->id;
EasyBlogHelper::accessNestedCategoriesId($item, $catIds);
$item->cnt = $this->getTotalPostCount($catIds);
if ($item->cnt > 0) {
$validCat[] = $item->id;
}
}
}
return $validCat;
}
示例4: getPrivateCategories
public static function getPrivateCategories()
{
$db = EasyBlogHelper::db();
$my = JFactory::getUser();
$excludeCats = array();
$catQuery = '';
// get all private categories id
if ($my->id == 0) {
$catQuery = 'select distinct a.`id`, a.`private`';
$catQuery .= ' from `#__easyblog_category` as a';
$catQuery .= ' left join `#__easyblog_category_acl` as b on a.`id` = b.`category_id` and b.`acl_id` = ' . $db->Quote(CATEGORY_ACL_ACTION_VIEW);
$catQuery .= ' where a.`private` != ' . $db->Quote('0');
$gid = array();
$gids = '';
if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
$gid = JAccess::getGroupsByUser(0, false);
} else {
$gid = EasyBlogHelper::getUserGids();
}
if (count($gid) > 0) {
foreach ($gid as $id) {
$gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id);
}
$catQuery .= ' and b.`category_id` NOT IN (';
$catQuery .= ' SELECT c.category_id FROM `#__easyblog_category_acl` as c ';
$catQuery .= ' WHERE c.acl_id = ' . $db->Quote(CATEGORY_ACL_ACTION_VIEW);
$catQuery .= ' AND c.content_id IN (' . $gids . ') )';
}
} else {
$gid = EasyBlogHelper::getUserGids();
$gids = '';
if (count($gid) > 0) {
foreach ($gid as $id) {
$gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id);
}
}
$catQuery = 'select id from `#__easyblog_category` as a';
$catQuery .= ' where not exists (';
$catQuery .= ' select b.category_id from `#__easyblog_category_acl` as b';
$catQuery .= ' where b.category_id = a.id and b.`acl_id` = ' . $db->Quote(CATEGORY_ACL_ACTION_VIEW);
$catQuery .= ' and b.type = ' . $db->Quote('group');
$catQuery .= ' and b.content_id IN (' . $gids . ')';
$catQuery .= ' )';
$catQuery .= ' and a.`private` = ' . $db->Quote(CATEGORY_PRIVACY_ACL);
}
if (!empty($catQuery)) {
$db->setQuery($catQuery);
$result = $db->loadObjectList();
for ($i = 0; $i < count($result); $i++) {
$item =& $result[$i];
$item->childs = null;
EasyBlogHelper::buildNestedCategories($item->id, $item);
$catIds = array();
$catIds[] = $item->id;
EasyBlogHelper::accessNestedCategoriesId($item, $catIds);
$excludeCats = array_merge($excludeCats, $catIds);
}
}
return $excludeCats;
}
示例5: onAlbumPrepare
/**
* Plugin that returns the object list for DJ-Mediatools album
*
* Each object must contain following properties (mandatory): title, description, image
* Optional properties: link, target (_blank or _self), alt (alt attribute for image)
*
* @param object The album params
*/
public function onAlbumPrepare(&$source, &$params)
{
// Lets check the requirements
$check = $this->onCheckRequirements($source);
if (is_null($check) || is_string($check)) {
return null;
}
$app = JFactory::getApplication();
$default_image = $params->get('plg_easyblog_image');
$path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php';
if (!JFile::exists($path)) {
return null;
}
require_once $path;
require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php';
JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
$mparams = new JRegistry();
$count = $params->get('max_images');
$sort = array();
$sort[0] = $params->get('plg_easyblog_order');
$sort[1] = $params->get('plg_easyblog_order_dir');
$featured = $params->get('plg_easyblog_usefeatured');
$type = 'latest';
$model = EasyBlogHelper::getModel('Blog');
$categories = EasyBlogHelper::getCategoryInclusion($params->get('plg_easyblog_catid'));
$catIds = array();
if (!empty($categories)) {
if (!is_array($categories)) {
$categories = array($categories);
}
foreach ($categories as $item) {
$category = new stdClass();
$category->id = trim($item);
$catIds[] = $category->id;
if ($params->get('plg_easyblog_includesubcategory', 0)) {
$category->childs = null;
EasyBlogHelper::buildNestedCategories($category->id, $category, false, true);
EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
}
}
$catIds = array_unique($catIds);
}
$cid = $catIds;
if (!empty($cid)) {
$type = 'category';
}
$posts = $model->getBlogsBy($type, $cid, $sort, $count, EBLOG_FILTER_PUBLISHED, null, $featured, array(), false, false, true, array(), $cid);
$slides = array();
foreach ($posts as $item) {
$slide = (object) array();
$row = EasyBlogHelper::getTable('Blog', 'Table');
$row->bind($item);
$image = $row->getImage();
if (!empty($image)) {
$slide->image = str_replace(JURI::base(), '', $image->getSource('original'));
} else {
$slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->intro);
}
// if no image found in images and introtext then try fulltext
if (empty($slide->image)) {
$slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->content);
}
// if no image found in fulltext then take default image
if (empty($slide->image)) {
$slide->image = $default_image;
}
// if no default image set then don't display this article
if (empty($slide->image)) {
continue;
}
$slide->title = $item->title;
$slide->description = $item->intro;
if (empty($slide->description)) {
$slide->description = $item->content;
}
$slide->canonical = $slide->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id);
//.'&Itemid='. EasyBlogRouter::getItemIdByCategories( $item->category_id ) );
$slide->id = $item->id . ':' . $item->permalink;
//$this->dd($item);
if ($comments = $params->get('commnets', 0)) {
$host = str_replace(JURI::root(true), '', JURI::root());
$host = preg_replace('/\\/$/', '', $host);
switch ($comments) {
case 1:
// jcomments
$slide->comments = array('id' => $item->id, 'group' => 'com_easyblog');
break;
case 2:
// disqus
$disqus_shortname = $params->get('disqus_shortname', '');
if (!empty($disqus_shortname)) {
$slide->comments = array();
//.........这里部分代码省略.........
示例6: listings
function listings()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$config = EasyBlogHelper::getConfig();
$my = JFactory::getUser();
$acl = EasyBlogACLHelper::getRuleSet();
$sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
$catId = JRequest::getCmd('id', '0');
$category = EasyBlogHelper::getTable('Category', 'Table');
$category->load($catId);
if ($category->id == 0) {
$category->title = JText::_('COM_EASYBLOG_UNCATEGORIZED');
}
// Set the meta description for the category
EasyBlogHelper::setMeta($category->id, META_TYPE_CATEGORY);
// Set the meta description for the category
// $doc->setMetadata( 'description' , strip_tags( $category->description ) );
//setting pathway
$pathway = $app->getPathway();
$privacy = $category->checkPrivacy();
$addRSS = true;
if (!$privacy->allowed) {
if ($my->id == 0 && !$config->get('main_allowguestsubscribe')) {
$addRSS = false;
}
}
if ($addRSS) {
// Add rss feed link
$doc->addHeadLink($category->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
$doc->addHeadLink($category->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
}
if (!EasyBlogRouter::isCurrentActiveMenu('categories', $category->id)) {
if (!EasyBlogRouter::isCurrentActiveMenu('categories')) {
$this->setPathway(JText::_('COM_EASYBLOG_CATEGORIES_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=categories'));
}
//add the pathway for category
$this->setPathway($category->title, '');
}
//get the nested categories
$category->childs = null;
EasyBlogHelper::buildNestedCategories($category->id, $category, false, true);
// TODO: Parameterize initial subcategories to display. Ability to configure from backend.
$nestedLinks = '';
$initialLimit = $app->getCfg('list_limit') == 0 ? 5 : $app->getCfg('list_limit');
if (count($category->childs) > $initialLimit) {
$initialNestedLinks = '';
$initialRow = new stdClass();
$initialRow->childs = array_slice($category->childs, 0, $initialLimit);
EasyBlogHelper::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', ');
$moreNestedLinks = '';
$moreRow = new stdClass();
$moreRow->childs = array_slice($category->childs, $initialLimit);
EasyBlogHelper::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', ');
// Hide more nested links until triggered
$nestedLinks .= $initialNestedLinks;
$nestedLinks .= '<span class="more-subcategories-toggle"> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript: void(0);onclick="eblog.categories.loadMore( this );">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($category->childs) - $initialLimit) . '</a></span>';
$nestedLinks .= '<span class="more-subcategories" style="display: none;">, ' . $moreNestedLinks . '</span>';
} else {
EasyBlogHelper::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', ');
}
$catIds = array();
$catIds[] = $category->id;
EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
$category->nestedLink = $nestedLinks;
$modelC = $this->getModel('Category');
$category->cnt = $modelC->getTotalPostCount($category->id);
$modelPT = $this->getModel('PostTag');
$model = $this->getModel('Blog');
$modelCat = $this->getModel('Category');
$data = $model->getBlogsBy('category', $catIds, $sort, null, null, null, null, array(), null, null, null, array(), array(), null, EBLOG_PAGINATION_CATEGORIES);
$pagination = $model->getPagination();
$allowCat = $modelCat->allowAclCategory($category->id);
//for trigger
$params = $app->getParams('com_easyblog');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
if (!empty($data)) {
$data = EasyBlogHelper::formatBlog($data, false, true, true, true);
if ($config->get('layout_showcomment', false)) {
for ($i = 0; $i < count($data); $i++) {
$row =& $data[$i];
$maxComment = $config->get('layout_showcommentcount', 3);
$comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc');
$comments = EasyBlogHelper::formatBlogCommentsLite($comments);
$row->comments = $comments;
}
}
}
$teamBlogCount = $modelCat->getTeamBlogCount($category->id);
$title = EasyBlogHelper::getPageTitle(JText::_($category->title));
// @task: Set the page title
parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend'));
$themes = new CodeThemes();
$themes->set('allowCat', $allowCat);
$themes->set('category', $category);
$themes->set('sort', $sort);
$themes->set('blogs', $data);
$themes->set('currentURL', 'index.php?option=com_easyblog&view=categories&layout=listings&id=' . $category->id);
$themes->set('pagination', $pagination->getPagesLinks());
$themes->set('config', $config);
//.........这里部分代码省略.........
示例7: display
/**
* Responsible to display the front page of the blog listings
*
* @access public
*/
function display($tmpl = null)
{
// @task: Set meta tags for latest post
EasyBlogHelper::setMeta(META_ID_LATEST, META_TYPE_VIEW);
// @task: Set rss links into headers.
EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=latest');
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$config = EasyBlogHelper::getConfig();
$my = JFactory::getUser();
$acl = EasyBlogACLHelper::getRuleSet();
// @task: Add a breadcrumb if the current menu that's being accessed is not from the latest view.
if (!EasyBlogRouter::isCurrentActiveMenu('latest')) {
$this->setPathway(JText::_('COM_EASYBLOG_LATEST_BREADCRUMB'), '');
}
// @task: Get the current active menu's properties.
$menu = $app->getMenu()->getActive();
$menu = JFactory::getApplication()->getMenu()->getActive();
$inclusion = '';
if (is_object($menu)) {
$params = EasyBlogHelper::getRegistry();
$params->load($menu->params);
$inclusion = EasyBlogHelper::getCategoryInclusion($params->get('inclusion'));
if ($params->get('includesubcategories', 0) && !empty($inclusion)) {
$tmpInclusion = array();
foreach ($inclusion as $includeCatId) {
//get the nested categories
$category = new stdClass();
$category->id = $includeCatId;
$category->childs = null;
EasyBlogHelper::buildNestedCategories($category->id, $category);
$linkage = '';
EasyBlogHelper::accessNestedCategories($category, $linkage, '0', '', 'link', ', ');
$catIds = array();
$catIds[] = $category->id;
EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
$tmpInclusion = array_merge($tmpInclusion, $catIds);
}
$inclusion = $tmpInclusion;
}
}
// @task: Necessary filters
$sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
$model = $this->getModel('Blog');
// @task: Retrieve the list of featured blog posts.
$featured = $model->getFeaturedBlog($inclusion);
$excludeIds = array();
// @task: Add canonical URLs.
if ($config->get('main_canonical_entry')) {
$canonicalUrl = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=latest', false, true, true);
$doc->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '"/>');
}
// Test if user also wants the featured items to be appearing in the blog listings on the front page.
// Otherwise, we'll need to exclude the featured id's from appearing on the front page.
if (!$config->get('layout_featured_frontpage')) {
foreach ($featured as $item) {
$excludeIds[] = $item->id;
}
}
// @task: Admin might want to display the featured blogs on all pages.
if (!$config->get('layout_featured_allpages') && (JRequest::getInt('start', 0) != 0 || JRequest::getInt('limitstart', 0) != 0)) {
$featured = array();
} else {
for ($i = 0; $i < count($featured); $i++) {
$row = $featured[$i];
$row->featuredImage = EasyBlogHelper::getFeaturedImage($row->intro . $row->content);
}
$featured = EasyBlogHelper::formatBlog($featured, true, false, false, false, false);
}
// @task: Try to retrieve any categories to be excluded.
$excludedCategories = $config->get('layout_exclude_categories');
$excludedCategories = empty($excludedCategories) ? '' : explode(',', $excludedCategories);
// @task: Fetch the blog entries.
$data = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true, $excludeIds, false, false, true, $excludedCategories, $inclusion);
$pagination = $model->getPagination();
$params = $app->getParams('com_easyblog');
// @task: Perform necessary formatting here.
$data = EasyBlogHelper::formatBlog($data, true, true, true, true);
// @task: Update the title of the page if navigating on different pages to avoid Google marking these title's as duplicates.
$title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_LATEST_PAGE_TITLE'));
// @task: Set the page title
parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend'));
// @task: Get pagination output here.
$paginationHTML = $pagination->getPagesLinks();
$theme = new CodeThemes();
$theme->set('data', $data);
$theme->set('featured', $featured);
$theme->set('currentURL', EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false));
$theme->set('pagination', $paginationHTML);
// @task: Send back response to the browser.
echo $theme->fetch('blog.latest.php');
}
示例8: display
function display($tmpl = null)
{
$config = EasyBlogHelper::getConfig();
$jConfig = EasyBlogHelper::getJConfig();
if (!$config->get('main_rss')) {
return;
}
$id = JRequest::getCmd('id', '0');
$category = EasyBlogHelper::getTable('Category', 'Table');
$category->load($id);
// private category shouldn't allow to access.
$privacy = $category->checkPrivacy();
if (!$privacy->allowed) {
return;
}
if ($category->id == 0) {
$category->title = JText::_('COM_EASYBLOG_UNCATEGORIZED');
}
//get the nested categories
$category->childs = null;
EasyBlogHelper::buildNestedCategories($category->id, $category);
$linkage = '';
EasyBlogHelper::accessNestedCategories($category, $linkage, '0', '', 'link', ', ');
$catIds = array();
$catIds[] = $category->id;
EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
$category->nestedLink = $linkage;
$model = $this->getModel('Blog');
$sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
$data = $model->getBlogsBy('category', $catIds, $sort);
$document = JFactory::getDocument();
$document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=categories&id=' . $id . '&layout=listings');
$document->setTitle($this->escape($category->title));
$document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->title)));
if (empty($data)) {
return;
}
for ($i = 0; $i < count($data); $i++) {
$row =& $data[$i];
$blog = EasyBlogHelper::getTable('Blog');
$blog->load($row->id);
$user = JFactory::getUser($row->created_by);
$profile = EasyBlogHelper::getTable('Profile', 'Table');
$profile->load($user->id);
$created = EasyBlogHelper::getDate($row->created);
$formatDate = true;
if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
$langCode = EasyBlogStringHelper::getLangCode();
if ($langCode != 'en-GB' || $langCode != 'en-US') {
$formatDate = false;
}
}
//$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat();
$row->created = $created->toMySQL();
if ($config->get('main_rss_content') == 'introtext') {
$row->text = !empty($row->intro) ? $row->intro : $row->content;
} else {
$row->text = $row->intro . $row->content;
}
$row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text);
$row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text);
$image = '';
if ($blog->getImage()) {
$image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />';
}
// load individual item creator class
$item = new JFeedItem();
$item->title = html_entity_decode($this->escape($row->title));
$item->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
$item->description = $image . $row->text;
$item->date = $row->created;
$item->category = $category->title;
$item->author = $profile->getName();
if ($jConfig->get('feed_email') == 'author') {
$item->authorEmail = $profile->user->email;
} else {
$item->authorEmail = $jConfig->get('mailfrom');
}
$document->addItem($item);
}
}