Commit 099369df by Scott

Minor changes and refactorings

From PRs by @pupi1985 (unmergeable due to file structure changes).
Closes #69.
Closes #126.
parent 568ac85b
......@@ -384,7 +384,7 @@
if ( (!QA_FINAL_EXTERNAL_USERS) && qa_opt('moderate_users') && ($level>=QA_USER_LEVEL_MODERATOR)) {
$count=qa_opt('cache_uapprovecount');
$navigation['admin/moderate-users']=array(
$navigation['admin/approve']=array(
'label' => qa_lang_html('admin/approve_users_title').($count ? (' ('.$count.')') : ''),
'url' => qa_path_html('admin/approve'),
);
......
......@@ -379,7 +379,7 @@
if (qa_opt('comment_on_qs') || qa_opt('comment_on_as'))
array_push($showoptions, 'show_fewer_cs_from', 'show_fewer_cs_count', 'show_c_reply_buttons');
$showoptins[] = '';
$showoptions[] = '';
$widgets = qa_db_single_select(qa_db_widgets_selectspec());
......
......@@ -705,7 +705,7 @@
if ($otheranswer['created']>$lastbeforetime) {
$lastbeforeid=$otheranswer['postid'];
$lastebeforetime=$otheranswer['created'];
$lastbeforetime=$otheranswer['created'];
}
}
......
......@@ -1138,14 +1138,14 @@
// Language phrase support
/**
* Return the translated string for $identifier, unless we're using external translation logic.
* This will retrieve the 'site_language' option so make sure you've already loaded/set that if
* loading an option now will cause a problem (see issue in qa_default_option()). The part of
* $identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the
* part after the / is the key of the array element to be taken from that file's returned result.
*/
function qa_lang($identifier)
/*
Return the translated string for $identifier, unless we're using external translation logic.
This will retrieve the 'site_language' option so make sure you've already loaded/set that if
loading an option now will cause a problem (see issue in qa_default_option()). The part of
$identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the
part after the / is the key of the array element to be taken from that file's returned result.
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
......@@ -1153,7 +1153,7 @@
list($group, $label)=explode('/', $identifier, 2);
// First look for a custom phrase
// First look for a custom phrase in qa-lang/custom/
if (!isset($qa_phrases_custom[$group])) { // only load each language file once
$phrases=@include QA_LANG_DIR.'custom/qa-lang-'.$group.'.php'; // can tolerate missing file or directory
......@@ -1163,7 +1163,7 @@
if (isset($qa_phrases_custom[$group][$label]))
return $qa_phrases_custom[$group][$label];
// Second look for a localized file
// Second look for a localized file in qa-lang/<lang>/
$languagecode=qa_opt('site_language');
......@@ -1182,7 +1182,7 @@
return $qa_phrases_lang[$group][$label];
}
// Finally load the default
// Finally load the default language files
if (!isset($qa_phrases_default[$group])) { // only load each default language file once
if (isset($qa_lang_file_pattern[$group]))
......
......@@ -186,37 +186,37 @@
}
/**
* Run the appropriate qa-page-*.php file for this request and return back the $qa_content it passed
*/
function qa_get_request_content()
/*
Run the appropriate qa-page-*.php file for this request and return back the $qa_content it passed
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$requestlower=strtolower(qa_request());
$requestparts=qa_request_parts();
$firstlower=strtolower($requestparts[0]);
$routing=qa_page_routing();
$requestlower = strtolower(qa_request());
$requestparts = qa_request_parts();
$firstlower = strtolower($requestparts[0]);
$routing = qa_page_routing();
if (isset($routing[$requestlower])) {
qa_set_template($firstlower);
$qa_content=require QA_INCLUDE_DIR.$routing[$requestlower];
$qa_content = require QA_INCLUDE_DIR.$routing[$requestlower];
} elseif (isset($routing[$firstlower.'/'])) {
qa_set_template($firstlower);
$qa_content=require QA_INCLUDE_DIR.$routing[$firstlower.'/'];
$qa_content = require QA_INCLUDE_DIR.$routing[$firstlower.'/'];
} elseif (is_numeric($requestparts[0])) {
qa_set_template('question');
$qa_content=require QA_INCLUDE_DIR.'pages/question.php';
$qa_content = require QA_INCLUDE_DIR.'pages/question.php';
} else {
qa_set_template(strlen($firstlower) ? $firstlower : 'qa'); // will be changed later
$qa_content=require QA_INCLUDE_DIR.'pages/default.php'; // handles many other pages, including custom pages and page modules
$qa_content = require QA_INCLUDE_DIR.'pages/default.php'; // handles many other pages, including custom pages and page modules
}
if ($firstlower=='admin') {
$_COOKIE['qa_admin_last']=$requestlower; // for navigation tab now...
if ($firstlower == 'admin') {
$_COOKIE['qa_admin_last'] = $requestlower; // for navigation tab now...
setcookie('qa_admin_last', $_COOKIE['qa_admin_last'], 0, '/', QA_COOKIE_DOMAIN); // ...and in future
}
......@@ -227,10 +227,10 @@
}
/**
* Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript
*/
function qa_output_content($qa_content)
/*
Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
......@@ -312,21 +312,21 @@
// Combine various Javascript elements in $qa_content into single array for theme layer
$script=array('<script type="text/javascript">');
$script = array('<script>');
if (isset($qa_content['script_var']))
foreach ($qa_content['script_var'] as $var => $value)
$script[]='var '.$var.'='.qa_js($value).';';
$script[] = 'var '.$var.' = '.qa_js($value).';';
if (isset($qa_content['script_lines']))
foreach ($qa_content['script_lines'] as $scriptlines) {
$script[]='';
$script=array_merge($script, $scriptlines);
$script[] = '';
$script = array_merge($script, $scriptlines);
}
if (isset($qa_content['focusid']))
$qa_content['script_onloads'][]=array(
"var elem=document.getElementById(".qa_js($qa_content['focusid']).");",
$qa_content['script_onloads'][] = array(
"var elem = document.getElementById(".qa_js($qa_content['focusid']).");",
"if (elem) {",
"\telem.select();",
"\telem.focus();",
......@@ -336,41 +336,42 @@
if (isset($qa_content['script_onloads'])) {
array_push($script,
'',
'var qa_oldonload=window.onload;',
'window.onload=function() {',
"\tif (typeof qa_oldonload=='function')",
'var qa_oldonload = window.onload;',
'window.onload = function() {',
"\tif (typeof qa_oldonload == 'function')",
"\t\tqa_oldonload();"
);
foreach ($qa_content['script_onloads'] as $scriptonload) {
$script[]="\t";
$script[] = "\t";
foreach ((array)$scriptonload as $scriptline)
$script[]="\t".$scriptline;
$script[] = "\t".$scriptline;
}
$script[]='};';
$script[] = '};';
}
$script[]='</script>';
$script[] = '</script>';
if (isset($qa_content['script_rel'])) {
$uniquerel=array_unique($qa_content['script_rel']); // remove any duplicates
$uniquerel = array_unique($qa_content['script_rel']); // remove any duplicates
foreach ($uniquerel as $script_rel)
$script[]='<script src="'.qa_html(qa_path_to_root().$script_rel).'" type="text/javascript"></script>';
$script[] = '<script src="'.qa_html(qa_path_to_root().$script_rel).'"></script>';
}
if (isset($qa_content['script_src'])) {
$uniquesrc=array_unique($qa_content['script_src']); // remove any duplicates
$uniquesrc = array_unique($qa_content['script_src']); // remove any duplicates
foreach ($uniquesrc as $script_src)
$script[]='<script src="'.qa_html($script_src).'" type="text/javascript"></script>';
$script[] = '<script src="'.qa_html($script_src).'"></script>';
}
$qa_content['script']=$script;
$qa_content['script'] = $script;
// Load the appropriate theme class and output the page
$themeclass=qa_load_theme_class(qa_get_site_theme(), (substr($qa_template, 0, 7)=='custom-') ? 'custom' : $qa_template, $qa_content, qa_request());
$tmpl = substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template;
$themeclass = qa_load_theme_class(qa_get_site_theme(), $tmpl, $qa_content, qa_request());
$themeclass->initialize();
header('Content-type: '.$qa_content['content_type']);
......
......@@ -774,7 +774,7 @@ class qa_html_theme_base
strpos($key, 'custom') === 0 ||
strpos($key, 'form') === 0 ||
strpos($key, 'q_list') === 0 ||
strpos($key, 'q_view') === 0 ||
(strpos($key, 'q_view') === 0 && !isset($this->content['form_q_edit'])) ||
strpos($key, 'a_form') === 0 ||
strpos($key, 'a_list') === 0 ||
strpos($key, 'ranking') === 0 ||
......
......@@ -690,13 +690,15 @@
function qa_string_matches_one($string, $matches)
/*
Return true if one of the elements in $matches is contained within $string
Return true if at least one of the values in array $matches is a substring of $string. Otherwise, return false.
*/
{
if (strlen($string))
foreach ($matches as $match)
if (strpos($string, $match)!==false)
if (strlen($string)) {
foreach ($matches as $match) {
if (strpos($string, $match) !== false)
return true;
}
}
return false;
}
......
......@@ -22,16 +22,6 @@
class qa_xml_sitemap
{
private $directory;
private $urltoroot;
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
}
public function option_default($option)
{
switch ($option) {
......
......@@ -166,13 +166,13 @@ h1 {
color: #444;
font-size: 20px;
font-weight: 700;
margin: 0.5em 0 25px;
margin: 5px 0 25px;
font-family: Arial,Helvetica,sans-serif;
font-weight: 700;
line-height: 1.1em;
border-bottom: 1px solid #ddd;
position: relative;
padding: 14px 25px 5px 0;
padding: 0 25px 5px 0;
}
h2 {
......@@ -231,15 +231,9 @@ p {
/*---[ other comomn used css ]---*/
#qa-register, #qa-login {
background: #0099cc; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTljYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDY2OTkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #0099cc 0%, #0179b5 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #0099cc), color-stop(100%, #0179b5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099cc 0%, #0179b5 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099cc 0%, #0179b5 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099cc 0%, #0179b5 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099cc 0%, #0179b5 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0099cc', endColorstr='#0179b5',GradientType=0 ); /* IE6-8 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0099cc', endColorstr='#0179b5',GradientType=0); /* IE6-8 */
border: 1px solid #004f76;
color: #fff;
font-weight: bold;
......@@ -250,15 +244,9 @@ p {
#qa-register:hover, #qa-register:focus,
#qa-login:hover, #qa-login:focus {
background: #1ca0cc; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFjYTBjYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDk5Y2MiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #1ca0cc 0%, #0099cc 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #1ca0cc), color-stop(100%, #0099cc)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #1ca0cc 0%, #0099cc 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #1ca0cc 0%, #0099cc 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #1ca0cc 0%, #0099cc 100%); /* IE10+ */
background: linear-gradient(to bottom, #1ca0cc 0%, #0099cc 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1ca0cc', endColorstr='#0099cc',GradientType=0 ); /* IE6-8 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1ca0cc', endColorstr='#0099cc',GradientType=0); /* IE6-8 */
}
/*---[ Begin: login bar css ]---*/
......@@ -503,7 +491,6 @@ input[type="submit"].qa-search-button:hover {
/*-- header css --*/
.qa-header {
/*position:relative;*/
padding: 15px 10px 5px;
height: auto;
}
......@@ -512,9 +499,6 @@ input[type="submit"].qa-search-button:hover {
float: left;
font-size: 38px;
font-weight: 700;
/*position:absolute;
bottom:5px;
left:10px;*/
}
div.header-banner {
......@@ -593,23 +577,13 @@ div.header-banner {
.qa-nav-sub {
background: #f4f4f4; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Y0ZjRmNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNlNmU2ZTYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #f4f4f4 0%, #e6e6e6 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f4f4f4), color-stop(100%, #e6e6e6)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f4f4f4 0%, #e6e6e6 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f4f4f4 0%, #e6e6e6 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f4f4f4 0%, #e6e6e6 100%); /* IE10+ */
background: linear-gradient(to bottom, #f4f4f4 0%, #e6e6e6 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f4f4f4', endColorstr='#e6e6e6',GradientType=0 ); /* IE6-8 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f4f4f4', endColorstr='#e6e6e6',GradientType=0); /* IE6-8 */
clear: both;
border: 1px solid #ddd;
}
* html .qa-nav-sub {
/* background:none; */
}
/* IE6 since z-order goes wrong */
.qa-nav-sub-list {
font-size: 11px;
......@@ -706,12 +680,6 @@ div.header-banner {
background: none;
}
/* .qa-headings{
border-bottom:1px solid #ddd;
margin-bottom:25px;
position:relative;
padding:14px 25px 5px 0;
} */
.entry-title {
color: #000;
font-family: Arial,Helvetica,sans-serif;
......@@ -719,15 +687,14 @@ div.header-banner {
}
.qa-rss-icon {
/* text-align:right;
float:right; */
position: absolute;
bottom: 0;
right: 4px;
position: relative;
float: right;
top: 4px;
right: 2px;
}
/*--------- VOTING + ANSWER + VIEW BLOCKS CSS ------------------*/
/*--- VOTING + ANSWER + VIEW BLOCKS CSS ---*/
/* Votes */
.qa-q-item-stats {
......@@ -996,14 +963,12 @@ div.header-banner {
letter-spacing: 1px;
}
/*--------- END VOTING + ANSWER + VIEW BLOCKS CSS ------------------*/
/*--- END VOTING + ANSWER + VIEW BLOCKS CSS ---*/
.qa-favoriting {
/* float:right;
margin-right:8px; */
position: absolute;
right: 0;
bottom: 24px;
bottom: 5px;
}
.qa-favorite-button, .qa-unfavorite-button {
......@@ -1103,7 +1068,6 @@ div.header-banner {
Widget wrappers */
.qa-widget-full {
clear: both;
/* width:920px; */
margin: 15px 0;
}
......@@ -1346,15 +1310,12 @@ div.header-banner {
}
.qa-form-tall-label {
/* background:#f4f4f4;
border-top:1px solid #ddd; */
color: #444;
font-size: 14px;
padding: 8px 8px 2px 8px;
}
.qa-form-tall-data {
/* background:#f4f4f4; */
width: 480px;
padding: 2px 8px 8px 8px;
}
......@@ -1420,7 +1381,6 @@ div.header-banner {
}
.qa-form-tall-buttons {
/* text-align:center; */
padding: 8px 8px 8px 8px;
}
......@@ -1471,7 +1431,6 @@ div.header-banner {
/* Standard form (wide version) */
.qa-form-wide-table {
/* background:#f4f4f4; */
border-collapse: collapse;
width: 100%;
}
......@@ -1480,7 +1439,6 @@ div.header-banner {
line-height: 1px;
font-size: 1px;
border-bottom: 1px solid #ccc;
/* background:#f4f4f4; */
padding: 0;
}
......@@ -2154,7 +2112,6 @@ a.qa-browse-cat-link:visited {
font-size: 9px;
font-weight: 800;
display: block;
/* margin-top:6px; */
color: #73A651;
line-height: 6px;
}
......@@ -2345,16 +2302,21 @@ a.qa-browse-cat-link:visited {
font-size: 14px;
color: #666;
padding: 10px;
display: table;
}
.qa-activity-count-item {
margin: 0;
display: table-row;
}
.qa-activity-count-data {
font-size: 24px;
font-weight: 700;
color: #0179b5;
display: table-cell;
text-align: right;
padding-right: 0.25em;
}
/* Footer parts */
......@@ -2575,14 +2537,8 @@ a.qa-browse-cat-link:visited {
background: url(images/a-count-icon-ie6.png) no-repeat 32px 13px;
}
/*----------------------------------------------------------------------------
-----[ custom home page html content css ]-----
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-----[ q2a 1.6 new user profile page css ]-----
----------------------------------------------------------------------------*/
/* q2a 1.6 new user profile page css */
.qa-template-user .qa-main {
width: 100%;
......
......@@ -441,7 +441,8 @@ h1 {
.qa-feed-link:before {
float: right;
margin-left: 15px;
margin-right: 0;
margin-left: 8px;
}
@media (min-width: 980px) {
......
......@@ -3285,11 +3285,11 @@ input[type="submit"], button {
}
.qa-feed-link:before {
font-family: "fontello";
font-size: 32px;
font-size: 20px;
content: '\e81d';
display: inline-block;
float: left;
margin-right: 15px;
margin-right: 8px;
}
/*------[ footer ]------*/
......
......@@ -163,6 +163,7 @@ class qa_html_theme extends qa_html_theme_base
$class .= ' qam-approve-users';
}
if (isset($qam_snow->fixed_topbar))
$class .= ' qam-body-' . $qam_snow->fixed_topbar;
$this->output('class="' . $class . ' qa-body-js-off"');
......@@ -286,7 +287,9 @@ class qa_html_theme extends qa_html_theme_base
{
global $qam_snow;
$this->output('<div id="qam-topbar" class="clearfix ' . $qam_snow->fixed_topbar . '">');
$class = isset($qam_snow->fixed_topbar) ? ' ' . $qam_snow->fixed_topbar : '';
$this->output('<div id="qam-topbar" class="clearfix' . $class . '">');
$this->nav_main_sub();
$this->output('</div><!-- END qam-topbar -->');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment