Ejemplo n.º 1
0
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $conf;
    global $lang;
    $query = cleanID($_POST['q']);
    if (empty($query)) {
        $query = cleanID($_GET['q']);
    }
    if (empty($query)) {
        return;
    }
    require_once DOKU_INC . 'inc/html.php';
    require_once DOKU_INC . 'inc/fulltext.php';
    $data = array();
    $data = ft_pageLookup($query);
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    foreach ($data as $id) {
        print '<li>';
        $ns = getNS($id);
        if ($ns) {
            $name = shorten(noNS($id), ' (' . $ns . ')', 30);
        } else {
            $name = $id;
        }
        print html_wikilink(':' . $id, $name);
        print '</li>';
    }
    print '</ul>';
}
Ejemplo n.º 2
0
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $conf;
    global $lang;
    global $INPUT;
    $query = $INPUT->post->str('q');
    if (empty($query)) {
        $query = $INPUT->get->str('q');
    }
    if (empty($query)) {
        return;
    }
    $query = urldecode($query);
    $data = ft_pageLookup($query, true, useHeading('navigation'));
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    foreach ($data as $id => $title) {
        if (useHeading('navigation')) {
            $name = $title;
        } else {
            $ns = getNS($id);
            if ($ns) {
                $name = noNS($id) . ' (' . $ns . ')';
            } else {
                $name = $id;
            }
        }
        echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
    }
    print '</ul>';
}
Ejemplo n.º 3
0
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $conf;
    global $lang;
    $query = $_POST['q'];
    if (empty($query)) {
        $query = $_GET['q'];
    }
    if (empty($query)) {
        return;
    }
    $data = ft_pageLookup($query, true, useHeading('navigation'));
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    foreach ($data as $id => $title) {
        if (useHeading('navigation')) {
            $name = $title;
        } else {
            $ns = getNS($id);
            if ($ns) {
                $name = shorten(noNS($id), ' (' . $ns . ')', 30);
            } else {
                $name = $id;
            }
        }
        echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
    }
    print '</ul>';
}
Ejemplo n.º 4
0
 function handle_start(&$event, $param)
 {
     global $ID;
     global $ACT;
     global $INFO;
     if ($ACT != 'show') {
         return;
     }
     if (!$INFO['exists']) {
         return;
     }
     # don't try to read an article that doesn't exist
     $all = rtrim(rawWiki($ID));
     $inner = substr($all, 2, -2);
     if ($all == '[[' . $inner . ']]' and strpos($inner, '[[') === false and strpos($inner, ']]') === false) {
         if (!strpos($inner, '://') === false) {
             $url = $inner;
             # link is URL already
         } else {
             msg(sprintf('From: <a href="' . wl($ID, 'do=edit') . '">' . hsc($ID) . '</a>'));
             $url = html_wikilink($inner, $name = null, $search = '');
             $url = substr($url, strpos($url, '"') + 1);
             $url = substr($url, 0, strpos($url, '"'));
         }
         idx_addPage($ID);
         # ensure fulltext search indexing of referrer article - to put it on the backlink page of target article
         send_redirect($url);
     }
 }
 /** 
  * Handle the match 
  */
 function handle($match, $state, $pos, &$handler)
 {
     // extract target page from match pattern
     $page = substr($match, 11, -2);
     // prepare message here instead of in render
     $message = '<div class="noteredirect">' . sprintf($this->getLang('redirect_to'), html_wikilink($page)) . '</div>';
     return array($page, $message);
 }
Ejemplo n.º 6
0
 /**
  * Handle the user input [required]
  *
  * @param helper_plugin_bureaucracy_field[] $fields the list of fields in the form
  * @param string                            $thanks the thank you message as defined in the form
  *                                                  or default one. Might be modified by the action
  *                                                  before returned
  * @param array                             $argv   additional arguments passed to the action
  * @return bool|string false on error, $thanks on success
  */
 public function run($fields, $thanks, $argv)
 {
     global $ID;
     // prepare replacements
     $this->prepareNamespacetemplateReplacements();
     $this->prepareDateTimereplacements();
     $this->prepareLanguagePlaceholder();
     $this->prepareNoincludeReplacement();
     $this->prepareFieldReplacements($fields);
     //handle arguments
     $page_to_modify = array_shift($argv);
     if ($page_to_modify === '_self') {
         # shortcut to modify the same page as the submitter
         $page_to_modify = $ID;
     } else {
         //resolve against page which contains the form
         resolve_pageid(getNS($ID), $page_to_modify, $ignored);
     }
     $template_section_id = cleanID(array_shift($argv));
     if (!page_exists($page_to_modify)) {
         msg(sprintf($this->getLang('e_pagenotexists'), html_wikilink($page_to_modify)), -1);
         return false;
     }
     // check auth
     //
     // This is an important point.  In order to be able to modify a page via this method ALL you need is READ access to the page
     // This is good for admins to be able to only allow people to modify a page via a certain method.  If you want to protect the page
     // from people to WRITE via this method, deny access to the form page.
     $auth = $this->aclcheck($page_to_modify);
     // runas
     if ($auth < AUTH_READ) {
         msg($this->getLang('e_denied'), -1);
         return false;
     }
     // fetch template
     $template = rawWiki($page_to_modify);
     if (empty($template)) {
         msg(sprintf($this->getLang('e_template'), $page_to_modify), -1);
         return false;
     }
     // do the replacements
     $template = $this->updatePage($template, $template_section_id);
     if (!$template) {
         msg(sprintf($this->getLang('e_failedtoparse'), $page_to_modify), -1);
         return false;
     }
     // save page
     saveWikiText($page_to_modify, $template, sprintf($this->getLang('summary'), $ID));
     //thanks message with redirect
     $link = wl($page_to_modify);
     return sprintf($this->getLang('pleasewait'), "<script type='text/javascript' charset='utf-8'>location.replace('{$link}')</script>", html_wikilink($page_to_modify));
 }
Ejemplo n.º 7
0
 /**
  * main hooks
  */
 function _prepend_to_edit(&$event, $param)
 {
     global $ID;
     if ($event->data != 'edit') {
         return;
     }
     if (!$this->_auth_check_all($ID)) {
         return;
     }
     $link = html_wikilink($ID . '?do=editx');
     $intro = $this->locale_xhtml('intro');
     $intro = str_replace('@LINK@', $link, $intro);
     print $intro;
 }
Ejemplo n.º 8
0
 public function xhtml()
 {
     global $ID;
     $ns = getNS($ID);
     list($files, $subprojects) = Projects_file::project_files($ns);
     $generated = array();
     $source = array();
     foreach ($files as $id => $file) {
         if ($file->type() == 'source') {
             $source[$id] = $file;
         } elseif ($file->type() == 'generated') {
             $generated[$id] = $file;
         }
     }
     ksort($generated);
     ksort($source);
     sort($subprojects);
     echo '<h1>Source files</h1>' . DOKU_LF;
     echo '<ul>' . DOKU_LF;
     echo '<li>' . create_button('source') . '</li>' . DOKU_LF;
     foreach ($source as $id => $file) {
         echo '<li>' . html_wikilink($id) . ': ' . download_button($id) . ', ' . delete_button($id) . '</li>' . DOKU_LF;
     }
     echo '</ul>' . DOKU_LF;
     echo '<h1>Generated files</h1>' . DOKU_LF;
     echo '<ul>' . DOKU_LF;
     echo '<li>' . create_button('generated') . '</li>' . DOKU_LF;
     foreach ($generated as $id => $file) {
         $make = make_button($id, $file->status() == PROJECTS_MADE);
         echo '<li>' . html_wikilink($id) . ': ' . download_button($id) . ', ' . delete_button($id) . ', ' . $make . '</li>' . DOKU_LF;
     }
     echo '</ul>' . DOKU_LF;
     echo '<h1>Subprojects</h1>' . DOKU_LF;
     echo '<ul>' . DOKU_LF;
     echo '<li>' . create_button($ID, 'project') . '</li>' . DOKU_LF;
     foreach ($subprojects as $sub) {
         echo '<li><a href="' . wl($sub . ':', array('do' => 'manage_files')) . '">' . noNS($sub) . '</a></li>' . DOKU_LF;
     }
     echo '</ul>' . DOKU_LF;
     if ($ns) {
         $name = getNS($ns);
         $id = $name . ':';
         if (!$name) {
             $id = '/';
             $name = '/ (root)';
         }
         echo '<h1>Parent projects</h1>' . DOKU_LF;
         echo '<ul><li><a href="' . wl($id, array('do' => 'manage_files')) . '">' . $name . '</a></li></ul>' . DOKU_LF;
     }
 }
Ejemplo n.º 9
0
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $lang;
    global $INPUT;
    $maxnumbersuggestions = 50;
    $query = $INPUT->post->str('q');
    if (empty($query)) {
        $query = $INPUT->get->str('q');
    }
    if (empty($query)) {
        return;
    }
    $query = urldecode($query);
    $data = ft_pageLookup($query, true, useHeading('navigation'));
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    $counter = 0;
    foreach ($data as $id => $title) {
        if (useHeading('navigation')) {
            $name = $title;
        } else {
            $ns = getNS($id);
            if ($ns) {
                /* Displays the Header of the Namespace-Page or of namespace:start as the Name of the NS */
                $ns_name = p_get_first_heading(getNS($id));
                if (!$ns_name) {
                    $ns_name = p_get_first_heading(getNS($id) . ':start');
                }
                $name = shorten(' [' . $ns_name . ']', 30);
            } else {
                $name = $id;
            }
        }
        echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
        $counter++;
        if ($counter > $maxnumbersuggestions) {
            echo '<li>...</li>';
            break;
        }
    }
    print '</ul>';
}
Ejemplo n.º 10
0
 /**
  * Handler to prepare matched data for the rendering process
  *
  * This function can only pass data to render() via its return value - render()
  * may be not be run during the object's current life.
  *
  * Usually you should only need the $match param.
  *
  * @param   string       $match   The text matched by the patterns
  * @param   int          $state   The lexer state for the match
  * @param   int          $pos     The character position of the matched text
  * @param   Doku_Handler $handler Reference to the Doku_Handler object
  * @return  array Return an array with all data you want to use in render
  */
 public function handle($match, $state, $pos, Doku_Handler $handler)
 {
     // extract target page from match pattern
     if ($match[0] == '#') {
         # #REDIRECT PAGE
         $page = substr($match, 10);
     } else {
         # ~~REDIRECT>PAGE~~
         $page = substr($match, 11, -2);
     }
     $page = trim($page);
     if (!preg_match('#^(https?)://#i', $page)) {
         $link = html_wikilink($page);
     } else {
         $link = '<a href="' . hsc($page) . '" class="urlextern">' . hsc($page) . '</a>';
     }
     // prepare message here instead of in render
     $message = '<div class="noteredirect">' . sprintf($this->getLang('redirect_to'), $link) . '</div>';
     return array($page, $message);
 }
Ejemplo n.º 11
0
 public function addDependence($dependence, $automatic)
 {
     $li = $this->newElement('li');
     $this->list->appendChild($li);
     $span = $this->newElement('span', array('use' => $dependence, 'class' => 'dependency'));
     $li->appendChild($span);
     $use = $this->loadElement(html_wikilink($dependence));
     $span->appendChild($use);
     if ($automatic) {
         $li->appendChild($this->newText('(automatic)'));
     } else {
         if ($this->editable) {
             $li->appendChild($this->newText('('));
             $input = $this->newElement('a', array('class' => 'remove_dependency action', 'use' => $dependence, 'href' => ''), 'remove');
             $li->appendChild($input);
             $li->appendChild($this->newText(')'));
         }
     }
 }
Ejemplo n.º 12
0
/**
 * Prints a link to a WikiPage
 *
 * Wrapper around html_wikilink
 *
 * @author Andreas Gohr <*****@*****.**>
 *
 * @param string      $id   page id
 * @param string|null $name the name of the link
 * @return bool true
 */
function tpl_pagelink($id, $name = null)
{
    print '<bdi>' . html_wikilink($id, $name) . '</bdi>';
    return true;
}
Ejemplo n.º 13
0
 /**
  * Renders the page link, plus tooltip, abstract, casing, etc...
  * @param string $id
  * @param bool $display
  * @param string $abstract
  * @param array $opt
  * @param bool $track_snippets
  * @param bool $raw => non-formatted (no html)
  * @return string
  */
 private function _html_wikilink($id, $display, $abstract, $opt, $track_snippets = true, $raw = false)
 {
     $id = strpos($id, ':') === false ? ':' . $id : $id;
     // : needed for root pages (root level)
     $link = html_wikilink($id, $display);
     $type = $opt['snippet']['type'];
     $inline = '';
     $after = '';
     if ($type == 'tooltip') {
         $tooltip = str_replace("\n\n", "\n", $abstract);
         $tooltip = htmlentities($tooltip, ENT_QUOTES, 'UTF-8');
         $link = $this->_add_tooltip($link, $tooltip);
     } elseif (in_array($type, array('quoted', 'plain', 'inline')) && $this->snippet_cnt > 0) {
         $short = $this->_shorten($abstract, $opt['snippet']['extent']);
         $short = htmlentities($short, ENT_QUOTES, 'UTF-8');
         if (!empty($short)) {
             if ($type == 'quoted' || $type == 'plain') {
                 $more = html_wikilink($id, 'more');
                 $after = trim($short);
                 $after = str_replace("\n\n", "\n", $after);
                 $after = str_replace("\n", '<br/>', $after);
                 $after = '<div class="' . $type . '">' . $after . $more . '</div>' . DOKU_LF;
             } elseif ($type == 'inline') {
                 $inline .= '<span class=inline>' . $short . '</span>';
             }
         }
     }
     $border = $opt['underline'] ? 'border' : '';
     if ($raw) {
         $wikilink = $link . $inline;
     } else {
         $wikilink = '<li class="' . $border . '">' . $link . $inline . DOKU_LF . $after . '</li>';
     }
     if ($track_snippets) {
         $this->snippet_cnt--;
     }
     return $wikilink;
 }
Ejemplo n.º 14
0
 /**
  * Handles the actual output creation.
  */
 function render($mode, &$renderer, $data)
 {
     global $lang;
     if ($mode == 'xhtml') {
         $renderer->info['cache'] = false;
         @(require_once DOKU_INC . 'inc/fulltext.php');
         $backlinks = ft_backlinks($data[0]);
         $renderer->doc .= '<div id="plugin__backlinks">' . DW_LF;
         if (!empty($backlinks)) {
             $renderer->doc .= '<ul class="idx">';
             foreach ($backlinks as $backlink) {
                 $name = p_get_metadata($backlink, 'title');
                 if (empty($name)) {
                     $name = $backlink;
                 }
                 $renderer->doc .= '<li><div class="li">';
                 $renderer->doc .= html_wikilink(':' . $backlink, $name, '');
                 $renderer->doc .= '</div></li>';
             }
             $renderer->doc .= '</ul>';
         } else {
             $renderer->doc .= "<strong>Plugin Backlinks: " . $lang['nothingfound'] . "</strong>";
         }
         $renderer->doc .= '</div>' . DW_LF;
         return true;
     }
     return false;
 }
Ejemplo n.º 15
0
                        <?php 
    tpl_img(900, 700);
    /* parameters: maximum width, maximum height (and more) */
    ?>

                        <div class="img_detail">
                            <?php 
    tpl_img_meta();
    ?>
                            <dl>
                            <?php 
    echo '<dt>' . $lang['reference'] . ':</dt>';
    $media_usage = ft_mediause($IMG, true);
    if (count($media_usage) > 0) {
        foreach ($media_usage as $path) {
            echo '<dd>' . html_wikilink($path) . '</dd>';
        }
    } else {
        echo '<dd>' . $lang['nothingfound'] . '</dd>';
    }
    ?>
                            </dl>
                            <p><?php 
    echo $lang['media_acl_warning'];
    ?>
</p>
                        </div>
                        <?php 
    //Comment in for Debug// dbg(tpl_img_getTag('Simple.Raw'));
    ?>
                    <?php 
/**
 * Hierarchical breadcrumbs with Bootstrap style
 *
 * This code was suggested as replacement for the usual breadcrumbs.
 * It only makes sense with a deep site structure.
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Nigel McNie <*****@*****.**>
 * @author Sean Coates <*****@*****.**>
 * @author <*****@*****.**>
 * @author Giuseppe Di Terlizzi <*****@*****.**>
 * @todo   May behave strangely in RTL languages
 *
 * @return bool
 */
function bootstrap3_youarehere()
{
    global $conf;
    global $ID;
    global $lang;
    // check if enabled
    if (!$conf['youarehere']) {
        return false;
    }
    $parts = explode(':', $ID);
    $count = count($parts);
    $semantic = bootstrap3_conf('semantic');
    echo '<ol class="breadcrumb"' . ($semantic ? ' itemscope itemtype="http://schema.org/BreadcrumbList"' : '') . '>';
    echo '<li>' . rtrim($lang['youarehere'], ':') . '</li>';
    // always print the startpage
    echo '<li' . ($semantic ? ' itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"' : '') . '>';
    tpl_link(wl($conf['start']), ($semantic ? '<span itemprop="name">' : '') . '<i class="fa fa-fw fa-home"></i>' . ($semantic ? '</span>' : ''), ($semantic ? ' itemprop="item" ' : '') . 'title="' . $conf['start'] . '"');
    echo '</li>';
    // print intermediate namespace links
    $part = '';
    for ($i = 0; $i < $count - 1; $i++) {
        $part .= $parts[$i] . ':';
        $page = $part;
        if ($page == $conf['start']) {
            continue;
        }
        // Skip startpage
        // output
        echo '<li' . ($semantic ? ' itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"' : '') . '>';
        $link = html_wikilink($page);
        $link = str_replace(' class="curid"', '', html_wikilink($page));
        if ($semantic) {
            $link = str_replace(array('<a', '<span'), array('<a itemprop="item" ', '<span itemprop="name" '), $link);
        }
        echo $link;
        echo '</li>';
    }
    // print current page, skipping start page, skipping for namespace index
    resolve_pageid('', $page, $exists);
    if (isset($page) && $page == $part . $parts[$i]) {
        echo '</ol>';
        return true;
    }
    $page = $part . $parts[$i];
    if ($page == $conf['start']) {
        echo '</ol>';
        return true;
    }
    echo '<li class="active"' . ($semantic ? ' itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"' : '') . '>';
    $link = html_wikilink($page);
    $link = str_replace(' class="curid"', '', html_wikilink($page));
    if ($semantic) {
        $link = str_replace(array('<a', '<span'), array('<a itemprop="item" ', '<span itemprop="name" '), $link);
    }
    echo $link;
    echo '</li>';
    echo '</ol>';
    return true;
}
/**
 * Hierarchical breadcrumbs with Bootstrap style
 *
 * This code was suggested as replacement for the usual breadcrumbs.
 * It only makes sense with a deep site structure.
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Nigel McNie <*****@*****.**>
 * @author Sean Coates <*****@*****.**>
 * @author <*****@*****.**>
 * @author Giuseppe Di Terlizzi <*****@*****.**>
 * @todo   May behave strangely in RTL languages
 *
 * @return bool
 */
function bootstrap3_youarehere()
{
    global $conf;
    global $ID;
    global $lang;
    // check if enabled
    if (!$conf['youarehere']) {
        return false;
    }
    $parts = explode(':', $ID);
    $count = count($parts);
    echo '<ol class="breadcrumb">';
    echo '<li>' . rtrim($lang['youarehere'], ':') . '</li>';
    // always print the startpage
    echo '<li>';
    tpl_link(wl($conf['start']), '<i class="fa fa-fw fa-home"></i>', 'title="' . $conf['start'] . '"');
    echo '</li>';
    // print intermediate namespace links
    $part = '';
    for ($i = 0; $i < $count - 1; $i++) {
        $part .= $parts[$i] . ':';
        $page = $part;
        if ($page == $conf['start']) {
            continue;
        }
        // Skip startpage
        // output
        echo '<li>';
        echo str_replace('curid', '', html_wikilink($page));
        echo '</li>';
    }
    // print current page, skipping start page, skipping for namespace index
    resolve_pageid('', $page, $exists);
    if (isset($page) && $page == $part . $parts[$i]) {
        echo '</ol>';
        return true;
    }
    $page = $part . $parts[$i];
    if ($page == $conf['start']) {
        echo '</ol>';
        return true;
    }
    echo '<li class="active">';
    echo str_replace('curid', '', html_wikilink($page));
    echo '</li>';
    echo '</ol>';
    return true;
}
 static function html_list_index($item)
 {
     global $ID;
     $ret = '';
     $base = ':' . $item['id'];
     $base = substr($base, strrpos($base, ':') + 1);
     if ($item['type'] == 'f') {
         $ret .= html_wikilink(':' . $item['id']);
     } else {
         $ret .= '<strong>' . trim(substr($item['id'], strrpos($item['id'], ':', -2)), ':') . '</strong>';
     }
     return $ret;
 }
Ejemplo n.º 19
0
 /**
  * List recent edits matching the given filter
  */
 function _list($filter)
 {
     global $conf;
     global $lang;
     echo '<hr /><br />';
     echo '<form action="" method="post"><div class="no">';
     echo '<input type="hidden" name="filter" value="' . hsc($filter) . '" />';
     formSecurityToken();
     $recents = getRecents(0, $this->max_lines);
     echo '<ul>';
     $cnt = 0;
     foreach ($recents as $recent) {
         if ($filter) {
             if (strpos(rawWiki($recent['id']), $filter) === false) {
                 continue;
             }
         }
         $cnt++;
         $date = strftime($conf['dformat'], $recent['date']);
         echo $recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT ? '<li class="minor">' : '<li>';
         echo '<div class="li">';
         echo '<input type="checkbox" name="revert[]" value="' . hsc($recent['id']) . '" checked="checked" id="revert__' . $cnt . '" />';
         echo '<label for="revert__' . $cnt . '">' . $date . '</label> ';
         echo '<a href="' . wl($recent['id'], "do=diff") . '">';
         $p = array();
         $p['src'] = DOKU_BASE . 'lib/images/diff.png';
         $p['width'] = 15;
         $p['height'] = 11;
         $p['title'] = $lang['diff'];
         $p['alt'] = $lang['diff'];
         $att = buildAttributes($p);
         echo "<img {$att} />";
         echo '</a> ';
         echo '<a href="' . wl($recent['id'], "do=revisions") . '">';
         $p = array();
         $p['src'] = DOKU_BASE . 'lib/images/history.png';
         $p['width'] = 12;
         $p['height'] = 14;
         $p['title'] = $lang['btn_revs'];
         $p['alt'] = $lang['btn_revs'];
         $att = buildAttributes($p);
         echo "<img {$att} />";
         echo '</a> ';
         echo html_wikilink(':' . $recent['id'], useHeading('navigation') ? NULL : $recent['id']);
         echo ' – ' . htmlspecialchars($recent['sum']);
         echo ' <span class="user">';
         echo $recent['user'] . ' ' . $recent['ip'];
         echo '</span>';
         echo '</div>';
         echo '</li>';
         @set_time_limit(10);
         flush();
     }
     echo '</ul>';
     echo '<p>';
     echo '<input type="submit" class="button" value="' . $this->getLang('revert') . '" /> ';
     printf($this->getLang('note2'), hsc($filter));
     echo '</p>';
     echo '</div></form>';
 }
 function handle_pageredirect_note(&$event, $param)
 {
     global $ID, $ACT;
     if ($ACT == 'show' || $ACT == '') {
         if (!$this->getConf('show_note')) {
             return;
         }
         if (isset($_GET['redirect']) && $_GET['redirect'] > 0 && $_GET['redirect'] < 6) {
             if (isset($_SESSION[DOKU_COOKIE]['redirect']) && $_SESSION[DOKU_COOKIE]['redirect'] != '') {
                 // we were redirected from another page, show it!
                 $page = $_SESSION[DOKU_COOKIE]['redirect'];
                 global $conf;
                 //$pagetitle = $conf['useheading'] ? p_get_first_heading($page) : $page;
                 //echo '<div class="noteredirect">'.sprintf($this->getLang('redirected_from'), '<a href="'.wl(':'.$page, Array('redirect' => 'no'), TRUE, '&').'" class="wikilink1" title="'.$page.'">'.$pagetitle.'</a>').'</div>';
                 echo '<div class="noteredirect">' . sprintf($this->getLang('redirected_from'), html_wikilink($page . '?redirect=no')) . '</div>';
                 unset($_SESSION[DOKU_COOKIE]['redirect']);
                 return true;
             }
         }
     }
     return true;
 }
Ejemplo n.º 21
0
 function render($format, &$renderer, $data)
 {
     if ($format != 'xhtml') {
         return;
     }
     global $ID;
     $svg_wiki_page = trim(substr($data[1], 6, -2));
     //name of wiki page containing SVG image
     resolve_pageid(getNS($ID), $svg_wiki_page, $exists);
     //resolve relative IDs
     //detect image size for stupid browsers (like firefox) - ugly (fails if svg does not contain information about it's size)
     $svg_dimensions = '';
     preg_match('/width="[0-9]+" height="[0-9]+"/', $data[1] . rawWiki($svg_wiki_page), $_);
     if (isset($_[0])) {
         $svg_dimensions = $_[0];
     }
     // Check alignment
     $ralign = (bool) preg_match('/^\\{\\{ /', $data[1]);
     $lalign = (bool) preg_match('/ \\}\\}$/', $data[1]);
     switch (true) {
         case $lalign & $ralign:
             $align = 'center';
             break;
         case $ralign:
             $align = 'right';
             break;
         case $lalign:
             $align = 'left';
             break;
         default:
             $align = '';
     }
     if ($data[0] === '<svg') {
         $svgenc = $this->svg_base64_encode($data[1]);
         $renderer->doc .= $this->svg_format_embed($svgenc, 'inline-svg@' . $ID, $svg_dimensions);
         return true;
     }
     if ($data[0] === '{{sv' || $data[0] === '{{ s') {
         $svglink = exportlink($svg_wiki_page, 'svg');
         $renderer->doc .= $this->svg_format_embed($svglink, 'image:' . htmlspecialchars($svg_wiki_page), $svg_dimensions, $align);
         $renderer->doc .= '<br /><small>' . html_wikilink($svg_wiki_page, 'svg@' . $svg_wiki_page) . '</small>';
         return true;
     }
     if ($data[0] === '{{SV' || $data[0] === '{{ S') {
         $svgenc = $this->svg_base64_encode(rawWiki($svg_wiki_page));
         $renderer->doc .= $this->svg_format_embed($svgenc, 'image:' . htmlspecialchars($svg_wiki_page), $svg_dimensions, $align);
         $renderer->doc .= '<br /><small>' . html_wikilink($svg_wiki_page, 'SVG@' . $svg_wiki_page) . '</small>';
         return true;
     }
 }
Ejemplo n.º 22
0
 /**
  * (Callback) Build content of item
  *
  * @param array $item
  * @return string
  */
 public function html_list_index($item)
 {
     $ret = '';
     if ($item['type'] == 'f') {
         $ret .= html_wikilink(':' . $item['id']);
     } else {
         $ret .= '<strong>' . trim(substr($item['id'], strrpos($item['id'], ':', -2)), ':') . '</strong>';
     }
     return $ret;
 }
Ejemplo n.º 23
0
 /**
  * Index item formatter
  *
  * User function for html_buildlist()
  *
  * @author Andreas Gohr <*****@*****.**>
  * modified by Samuele Tognini <*****@*****.**>
  */
 function _html_list_index($item)
 {
     $ret = '';
     //namespace
     if ($item['type'] == 'd' || $item['type'] == 'l') {
         $link = $item['id'];
         $more = 'idx=' . $item['id'];
         //namespace link
         if ($item['hns']) {
             $link = $item['hns'];
             $tagid = "indexmenu_idx_head";
             $more = '';
         } else {
             //namespace with headpage
             $tagid = "indexmenu_idx";
             if ($item['open']) {
                 $tagid .= ' open';
             }
         }
         $ret .= '<a href="' . wl($link, $more) . '" class="' . $tagid . '">';
         $ret .= $item['title'];
         $ret .= '</a>';
     } else {
         //page link
         $ret .= html_wikilink(':' . $item['id']);
     }
     return $ret;
 }
function generateLinks($naviID)
{
    global $INFO;
    global $ID;
    $id = $naviID;
    // fetch the instructions of the control page
    $instructions = p_cached_instructions(wikiFN($id), false, $id);
    // prepare some vars
    $max = count($instructions);
    $pre = true;
    $lvl = 0;
    $parents = array();
    $page = '';
    $cnt = 0;
    // build a lookup table
    for ($i = 0; $i < $max; $i++) {
        if ($instructions[$i][0] == 'listu_open') {
            $pre = false;
            $lvl++;
            if ($page) {
                array_push($parents, $page);
            }
        } elseif ($instructions[$i][0] == 'listu_close') {
            $lvl--;
            array_pop($parents);
        } elseif ($pre || $lvl == 0) {
            unset($instructions[$i]);
        } elseif ($instructions[$i][0] == 'listitem_close') {
            $cnt++;
        } elseif ($instructions[$i][0] == 'internallink') {
            $page = cleanID($instructions[$i][1][0]);
            $list[$page] = array('parents' => $parents, 'page' => $instructions[$i][1][0], 'title' => $instructions[$i][1][1], 'lvl' => $lvl);
        }
    }
    $list;
    $data = $list;
    $parent = (array) $data[$INFO['id']]['parents'];
    // get the "path" of the page we're on currently
    array_push($parent, $INFO['id']);
    //print_r($list);
    $navigation = array(1 => array(), 2 => array());
    foreach ((array) $data as $pid => $info) {
        // only show if we are in the "path"
        if (array_diff($info['parents'], $parent)) {
            continue;
        }
        // skip every non readable page
        if (auth_quickaclcheck(cleanID($info['page'])) < AUTH_READ) {
            continue;
        }
        $mylink = html_wikilink($info['page'], $info['title']);
        if (in_array(ltrim($info['page'], ':'), $parent) || in_array($info['page'], $parent)) {
            $mylink = '<span class="in-path">' . $mylink . '</span>';
        }
        array_push($navigation[$info['lvl']], $mylink);
    }
    return $navigation;
}
Ejemplo n.º 25
0
 /**
  * Initializes the labels, loaded from a defined labelpage
  *
  * @param array $data all data passed to render()
  */
 protected function loadlabels(&$data)
 {
     global $INFO;
     $labelpage = $data['labels'];
     $exists = false;
     resolve_pageid($INFO['namespace'], $labelpage, $exists);
     if (!$exists) {
         msg(sprintf($this->getLang('e_labelpage'), html_wikilink($labelpage)), -1);
         return;
     }
     // parse simple list (first level cdata only)
     $labels = array();
     $instructions = p_cached_instructions(wikiFN($labelpage));
     $inli = 0;
     $item = '';
     foreach ($instructions as $instruction) {
         if ($instruction[0] == 'listitem_open') {
             $inli++;
             continue;
         }
         if ($inli === 1 && $instruction[0] == 'cdata') {
             $item .= $instruction[1][0];
         }
         if ($instruction[0] == 'listitem_close') {
             $inli--;
             if ($inli === 0) {
                 list($k, $v) = explode('=', $item, 2);
                 $k = trim($k);
                 $v = trim($v);
                 if ($k && $v) {
                     $labels[$k] = $v;
                 }
                 $item = '';
             }
         }
     }
     // apply labels to all fields
     $len = count($data['fields']);
     for ($i = 0; $i < $len; $i++) {
         if (isset($data['fields'][$i]->depends_on)) {
             // translate dependency on fieldsets
             $label = $data['fields'][$i]->depends_on[0];
             if (isset($labels[$label])) {
                 $data['fields'][$i]->depends_on[0] = $labels[$label];
             }
         } else {
             if (isset($data['fields'][$i]->opt['label'])) {
                 // translate field labels
                 $label = $data['fields'][$i]->opt['label'];
                 if (isset($labels[$label])) {
                     $data['fields'][$i]->opt['display'] = $labels[$label];
                 }
             }
         }
     }
     if (isset($data['thanks'])) {
         if (isset($labels[$data['thanks']])) {
             $data['thanks'] = $labels[$data['thanks']];
         }
     }
 }
Ejemplo n.º 26
0
/**
 * Index item formatter
 *
 * User function for html_buildlist()
 *
 */
function _html_list_index($item)
{
    global $ID;
    global $conf;
    $ret = '';
    if ($item['type'] == 'd') {
        if (@file_exists(wikiFN($item['id'] . ':' . $conf['start']))) {
            $ret .= html_wikilink($item['id'] . ':' . $conf['start']);
        } else {
            $ret .= html_wikilink($item['id'] . ':');
        }
    } else {
        $ret .= html_wikilink(':' . $item['id']);
    }
    return $ret;
}
Ejemplo n.º 27
0
/**
 * Prints a link to a WikiPage
 *
 * Wrapper around html_wikilink
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function tpl_pagelink($id, $name = null)
{
    print html_wikilink($id, $name);
    return true;
}
        $value = tpl_img_getTag($t);
        if ($value) {
            echo '<dt>' . $lang[$tag[1]] . ':</dt><dd>';
            if ($tag[2] == 'date') {
                echo dformat($value);
            } else {
                echo hsc($value);
            }
            echo '</dd>';
        }
    }
    $t_array = media_inuse(tpl_img_getTag('IPTC.File.Name', $IMG));
    if (isset($t_array[0])) {
        echo '<dt>' . $lang['reference'] . ':</dt>';
        foreach ($t_array as $t) {
            echo '<dd>' . html_wikilink($t, $t) . '</dd>';
        }
    }
    ?>
                    </dl>
                    <?php 
    //Comment in for Debug// dbg(tpl_img_getTag('Simple.Raw'));
    ?>
                </div>
                <div class="clearer"></div>
            </div><!-- /.content -->

            <p class="back">
                <?php 
    $imgNS = getNS($IMG);
    $authNS = auth_quickaclcheck("{$imgNS}:*");
Ejemplo n.º 29
0
/**
 * display backlinks
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Michael Klier <*****@*****.**>
 */
function html_backlinks()
{
    global $ID;
    global $conf;
    global $lang;
    print p_locale_xhtml('backlinks');
    $data = ft_backlinks($ID);
    if (!empty($data)) {
        print '<ul class="idx">';
        foreach ($data as $blink) {
            print '<li><div class="li">';
            print html_wikilink(':' . $blink, useHeading('navigation') ? null : $blink);
            print '</div></li>';
        }
        print '</ul>';
    } else {
        print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
    }
}
Ejemplo n.º 30
0
 /**
  * Return the (localized) about link
  */
 function showAbout()
 {
     global $ID;
     global $conf;
     global $INFO;
     $curlc = $this->getLangPart($ID);
     $about = $this->getConf('about');
     if ($this->getConf('localabout')) {
         list($lc, $idpart) = $this->getTransParts($about);
         list($about, $name) = $this->buildTransID($curlc, $idpart);
         $about = cleanID($about);
     }
     $out = '';
     $out .= '<sup>';
     $out .= html_wikilink($about, '?');
     $out .= '</sup>';
     return $out;
 }