示例#1
0
 /**
  * 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;
 }
示例#2
0
/**
 * 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;
}
示例#3
0
    unset($edit);
}
$xoopsTpl->assign('lang_reads', sprintf(__('%u views', 'mywords'), $post->getVar('reads')));
// Tags
$tags = $post->tags(true);
$tags_list = '';
foreach ($tags as $i => $tag) {
    $tags_list .= ($tags_list == '' ? '' : ', ') . '<a href="' . $tag->permalink() . '">' . $tag->getVar('tag') . '</a>';
}
// Post pages
$total_pages = $post->total_pages();
$nav = new RMPageNav($total_pages, 1, $page, 5);
$nav->target_url($post->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&amp;page={PAGE_NUM}'));
$xoopsTpl->assign('post_navbar', $nav->render(true));
// Post data
$post_arr = array('id' => $post->id(), 'title' => $post->getVar('title'), 'published' => sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate')), date('H:i', $post->getVar('pubdate')), '<a href="' . $editor->permalink() . '">' . (isset($editor) ? $editor->getVar('name') : __('Anonymous', 'mywords')) . "</a>"), 'text' => $post->content(false, $page), 'cats' => $post->get_categories_names(), 'tags' => $tags_list, 'trackback' => $post->getVar('pingstatus') ? MWFunctions::get_url(true) . $post->id() : '', 'meta' => $post->get_meta('', false), 'time' => $post->getVar('pubdate'), 'image' => $post->getImage($xoopsModuleConfig['post_imgs_size']), 'author' => $editor->getVar('name'), 'alink' => $editor->permalink());
// Plugins?
$post_arr = RMEvents::get()->run_event('mywords.view.post', $post_arr, $post);
$xoopsTpl->assign('post', $post_arr);
// Social sites
if ($xoopsModuleConfig['showbookmarks']) {
    foreach ($socials as $site) {
        $xoopsTpl->append('socials', array('title' => $site->getVar('title'), 'icon' => $site->getVar('icon'), 'url' => $site->link($post->getVar('title'), $post->permalink(), TextCleaner::truncate($post->content(true), 60)), 'alt' => $site->getVar('alt')));
    }
}
unset($tags_list);
// Comments
// When use the common utilities comments system you can choose between
// use of Common Utilities templates or use your own templates
// We will use MyWords included templates
if ($post->getVar('comstatus')) {
示例#4
0
$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'));
foreach ($tracks as $t) {
    if (!empty($pinged) && in_array($t, $pinged)) {
        continue;
    }
    $ret = $tback->ping($t, $post->permalink(), $post->getVar('title'), TextCleaner::getInstance()->truncate($post->content(true), 240));
    if ($ret) {
        $pinged[] = $t;
    } else {
        $tp[] = $t;
    }
}
$post->setVar('toping', empty($tp) ? '' : $tp);
$post->setVar('pinged', $pinged);
$post->update();
die;
示例#5
0
            $editors[$post->getVar('author')]->uid = $user->uid();
            $editors[$post->getVar('author')]->name = $user->getVar('name');
            $editors[$post->getVar('author')]->shortname = $user->getVar('uname');
            $editors[$post->getVar('author')]->privileges = array('tags', 'tracks', 'comms');
            $editors[$post->getVar('author')]->save();
        }
        $editor = $editors[$post->getVar('author')];
        $alink = $editor->permalink();
    } else {
        $alink = '';
    }
    # Información de Publicación
    $published = sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate'), 'string'), '<a href="' . $alink . '">' . (isset($editor) ? $editor->name : __('Anonymous', 'mywords')) . "</a>");
    # Texto de continuar leyendo
    if ($post->getVar('visibility') == 'password') {
        $text = isset($_SESSION['password-' . $post->id()]) && $_SESSION['password-' . $post->id()] == $post->getVar('password') ? $post->content(true) : MWFunctions::show_password($post);
    } else {
        $text = $post->content(true);
    }
    // Redes Sociales
    if ($xoopsModuleConfig['showbookmarks']) {
        $bms = array();
        foreach ($socials as $bm) {
            $bms[] = array('icon' => $bm->getVar('icon'), 'alt' => $bm->getVar('alt'), 'link' => str_replace(array('{URL}', '{TITLE}', '{DESC}'), array($post->permalink(), $post->getVar('title'), TextCleaner::getInstance()->truncate($text, 50)), $bm->getVar('url')));
        }
    }
    $xoopsTpl->append('posts', array('id' => $post->id(), 'title' => $post->getVar('title'), 'format' => $post->getVar('format'), 'text' => $text, 'description' => $post->getVar('description'), 'keywords' => $post->getVar('keywords'), 'cats' => $post->get_categos('data'), 'link' => $link, 'published' => $published, 'comments' => $post->getVar('comments'), 'lang_comments' => sprintf(__('%u Comments', 'mywords'), $post->getVar('comments')), 'continue' => $post->hasmore_text(), 'lang_continue' => $post->hasmore_text() ? sprintf(__('Read more about "%s"', 'mywords'), $post->getVar('title')) : '', 'bookmarks' => $bms, 'time' => $post->getVar('pubdate'), 'author' => array('name' => $editor->name != '' ? $editor->name : $editor->shortname, 'id' => $editor->id(), 'link' => $editor->permalink(), 'bio' => $editor->getVar('bio'), 'email' => $editor->data('email'), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $editor->data('email'))), 'alink' => $alink, 'edit' => $xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid()), 'tags' => $post->tags(false), 'meta' => $post->get_meta('', false), 'image' => $post->image(), 'video' => $post->video, 'player' => $post->format == 'video' ? $post->video_player() : ''));
}
$xoopsTpl->assign('lang_editpost', __('Edit Post', 'mywords'));
$xoopsTpl->assign('lang_postedin', __('Posted in:', 'mywords'));
$xoopsTpl->assign('lang_taggedas', __('Tagged as:', 'mywords'));
示例#6
0
}
$xoopsTpl->assign('shownav', $xoopsModuleConfig['shownav']);
if ($xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid())) {
    $editLink = XOOPS_URL . '/modules/mywords/admin/posts.php?op=edit&amp;id=' . $post->id();
    $xoopsTpl->assign('can_edit', true);
    $xoopsTpl->assign('edit_link', $editLink);
    unset($editLink);
}
$xoopsTpl->assign('lang_reads', sprintf(__('%u views', 'mywords'), $post->getVar('reads')));
// Post pages
$total_pages = $post->total_pages();
$nav = new RMPageNav($total_pages, 1, $page, 5);
$nav->target_url($post->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&amp;page={PAGE_NUM}'));
$xoopsTpl->assign('post_navbar', $nav->render(true));
// Post data
$post_arr = array('id' => $post->id(), 'title' => $post->getVar('title'), 'published' => sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate')) . ' ' . date('H:i', $post->getVar('pubdate')), '<a href="' . $editor->permalink() . '">' . (isset($editor) ? $editor->getVar('name') : __('Anonymous', 'mywords')) . "</a>"), 'text' => $post->content(false, $page), 'cats' => $post->get_categos('data'), 'tags' => $post->tags(false), 'trackback' => $post->getVar('pingstatus') ? MWFunctions::get_url(true) . $post->id() : '', 'meta' => $post->get_meta('', false), 'time' => $post->getVar('pubdate'), 'image' => $post->image(), 'video' => $post->video, 'player' => $post->video != '' ? $post->video_player() : '', 'author' => array('name' => $editor->getVar('name') != '' ? $editor->name : $editor->shortname, 'id' => $editor->id(), 'link' => $editor->permalink(), 'bio' => $editor->getVar('bio'), 'email' => $editor->data('email'), 'uid' => $editor->uid, 'url' => $editor->data('url')), 'alink' => $editor->permalink(), 'format' => $post->format, 'comments' => $post->comments, 'comments_enabled' => $post->comstatus);
$xoopsTpl->assign('full_post', 1);
$xoopsTpl->assign('lang_editpost', __('Edit Post', 'mywords'));
$xoopsTpl->assign('lang_postedin', __('Posted in:', 'mywords'));
$xoopsTpl->assign('lang_taggedas', __('Tagged as:', 'mywords'));
$xoopsTpl->assign('enable_images', $xoopsModuleConfig['list_post_imgs']);
// Plugins?
$post_arr = RMEvents::get()->run_event('mywords.view.post', $post_arr, $post);
$xoopsTpl->assign('post', $post_arr);
// Related posts
if ($xoopsModuleConfig['related']) {
    $rtags = $post->tags();
    $tt = array();
    foreach ($rtags as $tag) {
        $tt[] = $tag['id_tag'];
    }