[pmwiki-users] New Page Form

Naeimeh.Shakoori-Najafi at dalsa.com Naeimeh.Shakoori-Najafi at dalsa.com
Thu Jun 28 14:30:53 CDT 2007


Hello,

I've modified the newpageform recipe so that it just shows a dropdown menu 
and a field for the name of the new page.
and also show a template for each group when it brings the edit page. But 
I guess the modifications I've made 
disables the search function. 
Here are the changes I made to the NewPageFunction:

function NewPageForm($pagename) {
global $NewGroup;
//  $PageUrl = PageVar($pagename, '$PageUrl');
 $out[] = "<form method='post'>
    <input type='hidden' name='action' value='postnewpage'/>
    <table >
       <tr>Group:
       <td><select name='group'>";
        foreach($NewGroup as $k=>$v) {
    $x = is_string($k) ? $k : $v;
    $out[] = "<option value='$x'>$v</option>";
  } 
  $out [] = "</table>
            <form method='post'>
            <input type='hidden' name='action' value='postnewpage' />
            <table>
                 <tr>Pagename:
                 <td><input type='text' name='newpagename'></td></tr>"; 
   $out[] = "</table>";
  return FmtPageName(implode('',$out),$pagename);
}

And I added 3 lines to the end of the first else:
$_REQUEST ['template'] = $_REQUEST ['group'].'.Template';
$urlfmt = '$PageUrl?action=edit&template='."{$_REQUEST ['template']}";
Redirect($pagename, $urlfmt);


Bellow is the whole recipe in case it's needed.
Thanks
Naeimeh 
 




<?php if (!defined('PmWiki')) exit();
$NewGroup = array('Select Category', 'Dalsa','DigitalCinema', 
'Electronics', 'Finance',  'Sensor', 'TechnicalMarketing', 'Testing');
markup('newpageform','inline','/\\(:newpageform:\\)/e',"Keep(NewPageForm(\$pagename))");
## NewPageForm() generates the form for entering a new page.  Note that
## once a page has been created, it's a normal wikipage and is edited
## according to the normal editing code (i.e., there's no form-based
## editing yet).
function NewPageForm($pagename) {
global $NewGroup;
//  $PageUrl = PageVar($pagename, '$PageUrl');
 $out[] = "<form method='post'>
    <input type='hidden' name='action' value='postnewpage'/>
    <table >
       <tr>Group:
       <td><select name='group'>";
        foreach($NewGroup as $k=>$v) {
    $x = is_string($k) ? $k : $v;
    $out[] = "<option value='$x'>$v</option>";
  } 
  $out [] = "</table>
            <form method='post'>
            <input type='hidden' name='action' value='postnewpage' />
            <table width=18% >
                 <tr>Pagename:
                 <td><input type='text' name='newpagename'></td></tr>";

 /* $out[] = "
         <tr><td valign='top'>$[NewPage]:</td>
        <td><textarea name='description' cols='60' rows='15'></textarea>
        </td></tr></table>
      <div align='center'><input type='submit' value='$[submit new page]' 
/>
       </div>
     </form>";*/ 
   $out[] = "</table>";
  return FmtPageName(implode('',$out),$pagename);
}

$HTMLStylesFmt[] = ".pitsfield { text-align:right; font-weight:bold; }\n";

include_once("$FarmD/scripts/author.php");

if ($action=='postnewpage') {
//$_REQUEST ['template'] = $_REQUEST ['group'].'.Template'; 
$pagename = "{$_REQUEST ['group']}."."{$_REQUEST ['newpagename']}";
 if (!PageExists($pagename))
  {      if ($_REQUEST ['group'] == "") {
           $pagename = "Main."."{$_REQUEST ['newpagename']}";}
     if ($_REQUEST ['group'] == "PITS") {
           Abort("cannot create pages in PITS. Please use the PITS Form 
for a new issue. It's located at $ScriptUrl/PITS/PITS ");}
            if ($_REQUEST ['newpagename'] == "") {
        $UrlPage="{$_REQUEST ['group']}";
        Redirect($PageNotFound);}
    else
     Lock(2);
//echo($urlfmt);
          $action = 'edit';
          $_REQUEST['post'] = 1;
          $CreateTime = strftime('%Y-%m-%d %H:%M',$Now);
          $EditMessageFmt = "<p class='vspace'>Please review and make any 
edits 
                to your issue below, then press 'Save'</p>";
          $_POST['text'] = "{$_REQUEST['description']}";
         $_REQUEST ['template'] = $_REQUEST ['group'].'.Template';
         $urlfmt = '$PageUrl?action=edit&template='."{$_REQUEST 
['template']}";
         Redirect($pagename, $urlfmt);
         }
    else
        {
         // echo($urlfmt);
          Redirect($pagename);
        } 
}
?>

**********************************************************************
To help combat SPAM DALSA will no longer return delivery failure notifications for incorrect or invalid addresses.

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This email message has also been swept for the presence of computer viruses

Please note that DALSA employee addresses have been standardized to dalsa.com-- Please update your address book as may be required
**********************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20070628/a03887a4/attachment-0001.html 


More information about the pmwiki-users mailing list