Exemplo n.º 1
0
 /**
  * @param unknown_type $articleA
  * @param unknown_type $layout (  0, full article, 1 intro only, 2 title only )
  */
 function _convertAndLayoutHTML($articleA, $layout)
 {
     global $mainframe;
     if (empty($layout)) {
         $layout = 1;
     }
     foreach ($articleA as $oneArticle) {
         if (version_compare(JVERSION, '1.6.0', '<')) {
             $Itemid = $mainframe->getItemId($oneArticle->id);
         }
         if (empty($Itemid)) {
             $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
         }
         if ($GLOBALS[JNEWS . 'show_author'] == 1) {
             $author = '<br />' . $oneArticle->created_by_alias;
         } else {
             $author = '';
         }
         if ($layout == 0) {
             $html = '<div class="aca_content"><span class="aca_title">' . $oneArticle->title . '</span>' . "\r\n" . $author . '<br />' . $oneArticle->introtext . '<br />' . "\r\n" . $oneArticle->fulltext . "\r\n" . '</div>';
         } else {
             $link = 'option=com_content&view=article&id=' . $oneArticle->id . '&Itemid=' . $Itemid;
             $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
             if ($layout == 1) {
                 if (empty($oneArticle->fulltext) && !empty($GLOBALS[JNEWS . 'word_wrap'])) {
                     //Limit the number of words
                     if (strlen($oneArticle->introtext) > $GLOBALS[JNEWS . 'word_wrap']) {
                         static $requiredOnce = true;
                         if ($requiredOnce) {
                             require_once JNEWSPATH_CLASS . 'content.php';
                             $requiredOnce = false;
                         }
                         $convertContent = new jNews_Content();
                         $fulltext = $convertContent->HTMLtoText($oneArticle->introtext, false, false);
                         //             			$fulltext = strip_tags($oneArticle->introtext,'<br><img>');
                         if (strlen($fulltext) > $GLOBALS[JNEWS . 'word_wrap']) {
                             //We make sure we won't cut any html tag :
                             $oneArticle->introtext = substr($fulltext, 0, $GLOBALS[JNEWS . 'word_wrap'] - 3) . '...';
                         } else {
                             $oneArticle->introtext = $fulltext . '...';
                         }
                     }
                 }
                 $html = '<div class="aca_content"><span class="aca_title">' . $oneArticle->title . '</span>' . "\r\n" . $author . '<br />' . $oneArticle->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore">' . _JNEWS_READMORE . '</span></a>' . "\r\n" . '</div>';
             } else {
                 $html = '<a href="' . $link . '"><span class="aca_title">' . $oneArticle->title . '</span></a>';
             }
         }
         $images = $this->_getImageInfo($oneArticle->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'] . '" />';
             $html = preg_replace('/{mosimage}/', $image_string, $html, 1);
         }
     }
     $html = str_replace('{mospagebreak}', '<div style="clear: both;" ></div>', $html);
     return $html;
 }
Exemplo n.º 2
0
function jnewsbot_content_transformall(&$html, &$text, &$subject, $queueInfo = null)
{
    global $mainframe;
    $contentItemsNew = array();
    $contentItemsOld = array();
    preg_match_all('/\\{contentitem:(.{1,8})\\|(.{1})\\|(.{1})}/', $html, $contentItemsNew, PREG_SET_ORDER);
    preg_match_all('/\\{contentitem:(.{1,8})\\|(.{1})}/', $html, $contentItemsOld, PREG_SET_ORDER);
    $content_items = jnewsbot_class_transform_mergeArray($contentItemsNew, $contentItemsOld);
    /*$contentItemsNew
      [0] => {contentitem:10|0|1}
      [1] => 10
      [2] => 0
      [3] => 1   */
    foreach ($content_items as $content_item) {
        if (version_compare(JVERSION, '1.6.0', '<')) {
            $Itemid = $mainframe->getItemId($content_item[1]);
        }
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
        }
        $replacement = jnewsbot_content_getitem($content_item[1]);
        if (empty($replacement)) {
            continue;
        }
        if ($GLOBALS[JNEWS . 'show_author'] == 1) {
            $author = '<br />' . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        //hide title or no
        if (isset($content_item[3])) {
            if ($content_item[3] == 1 && $content_item[2] != 2) {
                $replacement->title = "";
            }
        }
        if ($content_item[2] == 0) {
            $html = str_replace($content_item[0], '<div class="aca_content"><span class="aca_title">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . $replacement->fulltext . "\r\n" . '</div>', $html);
        } else {
            $link = 'option=com_content&view=article&id=' . $content_item[1] . '&Itemid=' . $Itemid;
            $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
            if ($content_item[2] == 1) {
                if (empty($replacement->fulltext) && !empty($GLOBALS[JNEWS . 'word_wrap'])) {
                    //Limit the number of words
                    if (strlen($replacement->introtext) > $GLOBALS[JNEWS . 'word_wrap']) {
                        static $requiredOnce = true;
                        if ($requiredOnce) {
                            require_once JNEWSPATH_CLASS . 'content.php';
                            $requiredOnce = false;
                        }
                        $convertContent = new jNews_Content();
                        $fulltext = $convertContent->HTMLtoText($replacement->introtext, false, false);
                        //             			$fulltext = strip_tags($replacement->introtext,'<br><img>');
                        if (strlen($fulltext) > $GLOBALS[JNEWS . 'word_wrap']) {
                            //We make sure we won't cut any html tag :
                            //	             			$open = 0;
                            //	             			$limitText = strlen($fulltext) - 1;
                            //	             			for($i=0;$i<strlen($fulltext);$i++){
                            //	             				if($replacement->introtext[$i] == '<'){ $open++; continue;}
                            //	             				if($replacement->introtext[$i] == '>'){$open--; continue;}
                            //	             				if($replacement->introtext[$i] == " " AND $i>$GLOBALS[JNEWS.'word_wrap'] AND $open == 0){
                            //	             					$limitText = $i-1;
                            //	             					break;
                            //	             				}
                            //	             			}
                            $replacement->introtext = substr($fulltext, 0, $GLOBALS[JNEWS . 'word_wrap'] - 3) . '...';
                        } else {
                            $replacement->introtext = $fulltext . '...';
                        }
                    }
                }
                $html = str_replace($content_item[0], '<div class="aca_content"><span class="aca_title">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore">' . _JNEWS_READMORE . '</span></a>' . "\r\n" . '</div>', $html);
            } else {
                $html = str_replace($content_item[0], '<a href="' . $link . '"><span class="aca_title">' . $replacement->title . '</span></a>', $html);
            }
        }
        $images = jnewsbot_content_getimage($replacement->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'] . '" />';
            $html = preg_replace('/{mosimage}/', $image_string, $html, 1);
        }
    }
    //endfcy
    $contentItemsNew = array();
    $contentItemsOld = array();
    //use to be {contentitem:(.{1,5})\|(.{1})}
    preg_match_all('/\\{contentitem:(.{1,8})\\|(.{1})\\|(.{1})}/', $text, $contentItemsNew, PREG_SET_ORDER);
    preg_match_all('/\\{contentitem:(.{1,8})\\|(.{1})}/', $text, $contentItemsOld, PREG_SET_ORDER);
    $content_items = jnewsbot_class_transform_mergeArray($contentItemsNew, $contentItemsOld);
    foreach ($content_items as $content_item) {
        if (version_compare(JVERSION, '1.6.0', '<')) {
            $Itemid = $mainframe->getItemId($content_item[1]);
        }
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
        }
        $replacement = jnewsbot_content_getitem($content_item[1]);
        if (empty($replacement)) {
            continue;
        }
        if ($GLOBALS[JNEWS . 'show_author'] == 1) {
            $author = "\r\n" . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        $replacement->title = "<b>" . strtoupper(jNews_ProcessMail::htmlToText($replacement->title)) . "</b>";
        $replacement->introtext = jNews_ProcessMail::htmlToText($replacement->introtext);
        $replacement->fulltext = jNews_ProcessMail::htmlToText($replacement->fulltext);
        //hide title or no
        if (isset($content_item[3])) {
            if ($content_item[3] == 1 && $content_item[2] != 2) {
                $replacement->title = "";
            }
        }
        if ($content_item[2] == 0) {
            $text = str_replace($content_item[0], $replacement->title . $author . "\r\n" . $replacement->introtext . "\r\n" . $replacement->fulltext . "\r\n", $text);
        } else {
            $link = 'option=com_content&view=article&id=' . $content_item[1] . '&Itemid=' . $Itemid;
            $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
            if ($content_item[2] == 1) {
                if (empty($replacement->fulltext) and !empty($GLOBALS[JNEWS . 'word_wrap'])) {
                    if (strlen($replacement->introtext) > $GLOBALS[JNEWS . 'word_wrap']) {
                        $replacement->introtext = substr(strip_tags($replacement->introtext), 0, $GLOBALS[JNEWS . 'word_wrap']) . '...';
                    }
                }
                $text = str_replace($content_item[0], $replacement->title . $author . "\r\n" . $replacement->introtext . "\r\n" . '* ' . _JNEWS_READMORE . ' ( ' . $link . ' )' . "\r\n", $text);
            } else {
                $text = str_replace($content_item[0], $replacement->title . ' ( ' . $link . ' )', $text);
            }
        }
        $text = str_replace('{mosimage}', '', $text);
    }
    $html = str_replace('{mospagebreak}', '<div style="clear: both;" ></div>', $html);
    $text = str_replace('{mospagebreak}', "\r\n \r\n", $text);
}