ManageSearch.template.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_modify_weights()
  13. {
  14. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  15. echo '
  16. <div id="admincenter">
  17. <form action="', $scripturl, '?action=admin;area=managesearch;sa=weights" method="post" accept-charset="', $context['character_set'], '">
  18. <div class="cat_bar">
  19. <h3 class="catbg">', $txt['search_weights'], '</h3>
  20. </div>
  21. <div class="windowbg">
  22. <span class="topslice"><span></span></span>
  23. <div class="content">
  24. <dl class="settings">
  25. <dt class="large_caption">
  26. <a href="', $scripturl, '?action=helpadmin;help=search_weight_frequency" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>
  27. ', $txt['search_weight_frequency'], ':
  28. </dt>
  29. <dd class="large_caption">
  30. <span class="search_weight"><input type="text" name="search_weight_frequency" id="weight1_val" value="', empty($modSettings['search_weight_frequency']) ? '0' : $modSettings['search_weight_frequency'], '" onchange="calculateNewValues()" size="3" class="input_text" /></span>
  31. <span id="weight1" class="search_weight">', $context['relative_weights']['search_weight_frequency'], '%</span>
  32. </dd>
  33. <dt class="large_caption">
  34. <a href="', $scripturl, '?action=helpadmin;help=search_weight_age" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>
  35. ', $txt['search_weight_age'], ':
  36. </dt>
  37. <dd class="large_caption">
  38. <span class="search_weight"><input type="text" name="search_weight_age" id="weight2_val" value="', empty($modSettings['search_weight_age']) ? '0' : $modSettings['search_weight_age'], '" onchange="calculateNewValues()" size="3" class="input_text" /></span>
  39. <span id="weight2" class="search_weight">', $context['relative_weights']['search_weight_age'], '%</span>
  40. </dd>
  41. <dt class="large_caption">
  42. <a href="', $scripturl, '?action=helpadmin;help=search_weight_length" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>
  43. ', $txt['search_weight_length'], ':
  44. </dt>
  45. <dd class="large_caption">
  46. <span class="search_weight"><input type="text" name="search_weight_length" id="weight3_val" value="', empty($modSettings['search_weight_length']) ? '0' : $modSettings['search_weight_length'], '" onchange="calculateNewValues()" size="3" class="input_text" /></span>
  47. <span id="weight3" class="search_weight">', $context['relative_weights']['search_weight_length'], '%</span>
  48. </dd>
  49. <dt class="large_caption">
  50. <a href="', $scripturl, '?action=helpadmin;help=search_weight_subject" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>
  51. ', $txt['search_weight_subject'], ':
  52. </dt>
  53. <dd class="large_caption">
  54. <span class="search_weight"><input type="text" name="search_weight_subject" id="weight4_val" value="', empty($modSettings['search_weight_subject']) ? '0' : $modSettings['search_weight_subject'], '" onchange="calculateNewValues()" size="3" class="input_text" /></span>
  55. <span id="weight4" class="search_weight">', $context['relative_weights']['search_weight_subject'], '%</span>
  56. </dd>
  57. <dt class="large_caption">
  58. <a href="', $scripturl, '?action=helpadmin;help=search_weight_first_message" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>
  59. ', $txt['search_weight_first_message'], ':
  60. </dt>
  61. <dd class="large_caption">
  62. <span class="search_weight"><input type="text" name="search_weight_first_message" id="weight5_val" value="', empty($modSettings['search_weight_first_message']) ? '0' : $modSettings['search_weight_first_message'], '" onchange="calculateNewValues()" size="3" class="input_text" /></span>
  63. <span id="weight5" class="search_weight">', $context['relative_weights']['search_weight_first_message'], '%</span>
  64. </dd>
  65. <dt class="large_caption">
  66. <a href="', $scripturl, '?action=helpadmin;help=search_weight_frequency" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a>
  67. ', $txt['search_weight_sticky'], ':
  68. </dt>
  69. <dd class="large_caption">
  70. <span class="search_weight"><input type="text" name="search_weight_sticky" id="weight6_val" value="', empty($modSettings['search_weight_sticky']) ? '0' : $modSettings['search_weight_sticky'], '" onchange="calculateNewValues()" size="3" class="input_text" /></span>
  71. <span id="weight6" class="search_weight">', $context['relative_weights']['search_weight_sticky'], '%</span>
  72. </dd>
  73. <dt class="large_caption">
  74. <strong>', $txt['search_weights_total'], '</strong>
  75. </dt>
  76. <dd class="large_caption">
  77. <span id="weighttotal" class="search_weight"><strong>', $context['relative_weights']['total'], '</strong></span>
  78. <span class="search_weight"><strong>100%</strong></span>
  79. </dd>
  80. </dl>
  81. <input type="submit" name="save" value="', $txt['search_weights_save'], '" class="button_submit floatright" />
  82. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  83. <input type="hidden" name="', $context['admin-msw_token_var'], '" value="', $context['admin-msw_token'], '" /><br class="clear" />
  84. </div>
  85. <span class="botslice"><span></span></span>
  86. </div>
  87. </form>
  88. </div>
  89. <br class="clear" />
  90. <script type="text/javascript"><!-- // --><![CDATA[
  91. function calculateNewValues()
  92. {
  93. var total = 0;
  94. for (var i = 1; i <= 6; i++)
  95. {
  96. total += parseInt(document.getElementById(\'weight\' + i + \'_val\').value);
  97. }
  98. setInnerHTML(document.getElementById(\'weighttotal\'), total);
  99. for (var i = 1; i <= 6; i++)
  100. {
  101. setInnerHTML(document.getElementById(\'weight\' + i), (Math.round(1000 * parseInt(document.getElementById(\'weight\' + i + \'_val\').value) / total) / 10) + \'%\');
  102. }
  103. }
  104. // ]]></script>';
  105. }
  106. function template_select_search_method()
  107. {
  108. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  109. echo '
  110. <div id="admincenter">
  111. <form action="', $scripturl, '?action=admin;area=managesearch;sa=method" method="post" accept-charset="', $context['character_set'], '">
  112. <div class="cat_bar">
  113. <h3 class="catbg">', $txt['search_method'], '</h3>
  114. </div>
  115. <div class="information">
  116. <div class="smalltext" style="font-weight: normal;"><a href="', $scripturl, '?action=helpadmin;help=search_why_use_index" onclick="return reqWin(this.href);">', $txt['search_create_index_why'], '</a></div>
  117. </div>
  118. <div class="windowbg">
  119. <span class="topslice"><span></span></span>
  120. <div class="content">
  121. <dl class="settings">
  122. ';
  123. if (!empty($context['table_info']))
  124. echo '
  125. <dt>
  126. <strong>', $txt['search_method_messages_table_space'], ':</strong>
  127. </dt>
  128. <dd>
  129. ', $context['table_info']['data_length'], '
  130. </dd>
  131. <dt>
  132. <strong>', $txt['search_method_messages_index_space'], ':</strong>
  133. </dt>
  134. <dd>
  135. ', $context['table_info']['index_length'], '
  136. </dd>';
  137. echo '
  138. </dl>
  139. ', $context['double_index'] ? '<div class="information">
  140. ' . $txt['search_double_index'] . '</div>' : '', '
  141. <fieldset class="search_settings floatleft">
  142. <legend>', $txt['search_index'], '</legend>
  143. <dl>
  144. <dt><input type="radio" name="search_index" value=""', empty($modSettings['search_index']) ? ' checked="checked"' : '', ' class="input_radio" />
  145. ', $txt['search_index_none'], '
  146. </dt>';
  147. if ($context['supports_fulltext'])
  148. {
  149. echo '
  150. <dt>
  151. <input type="radio" name="search_index" value="fulltext"', !empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext' ? ' checked="checked"' : '', empty($context['fulltext_index']) ? ' onclick="alert(\'' . $txt['search_method_fulltext_warning'] . '\'); selectRadioByName(this.form.search_index, \'fulltext\');"': '', ' class="input_radio" />
  152. ', $txt['search_method_fulltext_index'], '
  153. </dt>
  154. <dd>
  155. <span class="smalltext">';
  156. if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext']))
  157. echo '
  158. <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createfulltext;', $context['session_var'], '=', $context['session_id'], '">', $txt['search_method_fulltext_create'], '</a>]';
  159. elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext']))
  160. echo '
  161. <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_fulltext_cannot_create'];
  162. else
  163. echo '
  164. <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removefulltext;', $context['session_var'], '=', $context['session_id'], '">', $txt['search_method_fulltext_remove'], '</a>]<br />
  165. <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['fulltext_length'];
  166. echo '
  167. </span>
  168. </dd>';
  169. }
  170. echo '
  171. <dt>
  172. <input type="radio" name="search_index" value="custom"', !empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom' ? ' checked="checked"' : '', $context['custom_index'] ? '' : ' onclick="alert(\'' . $txt['search_index_custom_warning'] . '\'); selectRadioByName(this.form.search_method, \'1\');"', ' class="input_radio" />
  173. ', $txt['search_index_custom'], '
  174. </dt>
  175. <dd>
  176. <span class="smalltext">';
  177. if ($context['custom_index'])
  178. echo '
  179. <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], '">', $txt['search_index_custom_remove'], '</a>]<br />
  180. <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length'];
  181. elseif ($context['partial_custom_index'])
  182. echo '
  183. <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_partial'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], '">', $txt['search_index_custom_remove'], '</a>] [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex;resume;', $context['session_var'], '=', $context['session_id'], '">', $txt['search_index_custom_resume'], '</a>]<br />
  184. <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length'];
  185. else
  186. echo '
  187. <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex">', $txt['search_index_create_custom'], '</a>]';
  188. echo '
  189. </span>
  190. </dd>';
  191. foreach ($context['search_apis'] as $api)
  192. {
  193. if (empty($api['label']) || $api['has_template'])
  194. continue;
  195. echo '
  196. <dt>
  197. <input type="radio" name="search_index" value="', $api['setting_index'], '"', !empty($modSettings['search_index']) && $modSettings['search_index'] == $api['setting_index'] ? ' checked="checked"' : '', ' class="input_radio" />
  198. ', $api['label'] ,'
  199. </dt>';
  200. if ($api['desc'])
  201. echo '
  202. <dd>
  203. <span class="smalltext">', $api['desc'], '</span>
  204. </dd>';
  205. }
  206. echo '
  207. </dl>
  208. </fieldset>
  209. <fieldset class="search_settings floatright">
  210. <legend>', $txt['search_method'], '</legend>
  211. <input type="checkbox" name="search_force_index" id="search_force_index_check" value="1"', empty($modSettings['search_force_index']) ? '' : ' checked="checked"', ' class="input_check" /><label for="search_force_index_check">', $txt['search_force_index'], '</label><br />
  212. <input type="checkbox" name="search_match_words" id="search_match_words_check" value="1"', empty($modSettings['search_match_words']) ? '' : ' checked="checked"', ' class="input_check" /><label for="search_match_words_check">', $txt['search_match_words'], '</label>
  213. </fieldset>
  214. <div class="clear">
  215. <input type="submit" name="save" value="', $txt['search_method_save'], '" class="button_submit floatright" />
  216. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  217. <input type="hidden" name="', $context['admin-msm_token_var'], '" value="', $context['admin-msm_token'], '" />
  218. </div>
  219. </div>
  220. <span class="botslice clear"><span></span></span>
  221. </div>
  222. </form>
  223. </div>
  224. <br class="clear" />';
  225. }
  226. function template_create_index()
  227. {
  228. global $context, $settings, $options, $scripturl, $txt;
  229. echo '
  230. <div id="admincenter">
  231. <form action="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex;step=1" method="post" accept-charset="', $context['character_set'], '" name="create_index">
  232. <div class="cat_bar">
  233. <h3 class="catbg">', $txt['search_create_index'], '</h3>
  234. </div>
  235. <div class="windowbg">
  236. <span class="topslice"><span></span></span>
  237. <div class="content">
  238. <dl class="settings">
  239. <dt>
  240. <label for="predefine_select">', $txt['search_predefined'], ':</label>
  241. </dt>
  242. <dd>
  243. <select name="bytes_per_word" id="predefine_select">
  244. <option value="2">', $txt['search_predefined_small'], '</option>
  245. <option value="4" selected="selected">', $txt['search_predefined_moderate'], '</option>
  246. <option value="5">', $txt['search_predefined_large'], '</option>
  247. </select>
  248. </dd>
  249. </dl>
  250. <input type="submit" name="save" value="', $txt['search_create_index_start'], '" class="button_submit" />
  251. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  252. </div>
  253. <span class="botslice"><span></span></span>
  254. </div>
  255. </form>
  256. </div>
  257. <br class="clear" />';
  258. }
  259. function template_create_index_progress()
  260. {
  261. global $context, $settings, $options, $scripturl, $txt;
  262. echo '
  263. <div id="admincenter">
  264. <form action="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex;step=1" name="autoSubmit" method="post" accept-charset="', $context['character_set'], '">
  265. <div class="cat_bar">
  266. <h3 class="catbg">', $txt['search_create_index'], '</h3>
  267. </div>
  268. <div class="windowbg">
  269. <span class="topslice"><span></span></span>
  270. <div class="content">
  271. <p>
  272. ', $txt['search_create_index_not_ready'], '
  273. </p>
  274. <p>
  275. <strong>', $txt['search_create_index_progress'], ': ', $context['percentage'], '%</strong>
  276. </p>
  277. <input type="submit" name="b" value="', $txt['search_create_index_continue'], '" class="button_submit" />
  278. </div>
  279. <span class="botslice"><span></span></span>
  280. </div>
  281. <input type="hidden" name="step" value="', $context['step'], '" />
  282. <input type="hidden" name="start" value="', $context['start'], '" />
  283. <input type="hidden" name="bytes_per_word" value="', $context['index_settings']['bytes_per_word'], '" />
  284. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  285. </form>
  286. </div>
  287. <br class="clear" />
  288. <script type="text/javascript"><!-- // --><![CDATA[
  289. var countdown = 10;
  290. doAutoSubmit();
  291. function doAutoSubmit()
  292. {
  293. if (countdown == 0)
  294. document.forms.autoSubmit.submit();
  295. else if (countdown == -1)
  296. return;
  297. document.forms.autoSubmit.b.value = "', $txt['search_create_index_continue'], ' (" + countdown + ")";
  298. countdown--;
  299. setTimeout("doAutoSubmit();", 1000);
  300. }
  301. // ]]></script>';
  302. }
  303. function template_create_index_done()
  304. {
  305. global $context, $settings, $options, $scripturl, $txt;
  306. echo '
  307. <div id="admincenter">
  308. <div class="cat_bar">
  309. <h3 class="catbg">', $txt['search_create_index'], '</h3>
  310. </div>
  311. <div class="windowbg">
  312. <span class="topslice"><span></span></span>
  313. <div class="content">
  314. <p>', $txt['search_create_index_done'], '</p>
  315. <p>
  316. <strong><a href="', $scripturl, '?action=admin;area=managesearch;sa=method">', $txt['search_create_index_done_link'], '</a></strong>
  317. </p>
  318. </div>
  319. <span class="botslice"><span></span></span>
  320. </div>
  321. </div>
  322. <br class="clear" />';
  323. }
  324. // Add or edit a search engine spider.
  325. function template_spider_edit()
  326. {
  327. global $context, $settings, $options, $scripturl, $txt;
  328. echo '
  329. <div id="admincenter">
  330. <form action="', $scripturl, '?action=admin;area=sengines;sa=editspiders;sid=', $context['spider']['id'], '" method="post" accept-charset="', $context['character_set'], '">
  331. <div class="cat_bar">
  332. <h3 class="catbg">', $context['page_title'], '</h3>
  333. </div>
  334. <div class="information">
  335. ', $txt['add_spider_desc'], '
  336. </div>
  337. <div class="windowbg">
  338. <span class="topslice"><span></span></span>
  339. <div class="content">
  340. <dl class="settings">
  341. <dt>
  342. <strong>', $txt['spider_name'], ':</strong><br />
  343. <span class="smalltext">', $txt['spider_name_desc'], '</span>
  344. </dt>
  345. <dd>
  346. <input type="text" name="spider_name" value="', $context['spider']['name'], '" class="input_text" />
  347. </dd>
  348. <dt>
  349. <strong>', $txt['spider_agent'], ':</strong><br />
  350. <span class="smalltext">', $txt['spider_agent_desc'], '</span>
  351. </dt>
  352. <dd>
  353. <input type="text" name="spider_agent" value="', $context['spider']['agent'], '" class="input_text" />
  354. </dd>
  355. <dt>
  356. <strong>', $txt['spider_ip_info'], ':</strong><br />
  357. <span class="smalltext">', $txt['spider_ip_info_desc'], '</span>
  358. </dt>
  359. <dd>
  360. <textarea name="spider_ip" rows="4" cols="20">', $context['spider']['ip_info'], '</textarea>
  361. </dd>
  362. </dl>
  363. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  364. <input type="hidden" name="', $context['admin-ses_token_var'], '" value="', $context['admin-ses_token'], '" />
  365. <input type="submit" name="save" value="', $context['page_title'], '" class="button_submit" />
  366. </div>
  367. <span class="botslice"><span></span></span>
  368. </div>
  369. </form>
  370. </div>
  371. <br class="clear" />';
  372. }
  373. // Show... spider... logs...
  374. function template_show_spider_logs()
  375. {
  376. global $context, $txt, $settings, $scripturl;
  377. echo '
  378. <div id="admincenter">';
  379. // Standard fields.
  380. template_show_list('spider_logs');
  381. echo '
  382. <br />
  383. <div class="cat_bar">
  384. <h3 class="catbg">', $txt['spider_logs_delete'], '</h3>
  385. </div>
  386. <form action="', $scripturl, '?action=admin;area=sengines;sa=logs;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  387. <div class="windowbg">
  388. <span class="topslice"><span></span></span>
  389. <div class="content">
  390. <p>
  391. ', $txt['spider_logs_delete_older'], '
  392. <input type="text" name="older" id="older" value="7" size="3" class="input_text" />
  393. ', $txt['spider_logs_delete_day'], '
  394. </p>
  395. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  396. <input type="submit" name="delete_entries" value="', $txt['spider_logs_delete_submit'], '" onclick="if (document.getElementById(\'older\').value &lt; 1 &amp;&amp; !confirm(\'' . addcslashes($txt['spider_logs_delete_confirm'], "'") . '\')) return false; return true;" class="button_submit" />
  397. </div>
  398. <span class="botslice"><span></span></span>
  399. </div>
  400. </form>
  401. </div>
  402. <br class="clear" />';
  403. }
  404. ?>