function showareas()
{
    doAreaEdit();
    global $indexTemplateAreas;
    //execute the nano site in demo to read the content areas
    demoExecuteNanoSite();
    $sett = getDetails('settings');
    $contents = $sett['def-template-areas'];
    $areaInfo = array();
    foreach ($contents as $areaName) {
        $areaFile = areaDataDir("{$areaName}");
        $fileContent = file_exists($areaFile) ? file_get_contents($areaFile) : '';
        $areaInfo[$areaName] = $fileContent;
    }
    $saveAllTxt = lt('Save all Areas');
    $biggerInp = lt('Bigger Input Box');
    $smallerInp = lt('Smaller Input Box');
    echo "<form action='?action=showareas&do=editarea' method='post'>";
    echo "<input type='submit' value='+ {$saveAllTxt} +' class='floatright'>";
    echo "<input type='hidden' name='areaCount' value='" . count($areaInfo) . "'>";
    $cnt = 1;
    foreach ($areaInfo as $areaName => $areaContents) {
        $boxId = "box{$cnt}";
        //md5($areaName);
        echo "<h2>&raquo; {$areaName}</h2>\r\n\t\t\t    <input type='hidden' name='areaName{$cnt}' value='{$areaName}'>\r\n\t\t\t\t<table><tr valign='top'><td>\r\n\t\t\t\t<textarea name='areaContent{$cnt}' rows='2' cols='60' id='{$boxId}' class='areabox'>" . htmlentities($areaContents) . "</textarea>\r\n\t\t\t\t</td><td>\r\n\t\t\t\t<input type='button' onclick='makesmall(\"{$boxId}\")' value='-' title='{$smallerInp}' class='isizeh'>\r\n\t\t\t\t<input type='button' onclick='makebig(\"{$boxId}\")' value='+' title='{$biggerInp}' class='isizeh'>\r\n\t\t\t\t</td></tr></table>\r\n\t\t\t ";
        $cnt++;
    }
    echo "<input type='submit' value='+ {$saveAllTxt} +' class='floatright'>";
    echo "</form>";
    echo "<script language='javascript'>\r\n\t\t\tfunction makebig(id) {\r\n\t\t\tobj = document.getElementById(id);\r\n\t\t\tif( obj.rows < 30 ) obj.rows+= 5;\r\n\t\t\t}\r\n\t\t\tfunction makesmall(id) {\r\n\t\t\tobj = document.getElementById(id);\r\n\t\t\tif( obj.rows > 5 ) obj.rows-= 5;\r\n\t\t\t}\r\n\t\t  </script>";
}
Esempio n. 2
0
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>";
}
Esempio n. 3
0
function showareas()
{
    global $indexTemplateAreas;
    //execute the nano site in demo to read the content areas
    demoExecuteNanoSite();
    $contents = $indexTemplateAreas;
    $contents = array_unique($contents);
    foreach ($contents as $areaName) {
        $areaFile = areaDataDir("{$areaName}");
        $fileContent = file_exists($areaFile) ? file_get_contents($areaFile) : '';
        $boxId = md5($areaFile);
        echo "<h2>{$areaName}</h2>\r\n\t\t\t  <form action='?action=editarea' method='post'>\r\n\t\t\t\t<textarea name='content' rows='2' cols='60' id='{$boxId}' class='areabox'>" . htmlentities($fileContent) . "</textarea>\r\n\t\t\t\t<input type='hidden' name='areaname' value='{$areaName}'><br />\r\n\t\t\t\t<input type='submit' value='Save'>\r\n\t\t\t\t<input type='button' onclick='makebig(\"{$boxId}\")' value='  +  ' title='Bigger Input'>\r\n\t\t\t\t<input type='button' onclick='makesmall(\"{$boxId}\")' value='  -  ' title='Smaller Input'>\r\n\t\t\t\t<input type='button' onclick='makenarrow(\"{$boxId}\")' value='  <  ' title='Narrower Input'>\r\n\t\t\t\t<input type='button' onclick='makewide(\"{$boxId}\")' value='  >  ' title='Wider Input'>\r\n\t\t\t  </form>";
    }
    echo "<script langua='javascript'>\r\n\t\t\tfunction makebig(id) {\r\n\t\t\tobj = document.getElementById(id);\r\n\t\t\tif( obj.rows < 30 ) obj.rows+= 3;\r\n\t\t\t}\r\n\t\t\tfunction makesmall(id) {\r\n\t\t\tobj = document.getElementById(id);\r\n\t\t\tif( obj.rows > 3 ) obj.rows-= 3;\r\n\t\t\t}\r\n\t\t\tfunction makewide(id) {\r\n\t\t\tobj = document.getElementById(id);\r\n\t\t\tif( obj.cols < 90 ) obj.cols+= 5;\r\n\t\t\t}\r\n\t\t\tfunction makenarrow(id) {\r\n\t\t\tobj = document.getElementById(id);\r\n\t\t\tif( obj.cols > 60 ) obj.cols-= 5;\r\n\t\t\t}\r\n\t\t  </script>";
}