Beispiel #1
0
 /**
  * createInfoBox
  *
  * @param Container  $container
  * @param \stdClass  $article
  * @param mixed      $params
  *
  * @return  string
  */
 public static function createInfoBox(Container $container, $article, $params = null)
 {
     // Include Component Core
     $param = ExtensionHelper::getParams('com_userxtd');
     $doc = \JFactory::getDocument();
     $app = $container->get('app');
     LanguageHelper::loadLanguage('com_userxtd', 'admin');
     // init params
     $image_field = $param->get('UserInfo_ImageField', 'BASIC_AVATAR');
     $website_field = $param->get('UserInfo_WebiteField', 'BASIC_WEBSITE');
     $include_css = $param->get('UserInfo_IncludeCSS_Article', 1);
     // Image params
     $width = $param->get('UserInfo_ImageWidth', 150);
     $height = $param->get('UserInfo_ImageHeight', 150);
     $crop = $param->get('UserInfo_ImageCrop', 1) ? \JImage::CROP_RESIZE : false;
     // Include CSS
     if ($include_css) {
         /** @var $asset \Windwalker\Helper\AssetHelper */
         $asset = $container->get('helper.asset');
         $asset->addCss('userxtd-userinfo.css', 'com_userxtd');
     }
     $user = \UXFactory::getUser($article->created_by);
     // Images
     $image = $user->get($image_field);
     $thumb = new Thumb(null, 'com_userxtd');
     $image = $thumb->resize($image, $width, $height, $crop);
     // Link
     $query = array('option' => 'com_users', 'view' => 'profile', 'id' => $user->get('id'));
     $link = \JRoute::_('index.php?' . http_build_query($query));
     //Route::_('com_userxtd.user_id', array('id' => $user->get('id')));
     // Website
     $website_link = $user->get($website_field);
     // Render
     return with(new FileLayout('userxtd.content.userinfo', null, array('component' => 'com_userxtd')))->render(array('params' => $param, 'article' => $article, 'link' => $link, 'website_link' => $website_link, 'image' => $image, 'user' => $user));
 }
Beispiel #2
0
 /**
  * Method to get a single record.
  *
  * @param	integer	$pk The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : $this->state->get($this->getName() . '.id');
     $user = UXFactory::getUser($pk);
     if ($user) {
         return (object) get_object_vars($user);
     }
     return false;
 }
Beispiel #3
0
 /**
  * createInfoBox
  *
  * @param $context
  * @param $article
  * @param $params
  *
  * @return  string
  */
 public static function createInfoBox($context, $article, $params)
 {
     $input->{$option} = JRequest::getVar('option');
     $view = JRequest::getVar('view');
     $layout = JRequest::getVar('layout', 'default');
     if ($option != 'com_content' || $view != 'article' || $layout != 'default') {
         return;
     }
     // Include Component Core
     include_once JPATH_ADMINISTRATOR . '/components/com_userxtd/includes/core.php';
     $ux = plgSystemUserxtd::getInstance();
     $param = $ux->params;
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     UXHelper::_('lang.loadLanguage', 'com_userxtd', 'admin');
     if ($app->isAdmin()) {
         return;
     }
     // init params
     $image_field = $param->get('UserInfo_ImageField', 'BASIC_AVATAR');
     $title_field = $param->get('UserInfo_TitleField', 'name');
     $about_field = $param->get('UserInfo_AboutField', 'BASIC_ABOUT');
     $website_field = $param->get('UserInfo_WebiteField', 'BASIC_WEBSITE');
     $width = $param->get('UserInfo_ImageWidth', 150);
     $height = $param->get('UserInfo_ImageHeight', 150);
     $crop = $param->get('UserInfo_ImageCrop', 1);
     $include_css = $param->get('UserInfo_IncludeCSS_Article', 1);
     // Include CSS
     if ($include_css) {
         $doc->addStyleSheet('administrator/components/com_userxtd/includes/bootstrap/css/bootstrap.min.css');
         $doc->addStyleSheet('components/com_userxtd/includes/css/userxtd-userinfo.css');
     }
     // handle params
     $user = UXFactory::getUser($article->created_by);
     $image = $user->get($image_field);
     $image = AKHelper::_('thumb.resize', $image, $width, $height, $crop);
     $link = JRoute::_('index.php?option=com_userxtd&view=user&id=' . $user->get('id'));
     $link = JHtml::link($link, JText::_('COM_USERXTD_USER_INFO_MORE'));
     $website_link = $user->get($website_field);
     $website_link = $website_link ? JHtml::link($website_link, JText::_('COM_USERXTD_USER_INFO_WEBSITE')) : null;
     // Get Template override
     $tpl = $app->getTemplate();
     $file = JPATH_THEMES . "/{$tpl}/html/plg_userxtd/content/userInfo.php";
     if (!JFile::exists($file)) {
         $file = dirname(__FILE__) . '/tmpl/userInfo.php';
     }
     // Start capturing output into a buffer
     ob_start();
     // Include the requested template filename in the local scope
     include $file;
     // Done with the requested template; get the buffer and clear it.
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }