Esempio n. 1
0
/**
* @desc Muestra el menu de opciones para sindicación
* @param int $limit Limite de resultados solicitados. 0 Indica ilimitado
* @param bool $more Referencia. Debe devolver true si existen mas resultados que el límite deseado
* @return array
*/
function &mywords_rssfeed($limit, &$more)
{
    global $db;
    $limit = $limit > 0 ? $limit - 1 : 0;
    include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwcategory.class.php';
    $ret = array();
    $rtn = array();
    $ret['name'] = _MI_MW_RSSALL;
    $ret['desc'] = _MI_MW_RSSALLDESC;
    $ret['params'] = "show=all";
    $rtn[] = $ret;
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("mw_categos") . " ORDER BY parent ASC";
    list($num) = $db->fetchRow($db->query($sql));
    if ($num > $limit && $limit > 0) {
        $more = true;
    }
    $sql = str_replace("COUNT(*)", '*', $sql);
    if ($limit > 0) {
        $sql .= " LIMIT 0, {$limit}";
    }
    $result = $db->query($sql);
    while ($row = $db->fetchArray($result)) {
        $cat = new MWCategory();
        $cat->assignVars($row);
        $ret = array();
        $ret['name'] = $cat->getName();
        $ret['desc'] = $cat->getDescription();
        $ret['params'] = "show=cat&id=" . $cat->getFriendName();
        $rtn[] = $ret;
    }
    return $rtn;
}
Esempio n. 2
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. 3
0
/**
 * Elimina una categoría de la base de datos.
 * Las subcategorías pertenecientes a esta categoría no son eliminadas,
 * sino que son asignadas a la categoría superior.
 */
function deleteCatego()
{
    global $xoopsSecurity, $xoopsModule;
    $cats = rmc_server_var($_POST, 'cats', array());
    if (empty($cats)) {
        redirectMsg('categories.php', __('You must select one category at least!', 'mywords'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('categories.php', __("Session token expired!", 'mw_categories'), 1);
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("mw_categories") . " WHERE id_cat IN (" . implode(",", $cats) . ")";
    $result = $db->query($sql);
    while ($row = $db->fetchArray($result)) {
        $cat = new MWCategory();
        $cat->assignVars($row);
        if (!$cat->delete()) {
            showMessage(__('Category "%s" could not be deleted', 'mywords'), 1);
        }
    }
    redirectMsg('categories.php', __('Database updated!', 'mw_categories'), 0);
}
Esempio n. 4
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;
 }