Commit a43f19ad by Scott

Refactor plugin classes for PHP 5

parent b2da9e7e
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
'activity', 'categories', 'custom', 'feedback', 'qa', 'questions', 'activity', 'categories', 'custom', 'feedback', 'qa', 'questions',
'hot', 'search', 'tag', 'tags', 'unanswered' 'hot', 'search', 'tag', 'tags', 'unanswered'
); );
return in_array($template, $allowed); return in_array($template, $allowed);
} }
......
...@@ -26,19 +26,19 @@ ...@@ -26,19 +26,19 @@
class qa_basic_adsense { class qa_basic_adsense {
function allow_template($template) public function allow_template($template)
{ {
return ($template!='admin'); return ($template!='admin');
} }
function allow_region($region) public function allow_region($region)
{ {
return in_array($region, array('main', 'side', 'full')); return in_array($region, array('main', 'side', 'full'));
} }
function admin_form(&$qa_content) public function admin_form(&$qa_content)
{ {
$saved=false; $saved=false;
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
} }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{ {
$divstyle=''; $divstyle='';
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
class qa_event_logger { class qa_event_logger {
function init_queries($tableslc) public 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');
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
} }
function admin_form(&$qa_content) public function admin_form(&$qa_content)
{ {
// Process form input // Process form input
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
} }
function value_to_text($value) public function value_to_text($value)
{ {
if (is_array($value)) if (is_array($value))
$text='array('.count($value).')'; $text='array('.count($value).')';
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
} }
function process_event($event, $userid, $handle, $cookieid, $params) public function process_event($event, $userid, $handle, $cookieid, $params)
{ {
if (qa_opt('event_logger_to_database')) { if (qa_opt('event_logger_to_database')) {
$paramstring=''; $paramstring='';
......
...@@ -26,18 +26,18 @@ ...@@ -26,18 +26,18 @@
class qa_example_page { class qa_example_page {
var $directory; private $directory;
var $urltoroot; private $urltoroot;
function load_module($directory, $urltoroot) public function load_module($directory, $urltoroot)
{ {
$this->directory=$directory; $this->directory=$directory;
$this->urltoroot=$urltoroot; $this->urltoroot=$urltoroot;
} }
function suggest_requests() // for display in admin interface public function suggest_requests() // for display in admin interface
{ {
return array( return array(
array( array(
...@@ -49,16 +49,13 @@ ...@@ -49,16 +49,13 @@
} }
function match_request($request) public function match_request($request)
{ {
if ($request=='example-plugin-page') return $request == 'example-plugin-page';
return true;
return false;
} }
function process_request($request) public function process_request($request)
{ {
$qa_content=qa_content_prepare(); $qa_content=qa_content_prepare();
......
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
class qa_html_theme_layer extends qa_html_theme_base { class qa_html_theme_layer extends qa_html_theme_base {
function head_css() public 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>',
'.fb-login-button.fb_iframe_widget.fb_hide_iframes span {display:none;}', '.fb-login-button.fb_iframe_widget.fb_hide_iframes span {display:none;}',
'--></style>' '</style>'
); );
} }
......
...@@ -26,21 +26,21 @@ ...@@ -26,21 +26,21 @@
class qa_facebook_login_page { class qa_facebook_login_page {
var $directory; private $directory;
var $urltoroot; private $urltoroot;
function load_module($directory, $urltoroot) public function load_module($directory, $urltoroot)
{ {
$this->directory=$directory; $this->directory=$directory;
$this->urltoroot=$urltoroot; $this->urltoroot=$urltoroot;
} }
function match_request($request) public function match_request($request)
{ {
return ($request=='facebook-login'); return ($request=='facebook-login');
} }
function process_request($request) public function process_request($request)
{ {
if ($request=='facebook-login') { if ($request=='facebook-login') {
$app_id=qa_opt('facebook_app_id'); $app_id=qa_opt('facebook_app_id');
......
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
class qa_facebook_login { class qa_facebook_login {
function match_source($source) public function match_source($source)
{ {
return $source=='facebook'; return $source=='facebook';
} }
function login_html($tourl, $context) public function login_html($tourl, $context)
{ {
$app_id=qa_opt('facebook_app_id'); $app_id=qa_opt('facebook_app_id');
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
} }
function logout_html($tourl) public function logout_html($tourl)
{ {
$app_id=qa_opt('facebook_app_id'); $app_id=qa_opt('facebook_app_id');
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
} }
function facebook_html($tourl, $logout, $context) public function facebook_html($tourl, $logout, $context)
{ {
if (($context=='login') || ($context=='register')) if (($context=='login') || ($context=='register'))
$size='large'; $size='large';
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
} }
function admin_form() public function admin_form()
{ {
$saved=false; $saved=false;
......
...@@ -26,14 +26,14 @@ ...@@ -26,14 +26,14 @@
class qa_mouseover_admin_form { class qa_mouseover_admin_form {
function option_default($option) public 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) public function admin_form(&$qa_content)
{ {
$saved=false; $saved=false;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
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) public 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
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
class qa_html_theme_layer extends qa_html_theme_base { class qa_html_theme_layer extends qa_html_theme_base {
function head_links() public function head_links()
{ {
qa_html_theme_base::head_links(); qa_html_theme_base::head_links();
......
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
class qa_opensearch_xml { class qa_opensearch_xml {
function match_request($request) public function match_request($request)
{ {
return ($request=='opensearch.xml'); return ($request=='opensearch.xml');
} }
function process_request($request) public 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
......
...@@ -32,15 +32,15 @@ ...@@ -32,15 +32,15 @@
class qa_recaptcha_captcha { class qa_recaptcha_captcha {
var $directory; private $directory;
function load_module($directory, $urltoroot) public function load_module($directory, $urltoroot)
{ {
$this->directory=$directory; $this->directory=$directory;
} }
function admin_form() public function admin_form()
{ {
$saved=false; $saved=false;
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
} }
function recaptcha_error_html() public 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.';
...@@ -98,13 +98,13 @@ ...@@ -98,13 +98,13 @@
} }
function allow_captcha() public 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) public function form_html(&$qa_content, $error)
{ {
require_once $this->directory.'recaptchalib.php'; require_once $this->directory.'recaptchalib.php';
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
} }
function validate_post(&$error) public function validate_post(&$error)
{ {
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';
......
...@@ -26,18 +26,18 @@ ...@@ -26,18 +26,18 @@
class qa_tag_cloud { class qa_tag_cloud {
function option_default($option) public function option_default($option)
{ {
if ($option=='tag_cloud_count_tags') if ($option=='tag_cloud_count_tags')
return 100; return 100;
elseif ($option=='tag_cloud_font_size') if ($option=='tag_cloud_font_size')
return 24; return 24;
elseif ($option=='tag_cloud_size_popular') if ($option=='tag_cloud_size_popular')
return true; return true;
} }
function admin_form() public function admin_form()
{ {
$saved=false; $saved=false;
...@@ -86,42 +86,23 @@ ...@@ -86,42 +86,23 @@
} }
function allow_template($template) public function allow_template($template)
{ {
$allow=false; $allowed = array(
'activity', 'qa', 'questions', 'hot', 'ask', 'categories', 'question',
switch ($template) 'tag', 'tags', 'unanswered', 'user', 'users', 'search', 'admin', 'custom',
{ );
case 'activity': return in_array($template, $allowed);
case 'qa':
case 'questions':
case 'hot':
case 'ask':
case 'categories':
case 'question':
case 'tag':
case 'tags':
case 'unanswered':
case 'user':
case 'users':
case 'search':
case 'admin':
case 'custom':
$allow=true;
break;
}
return $allow;
} }
function allow_region($region) public function allow_region($region)
{ {
return ($region=='side'); return ($region=='side');
} }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) public 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';
......
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
class qa_xml_sitemap { class qa_xml_sitemap {
var $directory; private $directory;
var $urltoroot; private $urltoroot;
function load_module($directory, $urltoroot) public function load_module($directory, $urltoroot)
{ {
$this->directory=$directory; $this->directory=$directory;
$this->urltoroot=$urltoroot; $this->urltoroot=$urltoroot;
} }
function option_default($option) public function option_default($option)
{ {
switch ($option) { switch ($option) {
case 'xml_sitemap_show_questions': case 'xml_sitemap_show_questions':
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
} }
function admin_form() public function admin_form()
{ {
require_once QA_INCLUDE_DIR.'qa-util-sort.php'; require_once QA_INCLUDE_DIR.'qa-util-sort.php';
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
} }
function suggest_requests() public function suggest_requests()
{ {
return array( return array(
array( array(
...@@ -141,13 +141,13 @@ ...@@ -141,13 +141,13 @@
} }
function match_request($request) public function match_request($request)
{ {
return ($request=='sitemap.xml'); return ($request=='sitemap.xml');
} }
function process_request($request) public 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
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
} }
function sitemap_output($request, $priority) private function sitemap_output($request, $priority)
{ {
echo "\t<url>\n". echo "\t<url>\n".
"\t\t<loc>".qa_xml(qa_path($request, null, qa_opt('site_url')))."</loc>\n". "\t\t<loc>".qa_xml(qa_path($request, null, qa_opt('site_url')))."</loc>\n".
......
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
class qa_html_theme extends qa_html_theme_base class qa_html_theme extends qa_html_theme_base
{
public function nav_user_search() // reverse the usual order
{ {
function nav_user_search() // reverse the usual order $this->search();
{ $this->nav('user');
$this->search();
$this->nav('user');
}
} }
}
/* /*
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class qa_html_theme extends qa_html_theme_base class qa_html_theme extends qa_html_theme_base
{ {
// outputs login form if user not logged in // outputs login form if user not logged in
function nav_user_search() public function nav_user_search()
{ {
if (!qa_is_logged_in()) { if (!qa_is_logged_in()) {
$login=@$this->content['navigation']['user']['login']; $login=@$this->content['navigation']['user']['login'];
...@@ -29,7 +29,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -29,7 +29,7 @@ class qa_html_theme extends qa_html_theme_base
qa_html_theme_base::nav_user_search(); qa_html_theme_base::nav_user_search();
} }
function logged_in() public 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(
...@@ -60,7 +60,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -60,7 +60,7 @@ class qa_html_theme extends qa_html_theme_base
} }
// adds login bar, user navigation and search at top of page in place of custom header content // adds login bar, user navigation and search at top of page in place of custom header content
function body_header() public function body_header()
{ {
$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();
...@@ -68,7 +68,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -68,7 +68,7 @@ class qa_html_theme extends qa_html_theme_base
} }
// allows modification of custom element shown inside header after logo // allows modification of custom element shown inside header after logo
function header_custom() public function header_custom()
{ {
if (isset($this->content['body_header'])) { if (isset($this->content['body_header'])) {
$this->output('<div class="header-banner">'); $this->output('<div class="header-banner">');
...@@ -78,7 +78,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -78,7 +78,7 @@ class qa_html_theme extends qa_html_theme_base
} }
// removes user navigation and search from header and replaces with custom header content. Also opens new <div>s // removes user navigation and search from header and replaces with custom header content. Also opens new <div>s
function header() public function header()
{ {
$this->output('<div class="qa-header">'); $this->output('<div class="qa-header">');
...@@ -95,21 +95,21 @@ class qa_html_theme extends qa_html_theme_base ...@@ -95,21 +95,21 @@ class qa_html_theme extends qa_html_theme_base
} }
// removes sidebar for user profile pages // removes sidebar for user profile pages
function sidepanel() public function sidepanel()
{ {
if ($this->template!='user') if ($this->template!='user')
qa_html_theme_base::sidepanel(); qa_html_theme_base::sidepanel();
} }
// prevent display of regular footer content (see body_suffix()) and replace with closing new <div>s // prevent display of regular footer content (see body_suffix()) and replace with closing new <div>s
function footer() public function footer()
{ {
$this->output('</div> <!-- END main-wrapper -->'); $this->output('</div> <!-- END main-wrapper -->');
$this->output('</div> <!-- END main-shadow -->'); $this->output('</div> <!-- END main-shadow -->');
} }
// add RSS feed icon after the page title // add RSS feed icon after the page title
function title() public function title()
{ {
qa_html_theme_base::title(); qa_html_theme_base::title();
...@@ -120,7 +120,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -120,7 +120,7 @@ class qa_html_theme extends qa_html_theme_base
} }
// add view count to question list // add view count to question list
function q_item_stats($q_item) public function q_item_stats($q_item)
{ {
$this->output('<div class="qa-q-item-stats">'); $this->output('<div class="qa-q-item-stats">');
...@@ -132,21 +132,21 @@ class qa_html_theme extends qa_html_theme_base ...@@ -132,21 +132,21 @@ class qa_html_theme extends qa_html_theme_base
} }
// prevent display of view count in the usual place // prevent display of view count in the usual place
function view_count($q_item) public function view_count($q_item)
{ {
if ($this->template=='question') if ($this->template=='question')
qa_html_theme_base::view_count($q_item); qa_html_theme_base::view_count($q_item);
} }
// to replace standard Q2A footer // to replace standard Q2A footer
function body_suffix() public function body_suffix()
{ {
$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() public function attribution()
{ {
$this->output( $this->output(
'<div class="qa-attribution">', '<div class="qa-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