/**
* Generate a Table of Contents for an specific section
*/
function rd_generate_toc()
{
    $id = rmc_server_var($_GET, 'id', 0);
    $number = rmc_server_var($GLOBALS, 'rd_section_number', 0);
    if ($id <= 0) {
        return;
    }
    $sec = new RDSection($id);
    if ($sec->isNew()) {
        return;
    }
    $toc = RDFunctions::get_section_tree($id, new RDResource($sec->getVar('id_res')), $number);
    ob_start();
    include RMEvents::get()->run_event('docs.template.toc', RMTemplate::get()->get_template('specials/rd_toc.php', 'module', 'docs'));
    $ret = ob_get_clean();
    return $ret;
}
Esempio n. 2
0
 /**
  * Gets the first parent for a section
  * 
  * @param int $id
  * @return RDSection object
  */
 function super_parent($id)
 {
     global $db;
     if ($id <= 0) {
         return;
     }
     $sec = new RDSection($id);
     if ($sec->isNew()) {
         return array();
     }
     if ($sec->getVar('parent') > 0) {
         $section = self::super_parent($sec->getVar('parent'));
     } else {
         $section = $sec;
     }
     return $sec;
 }
Esempio n. 3
0
    } else {
        $print_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&amp;id=' . $section->id() . '&amp;action=printbook';
        $print_section_url = XOOPS_URL . '/modules/docs/index.php?page=content&amp;id=' . $section->id() . '&amp;action=printsection';
    }
    // This options only works when pdfmyurl is enabled on topdf plugin
    $options = array('--filename' => $res->getVar('title') . '.pdf', '--header-left' => $res->getVar('title'), '--header-right' => $xoopsConfig['sitename'], '--header-line' => '1');
    header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    $plugin->create_pdf_url($all ? $print_book_url : $print_section_url, $res->getVar('title') . '.pdf', $options);
}
// Sección
$section = new RDSection($id, isset($res) ? $res : null);
if ($section->isNew()) {
    RDfunctions::error_404();
}
$res = new RDResource($section->getVar('id_res'));
//Verificamos si es una publicación aprobada
if ($res->isNew()) {
    RDFunctions::error_404();
}
// Check if section is a top parent
if ($section->getVar('parent') > 0) {
    $top = RDfunctions::super_parent($section->getVar('parent'));
    header('location: ' . html_entity_decode($top->permalink()) . '#' . $section->getVar('nameid'));
    die;
}
if (!$res->getVar('approved')) {
    redirect_header(RDURL, 0, __('This content is not available!', 'docs'));
Esempio n. 4
0
/**
* @desc Modifica el orden de las secciones
**/
function changeOrderSections()
{
    global $xoopsSecurity, $xoopsModuleConfig;
    $orders = rmc_server_var($_POST, 'orders', array());
    $id = rmc_server_var($_POST, 'id', 0);
    if ($xoopsModuleConfig['permalinks']) {
        $url_ret = RDfunctions::url() . '/list/' . $id . '/';
    } else {
        $url_ret = RDFunctions::url() . '?page=edit&action=list&id=' . $id;
    }
    if (!$xoopsSecurity->check()) {
        redirect_header($url_ret, 0, __('Session token expired!', 'docs'));
        die;
    }
    if (!is_array($orders) || empty($orders)) {
        redirect_header($url_ret, 1, __('Sorry, the data provided contains some errors!', 'docs'), 1);
        die;
    }
    $errors = '';
    foreach ($orders as $k => $v) {
        if ($k <= 0) {
            continue;
        }
        //Comprueba si la sección es existente
        $sec = new RDSection($k);
        if ($sec->isNew()) {
            continue;
        }
        $sec->setVar('order', $v);
        if (!$sec->save()) {
            $errors .= sprintf(__('Order could not be saved for section %s', 'docs'), $sec->getVar('title')) . '<br />';
        }
    }
    if ($errors != '') {
        redirect_header($url_ret, 1, __('Errors ocurred while trying to update orders') . '<br />' . $errors);
    } else {
        redirect_header($url_ret, 0, __('Sections updated successfully!', 'docs'));
    }
}
Esempio n. 5
0
/**
* @desc Elimina la información de una sección
**/
function rd_delete_sections()
{
    global $xoopsModule;
    $id = rmc_server_var($_GET, 'id', 0);
    $id_sec = rmc_server_var($_GET, 'sec', 0);
    // Check if a Document id has been provided
    if ($id <= 0) {
        redirectMsg('resources.php', __('You have not specify a Document id', 'docs'), 1);
        die;
    }
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('The specified Document does not exists!', 'docs');
        die;
    }
    // Check if a section id has been provided
    if ($id_sec <= 0) {
        redirectMsg('./sections.php?id=' . $id, __('You have not specified a section ID to delete!', 'docs'), 1);
        die;
    }
    $sec = new RDSection($id_sec);
    if ($sec->isNew()) {
        redirectMsg('./sections.php?id=' . $id, __('Specified section does not exists!', 'docs'), 1);
        die;
    }
    if (!$sec->delete()) {
        redirectMsg('./sections.php?id=' . $id, __('Errors ocurred while trying to delete sections!', 'docs') . '<br />' . $sec->errors(), 1);
        die;
    } else {
        redirectMsg('./sections.php?id=' . $id, __('Sections deleted successfully!', 'docs'), 0);
    }
}
Esempio n. 6
0
function showFormEdits()
{
    global $xoopsModule, $xoopsConfig;
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        redirectMsg('edits.php', __('You have not specified any waiting section!', 'docs'), 1);
        die;
    }
    $edit = new RDEdit($id);
    if ($edit->isNew()) {
        redirectMsg('edits.php', __('Specified content does not exists!', 'docs'), 1);
        die;
    }
    $sec = new RDSection($edit->getVar('id_sec'));
    if ($sec->isNew()) {
        redirectMsg('edits.php', __('This waiting content does not have any section assigned!', 'docs'), 1);
        die;
    }
    $res = new RDResource($sec->getVar('id_res'));
    $form = new RMForm(__('Editing Waiting Content', 'docs'), 'frmsec', 'edits.php');
    $form->addElement(new RMFormLabel(__('Belong to', 'docs'), $res->getVar('title')));
    $form->addElement(new RMFormText(__('Title', 'docs'), 'title', 50, 200, $edit->getVar('title')), true);
    $form->addElement(new RMFormEditor(__('Contenido', 'docs'), 'content', '90%', '300px', $edit->getVar('content', 'e')), true);
    // Arbol de Secciones
    $ele = new RMFormSelect(__('Parent Section', 'docs'), 'parent');
    $ele->addOption(0, __('Select section...', 'docs'));
    $tree = array();
    RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $tree, false);
    foreach ($tree as $k) {
        $ele->addOption($k['id'], str_repeat('&#151;', $k['jump']) . ' ' . $k['title'], $edit->getVar('parent') == $k['id'] ? 1 : 0);
    }
    $form->addElement($ele);
    $form->addElement(new RMFormText(__('Display order', 'docs'), 'order', 5, 5, $edit->getVar('order')), true);
    // Usuario
    $form->addElement(new RMFormUser(__('Owner', 'docs'), 'uid', 0, array($edit->getVar('uid')), 30));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', __('Save Now', 'docs'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'edits.php\';"');
    $form->addElement($buttons);
    $form->addElement(new RMFormHidden('action', 'save'));
    $form->addElement(new RMFormHidden('id', $edit->id()));
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./edits.php'>" . __('Waiting Content', 'docs') . "</a> &raquo; " . sprintf(__('Editing %s', 'docs'), $edit->getVar('title')));
    xoops_cp_header();
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Waiting Content', 'docs'));
    $form->display();
    xoops_cp_footer();
}
Esempio n. 7
0
 public function get_item_url($params, $com)
 {
     static $cresources;
     static $csections;
     $params = urldecode($params);
     parse_str($params);
     if (!isset($res) || $res <= 0) {
         return __('Unknow element', 'docs');
     }
     include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdsection.class.php';
     if (isset($id) && $id > 0) {
         if (isset($csections[$id])) {
             $ret = $csections[$id]->permalink() . '#comment-' . $com->id();
             return $ret;
         }
         $sec = new RDSection($id);
         if ($sec->isNew()) {
             return '';
         }
         $ret = $sec->permalink() . '#comment-' . $com->id();
         $csections[$id] = $sec;
         return $ret;
     } else {
         if (isset($cresources[$res])) {
             $ret = $cresources[$res]->permalink() . '#comment-' . $com->id();
             return $ret;
         }
         $resoruce = new RDResource($res);
         if ($resoruce->isNew()) {
             return '';
         }
         $ret = $resoruce->permalink() . '#comment-' . $com->id();
         $cresources[$res] = $resoruce;
         return $ret;
     }
 }