示例#1
0
function acajoombot_content_transformall($html, $text)
{
    global $mainframe;
    $content_items = array();
    preg_match_all('/\\{contentitem:(.{1,8})\\|(.{1})}/', $html, $content_items, PREG_SET_ORDER);
    foreach ($content_items as $content_item) {
        $Itemid = $mainframe->getItemId($content_item[1]);
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[ACA . 'itemidAca'];
        }
        $replacement = acajoombot_content_getitem($content_item[1]);
        if ($GLOBALS[ACA . 'show_author'] == 1) {
            $author = '<br />' . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        if ($content_item[2] == 0) {
            $html = str_replace($content_item[0], '<div class="contentpaneopen_nws"><span class="contentheading_nws">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . $replacement->fulltext . "\r\n" . '</div>', $html);
        } else {
            $link = '.php?option=com_content&view=article&id=' . $content_item[1] . '&Itemid=' . $Itemid;
            compa::completeLink($link, false, $GLOBALS[ACA . 'use_sef']);
            if ($content_item[2] == 1) {
                if (empty($replacement->fulltext) and !empty($GLOBALS[ACA . 'word_wrap'])) {
                    //Limit the number of words
                    if (strlen($replacement->introtext) > $GLOBALS[ACA . 'word_wrap']) {
                        $fulltext = strip_tags($replacement->introtext, '<br><img>');
                        if (strlen($fulltext) > $GLOBALS[ACA . '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[ACA . 'word_wrap'] and $open == 0) {
                                    $limitText = $i - 1;
                                    break;
                                }
                            }
                            $replacement->introtext = substr($fulltext, 0, $limitText) . '...';
                        }
                    }
                }
                $html = str_replace($content_item[0], '<div class="contentpaneopen_nws"><span class="contentheading_nws">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="readon_nws">' . _ACA_READMORE . '</span></a>' . "\r\n" . '</div>', $html);
            } else {
                $html = str_replace($content_item[0], '<a href="' . $link . '"><span class="contentheading_nws">' . $replacement->title . '</span></a>', $html);
            }
        }
        $images = acajoombot_content_getimage($replacement->images);
        foreach ($images as $image) {
            $image_string = '<img src="' . ACA_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);
        }
    }
    $content_items = array();
    preg_match_all('/\\{contentitem:(.{1,5})\\|(.{1})}/', $text, $content_items, PREG_SET_ORDER);
    foreach ($content_items as $content_item) {
        $Itemid = $mainframe->getItemId($content_item[1]);
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[ACA . 'itemidAca'];
        }
        $replacement = acajoombot_content_getitem($content_item[1]);
        if ($GLOBALS[ACA . 'show_author'] == 1) {
            $author = "\r\n" . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        $replacement->title = strtoupper(acajoom_mail::htmlToText($replacement->title));
        $replacement->introtext = acajoom_mail::htmlToText($replacement->introtext);
        $replacement->fulltext = acajoom_mail::htmlToText($replacement->fulltext);
        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 = '.php?option=com_content&view=article&id=' . $content_item[1] . '&Itemid=' . $Itemid;
            compa::completeLink($link, false, $GLOBALS[ACA . 'use_sef']);
            if ($content_item[2] == 1) {
                if (empty($replacement->fulltext) and !empty($GLOBALS[ACA . 'word_wrap'])) {
                    if (strlen($replacement->introtext) > $GLOBALS[ACA . 'word_wrap']) {
                        $replacement->introtext = substr(strip_tags($replacement->introtext, 0, $GLOBALS[ACA . 'word_wrap'])) . '...';
                    }
                }
                $text = str_replace($content_item[0], $replacement->title . $author . "\r\n" . $replacement->introtext . "\r\n" . '* ' . _ACA_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);
}
示例#2
0
function acajoombot_content_transformall($html, $text)
{
    global $mainframe, $_MAMBOTS;
    $content_items = array();
    preg_match_all('/\\{contentitem:(.{1,8})\\|(.{1})}/', $html, $content_items, PREG_SET_ORDER);
    foreach ($content_items as $content_item) {
        $Itemid = $mainframe->getItemId($content_item[1]);
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[ACA . 'itemidAca'];
        }
        $replacement = acajoombot_content_getitem($content_item[1]);
        if ($GLOBALS[ACA . 'show_author'] == 1) {
            $author = '<br />' . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        $replacement->introtext = str_replace('{mospagebreak}', '<div style="clear: both;" ><div />', $replacement->introtext);
        $replacement->fulltext = str_replace('{mospagebreak}', '<div style="clear: both;" ><div />', $replacement->fulltext);
        if ($content_item[2] == 0) {
            $html = str_replace($content_item[0], '<div class="contentpaneopen_nws"><span class="contentheading_nws">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . $replacement->fulltext . "\r\n" . '</div>', $html);
        } else {
            if ($GLOBALS[ACA . 'use_sef'] == '1' and $GLOBALS['mosConfig_sef'] == '1' and function_exists('sefRelToAbs')) {
                $link = sefRelToAbs('index.php?option=com_content&task=view&id=' . $content_item[1] . '&Itemid=' . $Itemid);
            } else {
                $link = $GLOBALS['mosConfig_live_site'] . '/index.php?option=com_content&task=view&id=' . $content_item[1] . '&Itemid=' . $Itemid;
            }
            if ($content_item[2] == 1) {
                $html = str_replace($content_item[0], '<div class="contentpaneopen_nws"><span class="contentheading_nws">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="readon_nws">' . _READ_MORE . '</span></a>' . "\r\n" . '</div>', $html);
            } else {
                $html = str_replace($content_item[0], '<a href="' . $link . '"><span class="contentheading_nws">' . $replacement->title . '</span></a>', $html);
            }
        }
        $images = acajoombot_content_getimage($replacement->images);
        foreach ($images as $image) {
            $image_string = '<img src="' . $GLOBALS['mosConfig_live_site'] . '/images/stories/' . $image['image'] . '" align="' . $image['align'] . '" alt="' . $image['alttext'] . '" border="' . $image['border'] . '" />';
            $html = preg_replace('/{mosimage}/', $image_string, $html, 1);
        }
    }
    $content_items = array();
    preg_match_all('/\\{contentitem:(.{1,5})\\|(.{1})}/', $text, $content_items, PREG_SET_ORDER);
    foreach ($content_items as $content_item) {
        $Itemid = $mainframe->getItemId($content_item[1]);
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[ACA . 'itemidAca'];
        }
        $replacement = acajoombot_content_getitem($content_item[1]);
        if ($GLOBALS[ACA . 'show_author'] == 1) {
            $author = "\r\n" . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        $replacement->title = strtoupper(acajoom_mail::htmlToText($replacement->title));
        $replacement->introtext = acajoom_mail::htmlToText($replacement->introtext);
        $replacement->fulltext = acajoom_mail::htmlToText($replacement->fulltext);
        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 {
            if ($GLOBALS[ACA . 'use_sef'] == '1' and $GLOBALS['mosConfig_sef'] == '1' and function_exists('sefRelToAbs')) {
                $link = sefRelToAbs('index.php?option=com_content&task=view&id=' . $content_item[1] . '&Itemid=' . $Itemid);
            } else {
                $link = $GLOBALS['mosConfig_live_site'] . '/index.php?option=com_content&task=view&id=' . $content_item[1] . '&Itemid=' . $Itemid;
            }
            if ($content_item[2] == 1) {
                $text = str_replace($content_item[0], $replacement->title . $author . "\r\n" . $replacement->introtext . "\r\n" . '* ' . _READ_MORE . ' ( ' . $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);
}