<?php

/* ====================
[BEGIN_COT_EXT]
Hooks=tags.search.pages.loop
[END_COT_EXT]
==================== */
/**
 * Tag search for i18n pages
 *
 * @package I18n
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
if (!empty($row['ipage_title'])) {
    $tags = cot_tag_list($row['page_id'], 'pages', array('tag_locale' => $row['ipage_locale']));
    $tag_list = '';
    $tag_i = 0;
    foreach ($tags as $tag) {
        $tag_t = $cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag;
        $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
        $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
        if ($tag_i > 0) {
            $tag_list .= ', ';
        }
        $tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'pages', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t), 'rel="nofollow"');
        $tag_i++;
    }
    $t->assign(array('TAGS_RESULT_ROW_URL' => empty($row['page_alias']) ? cot_url('page', 'c=' . $row['page_cat'] . '&id=' . $row['page_id'] . '&l=' . $row['ipage_locale']) : cot_url('page', 'c=' . $row['page_cat'] . '&al=' . $row['page_alias'] . '&l=' . $row['ipage_locale']), 'TAGS_RESULT_ROW_TITLE' => htmlspecialchars($row['ipage_title']), 'TAGS_RESULT_ROW_PATH' => cot_breadcrumbs(cot_i18n_build_catpath('page', $row['page_cat'], $row['ipage_locale']), false), 'TAGS_RESULT_ROW_TAGS' => $tag_list));
}
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['projects']) {
    require_once cot_incfile('tags', 'plug');
    if (cot_plugin_active('i18n') && $i18n_enabled && $i18n_notmain) {
        $tags_extra = array('tag_locale' => $i18n_locale);
    } else {
        $tags_extra = null;
    }
    $item_id = $item['item_id'];
    if (!isset($tags_rowset_list)) {
        $tags_rowset_list = cot_tag_list(array_keys($sqllist_idset), 'projects', $tags_extra);
    }
    $tags = isset($tags_rowset_list[$item_id]) ? $tags_rowset_list[$item_id] : array();
    if (count($tags) > 0) {
        $tag_i = 0;
        foreach ($tags as $tag) {
            $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
            $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
            $t_pr->assign(array('PRJ_ROW_TAGS_ROW_TAG' => $cfg['plugin']['tags']['title'] ? htmlspecialchars(cot_tag_title($tag)) : htmlspecialchars($tag), 'PRJ_ROW_TAGS_ROW_URL' => cot_url('plug', array('e' => 'tags', 'a' => 'projects', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl))));
            $t_pr->parse('PROJECTS.PRJ_ROWS.PRJ_ROW_TAGS_ROW');
            $tag_i++;
        }
    } else {
        $t_pr->assign(array('PRJ_ROW_NO_TAGS' => $L['tags_Tag_cloud_none']));
        $t_pr->parse('PROJECTS.PRJ_ROWS.PRJ_ROW_NO_TAGS');
    }
}
Esempio n. 3
0
/**
 * Search by tag in forums
 *
 * @param string $query User-entered query string
 * @global CotDB $db
 */
function cot_tag_search_forums($query)
{
    global $db, $t, $L, $lang, $cfg, $usr, $qs, $d, $db_tag_references, $db_forum_topics, $o, $row;
    if (!cot_module_active('forums')) {
        return;
    }
    $query = cot_tag_parse_query($query, 't.ft_id');
    if (empty($query)) {
        return;
    }
    $maxperpage = cot::$cfg['maxrowsperpage'] && is_numeric(cot::$cfg['maxrowsperpage']) && cot::$cfg['maxrowsperpage'] > 0 ? cot::$cfg['maxrowsperpage'] : 15;
    $join_columns = '';
    $join_tables = '';
    $join_where = '';
    switch ($o) {
        case 'title':
            $order = 'ORDER BY `ft_title`';
            break;
        case 'date':
            $order = 'ORDER BY `ft_updated` DESC';
            break;
        case 'category':
            $order = 'ORDER BY `ft_cat`';
            break;
        default:
            $order = '';
    }
    /* == Hook == */
    foreach (cot_getextplugins('tags.search.forums.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $totalitems = $db->query("SELECT DISTINCT COUNT(*)\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_forum_topics} AS t\n\t\t\tON r.tag_item = t.ft_id {$join_tables}\n\t\tWHERE r.tag_area = 'forums' AND ({$query}) {$join_where}")->fetchColumn();
    $sql = $db->query("SELECT DISTINCT t.ft_id, t.ft_cat, t.ft_title {$join_columns}\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_forum_topics} AS t\n\t\t\tON r.tag_item = t.ft_id {$join_tables}\n\t\tWHERE r.tag_area = 'forums' AND ({$query}) AND t.ft_id IS NOT NULL {$join_where}\n\t\t{$order}\n\t\tLIMIT {$d}, {$maxperpage}");
    $t->assign('TAGS_RESULT_TITLE', $L['tags_Found_in_forums']);
    if ($sql->rowCount() > 0) {
        while ($row = $sql->fetch()) {
            $tags = cot_tag_list($row['ft_id'], 'forums');
            $tag_list = '';
            $tag_i = 0;
            foreach ($tags as $tag) {
                $tag_t = $cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag;
                $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
                $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
                if ($tag_i > 0) {
                    $tag_list .= ', ';
                }
                $tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'forums', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t));
                $tag_i++;
            }
            $master = $row['fs_masterid'] > 0 ? array($row['fs_masterid'], $row['fs_mastername']) : false;
            $t->assign(array('TAGS_RESULT_ROW_URL' => cot_url('forums', 'm=posts&q=' . $row['ft_id']), 'TAGS_RESULT_ROW_TITLE' => htmlspecialchars($row['ft_title']), 'TAGS_RESULT_ROW_PATH' => cot_breadcrumbs(cot_forums_buildpath($row['ft_cat']), false), 'TAGS_RESULT_ROW_TAGS' => $tag_list));
            $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_ROW');
        }
        $sql->closeCursor();
        $qs_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($qs) : $qs;
        $tl = $lang != 'en' && $qs_u != $qs ? 1 : null;
        $pagenav = cot_pagenav('plug', array('e' => 'tags', 'a' => 'forums', 't' => $qs_u, 'tl' => $tl), $d, $totalitems, $maxperpage);
        $t->assign(array('TAGS_PAGEPREV' => $pagenav['prev'], 'TAGS_PAGENEXT' => $pagenav['next'], 'TAGS_PAGNAV' => $pagenav['main']));
    } else {
        $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_NONE');
    }
    $t->parse('MAIN.TAGS_RESULT');
}
function cot_tag_search_projects($query)
{
    global $db, $t, $L, $lang, $cfg, $usr, $qs, $d, $db_tag_references, $db_projects, $o, $row, $sys;
    if (!cot_module_active('projects')) {
        return;
    }
    $query = cot_tag_parse_query($query, 'p.item_id');
    if (empty($query)) {
        return;
    }
    $totalitems = $db->query("SELECT DISTINCT COUNT(*)\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_projects} AS p\n\t\t\tON r.tag_item = p.item_id\n\t\tWHERE r.tag_area = 'projects' AND ({$query}) AND p.item_state = 0")->fetchColumn();
    switch ($o) {
        case 'title':
            $order = 'ORDER BY `item_title`';
            break;
        case 'date':
            $order = 'ORDER BY `item_date` DESC';
            break;
        case 'category':
            $order = 'ORDER BY `item_cat`';
            break;
        default:
            $order = '';
    }
    /* == Hook == */
    foreach (cot_getextplugins('tags.search.projects.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT DISTINCT p.* {$join_columns}\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_projects} AS p\n\t\t\tON r.tag_item = p.item_id {$join_tables}\n\t\tWHERE r.tag_area = 'projects' AND ({$query}) AND p.item_id IS NOT NULL AND p.item_state = 0 {$join_where}\n\t\t{$order}\n\t\tLIMIT {$d}, {$cfg['maxrowsperpage']}");
    $t->assign('TAGS_RESULT_TITLE', $L['tags_Found_in_projects']);
    $pcount = $sql->rowCount();
    /* == Hook : Part 1 == */
    $extp = cot_getextplugins('tags.search.projects.loop');
    /* ===== */
    if ($pcount > 0) {
        foreach ($sql->fetchAll() as $row) {
            $tags = cot_tag_list($row['item_id'], 'projects');
            $tag_list = '';
            $tag_i = 0;
            foreach ($tags as $tag) {
                $tag_t = $cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag;
                $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
                $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
                if ($tag_i > 0) {
                    $tag_list .= ', ';
                }
                $tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'projects', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t));
                $tag_i++;
            }
            $t->assign(cot_generate_projecttags($row, 'TAGS_RESULT_ROW_'));
            $t->assign(array('TAGS_RESULT_ROW_TITLE' => htmlspecialchars($row['item_title']), 'TAGS_RESULT_ROW_PATH' => cot_breadcrumbs(cot_structure_buildpath('projects', $row['item_cat']), false), 'TAGS_RESULT_ROW_TAGS' => $tag_list));
            /* == Hook : Part 2 == */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_ROW');
        }
        $sql->closeCursor();
        $qs_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($qs) : $qs;
        $tl = $lang != 'en' && $qs_u != $qs ? 1 : null;
        $pagenav = cot_pagenav('plug', array('e' => 'tags', 'a' => 'projects', 't' => $qs_u, 'tl' => $tl), $d, $totalitems, $cfg['maxrowsperpage']);
        $t->assign(array('TAGS_PAGEPREV' => $pagenav['prev'], 'TAGS_PAGENEXT' => $pagenav['next'], 'TAGS_PAGNAV' => $pagenav['main']));
        /* == Hook == */
        foreach (cot_getextplugins('tags.search.projects.tags') as $pl) {
            include $pl;
        }
        /* ===== */
    }
    if ($pcount == 0) {
        $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_NONE');
    }
    $t->parse('MAIN.TAGS_RESULT');
}
Esempio n. 5
0
        $tags_extra = array('tag_locale' => $i18n_locale);
    } else {
        $tags_extra = null;
    }
    $item_id = $pag['page_id'];
    if (!isset($tags_rowset_list)) {
        // Load tags for all entries with 1 query
        $rowset_copy = $sql_rowset;
        reset($rowset_copy);
        $tag_items = array();
        foreach ($rowset_copy as $t_row) {
            $tag_items[] = $t_row['page_id'];
        }
        unset($rowset_copy);
        $tags_rowset_list = cot_tag_list($tag_items, 'pages', $tags_extra);
    }
    $tags = isset($tags_rowset_list[$item_id]) ? $tags_rowset_list[$item_id] : array();
    if (count($tags) > 0) {
        $tag_ii = 0;
        foreach ($tags as $tag) {
            $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
            $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
            $news->assign(array('PAGE_TAGS_ROW_TAG' => $cfg['plugin']['tags']['title'] ? htmlspecialchars(cot_tag_title($tag)) : htmlspecialchars($tag), 'PAGE_TAGS_ROW_TAG_COUNT' => $tag_ii, 'PAGE_TAGS_ROW_URL' => cot_url('plug', array('e' => 'tags', 'a' => 'pages', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl))));
            $news->parse('NEWS.PAGE_ROW.PAGE_TAGS.PAGE_TAGS_ROW');
            $tag_ii++;
        }
        $news->parse('NEWS.PAGE_ROW.PAGE_TAGS');
    } else {
        $news->parse('NEWS.PAGE_ROW.PAGE_NO_TAGS');
    }
}
Esempio n. 6
0
/**
 * Global tag cloud and search form
 *
 * @param string $area Site area
 * @global CotDB $db
 */
function cot_tag_search_form($area = 'all')
{
    global $db, $dt, $perpage, $lang, $tl, $qs, $t, $L, $R, $cfg, $db_tag_references, $tc_styles;
    $limit = $perpage > 0 ? "{$dt}, {$perpage}" : NULL;
    $tcloud = cot_tag_cloud($area, $cfg['plugin']['tags']['order'], $limit);
    $tc_html = $R['tags_code_cloud_open'];
    foreach ($tcloud as $tag => $cnt) {
        $tag_t = $cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag;
        $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
        $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
        foreach ($tc_styles as $key => $val) {
            if ($cnt <= $key) {
                $dim = $val;
                break;
            }
        }
        $tc_html .= cot_rc('tags_link_cloud_tag', array('url' => cot_url('plug', array('e' => 'tags', 'a' => $area, 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), 'tag_title' => htmlspecialchars($tag_t), 'dim' => $dim));
    }
    $tc_html .= $R['tags_code_cloud_close'];
    $t->assign('TAGS_CLOUD_BODY', $tc_html);
    $t->parse('MAIN.TAGS_CLOUD');
    if ($perpage > 0) {
        $where = $area == 'all' ? '' : "WHERE tag_area = '{$area}'";
        $sql = $db->query("SELECT COUNT(DISTINCT `tag`) FROM {$db_tag_references} {$where}");
        $totalitems = (int) $sql->fetchColumn();
        $pagenav = cot_pagenav('plug', 'e=tags&a=' . $area, $dt, $totalitems, $perpage, 'dt');
        $t->assign(array('TAGS_PAGEPREV' => $pagenav['prev'], 'TAGS_PAGENEXT' => $pagenav['next'], 'TAGS_PAGNAV' => $pagenav['main']));
    }
}
Esempio n. 7
0
        // Load tags for all entries with 1 query
        $rowset_copy = $sql_forums_rowset;
        reset($rowset_copy);
        $tag_items = array();
        foreach ($rowset_copy as $t_row) {
            $tag_items[] = $t_row['ft_id'];
        }
        unset($rowset_copy);
        $tags_rowset_list = cot_tag_list($tag_items, 'forums');
    }
    $tags = isset($tags_rowset_list[$item_id]) ? $tags_rowset_list[$item_id] : array();
    if (count($tags) > 0) {
        $tc_html = $L['Tags'] . ': ';
        $tag_i = 0;
        foreach ($tags as $tag) {
            $tag_t = $cfg['plugin']['tags']['title'] ? htmlspecialchars(cot_tag_title($tag)) : htmlspecialchars($tag);
            $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
            $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
            if ($tag_i > 0) {
                $tc_html .= ', ';
            }
            $tc_html .= cot_rc('tags_link_tag', array('url' => cot_url('plug', array('e' => 'tags', 'a' => 'forums', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), 'tag_title' => $tag_t));
            $tag_i++;
        }
        $t->assign('FORUMS_TOPICS_ROW_TAGS', $tc_html);
    } else {
        //$tc_html = $L['tags_Tag_cloud_none'];
        $t->assign('FORUMS_TOPICS_ROW_TAGS', '');
    }
}
// TODO tag cloud with subforums support