/** we call this public static function to get the content of the articles via ajax * we directly insert the article in the newsletter without the tags * */ public static function getContent($artId = 0, $contentType = 0, $task = '', $template_id = '') { $mainframe = JFactory::getApplication(); ob_clean(); //j15 if (version_compare(JVERSION, '1.6.0', '<')) { $Itemid = $mainframe->getItemId($artId); } if (empty($Itemid)) { $Itemid = $GLOBALS[JNEWS . 'itemidAca']; } if ($task == 'articleContent') { $content = jNews_Mailing::getContentDetail($artId); } elseif ($task == 'blogContent') { $content = jNews_Mailing::getBlogDetail($artId); } if ($GLOBALS[JNEWS . 'show_author'] == 1) { $author = '<br />' . $content->created_by_alias; } else { $author = ''; } //we get the details of the article //if show only the title if ($contentType == 2) { $link = 'option=com_content&view=article&id=' . $artId . '&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']); $contentD = '<a href="' . $link . '"><span class="aca_title">' . $content->title . '</span></a>'; } elseif ($contentType == 0) { //to show the full article $contentD = '<div class="aca_content"><span class="aca_title">' . $content->title . '</span>' . "\r\n" . $author . '<br />' . $content->introtext . '<br />' . "\r\n" . $content->fulltext . "\r\n" . '</div>'; //TO DO: images } else { //title, intro and readmore if ($task == 'articleContent') { $link = 'option=com_content&view=article&id=' . $artId . '&Itemid=' . $Itemid; } elseif ($task == 'blogContent') { $link = 'option=com_lyftenbloggie&view=lyftenbloggie&view=entry&id=' . $artId . '&Itemid=' . $Itemid; } $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']); $wordwrap = $GLOBALS[JNEWS . 'word_wrap']; if (empty($content->fulltext) and !empty($wordwrap)) { //Limit the number of words if (strlen($content->introtext) > $wordwrap) { //$fulltext = $content->introtext; $fulltext = strip_tags($content->introtext, '<br><img>'); if (strlen($fulltext) > $wordwrap) { //We make sure we won't cut any html tag : $open = 0; $limitText = strlen($fulltext) - 1; for ($i = 0; $i < strlen($fulltext); $i++) { if ($content->introtext[$i] == '<') { $open++; } continue; if ($content->introtext[$i] == '>') { $open--; } continue; if ($content->introtext[$i] == " " and $i > $wordwrap and $open == 0) { $limitText = $i - 1; break; } } $content->introtext = substr($fulltext, 0, $limitText) . '...'; } } if (empty($content->fulltext) and !empty($GLOBALS[JNEWS . 'word_wrap'])) { if (strlen($content->introtext) > $GLOBALS[JNEWS . 'word_wrap']) { //$content->introtext = substr(strip_tags($content->introtext),0,$GLOBALS[JNEWS.'word_wrap']).'...'; $content->introtext = substr($content->introtext, 0, $GLOBALS[JNEWS . 'word_wrap']) . '...'; } } } $images = jNews_Mailing::getimage($content->images); foreach ($images as $image) { $image_string = '<img src="' . JNEWS_JPATH_LIVE_NO_HTTPS . '/images/stories/' . $image['image'] . '" align="' . $image['align'] . '" alt="' . $image['alttext'] . '" border="' . $image['border'] . '" />'; $contentD = preg_replace('/{mosimage}/', $image_string, $contentD, 1); } $contentD = str_replace('{mosimage}', '', $contentD); $contentD = '<div class="aca_content"><span class="aca_title">' . $content->title . '</span>' . "\r\n" . $author . '<br />' . $content->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore">' . _JNEWS_READMORE . '</span></a>' . "\r\n" . '</div>'; //$contentD = '<div class="aca_content"><span class="aca_title" style="display:block; text-indent:5px; font-weight: bold; width: 100%; font-size: 1.2em; text-decoration: none; color: rgb(255, 255, 255); border: 1px solid rgb(50, 154, 167); background-color: rgb(2, 91, 135);">' . $content->title . '</span>' . "\r\n" . $author . '<br />' . $content->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore" style="font-weight:bold; color:#ffffff; font-size:11px; float: right; border: 1px solid rgb(50, 154, 167); background-color: rgb(2, 91, 135); padding: 2px 8px;">' . _JNEWS_READMORE . '</span></a>' . "\r\n".'</div>'; //} } //insert the styles of this template if (!empty($template_id)) { jNews_Templates::includeStyles($contentD, $template_id); } if ($task == 'articleContent') { echo "<div id=artcontent_{$artId}>{$contentD}</div>"; } elseif ($task == 'blogContent') { echo "<div id=blogcontent_{$artId}>{$contentD}</div>"; } return true; }