/**
  * @since       1.1.0
  */
 public static function getLayoutPath($type, $name, $layout = 'default')
 {
     // Create the plugin name
     $extension = 'plg_' . $type . '_' . $name;
     if (!($path = self::getPath($extension, $layout))) {
         if (FieldsandfiltersFactory::isVersion()) {
             $path = JPluginHelper::getLayoutPath($type, $name, $layout);
         } else {
             $template = JFactory::getApplication()->getTemplate();
             $defaultLayout = $layout;
             if (strpos($layout, ':') !== false) {
                 // Get the template and file name from the string
                 $temp = explode(':', $layout);
                 $template = $temp[0] == '_' ? $template : $temp[0];
                 $layout = $temp[1];
                 $defaultLayout = $temp[1] ? $temp[1] : 'default';
             }
             // Build the template and base path for the layout
             $tPath = JPATH_THEMES . '/' . $template . '/html/plg_' . $type . '_' . $name . '/' . $layout . '.php';
             $bPath = JPATH_BASE . '/plugins/' . $type . '/' . $name . '/tmpl/' . $defaultLayout . '.php';
             $dPath = JPATH_BASE . '/plugins/' . $type . '/' . $name . '/tmpl/default.php';
             // If the template has a layout override use it
             if (file_exists($tPath)) {
                 $path = $tPath;
             } elseif (file_exists($bPath)) {
                 $path = $bPath;
             } else {
                 $path = $dPath;
             }
         }
         self::setPath($path, $extension, $layout);
     }
     return $path;
 }
Example #2
0
 public function onContentAfterDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.details", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     $html = "";
     $files = new CrowdfundingFiles\Files(JFactory::getDbo());
     $files->load(array("project_id" => $item->id));
     if (count($files) > 0) {
         $mediaFolderUri = CrowdfundingFilesHelper::getMediaFolderUri($item->user_id);
         // Get the path for the layout file
         $path = JPath::clean(JPluginHelper::getLayoutPath('content', 'crowdfundingfiles'));
         // Render the login form.
         ob_start();
         include $path;
         $html = ob_get_clean();
     }
     return $html;
 }
 /**
  * Method called to prepare content before html output
  *
  * @param string  $context    The context of the content being passed to the plugin.
  * @param object  &$item      The content object.  Note $item->text is also available
  * @param object  &$params    The content params.
  * @param integer $page       The 'page' number.
  *
  * @return mixed Returns void on success or false otherwise
  *
  * @since 2.5
  */
 public function onContentPrepare($context, &$row, &$params, $page = 0)
 {
     require_once dirname(__FILE__) . '/helper.php';
     // Simple performance check to determine whether bot should process further.
     if (JString::strpos($row->text, '{gallery}') === false) {
         return;
     }
     $regex = "/{gallery}(.+?){\\/gallery}/is";
     preg_match_all($regex, $row->text, $matches);
     if (!count($matches)) {
         return;
     }
     // Get the path for the layout file
     $version = new JVersion();
     if ($version->isCompatible(3.0)) {
         $path = JPluginHelper::getLayoutPath('content', 'gallery');
     } else {
         $path = GalleryHelper::getLayoutPath('content', 'gallery');
     }
     foreach ($matches[1] as $source) {
         $row->gallery = GalleryHelper::getGallery($source, '200x160', true, 90, 86400, $row->id);
         ob_start();
         include $path;
         $html = ob_get_contents();
         ob_end_clean();
         $regex = '/{gallery}' . str_replace('.', '\\.', str_replace('/', '\\/', $source)) . '{\\/gallery}/is';
         $row->text = preg_replace($regex, $html, $row->text);
     }
     return true;
 }
Example #4
0
 public function onDisplaySlider()
 {
     if (!$this->isHomePage()) {
         return;
     }
     $app = JFactory::getApplication();
     $articles = $this->getLatestPublishedArticles();
     ob_start();
     include JPluginHelper::getLayoutPath('content', 'slider');
     return ob_get_clean();
 }
 /**
  * Textfield or Form of the Plugin.
  *
  * @return  array  Returns an array with the tab information
  *
  * @since   3.6.0
  */
 public function onInstallerAddInstallationTab()
 {
     $tab = array();
     $tab['name'] = 'package';
     $tab['label'] = JText::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_PACKAGE_FILE');
     // Render the input
     ob_start();
     include JPluginHelper::getLayoutPath('installer', 'packageinstaller');
     $tab['content'] = ob_get_clean();
     return $tab;
 }
 /**
  * Textfield or Form of the Plugin.
  *
  * @return  array  Returns an array with the tab information
  *
  * @since   3.6.0
  */
 public function onInstallerAddInstallationTab()
 {
     $tab = array();
     $tab['name'] = 'url';
     $tab['label'] = JText::_('PLG_INSTALLER_URLINSTALLER_TEXT');
     // Render the input
     ob_start();
     include JPluginHelper::getLayoutPath('installer', 'urlinstaller');
     $tab['content'] = ob_get_clean();
     return $tab;
 }
 public function onContentAfterDisplay($context, &$article, &$params, $limitstart)
 {
     $app = JFactory::getApplication();
     $view = $app->input->get('view');
     if ($context == 'com_content.article' && $view == 'article') {
         $articles = $this->getRelatedArticles($article->id, $article->catid);
         ob_start();
         include JPluginHelper::getLayoutPath('content', 'relatedarticles');
         return ob_get_clean();
     }
     return;
 }
Example #8
0
 /**
  * This method prepares a code that will be included to step "Extras" on project wizard.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onExtrasDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.project.extras", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (empty($item->user_id)) {
         return null;
     }
     // Create a media folder.
     $mediaFolder = CrowdfundingFilesHelper::getMediaFolder();
     if (!JFolder::exists($mediaFolder)) {
         CrowdfundingHelper::createFolder($mediaFolder);
     }
     // Create a media folder for a user.
     $mediaFolder = CrowdfundingFilesHelper::getMediaFolder($item->user_id);
     if (!JFolder::exists($mediaFolder)) {
         CrowdfundingHelper::createFolder($mediaFolder);
     }
     $componentParams = JComponentHelper::getParams("com_crowdfundingfiles");
     /** @var  $componentParams Joomla\Registry\Registry */
     $mediaUri = CrowdfundingFilesHelper::getMediaFolderUri($item->user_id);
     $options = array("project_id" => $item->id, "user_id" => $item->user_id);
     $files = new CrowdfundingFiles\Files(JFactory::getDbo());
     $files->load($options);
     // Load jQuery
     JHtml::_("jquery.framework");
     JHtml::_("prism.ui.pnotify");
     JHtml::_('prism.ui.fileupload');
     JHtml::_('prism.ui.joomlaHelper');
     // Include the translation of the confirmation question.
     JText::script('PLG_CROWDFUNDING_FILES_DELETE_QUESTION');
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'files'));
     // Render the login form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
Example #9
0
 /**
  * This method prepares a code that will be included to step "Extras" on project wizard.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onExtrasDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.project.extras", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (empty($item->user_id)) {
         return null;
     }
     // A flag that shows the options are active.
     if (!$this->params->get("display_paypal", 0) and !$this->params->get("display_banktransfer", 0)) {
         return "";
     }
     $activeTab = "";
     if ($this->params->get("display_paypal", 0)) {
         $activeTab = "paypal";
     } elseif ($this->params->get("display_banktransfer", 0)) {
         $activeTab = "banktransfer";
     }
     $payout = new CrowdfundingFinance\Payout(JFactory::getDbo());
     $payout->load($item->id);
     // Load jQuery
     JHtml::_("jquery.framework");
     JHtml::_("prism.ui.pnotify");
     JHtml::_('prism.ui.joomlaHelper');
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'payoutoptions'));
     // Render the login form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
 public function onContentPrepare($context, &$article, &$params, $page)
 {
     $pattern = '/\\{simpleimageslider (.*)\\}/';
     if (preg_match($pattern, $article->text) !== 1) {
         return;
     }
     JHTML::_('bootstrap.framework');
     // TODO necessary or is jQuery enough?
     $doc = JFactory::getDocument();
     $doc->addScript('media/plg_content_simpleimageslider/simpleimageslider.js');
     $doc->addStyleSheet('media/plg_content_simpleimageslider/simpleimageslider.css');
     $path = JPluginHelper::getLayoutPath('content', 'simpleimageslider');
     $replacement = file_get_contents($path);
     $lang = JFactory::getLanguage();
     $lang->load('plg_content_simpleimageslider', JPATH_ADMINISTRATOR);
     $replacement = preg_replace('/SIS_LOADING/', JText::_('PLG_CONTENT_SIMPLEIMAGESLIDER_LOADING'), $replacement);
     $replacement = preg_replace('/SIS_IMAGE/', JText::_('PLG_CONTENT_SIMPLEIMAGESLIDER_IMAGE'), $replacement);
     $replacement = preg_replace('/SIS_OF/', JText::_('PLG_CONTENT_SIMPLEIMAGESLIDER_OF'), $replacement);
     $replacement = preg_replace('/SIS_BASEPATH/', JURI::base(), $replacement);
     $article->text = preg_replace($pattern, $replacement, $article->text);
     // TODO use preg_quote for $replacement?
 }
Example #11
0
 /**
  * Generate and display a list of team members on details page.
  *
  * @param string $context
  * @param object $item
  * @param Joomla\Registry\Registry $params
  *
  * @return null|string
  */
 public function onContentAfterDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.details", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     $html = "";
     $partners = new CrowdfundingPartners\Partners(JFactory::getDbo());
     $partners->load($item->id);
     if (0 < count($partners)) {
         // Include the project owner to the team.
         if ($this->params->get("display_owner", 0)) {
             $user = JFactory::getUser($item->user_id);
             $owner = array("name" => $user->get("name"), "project_id" => $item->id, "partner_id" => $item->user_id);
             $partners->add($owner);
         }
         // Get a social platform for integration
         $socialPlatform = $params->get("integration_social_platform");
         // Prepare avatars.
         $this->prepareIntegration($partners, $socialPlatform);
         // Get the path for the layout file
         $path = JPath::clean(JPluginHelper::getLayoutPath('content', 'crowdfundingpartners'));
         // Render the login form.
         ob_start();
         include $path;
         $html = ob_get_clean();
     }
     return $html;
 }
Example #12
0
 /**
  * This method prepares a code that will be included to step "Extras" on project wizard.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onExtrasDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.project.extras", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (empty($item->user_id)) {
         return null;
     }
     $partners = new CrowdfundingPartners\Partners(JFactory::getDbo());
     $partners->load($item->id);
     // Get a social platform for integration
     $socialPlatform = $params->get("integration_social_platform");
     // Prepare avatars.
     $this->prepareIntegration($partners, $socialPlatform);
     // Load jQuery
     JHtml::_("jquery.framework");
     JHtml::_("prism.ui.pnotify");
     JHtml::_('prism.ui.joomlaHelper');
     // Include the translation of the confirmation question.
     JText::script('PLG_CROWDFUNDING_PARTNERS_DELETE_QUESTION');
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'partners'));
     // Render the login form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
Example #13
0
 /**
  * This method prepares a payment gateway - buttons, forms,...
  * That gateway will be displayed on the summary page as a payment option.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onProjectPayment($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.payment", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     JHtml::_('jquery.framework');
     JText::script('PLG_CROWDFUNDINGPAYMENT_BANKTRANSFER_REGISTER_TRANSACTION_QUESTION');
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfundingpayment', 'banktransfer'));
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
Example #14
0
<?php

defined('_JEXEC') or die;
?>

<div class="main-slider-wrap">
    <div class="main-slider">
        <?php 
foreach ($articles as $item) {
    ?>
            <?php 
    require JPluginHelper::getLayoutPath('content', 'slider', $app->input->get('layout', 'default') . '_slide_image');
    ?>
        <?php 
}
?>
    </div>

    <div class="main-text-slider">
        <?php 
foreach ($articles as $item) {
    ?>
            <?php 
    require JPluginHelper::getLayoutPath('content', 'slider', $app->input->get('layout', 'default') . '_slide_text');
    ?>
        <?php 
}
?>
    </div>
</div>
 /**
  * Test JPluginHelper::getLayoutPath
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testGetLayoutPath()
 {
     $this->assertEquals(JPluginHelper::getLayoutPath('content', 'pagenavigation'), JPATH_ROOT . '/plugins/content/pagenavigation/tmpl/default.php', 'The default layout path for plg_content_pagenavigation should be returned');
 }
Example #16
0
 /**
  * Displays the voting area
  *
  * @param   string   $context  The context of the content being passed to the plugin
  * @param   object   &$row     The article object
  * @param   object   &$params  The article params
  * @param   integer  $page     The 'page' number
  *
  * @return  string|boolean  HTML string containing code for the votes if in com_content else boolean false
  *
  * @since   __DEPLOY_VERSION__
  */
 private function displayVotingData($context, &$row, &$params, $page)
 {
     $parts = explode(".", $context);
     if ($parts[0] != 'com_content') {
         return false;
     }
     if (empty($params) || !$params->get('show_vote', null)) {
         return '';
     }
     // Load plugin language files only when needed (ex: they are not needed if show_vote is not active).
     $this->loadLanguage();
     // Get the path for the rating summary layout file
     $path = JPluginHelper::getLayoutPath('content', 'vote', 'rating');
     // Render the layout
     ob_start();
     include $path;
     $html = ob_get_clean();
     if ($this->app->input->getString('view', '') == 'article' && $row->state == 1) {
         // Get the path for the voting form layout file
         $path = JPluginHelper::getLayoutPath('content', 'vote', 'vote');
         // Render the layout
         ob_start();
         include $path;
         $html .= ob_get_clean();
     }
     return $html;
 }
Example #17
0
 /**
  * This method prepares a payment gateway - buttons, forms,...
  * That gateway will be displayed on the summary page as a payment option.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onPaymentExtras($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.payment.step2", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     // Load language file of the component.
     $language = JFactory::getLanguage();
     $language->load('com_crowdfundingdata', CROWDFUNDINGDATA_PATH_COMPONENT_SITE);
     $componentParams = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $componentParams Joomla\Registry\Registry */
     // Get payment session.
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
     $paymentSession = $this->app->getUserState($paymentSessionContext);
     if (!isset($paymentSession->step1)) {
         $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfundingpayment', 'data', 'error'));
         // Render error layout.
         ob_start();
         include $path;
         return ob_get_clean();
     }
     // Get the value of therms and conditions.
     $this->terms = $paymentSession->terms;
     // Check for duplication of session ID.
     $this->prepareSessionId($item);
     // Load the form.
     JForm::addFormPath(CROWDFUNDINGDATA_PATH_COMPONENT_SITE . '/models/forms');
     JForm::addFieldPath(CROWDFUNDINGDATA_PATH_COMPONENT_SITE . '/models/fields');
     $form = JForm::getInstance('com_crowdfundingdata.record', 'record', array('control' => "jform", 'load_data' => false));
     // Prepare default name of a user.
     $user = JFactory::getUser();
     if ($user->get("id")) {
         $form->setValue("name", null, $user->get("name"));
     }
     // Set item id to the form.
     $form->setValue("project_id", null, $item->id);
     $this->form = $form;
     // Load jQuery
     JHtml::_("jquery.framework");
     // Include Chosen
     if ($this->params->get("enable_chosen", 0)) {
         JHtml::_('formbehavior.chosen', '#jform_country_id');
     }
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfundingpayment', 'data'));
     // Render the form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
Example #18
0
    /**
     * This method prepares a payment gateway - buttons, forms,...
     * That gateway will be displayed on the summary page as a payment option.
     *
     * @param string    $context This string gives information about that where it has been executed the trigger.
     * @param object    $item    A project data.
     * @param Joomla\Registry\Registry $params  The parameters of the component
     *
     * @return null|string
     */
    public function onPaymentExtras($context, &$item, &$params)
    {
        if (strcmp("com_crowdfunding.payment.step2", $context) != 0) {
            return null;
        }
        if ($this->app->isAdmin()) {
            return null;
        }
        $doc = JFactory::getDocument();
        /**  @var $doc JDocumentHtml */
        // Check document type
        $docType = $doc->getType();
        if (strcmp("html", $docType) != 0) {
            return null;
        }
        // Get user ID.
        $userId = JFactory::getUser()->get("id");
        // Display login form
        if (!$userId) {
            // Get the form.
            JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
            JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
            $form = JForm::getInstance('com_users.login', 'login', array('load_data' => false), false, false);
            $this->loginForm = $form;
            $this->returnUrl = CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug);
            // Get the path for the layout file
            $path = JPluginHelper::getLayoutPath('crowdfundingpayment', 'login');
            // Render the login form.
            ob_start();
            include $path;
            $html = ob_get_clean();
        } else {
            // Redirect to step "Payment".
            $componentParams = JComponentHelper::getParams("com_crowdfunding");
            /** @var  $componentParams Joomla\Registry\Registry */
            // Get the payment process object and
            // store the selected data from the user.
            $paymentProcessContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
            $paymentSession = $this->app->getUserState($paymentProcessContext);
            $this->rewardId = $paymentSession->rewardId;
            $this->amount = $paymentSession->amount;
            $this->terms = $paymentSession->terms;
            // Get the path for the layout file
            $path = JPluginHelper::getLayoutPath('crowdfundingpayment', 'login', 'redirect');
            // Render the login form.
            ob_start();
            include $path;
            $html = ob_get_clean();
            // Include JavaScript code to redirect user to next step.
            $processUrl = JUri::base() . "index.php?option=com_crowdfunding&task=backing.process&id=" . (int) $item->id . "&rid=" . (int) $this->rewardId . "&amount=" . rawurldecode($this->amount) . "&" . JSession::getFormToken() . "=1";
            // Set the value of terms of use condition.
            if ($componentParams->get("backing_terms", 0) and !empty($this->terms)) {
                $processUrl .= "&terms=1";
            }
            $filter = JFilterInput::getInstance();
            $processUrl = $filter->clean($processUrl);
            $js = '
jQuery(document).ready(function() {
     window.location.replace("' . $processUrl . '");
});';
            $doc->addScriptDeclaration($js);
        }
        return $html;
    }
Example #19
0
 /**
  * @param string    $context
  * @param object    $item
  * @param Joomla\Registry\Registry    $params
  * @param int $page
  *
  * @return null|string
  */
 public function onContentAfterDisplay($context, &$item, &$params, $page = 0)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (strcmp("com_crowdfunding.details", $context) != 0) {
         return null;
     }
     $user = JFactory::getUser($item->user_id);
     // Load language
     $this->loadLanguage();
     if ($this->params->get("display_location", 0) or $this->params->get("display_map", 0)) {
         $location = $this->getLocation($item->location_id);
     }
     // Social Profile Integration
     $componentParams = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $componentParams Joomla\Registry\Registry */
     // Check for verified user account.
     $proofVerified = false;
     if ($this->params->get("display_account_state", 0) and JComponentHelper::isEnabled("com_identityproof")) {
         jimport("IdentityProof.init");
         $proof = new IdentityProof\User(JFactory::getDbo());
         $proof->load(array("user_id" => $user->get("id")));
         if ($proof->isVerified()) {
             $proofVerified = true;
         }
     }
     // Get profile
     $socialPlatform = $componentParams->get("integration_social_platform");
     if (!empty($socialPlatform)) {
         // Get social profile
         $config = array("social_platform" => $socialPlatform, "user_id" => $user->get("id"));
         $profileBuilder = new Prism\Integration\Profile\Builder($config);
         $profileBuilder->build();
         $socialProfile = $profileBuilder->getProfile();
         $profileLink = $socialProfile->getLink();
         // Prepare the avatar
         $socialAvatar = $socialProfile->getAvatar($this->params->get("image_size", "small"));
         $socialLocation = $socialProfile->getLocation();
         if ($socialProfile->getCountryCode()) {
             $socialLocation .= ", " . $socialProfile->getCountryCode();
         }
     } else {
         // Set default values
         $profileLink = "";
         $socialAvatar = $params->get("integration_avatars_default", "/media/com_crowdfunding/images/no-profile.png");
         $socialLocation = "";
     }
     // END Social Profile Integration
     // Preparing HTML output
     // Prepare map
     $mapCode = "";
     if ($this->params->get("display_map", 0) and !empty($location)) {
         $mapCode = $this->getMapCode($doc, $location);
     }
     // Prepare output
     // Get the path for the layout file
     $path = JPluginHelper::getLayoutPath('content', 'crowdfundinginfo', 'default');
     // Render the login form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
 /**
  * This method prepares a code that will be included to step "Extras" on project wizard.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param stdClass    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onExtrasDisplay($context, $item, $params)
 {
     if (strcmp('com_crowdfunding.project.extras', $context) !== 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp('html', $docType) !== 0) {
         return null;
     }
     if (!isset($item->user_id) or !$item->user_id) {
         return null;
     }
     // A flag that shows the options are active.
     if (!$this->params->get('display_paypal', 0) and !$this->params->get('display_banktransfer', 0) and !$this->params->get('display_stripe', 0)) {
         return '';
     }
     $activeTab = '';
     if ($this->params->get('display_paypal', 0)) {
         $activeTab = 'paypal';
     } elseif ($this->params->get('display_banktransfer', 0)) {
         $activeTab = 'banktransfer';
     } elseif ($this->params->get('display_stripe', 0)) {
         $activeTab = 'stripe';
     }
     $payout = new Crowdfundingfinance\Payout(JFactory::getDbo());
     $payout->setSecretKey($this->app->get('secret'));
     $payout->load(array('project_id' => $item->id));
     // Create payout record, if it does not exists.
     if (!$payout->getId()) {
         $payout->setProjectId($item->id);
         $payout->store();
     }
     // Check if Stripe connected.
     if ($this->params->get('display_stripe', 0)) {
         $stripeWarning = null;
         $stripeButton = array();
         $cfFinanceParams = JComponentHelper::getParams('com_crowdfundingfinance');
         // Get keys.
         $apiKeys = Crowdfundingfinance\Stripe\Helper::getKeys($cfFinanceParams);
         if (!$apiKeys['client_id']) {
             $stripeWarning = JText::_('PLG_CROWDFUNDING_PAYOUTOPTIONS_ERROR_STRIPE_NOT_CONFIGURED');
         }
         $token = Crowdfundingfinance\Stripe\Helper::getPayoutAccessToken($apiKeys, $payout, $cfFinanceParams->get('stripe_expiration_period', 7));
         // Generate state HASH and use it as a session key that contains redirect URL.
         $state = Prism\Utilities\StringHelper::generateRandomString(32);
         $stateData = array('redirect_url' => base64_encode(JRoute::_(CrowdfundingHelperRoute::getFormRoute($item->id, 'extras'), false)), 'project_id' => $item->id);
         $this->app->setUserState($state, $stateData);
         if (!$token) {
             $stripeButton[] = '<div class="mt-20">';
             $stripeButton[] = '<a href="https://connect.stripe.com/oauth/authorize?response_type=code&client_id=' . $apiKeys['client_id'] . '&scope=read_write&state=' . $state . '&redirect_uri=' . rawurlencode($this->params->get('stripe_redirect_uri')) . '">';
             $stripeButton[] = '<img src="media/com_crowdfundingfinance/images/stripe/' . $cfFinanceParams->get('button', 'blue-on-dark') . '.png" width="190" height="33" />';
             $stripeButton[] = '</a>';
             $stripeButton[] = '</div>';
         } else {
             $url = JRoute::_('index.php?option=com_crowdfundingfinance&task=payouts.deauthorize&payment_service=stripeconnect&pid=' . (int) $item->id . '&state=' . $state . '&' . JSession::getFormToken() . '=1');
             $stripeButton[] = '<div class="mt-20">';
             $stripeButton[] = '<p class="alert alert-info"><span class="fa fa-info-circle"></span> ' . JText::_('PLG_CROWDFUNDING_PAYOUTOPTIONS_STRIPE_CONNECTED') . '</p>';
             $stripeButton[] = '<a href="' . $url . '" class="btn btn-danger" id="js-cff-btn-stripe-disconnect">';
             $stripeButton[] = '<span class="fa fa-chain-broken"></span> ' . JText::_('PLG_CROWDFUNDING_PAYOUTOPTIONS_DISCONNECT_STRIPE');
             $stripeButton[] = '</a>';
             $stripeButton[] = '</div>';
         }
     }
     // Load jQuery
     JHtml::_('jquery.framework');
     JHtml::_('Prism.ui.pnotify');
     JHtml::_('Prism.ui.joomlaHelper');
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'payoutoptions'));
     // Render the login form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
 protected function getShares($row)
 {
     JHtml::_('bootstrap.framework');
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $user = JFactory::getUser();
     $uri = JFactory::getURI();
     $twittervia = $this->params->get('twitter-via');
     $theme = $this->params->get('theme', 'basic');
     $view = $app->input->getCmd('view');
     $views = $this->params->get('views');
     $cssId = $this->params->get('css_id') ? $this->params->get('css_id') : '';
     $cssClass = $this->params->get('css_class') ? $this->params->get('css_class') : '';
     $html = '';
     $newServiceArray = '';
     $bitlyState = (bool) $this->params->get('bitly-state');
     $bitlyDomain = (string) $this->params->get('bitly-domain');
     $bitlyAccessToken = (string) $this->params->get('bitly-access-token');
     if (!$user->id and $app->getName() != 'site') {
         return false;
     }
     if (!in_array($view, $views)) {
         return false;
     }
     /*
     		$html .= '<pre>';
     		$html .= count($views) . '<br>';
     		$html .= print_r($view, true) . '<br>';
     		$html .= print_r($views, true);
     		$html .= '</pre>';
     		//*/
     if (!defined('SOCIALSHARE_LOADED')) {
         $doc->addStylesheet('plugins/content/socialshare/assets/socialshare/themes/' . $theme . '/css/styles.min.css');
         $doc->addScriptDeclaration($this->loadAjax());
         require_once JPATH_PLUGINS . DS . 'content' . DS . 'socialshare' . DS . 'assets' . DS . 'socialshare' . DS . 'library' . DS . 'shares.php';
         define('SOCIALSHARE_LOADED', true);
     }
     $longUrl = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid));
     // TODO: Error-Handling. If you test oin localhost, bitly give an 500-Error :-/
     if ($bitlyState and !empty($bitlyDomain) and !empty($bitlyAccessToken)) {
         $shortUrl = trim(file_get_contents('https://api-ssl.bitly.com/v3/shorten?access_token=' . $bitlyAccessToken . '&longUrl=' . urlencode($longUrl) . '&domain=' . $bitlyDomain . '&format=txt'));
     }
     if (!empty($shortUrl)) {
         $url = $shortUrl;
     } else {
         $url = $longUrl;
     }
     $layoutPath = JPluginHelper::getLayoutPath('content', 'socialshare');
     $socialshares = new SocialShares();
     foreach ($socialshares->services as $service => $options) {
         if ($this->params->get($service)) {
             $params = '';
             if ($service == 'twitter' and !empty($twittervia)) {
                 $params = '&amp;via=' . $twittervia;
             }
             $newServiceArray['options']['css-id'] = $cssId;
             $newServiceArray['options']['css-class'] = $cssClass;
             $newServiceArray['options']['article-id'] = $app->input->getCmd('id');
             $newServiceArray['options']['article-url'] = $longUrl;
             $newServiceArray['services'][$service] = $options;
             $newServiceArray['services'][$service]['share-url'] = $socialshares->getUrlToShare($service, $url, $row->title) . $params;
         }
     }
     ob_start();
     require_once $layoutPath;
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
 /**
  * Listener for the `onContentAfterTitle` event
  *
  * @param   string   $context   The context of the content being passed to the plugin.
  * @param   object   &$article  The article object.  Note $article->text is also available
  * @param   object   &$params   The article params
  * @param   integer  $page      The 'page' number
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onContentAfterTitle($context, &$article, &$params, $page)
 {
     // Set the parameters
     $document = JFactory::getDocument();
     $displayEmail = $this->params->get('displayEmail', '1');
     $displayFacebook = $this->params->get('displayFacebook', '1');
     $displayGoogle = $this->params->get('displayGoogle', '1');
     $displayLinkedin = $this->params->get('displayLinkedin', '1');
     $displayPinterest = $this->params->get('displayPinterest', '1');
     $displayTwitter = $this->params->get('displayTwitter', '1');
     $selectedCategories = $this->params->def('displayCategories', '');
     $position = $this->params->def('displayPosition', 'top');
     $view = $this->app->input->getCmd('view', '');
     $shorten = $this->params->def('useYOURLS', true);
     // Check if the plugin is enabled
     if (JPluginHelper::isEnabled('content', 'joomlarrssb') == false) {
         return;
     }
     // Make sure the document is an HTML document
     if ($document->getType() != 'html') {
         return;
     }
     // Check whether we're displaying the plugin in the current view
     if ($this->params->get('view' . ucfirst($view), '1') == '0') {
         return;
     }
     // Check that we're actually displaying a button
     if ($displayEmail == '0' && $displayFacebook == '0' && $displayGoogle == '0' && $displayLinkedin == '0' && $displayPinterest == '0' && $displayTwitter == '0') {
         return;
     }
     // If we're not in the article view, we have to get the full $article object ourselves
     if ($view == 'featured' || $view == 'category') {
         /*
          * We only want to handle com_content items; if this function returns null, there's no DB item
          * Also, make sure the object isn't already loaded and undo previous plugin processing
          */
         $data = $this->loadArticle($article);
         if (!is_null($data) && !isset($article->catid)) {
             $article = $data;
         }
     }
     // Make sure we have a category ID, otherwise, end processing
     $properties = get_object_vars($article);
     if (!array_key_exists('catid', $properties)) {
         return;
     }
     // Get the current category
     if (is_null($article->catid)) {
         $currentCategory = 0;
     } else {
         $currentCategory = $article->catid;
     }
     // Define category restrictions
     if (is_array($selectedCategories)) {
         $categories = $selectedCategories;
     } elseif ($selectedCategories == '') {
         $categories = [$currentCategory];
     } else {
         $categories = [$selectedCategories];
     }
     // If we aren't in a defined category, exit
     if (!in_array($currentCategory, $categories)) {
         // If we made it this far, we probably deleted the text object; reset it
         if (!isset($article->text)) {
             $article->text = $article->introtext;
         }
         return;
     }
     // Create the article slug
     $article->slug = $article->alias ? $article->id . ':' . $article->alias : $article->id;
     // Build the URL for the plugins to use
     $siteURL = substr(JUri::root(), 0, -1);
     $itemURL = $siteURL . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
     $document->addCustomTag('<meta property="og:title" content="' . $article->title . '"/>');
     $document->addCustomTag('<meta property="og:type" content="article"/>');
     $document->addCustomTag('<meta property="og:url" content="' . $itemURL . '"/>');
     if ($shorten) {
         $http = JHttpFactory::getHttp();
         $data = array('signature' => $this->params->def('YOURLSAPIKey', '2909bc72e7'), 'action' => 'shorturl', 'url' => $itemURL, 'format' => 'simple');
         $response = $http->post($this->params->def('YOURLSUrl', 'http://joom.la') . '/yourls-api.php', $data);
         if ($response->code == 200) {
             $itemURL = $response->body;
         }
     }
     // Get the content and merge in the template; first see if $article->text is defined
     if (!isset($article->text)) {
         $article->text = $article->introtext;
     }
     // Add extra template metadata
     $pattern = "/<img[^>]*src\\=['\"]?(([^>]*)(jpg|gif|JPG|png|jpeg))['\"]?/";
     preg_match($pattern, $article->text, $matches);
     if (!empty($matches)) {
         $document->addCustomTag('<meta property="og:image" content="' . $siteURL . '/' . $matches[1] . '"/>');
     }
     // Load the layout
     ob_start();
     $template = JPluginHelper::getLayoutPath('content', 'joomlarrssb');
     include $template;
     $output = ob_get_clean();
     // Add the output
     if ($position == 'top') {
         $article->introtext = $output . $article->introtext;
         $article->text = $output . $article->text;
     } else {
         $article->introtext = $output . $article->introtext;
         $article->text .= $output;
     }
     return;
 }
 /**
  * If in the article view and the parameter is enabled shows the page navigation
  *
  * @param   string   $context  The context of the content being passed to the plugin
  * @param   object   &$row     The article object
  * @param   mixed    &$params  The article params
  * @param   integer  $page     The 'page' number
  *
  * @return  mixed  void or true
  *
  * @since   1.6
  */
 public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
 {
     $app = JFactory::getApplication();
     $view = $app->input->get('view');
     $print = $app->input->getBool('print');
     if ($print) {
         return false;
     }
     if ($context == 'com_content.article' && $view == 'article' && $params->get('show_item_navigation')) {
         $db = JFactory::getDbo();
         $user = JFactory::getUser();
         $lang = JFactory::getLanguage();
         $nullDate = $db->getNullDate();
         $date = JFactory::getDate();
         $now = $date->toSql();
         $uid = $row->id;
         $option = 'com_content';
         $canPublish = $user->authorise('core.edit.state', $option . '.article.' . $row->id);
         /**
          * The following is needed as different menu items types utilise a different param to control ordering.
          * For Blogs the `orderby_sec` param is the order controlling param.
          * For Table and List views it is the `orderby` param.
          **/
         $params_list = $params->toArray();
         if (array_key_exists('orderby_sec', $params_list)) {
             $order_method = $params->get('orderby_sec', '');
         } else {
             $order_method = $params->get('orderby', '');
         }
         // Additional check for invalid sort ordering.
         if ($order_method == 'front') {
             $order_method = '';
         }
         // Determine sort order.
         switch ($order_method) {
             case 'date':
                 $orderby = 'a.created';
                 break;
             case 'rdate':
                 $orderby = 'a.created DESC';
                 break;
             case 'alpha':
                 $orderby = 'a.title';
                 break;
             case 'ralpha':
                 $orderby = 'a.title DESC';
                 break;
             case 'hits':
                 $orderby = 'a.hits';
                 break;
             case 'rhits':
                 $orderby = 'a.hits DESC';
                 break;
             case 'order':
                 $orderby = 'a.ordering';
                 break;
             case 'author':
                 $orderby = 'a.created_by_alias, u.name';
                 break;
             case 'rauthor':
                 $orderby = 'a.created_by_alias DESC, u.name DESC';
                 break;
             case 'front':
                 $orderby = 'f.ordering';
                 break;
             default:
                 $orderby = 'a.ordering';
                 break;
         }
         $xwhere = ' AND (a.state = 1 OR a.state = -1)' . ' AND (publish_up = ' . $db->quote($nullDate) . ' OR publish_up <= ' . $db->quote($now) . ')' . ' AND (publish_down = ' . $db->quote($nullDate) . ' OR publish_down >= ' . $db->quote($now) . ')';
         // Array of articles in same category correctly ordered.
         $query = $db->getQuery(true);
         // Sqlsrv changes
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.alias', '!=', '0');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('cc.alias', '!=', '0');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('cc.id');
         $case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('a.id,' . $case_when . ',' . $case_when1)->from('#__content AS a')->join('LEFT', '#__categories AS cc ON cc.id = a.catid')->where('a.catid = ' . (int) $row->catid . ' AND a.state = ' . (int) $row->state . ($canPublish ? '' : ' AND a.access = ' . (int) $row->access) . $xwhere);
         $query->order($orderby);
         if ($app->isSite() && $app->getLanguageFilter()) {
             $query->where('a.language in (' . $db->quote($lang->getTag()) . ',' . $db->quote('*') . ')');
         }
         $db->setQuery($query);
         $list = $db->loadObjectList('id');
         // This check needed if incorrect Itemid is given resulting in an incorrect result.
         if (!is_array($list)) {
             $list = array();
         }
         reset($list);
         // Location of current content item in array list.
         $location = array_search($uid, array_keys($list));
         $rows = array_values($list);
         $row->prev = null;
         $row->next = null;
         if ($location - 1 >= 0) {
             // The previous content item cannot be in the array position -1.
             $row->prev = $rows[$location - 1];
         }
         if ($location + 1 < count($rows)) {
             // The next content item cannot be in an array position greater than the number of array postions.
             $row->next = $rows[$location + 1];
         }
         // $pnSpace is/can be used in the include file
         $pnSpace = "";
         if (JText::_('JGLOBAL_LT') || JText::_('JGLOBAL_GT')) {
             $pnSpace = " ";
         }
         if ($row->prev) {
             $row->prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->prev->slug, $row->prev->catslug));
         } else {
             $row->prev = '';
         }
         if ($row->next) {
             $row->next = JRoute::_(ContentHelperRoute::getArticleRoute($row->next->slug, $row->next->catslug));
         } else {
             $row->next = '';
         }
         // Output.
         if ($row->prev || $row->next) {
             // Get the path for the layout file
             $path = JPluginHelper::getLayoutPath('content', 'pagenavigation');
             // Render the pagenav
             ob_start();
             include $path;
             $row->pagination = ob_get_clean();
             $row->paginationposition = $this->params->get('position', 1);
             // This will default to the 1.5 and 1.6-1.7 behavior.
             $row->paginationrelative = $this->params->get('relative', 0);
         }
     }
     return;
 }
 /**
  * Listener for the `onContentAfterTitle` event
  *
  * @param   string   $context   The context of the content being passed to the plugin.
  * @param   object   &$article  The article object.  Note $article->text is also available
  * @param   object   &$params   The article params
  * @param   integer  $page      The 'page' number
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onContentAfterTitle($context, &$article, &$params, $page)
 {
     /*
      * Validate the plugin should run in the current context
      */
     // Context check - This only works for com_content
     if (strpos($context, 'com_content') === false) {
         return;
     }
     // Additional context check; we only want this for the component!
     if (strpos($this->app->scope, 'mod_') === 0) {
         return;
     }
     // Check if the plugin is enabled
     if (JPluginHelper::isEnabled('content', 'joomlarrssb') == false) {
         return;
     }
     // Make sure the document is an HTML document
     $document = $this->app->getDocument();
     if ($document->getType() != 'html') {
         return;
     }
     /*
      * Start processing the plugin event
      */
     // Set the parameters
     $displayEmail = $this->params->get('displayEmail', '1');
     $displayFacebook = $this->params->get('displayFacebook', '1');
     $displayGoogle = $this->params->get('displayGoogle', '1');
     $displayLinkedin = $this->params->get('displayLinkedin', '1');
     $displayPinterest = $this->params->get('displayPinterest', '1');
     $displayTwitter = $this->params->get('displayTwitter', '1');
     $selectedCategories = $this->params->def('displayCategories', '');
     $position = $this->params->def('displayPosition', 'top');
     $view = $this->app->input->getCmd('view', '');
     $shorten = $this->params->def('useYOURLS', true);
     // Check whether we're displaying the plugin in the current view
     if ($this->params->get('view' . ucfirst($view), '1') == '0') {
         return;
     }
     // If we're not in the article view, we have to get the full $article object ourselves
     if ($view == 'featured' || $view == 'category') {
         /*
          * We only want to handle com_content items; if this function returns null, there's no DB item
          * Also, make sure the object isn't already loaded and undo previous plugin processing
          */
         $data = $this->loadArticle($article);
         if (!is_null($data) && !isset($article->catid)) {
             $article = $data;
         }
     }
     // Make sure we have a category ID, otherwise, end processing
     $properties = get_object_vars($article);
     if (!array_key_exists('catid', $properties)) {
         return;
     }
     // Get the current category
     if (is_null($article->catid)) {
         $currentCategory = 0;
     } else {
         $currentCategory = $article->catid;
     }
     // Define category restrictions
     if (is_array($selectedCategories)) {
         $categories = $selectedCategories;
     } elseif ($selectedCategories == '') {
         $categories = [$currentCategory];
     } else {
         $categories = [$selectedCategories];
     }
     // If we aren't in a defined category, exit
     if (!in_array($currentCategory, $categories)) {
         // If we made it this far, we probably deleted the text object; reset it
         if (!isset($article->text)) {
             $article->text = $article->introtext;
         }
         return;
     }
     // Create the article slug
     $article->slug = $article->alias ? $article->id . ':' . $article->alias : $article->id;
     // Build the URL for the plugins to use - the site URL should only be the scheme and host segments, JRoute will take care of the rest
     $siteURL = JUri::getInstance()->toString(['scheme', 'host', 'port']);
     $itemURL = $siteURL . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
     // Check if we have an intro text image (Priority: fulltext image, intro image, content image, category image)
     $images = json_decode($article->images);
     if (isset($images->image_fulltext) && !empty($images->image_fulltext)) {
         $imageOg = $images->image_fulltext;
     } elseif (isset($images->image_intro) && !empty($images->image_intro)) {
         $imageOg = $images->image_intro;
     } else {
         // Get the content and merge in the template; first see if $article->text is defined
         if (!isset($article->text)) {
             $article->text = $article->introtext;
         }
         // Always run this preg_match as the results are also used in the layout
         $pattern = "/<img[^>]*src\\=['\"]?(([^>]*)(jpg|gif|JPG|png|jpeg))['\"]?/";
         preg_match($pattern, $article->text, $matches);
         $imageOg = isset($matches[1]) ? $matches[1] : '';
         // Check for category image
         if (empty($imageOg)) {
             // We get the article mostly from content plugin, so we need to do a query and can't do a join..
             $query = $this->db->getQuery(true);
             $query->select('params')->from($this->db->quoteName('#__categories'))->where($this->db->quoteName('id') . ' = ' . $this->db->q($article->catid));
             $this->db->setQuery($query);
             $result = $this->db->loadResult();
             if ($result) {
                 $categoryParams = json_decode($result);
                 if (isset($categoryParams->image) && !empty($categoryParams->image)) {
                     $imageOg = $categoryParams->image;
                 }
             }
         }
     }
     // Make sure the image has an absolute URL
     if (!empty($imageOg)) {
         // If the image isn't prefixed with http then assume it's relative and put the site URL in front
         if (strpos($imageOg, 'http') !== 0) {
             $imageOg = substr(JUri::root(), 0, -1) . (substr($imageOg, 0, 1) !== '/' ? '/' : '') . $imageOg;
         }
     }
     /*
      * Add template metadata per the context
      */
     // The metadata in this check should only be applied on a single article view
     if ($context === 'com_content.article') {
         if (!empty($imageOg)) {
             if (!$document->getMetaData('og:image')) {
                 $document->setMetaData('og:image', $imageOg, 'property');
             }
             if (!$document->getMetaData('twitter:image')) {
                 $document->setMetaData('twitter:image', $imageOg);
             }
         }
         $description = !empty($article->metadesc) ? $article->metadesc : $article->introtext;
         $description = JHtml::_('string.truncate', $description, 200, true, false);
         // OpenGraph metadata
         if (!$document->getMetaData('og:description')) {
             $document->setMetaData('og:description', $description, 'property');
         }
         if (!$document->getMetaData('og:title')) {
             $document->setMetaData('og:title', $article->title, 'property');
         }
         if (!$document->getMetaData('og:type')) {
             $document->setMetaData('og:type', 'article', 'property');
         }
         if (!$document->getMetaData('og:url')) {
             $document->setMetaData('og:url', $itemURL, 'property');
         }
         // Twitter Card metadata
         if (!$document->getMetaData('twitter:description')) {
             $document->setMetaData('twitter:description', $description);
         }
         if (!$document->getMetaData('twitter:title')) {
             $document->setMetaData('twitter:title', JHtml::_('string.truncate', $article->title, 70, true, false));
         }
     }
     // Check that we're actually displaying a button
     if ($displayEmail == '0' && $displayFacebook == '0' && $displayGoogle == '0' && $displayLinkedin == '0' && $displayPinterest == '0' && $displayTwitter == '0') {
         return;
     }
     // Apply our shortened URL if configured
     if ($shorten) {
         $data = ['signature' => $this->params->def('YOURLSAPIKey', '2909bc72e7'), 'action' => 'shorturl', 'url' => $itemURL, 'format' => 'simple'];
         try {
             $response = JHttpFactory::getHttp()->post($this->params->def('YOURLSUrl', 'http://joom.la') . '/yourls-api.php', $data);
             if ($response->code == 200) {
                 $itemURL = $response->body;
             }
         } catch (Exception $e) {
             // In case of an error connecting out here, we can still use the 'real' URL.  Carry on.
         }
     }
     // Load the layout
     ob_start();
     $template = JPluginHelper::getLayoutPath('content', 'joomlarrssb');
     include $template;
     $output = ob_get_clean();
     // Add the output
     if ($position == 'top') {
         $article->introtext = $output . $article->introtext;
         $article->text = $output . $article->text;
     } else {
         $article->introtext = $output . $article->introtext;
         $article->text .= $output;
     }
     return;
 }