Esempio n. 1
0
function publisher_latest_news_show($options)
{
    $xoops = Xoops::getInstance();
    $publisher = Publisher::getInstance();
    $publisher->loadLanguage('main');
    $block = array();
    $start = $options[0];
    // You can show articles from specified range
    $limit = $options[1];
    $column_count = $options[2];
    $letters = $options[3];
    $selected_stories = $options[4];
    $sort = $options[9];
    $order = PublisherUtils::getOrderBy($sort);
    $imgwidth = $options[11];
    $imgheight = $options[12];
    $border = $options[13];
    $bordercolor = $options[14];
    $block['spec']['columnwidth'] = (int) (1 / $column_count * 100);
    $allcats = false;
    if (!isset($options[29])) {
        $allcats = true;
    } elseif (in_array(0, explode(',', $options[29]))) {
        $allcats = true;
    }
    // creating the ITEM objects that belong to the selected category
    if ($allcats) {
        $criteria = null;
    } else {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('categoryid', '(' . $options[29] . ')', 'IN'));
    }
    // Use specific ITEMS
    if ($selected_stories != 0) {
        unset($criteria);
        //removes category option
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('itemid', '(' . $selected_stories . ')', 'IN'));
    }
    $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, 'itemid');
    $scount = count($itemsObj);
    if ($scount == 0) {
        return false;
    }
    $k = 0;
    $columns = array();
    $thumbService = \Xoops::getInstance()->service('thumbnail');
    /* @var $itemObj PublisherItem */
    foreach ($itemsObj as $itemObj) {
        $item = array();
        $item['itemurl'] = $itemObj->getItemUrl();
        $item['title'] = $itemObj->getItemLink();
        $item['alt'] = strip_tags($itemObj->getItemLink());
        $mainImage = $itemObj->getMainImage();
        $item['item_image'] = $thumbService->getImgUrl($mainImage['image_vpath'], $imgwidth, 0)->getValue();
        $item['text'] = $itemObj->getBlockSummary($letters);
        $item = $itemObj->getMainImage($item);
        //returns an array
        $ls_height = '';
        if ($options[12] != 0) {
            $ls_height = 'height="' . $imgheight . '" ';
        }
        if ($options[15] == 'LEFT') {
            $imgposition = "float: left";
            $ls_margin = '-right';
        } elseif ($options[15] == 'CENTER') {
            $imgposition = "text-align:center";
            $ls_margin = '';
        } else {
            $imgposition = "float: right";
            $ls_margin = '-left';
        }
        //Image
        if ($options[10] == 1 && $item['image_path'] != '') {
            $startdiv = '<div style="' . $imgposition . '"><a href="' . $item['itemurl'] . '">';
            $style = 'style="margin' . $ls_margin . ': 10px; padding: 2px; border: ' . $border . 'px solid #' . $bordercolor . '"';
            $enddiv = 'width="' . $imgwidth . '" ' . $ls_height . '/></a></div>';
            $image = $startdiv . '<img ' . $style . ' src="' . $item['item_image'] . '" alt="' . $item['image_name'] . '" ' . $enddiv;
            $item['image'] = $image;
        }
        if ($publisher->isUserAdmin()) {
            $item['admin'] = "<a href='" . PUBLISHER_URL . "/submit.php?itemid=" . $itemObj->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "' /></a>&nbsp;";
            $item['admin'] .= "<a href='" . PUBLISHER_URL . "/admin/item.php?op=del&amp;itemid=" . $itemObj->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png'" . " title='" . _CO_PUBLISHER_DELETE . "' alt='" . _CO_PUBLISHER_DELETE . "' /></a>";
        } else {
            $item['admin'] = '';
        }
        $block['topiclink'] = '';
        /*
                if ($options[16] == 1) {
        $block['topiclink'] = '| <a href="'.\XoopsBaseConfig::get('url').'/modules/news/topics_directory.php">'._AM_NEWS_TOPICS_DIRECTORY.'</a> ';
        }
        */
        $block['archivelink'] = '';
        if ($options[17] == 1) {
            $block['archivelink'] = '| <a href="' . PUBLISHER_URL . '/archive.php">' . _MB_PUBLISHER_ARCHIVE . '</a> ';
        }
        //TODO: Should we not show link to Anonymous?
        $block['submitlink'] = '';
        if ($options[18] == 1 && $xoops->isUser()) {
            $block['submitlink'] = '| <a href="' . PUBLISHER_URL . '/submit.php">' . _MB_PUBLISHER_SUBMITNEWS . '</a> ';
        }
        $item['poster'] = '';
        if ($options[19] == 1) {
            $item['poster'] = _MB_PUBLISHER_POSTER . ' ' . $itemObj->posterName();
        }
        $item['posttime'] = '';
        if ($options[20] == 1) {
            //todo, check this concatenation
            $item['posttime'] = strtolower(XoopsLocale::ON) . ' ' . $itemObj->datesub();
        }
        $item['topic_title'] = '';
        if ($options[21] == 1) {
            $item['topic_title'] = $itemObj->getCategoryLink() . _MB_PUBLISHER_SP;
        }
        $item['read'] = '';
        if ($options[22] == 1) {
            //todo, check this concatenation
            $item['read'] = '&nbsp;(' . $itemObj->getVar('counter') . ' ' . strtolower(XoopsLocale::READS) . ')';
        }
        $item['more'] = '';
        if ($itemObj->body() != '' || $itemObj->getVar('comments') > 0) {
            $item['more'] = '<a class="publisher_spotlight_readmore" href="' . $itemObj->getItemUrl() . '">' . _MB_PUBLISHER_READMORE . '</a>';
        }
        $comments = $itemObj->getVar('comments');
        if ($options[23] == 1) {
            if ($comments > 0) {
                //shows 1 comment instead of 1 comm. if comments ==1
                //langugage file modified accordingly
                if ($comments == 1) {
                    $item['comment'] = '&nbsp;' . _MB_PUBLISHER_ONECOMMENT . '&nbsp;';
                } else {
                    $item['comment'] = '&nbsp;' . $comments . '&nbsp;' . _MB_PUBLISHER_COMMENTS . '&nbsp;';
                }
            } else {
                $item['comment'] = '&nbsp;' . _MB_PUBLISHER_NO_COMMENTS . '&nbsp;';
            }
        }
        $item['print'] = '';
        if ($options[24] == 1) {
            $item['print'] = '<a href="' . PublisherUtils::seoGenUrl("print", $itemObj->getVar('itemid'), $itemObj->getVar('short_url')) . '" rel="nofollow"><img src="' . PUBLISHER_URL . '/images/links/print.gif" title="' . _CO_PUBLISHER_PRINT . '" alt="' . _CO_PUBLISHER_PRINT . '" /></a>&nbsp;';
        }
        $item['pdf'] = '';
        if ($options[25] == 1) {
            $item['pdf'] = "<a href='" . PUBLISHER_URL . "/makepdf.php?itemid=" . $itemObj->getVar('itemid') . "' rel='nofollow'><img src='" . PUBLISHER_URL . "/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a>&nbsp;";
        }
        $item['email'] = '';
        if ($options[26] == 1 && $xoops->isActiveModule('tellafriend')) {
            $subject = sprintf(_CO_PUBLISHER_INTITEMFOUND, $xoops->getConfig('sitename'));
            $subject = $itemObj->_convert_for_japanese($subject);
            $maillink = PublisherUtils::tellafriend($subject);
            $item['email'] = '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a>&nbsp;';
        }
        $block['morelink'] = '';
        if ($options[27] == 1) {
            $block['morelink'] = '<a href="' . PUBLISHER_URL . '/index.php">' . _MB_PUBLISHER_MORE_ITEMS . '</a> ';
        }
        $block['latestnews_scroll'] = false;
        if ($options[5] == 1) {
            $block['latestnews_scroll'] = true;
        }
        $block['scrollheight'] = $options[6];
        $block['scrollspeed'] = $options[7];
        $block['scrolldir'] = $options[8];
        $block['template'] = $options[28];
        $block['imgwidth'] = $options[11];
        $block['imgheight'] = $options[12];
        $block['letters'] = $letters;
        $columns[$k][] = $item;
        ++$k;
        if ($k == $column_count) {
            $k = 0;
        }
    }
    unset($item);
    $block['columns'] = $columns;
    return $block;
}
Esempio n. 2
0
 /**
  * @return string
  */
 public function getAdminLinks()
 {
     $xoops = Xoops::getInstance();
     $adminLinks = '';
     if ($xoops->isUser() && (PublisherUtils::IsUserAdmin() || PublisherUtils::IsUserAuthor($this) || $this->publisher->getPermissionHandler()->isGranted('item_submit', $this->getVar('categoryid')))) {
         if (PublisherUtils::IsUserAdmin() || PublisherUtils::IsUserAuthor($this) || PublisherUtils::IsUserModerator($this)) {
             if ($this->publisher->getConfig('perm_edit') || PublisherUtils::IsUserModerator($this) || PublisherUtils::IsUserAdmin()) {
                 // Edit button
                 $adminLinks .= "<a href='" . PUBLISHER_URL . "/submit.php?itemid=" . $this->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "'/></a>";
                 $adminLinks .= " ";
             }
             if ($this->publisher->getConfig('perm_delete') || PublisherUtils::IsUserModerator($this) || PublisherUtils::IsUserAdmin()) {
                 // Delete button
                 $adminLinks .= "<a href='" . PUBLISHER_URL . "/submit.php?op=del&amp;itemid=" . $this->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png'" . " title='" . _CO_PUBLISHER_DELETE . "' alt='" . _CO_PUBLISHER_DELETE . "' /></a>";
                 $adminLinks .= " ";
             }
         }
         if ($this->publisher->getConfig('perm_clone') || PublisherUtils::IsUserModerator($this) || PublisherUtils::IsUserAdmin()) {
             // Duplicate button
             $adminLinks .= "<a href='" . PUBLISHER_URL . "/submit.php?op=clone&amp;itemid=" . $this->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/clone.gif'" . " title='" . _CO_PUBLISHER_CLONE . "' alt='" . _CO_PUBLISHER_CLONE . "' /></a>";
             $adminLinks .= " ";
         }
     }
     // PDF button
     if ($xoops->service('htmltopdf')->isAvailable()) {
         $adminLinks .= "<a href='" . PUBLISHER_URL . "/makepdf.php?itemid=" . $this->getVar('itemid') . "' rel='nofollow' target='_blank'><img src='" . PUBLISHER_URL . "/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a>";
         $adminLinks .= " ";
     }
     // Print button
     $adminLinks .= "<a href='" . PublisherUtils::seoGenUrl("print", $this->getVar('itemid'), $this->getVar('short_url')) . "' rel='nofollow' target='_blank'><img src='" . PUBLISHER_URL . "/images/links/print.gif' title='" . _CO_PUBLISHER_PRINT . "' alt='" . _CO_PUBLISHER_PRINT . "' /></a>";
     $adminLinks .= " ";
     // Email button
     if ($xoops->isActiveModule('tellafriend')) {
         $subject = sprintf(_CO_PUBLISHER_INTITEMFOUND, $xoops->getConfig('sitename'));
         $subject = $this->_convert_for_japanese($subject);
         $maillink = PublisherUtils::tellafriend($subject);
         $adminLinks .= '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a>';
         $adminLinks .= " ";
     }
     return $adminLinks;
 }