/*
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
Description: Default theme class, broken into lots of little functions for easy overriding
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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
header('Location: ../');
exit;
}
/*
How do I make a theme which goes beyond CSS to actually modify the HTML output?
Create a file named qa-theme.php in your new theme directory which defines a class qa_html_theme
that extends this base class qa_html_theme_base. You can then override any of the methods below,
referring back to the default method using double colon (qa_html_theme_base::) notation.
Plugins can also do something similar by using a layer. For more information and to see some example
code, please consult the online Q2A documentation.
*/
class qa_html_theme_base
{
public $template;
public $content;
public $rooturl;
public $request;
public $isRTL; // (boolean) whether text direction is Right-To-Left
protected $minifyHtml; // (boolean) whether to indent the HTML
protected $indent = 0;
protected $lines = 0;
protected $context = array();
// whether to use new block layout in rankings (true) or fall back to tables (false)
protected $ranking_block_layout = false;
// theme 'slug' to use as CSS class
protected $theme;
/**
* Initialize the object and assign local variables.
* @param $template
* @param $content
* @param $rooturl
* @param $request
*/
public function __construct($template, $content, $rooturl, $request)
{
$this->template = $template;
$this->content = $content;
$this->rooturl = $rooturl;
$this->request = $request;
$this->isRTL = isset($content['direction']) && $content['direction'] === 'rtl';
$this->minifyHtml = !empty($content['options']['minify_html']);
}
/**
* @deprecated PHP4-style constructor deprecated from 1.7; please use proper `__construct`
* function instead.
* @param $template
* @param $content
* @param $rooturl
* @param $request
*/
public function qa_html_theme_base($template, $content, $rooturl, $request)
{
self::__construct($template, $content, $rooturl, $request);
}
/**
* Output each element in $elements on a separate line, with automatic HTML indenting.
* This should be passed markup which uses the form for unpaired tags, to help keep
* track of indenting, although its actual output converts these to for W3C validation.
* @param $elements
*/
public function output_array($elements)
{
foreach ($elements as $element) {
$line = str_replace('/>', '>', $element);
if ($this->minifyHtml) {
if (strlen($line))
echo $line . "\n";
} else {
$delta = substr_count($element, '<') - substr_count($element, '');
if ($delta < 0) {
$this->indent += $delta;
}
echo str_repeat("\t", max(0, $this->indent)) . $line . "\n";
if ($delta > 0) {
$this->indent += $delta;
}
}
$this->lines++;
}
}
/**
* Output each passed parameter on a separate line - see output_array() comments.
*/
public function output() // other parameters picked up via func_get_args()
{
$args = func_get_args();
$this->output_array($args);
}
/**
* Output $html at the current indent level, but don't change indent level based on the markup within.
* Useful for user-entered HTML which is unlikely to follow the rules we need to track indenting.
* @param $html
*/
public function output_raw($html)
{
if (strlen($html))
echo str_repeat("\t", max(0, $this->indent)) . $html . "\n";
}
/**
* Output the three elements ['prefix'], ['data'] and ['suffix'] of $parts (if they're defined),
* with appropriate CSS classes based on $class, using $outertag and $innertag in the markup.
* @param $parts
* @param $class
* @param string $outertag
* @param string $innertag
* @param string $extraclass
*/
public function output_split($parts, $class, $outertag = 'span', $innertag = 'span', $extraclass = null)
{
if (empty($parts) && strtolower($outertag) != 'td')
return;
$this->output(
'<' . $outertag . ' class="' . $class . (isset($extraclass) ? (' ' . $extraclass) : '') . '">',
(strlen(@$parts['prefix']) ? ('<' . $innertag . ' class="' . $class . '-pad">' . $parts['prefix'] . '' . $innertag . '>') : '') .
(strlen(@$parts['data']) ? ('<' . $innertag . ' class="' . $class . '-data">' . $parts['data'] . '' . $innertag . '>') : '') .
(strlen(@$parts['suffix']) ? ('<' . $innertag . ' class="' . $class . '-pad">' . $parts['suffix'] . '' . $innertag . '>') : ''),
'' . $outertag . '>'
);
}
/**
* Set some context, which be accessed via $this->context for a function to know where it's being used on the page.
* @param $key
* @param $value
*/
public function set_context($key, $value)
{
$this->context[$key] = $value;
}
/**
* Clear some context (used at the end of the appropriate loop).
* @param $key
*/
public function clear_context($key)
{
unset($this->context[$key]);
}
/**
* Reorder the parts of the page according to the $parts array which contains part keys in their new order. Call this
* before main_parts(). See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $parts
* @param string $beforekey
* @param bool $reorderrelative
*/
public function reorder_parts($parts, $beforekey = null, $reorderrelative = true)
{
require_once QA_INCLUDE_DIR . 'util/sort.php';
qa_array_reorder($this->content, $parts, $beforekey, $reorderrelative);
}
/**
* Output the widgets (as provided in $this->content['widgets']) for $region and $place.
* @param $region
* @param $place
*/
public function widgets($region, $place)
{
$widgetsHere = isset($this->content['widgets'][$region][$place]) ? $this->content['widgets'][$region][$place] : array();
if (is_array($widgetsHere) && count($widgetsHere) > 0) {
$this->output(' ', '');
}
}
/**
* Pre-output initialization. Immediately called after loading of the module. Content and template variables are
* already setup at this point. Useful to perform layer initialization in the earliest and safest stage possible.
*/
public function initialize()
{
// abstract method
}
/**
* Post-output cleanup. For now, check that the indenting ended right, and if not, output a warning in an HTML comment.
*/
public function finish()
{
if ($this->indent !== 0 && !$this->minifyHtml) {
echo "\n";
}
}
// From here on, we have a large number of class methods which output particular pieces of HTML markup
// The calling chain is initiated from qa-page.php, or ajax/*.php for refreshing parts of a page,
// For most HTML elements, the name of the function is similar to the element's CSS class, for example:
// search() outputs , q_list() outputs , etc...
public function doctype()
{
$this->output('');
}
public function html()
{
$attribution = '';
$extratags = isset($this->content['html_tags']) ? $this->content['html_tags'] : '';
$this->output(
'',
$attribution
);
$this->head();
$this->body();
$this->output(
$attribution,
''
);
}
public function head()
{
$this->output(
'',
''
);
$this->head_title();
$this->head_metas();
$this->head_css();
$this->head_links();
$this->head_lines();
$this->head_script();
$this->head_custom();
$this->output('');
}
public function head_title()
{
$pagetitle = strlen($this->request) ? strip_tags(@$this->content['title']) : '';
$headtitle = (strlen($pagetitle) ? "$pagetitle - " : '') . $this->content['site_title'];
$this->output('' . $headtitle . ' ');
}
public function head_metas()
{
if (strlen(@$this->content['description'])) {
$this->output('');
}
if (strlen(@$this->content['keywords'])) {
// as far as I know, meta keywords have zero effect on search rankings or listings
$this->output('');
}
}
public function head_links()
{
if (isset($this->content['canonical'])) {
$this->output('');
}
if (isset($this->content['feed']['url'])) {
$this->output('');
}
// convert page links to rel=prev and rel=next tags
if (isset($this->content['page_links']['items'])) {
foreach ($this->content['page_links']['items'] as $page_link) {
if (in_array($page_link['type'], array('prev', 'next')))
$this->output('');
}
}
}
public function head_script()
{
if (isset($this->content['script'])) {
foreach ($this->content['script'] as $scriptline) {
$this->output_raw($scriptline);
}
}
}
public function head_css()
{
$this->output('');
if (isset($this->content['css_src'])) {
foreach ($this->content['css_src'] as $css_src) {
$this->output('');
}
}
if (!empty($this->content['notices'])) {
$this->output(
''
);
}
}
public function css_name()
{
return 'qa-styles.css?' . QA_VERSION;
}
public function head_lines()
{
if (isset($this->content['head_lines'])) {
foreach ($this->content['head_lines'] as $line) {
$this->output_raw($line);
}
}
}
public function head_custom()
{
// abstract method
}
public function body()
{
$this->output(' $this->body_tags();
$this->output('>');
$this->body_script();
$this->body_header();
$this->body_content();
$this->body_footer();
$this->body_hidden();
$this->output('');
}
public function body_hidden()
{
$this->output(' ');
}
public function waiting_template()
{
$this->output('...');
}
public function body_script()
{
$this->output(
'<script>',
"var b = document.getElementsByTagName('body')[0];",
"b.className = b.className.replace('qa-body-js-off', 'qa-body-js-on');",
'</script>'
);
}
public function body_header()
{
if (isset($this->content['body_header'])) {
$this->output_raw($this->content['body_header']);
}
}
public function body_footer()
{
if (isset($this->content['body_footer'])) {
$this->output_raw($this->content['body_footer']);
}
}
public function body_content()
{
$this->body_prefix();
$this->notices();
$this->output('', '');
$this->widgets('full', 'top');
$this->header();
$this->widgets('full', 'high');
$this->sidepanel();
$this->main();
$this->widgets('full', 'low');
$this->footer();
$this->widgets('full', 'bottom');
$this->output(' ');
$this->body_suffix();
}
public function body_tags()
{
$class = 'qa-template-' . qa_html($this->template);
$class .= empty($this->theme) ? '' : ' qa-theme-' . qa_html($this->theme);
if (isset($this->content['categoryids'])) {
foreach ($this->content['categoryids'] as $categoryid) {
$class .= ' qa-category-' . qa_html($categoryid);
}
}
$this->output('class="' . $class . ' qa-body-js-off"');
}
public function body_prefix()
{
// abstract method
}
public function body_suffix()
{
// abstract method
}
public function notices()
{
if (!empty($this->content['notices'])) {
foreach ($this->content['notices'] as $notice) {
$this->notice($notice);
}
}
}
public function notice($notice)
{
$this->output('');
if (isset($notice['form_tags']))
$this->output('');
}
$this->output('');
}
public function header()
{
$this->output('');
$this->logo();
$this->nav_user_search();
$this->nav_main_sub();
$this->header_clear();
$this->output(' ', '');
}
public function nav_user_search()
{
$this->nav('user');
$this->search();
}
public function nav_main_sub()
{
$this->nav('main');
$this->nav('sub');
}
public function logo()
{
$this->output(
'',
$this->content['logo'],
''
);
}
public function search()
{
$search = $this->content['search'];
$this->output(
'',
'',
''
);
}
public function search_field($search)
{
$this->output('');
}
public function search_button($search)
{
$this->output('');
}
public function nav($navtype, $level = null)
{
$navigation = @$this->content['navigation'][$navtype];
if ($navtype == 'user' || isset($navigation)) {
$this->output('');
if ($navtype == 'user')
$this->logged_in();
// reverse order of 'opposite' items since they float right
foreach (array_reverse($navigation, true) as $key => $navlink) {
if (@$navlink['opposite']) {
unset($navigation[$key]);
$navigation[$key] = $navlink;
}
}
$this->set_context('nav_type', $navtype);
$this->nav_list($navigation, 'nav-' . $navtype, $level);
$this->nav_clear($navtype);
$this->clear_context('nav_type');
$this->output('');
}
}
public function nav_list($navigation, $class, $level = null)
{
$this->output('');
$index = 0;
foreach ($navigation as $key => $navlink) {
$this->set_context('nav_key', $key);
$this->set_context('nav_index', $index++);
$this->nav_item($key, $navlink, $class, $level);
}
$this->clear_context('nav_key');
$this->clear_context('nav_index');
$this->output('
');
}
public function nav_clear($navtype)
{
$this->output(
'',
''
);
}
public function nav_item($key, $navlink, $class, $level = null)
{
$suffix = strtr($key, array( // map special character in navigation key
'$' => '',
'/' => '-',
));
$this->output('');
$this->nav_link($navlink, $class);
$subnav = isset($navlink['subnav']) ? $navlink['subnav'] : array();
if (is_array($subnav) && count($subnav) > 0) {
$this->nav_list($subnav, $class, 1 + $level);
}
$this->output(' ');
}
public function nav_link($navlink, $class)
{
if (isset($navlink['url'])) {
$this->output(
' (isset($navlink['target']) ? (' target="' . $navlink['target'] . '"') : '') . '>' . $navlink['label'] .
''
);
} else {
$this->output(
' (strlen(@$navlink['popup']) ? (' title="' . $navlink['popup'] . '"') : '') .
'>' . $navlink['label'] . ''
);
}
if (strlen(@$navlink['note']))
$this->output('' . $navlink['note'] . '');
}
public function logged_in()
{
$this->output_split(@$this->content['loggedin'], 'qa-logged-in', 'div');
}
public function header_clear()
{
$this->output(
'',
''
);
}
public function sidepanel()
{
$this->output('');
$this->widgets('side', 'top');
$this->sidebar();
$this->widgets('side', 'high');
$this->widgets('side', 'low');
$this->output_raw(@$this->content['sidepanel']);
$this->feed();
$this->widgets('side', 'bottom');
$this->output('', '');
}
public function sidebar()
{
$sidebar = @$this->content['sidebar'];
if (!empty($sidebar)) {
$this->output(' ', '');
}
}
public function feed()
{
$feed = @$this->content['feed'];
if (!empty($feed)) {
$this->output('');
}
}
public function main()
{
$content = $this->content;
$hidden = !empty($content['hidden']) ? ' qa-main-hidden' : '';
$extratags = isset($this->content['main_tags']) ? $this->content['main_tags'] : '';
$this->output('');
$this->widgets('main', 'top');
$this->page_title_error();
$this->widgets('main', 'high');
$this->main_parts($content);
$this->widgets('main', 'low');
$this->page_links();
$this->suggest_next();
$this->widgets('main', 'bottom');
$this->output(' ', '');
}
public function page_title_error()
{
if (isset($this->content['title'])) {
$favorite = isset($this->content['favorite']) ? $this->content['favorite'] : null;
if (isset($favorite))
$this->output('');
}
}
if (isset($this->content['success']))
$this->success($this->content['success']);
if (isset($this->content['error']))
$this->error($this->content['error']);
}
public function favorite()
{
$favorite = isset($this->content['favorite']) ? $this->content['favorite'] : null;
if (isset($favorite)) {
$favoritetags = isset($favorite['favorite_tags']) ? $favorite['favorite_tags'] : '';
$this->output('');
$this->favorite_inner_html($favorite);
$this->output('');
}
}
public function title()
{
$q_view = @$this->content['q_view'];
// link title where appropriate
$url = isset($q_view['url']) ? $q_view['url'] : false;
if (isset($this->content['title'])) {
$this->output(
$url ? '' : '',
$this->content['title'],
$url ? '' : ''
);
}
// add closed note in title
if (!empty($q_view['closed']['state']))
$this->output(' [' . $q_view['closed']['state'] . ']');
}
public function favorite_inner_html($favorite)
{
$this->favorite_button(@$favorite['favorite_add_tags'], 'qa-favorite');
$this->favorite_button(@$favorite['favorite_remove_tags'], 'qa-unfavorite');
}
public function favorite_button($tags, $class)
{
if (isset($tags))
$this->output(' ');
}
public function error($error)
{
if (strlen($error)) {
$this->output(
'',
$error,
''
);
}
}
public function success($message)
{
if (strlen($message)) {
$this->output(
'',
$message,
''
);
}
}
public function main_parts($content)
{
foreach ($content as $key => $part) {
$this->set_context('part', $key);
$this->main_part($key, $part);
}
$this->clear_context('part');
}
public function main_part($key, $part)
{
$isRanking = strpos($key, 'ranking') === 0;
$partdiv = (
strpos($key, 'custom') === 0 ||
strpos($key, 'form') === 0 ||
strpos($key, 'q_list') === 0 ||
(strpos($key, 'q_view') === 0 && !isset($this->content['form_q_edit'])) ||
strpos($key, 'a_form') === 0 ||
strpos($key, 'a_list') === 0 ||
$isRanking ||
strpos($key, 'message_list') === 0 ||
strpos($key, 'nav_list') === 0
);
if ($partdiv) {
$class = 'qa-part-' . strtr($key, '_', '-');
if ($isRanking)
$class .= ' qa-ranking-' . $part['type'] . '-' . (isset($part['sort']) ? $part['sort'] : 'points');
// help target CSS to page parts
$this->output('');
}
if (strpos($key, 'custom') === 0)
$this->output_raw($part);
elseif (strpos($key, 'form') === 0)
$this->form($part);
elseif (strpos($key, 'q_list') === 0)
$this->q_list_and_form($part);
elseif (strpos($key, 'q_view') === 0)
$this->q_view($part);
elseif (strpos($key, 'a_form') === 0)
$this->a_form($part);
elseif (strpos($key, 'a_list') === 0)
$this->a_list($part);
elseif (strpos($key, 'ranking') === 0)
$this->ranking($part);
elseif (strpos($key, 'message_list') === 0)
$this->message_list_and_form($part);
elseif (strpos($key, 'nav_list') === 0) {
$this->part_title($part);
$this->nav_list($part['nav'], $part['type'], 1);
}
if ($partdiv)
$this->output('');
}
public function footer()
{
$this->output(' ', '');
}
public function attribution()
{
// Hi there. I'd really appreciate you displaying this link on your Q2A site. Thank you - Gideon
$this->output(
''
);
}
public function footer_clear()
{
$this->output(
' '
);
}
public function section($title)
{
$this->part_title(array('title' => $title));
}
public function part_title($part)
{
if (strlen(@$part['title']) || strlen(@$part['title_tags']))
$this->output('' . @$part['title'] . '
');
}
public function part_footer($part)
{
if (isset($part['footer']))
$this->output($part['footer']);
}
public function form($form)
{
if (!empty($form)) {
$this->part_title($form);
if (isset($form['tags']))
$this->output('');
}
}
public function form_columns($form)
{
if (isset($form['ok']) || !empty($form['fields']))
$columns = ($form['style'] == 'wide') ? 2 : 1;
else
$columns = 0;
return $columns;
}
public function form_spacer($form, $columns)
{
$this->output(
'',
'',
' ',
' ',
' '
);
}
public function form_body($form)
{
if (@$form['boxed'])
$this->output('');
$columns = $this->form_columns($form);
if ($columns)
$this->output('');
$this->form_ok($form, $columns);
$this->form_fields($form, $columns);
$this->form_buttons($form, $columns);
if ($columns)
$this->output('
');
$this->form_hidden($form);
if (@$form['boxed'])
$this->output('');
}
public function form_ok($form, $columns)
{
if (!empty($form['ok'])) {
$this->output(
'',
'',
$form['ok'],
' ',
' '
);
}
}
/**
* Reorder the fields of $form according to the $keys array which contains the field keys in their new order. Call
* before any fields are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form
* @param $keys
* @param mixed $beforekey
* @param bool $reorderrelative
*/
public function form_reorder_fields(&$form, $keys, $beforekey = null, $reorderrelative = true)
{
require_once QA_INCLUDE_DIR . 'util/sort.php';
if (is_array($form['fields']))
qa_array_reorder($form['fields'], $keys, $beforekey, $reorderrelative);
}
public function form_fields($form, $columns)
{
if (!empty($form['fields'])) {
foreach ($form['fields'] as $key => $field) {
$this->set_context('field_key', $key);
if (@$field['type'] == 'blank')
$this->form_spacer($form, $columns);
else
$this->form_field_rows($form, $columns, $field);
}
$this->clear_context('field_key');
}
}
public function form_field_rows($form, $columns, $field)
{
$style = $form['style'];
if (isset($field['style'])) { // field has different style to most of form
$style = $field['style'];
$colspan = $columns;
$columns = ($style == 'wide') ? 2 : 1;
} else
$colspan = null;
$prefixed = (@$field['type'] == 'checkbox') && ($columns == 1) && !empty($field['label']);
$suffixed = (@$field['type'] == 'select' || @$field['type'] == 'number') && $columns == 1 && !empty($field['label']) && !@$field['loose'];
$skipdata = @$field['tight'];
$tworows = ($columns == 1) && (!empty($field['label'])) && (!$skipdata) &&
((!($prefixed || $suffixed)) || (!empty($field['error'])) || (!empty($field['note'])));
if (isset($field['id'])) {
if ($columns == 1)
$this->output('', '');
else
$this->output(' ');
} else
$this->output(' ');
if ($columns > 1 || !empty($field['label']))
$this->form_label($field, $style, $columns, $prefixed, $suffixed, $colspan);
if ($tworows) {
$this->output(
' ',
''
);
}
if (!$skipdata)
$this->form_data($field, $style, $columns, !($prefixed || $suffixed), $colspan);
$this->output(' ');
if ($columns == 1 && isset($field['id']))
$this->output('');
}
public function form_label($field, $style, $columns, $prefixed, $suffixed, $colspan)
{
$extratags = '';
if ($columns > 1 && (@$field['type'] == 'select-radio' || @$field['rows'] > 1))
$extratags .= ' style="vertical-align:top;"';
if (isset($colspan))
$extratags .= ' colspan="' . $colspan . '"';
$this->output('');
if ($prefixed) {
$this->output('');
if ($suffixed) {
$this->output(' ');
$this->form_field($field, $style);
}
$this->output(' ');
}
public function form_data($field, $style, $columns, $showfield, $colspan)
{
if ($showfield || (!empty($field['error'])) || (!empty($field['note']))) {
$this->output(
''
);
if ($showfield)
$this->form_field($field, $style);
if (!empty($field['error'])) {
if (@$field['note_force'])
$this->form_note($field, $style, $columns);
$this->form_error($field, $style, $columns);
} elseif (!empty($field['note']))
$this->form_note($field, $style, $columns);
$this->output(' ');
}
}
public function form_field($field, $style)
{
$this->form_prefix($field, $style);
$this->output_raw(@$field['html_prefix']);
switch (@$field['type']) {
case 'checkbox':
$this->form_checkbox($field, $style);
break;
case 'static':
$this->form_static($field, $style);
break;
case 'password':
$this->form_password($field, $style);
break;
case 'number':
$this->form_number($field, $style);
break;
case 'file':
$this->form_file($field, $style);
break;
case 'select':
$this->form_select($field, $style);
break;
case 'select-radio':
$this->form_select_radio($field, $style);
break;
case 'image':
$this->form_image($field, $style);
break;
case 'custom':
$this->output_raw(@$field['html']);
break;
default:
if (@$field['type'] == 'textarea' || @$field['rows'] > 1)
$this->form_text_multi_row($field, $style);
else
$this->form_text_single_row($field, $style);
break;
}
$this->output_raw(@$field['html_suffix']);
$this->form_suffix($field, $style);
}
/**
* Reorder the buttons of $form according to the $keys array which contains the button keys in their new order. Call
* before any buttons are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form
* @param $keys
* @param mixed $beforekey
* @param bool $reorderrelative
*/
public function form_reorder_buttons(&$form, $keys, $beforekey = null, $reorderrelative = true)
{
require_once QA_INCLUDE_DIR . 'util/sort.php';
if (is_array($form['buttons']))
qa_array_reorder($form['buttons'], $keys, $beforekey, $reorderrelative);
}
public function form_buttons($form, $columns)
{
if (!empty($form['buttons'])) {
$style = @$form['style'];
if ($columns) {
$this->output(
'',
''
);
}
foreach ($form['buttons'] as $key => $button) {
$this->set_context('button_key', $key);
if (empty($button))
$this->form_button_spacer($style);
else {
$this->form_button_data($button, $key, $style);
$this->form_button_note($button, $style);
}
}
$this->clear_context('button_key');
if ($columns) {
$this->output(
' ',
' '
);
}
}
}
public function form_button_data($button, $key, $style)
{
$baseclass = 'qa-form-' . $style . '-button qa-form-' . $style . '-button-' . $key;
$this->output(' (isset($style) ? (' class="' . $baseclass . '"') : '') . '/>');
}
public function form_button_note($button, $style)
{
if (!empty($button['note'])) {
$this->output(
'',
$button['note'],
'',
'
'
);
}
}
public function form_button_spacer($style)
{
$this->output(' ');
}
public function form_hidden($form)
{
$this->form_hidden_elements(@$form['hidden']);
}
public function form_hidden_elements($hidden)
{
if (empty($hidden))
return;
foreach ($hidden as $name => $value) {
if (is_array($value)) {
// new method of outputting tags
$this->output('');
} else {
// old method
$this->output('');
}
}
}
public function form_prefix($field, $style)
{
if (!empty($field['prefix']))
$this->output('' . $field['prefix'] . '');
}
public function form_suffix($field, $style)
{
if (!empty($field['suffix']))
$this->output('' . $field['suffix'] . '');
}
public function form_checkbox($field, $style)
{
$this->output('');
}
public function form_static($field, $style)
{
$this->output('' . @$field['value'] . '');
}
public function form_password($field, $style)
{
$this->output('');
}
public function form_number($field, $style)
{
$this->output('');
}
public function form_file($field, $style)
{
$this->output('');
}
/**
* Output a ', '');
}
public function a_list($a_list)
{
if (!empty($a_list)) {
$this->part_title($a_list);
$this->output('', '');
$this->a_list_items($a_list['as']);
$this->output(' ', '');
}
}
public function a_list_items($a_items)
{
foreach ($a_items as $a_item) {
$this->a_list_item($a_item);
}
}
public function a_list_item($a_item)
{
$extraclass = @$a_item['classes'] . ($a_item['hidden'] ? ' qa-a-list-item-hidden' : ($a_item['selected'] ? ' qa-a-list-item-selected' : ''));
$this->output('');
if (isset($a_item['main_form_tags'])) {
$this->output('');
}
$this->a_item_main($a_item);
$this->a_item_clear();
$this->output(' ', '');
}
public function a_item_main($a_item)
{
$this->output('');
if (isset($a_item['main_form_tags'])) {
$this->output(' ', '');
}
public function c_list($c_list, $class)
{
if (!empty($c_list)) {
$this->output('', ' ', '');
}
}
public function c_list_items($c_items)
{
foreach ($c_items as $c_item) {
$this->c_list_item($c_item);
}
}
public function c_list_item($c_item)
{
$extraclass = @$c_item['classes'] . (@$c_item['hidden'] ? ' qa-c-item-hidden' : '');
$this->output('');
if (isset($c_item['vote_view']) && isset($c_item['main_form_tags'])) {
// form for comment voting buttons
$this->output('');
}
$this->c_item_main($c_item);
$this->c_item_clear();
$this->output(' ');
}
public function c_item_main($c_item)
{
if (isset($c_item['main_form_tags'])) {
$this->output('');
}
}
public function c_item_link($c_item)
{
$this->output(
'' . $c_item['title'] . ''
);
}
public function c_item_expand($c_item)
{
$this->output(
'' . $c_item['title'] . ''
);
}
public function c_item_content($c_item)
{
if (!isset($c_item['content'])) {
$c_item['content'] = '';
}
$this->output('');
$this->output_raw($c_item['content']);
$this->output('');
}
public function c_item_buttons($c_item)
{
if (!empty($c_item['form'])) {
$this->output(' ');
}
}
public function c_item_clear()
{
$this->output(
'',
''
);
}
/**
* Generic method to output a basic list of question links.
* @param array $q_list
* @param string $attrs
*/
public function q_title_list($q_list, $attrs = null)
{
$this->output('');
foreach ($q_list as $q) {
$this->output(
'- ',
'' . qa_html($q['title']) . '',
' '
);
}
$this->output('
');
}
/**
* Output block of similar questions when asking.
* @param array $q_list
* @param string $pretext
*/
public function q_ask_similar($q_list, $pretext = '')
{
if (!count($q_list))
return;
$this->output('');
if (strlen($pretext) > 0)
$this->output('' . $pretext . '
');
$this->q_title_list($q_list, 'target="_blank"');
$this->output('');
}
}
Sözde kendisi burada gerekli değişiklikleri yapmış.