/** * 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 body($maxLength = 0, $format = 'S', $stripTags = '') { $ret = $this->getVar('body', $format); $wrap_pos = strpos($ret, '[pagewrap='); if (!($wrap_pos === false)) { $wrap_pages = array(); $wrap_code_length = strlen('[pagewrap='); while (!($wrap_pos === false)) { $end_wrap_pos = strpos($ret, ']', $wrap_pos); if ($end_wrap_pos) { $wrap_page_name = substr($ret, $wrap_pos + $wrap_code_length, $end_wrap_pos - $wrap_code_length - $wrap_pos); $wrap_pages[] = $wrap_page_name; } $wrap_pos = strpos($ret, '[pagewrap=', $end_wrap_pos - 1); } foreach ($wrap_pages as $page) { $wrap_page_content = $this->wrappage($page); $ret = str_replace("[pagewrap={$page}]", $wrap_page_content, $ret); } } if ($this->publisher->getConfig('item_disp_blocks_summary')) { $summary = $this->summary($maxLength, $format, $stripTags); if ($summary) { $ret = $this->summary() . '<br /><br />' . $ret; } } if (!empty($stripTags)) { $ret = strip_tags($ret, $stripTags); } if ($maxLength != 0) { if (!XoopsLocale::isMultiByte()) { if (strlen($ret) >= $maxLength) { //$ret = PublisherUtils::substr($ret , 0, $maxLength); $ret = PublisherUtils::truncateTagSafe($ret, $maxLength, $etc = '...', $break_words = false); } } } return $ret; }
function publisher_items_spot_show($options) { $publisher = Publisher::getInstance(); $opt_display_last = $options[0]; $opt_items_count = $options[1]; $opt_categoryid = $options[2]; $sel_items = isset($options[3]) ? explode(',', $options[3]) : ''; $opt_display_poster = $options[4]; $opt_display_comment = $options[5]; $opt_display_type = $options[6]; $opt_truncate = (int) $options[7]; $opt_catimage = $options[8]; if ($opt_categoryid == 0) { $opt_categoryid = -1; } $block = array(); if ($opt_display_last == 1) { $itemsObj = $publisher->getItemHandler()->getAllPublished($opt_items_count, 0, $opt_categoryid, $sort = 'datesub', $order = 'DESC', 'summary'); $i = 1; $itemsCount = count($itemsObj); if ($itemsObj) { if ($opt_categoryid != -1 && $opt_catimage) { $cat = $publisher->getCategoryHandler()->get($opt_categoryid); $category['name'] = $cat->getVar('name'); $category['categoryurl'] = $cat->getCategoryUrl(); if ($cat->image() != 'blank.png') { $category['image_path'] = PublisherUtils::getImageDir('category', false) . $cat->image(); } else { $category['image_path'] = ''; } $block['category'] = $category; } /* @var $thisitem PublisherItem */ foreach ($itemsObj as $thisitem) { $item = $thisitem->toArray('default', 0, $opt_truncate); if ($i < $itemsCount) { $item['showline'] = true; } else { $item['showline'] = false; } if ($opt_truncate > 0) { $block['truncate'] = true; } $block['items'][] = $item; ++$i; } } } else { $i = 1; $itemsCount = count($sel_items); foreach ($sel_items as $item_id) { /* @var $itemObj PublisherItem */ $itemObj = $publisher->getItemHandler()->get($item_id); if (!$itemObj->notLoaded()) { $item = $itemObj->toArray(); $item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub()); if ($i < $itemsCount) { $item['showline'] = true; } else { $item['showline'] = false; } if ($opt_truncate > 0) { $block['truncate'] = true; $item['summary'] = PublisherUtils::truncateTagSafe($item['summary'], $opt_truncate); } $block['items'][] = $item; ++$i; } } } if (!isset($block['items']) || count($block['items']) == 0) { return false; } $block["publisher_url"] = PUBLISHER_URL; $block['lang_reads'] = _MB_PUBLISHER_READS; $block['lang_comments'] = _MB_PUBLISHER_COMMENTS; $block['lang_readmore'] = _MB_PUBLISHER_READMORE; $block['display_whowhen_link'] = $opt_display_poster; $block['display_comment_link'] = $opt_display_comment; $block['display_type'] = $opt_display_type; return $block; }