コード例 #1
0
ファイル: blog.php プロジェクト: knigherrant/decopatio
 /**
  * Retrieves a list of comments from a blog post
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getBlogComment($id, $limitFrontEnd = 0, $sort = 'asc', $lite = false)
 {
     $db = EB::db();
     $config = EB::getConfig();
     $sort = $config->get('comment_sort', 'asc');
     if ($lite) {
         $query = 'SELECT a.* FROM `#__easyblog_comment` a';
         $query .= ' INNER JOIN #__users AS c ON a.`created_by` = c.`id`';
         $query .= ' WHERE a.`post_id` = ' . $db->Quote($id);
         $query .= ' AND a.`published` = 1';
     } else {
         $query = 'SELECT a.*, (count(b.id) - 1) AS `depth` FROM `#__easyblog_comment` AS a';
         $query .= ' INNER JOIN `#__easyblog_comment` AS b';
         $query .= ' LEFT JOIN `#__users` AS c ON a.`created_by` = c.`id`';
         $query .= ' WHERE a.`post_id` = ' . $db->Quote($id);
         $query .= ' AND b.`post_id` = ' . $db->Quote($id);
         $query .= ' AND a.`published` = 1';
         $query .= ' AND b.`published` = 1';
         $query .= ' AND a.`lft` BETWEEN b.`lft` AND b.`rgt`';
         $query .= ' GROUP BY a.`id`';
     }
     // prepare the query to get total comment
     $queryTotal = 'SELECT COUNT(1) FROM (';
     $queryTotal .= $query;
     $queryTotal .= ') AS x';
     // continue the query.
     $limit = $this->getState('limit');
     $limitstart = $this->getState('limitstart');
     switch ($sort) {
         case 'desc':
             $query .= ' ORDER BY a.`rgt` desc';
             break;
         default:
             $query .= ' ORDER BY a.`lft` asc';
             break;
     }
     if ($limitFrontEnd > 0) {
         $query .= ' LIMIT ' . $limitFrontEnd;
     } else {
         $query .= ' LIMIT ' . $limitstart . ',' . $limit;
     }
     if ($limitFrontEnd <= 0) {
         $db->setQuery($queryTotal);
         $this->_total = $db->loadResult();
         jimport('joomla.html.pagination');
         $this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
     }
     // the actual content sql
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!$result) {
         return $result;
     }
     // Format the comments
     $result = EB::comment()->format($result);
     return $result;
 }
コード例 #2
0
ファイル: views.php プロジェクト: knigherrant/decopatio
 public function __construct()
 {
     $this->config = EB::getConfig();
     $this->jconfig = JFactory::getConfig();
     $this->app = JFactory::getApplication();
     $this->doc = JFactory::getDocument();
     $this->my = JFactory::getUser();
     $this->input = EB::request();
     $this->info = EB::info();
     $this->theme = EB::getTemplate(null, array('view' => $this, 'admin' => true));
     if ($this->doc->getType() == 'ajax') {
         $this->ajax = EB::ajax();
     }
     parent::__construct();
 }
コード例 #3
0
ファイル: comment.php プロジェクト: knigherrant/decopatio
 /**
  * Method to get total comment post currently iregardless the status and associated blogs.
  *
  * @access public
  * @return integer
  */
 function getTotalComment($userId = 0)
 {
     $db = EB::db();
     $config = EB::getConfig();
     if ($config->get('comment_compojoom')) {
         $file = JPATH_ROOT . '/administrator/components/com_comment/plugin/com_easyblog/josc_com_easyblog.php';
         if (JFile::exists($file)) {
             require_once $file;
             $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__comment') . ' ' . 'WHERE ' . $db->nameQuote('component') . ' = ' . $db->Quote('com_easyblog') . ' ' . 'AND ' . $db->nameQuote('userid') . ' = ' . $db->Quote($userId) . ' ' . 'AND ' . $db->nameQuote('published') . ' = ' . $db->Quote(1);
             $db->setQuery($query);
             return $db->loadResult();
         }
     }
     $where = array();
     $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__easyblog_comment');
     if (!empty($userId)) {
         $where[] = '`created_by` = ' . $db->Quote($userId);
     }
     $extra = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
     $query = $query . $extra;
     $db->setQuery($query);
     $result = $db->loadResult();
     return empty($result) ? 0 : $result;
 }
コード例 #4
0
ファイル: k2.php プロジェクト: knigherrant/decopatio
 public function migrateK2Images(&$item, &$blog, $author)
 {
     jimport('joomla.filesystem.file');
     $name = md5('Image' . $item->id);
     $path = JPATH_ROOT . '/media/k2/items/src/' . $name . '.jpg';
     $config = EB::getConfig();
     $configStorage = str_ireplace('\\', '/', $config->get('main_image_path'));
     $newPath = JPATH_ROOT . '/' . rtrim($configStorage, '/') . '/' . $author->id;
     if (!JFolder::exists($newPath)) {
         JFolder::create($newPath);
     }
     if (JFile::exists($path)) {
         // Copy the full scaled image
         $large = JPATH_ROOT . '/media/k2/items/cache/' . $name . '_XL.jpg';
         $targetLarge = $newPath . '/' . $name . '.jpg';
         $targetURL = rtrim(JURI::root(), '/') . '/' . str_ireplace('\\', '/', $configStorage) . '/' . $author->id;
         $largeSrc = rtrim(JURI::root(), '/') . '/' . str_ireplace('\\', '/', $configStorage) . '/' . $author->id . '/' . $name . '.jpg';
         $file = getimagesize($large);
         $file['name'] = basename($large);
         $file['tmp_name'] = $large;
         $media = EB::mediamanager();
         $result = $media->upload($file, 'user:' . $author->id);
         $result = json_encode($result);
         $blog->image = $result;
     }
 }
コード例 #5
0
ファイル: easyblog.php プロジェクト: knigherrant/decopatio
 public static function getLikesAuthors($contentId, $type, $userId)
 {
     $db = EB::db();
     $config = EB::getConfig();
     $result = new stdClass();
     $displayFormat = $config->get('layout_nameformat');
     $displayName = '';
     switch ($displayFormat) {
         case "name":
             $displayName = 'a.name';
             break;
         case "username":
             $displayName = 'a.username';
             break;
         case "nickname":
         default:
             $displayName = 'b.nickname';
             break;
     }
     $query = 'select a.id as `user_id`, c.id, ' . $displayName . ' as `displayname`';
     $query .= ' FROM `#__users` as a';
     $query .= '  inner join `#__easyblog_users` as b';
     $query .= '    on a.id = b.id';
     $query .= '  inner join `#__easyblog_likes` as c';
     $query .= '    on a.id = c.created_by';
     $query .= ' where c.content_id = ' . $db->Quote($contentId);
     $query .= ' and c.`type` = ' . $db->Quote($type);
     $query .= ' order by c.id desc';
     $db->setQuery($query);
     $list = $db->loadObjectList();
     if (count($list) <= 0) {
         $result->string = '';
         $result->count = 0;
         return $result;
     }
     // else continue here
     $onwerInside = false;
     $names = array();
     for ($i = 0; $i < count($list); $i++) {
         if ($list[$i]->user_id == $userId) {
             $onwerInside = true;
             array_unshift($names, JText::_('COM_EASYBLOG_YOU'));
         } else {
             $names[] = $list[$i]->displayname;
         }
     }
     $max = 3;
     $total = count($names);
     $break = 0;
     if ($total == 1) {
         $break = $total;
     } else {
         if ($max >= $total) {
             $break = $total - 1;
         } elseif ($max < $total) {
             $break = $max;
         }
     }
     $main = array_slice($names, 0, $break);
     $remain = array_slice($names, $break);
     $stringFront = implode(", ", $main);
     $returnString = '';
     if (count($remain) > 1) {
         $returnString = JText::sprintf('COM_EASYBLOG_AND_OTHERS_LIKE_THIS', $stringFront, count($remain));
     } else {
         if (count($remain) == 1) {
             $returnString = JText::sprintf('COM_EASYBLOG_AND_LIKE_THIS', $stringFront, $remain[0]);
         } else {
             if (EasyBlogHelper::isLoggedIn() && $onwerInside) {
                 $returnString = JText::sprintf('COM_EASYBLOG_LIKE_THIS_SINGULAR', $stringFront);
             } else {
                 $returnString = JText::sprintf('COM_EASYBLOG_LIKE_THIS_PLURAL', $stringFront);
             }
         }
     }
     $result->count = $total;
     $result->string = $returnString;
     return $result;
 }
コード例 #6
0
ファイル: comment.php プロジェクト: knigherrant/decopatio
 /**
  * Validates the comment
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function validate($type)
 {
     $config = EB::getConfig();
     if ($config->get('comment_requiretitle') && $type == 'title') {
         return JString::strlen($this->title) != 0;
     }
     if ($type == 'name') {
         return JString::strlen($this->name) != 0;
     }
     if ($type == 'email') {
         return JString::strlen($this->email) != 0;
     }
     if ($type == 'comment') {
         return JString::strlen($this->comment) != 0;
     }
     return true;
 }
コード例 #7
0
ファイル: helper.php プロジェクト: knigherrant/decopatio
 private static function processItems($posts, &$params)
 {
     $config = EB::getConfig();
     $results = array();
     $posts = EB::formatter('list', $posts);
     foreach ($posts as $data) {
         $row = EB::post($data->id);
         $row->bind($data);
         $row->author = EB::user($row->created_by);
         $row->commentCount = EB::getCommentCount($row->id);
         $row->featuredImage = '';
         if ($params->get('showfeatureimage', 1)) {
             $row->featuredImage = self::getFeaturedImage($row, $params);
         }
         self::prepareTooltipContent($row, $params);
         $results[] = $row;
     }
     return $results;
 }
コード例 #8
0
ファイル: zoo.php プロジェクト: BetterBetterBetter/B3App
 public function migrateZooImages($path, &$blog, $author)
 {
     jimport('joomla.filesystem.file');
     $path = JPATH_ROOT . '/' . $path;
     $config = EB::getConfig();
     $configStorage = str_ireplace('\\', '/', $config->get('main_image_path'));
     $newPath = JPATH_ROOT . '/' . rtrim($configStorage, '/') . '/' . $author->id;
     if (!JFolder::exists($newPath)) {
         JFolder::create($newPath);
     }
     if (JFile::exists($path)) {
         // Copy the full scaled image
         $large = $path;
         $targetURL = rtrim(JURI::root(), '/') . '/' . str_ireplace('\\', '/', $configStorage) . '/' . $author->id;
         $file = getimagesize($large);
         $file['name'] = basename($large);
         $file['tmp_name'] = $large;
         $result = EB::mediamanager()->upload($file, 'user:'******'/' . $file['name'];
             $result->path = $relativeImagePath;
         }
         $result = json_encode($result);
         $blog->image = $result;
     }
 }
コード例 #9
0
 function migrateBloggerImage($image, $userid, $content)
 {
     jimport('joomla.utilities.error');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $config = EB::getConfig();
     $main_image_path = $config->get('main_image_path');
     $main_image_path = rtrim($main_image_path, '/');
     $rel_upload_path = $main_image_path . '/' . $userid;
     $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . str_ireplace('/', DIRECTORY_SEPARATOR, $main_image_path . DIRECTORY_SEPARATOR . $userid);
     $folder = JPath::clean($userUploadPath);
     $dir = $userUploadPath . DIRECTORY_SEPARATOR;
     $tmp_dir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
     if (!JFolder::exists($dir)) {
         JFolder::create($dir);
     }
     //now let get the image from remove url.
     $segments = explode('/', $image);
     $fileName = $segments[count($segments) - 1];
     $fileName = JFile::makesafe($fileName);
     $tmpFileName = $tmp_dir . $fileName;
     $file['name'] = $fileName;
     $file['tmp_name'] = $tmpFileName;
     // write to JOOMLA tmp folder
     file_put_contents($tmpFileName, file_get_contents($image));
     $media = EB::mediamanager();
     $result = $media->upload($file, 'user:'******'tmp_name']);
     if (isset($result->type)) {
         $relativeImagePath = $rel_upload_path . '/' . $file['name'];
         // lets replace the image from the content to this uploaded one.
         $content = str_replace($image, $relativeImagePath, $content);
     }
     return $content;
 }
コード例 #10
0
ファイル: adsense.php プロジェクト: knigherrant/decopatio
 private static function _getAdsenseTemplate($bloggerId, $alignment = '')
 {
     $config = EB::getConfig();
     $my = JFactory::getUser();
     if ($config->get('integration_google_adsense_display_access') == 'members' && $my->id == 0) {
         return '';
     }
     if ($config->get('integration_google_adsense_display_access') == 'guests' && $my->id > 0) {
         return '';
     }
     if (!$config->get('integration_google_adsense_enable')) {
         return '';
     }
     if ($config->get('integration_google_adsense_centralized')) {
         $adminAdsenseCode = $config->get('integration_google_adsense_code');
         $adsenseResponsiveCode = $config->get('integration_google_adsense_responsive_code');
         $adminAdsenseDisplay = $config->get('integration_google_adsense_display');
         if (!empty($adminAdsenseCode) && !$config->get('integration_google_adsense_responsive')) {
             $defaultCode = $adminAdsenseCode;
             $defaultDisplay = $adminAdsenseDisplay;
         } else {
             $defaultCode = $adsenseResponsiveCode;
             $defaultDisplay = $adminAdsenseDisplay;
         }
     }
     //blogger adsense
     //now we check whether user enabled adsense or not.
     $bloggerAdsense = EB::table('Adsense');
     $bloggerAdsense->load($bloggerId);
     if (!empty($bloggerAdsense->code) && $bloggerAdsense->published) {
         $defaultCode = $bloggerAdsense->code;
         $defaultDisplay = $bloggerAdsense->display;
     }
     // @task: If the user did not enter any adsense codes, fallback to the site admin's code
     if (empty($defaultCode)) {
         $adminAdsenseCode = $config->get('integration_google_adsense_code');
         $adminAdsenseDisplay = $config->get('integration_google_adsense_display');
         if (!empty($adminAdsenseCode)) {
             $defaultCode = $adminAdsenseCode;
             $defaultDisplay = $adminAdsenseDisplay;
         }
     }
     if ($defaultDisplay != 'userspecified') {
         return '';
     }
     $responsive = $config->get('integration_google_adsense_responsive');
     $theme = EB::template();
     $theme->set('code', $defaultCode);
     $align = '';
     if (!empty($alignment)) {
         $align = $alignment == 'right' ? ' alignright' : ' alignleft';
     }
     $theme->set('alignment', $align);
     $namespace = 'site/adsense/responsive';
     if (!$responsive) {
         $namespace = 'site/adsense/code';
     }
     $adsenseHTML = $theme->output($namespace);
     return $adsenseHTML;
 }
コード例 #11
0
ファイル: comments.php プロジェクト: knigherrant/decopatio
 /**
  * Delete comments from particular post
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function deletePostComments($postId)
 {
     $db = EB::db();
     $config = EB::getConfig();
     // if komento exist and check the integration option
     $komentoEngine = JPATH_ROOT . '/components/com_komento/helpers/helper.php';
     if (JFile::exists($komentoEngine) && $config->get('comment_komento') == true) {
         require_once $komentoEngine;
         $model = Komento::getModel('comments');
         // delete comment based on the article id
         $model->deleteArticleComments('com_easyblog', $postId);
     }
     $query = array();
     $query[] = 'DELETE FROM ' . $db->quoteName('#__easyblog_comment');
     $query[] = 'WHERE ' . $db->quoteName('post_id') . '=' . $db->Quote($postId);
     $query = implode(' ', $query);
     $db->setQuery($query);
     return $db->Query();
 }