function nanoadmin_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' accept-charset='utf-8'>"; 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>» {$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_charset($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>"; }
function performEdit() { if ($_GET[action] != 'edit') { return; } global $editErrMsg; $slug = $_GET[slug]; $editErrMsg = array(); $catlist = getDetails('cats'); if (isset($_POST[save])) { //declare a new page class $EditPageObj = new Page(); $EditPageObj->loadSlug($slug); $oldSlug = $slug; $newSlug = slugify($_POST[title]); //newp->slug; $fileName = pageDataDir($slug); $newFileName = $newName = pageDataDir($newSlug); if ($slug == '') { $editErrMsg[] = lt("Title cannot be empty"); } // :: New procedure :: Fix $postVariables = $_POST; $selectedCats = array(); foreach ($postVariables as $catKey => $categoryName) { if (strpos($catKey, 'check_') !== false) { $selectedCats[] = $categoryName; } } // the default one os 'other-pages' section if nothing is selected... if (count($selectedCats) == 0) { $selectedCats[] = 'other-pages'; } $EditPageObj->cats = $selectedCats; // $EditPageObj->commitChanges(); // dont commit yet // :: fix complete if ($newSlug != $oldSlug) { $renameErr = false; if (file_exists($newName)) { $editErrMsg[] = lt("Cannot Rename Title: Another page with similar title already exists", 'cannot-rename-title'); $renameErr = true; } else { if (!rename($fileName, $newName)) { $editErrMsg[] = lt("Error Renaming"); $renameErr = true; } } if (!$renameErr) { //edit title only ifrename error has not occured $EditPageObj->editTitle(stripslashes($_POST[title])); } $fileName = $newName; } runTweak('file-contents-edit', array(&$_POST[content])); if (!put2file($fileName, stripslashes($_POST[content]))) { $editErrMsg[] = lt("Error writing to file", 'file-write-error'); } } if (count($addtErrMsg) != 0 and isset($EditPageObj)) { //error occured $em = ''; foreach ($addtErrMsg as $msg) { $em .= "<li>{$msg}</li>"; } MsgBox(lt('Errors Occured') . " : <ul>{$em}</ul>", 'redbox'); } elseif (isset($EditPageObj)) { $EditPageObj->commitChanges(); savepages(); $em = ''; $gmsg = array(); $gmsg[] = lt("Content Edited Successfully. You can continue editing", 'content-edit-success-msg'); foreach ($gmsg as $msg) { $em .= "<li>{$msg}</li>"; } MsgBox("<ul>{$em}</ul>"); $slug = $newSlug; // return; } $ep = new Page(); $ep->loadSlug($slug); $fileName = pageDataDir($slug); $formAction = "?action=edit&slug={$slug}"; $fileContent = file_exists($fileName) ? htmlentities_charset(file_get_contents($fileName)) : lt("no content yet"); $submitButton = lt('Save Page Content'); $editLabel = lt('Edit Content'); $catLabel = lt('Categories'); $contentLabel = lt('Content'); $pagetitle_l = lt('Page Title'); $title = $ep->title; $chkboxs = checkBoxList(getDetails('cats'), $ep->cats); runTweak('edit-form-display'); echo $te = <<<TET \t<form action='{$formAction}' method=post class='pagemod_form' accept-charset='utf-8'> \t\t<h2>{$editLabel} : {$ep->title}</h2> \t\t<table width='98%' border='0'> \t\t <tr> \t\t\t<td width='20%'>{$pagetitle_l}</td> \t\t\t<td><input type='text' value='{$title}' name='title'></td> \t\t\t<td align='right'><input type='submit' value='{$submitButton}' name='save'></td> \t\t </tr> \t\t <tr> \t\t\t<td>{$catLabel}</td> \t\t\t<td colspan=2>{$chkboxs}</td> \t\t </tr> \t\t</table> \t\t<h2>{$contentLabel}</h2> \t\t<table width="98%"> \t\t <tr><td colspan=2> \t\t\t<textarea name='content' rows=20 cols=70 id='editbox' class='editbox'>{$fileContent}</textarea> \t\t </td></tr> \t\t <tr><td colspan=2><br /><input type='submit' value='{$submitButton}' name='save'></td></tr> \t\t</table> \t</form> TET; runTweak('after-edit-form-display'); }