Exemplo n.º 1
0
/**
* @desc Formulario para la creación de una nueva publicación
**/
function formPublish()
{
    global $xoopsModuleConfig, $xoopsUser, $xoopsTpl, $xoopsConfig;
    include 'header.php';
    //Verificamos si existen permisos para crear un nuevo recurso
    if (!$xoopsModuleConfig['createres']) {
        redirect_header(RDFunctions::url(), 1, __('The creation of new Documents has been disabled by administrator.', 'docs'));
        die;
    }
    //Verificamos si usuario tiene permisos de crear nuevo recurso
    $res = new RDResource();
    if (!RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS))) {
        redirect_header(RDFunctions::url(), 1, __('You can not create Documents.', 'docs'));
        die;
    }
    $xoopsTpl->assign('xoops_pagetitle', __('Create Document', 'docs'));
    $form = new RMForm(__('Create Document', 'docs'), 'frmres', RMFunctions::current_url());
    $form->setExtra("enctype='multipart/form-data'");
    $form->addElement(new RMFormText(__('Document title', 'docs'), 'title', 50, 150), true);
    $form->addElement(new RMFormTextArea(__('Description', 'docs'), 'desc', 5, 50), true);
    //editores de la publicación
    $form->addElement(new RMFormUser(__('Editors', 'docs'), 'editors', 1, $xoopsUser ? array($xoopsUser->uid()) : array(), 30));
    //Grupos con permiso de acceso
    $form->addElement(new RMFormGroups(__('Groups that can read Document', 'docs'), 'groups', 1, 1, 1, array(1, 2)), true);
    $form->addElement(new RMFormYesno(__('Quick index', 'docs'), 'quick'));
    $form->addElement(new RMFormYesno(__('Show index to restricted users', 'docs'), 'showindex'));
    $form->addElement(new RMFormYesno(__('Show content in a single page', 'docs'), 'single'));
    $form->addElement(new RMFormLabel(__('Approved', 'docs'), $xoopsModuleConfig['approved'] ? __('Inmediatly', 'docs') : __('Wait for approval', 'docs')));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', __('Publish Document'), 'submit');
    $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="history.go(-1);"');
    $form->addElement($buttons);
    $form->addElement(new RMFormHidden('action', 'save'));
    $form->display();
    RMTemplate::get()->add_style('forms.css', 'docs');
    include 'footer.php';
}
Exemplo n.º 2
0
/**
* @desc Muestra el contenido completo de una sección
*/
function showSection(RDResource &$res, RDSection &$section)
{
    global $xoopsUser, $xoopsModuleConfig, $xoopsOption, $xoopsTpl, $xoopsConfig, $standalone;
    include 'header.php';
    $xoopsTpl->assign('xoops_pagetitle', $section->getVar('title'));
    // Resource data
    $resource = array('id' => $res->id(), 'title' => $res->getVar('title'), 'link' => $res->permalink(), 'reads' => $res->getVar('reads'));
    $res->add_read($res);
    // Navegación de Secciones
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("rd_sections") . " WHERE id_res='" . $res->id() . "' AND parent = '0' ORDER BY `order`";
    $result = $db->query($sql);
    $i = 1;
    $number = 1;
    $located = false;
    // Check if current position has been located
    while ($row = $db->fetchArray($result)) {
        $sec = new RDSection();
        $sec->assignVars($row);
        if ($sec->id() == $section->id()) {
            $number = $i;
            $located = true;
        }
        if ($sec->id() == $section->id() && isset($sprev)) {
            $prev_section = array('id' => $sprev->id(), 'title' => $sprev->getVar('title'), 'link' => $sprev->permalink());
        }
        if ($number == $i - 1 && $located) {
            $next_section = array('id' => $sec->id(), 'title' => $sec->getVar('title'), 'link' => $sec->permalink());
            break;
        }
        $i++;
        $sprev = $sec;
    }
    $GLOBALS['rd_section_number'] = $number;
    $sections = RDFunctions::get_section_tree($section->id(), $res, $number, true);
    array_walk($sections, 'rd_insert_edit');
    // Check last modification date
    $last_modification = 0;
    foreach ($sections as $sec) {
        if ($sec['modified'] > $last_modification) {
            $last_modification = $sec['modified'];
            $last_author = array('id' => $sec['author'], 'name' => $sec['author_name']);
        }
    }
    // Event
    $sections = RMEvents::get()->run_event('docs.show.section', $sections, $res, $section);
    RMTemplate::get()->add_style('docs.css', 'docs');
    RMTemplate::get()->add_jquery();
    RMTemplate::get()->add_script(XOOPS_URL . '/modules/docs/include/js/docs.js');
    // URLs
    if ($xoopsModuleConfig['permalinks']) {
        /**
         * @todo Generate friendly links
         */
        if (RMFunctions::plugin_installed('topdf')) {
            $pdf_book_url = RDFunctions::url() . '/pdfbook/' . $section->id() . '/';
            $pdf_section_url = RDFunctions::url() . '/pdfsection/' . $section->id() . '/';
        }
        $print_book_url = RDFunctions::url() . '/printbook/' . $section->id() . '/';
        $print_section_url = RDFunctions::url() . '/printsection/' . $section->id() . '/';
        if (RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) {
            $publish_url = RDFunctions::url() . '/publish/';
        }
    } else {
        if (RMFunctions::plugin_installed('topdf')) {
            $pdf_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=pdfbook';
            $pdf_section_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=pdfsection';
        }
        $print_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=printbook';
        $print_section_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=printsection';
        if (RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) {
            $publish_url = RDFunctions::url() . '/?action=publish';
        }
    }
    // Comments
    RMFunctions::get_comments('docs', 'res=' . $res->id() . '&id=' . $section->id(), 'module', 0);
    RMFunctions::comments_form('docs', 'res=' . $res->id() . '&id=' . $section->id(), 'module', RDPATH . '/class/mywordscontroller.php');
    RDFunctions::breadcrumb();
    RMBreadCrumb::get()->add_crumb($res->getVar('title'), $res->permalink());
    RMBreadCrumb::get()->add_crumb($section->getVar('title'), $section->permalink());
    include RMEvents::get()->run_event('docs.section.template', RMTemplate::get()->get_template('rd_section.php', 'module', 'docs'));
    if ($standalone) {
        RDFunctions::standalone();
    }
    include 'footer.php';
}
Exemplo n.º 3
0
        /**
         * @todo Generate friendly links
         */
        if (RMFunctions::plugin_installed('topdf')) {
            $pdf_book_url = ($xoopsModuleConfig['subdomain'] != '' ? $xoopsModuleConfig['subdomain'] : XOOPS_URL) . $xoopsModuleConfig['htpath'] . '/pdfbook/' . $toc[0]['id'] . '/';
        }
        $print_book_url = ($xoopsModuleConfig['subdomain'] != '' ? $xoopsModuleConfig['subdomain'] : XOOPS_URL) . $xoopsModuleConfig['htpath'] . '/printbook/' . $toc[0]['id'] . '/';
        if (RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) {
            $publish_url = RDFunctions::url() . '/publish/';
        }
    } else {
        if (RMFunctions::plugin_installed('topdf')) {
            $pdf_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $res->id() . '&action=pdfbook';
        }
        $print_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $res->id() . '&action=printbook';
        if (RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) {
            $publish_url = RDFunctions::url() . '/?action=publish';
        }
    }
    include RMTemplate::get()->get_template('rd_resall.php', 'module', 'docs');
} elseif ($res->getVar('quick')) {
    // Show Quick Index to User
    $content = false;
    //Obtiene índice
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix('rd_sections') . " WHERE id_res='" . $res->id() . "' AND parent=0 ORDER BY `order`";
    $result = $db->queryF($sql);
    // Quick index array
    $qindex_sections = array();
    while ($rows = $db->fetchArray($result)) {
        $sec = new RDSection();