Skip to content

Commit

Permalink
got rid of some hardcoded strings (use $txt)
Browse files Browse the repository at this point in the history
support for local CSS overrides in the header via register-able CSS fragments
  • Loading branch information
silvercircle committed Jan 11, 2012
1 parent 797ef9f commit d0de0bf
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Sources/CommonAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private static function getMemcacheServer($level = 3)
self::getMemcacheServer($level - 1);
}

public static function cacheInit($desired, $basekey, $memcached_hosts)
public static function init($desired, $basekey, $memcached_hosts)
{
self::$basekey = $basekey;
self::$memcached_hosts = $memcached_hosts;
Expand Down Expand Up @@ -368,10 +368,11 @@ public static function disable()

public static function getEngine()
{
global $txt;
$engines = array('Filesystem cache', 'APC', 'Xcache', 'Zend', 'Memcached', 'New PECL Memcached');

if(-1 == self::$API)
return('Caching is disabled or not available');
return($txt['caching_disabled']);
else
return($engines[(int)self::$API]);
}
Expand Down
7 changes: 4 additions & 3 deletions Sources/Load.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@
// Load the $modSettings array.
function reloadSettings()
{
global $modSettings, $sourcedir, $boardurl, $db_cache_api, $db_cache_memcached;
global $modSettings, $sourcedir, $boardurl;

//todo: the $_REQUEST[] thing should go away, it is only for debugging
$no_hooks = ((isset($GLOBALS['g_disable_all_hooks']) && $GLOBALS['g_disable_all_hooks'] === true) || isset($_REQUEST['nohooks']));

CacheAPI::cacheInit($db_cache_api, md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-', $db_cache_memcached);
CacheAPI::init($GLOBALS['db_cache_api'], md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-', $GLOBALS['db_cache_memcached']);

// Most database systems have not set UTF-8 as their default input charset.
smf_db_query('
Expand Down Expand Up @@ -1121,7 +1122,7 @@ function loadMemberContext($user, $display_custom_fields = false)
'buddies' => $buddy_list,
'title' => !empty($modSettings['titlesEnable']) ? $profile['usertitle'] : '',
'href' => $m_href,
'link' => '<a onclick="getMcard('.$profile['id_member'].', $(this));return(false);" href="' . $m_href . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '">' . $profile['real_name'] . '</a>',
'link' => '<a onclick="getMcard('.$profile['id_member'].');return(false);" href="' . $m_href . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '">' . $profile['real_name'] . '</a>',
'email' => $profile['email_address'],
'show_email' => showEmailAddress(!empty($profile['hide_email']), $profile['id_member']),
'registered' => empty($profile['date_registered']) ? $txt['not_applicable'] : timeformat($profile['date_registered']),
Expand Down
2 changes: 1 addition & 1 deletion Sources/Subs-LikeSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function LikesGenerateOutput($like_status, &$output, $total_likes, $mid, $have_l
$output = $txt['you_like_it'];
else if($total_likes > 4) {
$output = vsprintf($like_template[5], $results);
$output .= ('<a class="likedpost" onclick="getLikes('.$mid.', $(this));return(false);" rel="nofollow" href="'.$scripturl.'?action=like;sa=getlikes;;m='.$mid.'">'. ($total_likes - $count).$txt['like_others']);
$output .= ('<a class="likedpost" onclick="getLikes('.$mid.');return(false);" rel="nofollow" href="'.$scripturl.'?action=like;sa=getlikes;;m='.$mid.'">'. ($total_likes - $count).$txt['like_others']);
}
else
$output = vsprintf($like_template[$count], $results);
Expand Down
8 changes: 8 additions & 0 deletions Sources/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4116,6 +4116,14 @@ function registerFooterScriptFragment($key, $script)
if(!empty($key) && !empty($script))
$context['footer_script_fragments'][$key] = $script;
}

function registerCSSOverrideFragment($t)
{
global $context;

if(!empty($t))
$context['css_overrides'][] = $t;
}
/**
* @param int $board board id or 0
* @param int $topic topic id or 0
Expand Down
5 changes: 4 additions & 1 deletion Themes/default/LikeSystem.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* license: BSD, See included LICENSE.TXT for terms and conditions.
*
* @version 1.0pre
*
* this implements templates for the output of likes, except the templates for
* a member's profile which are in Profile.template.php
*/
function template_getlikes_xml()
{
Expand All @@ -18,7 +21,7 @@ function template_getlikes_xml()
echo '<', '?xml version="1.0" encoding="UTF-8" ?', '>';
echo '
<document>
<response open="default" width="400px">
<response open="default" width="400px" offset="-100">
<content>
<![CDATA[
<div class="title_bar">
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ li.cat_desc > h3 {
#mcard h1 {
height: 20px;
line-height: 20px;
font-size: 1.3em;
font-size: 1.2em;
color: white;
text-shadow: 2px 2px 5px black;
}
Expand Down
9 changes: 8 additions & 1 deletion Themes/default/index.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ function template_html_above()
echo $context['html_headers'];
echo '
<style>
#main_content_section {max-width:',isset($options['content_width']) ? $options['content_width'] : '95%', ';}
#main_content_section {max-width:',isset($options['content_width']) ? $options['content_width'] : '95%', ';}';
if(isset($context['css_overrides'])) {
foreach($context['css_overrides'] as $k)
echo '
',$k,'
';
}
echo '
</style>
</head>
<body>';
Expand Down
5 changes: 4 additions & 1 deletion Themes/default/languages/Activities-Profile.english.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

/*
* this is outsourced from the Activities language file, because all these strings are only needed
* in the user's profile secion. We avoid some language file bloat...
*/
$txt['act_optout_desc'] = 'Select the activity entries that should be created on your behalf. Any activity you uncheck here will prevent the activity stream from recording it. It will also stop other users from receiving notification from events done by you.<br><br>You will still receive notifications from events done by other users (see below for selecting the notification types you want to receive).';
$txt['notify_optout_desc'] = 'Select what types of notifications from activities by other forum members you want to receive.';

Expand Down
2 changes: 1 addition & 1 deletion Themes/default/languages/Help.english.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@

$helptxt['disableHostnameLookup'] = 'This disables host name lookups, which on some servers are very slow. Note that this will make banning less effective.';
$helptxt['disableAllHooks'] = 'If checked, all hooks are disabled. You can use this temporarily to prevent broken addons from rendering your forum unusable';
$helptxt['jQueryFromGoogleCDN'] = 'When checked, the jQuery JavaScript library will be loaded from Google\'s content delivery network to save some bandwidth on your server.<br><br>Also, it may speed up initial page loading for some users, because it is likely that a user\'s browser already has a cached copy of jQuery from Google\'s CDN in the browser cache.';
$helptxt['jQueryFromGoogleCDN'] = 'When checked, the jQuery JavaScript library will be loaded from Google\'s content delivery network to save some bandwidth on your server.<br><br>Also, it may speed up initial page loading for users, because a visitor\'s browser may already hold a cached copy of jQuery from Google\'s CDN in its cache.';

$helptxt['search_weight_frequency'] = 'Weight factors are used to determine the relevancy of a search result. Change these weight factors to match the things that are specifically important for your forum. For instance, a forum of a news site, might want a relatively high value for \'age of last matching message\'. All values are relative in relation to each other and should be positive integers.<br /><br />This factor counts the amount of matching messages and divides them by the total number of messages within a topic.';
$helptxt['search_weight_age'] = 'Weight factors are used to determine the relevancy of a search result. Change these weight factors to match the things that are specifically important for your forum. For instance, a forum of a news site, might want a relatively high value for \'age of last matching message\'. All values are relative in relation to each other and should be positive integers.<br /><br />This factor rates the age of the last matching message within a topic. The more recent this message is, the higher the score.';
Expand Down
1 change: 1 addition & 0 deletions Themes/default/languages/ManageSettings.english.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
%1$s
</div>';

$txt['caching_disabled'] = 'Caching is either disabled or not supported on your server';
$txt['detected_no_caching'] = '<strong class="alert">SMF has not been able to detect a compatible accelerator on your server.</strong>';
$txt['detected_APC'] = '<strong style="color: green">SMF has detected that your server has APC installed.</strong> (config value for Settings.php = "apc")';
$txt['detected_Zend'] = '<strong style="color: green">SMF has detected that your server has Zend installed.</strong> (config value for Settings.php = "zend")';
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/scripts/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,14 +1439,14 @@ function getAStream(el)
else
sendRequest('action=astream;sa=get;b=' + parseInt(_el.attr('data-board')) + ';xml', null);
}
function getMcard(uid, el)
function getMcard(uid)
{
if(uid > 0)
sendRequest('action=xmlhttp;sa=mcard;u=' + parseInt(uid), null);
return(false);
}

function getLikes(mid, el)
function getLikes(mid)
{
sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=like;sa=getlikes;m=' + mid + ';xml', '', response_xml);
}
Expand Down

0 comments on commit d0de0bf

Please sign in to comment.