/** * @param $options * * @return array */ function publisher_latest_files_show($options) { $publisher =& PublisherPublisher::getInstance(); /** * $options[0] : Category * $options[1] : Sort order - datesub | counter * $options[2] : Number of files to display * $oprions[3] : bool TRUE to link to the file download, FALSE to link to the article */ $block = array(); $sort = $options[1]; $order = publisherGetOrderBy($sort); $limit = $options[2]; $directDownload = $options[3]; // creating the files objects $filesObj =& $publisher->getHandler('file')->getAllFiles(0, PublisherConstants::PUBLISHER_STATUS_FILE_ACTIVE, $limit, 0, $sort, $order, explode(',', $options[0])); foreach ($filesObj as $fileObj) { $aFile = array(); $aFile['link'] = $directDownload ? $fileObj->getFileLink() : $fileObj->getItemLink(); if ($sort === 'datesub') { $aFile['new'] = $fileObj->getDatesub(); } elseif ($sort === 'counter') { $aFile['new'] = $fileObj->counter(); } elseif ($sort === 'weight') { $aFile['new'] = $fileObj->weight(); } $block['files'][] = $aFile; } return $block; }
/** * @param $options * * @return array */ function publisher_items_recent_show($options) { $publisher =& PublisherPublisher::getInstance(); $myts = MyTextSanitizer::getInstance(); $block = array(); $selectedcatids = explode(',', $options[0]); if (in_array(0, $selectedcatids)) { $allcats = true; } else { $allcats = false; } $sort = $options[1]; $order = publisherGetOrderBy($sort); $limit = $options[2]; $start = 0; // creating the ITEM objects that belong to the selected category if ($allcats) { $criteria = null; } else { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN')); } $itemsObj =& $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); $totalItems = count($itemsObj); if ($itemsObj && $totalItems > 1) { for ($i = 0; $i < $totalItems; ++$i) { $newItems['itemid'] = $itemsObj[$i]->itemid(); $newItems['title'] = $itemsObj[$i]->getTitle(); $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); $newItems['categoryid'] = $itemsObj[$i]->categoryid(); $newItems['date'] = $itemsObj[$i]->getDatesub(); $newItems['poster'] = $itemsObj[$i]->getLinkedPosterName(); $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); $block['items'][] = $newItems; } $block['lang_title'] = _MB_PUBLISHER_ITEMS; $block['lang_category'] = _MB_PUBLISHER_CATEGORY; $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; $block['lang_date'] = _MB_PUBLISHER_DATE; $modulename = $myts->displayTarea($publisher->getModule()->getVar('name')); $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $modulename; } return $block; }
/** * @param $options * * @return array */ function publisher_category_items_sel_show($options) { $publisher =& PublisherPublisher::getInstance(); $block = array(); $categories =& $publisher->getHandler('category')->getCategories(0, 0, -1); if (count($categories) === 0) { return $block; } $selectedcatids = explode(',', $options[0]); $sort = $options[1]; $order = publisherGetOrderBy($sort); $limit = $options[2]; $start = 0; // creating the ITEM objects that belong to the selected category $block['categories'] = array(); foreach ($categories as $catID => $catObj) { if (!in_array(0, $selectedcatids) && !in_array($catID, $selectedcatids)) { continue; } $criteria = new Criteria('categoryid', $catID); $items =& $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); unset($criteria); if (count($items) === 0) { continue; } $item['title'] = $catObj->name(); $item['itemurl'] = 'none'; $block['categories'][$catID]['items'][] = $item; foreach ($items as $itemObj) { $item['title'] = $itemObj->getTitle(isset($options[3]) ? $options[3] : 0); $item['itemurl'] = $itemObj->getItemUrl(); $block['categories'][$catID]['items'][] = $item; } $block['categories'][$catID]['name'] = $catObj->name(); } unset($items, $categories, $itemObj, $catID, $catObj); if (count($block['categories']) === 0) { return $block; } return $block; }
/** * @param $options * * @return array */ function publisher_latest_news_show($options) { $block = array(); xoops_loadLanguage('main', 'publisher'); $publisher =& PublisherPublisher::getInstance(); $start = $options[0]; // You can show articles from specified range $limit = $options[1]; $columnCount = $options[2]; $letters = $options[3]; $selectedStories = $options[4]; $sort = $options[9]; $order = publisherGetOrderBy($sort); $imgWidth = $options[11]; $imgHeight = $options[12]; $border = $options[13]; $bordercolor = $options[14]; $block['spec']['columnwidth'] = (int) (1 / $columnCount * 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 ($selectedStories != 0) { unset($criteria); //removes category option $criteria = new CriteriaCompo(); $criteria->add(new Criteria('itemid', '(' . $selectedStories . ')', 'IN')); } $itemsObj =& $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, 'itemid'); $scount = count($itemsObj); if ($scount == 0) { return false; } $k = 0; $columns = array(); foreach ($itemsObj as $itemid => $itemObj) { $item = array(); $item['itemurl'] = $itemObj->getItemUrl(); $item['title'] = $itemObj->getItemLink(); $item['alt'] = strip_tags($itemObj->getItemLink()); $mainImage = $itemObj->getMainImage(); // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { $item['item_image'] = $mainImage['image_path']; } else { $item['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&w=' . $imgWidth; // No $imgHeight for autoheight option } $item['text'] = $itemObj->getBlockSummary($letters); $item = $itemObj->getMainImage($item); //returns an array $lsHeight = ''; if ($options[12] != 0) { $lsHeight = 'height="' . $imgHeight . '" '; } // set height = 0 in block option for auto height if ($options[15] === 'LEFT') { $imgPosition = 'float: left'; $lsMargin = '-right'; } if ($options[15] === 'CENTER') { $imgPosition = 'text-align:center'; $lsMargin = ''; } if ($options[15] === 'RIGHT') { $imgPosition = 'float: right'; $lsMargin = '-left'; } //Image if ($options[10] == 1 && $item['image_path'] != '') { $startdiv = '<div style="' . $imgPosition . '"><a href="' . $item['itemurl'] . '">'; $style = 'style="margin' . $lsMargin . ': 10px; padding: 2px; border: ' . $border . 'px solid #' . $bordercolor . '"'; $enddiv = 'width="' . $imgWidth . '" ' . $lsHeight . '/></a></div>'; $image = $startdiv . '<img ' . $style . ' src="' . $item['item_image'] . '" alt="' . $item['image_name'] . '" ' . $enddiv; $item['image'] = $image; } if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin(-1)) { $item['admin'] = "<a href='" . PUBLISHER_URL . '/submit.php?itemid=' . $itemObj->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "' /></a> "; $item['admin'] .= "<a href='" . PUBLISHER_URL . '/admin/item.php?op=del&itemid=' . $itemObj->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/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="'.XOOPS_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 && $GLOBALS['xoopsUser']) { $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) { $item['posttime'] = _ON . ' ' . $itemObj->getDatesub(); } $item['topic_title'] = ''; if ($options[21] == 1) { $item['topic_title'] = $itemObj->getCategoryLink() . _MB_PUBLISHER_SP; } $item['read'] = ''; if ($options[22] == 1) { $item['read'] = ' (' . $itemObj->counter() . ' ' . _READS . ')'; } $item['more'] = ''; if ($itemObj->body() != '' || $itemObj->comments() > 0) { $item['more'] = '<a class="publisher_spotlight_readmore" href="' . $itemObj->getItemUrl() . '">' . _MB_PUBLISHER_READMORE . '</a>'; } $comments = $itemObj->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'] = ' ' . _MB_PUBLISHER_ONECOMMENT . ' '; } else { $item['comment'] = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; } } else { $item['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; } } $item['print'] = ''; if ($options[24] == 1) { $item['print'] = '<a href="' . PublisherSeo::generateUrl('print', $itemObj->itemid(), $itemObj->short_url()) . '" rel="nofollow"><img src="' . PUBLISHER_URL . '/assets/images/links/print.gif" title="' . _CO_PUBLISHER_PRINT . '" alt="' . _CO_PUBLISHER_PRINT . '" /></a> '; } $item['pdf'] = ''; if ($publisher->getConfig('display_pdf')) { if ($options[25] == 1) { $item['pdf'] = "<a href='" . PUBLISHER_URL . '/makepdf.php?itemid=' . $itemObj->itemid() . "' rel='nofollow'><img src='" . PUBLISHER_URL . "/assets/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a> "; } } $item['email'] = ''; if ($options[26] == 1 && xoops_isActiveModule('tellafriend')) { $subject = sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']); $subject = $itemObj->convertForJapanese($subject); $maillink = publisherTellAFriend($subject); $item['email'] = '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/assets/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a> '; } $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 == $columnCount) { $k = 0; } } unset($item); $block['columns'] = $columns; return $block; }
/** * @param $options * * @return array */ function publisher_items_new_show($options) { $publisher =& PublisherPublisher::getInstance(); $selectedcatids = explode(',', $options[0]); $block = array(); if (in_array(0, $selectedcatids)) { $allcats = true; } else { $allcats = false; } $sort = $options[1]; $order = publisherGetOrderBy($sort); $limit = $options[3]; $start = 0; $image = $options[5]; // creating the ITEM objects that belong to the selected category if ($allcats) { $criteria = null; } else { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN')); } $itemsObj =& $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); $totalitems = count($itemsObj); if ($itemsObj && $totalitems > 1) { for ($i = 0; $i < $totalitems; ++$i) { $item = array(); $item['link'] = $itemsObj[$i]->getItemLink(false, isset($options[4]) ? $options[4] : 65); $item['id'] = $itemsObj[$i]->itemid(); $item['poster'] = $itemsObj[$i]->posterName(); // for make poster name linked, use getLinkedPosterName() instead of posterName() if ('article' === $image) { $item['image'] = XOOPS_URL . '/uploads/blank.gif'; $item['image_name'] = ''; $images = $itemsObj[$i]->getImages(); if (is_object($images['main'])) { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { $item['image'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name'); } else { $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . '&w=50'; } $item['image_name'] = $images['main']->getVar('image_nicename'); } } elseif ('category' === $image) { $item['image'] = $itemsObj[$i]->getCategoryImagePath(); $item['image_name'] = $itemsObj[$i]->getCategoryName(); } elseif ('avatar' === $image) { if ($itemsObj[$i]->uid() == '0') { $item['image'] = XOOPS_URL . '/uploads/blank.gif'; $images = $itemsObj[$i]->getImages(); if (is_object($images['main'])) { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { $item['image'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name'); } else { $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . '&w=50'; } } } else { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { $item['image'] = XOOPS_URL . '/uploads/' . $itemsObj[$i]->posterAvatar(); } else { $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $itemsObj[$i]->posterAvatar() . '&w=50'; } } $item['image_name'] = $itemsObj[$i]->posterName(); } $item['title'] = $itemsObj[$i]->getTitle(); if ('datesub' === $sort) { $item['new'] = $itemsObj[$i]->getDatesub(); } elseif ('counter' === $sort) { $item['new'] = $itemsObj[$i]->counter(); } elseif ('weight' === $sort) { $item['new'] = $itemsObj[$i]->weight(); } elseif ('rating' === $sort) { $item['new'] = $itemsObj[$i]->rating(); } elseif ('votes' === $sort) { $item['new'] = $itemsObj[$i]->votes(); } elseif ('comments' === $sort) { $item['new'] = $itemsObj[$i]->comments(); } $block['newitems'][] = $item; } } $block['show_order'] = $options[2]; return $block; }