} } // order by pubdate desc usort($items, create_function('$a,$b', 'return $a["sort_weight"] < $b["sort_weight"] ? 1 : -1 ;')); $mixlist['maxitem'] = $xoopsModuleConfig["mixed_maxitem"]; $mixlist['items'] = $items; $mixlist['mod_url'] = XOOPS_URL . '/modules/' . $mydirname; $mixlist['dtfmt_short'] = $dtfmt_short; $tpl->assign('mixlist', $mixlist); } } // headline_id specified if ($hlid > 0) { $headline =& $hlman->get($hlid); if (is_object($headline)) { $renderer =& xhld_getrenderer($headline, $mydirname); $data = $renderer->getRawDataAsArray(false); // num is 1 origin instead of 0 origin $num = empty($_GET['num']) ? 1 : intval($_GET['num']); // item preparing $item = empty($data['items'][$num - 1]) ? $data['items'][0] : $data['items'][$num - 1]; if ($item['pubdate'] > 0) { $item['date_short'] = date($dtfmt_short, xoops_getUserTimestamp($item['pubdate'])); $item['date'] = formatTimestamp($item['pubdate'], 'm'); } // strip tags other than <BR> $item['description'] = str_replace('[br]', '<BR>', strip_tags(str_replace(array('<br />', '<br>', '<BR />', '<BR>'), '[br]', $item['description']))); // navigation if ($num > 1) { $tpl->assign('prev_num', $num - 1); }
function b_xhld_mixed_show($options) { $mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0]; $maxitem = empty($options[1]) ? 10 : intval($options[1]); $maxlen = empty($options[2]) ? 128 : intval($options[2]); $maxitemafeed = empty($options[3]) ? 99 : intval($options[3]); $block = array(); $hlman =& xoops_getmodulehandler('headline', $mydirname, true); if (!$hlman) { $mydirname = basename(dirname(dirname(__FILE__))); $hlman =& xoops_getmodulehandler('headline', $mydirname, true); if (!$hlman) { return array(); } } $headlines =& $hlman->getObjects(new Criteria('headline_asblock', 1)); $count = count($headlines); $items = array(); for ($i = 0; $i < $count; $i++) { // list( $usec , $sec ) = explode( " " , microtime() ) ; // $starttime = $sec + $usec ; $renderer =& xhld_getrenderer($headlines[$i], $mydirname); $itemsperfeed = empty($renderer->config["mixed_mode"]) ? 100 : $headlines[$i]->getVar('headline_blockmax'); $tmp_data = $renderer->getRawDataAsArray(false, min($itemsperfeed, $maxitemafeed), $maxlen); $dtfmt_short = empty($renderer->config["dtfmt_short"]) ? '' : $renderer->config["dtfmt_short"]; // list( $usec , $sec ) = explode( " " , microtime() ) ; // echo "<p>" . ( $sec + $usec - $starttime ) . "sec.</p>" ; if (!empty($tmp_data)) { $no_pubdate_counter = $i; foreach ($tmp_data['items'] as $item) { if (empty($item['pubdate'])) { $item['pubdate'] = ''; $no_pubdate_counter += $count; $sort_weight = -$no_pubdate_counter; } else { $sort_weight = $item['pubdate']; } $items[] = array('site_name' => $tmp_data['site_name'], 'site_url' => $tmp_data['site_url'], 'site_id' => $tmp_data['site_id'], 'channel_data' => $tmp_data['channel_data'], 'image_data' => empty($tmp_data['image_data']) ? array() : $tmp_data['image_data'], 'title' => $item['title'], 'link' => $item['link'], 'sort_weight' => $sort_weight, 'pubdate' => $item['pubdate'], 'pubdate_utz' => xoops_getUserTimestamp($item['pubdate']), 'date_short' => date($dtfmt_short, xoops_getUserTimestamp($item['pubdate'])), 'date' => formatTimestamp($item['pubdate'], 'm'), 'description' => empty($item['description']) ? '' : $item['description']); } } } // order by pubdate desc usort($items, create_function('$a,$b', 'return $a["sort_weight"] < $b["sort_weight"] ? 1 : -1 ;')); $block['maxitem'] = $maxitem; $block['items'] = $items; $block['mod_url'] = XOOPS_URL . '/modules/' . $mydirname; $block['dtfmt_short'] = empty($dtfmt_short) ? '' : $dtfmt_short; return $block; }
$hl->setVar('headline_asblock', $headline_asblock); $hl->setVar('headline_encoding', $headline_encoding); $hl->setVar('headline_cachetime', $headline_cachetime); $hl->setVar('headline_mainfull', $headline_mainfull); $hl->setVar('headline_mainimg', $headline_mainimg); $hl->setVar('headline_mainmax', $headline_mainmax); $hl->setVar('headline_blockimg', $headline_blockimg); $hl->setVar('headline_blockmax', $headline_blockmax); $hl->setVar('headline_updated', 0); $hl->setVar('headline_xml', array()); // remove block caches @unlink(XOOPS_CACHE_PATH . "/db%3Axhld{$mydirnumber}_block_rss.html"); @unlink(XOOPS_CACHE_PATH . "/db%3Axhld{$mydirnumber}_block_mixed.html"); $msg = ''; if ($hlman->insert($hl)) { $renderer =& xhld_getrenderer($hl, $mydirname); if ($renderer->updateCache(true) !== false) { // save success , fetch success redirect_header('index.php', 2, _AM_DBUPDATED); exit; } // save success , fetch fail $msg .= '<br />' . sprintf(_AM_FAILUPDATE, $hl->getVar('headline_name')) . '<br />'; $msg .= $renderer->getErrors(); } else { // save fail $msg .= sprintf(_AM_FAILUPDATE, $hl->getVar('headline_name')); foreach ($hl->getErrors() as $error) { $msg .= '<br />' . $error; } }