本文整理汇总了PHP中EB::modules方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::modules方法的具体用法?PHP EB::modules怎么用?PHP EB::modules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::modules方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
public static function getData(&$params, $id, $count = 0)
{
$model = EB::model('Blog');
$entries = $model->getRelatedPosts($id, $count);
$entries = EB::modules()->processItems($entries, $params);
return $entries;
}
示例2: getPosts
static function getPosts($params)
{
$db = EB::db();
$order = trim($params->get('order', 'postcount_desc'));
$count = (int) trim($params->get('count', 0));
$showprivate = $params->get('showprivate', true);
$config = EB::config();
$query = 'SELECT a.* , SUM(b.value) AS ratings FROM ' . $db->nameQuote('#__easyblog_post') . ' AS a ' . 'LEFT JOIN ' . $db->nameQuote('#__easyblog_ratings') . ' AS b ' . 'ON a.id=b.uid ' . 'AND b.type=' . $db->Quote('entry') . ' ' . 'INNER JOIN ' . $db->quoteName('#__easyblog_post_category') . ' as c ON a.`id` = c.`post_id` INNER JOIN ' . $db->quoteName('#__easyblog_category') . ' as d ON c.`category_id` = d.`id` ' . 'WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED);
$query .= 'AND a.' . $db->nameQuote('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL) . ' ';
if (!$showprivate) {
$query .= ' AND a.' . $db->nameQuote('access') . '=' . $db->Quote(0);
}
// Respect inclusion categories
$categories = $params->get('catid');
if (!empty($categories)) {
$categories = explode(',', $categories);
$query .= ' AND d.`id` IN(';
if (!is_array($categories)) {
$categories = array($categories);
}
for ($i = 0; $i < count($categories); $i++) {
$query .= $db->Quote($categories[$i]);
if (next($categories) !== false) {
$query .= ',';
}
}
$query .= ')';
}
$query .= ' AND a.' . $db->nameQuote('source_id') . '=' . $db->Quote('0');
$query .= 'GROUP BY b.uid ';
$query .= 'ORDER BY ' . $db->nameQuote('ratings') . ' DESC ';
if (!empty($count)) {
$query .= ' LIMIT ' . $count;
}
$db->setQuery($query);
$result = $db->loadObjectList();
$posts = EB::modules()->processItems($result, $params);
return $posts;
}
示例3: processItems
/**
* Formats the result of the module
*
* @since 5.0
*/
public static function processItems($data, &$params)
{
$config = EB::config();
$app = JFactory::getApplication();
$appParams = $app->getParams('com_easyblog');
$limitstart = $app->input->get('limitstart', 0, 'int');
$result = array();
$posts = EB::formatter('list', $data, false);
foreach ($posts as $post) {
// Default media items
$post->media = '';
// If the post doesn't have a blog image try to locate for an image
if ($post->posttype == 'standard' && !$post->hasImage()) {
$photoWSize = $params->get('photo_width', 250);
$photoHSize = $params->get('photo_height', 250);
$size = array('width' => $photoWSize, 'height' => $photoHSize);
$post->media = EB::modules()->getMedia($post, $params, $size);
}
// Get the comment count
$post->commentCount = $post->getTotalComments();
// Determines if this post is password protected or not.
$requireVerification = false;
if ($config->get('main_password_protect', true) && !empty($r->blogpassword)) {
$row->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $row->title);
$requireVerification = true;
}
$post->showRating = true;
$post->protect = false;
$post->summary = '';
// Only if verification is necessary, we do not want to show the content
if ($requireVerification && !EB::verifyBlogPassword($post->blogpassword, $post->id)) {
$return = base64_encode($post->getPermalink());
$theme = EB::template();
$theme->set('post', $post);
$theme->set('id', $post->id);
$theme->set('return', $return);
$post->summary = $theme->output('site/blogs/latest/default.protected');
$post->showRating = false;
$post->protect = true;
}
// Determines the content source
$contentSource = $params->get('showintro', -1);
// Display only the intro
if ($contentSource == self::SOURCE_INTRO) {
$post->summary = $post->getIntro(self::POST_STRIP_TAGS, self::POST_TRUNCATE, self::POST_SOURCE_INTRO_COLUMN);
}
// Display the main content without intro
if ($contentSource == self::SOURCE_CONTENT) {
$post->summary = $post->getContentWithoutIntro('entry', self::POST_TRIGGER_PLUGIN);
}
// Remove any html codes from the content
$post->summary = strip_tags($post->summary);
// Truncation settings
$maxLength = $params->get('textcount', 0);
$length = JString::strlen($post->summary);
if ($maxLength && $length > $maxLength && !$post->protect) {
$post->summary = JString::substr($post->summary, 0, $maxLength) . JText::_('COM_EASYBLOG_ELLIPSES');
}
$result[] = $post;
}
return $result;
}
示例4: trim
$config = EB::config();
if ($config->get('main_ratings')) {
EB::init('module');
}
// Attach modules stylesheet
EB::stylesheet('module')->attach();
$count = (int) trim($params->get('total', 0));
$model = EB::model('Blog');
$cid = '';
$type = '';
$categories = trim($params->get('catid', ''));
if (!empty($categories)) {
$type = 'category';
$cid = explode(',', $categories);
}
$posts = $model->getBlogsBy('', '', 'random', $count, EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, true, array(), $cid, '', '', false);
$posts = EB::modules()->processItems($posts, $params);
$config = EB::config();
$textcount = $params->get('textcount', 150);
$disabled = $params->get('enableratings') ? false : true;
$layout = $params->get('layout');
$columnCount = $params->get('column');
// Get the photo layout option
$photoLayout = $params->get('photo_layout');
$photoSize = $params->get('photo_size', 'medium');
$photoAlignment = $params->get('alignment', 'center');
$photoAlignment = $photoAlignment == 'default' ? 'center' : $photoAlignment;
if (!$posts) {
return;
}
require JModuleHelper::getLayoutPath('mod_easyblograndompost');
示例5: getMostCommentedPost
public static function getMostCommentedPost(&$params)
{
$mainframe = JFactory::getApplication();
$db = EB::db();
$my = JFactory::getUser();
$config = EB::config();
$count = (int) trim($params->get('count', 0));
$categories = $params->get('catid');
$catAccess = array();
// Get the category ID if any from the module setting
if (!empty($categories)) {
$categories = explode(',', $categories);
}
// Respect inclusion categories
if (!empty($categories)) {
if (!is_array($categories)) {
$categories = array($categories);
}
$catAccess['include'] = $categories;
}
$showprivate = $params->get('showprivate', true);
$showcomment = $params->get('showlatestcomment', true);
$query = 'SELECT a.*, count(b.' . $db->quoteName('id') . ') as ' . $db->quoteName('comment_count');
if ($showcomment) {
$query .= ', c.' . $db->quoteName('id') . ' as ' . $db->quoteName('comment_id') . ', c.' . $db->quoteName('comment') . ', c.' . $db->quoteName('created_by') . ' as ' . $db->quoteName('commentor') . ', c.' . $db->quoteName('title') . ' as ' . $db->quoteName('comment_title') . ', c.' . $db->quoteName('name') . ' as ' . $db->quoteName('commentor_name');
}
$query .= ' FROM ' . $db->quoteName('#__easyblog_post') . ' AS a';
$query .= ' LEFT JOIN ' . $db->quoteName('#__easyblog_comment') . ' AS b ON a.' . $db->quoteName('id') . ' = b.' . $db->quoteName('post_id');
if ($showcomment) {
$query .= ' LEFT JOIN ' . $db->quoteName('#__easyblog_comment') . ' AS c ON a.' . $db->quoteName('id') . ' = c.' . $db->quoteName('post_id');
$query .= ' AND c.' . $db->quoteName('id') . ' = (SELECT MAX(d.' . $db->quoteName('id') . ') FROM ' . $db->quoteName('#__easyblog_comment') . ' AS d WHERE c.' . $db->quoteName('post_id') . ' = d.' . $db->quoteName('post_id') . ')';
}
$query .= ' WHERE a.' . $db->quoteName('published') . ' = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
$query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL);
if (!$showprivate) {
$query .= ' AND a.' . $db->quoteName('access') . ' = ' . $db->Quote('0');
}
// get teamblogs id.
// contribution type sql
$contributor = EB::contributor();
$contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
if ($config->get('main_includeteamblogpost')) {
$contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
}
$contributeSQL .= ')';
$query .= $contributeSQL;
// category access here
$catLib = EB::category();
$catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess);
$query .= ' AND (' . $catAccessSQL . ')';
$query .= ' GROUP BY a.' . $db->quoteName('id');
$query .= ' HAVING (' . $db->quoteName('comment_count') . ' > 0)';
$query .= ' ORDER BY ' . $db->quoteName('comment_count') . ' DESC';
if ($count > 0) {
$query .= ' LIMIT ' . $count;
}
$db->setQuery($query);
$posts = $db->loadObjectList();
// process item
$posts = EB::modules()->processItems($posts, $params);
return $posts;
}
示例6: getFeaturedImage
private static function getFeaturedImage(&$row, &$params)
{
$image = '';
$isImage = $row->getImage();
if (!empty($isImage)) {
$imagesrc = $row->getImage('small');
$image = '<img title="' . $row->title . '" src="' . $imagesrc . '" />';
} else {
$image = EB::modules()->getMedia($row, $params);
}
return $image;
}
示例7: getLatestPost
static function getLatestPost(&$params, $id = null, $type = 'latest')
{
$db = EB::db();
$config = EB::config();
$count = (int) $params->get('count', 0);
$model = EB::model('Blog');
$posts = '';
$sort = $params->get('sortby', 'latest') == 'latest' ? 'latest' : 'modified';
switch ($type) {
case 'blogger':
$posts = $model->getBlogsBy('blogger', $id, $sort, $count, EBLOG_FILTER_PUBLISHED, null, false);
break;
case 'category':
$posts = $model->getBlogsBy('category', $id, $sort, $count, EBLOG_FILTER_PUBLISHED, null, false);
break;
case 'tag':
$posts = $model->getTaggedBlogs($id, $count);
break;
case 'team':
$posts = $model->getBlogsBy('teamblog', $id, $sort, $count, EBLOG_FILTER_PUBLISHED, null, false);
break;
case 'latest':
default:
if ($params->get('usefeatured')) {
$posts = $model->getFeaturedBlog(array(), $count);
} else {
$categories = EB::getCategoryInclusion($params->get('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('includesubcategory', 0)) {
$category->childs = null;
EB::buildNestedCategories($category->id, $category, false, true);
EB::accessNestedCategoriesId($category, $catIds);
}
}
$catIds = array_unique($catIds);
}
$cid = $catIds;
if (!empty($cid)) {
$type = 'category';
}
$postType = null;
if ($params->get('postType') != 'all') {
$postType = $params->get('postType');
}
$posts = $model->getBlogsBy($type, $cid, 'latest', $count, EBLOG_FILTER_PUBLISHED, null, false, array(), false, false, true, array(), $cid, $postType);
}
break;
}
if (count($posts) > 0) {
$posts = EB::modules()->processItems($posts, $params);
}
return $posts;
}