Commit fedbc59d by Scott Vivian

Trim trailing space in plugins/javascript

parent ec46ded0
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-content/qa-admin.js File: qa-content/qa-admin.js
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Javascript for admin pages to handle Ajax-triggered operations Description: Javascript for admin pages to handle Ajax-triggered operations
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -38,20 +38,20 @@ function qa_recalc_click(state, elem, value, noteid) ...@@ -38,20 +38,20 @@ function qa_recalc_click(state, elem, value, noteid)
{ {
if (elem.qa_recalc_running) { if (elem.qa_recalc_running) {
elem.qa_recalc_stopped=true; elem.qa_recalc_stopped=true;
} else { } else {
elem.qa_recalc_running=true; elem.qa_recalc_running=true;
elem.qa_recalc_stopped=false; elem.qa_recalc_stopped=false;
qa_recalc_running++; qa_recalc_running++;
document.getElementById(noteid).innerHTML=''; document.getElementById(noteid).innerHTML='';
elem.qa_original_value=elem.value; elem.qa_original_value=elem.value;
if (value) if (value)
elem.value=value; elem.value=value;
qa_recalc_update(elem, state, noteid); qa_recalc_update(elem, state, noteid);
} }
return false; return false;
} }
...@@ -63,16 +63,16 @@ function qa_recalc_update(elem, state, noteid) ...@@ -63,16 +63,16 @@ function qa_recalc_update(elem, state, noteid)
if (lines[0]=='1') { if (lines[0]=='1') {
if (lines[2]) if (lines[2])
document.getElementById(noteid).innerHTML=lines[2]; document.getElementById(noteid).innerHTML=lines[2];
if (elem.qa_recalc_stopped) if (elem.qa_recalc_stopped)
qa_recalc_cleanup(elem); qa_recalc_cleanup(elem);
else else
qa_recalc_update(elem, lines[1], noteid); qa_recalc_update(elem, lines[1], noteid);
} else if (lines[0]=='0') { } else if (lines[0]=='0') {
document.getElementById(noteid).innerHTML=lines[2]; document.getElementById(noteid).innerHTML=lines[2];
qa_recalc_cleanup(elem); qa_recalc_cleanup(elem);
} else { } else {
qa_ajax_error(); qa_ajax_error();
qa_recalc_cleanup(elem); qa_recalc_cleanup(elem);
...@@ -98,11 +98,11 @@ function qa_mailing_start(noteid, pauseid) ...@@ -98,11 +98,11 @@ function qa_mailing_start(noteid, pauseid)
if (lines[0]=='1') { if (lines[0]=='1') {
document.getElementById(noteid).innerHTML=lines[1]; document.getElementById(noteid).innerHTML=lines[1];
window.setTimeout(function() { qa_mailing_start(noteid, pauseid); }, 1); // don't recurse window.setTimeout(function() { qa_mailing_start(noteid, pauseid); }, 1); // don't recurse
} else if (lines[0]=='0') { } else if (lines[0]=='0') {
document.getElementById(noteid).innerHTML=lines[1]; document.getElementById(noteid).innerHTML=lines[1];
document.getElementById(pauseid).style.display='none'; document.getElementById(pauseid).style.display='none';
} else { } else {
qa_ajax_error(); qa_ajax_error();
} }
...@@ -113,7 +113,7 @@ function qa_mailing_start(noteid, pauseid) ...@@ -113,7 +113,7 @@ function qa_mailing_start(noteid, pauseid)
function qa_admin_click(target) function qa_admin_click(target)
{ {
var p=target.name.split('_'); var p=target.name.split('_');
var params={entityid:p[1], action:p[2]}; var params={entityid:p[1], action:p[2]};
params.code=target.form.elements.code.value; params.code=target.form.elements.code.value;
...@@ -128,16 +128,16 @@ function qa_admin_click(target) ...@@ -128,16 +128,16 @@ function qa_admin_click(target)
qa_ajax_error(); qa_ajax_error();
} }
); );
qa_show_waiting_after(target, false); qa_show_waiting_after(target, false);
return false; return false;
} }
function qa_version_check(uri, versionkey, version, urikey, elem) function qa_version_check(uri, versionkey, version, urikey, elem)
{ {
var params={uri:uri, versionkey:versionkey, version:version, urikey:urikey}; var params={uri:uri, versionkey:versionkey, version:version, urikey:urikey};
qa_ajax_post('version', params, qa_ajax_post('version', params,
function (lines) { function (lines) {
if (lines[0]=='1') if (lines[0]=='1')
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-content/qa-ask.js File: qa-content/qa-ask.js
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Javascript for ask page and question editing, including tag auto-completion Description: Javascript for ask page and question editing, including tag auto-completion
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -30,19 +30,19 @@ function qa_title_change(value) ...@@ -30,19 +30,19 @@ function qa_title_change(value)
qa_tags_examples=lines[1]; qa_tags_examples=lines[1];
qa_tag_hints(true); qa_tag_hints(true);
} }
if (lines.length>2) { if (lines.length>2) {
var simelem=document.getElementById('similar'); var simelem=document.getElementById('similar');
if (simelem) if (simelem)
simelem.innerHTML=lines.slice(2).join('\n'); simelem.innerHTML=lines.slice(2).join('\n');
} }
} else if (lines[0]=='0') } else if (lines[0]=='0')
alert(lines[1]); alert(lines[1]);
else else
qa_ajax_error(); qa_ajax_error();
}); });
qa_show_waiting_after(document.getElementById('similar'), true); qa_show_waiting_after(document.getElementById('similar'), true);
} }
...@@ -60,16 +60,16 @@ function qa_tag_click(link) ...@@ -60,16 +60,16 @@ function qa_tag_click(link)
{ {
var elem=document.getElementById('tags'); var elem=document.getElementById('tags');
var parts=qa_tag_typed_parts(elem); var parts=qa_tag_typed_parts(elem);
// removes any HTML tags and ampersand // removes any HTML tags and ampersand
var tag=qa_html_unescape(link.innerHTML.replace(/<[^>]*>/g, '')); var tag=qa_html_unescape(link.innerHTML.replace(/<[^>]*>/g, ''));
var separator=qa_tag_onlycomma ? ', ' : ' '; var separator=qa_tag_onlycomma ? ', ' : ' ';
// replace if matches typed, otherwise append // replace if matches typed, otherwise append
var newvalue=(parts.typed && (tag.toLowerCase().indexOf(parts.typed.toLowerCase())>=0)) var newvalue=(parts.typed && (tag.toLowerCase().indexOf(parts.typed.toLowerCase())>=0))
? (parts.before+separator+tag+separator+parts.after+separator) : (elem.value+separator+tag+separator); ? (parts.before+separator+tag+separator+parts.after+separator) : (elem.value+separator+tag+separator);
// sanitize and set value // sanitize and set value
if (qa_tag_onlycomma) if (qa_tag_onlycomma)
elem.value=newvalue.replace(/[\s,]*,[\s,]*/g, ', ').replace(/^[\s,]+/g, ''); elem.value=newvalue.replace(/[\s,]*,[\s,]*/g, ', ').replace(/^[\s,]+/g, '');
...@@ -78,7 +78,7 @@ function qa_tag_click(link) ...@@ -78,7 +78,7 @@ function qa_tag_click(link)
elem.focus(); elem.focus();
qa_tag_hints(); qa_tag_hints();
return false; return false;
} }
...@@ -87,21 +87,21 @@ function qa_tag_hints(skipcomplete) ...@@ -87,21 +87,21 @@ function qa_tag_hints(skipcomplete)
var elem=document.getElementById('tags'); var elem=document.getElementById('tags');
var html=''; var html='';
var completed=false; var completed=false;
// first try to auto-complete // first try to auto-complete
if (qa_tags_complete && !skipcomplete) { if (qa_tags_complete && !skipcomplete) {
var parts=qa_tag_typed_parts(elem); var parts=qa_tag_typed_parts(elem);
if (parts.typed) { if (parts.typed) {
html=qa_tags_to_html((qa_html_unescape(qa_tags_examples+','+qa_tags_complete)).split(','), parts.typed.toLowerCase()); html=qa_tags_to_html((qa_html_unescape(qa_tags_examples+','+qa_tags_complete)).split(','), parts.typed.toLowerCase());
completed=html ? true : false; completed=html ? true : false;
} }
} }
// otherwise show examples // otherwise show examples
if (qa_tags_examples && !completed) if (qa_tags_examples && !completed)
html=qa_tags_to_html((qa_html_unescape(qa_tags_examples)).split(','), null); html=qa_tags_to_html((qa_html_unescape(qa_tags_examples)).split(','), null);
// set title visiblity and hint list // set title visiblity and hint list
document.getElementById('tag_examples_title').style.display=(html && !completed) ? '' : 'none'; document.getElementById('tag_examples_title').style.display=(html && !completed) ? '' : 'none';
document.getElementById('tag_complete_title').style.display=(html && completed) ? '' : 'none'; document.getElementById('tag_complete_title').style.display=(html && completed) ? '' : 'none';
...@@ -113,14 +113,14 @@ function qa_tags_to_html(tags, matchlc) ...@@ -113,14 +113,14 @@ function qa_tags_to_html(tags, matchlc)
var html=''; var html='';
var added=0; var added=0;
var tagseen={}; var tagseen={};
for (var i=0; i<tags.length; i++) { for (var i=0; i<tags.length; i++) {
var tag=tags[i]; var tag=tags[i];
var taglc=tag.toLowerCase(); var taglc=tag.toLowerCase();
if (!tagseen[taglc]) { if (!tagseen[taglc]) {
tagseen[taglc]=true; tagseen[taglc]=true;
if ( (!matchlc) || (taglc.indexOf(matchlc)>=0) ) { // match if necessary if ( (!matchlc) || (taglc.indexOf(matchlc)>=0) ) { // match if necessary
if (matchlc) { // if matching, show appropriate part in bold if (matchlc) { // if matching, show appropriate part in bold
var matchstart=taglc.indexOf(matchlc); var matchstart=taglc.indexOf(matchlc);
...@@ -129,15 +129,15 @@ function qa_tags_to_html(tags, matchlc) ...@@ -129,15 +129,15 @@ function qa_tags_to_html(tags, matchlc)
qa_html_escape(tag.substring(matchstart, matchend))+'</b>'+qa_html_escape(tag.substring(matchend))+'</span>'; qa_html_escape(tag.substring(matchstart, matchend))+'</b>'+qa_html_escape(tag.substring(matchend))+'</span>';
} else // otherwise show as-is } else // otherwise show as-is
inner=qa_html_escape(tag); inner=qa_html_escape(tag);
html+=qa_tag_template.replace(/\^/g, inner.replace('$', '$$$$'))+' '; // replace ^ in template, escape $s html+=qa_tag_template.replace(/\^/g, inner.replace('$', '$$$$'))+' '; // replace ^ in template, escape $s
if (++added>=qa_tags_max) if (++added>=qa_tags_max)
break; break;
} }
} }
} }
return html; return html;
} }
...@@ -147,7 +147,7 @@ function qa_caret_from_end(elem) ...@@ -147,7 +147,7 @@ function qa_caret_from_end(elem)
elem.focus(); elem.focus();
var sel=document.selection.createRange(); var sel=document.selection.createRange();
sel.moveStart('character', -elem.value.length); sel.moveStart('character', -elem.value.length);
return elem.value.length-sel.text.length; return elem.value.length-sel.text.length;
} else if (typeof(elem.selectionEnd)!='undefined') // other browsers } else if (typeof(elem.selectionEnd)!='undefined') // other browsers
...@@ -162,7 +162,7 @@ function qa_tag_typed_parts(elem) ...@@ -162,7 +162,7 @@ function qa_tag_typed_parts(elem)
var caret=elem.value.length-qa_caret_from_end(elem); var caret=elem.value.length-qa_caret_from_end(elem);
var active=elem.value.substring(0, caret); var active=elem.value.substring(0, caret);
var passive=elem.value.substring(active.length); var passive=elem.value.substring(active.length);
// if the caret is in the middle of a word, move the end of word from passive to active // if the caret is in the middle of a word, move the end of word from passive to active
if ( if (
active.match(qa_tag_onlycomma ? /[^\s,][^,]*$/ : /[^\s,]$/) && active.match(qa_tag_onlycomma ? /[^\s,][^,]*$/ : /[^\s,]$/) &&
...@@ -171,10 +171,10 @@ function qa_tag_typed_parts(elem) ...@@ -171,10 +171,10 @@ function qa_tag_typed_parts(elem)
active+=adjoinmatch[0]; active+=adjoinmatch[0];
passive=elem.value.substring(active.length); passive=elem.value.substring(active.length);
} }
// find what has been typed so far // find what has been typed so far
var typedmatch=active.match(qa_tag_onlycomma ? /[^\s,]+[^,]*$/ : /[^\s,]+$/) || ['']; var typedmatch=active.match(qa_tag_onlycomma ? /[^\s,]+[^,]*$/ : /[^\s,]+$/) || [''];
return {before:active.substring(0, active.length-typedmatch[0].length), after:passive, typed:typedmatch[0]}; return {before:active.substring(0, active.length-typedmatch[0].length), after:passive, typed:typedmatch[0]};
} }
...@@ -182,15 +182,15 @@ function qa_category_select(idprefix, startpath) ...@@ -182,15 +182,15 @@ function qa_category_select(idprefix, startpath)
{ {
var startval=startpath ? startpath.split("/") : []; var startval=startpath ? startpath.split("/") : [];
var setdescnow=true; var setdescnow=true;
for (var l=0; l<=qa_cat_maxdepth; l++) { for (var l=0; l<=qa_cat_maxdepth; l++) {
var elem=document.getElementById(idprefix+'_'+l); var elem=document.getElementById(idprefix+'_'+l);
if (elem) { if (elem) {
if (l) { if (l) {
if (l<startval.length && startval[l].length) { if (l<startval.length && startval[l].length) {
var val=startval[l]; var val=startval[l];
for (var j=0; j<elem.options.length; j++) for (var j=0; j<elem.options.length; j++)
if (elem.options[j].value==val) if (elem.options[j].value==val)
elem.selectedIndex=j; elem.selectedIndex=j;
...@@ -198,67 +198,67 @@ function qa_category_select(idprefix, startpath) ...@@ -198,67 +198,67 @@ function qa_category_select(idprefix, startpath)
var val=elem.options[elem.selectedIndex].value; var val=elem.options[elem.selectedIndex].value;
} else } else
val=''; val='';
if (elem.qa_last_sel!==val) { if (elem.qa_last_sel!==val) {
elem.qa_last_sel=val; elem.qa_last_sel=val;
var subelem=document.getElementById(idprefix+'_'+l+'_sub'); var subelem=document.getElementById(idprefix+'_'+l+'_sub');
if (subelem) if (subelem)
subelem.parentNode.removeChild(subelem); subelem.parentNode.removeChild(subelem);
if (val.length || (l==0)) { if (val.length || (l==0)) {
subelem=elem.parentNode.insertBefore(document.createElement('span'), elem.nextSibling); subelem=elem.parentNode.insertBefore(document.createElement('span'), elem.nextSibling);
subelem.id=idprefix+'_'+l+'_sub'; subelem.id=idprefix+'_'+l+'_sub';
qa_show_waiting_after(subelem, true); qa_show_waiting_after(subelem, true);
qa_ajax_post('category', {categoryid:val}, qa_ajax_post('category', {categoryid:val},
(function(elem, l) { (function(elem, l) {
return function(lines) { return function(lines) {
var subelem=document.getElementById(idprefix+'_'+l+'_sub'); var subelem=document.getElementById(idprefix+'_'+l+'_sub');
if (subelem) if (subelem)
subelem.parentNode.removeChild(subelem); subelem.parentNode.removeChild(subelem);
if (lines[0]=='1') { if (lines[0]=='1') {
elem.qa_cat_desc=lines[1]; elem.qa_cat_desc=lines[1];
var addedoption=false; var addedoption=false;
if (lines.length>2) { if (lines.length>2) {
var subelem=elem.parentNode.insertBefore(document.createElement('span'), elem.nextSibling); var subelem=elem.parentNode.insertBefore(document.createElement('span'), elem.nextSibling);
subelem.id=idprefix+'_'+l+'_sub'; subelem.id=idprefix+'_'+l+'_sub';
subelem.innerHTML=' '; subelem.innerHTML=' ';
var newelem=elem.cloneNode(false); var newelem=elem.cloneNode(false);
newelem.name=newelem.id=idprefix+'_'+(l+1); newelem.name=newelem.id=idprefix+'_'+(l+1);
newelem.options.length=0; newelem.options.length=0;
if (l ? qa_cat_allownosub : qa_cat_allownone) if (l ? qa_cat_allownosub : qa_cat_allownone)
newelem.options[0]=new Option(l ? '' : elem.options[0].text, '', true, true); newelem.options[0]=new Option(l ? '' : elem.options[0].text, '', true, true);
for (var i=2; i<lines.length; i++) { for (var i=2; i<lines.length; i++) {
var parts=lines[i].split('/'); var parts=lines[i].split('/');
if (String(qa_cat_exclude).length && (String(qa_cat_exclude)==parts[0])) if (String(qa_cat_exclude).length && (String(qa_cat_exclude)==parts[0]))
continue; continue;
newelem.options[newelem.options.length]=new Option(parts.slice(1).join('/'), parts[0]); newelem.options[newelem.options.length]=new Option(parts.slice(1).join('/'), parts[0]);
addedoption=true; addedoption=true;
} }
if (addedoption) { if (addedoption) {
subelem.appendChild(newelem); subelem.appendChild(newelem);
qa_category_select(idprefix, startpath); qa_category_select(idprefix, startpath);
} }
if (l==0) if (l==0)
elem.style.display='none'; elem.style.display='none';
} }
if (!addedoption) if (!addedoption)
set_category_description(idprefix); set_category_description(idprefix);
} else if (lines[0]=='0') } else if (lines[0]=='0')
alert(lines[1]); alert(lines[1]);
else else
...@@ -266,15 +266,15 @@ function qa_category_select(idprefix, startpath) ...@@ -266,15 +266,15 @@ function qa_category_select(idprefix, startpath)
} }
})(elem, l) })(elem, l)
); );
setdescnow=false; setdescnow=false;
} }
break; break;
} }
} }
} }
if (setdescnow) if (setdescnow)
set_category_description(idprefix); set_category_description(idprefix);
} }
...@@ -282,17 +282,17 @@ function qa_category_select(idprefix, startpath) ...@@ -282,17 +282,17 @@ function qa_category_select(idprefix, startpath)
function set_category_description(idprefix) function set_category_description(idprefix)
{ {
var n=document.getElementById(idprefix+'_note'); var n=document.getElementById(idprefix+'_note');
if (n) { if (n) {
desc=''; desc='';
for (var l=1; l<=qa_cat_maxdepth; l++) { for (var l=1; l<=qa_cat_maxdepth; l++) {
var elem=document.getElementById(idprefix+'_'+l); var elem=document.getElementById(idprefix+'_'+l);
if (elem && elem.options[elem.selectedIndex].value.length) if (elem && elem.options[elem.selectedIndex].value.length)
desc=elem.qa_cat_desc; desc=elem.qa_cat_desc;
} }
n.innerHTML=desc; n.innerHTML=desc;
} }
} }
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-content/qa-page.js File: qa-content/qa-page.js
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Common Javascript including voting, notices and favorites Description: Common Javascript including voting, notices and favorites
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -53,11 +53,11 @@ function qa_show_waiting_after(elem, inside) ...@@ -53,11 +53,11 @@ function qa_show_waiting_after(elem, inside)
{ {
if (elem && !elem.qa_waiting_shown) { if (elem && !elem.qa_waiting_shown) {
var w=document.getElementById('qa-waiting-template'); var w=document.getElementById('qa-waiting-template');
if (w) { if (w) {
var c=w.cloneNode(true); var c=w.cloneNode(true);
c.id=null; c.id=null;
if (inside) if (inside)
elem.insertBefore(c, null); elem.insertBefore(c, null);
else else
...@@ -85,7 +85,7 @@ function qa_vote_click(elem) ...@@ -85,7 +85,7 @@ function qa_vote_click(elem)
var vote=parseInt(ens[2]); var vote=parseInt(ens[2]);
var code=elem.form.elements.code.value; var code=elem.form.elements.code.value;
var anchor=ens[3]; var anchor=ens[3];
qa_ajax_post('vote', {postid:postid, vote:vote, code:code}, qa_ajax_post('vote', {postid:postid, vote:vote, code:code},
function(lines) { function(lines) {
if (lines[0]=='1') { if (lines[0]=='1') {
...@@ -93,7 +93,7 @@ function qa_vote_click(elem) ...@@ -93,7 +93,7 @@ function qa_vote_click(elem)
} else if (lines[0]=='0') { } else if (lines[0]=='0') {
var mess=document.getElementById('errorbox'); var mess=document.getElementById('errorbox');
if (!mess) { if (!mess) {
var mess=document.createElement('div'); var mess=document.createElement('div');
mess.id='errorbox'; mess.id='errorbox';
...@@ -101,16 +101,16 @@ function qa_vote_click(elem) ...@@ -101,16 +101,16 @@ function qa_vote_click(elem)
mess.innerHTML=lines[1]; mess.innerHTML=lines[1];
mess.style.display='none'; mess.style.display='none';
} }
var postelem=document.getElementById(anchor); var postelem=document.getElementById(anchor);
var e=postelem.parentNode.insertBefore(mess, postelem); var e=postelem.parentNode.insertBefore(mess, postelem);
qa_reveal(e); qa_reveal(e);
} else } else
qa_ajax_error(); qa_ajax_error();
} }
); );
return false; return false;
} }
...@@ -118,7 +118,7 @@ function qa_notice_click(elem) ...@@ -118,7 +118,7 @@ function qa_notice_click(elem)
{ {
var ens=elem.name.split('_'); var ens=elem.name.split('_');
var code=elem.form.elements.code.value; var code=elem.form.elements.code.value;
qa_ajax_post('notice', {noticeid:ens[1], code:code}, qa_ajax_post('notice', {noticeid:ens[1], code:code},
function(lines) { function(lines) {
if (lines[0]=='1') if (lines[0]=='1')
...@@ -129,7 +129,7 @@ function qa_notice_click(elem) ...@@ -129,7 +129,7 @@ function qa_notice_click(elem)
qa_ajax_error(); qa_ajax_error();
} }
); );
return false; return false;
} }
...@@ -137,7 +137,7 @@ function qa_favorite_click(elem) ...@@ -137,7 +137,7 @@ function qa_favorite_click(elem)
{ {
var ens=elem.name.split('_'); var ens=elem.name.split('_');
var code=elem.form.elements.code.value; var code=elem.form.elements.code.value;
qa_ajax_post('favorite', {entitytype:ens[1], entityid:ens[2], favorite:parseInt(ens[3]), code:code}, qa_ajax_post('favorite', {entitytype:ens[1], entityid:ens[2], favorite:parseInt(ens[3]), code:code},
function (lines) { function (lines) {
if (lines[0]=='1') if (lines[0]=='1')
...@@ -149,20 +149,20 @@ function qa_favorite_click(elem) ...@@ -149,20 +149,20 @@ function qa_favorite_click(elem)
qa_ajax_error(); qa_ajax_error();
} }
); );
qa_show_waiting_after(elem, false); qa_show_waiting_after(elem, false);
return false; return false;
} }
function qa_ajax_post(operation, params, callback) function qa_ajax_post(operation, params, callback)
{ {
jQuery.extend(params, {qa:'ajax', qa_operation:operation, qa_root:qa_root, qa_request:qa_request}); jQuery.extend(params, {qa:'ajax', qa_operation:operation, qa_root:qa_root, qa_request:qa_request});
jQuery.post(qa_root, params, function(response) { jQuery.post(qa_root, params, function(response) {
var header='QA_AJAX_RESPONSE'; var header='QA_AJAX_RESPONSE';
var headerpos=response.indexOf(header); var headerpos=response.indexOf(header);
if (headerpos>=0) if (headerpos>=0)
callback(response.substr(headerpos+header.length).replace(/^\s+/, '').split("\n")); callback(response.substr(headerpos+header.length).replace(/^\s+/, '').split("\n"));
else else
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-content/qa-question.js File: qa-content/qa-question.js
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Javascript to handle question page actions Description: Javascript to handle question page actions
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -27,10 +27,10 @@ var qa_element_revealed=null; ...@@ -27,10 +27,10 @@ var qa_element_revealed=null;
function qa_toggle_element(elem) function qa_toggle_element(elem)
{ {
var e=elem ? document.getElementById(elem) : null; var e=elem ? document.getElementById(elem) : null;
if (e && e.qa_disabled) if (e && e.qa_disabled)
e=null; e=null;
if (e && (qa_element_revealed==e)) { if (e && (qa_element_revealed==e)) {
qa_conceal(qa_element_revealed, 'form'); qa_conceal(qa_element_revealed, 'form');
qa_element_revealed=null; qa_element_revealed=null;
...@@ -38,22 +38,22 @@ function qa_toggle_element(elem) ...@@ -38,22 +38,22 @@ function qa_toggle_element(elem)
} else { } else {
if (qa_element_revealed) if (qa_element_revealed)
qa_conceal(qa_element_revealed, 'form'); qa_conceal(qa_element_revealed, 'form');
if (e) { if (e) {
if (e.qa_load && !e.qa_loaded) { if (e.qa_load && !e.qa_loaded) {
e.qa_load(); e.qa_load();
e.qa_loaded=true; e.qa_loaded=true;
} }
if (e.qa_show) if (e.qa_show)
e.qa_show(); e.qa_show();
qa_reveal(e, 'form', function() { qa_reveal(e, 'form', function() {
var t=$(e).offset().top; var t=$(e).offset().top;
var h=$(e).height()+16; var h=$(e).height()+16;
var wt=$(window).scrollTop(); var wt=$(window).scrollTop();
var wh=$(window).height(); var wh=$(window).height();
if ( (t<wt) || (t>(wt+wh)) ) if ( (t<wt) || (t>(wt+wh)) )
qa_scroll_page_to(t); qa_scroll_page_to(t);
else if ((t+h)>(wt+wh)) else if ((t+h)>(wt+wh))
...@@ -63,60 +63,60 @@ function qa_toggle_element(elem) ...@@ -63,60 +63,60 @@ function qa_toggle_element(elem)
e.qa_focus(); e.qa_focus();
}); });
} }
qa_element_revealed=e; qa_element_revealed=e;
} }
return !(e||!elem); // failed to find item return !(e||!elem); // failed to find item
} }
function qa_submit_answer(questionid, elem) function qa_submit_answer(questionid, elem)
{ {
var params=qa_form_params('a_form'); var params=qa_form_params('a_form');
params.a_questionid=questionid; params.a_questionid=questionid;
qa_ajax_post('answer', params, qa_ajax_post('answer', params,
function(lines) { function(lines) {
if (lines[0]=='1') { if (lines[0]=='1') {
if (lines[1]<1) { if (lines[1]<1) {
var b=document.getElementById('q_doanswer'); var b=document.getElementById('q_doanswer');
if (b) if (b)
b.style.display='none'; b.style.display='none';
} }
var t=document.getElementById('a_list_title'); var t=document.getElementById('a_list_title');
qa_set_inner_html(t, 'a_list_title', lines[2]); qa_set_inner_html(t, 'a_list_title', lines[2]);
qa_reveal(t, 'a_list_title'); qa_reveal(t, 'a_list_title');
var e=document.createElement('div'); var e=document.createElement('div');
e.innerHTML=lines.slice(3).join("\n"); e.innerHTML=lines.slice(3).join("\n");
var c=e.firstChild; var c=e.firstChild;
c.style.display='none'; c.style.display='none';
var l=document.getElementById('a_list'); var l=document.getElementById('a_list');
l.insertBefore(c, l.firstChild); l.insertBefore(c, l.firstChild);
var a=document.getElementById('anew'); var a=document.getElementById('anew');
a.qa_disabled=true; a.qa_disabled=true;
qa_reveal(c, 'answer'); qa_reveal(c, 'answer');
qa_conceal(a, 'form'); qa_conceal(a, 'form');
} else if (lines[0]=='0') { } else if (lines[0]=='0') {
document.forms['a_form'].submit(); document.forms['a_form'].submit();
} else { } else {
qa_ajax_error(); qa_ajax_error();
} }
} }
); );
qa_show_waiting_after(elem, false); qa_show_waiting_after(elem, false);
return false; return false;
} }
...@@ -126,7 +126,7 @@ function qa_submit_comment(questionid, parentid, elem) ...@@ -126,7 +126,7 @@ function qa_submit_comment(questionid, parentid, elem)
params.c_questionid=questionid; params.c_questionid=questionid;
params.c_parentid=parentid; params.c_parentid=parentid;
qa_ajax_post('comment', params, qa_ajax_post('comment', params,
function (lines) { function (lines) {
...@@ -134,42 +134,42 @@ function qa_submit_comment(questionid, parentid, elem) ...@@ -134,42 +134,42 @@ function qa_submit_comment(questionid, parentid, elem)
var l=document.getElementById('c'+parentid+'_list'); var l=document.getElementById('c'+parentid+'_list');
l.innerHTML=lines.slice(2).join("\n"); l.innerHTML=lines.slice(2).join("\n");
l.style.display=''; l.style.display='';
var a=document.getElementById('c'+parentid); var a=document.getElementById('c'+parentid);
a.qa_disabled=true; a.qa_disabled=true;
var c=document.getElementById(lines[1]); // id of comment var c=document.getElementById(lines[1]); // id of comment
if (c) { if (c) {
c.style.display='none'; c.style.display='none';
qa_reveal(c, 'comment'); qa_reveal(c, 'comment');
} }
qa_conceal(a, 'form'); qa_conceal(a, 'form');
} else if (lines[0]=='0') { } else if (lines[0]=='0') {
document.forms['c_form_'+parentid].submit(); document.forms['c_form_'+parentid].submit();
} else { } else {
qa_ajax_error(); qa_ajax_error();
} }
} }
); );
qa_show_waiting_after(elem, false); qa_show_waiting_after(elem, false);
return false; return false;
} }
function qa_answer_click(answerid, questionid, target) function qa_answer_click(answerid, questionid, target)
{ {
var params={}; var params={};
params.answerid=answerid; params.answerid=answerid;
params.questionid=questionid; params.questionid=questionid;
params.code=target.form.elements.code.value; params.code=target.form.elements.code.value;
params[target.name]=target.value; params[target.name]=target.value;
qa_ajax_post('click_a', params, qa_ajax_post('click_a', params,
function (lines) { function (lines) {
if (lines[0]=='1') { if (lines[0]=='1') {
...@@ -177,64 +177,64 @@ function qa_answer_click(answerid, questionid, target) ...@@ -177,64 +177,64 @@ function qa_answer_click(answerid, questionid, target)
var l=document.getElementById('a'+answerid); var l=document.getElementById('a'+answerid);
var h=lines.slice(2).join("\n"); var h=lines.slice(2).join("\n");
if (h.length) if (h.length)
qa_set_outer_html(l, 'answer', h); qa_set_outer_html(l, 'answer', h);
else else
qa_conceal(l, 'answer'); qa_conceal(l, 'answer');
} else { } else {
target.form.elements.qa_click.value=target.name; target.form.elements.qa_click.value=target.name;
target.form.submit(); target.form.submit();
} }
} }
); );
qa_show_waiting_after(target, false); qa_show_waiting_after(target, false);
return false; return false;
} }
function qa_comment_click(commentid, questionid, parentid, target) function qa_comment_click(commentid, questionid, parentid, target)
{ {
var params={}; var params={};
params.commentid=commentid; params.commentid=commentid;
params.questionid=questionid; params.questionid=questionid;
params.parentid=parentid; params.parentid=parentid;
params.code=target.form.elements.code.value; params.code=target.form.elements.code.value;
params[target.name]=target.value; params[target.name]=target.value;
qa_ajax_post('click_c', params, qa_ajax_post('click_c', params,
function (lines) { function (lines) {
if (lines[0]=='1') { if (lines[0]=='1') {
var l=document.getElementById('c'+commentid); var l=document.getElementById('c'+commentid);
var h=lines.slice(1).join("\n"); var h=lines.slice(1).join("\n");
if (h.length) if (h.length)
qa_set_outer_html(l, 'comment', h) qa_set_outer_html(l, 'comment', h)
else else
qa_conceal(l, 'comment'); qa_conceal(l, 'comment');
} else { } else {
target.form.elements.qa_click.value=target.name; target.form.elements.qa_click.value=target.name;
target.form.submit(); target.form.submit();
} }
} }
); );
qa_show_waiting_after(target, false); qa_show_waiting_after(target, false);
return false; return false;
} }
function qa_show_comments(questionid, parentid, elem) function qa_show_comments(questionid, parentid, elem)
{ {
var params={}; var params={};
params.c_questionid=questionid; params.c_questionid=questionid;
params.c_parentid=parentid; params.c_parentid=parentid;
qa_ajax_post('show_cs', params, qa_ajax_post('show_cs', params,
function (lines) { function (lines) {
if (lines[0]=='1') { if (lines[0]=='1') {
...@@ -242,15 +242,15 @@ function qa_show_comments(questionid, parentid, elem) ...@@ -242,15 +242,15 @@ function qa_show_comments(questionid, parentid, elem)
l.innerHTML=lines.slice(1).join("\n"); l.innerHTML=lines.slice(1).join("\n");
l.style.display='none'; l.style.display='none';
qa_reveal(l, 'comments'); qa_reveal(l, 'comments');
} else { } else {
qa_ajax_error(); qa_ajax_error();
} }
} }
); );
qa_show_waiting_after(elem, true); qa_show_waiting_after(elem, true);
return false; return false;
} }
...@@ -258,15 +258,15 @@ function qa_form_params(formname) ...@@ -258,15 +258,15 @@ function qa_form_params(formname)
{ {
var es=document.forms[formname].elements; var es=document.forms[formname].elements;
var params={}; var params={};
for (var i=0; i<es.length; i++) { for (var i=0; i<es.length; i++) {
var e=es[i]; var e=es[i];
var t=(e.type || '').toLowerCase(); var t=(e.type || '').toLowerCase();
if ( ((t!='checkbox') && (t!='radio')) || e.checked) if ( ((t!='checkbox') && (t!='radio')) || e.checked)
params[e.name]=e.value; params[e.name]=e.value;
} }
return params; return params;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-content/qa-user.js File: qa-content/qa-user.js
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Javascript to handle user page actions Description: Javascript to handle user page actions
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,20 +25,20 @@ ...@@ -25,20 +25,20 @@
function qa_submit_wall_post(elem, morelink) function qa_submit_wall_post(elem, morelink)
{ {
var params={}; var params={};
params.message=document.forms.wallpost.message.value; params.message=document.forms.wallpost.message.value;
params.handle=document.forms.wallpost.handle.value; params.handle=document.forms.wallpost.handle.value;
params.start=document.forms.wallpost.start.value; params.start=document.forms.wallpost.start.value;
params.code=document.forms.wallpost.code.value; params.code=document.forms.wallpost.code.value;
params.morelink=morelink ? 1 : 0; params.morelink=morelink ? 1 : 0;
qa_ajax_post('wallpost', params, qa_ajax_post('wallpost', params,
function(lines) { function(lines) {
if (lines[0]=='1') { if (lines[0]=='1') {
var l=document.getElementById('wallmessages'); var l=document.getElementById('wallmessages');
l.innerHTML=lines.slice(2).join("\n"); l.innerHTML=lines.slice(2).join("\n");
var c=document.getElementById(lines[1]); // id of new message var c=document.getElementById(lines[1]); // id of new message
if (c) { if (c) {
c.style.display='none'; c.style.display='none';
...@@ -47,19 +47,19 @@ function qa_submit_wall_post(elem, morelink) ...@@ -47,19 +47,19 @@ function qa_submit_wall_post(elem, morelink)
document.forms.wallpost.message.value=''; document.forms.wallpost.message.value='';
qa_hide_waiting(elem); qa_hide_waiting(elem);
} else if (lines[0]=='0') { } else if (lines[0]=='0') {
document.forms.wallpost.qa_click.value=elem.name; document.forms.wallpost.qa_click.value=elem.name;
document.forms.wallpost.submit(); document.forms.wallpost.submit();
} else { } else {
qa_ajax_error(); qa_ajax_error();
} }
} }
); );
qa_show_waiting_after(elem, false); qa_show_waiting_after(elem, false);
return false; return false;
} }
...@@ -67,7 +67,7 @@ function qa_submit_wall_post(elem, morelink) ...@@ -67,7 +67,7 @@ function qa_submit_wall_post(elem, morelink)
function qa_wall_post_click(messageid, target) function qa_wall_post_click(messageid, target)
{ {
var params={}; var params={};
params.messageid=messageid; params.messageid=messageid;
params.handle=document.forms.wallpost.handle.value; params.handle=document.forms.wallpost.handle.value;
params.code=document.forms.wallpost.code.value; params.code=document.forms.wallpost.code.value;
...@@ -79,20 +79,20 @@ function qa_wall_post_click(messageid, target) ...@@ -79,20 +79,20 @@ function qa_wall_post_click(messageid, target)
if (lines[0]=='1') { if (lines[0]=='1') {
var l=document.getElementById('m'+messageid); var l=document.getElementById('m'+messageid);
var h=lines.slice(1).join("\n"); var h=lines.slice(1).join("\n");
if (h.length) if (h.length)
qa_set_outer_html(l, 'wallpost', h) qa_set_outer_html(l, 'wallpost', h)
else else
qa_conceal(l, 'wallpost'); qa_conceal(l, 'wallpost');
} else { } else {
document.forms.wallpost.qa_click.value=target.name; document.forms.wallpost.qa_click.value=target.name;
document.forms.wallpost.submit(); document.forms.wallpost.submit();
} }
} }
); );
qa_show_waiting_after(target, false); qa_show_waiting_after(target, false);
return false; return false;
} }
\ No newline at end of file
<?php <?php
/* /*
Question2Answer (c) Gideon Greenspan Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-lang/en-GB/qa-lang-admin.php File: qa-lang/en-GB/qa-lang-admin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: UK English translations - not much to do here Description: UK English translations - not much to do here
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
'admin_title' => 'Administration Centre', 'admin_title' => 'Administration Centre',
'url_format_note' => 'Options with the ^ label are working for your site\'s configuration. For best search engine optimisation (SEO), use the first ^ option available.', 'url_format_note' => 'Options with the ^ label are working for your site\'s configuration. For best search engine optimisation (SEO), use the first ^ option available.',
); );
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/basic-adsense/qa-basic-adsense.php File: qa-plugin/basic-adsense/qa-basic-adsense.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Widget module class for AdSense widget plugin Description: Widget module class for AdSense widget plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,17 +25,17 @@ ...@@ -25,17 +25,17 @@
*/ */
class qa_basic_adsense { class qa_basic_adsense {
function allow_template($template) function allow_template($template)
{ {
return ($template!='admin'); return ($template!='admin');
} }
function allow_region($region) function allow_region($region)
{ {
$allow=false; $allow=false;
switch ($region) switch ($region)
{ {
case 'main': case 'main':
...@@ -44,24 +44,24 @@ ...@@ -44,24 +44,24 @@
$allow=true; $allow=true;
break; break;
} }
return $allow; return $allow;
} }
function admin_form(&$qa_content) function admin_form(&$qa_content)
{ {
$saved=false; $saved=false;
if (qa_clicked('adsense_save_button')) { if (qa_clicked('adsense_save_button')) {
$trimchars="=;\"\' \t\r\n"; // prevent common errors by copying and pasting from Javascript $trimchars="=;\"\' \t\r\n"; // prevent common errors by copying and pasting from Javascript
qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars)); qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars));
$saved=true; $saved=true;
} }
return array( return array(
'ok' => $saved ? 'AdSense settings saved' : null, 'ok' => $saved ? 'AdSense settings saved' : null,
'fields' => array( 'fields' => array(
array( array(
'label' => 'AdSense Publisher ID:', 'label' => 'AdSense Publisher ID:',
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
'note' => 'Example: <i>pub-1234567890123456</i>', 'note' => 'Example: <i>pub-1234567890123456</i>',
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -84,24 +84,24 @@ ...@@ -84,24 +84,24 @@
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{ {
$divstyle=''; $divstyle='';
switch ($region) { switch ($region) {
case 'full': // Leaderboard case 'full': // Leaderboard
$divstyle='width:728px; margin:0 auto;'; $divstyle='width:728px; margin:0 auto;';
case 'main': // Leaderboard case 'main': // Leaderboard
$width=728; $width=728;
$height=90; $height=90;
$format='728x90_as'; $format='728x90_as';
break; break;
case 'side': // Wide skyscraper case 'side': // Wide skyscraper
$width=160; $width=160;
$height=600; $height=600;
$format='160x600_as'; $format='160x600_as';
break; break;
} }
?> ?>
<div style="<?php echo $divstyle?>"> <div style="<?php echo $divstyle?>">
<script type="text/javascript"> <script type="text/javascript">
...@@ -118,9 +118,9 @@ src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> ...@@ -118,9 +118,9 @@ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</div> </div>
<?php <?php
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/basic-adsense/qa-plugin.php File: qa-plugin/basic-adsense/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates Adsense widget plugin Description: Initiates Adsense widget plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: Basic AdSense Plugin Name: Basic AdSense
Plugin URI: Plugin URI:
Plugin Description: Provides a basic widget for displaying Google AdSense ads Plugin Description: Provides a basic widget for displaying Google AdSense ads
Plugin Version: 1.0 Plugin Version: 1.0
Plugin Date: 2011-03-27 Plugin Date: 2011-03-27
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.4 Plugin Minimum Question2Answer Version: 1.4
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
qa_register_plugin_module('widget', 'qa-basic-adsense.php', 'qa_basic_adsense', 'Basic AdSense'); qa_register_plugin_module('widget', 'qa-basic-adsense.php', 'qa_basic_adsense', 'Basic AdSense');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/event-logger/qa-event-logger.php File: qa-plugin/event-logger/qa-event-logger.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Event module class for event logger plugin Description: Event module class for event logger plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
*/ */
class qa_event_logger { class qa_event_logger {
function init_queries($tableslc) function init_queries($tableslc)
{ {
if (qa_opt('event_logger_to_database')) { if (qa_opt('event_logger_to_database')) {
$tablename=qa_db_add_table_prefix('eventlog'); $tablename=qa_db_add_table_prefix('eventlog');
if (!in_array($tablename, $tableslc)) { if (!in_array($tablename, $tableslc)) {
require_once QA_INCLUDE_DIR.'qa-app-users.php'; require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-db-maxima.php'; require_once QA_INCLUDE_DIR.'qa-db-maxima.php';
...@@ -52,14 +52,14 @@ ...@@ -52,14 +52,14 @@
} }
} }
function admin_form(&$qa_content) function admin_form(&$qa_content)
{ {
// Process form input // Process form input
$saved=false; $saved=false;
if (qa_clicked('event_logger_save_button')) { if (qa_clicked('event_logger_save_button')) {
qa_opt('event_logger_to_database', (int)qa_post_text('event_logger_to_database_field')); qa_opt('event_logger_to_database', (int)qa_post_text('event_logger_to_database_field'));
qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field')); qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field'));
...@@ -68,14 +68,14 @@ ...@@ -68,14 +68,14 @@
$saved=true; $saved=true;
} }
// Check the validity of the currently entered directory (if any) // Check the validity of the currently entered directory (if any)
$directory=qa_opt('event_logger_directory'); $directory=qa_opt('event_logger_directory');
$note=null; $note=null;
$error=null; $error=null;
if (!strlen($directory)) if (!strlen($directory))
$note='Please specify a directory that is writable by the web server.'; $note='Please specify a directory that is writable by the web server.';
elseif (!file_exists($directory)) elseif (!file_exists($directory))
...@@ -84,17 +84,17 @@ ...@@ -84,17 +84,17 @@
$error='This is a file. Please enter the full path of a directory.'; $error='This is a file. Please enter the full path of a directory.';
elseif (!is_writable($directory)) elseif (!is_writable($directory))
$error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.'; $error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';
// Create the form for display // Create the form for display
qa_set_display_rules($qa_content, array( qa_set_display_rules($qa_content, array(
'event_logger_directory_display' => 'event_logger_to_files_field', 'event_logger_directory_display' => 'event_logger_to_files_field',
'event_logger_hide_header_display' => 'event_logger_to_files_field', 'event_logger_hide_header_display' => 'event_logger_to_files_field',
)); ));
return array( return array(
'ok' => ($saved && !isset($error)) ? 'Event log settings saved' : null, 'ok' => ($saved && !isset($error)) ? 'Event log settings saved' : null,
'fields' => array( 'fields' => array(
array( array(
'label' => 'Log events to <code>'.QA_MYSQL_TABLE_PREFIX.'eventlog</code> database table', 'label' => 'Log events to <code>'.QA_MYSQL_TABLE_PREFIX.'eventlog</code> database table',
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
'value' => qa_opt('event_logger_to_files'), 'value' => qa_opt('event_logger_to_files'),
'type' => 'checkbox', 'type' => 'checkbox',
), ),
array( array(
'id' => 'event_logger_directory_display', 'id' => 'event_logger_directory_display',
'label' => 'Directory for log files - enter full path:', 'label' => 'Directory for log files - enter full path:',
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
'note' => $note, 'note' => $note,
'error' => qa_html($error), 'error' => qa_html($error),
), ),
array( array(
'id' => 'event_logger_hide_header_display', 'id' => 'event_logger_hide_header_display',
'label' => 'Include header lines at top of each log file', 'label' => 'Include header lines at top of each log file',
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
'value' => !qa_opt('event_logger_hide_header'), 'value' => !qa_opt('event_logger_hide_header'),
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
); );
} }
function value_to_text($value) function value_to_text($value)
{ {
if (is_array($value)) if (is_array($value))
...@@ -146,45 +146,45 @@ ...@@ -146,45 +146,45 @@
$text=substr($value, 0, 38).'...'; $text=substr($value, 0, 38).'...';
else else
$text=$value; $text=$value;
return strtr($text, "\t\n\r", ' '); return strtr($text, "\t\n\r", ' ');
} }
function process_event($event, $userid, $handle, $cookieid, $params) function process_event($event, $userid, $handle, $cookieid, $params)
{ {
if (qa_opt('event_logger_to_database')) { if (qa_opt('event_logger_to_database')) {
$paramstring=''; $paramstring='';
foreach ($params as $key => $value) foreach ($params as $key => $value)
$paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value); $paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value);
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '. 'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
'VALUES (NOW(), $, $, $, #, $, $)', 'VALUES (NOW(), $, $, $, #, $, $)',
qa_remote_ip_address(), $userid, $handle, $cookieid, $event, $paramstring qa_remote_ip_address(), $userid, $handle, $cookieid, $event, $paramstring
); );
} }
if (qa_opt('event_logger_to_files')) { if (qa_opt('event_logger_to_files')) {
// Substitute some placeholders if certain information is missing // Substitute some placeholders if certain information is missing
if (!strlen($userid)) if (!strlen($userid))
$userid='no_userid'; $userid='no_userid';
if (!strlen($handle)) if (!strlen($handle))
$handle='no_handle'; $handle='no_handle';
if (!strlen($cookieid)) if (!strlen($cookieid))
$cookieid='no_cookieid'; $cookieid='no_cookieid';
$ip=qa_remote_ip_address(); $ip=qa_remote_ip_address();
if (!strlen($ip)) if (!strlen($ip))
$ip='no_ipaddress'; $ip='no_ipaddress';
// Build the log file line to be written // Build the log file line to be written
$fixedfields=array( $fixedfields=array(
'Date' => date('Y\-m\-d'), 'Date' => date('Y\-m\-d'),
'Time' => date('H\:i\:s'), 'Time' => date('H\:i\:s'),
...@@ -194,36 +194,36 @@ ...@@ -194,36 +194,36 @@
'CookieID' => $cookieid, 'CookieID' => $cookieid,
'Event' => $event, 'Event' => $event,
); );
$fields=$fixedfields; $fields=$fixedfields;
foreach ($params as $key => $value) foreach ($params as $key => $value)
$fields['param_'.$key]=$key.'='.$this->value_to_text($value); $fields['param_'.$key]=$key.'='.$this->value_to_text($value);
$string=implode("\t", $fields); $string=implode("\t", $fields);
// Build the full path and file name // Build the full path and file name
$directory=qa_opt('event_logger_directory'); $directory=qa_opt('event_logger_directory');
if (substr($directory, -1)!='/') if (substr($directory, -1)!='/')
$directory.='/'; $directory.='/';
$filename=$directory.'q2a-log-'.date('Y\-m\-d').'.txt'; $filename=$directory.'q2a-log-'.date('Y\-m\-d').'.txt';
// Open, lock, write, unlock, close (to prevent interference between multiple writes) // Open, lock, write, unlock, close (to prevent interference between multiple writes)
$exists=file_exists($filename); $exists=file_exists($filename);
$file=@fopen($filename, 'a'); $file=@fopen($filename, 'a');
if (is_resource($file)) { if (is_resource($file)) {
if (flock($file, LOCK_EX)) { if (flock($file, LOCK_EX)) {
if ( (!$exists) && (filesize($filename)===0) && !qa_opt('event_logger_hide_header') ) if ( (!$exists) && (filesize($filename)===0) && !qa_opt('event_logger_hide_header') )
$string="Question2Answer ".QA_VERSION." log file generated by Event Logger plugin.\n". $string="Question2Answer ".QA_VERSION." log file generated by Event Logger plugin.\n".
"This file is formatted as tab-delimited text with UTF-8 encoding.\n\n". "This file is formatted as tab-delimited text with UTF-8 encoding.\n\n".
implode("\t", array_keys($fixedfields))."\textras...\n\n".$string; implode("\t", array_keys($fixedfields))."\textras...\n\n".$string;
fwrite($file, $string."\n"); fwrite($file, $string."\n");
flock($file, LOCK_UN); flock($file, LOCK_UN);
} }
...@@ -232,9 +232,9 @@ ...@@ -232,9 +232,9 @@
} }
} }
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/event-logger/qa-plugin.php File: qa-plugin/event-logger/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates event logger plugin Description: Initiates event logger plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: Event Logger Plugin Name: Event Logger
Plugin URI: Plugin URI:
Plugin Description: Stores a record of user activity in the database and/or log files Plugin Description: Stores a record of user activity in the database and/or log files
Plugin Version: 1.1 Plugin Version: 1.1
Plugin Date: 2011-12-06 Plugin Date: 2011-12-06
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.5 Plugin Minimum Question2Answer Version: 1.5
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
qa_register_plugin_module('event', 'qa-event-logger.php', 'qa_event_logger', 'Event Logger'); qa_register_plugin_module('event', 'qa-event-logger.php', 'qa_event_logger', 'Event Logger');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
<?php <?php
/* /*
Question2Answer (c) Gideon Greenspan Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/example-page/qa-example-lang-default.php File: qa-plugin/example-page/qa-example-lang-default.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: US English language phrases for example plugin Description: US English language phrases for example plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
return array( return array(
'page_title' => 'Example plugin page (US English)', 'page_title' => 'Example plugin page (US English)',
); );
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
<?php <?php
/* /*
Question2Answer (c) Gideon Greenspan Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/example-page/qa-example-lang-en-GB.php File: qa-plugin/example-page/qa-example-lang-en-GB.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: UK English language phrases for example plugin Description: UK English language phrases for example plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
return array( return array(
'page_title' => 'Example plugin page (UK English)', 'page_title' => 'Example plugin page (UK English)',
); );
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/example-page/qa-example-page.php File: qa-plugin/example-page/qa-example-page.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Page module class for example page plugin Description: Page module class for example page plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
*/ */
class qa_example_page { class qa_example_page {
var $directory; var $directory;
var $urltoroot; var $urltoroot;
function load_module($directory, $urltoroot) function load_module($directory, $urltoroot)
{ {
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
$this->urltoroot=$urltoroot; $this->urltoroot=$urltoroot;
} }
function suggest_requests() // for display in admin interface function suggest_requests() // for display in admin interface
{ {
return array( return array(
array( array(
'title' => 'Example', 'title' => 'Example',
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
); );
} }
function match_request($request) function match_request($request)
{ {
if ($request=='example-plugin-page') if ($request=='example-plugin-page')
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
return false; return false;
} }
function process_request($request) function process_request($request)
{ {
$qa_content=qa_content_prepare(); $qa_content=qa_content_prepare();
...@@ -68,13 +68,13 @@ ...@@ -68,13 +68,13 @@
$qa_content['form']=array( $qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="'.qa_self_html().'"',
'style' => 'wide', 'style' => 'wide',
'ok' => qa_post_text('okthen') ? 'You clicked OK then!' : null, 'ok' => qa_post_text('okthen') ? 'You clicked OK then!' : null,
'title' => 'Form title', 'title' => 'Form title',
'fields' => array( 'fields' => array(
'request' => array( 'request' => array(
'label' => 'The request', 'label' => 'The request',
...@@ -82,9 +82,9 @@ ...@@ -82,9 +82,9 @@
'value' => qa_html($request), 'value' => qa_html($request),
'error' => qa_html('Another error'), 'error' => qa_html('Another error'),
), ),
), ),
'buttons' => array( 'buttons' => array(
'ok' => array( 'ok' => array(
'tags' => 'name="okthen"', 'tags' => 'name="okthen"',
...@@ -92,19 +92,19 @@ ...@@ -92,19 +92,19 @@
'value' => '1', 'value' => '1',
), ),
), ),
'hidden' => array( 'hidden' => array(
'hiddenfield' => '1', 'hiddenfield' => '1',
), ),
); );
$qa_content['custom_2']='<p><br>More <i>custom html</i></p>'; $qa_content['custom_2']='<p><br>More <i>custom html</i></p>';
return $qa_content; return $qa_content;
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/example-page/qa-plugin.php File: qa-plugin/example-page/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates example page plugin Description: Initiates example page plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: Example Page Plugin Name: Example Page
Plugin URI: Plugin URI:
Plugin Description: Example of page plugin Plugin Description: Example of page plugin
Plugin Version: 1.1 Plugin Version: 1.1
Plugin Date: 2011-12-06 Plugin Date: 2011-12-06
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.5 Plugin Minimum Question2Answer Version: 1.5
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
qa_register_plugin_module('page', 'qa-example-page.php', 'qa_example_page', 'Example Page'); qa_register_plugin_module('page', 'qa-example-page.php', 'qa_example_page', 'Example Page');
qa_register_plugin_phrases('qa-example-lang-*.php', 'example_page'); qa_register_plugin_phrases('qa-example-lang-*.php', 'example_page');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -134,8 +134,8 @@ class Services_JSON ...@@ -134,8 +134,8 @@ class Services_JSON
* bubble up with an error, so all return values * bubble up with an error, so all return values
* from encode() should be checked with isError() * from encode() should be checked with isError()
* - SERVICES_JSON_USE_TO_JSON: call toJSON when serializing objects * - SERVICES_JSON_USE_TO_JSON: call toJSON when serializing objects
* It serializes the return value from the toJSON call rather * It serializes the return value from the toJSON call rather
* than the object it'self, toJSON can return associative arrays, * than the object it'self, toJSON can return associative arrays,
* strings or numbers, if you return an object, make sure it does * strings or numbers, if you return an object, make sure it does
* not have a toJSON method, otherwise an error will occur. * not have a toJSON method, otherwise an error will occur.
*/ */
...@@ -150,7 +150,7 @@ class Services_JSON ...@@ -150,7 +150,7 @@ class Services_JSON
var $_mb_strlen = false; var $_mb_strlen = false;
var $_mb_substr = false; var $_mb_substr = false;
var $_mb_convert_encoding = false; var $_mb_convert_encoding = false;
/** /**
* convert a string from one UTF-16 char to one UTF-8 char * convert a string from one UTF-16 char to one UTF-8 char
* *
...@@ -274,10 +274,10 @@ class Services_JSON ...@@ -274,10 +274,10 @@ class Services_JSON
$ret = $this->_encode($var); $ret = $this->_encode($var);
setlocale(LC_NUMERIC, $lc); setlocale(LC_NUMERIC, $lc);
return $ret; return $ret;
} }
/** /**
* PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
* *
* @param mixed $var any number, boolean, string, array, or object to be encoded. * @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior. * see argument 1 to Services_JSON() above for array-parsing behavior.
...@@ -287,9 +287,9 @@ class Services_JSON ...@@ -287,9 +287,9 @@ class Services_JSON
* @return mixed JSON string representation of input var or an error if a problem occurs * @return mixed JSON string representation of input var or an error if a problem occurs
* @access public * @access public
*/ */
function _encode($var) function _encode($var)
{ {
switch (gettype($var)) { switch (gettype($var)) {
case 'boolean': case 'boolean':
return $var ? 'true' : 'false'; return $var ? 'true' : 'false';
...@@ -354,7 +354,7 @@ class Services_JSON ...@@ -354,7 +354,7 @@ class Services_JSON
$ascii .= '?'; $ascii .= '?';
break; break;
} }
$char = pack('C*', $ord_var_c, ord($var{$c + 1})); $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1; $c += 1;
$utf16 = $this->utf82utf16($char); $utf16 = $this->utf82utf16($char);
...@@ -480,27 +480,27 @@ class Services_JSON ...@@ -480,27 +480,27 @@ class Services_JSON
return '[' . join(',', $elements) . ']'; return '[' . join(',', $elements) . ']';
case 'object': case 'object':
// support toJSON methods. // support toJSON methods.
if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) { if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) {
// this may end up allowing unlimited recursion // this may end up allowing unlimited recursion
// so we check the return value to make sure it's not got the same method. // so we check the return value to make sure it's not got the same method.
$recode = $var->toJSON(); $recode = $var->toJSON();
if (method_exists($recode, 'toJSON')) { if (method_exists($recode, 'toJSON')) {
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null' ? 'null'
: new Services_JSON_Error(class_name($var). : new Services_JSON_Error(class_name($var).
" toJSON returned an object with a toJSON method."); " toJSON returned an object with a toJSON method.");
} }
return $this->_encode( $recode ); return $this->_encode( $recode );
} }
$vars = get_object_vars($var); $vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'), $properties = array_map(array($this, 'name_value'),
array_keys($vars), array_keys($vars),
array_values($vars)); array_values($vars));
...@@ -764,7 +764,7 @@ class Services_JSON ...@@ -764,7 +764,7 @@ class Services_JSON
// element in an associative array, // element in an associative array,
// for now // for now
$parts = array(); $parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) { if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) {
// "name":value pair // "name":value pair
$key = $this->decode($parts[1]); $key = $this->decode($parts[1]);
...@@ -871,28 +871,28 @@ class Services_JSON ...@@ -871,28 +871,28 @@ class Services_JSON
return false; return false;
} }
/** /**
* Calculates length of string in bytes * Calculates length of string in bytes
* @param string * @param string
* @return integer length * @return integer length
*/ */
function strlen8( $str ) function strlen8( $str )
{ {
if ( $this->_mb_strlen ) { if ( $this->_mb_strlen ) {
return mb_strlen( $str, "8bit" ); return mb_strlen( $str, "8bit" );
} }
return strlen( $str ); return strlen( $str );
} }
/** /**
* Returns part of a string, interpreting $start and $length as number of bytes. * Returns part of a string, interpreting $start and $length as number of bytes.
* @param string * @param string
* @param integer start * @param integer start
* @param integer length * @param integer length
* @return integer length * @return integer length
*/ */
function substr8( $string, $start, $length=false ) function substr8( $string, $start, $length=false )
{ {
if ( $length === false ) { if ( $length === false ) {
$length = $this->strlen8( $string ) - $start; $length = $this->strlen8( $string ) - $start;
...@@ -929,5 +929,5 @@ if (class_exists('PEAR_Error')) { ...@@ -929,5 +929,5 @@ if (class_exists('PEAR_Error')) {
} }
} }
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/facebook-login/qa-facebook-layer.php File: qa-plugin/facebook-login/qa-facebook-layer.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Theme layer class for mouseover layer plugin Description: Theme layer class for mouseover layer plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
*/ */
class qa_html_theme_layer extends qa_html_theme_base { class qa_html_theme_layer extends qa_html_theme_base {
function head_css() function head_css()
{ {
qa_html_theme_base::head_css(); qa_html_theme_base::head_css();
if (strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'))) if (strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret')))
$this->output( $this->output(
'<style><!--', '<style><!--',
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/facebook-login/qa-facebook-login-page.php File: qa-plugin/facebook-login/qa-facebook-login-page.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Page which performs Facebook login action Description: Page which performs Facebook login action
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
*/ */
class qa_facebook_login_page { class qa_facebook_login_page {
var $directory; var $directory;
var $urltoroot; var $urltoroot;
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
{ {
return ($request=='facebook-login'); return ($request=='facebook-login');
} }
function process_request($request) function process_request($request)
{ {
if ($request=='facebook-login') { if ($request=='facebook-login') {
...@@ -52,28 +52,28 @@ ...@@ -52,28 +52,28 @@
if (strlen($app_id) && strlen($app_secret)) { if (strlen($app_id) && strlen($app_secret)) {
if (!function_exists('json_decode')) { // work around fact that PHP might not have JSON extension installed if (!function_exists('json_decode')) { // work around fact that PHP might not have JSON extension installed
require_once $this->directory.'JSON.php'; require_once $this->directory.'JSON.php';
function json_decode($json) function json_decode($json)
{ {
$decoder=new Services_JSON(SERVICES_JSON_LOOSE_TYPE); $decoder=new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
return $decoder->decode($json); return $decoder->decode($json);
} }
} }
require_once $this->directory.'facebook.php'; require_once $this->directory.'facebook.php';
$facebook = new Facebook(array( $facebook = new Facebook(array(
'appId' => $app_id, 'appId' => $app_id,
'secret' => $app_secret, 'secret' => $app_secret,
'cookie' => true, 'cookie' => true,
)); ));
$fb_userid=$facebook->getUser(); $fb_userid=$facebook->getUser();
if ($fb_userid) { if ($fb_userid) {
try { try {
$user=$facebook->api('/me?fields=email,name,verified,location,website,about,picture'); $user=$facebook->api('/me?fields=email,name,verified,location,website,about,picture');
if (is_array($user)) if (is_array($user))
qa_log_in_external_user('facebook', $fb_userid, array( qa_log_in_external_user('facebook', $fb_userid, array(
'email' => @$user['email'], 'email' => @$user['email'],
...@@ -93,13 +93,13 @@ ...@@ -93,13 +93,13 @@
qa_redirect_raw($facebook->getLoginUrl(array('redirect_uri' => $tourl))); qa_redirect_raw($facebook->getLoginUrl(array('redirect_uri' => $tourl)));
} }
} }
qa_redirect_raw($tourl); qa_redirect_raw($tourl);
} }
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/facebook-login/qa-facebook-login.php File: qa-plugin/facebook-login/qa-facebook-login.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Login module class for Facebook login plugin Description: Login module class for Facebook login plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,34 +25,34 @@ ...@@ -25,34 +25,34 @@
*/ */
class qa_facebook_login { class qa_facebook_login {
function match_source($source) function match_source($source)
{ {
return $source=='facebook'; return $source=='facebook';
} }
function login_html($tourl, $context) function login_html($tourl, $context)
{ {
$app_id=qa_opt('facebook_app_id'); $app_id=qa_opt('facebook_app_id');
if (!strlen($app_id)) if (!strlen($app_id))
return; return;
$this->facebook_html(qa_path_absolute('facebook-login', array('to' => $tourl)), false, $context); $this->facebook_html(qa_path_absolute('facebook-login', array('to' => $tourl)), false, $context);
} }
function logout_html($tourl) function logout_html($tourl)
{ {
$app_id=qa_opt('facebook_app_id'); $app_id=qa_opt('facebook_app_id');
if (!strlen($app_id)) if (!strlen($app_id))
return; return;
$this->facebook_html($tourl, true, 'menu'); $this->facebook_html($tourl, true, 'menu');
} }
function facebook_html($tourl, $logout, $context) function facebook_html($tourl, $logout, $context)
{ {
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
window.fbAsyncInit = function() { window.fbAsyncInit = function() {
FB.init({ FB.init({
appId : <?php echo qa_js(qa_opt('facebook_app_id'), true)?>, appId : <?php echo qa_js(qa_opt('facebook_app_id'), true)?>,
status : true, status : true,
cookie : true, cookie : true,
xfbml : true, xfbml : true,
oauth : true oauth : true
...@@ -88,25 +88,25 @@ ...@@ -88,25 +88,25 @@
</div> </div>
<?php <?php
} }
function admin_form() function admin_form()
{ {
$saved=false; $saved=false;
if (qa_clicked('facebook_save_button')) { if (qa_clicked('facebook_save_button')) {
qa_opt('facebook_app_id', qa_post_text('facebook_app_id_field')); qa_opt('facebook_app_id', qa_post_text('facebook_app_id_field'));
qa_opt('facebook_app_secret', qa_post_text('facebook_app_secret_field')); qa_opt('facebook_app_secret', qa_post_text('facebook_app_secret_field'));
$saved=true; $saved=true;
} }
$ready=strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret')); $ready=strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'));
return array( return array(
'ok' => $saved ? 'Facebook application details saved' : null, 'ok' => $saved ? 'Facebook application details saved' : null,
'fields' => array( 'fields' => array(
array( array(
'label' => 'Facebook App ID:', 'label' => 'Facebook App ID:',
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
'error' => $ready ? null : 'To use Facebook Login, please <a href="http://developers.facebook.com/setup/" target="_blank">set up a Facebook application</a>.', 'error' => $ready ? null : 'To use Facebook Login, please <a href="http://developers.facebook.com/setup/" target="_blank">set up a Facebook application</a>.',
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -130,9 +130,9 @@ ...@@ -130,9 +130,9 @@
), ),
); );
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/facebook-login/qa-plugin.php File: qa-plugin/facebook-login/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates Facebook login plugin Description: Initiates Facebook login plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: Facebook Login Plugin Name: Facebook Login
Plugin URI: Plugin URI:
Plugin Description: Allows users to log in via Facebook Plugin Description: Allows users to log in via Facebook
Plugin Version: 1.1.5 Plugin Version: 1.1.5
Plugin Date: 2012-09-13 Plugin Date: 2012-09-13
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
qa_register_plugin_module('page', 'qa-facebook-login-page.php', 'qa_facebook_login_page', 'Facebook Login Page'); qa_register_plugin_module('page', 'qa-facebook-login-page.php', 'qa_facebook_login_page', 'Facebook Login Page');
qa_register_plugin_layer('qa-facebook-layer.php', 'Facebook Login Layer'); qa_register_plugin_layer('qa-facebook-layer.php', 'Facebook Login Layer');
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/mouseover-layer/qa-mouseover-admin-form.php File: qa-plugin/mouseover-layer/qa-mouseover-admin-form.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Generic module class for mouseover layer plugin to provide admin form and default option Description: Generic module class for mouseover layer plugin to provide admin form and default option
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,31 +25,31 @@ ...@@ -25,31 +25,31 @@
*/ */
class qa_mouseover_admin_form { class qa_mouseover_admin_form {
function option_default($option) function option_default($option)
{ {
if ($option=='mouseover_content_max_len') if ($option=='mouseover_content_max_len')
return 480; return 480;
} }
function admin_form(&$qa_content) function admin_form(&$qa_content)
{ {
$saved=false; $saved=false;
if (qa_clicked('mouseover_save_button')) { if (qa_clicked('mouseover_save_button')) {
qa_opt('mouseover_content_on', (int)qa_post_text('mouseover_content_on_field')); qa_opt('mouseover_content_on', (int)qa_post_text('mouseover_content_on_field'));
qa_opt('mouseover_content_max_len', (int)qa_post_text('mouseover_content_max_len_field')); qa_opt('mouseover_content_max_len', (int)qa_post_text('mouseover_content_max_len_field'));
$saved=true; $saved=true;
} }
qa_set_display_rules($qa_content, array( qa_set_display_rules($qa_content, array(
'mouseover_content_max_len_display' => 'mouseover_content_on_field', 'mouseover_content_max_len_display' => 'mouseover_content_on_field',
)); ));
return array( return array(
'ok' => $saved ? 'Mouseover settings saved' : null, 'ok' => $saved ? 'Mouseover settings saved' : null,
'fields' => array( 'fields' => array(
array( array(
'label' => 'Show content preview on mouseover in question lists', 'label' => 'Show content preview on mouseover in question lists',
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
'value' => qa_opt('mouseover_content_on'), 'value' => qa_opt('mouseover_content_on'),
'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"', 'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"',
), ),
array( array(
'id' => 'mouseover_content_max_len_display', 'id' => 'mouseover_content_max_len_display',
'label' => 'Maximum length of preview:', 'label' => 'Maximum length of preview:',
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
'tags' => 'name="mouseover_content_max_len_field"', 'tags' => 'name="mouseover_content_max_len_field"',
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -76,9 +76,9 @@ ...@@ -76,9 +76,9 @@
), ),
); );
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/mouseover-layer/qa-mouseover-layer.php File: qa-plugin/mouseover-layer/qa-mouseover-layer.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Theme layer class for mouseover layer plugin Description: Theme layer class for mouseover layer plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,35 +25,35 @@ ...@@ -25,35 +25,35 @@
*/ */
class qa_html_theme_layer extends qa_html_theme_base { class qa_html_theme_layer extends qa_html_theme_base {
function q_list($q_list) function q_list($q_list)
{ {
if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query) // Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids=array(); $postids=array();
foreach ($q_list['qs'] as $question) foreach ($q_list['qs'] as $question)
if (isset($question['raw']['postid'])) if (isset($question['raw']['postid']))
$postids[]=$question['raw']['postid']; $postids[]=$question['raw']['postid'];
if (count($postids)) { if (count($postids)) {
// Retrieve the content for these questions from the database and put into an array // Retrieve the content for these questions from the database and put into an array
$result=qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $result=qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo=qa_db_read_all_assoc($result, 'postid'); $postinfo=qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show // Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg=qa_get_block_words_preg(); $blockwordspreg=qa_get_block_words_preg();
$maxlength=qa_opt('mouseover_content_max_len'); $maxlength=qa_opt('mouseover_content_max_len');
// Now add the popup to the title for each question // Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) { foreach ($q_list['qs'] as $index => $question) {
$thispost=@$postinfo[$question['raw']['postid']]; $thispost=@$postinfo[$question['raw']['postid']];
if (isset($thispost)) { if (isset($thispost)) {
$text=qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text=qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line($text, $maxlength); $text=qa_shorten_string_line($text, $maxlength);
...@@ -62,12 +62,12 @@ ...@@ -62,12 +62,12 @@
} }
} }
} }
qa_html_theme_base::q_list($q_list); // call back through to the default function qa_html_theme_base::q_list($q_list); // call back through to the default function
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/mouseover-layer/qa-plugin.php File: qa-plugin/mouseover-layer/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates mouseover layer plugin Description: Initiates mouseover layer plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: Mouseover Layer Plugin Name: Mouseover Layer
Plugin URI: Plugin URI:
Plugin Description: Shows question content on mouse over in question lists Plugin Description: Shows question content on mouse over in question lists
Plugin Version: 1.0.1 Plugin Version: 1.0.1
Plugin Date: 2011-12-06 Plugin Date: 2011-12-06
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.5 Plugin Minimum Question2Answer Version: 1.5
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
qa_register_plugin_layer('qa-mouseover-layer.php', 'Mouseover Layer'); qa_register_plugin_layer('qa-mouseover-layer.php', 'Mouseover Layer');
qa_register_plugin_module('module', 'qa-mouseover-admin-form.php', 'qa_mouseover_admin_form', 'Mouseover Layer'); qa_register_plugin_module('module', 'qa-mouseover-admin-form.php', 'qa_mouseover_admin_form', 'Mouseover Layer');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/opensearch-support/qa-opensearch-layer.php File: qa-plugin/opensearch-support/qa-opensearch-layer.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Theme layer class for OpenSearch plugin Description: Theme layer class for OpenSearch plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,16 +25,16 @@ ...@@ -25,16 +25,16 @@
*/ */
class qa_html_theme_layer extends qa_html_theme_base { class qa_html_theme_layer extends qa_html_theme_base {
function head_links() function head_links()
{ {
qa_html_theme_base::head_links(); qa_html_theme_base::head_links();
$this->output('<link rel="search" type="application/opensearchdescription+xml" title="'.qa_html(qa_opt('site_title')).'" href="'.qa_path_html('opensearch.xml').'"/>'); $this->output('<link rel="search" type="application/opensearchdescription+xml" title="'.qa_html(qa_opt('site_title')).'" href="'.qa_path_html('opensearch.xml').'"/>');
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/opensearch-support/qa-opensearch-page.php File: qa-plugin/opensearch-support/qa-opensearch-page.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Page module class for XML sitemap plugin Description: Page module class for XML sitemap plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
*/ */
class qa_opensearch_xml { class qa_opensearch_xml {
function match_request($request) function match_request($request)
{ {
return ($request=='opensearch.xml'); return ($request=='opensearch.xml');
...@@ -39,22 +39,22 @@ ...@@ -39,22 +39,22 @@
$template=str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path_absolute('search', array('q' => '_searchTerms_placeholder_'))); $template=str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path_absolute('search', array('q' => '_searchTerms_placeholder_')));
header('Content-type: text/xml; charset=utf-8'); header('Content-type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'."\n"; echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'."\n";
echo "\t<ShortName>".$titlexml."</ShortName>\n"; echo "\t<ShortName>".$titlexml."</ShortName>\n";
echo "\t<Description>".qa_xml(qa_lang('main/search_button')).' '.$titlexml."</Description>\n"; echo "\t<Description>".qa_xml(qa_lang('main/search_button')).' '.$titlexml."</Description>\n";
echo "\t".'<Url type="text/html" method="get" template="'.qa_xml($template).'"/>'."\n"; echo "\t".'<Url type="text/html" method="get" template="'.qa_xml($template).'"/>'."\n";
echo "\t<InputEncoding>UTF-8</InputEncoding>\n"; echo "\t<InputEncoding>UTF-8</InputEncoding>\n";
echo '</OpenSearchDescription>'."\n"; echo '</OpenSearchDescription>'."\n";
return null; return null;
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/opensearch-support/qa-plugin.php File: qa-plugin/opensearch-support/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates OpenSearch plugin Description: Initiates OpenSearch plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: OpenSearch Support Plugin Name: OpenSearch Support
Plugin URI: Plugin URI:
Plugin Description: Allows OpenSearch clients to search Q2A site directly Plugin Description: Allows OpenSearch clients to search Q2A site directly
Plugin Version: 1.0 Plugin Version: 1.0
Plugin Date: 2012-08-21 Plugin Date: 2012-08-21
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.5 Plugin Minimum Question2Answer Version: 1.5
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -43,10 +43,10 @@ ...@@ -43,10 +43,10 @@
exit; exit;
} }
qa_register_plugin_layer('qa-opensearch-layer.php', 'OpenSearch Layer'); qa_register_plugin_layer('qa-opensearch-layer.php', 'OpenSearch Layer');
qa_register_plugin_module('page', 'qa-opensearch-page.php', 'qa_opensearch_xml', 'OpenSearch XML'); qa_register_plugin_module('page', 'qa-opensearch-page.php', 'qa_opensearch_xml', 'OpenSearch XML');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/recaptcha-captcha/qa-plugin.php File: qa-plugin/recaptcha-captcha/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates reCAPTCHA plugin Description: Initiates reCAPTCHA plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: reCAPTCHA Plugin Name: reCAPTCHA
Plugin URI: Plugin URI:
Plugin Description: Provides support for reCAPTCHA captchas Plugin Description: Provides support for reCAPTCHA captchas
Plugin Version: 1.0 Plugin Version: 1.0
Plugin Date: 2011-11-17 Plugin Date: 2011-11-17
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
qa_register_plugin_module('captcha', 'qa-recaptcha-captcha.php', 'qa_recaptcha_captcha', 'reCAPTCHA'); qa_register_plugin_module('captcha', 'qa-recaptcha-captcha.php', 'qa_recaptcha_captcha', 'reCAPTCHA');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/recaptcha-captcha/qa-recaptcha-captcha.php File: qa-plugin/recaptcha-captcha/qa-recaptcha-captcha.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Captcha module for reCAPTCHA Description: Captcha module for reCAPTCHA
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
class qa_recaptcha_captcha { class qa_recaptcha_captcha {
var $directory; var $directory;
function load_module($directory, $urltoroot) function load_module($directory, $urltoroot)
{ {
$this->directory=$directory; $this->directory=$directory;
...@@ -43,17 +43,17 @@ ...@@ -43,17 +43,17 @@
function admin_form() function admin_form()
{ {
$saved=false; $saved=false;
if (qa_clicked('recaptcha_save_button')) { if (qa_clicked('recaptcha_save_button')) {
qa_opt('recaptcha_public_key', qa_post_text('recaptcha_public_key_field')); qa_opt('recaptcha_public_key', qa_post_text('recaptcha_public_key_field'));
qa_opt('recaptcha_private_key', qa_post_text('recaptcha_private_key_field')); qa_opt('recaptcha_private_key', qa_post_text('recaptcha_private_key_field'));
$saved=true; $saved=true;
} }
$form=array( $form=array(
'ok' => $saved ? 'reCAPTCHA settings saved' : null, 'ok' => $saved ? 'reCAPTCHA settings saved' : null,
'fields' => array( 'fields' => array(
'public' => array( 'public' => array(
'label' => 'reCAPTCHA public key:', 'label' => 'reCAPTCHA public key:',
...@@ -76,49 +76,49 @@ ...@@ -76,49 +76,49 @@
), ),
), ),
); );
return $form; return $form;
} }
function recaptcha_error_html() function recaptcha_error_html()
{ {
if (!function_exists('fsockopen')) if (!function_exists('fsockopen'))
return 'To use reCAPTCHA, the fsockopen() PHP function must be enabled on your server. Please check with your system administrator.'; return 'To use reCAPTCHA, the fsockopen() PHP function must be enabled on your server. Please check with your system administrator.';
elseif ( (!strlen(trim(qa_opt('recaptcha_public_key')))) || (!strlen(trim(qa_opt('recaptcha_private_key')))) ) { elseif ( (!strlen(trim(qa_opt('recaptcha_public_key')))) || (!strlen(trim(qa_opt('recaptcha_private_key')))) ) {
require_once $this->directory.'recaptchalib.php'; require_once $this->directory.'recaptchalib.php';
$url=recaptcha_get_signup_url(@$_SERVER['HTTP_HOST'], qa_opt('site_title')); $url=recaptcha_get_signup_url(@$_SERVER['HTTP_HOST'], qa_opt('site_title'));
return 'To use reCAPTCHA, you must <a href="'.qa_html($url).'">sign up</a> to get these keys.'; return 'To use reCAPTCHA, you must <a href="'.qa_html($url).'">sign up</a> to get these keys.';
} }
return null; return null;
} }
function allow_captcha() function allow_captcha()
{ {
return function_exists('fsockopen') && strlen(trim(qa_opt('recaptcha_public_key'))) && strlen(trim(qa_opt('recaptcha_private_key'))); return function_exists('fsockopen') && strlen(trim(qa_opt('recaptcha_public_key'))) && strlen(trim(qa_opt('recaptcha_private_key')));
} }
function form_html(&$qa_content, $error) function form_html(&$qa_content, $error)
{ {
require_once $this->directory.'recaptchalib.php'; require_once $this->directory.'recaptchalib.php';
$language=qa_opt('site_language'); $language=qa_opt('site_language');
if (strpos('|en|nl|fr|de|pt|ru|es|tr|', '|'.$language.'|')===false) // supported as of 3/2010 if (strpos('|en|nl|fr|de|pt|ru|es|tr|', '|'.$language.'|')===false) // supported as of 3/2010
$language='en'; $language='en';
$qa_content['script_lines'][]=array( $qa_content['script_lines'][]=array(
"var RecaptchaOptions={", "var RecaptchaOptions={",
"\ttheme:'white',", "\ttheme:'white',",
"\tlang:".qa_js($language), "\tlang:".qa_js($language),
"};", "};",
); );
return recaptcha_get_html(qa_opt('recaptcha_public_key'), $error, qa_is_https_probably()); return recaptcha_get_html(qa_opt('recaptcha_public_key'), $error, qa_is_https_probably());
} }
...@@ -127,25 +127,25 @@ ...@@ -127,25 +127,25 @@
{ {
if ( (!empty($_POST['recaptcha_challenge_field'])) && (!empty($_POST['recaptcha_response_field'])) ) { if ( (!empty($_POST['recaptcha_challenge_field'])) && (!empty($_POST['recaptcha_response_field'])) ) {
require_once $this->directory.'recaptchalib.php'; require_once $this->directory.'recaptchalib.php';
$answer=recaptcha_check_answer( $answer=recaptcha_check_answer(
qa_opt('recaptcha_private_key'), qa_opt('recaptcha_private_key'),
qa_remote_ip_address(), qa_remote_ip_address(),
$_POST['recaptcha_challenge_field'], $_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field'] $_POST['recaptcha_response_field']
); );
if ($answer->is_valid) if ($answer->is_valid)
return true; return true;
$error=@$answer->error; $error=@$answer->error;
} }
return false; return false;
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -108,7 +108,7 @@ function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) ...@@ -108,7 +108,7 @@ function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
if ($pubkey == null || $pubkey == '') { if ($pubkey == null || $pubkey == '') {
die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
} }
if ($use_ssl) { if ($use_ssl) {
$server = RECAPTCHA_API_SECURE_SERVER; $server = RECAPTCHA_API_SECURE_SERVER;
} else { } else {
...@@ -159,8 +159,8 @@ function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $ex ...@@ -159,8 +159,8 @@ function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $ex
die ("For security reasons, you must pass the remote ip to reCAPTCHA"); die ("For security reasons, you must pass the remote ip to reCAPTCHA");
} }
//discard spam submissions //discard spam submissions
if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
$recaptcha_response = new ReCaptchaResponse(); $recaptcha_response = new ReCaptchaResponse();
...@@ -215,7 +215,7 @@ function _recaptcha_aes_encrypt($val,$ky) { ...@@ -215,7 +215,7 @@ function _recaptcha_aes_encrypt($val,$ky) {
if (! function_exists ("mcrypt_encrypt")) { if (! function_exists ("mcrypt_encrypt")) {
die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
} }
$mode=MCRYPT_MODE_CBC; $mode=MCRYPT_MODE_CBC;
$enc=MCRYPT_RIJNDAEL_128; $enc=MCRYPT_RIJNDAEL_128;
$val=_recaptcha_aes_pad($val); $val=_recaptcha_aes_pad($val);
return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
...@@ -232,11 +232,11 @@ function recaptcha_mailhide_url($pubkey, $privkey, $email) { ...@@ -232,11 +232,11 @@ function recaptcha_mailhide_url($pubkey, $privkey, $email) {
die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
"you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>"); "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
} }
$ky = pack('H*', $privkey); $ky = pack('H*', $privkey);
$cryptmail = _recaptcha_aes_encrypt ($email, $ky); $cryptmail = _recaptcha_aes_encrypt ($email, $ky);
return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
} }
...@@ -267,7 +267,7 @@ function _recaptcha_mailhide_email_parts ($email) { ...@@ -267,7 +267,7 @@ function _recaptcha_mailhide_email_parts ($email) {
function recaptcha_mailhide_html($pubkey, $privkey, $email) { function recaptcha_mailhide_html($pubkey, $privkey, $email) {
$emailparts = _recaptcha_mailhide_email_parts ($email); $emailparts = _recaptcha_mailhide_email_parts ($email);
$url = recaptcha_mailhide_url ($pubkey, $privkey, $email); $url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) . return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
"' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]); "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/tag-cloud-widget/qa-plugin.php File: qa-plugin/tag-cloud-widget/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates tag cloud widget plugin Description: Initiates tag cloud widget plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: Tag Cloud Widget Plugin Name: Tag Cloud Widget
Plugin URI: Plugin URI:
Plugin Description: Provides a list of tags with size indicating popularity Plugin Description: Provides a list of tags with size indicating popularity
Plugin Version: 1.0.1 Plugin Version: 1.0.1
Plugin Date: 2011-12-06 Plugin Date: 2011-12-06
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.4 Plugin Minimum Question2Answer Version: 1.4
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
qa_register_plugin_module('widget', 'qa-tag-cloud.php', 'qa_tag_cloud', 'Tag Cloud'); qa_register_plugin_module('widget', 'qa-tag-cloud.php', 'qa_tag_cloud', 'Tag Cloud');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/tag-cloud-widget/qa-tag-cloud.php File: qa-plugin/tag-cloud-widget/qa-tag-cloud.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Widget module class for tag cloud plugin Description: Widget module class for tag cloud plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
*/ */
class qa_tag_cloud { class qa_tag_cloud {
function option_default($option) function option_default($option)
{ {
if ($option=='tag_cloud_count_tags') if ($option=='tag_cloud_count_tags')
...@@ -36,21 +36,21 @@ ...@@ -36,21 +36,21 @@
return true; return true;
} }
function admin_form() function admin_form()
{ {
$saved=false; $saved=false;
if (qa_clicked('tag_cloud_save_button')) { if (qa_clicked('tag_cloud_save_button')) {
qa_opt('tag_cloud_count_tags', (int)qa_post_text('tag_cloud_count_tags_field')); qa_opt('tag_cloud_count_tags', (int)qa_post_text('tag_cloud_count_tags_field'));
qa_opt('tag_cloud_font_size', (int)qa_post_text('tag_cloud_font_size_field')); qa_opt('tag_cloud_font_size', (int)qa_post_text('tag_cloud_font_size_field'));
qa_opt('tag_cloud_size_popular', (int)qa_post_text('tag_cloud_size_popular_field')); qa_opt('tag_cloud_size_popular', (int)qa_post_text('tag_cloud_size_popular_field'));
$saved=true; $saved=true;
} }
return array( return array(
'ok' => $saved ? 'Tag cloud settings saved' : null, 'ok' => $saved ? 'Tag cloud settings saved' : null,
'fields' => array( 'fields' => array(
array( array(
'label' => 'Maximum tags to show:', 'label' => 'Maximum tags to show:',
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
'value' => (int)qa_opt('tag_cloud_font_size'), 'value' => (int)qa_opt('tag_cloud_font_size'),
'tags' => 'name="tag_cloud_font_size_field"', 'tags' => 'name="tag_cloud_font_size_field"',
), ),
array( array(
'label' => 'Font size represents tag popularity', 'label' => 'Font size represents tag popularity',
'type' => 'checkbox', 'type' => 'checkbox',
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
'tags' => 'name="tag_cloud_size_popular_field"', 'tags' => 'name="tag_cloud_size_popular_field"',
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -85,11 +85,11 @@ ...@@ -85,11 +85,11 @@
); );
} }
function allow_template($template) function allow_template($template)
{ {
$allow=false; $allow=false;
switch ($template) switch ($template)
{ {
case 'activity': case 'activity':
...@@ -110,53 +110,53 @@ ...@@ -110,53 +110,53 @@
$allow=true; $allow=true;
break; break;
} }
return $allow; return $allow;
} }
function allow_region($region) function allow_region($region)
{ {
return ($region=='side'); return ($region=='side');
} }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{ {
require_once QA_INCLUDE_DIR.'qa-db-selects.php'; require_once QA_INCLUDE_DIR.'qa-db-selects.php';
$populartags=qa_db_single_select(qa_db_popular_tags_selectspec(0, (int)qa_opt('tag_cloud_count_tags'))); $populartags=qa_db_single_select(qa_db_popular_tags_selectspec(0, (int)qa_opt('tag_cloud_count_tags')));
reset($populartags); reset($populartags);
$maxcount=current($populartags); $maxcount=current($populartags);
$themeobject->output( $themeobject->output(
'<h2 style="margin-top:0; padding-top:0;">', '<h2 style="margin-top:0; padding-top:0;">',
qa_lang_html('main/popular_tags'), qa_lang_html('main/popular_tags'),
'</h2>' '</h2>'
); );
$themeobject->output('<div style="font-size:10px;">'); $themeobject->output('<div style="font-size:10px;">');
$maxsize=qa_opt('tag_cloud_font_size'); $maxsize=qa_opt('tag_cloud_font_size');
$scale=qa_opt('tag_cloud_size_popular'); $scale=qa_opt('tag_cloud_size_popular');
$blockwordspreg=qa_get_block_words_preg(); $blockwordspreg=qa_get_block_words_preg();
foreach ($populartags as $tag => $count) { foreach ($populartags as $tag => $count) {
if (count(qa_block_words_match_all($tag, $blockwordspreg))) if (count(qa_block_words_match_all($tag, $blockwordspreg)))
continue; // skip censored tags continue; // skip censored tags
$size=number_format(($scale ? ($maxsize*$count/$maxcount) : $maxsize), 1); $size=number_format(($scale ? ($maxsize*$count/$maxcount) : $maxsize), 1);
if (($size>=5) || !$scale) if (($size>=5) || !$scale)
$themeobject->output('<a href="'.qa_path_html('tag/'.$tag).'" style="font-size:'.$size.'px; vertical-align:baseline;">'.qa_html($tag).'</a>'); $themeobject->output('<a href="'.qa_path_html('tag/'.$tag).'" style="font-size:'.$size.'px; vertical-align:baseline;">'.qa_html($tag).'</a>');
} }
$themeobject->output('</div>'); $themeobject->output('</div>');
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/wysiwyg-editor/qa-plugin.php File: qa-plugin/wysiwyg-editor/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates WYSIWYG editor plugin Description: Initiates WYSIWYG editor plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: WYSIWYG Editor Plugin Name: WYSIWYG Editor
Plugin URI: Plugin URI:
Plugin Description: Wrapper for CKEditor WYSIWYG rich text editor Plugin Description: Wrapper for CKEditor WYSIWYG rich text editor
Plugin Version: 1.1.1 Plugin Version: 1.1.1
Plugin Date: 2011-12-06 Plugin Date: 2011-12-06
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.3 Plugin Minimum Question2Answer Version: 1.3
Plugin Update Check URI: Plugin Update Check URI:
*/ */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/wysiwyg-editor/qa-wysiwyg-editor.php File: qa-plugin/wysiwyg-editor/qa-wysiwyg-editor.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Editor module class for WYSIWYG editor plugin Description: Editor module class for WYSIWYG editor plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,44 +26,44 @@ ...@@ -26,44 +26,44 @@
class qa_wysiwyg_editor { class qa_wysiwyg_editor {
var $urltoroot; var $urltoroot;
function load_module($directory, $urltoroot) function load_module($directory, $urltoroot)
{ {
$this->urltoroot=$urltoroot; $this->urltoroot=$urltoroot;
} }
function option_default($option) function option_default($option)
{ {
if ($option=='wysiwyg_editor_upload_max_size') { if ($option=='wysiwyg_editor_upload_max_size') {
require_once QA_INCLUDE_DIR.'qa-app-upload.php'; require_once QA_INCLUDE_DIR.'qa-app-upload.php';
return min(qa_get_max_upload_size(), 1048576); return min(qa_get_max_upload_size(), 1048576);
} }
} }
function bytes_to_mega_html($bytes) function bytes_to_mega_html($bytes)
{ {
return qa_html(number_format($bytes/1048576, 1)); return qa_html(number_format($bytes/1048576, 1));
} }
function admin_form(&$qa_content) function admin_form(&$qa_content)
{ {
require_once QA_INCLUDE_DIR.'qa-app-upload.php'; require_once QA_INCLUDE_DIR.'qa-app-upload.php';
$saved=false; $saved=false;
if (qa_clicked('wysiwyg_editor_save_button')) { if (qa_clicked('wysiwyg_editor_save_button')) {
qa_opt('wysiwyg_editor_upload_images', (int)qa_post_text('wysiwyg_editor_upload_images_field')); qa_opt('wysiwyg_editor_upload_images', (int)qa_post_text('wysiwyg_editor_upload_images_field'));
qa_opt('wysiwyg_editor_upload_all', (int)qa_post_text('wysiwyg_editor_upload_all_field')); qa_opt('wysiwyg_editor_upload_all', (int)qa_post_text('wysiwyg_editor_upload_all_field'));
qa_opt('wysiwyg_editor_upload_max_size', min(qa_get_max_upload_size(), 1048576*(float)qa_post_text('wysiwyg_editor_upload_max_size_field'))); qa_opt('wysiwyg_editor_upload_max_size', min(qa_get_max_upload_size(), 1048576*(float)qa_post_text('wysiwyg_editor_upload_max_size_field')));
$saved=true; $saved=true;
} }
qa_set_display_rules($qa_content, array( qa_set_display_rules($qa_content, array(
'wysiwyg_editor_upload_all_display' => 'wysiwyg_editor_upload_images_field', 'wysiwyg_editor_upload_all_display' => 'wysiwyg_editor_upload_images_field',
'wysiwyg_editor_upload_max_size_display' => 'wysiwyg_editor_upload_images_field', 'wysiwyg_editor_upload_max_size_display' => 'wysiwyg_editor_upload_images_field',
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
return array( return array(
'ok' => $saved ? 'WYSIWYG editor settings saved' : null, 'ok' => $saved ? 'WYSIWYG editor settings saved' : null,
'fields' => array( 'fields' => array(
array( array(
'label' => 'Allow images to be uploaded', 'label' => 'Allow images to be uploaded',
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
'value' => (int)qa_opt('wysiwyg_editor_upload_all'), 'value' => (int)qa_opt('wysiwyg_editor_upload_all'),
'tags' => 'name="wysiwyg_editor_upload_all_field"', 'tags' => 'name="wysiwyg_editor_upload_all_field"',
), ),
array( array(
'id' => 'wysiwyg_editor_upload_max_size_display', 'id' => 'wysiwyg_editor_upload_max_size_display',
'label' => 'Maximum size of uploads:', 'label' => 'Maximum size of uploads:',
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
'tags' => 'name="wysiwyg_editor_upload_max_size_field"', 'tags' => 'name="wysiwyg_editor_upload_max_size_field"',
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -106,8 +106,8 @@ ...@@ -106,8 +106,8 @@
), ),
); );
} }
function calc_quality($content, $format) function calc_quality($content, $format)
{ {
if ($format=='html') if ($format=='html')
...@@ -118,21 +118,21 @@ ...@@ -118,21 +118,21 @@
return 0; return 0;
} }
function get_field(&$qa_content, $content, $format, $fieldname, $rows /* $autofocus parameter deprecated */) function get_field(&$qa_content, $content, $format, $fieldname, $rows /* $autofocus parameter deprecated */)
{ {
$scriptsrc=$this->urltoroot.'ckeditor.js?'.QA_VERSION; $scriptsrc=$this->urltoroot.'ckeditor.js?'.QA_VERSION;
$alreadyadded=false; $alreadyadded=false;
if (isset($qa_content['script_src'])) if (isset($qa_content['script_src']))
foreach ($qa_content['script_src'] as $testscriptsrc) foreach ($qa_content['script_src'] as $testscriptsrc)
if ($testscriptsrc==$scriptsrc) if ($testscriptsrc==$scriptsrc)
$alreadyadded=true; $alreadyadded=true;
if (!$alreadyadded) { if (!$alreadyadded) {
$uploadimages=qa_opt('wysiwyg_editor_upload_images'); $uploadimages=qa_opt('wysiwyg_editor_upload_images');
$uploadall=$uploadimages && qa_opt('wysiwyg_editor_upload_all'); $uploadall=$uploadimages && qa_opt('wysiwyg_editor_upload_all');
$qa_content['script_src'][]=$scriptsrc; $qa_content['script_src'][]=$scriptsrc;
$qa_content['script_lines'][]=array( $qa_content['script_lines'][]=array(
"qa_wysiwyg_editor_config={toolbar:[". "qa_wysiwyg_editor_config={toolbar:[".
...@@ -157,8 +157,8 @@ ...@@ -157,8 +157,8 @@
($uploadall ? (", filebrowserUploadUrl:".qa_js(qa_path('wysiwyg-editor-upload'))) : ""). ($uploadall ? (", filebrowserUploadUrl:".qa_js(qa_path('wysiwyg-editor-upload'))) : "").
"};" "};"
); );
} }
if ($format=='html') { if ($format=='html') {
$html=$content; $html=$content;
$text=$this->html_to_text($content); $text=$this->html_to_text($content);
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
$text=$content; $text=$content;
$html=qa_html($content, true); $html=qa_html($content, true);
} }
return array( return array(
'tags' => 'name="'.$fieldname.'"', 'tags' => 'name="'.$fieldname.'"',
'value' => qa_html($text), 'value' => qa_html($text),
...@@ -174,39 +174,39 @@ ...@@ -174,39 +174,39 @@
'html_prefix' => '<input name="'.$fieldname.'_ckeditor_ok" id="'.$fieldname.'_ckeditor_ok" type="hidden" value="0"><input name="'.$fieldname.'_ckeditor_data" id="'.$fieldname.'_ckeditor_data" type="hidden" value="'.qa_html($html).'">', 'html_prefix' => '<input name="'.$fieldname.'_ckeditor_ok" id="'.$fieldname.'_ckeditor_ok" type="hidden" value="0"><input name="'.$fieldname.'_ckeditor_data" id="'.$fieldname.'_ckeditor_data" type="hidden" value="'.qa_html($html).'">',
); );
} }
function load_script($fieldname) function load_script($fieldname)
{ {
return "if (qa_ckeditor_".$fieldname."=CKEDITOR.replace(".qa_js($fieldname).", window.qa_wysiwyg_editor_config)) { qa_ckeditor_".$fieldname.".setData(document.getElementById(".qa_js($fieldname.'_ckeditor_data').").value); document.getElementById(".qa_js($fieldname.'_ckeditor_ok').").value=1; }"; return "if (qa_ckeditor_".$fieldname."=CKEDITOR.replace(".qa_js($fieldname).", window.qa_wysiwyg_editor_config)) { qa_ckeditor_".$fieldname.".setData(document.getElementById(".qa_js($fieldname.'_ckeditor_data').").value); document.getElementById(".qa_js($fieldname.'_ckeditor_ok').").value=1; }";
} }
function focus_script($fieldname) function focus_script($fieldname)
{ {
return "if (qa_ckeditor_".$fieldname.") qa_ckeditor_".$fieldname.".focus();"; return "if (qa_ckeditor_".$fieldname.") qa_ckeditor_".$fieldname.".focus();";
} }
function update_script($fieldname) function update_script($fieldname)
{ {
return "if (qa_ckeditor_".$fieldname.") qa_ckeditor_".$fieldname.".updateElement();"; return "if (qa_ckeditor_".$fieldname.") qa_ckeditor_".$fieldname.".updateElement();";
} }
function read_post($fieldname) function read_post($fieldname)
{ {
if (qa_post_text($fieldname.'_ckeditor_ok')) { // CKEditor was loaded successfully if (qa_post_text($fieldname.'_ckeditor_ok')) { // CKEditor was loaded successfully
$html=qa_post_text($fieldname); $html=qa_post_text($fieldname);
$htmlformatting=preg_replace('/<\s*\/?\s*(br|p)\s*\/?\s*>/i', '', $html); // remove <p>, <br>, etc... since those are OK in text $htmlformatting=preg_replace('/<\s*\/?\s*(br|p)\s*\/?\s*>/i', '', $html); // remove <p>, <br>, etc... since those are OK in text
if (preg_match('/<.+>/', $htmlformatting)) // if still some other tags, it's worth keeping in HTML if (preg_match('/<.+>/', $htmlformatting)) // if still some other tags, it's worth keeping in HTML
return array( return array(
'format' => 'html', 'format' => 'html',
'content' => qa_sanitize_html($html, false, true), // qa_sanitize_html() is ESSENTIAL for security 'content' => qa_sanitize_html($html, false, true), // qa_sanitize_html() is ESSENTIAL for security
); );
else { // convert to text else { // convert to text
$viewer=qa_load_module('viewer', ''); $viewer=qa_load_module('viewer', '');
...@@ -222,16 +222,16 @@ ...@@ -222,16 +222,16 @@
'content' => qa_post_text($fieldname), 'content' => qa_post_text($fieldname),
); );
} }
function html_to_text($html) function html_to_text($html)
{ {
$viewer=qa_load_module('viewer', ''); $viewer=qa_load_module('viewer', '');
return $viewer->get_text($html, 'html', array()); return $viewer->get_text($html, 'html', array());
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/wysiwyg-editor/qa-wysiwyg-upload.php File: qa-plugin/wysiwyg-editor/qa-wysiwyg-upload.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Page module class for WYSIWYG editor (CKEditor) file upload receiver Description: Page module class for WYSIWYG editor (CKEditor) file upload receiver
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,41 +26,41 @@ ...@@ -26,41 +26,41 @@
class qa_wysiwyg_upload { class qa_wysiwyg_upload {
function match_request($request) function match_request($request)
{ {
return ($request=='wysiwyg-editor-upload'); return ($request=='wysiwyg-editor-upload');
} }
function process_request($request) function process_request($request)
{ {
$message=''; $message='';
$url=''; $url='';
if (is_array($_FILES) && count($_FILES)) { if (is_array($_FILES) && count($_FILES)) {
if (!qa_opt('wysiwyg_editor_upload_images')) if (!qa_opt('wysiwyg_editor_upload_images'))
$message=qa_lang('users/no_permission'); $message=qa_lang('users/no_permission');
require_once QA_INCLUDE_DIR.'qa-app-upload.php'; require_once QA_INCLUDE_DIR.'qa-app-upload.php';
$upload=qa_upload_file_one( $upload=qa_upload_file_one(
qa_opt('wysiwyg_editor_upload_max_size'), qa_opt('wysiwyg_editor_upload_max_size'),
qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all'), qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all'),
qa_get('qa_only_image') ? 600 : null, // max width if it's an image upload qa_get('qa_only_image') ? 600 : null, // max width if it's an image upload
null // no max height null // no max height
); );
$message=@$upload['error']; $message=@$upload['error'];
$url=@$upload['bloburl']; $url=@$upload['bloburl'];
} }
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(".qa_js(qa_get('CKEditorFuncNum')). echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(".qa_js(qa_get('CKEditorFuncNum')).
", ".qa_js($url).", ".qa_js($message).");</script>"; ", ".qa_js($url).", ".qa_js($message).");</script>";
return null; return null;
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/xml-sitemap/qa-plugin.php File: qa-plugin/xml-sitemap/qa-plugin.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Initiates XML sitemap plugin Description: Initiates XML sitemap plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* /*
Plugin Name: XML Sitemap Plugin Name: XML Sitemap
Plugin URI: Plugin URI:
Plugin Description: Generates sitemap.xml file for submission to search engines Plugin Description: Generates sitemap.xml file for submission to search engines
Plugin Version: 1.1.1 Plugin Version: 1.1.1
Plugin Date: 2011-12-06 Plugin Date: 2011-12-06
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Plugin Author URI: http://www.question2answer.org/ Plugin Author URI: http://www.question2answer.org/
Plugin License: GPLv2 Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.5 Plugin Minimum Question2Answer Version: 1.5
Plugin Update Check URI: Plugin Update Check URI:
*/ */
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
qa_register_plugin_module('page', 'qa-xml-sitemap.php', 'qa_xml_sitemap', 'XML Sitemap'); qa_register_plugin_module('page', 'qa-xml-sitemap.php', 'qa_xml_sitemap', 'XML Sitemap');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-plugin/xml-sitemap/qa-xml-sitemap.php File: qa-plugin/xml-sitemap/qa-xml-sitemap.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Page module class for XML sitemap plugin Description: Page module class for XML sitemap plugin
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -25,17 +25,17 @@ ...@@ -25,17 +25,17 @@
*/ */
class qa_xml_sitemap { class qa_xml_sitemap {
var $directory; var $directory;
var $urltoroot; var $urltoroot;
function load_module($directory, $urltoroot) function load_module($directory, $urltoroot)
{ {
$this->directory=$directory; $this->directory=$directory;
$this->urltoroot=$urltoroot; $this->urltoroot=$urltoroot;
} }
function option_default($option) function option_default($option)
{ {
switch ($option) { switch ($option) {
...@@ -48,31 +48,31 @@ ...@@ -48,31 +48,31 @@
break; break;
} }
} }
function admin_form() function admin_form()
{ {
require_once QA_INCLUDE_DIR.'qa-util-sort.php'; require_once QA_INCLUDE_DIR.'qa-util-sort.php';
$saved=false; $saved=false;
if (qa_clicked('xml_sitemap_save_button')) { if (qa_clicked('xml_sitemap_save_button')) {
qa_opt('xml_sitemap_show_questions', (int)qa_post_text('xml_sitemap_show_questions_field')); qa_opt('xml_sitemap_show_questions', (int)qa_post_text('xml_sitemap_show_questions_field'));
if (!QA_FINAL_EXTERNAL_USERS) if (!QA_FINAL_EXTERNAL_USERS)
qa_opt('xml_sitemap_show_users', (int)qa_post_text('xml_sitemap_show_users_field')); qa_opt('xml_sitemap_show_users', (int)qa_post_text('xml_sitemap_show_users_field'));
if (qa_using_tags()) if (qa_using_tags())
qa_opt('xml_sitemap_show_tag_qs', (int)qa_post_text('xml_sitemap_show_tag_qs_field')); qa_opt('xml_sitemap_show_tag_qs', (int)qa_post_text('xml_sitemap_show_tag_qs_field'));
if (qa_using_categories()) { if (qa_using_categories()) {
qa_opt('xml_sitemap_show_category_qs', (int)qa_post_text('xml_sitemap_show_category_qs_field')); qa_opt('xml_sitemap_show_category_qs', (int)qa_post_text('xml_sitemap_show_category_qs_field'));
qa_opt('xml_sitemap_show_categories', (int)qa_post_text('xml_sitemap_show_categories_field')); qa_opt('xml_sitemap_show_categories', (int)qa_post_text('xml_sitemap_show_categories_field'));
} }
$saved=true; $saved=true;
} }
$form=array( $form=array(
'ok' => $saved ? 'XML sitemap settings saved' : null, 'ok' => $saved ? 'XML sitemap settings saved' : null,
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
'tags' => 'name="xml_sitemap_show_questions_field"', 'tags' => 'name="xml_sitemap_show_questions_field"',
), ),
), ),
'buttons' => array( 'buttons' => array(
array( array(
'label' => 'Save Changes', 'label' => 'Save Changes',
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
), ),
), ),
); );
if (!QA_FINAL_EXTERNAL_USERS) if (!QA_FINAL_EXTERNAL_USERS)
$form['fields']['users']=array( $form['fields']['users']=array(
'label' => 'Include user pages', 'label' => 'Include user pages',
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
'value' => (int)qa_opt('xml_sitemap_show_users'), 'value' => (int)qa_opt('xml_sitemap_show_users'),
'tags' => 'name="xml_sitemap_show_users_field"', 'tags' => 'name="xml_sitemap_show_users_field"',
); );
if (qa_using_tags()) if (qa_using_tags())
$form['fields']['tagqs']=array( $form['fields']['tagqs']=array(
'label' => 'Include question list for each tag', 'label' => 'Include question list for each tag',
...@@ -128,9 +128,9 @@ ...@@ -128,9 +128,9 @@
return $form; return $form;
} }
function suggest_requests() function suggest_requests()
{ {
return array( return array(
array( array(
'title' => 'XML Sitemap', 'title' => 'XML Sitemap',
...@@ -140,43 +140,43 @@ ...@@ -140,43 +140,43 @@
); );
} }
function match_request($request) function match_request($request)
{ {
return ($request=='sitemap.xml'); return ($request=='sitemap.xml');
} }
function process_request($request) function process_request($request)
{ {
@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML @ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
$siteurl=qa_opt('site_url'); $siteurl=qa_opt('site_url');
header('Content-type: text/xml; charset=utf-8'); header('Content-type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n"; echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
// Question pages // Question pages
if (qa_opt('xml_sitemap_show_questions')) { if (qa_opt('xml_sitemap_show_questions')) {
$hotstats=qa_db_read_one_assoc(qa_db_query_sub( $hotstats=qa_db_read_one_assoc(qa_db_query_sub(
"SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'" "SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"
)); ));
$nextpostid=0; $nextpostid=0;
while (1) { while (1) {
$questions=qa_db_read_all_assoc(qa_db_query_sub( $questions=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100", "SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100",
$nextpostid $nextpostid
)); ));
if (!count($questions)) if (!count($questions))
break; break;
foreach ($questions as $question) { foreach ($questions as $question) {
$this->sitemap_output(qa_q_request($question['postid'], $question['title']), $this->sitemap_output(qa_q_request($question['postid'], $question['title']),
0.1+0.9*($question['hotness']-$hotstats['base'])/(1+$hotstats['spread'])); 0.1+0.9*($question['hotness']-$hotstats['base'])/(1+$hotstats['spread']));
...@@ -184,106 +184,106 @@ ...@@ -184,106 +184,106 @@
} }
} }
} }
// User pages // User pages
if ((!QA_FINAL_EXTERNAL_USERS) && qa_opt('xml_sitemap_show_users')) { if ((!QA_FINAL_EXTERNAL_USERS) && qa_opt('xml_sitemap_show_users')) {
$nextuserid=0; $nextuserid=0;
while (1) { while (1) {
$users=qa_db_read_all_assoc(qa_db_query_sub( $users=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100", "SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100",
$nextuserid $nextuserid
)); ));
if (!count($users)) if (!count($users))
break; break;
foreach ($users as $user) { foreach ($users as $user) {
$this->sitemap_output('user/'.$user['handle'], 0.25); $this->sitemap_output('user/'.$user['handle'], 0.25);
$nextuserid=max($nextuserid, $user['userid']+1); $nextuserid=max($nextuserid, $user['userid']+1);
} }
} }
} }
// Tag pages // Tag pages
if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) { if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) {
$nextwordid=0; $nextwordid=0;
while (1) { while (1) {
$tagwords=qa_db_read_all_assoc(qa_db_query_sub( $tagwords=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100", "SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100",
$nextwordid $nextwordid
)); ));
if (!count($tagwords)) if (!count($tagwords))
break; break;
foreach ($tagwords as $tagword) { foreach ($tagwords as $tagword) {
$this->sitemap_output('tag/'.$tagword['word'], 0.5/(1+(1/$tagword['tagcount']))); // priority between 0.25 and 0.5 depending on tag frequency $this->sitemap_output('tag/'.$tagword['word'], 0.5/(1+(1/$tagword['tagcount']))); // priority between 0.25 and 0.5 depending on tag frequency
$nextwordid=max($nextwordid, $tagword['wordid']+1); $nextwordid=max($nextwordid, $tagword['wordid']+1);
} }
} }
} }
// Question list for each category // Question list for each category
if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) { if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) {
$nextcategoryid=0; $nextcategoryid=0;
while (1) { while (1) {
$categories=qa_db_read_all_assoc(qa_db_query_sub( $categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2", "SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2",
$nextcategoryid $nextcategoryid
)); ));
if (!count($categories)) if (!count($categories))
break; break;
foreach ($categories as $category) { foreach ($categories as $category) {
$this->sitemap_output('questions/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5); $this->sitemap_output('questions/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1); $nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
} }
} }
} }
// Pages in category browser // Pages in category browser
if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) { if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) {
$this->sitemap_output('categories', 0.5); $this->sitemap_output('categories', 0.5);
$nextcategoryid=0; $nextcategoryid=0;
while (1) { // only find categories with a child while (1) { // only find categories with a child
$categories=qa_db_read_all_assoc(qa_db_query_sub( $categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT parent.categoryid, parent.backpath FROM ^categories AS parent ". "SELECT parent.categoryid, parent.backpath FROM ^categories AS parent ".
"JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100", "JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100",
$nextcategoryid $nextcategoryid
)); ));
if (!count($categories)) if (!count($categories))
break; break;
foreach ($categories as $category) { foreach ($categories as $category) {
$this->sitemap_output('categories/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5); $this->sitemap_output('categories/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1); $nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
} }
} }
} }
// Finish up... // Finish up...
echo "</urlset>\n"; echo "</urlset>\n";
return null; return null;
} }
function sitemap_output($request, $priority) function sitemap_output($request, $priority)
{ {
...@@ -292,9 +292,9 @@ ...@@ -292,9 +292,9 @@
"\t\t<priority>".max(0, min(1.0, $priority))."</priority>\n". "\t\t<priority>".max(0, min(1.0, $priority))."</priority>\n".
"\t</url>\n"; "\t</url>\n";
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-theme/Candy/qa-styles.css File: qa-theme/Candy/qa-styles.css
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: CSS file for included Candy theme Description: CSS file for included Candy theme
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
*/ */
/* /*
Theme URI: Theme URI:
Theme Version: 1.5 Theme Version: 1.5
Theme Date: 2012-09-11 Theme Date: 2012-09-11
Theme Author: Question2Answer Theme Author: Question2Answer
Theme Author URI: http://www.question2answer.org/ Theme Author URI: http://www.question2answer.org/
Theme License: GPLv2 Theme License: GPLv2
Theme Update Check URI: Theme Update Check URI:
*/ */
...@@ -267,7 +267,7 @@ h2 {font-size:22px; color:#c659ab; padding-top:12px; clear:both;} ...@@ -267,7 +267,7 @@ h2 {font-size:22px; color:#c659ab; padding-top:12px; clear:both;}
.qa-vote-down-button {background-position:-27px 0; color:#f1c96b;} .qa-vote-down-button {background-position:-27px 0; color:#f1c96b;}
.qa-vote-down-disabled {background-position:-27px -116px; color:#CCC;} .qa-vote-down-disabled {background-position:-27px -116px; color:#CCC;}
.qa-vote-down-button:hover {background-position:-27px -29px; color:#f1c96b;} .qa-vote-down-button:hover {background-position:-27px -29px; color:#f1c96b;}
.qa-voted-up-button {background:url(vote-buttons.png); border:0; color:#f1c96b; font-size:1px; height:29px; width:27px;} .qa-voted-up-button {background:url(vote-buttons.png); border:0; color:#f1c96b; font-size:1px; height:29px; width:27px;}
.qa-voted-up-button {background-position:0 -87px; color:#f1c96b;} .qa-voted-up-button {background-position:0 -87px; color:#f1c96b;}
.qa-voted-up-button:hover {background-position:0 -29px; color:#f1c96b;} .qa-voted-up-button:hover {background-position:0 -29px; color:#f1c96b;}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-theme/Candy/qa-theme.php File: qa-theme/Candy/qa-theme.php
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: Override something in base theme class for Candy theme Description: Override something in base theme class for Candy theme
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
$this->nav('user'); $this->nav('user');
} }
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
http://www.question2answer.org/ http://www.question2answer.org/
File: qa-theme/Classic/qa-styles.css File: qa-theme/Classic/qa-styles.css
Version: See define()s at top of qa-include/qa-base.php Version: See define()s at top of qa-include/qa-base.php
Description: CSS file for included Classic theme Description: CSS file for included Classic theme
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
*/ */
/* /*
Theme URI: Theme URI:
Theme Version: 1.5 Theme Version: 1.5
Theme Date: 2012-09-11 Theme Date: 2012-09-11
Theme Author: Question2Answer Theme Author: Question2Answer
Theme Author URI: http://www.question2answer.org/ Theme Author URI: http://www.question2answer.org/
Theme License: GPLv2 Theme License: GPLv2
Theme Update Check URI: Theme Update Check URI:
*/ */
...@@ -248,7 +248,7 @@ h2 {font-size:16px; padding-top:12px; clear:both;} ...@@ -248,7 +248,7 @@ h2 {font-size:16px; padding-top:12px; clear:both;}
.qa-vote-down-button {background-position:-17px 0; color:#38544e;} .qa-vote-down-button {background-position:-17px 0; color:#38544e;}
.qa-vote-down-disabled {background-position:-17px -60px; color:#38544e;} .qa-vote-down-disabled {background-position:-17px -60px; color:#38544e;}
.qa-vote-down-button:hover {background-position:-17px -15px; color:#65968e;} .qa-vote-down-button:hover {background-position:-17px -15px; color:#65968e;}
.qa-voted-up-button {background:url(vote-buttons.gif) no-repeat; border:0; font-size:1px; height:15px; width:17px;} .qa-voted-up-button {background:url(vote-buttons.gif) no-repeat; border:0; font-size:1px; height:15px; width:17px;}
.qa-voted-up-button {background-position:0 -30px; color:#f3cb7f;} .qa-voted-up-button {background-position:0 -30px; color:#f3cb7f;}
.qa-voted-up-button:hover {background-position:0 -45px; color:#f3cb7f;} .qa-voted-up-button:hover {background-position:0 -45px; color:#f3cb7f;}
......
/* /*
Theme Name: Snow Theme Name: Snow
Theme URI: Theme URI:
Theme Version: 1.3 Theme Version: 1.3
Theme Date: 2013-11-13 Theme Date: 2013-11-13
Theme Author: Q2A Market Theme Author: Q2A Market
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Theme License: GPLv2 Theme License: GPLv2
*/ */
/*---[ Start: global css ]---*/ /*---[ Start: global css ]---*/
.clearfix:after, .clearfix:after,
#qa-login-group:after, #qa-login-group:after,
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
.qa-nav-main-list, .qa-nav-main-list,
.qa-nav-sub-list, .qa-nav-sub-list,
.qa-nav-cat-item { display: block; } .qa-nav-cat-item { display: block; }
/* End hide from IE-mac */ /* End hide from IE-mac */
:-moz-placeholder{ :-moz-placeholder{
color:#aaa !important; color:#aaa !important;
...@@ -99,7 +99,7 @@ input[type="text"],input[type="password"],textarea,select,checkbox,radio{ ...@@ -99,7 +99,7 @@ input[type="text"],input[type="password"],textarea,select,checkbox,radio{
transition:box-shadow ease-in-out 0.5s, border ease-in-out 0.5s; transition:box-shadow ease-in-out 0.5s, border ease-in-out 0.5s;
} }
input[type="text"]:focus,input[type="password"]:focus,textarea:focus{ input[type="text"]:focus,input[type="password"]:focus,textarea:focus{
box-shadow:0 2px 2px 0 rgba(0,0,0,0.3) inset; box-shadow:0 2px 2px 0 rgba(0,0,0,0.3) inset;
border:1px solid #00AAFF !important; border:1px solid #00AAFF !important;
color:#333; color:#333;
line-height: normal; line-height: normal;
...@@ -137,7 +137,7 @@ h1 { ...@@ -137,7 +137,7 @@ h1 {
line-height:1.1em; line-height:1.1em;
border-bottom:1px solid #ddd; border-bottom:1px solid #ddd;
position:relative; position:relative;
padding:14px 25px 5px 0; padding:14px 25px 5px 0;
} }
h2 { h2 {
font-size:16px; font-size:16px;
...@@ -150,7 +150,7 @@ h2 { ...@@ -150,7 +150,7 @@ h2 {
border-radius: 3px; border-radius: 3px;
box-shadow: 0 -25px 25px -25px rgba(255,255,255,1) inset; box-shadow: 0 -25px 25px -25px rgba(255,255,255,1) inset;
border:1px solid #ddd; border:1px solid #ddd;
text-shadow:1px 1px 0 rgba(255,255,255,1); text-shadow:1px 1px 0 rgba(255,255,255,1);
} }
h3{ h3{
margin:0 0 10px 0; margin:0 0 10px 0;
...@@ -214,7 +214,7 @@ p { ...@@ -214,7 +214,7 @@ p {
background: -o-linear-gradient(top, #1ca0cc 0%,#0099cc 100%); /* Opera 11.10+ */ background: -o-linear-gradient(top, #1ca0cc 0%,#0099cc 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #1ca0cc 0%,#0099cc 100%); /* IE10+ */ background: -ms-linear-gradient(top, #1ca0cc 0%,#0099cc 100%); /* IE10+ */
background: linear-gradient(to bottom, #1ca0cc 0%,#0099cc 100%); /* W3C */ 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 ]---*/ /*---[ Begin: login bar css ]---*/
#qa-login-bar{ #qa-login-bar{
...@@ -495,7 +495,7 @@ div.header-banner{ ...@@ -495,7 +495,7 @@ div.header-banner{
-webkit-transition:all ease-in-out 0.5s; -webkit-transition:all ease-in-out 0.5s;
-o-transition:all ease-in-out 0.5s; -o-transition:all ease-in-out 0.5s;
-ms-transition:all ease-in-out 0.5s; -ms-transition:all ease-in-out 0.5s;
transition:all ease-in-out 0.5s; transition:all ease-in-out 0.5s;
} }
.qa-nav-main-link:hover,.qa-nav-main-selected { .qa-nav-main-link:hover,.qa-nav-main-selected {
text-decoration:none; text-decoration:none;
...@@ -504,7 +504,7 @@ div.header-banner{ ...@@ -504,7 +504,7 @@ div.header-banner{
-webkit-transition:all ease-in-out 0.2s; -webkit-transition:all ease-in-out 0.2s;
-o-transition:all ease-in-out 0.2s; -o-transition:all ease-in-out 0.2s;
-ms-transition:all ease-in-out 0.2s; -ms-transition:all ease-in-out 0.2s;
transition:all ease-in-out 0.2s; transition:all ease-in-out 0.2s;
} }
.qa-nav-main-custom-1 .qa-nav-main-link{ .qa-nav-main-custom-1 .qa-nav-main-link{
border-left:none; border-left:none;
...@@ -549,7 +549,7 @@ div.header-banner{ ...@@ -549,7 +549,7 @@ div.header-banner{
-webkit-transition:all ease-in-out 0.5s; -webkit-transition:all ease-in-out 0.5s;
-o-transition:all ease-in-out 0.5s; -o-transition:all ease-in-out 0.5s;
-ms-transition:all ease-in-out 0.5s; -ms-transition:all ease-in-out 0.5s;
transition:all ease-in-out 0.5s; transition:all ease-in-out 0.5s;
} }
.qa-nav-sub-link:hover,.qa-nav-sub-selected { .qa-nav-sub-link:hover,.qa-nav-sub-selected {
color:#000 !important; color:#000 !important;
...@@ -561,7 +561,7 @@ div.header-banner{ ...@@ -561,7 +561,7 @@ div.header-banner{
-webkit-transition:all ease-in-out 0.2s; -webkit-transition:all ease-in-out 0.2s;
-o-transition:all ease-in-out 0.2s; -o-transition:all ease-in-out 0.2s;
-ms-transition:all ease-in-out 0.2s; -ms-transition:all ease-in-out 0.2s;
transition:all ease-in-out 0.2s; transition:all ease-in-out 0.2s;
} }
.qa-nav-sub-hot .qa-nav-sub-link{ .qa-nav-sub-hot .qa-nav-sub-link{
color:#af0000 !important; color:#af0000 !important;
...@@ -789,7 +789,7 @@ div.header-banner{ ...@@ -789,7 +789,7 @@ div.header-banner{
height:60px; height:60px;
text-align:center; text-align:center;
margin-right:5px; margin-right:5px;
padding:0; padding:0;
border-radius: 3px; border-radius: 3px;
} }
.qa-a-count-zero{ .qa-a-count-zero{
...@@ -897,7 +897,7 @@ div.header-banner{ ...@@ -897,7 +897,7 @@ div.header-banner{
} }
.qa-error a{ .qa-error a{
color:#fff; color:#fff;
font-weight:bold; font-weight:bold;
} }
.qa-error a:hover{ .qa-error a:hover{
text-decoration:underline; text-decoration:underline;
...@@ -928,7 +928,7 @@ div.header-banner{ ...@@ -928,7 +928,7 @@ div.header-banner{
padding-left:20px; padding-left:20px;
} }
.qa-footer-bottom-group{ .qa-footer-bottom-group{
background:#ddd; background:#ddd;
border-top:1px solid #aaa; border-top:1px solid #aaa;
} }
.qa-footer { .qa-footer {
...@@ -942,7 +942,7 @@ div.header-banner{ ...@@ -942,7 +942,7 @@ div.header-banner{
.qa-footer a, .qa-footer a:visited{ .qa-footer a, .qa-footer a:visited{
text-decoration:underline; text-decoration:underline;
} }
/* IE6 /* IE6
Widget wrappers */ Widget wrappers */
.qa-widget-full { .qa-widget-full {
clear:both; clear:both;
...@@ -1887,7 +1887,7 @@ margin:2px 0; ...@@ -1887,7 +1887,7 @@ margin:2px 0;
.qa-c-item-content { .qa-c-item-content {
display:block; display:block;
margin-bottom:6px; margin-bottom:6px;
font-size:12px; font-size:12px;
} }
.qa-c-item-footer { .qa-c-item-footer {
position:relative; position:relative;
...@@ -2092,14 +2092,14 @@ padding:10px; ...@@ -2092,14 +2092,14 @@ padding:10px;
font-size:0; font-size:0;
margin:0px 8px 0px 4px; margin:0px 8px 0px 4px;
vertical-align:middle; vertical-align:middle;
} }
.qa-favoriting .qa-waiting{ .qa-favoriting .qa-waiting{
position:absolute; position:absolute;
padding:0; padding:0;
left:50%; left:50%;
top:50%; top:50%;
margin:-7px 0 0 -7px; margin:-7px 0 0 -7px;
} }
.qa-a-selection .qa-waiting { .qa-a-selection .qa-waiting {
position:absolute; position:absolute;
padding:0; padding:0;
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
class qa_html_theme extends qa_html_theme_base class qa_html_theme extends qa_html_theme_base
{ {
function head_script() // change style of WYSIWYG editor to match theme better function head_script() // change style of WYSIWYG editor to match theme better
{ {
qa_html_theme_base::head_script(); qa_html_theme_base::head_script();
$this->output( $this->output(
'<script type="text/javascript">', '<script type="text/javascript">',
"if (typeof qa_wysiwyg_editor_config == 'object')", "if (typeof qa_wysiwyg_editor_config == 'object')",
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
'</script>' '</script>'
); );
} }
function nav_user_search() // outputs login form if user not logged in function nav_user_search() // outputs login form if user not logged in
{ {
if (!qa_is_logged_in()) { if (!qa_is_logged_in()) {
$login=@$this->content['navigation']['user']['login']; $login=@$this->content['navigation']['user']['login'];
if (isset($login) && !QA_FINAL_EXTERNAL_USERS) { if (isset($login) && !QA_FINAL_EXTERNAL_USERS) {
$this->output( $this->output(
'<!--[Begin: login form]-->', '<!--[Begin: login form]-->',
'<form id="qa-loginform" action="'.$login['url'].'" method="post">', '<form id="qa-loginform" action="'.$login['url'].'" method="post">',
'<input type="text" id="qa-userid" name="emailhandle" placeholder="'.trim(qa_lang_html(qa_opt('allow_login_email_only') ? 'users/email_label' : 'users/email_handle_label'), ':').'" />', '<input type="text" id="qa-userid" name="emailhandle" placeholder="'.trim(qa_lang_html(qa_opt('allow_login_email_only') ? 'users/email_label' : 'users/email_handle_label'), ':').'" />',
'<input type="password" id="qa-password" name="password" placeholder="'.trim(qa_lang_html('users/password_label'), ':').'" />', '<input type="password" id="qa-password" name="password" placeholder="'.trim(qa_lang_html('users/password_label'), ':').'" />',
...@@ -31,18 +31,18 @@ ...@@ -31,18 +31,18 @@
'<label for="qa-rememberme" id="qa-remember">'.qa_lang_html('users/remember').'</label></div>', '<label for="qa-rememberme" id="qa-remember">'.qa_lang_html('users/remember').'</label></div>',
'<input type="hidden" name="code" value="'.qa_html(qa_get_form_security_code('login')).'"/>', '<input type="hidden" name="code" value="'.qa_html(qa_get_form_security_code('login')).'"/>',
'<input type="submit" value="'.$login['label'].'" id="qa-login" name="dologin" />', '<input type="submit" value="'.$login['label'].'" id="qa-login" name="dologin" />',
'</form>', '</form>',
'<!--[End: login form]-->' '<!--[End: login form]-->'
); );
unset($this->content['navigation']['user']['login']); // removes regular navigation link to log in page unset($this->content['navigation']['user']['login']); // removes regular navigation link to log in page
} }
} }
qa_html_theme_base::nav_user_search(); qa_html_theme_base::nav_user_search();
} }
function logged_in() function logged_in()
{ {
if (qa_is_logged_in()) // output user avatar to login bar if (qa_is_logged_in()) // output user avatar to login bar
$this->output( $this->output(
...@@ -53,17 +53,17 @@ ...@@ -53,17 +53,17 @@
qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarheight'), qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarheight'),
24, true), 24, true),
'</div>' '</div>'
); );
qa_html_theme_base::logged_in(); qa_html_theme_base::logged_in();
if (qa_is_logged_in()) { // adds points count after logged in username if (qa_is_logged_in()) { // adds points count after logged in username
$userpoints=qa_get_logged_in_points(); $userpoints=qa_get_logged_in_points();
$pointshtml=($userpoints==1) $pointshtml=($userpoints==1)
? qa_lang_html_sub('main/1_point', '1', '1') ? qa_lang_html_sub('main/1_point', '1', '1')
: qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints)));
$this->output( $this->output(
'<span class="qa-logged-in-points">', '<span class="qa-logged-in-points">',
'('.$pointshtml.')', '('.$pointshtml.')',
...@@ -71,14 +71,14 @@ ...@@ -71,14 +71,14 @@
); );
} }
} }
function body_header() // adds login bar, user navigation and search at top of page in place of custom header content function body_header() // adds login bar, user navigation and search at top of page in place of custom header content
{ {
$this->output('<div id="qa-login-bar"><div id="qa-login-group">'); $this->output('<div id="qa-login-bar"><div id="qa-login-group">');
$this->nav_user_search(); $this->nav_user_search();
$this->output('</div></div>'); $this->output('</div></div>');
} }
function header_custom() // allows modification of custom element shown inside header after logo function header_custom() // allows modification of custom element shown inside header after logo
{ {
if (isset($this->content['body_header'])) { if (isset($this->content['body_header'])) {
...@@ -87,12 +87,12 @@ ...@@ -87,12 +87,12 @@
$this->output('</div>'); $this->output('</div>');
} }
} }
function header() // removes user navigation and search from header and replaces with custom header content. Also opens new <div>s function header() // removes user navigation and search from header and replaces with custom header content. Also opens new <div>s
{ {
$this->output('<div class="qa-header">'); $this->output('<div class="qa-header">');
$this->logo(); $this->logo();
$this->header_clear(); $this->header_clear();
$this->header_custom(); $this->header_custom();
...@@ -103,53 +103,53 @@ ...@@ -103,53 +103,53 @@
$this->nav_main_sub(); $this->nav_main_sub();
} }
function sidepanel() // removes sidebar for user profile pages function sidepanel() // removes sidebar for user profile pages
{ {
if ($this->template!='user') if ($this->template!='user')
qa_html_theme_base::sidepanel(); qa_html_theme_base::sidepanel();
} }
function footer() // prevent display of regular footer content (see body_suffix()) and replace with closing new <div>s function footer() // prevent display of regular footer content (see body_suffix()) and replace with closing new <div>s
{ {
$this->output('</div> <!-- END main-wrapper -->'); $this->output('</div> <!-- END main-wrapper -->');
$this->output('</div> <!-- END main-shadow -->'); $this->output('</div> <!-- END main-shadow -->');
} }
function title() // add RSS feed icon after the page title function title() // add RSS feed icon after the page title
{ {
qa_html_theme_base::title(); qa_html_theme_base::title();
$feed=@$this->content['feed']; $feed=@$this->content['feed'];
if (!empty($feed)) if (!empty($feed))
$this->output('<a href="'.$feed['url'].'" title="'.@$feed['label'].'"><img src="'.$this->rooturl.'images/rss.jpg" alt="" width="16" height="16" border="0" class="qa-rss-icon"/></a>'); $this->output('<a href="'.$feed['url'].'" title="'.@$feed['label'].'"><img src="'.$this->rooturl.'images/rss.jpg" alt="" width="16" height="16" border="0" class="qa-rss-icon"/></a>');
} }
function q_item_stats($q_item) // add view count to question list function q_item_stats($q_item) // add view count to question list
{ {
$this->output('<div class="qa-q-item-stats">'); $this->output('<div class="qa-q-item-stats">');
$this->voting($q_item); $this->voting($q_item);
$this->a_count($q_item); $this->a_count($q_item);
qa_html_theme_base::view_count($q_item); qa_html_theme_base::view_count($q_item);
$this->output('</div>'); $this->output('</div>');
} }
function view_count($q_item) // prevent display of view count in the usual place function view_count($q_item) // prevent display of view count in the usual place
{ {
if ($this->template=='question') if ($this->template=='question')
qa_html_theme_base::view_count($q_item); qa_html_theme_base::view_count($q_item);
} }
function body_suffix() // to replace standard Q2A footer function body_suffix() // to replace standard Q2A footer
{ {
$this->output('<div class="qa-footer-bottom-group">'); $this->output('<div class="qa-footer-bottom-group">');
qa_html_theme_base::footer(); qa_html_theme_base::footer();
$this->output('</div> <!-- END footer-bottom-group -->', ''); $this->output('</div> <!-- END footer-bottom-group -->', '');
} }
function attribution() function attribution()
{ {
$this->output( $this->output(
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
qa_html_theme_base::attribution(); qa_html_theme_base::attribution();
} }
} }
......
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