function isBlog()
{
    if (getRootNS(getID()) == 'blog' || noNSorNS(getID()) == 'blog') {
        return true;
    } else {
        return false;
    }
}
Beispiel #2
0
function _ft_pageLookup(&$data)
{
    // split out original parameters
    $id = $data['id'];
    if (preg_match('/(?:^| )@(\\w+)/', $id, $matches)) {
        $ns = cleanID($matches[1]) . ':';
        $id = str_replace($matches[0], '', $id);
    }
    $in_ns = $data['in_ns'];
    $in_title = $data['in_title'];
    $cleaned = cleanID($id);
    $Indexer = idx_get_indexer();
    $page_idx = $Indexer->getPages();
    $pages = array();
    if ($id !== '' && $cleaned !== '') {
        foreach ($page_idx as $p_id) {
            if (strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false) {
                if (!isset($pages[$p_id])) {
                    $pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER);
                }
            }
        }
        if ($in_title) {
            foreach ($Indexer->lookupKey('title', $id, '_ft_pageLookupTitleCompare') as $p_id) {
                if (!isset($pages[$p_id])) {
                    $pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER);
                }
            }
        }
    }
    if (isset($ns)) {
        foreach (array_keys($pages) as $p_id) {
            if (strpos($p_id, $ns) !== 0) {
                unset($pages[$p_id]);
            }
        }
    }
    // discard hidden pages
    // discard nonexistent pages
    // check ACL permissions
    foreach (array_keys($pages) as $idx) {
        if (!isVisiblePage($idx) || !page_exists($idx) || auth_quickaclcheck($idx) < AUTH_READ) {
            unset($pages[$idx]);
        }
    }
    uksort($pages, 'ft_pagesorter');
    return $pages;
}
Beispiel #3
0
/**
 * This builds the breadcrumb trail and returns it as array
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function breadcrumbs()
{
    // we prepare the breadcrumbs early for quick session closing
    static $crumbs = null;
    if ($crumbs != null) {
        return $crumbs;
    }
    global $ID;
    global $ACT;
    global $conf;
    //first visit?
    $crumbs = isset($_SESSION[DOKU_COOKIE]['bc']) ? $_SESSION[DOKU_COOKIE]['bc'] : array();
    //we only save on show and existing wiki documents
    $file = wikiFN($ID);
    if ($ACT != 'show' || !@file_exists($file)) {
        $_SESSION[DOKU_COOKIE]['bc'] = $crumbs;
        return $crumbs;
    }
    // page names
    $name = noNSorNS($ID);
    if (useHeading('navigation')) {
        // get page title
        $title = p_get_first_heading($ID, METADATA_RENDER_USING_SIMPLE_CACHE);
        if ($title) {
            $name = $title;
        }
    }
    //remove ID from array
    if (isset($crumbs[$ID])) {
        unset($crumbs[$ID]);
    }
    //add to array
    $crumbs[$ID] = $name;
    //reduce size
    while (count($crumbs) > $conf['breadcrumbs']) {
        array_shift($crumbs);
    }
    //save to session
    $_SESSION[DOKU_COOKIE]['bc'] = $crumbs;
    return $crumbs;
}
Beispiel #4
0
 /**
  * Removes any Namespace from the given name but keeps
  * casing and special chars
  *
  * @author Andreas Gohr <*****@*****.**>
  */
 function _simpleTitle($name)
 {
     global $conf;
     //if there is a hash we use the ancor name only
     list($name, $hash) = explode('#', $name, 2);
     if ($hash) {
         return $hash;
     }
     $name = strtr($name, ';', ':');
     if ($conf['useslash']) {
         $name = strtr($name, '/', ':');
     }
     return noNSorNS($name);
 }
function bootstrap3_page_browser_title()
{
    global $conf, $ACT, $ID;
    if (bootstrap3_conf('browserTitleShowNS') && $ACT == 'show') {
        $ns_parts = explode(':', $ID);
        $ns_pages = array();
        $ns_titles = array();
        $ns_separator = sprintf(' %s ', bootstrap3_conf('browserTitleCharSepNS'));
        if (useHeading('navigation')) {
            if (count($ns_parts) > 1) {
                foreach ($ns_parts as $ns_part) {
                    $ns_page .= "{$ns_part}:";
                    $ns_pages[] = $ns_page;
                }
                $ns_pages = array_unique($ns_pages);
                foreach ($ns_pages as $ns_page) {
                    resolve_pageid(getNS($ns_page), $ns_page, $exists);
                    $ns_page_title_heading = hsc(p_get_first_heading($ns_page));
                    $ns_page_title_page = noNSorNS($ns_page);
                    $ns_page_title = $exists ? $ns_page_title_heading : $ns_page_title_page;
                    if ($ns_page_title !== $conf['start']) {
                        $ns_titles[] = $ns_page_title;
                    }
                }
            }
            resolve_pageid(getNS($ID), $ID, $exists);
            if ($exists) {
                $ns_titles[] = tpl_pagetitle($ID, true);
            }
            $ns_titles = array_filter(array_unique($ns_titles));
        } else {
            $ns_titles = $ns_parts;
        }
        if (bootstrap3_conf('browserTitleOrderNS') == 'normal') {
            $ns_titles = array_reverse($ns_titles);
        }
        $browser_title = implode($ns_separator, $ns_titles);
    } else {
        $browser_title = tpl_pagetitle($ID, true);
    }
    return str_replace(array('@WIKI@', '@TITLE@'), array(strip_tags($conf['title']), $browser_title), bootstrap3_conf('browserTitle'));
}
 /**
  * Creates a link to an annotation page per Purple Number.
  */
 function _getAnnotationLink()
 {
     $annotationPage = $this->getConf('annotationPage');
     if ($annotationPage) {
         global $ID;
         // resolve placeholders
         $aID = str_replace(array('@PN@', '@PNID@', '@ID@', '@PAGE@'), array($this->_getID(0, 0, 1, 1), $this->_getID(0, 0, 0, 1), $ID, noNSorNS($ID)), $annotationPage);
         // in case linkText is only a pilcrow, only show the icon
         $onlyIcon = $this->getConf('linkText') ? '' : 'onlyIcon';
         $sep = $onlyIcon ? '&nbsp;' : ' ';
         return $sep . '<span class="pn ' . $onlyIcon . '">' . html_wikilink($aID, $this->getLang('comment')) . '</span>';
     }
     return '';
 }
Beispiel #7
0
function _ft_pageLookup(&$data)
{
    // split out original parameters
    $id = $data['id'];
    if (preg_match('/(?:^| )@(\\w+)/', $id, $matches)) {
        $ns = cleanID($matches[1]) . ':';
        $id = str_replace($matches[0], '', $id);
    }
    $in_ns = $data['in_ns'];
    $in_title = $data['in_title'];
    $pages = array_map('rtrim', idx_getIndex('page', ''));
    $titles = array_map('rtrim', idx_getIndex('title', ''));
    $pages = array_combine($pages, $titles);
    if ($id !== '' && cleanID($id) !== '') {
        $cleaned = cleanID($id);
        $matched_pages = array();
        foreach ($pages as $p_id => $p_title) {
            if ((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false || $in_title && stripos($p_title, $id) !== false) && (!isset($ns) || strpos($p_id, $ns) === 0)) {
                $matched_pages[$p_id] = $p_title;
            }
        }
        $pages = $matched_pages;
    }
    // discard hidden pages
    // discard nonexistent pages
    // check ACL permissions
    foreach (array_keys($pages) as $idx) {
        if (!isVisiblePage($idx) || !page_exists($idx) || auth_quickaclcheck($idx) < AUTH_READ) {
            unset($pages[$idx]);
        }
    }
    uasort($pages, 'ft_pagesorter');
    return $pages;
}
/**
 * Simple wrapper for tpl_getConf
 *
 * @author  Giuseppe Di Terlizzi <*****@*****.**>
 *
 * @param   string  $key
 * @param   mixed   $default value
 * @return  mixed
 */
function bootstrap3_conf($key, $default = false)
{
    global $ACT, $INFO, $ID, $conf;
    $value = tpl_getConf($key, $default);
    switch ($key) {
        case 'showTools':
        case 'showSearchForm':
        case 'showPageTools':
            return $value !== 'never' && ($value == 'always' || !empty($_SERVER['REMOTE_USER']));
        case 'showIndividualTool':
        case 'hideInThemeSwitcher':
        case 'tableStyle':
            return explode(',', $value);
        case 'showAdminMenu':
            return $value && $INFO['isadmin'];
        case 'hideLoginLink':
            return !$value || !empty($_SERVER['REMOTE_USER']);
        case 'browserTitle':
            if (bootstrap3_conf('browserTitleShowNS')) {
                $ns_parts = explode(':', $ID);
                $ns_pages = array();
                $ns_titles = array();
                $ns_separator = sprintf(' %s ', bootstrap3_conf('browserTitleCharSepNS'));
                if (useHeading('navigation')) {
                    foreach ($ns_parts as $ns_part) {
                        $ns_page .= "{$ns_part}:";
                        $ns_pages[] = $ns_page;
                    }
                    $ns_pages = array_unique($ns_pages);
                    foreach ($ns_pages as $ns_page) {
                        resolve_pageid(getNS($ns_page), $ns_page, $exists);
                        $ns_page_title_heading = hsc(p_get_first_heading($ns_page));
                        $ns_page_title_page = noNSorNS($ns_page);
                        $ns_page_title = $ns_page_title_heading ? $ns_page_title_heading : $ns_page_title_page;
                        $ns_titles[] = $ns_page_title;
                    }
                    $ns_titles[] = tpl_pagetitle($ID, true);
                    $ns_titles = array_unique($ns_titles);
                } else {
                    $ns_titles = $ns_parts;
                }
                if (bootstrap3_conf('browserTitleOrderNS') == 'normal') {
                    $ns_titles = array_reverse($ns_titles);
                }
                $browser_title = implode($ns_separator, $ns_titles);
            } else {
                $browser_title = tpl_pagetitle($ID, true);
            }
            return str_replace(array('@WIKI@', '@TITLE@'), array(strip_tags($conf['title']), $browser_title), $value);
        case 'showSidebar':
            return page_findnearest($conf['sidebar']) && $ACT == 'show';
        case 'showRightSidebar':
            return page_findnearest(tpl_getConf('rightSidebar')) && $ACT == 'show';
        case 'landingPages':
            return sprintf('/%s/', $value);
    }
    //$type = bootstrap3_metadata($key);
    //if ($type[0] == 'regex') {
    //  return sprintf('/%s/', $value);
    //}
    return $value;
}
Beispiel #9
0
function _ft_pageLookup(&$data)
{
    global $conf;
    // split out original parameters
    $id = $data['id'];
    if (preg_match('/(?:^| )@(\\w+)/', $id, $matches)) {
        $ns = cleanID($matches[1]) . ':';
        $id = str_replace($matches[0], '', $id);
    }
    $in_ns = $data['in_ns'];
    $in_title = $data['in_title'];
    $pages = array_map('rtrim', idx_getIndex('page', ''));
    $titles = array_map('rtrim', idx_getIndex('title', ''));
    // check for corrupt title index #FS2076
    if (count($pages) != count($titles)) {
        $titles = array_fill(0, count($pages), '');
        @unlink($conf['indexdir'] . '/title.idx');
        // will be rebuilt in inc/init.php
    }
    $pages = array_combine($pages, $titles);
    $cleaned = cleanID($id);
    if ($id !== '' && $cleaned !== '') {
        foreach ($pages as $p_id => $p_title) {
            if (strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) === false && (!$in_title || stripos($p_title, $id) === false)) {
                unset($pages[$p_id]);
            }
        }
    }
    if (isset($ns)) {
        foreach (array_keys($pages) as $p_id) {
            if (strpos($p_id, $ns) !== 0) {
                unset($pages[$p_id]);
            }
        }
    }
    // discard hidden pages
    // discard nonexistent pages
    // check ACL permissions
    foreach (array_keys($pages) as $idx) {
        if (!isVisiblePage($idx) || !page_exists($idx) || auth_quickaclcheck($idx) < AUTH_READ) {
            unset($pages[$idx]);
        }
    }
    uksort($pages, 'ft_pagesorter');
    return $pages;
}
function tpl_pageName($id)
{
    // page names
    $name = noNSorNS($id);
    if (useHeading('navigation')) {
        // get page title
        $title = p_get_first_heading($id, METADATA_RENDER_USING_SIMPLE_CACHE);
        if ($title) {
            $name = $title;
        }
    }
    return $name;
}
Beispiel #11
0
function processTrailArrayForPrinting($trail)
{
    $data = array();
    foreach ($trail as $jump) {
        $pageId = $jump['page'];
        $name = noNSorNS($pageId);
        $title = get_first_heading($pageId);
        if (isset($title)) {
            $name = $title;
        }
        $r['id'] = $pageId;
        $r['section'] = $jump['section'];
        $r['name'] = $name;
        $r['flag'] = $jump['flag'];
        $data[] = $r;
    }
    return $data;
}
/**
 * This builds the breadcrumb trail and returns it as array
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function breadcrumbs()
{
    // we prepare the breadcrumbs early for quick session closing
    $crumbs = null;
    if ($crumbs != null) {
        return $crumbs;
    }
    global $ID;
    global $ACT;
    global $conf;
    $crumbs = $_SESSION[DOKU_COOKIE]['bc'];
    //first visit?
    if (!is_array($crumbs)) {
        $crumbs = array();
    }
    //we only save on show and existing wiki documents
    $file = wikiFN($ID);
    if ($ACT != 'show' || !@file_exists($file)) {
        $_SESSION[DOKU_COOKIE]['bc'] = $crumbs;
        return $crumbs;
    }
    // page names
    $name = noNSorNS($ID);
    if ($conf['useheading']) {
        // get page title
        $title = p_get_first_heading($ID, true);
        if ($title) {
            $name = $title;
        }
    }
    //remove ID from array
    if (isset($crumbs[$ID])) {
        unset($crumbs[$ID]);
    }
    //add to array
    $crumbs[$ID] = $name;
    //reduce size
    while (count($crumbs) > $conf['breadcrumbs']) {
        array_shift($crumbs);
    }
    //save to session
    $_SESSION[DOKU_COOKIE]['bc'] = $crumbs;
    return $crumbs;
}