示例#1
0
 function likesComment($contentId, $status, $likesId)
 {
     $my = JFactory::getUser();
     $ejax = new Ejax();
     if ($my->id <= 0) {
         $ejax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), '', '450');
         $ejax->send();
         return;
     }
     $jsLink = '';
     if ($status) {
         // add likes
         $id = EasyBlogHelper::addLikes($contentId, 'comment', $my->id);
         $jsLink = "<a href=\"javascript:eblog.comment.likes('" . $contentId . "', '0', '" . $id . "');\" class=\"likes\">" . JText::_('COM_EASYBLOG_UNLIKE') . "</a>";
     } else {
         // remove likes
         EasyBlogHelper::removeLikes($likesId);
         $jsLink = '<b>&middot;</b>  ' . "<a href=\"javascript:eblog.comment.likes('" . $contentId . "', '1', '0');\" class=\"likes\">" . JText::_('COM_EASYBLOG_LIKES') . "</a>";
     }
     //now reformat the likes authors
     $authors = EasyBlogHelper::getLikesAuthors($contentId, 'comment', $my->id);
     $ejax->assign('likes-' . $contentId, $jsLink);
     $ejax->assign('likes-container-' . $contentId, '<b>&middot;</b>  ' . $authors);
     if (empty($authors)) {
         $ejax->script("\$('#likes-container-" . $contentId . "').hide();");
     } else {
         $ejax->script("\$('#likes-container-" . $contentId . "').show();");
     }
     $totalLikes = EasyBlogHelper::getModel('comment')->getCommentTotalLikes($contentId);
     $ejax->script("\$('#comment-likescounter-" . $contentId . "').html('Likes: " . $totalLikes . "');");
     $ejax->script("eblog.loader.doneLoading();");
     $ejax->send();
     return;
 }
示例#2
0
 function updateDisplayDate($eleId, $dateString)
 {
     $ajax = new Ejax();
     $config = EasyBlogHelper::getConfig();
     $date = EasyBlogHelper::getDate($dateString);
     $now = EasyBlogDateHelper::toFormat($date, $config->get('layout_dateformat'));
     $ajax->assign('datetime_' . $eleId . ' .datetime_caption', $now);
     return $ajax->send();
 }
示例#3
0
 public function search($query = '')
 {
     $ajax = new Ejax();
     $model = $this->getModel('Search');
     $result = $model->searchText($query);
     if (empty($result)) {
         $ajax->script('$("#editor-content .search-results-content").height(24);');
         $ajax->assign('editor-content .search-results-content', JText::_('COM_EASYBLOG_DASHBOARD_WRITE_SEARCH_NO_RESULT'));
         return $ajax->send();
     }
     $count = count($result);
     if ($count > 10) {
         $height = "240";
     } else {
         $height = "24" * $count;
     }
     $theme = new CodeThemes('dashboard');
     $theme->set('result', $result);
     $ajax->assign('editor-content .search-results-content', $theme->fetch('dashboard.write.search.result.php'));
     $ajax->script('$("#editor-content .search-results-content").height(' . $height . ');');
     $ajax->script('$("#editor-content .search-results-content").show();');
     // $ajax->script( 'eblog.fileManager.setDockLayout();' );
     return $ajax->send();
 }
示例#4
0
 function loadCalendar($position = 'module', $itemId = '0', $size = 'small', $type = 'blog', $timestamp = '')
 {
     $my = JFactory::getUser();
     $ajax = new Ejax();
     $config = EasyBlogHelper::getConfig();
     $tpl = new CodeThemes();
     $model = new EasyBlogModelArchive();
     $allowed = array('module', 'component');
     if (!in_array($position, $allowed)) {
         return;
     }
     if (!empty($itemId)) {
         JRequest::setVar('Itemid', $itemId);
     }
     //get date.
     $date = EasyBlogCalendarHelper::processDate($timestamp);
     //get the required data to build the calendar.
     $data = EasyBlogCalendarHelper::prepareData($date);
     //get the postcount
     //$postCount 	= $model->getArchivePostCountByMonth($date['month'], $date['year']);
     $postData = $model->getArchivePostByMonth($date['month'], $date['year']);
     switch ($position) {
         case 'module':
             $namespace = 'mod_easyblogcalendar';
             $preFix = 'mod_easyblog';
             $ajax->script('mod_easyblogcalendar.calendar.setItemId("' . $itemId . '");');
             break;
         case 'component':
             $namespace = 'eblog';
             $preFix = 'com_easyblog';
             break;
     }
     $previous = $namespace . '.calendar.reload( \'archive\' , \'loadCalendar\', \'' . $position . '\', \'' . $itemId . '\', \'' . $size . '\', \'' . $type . '\', \'' . $data->previous . '\');';
     $next = $namespace . '.calendar.reload( \'archive\' , \'loadCalendar\', \'' . $position . '\', \'' . $itemId . '\', \'' . $size . '\', \'' . $type . '\', \'' . $data->next . '\');';
     $tpl->set('calendar', $data);
     $tpl->set('date', $date);
     $tpl->set('postData', $postData);
     $tpl->set('previous', $previous);
     $tpl->set('next', $next);
     $tpl->set('namespace', $namespace);
     $tpl->set('preFix', $preFix);
     $tpl->set('itemId', $itemId);
     $layout = $tpl->fetch('calendar.' . $size . '.php');
     $ajax->assign('easyblogcalendar-' . $position . '-wrapper', $layout);
     $ajax->send();
     return;
 }
示例#5
0
 public function vote($value, $uid, $type, $elementId)
 {
     $ajax = new Ejax();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($uid);
     if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
         if (!EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) {
             echo 'Invalid Access.';
             exit;
         }
     }
     $rating = EasyBlogHelper::getTable('Ratings', 'Table');
     // Do not allow guest to vote, or if the voter already voted.
     if ($rating->fill($my->id, $uid, $type, JFactory::getSession()->getId()) || $my->id < 1 && !$config->get('main_ratings_guests')) {
         // We wouldn't allow user to vote more than once so don't do anything here
         $ajax->send();
     }
     $rating->set('created_by', $my->id);
     $rating->set('type', $type);
     $rating->set('uid', $uid);
     $rating->set('ip', @$_SERVER['REMOTE_ADDR']);
     $rating->set('value', (int) $value);
     $rating->set('sessionid', JFactory::getSession()->getId());
     $rating->set('created', EasyBlogHelper::getDate()->toMySQL());
     $rating->set('published', 1);
     $rating->store();
     $model = EasyBlogHelper::getModel('Ratings');
     $ratingValue = $model->getRatingValues($uid, $type);
     $total = $ratingValue->total;
     $rating = $ratingValue->ratings;
     // Assign badge for users that report blog post.
     // Only give points if the viewer is viewing another person's blog post.
     EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG'));
     $ajax->script('eblog.loader.doneLoading("' . $elementId . '-command .ratings-text")');
     $ajax->script('eblog.ratings.update("' . $elementId . '", "' . $type . '" , "' . $rating . '" , "' . JText::_('COM_EASYBLOG_RATINGS_RATED_THANK_YOU') . '");');
     $ajax->assign($elementId . ' .ratings-value', '<i></i>' . $total . '<b>&radic;</b>');
     if (EasyBlogHelper::isAUPEnabled()) {
         $id = AlphaUserPointsHelper::getAnyUserReferreID($my->id);
         AlphaUserPointsHelper::newpoints('plgaup_easyblog_rate_blog', $id, '', JText::sprintf('COM_EASYBLOG_AUP_BLOG_RATED'), '');
     }
     $ajax->send();
 }
示例#6
0
    public function getNews()
    {
        $news = EasyBlogHelper::getRecentNews();
        $content = '';
        ob_start();
        if ($news) {
            foreach ($news as $item) {
                ?>
		<li>
			<b><span><?php 
                echo $item->title . ' - ' . $item->date;
                ?>
</span></b>
			<div><?php 
                echo $item->desc;
                ?>
</div>
		</li>
		<?php 
            }
        } else {
            ?>
		<li><?php 
            echo JText::_('Unable to contact news server');
            ?>
</li>
		<?php 
        }
        $content = ob_get_contents();
        @ob_end_clean();
        $ajax = new Ejax();
        $ajax->assign('news-items', $content);
        // 		$ajax->script( "$('#news-items").html(\'' . addslashes( $content ) . '\');');
        $ajax->send();
    }
示例#7
0
    public function search($query = '', $elementId = '')
    {
        $ajax = new Ejax();
        $lang = JFactory::getLanguage();
        $lang->load('com_easyblog', JPATH_ROOT);
        $model = EasyBlogHelper::getModel('Search');
        $posts = $model->searchText($query);
        if (empty($elementId)) {
            $elementId = 'write_content';
        }
        if (empty($posts)) {
            $ajax->script('$("#editor-' . $elementId . ' .search-results-content").height(24);');
            $ajax->assign('editor-' . $elementId . ' .search-results-content', JText::_('No results found'));
            return $ajax->send();
        }
        $count = count($posts);
        if ($count > 10) {
            $height = "240";
        } else {
            $height = "24" * $count;
        }
        $config = EasyBlogHelper::getConfig();
        ob_start();
        ?>
<ul class="blog-search-items reset-ul">
	<?php 
        foreach ($posts as $entry) {
            $postLink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $entry->id);
            $externalLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $entry->id, false, true);
            ?>
	<li>
        <input type="button" onclick="eblog.editor.search.insert('<?php 
            echo $externalLink;
            ?>
', '<?php 
            echo $entry->title;
            ?>
', '<?php 
            echo $elementId;
            ?>
');return false;" value="<?php 
            echo JText::_('COM_EASYBLOG_DASHBOARD_EDITOR_INSERT_LINK');
            ?>
" class="ui-button float-r mts" />
        <div class="tablecell">
            <a href="<?php 
            echo $externalLink;
            ?>
" target="_BLANK"><?php 
            echo $entry->title;
            ?>
</a>
            <?php 
            echo JText::_('COM_EASYBLOG_ON');
            ?>
            <?php 
            echo $this->formatDate($config->get('layout_dateformat'), $entry->created);
            ?>
        </div>
        <div class="clear"></div>
	</li>
	<?php 
        }
        ?>
</ul>
<?php 
        $html = ob_get_contents();
        ob_end_clean();
        $ajax->assign('editor-content .search-results-content', $html);
        $ajax->script('$("#editor-content .search-results-content").height(' . $height . ');');
        $ajax->script('$("#editor-content .search-results-content").show();');
        return $ajax->send();
    }