Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -646,32 +646,34 @@ |
647 | 647 | $this->formClass = strtolower( $type ) . '-record recordadmin'; |
648 | 648 | $this->formAtts = ''; |
649 | 649 | $title = Title::newFromText( $type, NS_FORM ); |
650 | | - if ( $title->exists() ) { |
| 650 | + if ( is_object( $title ) { |
| 651 | + if ( $title->exists() ) { |
651 | 652 | |
652 | | - # Get the form content |
653 | | - $form = new Article( $title ); |
654 | | - $form = $form->getContent(); |
655 | | - |
656 | | - # Extract form's class and other attributes (except method and action) |
657 | | - if ( preg_match( "|<form\s*([^>]+)\s*>.+</form>|is", $form, $atts )) { |
658 | | - if ( preg_match( "|class\s*=\s*[\"'](.+?)['\"]|", $atts[1], $m ) ) $this->formClass .= ' ' . $m[1]; |
659 | | - $this->formAtts = ' ' . trim( preg_replace( "/(class|action|method)\s*=\s*[\"'](.*?)['\"]/", "", $atts[1] ) ); |
| 653 | + # Get the form content |
| 654 | + $form = new Article( $title ); |
| 655 | + $form = $form->getContent(); |
| 656 | + |
| 657 | + # Extract form's class and other attributes (except method and action) |
| 658 | + if ( preg_match( "|<form\s*([^>]+)\s*>.+</form>|is", $form, $atts )) { |
| 659 | + if ( preg_match( "|class\s*=\s*[\"'](.+?)['\"]|", $atts[1], $m ) ) $this->formClass .= ' ' . $m[1]; |
| 660 | + $this->formAtts = ' ' . trim( preg_replace( "/(class|action|method)\s*=\s*[\"'](.*?)['\"]/", "", $atts[1] ) ); |
| 661 | + } |
| 662 | + |
| 663 | + # Process content |
| 664 | + $form = preg_replace( '#<input.+?type=[\'"]?submit["\']?.+?/(input| *)>#i', '', $form ); # remove submits |
| 665 | + $form = preg_replace( '#^.+?<form.*?>#is', '', $form ); # remove up to and including form open |
| 666 | + $form = preg_replace( '#</form>.+?$#is', '', $form ); # remove form close and everything after |
| 667 | + $form = preg_replace( '#name\s*=\s*([\'"])(.*?)\\1#is', 'name="ra_$2"', $form ); # prefix input names with ra_ |
| 668 | + $form = preg_replace( '#(<select.+?>)\s*(?!<option/>)#is', '$1<option selected/>', $form ); # ensure all select lists have default blank |
660 | 669 | } |
661 | | - |
662 | | - # Process content |
663 | | - $form = preg_replace( '#<input.+?type=[\'"]?submit["\']?.+?/(input| *)>#i', '', $form ); # remove submits |
664 | | - $form = preg_replace( '#^.+?<form.*?>#is', '', $form ); # remove up to and including form open |
665 | | - $form = preg_replace( '#</form>.+?$#is', '', $form ); # remove form close and everything after |
666 | | - $form = preg_replace( '#name\s*=\s*([\'"])(.*?)\\1#is', 'name="ra_$2"', $form ); # prefix input names with ra_ |
667 | | - $form = preg_replace( '#(<select.+?>)\s*(?!<option/>)#is', '$1<option selected/>', $form ); # ensure all select lists have default blank |
668 | | - } |
669 | | - else { |
| 670 | + else { |
670 | 671 | |
671 | | - # Create a red link to the form if it doesn't exist |
672 | | - $form = '<b>' . wfMsg( 'recordadmin-noform', $type ) . '</b>' |
673 | | - . '<br /><a href="' . $title->getLocalURL( 'action=edit' ) |
674 | | - . '">(' . wfMsg( 'recordadmin-createlink' ) . ')</a><br />'; |
675 | | - } |
| 672 | + # Create a red link to the form if it doesn't exist |
| 673 | + $form = '<b>' . wfMsg( 'recordadmin-noform', $type ) . '</b>' |
| 674 | + . '<br /><a href="' . $title->getLocalURL( 'action=edit' ) |
| 675 | + . '">(' . wfMsg( 'recordadmin-createlink' ) . ')</a><br />'; |
| 676 | + } |
| 677 | + } else $form = ''; |
676 | 678 | $this->form = $form; |
677 | 679 | } |
678 | 680 | |
Index: trunk/extensions/RecordAdmin/RecordAdmin.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * @licence GNU General Public Licence 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -define( 'RECORDADMIN_VERSION', '0.11.9, 2010-03-31' ); |
| 15 | +define( 'RECORDADMIN_VERSION', '0.11.10, 2010-04-11' ); |
16 | 16 | |
17 | 17 | $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type |
18 | 18 | $wgRecordAdminCategory = 'Records'; # Category containing record types |