function convert_to_html() { $this->value = (string) $this->value; switch ($this->output_mode) { case 'code': return '<pre style="overflow:auto">' . htmlspecialchars($this->value, $this->specialchars_quotes, $this->specialchars_charset) . '</pre>'; case 'pre': return '<pre style="white-space: pre-wrap">' . htmlspecialchars($this->value, $this->specialchars_quotes, $this->specialchars_charset) . '</pre>'; case 'specialchars': return htmlspecialchars($this->value, $this->specialchars_quotes, $this->specialchars_charset); case 'nl2br': return nl2br(htmlentities($this->value, $this->specialchars_quotes, $this->specialchars_charset)); case 'midgard_f': return midcom_helper_misc::format_variable($this->value, 'f'); case 'midgard_F': return midcom_helper_misc::format_variable($this->value, 'F'); case 'markdown': static $markdown = null; if (!$markdown) { midcom::get('componentloader')->load_library('net.nehmer.markdown'); $markdown = new net_nehmer_markdown_markdown(); } if (!$this->purify || !$this->purify_markdown_on_output) { // Return the Markdown straight away return $markdown->render($this->value); } // Run the Markdown-generated HTML through Purifier to ensure consistency. This is expensive, however return $this->purify_string($markdown->render($this->value)); case substr($this->output_mode, 0, 1) == 'x': // Run the contents through a custom formatter registered via mgd_register_filter return midcom_helper_misc::format_variable($this->value, $this->output_mode); default: case 'html': return $this->value; } }
<?php $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); echo "<h1>" . sprintf(midcom::get('i18n')->get_string('mgdschemas in %s', 'midcom.admin.help'), midcom::get('i18n')->get_string($data['component'], $data['component'])) . "</h1>\n"; if (count($data['mgdschemas']) > 0) { $marker = new net_nehmer_markdown_markdown(); echo "<dl>\n"; foreach ($data['properties'] as $schema => $properties) { echo "<dt id=\"{$schema}\">{$schema}</dt>\n"; echo "<dd>\n"; echo " <table>\n"; echo " <tbody>\n"; echo " <tr>\n"; echo " <th class='property'>" . midcom::get('i18n')->get_string('property', 'midcom.admin.help') . "</th>\n"; echo " <th>" . midcom::get('i18n')->get_string('description', 'midcom.admin.help') . "</th>\n"; echo " </tr>\n"; $i = 1; foreach ($properties as $key => $val) { $propname = $key; $proplink = ""; $proplink_description = ''; if ($val['link']) { $linked_component = ''; if (substr($val['link_name'], 0, 8) == 'midgard_') { $linked_component = 'midcom'; } else { $linked_component = midcom::get('dbclassloader')->get_component_for_class($val['link_name']); } if ($linked_component) { $proplink = "<a href='{$prefix}__ais/help/{$linked_component}/mgdschemas/#{$val['link_name']}' title='{$linked_component}/{$val['link_name']}::{$val['link_target']}'>{$val['link_name']}:{$val['link_target']}</a>"; $proplink_description = "\n\n**This property links to {$val['link_name']}:{$val['link_target']}**";
/** * Load a help file and markdownize it */ function get_help_contents($help_id, $component) { $text = $this->_load_file($help_id, $component); if (!$text) { return false; } $marker = new net_nehmer_markdown_markdown(); // Finding [callback:some_method_of_viewer] if (preg_match_all('/(\\[callback:(.+?)\\])/', $text, $regs)) { foreach ($regs[1] as $i => $value) { if ($component != midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT)) { $text = str_replace($value, "\n\n __Note:__ documentation part _{$regs[2][$i]}_ from _{$component}_ is unavailable in this MidCOM context.\n\n", $text); } else { $method_name = "help_{$regs[2][$i]}"; if (method_exists($this->_master, $method_name)) { $text = str_replace($value, $this->_master->{$method_name}(), $text); } } } } return $marker->render($text); }