$tags = cot_tag_parse($rtags);
    $old_tags = cot_tag_list($id, 'projects', $tags_extra);
    $kept_tags = array();
    $new_tags = array();
    // Find new tags, count old tags that have been left
    $cnt = 0;
    foreach ($tags as $tag) {
        $p = array_search($tag, $old_tags);
        if ($p !== false) {
            $kept_tags[] = $old_tags[$p];
            $cnt++;
        } else {
            $new_tags[] = $tag;
        }
    }
    // Remove old tags that have been removed
    $rem_tags = array_diff($old_tags, $kept_tags);
    foreach ($rem_tags as $tag) {
        cot_tag_remove($tag, $id, 'projects', $tags_extra);
    }
    // Add new tags
    $ncnt = count($new_tags);
    if ($cfg['plugin']['tags']['limit'] > 0 && $ncnt > $cfg['plugin']['tags']['limit'] - $cnt) {
        $lim = $cfg['plugin']['tags']['limit'] - $cnt;
    } else {
        $lim = $ncnt;
    }
    for ($i = 0; $i < $lim; $i++) {
        cot_tag($new_tags[$i], $id, 'projects', $tags_extra);
    }
}
<?php

/* ====================
[BEGIN_COT_EXT]
Hooks=forums.newtopic.newtopic.done
[END_COT_EXT]
==================== */
/**
 * Adds tags when creating a new topic
 *
 * @package Tags
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
if ($cfg['plugin']['tags']['forums'] && cot_auth('plug', 'tags', 'W')) {
    require_once cot_incfile('tags', 'plug');
    $item_id = $q;
    $rtags = cot_import('rtags', 'P', 'TXT');
    $tags = cot_tag_parse($rtags);
    $cnt = 0;
    foreach ($tags as $tag) {
        cot_tag($tag, $item_id, 'forums');
        $cnt++;
        if ($cfg['plugin']['tags']['limit'] > 0 && $cnt == $cfg['plugin']['tags']['limit']) {
            break;
        }
    }
}
Example #3
0
    $tags = cot_tag_parse($rtags);
    $old_tags = cot_tag_list($id, 'pages', $tags_extra);
    $kept_tags = array();
    $new_tags = array();
    // Find new tags, count old tags that have been left
    $cnt = 0;
    foreach ($tags as $tag) {
        $p = array_search($tag, $old_tags);
        if ($p !== false) {
            $kept_tags[] = $old_tags[$p];
            $cnt++;
        } else {
            $new_tags[] = $tag;
        }
    }
    // Remove old tags that have been removed
    $rem_tags = array_diff($old_tags, $kept_tags);
    foreach ($rem_tags as $tag) {
        cot_tag_remove($tag, $id, 'pages', $tags_extra);
    }
    // Add new tags
    $ncnt = count($new_tags);
    if ($cfg['plugin']['tags']['limit'] > 0 && $ncnt > $cfg['plugin']['tags']['limit'] - $cnt) {
        $lim = $cfg['plugin']['tags']['limit'] - $cnt;
    } else {
        $lim = $ncnt;
    }
    for ($i = 0; $i < $lim; $i++) {
        cot_tag($new_tags[$i], $id, 'pages', $tags_extra);
    }
}
/** 
 * [BEGIN_COT_EXT]
 * Hooks=market.add.add.done
 * [END_COT_EXT]
 */
/**
 * plugin tagslance for Cotonti Siena
 * 
 * @package tagslance
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['market'] && cot_auth('plug', 'tags', 'W')) {
    require_once cot_incfile('tags', 'plug');
    // I18n
    $tags_extra = cot_get_caller() == 'i18n.market' ? array('tag_locale' => $i18n_locale) : null;
    $rtags = cot_import('rtags', 'P', 'TXT');
    $tags = cot_tag_parse($rtags);
    $cnt = 0;
    foreach ($tags as $tag) {
        cot_tag($tag, $id, 'market', $tags_extra);
        $cnt++;
        if ($cfg['plugin']['tags']['limit'] > 0 && $cnt == $cfg['plugin']['tags']['limit']) {
            break;
        }
    }
}
Example #5
0
[END_COT_EXT]
==================== */
/**
 * Adds tags for a new page
 *
 * @package Tags
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
if ($cfg['plugin']['tags']['pages'] && cot_auth('plug', 'tags', 'W')) {
    require_once cot_incfile('tags', 'plug');
    // I18n
    if (cot_get_caller() == 'i18n.page') {
        $tags_extra = array('tag_locale' => $i18n_locale);
        $item_id = $id;
    } else {
        $tags_extra = null;
        $item_id = $db->query("SELECT LAST_INSERT_ID()")->fetchColumn();
    }
    $rtags = cot_import('rtags', 'P', 'TXT');
    $tags = cot_tag_parse($rtags);
    $cnt = 0;
    foreach ($tags as $tag) {
        cot_tag($tag, $item_id, 'pages', $tags_extra);
        $cnt++;
        if ($cfg['plugin']['tags']['limit'] > 0 && $cnt == $cfg['plugin']['tags']['limit']) {
            break;
        }
    }
}
    $tags = cot_tag_parse($rtags);
    $old_tags = cot_tag_list($q, 'forums');
    $kept_tags = array();
    $new_tags = array();
    // Find new tags, count old tags that have been left
    $cnt = 0;
    foreach ($tags as $tag) {
        $ps = array_search($tag, $old_tags);
        if ($ps !== false) {
            $kept_tags[] = $old_tags[$ps];
            $cnt++;
        } else {
            $new_tags[] = $tag;
        }
    }
    // Remove old tags that have been removed
    $rem_tags = array_diff($old_tags, $kept_tags);
    foreach ($rem_tags as $tag) {
        cot_tag_remove($tag, $q, 'forums');
    }
    // Add new tags
    $ncnt = count($new_tags);
    if ($cfg['plugin']['tags']['limit'] > 0 && $ncnt > $cfg['plugin']['tags']['limit'] - $cnt) {
        $lim = $cfg['plugin']['tags']['limit'] - $cnt;
    } else {
        $lim = $ncnt;
    }
    for ($i = 0; $i < $lim; $i++) {
        cot_tag($new_tags[$i], $q, 'forums');
    }
}
/** 
 * [BEGIN_COT_EXT]
 * Hooks=projects.add.add.done
 * [END_COT_EXT]
 */
/**
 * plugin tagslance for Cotonti Siena
 * 
 * @package tagslance
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['projects'] && cot_auth('plug', 'tags', 'W')) {
    require_once cot_incfile('tags', 'plug');
    // I18n
    $tags_extra = cot_get_caller() == 'i18n.projects' ? array('tag_locale' => $i18n_locale) : null;
    $rtags = cot_import('rtags', 'P', 'TXT');
    $tags = cot_tag_parse($rtags);
    $cnt = 0;
    foreach ($tags as $tag) {
        cot_tag($tag, $id, 'projects', $tags_extra);
        $cnt++;
        if ($cfg['plugin']['tags']['limit'] > 0 && $cnt == $cfg['plugin']['tags']['limit']) {
            break;
        }
    }
}
/** 
 * [BEGIN_COT_EXT]
 * Hooks=folio.add.add.done
 * [END_COT_EXT]
 */
/**
 * plugin tagslance for Cotonti Siena
 * 
 * @package tagslance
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['folio'] && cot_auth('plug', 'tags', 'W')) {
    require_once cot_incfile('tags', 'plug');
    // I18n
    $tags_extra = cot_get_caller() == 'i18n.folio' ? array('tag_locale' => $i18n_locale) : null;
    $rtags = cot_import('rtags', 'P', 'TXT');
    $tags = cot_tag_parse($rtags);
    $cnt = 0;
    foreach ($tags as $tag) {
        cot_tag($tag, $id, 'folio', $tags_extra);
        $cnt++;
        if ($cfg['plugin']['tags']['limit'] > 0 && $cnt == $cfg['plugin']['tags']['limit']) {
            break;
        }
    }
}
    $tags = cot_tag_parse($rtags);
    $old_tags = cot_tag_list($id, 'market', $tags_extra);
    $kept_tags = array();
    $new_tags = array();
    // Find new tags, count old tags that have been left
    $cnt = 0;
    foreach ($tags as $tag) {
        $p = array_search($tag, $old_tags);
        if ($p !== false) {
            $kept_tags[] = $old_tags[$p];
            $cnt++;
        } else {
            $new_tags[] = $tag;
        }
    }
    // Remove old tags that have been removed
    $rem_tags = array_diff($old_tags, $kept_tags);
    foreach ($rem_tags as $tag) {
        cot_tag_remove($tag, $id, 'market', $tags_extra);
    }
    // Add new tags
    $ncnt = count($new_tags);
    if ($cfg['plugin']['tags']['limit'] > 0 && $ncnt > $cfg['plugin']['tags']['limit'] - $cnt) {
        $lim = $cfg['plugin']['tags']['limit'] - $cnt;
    } else {
        $lim = $ncnt;
    }
    for ($i = 0; $i < $lim; $i++) {
        cot_tag($new_tags[$i], $id, 'market', $tags_extra);
    }
}
    $tags = cot_tag_parse($rtags);
    $old_tags = cot_tag_list($id, 'folio', $tags_extra);
    $kept_tags = array();
    $new_tags = array();
    // Find new tags, count old tags that have been left
    $cnt = 0;
    foreach ($tags as $tag) {
        $p = array_search($tag, $old_tags);
        if ($p !== false) {
            $kept_tags[] = $old_tags[$p];
            $cnt++;
        } else {
            $new_tags[] = $tag;
        }
    }
    // Remove old tags that have been removed
    $rem_tags = array_diff($old_tags, $kept_tags);
    foreach ($rem_tags as $tag) {
        cot_tag_remove($tag, $id, 'folio', $tags_extra);
    }
    // Add new tags
    $ncnt = count($new_tags);
    if ($cfg['plugin']['tags']['limit'] > 0 && $ncnt > $cfg['plugin']['tags']['limit'] - $cnt) {
        $lim = $cfg['plugin']['tags']['limit'] - $cnt;
    } else {
        $lim = $ncnt;
    }
    for ($i = 0; $i < $lim; $i++) {
        cot_tag($new_tags[$i], $id, 'folio', $tags_extra);
    }
}