Ejemplo n.º 1
0
/**
* 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;
}
Ejemplo n.º 2
0
 /**
  * Get a single section and all his sub sections
  */
 public function get_section_tree($id, RDResource $res, $number = 1, $text = false)
 {
     global $xoopsUser;
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     if (get_class($res) != 'RDResource') {
         return;
     }
     $sql = "SELECT * FROM " . $db->prefix("rd_sections") . " WHERE " . ($res->id() > 0 ? "id_res='" . $res->id() . "' AND" : '') . "\n                id_sec='{$id}'";
     $result = $db->query($sql);
     if ($db->getRowsNum($result) <= 0) {
         return;
     }
     $sec = new RDSection();
     $row = $db->fetchArray($result);
     $sec->assignVars($row);
     $sections[0] = array('id' => $sec->id(), 'title' => $sec->getVar('title'), 'nameid' => $sec->getVar('nameid'), 'jump' => 0, 'link' => $sec->permalink(), 'order' => $sec->getVar('order'), 'author' => $sec->getVar('uid'), 'author_name' => $sec->getVar('uname'), 'created' => $sec->getVar('created'), 'modified' => $sec->getVar('modified'), 'number' => $number, 'comments' => $sec->getVar('comments'), 'edit' => !$xoopsUser ? 0 : ($xoopsUser->isAdmin() ? true : $res->isEditor($xoopsUser->uid())), 'resource' => $sec->getVar('id_res'), 'metas' => $sec->metas());
     if ($text) {
         $sections[0]['content'] = $sec->getVar('content');
     }
     self::sections_tree_index($sec->id(), 1, $res, '', $number, false, $sections, $text);
     return $sections;
 }
Ejemplo n.º 3
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&amp;id=' . $section->id() . '&amp;action=pdfbook';
            $pdf_section_url = XOOPS_URL . '/modules/docs/index.php?page=content&amp;id=' . $section->id() . '&amp;action=pdfsection';
        }
        $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';
        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';
}
Ejemplo 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'));
    }
}
Ejemplo n.º 5
0
/**
* @desc Realiza una búsqueda en el módulo desde EXM
*/
function ahelpSearch($queryarray, $andor, $limit, $offset, $userid)
{
    global $myts;
    include_once XOOPS_ROOT_PATH . "/modules/docs/class/rdsection.class.php";
    include_once XOOPS_ROOT_PATH . "/modules/docs/class/rdresource.class.php";
    $mc = RMUtilities::module_config('docs');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $tbl1 = $db->prefix("rd_resources");
    $tbl2 = $db->prefix("rd_sections");
    $sql = "SELECT a.id_res,a.title,a.description,a.created,a.modified,a.public,a.nameid,a.owner,a.owname,a.approved,b.id_sec,b.title AS stitle,b.content,b.id_res AS sid_res,\n\tb.nameid AS snameid,b.uid,b.uname,b.created AS screated FROM {$tbl1} a, {$tbl2} b ";
    $sql1 = '';
    foreach ($queryarray as $k) {
        $sql1 .= ($sql1 == '' ? '' : " {$andor} ") . " (a.id_res=b.id_res) AND (\n        \t (b.title LIKE '%{$k}%' AND b.id_res=a.id_res) OR \n        \t (b.content LIKE '%{$k}%' AND b.id_res=a.id_res))";
    }
    $sql .= $sql1 != '' ? "WHERE {$sql1}" : '';
    $sql .= " AND approved=1 AND public=1 ORDER BY a.modified DESC LIMIT {$offset}, {$limit}";
    $result = $db->queryF($sql);
    $ret = array();
    while ($row = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($row);
        $sec = new RDSection();
        $sec->assignVars($row);
        $sec->assignVar('title', $row['stitle']);
        $sec->assignVar('id_res', $row['sid_res']);
        $sec->assignVar('nameid', $row['snameid']);
        $sec->assignVar('created', $row['screated']);
        $rtn = array();
        $rtn['image'] = 'images/result.png';
        $rtn['link'] = $sec->permalink();
        $rtn['title'] = $sec->getVar('title');
        $rtn['time'] = $sec->getVar('created');
        $rtn['uid'] = $sec->getVar('uid');
        $rtn['desc'] = TextCleaner::getInstance()->truncate($sec->getVar('content'), 150);
        $ret[] = $rtn;
    }
    return $ret;
}
Ejemplo n.º 6
0
/**
* @desc Modifica el orden de las secciones
**/
function changeOrderSections()
{
    global $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        json_response(__('Session token expired!', 'docs'), 1);
    }
    parse_str(rmc_server_var($_POST, 'items', ''));
    if (empty($list)) {
        json_response(__('Data not valid!', 'docs'), 1);
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $res = '';
    $pos = 0;
    foreach ($list as $id => $parent) {
        $parent = $parent == 'root' ? 0 : $parent;
        if ($parent == 0 && !is_object($res)) {
            $res = new RDSection($id);
        }
        $sql = "UPDATE " . $db->prefix("rd_sections") . " SET parent={$parent}, `order`={$pos} WHERE id_sec={$id}";
        $db->queryF($sql);
        $pos++;
    }
    json_response(__('Sections positions saved!', 'docs'), 0, $res->getVar('id_res'));
}
Ejemplo n.º 7
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();
}
Ejemplo n.º 8
0
 /**
  * Get the permalink for this section
  */
 public function permalink($edit = 0)
 {
     global $standalone;
     $config = RMUtilities::module_config('docs');
     $res = new RDResource($this->getVar('id_res'));
     if ($res->getVar('single') && defined('RD_LOCATION') && RD_LOCATION == 'resource_content') {
         return "#" . $this->getVar('nameid');
     }
     if ($config['permalinks']) {
         if ($this->getVar('parent') > 0) {
             $sec = new RDSection($this->getVar('parent'));
             $perma = $sec->permalink() . '#' . ($edit ? '<span>' . $this->getVar('nameid') . '</span>' : $this->getVar('nameid'));
         } else {
             $perma = ($config['subdomain'] != '' ? $config['subdomain'] : XOOPS_URL) . $config['htpath'] . '/' . $res->getVar('nameid') . '/' . ($edit ? '<span>' . $this->getVar('nameid') . '</span>' : $this->getVar('nameid')) . '/';
             $perma .= $standalone ? 'standalone/1/' : '';
         }
     } else {
         if ($this->getVar('parent') > 0) {
             $sec = new RDSection($this->getVar('parent'));
             $perma = $sec->permalink() . '#' . $this->getVar('nameid');
         } else {
             $perma = XOOPS_URL . '/modules/docs/index.php?page=content&amp;id=' . $this->id();
             $perma .= $standalone ? '&amp;standalone=1' : '';
         }
     }
     return $perma;
 }
Ejemplo n.º 9
0
        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();
        $sec->assignVars($rows);
        $qindex_sections[] = array('id' => $id, 'title' => $sec->getVar('title'), 'desc' => TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::truncate($sec->getVar('content'), 255)), 'link' => $sec->permalink());
    }
    include RMTemplate::get()->get_template('rd_quickindex.php', 'module', 'docs');
} else {
    if (!$allowed) {
        RDFunctions::error_404();
    }
    $toc = array();
    RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $toc);
    include RMTemplate::get()->get_template('rd_resindextoc.php', 'module', 'docs');
}
RMTemplate::get()->add_style('docs.css', 'docs');
RMTemplate::get()->add_jquery();
RMTemplate::get()->add_script(RDURL . '/include/js/docs.js');
Ejemplo n.º 10
0
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE public=1 ORDER BY `reads` DESC LIMIT 0, 15";
$result = $db->query($sql);
$top_data = array();
while ($row = $db->fetchArray($result)) {
    $res = new RDResource();
    $res->assignVars($row);
    $top_data['reads'][] = $res->getVar('reads');
    $top_data['names'][] = $res->getVar('title') . ' (' . $res->getVar('reads') . ')';
}
array_multisort($top_data['names'], SORT_STRING, $top_data['reads'], SORT_NUMERIC);
$sql = "SELECT * FROM " . $db->prefix("rd_sections") . " ORDER BY `comments` DESC LIMIT 0, 15";
$result = $db->query($sql);
$comm_data = array();
while ($row = $db->fetchArray($result)) {
    $sec = new RDSection();
    $sec->assignVars($row);
    $comm_data['comments'][] = $sec->getVar('comments');
    $comm_data['names'][] = $sec->getVar('title') . ' (' . $sec->getVar('comments') . ')';
}
array_multisort($comm_data['names'], SORT_STRING, $comm_data['comments'], SORT_NUMERIC);
// Resume data
list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("rd_resources")));
$resume_data['resources'] = $num;
list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("rd_sections")));
$resume_data['sections'] = $num;
list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("rd_figures")));
$resume_data['figures'] = $num;
list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("rd_references")));
$resume_data['notes'] = $num;
// No published resoruces
Ejemplo n.º 11
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;
     }
 }