Ejemplo n.º 1
0
function qpagesBlockCategos()
{
    global $xoopsConfig, $mc;
    include_once XOOPS_ROOT_PATH . '/modules/qpages/class/qpcategory.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/qpages/include/general.func.php';
    $mc =& RMUtilities::module_config('qpages');
    $db =& XoopsDatabaseFactory::getDatabaseConnection();
    if (!defined('QP_URL')) {
        define('QP_URL', XOOPS_URL . ($mc['links'] ? $mc['basepath'] : '/modules/qpages'));
    }
    $block = array();
    $categos = array();
    qpArrayCategos($categos);
    foreach ($categos as $k) {
        $catego = new QPCategory();
        $catego->assignVars($k);
        $rtn = array();
        $rtn['id'] = $catego->getID();
        $rtn['nombre'] = $catego->getName();
        $rtn['link'] = $catego->getLink();
        $rtn['ident'] = $k['saltos'] > 0 ? $k['saltos'] + 8 : 0;
        $block['categos'][] = $rtn;
    }
    return $block;
}
Ejemplo n.º 2
0
/**
 * Muestra los envíos existentes
 */
function showPages($acceso = -1)
{
    global $mc, $xoopsModule, $xoopsSecurity;
    $keyw = rmc_server_var($_REQUEST, 'keyw', '');
    $acceso = rmc_server_var($_REQUEST, 'acceso', -1);
    $cat = rmc_server_var($_REQUEST, 'cat', '');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("qpages_pages");
    if ($acceso >= 0) {
        $sql .= " WHERE acceso={$acceso}";
    }
    if (trim($keyw) != '') {
        $sql .= ($acceso >= 0 ? " AND " : " WHERE ") . "titulo LIKE '%{$keyw}%'";
    }
    if (isset($cat) && $cat > 0) {
        $sql .= ($acceso >= 0 || $keyw != '' ? " AND " : " WHERE ") . "cat='{$cat}'";
    }
    /**
     * Paginacion de Resultados
     */
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $page = $page <= 0 ? 1 : $page;
    $limit = 15;
    list($num) = $db->fetchRow($db->query($sql));
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('pages.php?cat=' . $cat . '&page={PAGE_NUM}');
    $sql .= " ORDER BY id_page DESC LIMIT {$start},{$limit}";
    $sql = str_replace("SELECT COUNT(*)", "SELECT *", $sql);
    $result = $db->query($sql);
    $pages = array();
    while ($row = $db->fetchArray($result)) {
        $p = new QPPage();
        $p->assignVars($row);
        # Enlaces para las categorías
        $catego = new QPCategory($p->getCategory());
        $pages[] = array('id' => $p->getID(), 'titulo' => $p->getTitle(), 'catego' => $catego->getName(), 'fecha' => formatTimeStamp($p->getDate(), 's'), 'link' => $p->getPermaLink(), 'estado' => $p->getAccess(), 'modificada' => $p->getModDate() == 0 ? '--' : formatTimestamp($p->getModDate(), 'c'), 'lecturas' => $p->getReads(), 'order' => $p->order(), 'type' => $p->type(), 'desc' => $p->getDescription());
    }
    /**
     * Cargamos las categorias
     */
    $categos = array();
    qpArrayCategos($categos);
    $categories = array();
    foreach ($categos as $k) {
        $categories[] = array('id' => $k['id_cat'], 'nombre' => $k['nombre'], 'saltos' => $k['saltos']);
    }
    RMTemplate::get()->add_style('admin.css', 'qpages');
    RMTemplate::get()->add_script('../include/js/qpages.js');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->assign('xoops_pagetitle', __('Pages Management', 'qpages'));
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . ($acceso < 0 ? __('All Pages', 'qpages') : ($acceso == 0 ? __('Draft pages', 'qpages') : __('Published pages', 'qpages'))));
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/qp_pages.php", 'module', 'qpages');
    xoops_cp_footer();
}
Ejemplo n.º 3
0
    $rp->assignVars($p);
    $tpl->append('pages', array('id' => $rp->getID(), 'link' => $rp->getPermaLink(), 'title' => $rp->getTitle(), 'modified' => formatTimestamp($rp->getModDate(), 'l'), 'hits' => $rp->getReads(), 'desc' => $rp->getDescription()));
}
$tpl->assign('page_count', count($lpages));
unset($pages);
// Subcategorias
$result = $db->query("SELECT * FROM " . $db->prefix("qpages_categos") . " WHERE parent = " . $catego->getID());
$tpl->assign('subcats_count', $db->getRowsNum($result));
while ($k = $db->fetchArray($result)) {
    $cat = new QPCategory();
    $cat->assignVars($k);
    $lpages = $cat->loadPages();
    $pages = array();
    foreach ($lpages as $p) {
        $page = new QPPage();
        $page->assignVars($p);
        $ret = array();
        $ret['titulo'] = $page->getTitle();
        $ret['desc'] = $page->getDescription();
        $ret['link'] = $page->getPermaLink();
        $pages[] = $ret;
    }
    $link = $cat->getLink();
    $subcats = $cat->getSubcategos();
    $tpl->append('categos', array('id' => $cat->getID(), 'nombre' => $cat->getName(), 'desc' => $cat->getDescription(), 'pages_count' => sprintf(__('%u pages', 'qpages'), count($lpages)), 'link' => $link, 'subcats' => count($subcats) > 0 ? $subcats : '', 'subcats_count' => count($subcats)));
}
$tpl->assign('lang_subcats', __('Subcategories', 'qpages'));
$tpl->assign('lang_page', __('Page', 'qpages'));
$tpl->assign('lang_modified', __('Last update', 'qpages'));
$tpl->assign('lang_hits', __('Reads', 'qpages'));
require 'footer.php';
Ejemplo n.º 4
0
 /**
  * Obtenemos las subcategorías
  */
 public function getSubcategos()
 {
     global $mc, $xoopsModule;
     $result = $this->db->query("SELECT * FROM " . $this->_dbtable . " WHERE parent='" . $this->getID() . "'");
     $cats = array();
     while ($row = $this->db->fetchArray($result)) {
         $ret = array();
         $ret['id'] = $row['id_cat'];
         $catego = new QPCategory();
         $catego->assignVars($row);
         $ret['nombre'] = $catego->getName();
         $ret['link'] = $catego->getLink();
         $ret['desc'] = $catego->getDescription();
         $cats[] = $ret;
     }
     return $cats;
 }
Ejemplo n.º 5
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 $db, $xoopsModule, $xoopsSecurity;
    $ids = rmc_server_var($_POST, 'ids', array());
    if (!$xoopsSecurity->check()) {
        redirectMsg('cats.php', __('Session token expired!', 'qpages'), 1);
        die;
    }
    if (!is_array($ids)) {
        redirectMsg('cats.php', __('No category has been selected!', 'qpages'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $id) {
        if ($id <= 0) {
            $errors .= sprintf(__('ID "%s" is not valid!', 'qpages'), $id) . '<br />';
            continue;
        }
        $catego = new QPCategory($id);
        if ($catego->isNew) {
            $errors .= sprintf(__('Category with ID "%s" does not exists!', 'qpages'), $id) . '<br />';
            continue;
        }
        if ($catego->delete()) {
            continue;
        } else {
            $errors .= sprintf(__('Category "%s" could not be deleted!', 'qpages'), $catego->getName()) . '<br />';
            continue;
        }
    }
    if ($errors != '') {
        redirectMsg('cats.php', __('Errors ocurred while trying to delete categories', 'qpages') . '<br />' . $errors, 1);
    } else {
        redirectMsg('cats.php', __('Categories deleted successfully!', 'qpages'));
    }
}
Ejemplo n.º 6
0
            }
        }
        if (!$ok && !$xoopsUser->isAdmin()) {
            redirect_header(QP_URL, 2, _MS_QP_NOALLOWED);
            die;
        }
    }
}
if ($page->type()) {
    header('location: ' . $page->url());
    die;
}
$catego = new QPCategory($page->getCategory());
require 'header.php';
// Asignamos datos de la categoría
$tpl->assign('qpcategory', array('id' => $catego->getID(), 'name' => $catego->getName(), 'nameid' => $catego->getFriendName()));
$idp = 0;
# ID de la categoria padre
$rutas = array();
$path = explode('/', $catego->getPath());
$tbl = $db->prefix("qpages_categos");
foreach ($path as $k) {
    if ($k == '') {
        continue;
    }
    $sql = "SELECT id_cat FROM {$tbl} WHERE nombre_amigo='{$k}' AND parent='{$idp}'";
    $result = $db->query($sql);
    if ($db->getRowsNum($result) > 0) {
        list($idp) = $db->fetchRow($result);
        $rutas[] = new QPCategory($idp);
    }