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) { $element = (string)$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((string)$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'] . '') : '') . (strlen($parts['data'] ?? '') ? ('<' . $innertag . ' class="' . $class . '-data">' . $parts['data'] . '') : '') . (strlen($parts['suffix'] ?? '') ? ('<' . $innertag . ' class="' . $class . '-pad">' . $parts['suffix'] . '') : ''), '' ); } /** * 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('
'); foreach ($widgetsHere as $module) { $this->output('
'); $module->output_widget($region, $place, $this, $this->template, $this->request, $this->content); $this->output('
'); } $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