当前位置: 首页>>代码示例>>PHP>>正文


PHP Tags::delete方法代码示例

本文整理汇总了PHP中Tags::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::delete方法的具体用法?PHP Tags::delete怎么用?PHP Tags::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tags的用法示例。


在下文中一共展示了Tags::delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rename

 /**
  * TODO: be more careful
  * INSERT INTO {tag2post} / SELECT $master_tag->ID,post_ID FROM {tag2post} WHERE tag_id = $tag->id" and then "DELETE FROM {tag2post} WHERE tag_id = $tag->id"
  * Renames tags.
  * If the master tag exists, the tags will be merged with it.
  * If not, it will be created first.
  *
  * @param Array tags The tag text, slugs or ids to be renamed
  * @param mixed master The Tag to which they should be renamed, or the slug, text or id of it
  **/
 public static function rename($master, $tags)
 {
     if (!is_array($tags)) {
         $tags = array($tags);
     }
     $tag_names = array();
     // get array of existing tags first to make sure we don't conflict with a new master tag
     foreach ($tags as $tag) {
         $posts = array();
         $post_ids = array();
         $tag = Tags::get_one($tag);
         // get all the post ID's tagged with this tag
         $posts = DB::get_results('SELECT post_id FROM {tag2post} WHERE tag_id = ?', array($tag->id));
         if (count($posts) > 0) {
             // build a list of all the post_id's we need for the new tag
             foreach ($posts as $post) {
                 $post_ids[] = $post->post_id;
             }
             $tag_names[] = $tag->tag;
         }
         Tags::delete($tag);
     }
     // get the master tag
     $master_tag = Tags::get_one($master);
     if (!isset($master_tag->slug)) {
         // it didn't exist, so we assume it's tag text and create it
         $master_tag = Tag::create(array('tag_slug' => Utils::slugify($master), 'tag_text' => $master));
         $master_ids = array();
     } else {
         // get the posts the tag is already on so we don't duplicate them
         $master_posts = DB::get_results('SELECT post_id FROM {tag2post} WHERE tag_id = ?', array($master_tag->id));
         $master_ids = array();
         foreach ($master_posts as $master_post) {
             $master_ids[] = $master_post->post_id;
         }
     }
     if (count($post_ids) > 0) {
         // only try and add the master tag to posts it's not already on
         $post_ids = array_diff($post_ids, $master_ids);
         // link the master tag to each distinct post we removed tags from
         foreach ($post_ids as $post_id) {
             DB::query('INSERT INTO {tag2post} ( tag_id, post_id ) VALUES ( ?, ? )', array($master_tag->id, $post_id));
         }
     }
     EventLog::log(sprintf(_n('Tag %s has been renamed to %s.', 'Tags %s have been renamed to %s.', count($tags)), implode($tag_names, ', '), $master), 'info', 'tag', 'habari');
 }
开发者ID:anupom,项目名称:my-blog,代码行数:56,代码来源:tags.php

示例2: _

        $msg = _("You must type a name for the tab.");
    } else {
        $id = Tags::insert($conn, $name, $bgcolor, $fgcolor, $italic, $bold);
        $msg = _("Tag successfully created.");
    }
} elseif (GET('mode') == "update" && $id != "") {
    if ($name == "") {
        $msg = _("You must type a name for the tab.");
    } else {
        Tags::update($conn, $id, $name, $bgcolor, $fgcolor, $italic, $bold);
        $msg = _("Tag successfully saved.");
    }
    $id = "";
}
if (GET('delete') != "") {
    Tags::delete($conn, $delete);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title> <?php 
echo _("Control Panel");
?>
 </title>
	<meta http-equiv="Pragma" content="no-cache"/>
	<link rel="stylesheet" href="../style/av_common.css?t=<?php 
echo Util::get_css_id();
?>
"/>
	<style type='text/css'>
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:tags_edit.php

示例3: onRemoveTag

 function onRemoveTag()
 {
     if (!isset($_SESSION['CATS']) || empty($_SESSION['CATS'])) {
         echo 'CATS has lost your session data!';
         return;
     }
     $tags = new Tags($this->_siteID);
     $tags->delete($_POST['tag_id']);
     return;
 }
开发者ID:rankinp,项目名称:OpenCATS,代码行数:10,代码来源:SettingsUI.php

示例4: removeTag

 function removeTag($tagId, $user, $removeFromAllResources = false)
 {
     require_once ROOT_DIR . '/services/MyResearch/lib/Tags.php';
     require_once ROOT_DIR . '/services/MyResearch/lib/Resource_tags.php';
     $rTag = new Resource_tags();
     if (!$removeFromAllResources) {
         $rTag->resource_id = $this->id;
     }
     $rTag->tag_id = $tagId;
     $rTag->user_id = $user->id;
     $rTag->find();
     if ($rTag->N > 0) {
         while ($rTag->fetch()) {
             $rTag->delete();
         }
     } else {
         //the tag was not found.
         return false;
     }
     //Check to see if the tag is still in use by any user for any resource.
     $rTag = new Resource_tags();
     $rTag->tag_id = $tagId;
     $rTag->find();
     if ($rTag->N == 0) {
         //Tag is still in use, delete it.
         $tags = new Tags();
         $tags->id = $tagId;
         if ($tags->find(true)) {
             $tags->delete();
         }
     }
     return true;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:33,代码来源:Resource.php

示例5: ajax_tags

 /**
  * Handles AJAX from /admin/tags
  * Used to delete and rename tags
  */
 public function ajax_tags($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $wsse = Utils::WSSE($handler_vars['nonce'], $handler_vars['timestamp']);
     if ($handler_vars['digest'] != $wsse['digest']) {
         Session::error(_t('WSSE authentication failed.'));
         echo Session::messages_get(true, array('Format', 'json_messages'));
         return;
     }
     $tag_names = array();
     $action = $this->handler_vars['action'];
     switch ($action) {
         case 'delete':
             foreach ($_POST as $id => $delete) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $delete) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->tag;
                     Tags::delete($tag);
                 }
             }
             $msg_status = sprintf(_n('Tag %s has been deleted.', 'Tags %s have been deleted.', count($tag_names)), implode($tag_names, ', '));
             Session::notice($msg_status);
             echo Session::messages_get(true, array('Format', 'json_messages'));
             break;
         case 'rename':
             if (isset($this->handler_vars['master'])) {
                 $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', TRUE));
                 $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
                 $master = $this->handler_vars['master'];
                 $tag_names = array();
                 foreach ($_POST as $id => $rename) {
                     // skip POST elements which are not tag ids
                     if (preg_match('/^tag_\\d+/', $id) && $rename) {
                         $id = substr($id, 4);
                         $tag = Tags::get_by_id($id);
                         $tag_names[] = $tag->tag;
                     }
                 }
                 Tags::rename($master, $tag_names);
                 $msg_status = sprintf(_n('Tag %1$s has been renamed to %2$s.', 'Tags %1$s have been renamed to %2$s.', count($tag_names)), implode($tag_names, ', '), $master);
                 Session::notice($msg_status);
                 $this->theme->tags = Tags::get();
                 $this->theme->max = Tags::max_count();
                 echo json_encode(array('msg' => Session::messages_get(true, 'array'), 'tags' => $this->theme->fetch('tag_collection')));
             }
             break;
     }
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:54,代码来源:adminhandler.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy(Tags $tags)
 {
     $tags->delete();
     return redirect()->route('admin.advertisement.index');
 }
开发者ID:lyovkin,项目名称:v2board,代码行数:11,代码来源:AdminAdvertisementController.php


注:本文中的Tags::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。