Commit f24542bb by Scott

Coding style (app posts/admin)

parent 5a94ef80
......@@ -20,18 +20,18 @@
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
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
}
function qa_admin_check_privileges(&$qa_content)
/*
Return true if user is logged in with admin privileges. If not, return false
and set up $qa_content with the appropriate title and error message
*/
{
/**
* Return true if user is logged in with admin privileges. If not, return false
* and set up $qa_content with the appropriate title and error message
*/
function qa_admin_check_privileges(&$qa_content)
{
if (!qa_is_logged_in()) {
require_once QA_INCLUDE_DIR.'app/format.php';
......@@ -52,14 +52,14 @@
}
return true;
}
}
/**
/**
* Return a sorted array of available languages, [short code] => [long name]
*/
function qa_admin_language_options()
{
function qa_admin_language_options()
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
/**
......@@ -133,14 +133,14 @@
asort($options, SORT_STRING);
return $options;
}
}
/**
/**
* Return a sorted array of available themes, [theme name] => [theme name]
*/
function qa_admin_theme_options()
{
function qa_admin_theme_options()
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$metadataUtil = new Q2A_Util_Metadata();
......@@ -157,14 +157,14 @@
asort($options, SORT_STRING);
return $options;
}
}
function qa_admin_place_options()
/*
Return an array of widget placement options, with keys matching the database value
*/
{
/**
* Return an array of widget placement options, with keys matching the database value
*/
function qa_admin_place_options()
{
return array(
'FT' => qa_lang_html('options/place_full_top'),
'FH' => qa_lang_html('options/place_full_below_nav'),
......@@ -179,14 +179,14 @@
'SL' => qa_lang_html('options/place_side_low'),
'SB' => qa_lang_html('options/place_side_last'),
);
}
}
function qa_admin_page_size_options($maximum)
/*
Return an array of page size options up to $maximum, [page size] => [page size]
*/
{
/**
* Return an array of page size options up to $maximum, [page size] => [page size]
*/
function qa_admin_page_size_options($maximum)
{
$rawoptions=array(5, 10, 15, 20, 25, 30, 40, 50, 60, 80, 100, 120, 150, 200, 250, 300, 400, 500, 600, 800, 1000);
$options=array();
......@@ -198,14 +198,14 @@
}
return $options;
}
}
function qa_admin_match_options()
/*
Return an array of options representing matching precision, [value] => [label]
*/
{
/**
* Return an array of options representing matching precision, [value] => [label]
*/
function qa_admin_match_options()
{
return array(
5 => qa_lang_html('options/match_5'),
4 => qa_lang_html('options/match_4'),
......@@ -213,15 +213,15 @@
2 => qa_lang_html('options/match_2'),
1 => qa_lang_html('options/match_1'),
);
}
}
function qa_admin_permit_options($widest, $narrowest, $doconfirms=true, $dopoints=true)
/*
Return an array of options representing permission restrictions, [value] => [label]
ranging from $widest to $narrowest. Set $doconfirms to whether email confirmations are on
*/
{
/**
* Return an array of options representing permission restrictions, [value] => [label]
* ranging from $widest to $narrowest. Set $doconfirms to whether email confirmations are on
*/
function qa_admin_permit_options($widest, $narrowest, $doconfirms=true, $dopoints=true)
{
require_once QA_INCLUDE_DIR.'app/options.php';
$options=array(
......@@ -260,14 +260,14 @@
}
return $options;
}
}
function qa_admin_sub_navigation()
/*
Return the sub navigation structure common to admin pages
*/
{
/**
* Return the sub navigation structure common to admin pages
*/
function qa_admin_sub_navigation()
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$navigation=array();
......@@ -399,14 +399,14 @@
}
return $navigation;
}
}
function qa_admin_page_error()
/*
Return the error that needs to displayed on all admin pages, or null if none
*/
{
/**
* Return the error that needs to displayed on all admin pages, or null if none
*/
function qa_admin_page_error()
{
if (file_exists(QA_INCLUDE_DIR.'db/install.php')) // file can be removed for extra security
include_once QA_INCLUDE_DIR.'db/install.php';
......@@ -425,23 +425,23 @@
else
return null;
}
}
function qa_admin_url_test_html()
/*
Return an HTML fragment to display for a URL test which has passed
*/
{
/**
* Return an HTML fragment to display for a URL test which has passed
*/
function qa_admin_url_test_html()
{
return '; font-size:9px; color:#060; font-weight:bold; font-family:arial,sans-serif; border-color:#060;">OK<';
}
}
function qa_admin_is_slug_reserved($requestpart)
/*
Returns whether a URL path beginning with $requestpart is reserved by the engine or a plugin page module
*/
{
/**
* Returns whether a URL path beginning with $requestpart is reserved by the engine or a plugin page module
*/
function qa_admin_is_slug_reserved($requestpart)
{
$requestpart=trim(strtolower($requestpart));
$routing=qa_page_routing();
......@@ -471,15 +471,15 @@
return true;
return false;
}
}
function qa_admin_single_click($entityid, $action)
/*
Returns true if admin (hidden/flagged/approve/moderate) page $action performed on $entityid is permitted by the
logged in user and was processed successfully
*/
{
/**
* Returns true if admin (hidden/flagged/approve/moderate) page $action performed on $entityid is permitted by the
* logged in user and was processed successfully
*/
function qa_admin_single_click($entityid, $action)
{
$userid=qa_get_logged_in_userid();
if ( (!QA_FINAL_EXTERNAL_USERS) && (($action=='userapprove') || ($action=='userblock')) ) { // approve/block moderated users
......@@ -561,14 +561,14 @@
}
return false;
}
}
function qa_admin_check_clicks()
/*
Checks for a POSTed click on an admin (hidden/flagged/approve/moderate) page, and refresh the page if processed successfully (non Ajax)
*/
{
/**
* Checks for a POSTed click on an admin (hidden/flagged/approve/moderate) page, and refresh the page if processed successfully (non Ajax)
*/
function qa_admin_check_clicks()
{
if (qa_is_http_post())
foreach ($_POST as $field => $value)
if (strpos($field, 'admin_')===0) {
......@@ -583,16 +583,16 @@
}
return null;
}
}
/**
/**
* Retrieve metadata information from the $contents of a qa-theme.php or qa-plugin.php file, mapping via $fields.
*
* @deprecated Deprecated from 1.7; use `qa_addon_metadata($contents, $type)` instead.
*/
function qa_admin_addon_metadata($contents, $fields)
{
function qa_admin_addon_metadata($contents, $fields)
{
$metadata=array();
foreach ($fields as $key => $field)
......@@ -600,43 +600,38 @@
$metadata[$key]=trim($matches[1]);
return $metadata;
}
}
/**
/**
* Return the hash code for the plugin in $directory (without trailing slash), used for in-page navigation on admin/plugins page
*/
function qa_admin_plugin_directory_hash($directory)
{
function qa_admin_plugin_directory_hash($directory)
{
$pluginManager = new Q2A_Plugin_PluginManager();
$hashes = $pluginManager->getHashesForPlugins(array($directory));
return reset($hashes);
}
}
/**
/**
* Return the URL (relative to the current page) to navigate to the options panel for the plugin in $directory (without trailing slash)
*/
function qa_admin_plugin_options_path($directory)
{
function qa_admin_plugin_options_path($directory)
{
$hash = qa_admin_plugin_directory_hash($directory);
return qa_path_html('admin/plugins', array('show' => $hash), null, null, $hash);
}
}
/**
/**
* Return the URL (relative to the current page) to navigate to the options panel for plugin module $name of $type
*/
function qa_admin_module_options_path($type, $name)
{
function qa_admin_module_options_path($type, $name)
{
$info = qa_get_module_info($type, $name);
$dir = rtrim($info['directory'], '/');
return qa_admin_plugin_options_path($dir);
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
}
......@@ -56,28 +56,28 @@
[but these are not entirely redundant since they can contain historical information no longer in ^posts]
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'db/recalc.php';
require_once QA_INCLUDE_DIR.'db/post-create.php';
require_once QA_INCLUDE_DIR.'db/points.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'db/admin.php';
require_once QA_INCLUDE_DIR.'db/users.php';
require_once QA_INCLUDE_DIR.'app/options.php';
require_once QA_INCLUDE_DIR.'app/post-create.php';
require_once QA_INCLUDE_DIR.'app/post-update.php';
function qa_recalc_perform_step(&$state)
/*
Advance the recalculation operation represented by $state by a single step.
$state can also be the name of a recalculation operation on its own.
*/
{
}
require_once QA_INCLUDE_DIR.'db/recalc.php';
require_once QA_INCLUDE_DIR.'db/post-create.php';
require_once QA_INCLUDE_DIR.'db/points.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'db/admin.php';
require_once QA_INCLUDE_DIR.'db/users.php';
require_once QA_INCLUDE_DIR.'app/options.php';
require_once QA_INCLUDE_DIR.'app/post-create.php';
require_once QA_INCLUDE_DIR.'app/post-update.php';
/**
* Advance the recalculation operation represented by $state by a single step.
* $state can also be the name of a recalculation operation on its own.
*/
function qa_recalc_perform_step(&$state)
{
$continue=false;
@list($operation, $length, $next, $done)=explode("\t", $state);
......@@ -528,27 +528,27 @@
$state=$operation."\t".$length."\t".$next."\t".$done;
return $continue && ($done<$length);
}
}
function qa_recalc_transition(&$state, $operation)
/*
Change the $state to represent the beginning of a new $operation
*/
{
/**
* Change the $state to represent the beginning of a new $operation
*/
function qa_recalc_transition(&$state, $operation)
{
$length=qa_recalc_stage_length($operation);
$next=(QA_FINAL_EXTERNAL_USERS && ($operation=='dorecalcpoints_recalc')) ? '' : 0;
$done=0;
$state=$operation."\t".$length."\t".$next."\t".$done;
}
}
function qa_recalc_stage_length($operation)
/*
Return how many steps there will be in recalculation $operation
*/
{
/**
* Return how many steps there will be in recalculation $operation
*/
function qa_recalc_stage_length($operation)
{
switch ($operation) {
case 'doreindexcontent_pagereindex':
$length=qa_db_count_pages();
......@@ -607,10 +607,10 @@
}
return $length;
}
}
/**
/**
* Return the translated language ID string replacing the progress and total in it.
* @access private
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
......@@ -620,20 +620,20 @@
* @return string Returns the language string ID with their placeholders replaced with
* the formatted progress and total numbers
*/
function qa_recalc_progress_lang($langId, $progress, $total)
{
function qa_recalc_progress_lang($langId, $progress, $total)
{
return strtr(qa_lang($langId), array(
'^1' => qa_format_number($progress),
'^2' => qa_format_number($total)
));
}
}
function qa_recalc_get_message($state)
/*
Return a string which gives a user-viewable version of $state
*/
{
/**
* Return a string which gives a user-viewable version of $state
*/
function qa_recalc_get_message($state)
{
require_once QA_INCLUDE_DIR . 'app/format.php';
@list($operation, $length, $next, $done) = explode("\t", $state);
......@@ -745,9 +745,4 @@
}
return $message;
}
/*
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