예제 #1
0
 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);
         }
     }
 }
예제 #2
0
 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');
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
 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));
     }
 }
예제 #5
0
파일: _admin.php 프로젝트: HackerMajor/root
 public static function setPostMeta(&$core, $get, $post)
 {
     if (empty($post['postId'])) {
         throw new Exception('No post ID');
     }
     if (empty($post['meta'])) {
         throw new Exception('No meta');
     }
     if (empty($post['metaType'])) {
         throw new Exception('No meta type');
     }
     $meta = new dcMeta($core);
     # Get previous meta for post
     $post_meta = $meta->getMeta($post['metaType'], null, null, $post['postId']);
     $pm = array();
     while ($post_meta->fetch()) {
         $pm[] = $post_meta->meta_id;
     }
     foreach ($meta->splitMetaValues($post['meta']) as $m) {
         if (!in_array($m, $pm)) {
             $meta->setPostMeta($post['postId'], $post['metaType'], $m);
         }
     }
     return true;
 }