Index: trunk/extensions/Eval/Makefile |
— | — | @@ -1,16 +0,0 @@ |
2 | | -help all: |
3 | | - @echo options: |
4 | | - @printf "\tinstall: get GeSHi from CVS into this directory\n" |
5 | | - @printf "\tupdate: update GeSHi from CVS\n" |
6 | | - @printf "\tclean: remove the GeSHi directory\n" |
7 | | - @printf "\thelp: this help message\n" |
8 | | -install: |
9 | | - cvs -d:pserver:anonymous:@cvs.sourceforge.net:/cvsroot/geshi login |
10 | | - cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/geshi co -P geshi-1.0.X |
11 | | - |
12 | | - mv geshi-1.0.X/src/ geshi |
13 | | - rm -rf geshi-1.0.X/ |
14 | | -update: |
15 | | - cd geshi/ && cvs up -dP |
16 | | -clean: |
17 | | - rm -rf geshi/ |
Index: trunk/extensions/Eval/SpecialEval.class.php |
— | — | @@ -0,0 +1,154 @@ |
| 2 | +<?php |
| 3 | +if (!defined('MEDIAWIKI')) die(); |
| 4 | + |
| 5 | +class SpecialEval extends SpecialPage { |
| 6 | + public function __construct() { |
| 7 | + SpecialPage::SpecialPage( 'Eval' ); |
| 8 | + } |
| 9 | + |
| 10 | + function getDescription() { |
| 11 | + return wfMsg( 'eval' ); |
| 12 | + } |
| 13 | + |
| 14 | + public function execute( $par ) { |
| 15 | + global $wgOut, $wgRequest, $wgUseTidy; |
| 16 | + wfLoadExtensionMessages( 'Eval' ); |
| 17 | + |
| 18 | + $this->setHeaders(); |
| 19 | + |
| 20 | + $code = isset( $par ) ? $par : $wgRequest->getText( 'code' ); |
| 21 | + $escape = $wgRequest->getBool( 'escape' ); |
| 22 | + |
| 23 | + $eform = new EvaluateForm( $code, $escape ); |
| 24 | + |
| 25 | + if ( trim( $code ) === '' ) |
| 26 | + $eform->execute(); |
| 27 | + else { |
| 28 | + $eform->execute(); |
| 29 | + |
| 30 | + $eout = new EvaluateOutput( $code, $escape ); |
| 31 | + $eout->execute(); |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +class EvaluateForm { |
| 37 | + private $mCode, $mEscape; |
| 38 | + |
| 39 | + public function __construct( $code, $escape ) { |
| 40 | + $this->mCode =& $code; |
| 41 | + $this->mEscape =& $escape; |
| 42 | + } |
| 43 | + |
| 44 | + public function execute() { |
| 45 | + global $wgOut, $wgTitle; |
| 46 | + |
| 47 | + $wgOut->addHTML( |
| 48 | + Xml::openElement( 'form', |
| 49 | + array( |
| 50 | + 'id' => 'specialeval', |
| 51 | + 'method' => 'get', |
| 52 | + 'action' => $wgTitle->escapeLocalUrl() |
| 53 | + ) |
| 54 | + ) . |
| 55 | + # Gotta use open and close here to |
| 56 | + # avoid <textarea /> which breaks |
| 57 | + Xml::openElement( 'textarea', |
| 58 | + array( |
| 59 | + 'cols' => 40, |
| 60 | + 'rows' => 10, |
| 61 | + 'name' => 'code', |
| 62 | + ) |
| 63 | + ) . |
| 64 | + $this->mCode . |
| 65 | + Xml::closeElement( 'textarea' ) . |
| 66 | + ' ' . |
| 67 | + Xml::element( 'br', null, '' ) . |
| 68 | + Xml::element( 'input', |
| 69 | + array( |
| 70 | + 'type' => 'checkbox', |
| 71 | + 'name' => 'escape', |
| 72 | + 'id' => 'escape' |
| 73 | + ) + ( $this->mEscape ? array( 'checked' => 'checked' ) : array() ), |
| 74 | + '' |
| 75 | + ) . |
| 76 | + Xml::element( 'label', |
| 77 | + array( |
| 78 | + 'for' => 'escape' |
| 79 | + ), |
| 80 | + wfMsg( 'eval_escape' ) |
| 81 | + ) . |
| 82 | + Xml::element( 'br', null, '' ) . |
| 83 | + Xml::element( 'input', |
| 84 | + array( |
| 85 | + 'type' => 'submit', |
| 86 | + 'value' => wfMsg( 'eval_submit' ) |
| 87 | + ), |
| 88 | + '' |
| 89 | + ) . |
| 90 | + Xml::element('input', |
| 91 | + array( |
| 92 | + 'type' => 'hidden', |
| 93 | + 'name' => 'title', |
| 94 | + 'value' => 'Special:Eval' |
| 95 | + ), |
| 96 | + '' |
| 97 | + ) . |
| 98 | + Xml::closeElement( 'form' ) |
| 99 | + ); |
| 100 | + } |
| 101 | + |
| 102 | +} |
| 103 | + |
| 104 | +class EvaluateOutput { |
| 105 | + private $mCode, $mEscape; |
| 106 | + private $mErr; |
| 107 | + |
| 108 | + public function __construct( &$code, &$escape ) { |
| 109 | + $this->mCode =& $code; |
| 110 | + $this->mEscape =& $escape; |
| 111 | + } |
| 112 | + |
| 113 | + public function execute() { |
| 114 | + ob_start(); |
| 115 | + eval( $this->mCode ); |
| 116 | + |
| 117 | + $this->mErr = ob_get_clean(); |
| 118 | + $this->summary(); |
| 119 | + } |
| 120 | + |
| 121 | + private function summary() { |
| 122 | + global $wgOut; |
| 123 | + |
| 124 | + if ( $this->mCode !== '' ) |
| 125 | + $this->code(); |
| 126 | + |
| 127 | + if ( $this->mErr !== '' ) { |
| 128 | + $this->mErr = preg_replace( '/^<br \/>/', '', $this->mErr ); |
| 129 | + $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'eval_out' ) ) ); |
| 130 | + if ( $this->mEscape ) |
| 131 | + $this->mErr = |
| 132 | + Xml::openElement( 'pre' ) . |
| 133 | + htmlspecialchars( $this->mErr ) . |
| 134 | + Xml::closeElement( 'pre ' ); |
| 135 | + $wgOut->addHTML( $this->mErr ); |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + private function code() { |
| 140 | + global $wgOut; |
| 141 | + |
| 142 | + if ( ! class_exists( 'GeSHi' ) ) |
| 143 | + require_once 'geshi/geshi.php'; |
| 144 | + |
| 145 | + $geshi = new Geshi( $this->mCode, 'php' ); |
| 146 | + $geshi->enable_line_numbers( GESHI_NORMAL_LINE_NUMBERS ); |
| 147 | + $geshi->set_header_type( GESHI_HEADER_DIV ); |
| 148 | + |
| 149 | + $wgOut->addHTML( |
| 150 | + Xml::element( 'h2', null, wfMsg( 'eval_code' ) ) . |
| 151 | + $geshi->parse_code() |
| 152 | + ); |
| 153 | + } |
| 154 | +} |
| 155 | +?> |
Index: trunk/extensions/Eval/SpecialEval.php |
— | — | @@ -11,177 +11,19 @@ |
12 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -$wgExtensionFunctions[] = 'wfSpecialEval'; |
16 | 15 | $wgExtensionCredits['specialpage'][] = array( |
17 | 16 | 'path' => __FILE__, |
18 | 17 | 'name' => 'Eval', |
19 | 18 | 'author' => 'Ævar Arnfjörð Bjarmason', |
20 | 19 | 'description' => 'adds [[Special:Eval|an interface]] to the <code>eval()</code> function', |
21 | | - 'descriptionmsg' => 'eval-desc', |
22 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:Eval', |
| 20 | + 'descriptionmsg' => 'eval-desc' |
23 | 21 | ); |
24 | 22 | |
25 | 23 | $dir = dirname(__FILE__) . '/'; |
26 | 24 | $wgExtensionMessagesFiles['Eval'] = $dir . 'SpecialEval.i18n.php'; |
27 | 25 | $wgExtensionAliasesFiles['Eval'] = $dir . 'SpecialEval.alias.php'; |
28 | 26 | |
29 | | -function wfSpecialEval() { |
30 | | - wfUsePHP( 5.0 ); |
31 | | - wfUseMW( '1.6alpha' ); |
| 27 | +$wgSpecialPages['Eval'] = 'SpecialEval'; |
| 28 | +$wgAutoloadClasses['SpecialEval'] = $dir . 'SpecialEval.class.php'; |
32 | 29 | |
33 | | - global $IP; |
34 | | - |
35 | | - class Evaluate extends SpecialPage { |
36 | | - public function __construct() { |
37 | | - |
38 | | - SpecialPage::SpecialPage( 'Eval' ); |
39 | | - } |
40 | | - |
41 | | - function getDescription() { |
42 | | - return wfMsg( 'eval' ); |
43 | | - } |
44 | | - |
45 | | - public function execute( $par ) { |
46 | | - global $wgOut, $wgRequest, $wgUseTidy; |
47 | | - wfLoadExtensionMessages( 'Eval' ); |
48 | | - |
49 | | - $this->setHeaders(); |
50 | | - |
51 | | - $code = isset( $par ) ? $par : $wgRequest->getText( 'code' ); |
52 | | - $escape = $wgRequest->getBool( 'escape' ); |
53 | | - |
54 | | - $eform = new EvaluateForm( $code, $escape ); |
55 | | - |
56 | | - if ( trim( $code ) === '' ) |
57 | | - $eform->execute(); |
58 | | - else { |
59 | | - $eform->execute(); |
60 | | - |
61 | | - $eout = new EvaluateOutput( $code, $escape ); |
62 | | - $eout->execute(); |
63 | | - } |
64 | | - } |
65 | | - } |
66 | | - |
67 | | - class EvaluateForm { |
68 | | - private $mCode, $mEscape; |
69 | | - |
70 | | - public function __construct( $code, $escape ) { |
71 | | - $this->mCode =& $code; |
72 | | - $this->mEscape =& $escape; |
73 | | - } |
74 | | - |
75 | | - public function execute() { |
76 | | - global $wgOut, $wgTitle; |
77 | | - |
78 | | - $wgOut->addHTML( |
79 | | - Xml::openElement( 'form', |
80 | | - array( |
81 | | - 'id' => 'specialeval', |
82 | | - 'method' => 'get', |
83 | | - 'action' => $wgTitle->escapeLocalUrl() |
84 | | - ) |
85 | | - ) . |
86 | | - # Gotta use open and close here to |
87 | | - # avoid <textarea /> which breaks |
88 | | - Xml::openElement( 'textarea', |
89 | | - array( |
90 | | - 'cols' => 40, |
91 | | - 'rows' => 10, |
92 | | - 'name' => 'code', |
93 | | - ) |
94 | | - ) . |
95 | | - $this->mCode . |
96 | | - Xml::closeElement( 'textarea' ) . |
97 | | - ' ' . |
98 | | - Xml::element( 'br', null, '' ) . |
99 | | - Xml::element( 'input', |
100 | | - array( |
101 | | - 'type' => 'checkbox', |
102 | | - 'name' => 'escape', |
103 | | - 'id' => 'escape' |
104 | | - ) + ( $this->mEscape ? array( 'checked' => 'checked' ) : array() ), |
105 | | - '' |
106 | | - ) . |
107 | | - Xml::element( 'label', |
108 | | - array( |
109 | | - 'for' => 'escape' |
110 | | - ), |
111 | | - wfMsg( 'eval_escape' ) |
112 | | - ) . |
113 | | - Xml::element( 'br', null, '' ) . |
114 | | - Xml::element( 'input', |
115 | | - array( |
116 | | - 'type' => 'submit', |
117 | | - 'value' => wfMsg( 'eval_submit' ) |
118 | | - ), |
119 | | - '' |
120 | | - ) . |
121 | | - Xml::element('input', |
122 | | - array( |
123 | | - 'type' => 'hidden', |
124 | | - 'name' => 'title', |
125 | | - 'value' => 'Special:Eval' |
126 | | - ), |
127 | | - '' |
128 | | - ) . |
129 | | - Xml::closeElement( 'form' ) |
130 | | - ); |
131 | | - } |
132 | | - |
133 | | - } |
134 | | - |
135 | | - class EvaluateOutput { |
136 | | - private $mCode, $mEscape; |
137 | | - private $mErr; |
138 | | - |
139 | | - public function __construct( &$code, &$escape ) { |
140 | | - $this->mCode =& $code; |
141 | | - $this->mEscape =& $escape; |
142 | | - } |
143 | | - |
144 | | - public function execute() { |
145 | | - ob_start(); |
146 | | - eval( $this->mCode ); |
147 | | - |
148 | | - $this->mErr = ob_get_clean(); |
149 | | - $this->summary(); |
150 | | - } |
151 | | - |
152 | | - private function summary() { |
153 | | - global $wgOut; |
154 | | - |
155 | | - if ( $this->mCode !== '' ) |
156 | | - $this->code(); |
157 | | - |
158 | | - if ( $this->mErr !== '' ) { |
159 | | - $this->mErr = preg_replace( '/^<br \/>/', '', $this->mErr ); |
160 | | - $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'eval_out' ) ) ); |
161 | | - if ( $this->mEscape ) |
162 | | - $this->mErr = |
163 | | - Xml::openElement( 'pre' ) . |
164 | | - htmlspecialchars( $this->mErr ) . |
165 | | - Xml::closeElement( 'pre ' ); |
166 | | - $wgOut->addHTML( $this->mErr ); |
167 | | - } |
168 | | - } |
169 | | - |
170 | | - private function code() { |
171 | | - global $wgOut; |
172 | | - |
173 | | - if ( ! class_exists( 'GeSHi' ) ) |
174 | | - require_once '../extensions/geshi/geshi.php'; |
175 | | - |
176 | | - $geshi = new Geshi( $this->mCode, 'php' ); |
177 | | - $geshi->enable_line_numbers( GESHI_NORMAL_LINE_NUMBERS ); |
178 | | - $geshi->set_header_type( GESHI_HEADER_DIV ); |
179 | | - |
180 | | - $wgOut->addHTML( |
181 | | - Xml::element( 'h2', null, wfMsg( 'eval_code' ) ) . |
182 | | - $geshi->parse_code() |
183 | | - ); |
184 | | - } |
185 | | - } |
186 | | - |
187 | | - SpecialPage::addPage( new Evaluate ); |
188 | | -} |
| 30 | +?> |
Property changes on: trunk/extensions/Eval |
___________________________________________________________________ |
Name: svn:externals |
189 | 31 | + geshi http://geshi.svn.sourceforge.net/svnroot/geshi/tags/RELEASE_1_0_8_6/geshi-1.0.X/src |