/** * Provides a widget to specify the default image for posts */ function mw_widget_image() { global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $rm_config; $id = rmc_server_var($_REQUEST, 'id', 0); $type = rmc_server_var($_REQUEST, 'type', ''); $op = rmc_server_var($_REQUEST, 'op', ''); $edit = $op == 'edit' ? 1 : 0; $widget = array(); $widget['title'] = __('Default Image', 'mywords'); $util = new RMUtilities(); if ($edit) { //Verificamos que el software sea válido if ($id <= 0) { $params = ''; } $post = new MWPost($id); if ($post->isNew()) { $params = ''; } else { $params = $post->getVar('image'); } } else { $params = ''; } $widget['content'] = '<form name="frmDefimage" id="frm-defimage" method="post">'; $widget['content'] .= $util->image_manager('image', $params); $widget['content'] .= '</form>'; return $widget; }
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'; }
public function eventRmcommonLoadingSingleEditorimgs($items, $url) { if (FALSE === strpos($url, 'modules/mywords/admin/posts.php')) { return $items; } parse_str($url); if (!isset($id) || $id <= 0) { return $items; } xoops_load('mwpost.class', 'mywords'); xoops_load('mwfunctions', 'mywords'); $post = new MWPost($id); if ($post->isNew()) { return $items; } $items['links']['post'] = array('caption' => __('Link to post', 'mywords'), 'value' => $post->permalink()); return $items; }
/** * 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; }
public function eventRmcommonImageInsertLinks($links, $image, $url) { if (FALSE === strpos($url, 'modules/mywords/admin/posts.php')) { return $links; } parse_str($url); if (!isset($id) || $id <= 0) { return $links; } xoops_load('mwpost.class', 'mywords'); xoops_load('mwfunctions', 'mywords'); $post = new MWPost($id); if ($post->isNew()) { return $links; } $links['post'] = array('caption' => __('Link to post', 'mywords'), 'value' => $post->permalink()); return $links; }
public function get_item_url($params, $com) { static $posts; $params = urldecode($params); parse_str($params); if (!isset($post) || $post <= 0) { return ''; } if (isset($posts[$post])) { $ret = $posts[$post]->permalink(); return $ret; } include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php'; $item = new MWPost($post); if ($item->isNew()) { return ''; } $posts[$post] = $item; return $item->permalink(); }
/** * Función para realizar búsquedas */ function mywords_search($qa, $andor, $limit, $offset, $userid) { global $xoopsUser; $db = XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; $util =& RMUtilities::get(); $mc =& $util->module_config('mywords'); $sql = "SELECT * FROM " . $db->prefix("mw_posts"); $adds = ''; if (is_array($qa) && ($count = count($qa))) { $adds = ''; for ($i = 0; $i < $count; $i++) { $adds .= $adds == '' ? "(title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')" : " {$andor} (title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')"; } } $sql .= $adds != '' ? " WHERE " . $adds : ''; if ($userid > 0) { $sql .= ($adds != '' ? " AND " : " WHERE ") . "author='{$userid}'"; } $sql .= " ORDER BY pubdate DESC"; $i = 0; $result = $db->query($sql, $limit, $offset); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $ret[$i]['image'] = "images/post.png"; $ret[$i]['link'] = $post->permalink(); $ret[$i]['title'] = $post->getVar('title'); $ret[$i]['time'] = $post->getVar('pubdate'); $ret[$i]['uid'] = $post->getVar('author'); $ret[$i]['desc'] = substr(strip_tags($post->content()), 0, 150); $i++; } return $ret; }
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; $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', '100%', '300px', $edit ? $post->getVar('content', $rmc_config['editor_type'] == 'tiny' ? 's' : 'e') : ''); $editor->setExtra('required'); $meta_names = MWFunctions::get()->get_metas(); RMTemplate::get()->add_style('submit.css', 'mywords');
list($numcoms) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_comments") . " WHERE id_obj='mywords'")); list($numtags) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_mywords_tags"))); /** * @desc Caragmaos los artículos recientemente enviados */ $drafts = array(); $result = $db->query("SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE status='draft' ORDER BY id_post DESC LIMIT 0,5"); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $drafts[] = $post; } $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]";
// $Id: post_data.php 976 2012-06-01 03:52:18Z i.bitcero $ // -------------------------------------------------------------- // MyWords // Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_ROOT_PATH')) { header('location: ./'); die; } // Authors cache $editors = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $link = $post->permalink(); # Generamos el vínculo para el autor if ($post->getVar('author') > 0) { if (!isset($editors[$post->getVar('author')])) { $editors[$post->getVar('author')] = new MWEditor($post->getVar('author'), 'user'); } if ($editors[$post->getVar('author')]->isNew()) { if ($xoopsUser && $xoopsUser->uid() == $post->author) { $user = $xoopsUser; } else {
/** * Widget that show tags selection in a post form */ function mw_widget_addtags() { global $xoopsModuleConfig, $xoopsUser, $allowed_tags; $widget['title'] = __('Add Tags', 'admin_mywords'); RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/scripts.php?file=tags.js'); $widget['icon'] = ''; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0; $edit = false; if ($id > 0) { $post = new MWPost($id); if ($post->isNew()) { unset($post); } else { $edit = true; } } ob_start(); ?> <div class="rmc_widget_content_reduced"> <form id="mw-post-tags-form"> <?php if ($xoopsUser->isAdmin() || $allowed_tags) { ?> <div class="tags_box"> <input type="text" name="tagsm" id="tags-m" class="formInput wtLeftInput" /> <input type="button" name="tags-button" id="tags-button" class="button" value="<?php _e('+ Add', 'admin_mywords'); ?> " /><br /> <span class="descriptions"><em><?php _e('Separate multiple tags with commas', 'admin_mywords'); ?> </em></span> </div> <?php } $tags = $edit ? $post->tags() : array(); ?> <div id="tags-container"> <span class="tip_legends" style="<?php echo empty($tags) ? 'display: none;' : ''; ?> "> <?php _e('Used Tags', 'admin_mywords'); ?> </span> <?php foreach ($tags as $tag) { ?> <label><input type='checkbox' name='tags[]' checked='checked' value='<?php echo $tag['tag']; ?> ' /><?php echo $tag['tag']; ?> </label> <?php } unset($tags); ?> </div> <a href="javascript:;" id="show-used-tags"><?php _e('Choose between most populars tags', 'admin_mywords'); ?> </a> <div id="popular-tags-container" style="display: none;"> <?php $tags = MWFunctions::get_tags('*', '', 'posts DESC', "0,{$xoopsModuleConfig['tags_widget_limit']}"); foreach ($tags as $tag) { ?> <a href="javascript:;" id="tag-<?php echo $tag['id_tag']; ?> " class="add_tag" style="font-size: <?php echo MWFunctions::get()->tag_font_size($tag['posts'], 2); ?> em;"><?php echo $tag['tag']; ?> </a> <?php } ?> </div> </form> </div> <?php $widget['content'] = ob_get_clean(); return $widget; }
/** * Imports a single article from Publisher */ public function article() { global $xoopsSecurity, $xoopsDB; $this->prepare_ajax_response(); $functions = MWFunctions::get(); if (!$xoopsSecurity->check(true, false, 'CUTOKEN')) { $this->ajax_response(__('Session token not valid!', 'mywords'), 1, 0); } $id = RMHttpRequest::post('id', 'integer', 0); if ($id <= 0) { $this->ajax_response(sprintf(__('Article ID %u is not valid!', 'mywords'), $id), 0, 1, ['result' => 'error']); } $sql = "SELECT * FROM " . $xoopsDB->prefix("publisher_items") . " WHERE itemid = {$id}"; $result = $xoopsDB->query($sql); if ($xoopsDB->getRowsNum($result)) { if ($id <= 0) { $this->ajax_response(sprintf(__('Article with ID %u was not found!', 'mywords'), $id), 0, 1, ['result' => 'error']); } } $row = $xoopsDB->fetchArray($result); $cache = $this->loadCache(); $post = new MWPost(); $post->setVar('title', $row['title']); $post->setVar('shortname', TextCleaner::getInstance()->sweetstring($row['title'])); $post->setVar('content', $row['body']); switch ($row['status']) { case 1: case 4: $status = 'pending'; break; case 2: $status = 'publish'; break; case 3: $status = 'draft'; break; } $post->setVar('status', $status); $post->setVar('visibility', 'public'); $post->setVar('author', $row['uid']); $post->setVar('comstatus', 1); $post->setVar('pubdate', $row['datesub']); $post->setVar('created', $row['datesub']); $post->setVar('reads', $row['counter']); $post->setVar('description', $row['summary']); $post->setVar('keywords', $row['meta_keywords']); $post->setVar('format', 'post'); if (isset($cache['categories'][$row['categoryid']])) { $post->add_categories($cache['categories'][$row['categoryid']]); } unset($row); if (!$post->save()) { $this->ajax_response(sprintf(__('Article %s could not be saved!', 'mywords'), $post->title), 0, 1, ['result' => 'error']); } $this->ajax_response(sprintf(__('Article %s imported successfully!', 'mywords'), '<strong>' . $post->title . '</strong>'), 0, 1, ['result' => 'success']); }
/** * @desc Genera la información para mostrar la Sindicación * @param int Limite de resultados * @return Array */ function &mywords_rssshow($limit) { global $util, $mc; $db = XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwcategory.class.php'; include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; foreach ($_GET as $k => $v) { ${$k} = $v; } $feed = array(); // Información General $ret = array(); $mc =& $util->moduleConfig('mywords'); if ($show == 'all') { $feed['title'] = htmlspecialchars(_MI_MW_RSSNAME); $feed['link'] = XOOPS_URL . '/modules/mywords'; $feed['description'] = htmlspecialchars($util->filterTags($mc['rssdesc'])); $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE aprovado='1' AND estado>'0' ORDER BY modificado DESC LIMIT 0,{$limit}"; } else { if ($id == '') { return; } $cat = new MWCategory($id); if ($cat->isNew()) { return; } $feed['title'] = sprintf(_MI_MW_RSSNAMECAT, $cat->getName()); $feed['link'] = $cat->getLink(); $feed['description'] = $cat->getDescription(); $sql = "SELECT b.* FROM " . $db->prefix("mw_catpost") . " a," . $db->prefix("mw_posts") . " b WHERE a.cat='" . $cat->getID() . "' AND b.id_post=a.post AND b.aprovado='1' AND b.estado>'0' ORDER BY b.modificado DESC LIMIT 0,{$limit}"; } // Generamos los elementos $result = $db->query($sql); $posts = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $rtn = array(); $rtn['title'] = $post->getTitle(); $rtn['link'] = $post->getPermaLink(); $rtn['description'] = xoops_utf8_encode(htmlspecialchars($post->getHomeText(), ENT_QUOTES)); $rtn['pubDate'] = formatTimestamp($post->getDate()); $posts[] = $rtn; } $ret = array('feed' => $feed, 'items' => $posts); return $ret; }
// Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- header('Content-Type: text/xml'); require '../../mainfile.php'; load_mod_locale('mywords'); global $xoopsLogger; $xoopsLogger->renderingEnabled = false; error_reporting(0); $xoopsLogger->activated = false; $id = rmc_server_var($_REQUEST, 'trackback', 0); if ($id <= 0) { die; } $post = new MWPost($id); if ($post->isNew()) { die; } $editor = new MWEditor($post->getVar('author')); if ($editor->isNew()) { $user = new XoopsUser($post->getVar('author')); } $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;
// Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- /** * This file execute the pings for a given post */ require '../../mainfile.php'; global $xoopsLogger; $xoopsLogger->renderingEnabled = false; error_reporting(0); $xoopsLogger->activated = false; $id = rmc_server_var($_GET, 'post', 0); if ($id <= 0) { die; } $post = new MWPost($id); if ($post->isNew()) { die; } $editor = new MWEditor($post->getVar('author')); if ($editor->isNew()) { $user = new XoopsUser($post->getVar('author')); } $tracks = $post->getVar('toping'); if (empty($tracks)) { die; } $pinged = $post->getVar('pinged'); $toping = $post->getVar('toping'); $tp = array(); $tback = new MWTrackback($xoopsModuleConfig['blogname'], $editor->isNew() ? $user->getVar('uname') : $editor->getVar('name'));
return_error(__('You must provide a valid post ID', 'mywords'), 0, 'posts.php'); die; } $post = new MWPost($id); if ($post->isNew()) { return_error(__('You must provide an existing post ID', 'mywords'), 0, 'posts.php'); die; } if (!$editor->id() == $post->getVar('author') && !$xoopsUser->isAdmin()) { return_error(__('You are not allowed to do this action!', 'mywords'), false, MW_URL); } $query = 'op=edit&id=' . $id; $edit = true; } else { $query = 'op=new'; $post = new MWPost(); $edit = false; } /** * @todo Insert code to verify token */ // Verify title if ($title == '') { return_error(__('You must provide a title for this post', 'mywords'), true); die; } if (!isset($shortname) || $shortname == '') { $shortname = TextCleaner::getInstance()->sweetstring($title); } else { $shortname = TextCleaner::getInstance()->sweetstring($shortname); }
/** * Publish widget * @return array */ function mw_widget_publish() { global $xoopsUser; RMTemplate::get()->add_style('publish_widget.css', 'mywords'); RMTemplate::get()->add_style('forms.css', 'rmcommon'); RMTemplate::get()->add_style('jquery.css', 'rmcommon'); RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/scripts.php?file=posts.js'); RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/mktime.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/forms.js'); $widget['title'] = __('Publish', 'mywords'); $widget['icon'] = ''; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0; $edit = false; if ($id > 0) { $post = new MWPost($id); if ($post->isNew()) { unset($post); } else { $edit = true; } } if ($edit) { switch ($post->getVar('status')) { case 'draft': $status = __('Draft', 'mywords'); break; case 'pending': $status = __('Pending review', 'mywords'); break; case 'publish': $status = __('Published', 'mywords'); break; case 'scheduled': $status = __('Scheduled', 'mywords'); break; } $visibility = $post->getVar('visibility') == 'public' ? 'Public' : ($post->getVar('visibility') == 'password' ? 'Password Protected' : 'Private'); } else { $status = 'Published'; $visibility = 'Public'; } ob_start(); ?> <div class="rmc_widget_content_reduced publish_container"> <form id="mw-post-publish-form"> <!-- Opciones de Publicación --> <div class="publish_options"> <?php _e('Status:', 'mywords'); ?> <strong id="publish-status-legend"><?php _e($status, 'mywords'); ?> </strong> <a href="javascript:;" id="edit-publish"><?php _e('Edit', 'mywords'); ?> </a> <div id="publish-options" style="display: none;"> <select name="status" id="status"> <option value="publish"<?php echo $edit && $post->getVar('status') == 'publish' ? 'selected="selected"' : ($edit ? '' : 'selected="selected"'); ?> ><?php _e('Published', 'mywords'); ?> </option> <option value="draft"<?php echo $edit && $post->getVar('status') == 'draft' ? 'selected="selected"' : ''; ?> ><?php _e('Draft', 'mywords'); ?> </option> <option value="pending"<?php echo $edit && $post->getVar('status') == 'pending' ? 'selected="selected"' : ''; ?> ><?php _e('Pending Review', 'mywords'); ?> </option> </select> <input type="button" name="publish-ok" id="publish-ok" class="button" value="<?php _e('Apply', 'mywords'); ?> " /><br /> <a href="javascript:;" onclick="$('#publish-options').slideUp('slow'); $('#edit-publish').show();"><?php _e('Cancel', 'mywords'); ?> </a> </div> </div> <!-- //Opciones de Publicación --> <!-- Visibilidad --> <div class="publish_options"> <?php _e('Visibility:', 'mywords'); ?> <strong id="visibility-caption"><?php _e($visibility, 'mywords'); ?> </strong> <a href="javascript:;" id="visibility-edit"><?php _e('Edit', 'mywords'); ?> </a> <?php if (!$edit) { $visibility = 'public'; } else { $visibility = $post->getVar('visibility'); } ?> <div id="visibility-options"> <input type="radio" name="visibility" value="public" id="visibility-public"<?php echo $visibility == 'public' ? ' checked="checked"' : ''; ?> /> <label for="visibility-public"><?php _e('Public', 'mywords'); ?> </label><br /> <input type="radio" name="visibility" value="password" id="visibility-password"<?php echo $visibility == 'password' ? ' checked="checked"' : ''; ?> /> <label for="visibility-password"><?php _e('Password protected', 'mywords'); ?> </label><br /> <span id="vis-password-text" style="<?php _e($visibility == 'password' ? '' : 'display: none'); ?> "> <label> <?php _e('Password:'******'mywords'); ?> <input type="text" name="vis_password" id="vis-password" value="<?php echo $edit ? $post->getVar('password') : ''; ?> " class="options_input" /> </label> <br /></span> <input type="radio" name="visibility" value="private" id="visibility-private"<?php echo $visibility == 'private' ? ' checked="checked"' : ''; ?> /> <label for="visibility-private"><?php _e('Private', 'mywords'); ?> </label><br /><br /> <input type="button" name="vis-button" id="vis-button" value="<?php _e('Apply', 'mywords'); ?> " class="button" /> <a href="javascript:;" id="vis-cancel"><?php _e('Cancel', 'mywords'); ?> </a> </div> </div> <!-- /Visibilidad --> <!-- Schedule --> <div class="publish_options"> <?php _e('Publish', 'mywords'); ?> <strong id="schedule-caption"><?php echo $edit ? $post->getVar('pubdate') > 0 ? __('Inmediatly', 'mywords') : date("d, M Y \\@ H:i", $post->getVar('schedule')) : __('Inmediatly', 'mywords'); ?> </strong> <a href="javascript:;" class="edit-schedule"><?php _e('Edit', 'mywords'); ?> </a> <div class="schedule-options" style="display: none;"> <?php // Determinamos la fecha correcta $time = $edit ? $post->getVar('pubdate') > 0 ? $post->getVar('pubdate') : $post->getVar('schedule') : time(); $day = date("d", $time); $month = date("n", $time); $year = date("Y", $time); $hour = date("H", $time); $minute = date("i", $time); $months = array(__('Jan', 'mywords'), __('Feb', 'mywords'), __('Mar', 'mywords'), __('Apr', 'mywords'), __('May', 'mywords'), __('Jun', 'mywords'), __('Jul', 'mywords'), __('Aug', 'mywords'), __('Sep', 'mywords'), __('Oct', 'mywords'), __('Nov', 'mywords'), __('Dec', 'mywords')); ?> <input type="text" name="schedule_day" id="schedule-day" size="2" maxlength="2" value="<?php _e($day); ?> " /> <select name="schedule_month" id="schedule-month"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php _e($i); ?> " "<?php if ($month == $i) { echo 'selected="selected"'; } ?> "><?php _e($months[$i - 1]); ?> </option> <?php } ?> </select> <input type="text" name="schedule_year" id="schedule-year" size="2" maxlength="4" value="<?php _e($year); ?> " /> @ <input type="text" name="schedule_hour" id="schedule-hour" size="2" maxlength="2" value="<?php _e($hour); ?> " /> : <input type="text" name="schedule_minute" id="schedule-minute" size="2" maxlength="2" value="<?php _e($minute); ?> " /><br /><br /> <input type="button" class="button" name="schedule-ok" id="schedule-ok" value="<?php _e('Apply', 'mywords'); ?> " /> <a href="javascript:;" class="schedule-cancel"><?php _e('Cancel', 'mywords'); ?> </a> <input type="hidden" name="schedule" id="schedule" value="<?php _e("{$day}-{$month}-{$year}-{$hour}-{$minute}"); ?> " /> </div> </div> <!-- /Shedule --> <div class="publish_options no_border"> <?php _e('Author:', 'mywords'); $user = new RMFormUser('', 'author', 0, $edit ? array($post->getVar('author')) : array($xoopsUser->uid())); if (!$xoopsUser->isAdmin()) { $user->button(false); } echo $user->render(); ?> </div> <div class="widget_button"> <input type="submit" value="<?php _e($edit ? 'Update Post' : 'Publish', 'mywords'); ?> " class="button default" id="publish-submit" /> </div> </form> </div> <?php $widget['content'] = ob_get_clean(); return $widget; }
if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) { $page = 1; } else { $page = $path[$srh + 1]; } } else { $page = 1; } } $post->add_read(); // Navegación entre artículos if ($xoopsModuleConfig['shownav']) { $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE id_post<" . $post->id() . " AND status='publish' ORDER BY id_post DESC LIMIT 0, 1"; $result = $db->query($sql); $pn = new MWPost(); // Anterior if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('prev_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } // Siguiente $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())) {
/** * Categories widget */ function mw_widget_categories() { global $xoopsUser, $allowed_cats; $widget['title'] = __('Categories', 'admin_mywords'); $widget['icon'] = ''; $id = rmc_server_var($_REQUEST, 'id', 0); $postcat = array(); $edit = false; if ($id > 0) { $post = new MWPost($id); if ($post->isNew()) { unset($post); $postcat = array(); } else { $edit = true; $postcat = $post->get_categos(true); } } ob_start(); ?> <div class="rmc_widget_content_reduced"> <form id="mw-post-categos-form"> <div class="w_categories" id="w-categos-container"> <?php $categories = array(); MWFunctions::categos_list($categories); foreach ($categories as $catego) { ?> <label class="cat_label" style="padding-left: <?php echo $catego['indent'] * 10; ?> px;"><input type="checkbox" name="categories[]" id="categories[]" value="<?php echo $catego['id_cat']; ?> "<?php echo in_array($catego['id_cat'], $postcat) ? ' checked="checked"' : ''; ?> /> <?php echo $catego['name']; ?> </label> <?php } ?> </div> <?php if ($xoopsUser->isAdmin() || $allowed_cats) { ?> <div class="w_catnew_container"> <a href="javascript:;" id="a-show-new"><strong><?php _e('+ Add Categories', 'admin_mywords'); ?> </strong></a> <div id="w-catnew-form"> <label class="error" style="display: none;" for="w-name"><?php _e('Please provide a name', 'admin_mywords'); ?> </label> <input type="text" name="name" id="w-name" value="" class="required" /> <select name="parent" id="w-parent"> <option value="0"><?php _e('Parent category', 'admin_mywords'); ?> </option> <?php foreach ($categories as $catego) { ?> <option value="<?php _e($catego['id_cat']); ?> "><?php _e($catego['name']); ?> </option> <?php } ?> </select> <input type="button" id="create-new-cat" value="<?php _e('Add', 'admin_mywords'); ?> " /> <a href="javascript:;"><?php _e('Cancel', 'admin_mywords'); ?> </a> </div> </div> <?php } ?> </form> </div> <?php $widget['content'] = ob_get_clean(); return $widget; }
public function get_filtered_posts($where = '', $start = 0, $limit = 1, $orderby = 'pubdate', $sort = 'desc', $status = 'publish') { $path = XOOPS_ROOT_PATH . '/modules/mywords'; include_once $path . '/class/mwpost.class.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mw_posts"); if ($where != '') { $sql .= " WHERE {$where}"; } if ($status != '') { $sql .= $where != '' ? " AND status='{$status}'" : " WHERE status='{$status}'"; } if ($orderby != '') { $sql .= " ORDER BY {$orderby}"; } if ($sort != '') { $sql .= " {$sort}"; } $sql .= " LIMIT {$start},{$limit}"; //echo $sql; $result = $db->query($sql); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $ret[] = $post; } return $ret; }
return_error(__('You must provide a valid post ID', 'mywords'), 0, 'posts.php'); die; } $post = new MWPost($id); if ($post->isNew()) { return_error(__('You must provide an existing post ID', 'mywords'), 0, 'posts.php'); die; } if (!$editor->id() == $post->getVar('author') && !$xoopsUser->isAdmin()) { return_error(__('You are not allowed to do this action!', 'mywords'), false, MW_URL); } $query = 'op=edit&id=' . $id; $edit = true; } else { $query = 'op=new'; $post = new MWPost(); $edit = false; } /** * @todo Insert code to verify token */ // Verify title if ($title == '') { return_error(__('You must provide a title for this post', 'mywords'), true); die; } if (!isset($shortname) || $shortname == '') { $shortname = TextCleaner::getInstance()->sweetstring($title); } else { $shortname = TextCleaner::getInstance()->sweetstring($shortname); }
/** * Elimina un artículo de la base de datos */ function deletePost() { global $xoopsSecurity; $posts = rmc_server_var($_POST, 'posts', array()); if (empty($posts)) { redirectMsg('posts.php', __('Select one post at least!', 'mywords'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('posts.php', __('Session token expired!', 'mywords'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE id_post IN (" . implode(",", $posts) . ")"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); if (!$post->delete()) { showMessage(sprintf(__('Errors ocurred while deleting "%s"', 'mw_categories'), $post->getVar('title')), 1); } RMFunctions::delete_comments('mywords', urlencode('post=' . $post->id())); } redirectMsg('posts.php', __('Database updated!', 'mw_categories'), 0); }
// $Id$ // -------------------------------------------------------------- // MyWords // Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_ROOT_PATH')) { header('location: ./'); die; } // Authors cache $authors = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $link = $post->permalink(); # Generamos el vínculo para el autor if ($post->getVar('author') > 0) { if (!isset($authors[$post->getVar('author')])) { $authors[$post->getVar('author')] = new MWEditor($post->getVar('author')); } $author = $authors[$post->getVar('author')]; $alink = $author->permalink(); } else { $alink = '';