当前位置: 首页>>代码示例>>PHP>>正文


PHP Doku_Event::advise_before方法代码示例

本文整理汇总了PHP中Doku_Event::advise_before方法的典型用法代码示例。如果您正苦于以下问题:PHP Doku_Event::advise_before方法的具体用法?PHP Doku_Event::advise_before怎么用?PHP Doku_Event::advise_before使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doku_Event的用法示例。


在下文中一共展示了Doku_Event::advise_before方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _tpl_toolsevent

/**
 * Create event for tools menues
 *
 * @author Anika Henke <anika@selfthinker.org>
 */
function _tpl_toolsevent($toolsname, $items, $view = 'main')
{
    $data = array('view' => $view, 'items' => $items);
    $hook = 'TEMPLATE_' . strtoupper($toolsname) . '_DISPLAY';
    $evt = new Doku_Event($hook, $data);
    if ($evt->advise_before()) {
        foreach ($evt->data['items'] as $k => $html) {
            echo $html;
        }
    }
    $evt->advise_after();
}
开发者ID:nicoverbruggen,项目名称:dw-writr-alt,代码行数:17,代码来源:tpl_functions.php

示例2: sendRequest

 /**
  * Wraps an event around the parent function
  *
  * @triggers HTTPCLIENT_REQUEST_SEND
  * @author   Andreas Gohr <andi@splitbrain.org>
  */
 function sendRequest($url, $data = '', $method = 'GET')
 {
     $httpdata = array('url' => $url, 'data' => $data, 'method' => $method);
     $evt = new Doku_Event('HTTPCLIENT_REQUEST_SEND', $httpdata);
     if ($evt->advise_before()) {
         $url = $httpdata['url'];
         $data = $httpdata['data'];
         $method = $httpdata['method'];
     }
     $evt->advise_after();
     unset($evt);
     return parent::sendRequest($url, $data, $method);
 }
开发者ID:ryankask,项目名称:dokuwiki,代码行数:19,代码来源:HTTPClient.php

示例3: white_toolsevent

/**
 * copied to core (available since Detritus)
 */
function white_toolsevent($toolsname, $items, $view = 'main')
{
    $data = array('view' => $view, 'items' => $items);
    $hook = 'TEMPLATE_' . strtoupper($toolsname) . '_DISPLAY';
    $evt = new Doku_Event($hook, $data);
    if ($evt->advise_before()) {
        $actions = array('export_pdf');
        foreach ($evt->data['items'] as $k => $html) {
            if (in_array($k, $actions)) {
                $html = str_replace(' ' . $k, ' plugin_' . $k, $html);
            }
            echo $html;
        }
    }
    $evt->advise_after();
}
开发者ID:ipari,项目名称:dokuwiki-template-white,代码行数:19,代码来源:tpl_functions.php

示例4: toolbar_JSdefines

/**
 * Prepares and prints an JavaScript array with all toolbar buttons
 *
 * @emits  TOOLBAR_DEFINE
 * @param  string $varname Name of the JS variable to fill
 * @author Andreas Gohr <andi@splitbrain.org>
 */
function toolbar_JSdefines($varname)
{
    global $lang;
    $menu = array();
    $evt = new Doku_Event('TOOLBAR_DEFINE', $menu);
    if ($evt->advise_before()) {
        // build button array
        $menu = array_merge($menu, array(array('type' => 'format', 'title' => $lang['qb_bold'], 'icon' => 'bold.png', 'key' => 'b', 'open' => '**', 'close' => '**', 'block' => false), array('type' => 'format', 'title' => $lang['qb_italic'], 'icon' => 'italic.png', 'key' => 'i', 'open' => '//', 'close' => '//', 'block' => false), array('type' => 'format', 'title' => $lang['qb_underl'], 'icon' => 'underline.png', 'key' => 'u', 'open' => '__', 'close' => '__', 'block' => false), array('type' => 'format', 'title' => $lang['qb_code'], 'icon' => 'mono.png', 'key' => 'c', 'open' => "''", 'close' => "''", 'block' => false), array('type' => 'format', 'title' => $lang['qb_strike'], 'icon' => 'strike.png', 'key' => 'd', 'open' => '<del>', 'close' => '</del>', 'block' => false), array('type' => 'autohead', 'title' => $lang['qb_hequal'], 'icon' => 'hequal.png', 'key' => '8', 'text' => $lang['qb_h'], 'mod' => 0, 'block' => true), array('type' => 'autohead', 'title' => $lang['qb_hminus'], 'icon' => 'hminus.png', 'key' => '9', 'text' => $lang['qb_h'], 'mod' => 1, 'block' => true), array('type' => 'autohead', 'title' => $lang['qb_hplus'], 'icon' => 'hplus.png', 'key' => '0', 'text' => $lang['qb_h'], 'mod' => -1, 'block' => true), array('type' => 'picker', 'title' => $lang['qb_hs'], 'icon' => 'h.png', 'class' => 'pk_hl', 'list' => array(array('type' => 'format', 'title' => $lang['qb_h1'], 'icon' => 'h1.png', 'key' => '1', 'open' => '====== ', 'close' => ' ======\\n'), array('type' => 'format', 'title' => $lang['qb_h2'], 'icon' => 'h2.png', 'key' => '2', 'open' => '===== ', 'close' => ' =====\\n'), array('type' => 'format', 'title' => $lang['qb_h3'], 'icon' => 'h3.png', 'key' => '3', 'open' => '==== ', 'close' => ' ====\\n'), array('type' => 'format', 'title' => $lang['qb_h4'], 'icon' => 'h4.png', 'key' => '4', 'open' => '=== ', 'close' => ' ===\\n'), array('type' => 'format', 'title' => $lang['qb_h5'], 'icon' => 'h5.png', 'key' => '5', 'open' => '== ', 'close' => ' ==\\n')), 'block' => true), array('type' => 'linkwiz', 'title' => $lang['qb_link'], 'icon' => 'link.png', 'key' => 'l', 'open' => '[[', 'close' => ']]', 'block' => false), array('type' => 'format', 'title' => $lang['qb_extlink'], 'icon' => 'linkextern.png', 'open' => '[[', 'close' => ']]', 'sample' => 'http://example.com|' . $lang['qb_extlink'], 'block' => false), array('type' => 'formatln', 'title' => $lang['qb_ol'], 'icon' => 'ol.png', 'open' => '  - ', 'close' => '', 'key' => '-', 'block' => true), array('type' => 'formatln', 'title' => $lang['qb_ul'], 'icon' => 'ul.png', 'open' => '  * ', 'close' => '', 'key' => '.', 'block' => true), array('type' => 'insert', 'title' => $lang['qb_hr'], 'icon' => 'hr.png', 'insert' => '\\n----\\n', 'block' => true), array('type' => 'mediapopup', 'title' => $lang['qb_media'], 'icon' => 'image.png', 'url' => 'lib/exe/mediamanager.php?ns=', 'name' => 'mediaselect', 'options' => 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes', 'block' => false), array('type' => 'picker', 'title' => $lang['qb_smileys'], 'icon' => 'smiley.png', 'list' => getSmileys(), 'icobase' => 'smileys', 'block' => false), array('type' => 'picker', 'title' => $lang['qb_chars'], 'icon' => 'chars.png', 'list' => explode(' ', 'À à Á á  â à ã Ä ä Ǎ ǎ Ă ă Å å Ā ā Ą ą Æ æ Ć ć Ç ç Č č Ĉ ĉ Ċ ċ Ð đ ð Ď ď È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ ĝ Ğ ğ Ġ ġ Ĥ ĥ Ì ì Í í Î î Ï ï Ǐ ǐ Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ Ł ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō ō Ő ő Œ œ Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ ŝ Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ Ý ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ Ə ə ∅ ∇ ∈ ∉ ∋ ∏ ∑ ‾ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦ α β Γ γ Δ δ ε ζ η Θ θ ι κ Λ λ μ Ξ ξ Π π ρ Σ σ Τ τ υ Φ φ χ Ψ ψ Ω ω ★ ☆ ☎ ☚ ☛ ☜ ☝ ☞ ☟ ☹ ☺ ✔ ✘ × „ “ ” ‚ ‘ ’ « » ‹ › — – … ← ↑ → ↓ ↔ ⇐ ⇑ ⇒ ⇓ ⇔ © ™ ® ′ ″ [ ] { } ~ ( ) % § $ # | @'), 'block' => false), array('type' => 'signature', 'title' => $lang['qb_sig'], 'icon' => 'sig.png', 'key' => 'y', 'block' => false)));
    }
    // end event TOOLBAR_DEFINE default action
    $evt->advise_after();
    unset($evt);
    // use JSON to build the JavaScript array
    $json = new JSON();
    print "var {$varname} = " . $json->encode($menu) . ";\n";
}
开发者ID:stretchyboy,项目名称:dokuwiki,代码行数:23,代码来源:toolbar.php

示例5: _preview_before

 /**
  * Triggers before preview xhtml render,
  * allows plugins to metadata render on the preview.
  */
 public function _preview_before(&$event, $param)
 {
     global $ACT;
     global $TEXT;
     global $SUF;
     global $PRE;
     global $ID;
     global $METADATA_RENDERERS;
     if ($ACT == 'preview') {
         $triples =& plugin_load('helper', 'strata_triples');
         $triples->beginPreview();
         $text = $PRE . $TEXT . $SUF;
         $orig = p_read_metadata($ID);
         // store the original metadata in the global $METADATA_RENDERERS so p_set_metadata can use it
         $METADATA_RENDERERS[$ID] =& $orig;
         // add an extra key for the event - to tell event handlers the page whose metadata this is
         $orig['page'] = $ID;
         $evt = new Doku_Event('STRATA_PREVIEW_METADATA_RENDER', $orig);
         if ($evt->advise_before()) {
             // get instructions
             $instructions = p_get_instructions($text);
             if (is_null($instructions)) {
                 unset($METADATA_RENDERERS[$ID]);
                 return null;
                 // something went wrong with the instructions
             }
             // set up the renderer
             $renderer = new renderer_plugin_strata();
             $renderer->meta =& $orig['current'];
             $renderer->persistent =& $orig['persistent'];
             // loop through the instructions
             foreach ($instructions as $instruction) {
                 // execute the callback against the renderer
                 call_user_func_array(array(&$renderer, $instruction[0]), (array) $instruction[1]);
             }
             $evt->result = array('current' => &$renderer->meta, 'persistent' => &$renderer->persistent);
         }
         $evt->advise_after();
         // clean up
         unset($METADATA_RENDERERS[$id]);
     }
 }
开发者ID:virk,项目名称:dokuwiki-strata,代码行数:46,代码来源:action.php

示例6: rss_buildItems

/**
 * Add recent changed pages to a feed object
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @param  object $rss - the FeedCreator Object
 * @param  array $data - the items to add
 * @param  array $opt  - the feed options
 */
function rss_buildItems(&$rss, &$data, $opt)
{
    global $conf;
    global $lang;
    global $auth;
    $eventData = array('rss' => &$rss, 'data' => &$data, 'opt' => &$opt);
    $event = new Doku_Event('FEED_DATA_PROCESS', $eventData);
    if ($event->advise_before(false)) {
        foreach ($data as $ditem) {
            if (!is_array($ditem)) {
                // not an array? then only a list of IDs was given
                $ditem = array('id' => $ditem);
            }
            $item = new FeedItem();
            $id = $ditem['id'];
            $meta = p_get_metadata($id);
            // add date
            if ($ditem['date']) {
                $date = $ditem['date'];
            } elseif ($meta['date']['modified']) {
                $date = $meta['date']['modified'];
            } else {
                $date = @filemtime(wikiFN($id));
            }
            if ($date) {
                $item->date = date('r', $date);
            }
            // add title
            if ($conf['useheading'] && $meta['title']) {
                $item->title = $meta['title'];
            } else {
                $item->title = $ditem['id'];
            }
            if ($conf['rss_show_summary'] && !empty($ditem['sum'])) {
                $item->title .= ' - ' . strip_tags($ditem['sum']);
            }
            // add item link
            switch ($opt['link_to']) {
                case 'page':
                    $item->link = wl($id, 'rev=' . $date, true, '&');
                    break;
                case 'rev':
                    $item->link = wl($id, 'do=revisions&rev=' . $date, true, '&');
                    break;
                case 'current':
                    $item->link = wl($id, '', true, '&');
                    break;
                case 'diff':
                default:
                    $item->link = wl($id, 'rev=' . $date . '&do=diff', true, '&');
            }
            // add item content
            switch ($opt['item_content']) {
                case 'diff':
                case 'htmldiff':
                    require_once DOKU_INC . 'inc/DifferenceEngine.php';
                    $revs = getRevisions($id, 0, 1);
                    $rev = $revs[0];
                    if ($rev) {
                        $df = new Diff(explode("\n", htmlspecialchars(rawWiki($id, $rev))), explode("\n", htmlspecialchars(rawWiki($id, ''))));
                    } else {
                        $df = new Diff(array(''), explode("\n", htmlspecialchars(rawWiki($id, ''))));
                    }
                    if ($opt['item_content'] == 'htmldiff') {
                        $tdf = new TableDiffFormatter();
                        $content = '<table>';
                        $content .= '<tr><th colspan="2" width="50%">' . $rev . '</th>';
                        $content .= '<th colspan="2" width="50%">' . $lang['current'] . '</th></tr>';
                        $content .= $tdf->format($df);
                        $content .= '</table>';
                    } else {
                        $udf = new UnifiedDiffFormatter();
                        $content = "<pre>\n" . $udf->format($df) . "\n</pre>";
                    }
                    break;
                case 'html':
                    $content = p_wiki_xhtml($id, $date, false);
                    // no TOC in feeds
                    $content = preg_replace('/(<!-- TOC START -->).*(<!-- TOC END -->)/s', '', $content);
                    // make URLs work when canonical is not set, regexp instead of rerendering!
                    if (!$conf['canonical']) {
                        $base = preg_quote(DOKU_REL, '/');
                        $content = preg_replace('/(<a href|<img src)="(' . $base . ')/s', '$1="' . DOKU_URL, $content);
                    }
                    break;
                case 'abstract':
                default:
                    $content = $meta['description']['abstract'];
            }
            $item->description = $content;
            //FIXME a plugin hook here could be senseful
            // add user
//.........这里部分代码省略.........
开发者ID:Harvie,项目名称:dokuwiki,代码行数:101,代码来源:feed.php

示例7: media_delete

/**
 * Handles media file deletions
 *
 * If configured, checks for media references before deletion
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @return mixed false on error, true on delete or array with refs
 */
function media_delete($id, $auth)
{
    if ($auth < AUTH_DELETE) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    global $conf;
    global $lang;
    $file = mediaFN($id);
    // trigger an event - MEDIA_DELETE_FILE
    $data['id'] = $id;
    $data['name'] = basename($file);
    $data['path'] = $file;
    $data['size'] = @file_exists($file) ? filesize($file) : 0;
    $data['unl'] = false;
    $data['del'] = false;
    $evt = new Doku_Event('MEDIA_DELETE_FILE', $data);
    if ($evt->advise_before()) {
        $data['unl'] = @unlink($file);
        if ($data['unl']) {
            addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
            $data['del'] = io_sweepNS($id, 'mediadir');
        }
    }
    $evt->advise_after();
    unset($evt);
    if ($data['unl'] && $data['del']) {
        // current namespace was removed. redirecting to root ns passing msg along
        send_redirect(DOKU_URL . 'lib/exe/mediamanager.php?msg1=' . rawurlencode(sprintf(noNS($id), $lang['deletesucc'])));
    }
    return $data['unl'];
}
开发者ID:jalemanyf,项目名称:wsnlocalizationscala,代码行数:42,代码来源:media.php

示例8: ft_snippet

/**
 * Creates a snippet extract
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @triggers FULLTEXT_SNIPPET_CREATE
 */
function ft_snippet($id, $highlight)
{
    $text = rawWiki($id);
    $text = str_replace("­", '', $text);
    // remove soft-hyphens
    $evdata = array('id' => $id, 'text' => &$text, 'highlight' => &$highlight, 'snippet' => '');
    $evt = new Doku_Event('FULLTEXT_SNIPPET_CREATE', $evdata);
    if ($evt->advise_before()) {
        $match = array();
        $snippets = array();
        $utf8_offset = $offset = $end = 0;
        $len = utf8_strlen($text);
        // build a regexp from the phrases to highlight
        $re1 = '(' . join('|', array_map('ft_snippet_re_preprocess', array_map('preg_quote_cb', array_filter((array) $highlight)))) . ')';
        $re2 = "{$re1}.{0,75}(?!\\1){$re1}";
        $re3 = "{$re1}.{0,45}(?!\\1){$re1}.{0,45}(?!\\1)(?!\\2){$re1}";
        for ($cnt = 4; $cnt--;) {
            if (0) {
            } else {
                if (preg_match('/' . $re3 . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
                } else {
                    if (preg_match('/' . $re2 . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
                    } else {
                        if (preg_match('/' . $re1 . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
                        } else {
                            break;
                        }
                    }
                }
            }
            list($str, $idx) = $match[0];
            // convert $idx (a byte offset) into a utf8 character offset
            $utf8_idx = utf8_strlen(substr($text, 0, $idx));
            $utf8_len = utf8_strlen($str);
            // establish context, 100 bytes surrounding the match string
            // first look to see if we can go 100 either side,
            // then drop to 50 adding any excess if the other side can't go to 50,
            $pre = min($utf8_idx - $utf8_offset, 100);
            $post = min($len - $utf8_idx - $utf8_len, 100);
            if ($pre > 50 && $post > 50) {
                $pre = $post = 50;
            } else {
                if ($pre > 50) {
                    $pre = min($pre, 100 - $post);
                } else {
                    if ($post > 50) {
                        $post = min($post, 100 - $pre);
                    } else {
                        // both are less than 50, means the context is the whole string
                        // make it so and break out of this loop - there is no need for the
                        // complex snippet calculations
                        $snippets = array($text);
                        break;
                    }
                }
            }
            // establish context start and end points, try to append to previous
            // context if possible
            $start = $utf8_idx - $pre;
            $append = $start < $end ? $end : false;
            // still the end of the previous context snippet
            $end = $utf8_idx + $utf8_len + $post;
            // now set it to the end of this context
            if ($append) {
                $snippets[count($snippets) - 1] .= utf8_substr($text, $append, $end - $append);
            } else {
                $snippets[] = utf8_substr($text, $start, $end - $start);
            }
            // set $offset for next match attempt
            //   substract strlen to avoid splitting a potential search success,
            //   this is an approximation as the search pattern may match strings
            //   of varying length and it will fail if the context snippet
            //   boundary breaks a matching string longer than the current match
            $utf8_offset = $utf8_idx + $post;
            $offset = $idx + strlen(utf8_substr($text, $utf8_idx, $post));
            $offset = utf8_correctIdx($text, $offset);
        }
        $m = "";
        $snippets = preg_replace('/' . $re1 . '/iu', $m . '$1' . $m, $snippets);
        $snippet = preg_replace('/' . $m . '([^' . $m . ']*?)' . $m . '/iu', '<strong class="search_hit">$1</strong>', hsc(join('... ', $snippets)));
        $evdata['snippet'] = $snippet;
    }
    $evt->advise_after();
    unset($evt);
    return $evdata['snippet'];
}
开发者ID:ngharaibeh,项目名称:Methodikos,代码行数:92,代码来源:fulltext.php

示例9: tpl_content_core

function tpl_content_core()
{
    global $ACT;
    global $TEXT;
    global $PRE;
    global $SUF;
    global $SUM;
    global $IDX;
    switch ($ACT) {
        case 'show':
            html_show();
            break;
        case 'preview':
            html_edit($TEXT);
            html_show($TEXT);
            break;
        case 'recover':
            html_edit($TEXT);
            break;
        case 'edit':
            html_edit();
            break;
        case 'draft':
            html_draft();
            break;
        case 'wordblock':
            html_edit($TEXT, 'wordblock');
            break;
        case 'search':
            html_search();
            break;
        case 'revisions':
            $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0;
            html_revisions($first);
            break;
        case 'diff':
            html_diff();
            break;
        case 'recent':
            if (is_array($_REQUEST['first'])) {
                $_REQUEST['first'] = array_keys($_REQUEST['first']);
                $_REQUEST['first'] = $_REQUEST['first'][0];
            }
            $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0;
            html_recent($first);
            break;
        case 'index':
            html_index($IDX);
            #FIXME can this be pulled from globals? is it sanitized correctly?
            break;
        case 'backlink':
            html_backlinks();
            break;
        case 'conflict':
            html_conflict(con($PRE, $TEXT, $SUF), $SUM);
            html_diff(con($PRE, $TEXT, $SUF), false);
            break;
        case 'locked':
            html_locked();
            html_edit();
            break;
        case 'login':
            html_login();
            break;
        case 'register':
            html_register();
            break;
        case 'resendpwd':
            html_resendpwd();
            break;
        case 'denied':
            print p_locale_xhtml('denied');
            break;
        case 'profile':
            html_updateprofile();
            break;
        case 'admin':
            tpl_admin();
            break;
        default:
            $evt = new Doku_Event('TPL_ACT_UNKNOWN', $ACT);
            if ($evt->advise_before()) {
                msg("Failed to handle command: " . hsc($ACT), -1);
            }
            $evt->advise_after();
            unset($evt);
            return false;
    }
    return true;
}
开发者ID:jalemanyf,项目名称:wsnlocalizationscala,代码行数:90,代码来源:template.php

示例10: idx_getPageWords

/**
 * Split a page into words
 *
 * Returns an array of word counts, false if an error occurred.
 * Array is keyed on the word length, then the word index.
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Christopher Smith <chris@jalakai.co.uk>
 */
function idx_getPageWords($page)
{
    global $conf;
    $swfile = DOKU_INC . 'inc/lang/' . $conf['lang'] . '/stopwords.txt';
    if (@file_exists($swfile)) {
        $stopwords = file($swfile);
    } else {
        $stopwords = array();
    }
    $body = '';
    $data = array($page, $body);
    $evt = new Doku_Event('INDEXER_PAGE_ADD', $data);
    if ($evt->advise_before()) {
        $data[1] .= rawWiki($page);
    }
    $evt->advise_after();
    unset($evt);
    list($page, $body) = $data;
    $body = strtr($body, "\r\n\t", '   ');
    $tokens = explode(' ', $body);
    $tokens = array_count_values($tokens);
    // count the frequency of each token
    // ensure the deaccented or romanised page names of internal links are added to the token array
    // (this is necessary for the backlink function -- there maybe a better way!)
    if ($conf['deaccent']) {
        $links = p_get_metadata($page, 'relation references');
        if (!empty($links)) {
            $tmp = join(' ', array_keys($links));
            // make a single string
            $tmp = strtr($tmp, ':', ' ');
            // replace namespace separator with a space
            $link_tokens = array_unique(explode(' ', $tmp));
            // break into tokens
            foreach ($link_tokens as $link_token) {
                if (isset($tokens[$link_token])) {
                    continue;
                }
                $tokens[$link_token] = 1;
            }
        }
    }
    $words = array();
    foreach ($tokens as $word => $count) {
        $arr = idx_tokenizer($word, $stopwords);
        $arr = array_count_values($arr);
        foreach ($arr as $w => $c) {
            $l = wordlen($w);
            if (isset($words[$l])) {
                $words[$l][$w] = $c * $count + (isset($words[$l][$w]) ? $words[$l][$w] : 0);
            } else {
                $words[$l] = array($w => $c * $count);
            }
        }
    }
    // arrive here with $words = array(wordlen => array(word => frequency))
    $index = array();
    //resulting index
    foreach (array_keys($words) as $wlen) {
        $word_idx = idx_getIndex('w', $wlen);
        foreach ($words[$wlen] as $word => $freq) {
            $wid = array_search("{$word}\n", $word_idx);
            if (!is_int($wid)) {
                $wid = count($word_idx);
                $word_idx[] = "{$word}\n";
            }
            if (!isset($index[$wlen])) {
                $index[$wlen] = array();
            }
            $index[$wlen][$wid] = $freq;
        }
        // save back word index
        if (!idx_saveIndex('w', $wlen, $word_idx)) {
            trigger_error("Failed to write word index", E_USER_ERROR);
            return false;
        }
    }
    return $index;
}
开发者ID:pijoter,项目名称:dokuwiki,代码行数:87,代码来源:indexer.php

示例11: p_render_metadata

/**
 * renders the metadata of a page
 *
 * @author Esther Brunner <esther@kaffeehaus.ch>
 */
function p_render_metadata($id, $orig)
{
    // make sure the correct ID is in global ID
    global $ID, $METADATA_RENDERERS;
    // avoid recursive rendering processes for the same id
    if (isset($METADATA_RENDERERS[$id])) {
        return $orig;
    }
    // store the original metadata in the global $METADATA_RENDERERS so p_set_metadata can use it
    $METADATA_RENDERERS[$id] =& $orig;
    $keep = $ID;
    $ID = $id;
    // add an extra key for the event - to tell event handlers the page whose metadata this is
    $orig['page'] = $id;
    $evt = new Doku_Event('PARSER_METADATA_RENDER', $orig);
    if ($evt->advise_before()) {
        require_once DOKU_INC . "inc/parser/metadata.php";
        // get instructions
        $instructions = p_cached_instructions(wikiFN($id), false, $id);
        if (is_null($instructions)) {
            $ID = $keep;
            unset($METADATA_RENDERERS[$id]);
            return null;
            // something went wrong with the instructions
        }
        // set up the renderer
        $renderer = new Doku_Renderer_metadata();
        $renderer->meta =& $orig['current'];
        $renderer->persistent =& $orig['persistent'];
        // loop through the instructions
        foreach ($instructions as $instruction) {
            // execute the callback against the renderer
            call_user_func_array(array(&$renderer, $instruction[0]), (array) $instruction[1]);
        }
        $evt->result = array('current' => &$renderer->meta, 'persistent' => &$renderer->persistent);
    }
    $evt->advise_after();
    // clean up
    $ID = $keep;
    unset($METADATA_RENDERERS[$id]);
    return $evt->result;
}
开发者ID:nextghost,项目名称:dokuwiki,代码行数:47,代码来源:parserutils.php

示例12: act_dispatch

/**
 * Call the needed action handlers
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @triggers ACTION_ACT_PREPROCESS
 * @triggers ACTION_HEADERS_SEND
 */
function act_dispatch()
{
    global $INFO;
    global $ACT;
    global $ID;
    global $QUERY;
    global $lang;
    global $conf;
    global $license;
    $preact = $ACT;
    // give plugins an opportunity to process the action
    $evt = new Doku_Event('ACTION_ACT_PREPROCESS', $ACT);
    if ($evt->advise_before()) {
        //sanitize $ACT
        $ACT = act_clean($ACT);
        //check if searchword was given - else just show
        $s = cleanID($QUERY);
        if ($ACT == 'search' && empty($s)) {
            $ACT = 'show';
        }
        //login stuff
        if (in_array($ACT, array('login', 'logout'))) {
            $ACT = act_auth($ACT);
        }
        //check if user is asking to (un)subscribe a page
        if ($ACT == 'subscribe') {
            try {
                $ACT = act_subscription($ACT);
            } catch (Exception $e) {
                msg($e->getMessage(), -1);
            }
        }
        //check permissions
        $ACT = act_permcheck($ACT);
        //register
        $nil = array();
        if ($ACT == 'register' && $_POST['save'] && register()) {
            $ACT = 'login';
        }
        if ($ACT == 'resendpwd' && act_resendpwd()) {
            $ACT = 'login';
        }
        //update user profile
        if ($ACT == 'profile') {
            if (!$_SERVER['REMOTE_USER']) {
                $ACT = 'login';
            } else {
                if (updateprofile()) {
                    msg($lang['profchanged'], 1);
                    $ACT = 'show';
                }
            }
        }
        //revert
        if ($ACT == 'revert') {
            if (checkSecurityToken()) {
                $ACT = act_revert($ACT);
            } else {
                $ACT = 'show';
            }
        }
        //save
        if ($ACT == 'save') {
            if (checkSecurityToken()) {
                $ACT = act_save($ACT);
            } else {
                $ACT = 'show';
            }
        }
        //cancel conflicting edit
        if ($ACT == 'cancel') {
            $ACT = 'show';
        }
        //draft deletion
        if ($ACT == 'draftdel') {
            $ACT = act_draftdel($ACT);
        }
        //draft saving on preview
        if ($ACT == 'preview') {
            $ACT = act_draftsave($ACT);
        }
        //edit
        if (($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']) {
            $ACT = act_edit($ACT);
        } else {
            unlock($ID);
            //try to unlock
        }
        //handle export
        if (substr($ACT, 0, 7) == 'export_') {
            $ACT = act_export($ACT);
        }
        //display some infos
//.........这里部分代码省略.........
开发者ID:JeromeS,项目名称:dokuwiki,代码行数:101,代码来源:actions.php

示例13: auth_pwgen

/**
 * Create a pronouncable password
 *
 * The $foruser variable might be used by plugins to run additional password
 * policy checks, but is not used by the default implementation
 *
 * @author   Andreas Gohr <andi@splitbrain.org>
 * @link     http://www.phpbuilder.com/annotate/message.php3?id=1014451
 * @triggers AUTH_PASSWORD_GENERATE
 *
 * @param  string $foruser username for which the password is generated
 * @return string  pronouncable password
 */
function auth_pwgen($foruser = '')
{
    $data = array('password' => '', 'foruser' => $foruser);
    $evt = new Doku_Event('AUTH_PASSWORD_GENERATE', $data);
    if ($evt->advise_before(true)) {
        $c = 'bcdfghjklmnprstvwz';
        //consonants except hard to speak ones
        $v = 'aeiou';
        //vowels
        $a = $c . $v;
        //both
        $s = '!$%&?+*~#-_:.;,';
        // specials
        //use thre syllables...
        for ($i = 0; $i < 3; $i++) {
            $data['password'] .= $c[auth_random(0, strlen($c) - 1)];
            $data['password'] .= $v[auth_random(0, strlen($v) - 1)];
            $data['password'] .= $a[auth_random(0, strlen($a) - 1)];
        }
        //... and add a nice number and special
        $data['password'] .= auth_random(10, 99) . $s[auth_random(0, strlen($s) - 1)];
    }
    $evt->advise_after();
    return $data['password'];
}
开发者ID:amondot,项目名称:dokuwiki_ynh,代码行数:38,代码来源:auth.php

示例14: _mixture_toolsevent

/**
 * Create event for tools menues, adapted from core to enable adding Fontawesome icons before echo
 *
 * @author Anika Henke <anika@selfthinker.org>
 * @param string $toolsname name of menu
 * @param array $items
 * @param string $view e.g. 'main', 'detail', ...
 */
function _mixture_toolsevent($toolsname, $items, $context)
{
    $data = array('view' => 'main', 'items' => $items);
    // Events triggered are: TEMPLATE_NAVTOOLS_DISPLAY, TEMPLATE_PAGETOOLS_DISPLAY, TEMPLATE_USERTOOLS_DISPLAY, TEMPLATE_SITETOOLS_DISPLAY
    $hook = 'TEMPLATE_' . strtoupper(str_replace("_", "", $toolsname)) . '_DISPLAY';
    $evt = new Doku_Event($hook, $data);
    if ($evt->advise_before()) {
        foreach ($evt->data['items'] as $k => $html) {
            $parts = explode('">', $html);
            // Adding proper Fonteawesome icons to plugins' page tools
            if (strpos($html, 'addtobook') !== false) {
                $html = '<li><a href="/doku.php?id=' . $ID . '&amp;do=addtobook" class="action addtobook" rel="nofollow" title="Ajouter au livre"><h1><i class="fa fa-file-pdf-o"></i></h1>Ajouter au livre</a></li>';
                $html = $parts[0] . '"><i class="fa fa-file-pdf-o"></i>' . _mixture_menuitem_string($parts[1], $context);
            } elseif (strpos($html, 'export_pdf') !== false) {
                $html = $parts[0] . '">' . _mixture_glyph('export_pdf', false) . _mixture_menuitem_string($parts[1], $context);
            } elseif (strpos($html, 'export_odt') !== false) {
                $html = $parts[0] . '">' . _mixture_glyph('export_odt', false) . _mixture_menuitem_string($parts[1], $context);
            } elseif (strpos($html, 'plugin_move_page') !== false) {
                $tooltip = str_replace("<span>", "", $parts[2]);
                $tooltip = str_replace("</span></a></li>", "", $tooltip);
                $link = '<a href="" class="action rename" rel="nofollow" title="' . $tooltip . '">';
                $parts[0] = '<li class="plugin_move_page"';
                $html = $parts[0] . '>' . $link . _mixture_glyph('rename', false) . _mixture_menuitem_string($parts[2], $context);
            }
            $html = str_replace('class="action', 'class="' . $toolsname . ' action', $html);
            if ($context == "fixed") {
                $html = str_replace('class=\'fa', 'class=\'fa fa-fw', $html);
            }
            echo $html;
        }
    }
    $evt->advise_after();
}
开发者ID:geekitude,项目名称:dokuwiki-template-mixture,代码行数:41,代码来源:tpl_functions.php

示例15: bootstrap3_toolsevent

/**
 * Create event for tools menues
 *
 * @author  Anika Henke <anika@selfthinker.org>
 * @author  Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
 *
 * @param   string   $toolsname name of menu
 * @param   array    $items
 * @param   string   $view e.g. 'main', 'detail', ...
 * @param   boolean  $return
 * @return  string
 */
function bootstrap3_toolsevent($toolsname, $items, $view = 'main', $return = false)
{
    $output = '';
    $data = array('view' => $view, 'items' => $items);
    $hook = 'TEMPLATE_' . strtoupper($toolsname) . '_DISPLAY';
    $evt = new Doku_Event($hook, $data);
    $search = array('<span>', '</span>');
    if ($evt->advise_before()) {
        foreach ($evt->data['items'] as $k => $html) {
            switch ($k) {
                case 'export_odt':
                    $icon = 'file-text';
                    break;
                case 'export_pdf':
                    $icon = 'file-pdf-o';
                    break;
                case 'plugin_move':
                    $icon = 'i-cursor text-muted';
                    $html = preg_replace('/<a href=""><span>(.*?)<\\/span>/', '<a href="" title="$1"><span>$1</span></a>', $html);
                    break;
                default:
                    $icon = 'puzzle-piece';
                    // Unknown
            }
            $replace = array('<i class="fa fa-fw fa-' . $icon . '"></i> ', '');
            $html = str_replace($search, $replace, $html);
            $output .= $html;
        }
    }
    $evt->advise_after();
    if ($return) {
        return $output;
    }
    echo $output;
}
开发者ID:ERTurner,项目名称:dokuwiki-template-bootstrap3,代码行数:47,代码来源:tpl_functions.php


注:本文中的Doku_Event::advise_before方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。