public function permalink() { $mc = RMUtilities::get()->module_config('mywords'); $rtn = MWFunctions::get_url(); $rtn .= $mc['permalinks'] == 1 ? '?author=' . $this->id() : ($mc['permalinks'] == 2 ? "author/" . $this->getVar('shortname', 'n') . "/" : "author/" . RMUtilities::add_slash($this->id())); return $rtn; }
/** * Obtiene el enlace a la categor?a */ public function permalink() { $mc = RMSettings::module_settings('mywords'); $link = MWFunctions::get_url(); $link .= $mc->permalinks == 1 ? '?cat=' . $this->id() : ($mc->permalinks == 2 ? 'category/' . $this->path() : 'category/' . $this->id()); return $link; }
function permalink() { $mc = RMSettings::module_settings('mywords'); $ret = MWFunctions::get_url(); $ret .= $mc->permalinks == 1 ? '?tag=' . $this->id() : ($mc->permalinks == 2 ? "tag/" . $this->getVar('shortname', 'n') . "/" : "tag/" . $this->id()); return $ret; }
public function permalink() { $mc = RMSettings::module_settings('mywords'); $rtn = MWFunctions::get_url(); $rtn .= $mc->permalinks == 1 ? '?author=' . $this->id() : ($mc->permalinks == 2 ? "author/" . $this->getVar('shortname', 'n') . "/" : "author/" . RMUtilities::add_slash($this->id())); return $rtn; }
/** * Obtiene el enlace a la categor?a */ public function permalink() { $mc = RMUtilities::get()->module_config('mywords'); $link = MWFunctions::get_url(); $link .= $mc['permalinks'] == 1 ? '?cat=' . $this->id() : ($mc['permalinks'] == 2 ? 'category/' . $this->path() : 'category/' . $this->id()); return $link; }
function mw_post_form($edit = 0) { global $xoopsConfig, $xoopsUser, $xoopsSecurity; if (!$xoopsUser) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } // Check if user is a editor $author = new MWEditor(); if (!$author->from_user($xoopsUser->uid()) && !$xoopsUser->isAdmin()) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.min.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery-ui.min.js'); if ($edit) { $id = rmc_server_var($_GET, 'id', 0); if ($id <= 0) { redirect_header(MWFunctions::get_url(), __('Please, specify a valid post ID', 'mywords'), 1); die; } $post = new MWPost($id); if ($post->isNew()) { redirect_header(MWFunctions::get_url(), __('Specified post does not exists!', 'mywords'), 1); die; } // Check if user is the admin or a editor of this this post if ($author->id() != $post->getVar('author') && !$xoopsUser->isAdmin()) { redirect_header($post->permalink(), 1, __('You are not allowed to do this action!', 'mywords')); die; } } // Read privileges $perms = @$author->getVar('privileges'); $perms = is_array($perms) ? $perms : array(); $allowed_tracks = in_array("tracks", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_tags = in_array("tags", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_cats = in_array("cats", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_comms = in_array("comms", $perms) || $xoopsUser->isAdmin() ? true : false; $xoopsOption['module_subpage'] = 'submit'; include 'header.php'; $form = new RMForm('', '', ''); $editor = new RMFormEditor('', 'content', '99%', '300px', $edit ? $post->getVar('content') : ''); $meta_names = MWFunctions::get()->get_metas(); RMTemplate::get()->add_xoops_style('submit.css', 'mywords'); RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/scripts.php?file=posts.js&front=1'); include RMTemplate::get()->get_template('mywords_submit_form.php', 'module', 'mywords'); include 'footer.php'; }
} $xoopsTpl->assign('comments', $comms); // Comments form RMFunctions::comments_form('mywords', 'post=' . $post->id(), 'module', MW_PATH . '/class/mywordscontroller.php'); } // Load trackbacks $trackbacks = $post->trackbacks(); foreach ($trackbacks as $tb) { $xoopsTpl->append('trackbacks', array('id' => $tb->id(), 'title' => $tb->getVar('title'), 'blog' => $tb->getVar('blog_name'), 'url' => $tb->getVar('url'), 'text' => $tb->getVar('excerpt'), 'date' => formatTimestamp($tb->getVar('date'), 'c'))); } // Language $xoopsTpl->assign('lang_publish', __('Published in', 'mywords')); $xoopsTpl->assign('lang_tagged', __('Tagged as', 'mywords')); $xoopsTpl->assign('lang_numcoms', sprintf(__('%u Comments', 'mywords'), $post->getVar('comments'))); $xoopsTpl->assign('lang_numtracks', sprintf(__('%u trackbacks', 'mywords'), count($trackbacks))); $xoopsTpl->assign('lang_trackback', __('Trackback', 'mywords')); $xoopsTpl->assign('lang_homemw', __('Main Page', 'mywords')); $xoopsTpl->assign('enable_images', $xoopsModuleConfig['post_imgs']); //Trackback if ($post->getVar('pingstatus')) { $tb = new MWTrackback($xoopsConfig['sitename'], $editor->getVar('name')); RMTemplate::get()->add_head($tb->rdf_autodiscover(date('r', $post->getVar('pubdate')), $post->getVar('title'), TextCleaner::getInstance()->truncate($post->content(true), 255), $post->permalink(), MWFunctions::get_url(true) . $post->id(), $editor->getVar('name'))); } $rmf = RMFunctions::get(); $description = $post->get_meta('description', false); $keywords = $post->get_meta('keywords', false); $rmf->add_keywords_description($description != '' ? $description : $post->content(true), $keywords != '' ? $keywords : ''); // Send pings? $pings = $post->getVar('toping'); $xoopsTpl->assign('pingnow', empty($pings)); include 'footer.php';
$author = new MWEditor(); if (!$author->from_user($xoopsUser->uid()) && !$xoopsUser->isAdmin()) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } RMTemplate::get()->add_jquery(); $edit = isset($edit) ? $edit : 0; if ($edit > 0) { $id = $edit; if ($id <= 0) { redirect_header(MWFunctions::get_url(), __('Please, specify a valid post ID', 'mywords'), 1); die; } $post = new MWPost($id); if ($post->isNew()) { redirect_header(MWFunctions::get_url(), __('Specified post does not exists!', 'mywords'), 1); die; } // Check if user is the admin or a editor of this this post if ($author->id() != $post->getVar('author') && !$xoopsUser->isAdmin()) { redirect_header($post->permalink(), 1, __('You are not allowed to do this action!', 'mywords')); die; } } else { $post = new MWPost(); } // Read privileges $perms = @$author->getVar('privileges'); $perms = is_array($perms) ? $perms : array(); $allowed_tracks = in_array("tracks", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_tags = in_array("tags", $perms) || $xoopsUser->isAdmin() ? true : false;
<?php // $Id$ // -------------------------------------------------------------- // MyWords // Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- $xoopsOption['template_main'] = 'mywords_tag.html'; $xoopsOption['module_subpage'] = 'author'; include 'header.php'; $tag = new MWTag($tag); if ($tag->isNew()) { redirect_header(MWFunctions::get_url(), 2, __('Sorry, this tag does not exists!', 'admin_mywords')); die; } $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 0; if ($page <= 0) { $path = explode("/", $request); $srh = array_search('page', $path); if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) { $page = 0; } else { $page = $path[$srh + 1]; } } } $request = substr($request, 0, strpos($request, 'page') > 0 ? strpos($request, 'page') - 1 : strlen($request));
foreach ($path as $k) { if ($k == '') { continue; } $sql = "SELECT id_cat FROM {$tbl1} WHERE shortname='{$k}' AND parent='{$idp}'"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { list($idp) = $db->fetchRow($result); } } $category = $idp; } } $catego = new MWCategory($category); if ($catego->isNew()) { redirect_header(MWFunctions::get_url(), 2, __('Specified category could not be found', 'mywords')); die; } // Datos de la Categoría $xoopsTpl->assign('category', array('id' => $catego->id(), 'name' => $catego->getVar('name'))); $xoopsTpl->assign('lang_postsincat', sprintf(__('Posts in ‘%s’ Category', 'mywords'), $catego->getVar('name'))); $request = substr($request, 0, strpos($request, 'page') > 0 ? strpos($request, 'page') - 1 : strlen($request)); //$request = // Select all posts from relations table //$sql = "SELECT post FROM ".$db->prefix("mw_catpost")." WHERE cat='$category'"; //$result = $db->query($sql); /** * Paginacion de Resultados */ $limit = $mc['posts_limit']; list($num) = $db->fetchRow($db->query("SELECT COUNT({$tbl2}.post) FROM {$tbl2}, {$tbl3} WHERE {$tbl2}.cat='{$category}' \n\t\tAND {$tbl3}.id_post={$tbl2}.post AND {$tbl3}.status='publish' AND \n\t\t(({$tbl3}.visibility='public' OR {$tbl3}.visibility='password') OR ({$tbl3}.visibility='private' AND \n\t\t{$tbl3}.author=" . ($xoopsUser ? $xoopsUser->uid() : -1) . "))"));
// $Id$ // -------------------------------------------------------------- // MyWords // Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- $xoopsOption['template_main'] = 'mywords_date.html'; $xoopsOption['module_subpage'] = 'date'; include 'header.php'; $sql = "SELECT COUNT(*) FROM " . $db->prefix("mw_posts") . " WHERE pubdate BETWEEN {$time} and {$time2} AND ((visibility='public' OR visibility='password') OR (visibility='private' AND author=" . ($xoopsUser ? $xoopsUser->uid() : -1) . "))"; list($num) = $db->fetchRow($db->query($sql)); // Check if there are posts for this date if ($num <= 0) { redirect_header(MWFunctions::get_url(), 1, __("There are not posts published on this date", 'mywords')); die; } $page = rmc_server_var($_GET, 'page', 0); if ($page <= 0) { $path = explode("/", $request); $srh = array_search('page', $path); if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) { $page = 0; } else { $page = $path[$srh + 1]; } } } $limit = $xoopsModuleConfig['posts_limit'];
/** * Obtiene el enlace permanente al artículo */ public function permalink() { $mc = RMUtilities::get()->module_config('mywords'); $day = date('d', $this->getVar('pubdate')); $month = date('m', $this->getVar('pubdate')); $year = date('Y', $this->getVar('pubdate')); $rtn = MWFunctions::get_url(); $rtn .= $mc['permalinks'] == 1 ? '?post=' . $this->id() : ($mc['permalinks'] == 2 ? "{$day}/{$month}/{$year}/" . $this->getVar('shortname', 'n') . "/" : "post/" . $this->id()); return $rtn; }
// Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- $xoopsOption['template_main'] = 'mywords_author.html'; $xoopsOption['module_subpage'] = 'author'; include 'header.php'; if (!is_numeric($editor)) { $sql = "SELECT id_editor FROM " . $db->prefix("mw_editors") . " WHERE shortname='{$editor}'"; list($editor) = $db->fetchRow($db->query($sql)); if ($editor == '') { $editor = 0; } } $ed = new MWEditor($editor); if ($ed->isNew()) { redirect_header(MWFunctions::get_url(), 2, __('Sorry, We don\'t know to this editor', 'admin_mywords')); die; } $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 0; if ($page <= 0) { $path = explode("/", $request); $srh = array_search('page', $path); if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) { $page = 0; } else { $page = $path[$srh + 1]; } } } $request = substr($request, 0, strpos($request, 'page') > 0 ? strpos($request, 'page') - 1 : strlen($request));
/** * Obtiene el enlace permanente al artículo */ public function permalink() { $mc = RMSettings::module_settings('mywords'); $day = date('d', $this->getVar('pubdate')); $month = date('m', $this->getVar('pubdate')); $year = date('Y', $this->getVar('pubdate')); $rtn = MWFunctions::get_url(); $rtn .= $mc->permalinks == 1 ? '?post=' . $this->id() : ($mc->permalinks == 2 ? "{$day}/{$month}/{$year}/" . $this->getVar('shortname', 'n') . "/" : "post/" . $this->id()); return $rtn; }
} $track = new MWTrackback($xoopsConfig['sitename'], $editor->getVar('name')); $id = $track->post_id; // The id of the item being trackbacked $url = $track->url; // The URL from which we got the trackback $title = $track->title; // Subject/title send by trackback $excerpt = $track->excerpt; // Short text send by trackback $blog_name = rmc_server_var($_POST, 'blog_name', ''); if ($url == '' || $title == '' || $excerpt == '') { echo $track->recieve(false, __('Sorry, your trackback seems to be invalid!', 'mywords')); die; } $params = array('blogurl' => MWFunctions::get_url(), 'name' => 'Trackback', 'email' => '', 'url' => $url, 'text' => $excerpt, 'permalink' => $post->permalink()); $ret = RMEvents::get()->run_event('rmcommon.check.post.spam', $params); if (!$ret) { echo $track->recieve(false, __('Sorry, your trackback seems to be SPAM', 'mywords')); } else { $to = new MWTrackbackObject(); $to->setVar('date', time()); $to->setVar('title', $title); $to->setVar('blog_name', $blog_name); $to->setVar('excerpt', $excerpt); $to->setVar('url', $url); $to->setVar('post', $post->id()); if ($to->save()) { echo $track->recieve(true); } else { echo $track->recieve(false, __('We are unable to store your trackback. Please try again later!', 'mywords'));
public function format_time($time) { $day = date('d', $time); $month = date('m', $time); $year = date('Y', $time); $format = __("Published on %s at %s", 'mywords'); $config = RMUtilities::module_config('mywords'); if ($config['permalinks'] > 1) { $url = MWFunctions::get_url() . "{$day}/{$month}/{$year}/"; } else { $url = MWFunctions::get_url() . "?date={$day}/{$month}/{$year}/"; } $date = '<a href="' . $url . '">' . date(__('D d M, Y', 'mywords'), $time) . '</a>'; $hour = date(__('H:i', 'mywords'), $time); $rtn = sprintf($format, $date, $hour); return $rtn; }
// $Id$ // -------------------------------------------------------------- // MyWords // Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- //include XOOPS_ROOT_PATH.'/modules/rmcommon/loader.php'; include XOOPS_ROOT_PATH . "/header.php"; load_mod_locale('mywords', ''); $mc =& $xoopsModuleConfig; $db = XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); define('MW_PATH', XOOPS_ROOT_PATH . '/modules/mywords'); define('MW_URL', MWFunctions::get_url()); $xoopsTpl->assign('mw_url', MW_URL); $xmh = ''; if ($mc['use_css']) { RMTemplate::get()->add_xoops_style('mywords.css', 'mywords'); } // Redes Sociales $sql = "SELECT * FROM " . $db->prefix("mw_bookmarks") . " WHERE `active`='1'"; $result = $db->query($sql); $socials = array(); $i = 0; while ($row = $db->fetchArray($result)) { $socials[$i] = new MWBookmark(); $socials[$i]->assignVars($row); $i++; }
/** * 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(); }
$tb = new MWTrackback('', ''); $trackbacks = $tb->auto_discovery($content); } if (!empty($trackbacks)) { foreach ($trackbacks as $t) { if (!empty($pinged) && in_array($t, $pinged)) { continue; } $toping[] = $t; } } $post->setVar('toping', !empty($toping) ? $toping : ''); $return = $edit ? $post->update() : $post->save(); if ($return) { if (!$edit) { $xoopsUser->incrementPost(); } showMessage($edit ? __('Post updated successfully', 'mywords') : __('Post saved successfully', 'mywords'), 0); $url = MWFunctions::get_url(); if ($mc->permalinks > 1) { $url .= $frontend ? 'edit/' . $post->id() : 'posts.php?op=edit&id=' . $post->id(); } else { $url .= $frontend ? '?edit=' . $post->id() : 'posts.php?op=edit&id=' . $post->id(); } $rtn = array('message' => $edit ? __('Post updated successfully', 'mywords') : __('Post saved successfully', 'mywords'), 'token' => $xoopsSecurity->createToken(), 'link' => '<strong>' . __('Permalink:', 'mywords') . '</strong> ' . $post->permalink(), 'post' => $post->id(), 'url' => $url); echo json_encode($rtn); die; } else { return_error(__('Errors ocurred while trying to save this post.', 'mywords') . '<br />' . $post->errors(), true); die; }