start
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| start [2024/01/16 23:36] – auretsky | start [2024/01/16 23:40] (current) – auretsky | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Electrical engineering ===== | ||
| ^ Heading 1 ^ Heading 2 ^ Heading 3 ^ | ^ Heading 1 ^ Heading 2 ^ Heading 3 ^ | ||
| | Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 | | | Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 | | ||
| Line 5: | Line 6: | ||
| - | + | ===== Mechanical engineering | |
| - | <?php | + | |
| - | /** | + | |
| - | * Plugin: Displays a link list in a nice way | + | |
| - | * | + | |
| - | * Syntax: <menu col=2,align=center, | + | |
| - | | + | |
| - | | + | |
| - | * | + | |
| - | * Options have to be separated by comma. | + | |
| - | * col (opt) The number of columns of the menu. Allowed are 1-4, default is 1 | + | |
| - | * align (opt) | + | |
| - | | + | |
| - | * caption (opt) Headline of the menu, default is none | + | |
| - | * | + | |
| - | * @license | + | |
| - | * @author | + | |
| - | * @author | + | |
| - | */ | + | |
| - | + | ||
| - | if(!defined(' | + | |
| - | if(!defined(' | + | |
| - | require_once(DOKU_PLUGIN.' | + | |
| - | + | ||
| - | /** | + | |
| - | * All DokuWiki plugins to extend the parser/ | + | |
| - | * need to inherit from this class | + | |
| - | */ | + | |
| - | class syntax_plugin_menu extends DokuWiki_Syntax_Plugin { | + | |
| - | + | ||
| - | var $rcmd = array(); | + | |
| - | + | ||
| - | function __construct() { | + | |
| - | } | + | |
| - | + | ||
| - | + | ||
| - | /** | + | |
| - | * Get an associative array with plugin info. | + | |
| - | * | + | |
| - | * <p> | + | |
| - | * The returned array holds the following fields: | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * (eg. syntax description)</ | + | |
| - | * </ | + | |
| - | * @param none | + | |
| - | * @return Array Information about this plugin class. | + | |
| - | * @public | + | |
| - | * @static | + | |
| - | */ | + | |
| - | function getInfo(){ | + | |
| - | return array( | + | |
| - | ' | + | |
| - | ' | + | |
| - | //' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ); | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Get the type of syntax this plugin defines. | + | |
| - | * | + | |
| - | * The type of this plugin is " | + | |
| - | * token and no other wiki commands shall be parsed between them. | + | |
| - | * | + | |
| - | * @param none | + | |
| - | * @return String < | + | |
| - | * @public | + | |
| - | * @static | + | |
| - | */ | + | |
| - | function getType(){ | + | |
| - | return ' | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Define how this plugin is handled regarding paragraphs. | + | |
| - | * | + | |
| - | * <p> | + | |
| - | * This method is important for correct XHTML nesting. It returns | + | |
| - | * one of the following values: | + | |
| - | * </ | + | |
| - | * < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * plugin output.</ | + | |
| - | * < | + | |
| - | * </ | + | |
| - | * @param none | + | |
| - | * @return String < | + | |
| - | * @public | + | |
| - | * @static | + | |
| - | */ | + | |
| - | function getPType(){ | + | |
| - | return ' | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Where to sort in? | + | |
| - | * | + | |
| - | * Sort the plugin in just behind the formating tokens | + | |
| - | * | + | |
| - | * @param none | + | |
| - | * @return Integer < | + | |
| - | * @public | + | |
| - | * @static | + | |
| - | */ | + | |
| - | function getSort(){ | + | |
| - | return 135; | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Connect lookup pattern to lexer. | + | |
| - | * | + | |
| - | * @param $aMode String The desired rendermode. | + | |
| - | * @return none | + | |
| - | * @public | + | |
| - | * @see render() | + | |
| - | */ | + | |
| - | function connectTo($mode) { | + | |
| - | | + | |
| - | | + | |
| - | } | + | |
| - | + | ||
| - | function postConnect() { | + | |
| - | $this-> | + | |
| - | $this-> | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Handler to prepare matched data for the rendering process. | + | |
| - | * | + | |
| - | * <p> | + | |
| - | * The < | + | |
| - | * which triggered the call to this method: | + | |
| - | * </ | + | |
| - | * < | + | |
| - | * < | + | |
| - | * <dd>a pattern set by < | + | |
| - | * < | + | |
| - | * <dd>a pattern set by < | + | |
| - | * < | + | |
| - | * <dd> a pattern set by < | + | |
| - | * < | + | |
| - | * <dd>a pattern set by < | + | |
| - | * < | + | |
| - | * < | + | |
| - | * which doesn' | + | |
| - | * </ | + | |
| - | * @param $aMatch String The text matched by the patterns. | + | |
| - | * @param $aState Integer The lexer state for the match. | + | |
| - | * @param $aPos Integer The character position of the matched text. | + | |
| - | * @param $aHandler Object Reference to the Doku_Handler object. | + | |
| - | * @return Integer The current lexer state for the match. | + | |
| - | * @public | + | |
| - | * @see render() | + | |
| - | * @static | + | |
| - | */ | + | |
| - | function handle($match, | + | |
| - | { | + | |
| - | switch ($state) { | + | |
| - | case DOKU_LEXER_ENTER: | + | |
| - | $this-> | + | |
| - | + | ||
| - | $opts = $this-> | + | |
| - | $col = $opts[' | + | |
| - | if (!empty($col) && is_numeric($col) && $col > 0 && $col < 5) | + | |
| - | $this-> | + | |
| - | if ($opts[' | + | |
| - | if ($opts[' | + | |
| - | if ($opts[' | + | |
| - | if ($opts[' | + | |
| - | if ($opts[' | + | |
| - | if ($opts[' | + | |
| - | if (!empty($opts[' | + | |
| - | $this-> | + | |
| - | if (!empty($opts[' | + | |
| - | $this-> | + | |
| - | if (!empty($opts[' | + | |
| - | $this-> | + | |
| - | $this-> | + | |
| - | break; | + | |
| - | case DOKU_LEXER_MATCHED: | + | |
| - | + | ||
| - | $menuitem = preg_split('/ | + | |
| - | + | ||
| - | $title = hsc($menuitem[0]); | + | |
| - | if (substr($menuitem[2], | + | |
| - | $link = $this-> | + | |
| - | else | + | |
| - | $link = $this-> | + | |
| - | $image = $this-> | + | |
| - | + | ||
| - | $this-> | + | |
| - | " | + | |
| - | " | + | |
| - | + | ||
| - | if (!empty($opts[' | + | |
| - | // find out how much space the biggest menu item needs | + | |
| - | $titlelen = mb_strlen($menuitem[0], | + | |
| - | if ($titlelen > $this-> | + | |
| - | $this-> | + | |
| - | } | + | |
| - | break; | + | |
| - | case DOKU_LEXER_EXIT: | + | |
| - | // give the menu a convinient width. IE6 needs more space here than Firefox | + | |
| - | if (!empty($opts[' | + | |
| - | $this-> | + | |
| - | } | + | |
| - | return $this-> | + | |
| - | default: | + | |
| - | break; | + | |
| - | } | + | |
| - | return array(); | + | |
| - | } | + | |
| - | + | ||
| - | function _reset() | + | |
| - | { | + | |
| - | $this-> | + | |
| - | $this-> | + | |
| - | $this-> | + | |
| - | $this-> | + | |
| - | } | + | |
| - | + | ||
| - | function _itemlink($match, | + | |
| - | // Strip the opening and closing markup | + | |
| - | $link = preg_replace(array('/ | + | |
| - | + | ||
| - | // Split title from URL | + | |
| - | $link = explode(' | + | |
| - | $ref = trim($link[0]); | + | |
| - | + | ||
| - | //decide which kind of link it is | + | |
| - | if ( preg_match('/ | + | |
| - | // Interwiki | + | |
| - | $interwiki = explode('>', | + | |
| - | return array(' | + | |
| - | | + | |
| - | } elseif ( preg_match('/ | + | |
| - | // Windows Share | + | |
| - | return array(' | + | |
| - | } elseif ( preg_match('# | + | |
| - | // external link (accepts all protocols) | + | |
| - | return array(' | + | |
| - | } elseif ( preg_match('<' | + | |
| - | // E-Mail (pattern above is defined in inc/ | + | |
| - | return array(' | + | |
| - | } elseif ( preg_match(' | + | |
| - | // local link | + | |
| - | return array(' | + | |
| - | } else { | + | |
| - | // internal link | + | |
| - | return array(' | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | function _itemimage($match, | + | |
| - | $p = Doku_Handler_Parse_Media($match); | + | |
| - | + | ||
| - | return array($p[' | + | |
| - | | + | |
| - | | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Handle the actual output creation. | + | |
| - | * | + | |
| - | * <p> | + | |
| - | * The method checks for the given < | + | |
| - | * < | + | |
| - | * contains a reference to the renderer object which is currently | + | |
| - | * handling the rendering. The contents of < | + | |
| - | * return value of the < | + | |
| - | * </ | + | |
| - | * @param $aFormat String The output format to generate. | + | |
| - | * @param $aRenderer Object A reference to the renderer object. | + | |
| - | * @param $aData Array The data created by the < | + | |
| - | * method. | + | |
| - | * @return Boolean < | + | |
| - | * < | + | |
| - | * @public | + | |
| - | * @see handle() | + | |
| - | */ | + | |
| - | function render($mode, | + | |
| - | + | ||
| - | if (empty($data)) return false; | + | |
| - | + | ||
| - | if($mode == ' | + | |
| - | if ($data[' | + | |
| - | $renderer-> | + | |
| - | $renderer-> | + | |
| - | if (isset($data[' | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | $width = floor(100 / $data[' | + | |
| - | + | ||
| - | foreach($data[' | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | // create <img .. /> tag | + | |
| - | list($type, $args) = $item[' | + | |
| - | list($ext, | + | |
| - | $class = ($ext == ' | + | |
| - | $img = $renderer-> | + | |
| - | + | ||
| - | // create <a href= .. /> tag | + | |
| - | list($type, $args) = $item[' | + | |
| - | $link = $this-> | + | |
| - | $link[' | + | |
| - | + | ||
| - | $link[' | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | $link[' | + | |
| - | $renderer-> | + | |
| - | $renderer-> | + | |
| - | $renderer-> | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | $renderer-> | + | |
| - | } | + | |
| - | + | ||
| - | $renderer-> | + | |
| - | + | ||
| - | // Clear left/right floats, unless the ' | + | |
| - | if (!$data[' | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | return true; | + | |
| - | } | + | |
| - | // menubar mode: 1 row with small captions | + | |
| - | if ($data[' | + | |
| - | $renderer-> | + | |
| - | // if (isset($data[' | + | |
| - | // $renderer-> | + | |
| - | + | ||
| - | foreach($data[' | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | // create <img .. /> tag | + | |
| - | list($type, $args) = $item[' | + | |
| - | list($ext, | + | |
| - | $class = ($ext == ' | + | |
| - | $img = $renderer-> | + | |
| - | + | ||
| - | // create <a href= .. /> tag | + | |
| - | list($type, $args) = $item[' | + | |
| - | $link = $this-> | + | |
| - | $link[' | + | |
| - | + | ||
| - | $link[' | + | |
| - | $renderer-> | + | |
| - | + | ||
| - | $link[' | + | |
| - | $renderer-> | + | |
| - | // | + | |
| - | $renderer-> | + | |
| - | } | + | |
| - | + | ||
| - | $renderer-> | + | |
| - | + | ||
| - | return true; | + | |
| - | } | + | |
| - | + | ||
| - | } | + | |
| - | return false; | + | |
| - | } | + | |
| - | + | ||
| - | function _createLink($url, | + | |
| - | { | + | |
| - | global $conf; | + | |
| - | + | ||
| - | $link = array(); | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | $link[' | + | |
| - | + | ||
| - | $link[' | + | |
| - | if ($target == ' | + | |
| - | //we stay at the same server, so use local target | + | |
| - | $link[' | + | |
| - | } | + | |
| - | + | ||
| - | return $link; | + | |
| - | } | + | |
| - | + | ||
| - | function _getLink($type, | + | |
| - | { | + | |
| - | global $ID; | + | |
| - | global $conf; | + | |
| - | + | ||
| - | $check = false; | + | |
| - | $exists = false; | + | |
| - | + | ||
| - | switch ($type) { | + | |
| - | case ' | + | |
| - | $url = $renderer-> | + | |
| - | $link = $this-> | + | |
| - | break; | + | |
| - | case ' | + | |
| - | $url = str_replace(' | + | |
| - | $url = ' | + | |
| - | $link = $this-> | + | |
| - | break; | + | |
| - | case ' | + | |
| - | $link = $this-> | + | |
| - | break; | + | |
| - | case ' | + | |
| - | $address = $renderer-> | + | |
| - | $address = obfuscate($address); | + | |
| - | if ($conf[' | + | |
| - | | + | |
| - | + | ||
| - | $link = $this-> | + | |
| - | $link[' | + | |
| - | break; | + | |
| - | case ' | + | |
| - | $hash = sectionID($args[0], | + | |
| - | $link = $this-> | + | |
| - | $link[' | + | |
| - | break; | + | |
| - | case ' | + | |
| - | resolve_pageid(getNS($ID), | + | |
| - | $url = wl($args[0]); | + | |
| - | list($id, | + | |
| - | if (!empty($hash)) $hash = sectionID($hash, | + | |
| - | if ($hash) $url .= '#' | + | |
| - | + | ||
| - | $link = $this-> | + | |
| - | $link[' | + | |
| - | break; | + | |
| - | case ' | + | |
| - | resolve_mediaid(getNS($ID), | + | |
| - | $url = ml($args[0], | + | |
| - | $link = $this-> | + | |
| - | if (!$exists) $link[' | + | |
| - | break; | + | |
| - | case ' | + | |
| - | $url = ml($args[0], | + | |
| - | $link = $this-> | + | |
| - | break; | + | |
| - | } | + | |
| - | return $link; | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Parse menu options | + | |
| - | * | + | |
| - | * | + | |
| - | * @param $string String Option string from < | + | |
| - | * @return array of options (name >= option). the array will be empty | + | |
| - | * if no options are found | + | |
| - | * @private | + | |
| - | */ | + | |
| - | function _parseOptions($string) { | + | |
| - | $data = array(); | + | |
| - | + | ||
| - | $dq = false; | + | |
| - | $iskey = true; | + | |
| - | $key | + | |
| - | $val | + | |
| - | + | ||
| - | $len = strlen($string); | + | |
| - | for ($i=0; $i< | + | |
| - | // done for this one? | + | |
| - | if ($string[$i] == ',' | + | |
| - | $key = trim($key); | + | |
| - | $val = trim($val); | + | |
| - | if($key && $val) $data[strtolower($key)] = $val; | + | |
| - | $iskey = true; | + | |
| - | $key = ''; | + | |
| - | $val = ''; | + | |
| - | continue; | + | |
| - | } | + | |
| - | + | ||
| - | // double quotes | + | |
| - | if ($string[$i] == '"' | + | |
| - | $dq = $dq ? false : true; | + | |
| - | continue; | + | |
| - | } | + | |
| - | + | ||
| - | // key value separator | + | |
| - | if ($string[$i] == ' | + | |
| - | $iskey = false; | + | |
| - | continue; | + | |
| - | } | + | |
| - | + | ||
| - | // default | + | |
| - | if ($iskey) | + | |
| - | $key .= $string[$i]; | + | |
| - | else | + | |
| - | $val .= $string[$i]; | + | |
| - | } | + | |
| - | return $data; | + | |
| - | } | + | |
| - | + | ||
| - | } | + | |
| - | + | ||
| - | //Setup VIM: ex: et ts=4 enc=utf-8 : | + | |
| - | ?> | + | |
start.1705448197.txt.gz · Last modified: 2024/01/16 23:36 by auretsky