Commit 4a51a213 by Scott

Coding style (core plugins)

parent 7ebb9fa6
...@@ -20,19 +20,12 @@ ...@@ -20,19 +20,12 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser class qa_editor_basic
header('Location: ../'); {
exit;
}
class qa_editor_basic {
public function load_module($localdir, $htmldir) public function load_module($localdir, $htmldir)
{ {
} }
public function calc_quality($content, $format) public function calc_quality($content, $format)
{ {
if ($format=='') if ($format=='')
...@@ -44,7 +37,6 @@ ...@@ -44,7 +37,6 @@
return 0; return 0;
} }
public function get_field(&$qa_content, $content, $format, $fieldname, $rows /* $autofocus parameter deprecated */) public function get_field(&$qa_content, $content, $format, $fieldname, $rows /* $autofocus parameter deprecated */)
{ {
return array( return array(
...@@ -60,7 +52,6 @@ ...@@ -60,7 +52,6 @@
return "document.getElementById('".$fieldname."').focus();"; return "document.getElementById('".$fieldname."').focus();";
} }
public function read_post($fieldname) public function read_post($fieldname)
{ {
return array( return array(
...@@ -68,10 +59,4 @@ ...@@ -68,10 +59,4 @@
'content' => qa_post_text($fieldname), 'content' => qa_post_text($fieldname),
); );
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,14 +20,8 @@ ...@@ -20,14 +20,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser class qa_event_limits
header('Location: ../'); {
exit;
}
class qa_event_limits {
public function process_event($event, $userid, $handle, $cookieid, $params) public function process_event($event, $userid, $handle, $cookieid, $params)
{ {
// Don't increment limits or report user actions for events that were delayed. For example, a 'q_post' // Don't increment limits or report user actions for events that were delayed. For example, a 'q_post'
...@@ -105,12 +99,5 @@ ...@@ -105,12 +99,5 @@
qa_cookie_report_action($cookieid, $event); qa_cookie_report_action($cookieid, $event);
} }
} }
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,14 +20,8 @@ ...@@ -20,14 +20,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser class qa_event_notify
header('Location: ../'); {
exit;
}
class qa_event_notify {
public function process_event($event, $userid, $handle, $cookieid, $params) public function process_event($event, $userid, $handle, $cookieid, $params)
{ {
require_once QA_INCLUDE_DIR.'app/emails.php'; require_once QA_INCLUDE_DIR.'app/emails.php';
...@@ -235,6 +229,7 @@ ...@@ -235,6 +229,7 @@
} }
break; break;
case 'u_register': case 'u_register':
if (qa_opt('register_notify_admin')) if (qa_opt('register_notify_admin'))
qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'), qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'),
...@@ -245,6 +240,7 @@ ...@@ -245,6 +240,7 @@
)); ));
break; break;
case 'u_level': case 'u_level':
if ( ($params['level']>=QA_USER_LEVEL_APPROVED) && ($params['oldlevel']<QA_USER_LEVEL_APPROVED) ) if ( ($params['level']>=QA_USER_LEVEL_APPROVED) && ($params['oldlevel']<QA_USER_LEVEL_APPROVED) )
qa_send_notification($params['userid'], null, $params['handle'], qa_lang('emails/u_approved_subject'), qa_lang('emails/u_approved_body'), array( qa_send_notification($params['userid'], null, $params['handle'], qa_lang('emails/u_approved_subject'), qa_lang('emails/u_approved_body'), array(
...@@ -252,6 +248,7 @@ ...@@ -252,6 +248,7 @@
)); ));
break; break;
case 'u_wall_post': case 'u_wall_post':
if ($userid!=$params['userid']) { if ($userid!=$params['userid']) {
$blockwordspreg=qa_get_block_words_preg(); $blockwordspreg=qa_get_block_words_preg();
...@@ -265,10 +262,4 @@ ...@@ -265,10 +262,4 @@
break; break;
} }
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,14 +20,8 @@ ...@@ -20,14 +20,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser class qa_event_updates
header('Location: ../'); {
exit;
}
class qa_event_updates {
public function process_event($event, $userid, $handle, $cookieid, $params) public function process_event($event, $userid, $handle, $cookieid, $params)
{ {
if (@$params['silent']) // don't create updates about silent edits, and possibly other silent events in future if (@$params['silent']) // don't create updates about silent edits, and possibly other silent events in future
...@@ -171,10 +165,4 @@ ...@@ -171,10 +165,4 @@
break; break;
} }
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,17 +20,11 @@ ...@@ -20,17 +20,11 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser require_once QA_INCLUDE_DIR.'db/maxima.php';
header('Location: ../'); require_once QA_INCLUDE_DIR.'qa-util-string.php';
exit;
}
require_once QA_INCLUDE_DIR.'db/maxima.php';
require_once QA_INCLUDE_DIR.'qa-util-string.php';
class qa_filter_basic {
class qa_filter_basic
{
public function filter_email(&$email, $olduser) public function filter_email(&$email, $olduser)
{ {
if (!strlen($email)) if (!strlen($email))
...@@ -43,7 +37,6 @@ ...@@ -43,7 +37,6 @@
return qa_lang_sub('main/max_length_x', QA_DB_MAX_EMAIL_LENGTH); return qa_lang_sub('main/max_length_x', QA_DB_MAX_EMAIL_LENGTH);
} }
public function filter_handle(&$handle, $olduser) public function filter_handle(&$handle, $olduser)
{ {
if (!strlen($handle)) if (!strlen($handle))
...@@ -56,7 +49,6 @@ ...@@ -56,7 +49,6 @@
return qa_lang_sub('main/max_length_x', QA_DB_MAX_HANDLE_LENGTH); return qa_lang_sub('main/max_length_x', QA_DB_MAX_HANDLE_LENGTH);
} }
public function filter_question(&$question, &$errors, $oldquestion) public function filter_question(&$question, &$errors, $oldquestion)
{ {
$this->validate_length($errors, 'title', @$question['title'], qa_opt('min_len_q_title'), $this->validate_length($errors, 'title', @$question['title'], qa_opt('min_len_q_title'),
...@@ -81,7 +73,6 @@ ...@@ -81,7 +73,6 @@
$this->validate_post_email($errors, $question); $this->validate_post_email($errors, $question);
} }
public function filter_answer(&$answer, &$errors, $question, $oldanswer) public function filter_answer(&$answer, &$errors, $question, $oldanswer)
{ {
$this->validate_length($errors, 'content', @$answer['content'], 0, QA_DB_MAX_CONTENT_LENGTH); // for storage $this->validate_length($errors, 'content', @$answer['content'], 0, QA_DB_MAX_CONTENT_LENGTH); // for storage
...@@ -89,7 +80,6 @@ ...@@ -89,7 +80,6 @@
$this->validate_post_email($errors, $answer); $this->validate_post_email($errors, $answer);
} }
public function filter_comment(&$comment, &$errors, $question, $parent, $oldcomment) public function filter_comment(&$comment, &$errors, $question, $parent, $oldcomment)
{ {
$this->validate_length($errors, 'content', @$comment['content'], 0, QA_DB_MAX_CONTENT_LENGTH); // for storage $this->validate_length($errors, 'content', @$comment['content'], 0, QA_DB_MAX_CONTENT_LENGTH); // for storage
...@@ -97,7 +87,6 @@ ...@@ -97,7 +87,6 @@
$this->validate_post_email($errors, $comment); $this->validate_post_email($errors, $comment);
} }
public function filter_profile(&$profile, &$errors, $user, $oldprofile) public function filter_profile(&$profile, &$errors, $user, $oldprofile)
{ {
foreach ($profile as $field => $value) foreach ($profile as $field => $value)
...@@ -105,12 +94,12 @@ ...@@ -105,12 +94,12 @@
} }
// The definitions below are not part of a standard filter module, but just used within this one // The definitions below are not part of a standard filter module, but just used within this one
private function validate_length(&$errors, $field, $input, $minlength, $maxlength) /**
/* * Add textual element $field to $errors if length of $input is not between $minlength and $maxlength
Add textual element $field to $errors if length of $input is not between $minlength and $maxlength
*/ */
private function validate_length(&$errors, $field, $input, $minlength, $maxlength)
{ {
$length = isset($input) ? qa_strlen($input) : 0; $length = isset($input) ? qa_strlen($input) : 0;
...@@ -120,7 +109,6 @@ ...@@ -120,7 +109,6 @@
$errors[$field] = qa_lang_sub('main/max_length_x', $maxlength); $errors[$field] = qa_lang_sub('main/max_length_x', $maxlength);
} }
private function validate_post_email(&$errors, $post) private function validate_post_email(&$errors, $post)
{ {
if (@$post['notify'] && strlen(@$post['email'])) { if (@$post['notify'] && strlen(@$post['email'])) {
...@@ -129,10 +117,4 @@ ...@@ -129,10 +117,4 @@
$errors['email']=$error; $errors['email']=$error;
} }
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
class qa_html_theme_layer extends qa_html_theme_base { class qa_html_theme_layer extends qa_html_theme_base
{
private $qa_voters_flaggers_queue=array(); private $qa_voters_flaggers_queue=array();
private $qa_voters_flaggers_cache=array(); private $qa_voters_flaggers_cache=array();
// Utility functions for this layer // Utility functions for this layer
private function queue_post_voters_flaggers($post) private function queue_post_voters_flaggers($post)
{ {
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
} }
// Collect up all required postids for the entire page to save DB queries - common case where whole page output // Collect up all required postids for the entire page to save DB queries - common case where whole page output
public function main() public function main()
{ {
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
} }
// Other functions which also collect up required postids for lists to save DB queries - helps with widget output and Ajax calls // Other functions which also collect up required postids for lists to save DB queries - helps with widget output and Ajax calls
public function q_list_items($q_items) public function q_list_items($q_items)
{ {
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
} }
// Actual output of the voters and flaggers // Actual output of the voters and flaggers
public function vote_count($post) public function vote_count($post)
{ {
...@@ -172,7 +172,6 @@ ...@@ -172,7 +172,6 @@
qa_html_theme_base::vote_count($post); qa_html_theme_base::vote_count($post);
} }
public function post_meta_flags($post, $class) public function post_meta_flags($post, $class)
{ {
$postid=@$post['raw']['opostid']; $postid=@$post['raw']['opostid'];
...@@ -198,10 +197,4 @@ ...@@ -198,10 +197,4 @@
if (strlen($tooltip)) if (strlen($tooltip))
$this->output('</span>'); $this->output('</span>');
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,14 +20,8 @@ ...@@ -20,14 +20,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser class qa_search_basic
header('Location: ../'); {
exit;
}
class qa_search_basic {
public function index_post($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid) public function index_post($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid)
{ {
require_once QA_INCLUDE_DIR.'db/post-create.php'; require_once QA_INCLUDE_DIR.'db/post-create.php';
...@@ -77,7 +71,6 @@ ...@@ -77,7 +71,6 @@
qa_db_tagcount_update(); qa_db_tagcount_update();
} }
public function unindex_post($postid) public function unindex_post($postid)
{ {
require_once QA_INCLUDE_DIR.'db/post-update.php'; require_once QA_INCLUDE_DIR.'db/post-update.php';
...@@ -99,25 +92,21 @@ ...@@ -99,25 +92,21 @@
qa_db_word_tagcount_update($wholetagids); qa_db_word_tagcount_update($wholetagids);
} }
public function move_post($postid, $categoryid) public function move_post($postid, $categoryid)
{ {
// for now, the built-in search engine ignores categories // for now, the built-in search engine ignores categories
} }
public function index_page($pageid, $request, $title, $content, $format, $text) public function index_page($pageid, $request, $title, $content, $format, $text)
{ {
// for now, the built-in search engine ignores custom pages // for now, the built-in search engine ignores custom pages
} }
public function unindex_page($pageid) public function unindex_page($pageid)
{ {
// for now, the built-in search engine ignores custom pages // for now, the built-in search engine ignores custom pages
} }
public function process_search($query, $start, $count, $userid, $absoluteurls, $fullcontent) public function process_search($query, $start, $count, $userid, $absoluteurls, $fullcontent)
{ {
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR.'db/selects.php';
...@@ -143,10 +132,4 @@ ...@@ -143,10 +132,4 @@
return $results; return $results;
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,14 +20,8 @@ ...@@ -20,14 +20,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser class qa_viewer_basic
header('Location: ../'); {
exit;
}
class qa_viewer_basic {
private $htmllineseparators; private $htmllineseparators;
private $htmlparagraphseparators; private $htmlparagraphseparators;
...@@ -39,7 +33,6 @@ ...@@ -39,7 +33,6 @@
'|hr|iframe|input|li|marquee|ol|p|pre|samp|select|spacer|table|tbody|td|textarea|tfoot|th|thead|tr|ul'; '|hr|iframe|input|li|marquee|ol|p|pre|samp|select|spacer|table|tbody|td|textarea|tfoot|th|thead|tr|ul';
} }
public function calc_quality($content, $format) public function calc_quality($content, $format)
{ {
if ( ($format=='') || ($format=='html') ) if ( ($format=='') || ($format=='html') )
...@@ -48,7 +41,6 @@ ...@@ -48,7 +41,6 @@
return 0.0001; // if there's nothing better this will give an error message for unknown formats return 0.0001; // if there's nothing better this will give an error message for unknown formats
} }
public function get_html($content, $format, $options) public function get_html($content, $format, $options)
{ {
if ($format=='html') { if ($format=='html') {
...@@ -138,7 +130,6 @@ ...@@ -138,7 +130,6 @@
return $html; return $html;
} }
public function get_text($content, $format, $options) public function get_text($content, $format, $options)
{ {
if ($format=='html') { if ($format=='html') {
...@@ -177,10 +168,4 @@ ...@@ -177,10 +168,4 @@
return $text; return $text;
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,20 +20,18 @@ ...@@ -20,20 +20,18 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
class qa_activity_count { class qa_activity_count
{
public function allow_template($template) public function allow_template($template)
{ {
return true; return true;
} }
public function allow_region($region) public function allow_region($region)
{ {
return ($region=='side'); return ($region=='side');
} }
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{ {
$themeobject->output('<div class="qa-activity-count">'); $themeobject->output('<div class="qa-activity-count">');
...@@ -49,7 +47,6 @@ ...@@ -49,7 +47,6 @@
$themeobject->output('</div>'); $themeobject->output('</div>');
} }
public function output_count($themeobject, $value, $langsingular, $langplural) public function output_count($themeobject, $value, $langsingular, $langplural)
{ {
$themeobject->output('<p class="qa-activity-count-item">'); $themeobject->output('<p class="qa-activity-count-item">');
...@@ -61,10 +58,4 @@ ...@@ -61,10 +58,4 @@
$themeobject->output('</p>'); $themeobject->output('</p>');
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
class qa_ask_box { class qa_ask_box
{
public function allow_template($template) public function allow_template($template)
{ {
$allowed = array( $allowed = array(
...@@ -31,13 +31,11 @@ ...@@ -31,13 +31,11 @@
return in_array($template, $allowed); return in_array($template, $allowed);
} }
public 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'));
} }
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{ {
if (isset($qa_content['categoryids'])) if (isset($qa_content['categoryids']))
...@@ -70,10 +68,4 @@ ...@@ -70,10 +68,4 @@
</div> </div>
<?php <?php
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,20 +20,18 @@ ...@@ -20,20 +20,18 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
class qa_related_qs { class qa_related_qs
{
public function allow_template($template) public function allow_template($template)
{ {
return ($template=='question'); return ($template=='question');
} }
public function allow_region($region) public function allow_region($region)
{ {
return ($region=='side') || ($region=='main') || ($region=='full'); return ($region=='side') || ($region=='main') || ($region=='full');
} }
public 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.'db/selects.php'; require_once QA_INCLUDE_DIR.'db/selects.php';
...@@ -102,10 +100,4 @@ ...@@ -102,10 +100,4 @@
$themeobject->q_list_and_form($q_list); $themeobject->q_list_and_form($q_list);
} }
} }
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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