]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Moved not always used functions to a library.
authorsembrestels <sembrestels@riseup.net>
Thu, 13 Oct 2011 02:58:09 +0000 (04:58 +0200)
committersembrestels <sembrestels@riseup.net>
Thu, 13 Oct 2011 02:58:09 +0000 (04:58 +0200)
lib/dokuwiki.php [new file with mode: 0644]
start.php

diff --git a/lib/dokuwiki.php b/lib/dokuwiki.php
new file mode 100644 (file)
index 0000000..af2e14b
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+function current_dokuwiki_entity($create = true) {
+       $page_owner = page_owner();
+       $user = get_loggedin_user();
+       //error_log($page_owner->guid);
+       //error_log($user->guid);
+       if (!$page_owner)
+               $page_owner = 0;
+       $entities = elgg_get_entities(array('types' => 'object', 'subtypes' => 'dokuwiki', 'limit' => 1, 'owner_guid' => $page_owner));
+       if ($entities) {
+               $doku = $entities[0];
+               return $doku;
+       }
+       elseif ($user && $create) {
+               elgg_set_ignore_access(true);
+               $newdoku = new ElggObject();
+               $newdoku->access_id = ACCESS_PUBLIC;
+               $newdoku->owner_guid = $page_owner;
+               $newdoku->subtype = 'dokuwiki';
+               $newdoku->container_guid = $page_owner;
+               $newdoku->save();
+               $acl = array();
+                       $acl[] = "# acl.auth.php";
+                       $acl[] = '# <?php exit()?\>';
+                       $acl[] = "*               @ALL        0";
+                       $acl[] = "*               @user        1";
+                       $acl[] = "*               @member        8";
+                       $acl[] = "*               @admin        16";
+                       $acl[] = "*               @root        255";
+               $newdoku->wiki_acl = implode("\n", $acl)."\n";
+               elgg_set_ignore_access(false);
+               return $newdoku;
+       }
+}
+
+function elggdoku_recurse_copy($src,$dst) {
+       $dir = opendir($src);
+       @mkdir($dst);
+       while(false !== ( $file = readdir($dir)) ) {
+       if (( $file != '.' ) && ( $file != '..' )) {
+               if ( is_dir($src . '/' . $file) ) {
+               elggdoku_recurse_copy($src . '/' . $file,$dst . '/' . $file);
+               }
+               else {
+               copy($src . '/' . $file,$dst . '/' . $file);
+               }
+       }
+       }
+       closedir($dir);
+} 
+
+function elggdokuwiki_create_datafolder($path) {
+       if (is_dir($path)) // if it exists must be already created
+               return;
+       mkdir($path, 0700, true);
+       $orig = elgg_get_plugins_path().'dokuwiki/lib/dokuwiki/data';
+       elggdoku_recurse_copy($orig, $path);
+       
+}
+       
+?>
index 9c278cc1bb39e24ac1924b6070a94b8c5dcb2b9a..9239a526e93d6d9283b5b0d72630f84d883858be 100644 (file)
--- a/start.php
+++ b/start.php
@@ -9,64 +9,7 @@
          * @link http://lorea.cc
          */
 
-       function current_dokuwiki_entity($create = true) {
-               $page_owner = page_owner();
-               $user = get_loggedin_user();
-               //error_log($page_owner->guid);
-               //error_log($user->guid);
-               if (!$page_owner)
-                       $page_owner = 0;
-               $entities = elgg_get_entities(array('types' => 'object', 'subtypes' => 'dokuwiki', 'limit' => 1, 'owner_guid' => $page_owner));
-               if ($entities) {
-                       $doku = $entities[0];
-                       return $doku;
-               }
-               elseif ($user && $create) {
-                       elgg_set_ignore_access(true);
-                       $newdoku = new ElggObject();
-                       $newdoku->access_id = ACCESS_PUBLIC;
-                       $newdoku->owner_guid = $page_owner;
-                       $newdoku->subtype = 'dokuwiki';
-                       $newdoku->container_guid = $page_owner;
-                       $newdoku->save();
-                       $acl = array();
-                       $acl[] = "# acl.auth.php";
-                       $acl[] = '# <?php exit()?\>';
-                       $acl[] = "*               @ALL        0";
-                       $acl[] = "*               @user        1";
-                       $acl[] = "*               @member        8";
-                       $acl[] = "*               @admin        16";
-                       $acl[] = "*               @root        255";
-                       $newdoku->wiki_acl = implode("\n", $acl)."\n";
-                       elgg_set_ignore_access(false);
-                       return $newdoku;
-               }
-       }
 
-       function elggdoku_recurse_copy($src,$dst) {
-           $dir = opendir($src);
-           @mkdir($dst);
-           while(false !== ( $file = readdir($dir)) ) {
-               if (( $file != '.' ) && ( $file != '..' )) {
-                   if ( is_dir($src . '/' . $file) ) {
-                       elggdoku_recurse_copy($src . '/' . $file,$dst . '/' . $file);
-                   }
-                   else {
-                       copy($src . '/' . $file,$dst . '/' . $file);
-                   }
-               }
-           }
-           closedir($dir);
-       } 
-
-       function elggdokuwiki_create_datafolder($path) {
-               if (is_dir($path)) // if it exists must be already created
-                       return;
-               mkdir($path, 0700, true);
-               $orig = elgg_get_plugins_path().'dokuwiki/lib/dokuwiki/data';
-               elggdoku_recurse_copy($orig, $path);
-               
-       }
 
        /**
         * Dispatches dokuwiki pages.
@@ -78,6 +21,9 @@
         * @return NULL
         */
        function dokuwiki_page_handler($page) {
+               
+               elgg_load_library('elgg:dokuwiki');
+               
                if ($page[0] === "all") {
                        set_context("search");
                        include(elgg_get_plugins_path().'dokuwiki/index.php');
 
        function elggdokuwiki_init(){
                
+               elgg_register_library('elgg:dokuwiki', elgg_get_plugins_path().'dokuwiki/lib/dokuwiki.php');
+               
                        register_entity_type('object','dokuwiki');
                        register_plugin_hook('entity:icon:url', 'object', 'elggdokuwiki_icon_hook');
                        register_entity_url_handler('elggdokuwiki_url','object', 'dokuwiki');