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 . '&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'; }
/** * 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; }
function rd_block_index($options) { global $xoopsModule, $xoopsModuleConfig, $res, $sec; if (!$xoopsModule || $xoopsModule->dirname() != 'docs') { return; } if (!defined('RD_LOCATION') || RD_LOCATION != 'content' && RD_LOCATION != 'resource_content') { return; } // get the sections $sections = array(); RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $sections, false); $block['sections'] = $sections; $block['section'] = $sec; $block['resource'] = $res->getVar('nameid'); return $block; }
<?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';
/** * Creates the BreadCrumb bar with basic options */ public function breadcrumb() { global $xoopsModule; // Breadcrumb $bc = RMBreadCrumb::get(); $bc->add_crumb(__('Home Page', 'docs'), XOOPS_URL); $bc->add_crumb($xoopsModule->name(), RDFunctions::url()); }
function rd_section_forpdf($all = 0) { global $section, $res, $xoopsConfig, $xoopsModuleConfig; $plugin = RMFunctions::load_plugin('topdf'); if ($xoopsModuleConfig['permalinks']) { $print_book_url = RDFunctions::url() . '/printbook/' . $section->id() . '/'; $print_section_url = RDFunctions::url() . '/printsection/' . $section->id() . '/'; } else { $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'; } // 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); }
// -------------------------------------------------------------- // RapidDocs // Documentation system for Xoops. // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- require '../../mainfile.php'; define('INCLUDED_INDEX', 1); /** * This file redirects all petions directly to his content */ if ($xoopsModuleConfig['permalinks']) { $url = RMFunctions::current_url(); if (FALSE !== strpos($url, XOOPS_URL . '/modules/docs')) { header('location: ' . RDFunctions::url()); die; } // If friendly urls are activated $path = str_replace(XOOPS_URL, '', RMFunctions::current_url()); $path = str_replace($xoopsModuleConfig['htpath'], '', $path); $path = trim($path, '/'); if ($xoopsModuleConfig['subdomain'] != '') { $path = str_replace(rtrim($xoopsModuleConfig['subdomain'], '/'), '', $path); $path = trim($path, '/'); } $params = explode("/", $path); } else { // If friendly urls are disabled $path = parse_url(RMFunctions::current_url()); if (isset($path['query'])) {
/** * @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')); } }
/** * Shows the figures for a Document */ function rd_widget_figures() { global $res, $rmc_config; $ret['title'] = __('Document Figures', 'docs'); $count = 0; $figures = RDFunctions::figures($res->id(), &$count, '', 0, 6); $nav = new RMPageNav($count, 6, 1, 3); $nav->target_url('javascript:;" onclick="docsAjax.getFigures(' . $res->id() . ',6,{PAGE_NUM},\'rd-wd-figures\')'); RMTemplate::get()->add_script('../include/js/scripts.php?file=ajax.js'); ob_start(); ?> <div id="rd-wd-figures"> <ul> <?php if (count($figures) <= 0) { _e('There are not exists figures for this Document yet!', 'docs'); } foreach ($figures as $fig) { ?> <li><a href="javascript:;" onclick="docsAjax.insertIntoEditor('[figure:<?php echo $fig['id']; ?> ]','<?php echo $rmc_config['editor_type']; ?> ');"><?php echo $fig['title']; ?> </a></li> <?php } ?> </ul> <?php $nav->display(false); ?> </div> <?php $ret['content'] = ob_get_clean(); return $ret; }
/** * @desc Formulario de creación y edición de sección **/ function rd_show_form($edit = 0) { global $xoopsModule, $xoopsConfig, $xoopsSecurity, $xoopsUser, $xoopsModuleConfig, $rmc_config; define('RMCSUBLOCATION', 'newresource'); $id = rmc_server_var($_GET, 'id', 0); $parent = rmc_server_var($_GET, 'parent', 0); if ($id <= 0) { redirectMsg('sections.php?id=' . $id, __('You must select a Document in order to create a new section', 'docs'), 1); die; } // Check if provided Document exists global $res; $res = new RDResource($id); if ($res->isNew()) { redirectMsg('sections.php?id=' . $id, __('Specified Document does not exists!', 'docs'), 1); die; } if ($edit) { $id_sec = rmc_server_var($_GET, 'sec', 0); //Verifica si la sección es válida if ($id_sec <= 0) { redirectMsg('sections.php?id=' . $id, __('Specify a section to edit', 'docs'), 1); die; } //Comprueba si la sección es existente $sec = new RDSection($id_sec); if ($sec->isNew()) { redirectMsg('sections.php?id=' . $id, __('Specified section does not exists', 'docs'), 1); die; } } // Get order $order = RDFunctions::order('MAX', $parent, $res->id()); $order++; $rmc_config = RMFunctions::configs(); $form = new RMForm('', 'frmsec', 'sections.php'); if ($rmc_config['editor_type'] == 'tiny') { $tiny = TinyEditor::getInstance(); $tiny->add_config('theme_advanced_buttons1', 'rd_refs'); $tiny->add_config('theme_advanced_buttons1', 'rd_figures'); $tiny->add_config('theme_advanced_buttons1', 'rd_toc'); } $editor = new RMFormEditor('', 'content', '100%', '300px', $edit ? $rmc_config['editor_type'] == 'tiny' ? $sec->getVar('content') : $sec->getVar('content', 'e') : '', '', 0); $usrfield = new RMFormUser('', 'uid', false, $edit ? array($sec->getVar('uid')) : $xoopsUser->getVar('uid')); RMTemplate::get()->add_style('admin.css', 'docs'); RMTemplate::get()->add_script('../include/js/scripts.php?file=metas.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.validate.min.js'); RMTemplate::get()->add_head('<script type="text/javascript">var docsurl = "' . XOOPS_URL . '/modules/docs";</script>'); RDFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Section', 'docs') : __('Create Section', 'docs'))); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Section', 'docs') : __('Create Section', 'docs')); xoops_cp_header(); $sections = array(); RDFunctions::getSectionTree($sections, 0, 0, $id, 'id_sec, title', isset($sec) ? $sec->id() : 0); include RMEvents::get()->run_event('docs.get.secform.template', RMTemplate::get()->get_template('admin/rd_sections_form.php', 'module', 'docs')); xoops_cp_footer(); }
/** * @desc Almacena información perteneciente a una publicación **/ function savePublish() { global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $xoopsConfig; $config_handler =& xoops_gethandler('config'); $xconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); foreach ($_POST as $k => $v) { ${$k} = $v; } if ($xoopsModuleConfig['permalinks']) { $purl = RDFunctions::url() . '/publish/'; } else { $purl = RDFunctions::url() . '?page=publish&action=publish'; } if (!$xoopsSecurity->check()) { redirect_header($prul, 1, __('Session token expired!', 'docs')); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); //Comprueba que el título de publicación no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE title='{$title}' "; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header($purl, 1, __('Already exists a Document with same name!', 'docs')); die; } $res = new RDResource(); //Genera $nameid Nombre identificador $found = false; $i = 0; do { $nameid = TextCleaner::getInstance()->sweetstring($title) . ($found ? $i : ''); $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE nameid = '{$nameid}'"; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { $found = true; $i++; } else { $found = false; } } while ($found == true); $res->setVar('title', $title); $res->setVar('description', $desc); $res->setVar('created', time()); $res->setVar('modified', time()); $res->setVar('editors', $editors); $res->setVar('groups', $groups); $res->setVar('public', 1); $res->setVar('quick', $quick); $res->setVar('nameid', $nameid); $res->setVar('owner', $xoopsUser->uid()); $res->setVar('owname', $xoopsUser->uname()); $res->setVar('approved', $xoopsModuleConfig['approved']); $res->setVar('single', $single); if (!$res->save()) { redirect_header($prul, 1, __('Document could not be created!', 'docs')); } else { //Si no se aprobó la publicación enviamos correo al administrador if (!$xoopsModuleConfig['approved']) { $mailer = new RMMailer('text/plain'); $mailer->add_user($xconfig['from'], $xconfig['fromname'], 'to'); $mailer->set_subject(__('New Document created at RapidDocs is waiting for approval', 'rmcommon')); $mailer->assign('to_name', $xconfig['fromname']); $mailer->assign('link_to_resource', XOOPS_URL . '/modules/docs/admin/resources.php?action=edit&id=' . $res->id()); $mailer->template(RMTemplate::get()->get_template('mail/resource_for_approval.php', 'module', 'docs')); if (!$mailer->send()) { redirect_header(RDFunctions::url(), 1, __('Your Document has been created, however the email to administrator could no be sent.', 'docs')); die; } redirect_header(RDFunctions::url(), 1, __('Your Document has been created and is pending for approval. We will sent an email when you can access to it and add content.', 'docs')); die; } if ($xoopsModuleConfig['permalinks']) { $purl = RDFunctions::url() . '/list/' . $res->id() . '/'; } else { $purl = RDFunctions::url() . '?page=edit&action=list&id=' . $res->id(); } redirect_header($purl, 1, __('Document created successfully!', 'docs')); die; } }
?> </a> | <a href="<?php echo RDFunctions::make_link('explore', array('by' => 'recent')); ?> "><?php _e('Recent Documents', 'docs'); ?> </a> | <a href="<?php echo RDFunctions::make_link('explore', array('by' => 'top')); ?> "><?php _e('Top Documents', 'docs'); ?> </a> <div class="right"> <form name="frmsearch" method="get" action="<?php echo RDFunctions::make_link('search'); ?> "> <input type="text" name="keyword" size="20" /> <input type="submit" value="<?php _e('Search', 'docs'); ?> " /> </form> </div> </div> <?php }
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('—', $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> » <a href='./edits.php'>" . __('Waiting Content', 'docs') . "</a> » " . sprintf(__('Editing %s', 'docs'), $edit->getVar('title'))); xoops_cp_header(); RMTemplate::get()->assign('xoops_pagetitle', __('Editing Waiting Content', 'docs')); $form->display(); xoops_cp_footer(); }
<?php // $Id$ // -------------------------------------------------------------- // RapidDocs // Documentation system for Xoops. // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- include XOOPS_ROOT_PATH . '/header.php'; $mc =& $xoopsModuleConfig; //include_once 'include/functions.php'; define('RDURL', RDFunctions::url()); define('RDPATH', XOOPS_ROOT_PATH . '/modules/docs'); $xoopsTpl->assign('rdurl', RDURL); RMTemplate::get()->add_style('docs.css', 'docs');
public function editlink() { $config = RMUtilities::module_config('docs'); if ($config['permalinks']) { $link = RDFunctions::url() . '/edit/' . $this->id() . '/' . $this->getVar('id_res'); } else { $link = RDFunctions::url() . '?page=edit&id=' . $this->id() . '&res=' . $this->getVar('id_res'); } return $link; }
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'); if ($standalone) { RDFunctions::standalone(); } include 'footer.php';
/** * @desc Permite aprobar o no una publicación **/ function approved_resources($app = 0) { global $xoopsSecurity, $xoopsConfig, $xoopsModuleConfig; $resources = rmc_server_var($_POST, 'ids', array()); $page = rmc_server_var($_POST, 'page', 1); if (!$xoopsSecurity->check()) { redirectMsg('./resources.php?page=' . $page, __('Session token expired!', 'docs'), 1); die; } //Verifica que se haya proporcionado una publicación if (!is_array($resources) || empty($resources)) { redirectMsg('./resources.php?page=' . $page, __('Select at least a Document!', 'docs'), 1); die; } $errors = ''; foreach ($resources as $k) { //Comprueba si la publicación es válida if ($k <= 0) { $errors .= sprintf(__('Document ID "%s" is not valid!', 'docs'), $k); continue; } //Comprueba si la publicación existe $res = new RDResource($k); if ($res->isNew()) { $errors .= sprintf(__('Document with ID "%s" does not exists!', 'docs'), $k); continue; } $approved = $res->getVar('approved'); $res->setVar('approved', $app); if (!$res->save()) { $errors .= sprintf(__('Resoource "%s" could not be saved!', 'docs'), $k); } else { if ($app && !$approved) { $errors .= RDFunctions::mail_approved($res) != true ? __('Notification email could not be sent!', 'docs') . '<br />' : ''; } } } if ($errors != '') { redirectMsg('./resources.php?page=' . $page, __('Errors ocurred while trying to update resources.') . '<br />' . $errors, 1); } else { redirectMsg('./resources.php?page=' . $page, __('Documents updated successfully!', 'docs'), 0); } }