/[eiffelstudio]/trunk/Documentation/tools/web/trunk/misc/mediawiki_filter.patch
ViewVC logotype

Contents of /trunk/Documentation/tools/web/trunk/misc/mediawiki_filter.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74770 - (show annotations)
Mon Sep 22 12:13:12 2008 UTC (11 years, 4 months ago) by jfiat
File size: 10431 byte(s)
new patch for mediawiki filter (rev 2675)
1 Index: mediawiki_filter.css
2 ===================================================================
3 --- mediawiki_filter.css (revision 2675)
4 +++ mediawiki_filter.css (working copy)
5 @@ -1,6 +1,12 @@
6 /* wikilinks */
7
8 -.wiki-link-new {
9 +.wiki-link-new,
10 +a.wiki-link-new,
11 +a.wiki-link-new:link,
12 +a.wiki-link-new:active,
13 +a.wiki-link-new:visited,
14 +a.wiki-link-new:hover
15 +{
16 color: #f33;
17 }
18
19 Index: mediawiki_filter.settings.inc
20 ===================================================================
21 --- mediawiki_filter.settings.inc (revision 2675)
22 +++ mediawiki_filter.settings.inc (working copy)
23 @@ -206,7 +206,7 @@
24 if ($line) {
25 list($title, $id, $url) = explode('|', $line, 3);
26 if (trim($url) == '<path>') {
27 - $url = '$1'; //str_replace('__QUERY_POSITION__', '$1', url('__QUERY_POSITION__', NULL, NULL, TRUE));
28 + $url = '$1'; //str_replace('__QUERY_POSITION__', '$1', url('__QUERY_POSITION__', array ('absolute' => TRUE)));
29 }
30 if ($op == 'url') {
31 $mappings[trim($id)] = trim($url);
32 Index: mediawiki_filter.info
33 ===================================================================
34 --- mediawiki_filter.info (revision 2675)
35 +++ mediawiki_filter.info (working copy)
36 @@ -1,3 +1,7 @@
37 ; $Id$
38 name = "Mediawiki filter"
39 description = "Filter which uses Mediawiki parser for formatting"
40 +package = Filters
41 +version = "6.x-0.1"
42 +core = "6.x"
43 +
44 Index: mediawiki_filter.lib.inc
45 ===================================================================
46 --- mediawiki_filter.lib.inc (revision 2675)
47 +++ mediawiki_filter.lib.inc (working copy)
48 @@ -63,7 +63,7 @@
49
50 // Set up some global variables needed for Mediawiki.
51 $settings = array(
52 - 'wgServer' => url(NULL, NULL, NULL, TRUE),
53 + 'wgServer' => url(NULL, array('absolute' => TRUE)),
54 'wgScriptPath' => '/xyz',
55 'wgScript' => '/xyz/index.php',
56 'wgRedirectScript' => '/xyz/redirect.php',
57 @@ -697,6 +697,7 @@
58 }
59 } else {
60 $dbkey = wfUrlencode( $this->getPrefixedDBkey() );
61 +
62 if ( $query == '' ) {
63 if($variant!=FALSE && $wgContLang->hasVariants()){
64 if($wgVariantArticlePath==FALSE) {
65 @@ -708,7 +709,14 @@
66 $url = str_replace( '$1', $dbkey, $url );
67 }
68 else {
69 - $url = str_replace( '$1', $dbkey, $wgArticlePath );
70 + /* FIXME: JFIAT */
71 + if (module_exists('pathauto')) {
72 + $l_url = pathauto_cleanstring($this->getPrefixedDBkey());
73 + } else {
74 + $l_url = $dbkey;
75 + }
76 + $l_url = $dbkey;
77 + $url = str_replace( '$1', $l_url, $wgArticlePath );
78 }
79 } else {
80 global $wgActionPaths;
81 @@ -732,7 +740,7 @@
82 $url = "{$wgScript}?title={$dbkey}&{$query}";
83 }
84 }
85 -
86 +
87 // FIXME: this causes breakage in various places when we
88 // actually expected a local URL and end up with dupe prefixes.
89 // TODO: For Drupal we always render, no matter what
90 @@ -1573,15 +1581,14 @@
91 $image_sizes = array();
92 }
93 if (isset($params['width'])) {
94 - foreach($image_sizes as $image_size) {
95 - $image_label = $image_size['label'];
96 + foreach($image_sizes as $image_key => $image_size) {
97 if ($image_size['width'] >= $params['width']) {
98 break;
99 }
100 }
101 }
102 /* $upright = $this->info['width'] < $this->info['height'];
103 - foreach($image_sizes as $image_label => $image_size) {
104 + foreach($image_sizes as $image_key => $image_size) {
105 if ($upright) {
106 if ($image_size['height'] >= $params['height']) {
107 break;
108 @@ -1594,12 +1601,12 @@
109 }
110 }*/
111
112 - if (!$image_label) {
113 - $image_label = IMAGE_ORIGINAL;
114 + if (!$image_key) {
115 + $image_key = IMAGE_ORIGINAL;
116 }
117 wfProfileIn( __METHOD__ );
118 - $path = file_create_path($this->node->images[$image_label]);
119 - $url = url($this->node->images[$image_label]);
120 + $path = file_create_path($this->node->images[$image_key]);
121 + $url = url($this->node->images[$image_key]);
122
123 $thumb = new DrupalImageTransformOutput($this, $url, $path, $params['width'], $params['height']);
124
125 @@ -1716,10 +1723,15 @@
126 $attribs = array(
127 'alt' => $alt,
128 'src' => $this->url,
129 - 'width' => $this->width,
130 - 'height' => $this->height,
131 'border' => 0,
132 );
133 +
134 + if ($this->width) {
135 + $attribs['width'] = $this->width ;
136 + }
137 + if ($this->height) {
138 + $attribs['height'] = $this->height ;
139 + }
140 if ( !empty( $options['valign'] ) ) {
141 $attribs['style'] = "vertical-align: {$options['valign']}";
142 }
143 @@ -1771,4 +1783,3 @@
144 return NULL;
145 }
146 }
147 -
148 Index: mediawiki_filter.classes.inc
149 ===================================================================
150 --- mediawiki_filter.classes.inc (revision 2675)
151 +++ mediawiki_filter.classes.inc (working copy)
152 @@ -159,9 +159,96 @@
153 else {
154 drupal_set_message('Unexpected Mediawiki query. Please report to module maintainer', 'error');
155 }
156 + $this->filterLastResultForBook();
157 return NULL;
158 }
159
160 + function getCurrentNodeBookId() {
161 + /* Dirty Hack ... might not work all the time...*/
162 + $q = $_GET['q'];
163 + if (substr($q, 0, 5) === 'node/') {
164 + $l_curr_nid = substr($q, 5, strlen($q));
165 + list($l_curr_nid) = split('/', $l_curr_nid, 1);
166 + $l_curr_node = node_load(array('nid' => $l_curr_nid));
167 + if ($l_curr_node and isset($l_curr_node->book['bid'])) {
168 + $l_curr_bid = $l_curr_node->book['bid'];
169 + return $l_curr_bid;
170 + }
171 + }
172 + return FALSE;
173 + }
174 +
175 + function filterLastResultForBook() {
176 + /* Dirty Hack ...*/
177 + if (count($this->lastResult) > 0) {
178 + $res_by_title = array();
179 + foreach ($this->lastResult as $k => $res_obj) {
180 + $res_by_title[$res_obj->page_title][] = $res_obj;
181 + }
182 + $bid = $this->getCurrentNodeBookId();
183 + $the_results = array();
184 + foreach ($res_by_title as $l_title => $l_pages) {
185 + $l_pages = $this->filterResultsForBook(&$l_pages, $l_title, $bid);
186 + foreach($l_pages as $k => $v) {
187 + $the_results[] = $v;
188 + }
189 + }
190 + if (count($the_results) > 0) {
191 + $this->lastResult = $the_results;
192 + }
193 + }
194 + }
195 +
196 + function filterResultsForBook(&$res, $a_title, $a_bid) {
197 + if ($a_bid) {
198 + $l_curr_bid = $a_bid;
199 + } else {
200 + $l_curr_bid = 0;
201 + }
202 + if (count($res) > 1) {
203 + $m = t("Found %nb pages with name \"%tit\":<ul>", array('%tit' => $a_title, '%nb' => count($res)));
204 + $the_results = array();
205 + foreach ($res as $k => $res_obj) {
206 + $l_node = node_load($res_obj->page_id);
207 + if ($l_node) {
208 + $m .= "<li><a href=\"".url($l_node->path, array('absolute' => TRUE))."\">".$l_node->title.": node ".$l_node->nid." (<em>".$l_node->path."</em>)</a>";
209 + if ($l_curr_bid <= 0 or $l_node->book['bid'] == $l_curr_bid) {
210 + $the_results[] = $res_obj;
211 + if ($l_curr_bid > 0) {
212 + $m .= " - Selected ";
213 + $l_curr_bid = -1; // Select only first result;
214 + }
215 + }
216 + $m .= "</li>";
217 + }
218 + }
219 + $m .= "</ul>";
220 + if ($l_curr_bid > 0) {
221 + $m .= "<br/>".t("Unable to find a page with name \"%tit\" in the same book!", array ('%tit' => $a_title));
222 + }
223 + drupal_set_message($m,'warning');
224 + } else if (count($res) == 1 and $l_curr_bid > 0) {
225 + $l_node = node_load(end(&$res)->page_id);
226 + if ($l_node and $l_node->book['bid'] != $l_curr_bid) {
227 + $m = t("The page used for name \"%tit\" in outside current book!", array ('%tit' => $a_title));
228 + $m .= "<ul><li><a href=\"".url($l_node->path, array('absolute' => TRUE))."\">".$l_node->title.": node ".$l_node->nid." (<em>".$l_node->path."</em>)</a></li></ul>";
229 + drupal_set_message($m,'warning');
230 + }
231 + if (defined('STATUS_TRASH')) {
232 + if ($l_node and $l_node->status == STATUS_TRASH) {
233 + $m = t("The page used for name \"%tit\" in trashed!", array ('%tit' => $a_title));
234 + $m .= "<ul><li><a href=\"".url($l_node->path, array('absolute' => TRUE))."\">".$l_node->title.": node ".$l_node->nid." (<em>".$l_node->path."</em>)</a></li></ul>";
235 + drupal_set_message($m,'warning');
236 + }
237 + }
238 + }
239 + if (count($the_results) > 0) {
240 + return $the_results;
241 + } else {
242 + return $res;
243 + }
244 + }
245 +
246 function fetchObject($res) {
247 return array_pop($this->lastResult);
248 }
249 Index: mediawiki_filter.module
250 ===================================================================
251 --- mediawiki_filter.module (revision 2675)
252 +++ mediawiki_filter.module (working copy)
253 @@ -12,8 +12,7 @@
254 /**
255 * Implementation of hook_menu().
256 */
257 -function mediawiki_filter_menu($may_cache) {
258 - if (!$may_cache) {
259 +function mediawiki_filter_init() {
260 drupal_add_css(drupal_get_path('module', 'mediawiki_filter') .'/mediawiki_filter.css');
261
262 // TODO: make external image an option
263 @@ -28,9 +27,25 @@
264 });
265 }',
266 'inline', 'footer');
267 - }
268 }
269
270 +function mediawiki_filter_menu() {
271 + drupal_add_css(drupal_get_path('module', 'mediawiki_filter') .'/mediawiki_filter.css');
272 +
273 + // TODO: make external image an option
274 + $external_img_url = base_path() . drupal_get_path('module', 'mediawiki_filter') .'/external.png';
275 + drupal_add_js(drupal_get_path('module', 'mediawiki_filter') .'/mediawiki_filter.js');
276 + drupal_add_js(
277 + 'if (Drupal.jsEnabled) {
278 + $(document).ready(function() {
279 + $(\'a.external\').each(function() {
280 + $(this).append(\'&nbsp;<img src="' . $external_img_url . '" alt="external"/>\');
281 + });
282 + });
283 + }',
284 + 'inline', 'footer');
285 +}
286 +
287 /**
288 * Implementation of hook_filter_tips()
289 */
290 @@ -218,7 +233,7 @@
291 $url = url(str_replace('$1', $title, $url));
292 break;
293 case 'create-link':
294 - $url = url('node/add/' . $type, 'edit[title]=' . urlencode($title));
295 + $url = url('node/add/' . $type, array('query' => 'edit[title]=' . urlencode($title)));
296 break;
297 }
298 }
299 @@ -230,7 +245,7 @@
300 $interwiki_links = mediawiki_filter_interwiki_mappings();
301 if (isset($interwiki_links[$key])) {
302 $url = str_replace('$1', '__QUERY_POSITION_REPLACEMENT__', $interwiki_links[$key]);
303 - $url = url($url, NULL, NULL, TRUE);
304 + $url = url($url, array('absolute' => TRUE));
305 $url = str_replace('__QUERY_POSITION_REPLACEMENT__', '$1', $url);
306 return $url;
307 }

  ViewVC Help
Powered by ViewVC 1.1.23