public function execute() { wa()->getResponse()->addJs('wa-content/js/jquery-plugins/jquery-tagsinput/jquery.tagsinput.min.js')->addCss('wa-content/js/jquery-plugins/jquery-tagsinput/jquery.tagsinput.css')->addJs('wa-content/js/jquery-plugins/jquery-autocomplete/jquery.autocomplete.min.js')->addCss('wa-content/js/jquery-plugins/jquery-autocomplete/jquery.autocomplete.css'); $tags = array(); $tag_model = new blogTagPluginModel(); $tag_records = $tag_model->getByPost($this->params['post_id']); foreach ($tag_records as $tag_info) { $tags[] = $tag_info['name']; } $this->view->assign('tags', implode(', ', $tags)); }
public function execute() { $limit = 30; $query = waRequest::request('q', '', waRequest::TYPE_STRING_TRIM); $tag_model = new blogTagPluginModel(); $tags = $tag_model->search($query, $limit); $tags = array_keys($tags); foreach ($tags as &$tag) { $tag = htmlspecialchars($tag); } unset($tag); echo implode("\n", $tags); }
/** * Delete posts related tags by post ID * @param int|array $post_id * @return bool */ public function deletePost($post_id) { $tag_ids = array_keys($this->getByField('post_id', $post_id, 'tag_id')); if (!$this->deleteByField('post_id', $post_id)) { return false; } if ($tag_ids) { $delete_tag_ids = array_keys($this->query("\n SELECT t.id, COUNT(pt.tag_id) cnt FROM `blog_tag` t \n LEFT JOIN `blog_post_tag` pt ON t.id = pt.tag_id\n WHERE t.id IN(" . implode(',', $tag_ids) . ")\n GROUP BY t.id\n HAVING cnt = 0")->fetchAll('id')); if ($delete_tag_ids) { $tag_model = new blogTagPluginModel(); $tag_model->deleteById($delete_tag_ids); } } return true; }
public function postSave($post) { $post_id = $post['id']; if (isset($post['plugin']) && isset($post['plugin'][$this->id])) { if ($post['plugin'][$this->id]) { $tags = preg_split('/(,[\\s]*)+/', $post['plugin'][$this->id]); } else { $tags = array(); } $tag_model = new blogTagPluginModel(); $tag_model->addTag($post_id, $tags); } }
<?php $model = new blogTagPluginModel(); $ids = array_keys($model->query("\n SELECT t.id, COUNT(pt.tag_id) cnt FROM `blog_tag` t \n LEFT JOIN `blog_post_tag` pt ON t.id = pt.tag_id\n GROUP BY t.id\n HAVING cnt = 0\n ")->fetchAll('id')); if ($ids) { $model->deleteById($ids); }
public function execute() { $config = (include wa()->getAppPath() . '/' . $this->getPluginRoot() . 'lib/config/config.php'); $tag_model = new blogTagPluginModel(); $this->view->assign('tags', $tag_model->getAllTags($config)); }