Commit a4d750a5 by pupi1985

PHPDoc update in pages/question-submit, pages/question-view, qa-base and qa-theme-base

parent ac7d7558
...@@ -33,11 +33,11 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php'; ...@@ -33,11 +33,11 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php';
* Checks for a POSTed click on $question by the current user and returns true if it was permitted and processed. Pass * Checks for a POSTed click on $question by the current user and returns true if it was permitted and processed. Pass
* in the question's $answers, all $commentsfollows from it or its answers, and its closing $closepost (or null if * in the question's $answers, all $commentsfollows from it or its answers, and its closing $closepost (or null if
* none). If there is an error to display, it will be passed out in $error. * none). If there is an error to display, it will be passed out in $error.
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $closepost * @param array $closepost
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error) function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error)
...@@ -127,12 +127,12 @@ function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closep ...@@ -127,12 +127,12 @@ function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closep
* the $question, all of its $answers, and all $commentsfollows from it or its answers. Set $allowselectmove to whether * the $question, all of its $answers, and all $commentsfollows from it or its answers. Set $allowselectmove to whether
* it is legitimate to change the selected answer for the question from one to another (this can't be done via Ajax). * it is legitimate to change the selected answer for the question from one to another (this can't be done via Ajax).
* If there is an error to display, it will be passed out in $error. * If there is an error to display, it will be passed out in $error.
* @param $answer * @param array $answer
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $allowselectmove * @param bool $allowselectmove
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows, $allowselectmove, &$error) function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows, $allowselectmove, &$error)
...@@ -231,10 +231,10 @@ function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows ...@@ -231,10 +231,10 @@ function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows
* Checks for a POSTed click on $comment by the current user and returns true if it was permitted and processed. Pass * Checks for a POSTed click on $comment by the current user and returns true if it was permitted and processed. Pass
* in the antecedent $question and the comment's $parent post. If there is an error to display, it will be passed out * in the antecedent $question and the comment's $parent post. If there is an error to display, it will be passed out
* in $error. * in $error.
* @param $comment * @param array $comment
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_single_click_c($comment, $question, $parent, &$error) function qa_page_q_single_click_c($comment, $question, $parent, &$error)
...@@ -322,8 +322,8 @@ function qa_page_q_single_click_c($comment, $question, $parent, &$error) ...@@ -322,8 +322,8 @@ function qa_page_q_single_click_c($comment, $question, $parent, &$error)
/** /**
* Check the form security (anti-CSRF protection) for one of the buttons shown for post $post. Return true if the * Check the form security (anti-CSRF protection) for one of the buttons shown for post $post. Return true if the
* security passed, otherwise return false and set an error message in $error * security passed, otherwise return false and set an error message in $error
* @param $post * @param array $post
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_click_check_form_code($post, &$error) function qa_page_q_click_check_form_code($post, &$error)
...@@ -341,12 +341,12 @@ function qa_page_q_click_check_form_code($post, &$error) ...@@ -341,12 +341,12 @@ function qa_page_q_click_check_form_code($post, &$error)
* Processes a POSTed form to add an answer to $question, returning the postid if successful, otherwise null. Pass in * Processes a POSTed form to add an answer to $question, returning the postid if successful, otherwise null. Pass in
* other $answers to the question and whether a $usecaptcha is required. The form fields submitted will be passed out * other $answers to the question and whether a $usecaptcha is required. The form fields submitted will be passed out
* as an array in $in, as well as any $errors on those fields. * as an array in $in, as well as any $errors on those fields.
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $usecaptcha * @param bool $usecaptcha
* @param $in * @param array $in
* @param $errors * @param array $errors
* @return mixed|null * @return int|null
*/ */
function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors) function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors)
{ {
...@@ -424,13 +424,13 @@ function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors ...@@ -424,13 +424,13 @@ function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors
* $question and the comment's $parent post. Set $usecaptcha to whether a captcha is required. Pass an array which * $question and the comment's $parent post. Set $usecaptcha to whether a captcha is required. Pass an array which
* includes the other comments with the same parent in $commentsfollows (it can contain other posts which are ignored). * includes the other comments with the same parent in $commentsfollows (it can contain other posts which are ignored).
* The form fields submitted will be passed out as an array in $in, as well as any $errors on those fields. * The form fields submitted will be passed out as an array in $in, as well as any $errors on those fields.
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $commentsfollows * @param array $commentsfollows
* @param $usecaptcha * @param bool $usecaptcha
* @param $in * @param array $in
* @param $errors * @param array $errors
* @return mixed|null * @return int|null
*/ */
function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors) function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors)
{ {
...@@ -494,7 +494,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch ...@@ -494,7 +494,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch
/** /**
* Return the array of information to be passed to filter modules for the post in $post (from the database) * Return the array of information to be passed to filter modules for the post in $post (from the database)
* @param $post * @param array $post
* @return array * @return array
*/ */
function qa_page_q_prepare_post_for_filters($post) function qa_page_q_prepare_post_for_filters($post)
......
...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Given a $question and its $childposts from the database, return a list of that question's answers * Given a $question and its $childposts from the database, return a list of that question's answers
* @param $question * @param array $question
* @param $childposts * @param array $childposts
* @return array * @return array
*/ */
function qa_page_q_load_as($question, $childposts) function qa_page_q_load_as($question, $childposts)
...@@ -53,9 +53,9 @@ function qa_page_q_load_as($question, $childposts) ...@@ -53,9 +53,9 @@ function qa_page_q_load_as($question, $childposts)
* Given a $question, its $childposts and its answers $achildposts from the database, * Given a $question, its $childposts and its answers $achildposts from the database,
* return a list of comments or follow-on questions for that question or its answers. * return a list of comments or follow-on questions for that question or its answers.
* Follow-on and duplicate questions are now returned, with their visibility determined in qa_page_q_comment_follow_list() * Follow-on and duplicate questions are now returned, with their visibility determined in qa_page_q_comment_follow_list()
* @param $question * @param array $question
* @param $childposts * @param array $childposts
* @param $achildposts * @param array $achildposts
* @param array $duplicateposts * @param array $duplicateposts
* @return array * @return array
*/ */
...@@ -93,11 +93,10 @@ function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplica ...@@ -93,11 +93,10 @@ function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplica
* Calculates which operations the current user may perform on a post. This function is a key part of Q2A's logic * Calculates which operations the current user may perform on a post. This function is a key part of Q2A's logic
* and is ripe for overriding by plugins. The latter two arrays can contain additional posts retrieved from the * and is ripe for overriding by plugins. The latter two arrays can contain additional posts retrieved from the
* database, and these will be ignored. * database, and these will be ignored.
*
* @param array $post The question/answer/comment to check. * @param array $post The question/answer/comment to check.
* @param array $parentpost The post's parent if there is one. * @param array|null $parentpost The post's parent if there is one.
* @param array $siblingposts The post's siblings (i.e. those with the same type and parent as the post). * @param array|null $siblingposts The post's siblings (i.e. those with the same type and parent as the post).
* @param array $childposts The post's children (e.g. comments on answers). * @param array|null $childposts The post's children (e.g. comments on answers).
* @return array List of elements that can be added to the post. * @return array List of elements that can be added to the post.
*/ */
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null) function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
...@@ -257,11 +256,11 @@ function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $ ...@@ -257,11 +256,11 @@ function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $
* is closed, pass the post used to close this question in $closepost, otherwise null. $usershtml should be an array * is closed, pass the post used to close this question in $closepost, otherwise null. $usershtml should be an array
* which maps userids to HTML user representations, including the question's author and (if present) last editor. If a * which maps userids to HTML user representations, including the question's author and (if present) last editor. If a
* form has been explicitly requested for the page, set $formrequested to true - this will hide the buttons. * form has been explicitly requested for the page, set $formrequested to true - this will hide the buttons.
* @param $question * @param array $question
* @param $parentquestion * @param array|null $parentquestion
* @param $closepost * @param int|null $closepost
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested) function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested)
...@@ -492,11 +491,11 @@ function qa_page_q_question_view($question, $parentquestion, $closepost, $usersh ...@@ -492,11 +491,11 @@ function qa_page_q_question_view($question, $parentquestion, $closepost, $usersh
* answer's $question and whether it $isselected. $usershtml should be an array which maps userids to HTML user * answer's $question and whether it $isselected. $usershtml should be an array which maps userids to HTML user
* representations, including the answer's author and (if present) last editor. If a form has been explicitly requested * representations, including the answer's author and (if present) last editor. If a form has been explicitly requested
* for the page, set $formrequested to true - this will hide the buttons. * for the page, set $formrequested to true - this will hide the buttons.
* @param $question * @param array $question
* @param $answer * @param array $answer
* @param $isselected * @param bool $isselected
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $formrequested) function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $formrequested)
...@@ -643,18 +642,17 @@ function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $for ...@@ -643,18 +642,17 @@ function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $for
* current user. Pass the comment's $parent post and antecedent $question. $usershtml should be an array which maps * current user. Pass the comment's $parent post and antecedent $question. $usershtml should be an array which maps
* userids to HTML user representations, including the comments's author and (if present) last editor. If a form has * userids to HTML user representations, including the comments's author and (if present) last editor. If a form has
* been explicitly requested for the page, set $formrequested to true - this will hide the buttons. * been explicitly requested for the page, set $formrequested to true - this will hide the buttons.
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $comment * @param array $comment
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formrequested) function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formrequested)
{ {
$commentid = $comment['postid']; $commentid = $comment['postid'];
$questionid = ($parent['basetype'] == 'Q') ? $parent['postid'] : $parent['parentid']; $questionid = ($parent['basetype'] == 'Q') ? $parent['postid'] : $parent['parentid'];
$answerid = ($parent['basetype'] == 'Q') ? null : $parent['postid'];
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get(); $cookieid = qa_cookie_get();
...@@ -784,13 +782,13 @@ function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formr ...@@ -784,13 +782,13 @@ function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formr
* comments' and follow on questions' authors and (if present) last editors. If a form has been explicitly requested * comments' and follow on questions' authors and (if present) last editors. If a form has been explicitly requested
* for the page, set $formrequested to true and pass the postid of the post for the form in $formpostid - this will * for the page, set $formrequested to true and pass the postid of the post for the form in $formpostid - this will
* hide the buttons and remove the $formpostid comment from the list. * hide the buttons and remove the $formpostid comment from the list.
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $commentsfollows * @param array $commentsfollows
* @param $alwaysfull * @param bool $alwaysfull
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @param $formpostid * @param int $formpostid
* @return array * @return array
*/ */
function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid) function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid)
...@@ -865,7 +863,7 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al ...@@ -865,7 +863,7 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al
} }
} }
if (!count($commentlist['cs'])) if (empty($commentlist['cs']))
$commentlist['hidden'] = true; $commentlist['hidden'] = true;
return $commentlist; return $commentlist;
...@@ -877,14 +875,14 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al ...@@ -877,14 +875,14 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al
* and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs from a submitted version of this * and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs from a submitted version of this
* form in the array $in and resulting errors in $errors. If $loadnow is true, the form will be loaded immediately. Set * form in the array $in and resulting errors in $errors. If $loadnow is true, the form will be loaded immediately. Set
* $formrequested to true if the user explicitly requested it, as opposed being shown automatically. * $formrequested to true if the user explicitly requested it, as opposed being shown automatically.
* @param $qa_content * @param array $qa_content
* @param $formid * @param string $formid
* @param $captchareason * @param string $captchareason
* @param $question * @param array $question
* @param $in * @param array $in
* @param $errors * @param array $errors
* @param $loadnow * @param bool $loadnow
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, $in, $errors, $loadnow, $formrequested) function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, $in, $errors, $loadnow, $formrequested)
...@@ -1026,14 +1024,14 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, ...@@ -1026,14 +1024,14 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question,
* to use for the form in $formid and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs * to use for the form in $formid and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs
* from a submitted version of this form in the array $in and resulting errors in $errors. If $loadfocusnow is true, * from a submitted version of this form in the array $in and resulting errors in $errors. If $loadfocusnow is true,
* the form will be loaded and focused immediately. * the form will be loaded and focused immediately.
* @param $qa_content * @param array $qa_content
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $formid * @param string $formid
* @param $captchareason * @param string $captchareason
* @param $in * @param array $in
* @param $errors * @param array $errors
* @param $loadfocusnow * @param bool $loadfocusnow
* @return array * @return array
*/ */
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow) function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow)
......
...@@ -35,7 +35,7 @@ define('QA_BUILD_DATE', '2019-01-12'); ...@@ -35,7 +35,7 @@ define('QA_BUILD_DATE', '2019-01-12');
* Classes are mapped to PHP files with the underscores converted to directory separators. The Q2A_Util_Debug class is in * Classes are mapped to PHP files with the underscores converted to directory separators. The Q2A_Util_Debug class is in
* the file qa-include/Q2A/Util/Debug.php. A class named Q2A_Db_User_Messages would be in a file qa-include/Q2A/Db/User/Messages.php. * the file qa-include/Q2A/Util/Debug.php. A class named Q2A_Db_User_Messages would be in a file qa-include/Q2A/Db/User/Messages.php.
* *
* @param $class * @param string $class
*/ */
function qa_autoload($class) function qa_autoload($class)
{ {
...@@ -86,7 +86,7 @@ if (!isset($qa_autoconnect) || $qa_autoconnect !== false) { ...@@ -86,7 +86,7 @@ if (!isset($qa_autoconnect) || $qa_autoconnect !== false) {
* Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons * Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons
* (PHP's version_compare() function is not quite suitable for our needs) * (PHP's version_compare() function is not quite suitable for our needs)
* @deprecated 1.8.2 no longer used * @deprecated 1.8.2 no longer used
* @param $version * @param string $version
* @return float * @return float
*/ */
function qa_version_to_float($version) function qa_version_to_float($version)
...@@ -109,7 +109,7 @@ function qa_version_to_float($version) ...@@ -109,7 +109,7 @@ function qa_version_to_float($version)
/** /**
* Returns true if the current Q2A version is lower than $version * Returns true if the current Q2A version is lower than $version
* @param $version * @param string $version
* @return bool * @return bool
*/ */
function qa_qa_version_below($version) function qa_qa_version_below($version)
...@@ -120,7 +120,7 @@ function qa_qa_version_below($version) ...@@ -120,7 +120,7 @@ function qa_qa_version_below($version)
/** /**
* Returns true if the current PHP version is lower than $version * Returns true if the current PHP version is lower than $version
* @param $version * @param string $version
* @return bool * @return bool
*/ */
function qa_php_version_below($version) function qa_php_version_below($version)
...@@ -350,7 +350,7 @@ function qa_initialize_modularity() ...@@ -350,7 +350,7 @@ function qa_initialize_modularity()
/** /**
* Set up output buffering. Use gzip compression if option set and it's not an admin page (since some of these contain lengthy processes). * Set up output buffering. Use gzip compression if option set and it's not an admin page (since some of these contain lengthy processes).
* @param $request * @param string $request
* @return bool whether buffering was used * @return bool whether buffering was used
*/ */
function qa_initialize_buffering($request = '') function qa_initialize_buffering($request = '')
...@@ -418,10 +418,10 @@ function qa_initialize_postdb_plugins() ...@@ -418,10 +418,10 @@ function qa_initialize_postdb_plugins()
/** /**
* Standard database failure handler function which bring up the install/repair/upgrade page * Standard database failure handler function which bring up the install/repair/upgrade page
* @param $type * @param string $type
* @param int $errno * @param int|null $errno
* @param string $error * @param string|null $error
* @param string $query * @param string|null $query
* @return mixed * @return mixed
*/ */
function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = null) function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = null)
...@@ -445,9 +445,9 @@ function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = n ...@@ -445,9 +445,9 @@ function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = n
* Name, Description, Min Q2A & Min PHP are not currently used by themes. * Name, Description, Min Q2A & Min PHP are not currently used by themes.
* *
* @deprecated Deprecated from 1.7; Q2A_Util_Metadata class and metadata.json files should be used instead * @deprecated Deprecated from 1.7; Q2A_Util_Metadata class and metadata.json files should be used instead
* @param $contents * @param string $contents
* @param $type * @param string $type
* @param bool $versiononly * @param bool|null $versiononly
* @return array * @return array
*/ */
function qa_addon_metadata($contents, $type, $versiononly = false) function qa_addon_metadata($contents, $type, $versiononly = false)
...@@ -538,12 +538,12 @@ function qa_load_override_files() ...@@ -538,12 +538,12 @@ function qa_load_override_files()
/** /**
* Register a module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary) * Register a module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary)
* If this module comes from a plugin, pass in the local plugin $directory and the $urltoroot relative url for that directory * If this module comes from a plugin, pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $type * @param string $type
* @param $include * @param string $include
* @param $class * @param string $class
* @param $name * @param string $name
* @param string $directory * @param string $directory
* @param string $urltoroot * @param string|null $urltoroot
*/ */
function qa_register_module($type, $include, $class, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null) function qa_register_module($type, $include, $class, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{ {
...@@ -568,10 +568,10 @@ function qa_register_module($type, $include, $class, $name, $directory = QA_INCL ...@@ -568,10 +568,10 @@ function qa_register_module($type, $include, $class, $name, $directory = QA_INCL
/** /**
* Register a layer named $name, defined in file $include. If this layer comes from a plugin (as all currently do), * Register a layer named $name, defined in file $include. If this layer comes from a plugin (as all currently do),
* pass in the local plugin $directory and the $urltoroot relative url for that directory * pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $include * @param string $include
* @param $name * @param string $name
* @param string $directory * @param string $directory
* @param string $urltoroot * @param string|null $urltoroot
*/ */
function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null) function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{ {
...@@ -595,9 +595,9 @@ function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltor ...@@ -595,9 +595,9 @@ function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltor
/** /**
* Register a file $include containing override functions. If this file comes from a plugin (as all currently do), * Register a file $include containing override functions. If this file comes from a plugin (as all currently do),
* pass in the local plugin $directory and the $urltoroot relative url for that directory * pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $include * @param string $include
* @param string $directory * @param string $directory
* @param string $urltoroot * @param string|null $urltoroot
*/ */
function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot = null) function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{ {
...@@ -615,8 +615,8 @@ function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot ...@@ -615,8 +615,8 @@ function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot
* Register a set of language phrases, which should be accessed by the prefix $name/ in the qa_lang_*() functions. * Register a set of language phrases, which should be accessed by the prefix $name/ in the qa_lang_*() functions.
* Pass in the $pattern representing the PHP files that define these phrases, where * in the pattern is replaced with * Pass in the $pattern representing the PHP files that define these phrases, where * in the pattern is replaced with
* the language code (e.g. 'fr') and/or 'default'. These files should be formatted like Q2A's qa-lang-*.php files. * the language code (e.g. 'fr') and/or 'default'. These files should be formatted like Q2A's qa-lang-*.php files.
* @param $pattern * @param string $pattern
* @param $name * @param string $name
*/ */
function qa_register_phrases($pattern, $name) function qa_register_phrases($pattern, $name)
{ {
...@@ -640,10 +640,10 @@ function qa_register_phrases($pattern, $name) ...@@ -640,10 +640,10 @@ function qa_register_phrases($pattern, $name)
/** /**
* Register a plugin module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary) * Register a plugin module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary)
* This function relies on some global variable values and can only be called from a plugin's qa-plugin.php file * This function relies on some global variable values and can only be called from a plugin's qa-plugin.php file
* @param $type * @param string $type
* @param $include * @param string $include
* @param $class * @param string $class
* @param $name * @param string $name
*/ */
function qa_register_plugin_module($type, $include, $class, $name) function qa_register_plugin_module($type, $include, $class, $name)
{ {
...@@ -659,8 +659,8 @@ function qa_register_plugin_module($type, $include, $class, $name) ...@@ -659,8 +659,8 @@ function qa_register_plugin_module($type, $include, $class, $name)
/** /**
* Register a plugin layer named $name, defined in file $include. Can only be called from a plugin's qa-plugin.php file * Register a plugin layer named $name, defined in file $include. Can only be called from a plugin's qa-plugin.php file
* @param $include * @param string $include
* @param $name * @param string $name
*/ */
function qa_register_plugin_layer($include, $name) function qa_register_plugin_layer($include, $name)
{ {
...@@ -676,7 +676,7 @@ function qa_register_plugin_layer($include, $name) ...@@ -676,7 +676,7 @@ function qa_register_plugin_layer($include, $name)
/** /**
* Register a plugin file $include containing override functions. Can only be called from a plugin's qa-plugin.php file * Register a plugin file $include containing override functions. Can only be called from a plugin's qa-plugin.php file
* @param $include * @param string $include
*/ */
function qa_register_plugin_overrides($include) function qa_register_plugin_overrides($include)
{ {
...@@ -692,8 +692,8 @@ function qa_register_plugin_overrides($include) ...@@ -692,8 +692,8 @@ function qa_register_plugin_overrides($include)
/** /**
* Register a file name $pattern within a plugin directory containing language phrases accessed by the prefix $name * Register a file name $pattern within a plugin directory containing language phrases accessed by the prefix $name
* @param $pattern * @param string $pattern
* @param $name * @param string $name
*/ */
function qa_register_plugin_phrases($pattern, $name) function qa_register_plugin_phrases($pattern, $name)
{ {
...@@ -712,8 +712,8 @@ function qa_register_plugin_phrases($pattern, $name) ...@@ -712,8 +712,8 @@ function qa_register_plugin_phrases($pattern, $name)
/** /**
* Calls eval() on the PHP code in $eval which came from the file $filename. It supplements PHP's regular error reporting by * Calls eval() on the PHP code in $eval which came from the file $filename. It supplements PHP's regular error reporting by
* displaying/logging (as appropriate) the original source filename, if an error occurred when evaluating the code. * displaying/logging (as appropriate) the original source filename, if an error occurred when evaluating the code.
* @param $eval * @param string $eval
* @param $filename * @param string $filename
*/ */
function qa_eval_from_file($eval, $filename) function qa_eval_from_file($eval, $filename)
{ {
...@@ -747,8 +747,8 @@ function qa_eval_from_file($eval, $filename) ...@@ -747,8 +747,8 @@ function qa_eval_from_file($eval, $filename)
/** /**
* Call $function with the arguments in the $args array (doesn't work with call-by-reference functions) * Call $function with the arguments in the $args array (doesn't work with call-by-reference functions)
* @param $function * @param string $function
* @param $args * @param array $args
* @return mixed * @return mixed
*/ */
function qa_call($function, $args) function qa_call($function, $args)
...@@ -776,7 +776,6 @@ function qa_call($function, $args) ...@@ -776,7 +776,6 @@ function qa_call($function, $args)
/** /**
* Determines whether a function is to be overridden by a plugin. But if the function is being called with * Determines whether a function is to be overridden by a plugin. But if the function is being called with
* the _base suffix, any override will be bypassed due to $qa_direct. * the _base suffix, any override will be bypassed due to $qa_direct.
*
* @param string $function The function to override * @param string $function The function to override
* @return string|null The name of the overriding function (of the form `qa_functionname_override_1_in_filename`) * @return string|null The name of the overriding function (of the form `qa_functionname_override_1_in_filename`)
*/ */
...@@ -804,8 +803,8 @@ function qa_to_override($function) ...@@ -804,8 +803,8 @@ function qa_to_override($function)
/** /**
* Call the function which immediately overrides $function with the arguments in the $args array * Call the function which immediately overrides $function with the arguments in the $args array
* @param $function * @param string $function
* @param $args * @param array $args
* @return mixed * @return mixed
*/ */
function qa_call_override($function, $args) function qa_call_override($function, $args)
...@@ -827,7 +826,7 @@ function qa_call_override($function, $args) ...@@ -827,7 +826,7 @@ function qa_call_override($function, $args)
/** /**
* Exit PHP immediately after reporting a shutdown with $reason to any installed process modules * Exit PHP immediately after reporting a shutdown with $reason to any installed process modules
* @param string $reason * @param string|null $reason
*/ */
function qa_exit($reason = null) function qa_exit($reason = null)
{ {
...@@ -840,7 +839,7 @@ function qa_exit($reason = null) ...@@ -840,7 +839,7 @@ function qa_exit($reason = null)
/** /**
* Display $message in the browser, write it to server error log, and then stop abruptly * Display $message in the browser, write it to server error log, and then stop abruptly
* @param $message * @param string $message
* @return mixed * @return mixed
*/ */
function qa_fatal_error($message) function qa_fatal_error($message)
...@@ -885,7 +884,7 @@ function qa_list_module_types() ...@@ -885,7 +884,7 @@ function qa_list_module_types()
/** /**
* Return a list of names of registered modules of $type * Return a list of names of registered modules of $type
* @param $type * @param string $type
* @return array * @return array
*/ */
function qa_list_modules($type) function qa_list_modules($type)
...@@ -896,8 +895,8 @@ function qa_list_modules($type) ...@@ -896,8 +895,8 @@ function qa_list_modules($type)
/** /**
* Return an array containing information about the module of $type named $name * Return an array containing information about the module of $type named $name
* @param $type * @param string $type
* @param $name * @param string $name
* @return array * @return array
*/ */
function qa_get_module_info($type, $name) function qa_get_module_info($type, $name)
...@@ -908,8 +907,8 @@ function qa_get_module_info($type, $name) ...@@ -908,8 +907,8 @@ function qa_get_module_info($type, $name)
/** /**
* Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist * Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist
* @param $type * @param string $type
* @param $name * @param string $name
* @return mixed|null * @return mixed|null
*/ */
function qa_load_module($type, $name) function qa_load_module($type, $name)
...@@ -942,7 +941,7 @@ function qa_load_module($type, $name) ...@@ -942,7 +941,7 @@ function qa_load_module($type, $name)
/** /**
* Return an array of instantiated clases for modules which have defined $method * Return an array of instantiated clases for modules which have defined $method
* (all modules are loaded but not included in the returned array) * (all modules are loaded but not included in the returned array)
* @param $method * @param string $method
* @return array * @return array
*/ */
function qa_load_all_modules_with($method) function qa_load_all_modules_with($method)
...@@ -966,8 +965,8 @@ function qa_load_all_modules_with($method) ...@@ -966,8 +965,8 @@ function qa_load_all_modules_with($method)
/** /**
* Return an array of instantiated clases for modules of $type which have defined $method * Return an array of instantiated clases for modules of $type which have defined $method
* (other modules of that type are also loaded but not included in the returned array) * (other modules of that type are also loaded but not included in the returned array)
* @param $type * @param string $type
* @param $method * @param string $method
* @return array * @return array
*/ */
function qa_load_modules_with($type, $method) function qa_load_modules_with($type, $method)
...@@ -991,13 +990,13 @@ function qa_load_modules_with($type, $method) ...@@ -991,13 +990,13 @@ function qa_load_modules_with($type, $method)
/** /**
* Return HTML representation of $string, work well with blocks of text if $multiline is true * Return HTML representation of $string, work well with blocks of text if $multiline is true
* @param $string * @param string $string
* @param bool $multiline * @param bool $multiline
* @return mixed|string * @return string
*/ */
function qa_html($string, $multiline = false) function qa_html($string, $multiline = false)
{ {
$html = htmlspecialchars((string)$string); $html = htmlspecialchars($string);
if ($multiline) { if ($multiline) {
$html = preg_replace('/\r\n?/', "\n", $html); $html = preg_replace('/\r\n?/', "\n", $html);
...@@ -1014,10 +1013,10 @@ function qa_html($string, $multiline = false) ...@@ -1014,10 +1013,10 @@ function qa_html($string, $multiline = false)
* Return $html after ensuring it is safe, i.e. removing Javascripts and the like - uses htmLawed library * Return $html after ensuring it is safe, i.e. removing Javascripts and the like - uses htmLawed library
* Links open in a new window if $linksnewwindow is true. Set $storage to true if sanitization is for * Links open in a new window if $linksnewwindow is true. Set $storage to true if sanitization is for
* storing in the database, rather than immediate display to user - some think this should be less strict. * storing in the database, rather than immediate display to user - some think this should be less strict.
* @param $html * @param string $html
* @param bool $linksnewwindow * @param bool $linksnewwindow
* @param bool $storage * @param bool $storage
* @return mixed|string * @return string
*/ */
function qa_sanitize_html($html, $linksnewwindow = false, $storage = false) function qa_sanitize_html($html, $linksnewwindow = false, $storage = false)
{ {
...@@ -1044,7 +1043,7 @@ function qa_sanitize_html($html, $linksnewwindow = false, $storage = false) ...@@ -1044,7 +1043,7 @@ function qa_sanitize_html($html, $linksnewwindow = false, $storage = false)
/** /**
* htmLawed hook function used to process tags in qa_sanitize_html(...) * htmLawed hook function used to process tags in qa_sanitize_html(...)
* @param $element * @param string $element
* @param array $attributes * @param array $attributes
* @return string * @return string
*/ */
...@@ -1074,19 +1073,19 @@ function qa_sanitize_html_hook_tag($element, $attributes = null) ...@@ -1074,19 +1073,19 @@ function qa_sanitize_html_hook_tag($element, $attributes = null)
/** /**
* Return XML representation of $string, which is similar to HTML but ASCII control characters are also disallowed * Return XML representation of $string, which is similar to HTML but ASCII control characters are also disallowed
* @param $string * @param string $string
* @return string * @return string
*/ */
function qa_xml($string) function qa_xml($string)
{ {
return htmlspecialchars(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', (string)$string)); return htmlspecialchars(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string));
} }
/** /**
* Return JavaScript representation of $value, putting in quotes if non-numeric or if $forcequotes is true. In the * Return JavaScript representation of $value, putting in quotes if non-numeric or if $forcequotes is true. In the
* case of boolean values they are returned as the appropriate true or false string * case of boolean values they are returned as the appropriate true or false string
* @param $value * @param mixed $value
* @param bool $forcequotes * @param bool $forcequotes
* @return string * @return string
*/ */
...@@ -1113,9 +1112,9 @@ function qa_js($value, $forcequotes = false) ...@@ -1113,9 +1112,9 @@ function qa_js($value, $forcequotes = false)
/** /**
* Inform Q2A that the current request is $request (slash-separated, independent of the url scheme chosen), * Inform Q2A that the current request is $request (slash-separated, independent of the url scheme chosen),
* that the relative path to the Q2A root apperas to be $relativeroot, and the url scheme appears to be $usedformat * that the relative path to the Q2A root apperas to be $relativeroot, and the url scheme appears to be $usedformat
* @param $request * @param string $request
* @param $relativeroot * @param string $relativeroot
* @param $usedformat * @param int|null $usedformat
* @return mixed * @return mixed
*/ */
function qa_set_request($request, $relativeroot, $usedformat = null) function qa_set_request($request, $relativeroot, $usedformat = null)
...@@ -1132,6 +1131,7 @@ function qa_set_request($request, $relativeroot, $usedformat = null) ...@@ -1132,6 +1131,7 @@ function qa_set_request($request, $relativeroot, $usedformat = null)
/** /**
* Returns the current Q2A request (slash-separated, independent of the url scheme chosen) * Returns the current Q2A request (slash-separated, independent of the url scheme chosen)
* @return string
*/ */
function qa_request() function qa_request()
{ {
...@@ -1144,8 +1144,8 @@ function qa_request() ...@@ -1144,8 +1144,8 @@ function qa_request()
/** /**
* Returns the indexed $part (as separated by slashes) of the current Q2A request, or null if it doesn't exist * Returns the indexed $part (as separated by slashes) of the current Q2A request, or null if it doesn't exist
* @param $part * @param int $part
* @return * @return string
*/ */
function qa_request_part($part) function qa_request_part($part)
{ {
...@@ -1167,8 +1167,8 @@ function qa_request_parts($start = 0) ...@@ -1167,8 +1167,8 @@ function qa_request_parts($start = 0)
/** /**
* Return string for incoming GET/POST/COOKIE value, stripping slashes if appropriate * Return string for incoming GET/POST/COOKIE value, stripping slashes if appropriate
* @param $string * @param string $string
* @return mixed|string * @return string
*/ */
function qa_gpc_to_string($string) function qa_gpc_to_string($string)
{ {
...@@ -1180,8 +1180,8 @@ function qa_gpc_to_string($string) ...@@ -1180,8 +1180,8 @@ function qa_gpc_to_string($string)
/** /**
* Return string with slashes added, if appropriate for later removal by qa_gpc_to_string() * Return string with slashes added, if appropriate for later removal by qa_gpc_to_string()
* @param $string * @param string $string
* @return mixed|string * @return string
*/ */
function qa_string_to_gpc($string) function qa_string_to_gpc($string)
{ {
...@@ -1193,8 +1193,8 @@ function qa_string_to_gpc($string) ...@@ -1193,8 +1193,8 @@ function qa_string_to_gpc($string)
/** /**
* Return string for incoming GET field, or null if it's not defined * Return string for incoming GET field, or null if it's not defined
* @param $field * @param string $field
* @return mixed|null|string * @return mixed|null
*/ */
function qa_get($field) function qa_get($field)
{ {
...@@ -1207,7 +1207,7 @@ function qa_get($field) ...@@ -1207,7 +1207,7 @@ function qa_get($field)
/** /**
* Return string for incoming POST field, or null if it's not defined. * Return string for incoming POST field, or null if it's not defined.
* While we're at it, trim() surrounding white space and converted to Unix line endings. * While we're at it, trim() surrounding white space and converted to Unix line endings.
* @param $field * @param string $field
* @return mixed|null * @return mixed|null
*/ */
function qa_post_text($field) function qa_post_text($field)
...@@ -1220,8 +1220,8 @@ function qa_post_text($field) ...@@ -1220,8 +1220,8 @@ function qa_post_text($field)
/** /**
* Return an array for incoming POST field, or null if it's not an array or not defined. * Return an array for incoming POST field, or null if it's not an array or not defined.
* While we're at it, trim() surrounding white space for each value and convert them to Unix line endings. * While we're at it, trim() surrounding white space for each value and convert them to Unix line endings.
* @param $field * @param string $field
* @return array|mixed|null * @return mixed|null
*/ */
function qa_post_array($field) function qa_post_array($field)
{ {
...@@ -1242,8 +1242,8 @@ function qa_post_array($field) ...@@ -1242,8 +1242,8 @@ function qa_post_array($field)
/** /**
* Return true if form button $name was clicked (as type=submit/image) to create this page request, or if a * Return true if form button $name was clicked (as type=submit/image) to create this page request, or if a
* simulated click was sent for the button (via 'qa_click' POST field) * simulated click was sent for the button (via 'qa_click' POST field)
* @param $name * @param string $name
* @return bool|mixed * @return bool
*/ */
function qa_clicked($name) function qa_clicked($name)
{ {
...@@ -1255,7 +1255,7 @@ function qa_clicked($name) ...@@ -1255,7 +1255,7 @@ function qa_clicked($name)
/** /**
* Determine the remote IP address of the user accessing the site. * Determine the remote IP address of the user accessing the site.
* @return mixed String representing IP if it's available, or null otherwise. * @return string|null String representing IP if it's available, or null otherwise.
*/ */
function qa_remote_ip_address() function qa_remote_ip_address()
{ {
...@@ -1270,6 +1270,7 @@ function qa_remote_ip_address() ...@@ -1270,6 +1270,7 @@ function qa_remote_ip_address()
* is too big to be properly processed by PHP, usually because there is an attachment in the HTTP request. A warning * is too big to be properly processed by PHP, usually because there is an attachment in the HTTP request. A warning
* is added to the server's log displaying the size of the file that triggered this situation. It is important to note * is added to the server's log displaying the size of the file that triggered this situation. It is important to note
* that whenever this happens the $_POST and $_FILES superglobals are empty. * that whenever this happens the $_POST and $_FILES superglobals are empty.
* @return bool
*/ */
function qa_post_limit_exceeded() function qa_post_limit_exceeded()
{ {
...@@ -1283,6 +1284,8 @@ function qa_post_limit_exceeded() ...@@ -1283,6 +1284,8 @@ function qa_post_limit_exceeded()
$postmaxsize = convert_to_bytes($unit, $postmaxsize); $postmaxsize = convert_to_bytes($unit, $postmaxsize);
return $_SERVER['CONTENT_LENGTH'] > $postmaxsize; return $_SERVER['CONTENT_LENGTH'] > $postmaxsize;
} }
return false;
} }
...@@ -1290,8 +1293,8 @@ function qa_post_limit_exceeded() ...@@ -1290,8 +1293,8 @@ function qa_post_limit_exceeded()
* Turns a numeric value and a unit (g/m/k) into bytes * Turns a numeric value and a unit (g/m/k) into bytes
* @param string $unit One of 'g', 'm', 'k'. It is case insensitive * @param string $unit One of 'g', 'm', 'k'. It is case insensitive
* @param int $value The value to turn into bytes * @param int $value The value to turn into bytes
* @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then * @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then the
* the original value is returned * original value is returned
*/ */
function convert_to_bytes($unit, $value) function convert_to_bytes($unit, $value)
{ {
...@@ -1311,7 +1314,7 @@ function convert_to_bytes($unit, $value) ...@@ -1311,7 +1314,7 @@ function convert_to_bytes($unit, $value)
/** /**
* Whether we are responding to an HTTP GET request * Return true if we are responding to an HTTP GET request
* @return bool True if the request is GET * @return bool True if the request is GET
*/ */
function qa_is_http_get() function qa_is_http_get()
...@@ -1323,6 +1326,7 @@ function qa_is_http_get() ...@@ -1323,6 +1326,7 @@ function qa_is_http_get()
/** /**
* Return true if we are responding to an HTTP POST request * Return true if we are responding to an HTTP POST request
* @return bool True if the request is POST
*/ */
function qa_is_http_post() function qa_is_http_post()
{ {
...@@ -1334,6 +1338,7 @@ function qa_is_http_post() ...@@ -1334,6 +1338,7 @@ function qa_is_http_post()
/** /**
* Return true if we appear to be responding to a secure HTTP request (but hard to be sure) * Return true if we appear to be responding to a secure HTTP request (but hard to be sure)
* @return bool
*/ */
function qa_is_https_probably() function qa_is_https_probably()
{ {
...@@ -1346,6 +1351,7 @@ function qa_is_https_probably() ...@@ -1346,6 +1351,7 @@ function qa_is_https_probably()
/** /**
* Return true if it appears the page request is coming from a human using a web browser, rather than a search engine * Return true if it appears the page request is coming from a human using a web browser, rather than a search engine
* or other bot. Based on a whitelist of terms in user agents, this can easily be tricked by a scraper or bad bot. * or other bot. Based on a whitelist of terms in user agents, this can easily be tricked by a scraper or bad bot.
* @return bool
*/ */
function qa_is_human_probably() function qa_is_human_probably()
{ {
...@@ -1363,7 +1369,9 @@ function qa_is_human_probably() ...@@ -1363,7 +1369,9 @@ function qa_is_human_probably()
/** /**
* Return true if it appears that the page request is coming from a mobile client rather than a desktop/laptop web browser * Return true if it appears that the page request is coming from a mobile client rather than a desktop/laptop web
* browser
* @return bool
*/ */
function qa_is_mobile_probably() function qa_is_mobile_probably()
{ {
...@@ -1405,7 +1413,7 @@ function qa_is_mobile_probably() ...@@ -1405,7 +1413,7 @@ function qa_is_mobile_probably()
* loading an option now will cause a problem (see issue in qa_default_option()). The part of * loading an option now will cause a problem (see issue in qa_default_option()). The part of
* $identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the * $identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the
* part after the / is the key of the array element to be taken from that file's returned result. * part after the / is the key of the array element to be taken from that file's returned result.
* @param $identifier * @param string $identifier
* @return string * @return string
*/ */
function qa_lang($identifier) function qa_lang($identifier)
...@@ -1455,8 +1463,8 @@ function qa_lang($identifier) ...@@ -1455,8 +1463,8 @@ function qa_lang($identifier)
/** /**
* Return the translated string for $identifier, with $symbol substituted for $textparam * Return the translated string for $identifier, with $symbol substituted for $textparam
* @param $identifier * @param string $identifier
* @param $textparam * @param string $textparam
* @param string $symbol * @param string $symbol
* @return mixed * @return mixed
*/ */
...@@ -1468,8 +1476,8 @@ function qa_lang_sub($identifier, $textparam, $symbol = '^') ...@@ -1468,8 +1476,8 @@ function qa_lang_sub($identifier, $textparam, $symbol = '^')
/** /**
* Return the translated string for $identifier, converted to HTML * Return the translated string for $identifier, converted to HTML
* @param $identifier * @param string $identifier
* @return mixed|string * @return string
*/ */
function qa_lang_html($identifier) function qa_lang_html($identifier)
{ {
...@@ -1479,8 +1487,8 @@ function qa_lang_html($identifier) ...@@ -1479,8 +1487,8 @@ function qa_lang_html($identifier)
/** /**
* Return the translated string for $identifier converted to HTML, with $symbol *then* substituted for $htmlparam * Return the translated string for $identifier converted to HTML, with $symbol *then* substituted for $htmlparam
* @param $identifier * @param string $identifier
* @param $htmlparam * @param string $htmlparam
* @param string $symbol * @param string $symbol
* @return mixed * @return mixed
*/ */
...@@ -1493,8 +1501,8 @@ function qa_lang_html_sub($identifier, $htmlparam, $symbol = '^') ...@@ -1493,8 +1501,8 @@ function qa_lang_html_sub($identifier, $htmlparam, $symbol = '^')
/** /**
* Return an array containing the translated string for $identifier converted to HTML, then split into three, * Return an array containing the translated string for $identifier converted to HTML, then split into three,
* with $symbol substituted for $htmlparam in the 'data' element, and obvious 'prefix' and 'suffix' elements * with $symbol substituted for $htmlparam in the 'data' element, and obvious 'prefix' and 'suffix' elements
* @param $identifier * @param string $identifier
* @param $htmlparam * @param string $htmlparam
* @param string $symbol * @param string $symbol
* @return array * @return array
*/ */
...@@ -1518,6 +1526,7 @@ function qa_lang_html_sub_split($identifier, $htmlparam, $symbol = '^') ...@@ -1518,6 +1526,7 @@ function qa_lang_html_sub_split($identifier, $htmlparam, $symbol = '^')
/** /**
* Return the relative path to the Q2A root (if it was previously set by qa_set_request()) * Return the relative path to the Q2A root (if it was previously set by qa_set_request())
* @return string
*/ */
function qa_path_to_root() function qa_path_to_root()
{ {
...@@ -1530,6 +1539,7 @@ function qa_path_to_root() ...@@ -1530,6 +1539,7 @@ function qa_path_to_root()
/** /**
* Return an array of mappings of Q2A requests, as defined in the qa-config.php file * Return an array of mappings of Q2A requests, as defined in the qa-config.php file
* @return array
*/ */
function qa_get_request_map() function qa_get_request_map()
{ {
...@@ -1545,11 +1555,11 @@ function qa_get_request_map() ...@@ -1545,11 +1555,11 @@ function qa_get_request_map()
* Slashes in $request will not be urlencoded, but any other characters will. * Slashes in $request will not be urlencoded, but any other characters will.
* If $neaturls is set, use that, otherwise retrieve the option. If $rooturl is set, take * If $neaturls is set, use that, otherwise retrieve the option. If $rooturl is set, take
* that as the root of the Q2A site, otherwise use path to root which was set elsewhere. * that as the root of the Q2A site, otherwise use path to root which was set elsewhere.
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return string * @return string
*/ */
function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
...@@ -1623,11 +1633,11 @@ function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $a ...@@ -1623,11 +1633,11 @@ function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $a
/** /**
* Return HTML representation of relative URI path for $request - see qa_path() for other parameters * Return HTML representation of relative URI path for $request - see qa_path() for other parameters
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return mixed|string * @return mixed|string
*/ */
function qa_path_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_path_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
...@@ -1638,9 +1648,9 @@ function qa_path_html($request, $params = null, $rooturl = null, $neaturls = nul ...@@ -1638,9 +1648,9 @@ function qa_path_html($request, $params = null, $rooturl = null, $neaturls = nul
/** /**
* Return the absolute URI for $request - see qa_path() for other parameters * Return the absolute URI for $request - see qa_path() for other parameters
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $anchor * @param string|null $anchor
* @return string * @return string
*/ */
function qa_path_absolute($request, $params = null, $anchor = null) function qa_path_absolute($request, $params = null, $anchor = null)
...@@ -1672,9 +1682,9 @@ function qa_q_request($questionid, $title) ...@@ -1672,9 +1682,9 @@ function qa_q_request($questionid, $title)
/** /**
* Return the HTML anchor that should be used for post $postid with $basetype (Q/A/C) * Return the HTML anchor that should be used for post $postid with $basetype (Q/A/C)
* @param $basetype * @param string $basetype
* @param $postid * @param int $postid
* @return mixed|string * @return string
*/ */
function qa_anchor($basetype, $postid) function qa_anchor($basetype, $postid)
{ {
...@@ -1687,12 +1697,12 @@ function qa_anchor($basetype, $postid) ...@@ -1687,12 +1697,12 @@ function qa_anchor($basetype, $postid)
/** /**
* Return the URL for question $questionid with $title, possibly using $absolute URLs. * Return the URL for question $questionid with $title, possibly using $absolute URLs.
* To link to a specific answer or comment in a question, set $showtype and $showid accordingly. * To link to a specific answer or comment in a question, set $showtype and $showid accordingly.
* @param $questionid * @param int $questionid
* @param $title * @param string $title
* @param bool $absolute * @param bool $absolute
* @param string $showtype * @param string|null $showtype
* @param int $showid * @param int|null $showid
* @return mixed|string * @return string
*/ */
function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $showid = null) function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $showid = null)
{ {
...@@ -1713,11 +1723,11 @@ function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $sh ...@@ -1713,11 +1723,11 @@ function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $sh
/** /**
* Return the HTML representation of the URL for $questionid - other parameters as for qa_q_path() * Return the HTML representation of the URL for $questionid - other parameters as for qa_q_path()
* @param $questionid * @param int $questionid
* @param $title * @param string $title
* @param bool $absolute * @param bool|null $absolute
* @param string $showtype * @param string|null $showtype
* @param int $showid * @param int|null $showid
* @return mixed|string * @return mixed|string
*/ */
function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null, $showid = null) function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null, $showid = null)
...@@ -1728,8 +1738,8 @@ function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null ...@@ -1728,8 +1738,8 @@ function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null
/** /**
* Return the request for the specified $feed * Return the request for the specified $feed
* @param $feed * @param string $feed
* @return mixed|string * @return string
*/ */
function qa_feed_request($feed) function qa_feed_request($feed)
{ {
...@@ -1741,6 +1751,7 @@ function qa_feed_request($feed) ...@@ -1741,6 +1751,7 @@ function qa_feed_request($feed)
/** /**
* Return an HTML-ready relative URL for the current page, preserving GET parameters - this is useful for action="..." in HTML forms * Return an HTML-ready relative URL for the current page, preserving GET parameters - this is useful for action="..." in HTML forms
* @return string
*/ */
function qa_self_html() function qa_self_html()
{ {
...@@ -1755,12 +1766,12 @@ function qa_self_html() ...@@ -1755,12 +1766,12 @@ function qa_self_html()
/** /**
* Return HTML for hidden fields to insert into a <form method="get"...> on the page. * Return HTML for hidden fields to insert into a <form method="get"...> on the page.
* This is needed because any parameters on the URL will be lost when the form is submitted. * This is needed because any parameters on the URL will be lost when the form is submitted.
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return mixed|string * @return string
*/ */
function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
{ {
...@@ -1784,11 +1795,11 @@ function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls ...@@ -1784,11 +1795,11 @@ function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls
/** /**
* Redirect the user's web browser to $request and then we're done - see qa_path() for other parameters * Redirect the user's web browser to $request and then we're done - see qa_path() for other parameters
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return mixed * @return mixed
*/ */
function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
...@@ -1801,7 +1812,7 @@ function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null ...@@ -1801,7 +1812,7 @@ function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null
/** /**
* Redirect the user's web browser to page $path which is already a URL * Redirect the user's web browser to page $path which is already a URL
* @param $url * @param string $url
* @return mixed * @return mixed
*/ */
function qa_redirect_raw($url) function qa_redirect_raw($url)
...@@ -1817,8 +1828,8 @@ function qa_redirect_raw($url) ...@@ -1817,8 +1828,8 @@ function qa_redirect_raw($url)
/** /**
* Return the contents of remote $url, using file_get_contents() if possible, otherwise curl functions * Return the contents of remote $url, using file_get_contents() if possible, otherwise curl functions
* @param $url * @param string $url
* @return mixed|string * @return bool|string
*/ */
function qa_retrieve_url($url) function qa_retrieve_url($url)
{ {
...@@ -1875,9 +1886,9 @@ function qa_service($key, $object = null) ...@@ -1875,9 +1886,9 @@ function qa_service($key, $object = null)
/** /**
* Shortcut to get or set an option value without specifying database * Shortcut to get or set an option value without specifying database
* @param $name * @param string $name
* @param mixed $value * @param mixed|null $value
* @return * @return string
*/ */
function qa_opt($name, $value = null) function qa_opt($name, $value = null)
{ {
...@@ -1898,7 +1909,7 @@ function qa_opt($name, $value = null) ...@@ -1898,7 +1909,7 @@ function qa_opt($name, $value = null)
/** /**
* Simple method to output a preformatted variable * Simple method to output a preformatted variable
* @param $var * @param mixed $var
*/ */
function qa_debug($var) function qa_debug($var)
{ {
...@@ -1925,12 +1936,12 @@ function qa_suspend_event_reports($suspend = true) ...@@ -1925,12 +1936,12 @@ function qa_suspend_event_reports($suspend = true)
/** /**
* Send a notification of event $event by $userid, $handle and $cookieid to all event modules, with extra $params * Send a notification of event $event by $userid, $handle and $cookieid to all event modules, with extra $params
* @param $event * @param string $event
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param array $params * @param array $params
* @return mixed|void * @return mixed
*/ */
function qa_report_event($event, $userid, $handle, $cookieid, $params = array()) function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
{ {
...@@ -1946,7 +1957,10 @@ function qa_report_event($event, $userid, $handle, $cookieid, $params = array()) ...@@ -1946,7 +1957,10 @@ function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
$eventmodule->process_event($event, $userid, $handle, $cookieid, $params); $eventmodule->process_event($event, $userid, $handle, $cookieid, $params);
} }
/**
* Execute the given $method in all process modules. Parameters can be sent as arguments.
* @param string $method
*/
function qa_report_process_stage($method) // can have extra params function qa_report_process_stage($method) // can have extra params
{ {
global $qa_process_reports_suspended; global $qa_process_reports_suspended;
......
...@@ -38,29 +38,60 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -38,29 +38,60 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
class qa_html_theme_base class qa_html_theme_base
{ {
/** @var string */
public $template; public $template;
/** @var array */
public $content; public $content;
/** @var string */
public $rooturl; public $rooturl;
/** @var string */
public $request; public $request;
public $isRTL; // (boolean) whether text direction is Right-To-Left
protected $minifyHtml; // (boolean) whether to indent the HTML /**
* Whether text direction is Right-To-Left
*
* @var bool
*/
public $isRTL;
/**
* Whether to indent the HTML
*
* @var bool
*/
protected $minifyHtml;
/** @var int */
protected $indent = 0; protected $indent = 0;
/** @var int */
protected $lines = 0; protected $lines = 0;
/** @var array */
protected $context = array(); protected $context = array();
// whether to use new block layout in rankings (true) or fall back to tables (false) /**
* Whether to use new block layout in rankings (true) or fall back to tables (false)
* @var bool
*/
protected $ranking_block_layout = false; protected $ranking_block_layout = false;
// theme 'slug' to use as CSS class
/**
* Theme 'slug' to use as CSS class
* @var string
*/
protected $theme; protected $theme;
/** /**
* Initialize the object and assign local variables. * Initialize the object and assign local variables.
* @param $template * @param string $template
* @param $content * @param string $content
* @param $rooturl * @param string $rooturl
* @param $request * @param string $request
*/ */
public function __construct($template, $content, $rooturl, $request) public function __construct($template, $content, $rooturl, $request)
{ {
...@@ -75,10 +106,10 @@ class qa_html_theme_base ...@@ -75,10 +106,10 @@ class qa_html_theme_base
/** /**
* @deprecated PHP4-style constructor deprecated from 1.7; please use proper `__construct` * @deprecated PHP4-style constructor deprecated from 1.7; please use proper `__construct`
* function instead. * function instead.
* @param $template * @param string $template
* @param $content * @param string $content
* @param $rooturl * @param string $rooturl
* @param $request * @param string $request
*/ */
public function qa_html_theme_base($template, $content, $rooturl, $request) public function qa_html_theme_base($template, $content, $rooturl, $request)
{ {
...@@ -90,7 +121,7 @@ class qa_html_theme_base ...@@ -90,7 +121,7 @@ class qa_html_theme_base
* Output each element in $elements on a separate line, with automatic HTML indenting. * Output each element in $elements on a separate line, with automatic HTML indenting.
* This should be passed markup which uses the <tag/> form for unpaired tags, to help keep * This should be passed markup which uses the <tag/> form for unpaired tags, to help keep
* track of indenting, although its actual output converts these to <tag> for W3C validation. * track of indenting, although its actual output converts these to <tag> for W3C validation.
* @param $elements * @param array $elements
*/ */
public function output_array($elements) public function output_array($elements)
{ {
...@@ -132,7 +163,7 @@ class qa_html_theme_base ...@@ -132,7 +163,7 @@ class qa_html_theme_base
/** /**
* Output $html at the current indent level, but don't change indent level based on the markup within. * Output $html at the current indent level, but don't change indent level based on the markup within.
* Useful for user-entered HTML which is unlikely to follow the rules we need to track indenting. * Useful for user-entered HTML which is unlikely to follow the rules we need to track indenting.
* @param $html * @param string $html
*/ */
public function output_raw($html) public function output_raw($html)
{ {
...@@ -144,8 +175,8 @@ class qa_html_theme_base ...@@ -144,8 +175,8 @@ class qa_html_theme_base
/** /**
* Output the three elements ['prefix'], ['data'] and ['suffix'] of $parts (if they're defined), * Output the three elements ['prefix'], ['data'] and ['suffix'] of $parts (if they're defined),
* with appropriate CSS classes based on $class, using $outertag and $innertag in the markup. * with appropriate CSS classes based on $class, using $outertag and $innertag in the markup.
* @param $parts * @param array $parts
* @param $class * @param string $class
* @param string $outertag * @param string $outertag
* @param string $innertag * @param string $innertag
* @param string $extraclass * @param string $extraclass
...@@ -167,8 +198,8 @@ class qa_html_theme_base ...@@ -167,8 +198,8 @@ class qa_html_theme_base
/** /**
* Set some context, which be accessed via $this->context for a function to know where it's being used on the page. * Set some context, which be accessed via $this->context for a function to know where it's being used on the page.
* @param $key * @param string $key
* @param $value * @param string $value
*/ */
public function set_context($key, $value) public function set_context($key, $value)
{ {
...@@ -178,7 +209,7 @@ class qa_html_theme_base ...@@ -178,7 +209,7 @@ class qa_html_theme_base
/** /**
* Clear some context (used at the end of the appropriate loop). * Clear some context (used at the end of the appropriate loop).
* @param $key * @param string $key
*/ */
public function clear_context($key) public function clear_context($key)
{ {
...@@ -189,8 +220,8 @@ class qa_html_theme_base ...@@ -189,8 +220,8 @@ class qa_html_theme_base
/** /**
* Reorder the parts of the page according to the $parts array which contains part keys in their new order. Call this * Reorder the parts of the page according to the $parts array which contains part keys in their new order. Call this
* before main_parts(). See the docs for qa_array_reorder() in util/sort.php for the other parameters. * before main_parts(). See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $parts * @param array $parts
* @param string $beforekey * @param string|null $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
public function reorder_parts($parts, $beforekey = null, $reorderrelative = true) public function reorder_parts($parts, $beforekey = null, $reorderrelative = true)
...@@ -203,8 +234,8 @@ class qa_html_theme_base ...@@ -203,8 +234,8 @@ class qa_html_theme_base
/** /**
* Output the widgets (as provided in $this->content['widgets']) for $region and $place. * Output the widgets (as provided in $this->content['widgets']) for $region and $place.
* @param $region * @param string $region
* @param $place * @param string $place
*/ */
public function widgets($region, $place) public function widgets($region, $place)
{ {
...@@ -1017,8 +1048,8 @@ class qa_html_theme_base ...@@ -1017,8 +1048,8 @@ class qa_html_theme_base
/** /**
* Reorder the fields of $form according to the $keys array which contains the field keys in their new order. Call * Reorder the fields of $form according to the $keys array which contains the field keys in their new order. Call
* before any fields are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters. * before any fields are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form * @param array
* @param $keys * @param array $keys
* @param mixed $beforekey * @param mixed $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
...@@ -1205,8 +1236,8 @@ class qa_html_theme_base ...@@ -1205,8 +1236,8 @@ class qa_html_theme_base
/** /**
* Reorder the buttons of $form according to the $keys array which contains the button keys in their new order. Call * Reorder the buttons of $form according to the $keys array which contains the button keys in their new order. Call
* before any buttons are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters. * before any buttons are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form * @param array $form
* @param $keys * @param array $keys
* @param mixed $beforekey * @param mixed $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
...@@ -1477,7 +1508,7 @@ class qa_html_theme_base ...@@ -1477,7 +1508,7 @@ class qa_html_theme_base
* removed in a future version. Themes can switch to the new layout by setting the member * removed in a future version. Themes can switch to the new layout by setting the member
* variable $ranking_block_layout to false. * variable $ranking_block_layout to false.
* @param $ranking * @param $ranking
* @param $class * @param string $class
*/ */
public function ranking_table($ranking, $class) public function ranking_table($ranking, $class)
{ {
...@@ -1507,7 +1538,7 @@ class qa_html_theme_base ...@@ -1507,7 +1538,7 @@ class qa_html_theme_base
/** /**
* @deprecated See ranking_table above. * @deprecated See ranking_table above.
* @param $item * @param $item
* @param $class * @param string $class
* @param $spacer * @param $spacer
*/ */
public function ranking_table_item($item, $class, $spacer) public function ranking_table_item($item, $class, $spacer)
...@@ -1535,7 +1566,7 @@ class qa_html_theme_base ...@@ -1535,7 +1566,7 @@ class qa_html_theme_base
/** /**
* @deprecated See ranking_table above. * @deprecated See ranking_table above.
* @param $class * @param string $class
*/ */
public function ranking_spacer($class) public function ranking_spacer($class)
{ {
...@@ -1897,8 +1928,8 @@ class qa_html_theme_base ...@@ -1897,8 +1928,8 @@ class qa_html_theme_base
/** /**
* @deprecated Deprecated from 1.7; please use avatar() instead. * @deprecated Deprecated from 1.7; please use avatar() instead.
* @param $post * @param array $post
* @param $class * @param string $class
* @param string $prefix * @param string $prefix
*/ */
public function post_avatar($post, $class, $prefix = null) public function post_avatar($post, $class, $prefix = null)
......
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