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