/** * Mostramos las página existentes */ function qpagesBlockPages($options) { global $xoopsConfig; include_once XOOPS_ROOT_PATH . '/modules/qpages/class/qppage.class.php'; $db =& XoopsDatabaseFactory::getDatabaseConnection(); $mc =& RMUtilities::module_config('qpages'); if (!defined('QP_URL')) { define('QP_URL', XOOPS_URL . ($mc['links'] ? $mc['basepath'] : '/modules/qpages')); } $sql = "SELECT * FROM " . $db->prefix("qpages_pages"); if ($options[0] > 0) { $sql .= " WHERE cat='{$options['0']}'"; } $sql .= " ORDER BY fecha DESC LIMIT 0,{$options['1']}"; $block = array(); $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $page = new QPPage(); $page->assignVars($row); $rtn = array(); $rtn['id'] = $page->getID(); $rtn['titulo'] = $page->getTitle(); $rtn['link'] = $page->getPermaLink(); $block['pages'][] = $rtn; } return $block; }
/** * Muestra los envíos existentes */ function showPages($acceso = -1) { global $mc, $xoopsModule, $xoopsSecurity; $keyw = rmc_server_var($_REQUEST, 'keyw', ''); $acceso = rmc_server_var($_REQUEST, 'acceso', -1); $cat = rmc_server_var($_REQUEST, 'cat', ''); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("qpages_pages"); if ($acceso >= 0) { $sql .= " WHERE acceso={$acceso}"; } if (trim($keyw) != '') { $sql .= ($acceso >= 0 ? " AND " : " WHERE ") . "titulo LIKE '%{$keyw}%'"; } if (isset($cat) && $cat > 0) { $sql .= ($acceso >= 0 || $keyw != '' ? " AND " : " WHERE ") . "cat='{$cat}'"; } /** * Paginacion de Resultados */ $page = rmc_server_var($_REQUEST, 'page', 1); $page = $page <= 0 ? 1 : $page; $limit = 15; list($num) = $db->fetchRow($db->query($sql)); $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('pages.php?cat=' . $cat . '&page={PAGE_NUM}'); $sql .= " ORDER BY id_page DESC LIMIT {$start},{$limit}"; $sql = str_replace("SELECT COUNT(*)", "SELECT *", $sql); $result = $db->query($sql); $pages = array(); while ($row = $db->fetchArray($result)) { $p = new QPPage(); $p->assignVars($row); # Enlaces para las categorías $catego = new QPCategory($p->getCategory()); $pages[] = array('id' => $p->getID(), 'titulo' => $p->getTitle(), 'catego' => $catego->getName(), 'fecha' => formatTimeStamp($p->getDate(), 's'), 'link' => $p->getPermaLink(), 'estado' => $p->getAccess(), 'modificada' => $p->getModDate() == 0 ? '--' : formatTimestamp($p->getModDate(), 'c'), 'lecturas' => $p->getReads(), 'order' => $p->order(), 'type' => $p->type(), 'desc' => $p->getDescription()); } /** * Cargamos las categorias */ $categos = array(); qpArrayCategos($categos); $categories = array(); foreach ($categos as $k) { $categories[] = array('id' => $k['id_cat'], 'nombre' => $k['nombre'], 'saltos' => $k['saltos']); } RMTemplate::get()->add_style('admin.css', 'qpages'); RMTemplate::get()->add_script('../include/js/qpages.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->assign('xoops_pagetitle', __('Pages Management', 'qpages')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> » ' . ($acceso < 0 ? __('All Pages', 'qpages') : ($acceso == 0 ? __('Draft pages', 'qpages') : __('Published pages', 'qpages')))); xoops_cp_header(); include RMTemplate::get()->get_template("admin/qp_pages.php", 'module', 'qpages'); xoops_cp_footer(); }
$rp->assignVars($p); $tpl->append('pages', array('id' => $rp->getID(), 'link' => $rp->getPermaLink(), 'title' => $rp->getTitle(), 'modified' => formatTimestamp($rp->getModDate(), 'l'), 'hits' => $rp->getReads(), 'desc' => $rp->getDescription())); } $tpl->assign('page_count', count($lpages)); unset($pages); // Subcategorias $result = $db->query("SELECT * FROM " . $db->prefix("qpages_categos") . " WHERE parent = " . $catego->getID()); $tpl->assign('subcats_count', $db->getRowsNum($result)); while ($k = $db->fetchArray($result)) { $cat = new QPCategory(); $cat->assignVars($k); $lpages = $cat->loadPages(); $pages = array(); foreach ($lpages as $p) { $page = new QPPage(); $page->assignVars($p); $ret = array(); $ret['titulo'] = $page->getTitle(); $ret['desc'] = $page->getDescription(); $ret['link'] = $page->getPermaLink(); $pages[] = $ret; } $link = $cat->getLink(); $subcats = $cat->getSubcategos(); $tpl->append('categos', array('id' => $cat->getID(), 'nombre' => $cat->getName(), 'desc' => $cat->getDescription(), 'pages_count' => sprintf(__('%u pages', 'qpages'), count($lpages)), 'link' => $link, 'subcats' => count($subcats) > 0 ? $subcats : '', 'subcats_count' => count($subcats))); } $tpl->assign('lang_subcats', __('Subcategories', 'qpages')); $tpl->assign('lang_page', __('Page', 'qpages')); $tpl->assign('lang_modified', __('Last update', 'qpages')); $tpl->assign('lang_hits', __('Reads', 'qpages')); require 'footer.php';
$location .= '» <a href="' . $k->getLink() . '">' . $k->getName() . '</a> '; $pt[] = $k->getName(); } $location .= '» ' . $page->getTitle(); $pt[] = $page->getTitle(); $pagetitle = ''; for ($i = count($pt) - 1; $i >= 0; $i--) { $pagetitle .= $pagetitle == '' ? $pt[$i] : " « {$pt[$i]}"; } $tpl->assign('page_location', $location); $tpl->assign('xoops_pagetitle', $pagetitle); $page->addRead(); $tpl->assign('page', array('title' => $page->getTitle(), 'text' => $page->getText(), 'id' => $page->getID(), 'name' => $page->getFriendTitle(), 'mod_date' => sprintf(__('Last update: %s', 'qpages'), formatTimestamp($page->getModDate(), 'c')), 'reads' => sprintf(__('Read %u times', 'qpages'), $page->getReads()), 'metas' => $page->get_meta())); // Páginas relacionadas if ($mc['related']) { $sql = "SELECT * FROM " . $db->prefix("qpages_pages") . " WHERE cat='" . $catego->getID() . "' AND id_page<>'" . $page->getID() . "' ORDER BY RAND() DESC LIMIT 0,{$mc['related_num']}"; $result = $db->query($sql); $tpl->assign('related_num', $db->getRowsNum($result)); while ($row = $db->fetchArray($result)) { $rp = new QPPage(); $rp->assignVars($row); $tpl->append('related', array('id' => $rp->getID(), 'link' => $rp->getPermaLink(), 'title' => $rp->getTitle(), 'modified' => formatTimestamp($rp->getModDate(), 'c'), 'hits' => $rp->getReads(), 'desc' => $rp->getDescription())); } } $tpl->assign('show_related', $mc['related']); $tpl->assign('lang_related', __('Related Pages', 'qpages')); $tpl->assign('lang_page', __('Page', 'qpages')); $tpl->assign('lang_modified', __('Last modification', 'qpages')); $tpl->assign('lang_hits', __('Hits', 'qpages')); RMEvents::get()->run_event('qpages.view.page', $page); require 'footer.php';
$leg .= urlencode($page->getTitle() . ' (' . $page->getReads() . ' times)') . "|"; $values .= $page->getReads() . ','; } $values = rtrim($values, ','); $leg = rtrim($leg, "|"); if ($max > 0) { $chart = "http://chart.apis.google.com/chart?"; $chart .= "cht=bvs&chco=99CC00|FFCC00|0099FF|FF6600|6666FF"; $chart .= "&" . $labels . '&' . $values . "&" . $leg; $chart .= "&chbh=a,20&chs=330x300&chxr=1,0," . $max . "&chds=0," . ($max + 1); $chart .= "&chtt=" . urlencode(__('Most viewed pages', 'qpages')); } else { $chart = ''; } // Recent pages $sql = "SELECT * FROM " . $db->prefix("qpages_pages") . " ORDER BY fecha DESC LIMIT 0, 5"; $result = $db->query($sql); $pages = array(); while ($row = $db->fetchArray($result)) { $page = new QPPage(); $page->assignVars($row); $pages[] = array('id' => $page->getID(), 'title' => $page->getTitle(), 'link' => $page->getPermaLink(), 'desc' => $page->getDescription(), 'public' => $page->getAccess()); } RMTemplate::get()->set_help('http://redmexico.com.mx/docs/quickpages'); // Left widgets and right widgets $left_widgets = array(); $left_widgets = RMEvents::get()->run_event('qpages.left.widgets', $left_widgets); $right_widgets = array(); $right_widgets = RMEvents::get()->run_event('qpages.right.widgets', $right_widgets); include RMTemplate::get()->get_template('admin/qp_index.php', 'module', 'qpages'); xoops_cp_footer();