function showpageslist()
{
    global $nc;
    demoExecuteNanoSite();
    $cdt = getDetails('cats');
    $sett = getDetails('settings');
    $slugs = getDetails('slugs');
    $titles = getDetails('titles');
    $templateCats = $sett['def-template-links'];
    $defaultCats = explode(',', NANO_MUSTHAVE_CATS);
    $musthaveCats = array_unique(array_merge($templateCats, $defaultCats));
    $selectedCat = 1;
    $toggStat = 'false';
    if (isset($_GET[addcat])) {
        $newCatName = strtolower(stripslashes($_POST[catname]));
        if (in_array($newCatName, array_keys($cdt))) {
            $msg = sprintf(lt("Cannot add new Links Category : %s already exists", 'cat-add-fail-already-exists'), "<b>{$newCatName}</b>");
            MsgBox($msg);
        } else {
            $cdt[$newCatName] = array();
            $msg = sprintf(lt("Pages Category %s Added Successfully", 'cat-add-success'), "<b>{$newCatName}</b>");
            MsgBox($msg, 'greenbox');
            setDetails('cats', $cdt);
            savepages();
        }
    }
    if (isset($_GET[removecat])) {
        $catN = $_GET[removecat];
        if (!in_array($catN, array_keys($cdt))) {
            MsgBox(lt("Category to be deleted does not exist", 'cat-to-del-not-exists'), 'redbox');
        } else {
            if (in_array($catN, $musthaveCats)) {
                MsgBox("<b>{$catN}</b> : " . lt('Cannot be deleted'), 'redbox');
            } else {
                unset($cdt[$catN]);
                $msg = sprintf(lt("Pages Category %s was removed Successfully", 'cat-remove-success'), "<b>{$catN}</b>");
                MsgBox($msg, 'greenbox');
                setDetails('cats', $cdt);
                savepages();
            }
        }
    }
    if (isset($_GET[addtocat])) {
        $slug2add = $_POST[page];
        $cat2add = $_POST[cat];
        if (in_array($slug2add, $cdt[$cat2add])) {
            $msg = sprintf(lt("The page %s is already listed in %s", 'page-already-listed'), "<b>{$titles[$slug2add]}</b>", "<b>{$cat2add}</b>");
            MsgBox($msg);
        } else {
            array_push($cdt[$cat2add], $slug2add);
            $msg = sprintf(lt("The page %s was added successfully under %s", 'page-to-cat-add-success'), "<b>{$titles[$slug2add]}</b>", "<b>{$cat2add}</b>");
            MsgBox($msg);
            setDetails('cats', $cdt);
            savepages();
            $selectedCat = $cat2add;
            $toggStat = 'true';
        }
    }
    $catSelectList = array();
    foreach ($cdt as $cN => $cSC) {
        $catSelectList[$cN] = $cN;
    }
    $pagesAndOpt = lt('Pages & Category Options', 'page-and-cat-opt');
    $pagesListing = lt('Pages & Category Listing', 'page-and-cat-list');
    $addNewCat = lt('Add new Category');
    $addToAnotherCat = lt('Add page to another category', 'add-page-to-another-cat');
    $addLabel = lt('Add');
    $useUrlLabel = lt('Url you can use');
    $moveLabel = lt('Move');
    $optLabel = lt('Options');
    $pageLabel = lt('Page');
    echo "<a href='#nogo' class='nodeco'><h2 id='cat_anchor' class='cattitle'><span id='toggCon'></span>{$pagesAndOpt}</h2></a>\r\n\t\t\t<table id='cat_options'>\r\n\t\t\t <tr>\r\n\t\t\t \t<form action='?action=showpages&addcat=true' method='post'>\r\n\t\t\t\t<td>{$addNewCat} : </td><td><input type='text' name='catname'> <input type='submit' value='{$addLabel}'></td>\r\n\t\t\t\t</form>\r\n\t\t\t </tr>\r\n\t\t\t <tr>\r\n\t\t\t\t<form action='?action=showpages&addtocat=true' method='post'>\r\n\t\t\t\t<td>{$addToAnotherCat}</td><td>" . pagesList('page', $titles, 0) . " to " . pagesList('cat', $catSelectList, $selectedCat) . "\r\n\t\t\t\t\t <input type='submit' value='{$addLabel}'>\r\n\t\t\t\t</td>\r\n\t\t\t\t</form>\r\n\t\t\t </tr>\r\n\t\t\t</table>";
    $js = "catopt = new Toggle('cat_options',{$toggStat},'cat_anchor');catopt.setToggleContent( 'toggCon', '+', '-' );";
    $v = 0;
    echo "<h2>&raquo; {$pagesListing}</h2>";
    echo "<div class='linkcats-div'>";
    foreach ($cdt as $catname => $catslugs) {
        $v++;
        $slugids = array_values($catslugs);
        $n = count($slugids) - 1;
        if (!in_array($catname, $musthaveCats)) {
            $removeOpt = "( <a href='?action=showpages&removecat={$catname}'>remove</a> )";
        } else {
            $removeOpt = '';
        }
        //just user interface stuff
        $toggStat = $catname == $_SESSION[opencat] ? 'true' : 'false';
        if (!isset($_SESSION[opencat]) and $catname == 'sidebar') {
            $toggStat = true;
        }
        if ($catname == $_SESSION[opencat]) {
            $toggStat = 'true';
            unset($_SESSION[opencat]);
        } else {
            $toggStat == 'false';
        }
        $js .= "catopt{$v} = new Toggle('t{$v}',{$toggStat},'h2{$v}'); catopt{$v}.setToggleContent( 'co{$v}', '+', '-' );";
        echo "<a href='#nogo'><h2 class='cattitle noborder' id='h2{$v}'><span id='co{$v}' class='togg'>&raquo;</span> {$catname} {$removeOpt}</h2></a>";
        echo "<div class='borderWrap'>";
        echo "<table cellpadding='5px' cellspacing='2px'  width='100%' id='t{$v}' class='pageListTable'>";
        echo "<tr class='th'><th>{$pageLabel}</th><th>{$optLabel}</th><th colspan=2>{$moveLabel}</th><th>{$useUrlLabel}</th></tr>";
        if (count($slugids) == 0) {
            echo "<tr><td colspan='10' class='center'>" . lt('No pages are added under this category', 'no-pages-added') . "</td></tr></table>";
            continue;
        }
        foreach ($slugids as $pos => $ids) {
            $delTxt = lt('Delete');
            $editTxt = lt('Edit');
            $upTxt = lt('Up');
            $downTxt = lt('Down');
            $ul = makeLink("?action=reorder&cat={$catname}&param=" . $pos . ',' . ($pos - 1), '<img src="stuff/icons/arrow_up.png" alt="up" title="Move up"/>');
            $dl = makeLink("?action=reorder&cat={$catname}&param=" . $pos . ',' . ($pos + 1), '<img src="stuff/icons/arrow_down.png" alt="down" title="Move Down" />');
            if ($pos == 0) {
                $ul = '<img src="stuff/icons/arrow_up_d.png" alt="$upTxt" />';
            }
            if ($pos == $n) {
                $dl = '<img src="stuff/icons/arrow_down_d.png" alt="$downTxt" />';
            }
            $deleteConfirmMsg = lt("Are you sure you want to delete this page!! Remember Once you delete you cannot retreive again!! Proceed???", 'page-delete-confirm-msg');
            $s = "<tr>\r\n\t\t\t\t\t<td><b>" . $titles[$ids] . "</b></td>\r\n\t\t\t\t\t<td class='center'>\r\n\t\t\t\t\t\t<a href='?action=edit&slug=" . $slugs[$ids] . "'><img src='stuff/icons/page_edit.png' alt='{$editTxt}' title='{$editTxt}' /></a> |\r\n\t\t\t\t\t\t<a href='?action=delete&slug=" . $slugs[$ids] . "' onclick='return confirm(\"{$deleteConfirmMsg}\");'><img src='stuff/icons/cross.png' alt='{$delTxt}' title='{$delTxt}' /></a>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td>{$ul}</td>\r\n\t\t\t\t\t<td>{$dl}</td>\r\n\t\t\t\t\t<td>" . makeLink((NANO_SEFURL ? '../' : '') . slugUrl($slugs[$ids]), slugUrl($slugs[$ids])) . "</td>\r\n\t\t\t\t  </tr>";
            echo $s;
        }
        echo "</table>";
        echo "</div>";
    }
    echo "</div>";
    echo "\t<script language='javascript'>\r\n\t\t\t\t{$js}\r\n\t\t\t</script>";
}
Exemple #2
0
function show_links($link_cat, $format = '', $before = '', $after = '')
{
    $linklist = get_links_array($link_cat);
    if ($format == '') {
        $format = "<li>%s</li>";
    }
    if ($format == 'nolist') {
        $format = '%s';
    }
    foreach ($linklist as $slug => $title) {
        echo sprintf($format, $before . makeLink(slugUrl($slug), $title) . $after);
    }
}
Exemple #3
0
function show_links($link_cat, $format = '', $before = '', $after = '')
{
    $linklist = get_links_array($link_cat);
    runTweak('show-links', array($link_cat, &$linklist));
    if ($format == '') {
        $format = "<li>%s</li>";
    }
    if ($format == 'nolist') {
        $format = '%s';
    }
    $links_html = '';
    foreach ((array) $linklist as $slug => $title) {
        $links_html .= sprintf($format, makeLink(slugUrl($slug), $title));
    }
    echo $links_html = $before . $links_html . $after;
}