Beispiel #1
0
function search_resources()
{
    global $xoopsConfig, $xoopsUser, $page, $xoopsTpl;
    $keyword = rmc_server_var($_GET, 'keyword', '');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1";
    list($num) = $db->fetchRow($db->query($sql));
    $page = rmc_server_var($_GET, 'page', 1);
    $limit = 15;
    $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(RDFunctions::make_link('search') . '?keyword=' . $keyword . '&amp;page={PAGE_NUM}');
    $sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1 LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $resources = array();
    while ($row = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($row);
        $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'desc' => TextCleaner::truncate($res->getVar('description'), 100), 'link' => $res->permalink(), 'created' => $res->getVar('created'), 'owner' => $res->getVar('owner'), 'uname' => $res->getVar('owname'), 'reads' => $res->getVar('reads'));
    }
    RDFunctions::breadcrumb();
    RMBreadCrumb::get()->add_crumb(__('Browsing recent Documents', 'docs'));
    RMTemplate::get()->add_style('docs.css', 'docs');
    include 'header.php';
    $xoopsTpl->assign('xoops_pagetitle', sprintf(__('Search results for "%s"', 'docs'), $keyword));
    include RMEvents::get()->run_event('docs.template.search', RMTemplate::get()->get_template('rd_search.php', 'module', 'docs'));
    include 'footer.php';
}
Beispiel #2
0
/**
* @desc Formulario para crear nueva sección
**/
function formSection($edit = 0)
{
    global $xoopsConfig, $xoopsUser, $xoopsModuleConfig, $id, $res;
    $res = rmc_server_var($_GET, 'id', $res);
    //Verifica si se proporcionó una publicación para la sección
    if ($res <= 0) {
        RDFunctions::error_404();
    }
    $res = new RDResource($res);
    if ($res->isNew()) {
        RDFunctions::error_404();
    }
    //Verificamos si es una publicación aprobada
    if (!$res->getVar('approved')) {
        redirect_header(RDURL, 2, __('Specified section does not exists!', 'docs'));
        die;
    }
    //Verificamos si el usuario tiene permisos de edicion
    if (!$xoopsUser->uid() == $res->getVar('owner') && !$res->isEditor($xoopsUser->uid()) && !$xoopsUser->isAdmin()) {
        redirect_header($section->permalink(), 1, __('Operation not allowed!', 'docs'));
        die;
    }
    if ($edit) {
        $id = rmc_server_var($_GET, 'id', $id);
        //Verifica si la sección es válida
        if ($id == '') {
            RDfunctions::error_404();
        }
        //Comprueba si la sección es existente
        $section = new RDSection($id);
        if ($section->isNew()) {
            RDFunctions::error_404();
        }
    }
    include 'header.php';
    include_once RMCPATH . '/class/form.class.php';
    define('RD_NO_FIGURES', 1);
    $rmc_config = RMFunctions::configs();
    $editor = new RMFormEditor('', 'content', '100%', '300px', $edit ? $section->getVar('content', $rmc_config['editor_type'] == 'tiny' ? 's' : 'e') : '', '', false);
    if ($rmc_config['editor_type'] == 'tiny') {
        $tiny = TinyEditor::getInstance();
        $tiny->configuration['content_css'] .= ',' . XOOPS_URL . '/modules/docs/css/figures.css';
        $tiny->add_config('theme_advanced_buttons1', 'rd_refs');
        $tiny->add_config('theme_advanced_buttons1', 'rd_figures');
        $tiny->add_config('theme_advanced_buttons1', 'rd_toc');
    }
    // Arbol de Secciones
    $sections = array();
    RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $sections, false);
    // Breadcrumb
    RDFunctions::breadcrumb();
    $res_edit = RDFunctions::url() . ($xoopsModuleConfig['permalinks'] ? '/list/' . $res->id() . '/' : '?action=list&id=' . $res->id());
    RMBreadCrumb::get()->add_crumb($res->getVar('title'), $res_edit);
    if ($edit) {
        RMBreadCrumb::get()->add_crumb(sprintf(__('Editing "%s"', 'docs'), $section->getVar('title')));
    } else {
        RMBreadCrumb::get()->add_crumb(__('Create new section', 'docs'));
    }
    RMTemplate::get()->add_jquery(true);
    RMTemplate::get()->add_style('forms.css', 'docs');
    RMTemplate::get()->add_script(XOOPS_URL . '/modules/docs/include/js/scripts.php?file=metas.js');
    include RMEvents::get()->run_event('docs.template.formsections.front', RMTemplate::get()->get_template('rd_sec.php', 'module', 'docs'));
    include 'footer.php';
}
Beispiel #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';
}
Beispiel #4
0
<?php

// $Id$
// --------------------------------------------------------------
// RapidDocs
// Documentation system for Xoops.
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
include '../../mainfile.php';
include 'header.php';
RDFunctions::breadcrumb();
RMTemplate::get()->add_style('docs.css', 'docs');
$content = @file_get_contents(XOOPS_CACHE_PATH . '/rd_homepage.html');
$content = TextCleaner::getInstance()->to_display($content);
include RMEvents::get()->run_event('docs.get.home.page', RMtemplate::get()->get_template('rd_index.php', 'module', 'docs'));
include 'footer.php';