public static function editPost($x, $post_id, &$cur, $content, $struct, $publish) { # Check if we have mt_keywords in struct if (isset($struct['mt_keywords'])) { $meta = new dcMeta($x->core); $meta->delPostMeta($post_id, 'tag'); foreach ($meta->splitMetaValues($struct['mt_keywords']) as $m) { $meta->setPostMeta($post_id, 'tag', $m); } } }
public function process($do) { if ($do == 'ok') { $this->status = true; return; } if (empty($_POST['feed_url'])) { return; } $this->feed_url = $_POST['feed_url']; $feed = feedReader::quickParse($this->feed_url); if ($feed === false) { throw new Exception(__('Cannot retrieve feed URL.')); } if (count($feed->items) == 0) { throw new Exception(__('No items in feed.')); } if ($this->core->plugins->moduleExists('metadata')) { $meta = new dcMeta($this->core); } $cur = $this->core->con->openCursor($this->core->prefix . 'post'); $this->core->con->begin(); foreach ($feed->items as $item) { $cur->clean(); $cur->user_id = $this->core->auth->userID(); $cur->post_content = $item->content ? $item->content : $item->description; $cur->post_title = $item->title ? $item->title : text::cutString(html::clean($cur->post_content), 60); $cur->post_format = 'xhtml'; $cur->post_status = -2; $cur->post_dt = strftime('%Y-%m-%d %H:%M:%S', $item->TS); try { $post_id = $this->core->blog->addPost($cur); } catch (Exception $e) { $this->core->con->rollback(); throw $e; } if (isset($meta)) { foreach ($item->subject as $subject) { $meta->setPostMeta($post_id, 'tag', dcMeta::sanitizeMetaID($subject)); } } } $this->core->con->commit(); http::redirect($this->getURL() . '&do=ok'); }
public static function wiki2xhtmlTag($url, $content) { $url = substr($url, 4); if (strpos($content, 'tag:') === 0) { $content = substr($content, 4); } $tag_url = html::stripHostURL($GLOBALS['core']->blog->url . $GLOBALS['core']->url->getURLFor('tag')); $res['url'] = $tag_url . '/' . rawurlencode(dcMeta::sanitizeMetaID($url)); $res['content'] = $content; return $res; }
if ($_ctx->posts->cat_id) { ?> - <a href="<?php echo context::global_filter($_ctx->posts->getCategoryURL(), 0, 0, 0, 0, 0, 'EntryCategoryURL'); ?> "><?php echo context::global_filter($_ctx->posts->cat_title, 1, 0, 0, 0, 0, 'EntryCategory'); ?> </a> <?php } ?> </p> <?php $objMeta = new dcMeta($core); $_ctx->meta = $objMeta->getMetaRecordset($_ctx->posts->post_meta, 'tag'); $_ctx->meta->sort('meta_id_lower', 'asc'); while ($_ctx->meta->fetch()) { ?> <?php if ($_ctx->meta->isStart()) { ?> <ul class="post-tags"><?php } ?> <li><a href="<?php echo context::global_filter($core->blog->url . $core->url->getBase("tag") . "/" . rawurlencode($_ctx->meta->meta_id), 0, 0, 0, 0, 0, 'TagURL'); ?> "><?php echo context::global_filter($_ctx->meta->meta_id, 0, 0, 0, 0, 0, 'TagID');
protected function importTags($post_id, $new_post_id, &$db) { $rs = $db->select('SELECT * FROM ' . $this->vars['db_prefix'] . 'terms AS t, ' . $this->vars['db_prefix'] . 'term_taxonomy AS x, ' . $this->vars['db_prefix'] . 'term_relationships AS r ' . 'WHERE t.term_id = x.term_id ' . 'AND x.taxonomy = \'post_tag\' ' . 'AND t.term_id = r.term_taxonomy_id ' . 'AND r.object_id =' . $post_id . ' ORDER BY t.term_id ASC'); if ($rs->isEmpty()) { return; } $meta = new dcMeta($this->core); while ($rs->fetch()) { $meta->setPostMeta($new_post_id, 'tag', $this->cleanStr($rs->name)); } }
protected function importMeta($post_id, $new_post_id, &$db) { $rs = $db->select('SELECT * FROM ' . $this->vars['db_prefix'] . 'post_meta ' . 'WHERE post_id = ' . (int) $post_id . ' ' . "AND meta_key = 'tag' "); if ($rs->isEmpty()) { return; } $meta = new dcMeta($this->core); while ($rs->fetch()) { $meta->setPostMeta($new_post_id, 'tag', $this->cleanStr($rs->meta_value)); } }
# -- BEGIN LICENSE BLOCK ---------------------------------- # # This file is part of Dotclear 2. # # Copyright (c) 2003-2009 Olivier Meunier and contributors # Licensed under the GPL version 2.0 license. # See LICENSE file or # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { return; } $tag = !empty($_REQUEST['tag']) ? $_REQUEST['tag'] : ''; $this_url = $p_url . '&m=tag_posts&tag=' . rawurlencode($tag); $meta = new dcMeta($core); $page = !empty($_GET['page']) ? $_GET['page'] : 1; $nb_per_page = 30; # Rename a meta if (!empty($_POST['new_meta_id'])) { $new_id = dcMeta::sanitizeMetaID($_POST['new_meta_id']); try { if ($meta->updateMeta($tag, $new_id, 'tag')) { http::redirect($p_url . '&m=tag_posts&tag=' . $new_id . '&renamed=1'); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Delete a tag if (!empty($_POST['delete']) && $core->auth->check('publish,contentadmin', $core->blog->id)) {
public static function delMeta(&$core, $get, $post) { if (empty($post['postId'])) { throw new Exception('No post ID'); } if (empty($post['metaId'])) { throw new Exception('No meta ID'); } if (empty($post['metaType'])) { throw new Exception('No meta type'); } $meta = new dcMeta($core); $meta->delPostMeta($post['postId'], $post['metaType'], $post['metaId']); return true; }
<body> <h2><?php echo html::escapeHTML($core->blog->name); ?> › <?php echo __('Tags'); ?> </h2> <?php if (!empty($_GET['del'])) { echo '<p class="message">' . __('Tag has been successfully removed') . '</p>'; } $meta = new dcMeta($core); $tags = $meta->getMeta('tag'); $tags->sort('meta_id_lower', 'asc'); $last_letter = null; $cols = array('', ''); $col = 0; while ($tags->fetch()) { $letter = mb_strtoupper(mb_substr($tags->meta_id, 0, 1)); if ($last_letter != $letter) { if ($tags->index() >= round($tags->count() / 2)) { $col = 1; } $cols[$col] .= '<tr class="tagLetter"><td colspan="2"><span>' . $letter . '</span></td></tr>'; } $cols[$col] .= '<tr class="line">' . '<td class="maximal"><a href="' . $p_url . '&m=tag_posts&tag=' . rawurlencode($tags->meta_id) . '">' . $tags->meta_id . '</a></td>' . '<td class="nowrap"><strong>' . $tags->count . '</strong> ' . __('entries') . '</td>' . '</tr>'; $last_letter = $letter;
public static function tagFeed($args) { if (!preg_match('#^(.+)/(atom|rss2)(/comments)?$#', $args, $m)) { self::p404(); } else { $tag = $m[1]; $type = $m[2]; $comments = !empty($m[3]); $objMeta = new dcMeta($GLOBALS['core']); $GLOBALS['_ctx']->meta = $objMeta->getMeta('tag', null, $tag); if ($GLOBALS['_ctx']->meta->isEmpty()) { # The specified tag does not exist. self::p404(); } else { $GLOBALS['_ctx']->feed_subtitle = ' - ' . __('Tag') . ' - ' . $GLOBALS['_ctx']->meta->meta_id; if ($type == 'atom') { $mime = 'application/atom+xml'; } else { $mime = 'application/xml'; } $tpl = $type; if ($comments) { $tpl .= '-comments'; $GLOBALS['_ctx']->nb_comment_per_page = $GLOBALS['core']->blog->settings->nb_comment_per_feed; } else { $GLOBALS['_ctx']->nb_entry_per_page = $GLOBALS['core']->blog->settings->nb_post_per_feed; $GLOBALS['_ctx']->short_feed_items = $GLOBALS['core']->blog->settings->short_feed_items; } $tpl .= '.xml'; self::serveDocument($tpl, $mime); } } }
public static function lastposts(&$w) { global $core; if ($w->homeonly && $core->url->type != 'default') { return; } $params['limit'] = abs((int) $w->limit); $params['order'] = 'post_dt desc'; $params['no_content'] = true; if ($w->category) { if ($w->category == 'null') { $params['sql'] = ' AND p.cat_id IS NULL '; } elseif (is_numeric($w->category)) { $params['cat_id'] = (int) $w->category; } else { $params['cat_url'] = $w->category; } } if ($core->plugins->moduleExists('metadata') && $w->tag) { $m = new dcMeta($core); $params['meta_id'] = $w->tag; $rs = $m->getPostsByMeta($params); } else { $rs = $core->blog->getPosts($params); } if ($rs->isEmpty()) { return; } $res = '<div class="lastposts">' . ($w->title ? '<h2>' . html::escapeHTML($w->title) . '</h2>' : '') . '<ul>'; while ($rs->fetch()) { $res .= '<li><a href="' . $rs->getURL() . '">' . html::escapeHTML($rs->post_title) . '</a></li>'; } $res .= '</ul></div>'; return $res; }
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear # Licensed under the GPL version 2.0 license. # See LICENSE file or # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # # -- END LICENSE BLOCK ----------------------------------------- if (!defined('DC_CONTEXT_ADMIN')) { return; } $tag = isset($_REQUEST['tag']) ? $_REQUEST['tag'] : ''; $this_url = $p_url . '&m=tag_posts&tag=' . rawurlencode($tag); $page = !empty($_GET['page']) ? max(1, (int) $_GET['page']) : 1; $nb_per_page = 30; # Rename a tag if (isset($_POST['new_tag_id'])) { $new_id = dcMeta::sanitizeMetaID($_POST['new_tag_id']); try { if ($core->meta->updateMeta($tag, $new_id, 'tag')) { dcPage::addSuccessNotice(__('Tag has been successfully renamed')); http::redirect($p_url . '&m=tag_posts&tag=' . $new_id); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Delete a tag if (!empty($_POST['delete']) && $core->auth->check('publish,contentadmin', $core->blog->id)) { try { $core->meta->delMeta($tag, 'tag'); dcPage::addSuccessNotice(__('Tag has been successfully removed')); http::redirect($p_url . '&m=tags');
private function getTags($user, $pwd) { if (!class_exists('dcMeta')) { throw new Exception('Metadata management is not available on this blog.'); } $this->setUser($user, $pwd); $this->setBlog(); $meta = new dcMeta($this->core); $tags = $meta->getMeta('tag'); $tags->sort('meta_id_lower', 'asc'); $res = array(); $url = $this->core->blog->url . $this->core->url->getBase('tag') . '/%s'; $f_url = $this->core->blog->url . $this->core->url->getBase('tag_feed') . '/%s'; while ($tags->fetch()) { $res[] = array('tag_id' => $tags->meta_id, 'name' => $tags->meta_id, 'count' => $tags->count, 'slug' => $tags->meta_id, 'html_url' => sprintf($url, $tags->meta_id), 'rss_url' => sprintf($f_url, $tags->meta_id)); } return $res; }