ManageSearch.template.php 21 KB

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