예제 #1
0
 public function generateTextContent($item, $userId, $index, $inProfile = false, $authorsection = false, $inHome = false, $type = 'default', $follower = false)
 {
     $draftClass = '';
     if ($type == 'draft') {
         $draftClass = ' draft';
     }
     $authorId = $item->created_by;
     $html = '<div class="text' . $draftClass . '" data-index="' . $index . '">';
     if (!$inProfile) {
         if ($item->first) {
             $html .= '<div class="category-color" style="background: #E02424"></div>';
         }
     }
     // #00B60E = green, #E65151 = red
     //else if($follower === true)
     //	$html .= '<div class="category-color" style="background: #00B60E"></div>'; //#c1c2c2 = gray
     if ($inProfile == false) {
         $html .= '<div class="save-container" data-text-id="' . $item->id . '">';
         if (!$item->pinned) {
             if ($item->saved) {
                 $html .= '<div class="text-saved-icon" title="' . JText::_('UNARCHIVE') . '" data-text-id="' . $item->id . '"></div>';
             } else {
                 $html .= '<div class="text-save-icon" title="' . JText::_('SAVE') . '" data-text-id="' . $item->id . '"></div>';
             }
         } else {
             $html .= '<div class="text-pinned-icon" title="' . JText::_('PINNED') . '" ></div>';
         }
         $html .= '</div>';
     }
     if ($item->image) {
         //verifico si el texto tiene imagen
         $html .= '<a href="' . JRoute::_("index.php?option=com_content&view=article&id=" . $item->id) . '">';
         $html .= '<div class="text-img">';
         $html .= '<img src="' . JURI::base() . "templates/beez_20/images/texts/" . $item->id . "/home/" . $item->image . '"/>';
         $html .= '</div>';
         $html .= '</a>';
         $text_data_margin_left = 20;
     } else {
         $text_data_margin_left = 0;
     }
     $html .= '<div class="text-data" style="margin-left: ' . $text_data_margin_left . 'px !important;">';
     $html .= '<div class="text-title-container">';
     if ($type == 'draft') {
         $html .= '<a href="' . JRoute::_("index.php?option=com_content&Itemid=101&a_id=" . $item->id . "&task=article.edit") . '">';
     } else {
         $html .= '<a href="' . JRoute::_("index.php?option=com_content&view=article&id=" . $item->id) . '">';
     }
     $html .= '<div class="text-title">';
     $html .= $item->title;
     $html .= '</div>';
     $html .= '</a>';
     $html .= '</div>';
     $html .= '<div class="text-actions">';
     $html .= '<div class="text-content">';
     //$html .= strip_tags(html_entity_decode($item->introtext));
     $html .= strip_tags($item->introtext, "<br>");
     $html .= '</div>';
     $html .= '<div class="text-bottom">';
     $html .= '<div class="text-bottom-content">';
     if ($type == 'draft') {
         $html .= '<div class="draft-bottom-left">';
         $html .= '<a href="' . JRoute::_("index.php?option=com_content&Itemid=101&a_id=" . $item->id . "&task=article.edit") . '">';
         $html .= '<div class="draft-edit" title="' . JTEXT::_('EDIT_DRAFT') . '"></div>';
         $html .= '</a>';
         $html .= '<div class="draft-delete" data-text-id="' . $item->id . '" title="' . JTEXT::_('DELETE_DRAFT') . '"></div>';
         $html .= '</div>';
         $html .= '<div class="draft-bottom-right">';
         $html .= JTEXT::_('DRAFT');
         $html .= '</div>';
     } else {
         if ($type == 'mine') {
             $html .= '<a href="' . JRoute::_("index.php?option=com_content&Itemid=101&a_id=" . $item->id . "&task=article.edit") . '">';
             $html .= '<div class="edit-text" title="' . JTEXT::_('EDIT_TEXT') . '"></div>';
             $html .= '</a>';
         } else {
             /*  $taglist = ideary::getTextTags($item->id,3);
             			   if ($taglist!=""){
             					$html .= '<div class="text-author" style="font-weight:normal;">';
             					$html .= "Tags: " . $taglist;
             					$html .= '</div>';
             			    }
             				*/
             if ($authorsection == false) {
                 $html .= '<div class="text-author">';
                 $author = $item->author;
                 $author = $item->created_by_alias ? $item->created_by_alias : $author;
                 $html .= JText::_('BY') . "&nbsp;";
                 //if($follower)
                 //	$html .= "<strong>";
                 if ($userId != $item->created_by) {
                     $html .= JHtml::_('link', JRoute::_('index.php?option=com_contact&view=public&id=' . $item->created_by), $author);
                 } else {
                     $html .= JHtml::_('link', JRoute::_('index.php?option=com_users&view=profile&user_id=' . $item->created_by), $author);
                 }
                 //if($follower)
                 //	$html .= "</strong>";
                 if ($item->created != "0000-00-00 00:00:00") {
                     $timeZone = 'America/Buenos_Aires';
                     $curDate = date_create();
                     $textDate = date_create($item->created);
                     if ($textDate > $curDate) {
                         $textDate = new DateTime($item->created, new DateTimeZone('GMT'));
                         $textDate->setTimeZone(new DateTimeZone($timeZone));
                     }
                     $dateDiff = $textDate->diff($curDate);
                     if ($dateDiff->days > 1) {
                         $dateDiff = str_replace('{X}', $dateDiff->days, $dateDiff->days > 1 ? JTEXT::_('X_DAYS_AGO') : JTEXT::_('X_DAY_AGO'));
                     } else {
                         if ($dateDiff->days > 0) {
                             $dateDiff = JTEXT::_('YESTERDAY');
                         } else {
                             if ($dateDiff->h > 0) {
                                 $dateDiff = str_replace('{X}', $dateDiff->h, $dateDiff->h > 1 ? JTEXT::_('X_HOURS_AGO') : JTEXT::_('X_HOUR_AGO'));
                             } else {
                                 if ($dateDiff->i > 0) {
                                     $dateDiff = str_replace('{X}', $dateDiff->i, $dateDiff->i > 1 ? JTEXT::_('X_MINUTES_AGO') : JTEXT::_('X_MINUTE_AGO'));
                                 } else {
                                     $dateDiff = str_replace('{X}', $dateDiff->s, $dateDiff->s > 1 ? JTEXT::_('X_SECONDS_AGO') : JTEXT::_('X_SECOND_AGO'));
                                 }
                             }
                         }
                     }
                     $dateDiff = strtolower($dateDiff);
                     $html .= "&nbsp;<div class=\"age\" >{$dateDiff}</div>";
                 }
                 $html .= "</div>";
             }
         }
         //if($inHome){
         $countComments = Ideary::getCommentsCountByTextId($item->id);
         if ($countComments > 0) {
             $comment_label = $countComments > 1 ? 'X-COMMENTS' : 'X-COMMENT';
             $html .= '<a href="' . JRoute::_("index.php?option=com_content&view=article&id=" . $item->id . "#comments-section") . '" style="text-decoration: none;">';
             $html .= '<div class="comments-count-container" title="' . str_replace('{x}', $countComments, JText::_($comment_label)) . '">';
             $html .= '<div class="comments-count-bg"></div>';
             $html .= '<div class="comments-count-num">' . $countComments . '</div>';
             $html .= '</div>';
             $html .= '</a>';
         }
         //}
         $countApplauses = ideary::getCountApplausesByTextId($item->id);
         if ($countApplauses > 0) {
             $clap_label = $countApplauses > 1 ? 'X-APPLAUSES' : 'X-APPLAUSE';
             $html .= '<div class="applauses applauses-clickable" data-text-id="' . $item->id . '" data-text-title="' . $item->title . '" title="' . str_replace('{x}', $countApplauses, JText::_($clap_label)) . '">';
             $html .= '<div class="icon_applauses"></div>';
             $html .= '<div class="count_applauses">' . $countApplauses . '</div>';
             $html .= '</div>';
         }
     }
     $html .= '</div>';
     $html .= '</div>';
     $html .= '</div>';
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }