Version Description
Download this release
Release Info
Developer | johnny5 |
Plugin | Search Regex |
Version | 1.4.12 |
Comparing to | |
See all releases |
Version 1.4.12
- admin.css +91 -0
- ajax.php +35 -0
- images/small.gif +0 -0
- js/search-regex.js +80 -0
- license.txt +674 -0
- locale/BY.mo +0 -0
- locale/BY.po +117 -0
- locale/ar.mo +0 -0
- locale/ar.po +118 -0
- locale/search-regex.po +119 -0
- messages.po +168 -0
- models/result.php +35 -0
- models/search.php +235 -0
- plugin.php +666 -0
- readme.txt +98 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- search-regex.php +104 -0
- searches/comment_author.php +71 -0
- searches/comment_author_email.php +71 -0
- searches/comment_author_url.php +71 -0
- searches/comment_content.php +66 -0
- searches/post_content.php +64 -0
- searches/post_excerpt.php +64 -0
- searches/post_meta.php +67 -0
- searches/post_title.php +64 -0
- searches/post_url.php +62 -0
- searches/sniplet_content.php +60 -0
- searches/tag_name.php +60 -0
- searches/tag_slug.php +60 -0
- view/admin/head.php +7 -0
- view/admin/results.php +61 -0
- view/admin/search.php +69 -0
admin.css
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.searchargs
|
2 |
+
{
|
3 |
+
width: 100%;
|
4 |
+
}
|
5 |
+
|
6 |
+
.searchargs th
|
7 |
+
{ text-align: right}
|
8 |
+
|
9 |
+
.searchargs .term
|
10 |
+
{
|
11 |
+
width: 90%;
|
12 |
+
}
|
13 |
+
|
14 |
+
.results li
|
15 |
+
{
|
16 |
+
margin-bottom: 10px;
|
17 |
+
-moz-border-radius: 10px;
|
18 |
+
padding: 5px;
|
19 |
+
border: 1px solid white;
|
20 |
+
}
|
21 |
+
|
22 |
+
.results li:hover
|
23 |
+
{
|
24 |
+
border: 1px solid #E8EEF1;
|
25 |
+
}
|
26 |
+
|
27 |
+
.searchx
|
28 |
+
{
|
29 |
+
color: #0F3D09;
|
30 |
+
margin: 5px 0px 5px 20px;
|
31 |
+
font-size: 0.9em;
|
32 |
+
padding: 5px;
|
33 |
+
background-color: #E7F5E1;
|
34 |
+
-moz-border-radius: 10px;
|
35 |
+
}
|
36 |
+
|
37 |
+
.searchx strong, .replacex strong, .searchx a
|
38 |
+
{
|
39 |
+
color: red;
|
40 |
+
background-color: pink;
|
41 |
+
padding: 2px 0px;
|
42 |
+
font-weight: bold;
|
43 |
+
border: none;
|
44 |
+
}
|
45 |
+
|
46 |
+
.results input, .results textarea
|
47 |
+
{
|
48 |
+
font-size: 0.9em;
|
49 |
+
}
|
50 |
+
|
51 |
+
.alt .searchx
|
52 |
+
{
|
53 |
+
background-color: #C0DAB5;
|
54 |
+
color: #1C465C;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
.replacex
|
59 |
+
{
|
60 |
+
color: #4B3510;
|
61 |
+
margin-top: 10px;
|
62 |
+
font-size: 0.9em;
|
63 |
+
margin-left: 20px;
|
64 |
+
padding: 5px;
|
65 |
+
background-color: #F5EEE1;
|
66 |
+
-moz-border-radius: 10px;
|
67 |
+
}
|
68 |
+
|
69 |
+
.alt .replacex
|
70 |
+
{
|
71 |
+
background-color: #E0D3BB;
|
72 |
+
}
|
73 |
+
|
74 |
+
.sub
|
75 |
+
{
|
76 |
+
font-weight: normal;
|
77 |
+
font-size: 0.8em;
|
78 |
+
color: #666;
|
79 |
+
}
|
80 |
+
|
81 |
+
.options, .options a
|
82 |
+
{
|
83 |
+
color: #666;
|
84 |
+
}
|
85 |
+
|
86 |
+
.options
|
87 |
+
{
|
88 |
+
float: right;
|
89 |
+
font-size: 0.9em;
|
90 |
+
margin-left: 10px;
|
91 |
+
}
|
ajax.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
include ('../../../wp-config.php');
|
4 |
+
include (dirname (__FILE__).'/models/search.php');
|
5 |
+
include (dirname (__FILE__).'/models/result.php');
|
6 |
+
|
7 |
+
class Search_AJAX extends Redirection_Plugin
|
8 |
+
{
|
9 |
+
function Search_AJAX ($id, $command)
|
10 |
+
{
|
11 |
+
if (!current_user_can ('administrator') && !current_user_can ('search_regex_write'))
|
12 |
+
die ('<p style="color: red">You are not allowed access to this resource</p>');
|
13 |
+
|
14 |
+
$this->register_plugin ('search-regex', __FILE__);
|
15 |
+
if (method_exists ($this, $command))
|
16 |
+
$this->$command ($id);
|
17 |
+
else
|
18 |
+
die ('<p style="color: red">That function is not defined</p>');
|
19 |
+
}
|
20 |
+
|
21 |
+
function regex_replace ($id)
|
22 |
+
{
|
23 |
+
if (Search::valid_search (stripslashes( $_POST['klass'] )))
|
24 |
+
{
|
25 |
+
$searcher = new $_POST['klass'];
|
26 |
+
$searcher->replace_inline (intval ($_POST['item']), intval ($_POST['offset']), intval ($_POST['length']), stripslashes( $_POST['replace']) );
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
$id = $_GET['id'];
|
33 |
+
$cmd = $_GET['cmd'];
|
34 |
+
|
35 |
+
$obj = new Search_AJAX ($id, $cmd);
|
images/small.gif
ADDED
Binary file
|
js/search-regex.js
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function toggle_regex ()
|
2 |
+
{
|
3 |
+
Element.toggle ('regex-options');
|
4 |
+
}
|
5 |
+
|
6 |
+
function regex_replace (classs, item, offset, length, replace)
|
7 |
+
{
|
8 |
+
// Need an ID, start, end, and replace
|
9 |
+
new Ajax.Request (wp_base + '?cmd=regex_replace&id=' + item,
|
10 |
+
{
|
11 |
+
asynchronous: true,
|
12 |
+
evalScripts: true,
|
13 |
+
parameters: { klass: classs, item: item, offset: offset, length: length, replace: replace },
|
14 |
+
onLoading: function(request)
|
15 |
+
{
|
16 |
+
$('options_' + item + '_' + offset).innerHTML = '<img src="' + wp_loading + '" alt="loading" width="16" height="16"/>';
|
17 |
+
},
|
18 |
+
onComplete: function(request)
|
19 |
+
{
|
20 |
+
new Effect.Fade ('search_' + item + '_' + offset, { to: 0.2});
|
21 |
+
new Effect.Fade ('options_' + item + '_' + offset);
|
22 |
+
}
|
23 |
+
});
|
24 |
+
}
|
25 |
+
|
26 |
+
function regex_edit_replace (classs, item, offset, length)
|
27 |
+
{
|
28 |
+
$('replace_' + item + '_' + offset).innerHTML = re_replace[item + '_' + offset];
|
29 |
+
$('replace_' + item + '_' + offset).innerHTML += ' <input type="submit" name="cancel" value="Cancel" onclick="regex_cancel_replace(' + item + ',' + offset + ')"/>';
|
30 |
+
Field.activate ('rep_' + item + '_' + offset);
|
31 |
+
}
|
32 |
+
|
33 |
+
function regex_edit (classs, item, offset, length)
|
34 |
+
{
|
35 |
+
$('value_' + item + '_' + offset).innerHTML = re_input[item + '_' + offset];
|
36 |
+
$('value_' + item + '_' + offset).innerHTML += ' <input type="submit" name="cancel" value="Cancel" onclick="regex_cancel(' + item + ',' + offset + ')"/>';
|
37 |
+
Field.activate ('txt_' + item + '_' + offset);
|
38 |
+
}
|
39 |
+
|
40 |
+
function regex_cancel (item, offset)
|
41 |
+
{
|
42 |
+
$('value_' + item + '_' + offset).innerHTML = re_text[item + '_' + offset].gsub ('"', '"');
|
43 |
+
}
|
44 |
+
|
45 |
+
function regex_cancel_replace (item, offset)
|
46 |
+
{
|
47 |
+
$('replace_' + item + '_' + offset).innerHTML = re_text_replace[item + '_' + offset].gsub ('"', '"');
|
48 |
+
}
|
49 |
+
|
50 |
+
function save_edit (classs, item, offset, start, length)
|
51 |
+
{
|
52 |
+
new Ajax.Request (wp_base + '?cmd=regex_replace&id=' + item,
|
53 |
+
{
|
54 |
+
asynchronous: true, evalScripts: true,
|
55 |
+
parameters: { klass: classs, item: item, offset: start, length: length, replace: $('txt_' + item + '_' + offset).value},
|
56 |
+
onLoading: function(request) { $('options_' + item + '_' + offset).innerHTML = '<img src="' + wp_loading + '" alt="loading" width="16" height="16"/>'; },
|
57 |
+
onComplete: function(request)
|
58 |
+
{
|
59 |
+
new Effect.Fade ('search_' + item + '_' + offset, { to: 0.2});
|
60 |
+
new Effect.Fade ('options_' + item + '_' + offset);
|
61 |
+
$('value_' + item + '_' + offset).innerHTML = $('txt_' + item + '_' + offset).value;
|
62 |
+
}
|
63 |
+
});
|
64 |
+
}
|
65 |
+
|
66 |
+
function save_edit_rep (classs, item, offset, start, length)
|
67 |
+
{
|
68 |
+
new Ajax.Request (wp_base + '?cmd=regex_replace&id=' + item,
|
69 |
+
{
|
70 |
+
asynchronous: true, evalScripts: true,
|
71 |
+
parameters: { klass: classs, item: item, offset: start, length: length, replace: $('rep_' + item + '_' + offset).value},
|
72 |
+
onLoading: function(request) { $('options_' + item + '_' + offset).innerHTML = '<img src="' + wp_loading + '" alt="loading" width="16" height="16"/>'; },
|
73 |
+
onComplete: function(request)
|
74 |
+
{
|
75 |
+
new Effect.Fade ('search_' + item + '_' + offset, { to: 0.2});
|
76 |
+
new Effect.Fade ('options_' + item + '_' + offset);
|
77 |
+
$('replace_' + item + '_' + offset).innerHTML = $('rep_' + item + '_' + offset).value;
|
78 |
+
}
|
79 |
+
});
|
80 |
+
}
|
license.txt
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<http://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
locale/BY.mo
ADDED
Binary file
|
locale/BY.po
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR John Godley
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
msgid ""
|
7 |
+
msgstr ""
|
8 |
+
"Project-Id-Version: search-regex\n"
|
9 |
+
"POT-Creation-Date: \n"
|
10 |
+
"PO-Revision-Date: \n"
|
11 |
+
"Last-Translator: Илья <mrilyuha@gmail.com>\n"
|
12 |
+
"Language-Team: \n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Content-Type: text/plain; charset=utf-8\n"
|
15 |
+
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
"X-Poedit-Language: Belarusian\n"
|
17 |
+
"X-Poedit-Country: BELARUS\n"
|
18 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
19 |
+
|
20 |
+
#: search-regex.php:335
|
21 |
+
#, php-format
|
22 |
+
msgid "%1$s results found."
|
23 |
+
msgstr "%1$s знойдзена."
|
24 |
+
|
25 |
+
#: search-regex.php:306
|
26 |
+
msgid "Case-less:"
|
27 |
+
msgstr "без уліку рэгістра:"
|
28 |
+
|
29 |
+
#: search-regex.php:343
|
30 |
+
msgid "Comment"
|
31 |
+
msgstr "Каментарый"
|
32 |
+
|
33 |
+
#: search-regex.php:296
|
34 |
+
msgid "Comments"
|
35 |
+
msgstr "Каментарыі"
|
36 |
+
|
37 |
+
#: search-regex.php:308
|
38 |
+
msgid "Dot-all:"
|
39 |
+
msgstr "Dot-all:"
|
40 |
+
|
41 |
+
#: search-regex.php:59
|
42 |
+
msgid "Invalid regular expression"
|
43 |
+
msgstr "Няправільны рэгулярны выраз"
|
44 |
+
|
45 |
+
#: search-regex.php:297
|
46 |
+
msgid "Meta-data"
|
47 |
+
msgstr "Метададзеныя"
|
48 |
+
|
49 |
+
#: search-regex.php:307
|
50 |
+
msgid "Multi-line:"
|
51 |
+
msgstr "Шмат радкоў:"
|
52 |
+
|
53 |
+
#: search-regex.php:286
|
54 |
+
msgid "NOTE: No liability is accepted for any damage caused - make sure to backup your database before clicking 'Replace & Save'."
|
55 |
+
msgstr "NOTE: No liability is accepted for any damage caused - make sure to backup your database before clicking 'Replace & Save'."
|
56 |
+
|
57 |
+
#: search-regex.php:85
|
58 |
+
msgid "No search pattern"
|
59 |
+
msgstr "Няма шаблонаў пошуку"
|
60 |
+
|
61 |
+
#: search-regex.php:341
|
62 |
+
msgid "Post"
|
63 |
+
msgstr "пост"
|
64 |
+
|
65 |
+
#: search-regex.php:295
|
66 |
+
msgid "Posts & pages"
|
67 |
+
msgstr "Пастоў & старонак"
|
68 |
+
|
69 |
+
#: search-regex.php:305
|
70 |
+
msgid "Regex:"
|
71 |
+
msgstr "Regex:"
|
72 |
+
|
73 |
+
#: search-regex.php:321
|
74 |
+
msgid "Replace"
|
75 |
+
msgstr "Замяніць"
|
76 |
+
|
77 |
+
#: search-regex.php:322
|
78 |
+
msgid "Replace & Save »"
|
79 |
+
msgstr "Замяніць & Захаваць »"
|
80 |
+
|
81 |
+
#: search-regex.php:312
|
82 |
+
msgid "Replace pattern"
|
83 |
+
msgstr "Шаблон замены"
|
84 |
+
|
85 |
+
#: search-regex.php:332
|
86 |
+
msgid "Results"
|
87 |
+
msgstr "рэзультаты"
|
88 |
+
|
89 |
+
#: search-regex.php:320
|
90 |
+
msgid "Search"
|
91 |
+
msgstr "пошук"
|
92 |
+
|
93 |
+
#: search-regex.php:284
|
94 |
+
#: search-regex.php:365
|
95 |
+
msgid "Search Regex"
|
96 |
+
msgstr "Search Regex"
|
97 |
+
|
98 |
+
#: search-regex.php:302
|
99 |
+
msgid "Search pattern"
|
100 |
+
msgstr "Шаблон пошуку"
|
101 |
+
|
102 |
+
#: search-regex.php:292
|
103 |
+
msgid "Source"
|
104 |
+
msgstr "Крыніца"
|
105 |
+
|
106 |
+
#: search-regex.php:356
|
107 |
+
msgid "There are no results."
|
108 |
+
msgstr "Няма рэзультатаў."
|
109 |
+
|
110 |
+
#: search-regex.php:285
|
111 |
+
msgid "WordPress Search & Replace, with full regular expression support. Replacements will only be saved to the database if you check 'save', otherwise you will get a preview of the results."
|
112 |
+
msgstr "WordPress пошук & замена, з поўнай падтрымкай рэгулярных выразаў. Замены будуць захаваныя ў базе дадзеных толькі пры ўмове, што вы адзначыце 'захаваць'."
|
113 |
+
|
114 |
+
#: search-regex.php:348
|
115 |
+
msgid "replaced with:"
|
116 |
+
msgstr "заменена"
|
117 |
+
|
locale/ar.mo
ADDED
Binary file
|
locale/ar.po
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR John Godley
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
msgid ""
|
7 |
+
msgstr ""
|
8 |
+
"Project-Id-Version: PACKAGE VERSION\n"
|
9 |
+
"Report-Msgid-Bugs-To: \n"
|
10 |
+
"POT-Creation-Date: 2006-07-13 12:44+0800\n"
|
11 |
+
"PO-Revision-Date: 2010-01-18 14:32+0300\n"
|
12 |
+
"Last-Translator: www.r-sn.com <web.rsn@gmail.com>\n"
|
13 |
+
"Language-Team: مدونة رسين <r-sn.com@hotmail.com>\n"
|
14 |
+
"MIME-Version: 1.0\n"
|
15 |
+
"Content-Type: text/plain; charset=utf8\n"
|
16 |
+
"Content-Transfer-Encoding: 8bit\n"
|
17 |
+
"X-Poedit-Language: Arabic\n"
|
18 |
+
"X-Poedit-Country: SAUDI ARABIA\n"
|
19 |
+
"X-Poedit-SourceCharset: utf8\n"
|
20 |
+
|
21 |
+
#: search-regex.php:335
|
22 |
+
#, php-format
|
23 |
+
msgid "%1$s results found."
|
24 |
+
msgstr "%1$s وجود نتائج"
|
25 |
+
|
26 |
+
#: search-regex.php:306
|
27 |
+
msgid "Case-less:"
|
28 |
+
msgstr "حالة على الأقل :"
|
29 |
+
|
30 |
+
#: search-regex.php:343
|
31 |
+
msgid "Comment"
|
32 |
+
msgstr "التعليق"
|
33 |
+
|
34 |
+
#: search-regex.php:296
|
35 |
+
msgid "Comments"
|
36 |
+
msgstr "التعليقات"
|
37 |
+
|
38 |
+
#: search-regex.php:308
|
39 |
+
msgid "Dot-all:"
|
40 |
+
msgstr "جميع النقاط :"
|
41 |
+
|
42 |
+
#: search-regex.php:59
|
43 |
+
msgid "Invalid regular expression"
|
44 |
+
msgstr "صلاحية المصطلح"
|
45 |
+
|
46 |
+
#: search-regex.php:297
|
47 |
+
msgid "Meta-data"
|
48 |
+
msgstr "البيانات الوصفية"
|
49 |
+
|
50 |
+
#: search-regex.php:307
|
51 |
+
msgid "Multi-line:"
|
52 |
+
msgstr "متعدد الأسطر :"
|
53 |
+
|
54 |
+
#: search-regex.php:286
|
55 |
+
msgid "NOTE: No liability is accepted for any damage caused - make sure to backup your database before clicking 'Replace & Save'."
|
56 |
+
msgstr "ملاحظة : لا نتحمل المسؤولية عن أي ضرر ناتج -- تأكد من أخذ نسخة احتياطية لقاعدة البيانات .. قبل النقر على 'استبدال & حفظ'"
|
57 |
+
|
58 |
+
#: search-regex.php:85
|
59 |
+
msgid "No search pattern"
|
60 |
+
msgstr "لا يوجد نمط البحث"
|
61 |
+
|
62 |
+
#: search-regex.php:341
|
63 |
+
msgid "Post"
|
64 |
+
msgstr "التدوينة"
|
65 |
+
|
66 |
+
#: search-regex.php:295
|
67 |
+
msgid "Posts & pages"
|
68 |
+
msgstr "تدوينات & صفحات"
|
69 |
+
|
70 |
+
#: search-regex.php:305
|
71 |
+
msgid "Regex:"
|
72 |
+
msgstr "Regex:"
|
73 |
+
|
74 |
+
#: search-regex.php:321
|
75 |
+
msgid "Replace"
|
76 |
+
msgstr "استبدال"
|
77 |
+
|
78 |
+
#: search-regex.php:322
|
79 |
+
msgid "Replace & Save »"
|
80 |
+
msgstr "استبدال & حفظ »"
|
81 |
+
|
82 |
+
#: search-regex.php:312
|
83 |
+
msgid "Replace pattern"
|
84 |
+
msgstr "كلمة الاستبدال"
|
85 |
+
|
86 |
+
#: search-regex.php:332
|
87 |
+
msgid "Results"
|
88 |
+
msgstr "نتائج"
|
89 |
+
|
90 |
+
#: search-regex.php:320
|
91 |
+
msgid "Search"
|
92 |
+
msgstr "بحث"
|
93 |
+
|
94 |
+
#: search-regex.php:284
|
95 |
+
#: search-regex.php:365
|
96 |
+
msgid "Search Regex"
|
97 |
+
msgstr "Search Regex"
|
98 |
+
|
99 |
+
#: search-regex.php:302
|
100 |
+
msgid "Search pattern"
|
101 |
+
msgstr "كلمة البحث"
|
102 |
+
|
103 |
+
#: search-regex.php:292
|
104 |
+
msgid "Source"
|
105 |
+
msgstr "المصدر"
|
106 |
+
|
107 |
+
#: search-regex.php:356
|
108 |
+
msgid "There are no results."
|
109 |
+
msgstr "لا توجد نتائج"
|
110 |
+
|
111 |
+
#: search-regex.php:285
|
112 |
+
msgid "WordPress Search & Replace, with full regular expression support. Replacements will only be saved to the database if you check 'save', otherwise you will get a preview of the results."
|
113 |
+
msgstr "البحث في الوورد بريس & والاستبدال ، مع دعم كامل المصطلحات العادية. الاستبدال سوف يتم حفظه في قاعدة البيانات إذا كنت من الاختيار اضغط 'حفظ' ، وإلا فإنك ستحصل على معاينة النتائج ."
|
114 |
+
|
115 |
+
#: search-regex.php:348
|
116 |
+
msgid "replaced with:"
|
117 |
+
msgstr "استبدال بـ :"
|
118 |
+
|
locale/search-regex.po
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR John Godley
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
#, fuzzy
|
7 |
+
msgid ""
|
8 |
+
msgstr ""
|
9 |
+
"Project-Id-Version: PACKAGE VERSION\n"
|
10 |
+
"Report-Msgid-Bugs-To: \n"
|
11 |
+
"POT-Creation-Date: 2006-07-13 12:44+0800\n"
|
12 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
+
"MIME-Version: 1.0\n"
|
16 |
+
"Content-Type: text/plain; charset=CHARSET\n"
|
17 |
+
"Content-Transfer-Encoding: 8bit\n"
|
18 |
+
|
19 |
+
#: search-regex.php:335
|
20 |
+
#, php-format
|
21 |
+
msgid "%1$s results found."
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: search-regex.php:306
|
25 |
+
msgid "Case-less:"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: search-regex.php:343
|
29 |
+
msgid "Comment"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: search-regex.php:296
|
33 |
+
msgid "Comments"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: search-regex.php:308
|
37 |
+
msgid "Dot-all:"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: search-regex.php:59
|
41 |
+
msgid "Invalid regular expression"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: search-regex.php:297
|
45 |
+
msgid "Meta-data"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: search-regex.php:307
|
49 |
+
msgid "Multi-line:"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: search-regex.php:286
|
53 |
+
msgid ""
|
54 |
+
"NOTE: No liability is accepted for any damage caused - make sure to backup "
|
55 |
+
"your database before clicking 'Replace & Save'."
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: search-regex.php:85
|
59 |
+
msgid "No search pattern"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: search-regex.php:341
|
63 |
+
msgid "Post"
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: search-regex.php:295
|
67 |
+
msgid "Posts & pages"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: search-regex.php:305
|
71 |
+
msgid "Regex:"
|
72 |
+
msgstr ""
|
73 |
+
|
74 |
+
#: search-regex.php:321
|
75 |
+
msgid "Replace"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: search-regex.php:322
|
79 |
+
msgid "Replace & Save »"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: search-regex.php:312
|
83 |
+
msgid "Replace pattern"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: search-regex.php:332
|
87 |
+
msgid "Results"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: search-regex.php:320
|
91 |
+
msgid "Search"
|
92 |
+
msgstr ""
|
93 |
+
|
94 |
+
#: search-regex.php:284 search-regex.php:365
|
95 |
+
msgid "Search Regex"
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: search-regex.php:302
|
99 |
+
msgid "Search pattern"
|
100 |
+
msgstr ""
|
101 |
+
|
102 |
+
#: search-regex.php:292
|
103 |
+
msgid "Source"
|
104 |
+
msgstr ""
|
105 |
+
|
106 |
+
#: search-regex.php:356
|
107 |
+
msgid "There are no results."
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: search-regex.php:285
|
111 |
+
msgid ""
|
112 |
+
"WordPress Search & Replace, with full regular expression support. "
|
113 |
+
"Replacements will only be saved to the database if you check 'save', "
|
114 |
+
"otherwise you will get a preview of the results."
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: search-regex.php:348
|
118 |
+
msgid "replaced with:"
|
119 |
+
msgstr ""
|
messages.po
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Adds search & replace functionality across posts, pages, comments, and meta-data, with full regular expression support
|
2 |
+
# Copyright (C) 2007 John Godley
|
3 |
+
# This file is distributed under the same license as the Search Regex package.
|
4 |
+
# John Godley, http://urbangiraffe.com/, 2007.
|
5 |
+
#
|
6 |
+
msgid ""
|
7 |
+
msgstr "Project-Id-Version: Search Regex 1.4\n"
|
8 |
+
"Report-Msgid-Bugs-To: \n"
|
9 |
+
"POT-Creation-Date: 2007-03-26 17:31+0800\n"
|
10 |
+
"PO-Revision-Date: 2007-MO-DA HO:MI+ZONE\n"
|
11 |
+
"Last-Translator: John Godley http://urbangiraffe.com/\n"
|
12 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Content-Type: text/plain; charset=UTF8\n"
|
15 |
+
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
|
17 |
+
#: view/admin/results.php:5
|
18 |
+
#, php-format
|
19 |
+
msgid "%1$s result(s) found."
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
#: searches/comment_author.php:44 searches/comment_author_email.php:44
|
23 |
+
#: searches/comment_author_url.php:44 searches/comment_content.php:44
|
24 |
+
#, php-format
|
25 |
+
msgid "Comment #%d: %s"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: searches/comment_author.php:47
|
29 |
+
msgid "Comment author"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: searches/comment_author_url.php:47
|
33 |
+
msgid "Comment author URL"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: searches/comment_author_email.php:47
|
37 |
+
msgid "Comment author email"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: searches/comment_content.php:47
|
41 |
+
msgid "Comment content"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: models/search.php:31
|
45 |
+
msgid "Invalid regular expression"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: searches/post_meta.php:45
|
49 |
+
#, php-format
|
50 |
+
msgid "Meta data for post #%d: %s"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: view/admin/search.php:4
|
54 |
+
msgid "NOTE: <strong>No liability</strong> is accepted for any damage "
|
55 |
+
"caused. You are strongly advised to backup your database before "
|
56 |
+
"making any changes."
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: models/search.php:68
|
60 |
+
msgid "No search pattern"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: searches/post_content.php:41 searches/post_excerpt.php:41
|
64 |
+
#: searches/post_title.php:41 searches/post_url.php:41
|
65 |
+
#, php-format
|
66 |
+
msgid "Post #%d: %s"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: searches/post_url.php:44
|
70 |
+
msgid "Post URL"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: searches/post_content.php:44
|
74 |
+
msgid "Post content"
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: searches/post_excerpt.php:44
|
78 |
+
msgid "Post excerpt"
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: searches/post_meta.php:48
|
82 |
+
msgid "Post meta value"
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: searches/post_title.php:44
|
86 |
+
msgid "Post title"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: view/admin/search.php:45
|
90 |
+
msgid "Replace"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: view/admin/search.php:46
|
94 |
+
msgid "Replace & Save »"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: view/admin/search.php:25
|
98 |
+
msgid "Replace pattern"
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: view/admin/search.php:3
|
102 |
+
msgid "Replacements will only be saved to the database if you click "
|
103 |
+
"'<strong>Replace & Save</strong>', otherwise you will get a "
|
104 |
+
"preview of the results."
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: view/admin/results.php:2
|
108 |
+
msgid "Results"
|
109 |
+
msgstr ""
|
110 |
+
|
111 |
+
#: view/admin/search.php:44
|
112 |
+
msgid "Search"
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: search-regex.php:75 view/admin/search.php:2
|
116 |
+
msgid "Search Regex"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: view/admin/search.php:19
|
120 |
+
msgid "Search pattern"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: view/admin/search.php:9
|
124 |
+
msgid "Source"
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: view/admin/results.php:58
|
128 |
+
msgid "There are no results."
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: view/admin/search.php:35
|
132 |
+
msgid "case-insensitive:"
|
133 |
+
msgstr ""
|
134 |
+
|
135 |
+
#: models/search.php:171
|
136 |
+
msgid "deleted"
|
137 |
+
msgstr ""
|
138 |
+
|
139 |
+
#: view/admin/search.php:37
|
140 |
+
msgid "dot-all:"
|
141 |
+
msgstr ""
|
142 |
+
|
143 |
+
#: models/search.php:146 models/search.php:167 searches/comment_author.php:38
|
144 |
+
#: searches/comment_author_email.php:38 searches/comment_author_url.php:38
|
145 |
+
#: searches/comment_content.php:38 searches/post_content.php:35
|
146 |
+
#: searches/post_excerpt.php:35 searches/post_meta.php:39
|
147 |
+
#: searches/post_title.php:35 searches/post_url.php:35
|
148 |
+
msgid "edit"
|
149 |
+
msgstr ""
|
150 |
+
|
151 |
+
#: view/admin/search.php:36
|
152 |
+
msgid "multi-line:"
|
153 |
+
msgstr ""
|
154 |
+
|
155 |
+
#: view/admin/results.php:18
|
156 |
+
msgid "replaced with:"
|
157 |
+
msgstr ""
|
158 |
+
|
159 |
+
#: searches/post_content.php:30 searches/post_excerpt.php:30
|
160 |
+
#: searches/post_title.php:30 searches/post_url.php:30
|
161 |
+
msgid "view"
|
162 |
+
msgstr ""
|
163 |
+
|
164 |
+
#: searches/comment_author.php:33 searches/comment_author_email.php:33
|
165 |
+
#: searches/comment_author_url.php:33 searches/comment_content.php:33
|
166 |
+
#: searches/post_meta.php:34
|
167 |
+
msgid "view post"
|
168 |
+
msgstr ""
|
models/result.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Result
|
4 |
+
{
|
5 |
+
var $search;
|
6 |
+
var $replace;
|
7 |
+
var $content;
|
8 |
+
var $id;
|
9 |
+
var $title;
|
10 |
+
|
11 |
+
var $offset;
|
12 |
+
var $length;
|
13 |
+
var $replace_string;
|
14 |
+
|
15 |
+
function for_js ($js)
|
16 |
+
{
|
17 |
+
$js = str_replace ('\\', '\\\\', $js);
|
18 |
+
$js = str_replace ('/', '\/', $js);
|
19 |
+
$js = str_replace ('<', '\<', $js);
|
20 |
+
$js = str_replace ("'", "\\'", $js);
|
21 |
+
$js = str_replace ('"', '"', $js);
|
22 |
+
$js = str_replace ("\n", "\\n", $js);
|
23 |
+
$js = str_replace ("\r", "\\r", $js);
|
24 |
+
return $js;
|
25 |
+
}
|
26 |
+
|
27 |
+
function single_line ()
|
28 |
+
{
|
29 |
+
if (strpos ($this->search_plain, "\r") !== false || strpos ($this->search_plain, "\n") !== false)
|
30 |
+
return false;
|
31 |
+
return true;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
?>
|
models/search.php
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Search
|
4 |
+
{
|
5 |
+
var $search = null;
|
6 |
+
var $replace = null;
|
7 |
+
var $search_params = null;
|
8 |
+
var $save = false;
|
9 |
+
var $source = null;
|
10 |
+
var $error = null;
|
11 |
+
|
12 |
+
var $regex_options = null;
|
13 |
+
var $regex_error = null;
|
14 |
+
var $regex = false;
|
15 |
+
|
16 |
+
function set_regex_options ($dotall, $case, $multi)
|
17 |
+
{
|
18 |
+
$this->regex = true;
|
19 |
+
if (!empty ($case))
|
20 |
+
$this->regex_options .= 'i';
|
21 |
+
|
22 |
+
if (!empty ($dotall))
|
23 |
+
$this->regex_options .= 's';
|
24 |
+
|
25 |
+
if (!empty ($multi))
|
26 |
+
$this->regex_options .= 'm';
|
27 |
+
}
|
28 |
+
|
29 |
+
function regex_error ($errno, $errstr, $errfile, $errline)
|
30 |
+
{
|
31 |
+
$this->regex_error = __ ("Invalid regular expression", 'search-regex').": ".preg_replace ('/(.*?):/', '', $errstr);
|
32 |
+
}
|
33 |
+
|
34 |
+
function name () { return '';}
|
35 |
+
function run_search ($search) { return false; }
|
36 |
+
|
37 |
+
function search_and_replace ($search, $replace, $limit, $offset, $orderby, $save = false)
|
38 |
+
{
|
39 |
+
$this->replace = $replace;
|
40 |
+
$results = $this->search_for_pattern ($search, $limit, $offset, $orderby);
|
41 |
+
|
42 |
+
if ($results !== false && $save)
|
43 |
+
$this->replace ($results);
|
44 |
+
return $results;
|
45 |
+
}
|
46 |
+
|
47 |
+
function search_for_pattern ($search, $limit, $offset, $orderby)
|
48 |
+
{
|
49 |
+
if (strlen ($search) > 0)
|
50 |
+
{
|
51 |
+
if (!ini_get ('safe_mode'))
|
52 |
+
set_time_limit (0);
|
53 |
+
|
54 |
+
// First test that the search and replace strings are valid regex
|
55 |
+
if ($this->regex)
|
56 |
+
{
|
57 |
+
set_error_handler (array (&$this, 'regex_error'));
|
58 |
+
$valid = @preg_match ($search, '', $matches);
|
59 |
+
restore_error_handler ();
|
60 |
+
|
61 |
+
if ($valid === false)
|
62 |
+
return $this->regex_error;
|
63 |
+
|
64 |
+
return $this->find ($search, $limit, $offset, $orderby);
|
65 |
+
}
|
66 |
+
else
|
67 |
+
return $this->find ('@'.preg_quote ($search, '@').'@', $limit, $offset, $orderby);
|
68 |
+
}
|
69 |
+
|
70 |
+
return __ ("No search pattern", 'search-regex');
|
71 |
+
}
|
72 |
+
|
73 |
+
function get_searches ()
|
74 |
+
{
|
75 |
+
global $search_regex_searches;
|
76 |
+
if (!is_array ($search_regex_searches))
|
77 |
+
{
|
78 |
+
$available = get_declared_classes ();
|
79 |
+
$files = glob (dirname (__FILE__).'/../searches/*.php');
|
80 |
+
if (!empty ($files))
|
81 |
+
{
|
82 |
+
foreach ($files AS $file)
|
83 |
+
include_once ($file);
|
84 |
+
}
|
85 |
+
|
86 |
+
$classes = array ();
|
87 |
+
$available = array_diff (get_declared_classes (), $available);
|
88 |
+
if (count ($available) > 0)
|
89 |
+
{
|
90 |
+
foreach ($available AS $class)
|
91 |
+
$classes[] = new $class;
|
92 |
+
}
|
93 |
+
|
94 |
+
$search_regex_searches = $classes;
|
95 |
+
}
|
96 |
+
|
97 |
+
return $search_regex_searches;
|
98 |
+
}
|
99 |
+
|
100 |
+
function valid_search ($class)
|
101 |
+
{
|
102 |
+
$classes = Search::get_searches ();
|
103 |
+
foreach ($classes AS $item)
|
104 |
+
{
|
105 |
+
if (strcasecmp (get_class ($item), $class) == 0)
|
106 |
+
return true;
|
107 |
+
}
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
|
111 |
+
function matches ($pattern, $content, $id)
|
112 |
+
{
|
113 |
+
if (preg_match_all ($pattern.$this->regex_options, $content, $matches, PREG_OFFSET_CAPTURE) > 0)
|
114 |
+
{
|
115 |
+
$results = array ();
|
116 |
+
|
117 |
+
// We found something
|
118 |
+
foreach ($matches[0] AS $found)
|
119 |
+
{
|
120 |
+
$result = new Result ();
|
121 |
+
$result->id = $id;
|
122 |
+
|
123 |
+
$result->offset = $found[1];
|
124 |
+
$result->length = strlen ($found[0]);
|
125 |
+
|
126 |
+
// Extract the context - surrounding 40 characters either side
|
127 |
+
// Index 0 is the match, index 1 is the position
|
128 |
+
$start = $found[1] - 40;
|
129 |
+
if ($start < 0)
|
130 |
+
$start = 0;
|
131 |
+
|
132 |
+
$end = $found[1] + 40;
|
133 |
+
if ($end > strlen ($content))
|
134 |
+
$end = strlen ($content);
|
135 |
+
|
136 |
+
$end -= $start;
|
137 |
+
|
138 |
+
$left = substr ($content, $start, $found[1] - $start);
|
139 |
+
$right = substr ($content, $found[1] + strlen ($found[0]), $end);
|
140 |
+
|
141 |
+
$result->left = $start;
|
142 |
+
$result->left_length = strlen ($found[0]) + ($found[1] - $start) + $end;
|
143 |
+
|
144 |
+
if ($start != 0)
|
145 |
+
$result->search = '… ';
|
146 |
+
|
147 |
+
$result->search .= htmlspecialchars ($left, HTML_ENTITIES, 'UTF-8');
|
148 |
+
$result->search .= '<a title="'.__ ('edit').'" onclick="return false;" ondblclick="regex_edit(\''.get_class ($this).'\','.$result->id.','.$result->offset.','.$result->length.'); return false" href="#">';
|
149 |
+
$result->search .= htmlspecialchars ($found[0], HTML_ENTITIES, 'UTF-8').'</a>';
|
150 |
+
$result->search .= htmlspecialchars ($right, HTML_ENTITIES, 'UTF-8');
|
151 |
+
|
152 |
+
$result->search_plain = htmlspecialchars ($left, HTML_ENTITIES, 'UTF-8');
|
153 |
+
$result->search_plain .= htmlspecialchars ($found[0], HTML_ENTITIES, 'UTF-8');
|
154 |
+
$result->search_plain .= htmlspecialchars ($right, HTML_ENTITIES, 'UTF-8');
|
155 |
+
|
156 |
+
if ($start + $end < strlen ($content))
|
157 |
+
$result->search .= ' …';
|
158 |
+
|
159 |
+
if (!is_null ($this->replace))
|
160 |
+
{
|
161 |
+
// Produce preview
|
162 |
+
$rep = preg_replace ($pattern.$this->regex_options, $this->replace, $found[0]);
|
163 |
+
$result->replace_string = $rep;
|
164 |
+
|
165 |
+
if ($start != 0)
|
166 |
+
$result->replace = '… ';
|
167 |
+
|
168 |
+
$result->replace .= htmlspecialchars ($left, HTML_ENTITIES, 'UTF-8');
|
169 |
+
$result->replace .= '<a title="'.__ ('edit').'" onclick="return false;" ondblclick="regex_edit_replace(\''.get_class ($this).'\','.$result->id.','.$result->offset.','.$result->length.'); return false" href="#">';
|
170 |
+
if ($rep != '')
|
171 |
+
$result->replace .= '<strong>'.htmlspecialchars ($rep, HTML_ENTITIES, 'UTF-8').'</strong></a>';
|
172 |
+
else
|
173 |
+
$result->replace .= '<strong>['.__ ('deleted','search-regex').']</strong></a>';
|
174 |
+
$result->replace .= htmlspecialchars ($right, HTML_ENTITIES, 'UTF-8');
|
175 |
+
|
176 |
+
$result->left_length_replace = strlen ($left) + strlen ($rep) + strlen ($right) + 1;
|
177 |
+
|
178 |
+
$result->replace_plain = htmlspecialchars ($left, HTML_ENTITIES, 'UTF-8');
|
179 |
+
$result->replace_plain .= htmlspecialchars ($rep, HTML_ENTITIES, 'UTF-8');
|
180 |
+
$result->replace_plain .= htmlspecialchars ($right, HTML_ENTITIES, 'UTF-8');
|
181 |
+
|
182 |
+
if ($start + $end < strlen ($content))
|
183 |
+
$result->replace .= ' …';
|
184 |
+
|
185 |
+
// And the real thing
|
186 |
+
$result->content = preg_replace ($pattern.$this->regex_options, $this->replace, $content);
|
187 |
+
}
|
188 |
+
|
189 |
+
$results[] = $result;
|
190 |
+
}
|
191 |
+
|
192 |
+
return $results;
|
193 |
+
}
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
function replace ($results)
|
199 |
+
{
|
200 |
+
global $wpdb;
|
201 |
+
|
202 |
+
// Update database, if appropriate
|
203 |
+
if (count ($results) > 0)
|
204 |
+
{
|
205 |
+
// We only do the first replace of any set, as that will cover everything
|
206 |
+
$lastid = '';
|
207 |
+
foreach ($results AS $result)
|
208 |
+
{
|
209 |
+
if ($result->id != $lastid)
|
210 |
+
{
|
211 |
+
$this->replace_content ($result->id, $result->content);
|
212 |
+
$lastid = $result->id;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
function replace_inline ($id, $offset, $length, $replace)
|
219 |
+
{
|
220 |
+
$content = $this->get_content ($id);
|
221 |
+
|
222 |
+
// Delete the original string
|
223 |
+
$before = substr ($content, 0, $offset);
|
224 |
+
$after = substr ($content, $offset + $length);
|
225 |
+
|
226 |
+
// Stick the new string between
|
227 |
+
$content = $before.$replace.$after;
|
228 |
+
|
229 |
+
// Insert back into database
|
230 |
+
$this->replace_content ($id, $content);
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
global $search_regex_searches;
|
235 |
+
?>
|
plugin.php
ADDED
@@ -0,0 +1,666 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// ======================================================================================
|
4 |
+
// This library is free software; you can redistribute it and/or
|
5 |
+
// modify it under the terms of the GNU Lesser General Public
|
6 |
+
// License as published by the Free Software Foundation; either
|
7 |
+
// version 2.1 of the License, or (at your option) any later version.
|
8 |
+
//
|
9 |
+
// This library is distributed in the hope that it will be useful,
|
10 |
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
+
// Lesser General Public License for more details.
|
13 |
+
// ======================================================================================
|
14 |
+
// @author John Godley (http://urbangiraffe.com)
|
15 |
+
// @version 0.1.26
|
16 |
+
// @copyright Copyright © 2007 John Godley, All Rights Reserved
|
17 |
+
// ======================================================================================
|
18 |
+
// 0.1.6 - Corrected WP locale functions
|
19 |
+
// 0.1.7 - Add phpdoc comments
|
20 |
+
// 0.1.8 - Support for Admin SSL
|
21 |
+
// 0.1.9 - URL encoding, defer localization until init
|
22 |
+
// 0.1.10 - Better URL encoding
|
23 |
+
// 0.1.11 - Make work in WP 2.0, fix HTTPS issue on IIS
|
24 |
+
// 0.1.12 - Activation/deactivation actions that take into account the directory
|
25 |
+
// 0.1.13 - Add realpath function
|
26 |
+
// 0.1.14 - Add select/checked functions, fix locale loader
|
27 |
+
// 0.1.15 - Remove dependency on prototype
|
28 |
+
// 0.1.16 - Add support for homedir in realpath
|
29 |
+
// 0.1.17 - Added widget class
|
30 |
+
// 0.1.18 - Expand checked function
|
31 |
+
// 0.1.19 - Make url() cope with sites with no trailing slash
|
32 |
+
// 0.1.20 - Change init function to prevent overloading
|
33 |
+
// 0.1.21 - Make widget work for WP 2.1
|
34 |
+
// 0.1.22 - Make select work with option groups, RSS compatability fix
|
35 |
+
// 0.1.23 - Make widget count work better, fix widgets in K2
|
36 |
+
// 0.1.24 - Make realpath better
|
37 |
+
// 0.1.25 - Support for new WP2.6 config location
|
38 |
+
// 0.1.26 - Add description to widget class
|
39 |
+
// ======================================================================================
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Wraps up several useful functions for WordPress plugins and provides a method to separate
|
44 |
+
* display HTML from PHP code.
|
45 |
+
*
|
46 |
+
* <h4>Display Rendering</h4>
|
47 |
+
* The class uses a similar technique to Ruby On Rails views, whereby the display HTML is kept
|
48 |
+
* in a separate directory and file from the main code. A display is 'rendered' (sent to the browser)
|
49 |
+
* or 'captured' (returned to the calling function).
|
50 |
+
*
|
51 |
+
* Template files are separated into two areas: admin and user. Admin templates are only for display in
|
52 |
+
* the WordPress admin interface, while user templates are typically for display on the site (although neither
|
53 |
+
* of these are enforced). All templates are PHP code, but are referred to without .php extension.
|
54 |
+
*
|
55 |
+
* The reason for this separation is that one golden rule of plugin creation is that someone will always want to change
|
56 |
+
* the formatting and style of your output. Rather than forcing them to modify the plugin (bad), or modify files within
|
57 |
+
* the plugin (equally bad), the class allows user templates to be overridden with files contained within the theme.
|
58 |
+
*
|
59 |
+
* An additional benefit is that it leads to code re-use, especially with regards to Ajax (i.e. your display code can be called from
|
60 |
+
* many locations)
|
61 |
+
*
|
62 |
+
* Template files are located within the 'view' subdirectory of the plugins base (specified when registering the plugin):
|
63 |
+
*
|
64 |
+
* <pre>myplugin/view/admin
|
65 |
+
* myplugin/view/myplugin</pre>
|
66 |
+
*
|
67 |
+
* Admin templates are contained within 'admin', and user templates are contained within a directory of the same name as the plugin.
|
68 |
+
*
|
69 |
+
* User files can be overridden within the theme by creating a similar directory structure:
|
70 |
+
*
|
71 |
+
* <pre>/themes/mytheme/view/myplugin</pre>
|
72 |
+
*
|
73 |
+
* The class will first look in the theme and then defaults to the plugin. A plugin should always provide default templates.
|
74 |
+
*
|
75 |
+
* <h4>Display Parameters</h4>
|
76 |
+
* Also similar to Ruby On Rails, when you display a template you must supply the parameters that the template has access to. This tries
|
77 |
+
* to ensure a very clean separation between code and display. Parameters are supplied as an associative array mapping variable name to variable value.
|
78 |
+
*
|
79 |
+
* For example,
|
80 |
+
*
|
81 |
+
* array ('message' => 'Your data was processed', 'items' => 103);
|
82 |
+
*
|
83 |
+
* <h4>How it works in practice</h4>
|
84 |
+
* You create a template file to display how many items have been processed. You store this in 'view/admin/processed.php':
|
85 |
+
*
|
86 |
+
* <pre><p>You processed <?php echo $items ?> items</p></pre>
|
87 |
+
*
|
88 |
+
* When you want to display this in your plugin you use:
|
89 |
+
*
|
90 |
+
* <pre> $this->render_admin ('processed', array ('items' => 100));
|
91 |
+
*
|
92 |
+
* @package WordPress base library
|
93 |
+
* @author John Godley
|
94 |
+
* @copyright Copyright (C) John Godley
|
95 |
+
**/
|
96 |
+
|
97 |
+
class SearchRegex_Plugin
|
98 |
+
{
|
99 |
+
/**
|
100 |
+
* Plugin name
|
101 |
+
* @var string
|
102 |
+
**/
|
103 |
+
var $plugin_name;
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Plugin 'view' directory
|
107 |
+
* @var string Directory
|
108 |
+
**/
|
109 |
+
var $plugin_base;
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Register your plugin with a name and base directory. This <strong>must</strong> be called once.
|
114 |
+
*
|
115 |
+
* @param string $name Name of your plugin. Is used to determine the plugin locale domain
|
116 |
+
* @param string $base Directory containing the plugin's 'view' files.
|
117 |
+
* @return void
|
118 |
+
**/
|
119 |
+
|
120 |
+
function register_plugin ($name, $base)
|
121 |
+
{
|
122 |
+
$this->plugin_base = rtrim (dirname ($base), '/');
|
123 |
+
$this->plugin_name = $name;
|
124 |
+
|
125 |
+
$this->add_action ('init', 'load_locale');
|
126 |
+
}
|
127 |
+
|
128 |
+
function load_locale ()
|
129 |
+
{
|
130 |
+
// Here we manually fudge the plugin locale as WP doesnt allow many options
|
131 |
+
$locale = get_locale ();
|
132 |
+
if ( empty($locale) )
|
133 |
+
$locale = 'en_US';
|
134 |
+
|
135 |
+
$mofile = dirname (__FILE__)."/locale/$locale.mo";
|
136 |
+
load_textdomain ($this->plugin_name, $mofile);
|
137 |
+
}
|
138 |
+
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Register a WordPress action and map it back to the calling object
|
142 |
+
*
|
143 |
+
* @param string $action Name of the action
|
144 |
+
* @param string $function Function name (optional)
|
145 |
+
* @param int $priority WordPress priority (optional)
|
146 |
+
* @param int $accepted_args Number of arguments the function accepts (optional)
|
147 |
+
* @return void
|
148 |
+
**/
|
149 |
+
|
150 |
+
function add_action ($action, $function = '', $priority = 10, $accepted_args = 1)
|
151 |
+
{
|
152 |
+
add_action ($action, array (&$this, $function == '' ? $action : $function), $priority, $accepted_args);
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Register a WordPress filter and map it back to the calling object
|
158 |
+
*
|
159 |
+
* @param string $action Name of the action
|
160 |
+
* @param string $function Function name (optional)
|
161 |
+
* @param int $priority WordPress priority (optional)
|
162 |
+
* @param int $accepted_args Number of arguments the function accepts (optional)
|
163 |
+
* @return void
|
164 |
+
**/
|
165 |
+
|
166 |
+
function add_filter ($filter, $function = '', $priority = 10, $accepted_args = 1)
|
167 |
+
{
|
168 |
+
add_filter ($filter, array (&$this, $function == '' ? $filter : $function), $priority, $accepted_args);
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Special activation function that takes into account the plugin directory
|
174 |
+
*
|
175 |
+
* @param string $pluginfile The plugin file location (i.e. __FILE__)
|
176 |
+
* @param string $function Optional function name, or default to 'activate'
|
177 |
+
* @return void
|
178 |
+
**/
|
179 |
+
|
180 |
+
function register_activation ($pluginfile, $function = '')
|
181 |
+
{
|
182 |
+
add_action ('activate_'.basename (dirname ($pluginfile)).'/'.basename ($pluginfile), array (&$this, $function == '' ? 'activate' : $function));
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Special deactivation function that takes into account the plugin directory
|
188 |
+
*
|
189 |
+
* @param string $pluginfile The plugin file location (i.e. __FILE__)
|
190 |
+
* @param string $function Optional function name, or default to 'deactivate'
|
191 |
+
* @return void
|
192 |
+
**/
|
193 |
+
|
194 |
+
function register_deactivation ($pluginfile, $function = '')
|
195 |
+
{
|
196 |
+
add_action ('deactivate_'.basename (dirname ($pluginfile)).'/'.basename ($pluginfile), array (&$this, $function == '' ? 'deactivate' : $function));
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Renders an admin section of display code
|
202 |
+
*
|
203 |
+
* @param string $ug_name Name of the admin file (without extension)
|
204 |
+
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
205 |
+
* @return void
|
206 |
+
**/
|
207 |
+
|
208 |
+
function render_admin ($ug_name, $ug_vars = array ())
|
209 |
+
{
|
210 |
+
global $plugin_base;
|
211 |
+
foreach ($ug_vars AS $key => $val)
|
212 |
+
$$key = $val;
|
213 |
+
|
214 |
+
if (file_exists ("{$this->plugin_base}/view/admin/$ug_name.php"))
|
215 |
+
include ("{$this->plugin_base}/view/admin/$ug_name.php");
|
216 |
+
else
|
217 |
+
echo "<p>Rendering of admin template {$this->plugin_base}/view/admin/$ug_name.php failed</p>";
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Renders a section of user display code. The code is first checked for in the current theme display directory
|
223 |
+
* before defaulting to the plugin
|
224 |
+
*
|
225 |
+
* @param string $ug_name Name of the admin file (without extension)
|
226 |
+
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
227 |
+
* @return void
|
228 |
+
**/
|
229 |
+
|
230 |
+
function render ($ug_name, $ug_vars = array ())
|
231 |
+
{
|
232 |
+
foreach ($ug_vars AS $key => $val)
|
233 |
+
$$key = $val;
|
234 |
+
|
235 |
+
if (file_exists (TEMPLATEPATH."/view/{$this->plugin_name}/$ug_name.php"))
|
236 |
+
include (TEMPLATEPATH."/view/{$this->plugin_name}/$ug_name.php");
|
237 |
+
else if (file_exists ("{$this->plugin_base}/view/{$this->plugin_name}/$ug_name.php"))
|
238 |
+
include ("{$this->plugin_base}/view/{$this->plugin_name}/$ug_name.php");
|
239 |
+
else
|
240 |
+
echo "<p>Rendering of template $ug_name.php failed</p>";
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Renders a section of user display code. The code is first checked for in the current theme display directory
|
246 |
+
* before defaulting to the plugin
|
247 |
+
*
|
248 |
+
* @param string $ug_name Name of the admin file (without extension)
|
249 |
+
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
250 |
+
* @return void
|
251 |
+
**/
|
252 |
+
|
253 |
+
function capture ($ug_name, $ug_vars = array ())
|
254 |
+
{
|
255 |
+
ob_start ();
|
256 |
+
$this->render ($ug_name, $ug_vars);
|
257 |
+
$output = ob_get_contents ();
|
258 |
+
ob_end_clean ();
|
259 |
+
return $output;
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Captures an admin section of display code
|
265 |
+
*
|
266 |
+
* @param string $ug_name Name of the admin file (without extension)
|
267 |
+
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
268 |
+
* @return string Captured code
|
269 |
+
**/
|
270 |
+
|
271 |
+
function capture_admin ($ug_name, $ug_vars = array ())
|
272 |
+
{
|
273 |
+
ob_start ();
|
274 |
+
$this->render_admin ($ug_name, $ug_vars);
|
275 |
+
$output = ob_get_contents ();
|
276 |
+
ob_end_clean ();
|
277 |
+
return $output;
|
278 |
+
}
|
279 |
+
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Display a standard error message (using CSS ID 'message' and classes 'fade' and 'error)
|
283 |
+
*
|
284 |
+
* @param string $message Message to display
|
285 |
+
* @return void
|
286 |
+
**/
|
287 |
+
|
288 |
+
function render_error ($message)
|
289 |
+
{
|
290 |
+
?>
|
291 |
+
<div class="fade error" id="message">
|
292 |
+
<p><?php echo $message ?></p>
|
293 |
+
</div>
|
294 |
+
<?php
|
295 |
+
}
|
296 |
+
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Display a standard notice (using CSS ID 'message' and class 'updated').
|
300 |
+
* Note that the notice can be made to automatically disappear, and can be removed
|
301 |
+
* by clicking on it.
|
302 |
+
*
|
303 |
+
* @param string $message Message to display
|
304 |
+
* @param int $timeout Number of seconds to automatically remove the message (optional)
|
305 |
+
* @return void
|
306 |
+
**/
|
307 |
+
|
308 |
+
function render_message ($message, $timeout = 0)
|
309 |
+
{
|
310 |
+
?>
|
311 |
+
<div class="updated" id="message" onclick="this.parentNode.removeChild (this)">
|
312 |
+
<p><?php echo $message ?></p>
|
313 |
+
</div>
|
314 |
+
<?php
|
315 |
+
}
|
316 |
+
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Get the plugin's base directory
|
320 |
+
*
|
321 |
+
* @return string Base directory
|
322 |
+
**/
|
323 |
+
|
324 |
+
function dir ()
|
325 |
+
{
|
326 |
+
return $this->plugin_base;
|
327 |
+
}
|
328 |
+
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Get a URL to the plugin. Useful for specifying JS and CSS files
|
332 |
+
*
|
333 |
+
* For example, <img src="<?php echo $this->url () ?>/myimage.png"/>
|
334 |
+
*
|
335 |
+
* @return string URL
|
336 |
+
**/
|
337 |
+
|
338 |
+
function url ($url = '')
|
339 |
+
{
|
340 |
+
if ($url)
|
341 |
+
return str_replace ('\\', urlencode ('\\'), str_replace ('&amp', '&', str_replace ('&', '&', $url)));
|
342 |
+
else
|
343 |
+
{
|
344 |
+
$root = ABSPATH;
|
345 |
+
if (defined ('WP_PLUGIN_DIR'))
|
346 |
+
$root = WP_PLUGIN_DIR;
|
347 |
+
|
348 |
+
$url = substr ($this->plugin_base, strlen ($this->realpath ($root)));
|
349 |
+
if (DIRECTORY_SEPARATOR != '/')
|
350 |
+
$url = str_replace (DIRECTORY_SEPARATOR, '/', $url);
|
351 |
+
|
352 |
+
if (defined ('WP_PLUGIN_URL'))
|
353 |
+
$url = WP_PLUGIN_URL.'/'.ltrim ($url, '/');
|
354 |
+
else
|
355 |
+
$url = get_bloginfo ('wpurl').'/'.ltrim ($url, '/');
|
356 |
+
|
357 |
+
// Do an SSL check - only works on Apache
|
358 |
+
global $is_IIS;
|
359 |
+
if (isset ($_SERVER['HTTPS']) && !$is_IIS)
|
360 |
+
$url = str_replace ('http://', 'https://', $url);
|
361 |
+
}
|
362 |
+
return $url;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Performs a version update check using an RSS feed. The function ensures that the feed is only
|
367 |
+
* hit once every given number of days, and the data is cached using the WordPress Magpie library
|
368 |
+
*
|
369 |
+
* @param string $url URL of the RSS feed
|
370 |
+
* @param int $days Number of days before next check
|
371 |
+
* @return string Text to display
|
372 |
+
**/
|
373 |
+
|
374 |
+
function version_update ($url, $days = 7)
|
375 |
+
{
|
376 |
+
if (!function_exists ('fetch_rss'))
|
377 |
+
{
|
378 |
+
if (!file_exists (ABSPATH.'wp-includes/rss.php'))
|
379 |
+
return '';
|
380 |
+
include (ABSPATH.'wp-includes/rss.php');
|
381 |
+
}
|
382 |
+
|
383 |
+
$now = time ();
|
384 |
+
|
385 |
+
$checked = get_option ('plugin_urbangiraffe_rss');
|
386 |
+
|
387 |
+
// Use built-in Magpie caching
|
388 |
+
if (function_exists ('fetch_rss') && (!isset ($checked[$this->plugin_name]) || $now > $checked[$this->plugin_name] + ($days * 24 * 60 * 60)))
|
389 |
+
{
|
390 |
+
$rss = fetch_rss ($url);
|
391 |
+
if (count ($rss->items) > 0)
|
392 |
+
{
|
393 |
+
foreach ($rss->items AS $pos => $item)
|
394 |
+
{
|
395 |
+
if (isset ($checked[$this->plugin_name]) && strtotime ($item['pubdate']) < $checked[$this->plugin_name])
|
396 |
+
unset ($rss->items[$pos]);
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
$checked[$this->plugin_name] = $now;
|
401 |
+
update_option ('plugin_urbangiraffe_rss', $checked);
|
402 |
+
return $rss;
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Version of realpath that will work on systems without realpath
|
409 |
+
*
|
410 |
+
* @param string $path The path to canonicalize
|
411 |
+
* @return string Canonicalized path
|
412 |
+
**/
|
413 |
+
|
414 |
+
function realpath ($path)
|
415 |
+
{
|
416 |
+
if (function_exists ('realpath'))
|
417 |
+
return realpath ($path);
|
418 |
+
else if (DIRECTORY_SEPARATOR == '/')
|
419 |
+
{
|
420 |
+
$path = preg_replace ('/^~/', $_SERVER['DOCUMENT_ROOT'], $path);
|
421 |
+
|
422 |
+
// canonicalize
|
423 |
+
$path = explode (DIRECTORY_SEPARATOR, $path);
|
424 |
+
$newpath = array ();
|
425 |
+
for ($i = 0; $i < sizeof ($path); $i++)
|
426 |
+
{
|
427 |
+
if ($path[$i] === '' || $path[$i] === '.')
|
428 |
+
continue;
|
429 |
+
|
430 |
+
if ($path[$i] === '..')
|
431 |
+
{
|
432 |
+
array_pop ($newpath);
|
433 |
+
continue;
|
434 |
+
}
|
435 |
+
|
436 |
+
array_push ($newpath, $path[$i]);
|
437 |
+
}
|
438 |
+
|
439 |
+
$finalpath = DIRECTORY_SEPARATOR.implode (DIRECTORY_SEPARATOR, $newpath);
|
440 |
+
return $finalpath;
|
441 |
+
}
|
442 |
+
|
443 |
+
return $path;
|
444 |
+
}
|
445 |
+
|
446 |
+
|
447 |
+
function checked ($item, $field = '')
|
448 |
+
{
|
449 |
+
if ($field && is_array ($item))
|
450 |
+
{
|
451 |
+
if (isset ($item[$field]) && $item[$field])
|
452 |
+
echo ' checked="checked"';
|
453 |
+
}
|
454 |
+
else if (!empty ($item))
|
455 |
+
echo ' checked="checked"';
|
456 |
+
}
|
457 |
+
|
458 |
+
function select ($items, $default = '')
|
459 |
+
{
|
460 |
+
if (count ($items) > 0)
|
461 |
+
{
|
462 |
+
foreach ($items AS $key => $value)
|
463 |
+
{
|
464 |
+
if (is_array ($value))
|
465 |
+
{
|
466 |
+
echo '<optgroup label="'.$key.'">';
|
467 |
+
foreach ($value AS $sub => $subvalue)
|
468 |
+
echo '<option value="'.$sub.'"'.($sub == $default ? ' selected="selected"' : '').'>'.$subvalue.'</option>';
|
469 |
+
echo '</optgroup>';
|
470 |
+
}
|
471 |
+
else
|
472 |
+
echo '<option value="'.$key.'"'.($key == $default ? ' selected="selected"' : '').'>'.$value.'</option>';
|
473 |
+
}
|
474 |
+
}
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
if (!function_exists ('pr'))
|
479 |
+
{
|
480 |
+
function pr ($thing)
|
481 |
+
{
|
482 |
+
echo '<pre>';
|
483 |
+
print_r ($thing);
|
484 |
+
echo '</pre>';
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
if (!class_exists ('SR_Widget_Class'))
|
489 |
+
{
|
490 |
+
class SR_Widget_Class
|
491 |
+
{
|
492 |
+
function SR_Widget_Class ($name, $max = 1, $id = '', $args = '')
|
493 |
+
{
|
494 |
+
$this->name = $name;
|
495 |
+
$this->id = $id;
|
496 |
+
$this->widget_max = $max;
|
497 |
+
$this->args = $args;
|
498 |
+
|
499 |
+
if ($this->id == '')
|
500 |
+
$this->id = strtolower (preg_replace ('/[^A-Za-z]/', '-', $this->name));
|
501 |
+
|
502 |
+
$this->widget_available = 1;
|
503 |
+
if ($this->widget_max > 1)
|
504 |
+
{
|
505 |
+
$this->widget_available = get_option ('widget_available_'.$this->id ());
|
506 |
+
if ($this->widget_available === false)
|
507 |
+
$this->widget_available = 1;
|
508 |
+
}
|
509 |
+
|
510 |
+
add_action ('init', array (&$this, 'initialize'));
|
511 |
+
}
|
512 |
+
|
513 |
+
function initialize ()
|
514 |
+
{
|
515 |
+
// Compatability functions for WP 2.1
|
516 |
+
if (!function_exists ('wp_register_sidebar_widget'))
|
517 |
+
{
|
518 |
+
function wp_register_sidebar_widget ($id, $name, $output_callback, $classname = '')
|
519 |
+
{
|
520 |
+
register_sidebar_widget($name, $output_callback, $classname);
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
if (!function_exists ('wp_register_widget_control'))
|
525 |
+
{
|
526 |
+
function wp_register_widget_control($name, $control_callback, $width = 300, $height = 200)
|
527 |
+
{
|
528 |
+
register_widget_control($name, $control_callback, $width, $height);
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
if (function_exists ('wp_register_sidebar_widget'))
|
533 |
+
{
|
534 |
+
if ($this->widget_max > 1)
|
535 |
+
{
|
536 |
+
add_action ('sidebar_admin_setup', array (&$this, 'setup_save'));
|
537 |
+
add_action ('sidebar_admin_page', array (&$this, 'setup_display'));
|
538 |
+
}
|
539 |
+
|
540 |
+
$this->load_widgets ();
|
541 |
+
}
|
542 |
+
}
|
543 |
+
|
544 |
+
function load_widgets ()
|
545 |
+
{
|
546 |
+
for ($pos = 1; $pos <= $this->widget_max; $pos++)
|
547 |
+
{
|
548 |
+
wp_register_sidebar_widget ($this->id ($pos), $this->name ($pos), $pos <= $this->widget_available ? array (&$this, 'show_display') : '', $this->args (), $pos);
|
549 |
+
|
550 |
+
if ($this->has_config ())
|
551 |
+
wp_register_widget_control ($this->id ($pos), $this->name ($pos), $pos <= $this->widget_available ? array (&$this, 'show_config') : '', $this->args (), $pos);
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
function args ()
|
556 |
+
{
|
557 |
+
if ($this->args)
|
558 |
+
$args = $this->args;
|
559 |
+
else
|
560 |
+
$args = array ('classname' => '');
|
561 |
+
|
562 |
+
if ($this->description ())
|
563 |
+
$args['description'] = $this->description ();
|
564 |
+
return $args;
|
565 |
+
}
|
566 |
+
|
567 |
+
function description () { return ''; }
|
568 |
+
|
569 |
+
function name ($pos)
|
570 |
+
{
|
571 |
+
if ($this->widget_available > 1)
|
572 |
+
return $this->name.' ('.$pos.')';
|
573 |
+
return $this->name;
|
574 |
+
}
|
575 |
+
|
576 |
+
function id ($pos = 0)
|
577 |
+
{
|
578 |
+
if ($pos == 0)
|
579 |
+
return $this->id;
|
580 |
+
return $this->id.'-'.$pos;
|
581 |
+
}
|
582 |
+
|
583 |
+
function show_display ($args, $number = 1)
|
584 |
+
{
|
585 |
+
$config = get_option ('widget_config_'.$this->id ($number));
|
586 |
+
if ($config === false)
|
587 |
+
$config = array ();
|
588 |
+
|
589 |
+
$this->load ($config);
|
590 |
+
$this->display ($args);
|
591 |
+
}
|
592 |
+
|
593 |
+
function show_config ($position)
|
594 |
+
{
|
595 |
+
if (isset ($_POST['widget_config_save_'.$this->id ($position)]))
|
596 |
+
{
|
597 |
+
$data = $_POST[$this->id ()];
|
598 |
+
if (count ($data) > 0)
|
599 |
+
{
|
600 |
+
$newdata = array ();
|
601 |
+
foreach ($data AS $item => $values)
|
602 |
+
$newdata[$item] = $values[$position];
|
603 |
+
$data = $newdata;
|
604 |
+
}
|
605 |
+
|
606 |
+
update_option ('widget_config_'.$this->id ($position), $this->save ($data));
|
607 |
+
}
|
608 |
+
|
609 |
+
$options = get_option ('widget_config_'.$this->id ($position));
|
610 |
+
if ($options === false)
|
611 |
+
$options = array ();
|
612 |
+
|
613 |
+
$this->config ($options, $position);
|
614 |
+
echo '<input type="hidden" name="widget_config_save_'.$this->id ($position).'" value="1" />';
|
615 |
+
}
|
616 |
+
|
617 |
+
function has_config () { return false; }
|
618 |
+
function save ($data)
|
619 |
+
{
|
620 |
+
return array ();
|
621 |
+
}
|
622 |
+
|
623 |
+
function setup_save ()
|
624 |
+
{
|
625 |
+
if (isset ($_POST['widget_setup_save_'.$this->id ()]))
|
626 |
+
{
|
627 |
+
$this->widget_available = intval ($_POST['widget_setup_count_'.$this->id ()]);
|
628 |
+
if ($this->widget_available < 1)
|
629 |
+
$this->widget_available = 1;
|
630 |
+
else if ($this->widget_available > $this->widget_max)
|
631 |
+
$this->widget_available = $this->widget_max;
|
632 |
+
|
633 |
+
update_option ('widget_available_'.$this->id (), $this->widget_available);
|
634 |
+
|
635 |
+
$this->load_widgets ();
|
636 |
+
}
|
637 |
+
}
|
638 |
+
|
639 |
+
function config_name ($field, $pos)
|
640 |
+
{
|
641 |
+
return $this->id ().'['.$field.']['.$pos.']';
|
642 |
+
}
|
643 |
+
|
644 |
+
function setup_display ()
|
645 |
+
{
|
646 |
+
?>
|
647 |
+
<div class="wrap">
|
648 |
+
<form method="post">
|
649 |
+
<h2><?php echo $this->name ?></h2>
|
650 |
+
<p style="line-height: 30px;"><?php _e('How many widgets would you like?', $this->id); ?>
|
651 |
+
<select name="widget_setup_count_<?php echo $this->id () ?>" value="<?php echo $options; ?>">
|
652 |
+
<?php for ( $i = 1; $i <= $this->widget_max; ++$i ) : ?>
|
653 |
+
<option value="<?php echo $i ?>"<?php if ($this->widget_available == $i) echo ' selected="selected"' ?>><?php echo $i ?></option>
|
654 |
+
<?php endfor; ?>
|
655 |
+
</select>
|
656 |
+
<span class="submit">
|
657 |
+
<input type="submit" name="widget_setup_save_<?php echo $this->id () ?>" value="<?php echo attribute_escape(__('Save', $this->id)); ?>" />
|
658 |
+
</span>
|
659 |
+
</p>
|
660 |
+
</form>
|
661 |
+
</div>
|
662 |
+
<?php
|
663 |
+
}
|
664 |
+
}
|
665 |
+
}
|
666 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Search Regex ===
|
2 |
+
Contributors: johnny5
|
3 |
+
Donate link: http://urbangiraffe.com/about/support/
|
4 |
+
Tags: search, regex, regular expression, admin, post, page
|
5 |
+
Requires at least: 2.0
|
6 |
+
Tested up to: 3.2.1
|
7 |
+
Stable tag: trunk
|
8 |
+
|
9 |
+
Search Regex adds a powerful set of search and replace functions to WordPress that go beyond the standard searching capabilities, with full regex support.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Search Regex adds a powerful set of search and replace functions to WordPress. These go beyond the standard searching capabilities, and allow you to search and replace almost any data stored on your site. In addition to simple searches you have the full power of PHP's regular expressions at your disposal.
|
14 |
+
|
15 |
+
The driving force behind this plugin is to aid in website migration and upgrading. If you've ever done either of these then you know the pain of having to go back through all your data, changing URL paths and fixing things. With this plugin you can reduce this work to a search and replace pattern and the job is finished in seconds.
|
16 |
+
|
17 |
+
Why would you want this? The primary reason for the plugin was to aid in relocating directories. It's a real pain to manually go through every post and change image directory names. With this plugin all that was required was a simple search and replace pattern, and the job was finished in a few seconds.
|
18 |
+
|
19 |
+
Search Regex is available in the following languages:
|
20 |
+
|
21 |
+
* English
|
22 |
+
* Arabic, thanks to ()[]
|
23 |
+
* Belarussian, thanks to (Marcis Gasuns)[http://www.fatcow.com]
|
24 |
+
|
25 |
+
== Installation ==
|
26 |
+
|
27 |
+
The plugin is simple to install:
|
28 |
+
|
29 |
+
1. Download `search-regex.zip`
|
30 |
+
1. Unzip
|
31 |
+
1. Upload `search-regex` directory to your `/wp-content/plugins` directory
|
32 |
+
1. Go to the plugin management page and enable the plugin
|
33 |
+
1. Configure the plugin from `Management/Search Regex`
|
34 |
+
|
35 |
+
You can find full details of installing a plugin on the [plugin installation page](http://urbangiraffe.com/articles/how-to-install-a-wordpress-plugin/).
|
36 |
+
|
37 |
+
== Screenshots ==
|
38 |
+
|
39 |
+
1. Search options
|
40 |
+
2. Inline search and replace
|
41 |
+
|
42 |
+
== Documentation ==
|
43 |
+
|
44 |
+
Full documentation can be found on the [Search Regex Page](http://urbangiraffe.com/plugins/search-regex/) page.
|
45 |
+
|
46 |
+
== Changelog ==
|
47 |
+
|
48 |
+
= 1.4.11 =
|
49 |
+
* Add Arabic translation
|
50 |
+
|
51 |
+
= 1.4.10 =
|
52 |
+
* Fix deep slashes
|
53 |
+
|
54 |
+
= 1.4.9 =
|
55 |
+
* WP 2.8 compatibility
|
56 |
+
|
57 |
+
= 1.4.8 =
|
58 |
+
* Update base library
|
59 |
+
* Fix issue with regex not being selected
|
60 |
+
|
61 |
+
= 1.4.7 =
|
62 |
+
* WP 2.6
|
63 |
+
= 1.4.6 =
|
64 |
+
* Added tag & sniplet searching.
|
65 |
+
* Make work in Safari
|
66 |
+
|
67 |
+
= 1.4.5 =
|
68 |
+
* Add search regex capabilities ('search_regex_read' and 'search_regex_write').
|
69 |
+
* Fix meta values
|
70 |
+
|
71 |
+
= 1.4.4 =
|
72 |
+
* Fix escaping issue
|
73 |
+
* Allowing search limit and direction
|
74 |
+
|
75 |
+
= 1.4.3 =
|
76 |
+
* Allow searching in pings & trackbacks
|
77 |
+
|
78 |
+
= 1.4.2 =
|
79 |
+
* Fix escaping bug
|
80 |
+
|
81 |
+
= 1.4 =
|
82 |
+
* Extensible plugins
|
83 |
+
* Reorganisation of code
|
84 |
+
|
85 |
+
= 1.3 =
|
86 |
+
* Use correct table prefix
|
87 |
+
|
88 |
+
= 1.2 =
|
89 |
+
* Fix stupid typo
|
90 |
+
|
91 |
+
= 1.1 =
|
92 |
+
* Minor cosmetic changes
|
93 |
+
* Set a timeout limit
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
search-regex.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Search Regex
|
4 |
+
Plugin URI: http://urbangiraffe.com/plugins/search-regex
|
5 |
+
Description: Adds search & replace functionality across posts, pages, comments, and meta-data, with full regular expression support
|
6 |
+
Author: John Godley
|
7 |
+
Version: 1.4.11
|
8 |
+
Author URI: http://urbangiraffe.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
include (dirname (__FILE__).'/plugin.php');
|
12 |
+
|
13 |
+
class SearchRegex extends SearchRegex_Plugin
|
14 |
+
{
|
15 |
+
function SearchRegex ()
|
16 |
+
{
|
17 |
+
if (is_admin ())
|
18 |
+
{
|
19 |
+
include (dirname (__FILE__).'/models/search.php');
|
20 |
+
include (dirname (__FILE__).'/models/result.php');
|
21 |
+
|
22 |
+
$this->register_plugin ('search-regex', __FILE__);
|
23 |
+
$this->add_filter ('admin_menu');
|
24 |
+
|
25 |
+
if (strstr ($_SERVER['REQUEST_URI'], 'search-regex.php'))
|
26 |
+
{
|
27 |
+
wp_enqueue_script ('prototype');
|
28 |
+
wp_enqueue_script ('scriptaculous');
|
29 |
+
$this->add_filter ('admin_head');
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
function admin_screen ()
|
35 |
+
{
|
36 |
+
$searches = Search::get_searches ();
|
37 |
+
|
38 |
+
$search_pattern = $replace_pattern = '';
|
39 |
+
if (isset ($_POST['search_pattern']))
|
40 |
+
$search_pattern = stripslashes( $_POST['search_pattern'] );
|
41 |
+
if (isset ($_POST['replace_pattern']))
|
42 |
+
$replace_pattern = stripslashes( $_POST['replace_pattern'] );
|
43 |
+
|
44 |
+
$search_pattern = str_replace ("\'", "'", $search_pattern);
|
45 |
+
$replace_pattern = str_replace ("\'", "'", $replace_pattern);
|
46 |
+
$orderby = isset( $_POST['orderby'] ) ? stripslashes( $_POST['orderby'] ) : '';
|
47 |
+
$limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 0;
|
48 |
+
$offset = 0;
|
49 |
+
|
50 |
+
$source = isset( $_POST['source'] ) ? stripslashes( $_POST['source'] ) : '';
|
51 |
+
|
52 |
+
if (Search::valid_search ($source) && (isset ($_POST['search']) || isset ($_POST['replace']) || isset ($_POST['replace_and_save'])))
|
53 |
+
{
|
54 |
+
$klass = stripslashes( $_POST['source'] );
|
55 |
+
$searcher = new $klass;
|
56 |
+
if (isset ($_POST['regex']))
|
57 |
+
$searcher->set_regex_options ($_POST['dotall'], $_POST['case'], $_POST['multi']);
|
58 |
+
|
59 |
+
// Make sure no one sneaks in with a replace
|
60 |
+
if (!current_user_can ('administrator') && !current_user_can ('search_regex_write'))
|
61 |
+
{
|
62 |
+
unset ($_POST['replace']);
|
63 |
+
unset ($_POST['replace_and_save']);
|
64 |
+
$_POST['search'] = 'search';
|
65 |
+
}
|
66 |
+
|
67 |
+
$results = array();
|
68 |
+
if (isset ($_POST['search']))
|
69 |
+
$results = $searcher->search_for_pattern (stripslashes( $_POST['search_pattern'] ), $limit, $offset, $orderby);
|
70 |
+
else if (isset ($_POST['replace']))
|
71 |
+
$results = $searcher->search_and_replace (stripslashes( $_POST['search_pattern'] ), stripslashes( $_POST['replace_pattern'] ), $limit, $offset, $orderby);
|
72 |
+
else if (isset ($_POST['replace_and_save']))
|
73 |
+
$results = $searcher->search_and_replace (stripslashes( $_POST['search_pattern'] ), stripslashes( $_POST['replace_pattern'] ), $limit, $offset, $orderby, true);
|
74 |
+
|
75 |
+
if (!is_array ($results))
|
76 |
+
$this->render_error ($results);
|
77 |
+
else if (isset ($_POST['replace_and_save']))
|
78 |
+
$this->render_message (sprintf ('%d occurrence(s) replaced', count ($results)));
|
79 |
+
|
80 |
+
$this->render_admin ('search', array ('search' => $search_pattern, 'replace' => $replace_pattern, 'searches' => $searches));
|
81 |
+
|
82 |
+
if (is_array ($results) && !isset ($_POST['replace_and_save']))
|
83 |
+
$this->render_admin ('results', array ('search' => $searcher, 'results' => $results));
|
84 |
+
}
|
85 |
+
else
|
86 |
+
$this->render_admin ('search', array ('search' => $search_pattern, 'replace' => $replace_pattern, 'searches' => $searches));
|
87 |
+
}
|
88 |
+
|
89 |
+
function admin_menu ()
|
90 |
+
{
|
91 |
+
if (current_user_can ('administrator'))
|
92 |
+
add_management_page (__ ("Search Regex", 'search-regex'), __ ("Search Regex", 'search-regex'), 'administrator', basename (__FILE__), array (&$this, 'admin_screen'));
|
93 |
+
else if (current_user_can ('search_regex_read'))
|
94 |
+
add_management_page (__ ("Search Regex", 'search-regex'), __ ("Search Regex", 'search-regex'), 'search_regex_read', basename (__FILE__), array (&$this, 'admin_screen'));
|
95 |
+
}
|
96 |
+
|
97 |
+
function admin_head ()
|
98 |
+
{
|
99 |
+
$this->render_admin ('head');
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$search_regex = new SearchRegex;
|
104 |
+
?>
|
searches/comment_author.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchCommentAuthor extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
if ($orderby == 'id')
|
10 |
+
$order = 'comment_ID ASC';
|
11 |
+
else
|
12 |
+
$order = 'comment_date DESC';
|
13 |
+
|
14 |
+
$results = array ();
|
15 |
+
$comments = $wpdb->get_results ("SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_author AS comment_author, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby LIMIT $offset,$limit");
|
16 |
+
if (count ($comments) > 0)
|
17 |
+
{
|
18 |
+
foreach ($comments AS $comment)
|
19 |
+
{
|
20 |
+
if (($matches = $this->matches ($pattern, $comment->comment_author, $comment->comment_ID)))
|
21 |
+
{
|
22 |
+
foreach ($matches AS $match)
|
23 |
+
{
|
24 |
+
$match->sub_id = $comment->comment_post_ID;
|
25 |
+
$match->title = $comment->post_title;
|
26 |
+
}
|
27 |
+
|
28 |
+
$results = array_merge ($results, $matches);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $results;
|
34 |
+
}
|
35 |
+
|
36 |
+
function get_options ($result)
|
37 |
+
{
|
38 |
+
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
39 |
+
if ($result->replace)
|
40 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentAuthor\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
41 |
+
|
42 |
+
if (current_user_can ('edit_post', $result->id))
|
43 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
44 |
+
return $options;
|
45 |
+
}
|
46 |
+
|
47 |
+
function show ($result)
|
48 |
+
{
|
49 |
+
printf (__ ('Comment #%d: %s', 'search-regex'), $result->id, $result->title);
|
50 |
+
}
|
51 |
+
|
52 |
+
function name () { return __ ('Comment author', 'search-regex'); }
|
53 |
+
|
54 |
+
function get_content ($id)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
|
58 |
+
$row = $wpdb->get_row ("SELECT comment_author FROM {$wpdb->comments} WHERE comment_ID='$id'");
|
59 |
+
return $row->comment_content;
|
60 |
+
}
|
61 |
+
|
62 |
+
function replace_content ($id, $content)
|
63 |
+
{
|
64 |
+
global $wpdb;
|
65 |
+
$content = $wpdb->escape ($content);
|
66 |
+
$wpdb->query ("UPDATE {$wpdb->comments} SET comment_author='{$content}' WHERE comment_ID='$id'");
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
?>
|
searches/comment_author_email.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchCommentAuthorEmail extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
if ($orderby == 'id')
|
10 |
+
$order = 'comment_ID ASC';
|
11 |
+
else
|
12 |
+
$order = 'comment_date DESC';
|
13 |
+
|
14 |
+
$results = array ();
|
15 |
+
$comments = $wpdb->get_results ("SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_author_email AS comment_author_email, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby LIMIT $offset,$limit");
|
16 |
+
if (count ($comments) > 0)
|
17 |
+
{
|
18 |
+
foreach ($comments AS $comment)
|
19 |
+
{
|
20 |
+
if (($matches = $this->matches ($pattern, $comment->comment_author_email, $comment->comment_ID)))
|
21 |
+
{
|
22 |
+
foreach ($matches AS $match)
|
23 |
+
{
|
24 |
+
$match->sub_id = $comment->comment_post_ID;
|
25 |
+
$match->title = $comment->post_title;
|
26 |
+
}
|
27 |
+
|
28 |
+
$results = array_merge ($results, $matches);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $results;
|
34 |
+
}
|
35 |
+
|
36 |
+
function get_options ($result)
|
37 |
+
{
|
38 |
+
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
39 |
+
if ($result->replace)
|
40 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentAuthorEmail\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
41 |
+
|
42 |
+
if (current_user_can ('edit_post', $result->id))
|
43 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
44 |
+
return $options;
|
45 |
+
}
|
46 |
+
|
47 |
+
function show ($result)
|
48 |
+
{
|
49 |
+
printf (__ ('Comment #%d: %s', 'search-regex'), $result->id, $result->title);
|
50 |
+
}
|
51 |
+
|
52 |
+
function name () { return __ ('Comment author email', 'search-regex'); }
|
53 |
+
|
54 |
+
function get_content ($id)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
|
58 |
+
$row = $wpdb->get_row ("SELECT comment_author_email FROM {$wpdb->comments} WHERE comment_ID='$id'");
|
59 |
+
return $row->comment_author_email;
|
60 |
+
}
|
61 |
+
|
62 |
+
function replace_content ($id, $content)
|
63 |
+
{
|
64 |
+
global $wpdb;
|
65 |
+
$content = $wpdb->escape ($content);
|
66 |
+
$wpdb->query ("UPDATE {$wpdb->comments} SET comment_author_email='{$content}' WHERE comment_ID='$id'");
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
?>
|
searches/comment_author_url.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchCommentAuthorURL extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
if ($orderby == 'id')
|
10 |
+
$order = 'comment_ID ASC';
|
11 |
+
else
|
12 |
+
$order = 'comment_date DESC';
|
13 |
+
|
14 |
+
$results = array ();
|
15 |
+
$comments = $wpdb->get_results ("SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_author_url AS comment_author_url, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby LIMIT $offset,$limit");
|
16 |
+
if (count ($comments) > 0)
|
17 |
+
{
|
18 |
+
foreach ($comments AS $comment)
|
19 |
+
{
|
20 |
+
if (($matches = $this->matches ($pattern, $comment->comment_author_url, $comment->comment_ID)))
|
21 |
+
{
|
22 |
+
foreach ($matches AS $match)
|
23 |
+
{
|
24 |
+
$match->sub_id = $comment->comment_post_ID;
|
25 |
+
$match->title = $comment->post_title;
|
26 |
+
}
|
27 |
+
|
28 |
+
$results = array_merge ($results, $matches);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $results;
|
34 |
+
}
|
35 |
+
|
36 |
+
function get_options ($result)
|
37 |
+
{
|
38 |
+
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
39 |
+
if ($result->replace)
|
40 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentAuthorURL\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
41 |
+
|
42 |
+
if (current_user_can ('edit_post', $result->id))
|
43 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
44 |
+
return $options;
|
45 |
+
}
|
46 |
+
|
47 |
+
function show ($result)
|
48 |
+
{
|
49 |
+
printf (__ ('Comment #%d: %s', 'search-regex'), $result->id, $result->title);
|
50 |
+
}
|
51 |
+
|
52 |
+
function name () { return __ ('Comment author URL', 'search-regex'); }
|
53 |
+
|
54 |
+
function get_content ($id)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
|
58 |
+
$row = $wpdb->get_row ("SELECT comment_author_url FROM {$wpdb->comments} WHERE comment_ID='$id'");
|
59 |
+
return $row->comment_author_url;
|
60 |
+
}
|
61 |
+
|
62 |
+
function replace_content ($id, $content)
|
63 |
+
{
|
64 |
+
global $wpdb;
|
65 |
+
$content = $wpdb->escape ($content);
|
66 |
+
$wpdb->query ("UPDATE {$wpdb->comments} SET comment_author_url='{$content}' WHERE comment_ID='$id'");
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
?>
|
searches/comment_content.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchCommentContent extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$comments = $wpdb->get_results ("SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_content AS comment_content, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby LIMIT $offset,$limit");
|
11 |
+
if (count ($comments) > 0)
|
12 |
+
{
|
13 |
+
foreach ($comments AS $comment)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $comment->comment_content, $comment->comment_ID)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
{
|
19 |
+
$match->sub_id = $comment->comment_post_ID;
|
20 |
+
$match->title = $comment->post_title;
|
21 |
+
}
|
22 |
+
|
23 |
+
$results = array_merge ($results, $matches);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $results;
|
29 |
+
}
|
30 |
+
|
31 |
+
function get_options ($result)
|
32 |
+
{
|
33 |
+
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
34 |
+
if ($result->replace)
|
35 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentContent\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
36 |
+
|
37 |
+
if (current_user_can ('edit_post', $result->id))
|
38 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
39 |
+
return $options;
|
40 |
+
}
|
41 |
+
|
42 |
+
function show ($result)
|
43 |
+
{
|
44 |
+
printf (__ ('Comment #%d: %s', 'search-regex'), $result->id, $result->title);
|
45 |
+
}
|
46 |
+
|
47 |
+
function name () { return __ ('Comment content', 'search-regex'); }
|
48 |
+
|
49 |
+
function get_content ($id)
|
50 |
+
{
|
51 |
+
global $wpdb;
|
52 |
+
|
53 |
+
$row = $wpdb->get_row ("SELECT comment_content FROM {$wpdb->comments} WHERE comment_ID='$id'");
|
54 |
+
return $row->comment_content;
|
55 |
+
}
|
56 |
+
|
57 |
+
function replace_content ($id, $content)
|
58 |
+
{
|
59 |
+
global $wpdb;
|
60 |
+
$content = $wpdb->escape ($content);
|
61 |
+
$wpdb->query ("UPDATE {$wpdb->comments} SET comment_content='{$content}' WHERE comment_ID='$id'");
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
?>
|
searches/post_content.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchPostContent extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$posts = $wpdb->get_results ("SELECT ID, post_content, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby LIMIT $offset,$limit");
|
11 |
+
if (count ($posts) > 0)
|
12 |
+
{
|
13 |
+
foreach ($posts AS $post)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $post->post_content, $post->ID)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
$match->title = $post->post_title;
|
19 |
+
|
20 |
+
$results = array_merge ($results, $matches);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $results;
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_options ($result)
|
29 |
+
{
|
30 |
+
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
31 |
+
if ($result->replace)
|
32 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostContent\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
33 |
+
|
34 |
+
if (current_user_can ('edit_post', $result->id))
|
35 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
36 |
+
return $options;
|
37 |
+
}
|
38 |
+
|
39 |
+
function show ($result)
|
40 |
+
{
|
41 |
+
printf (__ ('Post #%d: %s', 'search-regex'), $result->id, $result->title);
|
42 |
+
}
|
43 |
+
|
44 |
+
function name () { return __ ('Post content', 'search-regex'); }
|
45 |
+
|
46 |
+
function get_content ($id)
|
47 |
+
{
|
48 |
+
global $wpdb;
|
49 |
+
|
50 |
+
$post = $wpdb->get_row ("SELECT post_content FROM {$wpdb->prefix}posts WHERE id='$id'");
|
51 |
+
return $post->post_content;
|
52 |
+
}
|
53 |
+
|
54 |
+
function replace_content ($id, $content)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
$content = $wpdb->escape ($content);
|
58 |
+
$wpdb->query ("UPDATE {$wpdb->posts} SET post_content='{$content}' WHERE ID='$id'");
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
?>
|
searches/post_excerpt.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchPostExcerpt extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$posts = $wpdb->get_results ("SELECT ID, post_title, post_excerpt FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby LIMIT $offset,$limit");
|
11 |
+
if (count ($posts) > 0)
|
12 |
+
{
|
13 |
+
foreach ($posts AS $post)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $post->post_excerpt, $post->ID)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
$match->title = $post->post_title;
|
19 |
+
|
20 |
+
$results = array_merge ($results, $matches);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $results;
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_options ($result)
|
29 |
+
{
|
30 |
+
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
31 |
+
if ($result->replace)
|
32 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostExcerpt\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
33 |
+
|
34 |
+
if (current_user_can ('edit_post', $result->id))
|
35 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
36 |
+
return $options;
|
37 |
+
}
|
38 |
+
|
39 |
+
function show ($result)
|
40 |
+
{
|
41 |
+
printf (__ ('Post #%d: %s', 'search-regex'), $result->id, $result->title);
|
42 |
+
}
|
43 |
+
|
44 |
+
function name () { return __ ('Post excerpt', 'search-regex'); }
|
45 |
+
|
46 |
+
function get_content ($id)
|
47 |
+
{
|
48 |
+
global $wpdb;
|
49 |
+
|
50 |
+
$post = $wpdb->get_row ("SELECT post_excerpt FROM {$wpdb->prefix}posts WHERE id='$id'");
|
51 |
+
return $post->post_excerpt;
|
52 |
+
}
|
53 |
+
|
54 |
+
function replace_content ($id, $content)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
$content = $wpdb->escape ($content);
|
58 |
+
$wpdb->query ("UPDATE {$wpdb->posts} SET post_excerpt='{$content}' WHERE ID='$id'");
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
?>
|
searches/post_meta.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchPostMetaValue extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
|
11 |
+
$metas = $wpdb->get_results ("SELECT {$wpdb->postmeta}.meta_id AS meta_id, {$wpdb->postmeta}.meta_value AS meta_value, {$wpdb->postmeta}.post_id AS post_id, {$wpdb->posts}.post_title AS title FROM {$wpdb->postmeta} LEFT JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID ORDER BY meta_value $orderby LIMIT $offset,$limit");
|
12 |
+
|
13 |
+
if (count ($metas) > 0)
|
14 |
+
{
|
15 |
+
foreach ($metas AS $meta)
|
16 |
+
{
|
17 |
+
// Perform a regex
|
18 |
+
if (($result = $this->matches ($pattern, $meta->meta_value, $meta->meta_id)) !== false)
|
19 |
+
{
|
20 |
+
foreach ($result AS $item)
|
21 |
+
{
|
22 |
+
$item->sub_id = $meta->post_id;
|
23 |
+
$item->title = $meta->title;
|
24 |
+
}
|
25 |
+
$results = array_merge ($results, $result);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
return $results;
|
31 |
+
}
|
32 |
+
|
33 |
+
function get_options ($result)
|
34 |
+
{
|
35 |
+
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
36 |
+
if ($result->replace)
|
37 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostMetaValue\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
38 |
+
|
39 |
+
if (current_user_can ('edit_post', $result->sub_id))
|
40 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->sub_id.'">'.__ ('edit','search-regex').'</a>';
|
41 |
+
return $options;
|
42 |
+
}
|
43 |
+
|
44 |
+
function show ($result)
|
45 |
+
{
|
46 |
+
printf (__ ('Meta data for post #%d: %s', 'search-regex'), $result->sub_id, $result->title);
|
47 |
+
}
|
48 |
+
|
49 |
+
function name () { return __ ('Post meta value', 'search-regex'); }
|
50 |
+
|
51 |
+
function get_content ($id)
|
52 |
+
{
|
53 |
+
global $wpdb;
|
54 |
+
|
55 |
+
$post = $wpdb->get_row ("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_id='$id'");
|
56 |
+
return $post->meta_value;
|
57 |
+
}
|
58 |
+
|
59 |
+
function replace_content ($id, $content)
|
60 |
+
{
|
61 |
+
global $wpdb;
|
62 |
+
$content = $wpdb->escape ($content);
|
63 |
+
$wpdb->query ("UPDATE {$wpdb->postmeta} SET meta_value='{$content}' WHERE meta_id='$id'");
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
?>
|
searches/post_title.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchPostTitle extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$posts = $wpdb->get_results ("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby LIMIT $offset,$limit");
|
11 |
+
if (count ($posts) > 0)
|
12 |
+
{
|
13 |
+
foreach ($posts AS $post)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $post->post_title, $post->ID)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
$match->title = $post->post_title;
|
19 |
+
|
20 |
+
$results = array_merge ($results, $matches);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $results;
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_options ($result)
|
29 |
+
{
|
30 |
+
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
31 |
+
if ($result->replace)
|
32 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostTitle\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
33 |
+
|
34 |
+
if (current_user_can ('edit_post', $result->id))
|
35 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
36 |
+
return $options;
|
37 |
+
}
|
38 |
+
|
39 |
+
function show ($result)
|
40 |
+
{
|
41 |
+
printf (__ ('Post #%d: %s', 'search-regex'), $result->id, $result->title);
|
42 |
+
}
|
43 |
+
|
44 |
+
function name () { return __ ('Post title', 'search-regex'); }
|
45 |
+
|
46 |
+
function get_content ($id)
|
47 |
+
{
|
48 |
+
global $wpdb;
|
49 |
+
|
50 |
+
$post = $wpdb->get_row ("SELECT post_title FROM {$wpdb->prefix}posts WHERE id='$id'");
|
51 |
+
return $post->post_title;
|
52 |
+
}
|
53 |
+
|
54 |
+
function replace_content ($id, $content)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
$content = $wpdb->escape ($content);
|
58 |
+
$wpdb->query ("UPDATE {$wpdb->posts} SET post_title='{$content}' WHERE ID='$id'");
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
?>
|
searches/post_url.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchPostURL extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$posts = $wpdb->get_results ("SELECT ID, post_name, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby LIMIT $offset,$limit");
|
11 |
+
if (count ($posts) > 0)
|
12 |
+
{
|
13 |
+
foreach ($posts AS $post)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $post->post_name, $post->ID)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
$match->title = $post->post_title;
|
19 |
+
|
20 |
+
$results = array_merge ($results, $matches);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $results;
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_options ($result)
|
29 |
+
{
|
30 |
+
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
31 |
+
if ($result->replace)
|
32 |
+
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostURL\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
33 |
+
|
34 |
+
if (current_user_can ('edit_post', $result->id))
|
35 |
+
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
36 |
+
return $options;
|
37 |
+
}
|
38 |
+
|
39 |
+
function show ($result)
|
40 |
+
{
|
41 |
+
printf (__ ('Post #%d: %s', 'search-regex'), $result->id, $result->title);
|
42 |
+
}
|
43 |
+
|
44 |
+
function name () { return __ ('Post URL', 'search-regex'); }
|
45 |
+
|
46 |
+
function get_content ($id)
|
47 |
+
{
|
48 |
+
global $wpdb;
|
49 |
+
|
50 |
+
$post = $wpdb->get_row ("SELECT post_name FROM {$wpdb->prefix}posts WHERE id='$id'");
|
51 |
+
return $post->post_name;
|
52 |
+
}
|
53 |
+
|
54 |
+
function replace_content ($id, $content)
|
55 |
+
{
|
56 |
+
global $wpdb;
|
57 |
+
$content = $wpdb->escape ($content);
|
58 |
+
$wpdb->query ("UPDATE {$wpdb->posts} SET post_name='{$content}' WHERE ID='$id'");
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
?>
|
searches/sniplet_content.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchSnipletContent extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$terms = $wpdb->get_results ("SELECT {$wpdb->prefix}sniplets.id, {$wpdb->prefix}sniplets.contents, {$wpdb->prefix}sniplets.name FROM {$wpdb->prefix}sniplets LIMIT $offset,$limit");
|
11 |
+
if (count ($terms) > 0)
|
12 |
+
{
|
13 |
+
foreach ($terms AS $term)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $term->contents, $term->id)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
{
|
19 |
+
$match->sub_id = $term->id;
|
20 |
+
$match->title = $term->name;
|
21 |
+
}
|
22 |
+
|
23 |
+
$results = array_merge ($results, $matches);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $results;
|
29 |
+
}
|
30 |
+
|
31 |
+
function get_options ($result)
|
32 |
+
{
|
33 |
+
return array ();
|
34 |
+
}
|
35 |
+
|
36 |
+
function show ($result)
|
37 |
+
{
|
38 |
+
printf (__ ('Sniplet #%d: %s', 'search-regex'), $result->id, $result->title);
|
39 |
+
}
|
40 |
+
|
41 |
+
function name () { return __ ('Sniplet Content', 'search-regex'); }
|
42 |
+
|
43 |
+
function get_content ($id)
|
44 |
+
{
|
45 |
+
global $wpdb;
|
46 |
+
|
47 |
+
$row = $wpdb->get_row ("SELECT contents FROM {$wpdb->prefix}sniplets WHERE id='$id'");
|
48 |
+
return $row->contents;
|
49 |
+
}
|
50 |
+
|
51 |
+
function replace_content ($id, $content)
|
52 |
+
{
|
53 |
+
global $wpdb;
|
54 |
+
$content = $wpdb->escape ($content);
|
55 |
+
$wpdb->query ("UPDATE {$wpdb->prefix}sniplets SET contents='{$content}' WHERE id='$id'");
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
?>
|
searches/tag_name.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchTagName extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$terms = $wpdb->get_results ("SELECT {$wpdb->terms}.term_id, {$wpdb->terms}.name FROM {$wpdb->terms} LIMIT $offset,$limit");
|
11 |
+
if (count ($terms) > 0)
|
12 |
+
{
|
13 |
+
foreach ($terms AS $term)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $term->name, $term->term_id)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
{
|
19 |
+
$match->sub_id = $term->term_id;
|
20 |
+
$match->title = $term->name;
|
21 |
+
}
|
22 |
+
|
23 |
+
$results = array_merge ($results, $matches);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $results;
|
29 |
+
}
|
30 |
+
|
31 |
+
function get_options ($result)
|
32 |
+
{
|
33 |
+
return array ();
|
34 |
+
}
|
35 |
+
|
36 |
+
function show ($result)
|
37 |
+
{
|
38 |
+
printf (__ ('Tag #%d: %s', 'search-regex'), $result->id, $result->title);
|
39 |
+
}
|
40 |
+
|
41 |
+
function name () { return __ ('Tag Name', 'search-regex'); }
|
42 |
+
|
43 |
+
function get_content ($id)
|
44 |
+
{
|
45 |
+
global $wpdb;
|
46 |
+
|
47 |
+
$row = $wpdb->get_row ("SELECT name FROM {$wpdb->terms} WHERE term_id='$id'");
|
48 |
+
return $row->name;
|
49 |
+
}
|
50 |
+
|
51 |
+
function replace_content ($id, $content)
|
52 |
+
{
|
53 |
+
global $wpdb;
|
54 |
+
$content = $wpdb->escape ($content);
|
55 |
+
$wpdb->query ("UPDATE {$wpdb->terms} SET name='{$content}' WHERE term_id='$id'");
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
?>
|
searches/tag_slug.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SearchTagSlug extends Search
|
4 |
+
{
|
5 |
+
function find ($pattern, $limit, $offset, $orderby)
|
6 |
+
{
|
7 |
+
global $wpdb;
|
8 |
+
|
9 |
+
$results = array ();
|
10 |
+
$terms = $wpdb->get_results ("SELECT {$wpdb->terms}.term_id, {$wpdb->terms}.slug FROM {$wpdb->terms} LIMIT $offset,$limit");
|
11 |
+
if (count ($terms) > 0)
|
12 |
+
{
|
13 |
+
foreach ($terms AS $term)
|
14 |
+
{
|
15 |
+
if (($matches = $this->matches ($pattern, $term->slug, $term->term_id)))
|
16 |
+
{
|
17 |
+
foreach ($matches AS $match)
|
18 |
+
{
|
19 |
+
$match->sub_id = $term->term_id;
|
20 |
+
$match->title = $term->slug;
|
21 |
+
}
|
22 |
+
|
23 |
+
$results = array_merge ($results, $matches);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $results;
|
29 |
+
}
|
30 |
+
|
31 |
+
function get_options ($result)
|
32 |
+
{
|
33 |
+
return array ();
|
34 |
+
}
|
35 |
+
|
36 |
+
function show ($result)
|
37 |
+
{
|
38 |
+
printf (__ ('Tag #%d: %s', 'search-regex'), $result->id, $result->title);
|
39 |
+
}
|
40 |
+
|
41 |
+
function name () { return __ ('Tag slug', 'search-regex'); }
|
42 |
+
|
43 |
+
function get_content ($id)
|
44 |
+
{
|
45 |
+
global $wpdb;
|
46 |
+
|
47 |
+
$row = $wpdb->get_row ("SELECT slug FROM {$wpdb->terms} WHERE term_id='$id'");
|
48 |
+
return $row->slug;
|
49 |
+
}
|
50 |
+
|
51 |
+
function replace_content ($id, $content)
|
52 |
+
{
|
53 |
+
global $wpdb;
|
54 |
+
$content = $wpdb->escape ($content);
|
55 |
+
$wpdb->query ("UPDATE {$wpdb->terms} SET slug='{$content}' WHERE term_id='$id'");
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
?>
|
view/admin/head.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
2 |
+
<link rel="stylesheet" href="<?php echo $this->url () ?>/admin.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
|
3 |
+
<script type="text/javascript" charset="utf-8">
|
4 |
+
var wp_base = '<?php echo $this->url () ?>/ajax.php';
|
5 |
+
var wp_loading = '<?php echo $this->url () ?>/images/small.gif';
|
6 |
+
</script>
|
7 |
+
<script type="text/javascript" src="<?php echo $this->url () ?>/js/search-regex.js"></script>
|
view/admin/results.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
2 |
+
<div class="wrap">
|
3 |
+
<h2><?php _e ('Results', 'search-regex') ?></h2>
|
4 |
+
|
5 |
+
<?php if (count ($results) > 0) : ?>
|
6 |
+
<p><?php printf (__('%1$s result(s) found.', 'search-regex'), count ($results)); ?></p>
|
7 |
+
|
8 |
+
<ol class="results">
|
9 |
+
<?php foreach ($results AS $pos => $result) : ?>
|
10 |
+
<li id="search_<?php echo $result->id.'_'.$result->offset ?>"<?php if ($pos % 2 == 1) echo ' class="alt"' ?>>
|
11 |
+
|
12 |
+
<div id="options_<?php echo $result->id.'_'.$result->offset ?>" class="options"><?php echo implode (' | ', $search->get_options ($result)); ?></div>
|
13 |
+
|
14 |
+
<?php $search->show ($result); ?>
|
15 |
+
|
16 |
+
<div class="searchx" id="value_<?php echo $result->id.'_'.$result->offset ?>"><?php echo $result->search ?></div>
|
17 |
+
|
18 |
+
<?php if ($result->replace) : ?>
|
19 |
+
<?php _e ('replaced with:', 'search-regex') ?>
|
20 |
+
<div class="replacex" id="replace_<?php echo $result->id.'_'.$result->offset ?>"><?php echo $result->replace ?></div>
|
21 |
+
<?php endif; ?>
|
22 |
+
</li>
|
23 |
+
<?php endforeach; ?>
|
24 |
+
</ol>
|
25 |
+
|
26 |
+
<img src="<?php $this->url () ?>/images/small.gif" style="display: none" alt="pre"/>
|
27 |
+
|
28 |
+
<script type="text/javascript" charset="utf-8">
|
29 |
+
var re_text = new Array (), re_input = new Array (), re_replace = new Array (), re_text_replace = new Array ();
|
30 |
+
|
31 |
+
<?php foreach ($results AS $result) : ?>
|
32 |
+
<?php
|
33 |
+
$id = $result->id.'_'.$result->offset;
|
34 |
+
$edit = '<br/><input type="submit" name="save" value="Save" onclick="save_edit(\\\''.get_class ($search).'\\\','.$result->id.','.$result->offset.','.$result->left.','.$result->left_length.');return false"/>';
|
35 |
+
$rep = '<br/><input type="submit" name="save" value="Save" onclick="save_edit_rep(\\\''.get_class ($search).'\\\','.$result->id.','.$result->offset.','.$result->left.','.$result->left_length.');return false"/>';
|
36 |
+
?>
|
37 |
+
|
38 |
+
re_text['<?php echo $id ?>'] = '<?php echo $result->for_js ($result->search); ?>';
|
39 |
+
|
40 |
+
<?php if ($result->single_line ()) : ?>
|
41 |
+
re_input['<?php echo $id ?>'] = '<input id="txt_<?php echo $id ?>" style="width: 95%" type="text" name="replace" value="<?php echo $result->for_js ($result->search_plain); ?>"/><?php echo $edit ?>';
|
42 |
+
<?php else : ?>
|
43 |
+
re_input['<?php echo $id ?>'] = '<textarea id="txt_<?php echo $id ?>" style="width: 95%" rows="2" name="replace"><?php echo $result->for_js ($result->search_plain); ?><\/textarea><?php echo $edit ?>';
|
44 |
+
<?php endif; ?>
|
45 |
+
|
46 |
+
<?php if ($result->replace) : ?>
|
47 |
+
re_text_replace['<?php echo $id ?>'] = '<?php echo $result->for_js ($result->replace); ?>';
|
48 |
+
<?php if ($result->single_line ()) : ?>
|
49 |
+
re_replace['<?php echo $id ?>'] = '<input id="rep_<?php echo $id ?>" style="width: 95%" type="text" name="replace" value="<?php echo $result->for_js ($result->replace_plain); ?>"/><?php echo $rep ?>';
|
50 |
+
<?php else : ?>
|
51 |
+
re_replace['<?php echo $id ?>'] = '<textarea id="rep_<?php echo $id ?>" style="width: 95%" rows="2" name="replace"><?php echo $result->for_js ($result->replace_plain); ?><\/textarea><?php echo $rep ?>';
|
52 |
+
<?php endif; ?>
|
53 |
+
<?php endif; ?>
|
54 |
+
|
55 |
+
<?php endforeach; ?>
|
56 |
+
</script>
|
57 |
+
|
58 |
+
<?php else : ?>
|
59 |
+
<p><?php _e ('There are no results.', 'search-regex') ?></p>
|
60 |
+
<?php endif; ?>
|
61 |
+
</div>
|
view/admin/search.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><div class="wrap">
|
2 |
+
<h2><?php _e ('Search Regex', 'search-regex') ?></h2>
|
3 |
+
<p><?php _e ("Replacements will only be saved to the database if you click '<strong>Replace & Save</strong>', otherwise you will get a preview of the results.", 'search-regex') ?></p>
|
4 |
+
<p><?php _e ("NOTE: <strong>No liability</strong> is accepted for any damage caused. You are strongly advised to backup your database before making any changes.", 'search-regex') ?></p>
|
5 |
+
|
6 |
+
<form method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
|
7 |
+
<table class="searchargs">
|
8 |
+
<tr>
|
9 |
+
<th width="150"><?php _e ("Source", 'search-regex') ?></th>
|
10 |
+
<td>
|
11 |
+
<?php $source = isset( $_POST['source'] ) ? $_POST['source'] : ''; ?>
|
12 |
+
<select name="source">
|
13 |
+
<?php foreach ($searches AS $searcher) : ?>
|
14 |
+
<option value="<?php echo get_class ($searcher) ?>" <?php if (strcasecmp ($source, get_class ($searcher)) == 0 || ($source == '' && strcasecmp (get_class ($searcher), 'SearchPostContent') == 0)) echo ' selected="selected"' ?>><?php echo $searcher->name () ?></option>
|
15 |
+
<?php endforeach; ?>
|
16 |
+
</select>
|
17 |
+
|
18 |
+
<strong><?php _e ('Limit to', 'search-regex'); ?>:</strong>
|
19 |
+
<?php $limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 0 ?>
|
20 |
+
<select name="limit">
|
21 |
+
<?php echo $this->select (array ('18446744073709551615' => __ ('No limit', 'search-regex'), '10' => '10', '25' => '25', '50' => '50', '100' => '100'), $limit) ?>
|
22 |
+
</select>
|
23 |
+
|
24 |
+
<strong><?php _e ('Order By', 'search-regex'); ?>:</strong>
|
25 |
+
<?php $orderby = isset( $_POST['orderby'] ) ? $_POST['orderby'] : ''; ?>
|
26 |
+
<select name="orderby">
|
27 |
+
<?php echo $this->select (array ('asc' => __ ('Ascending', 'search-regex'), 'desc' => __ ('Descending', 'search-regex')), $orderby ); ?>
|
28 |
+
</select>
|
29 |
+
</td>
|
30 |
+
</tr>
|
31 |
+
<tr>
|
32 |
+
<th width="150" valign="top"><?php _e ("Search pattern", 'search-regex') ?></th>
|
33 |
+
<td>
|
34 |
+
<input class="term" type="text" name="search_pattern" value="<?php echo htmlspecialchars ($search) ?>"/><br/>
|
35 |
+
</td>
|
36 |
+
</tr>
|
37 |
+
<tr>
|
38 |
+
<th width="150" valign="top"><?php _e ('Replace pattern', 'search-regex') ?></th>
|
39 |
+
<td>
|
40 |
+
<input class="term" type="text" name="replace_pattern" value="<?php echo htmlspecialchars ($replace) ?>"/><br/>
|
41 |
+
</td>
|
42 |
+
</tr>
|
43 |
+
<tr>
|
44 |
+
<th><label for="regex"><?php _e( 'Regex', 'search-regex' ); ?></label>:</th>
|
45 |
+
<td>
|
46 |
+
<input onclick="toggle_regex(); return true" id="regex" type="checkbox" value="regex" name="regex"<?php if (isset ($_POST['regex'])) echo 'checked="checked"' ?>/>
|
47 |
+
<span id="regex-options" <?php if (!isset ($_POST['regex'])) : ?>style="display: none"<?php endif; ?> class="sub">
|
48 |
+
<label for="case"><?php _e ('case-insensitive:', 'search-regex') ?></label> <input id="case" type="checkbox" name="regex_case" value="caseless"<?php if (isset ($_POST['regex_case'])) echo 'checked="checked"' ?>/>
|
49 |
+
<label for="multi"><?php _e ('multi-line:', 'search-regex') ?></label> <input id="multi" type="checkbox" name="regex_multi" value="multiline"<?php if (isset ($_POST['regex_multi'])) echo 'checked="checked"' ?>/>
|
50 |
+
<label for="dotall"><?php _e ('dot-all:', 'search-regex') ?></label> <input id="dotall" type="checkbox" name="regex_dot" value="dotall"<?php if (isset ($_POST['regex_dot'])) echo 'checked="checked"' ?>/>
|
51 |
+
— <?php _e ('remember to surround your regex with a delimiter!', 'search-regex'); ?>
|
52 |
+
</span>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
<tr>
|
56 |
+
<th width="150"></th>
|
57 |
+
<td><p class="submit">
|
58 |
+
<input type="submit" name="search" value="<?php _e ('Search', 'search-regex')?> »" />
|
59 |
+
|
60 |
+
<?php if (current_user_can ('administrator') || current_user_can ('search_regex_write')) : ?>
|
61 |
+
<input type="submit" name="replace" value="<?php _e ('Replace', 'search-regex')?> »" />
|
62 |
+
<input type="submit" name="replace_and_save" value="<?php _e ('Replace & Save »', 'search-regex') ?>"/>
|
63 |
+
<?php endif; ?>
|
64 |
+
</p>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
</table>
|
68 |
+
</form>
|
69 |
+
</div>
|