Ejemplo 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 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() . '' . $ret;
         }
     }
     if (!empty($stripTags)) {
         $ret = strip_tags($ret, $stripTags);
     }
     if ($maxLength != 0) {
         if (!XOOPS_USE_MULTIBYTES) {
             if (strlen($ret) >= $maxLength) {
                 //$ret = publisher_substr($ret , 0, $maxLength);
                 $ret = publisher_truncateTagSafe($ret, $maxLength, $etc = '...', $break_words = false);
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 2
0
function publisher_items_spot_show($options)
{
    $publisher = PublisherPublisher::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 = intval($options[7]);
    $opt_catimage = $options[8];
    if ($opt_categoryid == 0) {
        $opt_categoryid = -1;
    }
    $block = array();
    if ($opt_display_last == 1) {
        $itemsObj = $publisher->getHandler('item')->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->getHandler('category')->get($opt_categoryid);
                $category['name'] = $cat->name();
                $category['categoryurl'] = $cat->getCategoryUrl();
                if ($cat->image() != 'blank.png') {
                    $category['image_path'] = publisher_getImageDir('category', false) . $cat->image();
                } else {
                    $category['image_path'] = '';
                }
                $block['category'] = $category;
            }
            foreach ($itemsObj as $key => $thisitem) {
                $item = $thisitem->ToArraySimple('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) {
            $itemObj = $publisher->getHandler('item')->get($item_id);
            if (!$itemObj->notLoaded()) {
                $item = $itemObj->ToArraySimple();
                $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'] = publisher_truncateTagSafe($item['summary'], $opt_truncate);
                }
                $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'] = $opt_display_poster;
    $block['display_comment_link'] = $opt_display_comment;
    $block['display_type'] = $opt_display_type;
    return $block;
}