Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <product productid="multitagsearch" active="1">
- <title><![CDATA[Multi-Tag Search]]></title>
- <description>Allows search by multiple tags</description>
- <version>1.0</version>
- <url><![CDATA[http://www.vbulletin.org/forum/misc.php?do=producthelp&pid=multitagsearch]]></url>
- <versioncheckurl><![CDATA[http://www.vbulletin.org/forum/misc.php?do=productcheck&pid=multitagsearch]]></versioncheckurl>
- <plugins>
- <plugin active="1" executionorder="5">
- <title><![CDATA[Multi-Tag Search: Fool the invalid tag checker]]></title>
- <hookname>tags_start</hookname>
- <phpcode><![CDATA[if ($vbulletin->options['multitagsearch_active'])
- {
- if ($_REQUEST['do'] == 'tag')
- {
- $multitag = explode(" ", $_REQUEST['tag']);
- $_REQUEST['tag'] = $multitag[0];
- if (substr($_REQUEST['tag'], 0, 1) == '+' OR substr($_REQUEST['tag'], 0, 1) == '-')
- {
- $_REQUEST['tag'] = substr($_REQUEST['tag'], 1, strlen($_REQUEST['tag']));
- }
- // we're bypassing the html check so let's make sure we're safe
- $cleantags = array();
- foreach($multitag AS $mtag)
- {
- $cleantags[] = htmlspecialchars_uni(trim(strval($mtag)));
- }
- // break the tags up into +/- and unsigned arrays
- $querytags = array();
- $plusquerytags = array();
- $notquerytags = array();
- foreach($cleantags as $mtag)
- {
- if (substr($mtag, 0, 1) == '+')
- {
- $plusquerytags[] = substr($mtag, 1, strlen($mtag));
- }
- elseif (substr($mtag, 0, 1) == '-')
- {
- $notquerytags[] = substr($mtag, 1, strlen($mtag));
- }
- else
- {
- $querytags[] = $mtag;
- }
- }
- // check for invalid combinations
- // 1: only minus tags
- if (empty($plusquerytags) AND empty($querytags))
- {
- standard_error(fetch_error('multitagsearch_negativeonly_error'));
- }
- }
- }]]></phpcode>
- </plugin>
- <plugin active="1" executionorder="5">
- <title><![CDATA[Multi-Tag Search: Replace the tag search]]></title>
- <hookname>tags_list_query_data</hookname>
- <phpcode><![CDATA[if ($vbulletin->options['multitagsearch_active'])
- {
- // start building the sql
- $multitag_where = '';
- $weight = '';
- $count = 0;
- foreach($querytags as $qtag)
- {
- if (empty($plusquerytags))
- {
- if ($count == 0)
- {
- $multitag_where .= " AND (";
- }
- else
- {
- $multitag_where .= " OR ";
- }
- $multitag_where .= "(taglist REGEXP '[[:<:]]" . $qtag . "[[:>:]]') > 0";
- $count++;
- }
- if (!empty($weight))
- {
- $weight .= ' + ';
- }
- $weight .= "(taglist REGEXP '[[:<:]]" . $qtag . "[[:>:]]')";
- }
- if (empty($plusquerytags))
- {
- $multitag_where .= ")";
- }
- foreach($plusquerytags as $ptag)
- {
- $multitag_where .= " AND (taglist REGEXP '[[:<:]]" . $ptag . "[[:>:]]') > 0";
- if (!empty($weight))
- {
- $weight .= ' + ';
- }
- $weight .= "(taglist REGEXP '[[:<:]]" . $qtag . "[[:>:]]')";
- }
- $weight = "(" . $weight . ") AS weight ";
- // Add the negative tags
- if (!empty($notquerytags))
- {
- foreach($notquerytags as $ntag)
- {
- $multitag_where .= " AND (taglist REGEXP '[[:<:]]" . $ntag . "[[:>:]]') = 0";
- }
- }
- $msql = "SELECT thread.threadid, thread.taglist, $weight, $tachy_columns
- FROM " . TABLE_PREFIX . "thread AS thread
- $tachyjoin
- $hook_query_joins
- WHERE thread.forumid IN(" . implode(', ', $forumids) . ")
- " . ($self_only ? 'AND IF(thread.forumid IN (' . implode(',', $self_only) . '), thread.postuserid = ' . $vbulletin->userinfo['userid'] . ', 1)' : '') . "
- AND thread.visible = 1
- AND thread.sticky IN (0, 1)
- AND thread.open <> 10
- $globalignore
- $hook_query_where
- $multitag_where
- ORDER BY weight DESC, lastpost DESC
- LIMIT " . intval($vbulletin->options['maxresults']);
- $threadid_sql = $db->query_read_slave($msql);
- $totalthreads = $db->num_rows($threadid_sql);
- if (!$totalthreads)
- {
- standard_error(fetch_error('multitagsearch_noresults_error'));
- }
- if ($vbulletin->GPC['pagenumber'] <= 1)
- {
- $db->query_write("INSERT INTO " . TABLE_PREFIX . "tagsearch (tagid, dateline) VALUES ($tag[tagid], " . TIMENOW . ")");
- }
- $pagenumber = $vbulletin->GPC['pagenumber'];
- $perpage = $vbulletin->GPC['perpage'];
- sanitize_pageresults($totalthreads, $pagenumber, $perpage, 200, $vbulletin->options['maxthreads']);
- if ($pagenumber > 1)
- {
- $db->data_seek($threadid_sql, ($pagenumber - 1) * $perpage);
- }
- $threadids = array();
- $resultnum = 0;
- while ($thread = $db->fetch_array($threadid_sql))
- {
- $threadids[] = $thread['threadid'];
- $resultnum++;
- if ($resultnum >= $perpage)
- {
- break;
- }
- }
- $db->free_result($threadid_sql);
- if ($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'])
- {
- // we need this for forum read times
- cache_ordered_forums(1);
- }
- // now move on to actual display code
- $hook_query_fields = $hook_query_joins = '';
- }]]></phpcode>
- </plugin>
- <plugin active="1" executionorder="5">
- <title><![CDATA[Multi-Tag Search: Get ready for display]]></title>
- <hookname>tags_list_threads</hookname>
- <phpcode><![CDATA[if ($vbulletin->options['multitagsearch_active'])
- {
- $show['multitags'] = true;
- foreach($threads as $key => $mthread)
- {
- $tmptags = '';
- $tagarray = explode(",", $mthread['taglist']);
- // trim them
- foreach($tagarray as $tkey => $ttag)
- {
- $tagarray[$tkey] = trim($ttag);
- }
- foreach ($querytags as $qtag)
- {
- if (array_search($qtag, $tagarray) !== false)
- {
- if (!empty($tmptags))
- {
- $tmptags .= ', ';
- }
- $tmptags .= $qtag;
- }
- }
- foreach ($plusquerytags as $ptag)
- {
- if (array_search($ptag, $tagarray) !== false)
- {
- if (!empty($tmptags))
- {
- $tmptags .= ', ';
- }
- $tmptags .= $ptag;
- }
- }
- $threads[$key]['taglist'] = $tmptags;
- }
- $columncount += 1;
- if ($vbulletin->options['multitagsearch_autotemplate'])
- {
- // add to the tag_search template
- $find = '<td class=\"thead\" width=\"25%\">$vbphrase[forum]</td>';
- $replace = '<if condition=\"$show[multitags]\"><td class=\"thead\" align=\"center\" nowrap=\"nowrap\">$vbphrase[tags]</td></if>';
- $vbulletin->templatecache['tag_search'] = str_replace($find, $find . $replace, $vbulletin->templatecache['tag_search']);
- // add to the threadbit template
- $find = '".(($show[\'inlinemod\']) ? ("';
- $replace = '<if condition=\"$show[multitags]\"><td class=\"alt1\"><div class=\"smallfont\">$thread[taglist]</div></td></if>';
- $vbulletin->templatecache['threadbit'] = str_replace($find, $replace . $find, $vbulletin->templatecache['threadbit']);
- }
- }]]></phpcode>
- </plugin>
- </plugins>
- <phrases>
- <phrasetype name="Error Messages" fieldname="error">
- <phrase name="multitagsearch_noresults_error" date="0" username="Hambil" version="1.0"><![CDATA[No results found.]]></phrase>
- <phrase name="multitagsearch_negativeonly_error" date="0" username="Hambil" version="1.0"><![CDATA[Search contains only negative tags.]]></phrase>
- </phrasetype>
- <phrasetype name="vBulletin Settings" fieldname="vbsettings">
- <phrase name="setting_multitagsearch_active_desc" date="0" username="" version=""><![CDATA[Set this to yes to make Multi-Tag Search active.]]></phrase>
- <phrase name="setting_multitagsearch_active_title" date="0" username="" version=""><![CDATA[Enable Multi-Tag Search?]]></phrase>
- <phrase name="setting_multitagsearch_autotemplate_desc" date="0" username="" version=""><![CDATA[Set this to yes to use automatic template edits.]]></phrase>
- <phrase name="setting_multitagsearch_autotemplate_title" date="0" username="" version=""><![CDATA[Automatic Template Edits?]]></phrase>
- <phrase name="settinggroup_multitagsearch_settings" date="0" username="" version=""><![CDATA[Multi-Tag Search Settings]]></phrase>
- </phrasetype>
- </phrases>
- <options>
- <settinggroup name="multitagsearch_settings" displayorder="10">
- <setting varname="multitagsearch_active" displayorder="5">
- <datatype>boolean</datatype>
- <optioncode>yesno</optioncode>
- <defaultvalue>1</defaultvalue>
- </setting>
- <setting varname="multitagsearch_autotemplate" displayorder="10">
- <datatype>boolean</datatype>
- <optioncode>yesno</optioncode>
- <defaultvalue>1</defaultvalue>
- </setting>
- </settinggroup>
- </options>
- </product>
Advertisement
Add Comment
Please, Sign In to add comment