Index: trunk/phase3/maintenance/getText.php |
— | — | @@ -0,0 +1,53 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Outputs page text to stdout, useful for command-line editing automation. |
| 5 | + * Example: php getText.php "page title" | sed -e '...' | php edit.php "page title" |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation; either version 2 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License along |
| 18 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | + * http://www.gnu.org/copyleft/gpl.html |
| 21 | + * |
| 22 | + * @ingroup Maintenance |
| 23 | + */ |
| 24 | + |
| 25 | +require_once( dirname(__FILE__) . '/Maintenance.php' ); |
| 26 | + |
| 27 | +class GetTextMaint extends Maintenance { |
| 28 | + public function __construct() { |
| 29 | + parent::__construct(); |
| 30 | + $this->mDescription = 'Outputs page text to stdout'; |
| 31 | + $this->addArg( 'title', 'Page title' ); |
| 32 | + } |
| 33 | + |
| 34 | + public function execute() { |
| 35 | + $this->db = wfGetDB( DB_MASTER ); |
| 36 | + |
| 37 | + $titleText = $this->getArg( 0 ); |
| 38 | + $title = Title::newFromText( $titleText ); |
| 39 | + if ( !$title ) { |
| 40 | + $this->error( "$titleText is not a valid title\n", true ); |
| 41 | + } |
| 42 | + |
| 43 | + $rev = Revision::newFromTitle( $title ); |
| 44 | + if ( !$rev ) { |
| 45 | + $titleText = $title->getText(); |
| 46 | + $this->error( "Page $titleText does not exist\n", true ); |
| 47 | + } |
| 48 | + |
| 49 | + $this->output( $rev->getText() ); |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +$maintClass = "GetTextMaint"; |
| 54 | +require_once( DO_MAINTENANCE ); |
\ No newline at end of file |
Property changes on: trunk/phase3/maintenance/getText.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 55 | + native |