Exemplo n.º 1
0
 /**
  * @param string  $context
  * @param object $article
  * @param Joomla\Registry\Registry $params
  * @param int $page
  *
  * @return null|string
  * @throws Exception
  */
 public function onContentBeforeDisplay($context, &$article, &$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;
     }
     // Load language
     $this->loadLanguage();
     $itemId = $app->input->getInt("id");
     $stats = CrowdfundingHelper::getProjectData($itemId);
     $screen = $app->input->getCmd("screen", "home");
     $html = '<ul class="nav nav-pills cf-plg-navigation">';
     if ($this->params->get("display_home")) {
         $class = 'class="cf-plg-nav-home';
         if (strcmp($screen, "home") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug)) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_HOME") . "</a></li>";
     }
     if ($this->params->get("display_updates")) {
         $class = 'class="cf-plg-nav-updates';
         if (strcmp($screen, "updates") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "updates", 0) . '</span>';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "updates")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_UPDATES") . ' ' . $stat . '</a></li>';
     }
     if ($this->params->get("display_comments")) {
         $class = 'class="cf-plg-nav-comments';
         if (strcmp($screen, "comments") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         if (!$params->get("comments_enabled", 1)) {
             $stat = '<span class="cf-dclabel">&nbsp;</span>';
         } else {
             $stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "comments", 0) . '</span>';
         }
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "comments")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_COMMENTS") . ' ' . $stat . '</a></li>';
     }
     if ($this->params->get("display_funders")) {
         $class = 'class="cf-plg-nav-funders';
         if (strcmp($screen, "funders") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "funders", 0) . '</span>';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "funders")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_FUNDERS") . ' ' . $stat . '</a></li>';
     }
     $html .= '</ul>';
     return $html;
 }
Exemplo n.º 2
0
 public function getStatistics($project)
 {
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $params->get("project_currency"));
     $amount = new Crowdfunding\Amount($params, $project->funded);
     $amount->setCurrency($currency);
     $projectData = CrowdfundingHelper::getProjectData($project->id);
     $html = array();
     $html[] = '<div class="panel panel-default">';
     $html[] = '<div class="panel-heading"><h5>' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_STATISTICS") . '</h5></div>';
     $html[] = '         <table class="table table-bordered">';
     // Hits
     $html[] = '             <tr>';
     $html[] = '                 <td>' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_HITS") . '</td>';
     $html[] = '                 <td>' . (int) $project->hits . '</td>';
     $html[] = '             </tr>';
     // Updates
     $html[] = '             <tr>';
     $html[] = '                 <td>' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_UPDATES") . '</td>';
     $html[] = '                 <td>' . JArrayHelper::getValue($projectData, "updates", 0, "integer") . '</td>';
     $html[] = '             </tr>';
     // Comments
     $html[] = '             <tr>';
     $html[] = '                 <td>' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_COMMENTS") . '</td>';
     $html[] = '                 <td>' . JArrayHelper::getValue($projectData, "comments", 0, "integer") . '</td>';
     $html[] = '             </tr>';
     // Funders
     $html[] = '             <tr>';
     $html[] = '                 <td>' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_FUNDERS") . '</td>';
     $html[] = '                 <td>' . JArrayHelper::getValue($projectData, "funders", 0, "integer") . '</td>';
     $html[] = '             </tr>';
     // Raised
     $html[] = '             <tr>';
     $html[] = '                 <td>' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_RAISED") . '</td>';
     $html[] = '                 <td>' . $amount->formatCurrency() . '</td>';
     $html[] = '             </tr>';
     $html[] = '         </table>';
     $html[] = '</div>';
     return implode("\n", $html);
 }