示例#1
0
/**
 * Lists pages which currently use a media file selected for deletion
 *
 * References uses the same visual as search results and share
 * their CSS tags except pagenames won't be links.
 *
 * @author Matthias Grimm <*****@*****.**>
 */
function media_filesinuse($data, $id)
{
    global $lang;
    echo '<h1>' . $lang['reference'] . ' <code>' . hsc(noNS($id)) . '</code></h1>';
    echo '<p>' . hsc($lang['ref_inuse']) . '</p>';
    $hidden = 0;
    //count of hits without read permission
    foreach ($data as $row) {
        if (auth_quickaclcheck($row) >= AUTH_READ && isVisiblePage($row)) {
            echo '<div class="search_result">';
            echo '<span class="mediaref_ref">' . hsc($row) . '</span>';
            echo '</div>';
        } else {
            $hidden++;
        }
    }
    if ($hidden) {
        print '<div class="mediaref_hidden">' . $lang['ref_hidden'] . '</div>';
    }
}
示例#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;
}
示例#3
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;
}
示例#4
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;
}