/** * This method is designed specially for MyWords */ public function eventMywordsViewPost($post_data, MWPost $post) { $config = RMFunctions::get()->plugin_settings('metaseo', true); if (!$config['meta']) { $metas = '<meta name="description" content="' . TextCleaner::truncate($post->content(true), $config['len']) . '" />'; $tags = array(); foreach ($post->tags() as $tag) { $tags[] = $tag['tag']; } $tags = implode(',', $tags); $metas .= '<meta name="keywords" content="' . $tags . '" />'; } else { $metas = '<meta name="description" content="' . $post->get_meta($config['meta_name'], false) . '" />'; $metas = '<meta name="description" content="' . $post->get_meta($config['meta_keys'], false) . '" />'; } RMTemplate::get()->add_head($metas); return $post_data; }
/** * Muestra los envíos existentes */ function showPosts($aprovado = -1) { global $db, $xoopsSecurity, $xoopsModule, $xoopsModuleConfig; $mc =& $xoopsModuleConfig; $keyw = ''; $op = ''; $cat = 0; $status = ''; foreach ($_REQUEST as $k => $v) { ${$k} = $v; } $tbl1 = $db->prefix("mod_mywords_posts"); $tbl2 = $db->prefix("mod_mywords_catpost"); $and = false; if ($cat > 0) { $sql = "SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.cat='{$cat}' AND a.id_post=b.post"; $and = true; } else { $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_mywords_posts"); } if (isset($status) && $status != '') { define('RMCSUBLOCATION', $status); $sql .= $and ? " AND a.status='{$status}'" : " WHERE status='{$status}'"; $and = true; } if (isset($author) && $author > 0) { $sql .= $and ? " AND a.author={$author}" : " WHERE author={$author}"; $and = true; } if (trim($keyw) != '') { $sql .= $and ? " AND title LIKE '%{$keyw}%'" : " WHERE title LIKE '%{$keyw}%'"; } /** * Paginacion de Resultados */ $page = rmc_server_var($_GET, 'page', 1); $limit = isset($limit) && $limit > 0 ? $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('posts.php?limit=' . $limit . '&page={PAGE_NUM}'); $sql .= " ORDER BY id_post DESC LIMIT {$start},{$limit}"; $sql = str_replace("SELECT COUNT(*)", "SELECT *", $sql); $result = $db->query($sql); $posts = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); # Enlace para el artículo $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $postlink = MWFunctions::get_url(); $postlink .= $mc['permalinks'] == 1 ? '?post=' . $post->id() : ($mc['permalinks'] == 2 ? "{$day}/{$month}/{$year}/" . $post->getVar('shortname') . "/" : "post/" . $post->id()); $posts[] = array('id' => $post->id(), 'title' => $post->getVar('title'), 'date' => $post->getVar('pubdate') > 0 ? formatTimeStamp($post->getVar('pubdate')) : '<em>' . __('Not published', 'mywords') . '</em>', 'created' => formatTimeStamp($post->getVar('created')), 'comments' => $post->getVar('comments'), 'uid' => $post->getVar('author'), 'uname' => $post->getVar('authorname'), 'link' => $postlink, 'status' => $post->getVar('status'), 'categories' => $post->get_categories_names(true, ',', true, 'admin'), 'tags' => $post->tags(false), 'reads' => $post->getVar('reads')); } // Published count $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_mywords_posts") . " WHERE status='publish'"; list($pub_count) = $db->fetchRow($db->query($sql)); // Drafts count $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_mywords_posts") . " WHERE status='draft'"; list($draft_count) = $db->fetchRow($db->query($sql)); // Pending count $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_mywords_posts") . " WHERE status='pending'"; list($pending_count) = $db->fetchRow($db->query($sql)); // Confirm message RMTemplate::get()->add_head('<script type="text/javascript"> function post_del_confirm(post, id){ var string = "' . __('Do you really want to delete \\"%s\\"', 'mywords') . '"; string = string.replace("%s", post); var ret = confirm(string); if (ret){ $("#form-posts input[type=checkbox]").removeAttr("checked"); $("#post-"+id).attr("checked","checked"); $("#posts-op").val("delete"); $("#form-posts").submit(); } } </script>'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); MWFunctions::include_required_files(); $title_by_status = ''; switch ($status) { case 'publish': $title_by_status = __('Published Posts', 'mywords'); break; case 'draft': $title_by_status = __('Drafts', 'mywords'); break; case 'waiting': $title_by_status = __('Pending of Review', 'dtransport'); break; } if ($title_by_status != '') { RMBreadCrumb::get()->add_crumb(__('Posts management', 'mywords'), 'posts.php'); RMBreadCrumb::get()->add_crumb($title_by_status); RMTemplate::get()->assign('xoops_pagetitle', sprintf(__('Posts Management: %s', 'mywords'), $title_by_status)); } else { RMBreadCrumb::get()->add_crumb(__('Posts management', 'mywords')); RMTemplate::get()->assign('xoops_pagetitle', __('Posts Management', 'mywords')); } xoops_cp_header(); include_once '../templates/admin/mywords-posts.php'; xoops_cp_footer(); }
$sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE id_post>" . $post->id() . " AND status='publish' ORDER BY id_post ASC LIMIT 0, 1"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('next_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } } $xoopsTpl->assign('shownav', $xoopsModuleConfig['shownav']); if ($xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid())) { $edit = '<a href="' . XOOPS_URL . '/modules/mywords/admin/posts.php?op=edit&id=' . $post->id() . '">' . __('Edit Post', 'mywords') . '</a>'; $xoopsTpl->assign('edit_link', $edit); unset($edit); } $xoopsTpl->assign('lang_reads', sprintf(__('%u views', 'mywords'), $post->getVar('reads'))); // Tags $tags = $post->tags(true); $tags_list = ''; foreach ($tags as $i => $tag) { $tags_list .= ($tags_list == '' ? '' : ', ') . '<a href="' . $tag->permalink() . '">' . $tag->getVar('tag') . '</a>'; } // Post pages $total_pages = $post->total_pages(); $nav = new RMPageNav($total_pages, 1, $page, 5); $nav->target_url($post->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&page={PAGE_NUM}')); $xoopsTpl->assign('post_navbar', $nav->render(true)); // Post data $post_arr = array('id' => $post->id(), 'title' => $post->getVar('title'), 'published' => sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate')), date('H:i', $post->getVar('pubdate')), '<a href="' . $editor->permalink() . '">' . (isset($editor) ? $editor->getVar('name') : __('Anonymous', 'mywords')) . "</a>"), 'text' => $post->content(false, $page), 'cats' => $post->get_categories_names(), 'tags' => $tags_list, 'trackback' => $post->getVar('pingstatus') ? MWFunctions::get_url(true) . $post->id() : '', 'meta' => $post->get_meta('', false), 'time' => $post->getVar('pubdate'), 'image' => $post->getImage($xoopsModuleConfig['post_imgs_size']), 'author' => $editor->getVar('name'), 'alink' => $editor->permalink()); // Plugins? $post_arr = RMEvents::get()->run_event('mywords.view.post', $post_arr, $post); $xoopsTpl->assign('post', $post_arr); // Social sites
} $xoopsTpl->assign('shownav', $xoopsModuleConfig['shownav']); if ($xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid())) { $editLink = XOOPS_URL . '/modules/mywords/admin/posts.php?op=edit&id=' . $post->id(); $xoopsTpl->assign('can_edit', true); $xoopsTpl->assign('edit_link', $editLink); unset($editLink); } $xoopsTpl->assign('lang_reads', sprintf(__('%u views', 'mywords'), $post->getVar('reads'))); // Post pages $total_pages = $post->total_pages(); $nav = new RMPageNav($total_pages, 1, $page, 5); $nav->target_url($post->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&page={PAGE_NUM}')); $xoopsTpl->assign('post_navbar', $nav->render(true)); // Post data $post_arr = array('id' => $post->id(), 'title' => $post->getVar('title'), 'published' => sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate')) . ' ' . date('H:i', $post->getVar('pubdate')), '<a href="' . $editor->permalink() . '">' . (isset($editor) ? $editor->getVar('name') : __('Anonymous', 'mywords')) . "</a>"), 'text' => $post->content(false, $page), 'cats' => $post->get_categos('data'), 'tags' => $post->tags(false), 'trackback' => $post->getVar('pingstatus') ? MWFunctions::get_url(true) . $post->id() : '', 'meta' => $post->get_meta('', false), 'time' => $post->getVar('pubdate'), 'image' => $post->image(), 'video' => $post->video, 'player' => $post->video != '' ? $post->video_player() : '', 'author' => array('name' => $editor->getVar('name') != '' ? $editor->name : $editor->shortname, 'id' => $editor->id(), 'link' => $editor->permalink(), 'bio' => $editor->getVar('bio'), 'email' => $editor->data('email'), 'uid' => $editor->uid, 'url' => $editor->data('url')), 'alink' => $editor->permalink(), 'format' => $post->format, 'comments' => $post->comments, 'comments_enabled' => $post->comstatus); $xoopsTpl->assign('full_post', 1); $xoopsTpl->assign('lang_editpost', __('Edit Post', 'mywords')); $xoopsTpl->assign('lang_postedin', __('Posted in:', 'mywords')); $xoopsTpl->assign('lang_taggedas', __('Tagged as:', 'mywords')); $xoopsTpl->assign('enable_images', $xoopsModuleConfig['list_post_imgs']); // Plugins? $post_arr = RMEvents::get()->run_event('mywords.view.post', $post_arr, $post); $xoopsTpl->assign('post', $post_arr); // Related posts if ($xoopsModuleConfig['related']) { $rtags = $post->tags(); $tt = array(); foreach ($rtags as $tag) { $tt[] = $tag['id_tag']; }