Esempio n. 1
0
 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 = 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;
 }
Esempio n. 3
0
/**
* @desc Muestra el formulario para agregar un nuevo sitio
*/
function edit_bookmark()
{
    global $xoopsModule, $xoopsConfig, $xoopsSecurity, $rmTpl;
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        redirectMsg('bookmarks.php', __('Site ID not provided!', 'mywords'), 1);
        die;
    }
    $book = new MWBookmark($id);
    if ($book->isNew()) {
        redirectMsg('bookmarks.php', __('Social site not exists!', 'mywords'), 1);
        die;
    }
    $temp = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/mywords/images/icons');
    foreach ($temp as $icon) {
        $icons[] = array('url' => XOOPS_URL . "/modules/mywords/images/icons/{$icon}", 'name' => $icon);
    }
    MWFunctions::include_required_files();
    RMBreadCrumb::get()->add_crumb(__('Social Sites', 'mywords'), 'bookmarks.php');
    RMBreadCrumb::get()->add_crumb(__('Edit Site', 'mywords'));
    xoops_cp_header();
    $show_edit = true;
    include $rmTpl->get_template('admin/mywords_bookmarks.php', 'module', 'mywords');
    $rmTpl->assign('xoops_pagetitle', __('Edit Social Site', 'mywords'));
    $rmTpl->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    $rmTpl->add_script('../include/js/scripts.php?file=bookmarks.js');
    xoops_cp_footer();
}
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
function mywordsBlockRecentEdit($options)
{
    $options[5] = isset($options[5]) ? $options[5] : 0;
    $form = '<strong>' . __('Posts Number:', 'mywords') . '</strong><br />
            <input type="text" size="10" value="' . $options[0] . '" name="options[0]" /><br /><br />
            <strong>' . __('Block type:', 'mywords') . '</strong><br />
            <label><input type="radio" name="options[1]"' . (!isset($options[1]) || $options[1] == 'recent' ? ' checked="checked"' : '') . ' value="recent" />
            ' . __('Recent Posts', 'mywords') . '</label>
            <label><input type="radio" name="options[1]"' . (isset($options[1]) && $options[1] == 'popular' ? ' checked="checked"' : '') . ' value="popular" />
            ' . __('Popular Posts', 'mywords') . '</label>
            <label><input type="radio" name="options[1]"' . (isset($options[1]) && $options[1] == 'comm' ? ' checked="checked"' : '') . ' value="comm" />
            ' . __('Most Commented', 'mywords') . '</label><br /><br />
            <strong>' . __('Show text:', 'mywords') . '</strong><br />
            <label><input type="radio" name="options[2]" value="1"' . (isset($options[2]) && $options[2] == 1 ? ' checked="checked"' : '') . ' /> ' . __('Yes', 'mywords') . '</label> 
            <label><input type="radio" name="options[2]" value="0"' . (!isset($options[2]) || $options[2] == 0 ? ' checked="checked"' : '') . ' /> ' . __('No', 'mywords') . '</label>
            <br /><br />
            <strong>Text lenght:</strong> <input type="text" size="10" value="' . (isset($options[3]) ? $options[3] : 50) . '" name="options[3]" />
            <br /><br /><strong>' . __('Show date:', 'mywords') . '</strong> 
            <label><input type="radio" name="options[4]" value="1"' . (isset($options[4]) && $options[4] == 1 ? ' checked="checked"' : '') . ' /> ' . __('Yes', 'mywords') . '</label> 
            <label><input type="radio" name="options[4]" value="0"' . (!isset($options[4]) || $options[4] == 0 ? ' checked="checked"' : '') . ' /> ' . __('No', 'mywords') . '</label>
            <br /><br />';
    $cats = array();
    MWFunctions::categos_list($cats);
    $form .= '<strong>' . __('Posts form category:', 'mywords') . '</strong><br />
            <select name="options[5]">
            <option value="0"' . ($options[5] == 0 ? ' selected="selected"' : '') . '>' . __('Select category...', 'mywords') . '</option>';
    foreach ($cats as $cat) {
        $form .= '<option value="' . $cat['id_cat'] . '"' . ($options[5] == $cat['id_cat'] ? ' selected="selected"' : '') . '>' . str_repeat("&#8212;", $cat['indent']) . $cat['name'] . '</option>';
    }
    $form .= "</select><br /><br />";
    return $form;
}
Esempio n. 8
0
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';
}
Esempio n. 9
0
function show_mw_trackbacks()
{
    global $xoopsModule, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("mw_trackbacks");
    if ($id > 0) {
        $sql .= "WHERE post={$id}";
    }
    list($num) = $db->fetchRow($db->query($sql));
    $page = rmc_server_var($_GET, 'page', 1);
    $limit = isset($limit) && $limit > 0 ? $limit : 15;
    $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('trackbacks.php?page={PAGE_NUM}' . ($id > 0 ? '&amp;id=' . $id : ''));
    $sql = str_replace("COUNT(*)", '*', $sql);
    $sql .= " ORDER BY `date` LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $posts = array();
    // posts cache
    $trackbacks = array();
    // Get trackbacks data
    while ($row = $db->fetchArray($result)) {
        $trac = new MWTrackbackObject();
        $trac->assignVars($row);
        $posts[$trac->getVar('post')] = isset($posts[$trac->getVar('post')]) ? $posts[$trac->getVar('post')] : new MWPost($trac->getVar('post'));
        $trackbacks[] = array('tb' => $trac, 'post' => array('title' => $posts[$trac->getVar('post')]->getVar('title'), 'link' => $posts[$trac->getVar('post')]->isNew() ? '' : $posts[$trac->getVar('post')]->permalink()));
    }
    // Event
    $trackbacks = RMEvents::get()->run_event("mywords.trackbacks.list", $trackbacks);
    MWFunctions::include_required_files();
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/scripts.php?file=trackbacks.js');
    xoops_cp_header();
    xoops_cp_location('<a href="' . XOOPS_URL . '/modules/mywords/admin/">' . $xoopsModule->getVar('name') . '</a> &raquo; ' . __('Trackbacks', 'mywords'));
    include RMTemplate::get()->get_template('admin/mywords_trackbacks.php', 'module', 'mywords');
    xoops_cp_footer();
}
Esempio n. 10
0
function edit_editor()
{
    global $xoopsModule, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    if ($id <= 0) {
        redirectMsg('editors.php?page=' . $page, __('Editor ID not provided!.', 'mywords'), 1);
        die;
    }
    $editor = new MWEditor($id);
    if ($editor->isNew()) {
        redirectMsg('editors.php?page=' . $page, __('Editor does not exists!', 'mywords'), 1);
        die;
    }
    include_once RMCPATH . '/class/form.class.php';
    MWFunctions::include_required_files();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; <a href="editors.php">' . __('Editors', 'mywords') . '</a> &raquo; ' . __('Editing Editor', 'mywords'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Editor', 'mywords'));
    xoops_cp_header();
    $show_edit = true;
    include RMTemplate::get()->get_template('admin/mywords_editors.php', 'module', 'mywords');
    xoops_cp_footer();
}
Esempio n. 11
0
function mywordsBlockCats($options)
{
    global $xoopsModuleConfig, $xoopsModule;
    $categos = array();
    MWFunctions::categos_list($categos, 0, 0, $options[0]);
    $block = array();
    $mc = $xoopsModule && $xoopsModule->getVar('dirname') == 'mywords' ? $xoopsModuleConfig : RMSettings::module_settings('mywords');
    foreach ($categos as $k) {
        $ret = array();
        $cat = new MWCategory();
        $cat->assignVars($k);
        $cat->loadPosts();
        $ret['id'] = $cat->id();
        $ret['name'] = $cat->getVar('name');
        if (isset($options[1]) && $options[1]) {
            $ret['posts'] = $cat->getVar('posts');
        }
        $ret['indent'] = $k['indent'] * 2;
        $ret['link'] = $cat->permalink();
        $block['categos'][] = $ret;
    }
    RMTemplate::get()->add_style('mwblocks.css', 'mywords');
    return $block;
}
Esempio n. 12
0
function edit_editor()
{
    global $xoopsModule, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    if ($id <= 0) {
        redirectMsg('editors.php?page=' . $page, __('Editor ID not provided!.', 'mywords'), 1);
        die;
    }
    $editor = new MWEditor($id);
    if ($editor->isNew()) {
        redirectMsg('editors.php?page=' . $page, __('Editor does not exists!', 'mywords'), 1);
        die;
    }
    include_once RMCPATH . '/class/form.class.php';
    MWFunctions::include_required_files();
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Editor', 'mywords'));
    RMBreadCrumb::get()->add_crumb(__('Editors Management', 'mywords'), 'editors.php');
    RMBreadCrumb::get()->add_crumb(__('Edit Editor', 'mywords'));
    xoops_cp_header();
    $show_edit = true;
    include RMTemplate::get()->get_template('admin/mywords-editors.php', 'module', 'mywords');
    xoops_cp_footer();
}
Esempio n. 13
0
function edit_form()
{
    global $xoopsModule, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    if ($id <= 0) {
        redirectMsg('tags.php?page=' . $page, __('Tag ID not provided!.', 'mywords'), 1);
        die;
    }
    $tag = new MWTag($id);
    if ($tag->isNew()) {
        redirectMsg('tags.php?page=' . $page, __('Tag does not exists!', 'mywords'), 1);
        die;
    }
    MWFunctions::include_required_files();
    RMBreadCrumb::get()->add_crumb(__('Tags management', 'mywords'), 'tags.php');
    RMBreadCrumb::get()->add_crumb(__('Edit tag', 'mywords'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Tag', 'mywords'));
    xoops_cp_header();
    $show_edit = true;
    include RMTemplate::get()->get_template('admin/mywords-tags.php', 'module', 'mywords');
    xoops_cp_footer();
}
Esempio n. 14
0
}
$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'));
/**
* 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;
}
Esempio n. 16
0
// 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++;
}
$socials = RMEvents::get()->run_event('mywords.loding.socials', $socials);
$tpl = RMTemplate::get();
// Update scheduled posts
MWFunctions::go_scheduled();
Esempio n. 17
0
    }
    $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';
Esempio n. 18
0
    $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;
}
Esempio n. 19
0
    $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');
RMTemplate::get()->add_script('scripts.php?file=posts.js', 'mywords', array('directory' => 'include'));
RMTemplate::get()->add_script('jquery.validate.min.js', 'rmcommon', array('footer' => 1));
include RMTemplate::get()->get_template('mywords-submit-form.php', 'module', 'mywords');
include 'footer.php';
Esempio n. 20
0
function edit_form()
{
    global $xoopsModule, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    if ($id <= 0) {
        redirectMsg('tags.php?page=' . $page, __('Tag ID not provided!.', 'mywords'), 1);
        die;
    }
    $tag = new MWTag($id);
    if ($tag->isNew()) {
        redirectMsg('tags.php?page=' . $page, __('Tag does not exists!', 'mywords'), 1);
        die;
    }
    MWFunctions::include_required_files();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; <a href="tags.php">' . __('Tags', 'mywords') . '</a> &raquo; ' . __('Edit Tag', 'mywords'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Tag', 'mywords'));
    xoops_cp_header();
    $show_edit = true;
    include RMTemplate::get()->get_template('admin/mywords_tags.php', 'module', 'mywords');
    xoops_cp_footer();
}
Esempio n. 21
0
/**
 * Presenta un formulario para la creación de una nueva
 * categoría para los artículos
 */
function newForm()
{
    global $xoopsModule;
    $id = isset($_GET['id']) ? $_GET['id'] : 0;
    if ($id <= 0) {
        redirectMsg('categories.php', __('You must specify a valid category', 'mywords'), 1);
        die;
    }
    // Cargamos la categoría
    $catego = new MWCategory($id);
    // Si no existe entonces devolvemos un error
    if ($catego->isNew()) {
        redirectMsg('cats.php', __('Specified category not exists!', 'mywords'), 1);
        die;
    }
    MWFunctions::include_required_files();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . __('New Category', 'mywords'));
    xoops_cp_header();
    $cats = array();
    MWFunctions::categos_list($cats, 0, 0, true, $id);
    $form = new RMForm($edit ? __('Edit Category', 'mywords') : __('Edit Category', 'mywords'), 'frmNew', 'categories.php');
    $form->styles('width: 30%;', 'odd');
    $form->addElement(new RMFormText(__('Category name', 'mywords'), 'name', 50, 150, $catego->getVar('name')), true);
    $form->addElement(new RMFormText(__('Category slug', 'mywords'), 'shortname', '', '150', $catego->getVar('shortname', 'n')));
    $form->addElement(new RMFormTextArea(__('Category description', 'mywords'), 'desc', 5, 45, $catego->getVar('description', 'e')));
    $ele = new RMFormSelect(__('Category Parent', 'mywords'), 'parent');
    $ele->addOption(0, _SELECT, $catego->getVar('parent') == 0 ? 1 : 0);
    foreach ($cats as $k) {
        $ele->addOption($k['id_cat'], str_repeat("-", $k['indent']) . ' ' . $k['name'], $catego->getVar('parent') == $k['id_cat'] ? 1 : 0);
    }
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', 'saveedit'));
    $form->addElement(new RMFormHidden('id', $id));
    $ele = new RMFormButtonGroup('', ' ');
    $ele->addButton('sbt', __('Update Category', 'mywords'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'mywords'), 'button');
    $ele->setExtra('cancel', "onclick='history.go(-1);'");
    $form->addElement($ele);
    $form->display();
    xoops_cp_footer();
}
Esempio n. 22
0
function mywordsBlockRecentEdit($options)
{
    $options[5] = isset($options[5]) ? $options[5] : 0;
    ob_start();
    $cats = array();
    MWFunctions::categos_list($cats);
    ?>

    <div class="form-horizontal">
        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Posts Number:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <input type="text" size="10" value="<?php 
    echo $options[0];
    ?>
" name="options[0]" />
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Block type:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <label class="radio">
                    <input type="radio" name="options[1]"<?php 
    echo !isset($options[1]) || $options[1] == 'recent' ? ' checked="checked"' : '';
    ?>
 value="recent" />
                    <?php 
    _e('Recent Posts', 'mywords');
    ?>
                </label>
                <label class="radio">
                    <input type="radio" name="options[1]"<?php 
    echo !isset($options[1]) || $options[1] == 'popular' ? ' checked="checked"' : '';
    ?>
 value="popular" />
                    <?php 
    _e('Popular Posts', 'mywords');
    ?>
                </label>
                <label class="radio">
                    <input type="radio" name="options[1]"<?php 
    echo !isset($options[1]) || $options[1] == 'comm' ? ' checked="checked"' : '';
    ?>
 value="comm" />
                    <?php 
    _e('Most Commented', 'mywords');
    ?>
                </label>
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Show text:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <label class="radio inline"><input type="radio" name="options[2]" value="1"<?php 
    echo isset($options[2]) && $options[2] == 1 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('Yes', 'mywords');
    ?>
</label>
                <label class="radio inline"><input type="radio" name="options[2]" value="0"<?php 
    echo !isset($options[2]) || $options[2] == 0 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('No', 'mywords');
    ?>
</label>
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Text length:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <input type="text" size="10" value="<?php 
    echo isset($options[3]) ? $options[3] : 50;
    ?>
" name="options[3]" />
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Show date:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <label class="radio inline"><input type="radio" name="options[4]" value="1"<?php 
    echo isset($options[4]) && $options[4] == 1 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('Yes', 'mywords');
    ?>
</label>
                <label class="radio inline"><input type="radio" name="options[4]" value="0"<?php 
    echo !isset($options[4]) || $options[4] == 0 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('No', 'mywords');
    ?>
</label>
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Posts from category:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <select name="options[5]">
                    <option value="0"<?php 
    echo $options[5] == 0 ? ' selected="selected"' : '';
    ?>
><?php 
    _e('Select category...', 'mywords');
    ?>
</option>';
                    <?php 
    foreach ($cats as $cat) {
        ?>
                    <option value="<?php 
        echo $cat['id_cat'];
        ?>
"<?php 
        echo $options[5] == $cat['id_cat'] ? ' selected="selected"' : '';
        ?>
><?php 
        echo str_repeat("&#8212;", $cat['indent']) . $cat['name'];
        ?>
</option>
                    <?php 
    }
    ?>
                </select>
            </div>

        </div>
    </div>

    <?php 
    $form = ob_get_clean();
    return $form;
}
Esempio n. 23
0
         $rss_items[] = $item;
     }
     break;
 case 'all':
 default:
     $rss_channel['title'] = sprintf(__('Posts in %s', 'mywords'), $xoopsConfig['sitename']);
     $rss_channel['link'] = XOOPS_URL . ($config->permalinks ? $config->basepath : '/modules/mywords');
     $rss_channel['description'] = __('All recent published posts', 'mywords');
     $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;
     // Get posts
     $posts = MWFunctions::get_posts(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'));
         if (!$img->isNew()) {
             $image = '<img src="' . $img->url() . '" alt="' . $post->getVar('title') . '" /><br />';
         } else {
             $image = '';
         }
         $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($image . $post->content(true), ENT_QUOTES));
         $item['pubdate'] = formatTimestamp($post->getVar('pubdate'), 'rss');
         $item['guid'] = $post->permalink();
Esempio n. 24
0
global $xoopsLogger;
$xoopsLogger->renderingEnabled = false;
error_reporting(0);
$xoopsLogger->activated = false;
extract($_POST);
if (!$xoopsSecurity->check() || !$xoopsSecurity->checkReferer()) {
    $ret = array('error' => __('You are not allowed to do this operation!', 'mywords'));
    echo json_encode($ret);
    die;
}
if (!isset($name) || $name == '') {
    $ret = array('error' => __('A name is neccesary to create a new category!', 'mywords'), 'token' => $xoopsSecurity->createToken());
    echo json_encode($ret);
    die;
}
$catego = new MWCategory();
$catego->setVar('name', $name);
$catego->setVar('shortname', TextCleaner::sweetstring($name));
$catego->setVar('parent', $parent);
if (MWFunctions::category_exists($catego)) {
    $ret = array('error' => __('There is already a category with same name!', 'mywords'), 'token' => $xoopsSecurity->createToken());
    echo json_encode($ret);
    die;
}
if (!$catego->save()) {
    $ret = array('error' => __('Category could not inserted!', 'mywords') . "\n" . $catego->errors(), 'token' => $xoopsSecurity->createToken());
    echo json_encode($ret);
    die;
}
$ret = array('message' => __('Category created successfully!', 'mywords'), 'token' => $xoopsSecurity->createToken(), 'id' => $catego->id());
echo json_encode($ret);
Esempio n. 25
0
 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;
 }
Esempio n. 26
0
    /**
     * Return the feed options to show in RSS Center
     */
    public function eventRmcommonGetFeedsList($feeds)
    {
        include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php';
        load_mod_locale('mywords');
        $module = RMFunctions::load_module('mywords');
        $config = RMUtilities::module_config('mywords');
        $data = array('title' => $module->name(), 'url' => XOOPS_URL . $config['basepath'], 'module' => 'mywords');
        $options[] = array('title' => __('All Recent Posts', 'mywords'), 'params' => 'show=all', 'description' => __('Show all recent posts', 'mywords'));
        $categories = array();
        MWFunctions::categos_list($categories);
        $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">';
        $count = 0;
        foreach ($categories as $cat) {
            if ($count >= 3) {
                $count = 0;
                $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">';
            }
            $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&amp;mod=mywords&amp;show=cat&amp;cat=' . $cat['id_cat'] . '">' . $cat['name'] . '</a></td>';
            $count++;
        }
        $table .= '</tr></table>';
        $options[] = array('title' => __('Posts by category', 'mywords'), 'description' => __('Select a category to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#categories-feed\').slideToggle(\'slow\');">Show Categories</a>
						    <div id="categories-feed" style="padding: 10px; display: none;">' . $table . '</div>');
        unset($categories);
        $tags = MWFunctions::get_tags("*", '', '', 99);
        $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">';
        $count = 0;
        foreach ($tags as $tag) {
            if ($count >= 3) {
                $count = 0;
                $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">';
            }
            $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&amp;mod=mywords&amp;show=tag&amp;tag=' . $tag['id_tag'] . '">' . $tag['tag'] . '</a></td>';
            $count++;
        }
        $table .= '</tr></table>';
        $options[] = array('title' => __('Show posts by tag', 'mywords'), 'description' => __('Select a tag to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#tags-feed\').slideToggle(\'slow\');">Show Tags</a>
						    <div id="tags-feed" style="padding: 10px; display: none;">' . $table . '</div>');
        unset($tags);
        $db = XoopsDatabaseFactory::getDatabaseConnection();
        $sql = "SELECT * FROM " . $db->prefix("mw_editors") . " ORDER BY name";
        $result = $db->query($sql);
        $editors = array();
        while ($row = $db->fetchArray($result)) {
            $editors[] = $row;
        }
        asort($editors);
        $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">';
        $count = 0;
        foreach ($editors as $ed) {
            if ($count >= 3) {
                $count = 0;
                $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">';
            }
            $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&amp;mod=mywords&amp;show=author&amp;author=' . $ed['id_editor'] . '">' . $ed['name'] . '</a></td>';
            $count++;
        }
        $table .= '</tr></table>';
        $options[] = array('title' => __('Show posts by author', 'mywords'), 'description' => __('Select an author to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#editor-feed\').slideToggle(\'slow\');">Show Authors</a>
						    <div id="editor-feed" style="padding: 10px; display: none;">' . $table . '</div>');
        unset($editors);
        unset($table);
        RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.min.js');
        RMTemplate::get()->add_script(RMCURL . '/include/js/jquery-ui.min.js');
        $feed = array('data' => $data, 'options' => $options);
        $feeds[] = $feed;
        return $feeds;
    }
Esempio n. 27
0
// $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'];
Esempio n. 28
0
<?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));
Esempio n. 29
0
/**
 * Muestra el formulario para la creación de un nuevo artículo
 */
function newForm($edit = 0)
{
    global $db, $xoopsModule, $myts, $util, $xoopsConfig, $tpl, $xoopsSecurity, $cuSettings;
    define('RMCSUBLOCATION', 'new_post');
    if ($edit) {
        $id = rmc_server_var($_GET, 'id', 0);
        if ($id <= 0) {
            redirectMsg('posts.php', __('Please, specify a valid post ID', 'mywords'), 1);
            die;
        }
        $post = new MWPost($id);
        if ($post->isNew()) {
            redirectMsg('posts.php', __('Specified post does not exists!', 'mywords'), 1);
            die;
        }
    }
    // Context help
    $tpl->add_help(__('Publish articles', 'mywords'), 'http://www.xoopsmexico.net/docs/mywords/publicar-entradas/');
    MWFunctions::include_required_files(false);
    RMBreadCrumb::get()->add_crumb(__('Posts', 'mywords'), 'posts.php');
    RMBreadCrumb::get()->add_crumb(__('Write post', 'mywords'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Write post', 'mywords'));
    $head = '<script type="text/javascript" src="' . MW_URL . '/include/forms_post.js"></script>';
    xoops_cp_header($head);
    include RMCPATH . '/class/form.class.php';
    /*include RMCPATH.'/class/fields/formelement.class.php';
      include RMCPATH.'/class/fields/editor.class.php';*/
    TinyEditor::getInstance()->add_config('elements', 'content_editor');
    //TinyEditor::getInstance()->add_config('theme_advanced_buttons1', 'bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,spellchecker,fullscreen,|,exm_more,exm_adv', true);
    //TinyEditor::getInstance()->add_config('theme_advanced_buttons2','formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,media,charmap,|,outdent,indent,|,undo,redo,|,exm_img,exm_icons,exm_page', true);
    //echo $post->getVar('content'); die();
    $editor = new RMFormEditor('', 'content', '100%', '350px', $edit ? $post->getVar('content', $cuSettings->editor_type == 'tiny' ? 's' : 'e') : '');
    // Get current metas
    $meta_names = MWFunctions::get()->get_metas();
    //RMTemplate::get()->add_script(RMCURL.'/include/js/jquery.validate.min.js');
    //RMTemplate::get()->add_script(RMCURL.'/include/js/forms.js');
    //RMTemplate::get()->add_head('<script type="text/javascript">$("form#mw-form-posts").validate();</script>');
    include '../templates/admin/mywords-formposts.php';
    xoops_cp_footer();
}
Esempio n. 30
0
    $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();
}
RMBreadCrumb::get()->add_crumb(__('Dashboard', 'mywords'));
include 'menu.php';
MWFunctions::include_required_files();
RMTemplate::get()->add_script('../include/js/scripts.php?file=dashboard.js');
RMTemplate::get()->add_help(__('MyWords Documentation', 'mywords'), 'http://www.xoopsmexico.net/docs/mywords/introduccion/');
// Other panels for dashboard
$dashboardPanels = [];
$dashboardPanels = RMEvents::get()->trigger('mywords.dashboard.panels', $dashboardPanels);
xoops_cp_header();
// Show Templates
RMTemplate::get()->add_body_class('dashboard');
//$tpl->header();
include RMtemplate::get()->get_template('admin/mywords-theindex.php', 'module', 'mywords');
//$tpl->footer();
xoops_cp_footer();