Commit fc634ce0 by Scott

Remove microdata from theme

Moved into question page so that it’s not on other pages, and so we can
obtain correct answer count.
parent 966feeb6
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
$isbyuser=qa_post_is_by_user($post, $userid, $cookieid); $isbyuser=qa_post_is_by_user($post, $userid, $cookieid);
$anchor=urlencode(qa_anchor($post['basetype'], $postid)); $anchor=urlencode(qa_anchor($post['basetype'], $postid));
$elementid=isset($options['elementid']) ? $options['elementid'] : $anchor; $elementid=isset($options['elementid']) ? $options['elementid'] : $anchor;
$microformats=qa_opt('use_microdata'); $microdata=qa_opt('use_microdata');
$isselected=@$options['isselected']; $isselected=@$options['isselected'];
$favoritedview=@$options['favoritedview']; $favoritedview=@$options['favoritedview'];
$favoritemap=$favoritedview ? qa_get_favorite_non_qs_map() : array(); $favoritemap=$favoritedview ? qa_get_favorite_non_qs_map() : array();
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
if ($isquestion && isset($post['closedbyid'])) if ($isquestion && isset($post['closedbyid']))
$fields['classes']=ltrim($fields['classes'].' qa-q-closed'); $fields['classes']=ltrim($fields['classes'].' qa-q-closed');
if ($microformats) { if ($microdata) {
if ($isanswer) { if ($isanswer) {
$fields['tags'] .= ' itemprop="suggestedAnswer' . ($isselected ? ' acceptedAnswer' : '') . '" itemscope itemtype="http://schema.org/Answer"'; $fields['tags'] .= ' itemprop="suggestedAnswer' . ($isselected ? ' acceptedAnswer' : '') . '" itemscope itemtype="http://schema.org/Answer"';
} }
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
$post['title']=qa_block_words_replace($post['title'], $options['blockwordspreg']); $post['title']=qa_block_words_replace($post['title'], $options['blockwordspreg']);
$fields['title']=qa_html($post['title']); $fields['title']=qa_html($post['title']);
if ($microformats) { if ($microdata) {
$fields['title'] = '<span itemprop="name">' . $fields['title'] . '</span>'; $fields['title'] = '<span itemprop="name">' . $fields['title'] . '</span>';
} }
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
if (isset($options['blockwordspreg']) && count(qa_block_words_match_all($tag, $options['blockwordspreg']))) // skip censored tags if (isset($options['blockwordspreg']) && count(qa_block_words_match_all($tag, $options['blockwordspreg']))) // skip censored tags
continue; continue;
$fields['q_tags'][]=qa_tag_html($tag, $microformats, @$favoritemap['tag'][qa_strtolower($tag)]); $fields['q_tags'][]=qa_tag_html($tag, $microdata, @$favoritemap['tag'][qa_strtolower($tag)]);
} }
} }
...@@ -376,7 +376,7 @@ ...@@ -376,7 +376,7 @@
'linksnewwindow' => @$options['linksnewwindow'], 'linksnewwindow' => @$options['linksnewwindow'],
)); ));
if ($microformats) { if ($microdata) {
$fields['content'] = '<div itemprop="text">' . $fields['content'] . '</div>'; $fields['content'] = '<div itemprop="text">' . $fields['content'] . '</div>';
} }
...@@ -424,7 +424,7 @@ ...@@ -424,7 +424,7 @@
// ...with microformats if appropriate // ...with microformats if appropriate
if ($microformats) { if ($microdata) {
// vote display might be compacted so use meta tag for true count // vote display might be compacted so use meta tag for true count
$netvoteshtml .= '<meta itemprop="upvoteCount" content="' . qa_html($netvotes) . '">'; $netvoteshtml .= '<meta itemprop="upvoteCount" content="' . qa_html($netvotes) . '">';
$upvoteshtml .= '<meta itemprop="upvoteCount" content="' . qa_html($upvotes) . '">'; $upvoteshtml .= '<meta itemprop="upvoteCount" content="' . qa_html($upvotes) . '">';
...@@ -526,14 +526,14 @@ ...@@ -526,14 +526,14 @@
if (isset($post['created']) && @$options['whenview']) { if (isset($post['created']) && @$options['whenview']) {
$fields['when']=qa_when_to_html($post['created'], @$options['fulldatedays']); $fields['when']=qa_when_to_html($post['created'], @$options['fulldatedays']);
if ($microformats) { if ($microdata) {
$gmdate = gmdate('Y-m-d\TH:i:sO', $post['created']); $gmdate = gmdate('Y-m-d\TH:i:sO', $post['created']);
$fields['when']['data'] = '<time itemprop="dateCreated" datetime="' . $gmdate . '" title="' . $gmdate . '">' . $fields['when']['data'] . '</time>'; $fields['when']['data'] = '<time itemprop="dateCreated" datetime="' . $gmdate . '" title="' . $gmdate . '">' . $fields['when']['data'] . '</time>';
} }
} }
if (@$options['whoview']) { if (@$options['whoview']) {
$fields['who']=qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? @$post['createip'] : null, $microformats, $post['name']); $fields['who']=qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? @$post['createip'] : null, $microdata, $post['name']);
if (isset($post['points'])) { if (isset($post['points'])) {
if (@$options['pointsview']) if (@$options['pointsview'])
...@@ -605,7 +605,7 @@ ...@@ -605,7 +605,7 @@
if (@$options['whenview']) { if (@$options['whenview']) {
$fields['when_2']=qa_when_to_html($post['updated'], @$options['fulldatedays']); $fields['when_2']=qa_when_to_html($post['updated'], @$options['fulldatedays']);
if ($microformats) { if ($microdata) {
$gmdate = gmdate('Y-m-d\TH:i:sO', $post['updated']); $gmdate = gmdate('Y-m-d\TH:i:sO', $post['updated']);
$fields['when_2']['data'] = '<time itemprop="dateModified" datetime="' . $gmdate . '" title="' . $gmdate . '">' . $fields['when_2']['data'] . '</time>'; $fields['when_2']['data'] = '<time itemprop="dateModified" datetime="' . $gmdate . '" title="' . $gmdate . '">' . $fields['when_2']['data'] . '</time>';
} }
......
...@@ -220,6 +220,13 @@ ...@@ -220,6 +220,13 @@
))); // as far as I know, META keywords have zero effect on search rankings or listings, but many people have asked for this ))); // as far as I know, META keywords have zero effect on search rankings or listings, but many people have asked for this
} }
$microdata = qa_opt('use_microdata');
if ($microdata) {
$qa_content['head_lines'][] = '<meta itemprop="name" content="' . qa_html($qa_content['q_view']['raw']['title']) . '">';
$qa_content['html_tags'] = ' itemscope itemtype="http://schema.org/QAPage"';
$qa_content['main_tags'] = ' itemscope itemtype="http://schema.org/Question"';
}
// Prepare content for an answer being edited (if any) or to be added // Prepare content for an answer being edited (if any) or to be added
...@@ -378,10 +385,16 @@ ...@@ -378,10 +385,16 @@
if ($question['basetype']=='Q') { if ($question['basetype']=='Q') {
$qa_content['a_list']['title_tags']='id="a_list_title"'; $qa_content['a_list']['title_tags']='id="a_list_title"';
if ($countfortitle==1) if ($countfortitle > 0) {
$qa_content['a_list']['title']=qa_lang_html('question/1_answer_title'); $split = $countfortitle == 1
elseif ($countfortitle>0) ? qa_lang_html_sub_split('question/1_answer_title', '1', '1')
$qa_content['a_list']['title']=qa_lang_html_sub('question/x_answers_title', $countfortitle); : qa_lang_html_sub_split('question/x_answers_title', $countfortitle);
if ($microdata)
$split['data'] = '<span itemprop="answerCount">' . $split['data'] . '</span>';
$qa_content['a_list']['title'] = $split['prefix'] . $split['data'] . $split['suffix'];
}
else else
$qa_content['a_list']['title_tags'].=' style="display:none;" '; $qa_content['a_list']['title_tags'].=' style="display:none;" ';
} }
......
...@@ -498,7 +498,6 @@ ...@@ -498,7 +498,6 @@
'content_type' => 'text/html; charset='.$charset, 'content_type' => 'text/html; charset='.$charset,
'charset' => $charset, 'charset' => $charset,
'direction' => qa_opt('site_text_direction'), 'direction' => qa_opt('site_text_direction'),
'microdata' => qa_opt('use_microdata'),
'site_title' => qa_html(qa_opt('site_title')), 'site_title' => qa_html(qa_opt('site_title')),
......
...@@ -51,8 +51,6 @@ class qa_html_theme_base ...@@ -51,8 +51,6 @@ class qa_html_theme_base
// 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)
protected $ranking_block_layout = false; protected $ranking_block_layout = false;
// whether schema.org microdata is being used
protected $microdata;
public function __construct($template, $content, $rooturl, $request) public function __construct($template, $content, $rooturl, $request)
...@@ -64,10 +62,7 @@ class qa_html_theme_base ...@@ -64,10 +62,7 @@ class qa_html_theme_base
$this->content = $content; $this->content = $content;
$this->rooturl = $rooturl; $this->rooturl = $rooturl;
$this->request = $request; $this->request = $request;
$this->isRTL = isset($content['direction']) && $content['direction'] === 'rtl'; $this->isRTL = isset($content['direction']) && $content['direction'] === 'rtl';
$this->microdata = isset($content['microdata']) && $content['microdata'] == 1;
} }
/** /**
...@@ -225,10 +220,10 @@ class qa_html_theme_base ...@@ -225,10 +220,10 @@ class qa_html_theme_base
public function html() public function html()
{ {
$attribution = '<!-- Powered by Question2Answer - http://www.question2answer.org/ -->'; $attribution = '<!-- Powered by Question2Answer - http://www.question2answer.org/ -->';
$md = $this->microdata ? ' itemscope itemtype="http://schema.org/QAPage"' : ''; $extratags = isset($this->content['html_tags']) ? $this->content['html_tags'] : '';
$this->output( $this->output(
'<html'.$md.'>', '<html'.$extratags.'>',
$attribution $attribution
); );
...@@ -667,9 +662,9 @@ class qa_html_theme_base ...@@ -667,9 +662,9 @@ class qa_html_theme_base
{ {
$content = $this->content; $content = $this->content;
$hidden = !empty($content['hidden']) ? ' qa-main-hidden' : ''; $hidden = !empty($content['hidden']) ? ' qa-main-hidden' : '';
$md = $this->microdata ? ' itemscope itemtype="http://schema.org/Question"' : ''; $extratags = isset($this->content['main_tags']) ? $this->content['main_tags'] : '';
$this->output('<div class="qa-main'.$hidden.'"'.$md.'>'); $this->output('<div class="qa-main'.$hidden.'"'.$extratags.'>');
$this->widgets('main', 'top'); $this->widgets('main', 'top');
...@@ -2169,10 +2164,6 @@ class qa_html_theme_base ...@@ -2169,10 +2164,6 @@ class qa_html_theme_base
if (!empty($a_list)) { if (!empty($a_list)) {
$this->part_title($a_list); $this->part_title($a_list);
if ($this->microdata) {
$this->output('<meta itemprop="answerCount" content="' . count($a_list['as']) . '">');
}
$this->output('<div class="qa-a-list'.($this->list_vote_disabled($a_list['as']) ? ' qa-a-list-vote-disabled' : '').'" '.@$a_list['tags'].'>', ''); $this->output('<div class="qa-a-list'.($this->list_vote_disabled($a_list['as']) ? ' qa-a-list-vote-disabled' : '').'" '.@$a_list['tags'].'>', '');
$this->a_list_items($a_list['as']); $this->a_list_items($a_list['as']);
$this->output('</div> <!-- END qa-a-list -->', ''); $this->output('</div> <!-- END qa-a-list -->', '');
......
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