} break; case 'author': include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mweditor.class.php'; $id = RMHttpRequest::get('author', 'integer', 0); if ($id <= 0) { redirect_header('backend.php', 1, __('Sorry, specified author was not foud!', 'mywords')); die; } $ed = new MWEditor($id); if ($ed->isNew()) { redirect_header('backend.php', 1, __('Sorry, specified author was not foud!', 'mywords')); die; } $rss_channel['title'] = sprintf(__('Posts by %s in %s', 'mywords'), $ed->name != '' ? $ed->name : $ed->shortname, $xoopsConfig['sitename']); $rss_channel['link'] = $ed->permalink(); $rss_channel['description'] = sprintf(__('Posts published by %s.', 'mywords'), $ed->getVar('name')) . ' ' . htmlspecialchars(strip_tags($ed->getVar('bio')), ENT_QUOTES); $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss'); $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['category'] = "Blog"; $rss_channel['generator'] = 'Common Utilities'; $rss_channel['language'] = RMCLANG; $posts = MWFunctions::get_filtered_posts("author=" . $ed->uid, 0, 10); $rss_items = array(); foreach ($posts as $post) { $item = array(); $item['title'] = $post->getVar('title'); $item['link'] = $post->permalink(); $img = new RMImage(); $img->load_from_params($post->getVar('image', 'e'));
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 if ($xoopsModuleConfig['showbookmarks']) { foreach ($socials as $site) { $xoopsTpl->append('socials', array('title' => $site->getVar('title'), 'icon' => $site->getVar('icon'), 'url' => $site->link($post->getVar('title'), $post->permalink(), TextCleaner::truncate($post->content(true), 60)), 'alt' => $site->getVar('alt'))); } } unset($tags_list); // Comments // When use the common utilities comments system you can choose between // use of Common Utilities templates or use your own templates // We will use MyWords included templates if ($post->getVar('comstatus')) {
} $request = substr($request, 0, strpos($request, 'page') > 0 ? strpos($request, 'page') - 1 : strlen($request)); /** * Paginamos los resultados */ $limit = $mc['posts_limit']; $sql = "SELECT COUNT(*) FROM " . $db->prefix("mw_posts") . " WHERE author='{$editor}' AND status='publish' AND \n\t\t((visibility='public' OR visibility='password') OR (visibility='private' AND\n\t\tauthor=" . ($xoopsUser ? $xoopsUser->uid() : -1) . "))"; list($num) = $db->fetchRow($db->query($sql)); if ($page > 0) { $page -= 1; } $start = $page * $mc['posts_limit']; $tpages = (int) ($num / $mc['posts_limit']); if ($num % $mc['posts_limit'] > 0) { $tpages++; } $pactual = $page + 1; if ($pactual > $tpages) { $rest = $pactual - $tpages; $pactual = $pactual - $rest + 1; $start = ($pactual - 1) * $limit; } $nav = new RMPageNav($num, $limit, $pactual, 6); $nav->target_url($ed->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&page={PAGE_NUM}')); $xoopsTpl->assign("nav_pages", $nav->render(false, 0)); $xoopsTpl->assign('pactual', $pactual); $xoopsTpl->assign('lang_fromauthor', sprintf(__('Posts by "%s"', 'mywords'), $ed->getVar('name'))); $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE author='{$editor}' AND status='publish' AND \n\t\t((visibility='public' OR visibility='password') OR (visibility='private' AND\n\t\tauthor=" . ($xoopsUser ? $xoopsUser->uid() : -1) . ")) ORDER BY pubdate DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); require 'post_data.php'; include 'footer.php';
} $pendings = array(); $result = $db->query("SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE status='waiting' ORDER BY id_post DESC LIMIT 0,8"); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $pendings[] = $post; } // Editors $sql = "SELECT *, (SELECT COUNT(*) FROM " . $db->prefix("mod_mywords_posts") . " WHERE author=id_editor) as counter FROM " . $db->prefix("mod_mywords_editors") . " ORDER BY counter DESC LIMIT 0, 5"; $result = $db->query($sql); $editors = array(); while ($row = $db->fetchArray($result)) { $editor = new MWEditor(); $editor->assignVars($row); $editors[] = array('id' => $editor->id(), 'name' => $editor->getVar('name'), 'link' => $editor->permalink(), 'total' => $row['counter']); } unset($editor, $result, $sql); // URL rewriting $rule = "RewriteRule ^" . trim($xoopsModuleConfig['basepath'], '/') . "/?(.*)\$ modules/mywords/index.php [L]"; if ($xoopsModuleConfig['permalinks'] > 1) { $ht = new RMHtaccess('mywords'); $htResult = $ht->write($rule); if ($htResult !== true) { showMessage(__('An error ocurred while trying to write .htaccess file!', 'mywords'), RMMSG_ERROR); } } else { $ht = new RMHtaccess('mywords'); $ht->removeRule(); $ht->write(); }
} $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']; }