Esempio n. 1
0
function mywordsBlockCats($options)
{
    global $xoopsModuleConfig, $xoopsModule;
    $categos = array();
    MWFunctions::categos_list($categos, 0, 0, $options[0]);
    $block = array();
    $mc = $xoopsModule && $xoopsModule->getVar('dirname') == 'mywords' ? $xoopsModuleConfig : RMSettings::module_settings('mywords');
    foreach ($categos as $k) {
        $ret = array();
        $cat = new MWCategory();
        $cat->assignVars($k);
        $cat->loadPosts();
        $ret['id'] = $cat->id();
        $ret['name'] = $cat->getVar('name');
        if (isset($options[1]) && $options[1]) {
            $ret['posts'] = $cat->getVar('posts');
        }
        $ret['indent'] = $k['indent'] * 2;
        $ret['link'] = $cat->permalink();
        $block['categos'][] = $ret;
    }
    RMTemplate::get()->add_style('mwblocks.css', 'mywords');
    return $block;
}
Esempio n. 2
0
$rss_channel = array();
switch ($show) {
    case 'cat':
        include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwcategory.class.php';
        $id = rmc_server_var($_GET, 'cat', 0);
        if ($id <= 0) {
            redirect_header('backend.php', 1, __('Sorry, specified category was not foud!', 'mywords'));
            die;
        }
        $cat = new MWCategory($id);
        if ($cat->isNew()) {
            redirect_header('backend.php', 1, __('Sorry, specified category was not foud!', 'mywords'));
            die;
        }
        $rss_channel['title'] = sprintf(__('Posts in %s - %s', 'mywords'), $cat->name, $xoopsConfig['sitename']);
        $rss_channel['link'] = $cat->permalink();
        $rss_channel['description'] = htmlspecialchars($cat->getVar('description'), ENT_QUOTES);
        $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
        $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
        $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
        $rss_channel['category'] = $cat->getVar('name');
        $rss_channel['generator'] = 'Common Utilities';
        $rss_channel['language'] = RMCLANG;
        $posts = MWFunctions::get_posts_by_cat($id, 0, 10);
        $rss_items = array();
        foreach ($posts as $post) {
            $item = array();
            $item['title'] = $post->getVar('title');
            $item['link'] = $post->permalink();
            $img = new RMImage();
            $img->load_from_params($post->getVar('image', 'e'));
Esempio n. 3
0
 /**
  * Devuelve los nombres de las categorías a las que pertenece
  * el post actual
  * @param bool $asList Detemina si se muestra en forma de lista o de array
  * @param string $delimiter Delimitador para la lista
  * @param bool Get names with links. Only works when $asList equal true
  * @param string Section for link. It can be front or admin. Only works when $asList equal true
  * @return string or array
  */
 public function get_categories_names($asList = true, $delimiter = ',', $links = true, $section = 'front')
 {
     if (empty($this->lcats)) {
         $this->get_categos('data');
     }
     $rtn = $asList ? '' : array();
     $url = MWFunctions::get_url();
     foreach ($this->lcats as $cat) {
         if ($asList) {
             if ($links) {
                 $category = new MWCategory();
                 $category->assignVars($cat);
                 $rtn .= $rtn == '' ? '' : "{$delimiter}";
                 $rtn .= '<a href="' . ($section == 'front' ? $category->permalink() : 'posts.php?cat=' . $cat['id_cat']) . '">' . $cat['name'] . '</a>';
             } else {
                 $rtn .= $rtn == '' ? $cat['name'] : "{$delimiter} {$cat['name']}";
             }
         } else {
             $rtn[] = $row['nombre'];
         }
     }
     return $rtn;
 }
Esempio n. 4
0
    redirect_header(MWFunctions::get_url(), 2, __('Specified category could not be found', 'mywords'));
    die;
}
// Datos de la Categoría
$xoopsTpl->assign('category', array('id' => $catego->id(), 'name' => $catego->getVar('name')));
$xoopsTpl->assign('lang_postsincat', sprintf(__('Posts in &#8216;%s&#8217; Category', 'mywords'), $catego->getVar('name')));
$request = substr($request, 0, strpos($request, 'page') > 0 ? strpos($request, 'page') - 1 : strlen($request));
//$request =
// Select all posts from relations table
//$sql = "SELECT post FROM ".$db->prefix("mw_catpost")." WHERE cat='$category'";
//$result = $db->query($sql);
/**
 * Paginacion de Resultados
 */
$limit = $mc['posts_limit'];
list($num) = $db->fetchRow($db->query("SELECT COUNT({$tbl2}.post) FROM {$tbl2}, {$tbl3} WHERE {$tbl2}.cat='{$category}' \n\t\tAND {$tbl3}.id_post={$tbl2}.post AND {$tbl3}.status='publish' AND \n\t\t(({$tbl3}.visibility='public' OR {$tbl3}.visibility='password') OR ({$tbl3}.visibility='private' AND \n\t\t{$tbl3}.author=" . ($xoopsUser ? $xoopsUser->uid() : -1) . "))"));
$page = isset($page) && $page > 0 ? $page : 1;
$limit = $xoopsModuleConfig['posts_limit'];
$tpages = ceil($num / $limit);
$page = $page > $tpages ? $tpages : $page;
$p = $page > 0 ? $page - 1 : $page;
$start = $num <= 0 ? 0 : $p * $limit;
$xoopsTpl->assign('page', $page);
$nav = new RMPageNav($num, $limit, $page, 5);
$nav->target_url($catego->permalink() . ($xoopsModuleConfig['permalinks'] == 1 ? '&page={PAGE_NUM}' : 'page/{PAGE_NUM}/'));
$xoopsTpl->assign('pagenav', $nav->render(false));
$xoopsTpl->assign('lang_permalink', __('Permalink to this post', 'mywords'));
$result = $db->query("SELECT {$tbl3}.* FROM {$tbl2}, {$tbl3} WHERE {$tbl2}.cat='{$category}' \n\t\tAND {$tbl3}.id_post={$tbl2}.post AND {$tbl3}.status='publish' AND \n\t\t(({$tbl3}.visibility='public' OR {$tbl3}.visibility='password') OR ({$tbl3}.visibility='private' AND \n\t\t{$tbl3}.author=" . ($xoopsUser ? $xoopsUser->uid() : -1) . ")) ORDER BY {$tbl3}.pubdate DESC LIMIT {$start},{$limit}");
require 'post_data.php';
$xoopsTpl->assign('xoops_pagetitle', sprintf(__('Posts published under "%s"', 'mywords'), $catego->getVar('name')));
include 'footer.php';