Example #1
0
/**
* Este archivo permite controlar el bloque o los bloques
* Bloques Existentes:
* 
* 1. Publicaciones Recientes
* 2. Publicaciones Populares (Mas Leídas)
* 3. Publicaciones Mejor Votadas
*/
function rd_block_resources($options)
{
    global $xoopsModule;
    include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $mc = RMUtilities::module_config('docs');
    $sql = "SELECT * FROM " . $db->prefix("rd_resources") . ' WHERE public=1 AND approved=1';
    switch ($options[0]) {
        case 'recents':
            $sql .= " ORDER BY created DESC";
            break;
        case 'popular':
            $sql .= " ORDER BY `reads` DESC";
            break;
    }
    $sql .= " LIMIT 0, " . ($options[1] > 0 ? $options[1] : 5);
    $result = $db->query($sql);
    $block = array();
    while ($row = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($row);
        $ret = array();
        $ret['id'] = $res->id();
        $ret['title'] = $res->getVar('title');
        if ($options[2]) {
            $ret['desc'] = $options[3] == 0 ? $res->getVar('description') : TextCleaner::truncate($res->getVar('description'), $options[3]);
        }
        $ret['link'] = $res->permalink();
        $ret['author'] = sprintf(__('Created by %s', 'docs'), '<strong>' . $res->getVar('owname') . '</strong>');
        $ret['reads'] = sprintf(__('Viewed %s times', 'docs'), '<strong>' . $res->getVar('reads') . '</strong>');
        $block['resources'][] = $ret;
    }
    RMTemplate::get()->add_style('blocks.css', 'docs');
    return $block;
}
/**
* Shows a list of existing resources in RapidDocs
*/
function resources_list()
{
    global $xoopsUser, $xoopsModule;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Navegador de páginas
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources');
    list($num) = $db->fetchRow($db->queryF($sql));
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $limit = 20;
    $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('javascript:;" onclick="docsAjax.getSectionsList({PAGE_NUM});');
    //Fin navegador de páginas
    $sql = "SELECT * FROM " . $db->prefix('rd_resources');
    if ($xoopsUser->isAdmin()) {
        $sql .= " ORDER BY `created` DESC LIMIT {$start},{$limit}";
    } else {
        $sql .= " WHERE public=1 OR (public=0 AND owner=" . $xoopsUser->uid() . ") ORDER BY `created` DESC LIMIT {$start},{$limit}";
    }
    $result = $db->queryF($sql);
    $resources = array();
    while ($rows = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($rows);
        $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'));
    }
    include RMTemplate::get()->get_template('ajax/rd_sections_list.php', 'module', 'docs');
}
Example #3
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';
}
Example #4
0
/**
* @desc Muestra todas las publicaciones existentes
**/
function show_resources()
{
    global $xoopsModule, $xoopsConfig, $xoopsSecurity;
    $query = rmc_server_var($_REQUEST, 'query', '');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Navegador de páginas
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources');
    if ($query) {
        $sql .= " WHERE title LIKE '%query%'";
    }
    list($num) = $db->fetchRow($db->queryF($sql));
    $page = rmc_server_var($_REQUEST, '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('resources.php?page={PAGE_NUM}');
    //Fin navegador de páginas
    $sql = "SELECT * FROM " . $db->prefix('rd_resources') . ($query != '' ? " WHERE title LIKE '%{$query}%'" : '') . " ORDER BY `created` DESC LIMIT {$start},{$limit}";
    $result = $db->queryF($sql);
    $resources = array();
    while ($rows = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($rows);
        $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'created' => formatTimestamp($res->getVar('created'), 'm'), 'public' => $res->getVar('public'), 'quick' => $res->getVar('quick'), 'approvededit' => $res->getVar('editor_approve'), 'featured' => $res->getVar('featured'), 'approved' => $res->getVar('approved'), 'owname' => $res->getVar('owname'), 'owner' => $res->getVar('owner'), 'description' => $res->getVar('description'), 'sections' => $res->sections_count(), 'notes' => $res->notes_count(), 'figures' => $res->figures_count());
    }
    RMTemplate::get()->add_style('admin.css', 'docs');
    RMTemplate::get()->assign('xoops_pagetitle', __('Documents', 'docs'));
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_script(XOOPS_URL . '/modules/docs/include/js/admin.js');
    RMTemplate::get()->add_head('<script type="text/javascript">
    var rd_message = "' . __('Do you really wish to delete selected Documents?', 'docs') . '";
    var rd_select_message = "' . __('You must select an element before to do this action!', 'docs') . '";
    </script>');
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Documents', 'docs'));
    RDFunctions::toolbar();
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/rd_resources.php', 'module', 'docs');
    xoops_cp_footer();
}
Example #5
0
function rd_show_sections()
{
    global $xoopsModule, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        redirectMsg('resources.php', __('Select a Document to see the sections inside this', 'docs'), 0);
        die;
    }
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('resources.php', __('The specified Document does not exists!', 'docs'), 1);
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Lista de Publicaciones
    $sql = "SELECT id_res,title FROM " . $db->prefix('rd_resources');
    $result = $db->queryF($sql);
    $resources = array();
    while ($rows = $db->fetchArray($result)) {
        $r = new RDResource();
        $r->assignVars($rows);
        $resources[] = array('id' => $r->id(), 'title' => $r->getVar('title'));
        unset($r);
    }
    //Secciones
    $sections = array();
    RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $sections, false, true);
    // Event
    $sections = RMEvents::get()->run_event('docs.loading.sections', $sections);
    RDFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Sections Management', 'docs'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Sections Management', 'docs'));
    RMTemplate::get()->add_style('admin.css', 'docs');
    RMTemplate::get()->add_style('sections.css', 'docs');
    RMTemplate::get()->add_local_script('sections.js', 'docs', 'include');
    RMTemplate::get()->add_local_script('jquery.ui.nestedSortable.js', 'docs', 'include');
    xoops_cp_header();
    include RMEvents::get()->run_event('docs.get.sections.template', RMTemplate::get()->get_template('admin/rd_sections.php', 'module', 'docs'));
    xoops_cp_footer();
}
Example #6
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;
}
Example #7
0
 /**
  * Get resources index according to given options
  */
 public function resources_index($type = 'all', $display = 1, $cols = 3, $limit = 15)
 {
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix("rd_resources");
     if ($type == 'featured') {
         $sql .= " WHERE public=1 AND approved=1 AND featured=1 ORDER BY created DESC";
     } elseif ($type == 'all') {
         $sql .= " WHERE public=1 AND approved=1 ORDER BY created DESC";
     }
     $sql .= " LIMIT 0,{$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' => $res->getVar('description'), 'link' => $res->permalink());
     }
     ob_start();
     include RMEvents::get()->run_event('docs.template.resources.index', RMTemplate::get()->get_template('rd_resindex.php', 'module', 'docs'));
     $ret = ob_get_clean();
     return $ret;
 }
Example #8
0
$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
$sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE public=0 ORDER BY created DESC LIMIT 0,5";
$result = $db->query($sql);
$nopublished = array();
while ($row = $db->fetchArray($result)) {
    $res = new RDResource();
    $res->assignVars($row);
    $nopublished[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'created' => $res->getVar('created'), 'desc' => TextCleaner::getInstance()->truncate($res->getVar('description'), 60));
}
// No published resoruces
$sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE approved=0 ORDER BY created DESC LIMIT 0,5";
$result = $db->query($sql);
$noapproved = array();
while ($row = $db->fetchArray($result)) {
    $res = new RDResource();
    $res->assignVars($row);
    $noapproved[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'created' => $res->getVar('created'), 'desc' => TextCleaner::getInstance()->truncate($res->getVar('description'), 60));
}
xoops_cp_header();
RMTemplate::get()->add_style('admin.css', 'docs');
RMTemplate::get()->add_style('dashboard.css', 'docs');
RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.gcharts.js');
RMTemplate::get()->add_head('<script type="text/javascript">var xoops_url="' . XOOPS_URL . '";</script>');
RMTemplate::get()->add_script('../include/js/dashboard.js');
include RMTemplate::get()->get_template('admin/rd_index.php', 'module', 'docs');
xoops_cp_footer();