本文整理汇总了PHP中EB::post方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::post方法的具体用法?PHP EB::post怎么用?PHP EB::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reportBlog
public function reportBlog()
{
$app = JFactory::getApplication();
// Get the composite keys
$log_user = $this->plugin->get('user')->id;
$id = $app->input->get('id', 0, 'int');
$type = $app->input->get('type', '', 'POST');
$reason = $app->input->get('reason', '', 'STRING');
if (!$reason) {
$message = "Reason is empty";
$final_result['message'] = $message;
$final_result['status'] = false;
return $final_result;
}
$report = EB::table('Report');
$report->obj_id = $id;
$report->obj_type = $type;
$report->reason = $reason;
$report->created = EB::date()->toSql();
$report->created_by = $log_user;
$state = $report->store();
if (!$state) {
$message = "Cant store your report";
$final_result['message'] = $message;
$final_result['status'] = false;
return $final_result;
}
// Notify the site admin when there's a new report made
$post = EB::post($id);
$report->notify($post);
$final_result['message'] = "Report logged successfully!";
$final_result['status'] = true;
return $final_result;
}
示例2: store
/**
* Saves a new rating item
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function store($updateNulls = false)
{
$config = EB::config();
$state = parent::store();
if ($this->type == 'entry' && $this->created_by) {
// Load the post item
$post = EB::post($this->uid);
// Get the author of the post
$author = $post->getAuthor();
// Get the link to the post
$link = $post->getExternalPermalink();
// Notify EasySocial users that someone rated their post
EB::easysocial()->notifySubscribers($post, 'ratings.add');
// Assign EasySocial points
EB::easysocial()->assignPoints('blog.rate');
EB::easysocial()->assignPoints('blog.rated', $post->created_by);
// Assign badge for users that report blog post.
// Only give points if the viewer is viewing another person's blog post.
EB::easysocial()->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG'));
// Assign points for AUP
EB::aup()->assign('plgaup_easyblog_rate_blog', '', 'easyblog_rating', JText::_('COM_EASYBLOG_AUP_BLOG_RATED'));
// Add notifications for EasyDiscuss
// Add notifications
// EB::jomsocial()->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', str_replace("administrator/","", $author->getProfileLink()), $author->getName() , $link , $blog->title), 'easyblog_new_blog' , $target , $author , $link);
// Add notifications for easydiscuss
if ($config->get('integrations_jomsocial_notification_rating')) {
$target = array($post->created_by);
EB::easydiscuss()->addNotification($post, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', $author->getName(), $post->title), EBLOG_NOTIFICATIONS_TYPE_RATING, array($post->created_by), $this->created_by, $link);
}
}
return $state;
}
示例3: reject
public function reject()
{
// Check for request forgeries
EB::checkToken();
// Ensure that user is logged in
EB::requireLogin();
// Get any return url
$return = EB::_('index.php?option=com_easyblog&view=dashboard&layout=moderate');
if ($this->getReturnURL()) {
$return = $this->getReturnURL();
}
// Check if the user is privileged enough
if (!$this->acl->get('add_entry') && !$this->acl->get('manage_pending')) {
return JError::raiseError(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_MODERATE_BLOG'));
}
// Get a list of ids
$ids = $this->input->get('ids', array(), 'array');
$message = $this->input->get('message', '', 'default');
foreach ($ids as $id) {
$id = (int) $id;
$post = EB::post($id);
$post->reject($message);
}
$message = JText::_('COM_EASYBLOG_BLOGS_BLOG_SAVE_REJECTED');
$this->info->set($message, 'success');
return $this->app->redirect($return);
}
示例4: load
public function load($cid)
{
static $instances = array();
if (!isset($instances[$cid])) {
$this->_item = EB::post($cid);
if (!$this->_item) {
return $this->onLoadArticleError($cid);
}
$blogger = EB::user($this->_item->created_by);
$this->_item->blogger = $blogger;
$link = 'index.php?option=com_easyblog&view=entry&id=' . $this->getContentId();
// forcefully get item id if request is ajax
$format = JRequest::getString('format', 'html');
if ($format === 'ajax') {
$itemid = JRequest::getInt('pageItemId');
if (!empty($itemid)) {
$link .= '&Itemid=' . $itemid;
}
}
$link = EBR::_($link);
$this->_item->permalink = $this->prepareLink($link);
$instances[$cid] = $this->_item;
}
$this->_item = $instances[$cid];
return $this;
}
示例5: display
public function display($tmpl = null)
{
// Ensure that the user is logged in.
EB::requireLogin();
// null = new post
// 63 = post 63 from post table
// 63.2 = post 63, revision 2 from history table
$uid = $this->input->getVar('uid', null);
// If no id given, create a new post.
$post = EB::post($uid);
// Verify access (see function manager())
if (!$post->canCreate() && !$post->canEdit()) {
// Do not allow user to access this page if he doesn't have access
JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_ACCESS_IN_THIS_SECTION'));
return;
}
// If there's no id provided, we will need to create the initial revision for the post.
if (!$uid) {
$post->create();
$uid = $post->uid;
}
// Determines if we should show the sidebars by default
$templateId = $this->input->get('block_template', 0, 'int');
if (!$post->title) {
$this->doc->setTitle(JText::_('COM_EASYBLOG_COMPOSER_POST_UNTITLED'));
}
$composer = EB::composer();
// Render default post templates
$postTemplatesModel = EB::model('Templates');
$postTemplates = $postTemplatesModel->getPostTemplates($this->my->id);
$this->set('postTemplates', $postTemplates);
$this->set('composer', $composer);
$this->set('post', $post);
return parent::display('composer/default');
}
示例6: display
public function display($tmpl = null)
{
JPluginHelper::importPlugin('easyblog');
$dispatcher = JDispatcher::getInstance();
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$config = EasyBlogHelper::getConfig();
//for trigger
$params = $mainframe->getParams('com_easyblog');
$joomlaVersion = EasyBlogHelper::getJoomlaVersion();
$blogId = $this->input->get('id', 0, 'int');
if (empty($blogId)) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_BLOG_NOT_FOUND'));
}
$my = JFactory::getUser();
$blog = EB::table('Blog');
$blog->load($blogId);
$post = EB::post($blogId);
// Check if blog is password protected.
$protected = $this->isProtected($post);
if ($protected !== false) {
return;
}
// If the blog post is already deleted, we shouldn't let it to be accessible at all.
if ($post->isTrashed()) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
}
// Check if the blog post is trashed
if (!$post->isPublished() && $this->my->id != $post->created_by && !EB::isSiteAdmin()) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
}
// Check for team's privacy
$allowed = $this->checkTeamPrivacy($post);
if ($allowed === false) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY'));
}
// Check if the blog post is accessible.
$accessible = $post->isAccessible();
if (!$accessible->allowed) {
echo $accessible->error;
return;
}
// Format the post
$post = EB::formatter('entry', $post);
$tags = $post->getTags();
$theme = EB::template();
$theme->set('post', $post);
$theme->set('tags', $tags);
$blogHtml = $theme->output('site/blogs/entry/pdf');
$pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title'));
$document->setTitle($post->title . $pageTitle);
$document->setName($post->getPermalink());
// Fix phoca pdf plugin.
if (method_exists($document, 'setArticleText')) {
$document->setArticleText($blogHtml);
}
echo $blogHtml;
return;
}
示例7: execute
public function execute()
{
if ($this->cache) {
// Cache data and preload posts
EB::cache()->insert($this->items);
}
// For list items we wouldn't want to process comments
$comment = true;
// For list items we do not want to load videos
$video = false;
// For list items we do not want to process gallery
$gallery = false;
// Result
$result = array();
// Load up the tags model
$tagsModel = EB::model('PostTag');
foreach ($this->items as $item) {
$post = EB::post($item->id);
$blog = new stdClass();
// Post details
$blog->id = $post->id;
$blog->title = $post->title;
$blog->intro = $post->getIntro();
$blog->content = $post->getContent();
$blog->content_plain = $this->sanitize($blog->content);
$blog->image = $post->getImage('thumbnail');
$blog->created = $post->created;
$blog->hits = $post->hits;
$blog->permalink = $post->getPermalink(true, true, 'json');
// Get the author details
$author = $post->getAuthor();
$blog->author = new stdClass();
$blog->author->name = $author->getName();
$blog->author->avatar = $author->getAvatar();
// Get the tags for this post
$tags = $post->getTags();
$blog->tags = array();
if ($tags) {
foreach ($tags as $tag) {
$item = new stdClass();
$item->title = $tag->getTitle();
$item->permalink = $tag->getExternalPermalink('json');
$blog->tags[] = $item;
}
}
// Get the category details
$category = $post->getPrimaryCategory();
$blog->category = new stdClass();
$blog->category->id = $category->id;
$blog->category->title = $category->getTitle();
$blog->category->avatar = $category->getAvatar();
$blog->category->permalink = $category->getExternalPermalink('json');
$result[] = $blog;
}
return $result;
}
示例8: getPosts
public static function getPosts(&$params)
{
$config = EB::config();
$count = (int) $params->get('count', 0);
// Retrieve the model from the component.
$model = EB::model('Blog');
$categories = trim($params->get('catid'));
$type = !empty($categories) ? 'category' : '';
if (!empty($categories)) {
$categories = explode(',', $categories);
}
$sorting = array();
$sorting[] = $params->get('sorting', 'latest');
$sorting[] = $params->get('ordering', 'desc');
$rows = $model->getBlogsBy($type, $categories, $sorting, $count, EBLOG_FILTER_PUBLISHED, null, false);
$posts = array();
// Retreive settings from params
$maxWidth = $params->get('imagewidth', 300);
$maxHeight = $params->get('imageheight', 200);
foreach ($rows as $data) {
$row = EB::post($data->id);
$row->bind($data);
$row->media = '';
//var_dump($row->image);
if (!empty($row->image)) {
$media = $row->getImage('thumbnail');
$imgHtml = $media;
$row->media = $imgHtml;
} else {
$image = self::getImage($row->intro . $row->content);
if ($image !== false) {
// TODO: Here's where we need to crop the image based on the cropping ratio provided in the params.
// Currently this is just a lame hack to fix the width and height
$pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'>]*)/i';
preg_match($pattern, $image, $matches);
$imageurl = '';
if ($matches) {
$imageurl = isset($matches[1]) ? $matches[1] : '';
}
if (!empty($imageurl)) {
// $imgHtml = '<img title="'.$row->title.'" src="' . $imageurl . '" style="width: '. $maxWidth . 'px !important;height: '. $maxHeight . 'px !important;" />';
$imgHtml = $imageurl;
$row->media = $imgHtml;
} else {
$row->media = $image;
}
}
}
if (!empty($row->media)) {
$posts[] = $row;
}
}
return $posts;
}
示例9: execute
/**
* Default method to format normal posts
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function execute()
{
// Result
$result = array();
// Cache data and preload posts
if ($this->cache) {
EB::cache()->insert($this->items);
}
// Preload all featured posts for posts
$featuredItems = array();
// Do a simple test to see if preload featured items is require or not
if (!isset($this->items[0]->featured)) {
$featuredItems = $this->preloadFeaturedItems();
}
$i = 0;
foreach ($this->items as $item) {
// Load up the post library
$post = EB::post();
$post->load($item->id);
// Get the list of categories for this particular blog post
$post->category = $post->getPrimaryCategory();
$post->categories = $post->getCategories();
// @Assign dynamic properties that must exist everytime formatBlog is called
// We can't rely on ->author because CB plugins would mess things up.
$post->author = $post->getAuthor();
// Determines if the blog post is featured
if (isset($item->featured)) {
$post->isFeatured = $item->featured;
} else {
if (isset($featuredItems[$post->id])) {
$post->isFeatured = $featuredItems[$post->id];
} else {
$post->isFeatured = 0;
}
}
// Password verifications
$this->password($post);
// Get custom fields
$post->fields = $post->getCustomFields();
// Format microblog postings
if ($post->posttype) {
$this->formatMicroblog($post);
} else {
$post->posttype = 'standard';
}
// Assign tags to the custom properties.
$post->tags = $post->getTags();
// Prepare nice date for the list
$post->date = EB::date($post->created)->format(JText::_('DATE_FORMAT_LC'));
$result[] = $post;
$i++;
}
return $result;
}
示例10: execute
public function execute()
{
if ($this->cache) {
//preload posts information
EB::cache()->insert($this->items);
}
// For featured items we wouldn't want to process comments
$comment = true;
// For featured items we want to remove featured image
$removeFeaturedImage = true;
// For featured items we do not want to load videos
$video = false;
// For featured items we do not want to process gallery
$gallery = false;
// Ensure that the content does not exceed the introtext limit for featured items
$contentLimit = $this->config->get('layout_featured_intro_limit');
$result = array();
foreach ($this->items as &$item) {
$blog = EB::post($item->id);
// Load the author's profile
$author = EB::user($blog->created_by);
// @Assign dynamic properties that must exist everytime formatBlog is called
// We can't rely on ->author because CB plugins would mess things up.
$blog->author = $author;
$blog->blogger = $author;
// Password verifications
$this->password($blog);
// Format microblog postings
if ($blog->posttype) {
$this->formatMicroblog($blog);
}
// Detect if content requires read more link
$blog->readmore = $this->hasReadmore($blog);
// // Truncate content
// $this->truncate($blog);
// EB::truncateContent($blog, $loadVideo, $frontpage, $loadGallery);
// Format the content for the featured items
if (empty($blog->intro)) {
$blog->intro = $blog->content;
}
// We wouldn't want to display html codes in the content
$blog->intro = strip_tags($blog->intro);
// Get the content length
$length = JString::strlen($blog->intro);
if ($length > $contentLimit) {
$blog->intro = JString::substr($blog->intro, 0, $contentLimit);
}
// Prepare nice date for the featured area
$blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC'));
$result[] = $blog;
}
return $result;
}
示例11: execute
public function execute()
{
if ($this->cache) {
//preload posts information
EB::cache()->insert($this->items);
}
// For featured items we wouldn't want to process comments
$comment = true;
// For featured items we want to remove featured image
$removeFeaturedImage = true;
// For featured items we do not want to load videos
$video = false;
// For featured items we do not want to process gallery
$gallery = false;
// Ensure that the content does not exceed the introtext limit for featured items
$contentLimit = $this->config->get('layout_featured_intro_limit');
$result = array();
foreach ($this->items as &$item) {
$blog = EB::post($item->id);
// Load the author's profile
$author = EB::user($blog->created_by);
// @Assign dynamic properties that must exist everytime formatBlog is called
// We can't rely on ->author because CB plugins would mess things up.
$blog->author = $author;
$blog->blogger = $author;
// Password verifications
$this->password($blog);
// Format microblog postings
if ($blog->posttype) {
$this->formatMicroblog($blog);
}
// Get featured image
if ($blog->hasImage()) {
$blog->image = $blog->getImage($this->config->get('cover_featured_size', 'large'));
} else {
$tmp = $blog->getContentImage();
if ($tmp) {
$blog->image = $tmp;
} else {
$blog->image = '';
}
}
// Detect if content requires read more link
$blog->readmore = $this->hasReadmore($blog);
// Prepare nice date for the featured area
$blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC'));
$result[] = $blog;
}
return $result;
}
示例12: moderate
/**
* Allows visitor to approve a comment
*
* @since 5.0
* @access public
*/
public function moderate()
{
// Get the hash key
$key = $this->input->get('key', '', 'default');
// Default redirection url
$redirect = EBR::_('index.php?option=com_easyblog', false);
if (!$key) {
$this->info->set('COM_EASYBLOG_NOT_ALLOWED', 'error');
return $this->app->redirect($redirect);
}
// Get the hashkey from the site
$hashkey = EB::table('Hashkeys');
$state = $hashkey->loadByKey($key);
// If the key doesn't exist, it may no longer be a valid request
if (!$state || !$hashkey->id) {
$this->info->set('COM_EASYBLOG_NOT_ALLOWED', 'error');
return $this->app->redirect($redirect);
}
// Load the comment now
$comment = EB::table('Comment');
$comment->load($hashkey->uid);
// Get the task to perform
$task = $this->getTask();
// Load up the post library
$post = EB::post($comment->post_id);
if ($task == 'approve') {
$comment->published = EBLOG_COMMENT_PUBLISHED;
// Save the comment now
$comment->store(true);
// Process the mails for comments now
$comment->processEmails(false, $post);
// Update the sent flag for the comment
$comment->updateSent();
}
if ($task == 'reject') {
$comment->published = EBLOG_COMMENT_UNPUBLISHED;
$comment->store(true);
}
// Delete the unused hashkey now.
$hashkey->delete();
$message = 'COM_EASYBLOG_MODERATE_COMMENT_PUBLISHED_SUCCESS';
if ($task == 'reject') {
$message = 'COM_EASYBLOG_MODERATE_COMMENT_UNPUBLISHED_SUCCESS';
}
$this->info->set($message, 'success');
// Get the permalink to the post
$permalink = $post->getPermalink(false);
return $this->app->redirect($permalink);
}
示例13: getInput
/**
* Displays the post selection form
*
* @since 5.0
* @access public
* @param string
* @return
*/
protected function getInput()
{
$title = JText::_('COM_EASYBLOG_MENU_SELECT_POST_TITLE');
if ($this->value) {
$post = EB::post($this->value);
$title = $post->title;
}
$theme = EB::template();
$theme->set('id', $this->id);
$theme->set('name', $this->name);
$theme->set('value', $this->value);
$theme->set('title', $title);
$output = $theme->output('admin/elements/post');
return $output;
}
示例14: publish
/**
* Processes scheduled blog posts to be published
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function publish()
{
// Retrieve a list of scheduled posts
$model = EB::model('Blogs');
$items = $model->getScheduledPosts();
if (!$items) {
return EB::exception('No scheduled posts to process currently.', EASYBLOG_MSG_INFO);
}
foreach ($items as $item) {
$post = EB::post($item->id);
// We know that all scheduled posts regardless if the author has access to publish or not should be published.
// Since pending posts that are being scheduled needs to be approved by the admin first.
$options = array('checkAcl' => false);
$post->publish($options);
}
}
示例15: display
/**
* Main display for the blog entry view
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function display($tpl = null)
{
// Get the blog post id from the request
$id = $this->input->get('id', 0, 'int');
// Load the blog post now
$post = EB::post($id);
// If blog id is not provided correctly, throw a 404 error page
if (!$id || !$post->id) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
}
// If the settings requires the user to be logged in, do not allow guests here.
if ($this->my->guest && $this->config->get('main_login_read')) {
return EB::requireLogin();
}
// Check if blog is password protected.
$protected = $this->isProtected($post);
if ($protected !== false) {
return;
}
// If the blog post is already deleted, we shouldn't let it to be accessible at all.
if ($post->isTrashed()) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
}
// Check if the blog post is trashed
if (!$post->isPublished() && $this->my->id != $post->created_by && !EB::isSiteAdmin()) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
}
// Check for team's privacy
$allowed = $this->checkTeamPrivacy($post);
if ($allowed === false) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY'));
}
// Check if the blog post is accessible.
$accessible = $post->isAccessible();
if (!$accessible->allowed) {
echo $accessible->error;
return;
}
// Increment the hit counter for the blog post.
$post->hit();
// Format the post
$post = EB::formatter('entry', $post);
$theme = EB::template();
$theme->set('post', $post);
$output = $theme->output('site/blogs/entry/default.print');
echo $output;
}