コード例 #1
0
ファイル: text.php プロジェクト: nemein/openpsa
 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;
     }
 }
コード例 #2
0
         $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']}**";
         }
     }
     $mod = $i / 2 == round($i / 2) ? " even" : " odd";
     $i++;
     echo "            <tr>\n";
     echo "                <td class='property{$mod}'><span class='mgdtype'>{$val['midgard_type']}</span> {$propname}<br/>{$proplink}</td>\n";
     echo "                <td class='{$mod}'>" . $marker->render($val['value'] . $proplink_description) . "</td>\n";
     echo "            </tr>\n";
 }
 echo "        </tbody>\n";
 echo "    </table>\n";
 echo "</dd>\n";
 // Reflect the methods too
 $reflectionclass = new ReflectionClass($schema);
 $reflectionmethods = $reflectionclass->getMethods();
 if ($reflectionmethods) {
     echo "<dd>\n";
     echo "    <table>\n";
     echo "        <tbody>\n";
     echo "            <tr>\n";
     echo "                <th class='property'>" . midcom::get('i18n')->get_string('signature', 'midcom.admin.help') . "</th>\n";
     echo "                <th>" . midcom::get('i18n')->get_string('description', 'midcom.admin.help') . "</th>\n";
コード例 #3
0
ファイル: help.php プロジェクト: nemein/openpsa
 /**
  * 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);
 }