示例#1
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';
}
示例#2
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();
}
示例#3
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';
示例#4
0
    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);
}
// Check content
if ($content == '' && $format != 'image') {
    return_error(__('Content for this post has not been provided!', 'mywords'), true);
    die;
}
// Categories
if (!isset($categories) || empty($categories)) {
    $categories = array(MWFunctions::get()->default_category_id());
}
// Check publish options
if ($visibility == 'password' && $vis_password == '') {
    return_error(__('You must provide a password for this post or select another visibility option', 'mywords'), true);
    die;
}
$time = explode("-", $schedule);
$schedule = mktime($time[3], $time[4], 0, $time[1], $time[0], $time[2]);
if ($schedule <= time()) {
    $schedule = 0;
}
$editor = new MWEditor($xoopsUser->uid(), 'user');
if ($editor->isNew()) {
    $editor->setVar('uid', $xoopsUser->uid());
    $editor->setVar('shortname', $xoopsUser->getVar('uname'));
示例#5
0
/**
* Widget that show tags selection in a post form
*/
function mywords_widget_addtags($post = null)
{
    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'] = '';
    $edit = false;
    if (isset($post) && is_a($post, 'MWPost')) {
        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">
    <div class="input-group">
        <input type="text" name="tagsm" id="tags-m" class="form-control">
        <div class="input-group-btn">
            <button type="button" name="tags-button" id="tags-button" class="btn btn-info"><?php 
        _e('+ Add', 'admin_mywords');
        ?>
</button>
        </div>
    </div>
    <span class="help-block"><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;
}
示例#6
0
 /**
  * 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']);
 }
示例#7
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;
    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;
        }
    }
    MWFunctions::include_required_files();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . ($edit ? __('Editing post', 'mywords') : __('Creating a new 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', '99%', '300px', $edit ? $post->getVar('content', $rmc_config['editor_type'] != 'tiny' ? 'e' : 's') : '');
    // 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();
}