adding some strings
[moodle-linuxchix.git] / mod / wiki / ewiki / plugins / pluginloader.php
blob36ed4dda6065de72eaa82d8673b515a61331120a
1 <?php
3 /*
4 dynamic plugin loading
5 ����������������������
6 Will load plugins on demand, so they must not be included() one by one
7 together with the core script. This is what commonly the "plugin idea"
8 suggests, and only has minimal disadvantages.
9 - This loader currently only handles "page" and "action" plugins,
10 many other extensions must be activated as before (the other ones
11 are real functionality enhancements and behaviour tweaks, so this
12 approach really made no sense for them).
13 - There is no security risk with this plugin loader extension, because
14 it allows you to set which of the available plugins CAN be loaded
15 on demand (all others must/can be included() as usual elsewhere).
16 - This however requires administration of this plugins` configuration
17 array, but that is not much more effort than maintaining a bunch of
18 include() statements.
19 - Is a small degree faster then including multiple plugin script files
20 one by one. Alternatively you could also merge (cat, mkhuge) all
21 wanted plugins into one script file so you get a speed improvement
22 against multiple include() calls.
23 - Use tools/mkpluginmap to create the initial plugin list.
28 $ewiki_plugins["dl"]["action"] = array(
29 "view" => array("", "", 0),
30 "links" => array("", "", 0),
31 "info" => array("", "", 0),
32 # "edit" => array("spellcheck.php", "", 0),
33 # "calendar" => array("calendar.php", "ewiki_page_calendar", 0),
34 # "addpost" => array("contrib/aview_posts.php", "ewiki_add_post", 0),
35 # "imageappend" => array("contrib/aview_imgappend.php", "ewiki_action_image_append", 0),
36 # "extodo" => array("contrib/action_extracttodo.php", "ewiki_extract_todo", 0),
37 # "addthread" => array("contrib/aview_threads.php", "ewiki_add_thread", 0),
38 # "control" => array("admin/control.php", "ewiki_action_control_page", 0),
39 # "pdf" => array("pdf.php", "ewiki_send_page_as_pdf", 0),
40 "diff" => array("diff.php", "ewiki_page_stupid_diff", 0),
41 # "diff" => array("diff_gnu.php", "ewiki_page_gnu_diff", 0),
42 # "binary" => array("downloads.php", "ewiki_binary", 0),
43 # "attachments" => array("downloads.php", "ewiki_action_attachments", 0),
44 "like" => array("like_pages.php", "ewiki_page_like", 0),
45 # "verdiff" => array("action_verdiff.php", "ewiki_action_verdiff", 0),
48 $ewiki_plugins["dl"]["page"] = array(
49 # "PageCalendar" => array("calendar.php", "ewiki_page_calendar", 0),
50 # "PageYearCalendar" => array("calendar.php", "ewiki_page_year_calendar", 0),
51 # "WikiNews" => array("contrib/page_wikinews.php", "ewiki_page_wikinews", 0),
52 # "WikiDump" => array("contrib/page_wikidump.php", "ewiki_page_wiki_dump_tarball", 0),
53 # "README" => array("contrib/page_README.php", "ewiki_page_README", 0),
54 # "README.de" => array("contrib/page_README.php", "ewiki_page_README", 0),
55 # "plugins/auth/README.auth" => array("contrib/page_README.php", "ewiki_page_README", 0),
56 # "Fortune" => array("contrib/page_fortune.php", "ewiki_page_fortune", 0),
57 # "ScanDisk" => array("contrib/page_scandisk.php", "ewiki_page_scandisk", 0),
58 "InterWikiMap" => array("contrib/page_interwikimap.php", "ewiki_page_interwikimap", 0),
59 # "WikiUserLogin" => array("contrib/page_wikiuserlogin.php", "ewiki_page_wikiuserlogin", 0),
60 # "PhpInfo" => array("contrib/page_phpinfo.php", "ewiki_page_phpinfo", 0),
61 # "ImageGallery" => array("contrib/page_imagegallery.php", "ewiki_page_image_gallery", 0),
62 # "SinceUpdatedPages" => array("contrib/page_since_updates.php", "ewiki_page_since_updates", 0),
63 # "TextUpload" => array("contrib/page_textupload.php", "ewiki_page_textupload", 0),
64 "HitCounter" => array("contrib/page_hitcounter.php", "ewiki_page_hitcounter", 0),
65 # "SearchCache" => array("admin/page_searchcache.php", "ewiki_cache_generated_pages", 0),
66 # "SearchAndReplace" => array("admin/page_searchandreplace.php", "ewiki_page_searchandreplace", 0),
67 # "FileUpload" => array("downloads.php", "ewiki_page_fileupload", 0),
68 # "FileDownload" => array("downloads.php", "ewiki_page_filedownload", 0),
69 "PowerSearch" => array("page_powersearch.php", "ewiki_page_powersearch", 0),
70 # "AboutPlugins" => array("page_aboutplugins.php", "ewiki_page_aboutplugins", 0),
71 "OrphanedPages" => array("page_orphanedpages.php", "ewiki_page_orphanedpages", 0),
72 "PageIndex" => array("page_pageindex.php", "ewiki_page_index", 0),
73 "RandomPage" => array("page_randompage.php", "ewiki_page_random", 0),
74 "WantedPages" => array("page_wantedpages.php", "ewiki_page_wantedpages", 0),
75 "WordIndex" => array("page_wordindex.php", "ewiki_page_wordindex", 0),
79 #-- plugin glue
80 $ewiki_plugins["view_init"][] = "ewiki_dynamic_plugin_loader";
83 function ewiki_dynamic_plugin_loader(&$id, &$data, &$action) {
85 global $ewiki_plugins, $ewiki_id, $ewiki_title, $ewiki_t,
86 $ewiki_ring, $ewiki_author, $ewiki_config, $ewiki_auth_user,
87 $ewiki_action;
89 #-- check for entry
90 if (empty($ewiki_plugins["page"][$id])) {
91 $load = $ewiki_plugins["dl"]["page"][$id];
93 elseif (empty($ewiki_plugins["action"][$action])) {
94 $load = $ewiki_plugins["dl"]["action"][$action];
97 #-- load plugin
98 if ($load) {
99 if (!is_array($load)) {
100 $load = array($load, "");
102 if (!($pf=$load[1]) || !function_exists($pf)) {
103 include(dirname(__FILE__)."/".$load[0]);
107 #-- fake static pages
108 foreach ($ewiki_plugins["dl"]["page"] as $name) {
109 if (empty($ewiki_plugins["page"][$name])) {
110 $ewiki_plugins["page"][$name] = "ewiki_dynamic_plugin_loader";
114 #-- show action links
115 foreach ($ewiki_plugins["dl"]["action"] as $action=>$uu) {
116 foreach ($ewiki_config["dl"]["action_links"] as $where) {
117 if ($title = $ewiki_config["dl"]["action_links"][$where][$action]) {
118 $ewiki_config["action_links"][$where][$action] = $title;
123 return(NULL);