Skip to content

Commit

Permalink
cleaned up many orphan references to $smcFunc[]
Browse files Browse the repository at this point in the history
tagging system is now an optional core feature
added template hook content output to board index, header, footer and side bar areas
  • Loading branch information
silvercircle committed Oct 29, 2011
1 parent 69332dc commit 98a7369
Show file tree
Hide file tree
Showing 35 changed files with 217 additions and 185 deletions.
6 changes: 3 additions & 3 deletions SSI.php
Expand Up @@ -393,7 +393,7 @@ function ssi_queryPosts($query_where = '', $query_where_params = array(), $query
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt['by'], ' ', $post['poster']['link'], '
', $post['is_new'] ? '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>' : '', '
', $post['is_new'] ? '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/new.png" alt="' . $txt['new'] . '" /></a>' : '', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
Expand Down Expand Up @@ -524,7 +524,7 @@ function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boar
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt['by'], ' ', $post['poster']['link'], '
', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>', '
', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/new.png" alt="' . $txt['new'] . '" /></a>', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
Expand Down Expand Up @@ -619,7 +619,7 @@ function ssi_topBoards($num_top = 10, $output_method = 'echo')
foreach ($boards as $board)
echo '
<tr>
<td>', $board['link'], $board['new'] ? ' <a href="' . $board['href'] . '"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>' : '', '</td>
<td>', $board['link'], $board['new'] ? ' <a href="' . $board['href'] . '"><img src="' . $settings['images_url'] . '/new.png" alt="' . $txt['new'] . '" /></a>' : '', '</td>
<td align="right">', comma_format($board['num_topics']), '</td>
<td align="right">', comma_format($board['num_posts']), '</td>
</tr>';
Expand Down
3 changes: 2 additions & 1 deletion Sources/Admin.php
Expand Up @@ -471,7 +471,8 @@ function AdminMain()
),
),
);

if(!$modSettings['tags_active'])
unset($admin_areas['layout']['areas']['postsettings']['subsections']['tags']);
// Any files to include for administration?
if (!empty($modSettings['integrate_admin_include']))
{
Expand Down
5 changes: 4 additions & 1 deletion Sources/BoardIndex.php
Expand Up @@ -116,9 +116,12 @@ function BoardIndex()

$context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);

$context['template_hooks']['boardindex'] = array(
'above_boardlisting' => '',
'below_boardlisting' => ''
);
if(!empty($modSettings['enableAdvancedHooks']))
HookAPI::callHook('integrate_boardindex', array());

fetchNewsItems(0, 0);
}

Expand Down
50 changes: 26 additions & 24 deletions Sources/Display.php
Expand Up @@ -184,22 +184,26 @@ function Display()
$_SESSION['last_read_topic'] = $topic;
}

// get the tags for this topic
$dbresult= smf_db_query( '
SELECT t.tag,l.ID,t.ID_TAG FROM {db_prefix}tags_log as l, {db_prefix}tags as t
WHERE t.ID_TAG = l.ID_TAG && l.ID_TOPIC = {int:topic}',
array('topic' => $topic));

$context['topic_tags'] = array();
while($row = mysql_fetch_assoc($dbresult)) {
$context['topic_tags'][] = array(
'ID' => $row['ID'],
'ID_TAG' => $row['ID_TAG'],
'tag' => $row['tag'],
);
}
mysql_free_result($dbresult);

if($modSettings['tags_active']) {
$dbresult= smf_db_query( '
SELECT t.tag,l.ID,t.ID_TAG FROM {db_prefix}tags_log as l, {db_prefix}tags as t
WHERE t.ID_TAG = l.ID_TAG && l.ID_TOPIC = {int:topic}',
array('topic' => $topic));

$context['topic_tags'] = array();
while($row = mysql_fetch_assoc($dbresult)) {
$context['topic_tags'][] = array(
'ID' => $row['ID'],
'ID_TAG' => $row['ID_TAG'],
'tag' => $row['tag'],
);
}
mysql_free_result($dbresult);
$context['tags_active'] = true;
}
else
$context['topic_tags'] = $context['tags_active'] = 0;

// Get all the important topic info.
$request = smf_db_query( '
SELECT
Expand Down Expand Up @@ -1227,8 +1231,8 @@ function Display()
// Callback for the message display.
function prepareDisplayContext($reset = false)
{
global $settings, $txt, $modSettings, $scripturl, $options, $user_info;
global $memberContext, $context, $messages_request, $topic, $board_info;
global $txt, $modSettings, $options, $user_info;
global $memberContext, $context, $messages_request, $topic;

static $counter = null;

Expand Down Expand Up @@ -1309,14 +1313,12 @@ function prepareDisplayContext($reset = false)
censorText($message['body']);

// Compose the memory eat- I mean message array.
$t_href = URL::topic($topic, $message['subject'], 0, false, '.msg' . $message['id_msg'] . '#msg'.$message['id_msg']);
//$t_href = URL::topic($topic, $message['subject'], 0, false, '.msg' . $message['id_msg'] . '#msg'.$message['id_msg']);
$output = array(
'attachment' => loadAttachmentContext($message['id_msg']),
'alternate' => $counter % 2,
'id' => $message['id_msg'],
//'href' => $scripturl . '?topic=' . $topic . '.msg' . $message['id_msg'] . '#msg' . $message['id_msg'],
'permahref' => URL::parse('?msg=' . $message['id_msg']),
//'link' => '<a href="' . $scripturl . '?topic=' . $topic . '.msg' . $message['id_msg'] . '#msg' . $message['id_msg'] . '" rel="nofollow">' . $message['subject'] . '</a>',
'member' => &$memberContext[$message['id_member']],
'icon' => $message['icon'],
'icon_url' => getPostIcon($message['icon']),
Expand Down Expand Up @@ -1352,7 +1354,7 @@ function prepareDisplayContext($reset = false)
$output['likes_count'] = 0;
// Is this user the message author?
$output['is_message_author'] = $message['id_member'] == $user_info['id'];
$counter = (empty($options['view_newest_first']) ? $counter++ : $counter--);
$counter += (empty($options['view_newest_first']) ? 1 : -1);
// hooks can populate these fields with additional content
$output['template_hook'] = array(
'before_sig' => '',
Expand All @@ -1369,7 +1371,7 @@ function prepareDisplayContext($reset = false)
// Download an attachment.
function Download()
{
global $txt, $modSettings, $user_info, $scripturl, $context, $sourcedir, $topic, $smcFunc;
global $txt, $modSettings, $user_info, $context, $topic;

// Some defaults that we need.
$context['character_set'] = empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'];
Expand Down Expand Up @@ -1785,7 +1787,7 @@ function approved_attach_sort($a, $b)
// In-topic quick moderation.
function QuickInTopicModeration()
{
global $sourcedir, $topic, $board, $user_info, $smcFunc, $modSettings, $context;
global $sourcedir, $topic, $board, $user_info, $modSettings, $context;

// Check the session = get or post.
checkSession('request');
Expand Down
51 changes: 25 additions & 26 deletions Sources/Load.php
Expand Up @@ -126,7 +126,7 @@
// Load the $modSettings array.
function reloadSettings()
{
global $modSettings, $smcFunc, $sourcedir, $boardurl, $db_cache_api, $db_cache_memcached;
global $modSettings, $sourcedir, $boardurl, $db_cache_api, $db_cache_memcached;

$no_hooks = ((isset($g_disable_all_hooks) && $g_disable_all_hooks === true) || isset($_REQUEST['nohooks']));

Expand Down Expand Up @@ -203,10 +203,15 @@ function reloadSettings()
db_fatal_error(true);
}

// Is post moderation alive and well?
$modSettings['postmod_active'] = isset($modSettings['admin_features']) ? in_array('pm', explode(',', $modSettings['admin_features'])) : true;
$modSettings['astream_active'] = isset($modSettings['admin_features']) ? in_array('as', explode(',', $modSettings['admin_features'])) : true;

if(isset($modSettings['admin_features'])) {
$_f = explode(',', $modSettings['admin_features']);
$modSettings['postmod_active'] = in_array('pm', $_f);
$modSettings['astream_active'] = in_array('as', $_f);
$modSettings['tags_active'] = in_array('ts', $_f);
}
else
$modSettings['tags_active'] = $modSettings['postmod_active'] = $modSettings['astream_active'] = true;

require_once($sourcedir . '/SimpleSEF.php');
//require_once($sourcedir . '/URLFactory.php');
URL::init($boardurl);
Expand All @@ -226,7 +231,7 @@ function reloadSettings()
// Load all the important user information...
function loadUserSettings()
{
global $modSettings, $user_settings, $sourcedir, $smcFunc;
global $modSettings, $user_settings, $sourcedir;
global $cookiename, $user_info, $language, $context;

// Check first the integration, then the cookie, and last the session.
Expand Down Expand Up @@ -499,7 +504,7 @@ function loadUserSettings()
function loadBoard()
{
global $txt, $scripturl, $context, $modSettings;
global $board_info, $board, $topic, $user_info, $smcFunc;
global $board_info, $board, $topic, $user_info;

// Assume they are not a moderator.
$user_info['is_mod'] = false;
Expand Down Expand Up @@ -779,7 +784,7 @@ function loadBoard()
// Load this user's permissions.
function loadPermissions()
{
global $user_info, $board, $board_info, $modSettings, $smcFunc, $sourcedir;
global $user_info, $board, $board_info, $modSettings, $sourcedir;

if ($user_info['is_admin'])
{
Expand Down Expand Up @@ -1054,8 +1059,7 @@ function loadMemberData($users, $is_name = false, $set = 'normal')
function loadMemberContext($user, $display_custom_fields = false)
{
global $memberContext, $user_profile, $txt, $scripturl, $user_info;
global $context, $modSettings, $board_info, $settings;
global $smcFunc;
global $context, $modSettings, $settings;
static $dataLoaded = array();

// If this person's data is already loaded, skip it.
Expand Down Expand Up @@ -1276,9 +1280,9 @@ function detectBrowser()
// Load a theme, by ID.
function loadTheme($id_theme = 0, $initialize = true)
{
global $user_info, $user_settings, $board_info, $sc, $boarddir;
global $txt, $boardurl, $scripturl, $mbname, $modSettings, $language;
global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc;
global $user_info, $user_settings, $board_info, $boarddir;
global $txt, $boardurl, $scripturl, $mbname, $modSettings;
global $context, $settings, $options, $sourcedir, $ssi_theme;

// The theme was specified by parameter.
if (!empty($id_theme))
Expand Down Expand Up @@ -1663,7 +1667,6 @@ function loadTheme($id_theme = 0, $initialize = true)

// This allows us to change the way things look for the admin.
$context['admin_features'] = isset($modSettings['admin_features']) ? explode(',', $modSettings['admin_features']) : array('cd,cp,k,w,rg,ml,pm');
$context['astream_active'] = in_array('as', $context['admin_features']);
// If we think we have mail to send, let's offer up some possibilities... robots get pain (Now with scheduled task support!)
if ((!empty($modSettings['mail_next_send']) && $modSettings['mail_next_send'] < time() && empty($modSettings['mail_queue_use_cron'])) || empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
{
Expand Down Expand Up @@ -1800,7 +1803,7 @@ function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
// Load a sub template... fatal is for templates that shouldn't get a 'pretty' error screen.
function loadSubTemplate($sub_template_name, $fatal = false)
{
global $context, $settings, $options, $txt, $db_show_debug;
global $context, $txt, $db_show_debug;

if ($db_show_debug === true)
$context['debug']['sub_templates'][] = $sub_template_name;
Expand All @@ -1826,7 +1829,7 @@ function loadSubTemplate($sub_template_name, $fatal = false)
function loadLanguage($template_name, $lang = '', $fatal = true, $force_reload = false)
{
global $user_info, $language, $settings, $context, $modSettings;
global $cachedir, $db_show_debug, $sourcedir, $txt;
global $db_show_debug, $sourcedir, $txt;
static $already_loaded = array();

// Default to the user's language.
Expand Down Expand Up @@ -1917,8 +1920,6 @@ function loadLanguage($template_name, $lang = '', $fatal = true, $force_reload =
// Get all parent boards (requires first parent as parameter)
function getBoardParents($id_parent)
{
global $scripturl, $smcFunc;

// First check if we have this cached already.
if (($boards = CacheAPI::getCache('board_parents-' . $id_parent, 480)) === null)
{
Expand Down Expand Up @@ -1980,7 +1981,7 @@ function getBoardParents($id_parent)
// Attempt to reload our languages.
function getLanguages($use_cache = true, $favor_utf8 = true)
{
global $context, $smcFunc, $settings, $modSettings;
global $context, $settings, $modSettings;

// Either we don't use the cache, or its expired.
if (!$use_cache || ($context['languages'] = CacheAPI::getCache('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
Expand Down Expand Up @@ -2050,7 +2051,7 @@ function getLanguages($use_cache = true, $favor_utf8 = true)
function &censorText(&$text, $force = false)
{
global $modSettings, $options, $settings, $txt;
static $censor_vulgar = null, $censor_proper;
static $censor_vulgar = null, $censor_proper = null;

if ((!empty($options['show_no_censored']) && $settings['allow_no_censored'] && !$force) || empty($modSettings['censor_vulgar']))
return $text;
Expand Down Expand Up @@ -2083,8 +2084,8 @@ function &censorText(&$text, $force = false)
// Load the template/language file using eval or require? (with eval we can show an error message!)
function template_include($filename, $once = false)
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;
global $user_info, $boardurl, $boarddir, $sourcedir;
global $context, $settings, $txt, $scripturl, $modSettings;
global $boardurl, $boarddir, $sourcedir;
global $maintenance, $mtitle, $mmessage;
static $templates = array();

Expand Down Expand Up @@ -2394,8 +2395,6 @@ function sessionWrite($session_id, $data)

function sessionDestroy($session_id)
{
global $smcFunc;

if (preg_match('~^[A-Za-z0-9,-]{16,32}$~', $session_id) == 0)
return false;

Expand Down Expand Up @@ -2487,7 +2486,7 @@ function cache_quick_get($key, $file, $function, $params, $level = 1)
// Do we think the current user is a spider?
function SpiderCheck()
{
global $modSettings, $smcFunc;
global $modSettings;

if (isset($_SESSION['id_robot']))
unset($_SESSION['id_robot']);
Expand Down Expand Up @@ -2561,7 +2560,7 @@ function SpiderCheck()
//!!! Different file?
function logSpider()
{
global $smcFunc, $modSettings, $context;
global $modSettings, $context;

if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot']))
return;
Expand Down
15 changes: 8 additions & 7 deletions Sources/ManagePosts.php
Expand Up @@ -55,7 +55,7 @@

function ManagePostSettings()
{
global $context, $txt, $scripturl;
global $context, $txt, $modSettings;

// Make sure you can be here.
isAllowedTo('admin_forum');
Expand All @@ -66,9 +66,10 @@ function ManagePostSettings()
'censor' => 'SetCensor',
'topics' => 'ModifyTopicSettings',
'prefixes' => 'ModifyPrefixSettings',
'tags' => 'ModifyTagSettings',
);

if($modSettings['tags_active'])
$subActions['tags'] = 'ModifyTagSettings';

if(in_array('dr', $context['admin_features']))
$subActions['drafts'] = 'ModifyDraftSettings';

Expand Down Expand Up @@ -108,7 +109,7 @@ function ManagePostSettings()
// Set the censored words.
function SetCensor()
{
global $txt, $modSettings, $context, $smcFunc;
global $txt, $modSettings, $context;

if (!empty($_POST['save_censor']))
{
Expand Down Expand Up @@ -187,7 +188,7 @@ function SetCensor()
// Modify all settings related to posts and posting.
function ModifyPostSettings($return_config = false)
{
global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $db_prefix;
global $context, $txt, $modSettings, $scripturl, $sourcedir;

// All the settings...
$config_vars = array(
Expand Down Expand Up @@ -284,7 +285,7 @@ function ModifyPostSettings($return_config = false)
// Bulletin Board Code...a lot of Bulletin Board Code.
function ModifyBBCSettings($return_config = false)
{
global $context, $txt, $modSettings, $helptxt, $scripturl, $sourcedir;
global $context, $txt, $modSettings, $scripturl, $sourcedir;

$config_vars = array(
// Main tweaks
Expand Down Expand Up @@ -395,7 +396,7 @@ function ModifyTopicSettings($return_config = false)

function getPrefixes()
{
global $context, $smcFunc;
global $context;

$request = smf_db_query( '
SELECT * FROM {db_prefix}prefixes');
Expand Down

0 comments on commit 98a7369

Please sign in to comment.