Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
Mar 18, 2012
Niko Pahajoki Order topics by time 2649bf3
Niko Pahajoki New theme db61dd6
146 SMF-2.0/Sources/RelatedTopics.php
@@ -3,153 +3,11 @@
3 3 * Related Topics
4 4 *
5 5 * @package RelatedTopics
6   - * @version 1.4
  6 + * @author Niko Pahajoki http://madjoki.com/
  7 + * @version 1.5
7 8 * @license http://madjoki.com/smf-mods/license/ New-BSD
8 9 */
9 10
10   -function RelatedTopicsAdmin()
11   -{
12   - global $context, $smcFunc, $sourcedir, $user_info, $txt, $related_version;
13   -
14   - require_once($sourcedir . '/Subs-Related.php');
15   - require_once($sourcedir . '/ManageServer.php');
16   -
17   - $related_version = '1.4';
18   -
19   - loadTemplate('RelatedTopicsAdmin');
20   -
21   - $context[$context['admin_menu_name']]['tab_data']['title'] = $txt['related_topics_admin_title'];
22   - $context[$context['admin_menu_name']]['tab_data']['description'] = $txt['related_topics_admin_desc'];
23   -
24   - $context['page_title'] = $txt['related_topics_admin_title'];
25   -
26   - $subActions = array(
27   - 'main' => array('RelatedTopicsAdminMain'),
28   - 'settings' => array('RelatedTopicsAdminSettings'),
29   - 'methods' => array('RelatedTopicsAdminMethods'),
30   - 'buildIndex' => array('RelatedTopicsAdminBuildIndex'),
31   - );
32   -
33   - $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'main';
34   -
35   - if (isset($subActions[$_REQUEST['sa']][1]))
36   - isAllowedTo($subActions[$_REQUEST['sa']][1]);
37   -
38   - $subActions[$_REQUEST['sa']][0]();
39   -}
40   -
41   -function RelatedTopicsAdminMain()
42   -{
43   - global $context, $smcFunc, $sourcedir, $scripturl, $user_info, $txt;
44   -
45   - $context['sub_template'] = 'related_topics_admin_main';
46   -}
47   -
48   -function RelatedTopicsAdminSettings($return_config = false)
49   -{
50   - global $context, $smcFunc, $sourcedir, $scripturl, $user_info, $txt;
51   -
52   - $config_vars = array(
53   - array('check', 'relatedTopicsEnabled'),
54   - array('int', 'relatedTopicsCount'),
55   - );
56   -
57   - if ($return_config)
58   - return $config_vars;
59   -
60   - if (isset($_GET['save']))
61   - {
62   - checkSession('post');
63   - saveDBSettings($config_vars);
64   -
65   - writeLog();
66   -
67   - redirectexit('action=admin;area=relatedtopics;sa=settings');
68   - }
69   -
70   - $context['post_url'] = $scripturl . '?action=admin;area=relatedtopics;sa=settings;save';
71   - $context['settings_title'] = $txt['related_topics_settings_title'];
72   - $context['sub_template'] = 'show_settings';
73   -
74   - prepareDBSettingContext($config_vars);
75   -}
76   -
77   -function RelatedTopicsAdminMethods()
78   -{
79   - global $context, $smcFunc, $modSettings, $scripturl, $user_info, $txt, $db_type;
80   -
81   - initRelated();
82   -
83   - $relatedIndexes = !empty($modSettings['relatedIndex']) ? explode(',', $modSettings['relatedIndex']) : array();
84   -
85   - $context['related_methods'] = array(
86   - 'fulltext' => array(
87   - 'name' => $txt['relatedFulltext'],
88   - 'selected' => false,
89   - 'supported' => $db_type == 'mysql',
90   - ),
91   - );
92   -
93   - foreach ($context['related_methods'] as $id => $dummy)
94   - $context['related_methods'][$id]['selected'] = in_array($id, $relatedIndexes);
95   -
96   - if (isset($_GET['save']))
97   - {
98   - checkSession('post');
99   -
100   - $methods = array();
101   -
102   - if (isset($_POST['related_methods']))
103   - {
104   - foreach ($_POST['related_methods'] as $method)
105   - {
106   - if (isset($context['related_methods'][$method]) && $context['related_methods'][$method]['supported'])
107   - $methods[] = $method;
108   - }
109   - }
110   -
111   - updateSettings(array(
112   - 'relatedIndex' => implode(',', $methods),
113   - 'relatedIgnoredboards' => !empty($_POST['ignored_boards']) ? implode(',', $_POST['ignored_boards']) : '',
114   - ));
115   -
116   - redirectexit('action=admin;area=relatedtopics;sa=methods');
117   - }
118   -
119   - $request = $smcFunc['db_query']('', '
120   - SELECT b.id_board, b.name, c.id_cat, c.name AS cat_name
121   - FROM {db_prefix}boards AS b
122   - LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
123   - WHERE b.redirect = {string:blank_redirect}'. (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? '
124   - AND NOT b.id_board = {int:recyle_board}' : ''),
125   - array(
126   - 'blank_redirect' => '',
127   - 'recyle_board' => $modSettings['recycle_board'],
128   - )
129   - );
130   -
131   - $context['categories'] = array();
132   -
133   - while ($row = $smcFunc['db_fetch_assoc']($request))
134   - {
135   - if (!isset($context['categories'][$row['id_cat']]))
136   - $context['categories'][$row['id_cat']] = array(
137   - 'id' => $row['id_cat'],
138   - 'name' => $row['cat_name'],
139   - 'boards' => array(),
140   - );
141   -
142   - $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
143   - 'id' => $row['id_board'],
144   - 'name' => $row['name'],
145   - 'selected' => in_array($row['id_board'], $context['rt_ignore']),
146   - );
147   - }
148   - $smcFunc['db_free_result']($request);
149   -
150   - $context['sub_template'] = 'related_topics_admin_methods';
151   -}
152   -
153 11 function RelatedTopicsAdminBuildIndex()
154 12 {
155 13 global $smcFunc, $scripturl, $modSettings, $context, $txt;
3  SMF-2.0/Sources/Subs-Related.php
@@ -83,7 +83,8 @@ function prepareTopicArray($topic_ids)
90 SMF-2.0/Themes/default/RelatedTopicsAdmin.template.php
@@ -6,7 +6,7 @@
6 6 * @version 1.4
7 7 */
8 8
9   -function template_related_topics_admin_main()
  9 +function template_main()
10 10 {
11 11 global $context, $modSettings, $txt, $related_version;
12 12
@@ -64,56 +64,8 @@ function setRelatedVersion()
64 64 }
65 65 // ]]></script>
66 66 <script language="JavaScript" type="text/javascript" src="http://service.smfarcade.info/related/news.js?v=', urlencode($related_version), '" defer="defer"></script>';
67   -}
68 67
69   -function template_related_topics_admin_methods()
70   -{
71   - global $context, $modSettings, $txt, $scripturl;
72   -
73   - echo '
74   - <form action="', $scripturl, '?action=admin;area=relatedtopics;sa=methods;save" method="post" accept-charset="', $context['character_set'], '">
75   - <div class="cat_bar">
76   - <h3 class="catbg">', $txt['related_topics_ignored_boards'], '</h3>
77   - </div>
78   - <div class="windowbg2">
79   - <span class="topslice"><span></span></span>
80   - <div class="content">
81   - <dl class="settings">';
82   -
83   - foreach ($context['categories'] as $cat)
84   - {
85   - echo '
86   - <dt>', $cat['name'], '</dt>
87   - <dd>';
88   -
89   - foreach ($cat['boards'] as $id => $board)
90   - echo '
91   - <input type="checkbox" id="ignored_boards_', $id, '" name="ignored_boards[]" value="', $id, '"', $board['selected'] ? ' checked="checked"' : '', '/> <label for="ignored_boards_', $id, '">', $board['name'], '</label><br />';
92   -
93   - echo '
94   - </dd>';
95   - }
96   -
97   - echo '
98   - <dt>', $txt['related_topics_methods'], '</dt>
99   - <dd>';
100   -
101   - foreach ($context['related_methods'] as $id => $method)
102   - echo '
103   - <input type="checkbox" id="method_', $id, '" name="related_methods[]" value="', $id, '"', !$method['supported'] ? ' disabled="disabled"' : '', $method['selected'] ? ' checked="checked"' : '', '/> <label for="method_', $id, '">', $method['name'], '</label><br />';
104   -
105   - echo '
106   - </dd>
107   - </dl>
108   - <hr class="hrcolor clear">
109   - <div class="righttext">
110   - <input type="submit" class="button_submit" value="', $txt['save'], '">
111   - </div>
112   - </div>
113   - <span class="botslice"><span></span></span>
114   - </div>
115   - <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
116   - </form><br /><br />';
  68 + template_show_settings();
117 69
118 70 echo '
119 71 <div class="cat_bar">
@@ -129,4 +81,42 @@ function template_related_topics_admin_methods()
129 81 </div><br />';
130 82 }
131 83
  84 +function template_callback_related_methods()
  85 +{
  86 + global $context, $modSettings, $txt, $related_version;
  87 +
  88 + echo '
  89 + <dt>', $txt['related_topics_methods'], '</dt>
  90 + <dd>';
  91 +
  92 + foreach ($context['related_methods'] as $id => $method)
  93 + echo '
  94 + <input type="checkbox" id="method_', $id, '" name="related_methods[]" value="', $id, '"', !$method['supported'] ? ' disabled="disabled"' : '', $method['selected'] ? ' checked="checked"' : '', '/> <label for="method_', $id, '">', $method['name'], '</label><br />';
  95 +
  96 + echo '
  97 + </dd>';
  98 +}
  99 +
  100 +function template_callback_ignored_boards()
  101 +{
  102 + global $context, $modSettings, $txt, $related_version;
  103 +
  104 + echo '
  105 + <dt>', $txt['related_topics_ignored_boards'], '</dt>
  106 + <dd>';
  107 +
  108 + foreach ($context['categories'] as $cat)
  109 + {
  110 + echo '
  111 + <strong>', $cat['name'], '</strong><br />';
  112 +
  113 + foreach ($cat['boards'] as $id => $board)
  114 + echo '
  115 + <input type="checkbox" id="ignored_boards_', $id, '" name="ignored_boards[]" value="', $id, '"', $board['selected'] ? ' checked="checked"' : '', '/> <label for="ignored_boards_', $id, '">', $board['name'], '</label><br />';
  116 + }
  117 +
  118 + echo '
  119 + </dd>';
  120 +}
  121 +
132 122 ?>
2  build.xml
@@ -4,7 +4,7 @@
4 4 <property name="repository" value="relatedtopics" override="true" />
5 5 <property name="branch" value="trunk" override="true" />
6 6 <property name="package" value="${phing.project.name}" override="true" />
7   - <property name="version" value="1.4.1" override="yes" />
  7 + <property name="version" value="1.5" override="yes" />
8 8
9 9 <property name="builddir" value="./.temp" override="true" />
10 10 <property name="docdir" value="./.temp" override="true" />
144 install.xml
@@ -3,13 +3,20 @@
3 3
4 4 <modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
5 5 <id>Niko:RelatedTopics</id>
6   - <version>{version}</version>
  6 + <version>1.5</version>
7 7
8 8 <file name="$sourcedir/Admin.php">
9 9 <operation>
10   - <search position="after"><![CDATA['current_theme' => array(]]></search>
  10 + <search position="after"><![CDATA['topics' => array($txt['manageposts_topic_settings']),]]></search>
11 11 <add><![CDATA[
12   - 'relatedtopics' => array(
  12 + 'relatedtopics' => array($txt['admin_related_topic']),]]></add>
  13 + </operation>
  14 +
  15 + <!--<operation>
  16 + <search position="before"><![CDATA[ // Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example:]]></search>
  17 + <add><![CDATA[ 'related' => array($txt['admin_related_topic']),]]></add>
  18 + </operation>
  19 + 'relatedtopics' => array(
13 20 'label' => $txt['admin_related_topic'],
14 21 'file' => 'RelatedTopics.php',
15 22 'function' => 'RelatedTopicsAdmin',
@@ -18,13 +25,134 @@
18 25 'settings' => array($txt['admin_related_topics_settings']),
19 26 'methods' => array($txt['admin_related_topics_methods']),
20 27 ),
21   - ),
22   - ]]></add>
  28 + ),-->
  29 + </file>
  30 +
  31 + <file name="$sourcedir/ManagePosts.php">
  32 + <operation>
  33 + <search position="before"><![CDATA['topics' => 'ModifyTopicSettings',]]></search>
  34 + <add><![CDATA[
  35 + 'relatedtopics' => 'ModifyRelatedTopicsSettings',]]></add>
23 36 </operation>
24   -
  37 +
25 38 <operation>
26   - <search position="before"><![CDATA[ // Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example:]]></search>
27   - <add><![CDATA[ 'related' => array($txt['admin_related_topic']),]]></add>
  39 + <search position="before"><![CDATA['topics' => array(
  40 + 'description' => $txt['manageposts_topic_settings_description'],
  41 + ),]]></search>
  42 + <add><![CDATA[
  43 + 'relatedtopics' => array(
  44 + 'description' => 'change this',
  45 + ),]]></add>
  46 + </operation>
  47 +
  48 + <operation>
  49 + <search position="end"></search>
  50 + <add><![CDATA[
  51 +function ModifyRelatedTopicsSettings($return_config = false)
  52 +{
  53 + global $context, $smcFunc, $modSettings, $sourcedir, $user_info, $txt, $related_version, $db_type;
  54 +
  55 + $context['show_rebuild_warning'] = empty($modSettings['relatedTopics_ID']) || $modSettings['relatedTopics_ID'] != $modSettings['maxMsgID'];
  56 +
  57 + $related_version = '1.5';
  58 +
  59 + loadTemplate('RelatedTopicsAdmin');
  60 +
  61 + $config_vars = array(
  62 + array('check', 'relatedTopicsEnabled'),
  63 + array('int', 'relatedTopicsCount'),
  64 +
  65 + array('callback', 'related_methods'),
  66 + array('callback', 'ignored_boards')
  67 + );
  68 +
  69 + if ($return_config)
  70 + return $config_vars;
  71 +
  72 + require_once($sourcedir . '/Subs-Related.php');
  73 + require_once($sourcedir . '/ManageServer.php');
  74 +
  75 + initRelated();
  76 +
  77 + //
  78 + $relatedIndexes = !empty($modSettings['relatedIndex']) ? explode(',', $modSettings['relatedIndex']) : array();
  79 +
  80 + $context['related_methods'] = array(
  81 + 'fulltext' => array(
  82 + 'name' => $txt['relatedFulltext'],
  83 + 'selected' => false,
  84 + 'supported' => $db_type == 'mysql',
  85 + ),
  86 + );
  87 +
  88 + foreach ($context['related_methods'] as $id => $dummy)
  89 + $context['related_methods'][$id]['selected'] = in_array($id, $relatedIndexes);
  90 +
  91 + if (isset($_GET['save']))
  92 + {
  93 + checkSession('post');
  94 + saveDBSettings($config_vars);
  95 +
  96 + //writeLog();
  97 +
  98 + $methods = array();
  99 +
  100 + if (isset($_POST['related_methods']))
  101 + {
  102 + foreach ($_POST['related_methods'] as $method)
  103 + {
  104 + if (isset($context['related_methods'][$method]) && $context['related_methods'][$method]['supported'])
  105 + $methods[] = $method;
  106 + }
  107 + }
  108 +
  109 + updateSettings(array(
  110 + 'relatedIndex' => implode(',', $methods),
  111 + 'relatedIgnoredboards' => !empty($_POST['ignored_boards']) ? implode(',', $_POST['ignored_boards']) : '',
  112 + 'relatedTopics_ID' => 0,
  113 + ));
  114 +
  115 + redirectexit('action=admin;area=postsettings;sa=relatedtopics');
  116 + }
  117 +
  118 + // Load boards
  119 + $request = $smcFunc['db_query']('', '
  120 + SELECT b.id_board, b.name, c.id_cat, c.name AS cat_name
  121 + FROM {db_prefix}boards AS b
  122 + LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
  123 + WHERE b.redirect = {string:blank_redirect}'. (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? '
  124 + AND NOT b.id_board = {int:recyle_board}' : ''),
  125 + array(
  126 + 'blank_redirect' => '',
  127 + 'recyle_board' => $modSettings['recycle_board'],
  128 + )
  129 + );
  130 +
  131 + $context['categories'] = array();
  132 +
  133 + while ($row = $smcFunc['db_fetch_assoc']($request))
  134 + {
  135 + if (!isset($context['categories'][$row['id_cat']]))
  136 + $context['categories'][$row['id_cat']] = array(
  137 + 'id' => $row['id_cat'],
  138 + 'name' => $row['cat_name'],
  139 + 'boards' => array(),
  140 + );
  141 +
  142 + $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
  143 + 'id' => $row['id_board'],
  144 + 'name' => $row['name'],
  145 + 'selected' => in_array($row['id_board'], $context['rt_ignore']),
  146 + );
  147 + }
  148 + $smcFunc['db_free_result']($request);
  149 +
  150 + $context['post_url'] = $scripturl . '?action=admin;area=postsettings;sa=relatedtopics;save';
  151 + $context['settings_title'] = $txt['related_topics_settings_title'];
  152 +
  153 + prepareDBSettingContext($config_vars);
  154 +}
  155 +]]></add>
28 156 </operation>
29 157 </file>
30 158
2  package-info.xml
@@ -21,7 +21,7 @@
21 21 <modification type="file">install.xml</modification>
22 22 <modification type="file">language.xml</modification>
23 23
24   - <redirect url="$scripturl?action=admin;area=relatedtopics;sa=methods"></redirect>
  24 + <redirect url="$scripturl?action=admin;area=postsettings;sa=relatedtopics"></redirect>
25 25 </install>
26 26
27 27 <uninstall>

No commit comments for this range

Something went wrong with that request. Please try again.