Commit c1b82ae1 by Scott

Coding style (plugins)

parent 936231ab
......@@ -30,7 +30,7 @@ class qa_event_limits
if (isset($params['delayed']))
return;
require_once QA_INCLUDE_DIR.'app/limits.php';
require_once QA_INCLUDE_DIR . 'app/limits.php';
switch ($event) {
case 'q_queue':
......@@ -76,7 +76,7 @@ class qa_event_limits
break;
}
$writeactions=array(
$writeactions = array(
'_approve', '_claim', '_clearflags', '_delete', '_edit', '_favorite', '_flag', '_hide',
'_post', '_queue', '_reject', '_reshow', '_unfavorite', '_unflag', '_vote_down', '_vote_nil', '_vote_up',
'a_select', 'a_to_c', 'a_unselect',
......
......@@ -27,8 +27,8 @@ class qa_event_updates
if (@$params['silent']) // don't create updates about silent edits, and possibly other silent events in future
return;
require_once QA_INCLUDE_DIR.'db/events.php';
require_once QA_INCLUDE_DIR.'app/events.php';
require_once QA_INCLUDE_DIR . 'db/events.php';
require_once QA_INCLUDE_DIR . 'app/events.php';
switch ($event) {
case 'q_post':
......@@ -47,44 +47,46 @@ class qa_event_updates
case 'c_post':
$keyuserids=array();
$keyuserids = array();
foreach ($params['thread'] as $comment) // previous comments in thread (but not author of parent again)
{
if (isset($comment['userid']))
$keyuserids[$comment['userid']]=true;
$keyuserids[$comment['userid']] = true;
}
foreach ($keyuserids as $keyuserid => $dummy)
foreach ($keyuserids as $keyuserid => $dummy) {
if ($keyuserid != $userid)
qa_db_event_create_not_entity($keyuserid, $params['questionid'], $params['postid'], QA_UPDATE_FOLLOWS, $userid);
}
switch ($params['parent']['basetype'])
{
switch ($params['parent']['basetype']) {
case 'Q':
$updatetype=QA_UPDATE_C_FOR_Q;
$updatetype = QA_UPDATE_C_FOR_Q;
break;
case 'A':
$updatetype=QA_UPDATE_C_FOR_A;
$updatetype = QA_UPDATE_C_FOR_A;
break;
default:
$updatetype=null;
$updatetype = null;
break;
}
// give precedence to 'your comment followed' rather than 'your Q/A commented' if both are true
qa_create_event_for_q_user($params['questionid'], $params['postid'], $updatetype, $userid,
@$keyuserids[$params['parent']['userid']] ? null : $params['parent']['userid']);
// give precedence to 'your comment followed' rather than 'your Q/A commented' if both are true
break;
case 'q_edit':
if ($params['titlechanged'] || $params['contentchanged'])
$updatetype=QA_UPDATE_CONTENT;
$updatetype = QA_UPDATE_CONTENT;
elseif ($params['tagschanged'])
$updatetype=QA_UPDATE_TAGS;
$updatetype = QA_UPDATE_TAGS;
else
$updatetype=null;
$updatetype = null;
if (isset($updatetype)) {
qa_create_event_for_q_user($params['postid'], $params['postid'], $updatetype, $userid, $params['oldquestion']['userid']);
......
......@@ -82,11 +82,9 @@ class qa_filter_basic
if ($counttags < $mintags) {
$errors['tags'] = qa_lang_sub('question/min_tags_x', $mintags);
}
elseif ($counttags > $maxtags) {
} elseif ($counttags > $maxtags) {
$errors['tags'] = qa_lang_sub('question/max_tags_x', $maxtags);
}
else {
} else {
$tagstring = qa_tags_to_tagstring($question['tags']);
if (qa_strlen($tagstring) > QA_DB_MAX_TAGS_LENGTH) { // for storage
$errors['tags'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_TAGS_LENGTH);
......@@ -115,7 +113,7 @@ class qa_filter_basic
{
foreach (array_keys($profile) as $field) {
// ensure fields are not NULL
$profile[$field] = (string) $profile[$field];
$profile[$field] = (string)$profile[$field];
$this->validate_field_length($errors, $profile, $field, 0, QA_DB_MAX_CONTENT_LENGTH);
}
}
......@@ -141,13 +139,13 @@ class qa_filter_basic
/**
* Check that a field meets the length requirements. If we're editing the post we can ignore missing fields.
*
* @param array $errors Array of errors, with keys matching $post
* @param array $post The post containing the field we want to validate
* @param string $key The element of $post to validate
* @param array $errors Array of errors, with keys matching $post
* @param array $post The post containing the field we want to validate
* @param string $key The element of $post to validate
* @param int $minlength
* @param int $maxlength
*/
private function validate_field_length(&$errors, &$post, $key, $minlength, $maxlength, $errorKey=null)
private function validate_field_length(&$errors, &$post, $key, $minlength, $maxlength, $errorKey = null)
{
if (!$errorKey) {
$errorKey = $key;
......@@ -159,8 +157,7 @@ class qa_filter_basic
if ($length < $minlength) {
$errors[$errorKey] = $minlength == 1 ? qa_lang('main/field_required') : qa_lang_sub('main/min_length_x', $minlength);
}
else if (isset($maxlength) && ($length > $maxlength)) {
} else if (isset($maxlength) && ($length > $maxlength)) {
$errors[$errorKey] = qa_lang_sub('main/max_length_x', $maxlength);
}
}
......
......@@ -183,23 +183,27 @@ class qa_html_theme_layer extends qa_html_theme_base
$postids = array_keys($this->qa_voters_flaggers_queue);
foreach ($postids as $postid)
foreach ($postids as $postid) {
$this->qa_voters_flaggers_cache[$postid] = array();
}
$newvotersflaggers = qa_db_uservoteflag_posts_get($postids);
if (QA_FINAL_EXTERNAL_USERS) {
$keyuserids = array();
foreach ($newvotersflaggers as $voterflagger)
foreach ($newvotersflaggers as $voterflagger) {
$keyuserids[$voterflagger['userid']] = true;
}
$useridhandles = qa_get_public_from_userids(array_keys($keyuserids));
foreach ($newvotersflaggers as $index => $voterflagger)
foreach ($newvotersflaggers as $index => $voterflagger) {
$newvotersflaggers[$index]['handle'] = isset($useridhandles[$voterflagger['userid']]) ? $useridhandles[$voterflagger['userid']] : null;
}
}
foreach ($newvotersflaggers as $voterflagger)
foreach ($newvotersflaggers as $voterflagger) {
$this->qa_voters_flaggers_cache[$voterflagger['postid']][] = $voterflagger;
}
$this->qa_voters_flaggers_queue = array();
}
......
......@@ -24,42 +24,43 @@ class qa_search_basic
{
public function index_post($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid)
{
require_once QA_INCLUDE_DIR.'db/post-create.php';
require_once QA_INCLUDE_DIR . 'db/post-create.php';
// Get words from each textual element
$titlewords=array_unique(qa_string_to_words($title));
$contentcount=array_count_values(qa_string_to_words($text));
$tagwords=array_unique(qa_string_to_words($tagstring));
$wholetags=array_unique(qa_tagstring_to_tags($tagstring));
$titlewords = array_unique(qa_string_to_words($title));
$contentcount = array_count_values(qa_string_to_words($text));
$tagwords = array_unique(qa_string_to_words($tagstring));
$wholetags = array_unique(qa_tagstring_to_tags($tagstring));
// Map all words to their word IDs
$words=array_unique(array_merge($titlewords, array_keys($contentcount), $tagwords, $wholetags));
$wordtoid=qa_db_word_mapto_ids_add($words);
$words = array_unique(array_merge($titlewords, array_keys($contentcount), $tagwords, $wholetags));
$wordtoid = qa_db_word_mapto_ids_add($words);
// Add to title words index
$titlewordids=qa_array_filter_by_keys($wordtoid, $titlewords);
$titlewordids = qa_array_filter_by_keys($wordtoid, $titlewords);
qa_db_titlewords_add_post_wordids($postid, $titlewordids);
// Add to content words index (including word counts)
$contentwordidcounts=array();
foreach ($contentcount as $word => $count)
$contentwordidcounts = array();
foreach ($contentcount as $word => $count) {
if (isset($wordtoid[$word]))
$contentwordidcounts[$wordtoid[$word]]=$count;
$contentwordidcounts[$wordtoid[$word]] = $count;
}
qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $contentwordidcounts);
// Add to tag words index
$tagwordids=qa_array_filter_by_keys($wordtoid, $tagwords);
$tagwordids = qa_array_filter_by_keys($wordtoid, $tagwords);
qa_db_tagwords_add_post_wordids($postid, $tagwordids);
// Add to whole tags index
$wholetagids=qa_array_filter_by_keys($wordtoid, $wholetags);
$wholetagids = qa_array_filter_by_keys($wordtoid, $wholetags);
qa_db_posttags_add_post_wordids($postid, $wholetagids);
// Update counts cached in database (will be skipped if qa_suspend_update_counts() was called
......@@ -73,21 +74,21 @@ class qa_search_basic
public function unindex_post($postid)
{
require_once QA_INCLUDE_DIR.'db/post-update.php';
require_once QA_INCLUDE_DIR . 'db/post-update.php';
$titlewordids=qa_db_titlewords_get_post_wordids($postid);
$titlewordids = qa_db_titlewords_get_post_wordids($postid);
qa_db_titlewords_delete_post($postid);
qa_db_word_titlecount_update($titlewordids);
$contentwordids=qa_db_contentwords_get_post_wordids($postid);
$contentwordids = qa_db_contentwords_get_post_wordids($postid);
qa_db_contentwords_delete_post($postid);
qa_db_word_contentcount_update($contentwordids);
$tagwordids=qa_db_tagwords_get_post_wordids($postid);
$tagwordids = qa_db_tagwords_get_post_wordids($postid);
qa_db_tagwords_delete_post($postid);
qa_db_word_tagwordcount_update($tagwordids);
$wholetagids=qa_db_posttags_get_post_wordids($postid);
$wholetagids = qa_db_posttags_get_post_wordids($postid);
qa_db_posttags_delete_post($postid);
qa_db_word_tagcount_update($wholetagids);
}
......@@ -109,21 +110,21 @@ class qa_search_basic
public function process_search($query, $start, $count, $userid, $absoluteurls, $fullcontent)
{
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'util/string.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
$words=qa_string_to_words($query);
$words = qa_string_to_words($query);
$questions=qa_db_select_with_pending(
$questions = qa_db_select_with_pending(
qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($query), $start, $fullcontent, $count)
);
$results=array();
$results = array();
foreach ($questions as $question) {
qa_search_set_max_match($question, $type, $postid); // to link straight to best part
$results[]=array(
$results[] = array(
'question' => $question,
'match_type' => $type,
'match_postid' => $postid,
......
......@@ -28,14 +28,14 @@ class qa_viewer_basic
public function load_module($localdir, $htmldir)
{
$this->htmllineseparators='br|option';
$this->htmlparagraphseparators='address|applet|blockquote|center|cite|col|div|dd|dl|dt|embed|form|frame|frameset|h1|h2|h3|h4|h5|h6'.
$this->htmllineseparators = 'br|option';
$this->htmlparagraphseparators = 'address|applet|blockquote|center|cite|col|div|dd|dl|dt|embed|form|frame|frameset|h1|h2|h3|h4|h5|h6' .
'|hr|iframe|input|li|marquee|ol|p|pre|samp|select|spacer|table|tbody|td|textarea|tfoot|th|thead|tr|ul';
}
public function calc_quality($content, $format)
{
if ( ($format=='') || ($format=='html') )
if ($format == '' || $format == 'html')
return 1.0;
return 0.0001; // if there's nothing better this will give an error message for unknown formats
......@@ -43,104 +43,102 @@ class qa_viewer_basic
public function get_html($content, $format, $options)
{
if ($format=='html') {
$html=qa_sanitize_html($content, @$options['linksnewwindow'], false); // sanitize again for display, for extra safety, and due to new window setting
if ($format == 'html') {
$html = qa_sanitize_html($content, @$options['linksnewwindow'], false); // sanitize again for display, for extra safety, and due to new window setting
if (isset($options['blockwordspreg'])) { // filtering out blocked words inline within HTML is pretty complex, e.g. p<b>oo</b>p must be caught
require_once QA_INCLUDE_DIR.'util/string.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
$html=preg_replace('/<\s*('.$this->htmllineseparators.')[^A-Za-z0-9]/i', "\n\\0", $html); // tags to single new line
$html=preg_replace('/<\s*('.$this->htmlparagraphseparators.')[^A-Za-z0-9]/i', "\n\n\\0", $html); // tags to double new line
$html = preg_replace('/<\s*(' . $this->htmllineseparators . ')[^A-Za-z0-9]/i', "\n\\0", $html); // tags to single new line
$html = preg_replace('/<\s*(' . $this->htmlparagraphseparators . ')[^A-Za-z0-9]/i', "\n\n\\0", $html); // tags to double new line
preg_match_all('/<[^>]*>/', $html, $pregmatches, PREG_OFFSET_CAPTURE); // find tag positions and lengths
$tagmatches=$pregmatches[0];
$text=preg_replace('/<[^>]*>/', '', $html); // effectively strip_tags() but use same regexp as above to ensure consistency
$tagmatches = $pregmatches[0];
$text = preg_replace('/<[^>]*>/', '', $html); // effectively strip_tags() but use same regexp as above to ensure consistency
$blockmatches=qa_block_words_match_all($text, $options['blockwordspreg']); // search for blocked words within text
$blockmatches = qa_block_words_match_all($text, $options['blockwordspreg']); // search for blocked words within text
$nexttagmatch=array_shift($tagmatches);
$texttohtml=0;
$htmlshift=0;
$nexttagmatch = array_shift($tagmatches);
$texttohtml = 0;
$htmlshift = 0;
foreach ($blockmatches as $textoffset => $textlength) {
while ( isset($nexttagmatch) && ($nexttagmatch[1]<=($textoffset+$texttohtml)) ) { // keep text and html in sync
$texttohtml+=strlen($nexttagmatch[0]);
$nexttagmatch=array_shift($tagmatches);
while (isset($nexttagmatch) && ($nexttagmatch[1] <= ($textoffset + $texttohtml))) { // keep text and html in sync
$texttohtml += strlen($nexttagmatch[0]);
$nexttagmatch = array_shift($tagmatches);
}
while (1) {
$replacepart=$textlength;
$replacepart = $textlength;
if (isset($nexttagmatch))
$replacepart=min($replacepart, $nexttagmatch[1]-($textoffset+$texttohtml)); // stop replacing early if we hit an HTML tag
$replacepart = min($replacepart, $nexttagmatch[1] - ($textoffset + $texttohtml)); // stop replacing early if we hit an HTML tag
$replacelength=qa_strlen(substr($text, $textoffset, $replacepart)); // to work with multi-byte characters
$replacelength = qa_strlen(substr($text, $textoffset, $replacepart)); // to work with multi-byte characters
$html=substr_replace($html, str_repeat('*', $replacelength), $textoffset+$texttohtml+$htmlshift, $replacepart);
$htmlshift+=$replacelength-$replacepart; // HTML might have moved around if we replaced multi-byte characters
$html = substr_replace($html, str_repeat('*', $replacelength), $textoffset + $texttohtml + $htmlshift, $replacepart);
$htmlshift += $replacelength - $replacepart; // HTML might have moved around if we replaced multi-byte characters
if ($replacepart>=$textlength)
if ($replacepart >= $textlength)
break; // we have replaced everything expected, otherwise more left (due to hitting an HTML tag)
$textlength-=$replacepart;
$textoffset+=$replacepart;
$texttohtml+=strlen($nexttagmatch[0]);
$nexttagmatch=array_shift($tagmatches);
$textlength -= $replacepart;
$textoffset += $replacepart;
$texttohtml += strlen($nexttagmatch[0]);
$nexttagmatch = array_shift($tagmatches);
}
}
}
if (@$options['showurllinks']) { // we need to ensure here that we don't put new links inside existing ones
require_once QA_INCLUDE_DIR.'util/string.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
$htmlunlinkeds=array_reverse(preg_split('|<[Aa]\s+[^>]+>.*</[Aa]\s*>|', $html, -1, PREG_SPLIT_OFFSET_CAPTURE)); // start from end so we substitute correctly
$htmlunlinkeds = array_reverse(preg_split('|<[Aa]\s+[^>]+>.*</[Aa]\s*>|', $html, -1, PREG_SPLIT_OFFSET_CAPTURE)); // start from end so we substitute correctly
foreach ($htmlunlinkeds as $htmlunlinked) { // and that we don't detect links inside HTML, e.g. <img src="http://...">
$thishtmluntaggeds=array_reverse(preg_split('/<[^>]*>/', $htmlunlinked[0], -1, PREG_SPLIT_OFFSET_CAPTURE)); // again, start from end
$thishtmluntaggeds = array_reverse(preg_split('/<[^>]*>/', $htmlunlinked[0], -1, PREG_SPLIT_OFFSET_CAPTURE)); // again, start from end
foreach ($thishtmluntaggeds as $thishtmluntagged) {
$innerhtml=$thishtmluntagged[0];
$innerhtml = $thishtmluntagged[0];
if (is_numeric(strpos($innerhtml, '://'))) { // quick test first
$newhtml=qa_html_convert_urls($innerhtml, qa_opt('links_in_new_window'));
$newhtml = qa_html_convert_urls($innerhtml, qa_opt('links_in_new_window'));
$html=substr_replace($html, $newhtml, $htmlunlinked[1]+$thishtmluntagged[1], strlen($innerhtml));
$html = substr_replace($html, $newhtml, $htmlunlinked[1] + $thishtmluntagged[1], strlen($innerhtml));
}
}
}
}
}
elseif ($format=='') {
} elseif ($format == '') {
if (isset($options['blockwordspreg'])) {
require_once QA_INCLUDE_DIR.'util/string.php';
$content=qa_block_words_replace($content, $options['blockwordspreg']);
require_once QA_INCLUDE_DIR . 'util/string.php';
$content = qa_block_words_replace($content, $options['blockwordspreg']);
}
$html=qa_html($content, true);
$html = qa_html($content, true);
if (@$options['showurllinks']) {
require_once QA_INCLUDE_DIR.'app/format.php';
$html=qa_html_convert_urls($html, qa_opt('links_in_new_window'));
require_once QA_INCLUDE_DIR . 'app/format.php';
$html = qa_html_convert_urls($html, qa_opt('links_in_new_window'));
}
}
else
$html='[no viewer found for format: '.qa_html($format).']'; // for unknown formats
} else
$html = '[no viewer found for format: ' . qa_html($format) . ']'; // for unknown formats
return $html;
}
public function get_text($content, $format, $options)
{
if ($format=='html') {
$text=strtr($content, "\n\r\t", ' '); // convert all white space in HTML to spaces
$text=preg_replace('/<\s*('.$this->htmllineseparators.')[^A-Za-z0-9]/i', "\n\\0", $text); // tags to single new line
$text=preg_replace('/<\s*('.$this->htmlparagraphseparators.')[^A-Za-z0-9]/i', "\n\n\\0", $text); // tags to double new line
$text=strip_tags($text); // all tags removed
$text=preg_replace('/ +/', ' ', $text); // combine multiple spaces into one
$text=preg_replace('/ *\n */', "\n", $text); // remove spaces either side new lines
$text=preg_replace('/\n\n\n+/', "\n\n", $text); // more than two new lines combine into two
$text=strtr($text, array(
if ($format == 'html') {
$text = strtr($content, "\n\r\t", ' '); // convert all white space in HTML to spaces
$text = preg_replace('/<\s*(' . $this->htmllineseparators . ')[^A-Za-z0-9]/i', "\n\\0", $text); // tags to single new line
$text = preg_replace('/<\s*(' . $this->htmlparagraphseparators . ')[^A-Za-z0-9]/i', "\n\n\\0", $text); // tags to double new line
$text = strip_tags($text); // all tags removed
$text = preg_replace('/ +/', ' ', $text); // combine multiple spaces into one
$text = preg_replace('/ *\n */', "\n", $text); // remove spaces either side new lines
$text = preg_replace('/\n\n\n+/', "\n\n", $text); // more than two new lines combine into two
$text = strtr($text, array(
'&#34;' => "\x22",
'&#38;' => "\x26",
'&#39;' => "\x27",
......@@ -153,17 +151,16 @@ class qa_viewer_basic
'&gt;' => "\x3E",
)); // base HTML entities (others should not be stored in database)
$text=trim($text);
$text = trim($text);
}
elseif ($format=='')
$text=$content;
} elseif ($format == '')
$text = $content;
else
$text='[no viewer found for format: '.$format.']'; // for unknown formats
$text = '[no viewer found for format: ' . $format . ']'; // for unknown formats
if (isset($options['blockwordspreg'])) {
require_once QA_INCLUDE_DIR.'util/string.php';
$text=qa_block_words_replace($text, $options['blockwordspreg']);
require_once QA_INCLUDE_DIR . 'util/string.php';
$text = qa_block_words_replace($text, $options['blockwordspreg']);
}
return $text;
......
......@@ -29,7 +29,7 @@ class qa_activity_count
public function allow_region($region)
{
return ($region=='side');
return ($region == 'side');
}
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
......@@ -53,10 +53,10 @@ class qa_activity_count
$themeobject->output('<p class="qa-activity-count-item">');
if ($value==1)
if ($value == 1)
$themeobject->output(qa_lang_html_sub($langsingular, '<span class="qa-activity-count-data">1</span>', '1'));
else
$themeobject->output(qa_lang_html_sub($langplural, '<span class="qa-activity-count-data">'.qa_format_number((int) $value, 0, true).'</span>'));
$themeobject->output(qa_lang_html_sub($langplural, '<span class="qa-activity-count-data">' . qa_format_number((int)$value, 0, true) . '</span>'));
$themeobject->output('</p>');
}
......
......@@ -26,7 +26,7 @@ class qa_ask_box
{
$allowed = array(
'activity', 'categories', 'custom', 'feedback', 'qa', 'questions',
'hot', 'search', 'tag', 'tags', 'unanswered'
'hot', 'search', 'tag', 'tags', 'unanswered',
);
return in_array($template, $allowed);
}
......@@ -39,9 +39,10 @@ class qa_ask_box
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
if (isset($qa_content['categoryids']))
$params=array('cat' => end($qa_content['categoryids']));
$params = array('cat' => end($qa_content['categoryids']));
else
$params=null;
$params = null;
?>
<div class="qa-ask-box">
<form method="post" action="<?php echo qa_path_html('ask', $params); ?>">
......@@ -50,14 +51,10 @@ class qa_ask_box
<td class="qa-form-tall-label" style="padding:8px; white-space:nowrap; <?php echo ($region=='side') ? 'padding-bottom:0;' : 'text-align:right;'?>" width="1">
<?php echo strtr(qa_lang_html('question/ask_title'), array(' ' => '&nbsp;'))?>:
</td>
<?php
if ($region=='side') {
?>
<?php if ($region=='side') : ?>
</tr>
<tr>
<?php
}
?>
<?php endif; ?>
<td class="qa-form-tall-data" style="padding:8px;" width="*">
<input name="title" type="text" class="qa-form-tall-text" style="width:95%;">
</td>
......
......@@ -40,8 +40,7 @@ class qa_category_list
if (isset($qa_content['navigation']['cat'])) {
$nav = $qa_content['navigation']['cat'];
}
else {
} else {
$selectspec = qa_db_category_nav_selectspec(null, true, false, true);
$selectspec['caching'] = array(
'key' => 'qa_db_category_nav_selectspec:default:full',
......@@ -51,7 +50,7 @@ class qa_category_list
$nav = qa_category_navigation($navcategories);
}
$this->themeobject->output('<h2>'.qa_lang_html('main/nav_categories').'</h2>');
$this->themeobject->output('<h2>' . qa_lang_html('main/nav_categories') . '</h2>');
$this->themeobject->set_context('nav_type', 'cat');
$this->themeobject->nav_list($nav, 'nav-cat', 1);
$this->themeobject->nav_clear('cat');
......
......@@ -34,7 +34,7 @@ class qa_related_qs
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
if (!isset($qa_content['q_view']['raw']['type']) || $qa_content['q_view']['raw']['type'] != 'Q') // question might not be visible, etc...
return;
......@@ -67,11 +67,11 @@ class qa_related_qs
foreach ($questions as $question) {
$themeobject->output(
'<li class="qa-related-q-item">' .
'<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' .
qa_html($question['title']) .
'</a>' .
'</li>'
'<li class="qa-related-q-item">' .
'<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' .
qa_html($question['title']) .
'</a>' .
'</li>'
);
}
......@@ -99,8 +99,9 @@ class qa_related_qs
$defaults = qa_post_html_defaults('Q');
$usershtml = qa_userids_handles_html($questions);
foreach ($questions as $question)
foreach ($questions as $question) {
$q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, qa_post_html_options($question, $defaults));
}
$themeobject->q_list_and_form($q_list);
}
......
......@@ -25,26 +25,26 @@ class qa_event_logger
public function init_queries($table_list)
{
if (qa_opt('event_logger_to_database')) {
$tablename=qa_db_add_table_prefix('eventlog');
$tablename = qa_db_add_table_prefix('eventlog');
if (!in_array($tablename, $table_list)) {
// table does not exist, so create it
require_once QA_INCLUDE_DIR.'app/users.php';
require_once QA_INCLUDE_DIR.'db/maxima.php';
return 'CREATE TABLE ^eventlog ('.
'datetime DATETIME NOT NULL,'.
'ipaddress VARCHAR (45) CHARACTER SET ascii,'.
'userid '.qa_get_mysql_user_column_type().','.
'handle VARCHAR('.QA_DB_MAX_HANDLE_LENGTH.'),'.
'cookieid BIGINT UNSIGNED,'.
'event VARCHAR (20) CHARACTER SET ascii NOT NULL,'.
'params VARCHAR (800) NOT NULL,'.
'KEY datetime (datetime),'.
'KEY ipaddress (ipaddress),'.
'KEY userid (userid),'.
'KEY event (event)'.
') ENGINE=MyISAM DEFAULT CHARSET=utf8';
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'db/maxima.php';
return 'CREATE TABLE ^eventlog (' .
'datetime DATETIME NOT NULL,' .
'ipaddress VARCHAR (45) CHARACTER SET ascii,' .
'userid ' . qa_get_mysql_user_column_type() . ',' .
'handle VARCHAR(' . QA_DB_MAX_HANDLE_LENGTH . '),' .
'cookieid BIGINT UNSIGNED,' .
'event VARCHAR (20) CHARACTER SET ascii NOT NULL,' .
'params VARCHAR (800) NOT NULL,' .
'KEY datetime (datetime),' .
'KEY ipaddress (ipaddress),' .
'KEY userid (userid),' .
'KEY event (event)' .
') ENGINE=MyISAM DEFAULT CHARSET=utf8';
} else {
// table exists: check it has the correct schema
$column = qa_db_read_one_assoc(qa_db_query_sub('SHOW COLUMNS FROM ^eventlog WHERE Field="ipaddress"'));
......@@ -61,10 +61,9 @@ class qa_event_logger
public function admin_form(&$qa_content)
{
// Process form input
// Process form input
$saved=false;
$saved = false;
if (qa_clicked('event_logger_save_button')) {
qa_opt('event_logger_to_database', (int)qa_post_text('event_logger_to_database_field'));
......@@ -72,26 +71,26 @@ class qa_event_logger
qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field'));
qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field'));
$saved=true;
$saved = true;
}
// Check the validity of the currently entered directory (if any)
// Check the validity of the currently entered directory (if any)
$directory=qa_opt('event_logger_directory');
$directory = qa_opt('event_logger_directory');
$note=null;
$error=null;
$note = null;
$error = null;
if (!strlen($directory))
$note='Please specify a directory that is writable by the web server.';
$note = 'Please specify a directory that is writable by the web server.';
elseif (!file_exists($directory))
$error='This directory cannot be found. Please enter the full path.';
$error = 'This directory cannot be found. Please enter the full path.';
elseif (!is_dir($directory))
$error='This is a file. Please enter the full path of a directory.';
$error = 'This is a file. Please enter the full path of a directory.';
elseif (!is_writable($directory))
$error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';
$error = 'This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';
// Create the form for display
// Create the form for display
qa_set_display_rules($qa_content, array(
'event_logger_directory_display' => 'event_logger_to_files_field',
......@@ -103,7 +102,7 @@ class qa_event_logger
'fields' => array(
array(
'label' => 'Log events to <code>'.QA_MYSQL_TABLE_PREFIX.'eventlog</code> database table',
'label' => 'Log events to <code>' . QA_MYSQL_TABLE_PREFIX . 'eventlog</code> database table',
'tags' => 'name="event_logger_to_database_field"',
'value' => qa_opt('event_logger_to_database'),
'type' => 'checkbox',
......@@ -147,11 +146,11 @@ class qa_event_logger
public function value_to_text($value)
{
if (is_array($value))
$text='array('.count($value).')';
elseif (strlen($value)>40)
$text=substr($value, 0, 38).'...';
$text = 'array(' . count($value) . ')';
elseif (strlen($value) > 40)
$text = substr($value, 0, 38) . '...';
else
$text=$value;
$text = $value;
return strtr($text, "\t\n\r", ' ');
}
......@@ -160,13 +159,14 @@ class qa_event_logger
public function process_event($event, $userid, $handle, $cookieid, $params)
{
if (qa_opt('event_logger_to_database')) {
$paramstring='';
$paramstring = '';
foreach ($params as $key => $value)
$paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value);
foreach ($params as $key => $value) {
$paramstring .= (strlen($paramstring) ? "\t" : '') . $key . '=' . $this->value_to_text($value);
}
qa_db_query_sub(
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) ' .
'VALUES (NOW(), $, $, $, #, $, $)',
qa_remote_ip_address(), $userid, $handle, $cookieid, $event, $paramstring
);
......@@ -174,24 +174,24 @@ class qa_event_logger
if (qa_opt('event_logger_to_files')) {
// Substitute some placeholders if certain information is missing
// Substitute some placeholders if certain information is missing
if (!strlen($userid))
$userid='no_userid';
$userid = 'no_userid';
if (!strlen($handle))
$handle='no_handle';
$handle = 'no_handle';
if (!strlen($cookieid))
$cookieid='no_cookieid';
$cookieid = 'no_cookieid';
$ip=qa_remote_ip_address();
$ip = qa_remote_ip_address();
if (!strlen($ip))
$ip='no_ipaddress';
$ip = 'no_ipaddress';
// Build the log file line to be written
// Build the log file line to be written
$fixedfields=array(
$fixedfields = array(
'Date' => date('Y\-m\-d'),
'Time' => date('H\:i\:s'),
'IPaddress' => $ip,
......@@ -201,36 +201,38 @@ class qa_event_logger
'Event' => $event,
);
$fields=$fixedfields;
$fields = $fixedfields;
foreach ($params as $key => $value)
$fields['param_'.$key]=$key.'='.$this->value_to_text($value);
foreach ($params as $key => $value) {
$fields['param_' . $key] = $key . '=' . $this->value_to_text($value);
}
$string=implode("\t", $fields);
$string = implode("\t", $fields);
// Build the full path and file name
// Build the full path and file name
$directory=qa_opt('event_logger_directory');
$directory = qa_opt('event_logger_directory');
if (substr($directory, -1)!='/')
$directory.='/';
if (substr($directory, -1) != '/')
$directory .= '/';
$filename=$directory.'q2a-log-'.date('Y\-m\-d').'.txt';
$filename = $directory . 'q2a-log-' . date('Y\-m\-d') . '.txt';
// Open, lock, write, unlock, close (to prevent interference between multiple writes)
// Open, lock, write, unlock, close (to prevent interference between multiple writes)
$exists=file_exists($filename);
$exists = file_exists($filename);
$file=@fopen($filename, 'a');
$file = @fopen($filename, 'a');
if (is_resource($file)) {
if (flock($file, LOCK_EX)) {
if ( (!$exists) && (filesize($filename)===0) && !qa_opt('event_logger_hide_header') )
$string="Question2Answer ".QA_VERSION." log file generated by Event Logger plugin.\n".
"This file is formatted as tab-delimited text with UTF-8 encoding.\n\n".
implode("\t", array_keys($fixedfields))."\textras...\n\n".$string;
if (!$exists && filesize($filename) === 0 && !qa_opt('event_logger_hide_header')) {
$string = "Question2Answer " . QA_VERSION . " log file generated by Event Logger plugin.\n" .
"This file is formatted as tab-delimited text with UTF-8 encoding.\n\n" .
implode("\t", array_keys($fixedfields)) . "\textras...\n\n" . $string;
}
fwrite($file, $string."\n");
fwrite($file, $string . "\n");
flock($file, LOCK_UN);
}
......
......@@ -28,8 +28,8 @@ class qa_example_page
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->urltoroot=$urltoroot;
$this->directory = $directory;
$this->urltoroot = $urltoroot;
}
......@@ -53,14 +53,14 @@ class qa_example_page
public function process_request($request)
{
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('example_page/page_title');
$qa_content['error']='An example error';
$qa_content['custom']='Some <b>custom html</b>';
$qa_content['title'] = qa_lang_html('example_page/page_title');
$qa_content['error'] = 'An example error';
$qa_content['custom'] = 'Some <b>custom html</b>';
$qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'wide',
......@@ -91,7 +91,7 @@ class qa_example_page
),
);
$qa_content['custom_2']='<p><br>More <i>custom html</i></p>';
$qa_content['custom_2'] = '<p><br>More <i>custom html</i></p>';
return $qa_content;
}
......
......@@ -26,37 +26,37 @@ class qa_facebook_login_page
public function load_module($directory, $urltoroot)
{
$this->directory=$directory;
$this->directory = $directory;
}
public function match_request($request)
{
return ($request=='facebook-login');
return ($request == 'facebook-login');
}
public function process_request($request)
{
if ($request=='facebook-login') {
$app_id=qa_opt('facebook_app_id');
$app_secret=qa_opt('facebook_app_secret');
$tourl=qa_get('to');
if ($request == 'facebook-login') {
$app_id = qa_opt('facebook_app_id');
$app_secret = qa_opt('facebook_app_secret');
$tourl = qa_get('to');
if (!strlen($tourl))
$tourl=qa_path_absolute('');
$tourl = qa_path_absolute('');
if (strlen($app_id) && strlen($app_secret)) {
require_once $this->directory.'facebook.php';
require_once $this->directory . 'facebook.php';
$facebook = new Facebook(array(
'appId' => $app_id,
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));
$fb_userid=$facebook->getUser();
$fb_userid = $facebook->getUser();
if ($fb_userid) {
try {
$user=$facebook->api('/me?fields=email,name,verified,location,website,about,picture.width(250)');
$user = $facebook->api('/me?fields=email,name,verified,location,website,about,picture.width(250)');
if (is_array($user))
qa_log_in_external_user('facebook', $fb_userid, array(
......
......@@ -24,13 +24,13 @@ class qa_facebook_login
{
public function match_source($source)
{
return $source=='facebook';
return $source == 'facebook';
}
public function login_html($tourl, $context)
{
$app_id=qa_opt('facebook_app_id');
$app_id = qa_opt('facebook_app_id');
if (!strlen($app_id))
return;
......@@ -41,7 +41,7 @@ class qa_facebook_login
public function logout_html($tourl)
{
$app_id=qa_opt('facebook_app_id');
$app_id = qa_opt('facebook_app_id');
if (!strlen($app_id))
return;
......@@ -52,10 +52,10 @@ class qa_facebook_login
public function facebook_html($tourl, $logout, $context)
{
if (($context=='login') || ($context=='register'))
$size='large';
if (($context == 'login') || ($context == 'register'))
$size = 'large';
else
$size='medium';
$size = 'medium';
?>
<div id="fb-root" style="display:inline;"></div>
......@@ -89,15 +89,15 @@ class qa_facebook_login
public function admin_form()
{
$saved=false;
$saved = false;
if (qa_clicked('facebook_save_button')) {
qa_opt('facebook_app_id', qa_post_text('facebook_app_id_field'));
qa_opt('facebook_app_secret', qa_post_text('facebook_app_secret_field'));
$saved=true;
$saved = true;
}
$ready=strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'));
$ready = strlen(qa_opt('facebook_app_id')) && strlen(qa_opt('facebook_app_secret'));
return array(
'ok' => $saved ? 'Facebook application details saved' : null,
......
......@@ -26,6 +26,6 @@ class qa_html_theme_layer extends qa_html_theme_base
{
qa_html_theme_base::head_links();
$this->output('<link rel="search" type="application/opensearchdescription+xml" title="'.qa_html(qa_opt('site_title')).'" href="'.qa_path_html('opensearch.xml').'"/>');
$this->output('<link rel="search" type="application/opensearchdescription+xml" title="' . qa_html(qa_opt('site_title')) . '" href="' . qa_path_html('opensearch.xml') . '"/>');
}
}
......@@ -24,27 +24,27 @@ class qa_opensearch_xml
{
public function match_request($request)
{
return ($request=='opensearch.xml');
return ($request == 'opensearch.xml');
}
public function process_request($request)
{
@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
$titlexml=qa_xml(qa_opt('site_title'));
$template=str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path_absolute('search', array('q' => '_searchTerms_placeholder_')));
$titlexml = qa_xml(qa_opt('site_title'));
$template = str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path_absolute('search', array('q' => '_searchTerms_placeholder_')));
header('Content-type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">'."\n";
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">' . "\n";
echo "\t<ShortName>".$titlexml."</ShortName>\n";
echo "\t<Description>".qa_xml(qa_lang('main/search_button')).' '.$titlexml."</Description>\n";
echo "\t".'<Url type="text/html" method="get" template="'.qa_xml($template).'"/>'."\n";
echo "\t<ShortName>" . $titlexml . "</ShortName>\n";
echo "\t<Description>" . qa_xml(qa_lang('main/search_button')) . ' ' . $titlexml . "</Description>\n";
echo "\t" . '<Url type="text/html" method="get" template="' . qa_xml($template) . '"/>' . "\n";
echo "\t<InputEncoding>UTF-8</InputEncoding>\n";
echo '</OpenSearchDescription>'."\n";
echo '</OpenSearchDescription>' . "\n";
return null;
}
......
......@@ -37,9 +37,9 @@ class qa_xml_sitemap
public function admin_form()
{
require_once QA_INCLUDE_DIR.'util/sort.php';
require_once QA_INCLUDE_DIR . 'util/sort.php';
$saved=false;
$saved = false;
if (qa_clicked('xml_sitemap_save_button')) {
qa_opt('xml_sitemap_show_questions', (int)qa_post_text('xml_sitemap_show_questions_field'));
......@@ -55,10 +55,10 @@ class qa_xml_sitemap
qa_opt('xml_sitemap_show_categories', (int)qa_post_text('xml_sitemap_show_categories_field'));
}
$saved=true;
$saved = true;
}
$form=array(
$form = array(
'ok' => $saved ? 'XML sitemap settings saved' : null,
'fields' => array(
......@@ -78,31 +78,33 @@ class qa_xml_sitemap
),
);
if (!QA_FINAL_EXTERNAL_USERS)
$form['fields']['users']=array(
if (!QA_FINAL_EXTERNAL_USERS) {
$form['fields']['users'] = array(
'label' => 'Include user pages',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_users'),
'tags' => 'name="xml_sitemap_show_users_field"',
);
}
if (qa_using_tags())
$form['fields']['tagqs']=array(
if (qa_using_tags()) {
$form['fields']['tagqs'] = array(
'label' => 'Include question list for each tag',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_tag_qs'),
'tags' => 'name="xml_sitemap_show_tag_qs_field"',
);
}
if (qa_using_categories()) {
$form['fields']['categoryqs']=array(
$form['fields']['categoryqs'] = array(
'label' => 'Include question list for each category',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_category_qs'),
'tags' => 'name="xml_sitemap_show_category_qs_field"',
);
$form['fields']['categories']=array(
$form['fields']['categories'] = array(
'label' => 'Include category browser',
'type' => 'checkbox',
'value' => (int)qa_opt('xml_sitemap_show_categories'),
......@@ -128,7 +130,7 @@ class qa_xml_sitemap
public function match_request($request)
{
return ($request=='sitemap.xml');
return ($request == 'sitemap.xml');
}
......@@ -138,21 +140,21 @@ class qa_xml_sitemap
header('Content-type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Question pages
// Question pages
if (qa_opt('xml_sitemap_show_questions')) {
$hotstats=qa_db_read_one_assoc(qa_db_query_sub(
$hotstats = qa_db_read_one_assoc(qa_db_query_sub(
"SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"
));
$nextpostid=0;
$nextpostid = 0;
while (1) {
$questions=qa_db_read_all_assoc(qa_db_query_sub(
$questions = qa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100",
$nextpostid
));
......@@ -162,20 +164,20 @@ class qa_xml_sitemap
foreach ($questions as $question) {
$this->sitemap_output(qa_q_request($question['postid'], $question['title']),
0.1+0.9*($question['hotness']-$hotstats['base'])/(1+$hotstats['spread']));
$nextpostid=max($nextpostid, $question['postid']+1);
0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread']));
$nextpostid = max($nextpostid, $question['postid'] + 1);
}
}
}
// User pages
// User pages
if ((!QA_FINAL_EXTERNAL_USERS) && qa_opt('xml_sitemap_show_users')) {
$nextuserid=0;
$nextuserid = 0;
while (1) {
$users=qa_db_read_all_assoc(qa_db_query_sub(
$users = qa_db_read_all_assoc(qa_db_query_sub(
"SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100",
$nextuserid
));
......@@ -184,20 +186,20 @@ class qa_xml_sitemap
break;
foreach ($users as $user) {
$this->sitemap_output('user/'.$user['handle'], 0.25);
$nextuserid=max($nextuserid, $user['userid']+1);
$this->sitemap_output('user/' . $user['handle'], 0.25);
$nextuserid = max($nextuserid, $user['userid'] + 1);
}
}
}
// Tag pages
// Tag pages
if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) {
$nextwordid=0;
$nextwordid = 0;
while (1) {
$tagwords=qa_db_read_all_assoc(qa_db_query_sub(
$tagwords = qa_db_read_all_assoc(qa_db_query_sub(
"SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100",
$nextwordid
));
......@@ -206,20 +208,20 @@ class qa_xml_sitemap
break;
foreach ($tagwords as $tagword) {
$this->sitemap_output('tag/'.$tagword['word'], 0.5/(1+(1/$tagword['tagcount']))); // priority between 0.25 and 0.5 depending on tag frequency
$nextwordid=max($nextwordid, $tagword['wordid']+1);
$this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + (1 / $tagword['tagcount']))); // priority between 0.25 and 0.5 depending on tag frequency
$nextwordid = max($nextwordid, $tagword['wordid'] + 1);
}
}
}
// Question list for each category
// Question list for each category
if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) {
$nextcategoryid=0;
$nextcategoryid = 0;
while (1) {
$categories=qa_db_read_all_assoc(qa_db_query_sub(
$categories = qa_db_read_all_assoc(qa_db_query_sub(
"SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2",
$nextcategoryid
));
......@@ -228,23 +230,23 @@ class qa_xml_sitemap
break;
foreach ($categories as $category) {
$this->sitemap_output('questions/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
$this->sitemap_output('questions/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
}
}
}
// Pages in category browser
// Pages in category browser
if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) {
$this->sitemap_output('categories', 0.5);
$nextcategoryid=0;
$nextcategoryid = 0;
while (1) { // only find categories with a child
$categories=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT parent.categoryid, parent.backpath FROM ^categories AS parent ".
$categories = qa_db_read_all_assoc(qa_db_query_sub(
"SELECT parent.categoryid, parent.backpath FROM ^categories AS parent " .
"JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100",
$nextcategoryid
));
......@@ -253,8 +255,8 @@ class qa_xml_sitemap
break;
foreach ($categories as $category) {
$this->sitemap_output('categories/'.implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid=max($nextcategoryid, $category['categoryid']+1);
$this->sitemap_output('categories/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
}
}
}
......@@ -271,9 +273,9 @@ class qa_xml_sitemap
*/
public function sitemap_output($request, $priority)
{
echo "\t<url>\n".
"\t\t<loc>".qa_xml(qa_path($request, null, qa_opt('site_url')))."</loc>\n".
"\t\t<priority>".max(0, min(1.0, $priority))."</priority>\n".
echo "\t<url>\n" .
"\t\t<loc>" . qa_xml(qa_path($request, null, qa_opt('site_url'))) . "</loc>\n" .
"\t\t<priority>" . max(0, min(1.0, $priority)) . "</priority>\n" .
"\t</url>\n";
}
}
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