Commit 39b13f70 by Scott Vivian

Merge branch 'patch-12' of https://github.com/pupi1985/question2answer into pupi1985-patch-12

parents 0fbbd7bd 45a66c64
......@@ -487,15 +487,12 @@
break;
default: // call option_default method in any registered modules
$moduletypes=qa_list_module_types();
$modules = qa_load_all_modules_with('option_default'); // Loads all modules with the 'option_default' method
foreach ($moduletypes as $moduletype) {
$modules=qa_load_modules_with($moduletype, 'option_default');
foreach ($modules as $module) {
$value=$module->option_default($name);
if (strlen($value))
return $value;
foreach ($modules as $module) {
$value = $module->option_default($name);
if (strlen($value)) {
return $value;
}
}
......@@ -792,4 +789,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
......@@ -612,14 +612,30 @@
// Functions for listing, loading and getting info on modules
function qa_list_all_registered_modules_info()
/*
Return an array with all registered modules' information
*/
{
global $qa_modules;
return $qa_modules;
}
function qa_list_module_types()
/*
Return an array of all the module types for which at least one module has been registered
*/
{
global $qa_modules;
return array_keys($qa_modules);
return array_keys(qa_list_all_registered_modules_info());
}
function qa_list_module_types()
/*
Return an array of all the module types for which at least one module has been registered
*/
{
return array_keys(qa_list_all_registered_modules_info());
}
......@@ -628,9 +644,8 @@
Return a list of names of registered modules of $type
*/
{
global $qa_modules;
return is_array(@$qa_modules[$type]) ? array_keys($qa_modules[$type]) : array();
$modules = qa_list_all_registered_modules_info();
return is_array(@$modules[$type]) ? array_keys($modules[$type]) : array();
}
......@@ -639,8 +654,8 @@
Return an array containing information about the module of $type named $name
*/
{
global $qa_modules;
return @$qa_modules[$type][$name];
$modules = qa_list_all_registered_modules_info();
return @$modules[$type][$name];
}
......@@ -673,8 +688,29 @@
return null;
}
function qa_load_all_modules_with($method)
/*
Return an array of instantiated clases for modules which have defined $method
(all modules are loaded but not included in the returned array)
*/
{
$modules = array();
$registeredmodules = qa_list_all_registered_modules_info();
foreach ($registeredmodules as $moduletype => $modulesinfo) {
foreach ($modulesinfo as $modulename => $moduleinfo) {
$module = qa_load_module($moduletype, $modulename);
if (method_exists($module, $method))
$modules[$moduletype] = $module;
}
}
return $modules;
}
function qa_load_modules_with($type, $method)
/*
Return an array of instantiated clases for modules of $type which have defined $method
......@@ -1466,4 +1502,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
......@@ -852,8 +852,8 @@
// The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here
// The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...)
$answer=($question['postid']==$parent['postid']) ? null : $parent;
$parentid=$parent['postid'];
$parentid = $parent['postid'];
$answer = ($question['postid'] == $parentid) ? null : $parent;
switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) {
case 'login':
......
......@@ -201,16 +201,17 @@
function html()
{
$attribution = '<!-- Powered by Question2Answer - http://www.question2answer.org/ -->';
$this->output(
'<html>',
'<!-- Powered by Question2Answer - http://www.question2answer.org/ -->'
$attribution
);
$this->head();
$this->body();
$this->output(
'<!-- Powered by Question2Answer - http://www.question2answer.org/ -->',
$attribution,
'</html>'
);
}
......@@ -260,10 +261,8 @@
if (isset($this->content['page_links']['items'])) // convert page links to rel=prev and rel=next tags
foreach ($this->content['page_links']['items'] as $page_link)
if ($page_link['type']=='prev')
$this->output('<link rel="prev" href="'.$page_link['url'].'"/>');
elseif ($page_link['type']=='next')
$this->output('<link rel="next" href="'.$page_link['url'].'"/>');
if (in_array($page_link['type'], array('prev', 'next')))
$this->output('<link rel="' . $page_link['type'] . '" href="' . $page_link['url'] . '" />');
}
function head_script()
......@@ -312,11 +311,11 @@
$this->body_tags();
$this->output('>');
$this->body_script();
$this->body_header();
$this->body_content();
$this->body_footer();
$this->body_hidden();
$this->body_script();
$this->output('</body>');
}
......@@ -934,10 +933,11 @@
$tworows=($columns==1) && (!empty($field['label'])) && (!$skipdata) &&
( (!($prefixed||$suffixed)) || (!empty($field['error'])) || (!empty($field['note'])) );
if (($columns==1) && isset($field['id']))
$this->output('<tbody id="'.$field['id'].'">', '<tr>');
elseif (isset($field['id']))
$this->output('<tr id="'.$field['id'].'">');
if (isset($field['id']))
if ($columns == 1)
$this->output('<tbody id="'.$field['id'].'">', '<tr>');
else
$this->output('<tr id="'.$field['id'].'">');
else
$this->output('<tr>');
......@@ -2211,4 +2211,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
......@@ -34,18 +34,7 @@
function allow_region($region)
{
$allow=false;
switch ($region)
{
case 'main':
case 'side':
case 'full':
$allow=true;
break;
}
return $allow;
return in_array($region, array('main', 'side', 'full'));
}
......
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