Ejemplo n.º 1
0
function qpagesBlockPagesEdit($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/qpages/include/general.func.php';
    $categos = array();
    qpArrayCategos($categos);
    $form = __('From category:', 'qpages') . "<br />\n\t\t\t<select name='options[0]'><option value='0'" . ($options[0] == 0 ? " selected='selected'" : '') . ">" . _SELECT . "</option>";
    foreach ($categos as $k) {
        $form .= "<option value='{$k['id_cat']}'" . ($options[0] == $k['id_cat'] ? " selected='selected'" : '') . ">{$k['nombre']}</option>";
    }
    $form .= "</select><br /><br />";
    $form .= __('Number of pages', 'qpages') . "<br />\n\t\t\t<input type='text' name='options[1]' size='10' value='{$options['1']}' />";
    return $form;
}
Ejemplo n.º 2
0
/**
 * Función para obtener las categorías en un array
 */
function qpArrayCategos(&$ret, $saltos = 0, $parent = 0, $exclude = null)
{
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix("qpages_categos") . " WHERE parent='{$parent}' ORDER BY `id_cat`");
    while ($row = $db->fetchArray($result)) {
        if (is_array($exclude) && (in_array($row['parent'], $exclude) || in_array($row['id_cat'], $exclude))) {
            $exclude[] = $row['id_cat'];
        } else {
            $rtn = array();
            $rtn = $row;
            $rtn['saltos'] = $saltos;
            $ret[] = $rtn;
        }
        qpArrayCategos($ret, $saltos + 1, $row['id_cat'], $exclude);
    }
    return true;
}
Ejemplo n.º 3
0
/**
 * Presenta un formulario para la creación de una nueva
 * categoría para los artículos
 */
function newForm($edit = 0)
{
    global $xoopsModule;
    if ($edit) {
        $id = isset($_GET['id']) ? $_GET['id'] : 0;
        if ($id <= 0) {
            redirectMsg('cats.php', __('You must provide a category ID to edit!', 'qpages'), 1);
            die;
        }
        // Cargamos la categoría
        $catego = new QPCategory($id);
        // Si no existe entonces devolvemos un error
        if ($catego->isNew()) {
            redirectMsg('cats.php', __('Specified category does not exists!', 'qpages'), 1);
            die;
        }
    }
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . ($edit ? __('Edit Category', 'qpages') : __('New Category', 'qpages')));
    xoops_cp_header();
    $cats = array();
    qpArrayCategos($cats, 0, 0, $edit ? array($id) : 0);
    $form = new RMForm($edit ? __('Edit Category', 'qpages') : __('New Category', 'qpages'), 'frmNew', 'cats.php');
    $form->addElement(new RMFormText(__('Category name', 'qpages'), 'nombre', 50, 150, $edit ? $catego->getName() : ''), true);
    $form->addElement(new RMFormTextArea(__('Description', 'qpages'), 'descripcion', 5, 45, $edit ? $catego->getVar('descripcion', 'e') : ''));
    $ele = new RMFormSelect(__('Category parent', 'qpages'), 'parent');
    $ele->addOption(0, _SELECT, $edit ? $catego->getParent() == 0 ? 1 : 0 : 1);
    foreach ($cats as $k) {
        $ele->addOption($k['id_cat'], str_repeat("-", $k['saltos']) . ' ' . $k['nombre'], $edit ? $catego->getParent() == $k['id_cat'] ? 1 : 0 : 0);
    }
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $ele = new RMFormButtonGroup('', ' ');
    $ele->addButton('sbt', $edit ? __('Update Category', 'qpages') : __('Create Category', 'qpages'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'qpages'), 'button');
    $ele->setExtra('cancel', "onclick='history.go(-1);'");
    $form->addElement($ele);
    $form->display();
    xoops_cp_footer();
}
Ejemplo n.º 4
0
/**
 * Muestra el formulario para la creación de una nueva página enlazada
 */
function newLinkForm($edit = 0)
{
    global $db, $mc, $xoopsModule, $myts;
    foreach ($_REQUEST as $k => $v) {
        ${$k} = $v;
    }
    $pag = isset($page) ? $page : 1;
    if ($edit) {
        $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
        if ($id <= 0) {
            redirectMsg("pages.php&cat={$cat}&page={$pag}", __('You must provide a page ID to edit', 'qpages'), 1);
            die;
        }
        $page = new QPPage($id);
    }
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . ($edit ? __('Edit linked page', 'qpages') : __('New linked page', 'qpages')));
    RMTemplate::get()->add_script('../include/js/forms_pages.js');
    xoops_cp_header();
    $form = new RMForm($edit ? __('Edit Linked Page', 'qpages') : __('New Linked Page', 'qpages'), 'frmNew', 'pages.php');
    $form->addElement(new RMFormText(__('Page title', 'qpages'), 'titulo', 50, 255, $edit ? $page->getTitle() : ''), true);
    if ($edit) {
        $ele = new RMFormText(__('Friendly title', 'qpages'), 'titulo_amigo', 50, 255, $page->getFriendTitle());
        $ele->setDescription(__('This title will be used in friendly url.', 'qpages'));
        $form->addElement($ele);
        $form->addElement(new RMFormHidden('id', $page->getID()));
    }
    $ele = new RMFormSelect(__('Category', 'qpages'), 'catego', 0);
    $categos = array();
    qpArrayCategos($categos);
    $ele->addOption('0', _SELECT, $edit ? 0 : 1);
    foreach ($categos as $k) {
        $ele->addOption($k['id_cat'], str_repeat("-", $k['saltos']) . " " . $k['nombre'], $edit ? $k['id_cat'] == $page->getCategory() ? 1 : 0 : 0);
    }
    $form->addElement($ele, true, "Select:0");
    $form->addElement(new RMFormTextArea(__('Introduction', 'qpages'), 'desc', 5, 60, $edit ? $page->getDescription() : ''));
    // URL
    $form->addElement(new RMFormText(__('Target URL', 'qpages'), 'url', 50, 255, $edit ? $page->url() : ''), true);
    // Grupos
    $ele = new RMFormGroups(__('Allowed groups', 'qpages'), 'grupos', 1, 1, 3, $edit ? $page->getGroups() : array(0));
    $ele->setDescription(__('Only selected groups can access to this document.', 'qpages'));
    $form->addElement($ele);
    $ele = new RMFormRadio(__('Status', 'qpages'), 'acceso', 1);
    $ele->addOption(__('Public', 'qpages'), '1', $edit ? $page->getAccess() ? 1 : 0 : 0);
    $ele->addOption(__('Draft', 'qpages'), '0', $edit ? $page->getAccess() ? 0 : 1 : 1);
    $form->addElement($ele);
    $page_metas = $edit ? $page->get_meta() : array();
    $available_metas = qp_get_metas();
    include 'metas.php';
    $form->addElement(new RMFormLabel('', $meta_data));
    $ele = new RMFormButtonGroup();
    $ele->addButton('save', $edit ? __('Update Page', 'qpages') : __('Save Page', 'qpages'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'qpages'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('type', 1));
    $form->addElement(new RMFormHidden('cat', $cat));
    $form->addElement(new RMFormHidden('page', $pag));
    $form->display();
    xoops_cp_footer();
}
Ejemplo n.º 5
0
// Create simple pages easily and quickly
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$xoopsOption['template_main'] = 'qpages_index.html';
$xoopsOption['module_subpage'] = 'index';
require 'header.php';
$tpl->assign('page_title', $xoopsModule->name());
$location = '<a href="' . QP_URL . '" title="' . $xoopsModule->name() . '">' . __('Main', 'qpages') . '</a>';
$tpl->assign('page_location', $location);
$tpl->assign('xoops_pagetitle', $xoopsModule->name() . ' &raquo; ' . __('Main', 'qpages'));
$tpl->assign('home_text', $mc['texto']);
$result = $db->query("SELECT * FROM " . $db->prefix("qpages_categos") . " WHERE parent='0' ORDER BY nombre ASC");
$categos = array();
qpArrayCategos($categos);
while ($k = $db->fetchArray($result)) {
    $catego = new QPCategory();
    $catego->assignVars($k);
    $lpages = $catego->loadPages();
    $pages = array();
    foreach ($lpages as $p) {
        $ret = array();
        $ret['titulo'] = $p['titulo'];
        $ret['desc'] = TextCleaner::getInstance()->clean_disabled_tags($p['desc']);
        $ret['link'] = $mc['links'] ? QP_URL . '/' . $p['titulo_amigo'] . '/' : QP_URL . '/page.php?page=' . $p['titulo_amigo'];
        $pages[] = $ret;
    }
    $link = $catego->getLink();
    $subcats = $catego->getSubcategos();
    $tpl->append('categos', array('id' => $catego->getID(), 'nombre' => $catego->getName(), 'desc' => $catego->getDescription(), 'pages' => $pages, 'pages_count' => count($lpages), 'link' => $link, 'subcats' => count($subcats) > 0 ? $subcats : '', 'subcats_count' => count($subcats)));