*
* Edit a page's title, description and other attributes
* using separate EditForm fields
*
* Developed and tested using PmWiki 2.2.x,
* partly based on Mike Shanley's EditMore
*
* To install, first add the following to your config file,
* adjusted for your configuration:
$EditAttrFields = array(
'title' => array(
'attribute' => 1,
'markup' => '(:title $1:)',
'filter' => 'EditAttrAutofillTitle' ),
'description' => array( 'attribute' => 1, 'markup' => '(:description $1:)' ),
'keywords' => array( 'attribute' => 1, 'markup' => '(:keywords $1:)' )
);
include_once("$FarmD/cookbook/editattr.php");
* Next, add the matching input fields to your Site.EditForm,
* these are of the form (:input e_FIELDNAME:) -- eg. (:input e_title:)
*
* For more information, please see the online documentation at
* http://www.pmwiki.org/wiki/Cookbook/EditAttributes
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License,
* Version 2, as published by the Free Software Foundation.
* http://www.gnu.org/copyleft/gpl.html
*/
$RecipeInfo['EditAttributes']['Version'] = '2009-07-30';
if (empty( $EditAttrFields )) return;
$EditFields = array_merge( $EditFields, array_keys($EditAttrFields) );
$SaveProperties = array_diff( $SaveProperties, array_keys($EditAttrFields) );
array_unshift($EditFunctions,'EditAttrBeforePost');
array_push($EditFunctions,'EditAttrAfterPost');
function EditAttrAutofillTitle( $pagename, $fn, &$new ) {
global $SearchPatterns, $EditAttrAutofillTitlePatterns;
if ( ($fn!='title') || @$new['title'] || isset($_POST['title']) || isset($_REQUEST['template']) ) return;
SDVA( $EditAttrAutofillTitlePatterns, array(
'recent' => $SearchPatterns['normal']['recent'],
'group' => $SearchPatterns['normal']['group'],
'admin' => '!^(Site|SiteAdmin|PmWiki)\.!',
'nonbase' => '!\b(SideBar|Draft)$!' ));
if ( MatchPageNames( $pagename, $EditAttrAutofillTitlePatterns ) )
$new['title'] = FmtPageName('$Title',$pagename);
}
function EditAttrRequireNotEmpty( $pagename, $fn, &$new ) {
global $MessagesFmt, $EnablePost;
if (empty( $new[$fn] )) {
$MessagesFmt[] = "