Exemplo n.º 1
0
 /**
  * This method returns the body to be displayed. Not to be used for editing
  *
  * @param int    $maxLength
  * @param string $format
  * @param string $stripTags
  *
  * @return mixed|string
  */
 public function getBody($maxLength = 0, $format = 'S', $stripTags = '')
 {
     $ret = $this->getVar('body', $format);
     $wrapPos = strpos($ret, '[pagewrap=');
     if (!($wrapPos === false)) {
         $wrapPages = array();
         $wrapCodeLength = strlen('[pagewrap=');
         while (!($wrapPos === false)) {
             $endWrapPos = strpos($ret, ']', $wrapPos);
             if ($endWrapPos) {
                 $wrap_page_name = substr($ret, $wrapPos + $wrapCodeLength, $endWrapPos - $wrapCodeLength - $wrapPos);
                 $wrapPages[] = $wrap_page_name;
             }
             $wrapPos = strpos($ret, '[pagewrap=', $endWrapPos - 1);
         }
         foreach ($wrapPages as $page) {
             $wrapPageContent = $this->wrapPage($page);
             $ret = str_replace("[pagewrap={$page}]", $wrapPageContent, $ret);
         }
     }
     if ($this->publisher->getConfig('item_disp_blocks_summary')) {
         $summary = $this->getSummary($maxLength, $format, $stripTags);
         if ($summary) {
             $ret = $this->getSummary() . $ret;
         }
     }
     if (!empty($stripTags)) {
         $ret = strip_tags($ret, $stripTags);
     }
     if ($maxLength != 0) {
         if (!XOOPS_USE_MULTIBYTES) {
             if (strlen($ret) >= $maxLength) {
                 //$ret = publisherSubstr($ret , 0, $maxLength);
                 $ret = publisherTruncateTagSafe($ret, $maxLength, $etc = '...', $breakWords = false);
             }
         }
     }
     return $ret;
 }
Exemplo n.º 2
0
/**
 * @param $options
 *
 * @return array|bool
 */
function publisher_items_spot_show($options)
{
    //    global $xoTheme;
    $publisher =& PublisherPublisher::getInstance();
    $optDisplayLast = $options[0];
    $optItemsCount = $options[1];
    $optCategoryId = $options[2];
    $selItems = isset($options[3]) ? explode(',', $options[3]) : '';
    $optDisplayPoster = $options[4];
    $optDisplayComment = $options[5];
    $optDisplayType = $options[6];
    $optTruncate = (int) $options[7];
    $optCatImage = $options[8];
    if ($optCategoryId == 0) {
        $optCategoryId = -1;
    }
    $block = array();
    if ($optDisplayLast == 1) {
        $itemsObj =& $publisher->getHandler('item')->getAllPublished($optItemsCount, 0, $optCategoryId, $sort = 'datesub', $order = 'DESC', 'summary');
        $i = 1;
        $itemsCount = count($itemsObj);
        if ($itemsObj) {
            if ($optCategoryId != -1 && $optCatImage) {
                $cat =& $publisher->getHandler('category')->get($optCategoryId);
                $category['name'] = $cat->name();
                $category['categoryurl'] = $cat->getCategoryUrl();
                if ($cat->getImage() !== 'blank.png') {
                    $category['image_path'] = publisherGetImageDir('category', false) . $cat->getImage();
                } else {
                    $category['image_path'] = '';
                }
                $block['category'] = $category;
            }
            foreach ($itemsObj as $key => $thisitem) {
                $item = $thisitem->toArraySimple('default', 0, $optTruncate);
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                if ($optTruncate > 0) {
                    $block['truncate'] = true;
                }
                $block['items'][] = $item;
                ++$i;
            }
        }
    } else {
        $i = 1;
        $itemsCount = count($selItems);
        foreach ($selItems as $itemId) {
            $itemObj =& $publisher->getHandler('item')->get($itemId);
            if (!$itemObj->notLoaded()) {
                $item = $itemObj->toArraySimple();
                $item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $itemObj->posterName(), $itemObj->getDatesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                if ($optTruncate > 0) {
                    $block['truncate'] = true;
                    $item['summary'] = publisherTruncateTagSafe($item['summary'], $optTruncate);
                }
                $block['items'][] = $item;
                ++$i;
            }
        }
    }
    if (!isset($block['items']) || count($block['items']) == 0) {
        return false;
    }
    $block['lang_reads'] = _MB_PUBLISHER_READS;
    $block['lang_comments'] = _MB_PUBLISHER_COMMENTS;
    $block['lang_readmore'] = _MB_PUBLISHER_READMORE;
    $block['display_whowhen_link'] = $optDisplayPoster;
    $block['display_comment_link'] = $optDisplayComment;
    $block['display_type'] = $optDisplayType;
    $block['moduleUrl'] = PUBLISHER_URL;
    $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/assets/css/publisher.css');
    return $block;
}